Market
The Market is the main contract of the protocol. It exposes all user-oriented actions for fixed and variable borrows, deposits, repayments, and withdrawals.
The contract is also an ERC20 token itself. Following the ERC4626 standard, exaTokens
are minted to the user once he deposits underlying assets into the variable pool. These tokens are then burned once the underlying assets are withdrawn. If transferred, the variable deposit position is also transferred.
Public State Variables
accounts
Tracks fixed deposit and borrow map and floating borrow shares of an account.
asset
Address of underlying ERC20 asset.
auditor
Auditor contract that validates health factor of accounts that operate with this Market.
backupFeeRate
Rate charged to the fixed pool to be retained by the floating pool for initially providing liquidity.
dampSpeedDown
Damp speed factor to update floatingAssetsAverage
when floatingAssets
is lower.
dampSpeedUp
Damp speed factor to update floatingAssetsAverage
when floatingAssets
is higher.
earningsAccumulator
Accumulated earnings from extraordinary sources to be gradually distributed.
earningsAccumulatorSmoothFactor
Factor used for gradual accrual of earnings to the floating pool.
fixedBorrowPositions
Tracks account's fixed borrow positions by maturity, account and position.
fixedDepositPositions
Tracks account's fixed deposit positions by maturity, account and position.
fixedPools
Tracks fixed pools state by maturity.
floatingAssets
Amount of floating assets deposited to the pool.
floatingAssetsAverage
Average of the floating assets to get fixed borrow rates and prevent rate manipulation.
floatingBackupBorrowed
Amount of assets lent by the floating pool to the fixed pools.
floatingDebt
Amount of assets lent by the floating pool to accounts.
floatingUtilization
Current floating utilization used to get the new floating borrow rate.
interestRateModel
Interest rate model contract used to get the borrow rates.
lastAccumulatorAccrual
Last time the accumulator distributed earnings.
lastAverageUpdate
Last time the floating assets average was updated.
lastFloatingDebtUpdate
Last time the floating debt was updated.
maxFuturePools
Number of fixed pools to be active at the same time.
penaltyRate
Rate per second to be charged to delayed fixed pools borrowers after maturity.
reserveFactor
Percentage factor that represents the liquidity reserves that can't be borrowed.
treasury
Address of the treasury that will receive the allocated earnings.
treasuryFeeRate
Rate to be charged by the treasury to floating and fixed borrows.
View Methods
accountSnapshot
Gets current snapshot for an account across all maturities.
Parameters
Returns
convertToAssets
Returns the amount of assets that would be exchanged by the pool for the amount of shares provided.
Parameters
Returns
convertToShares
Returns the amount of shares that would be exchanged by the vault for the amount of assets provided.
Parameters
Returns
maxRedeem
Returns the maximum amount of shares that can be redeem from the owner balance through a redeem call.
Parameters
Returns
maxWithdraw
Returns the maximum amount of underlying assets that can be withdrawn from the owner balance with a single withdraw call.
Parameters
Returns
previewBorrow
Simulates the effects of a borrow at the current time, given current contract conditions.
Parameters
Returns
previewDebt
Gets all borrows and penalties for an account.
Parameters
Returns
previewDeposit
Allows users to simulate the effects of their deposit at the current block.
Parameters
Returns
previewFloatingAssetsAverage
Gets the current floatingAssetsAverage
without updating the storage variable.
Returns
previewMint
Allows users to simulate the effects of their mint at the current block.
Parameters
Returns
previewRedeem
Allows users to simulate the effects of their redemption at the current block.
Parameters
Returns
previewRefund
Simulates the effects of a refund at the current time, given current contract conditions.
Parameters
Returns
previewRepay
Simulates the effects of a repay at the current time, given current contract conditions.
Parameters
Returns
previewWithdraw
Allows users to simulate the effects of their withdrawal at the current block.
Parameters
Returns
totalAssets
Calculates the floating pool balance plus earnings to be accrued at current timestamp from maturities and accumulator.
Returns
totalFloatingBorrowAssets
Calculates the total floating debt, considering elapsed time since last update and current interest rate.
Returns
totalFloatingBorrowShares
Total amount of floating borrow shares assigned to floating borrow accounts.
Write Methods
borrow
Borrows a certain amount from the floating pool.
Parameters
Returns
borrowAtMaturity
Borrows a certain amount from a maturity.
Parameters
Returns
clearBadDebt
Clears floating and fixed debt for an account spreading the losses to the earningsAccumulator
.
Can only be called from the auditor.
Parameters
deposit
Parameters
Returns
depositAtMaturity
Deposits a certain amount to a maturity.
Parameters
Returns
liquidate
Liquidates undercollateralized position(s).
Msg.sender liquidates borrower's position(s) and repays a certain amount of debt for multiple maturities, seizing a part of borrower's collateral.
Parameters
Returns
mint
Parameters
Returns
redeem
Redeems the owner's floating pool assets to the receiver address.
Makes sure that the owner doesn't have shortfall after withdrawing.
Parameters
Returns
refund
Repays a certain amount of shares to the floating pool.
Parameters
Returns
repay
Repays a certain amount of assets to the floating pool.
Parameters
Returns
repayAtMaturity
Repays a certain amount to a maturity.
Parameters
Returns
seize
Public function to seize a certain amount of assets.
Public function for liquidator to seize borrowers assets in the floating pool. This function will only be called from another Market, on liquidation
calls. That's why msg.sender needs to be passed to the private function (to be validated as a market)
Parameters
withdraw
Withdraws the owner's floating pool assets to the receiver address.
Makes sure that the owner doesn't have shortfall after withdrawing.
Parameters
Returns
withdrawAtMaturity
Withdraws a certain amount from a maturity.
It's expected that this function can't be paused to prevent freezing account funds.
Parameters
Returns
Last updated