Fallback Queued Liquidations
Last updated
Last updated
The liquidation process follows a tiered approach with three distinct phases:
Priority Phase (priorityDuration):
Duration: Configurable (default 1 second)
Only liquidators who previously called queueLiquidation() can execute liquidations
Creates a short exclusive window for early liquidation detectors
Prevents gas wars by giving priority to those who identified liquidation opportunities first
Regular Phase (regularDuration):
Duration: Configurable (default 3 seconds)
Any liquidator can execute liquidations regardless of whether they called queueLiquidation()
Ensures liquidations proceed even if priority liquidators fail to execute
Starts immediately after the priority phase ends
End Phase (endDuration):
Duration: Configurable (default 30 seconds)
Window during which liquidations can execute before the queue resets
After this period, a new liquidation cycle with a new nonce must be initiated
Prevents indefinite liquidation windows that could be exploited
The contract manages liquidation queues through several key mappings:
regularQueue[bytes32 => LiqQueue]
: Tracks liquidation windows for accounts/tokens
priorityAccess[bytes32 => uint256]
: Maps liquidator access rights to timestamps
Queuing requires validation through canLiquidate()
checks to prevent gaming the system
Critical hash construction: keccak256(abi.encodePacked(account, liquidationTarget))
Description: Queues a token-specific liquidation for an account, liquidating a specific pToken collateral by repaying active debt in the specified eToken. This function is called by the eToken itself to validate that liquidation is allowed based on the account's current liquidity.
Contract: Etoken
address
eToken
The earning token debt position to be repaid from the account
address
pToken
The position token to be liquidated from the account
address
liquidator
The account to execute the liquidation once queued
address
account
The account being liquidated and debt repaid on behalf of
Description: Queues an account liquidation for an entire account, allowing a liquidator to repay a portion of the account's active debt. This function is called by the liquidator themselves to queue up a different account's liquidation.
Contract: MarketManager/MarketManagerIsolated
address
account
The account being liquidated and debt repaid on behalf of
Description: Liquidates an entire account by partially paying down debts, distributing all of the account's collateral, and recognizing remaining debt as bad debt. This function updates the account's EToken interest before solvency is checked and includes extensive run invariant checks to prevent potential asset callback exploits.
Contract: MarketManager/MarketManagerIsolated
Function signature:
address
account
The address to liquidate completely
Description: Liquidates a specific amount of borrowed assets from a borrower who has fallen below the collateral maintenance requirement. The liquidator repays a portion of the borrower's debt and receives a proportional amount of the borrower's collateral in return, plus a liquidation incentive.
Contract: Etoken
Function signature:
address
account
The account to be liquidated
uint256
amount
The exact amount of underlying asset to be repaid
address
pToken
The address of the pToken collateral to be seized
Return data:
uint256
The number of collateral tokens seized
Description: Liquidates a borrower who has fallen below the collateral maintenance requirement. The liquidator repays a portion of the borrower's debt and receives a proportional amount of the borrower's collateral in return, plus a liquidation incentive. This function attempts to liquidate the maximum amount possible.
Contract: Etoken
Function signature:
address
account
The account to be liquidated
address
pToken
The address of the pToken collateral to be seized
Return data:
uint256
The number of collateral tokens seized