githubEdit

uToken

@title UToken Contract @dev Union accountBorrows can borrow and repay thru this component.

BorrowSnapshot

struct BorrowSnapshot {
  uint256 principal;
  uint256 interest;
  uint256 interestIndex;
  uint256 lastRepay;
}

WAD

uint256 WAD

Wad do you want

BORROW_RATE_MAX_MANTISSA

uint256 BORROW_RATE_MAX_MANTISSA

Maximum borrow rate that can ever be applied (.005% / block)

RESERVE_FACTORY_MAX_MANTISSA

uint256 RESERVE_FACTORY_MAX_MANTISSA

@dev Maximum fraction of interest that can be set aside for reserves

initialExchangeRateMantissa

@dev Initial exchange rate used when minting the first UTokens (used when totalSupply = 0)

reserveFactorMantissa

@dev Fraction of interest currently set aside for reserves

accrualBlockNumber

@dev Block number that interest was last accrued at

borrowIndex

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

totalBorrows

@dev Total amount of outstanding borrows of the underlying in this market

totalReserves

@dev Total amount of reserves of the underlying held in this marke

totalRedeemable

@dev Calculates the exchange rate from the underlying to the uToken

overdueBlocks

@dev overdue duration, based on the number of blocks

originationFee

@dev fee paid at loan origin

debtCeiling

@dev The debt limit for the whole system

maxBorrow

@dev Max amount that can be borrowed by a single member

minBorrow

@dev Min amount that can be borrowed by a single member

assetManager

@dev Asset manager contract address

userManager

@dev User manager contract address

underlying

Address of underlying token

interestRateModel

Interest rate model used for calculating interest rate

accountBorrows

Mapping of account addresses to outstanding borrow balances

AccrueInterestFailed

AmountExceedGlobalMax

AmountExceedMaxBorrow

AmountLessMinBorrow

AmountZero

BorrowRateExceedLimit

WithdrawFailed

CallerNotMember

CallerNotUserManager

InitExchangeRateNotZero

InsufficientFundsLeft

MemberIsOverdue

ReserveFactoryExceedLimit

DepositToAssetManagerFailed

LogNewMarketInterestRateModel

@dev Change of the interest rate model @param oldInterestRateModel Old interest rate model address @param newInterestRateModel New interest rate model address

LogMint

@dev Mint uToken by depositing token @param minter address of minter @param underlyingAmount amount of underlying token @param uTokenAmount amount of uToken

LogRedeem

@dev Redeem token for uToken

LogReservesAdded

@dev Token added to the reserves @param reserver address of sender that added to reservers @param actualAddAmount amount of tokens added @param totalReservesNew new total reserve amount

LogReservesReduced

@dev Token removed from the reserves @param receiver reciever address of tokens @param reduceAmount amount of tokens to withdraw @param totalReservesNew new total reserves amount

LogBorrow

@dev Event borrow @param account Member address @param amount Borrow amount @param fee Origination fee

LogRepay

@dev Event repay @param account Member address @param amount Repay amount

onlyMember

@dev modifier limit member

onlyUserManager

__UToken_init

setAssetManager

@dev set Asset Manager contract address Accept claims only from the admin

setUserManager

@dev set User Manager contract address Accept claims only from the admin

setOriginationFee

@dev Change loan origination fee value Accept claims only from the admin @param originationFee_ Fees deducted for each loan transaction

setDebtCeiling

@dev Update the market debt ceiling to a fixed amount, for example, 1 billion DAI etc. Accept claims only from the admin @param debtCeiling_ The debt limit for the whole system

setMinBorrow

@dev Update the minimum loan size Accept claims only from the admin @param minBorrow_ Minimum loan amount per user

setMaxBorrow

@dev Update the max loan size Accept claims only from the admin @param maxBorrow_ Max loan amount per user

setOverdueBlocks

@dev Change loan overdue duration, based on the number of blocks Accept claims only from the admin @param overdueBlocks_ Maximum late repayment block. The number of arrivals is a default

setInterestRateModel

@dev Change to a different interest rate model Accept claims only from the admin @param newInterestRateModel_ New interest rate model address

setReserveFactor

@dev set reserve factor mantissa Accept claims only from the admin

getRemainingDebtCeiling

@dev Returns the remaining amount that can be borrowed from the market. @return Remaining total amount

getLastRepay

@dev Get the last repay block @param account Member address @return lastRepay

checkIsOverdue

@dev Check if the member's loan is overdue @param account Member address @return isOverdue

calculatingFee

@dev Get the origination fee @param amount Amount to be calculated @return Handling fee

getBorrowed

@dev Get the borrowed principle @param account Member address @return borrowed

borrowBalanceView

@dev Get a member's current owed balance, including the principle and interest but without updating the user's states. @param account Member address @return Borrowed amount

borrowBalanceStoredInternal

@dev Get a member's total owed, including the principle and the interest calculated based on the interest index. @param account Member address @return Borrowed amount

borrowRatePerBlock

@dev Get the borrowing interest rate per block @return Borrow rate

supplyRatePerBlock

Returns the current per-block supply interest rate for this UToken

Return Values

Name
Type
Description

[0]

uint256

The supply interest rate per block, scaled by 1e18

exchangeRateStored

Calculates the exchange rate from the underlying to the UToken

This function does not accrue interest before calculating the exchange rate

Return Values

Name
Type
Description

[0]

uint256

Calculated exchange rate scaled by 1e18

calculatingInterest

@dev Calculating member's borrowed interest @param account Member address @return Interest amount

exchangeRateCurrent

Accrue interest then return the up-to-date exchange rate

Return Values

Name
Type
Description

[0]

uint256

Calculated exchange rate scaled by 1e18

balanceOfUnderlying

Get the underlying balance of the owner

This also accrues interest in a transaction

Parameters

Name
Type
Description

owner

address

The address of the account to query

Return Values

Name
Type
Description

[0]

uint256

The amount of underlying owned by owner

borrow

@dev Borrowing from the market Accept claims only from the member Borrow amount must in the range of creditLimit, minBorrow, maxBorrow, debtCeiling and not overdue @param amount Borrow amount

repayBorrow

Repay outstanding borrow

Repay borrow see _repayBorrowFresh

_repayBorrowFresh

@dev Repay the loan Accept claims only from the member Updated member lastPaymentEpoch only when the repayment amount is greater than interest @param payer Payer address @param borrower Borrower address @param amount Repay amount

accrueInterest

@dev Accrue interest @return Accrue interest finished

debtWriteOff

mint

Mint uTokens by depositing tokens

Parameters

Name
Type
Description

mintAmount

uint256

Amount of uTokens to mint

redeem

User redeems uTokens in exchange for the underlying asset

Assumes interest has already been accrued up to the current block

Parameters

Name
Type
Description

amountIn

uint256

The number of uTokens to redeem into underlying (only one of amountIn or amountOut may be non-zero)

amountOut

uint256

The number of underlying tokens to receive from (only one of amountIn or amountOut may be non-zero)

addReserves

Add tokens to the reseve

Parameters

Name
Type
Description

addAmount

uint256

amount of tokens to add

removeReserves

Remove tokens to the reseve

Parameters

Name
Type
Description

receiver

address

address to recieve tokens

reduceAmount

uint256

amount of tokens to remove

getBlockNumber

@dev Function to simply retrieve block number This exists mainly for inheriting test contracts to stub this result.

_depositToAssetManager

@dev Deposit tokens to the asset manager

Last updated