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
Copy function ASSETS_THRESHOLD () external view returns ( uint256 ) Maximum value the liquidator can send and still have granular control of max assets. Above this threshold, they should send type(uint256).max.
Copy function BASE_FEED () external view returns ( address ) Address that a market should have as price feed to consider as base price and avoid external price call.
Copy function TARGET_HEALTH () external view returns ( uint256 ) Target health factor that the account should have after it's liquidated to prevent cascade liquidations.
Copy function accountMarkets ( address ) external view returns ( uint256 ) 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.
Array of all enabled markets.
Stores market parameters per each enabled market.
Decimals that the answer of all price feeds should have.
accountLiquidity
Returns account's liquidity calculation.
Parameters
account in which the liquidity will be calculated.
market in which to simulate withdraw operation.
amount to simulate as withdraw.
Returns
sum of all collateral, already multiplied by each adjust factor (denominated in base).
sum of all debt divided by adjust factor considering withdrawal (denominated in base).
Retrieves all markets.
Returns
Gets the asset price of a price feed.
If Chainlink's asset price is <= 0 the call is reverted.
Parameters
address of Chainlink's Price Feed aggregator used to query the asset price.
Returns
The price of the asset scaled to 18-digit decimals.
Calculates the amount of collateral to be seized when a position is undercollateralized.
Parameters
market from where the debt will be repaid.
market from where the assets will be seized by the liquidator.
account in which assets are being seized.
Returns
amount to be added for other lenders as a compensation of bad debt clearing.
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
market from where the debt is being repaid.
market from where the liquidator will seize assets.
address in which the assets are being liquidated.
maximum amount of debt the liquidator is willing to accept.
Returns
capped amount of debt the liquidator is allowed to repay.
Allow/rejects seizing of assets.
This function can be called externally, but only will have effect when called from a market.
Parameters
market from where the debt will be repaid.
market where the assets will be seized.
Checks if the account has liquidity shortfall.
Parameters
address of the market where the operation will happen.
address of the account to check for possible shortfall.
amount that the account wants to withdraw or transfer.
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
address of the market where the borrow is made.
address of the account that will repay the debt.
Enables a certain market.
Enabling more than 256 markets will cause an overflow when casting market index to uint8.
Parameters
market to add to the protocol.
address of Chainlink's Price Feed aggregator used to query the asset price in base.
market's adjust factor for the underlying asset.
decimals of the market's underlying asset.
Allows assets of a certain market to be used as collateral for borrowing other assets.
Parameters
market to enabled as collateral.
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 to be disabled as collateral.
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 in which debt is being checked.