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

uint256 initialExchangeRateMantissa

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

reserveFactorMantissa

uint256 reserveFactorMantissa

@dev Fraction of interest currently set aside for reserves

accrualBlockNumber

uint256 accrualBlockNumber

@dev Block number that interest was last accrued at

borrowIndex

uint256 borrowIndex

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

totalBorrows

uint256 totalBorrows

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

totalReserves

uint256 totalReserves

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

totalRedeemable

uint256 totalRedeemable

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

overdueBlocks

uint256 overdueBlocks

@dev overdue duration, based on the number of blocks

originationFee

uint256 originationFee

@dev fee paid at loan origin

debtCeiling

uint256 debtCeiling

@dev The debt limit for the whole system

maxBorrow

uint256 maxBorrow

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

minBorrow

uint256 minBorrow

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

assetManager

address assetManager

@dev Asset manager contract address

userManager

address userManager

@dev User manager contract address

underlying

address underlying

Address of underlying token

interestRateModel

contract IInterestRateModel interestRateModel

Interest rate model used for calculating interest rate

accountBorrows

mapping(address => struct UToken.BorrowSnapshot) accountBorrows

Mapping of account addresses to outstanding borrow balances

AccrueInterestFailed

error AccrueInterestFailed()

AmountExceedGlobalMax

error AmountExceedGlobalMax()

AmountExceedMaxBorrow

error AmountExceedMaxBorrow()

AmountLessMinBorrow

error AmountLessMinBorrow()

AmountZero

error AmountZero()

BorrowRateExceedLimit

error BorrowRateExceedLimit()

WithdrawFailed

error WithdrawFailed()

CallerNotMember

error CallerNotMember()

CallerNotUserManager

error CallerNotUserManager()

InitExchangeRateNotZero

error InitExchangeRateNotZero()

InsufficientFundsLeft

error InsufficientFundsLeft()

MemberIsOverdue

error MemberIsOverdue()

ReserveFactoryExceedLimit

error ReserveFactoryExceedLimit()

DepositToAssetManagerFailed

error DepositToAssetManagerFailed()

LogNewMarketInterestRateModel

event LogNewMarketInterestRateModel(address oldInterestRateModel, address newInterestRateModel)

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

LogMint

event LogMint(address minter, uint256 underlyingAmount, uint256 uTokenAmount)

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

LogRedeem

event LogRedeem(address redeemer, uint256 amountIn, uint256 amountOut, uint256 redeemAmount)

@dev Redeem token for uToken

LogReservesAdded

event LogReservesAdded(address reserver, uint256 actualAddAmount, uint256 totalReservesNew)

@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

event LogReservesReduced(address receiver, uint256 reduceAmount, uint256 totalReservesNew)

@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

event LogBorrow(address account, address to, uint256 amount, uint256 fee)

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

LogRepay

event LogRepay(address payer, address account, uint256 amount)

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

onlyMember

modifier onlyMember(address account)

@dev modifier limit member

onlyUserManager

modifier onlyUserManager()

__UToken_init

function __UToken_init(string name_, string symbol_, address underlying_, uint256 initialExchangeRateMantissa_, uint256 reserveFactorMantissa_, uint256 originationFee_, uint256 debtCeiling_, uint256 maxBorrow_, uint256 minBorrow_, uint256 overdueBlocks_, address admin_) public

setAssetManager

function setAssetManager(address assetManager_) external

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

setUserManager

function setUserManager(address userManager_) external

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

setOriginationFee

function setOriginationFee(uint256 originationFee_) external

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

setDebtCeiling

function setDebtCeiling(uint256 debtCeiling_) external

@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

function setMinBorrow(uint256 minBorrow_) external

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

setMaxBorrow

function setMaxBorrow(uint256 maxBorrow_) external

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

setOverdueBlocks

function setOverdueBlocks(uint256 overdueBlocks_) external

@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

function setInterestRateModel(address newInterestRateModel_) external

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

setReserveFactor

function setReserveFactor(uint256 reserveFactorMantissa_) external

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

getRemainingDebtCeiling

function getRemainingDebtCeiling() public view returns (uint256)

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

getLastRepay

function getLastRepay(address account) public view returns (uint256)

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

checkIsOverdue

function checkIsOverdue(address account) public view returns (bool isOverdue)

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

calculatingFee

function calculatingFee(uint256 amount) public view returns (uint256)

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

getBorrowed

function getBorrowed(address account) public view returns (uint256)

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

borrowBalanceView

function borrowBalanceView(address account) public view returns (uint256)

@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

function borrowBalanceStoredInternal(address account) internal view returns (uint256)

@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

function borrowRatePerBlock() public view returns (uint256)

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

supplyRatePerBlock

function supplyRatePerBlock() external view returns (uint256)

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

function exchangeRateStored() public view returns (uint256)

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

function calculatingInterest(address account) public view returns (uint256)

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

exchangeRateCurrent

function exchangeRateCurrent() public returns (uint256)

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

Return Values

Name
Type
Description

[0]

uint256

Calculated exchange rate scaled by 1e18

balanceOfUnderlying

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

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

function borrow(address to, uint256 amount) external

@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

function repayBorrow(address borrower, uint256 repayAmount) external

Repay outstanding borrow

Repay borrow see _repayBorrowFresh

_repayBorrowFresh

function _repayBorrowFresh(address payer, address borrower, uint256 amount) internal

@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

function accrueInterest() public returns (bool)

@dev Accrue interest @return Accrue interest finished

debtWriteOff

function debtWriteOff(address borrower, uint256 amount) external

mint

function mint(uint256 mintAmount) external

Mint uTokens by depositing tokens

Parameters

Name
Type
Description

mintAmount

uint256

Amount of uTokens to mint

redeem

function redeem(uint256 amountIn, uint256 amountOut) external

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

function addReserves(uint256 addAmount) external

Add tokens to the reseve

Parameters

Name
Type
Description

addAmount

uint256

amount of tokens to add

removeReserves

function removeReserves(address receiver, uint256 reduceAmount) external

Remove tokens to the reseve

Parameters

Name
Type
Description

receiver

address

address to recieve tokens

reduceAmount

uint256

amount of tokens to remove

getBlockNumber

function getBlockNumber() internal view returns (uint256)

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

_depositToAssetManager

function _depositToAssetManager(uint256 amount) internal

@dev Deposit tokens to the asset manager

Last updated