Comptroller
The risk management layer of the protocol.
Introduction
The Comptroller is the heart and soul of all of the risk-management related business logic within the protocol. It determines multiple things, including but not limited to:
How much collateral a user is required to maintain
Whether a user can be liquidated.
How much a user can be liquidated for.
What markets are supported.
Mapping user balances to prices and their respective collateral factors.
Quantifies risk based off assets that a user is using in the protocol.
The Comptroller is also implemented as an upgradeable proxy, and the proxy contract is called the Unitroller. The Unitroller acts as a proxy for all logic and delegate calls the contract methods of the Comptroller contract and state parameters are stored in the Unitroller contract.
To properly call Comptroller functions, please use the Comptroller ABI on the Unitroller address.
Market Functions
Enter Markets
When a user supplies assets to the protocol, the enterMarkets
function is called with the associated cToken address. By calling this function, the respective asset is marked as collateral and is able to be borrowed against.
Exit Markets
A user can remove supplied assets from account health calculations by calling the exitMarkets
function.
Account Functions
Get Assets In
In order to decide how much account liquidity a user has and which markets they have entered, the Comptroller calls the getAssetsIn
function. All entered markets count towards the total liquidity an account has available.
Get Account Liquidity
Overview
Comptroller logic
Each time an asset is supplied, borrowed, withdrawn or repaid, an accounts overall liquidity will change accordingly.
Supplying increases the Account Liquidity of an account.
Borrowing reduces the Account Liquidity of an account.
Withdrawing reduces Account Liquidity by refactoring the account's overall liquidity per the equation listed above.
Repaying increases Account Liquidity of an account by refactoring the account's overall liquidity per the equation listed above.
Collateral Factor
Large, blue chip, liquid assets will have high Collateral Factors and will be able to be used as prime-collateral. Small, more niche, illiquid assets will have low Collateral Factors. Some assets may not have a Collateral Factor, which means they cannot be used as collateral and borrowed against.
Close Factor
The Comptroller applies the closeFactor
to a single borrowed asset, not the aggregated value of all of the assets a user has borrowed.
Liquidation Incentive
This value is represented by the liquidationIncentiveMantissa
parameter and acts as an incentive for liquidators to liquidate unhealthy accounts. The protocols default liquidation incentive for V0 is 8%.
Market Metadata
The Comptroller provides a useful function, getAllMarkets
, that can be used to retrieve all of the currently supported lToken markets and their corresponding addresses.
Last updated