iTokens

Interest bearing tokens to interact with Lending & Synthetic Protocol.

Each asset supported by the dForce Lending & Synthetic Protocol is integrated with an iToken contract, which is an EIP-20 compliant representation of balances supplied to the protocol. By minting iTokens, users (i) earn supply interest through iToken’s exchange rate, which increases in value relative to the underlying asset, and (ii) gain the ability to use iToken as collateral to borrow assets.

There are currently two types of iTokens: iToken and iETH, both expose the EIP-20 interface, iToken wraps an underlying ERC-20 asset, such as iWBTC wraps WBTC as underlying, while iETH simply wraps native Ether. The major difference involves transferring an asset into the protocol between ERC-20 asset and Ether.

EIP20 Methods

All standard EIP20 methods are implemented, such as balanceOf(), transfer(), transferFrom(), approve(), totalSupply(), etc.

EIP2612 Methods

permit()

Allows users to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions.

function permit(
        address _owner,
        address _spender,
        uint256 _value,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    )

Methods

Describes basic interfaces to integrate with the protocol, such as deposit as collaterals and take a loan, etc.

mint()

Caller deposits underlying asset and gets iToken in exchange according to the exchange rate.

function mint(address recipient, uint256 mintAmount);

mint&enterMarket()

Caller deposits underlying asset, gets iToken in exchange according to the exchange rate and make the asset as collateral.

function mintForSelfAndEnterMarket(uint256 mintAmount);

redeem()

Caller redeems specified iToken and gets underlying asset.

function redeem(address from, uint256 redeemTokens);

redeemUnderlying()

Redeem by the amount of underlying asset as input.

function redeemUnderlying(address _from, uint256 _redeemUnderlying);

borrow()

Take a loan if the caller has enough deposits as collateral.

function borrow(uint256 _borrowAmount);

repayBorrow()

Repay a loan.

function repayBorrow(uint256 _repayAmount);

repayBorrowBehalf()

Repay a loan on behalf of the borrower.

function repayBorrowBehalf(address _borrower, uint256 _repayAmount);

liquidateBorrow()

Repay a loan on behalf of the borrower and seize the same value of iToken plus incentive as a reward.

function liquidateBorrow(
        address _borrower,
        uint256 _repayAmount,
        address _assetCollateral
    );

updateInterest()

Update asset's borrow and supply interests, push total borrows and reserves up-to-date.

function updateInterest() external override returns (bool);

exchangeRateCurrent()

Gets the newest exchange rate by accruing interest.

function exchangeRateCurrent() external returns (uint256);

exchangeRateStored()

Gets the stored exchange rate without accruing interest.

function exchangeRateStored() external view override returns (uint256);

balanceOfUnderlying()

Gets the up-to-date underlying balance of a depositor.

function balanceOfUnderlying(address _account) external returns (uint256);

totalBorrowsCurrent()

Gets the current total borrows by accruing interest.

function totalBorrowsCurrent() external returns (uint256);

borrowBalanceCurrent()

Gets account's up-to-date borrow balance.

function borrowBalanceCurrent(address _user) external returns (uint256);

borrowBalanceStored()

Gets the stored borrow balance of an account.

function borrowBalanceStored(address _user) external view returns (uint256);

borrowRatePerBlock()

Gets borrow rate per block, annual yield = pow (borrowRatePerBlock, blockPerYear);

function borrowRatePerBlock() external view returns (uint256);

supplyRatePerBlock()

Get supply rate per block, annual yield = pow (supplyRatePerBlock, blockPerYear);

function supplyRatePerBlock() external view returns (uint256);

getCash()

Get cash of underlying in the protocol.

function getCash() external view returns (uint256);

Key Events

Event

Description

event Mint (

address spender,

address recipient,

uint256 mintAmount,

uint256 mintTokens )

Emitted upon a successful Mint.

event Redeem (

address from,

address recipient,

uint256 redeemiTokenAmount,

uint256 redeemUnderlyingAmount )

Emitted upon a successful Redeem.

event Borrow (

address borrower,

uint256 borrowAmount,

uint256 accountBorrows,

uint256 accountInterestIndex,

uint256 totalBorrows )

Emitted upon a successful Borrow.

event RepayBorrow (

address payer,

address borrower,

uint256 repayAmount,

uint256 accountBorrows,

uint256 accountInterestIndex,

uint256 totalBorrows )

Emitted upon a successful RepayBorrow.

event LiquidateBorrow (

address liquidator,

address borrower,

uint256 repayAmount,

address iTokenCollateral,

uint256 seizeTokens )

Emitted upon a successful LiquidateBorrow

Last updated