Union Protocol (v1)
Search
⌃K

uToken

Union members can borrow and repay through this component.

Functions:

getRemainingDebtCeiling() → uint256

Returns the remaining amount that can be borrowed from the market.

Return Values:

  • Remaining total amount

getBorrowed(address account) → uint256

Get the borrowed principle

Parameters:

  • account: Member address

Return Values:

  • Borrowed amount

getLastRepay(address account) → uint256

Get the last repay block

Parameters:

  • account: Member address

Return Values:

  • Block number

getInterestIndex(address account) → uint256

Get member interest index

Parameters:

  • account: Member address

Return Values:

  • Interest index

checkIsOverdue(address account) → bool

Check if the member's loan is overdue

Parameters:

  • account: Member address

Return Values:

  • Check result

borrowRatePerBlock() → uint256

Get the borrowing interest rate per block

Return Values:

  • Borrow rate

calculatingFee(uint256 amount) → uint256

Get the origination fee

Parameters:

  • amount: Amount to be calculated

Return Values:

  • Handling fee

calculatingInterest(address account) → uint256

Calculating member's borrowed interest

Parameters:

  • account: Member address

Return Values:

  • Interest amount

borrowBalanceView(address account) → uint256

Get a member's current owed balance, including the principle and interest but without updating the user's states.

Parameters:

  • account: Member address

Return Values:

  • Borrowed amount

setOriginationFee(uint256 originationFee_)

Change loan origination fee value Accept claims only from the admin

Parameters:

  • originationFee_: Fees deducted for each loan transaction

setDebtCeiling(uint256 debtCeiling_)

Update the market debt ceiling to a fixed amount, for example, 1 billion DAI etc. Accept claims only from the admin

Parameters:

  • debtCeiling_: The debt limit for the whole system

setMinLoan(uint256 minLoan_)

Update the minimum loan size Accept claims only from the admin

Parameters:

  • minLoan_: Minimum loan amount per user

setOverdueBlocks(uint256 overdueBlocks_)

Change loan overdue duration, based on the number of blocks Accept claims only from the admin

Parameters:

  • overdueBlocks_: Maximum late repayment block. The number of arrivals is a default

setInterestRateModel(address newInterestRateModel)

Change to a different interest rate model Accept claims only from the admin

Parameters:

  • newInterestRateModel: New interest rate model address

borrow(uint256 amount)

Borrowing from the market Accept claims only from the member Borrow amount must in the range of creditLimit, minLoan, debtCeiling and not overdue

Parameters:

  • amount: Borrow amount

repayBorrow(uint256 repayAmount)

Repay the loan Accept claims only from the member Updated member lastPaymentEpoch only when the repayment amount is greater than interest

Parameters:

  • repayAmount: Repay amount

repayBorrowBehalf(address borrower, uint256 repayAmount)

Repay behalf for a borrower

Parameters:

  • borrower: borrower address
  • repayAmount: Repay amount

updateOverdueInfo(address account)

Update borrower overdue info

Parameters:

  • account: Borrower address

batchUpdateOverdueInfos(address[] calldata accounts)

Batch update borrower overdue info

Parameters:

  • accounts: Borrowers address

supplyRatePerBlock() → uint256

Get the supply interest rate per block

Return Values:

  • Supply rate

exchangeRateCurrent() -> uint256

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

Return Values:

  • Calculated exchange rate

exchangeRateStored() -> uint256

Calculates the exchange rate from the underlying to the UToken

Return Values:

  • Calculated exchange rate

accrueInterest()

Accrue interest

balanceOfUnderlying(address owner) -> uint256

Get the underlying balance of the owner

Parameters:

  • owner: account address

Return Values:

  • The amount of underlying owned by owner

mint(uint256 mintAmount)

use underlying token to mint uToken

redeem(uint256 redeemTokens)

Sender redeems uTokens in exchange for the underlying asset

redeemUnderlying(uint256 redeemAmount)

Sender redeems uTokens in exchange for a specified amount of underlying asset

addReserves(uint256 addAmount)

Add reserves capital pool

Events:

LogBorrow(address account, uint256 amount, uint256 fee)

Event borrow

Parameters:

  • account: Member address
  • amount: Borrow amount
  • fee: Origination fee

LogRepay(address account, uint256 amount)

Event repay

Parameters:

  • account: Member address
  • amount: Repay amount

LogNewMarketInterestRateModel(address oldInterestRateModel, address newInterestRateModel)

Change of the interest rate model

Parameters:

  • oldInterestRateModel: Old interest rate model address
  • newInterestRateModel: New interest rate model address

LogMint(address minter, uint256 underlyingAmount, uint256 uTokenAmount)

Mint uToken event

Parameters:

  • minter: minter address
  • underlyingAmount: underlying amount
  • uTokenAmount: mint uToken amount

LogRedeem(address redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn, uint256 redeemAmount)

Redeem uToken event

Parameters:

  • redeemer: redeemer address
  • redeemTokensIn: redeem token address
  • redeemAmountIn: redeem token amount
  • redeemAmount: redeem amount

LogReservesAdded(address reserver, uint256 actualAddAmount, uint256 totalReservesNew)

Reserves added event

Parameters:

  • reserver: reserver address
  • actualAddAmount: actual add amount
  • totalReservesNew: new total reserves

LogReservesReduced(address receiver, uint256 reduceAmount, uint256 totalReservesNew)

Reserves reduced event

Parameters:

  • receiver: receiver address
  • reduceAmount: reduce amount
  • totalReservesNew: new total reserves
Last modified 1yr ago