ImToken

Git Source

Inherits: ImTokenMinimal

Title: ImToken

Author: Merge Layers Inc.

Core mToken interface with state views and actions

Functions

transfer

Transfers amount tokens to the dst address

function transfer(address dst, uint256 amount) external returns (bool);

Parameters

NameTypeDescription
dstaddressThe address of the recipient
amountuint256The number of tokens to transfer

Returns

NameTypeDescription
<none>boolsuccess Whether the transfer was successful or not

transferFrom

Transfers amount tokens from the src address to the dst address

function transferFrom(address src, address dst, uint256 amount) external returns (bool);

Parameters

NameTypeDescription
srcaddressThe address from which tokens are transferred
dstaddressThe address to which tokens are transferred
amountuint256The number of tokens to transfer

Returns

NameTypeDescription
<none>boolsuccess Whether the transfer was successful or not

approve

Approves spender to spend amount tokens on behalf of the caller

function approve(address spender, uint256 amount) external returns (bool);

Parameters

NameTypeDescription
spenderaddressThe address authorized to spend tokens
amountuint256The number of tokens to approve

Returns

NameTypeDescription
<none>boolsuccess Whether the approval was successful or not

balanceOfUnderlying

Returns the underlying asset balance of the owner

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

Parameters

NameTypeDescription
owneraddressThe address to query the balance of underlying assets for

Returns

NameTypeDescription
<none>uint256balance The balance of underlying assets owned by owner

totalBorrowsCurrent

Returns the total amount of borrows, accounting for interest

function totalBorrowsCurrent() external returns (uint256);

Returns

NameTypeDescription
<none>uint256totalBorrowsCurrentAmount The total amount of borrows

borrowBalanceCurrent

Returns the current borrow balance for account, accounting for interest

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

Parameters

NameTypeDescription
accountaddressThe address to query the borrow balance for

Returns

NameTypeDescription
<none>uint256borrowBalance Current borrow balance

exchangeRateCurrent

Returns the current exchange rate, with interest accrued

function exchangeRateCurrent() external returns (uint256 exchangeRate);

Returns

NameTypeDescription
exchangeRateuint256The current exchange rate

accrueInterest

Accrues interest on the contract's outstanding loans

function accrueInterest() external;

seize

Transfers collateral tokens (this market) to the liquidator.

Will fail unless called by another mToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed mToken and not a parameter.

function seize(address liquidator, address borrower, uint256 seizeTokens) external;

Parameters

NameTypeDescription
liquidatoraddressThe account receiving seized collateral
borroweraddressThe account having collateral seized
seizeTokensuint256The number of mTokens to seize

reduceReserves

Accrues interest and reduces reserves by transferring to admin

function reduceReserves(uint256 reduceAmount) external;

Parameters

NameTypeDescription
reduceAmountuint256Amount of reduction to reserves

rolesOperator

Roles manager

function rolesOperator() external view returns (IRoles);

Returns

NameTypeDescription
<none>IRolesroles Roles contract

admin

Administrator for this contract

function admin() external view returns (address payable adminAddr);

Returns

NameTypeDescription
adminAddraddress payableAdmin address

pendingAdmin

Pending administrator for this contract

function pendingAdmin() external view returns (address payable pending);

Returns

NameTypeDescription
pendingaddress payablePending admin address

operator

Contract which oversees inter-mToken operations

function operator() external view returns (address operatorAddr);

Returns

NameTypeDescription
operatorAddraddressOperator address

interestRateModel

Model which tells what the current interest rate should be

function interestRateModel() external view returns (address interestModel);

Returns

NameTypeDescription
interestModeladdressInterest rate model address

reserveFactorMantissa

Fraction of interest currently set aside for reserves

function reserveFactorMantissa() external view returns (uint256 reserveFactor);

Returns

NameTypeDescription
reserveFactoruint256Current reserve factor mantissa

accrualBlockTimestamp

Block timestamp that interest was last accrued at

function accrualBlockTimestamp() external view returns (uint256 timestamp);

Returns

NameTypeDescription
timestampuint256Last accrual block timestamp

borrowIndex

Accumulator of the total earned interest rate since the opening of the market

function borrowIndex() external view returns (uint256 index);

Returns

NameTypeDescription
indexuint256Borrow index

totalBorrows

Total amount of outstanding borrows of the underlying in this market

function totalBorrows() external view returns (uint256 borrows);

Returns

NameTypeDescription
borrowsuint256Total borrows

totalReserves

Total amount of reserves of the underlying held in this market

function totalReserves() external view returns (uint256 reserves);

Returns

NameTypeDescription
reservesuint256Total reserves

getAccountSnapshot

Returns the snapshot of account details for the given account

function getAccountSnapshot(address account)
    external
    view
    returns (uint256 tokenBalance, uint256 borrowBalance, uint256 exchangeRate);

Parameters

NameTypeDescription
accountaddressThe address to query the account snapshot for

Returns

NameTypeDescription
tokenBalanceuint256Token balance
borrowBalanceuint256Borrow balance
exchangeRateuint256Exchange rate

borrowBalanceStored

Returns the stored borrow balance for account, without accruing interest

function borrowBalanceStored(address account) external view returns (uint256 storedBalance);

Parameters

NameTypeDescription
accountaddressThe address to query the stored borrow balance for

Returns

NameTypeDescription
storedBalanceuint256The stored borrow balance

exchangeRateStored

Returns the stored exchange rate, without accruing interest

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

Returns

NameTypeDescription
exchangeRateStoredMantissauint256The stored exchange rate

getCash

Returns the total amount of available cash in the contract

function getCash() external view returns (uint256 cash);

Returns

NameTypeDescription
cashuint256The total amount of cash

allowance

Returns the current allowance the spender has from the owner

function allowance(address owner, address spender) external view returns (uint256 allowanceAmount);

Parameters

NameTypeDescription
owneraddressThe address of the token holder
spenderaddressThe address authorized to spend the tokens

Returns

NameTypeDescription
allowanceAmountuint256The current remaining number of tokens spender can spend

balanceOf

Returns the balance of tokens held by owner

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

Parameters

NameTypeDescription
owneraddressThe address to query the balance for

Returns

NameTypeDescription
ownerBalanceuint256The balance of tokens owned by owner

borrowRatePerBlock

Returns the current borrow rate per block

function borrowRatePerBlock() external view returns (uint256 borrowRate);

Returns

NameTypeDescription
borrowRateuint256The current borrow rate per block, scaled by 1e18

supplyRatePerBlock

Returns the current supply rate per block

function supplyRatePerBlock() external view returns (uint256 supplyRate);

Returns

NameTypeDescription
supplyRateuint256The current supply rate per block, scaled by 1e18