Was learning how call liquidation on Compound Finance via another smart contract. In compound's codebase, CEther's liquidateBorrow() is different from other CERC20's liquidateBorrow().

Was trying the below on mainnet fork:=

CEther's liquidateBorrow function

    function liquidateBorrow(address borrower, CToken cTokenCollateral) external payable {
        liquidateBorrowInternal(borrower, msg.value, cTokenCollateral);

Tried to call CEther's liquidateBorrow function as below:

    CEther.liquidateBorrow{value: _repayAmount}(

However the code does not work as intended, debt wasn't properly repaid. Ether of _repayAmount amount did sent to the contract address of CEther. The borower's account is indeed in shortfall and is available to be liquidated.

How can I properly call liquidateBorrow function of CEther?


2 Answers 2


According to the example of the docs on Compound Finance, the liquidateBorrow() function of CEther is called as follows in Solidity:

CEther cToken = CEther(0x3FDB...);

CErc20 cTokenCollateral = CErc20(0x3FDA...);

cToken.liquidateBorrow.value(100)(0xBorrower, cTokenCollateral)

where 100 is the repayAmount, 0xBorrower is the address of the borrower with negative liquidity, cTokenCollateral is the address of the cToken currently held as collateral by a borrower.

See: https://compound.finance/Developers#liquidate-borrow


From Compound's docs, we learn that for CEther.liquidateBorrow(), the passed msg.value is the amount of ether to be repaid and converted into collateral (in wei).

By reading the CEther contract via Etherscan, we discover that CETH has 8 decimals. While we already know that ETH is 18 decimals.

Therefore, I think this might be causing a confusion when converting ETH amounts to CETH amounts or vice-versa and passing the value as msg.value to CEther.liquidateBorrow().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.