The liquidation mechanism does not enforce any time-based cooldown between successive liquidation attempts. As a result, accounts that have just been liquidated (or are borderline liquidatable) can be immediately targeted again. This absence of a grace period prevents traders from adding margin or adjusting positions, potentially leading to unnecessarily aggressive and repeated liquidations.
In the liquidateAccounts(uint128[] calldata accountsIds)
function, there is no check of a time-stamp or cooldown parameter to ensure that sufficient time has passed between liquidation attempts on the same account. For example, the function implementation:
The lack of any time-based cooldown mechanism means that an account that is liquidatable can be processed repeatedly in rapid succession. During periods of high market volatility, temporary price fluctuations might push an account below the maintenance margin requirement. Without a cooldown, the account can be liquidated multiple times without giving the trader an opportunity to add margin or otherwise mitigate the situation.
Repeated Liquidations: Traders may experience multiple liquidations in quick succession, which can drastically erode their collateral and lead to severe financial losses.
Unfair Penalties: A lack of a grace period means that temporary market perturbations can trigger unnecessary liquidations, penalizing traders for momentary liquidity issues.
Market Manipulation: Malicious actors could exploit this rapid-fire liquidation mechanism to manipulate the market or repeatedly target specific accounts.
Manual Code Review
Static Analysis Tools
Simulation Testing.
Implement a Cooldown Period: Introduce a time-based cooldown interval in the liquidation mechanism, during which an account cannot be re-liquidated. This can be achieved by storing the timestamp of the last liquidation attempt for each account.
Example:
Grace Period for Margin Top-ups: Allow a grace period after an account becomes liquidatable to provide traders with the opportunity to add margin or adjust their positions.
Update State Variables: Ensure that upon liquidation, the account’s lastLiquidationTimestamp
(or equivalent storage variable) is updated accordingly.
Extensive Testing: Develop tests to verify that the cooldown mechanism effectively prevents repeated liquidations in rapid succession and works correctly under various market conditions.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.