liquidation process
Trustin regularly (every block time) fetches the liquidation ratio, liquidation reward factor, oracle address, and exchange rates for various markets.
After obtaining the market list through the Comptroller and Lens contracts, TrustIn checks whether the reserve fund custody contract has authorized the corresponding market to use cTokens and underlying assets. If not, authorization processing is performed. This check is conducted once per minute to determine if there are any new markets. Each market spawns a separate goroutine to query the list of borrowing users for that market through a subgraph.
If a user is not in the vicinity of the liquidation user list, TrustIn will check the list every 4 block times through the reserve fund custody contract for batch screening.
If a user's liquidity and health score are nearing the liquidation user list, TrustIn will check the list every block time through the reserve fund custody contract for querying user liquidity and health score.
If liquidation is triggered, the user information is sent to the liquidation queue, and the user is marked as "in liquidation" status.
liquidation
When a user enters the liquidation list, TrustIn will recheck whether the user meets the liquidation criteria for the corresponding market
If the user does not meet the liquidation criteria, TrustIn will remove the user from the "in liquidation" status.
If the user meets the liquidation criteria, TrustIn will apply the Lens contract to retrieve all borrowing/collateral information for the user and select the market with the largest borrowing amount for liquidation.
When selecting the assets for liquidation, TrustIn prioritizes the user's largest collateral asset.
If the user's collateral in that market is sufficient to repay the loan, then:
If the user's collateral in that market is not sufficient to repay the loan, then the seized tokens will be the maximum collateral quantity:
the liquidation transaction will be constructed, logged and sent to the blockchain after signed.
Last updated