Comment on page
The risk management layer of the protocol.
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.
When a user supplies assets to the protocol, the
enterMarketsfunction 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.
A user can remove supplied assets from account health calculations by calling the
In order to decide how much account liquidity a user has and which markets they have entered, the Comptroller calls the
getAssetsInfunction. All entered markets count towards the total liquidity an account has available.
As stated in the Account Liquidity paragraph on the Collateral section, this value can be used to see the maximum USD value borrowable for a particular account before it reaches liquidation. Any users that have a negative Account Liquidity are subject to liquidation. In addition, a user will not be able to use the protocol to withdraw assets or borrow additional assets until their Account Liquidity is positive again.
After a user has entered a market and the comptroller knows what assets they are in, it will then compute the available liquidity in the account. The Comptroller looks at each market a user has entered into and multiplies their Supply balance by the respective assets Collateral Factor, sums it up and then subtracts the Borrow balances; this yields Account Liquidity.
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.
Within the protocol, a lToken's Collateral Factor can currently fall within a range of 15-85% (subject to change by governance or with the addition of new markets). As described in our Interest Rate Models section, Lodestar places assets into different buckets based on their level of risk.
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.
As outlined in the Close Factor paragraph on the Liquidation section, the protocol has a default Close Factor of 0.5 and this represents the maximum amount (50%) of a user's borrow balance that can be liquidated in a single transaction. If a user's account is still insolvent after liquidation, the account can be liquidated again until the account is back in good standing.
The Comptroller applies the
closeFactorto a single borrowed asset, not the aggregated value of all of the assets a user has borrowed.
This value is represented by the
liquidationIncentiveMantissaparameter and acts as an incentive for liquidators to liquidate unhealthy accounts. The protocols default liquidation incentive for V0 is 8%.
The Comptroller provides a useful function,
getAllMarkets, that can be used to retrieve all of the currently supported lToken markets and their corresponding addresses.