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.
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.
mint&enterMarket()
Caller deposits underlying asset, gets iToken in exchange according to the exchange rate and make the asset as collateral.
redeem()
Caller redeems specified iToken and gets underlying asset.
redeemUnderlying()
Redeem by the amount of underlying asset as input.
borrow()
Take a loan if the caller has enough deposits as collateral.
repayBorrow()
Repay a loan.
repayBorrowBehalf()
Repay a loan on behalf of the borrower.
liquidateBorrow()
Repay a loan on behalf of the borrower and seize the same value of iToken plus incentive as a reward.
updateInterest()
Update asset's borrow and supply interests, push total borrows and reserves up-to-date.
exchangeRateCurrent()
Gets the newest exchange rate by accruing interest.
exchangeRateStored()
Gets the stored exchange rate without accruing interest.
balanceOfUnderlying()
Gets the up-to-date underlying balance of a depositor.
totalBorrowsCurrent()
Gets the current total borrows by accruing interest.
borrowBalanceCurrent()
Gets account's up-to-date borrow balance.
borrowBalanceStored()
Gets the stored borrow balance of an account.
borrowRatePerBlock()
Gets borrow rate per block, annual yield = pow (borrowRatePerBlock, blockPerYear);
supplyRatePerBlock()
Get supply rate per block, annual yield = pow (supplyRatePerBlock, blockPerYear);
getCash()
Get cash of underlying in the protocol.
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