Liquidation Process
AFX uses a multi-phase liquidation process to handle under-margined positions in an orderly manner, minimizing market impact and protecting other users.
Phase 1: Trigger and Pre-Processing
When the Risk Engine detects that a position's margin ratio has reached 100%:
The account is flagged as "in liquidation."
All open orders in the same direction as the endangered position are cancelled. If cancelling these orders brings the margin ratio back below 95%, the liquidation stops.
If the margin ratio is still above the safe threshold after cancellation, the system proceeds to forcibly close the position.
Tiered Liquidation: For positions with a notional value exceeding 100,000 USDC, the system liquidates in steps — closing 20% of the position at a time, with a 30-second cooldown between each step. If the margin ratio recovers to the safe level after any step, the liquidation process stops.
The position is closed at market price. Any remaining margin after closing is returned to the user's account.
Phase 2: Vault Takeover
If the liquidated position cannot be immediately closed in the market (e.g., due to insufficient liquidity), the LP Vault takes over the position.
The Vault calculates the notional value of the position using the Mark Price.
The positions taken over cannot exceed the Vault's limit; otherwise, ADL will be triggered directly.
The Vault collects a liquidation fee of 0.5% of the remaining maintenance margin from the liquidated position.
Phase 3: Market Matching
The Vault's liquidation orders enter the matching engine.
Other market participants (market makers, regular traders) can take the other side of these orders.
Once filled, the Vault recovers the position margin and any remaining balance.
Phase 4: ADL (if Vault is Overwhelmed)
If the Vault cannot fully close the position at a reasonable price (market depth is insufficient) or the Vault's balance becomes negative, the system triggers Auto-Deleveraging. See ADL for details.
Fund Flow Summary
Liquidated user
Position closed; remaining margin (minus liquidation fee) returned. If fully depleted, balance goes to zero.
LP Vault
Receives liquidation fee. Assumes temporary position risk during takeover.
Market counterparties
Can fill liquidation orders at a discount.
ADL targets
Positions partially or fully reduced at the Vault's liquidation price (only in extreme cases).
Last updated

