Skip to main content

ICERC20

ICERC20

Compound C Token interface Documentation: https://compound.finance/developers/ctokens

mint

function mint(uint256 mintAmount) external returns (uint256)

The mint function transfers an asset into the protocol, which begins accumulating interest based on the current Supply Rate for the asset. The user receives a quantity of cTokens equal to the underlying tokens supplied, divided by the current Exchange Rate.

Parameters

NameTypeDescription
mintAmountuint256The amount of the asset to be supplied, in units of the underlying asset.

Return Values

NameTypeDescription
[0]uint2560 on success, otherwise an Error codes

redeem

function redeem(uint256 redeemTokens) external returns (uint256)

Sender redeems cTokens in exchange for the underlying asset

Accrues interest whether or not the operation succeeds, unless reverted

Parameters

NameTypeDescription
redeemTokensuint256The number of cTokens to redeem into underlying

Return Values

NameTypeDescription
[0]uint256uint 0=success, otherwise an error code.

redeemUnderlying

function redeemUnderlying(uint256 redeemAmount) external returns (uint256)

The redeem underlying function converts cTokens into a specified quantity of the underlying asset, and returns them to the user. The amount of cTokens redeemed is equal to the quantity of underlying tokens received, divided by the current Exchange Rate. The amount redeemed must be less than the user's Account Liquidity and the market's available liquidity.

Parameters

NameTypeDescription
redeemAmountuint256The amount of underlying to be redeemed.

Return Values

NameTypeDescription
[0]uint2560 on success, otherwise an error code.

balanceOfUnderlying

function balanceOfUnderlying(address owner) external returns (uint256)

The user's underlying balance, representing their assets in the protocol, is equal to the user's cToken balance multiplied by the Exchange Rate.

Parameters

NameTypeDescription
owneraddressThe account to get the underlying balance of.

Return Values

NameTypeDescription
[0]uint256The amount of underlying currently owned by the account.

exchangeRateStored

function exchangeRateStored() external view returns (uint256)

Calculates the exchange rate from the underlying to the CToken

This function does not accrue interest before calculating the exchange rate

Return Values

NameTypeDescription
[0]uint256Calculated exchange rate scaled by 1e18

balanceOf

function balanceOf(address owner) external view returns (uint256)

Get the token balance of the owner

Parameters

NameTypeDescription
owneraddressThe address of the account to query

Return Values

NameTypeDescription
[0]uint256The number of tokens owned by owner

supplyRatePerBlock

function supplyRatePerBlock() external view returns (uint256)

Get the supply rate per block for supplying the token to Compound.

comptroller

function comptroller() external view returns (address)

Address of the Compound Comptroller.