Auditor
The Auditor is the risk management layer of the protocol; it determines how much collateral a user is required to maintain, and whether (and by how much) a user can be liquidated. Each time a user borrows from a Market, the Auditor validates his accountโs liquidity to determine his health factor.
Public State Variables
ASSETS_THRESHOLD
Maximum value the liquidator can send and still have granular control of max assets. Above this threshold, they should send type(uint256).max
.
BASE_FEED
Address that a market should have as price feed to consider as base price and avoid external price call.
TARGET_HEALTH
Target health factor that the account should have after it's liquidated to prevent cascade liquidations.
accountMarkets
Tracks the markets' indexes that an account has entered as collateral.
liquidationIncentive
Liquidation incentive factors for the liquidator and the lenders of the market where the debt is repaid.
marketList
Array of all enabled markets.
markets
Stores market parameters per each enabled market.
priceDecimals
Decimals that the answer of all price feeds should have.
View Methods
accountLiquidity
Returns account's liquidity calculation.
Parameters
account
address
account in which the liquidity will be calculated.
marketToSimulate
contract Market
market in which to simulate withdraw operation.
withdrawAmount
uint256
amount to simulate as withdraw.
Returns
sumCollateral
uint256
sum of all collateral, already multiplied by each adjust factor (denominated in base).
sumDebtPlusEffects
uint256
sum of all debt divided by adjust factor considering withdrawal (denominated in base).
allMarkets
Retrieves all markets.
Returns
contract Market[]
List of enabled markets.
assetPrice
Gets the asset price of a price feed.
If Chainlink's asset price is <= 0 the call is reverted.
Parameters
priceFeed
contract IPriceFeed
address of Chainlink's Price Feed aggregator used to query the asset price.
Returns
uint256
The price of the asset scaled to 18-digit decimals.
calculateSeize
Calculates the amount of collateral to be seized when a position is undercollateralized.
Parameters
repayMarket
contract Market
market from where the debt will be repaid.
seizeMarket
contract Market
market from where the assets will be seized by the liquidator.
borrower
address
account in which assets are being seized.
actualRepayAssets
uint256
amount being repaid.
Returns
lendersAssets
uint256
amount to be added for other lenders as a compensation of bad debt clearing.
seizeAssets
uint256
amount that can be seized by the liquidator.
checkLiquidation
Allows/rejects liquidation of assets.
This function can be called externally, but only will have effect when called from a market.
Parameters
repayMarket
contract Market
market from where the debt is being repaid.
seizeMarket
contract Market
market from where the liquidator will seize assets.
borrower
address
address in which the assets are being liquidated.
maxLiquidatorAssets
uint256
maximum amount of debt the liquidator is willing to accept.
Returns
maxRepayAssets
uint256
capped amount of debt the liquidator is allowed to repay.
checkSeize
Allow/rejects seizing of assets.
This function can be called externally, but only will have effect when called from a market.
Parameters
repayMarket
contract Market
market from where the debt will be repaid.
seizeMarket
contract Market
market where the assets will be seized.
checkShortfall
Checks if the account has liquidity shortfall.
Parameters
market
contract Market
address of the market where the operation will happen.
account
address
address of the account to check for possible shortfall.
amount
uint256
amount that the account wants to withdraw or transfer.
Write Methods
checkBorrow
Validates that the current state of the position and system are valid.
To be called after adding the borrowed debt to the account position.
Parameters
market
contract Market
address of the market where the borrow is made.
borrower
address
address of the account that will repay the debt.
enableMarket
Enables a certain market.
Enabling more than 256 markets will cause an overflow when casting market index to uint8.
Parameters
market
contract Market
market to add to the protocol.
priceFeed
contract IPriceFeed
address of Chainlink's Price Feed aggregator used to query the asset price in base.
adjustFactor
uint128
market's adjust factor for the underlying asset.
decimals
uint8
decimals of the market's underlying asset.
enterMarket
Allows assets of a certain market to be used as collateral for borrowing other assets.
Parameters
market
contract Market
market to enabled as collateral.
exitMarket
Removes market from sender's account liquidity calculation.
Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral for an outstanding borrow.
Parameters
market
contract Market
market to be disabled as collateral.
handleBadDebt
Checks if account has debt with no collateral, if so then call clearBadDebt
from each market.
Collateral is multiplied by price and adjust factor to be accurately evaluated as positive collateral asset.
Parameters
account
address
account in which debt is being checked.
Last updated