Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Compound Redeem Function Giving False Transaction

I am trying to mint ceth from compound and redeem it. But the withdraw function in which I call redeem function of Compound is giving the following response. enter image description here

pragma solidity ^0.8.3;

interface cETH {

// define functions of COMPOUND we'll be using

function mint() external payable; // to deposit to compound
function redeem(uint redeemTokens) external returns (uint); // to withdraw from compound

//following 2 functions to determine how much you'll be able to withdraw
function exchangeRateStored() external view returns (uint); 
function balanceOf(address owner) external view returns (uint256 balance);

}

contract smartBankContract{ event MyLog(string, uint256);

address COMPOUND_CETH_ADDRESS = 0x859e9d8a4edadfEDb5A2fF311243af80F85A91b8;
cETH ceth = cETH(COMPOUND_CETH_ADDRESS);

uint totalContractBalance = 0; 
mapping(address => uint) balances;
mapping(address => uint) depositTimestamps;


function getContractBalance() public view returns(uint){
    return totalContractBalance;
}

function addBalance() public payable{
    uint balanceBefore = ceth.balanceOf(address(this));
    ceth.mint{value:msg.value}();
    uint balanceAfter = ceth.balanceOf(address(this));

    balances[msg.sender] = balanceAfter - balanceBefore;
    totalContractBalance = totalContractBalance + msg.value;
    depositTimestamps[msg.sender] = block.timestamp;

}

function getBalance(address user) public view returns(uint){
    return balances[user] * ceth.exchangeRateStored() / 1e18 ;
}

function getExchangeRate() public view returns(uint){
    return ceth.exchangeRateStored() / 1e18 ;
}

function getCethBalance(address user) public view returns(uint){
    return balances[user] ;
}


// function withdraw() public payable{

//     address payable withdrawTo = payable(msg.sender);
//     uint user_balance = getBalance(msg.sender);


//     uint redeemResult = ceth.redeem(getCethBalance(msg.sender));

//     emit MyLog("If this is not 0, there was an error", redeemResult);


//     withdrawTo.transfer((98*user_balance)/100);
//     totalContractBalance = totalContractBalance - user_balance;

//     balances[msg.sender] = 0;
// }

function withdraw() public payable {
    ceth.redeem((90*balances[msg.sender])/100);
    balances[msg.sender] = 0;
}

function addMoneyToContract() public payable {
    totalContractBalance += msg.value;
}

}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!