Liquidation & Auto-Deleveraging (ADL)
This document describes how the perpetual futures exchange protects itself from under-collateralised accounts and socialises losses via auto-deleveraging and the insurance fund.
1. Liquidation trigger
Every account has an equity and a maintenance margin (MM):
where is the per-pair maintenance-margin ratio. An account becomes liquidatable when
Strict inequality: an account whose equity exactly equals its MM is still safe. An account with no open positions is never liquidatable regardless of its equity.
2. Close schedule
When an account is liquidatable, the system computes the minimum set of position closures needed to restore it above maintenance margin.
-
For every open position, compute its MM contribution:
-
Sort positions by MM contribution descending (largest first).
-
Walk the sorted list and close just enough to cover the deficit:
- For each position:
- If : stop
This produces a vector of entries. Each has the opposite sign of the existing position (a long is closed with a sell, a short with a buy). Only positions that contribute to the deficit are touched and they may be partially closed when the deficit is small relative to the position.
3. Position closure
Each entry in the close schedule is executed in two phases:
3a. Order book matching
The close is submitted as a market order against the on-chain order book. It matches resting limit orders at price-time priority. Any filled amount is settled normally (mark-to-market PnL between the entry price and the fill price).
3b. Auto-deleveraging (ADL)
If any quantity remains unfilled after the order book is exhausted, the system automatically deleverages against counter-parties. The unfilled remainder is closed against the most profitable counter-positions at the liquidated user’s bankruptcy price.
Counter-party selection: Positions are indexed by the tuple . For a long being liquidated (selling), the system finds shorts with the highest entry price (most profitable) first. For a short being liquidated (buying), it finds longs with the lowest entry price first.1
Bankruptcy price: The fill price at which the liquidated user’s total equity would be exactly zero:
Since equity is typically negative for liquidatable users, the bankruptcy price is worse than the oracle price — the counter-party receives a favourable fill. The counter-party’s resting limit orders are not affected by ADL; only their position is force-reduced.
Liquidation fills (both order-book and ADL) carry zero trading fees for both taker and maker.
4. Liquidation fee
After all positions in the schedule are closed, a one-time liquidation fee is charged:
The fee is deducted from the user’s margin and routed to the insurance fund (not the vault). It is capped at the remaining margin so the fee itself never creates bad debt.
5. PnL settlement
All PnL from the liquidation fills (user, book makers, ADL counter-parties) is settled atomically as in-place USD margin adjustments — no token transfers occur. Both user and maker PnL are applied via the same settlement logic described in Order matching §8.
6. Bad debt
After PnL and fee settlement, if the user’s margin is negative the absolute value is bad debt. The margin is floored to zero and the bad debt is subtracted from the insurance fund:
The insurance fund may go negative. A negative insurance fund represents unresolved bad debt — future liquidation fees will replenish it.
Note: when positions are fully ADL’d at the bankruptcy price, the user’s equity is zeroed by construction. Bad debt from ADL fills is therefore zero. Bad debt arises only from book fills at prices worse than the bankruptcy price (e.g., thin order books with deep bids/asks far from oracle).
7. Insurance fund
The insurance fund is a separate pool from the vault that absorbs bad debt and is funded by liquidation fees.
Funding: Every liquidation fee (§4) is credited to the insurance fund.
Usage: Every bad debt event (§6) is debited from the insurance fund.
Negative balance: The insurance fund may go negative when accumulated bad debt exceeds accumulated fees. This is the simplest approach — no special trigger or intervention is needed. Future liquidation fees will naturally replenish the fund.
The vault’s margin is never touched for bad debt or liquidation fees. This isolates liquidity providers from liquidation losses.
Examples
All examples use:
| Parameter | Value |
|---|---|
| Pair | BTC / USD |
| Maintenance-margin ratio (mmr) | 5 % |
| Liquidation-fee rate | 0.1 % |
| Settlement currency | USDC at $1 |
Example 1 — Clean liquidation on book (no bad debt)
Setup
| Alice | Bob (maker) | |
|---|---|---|
| Direction | Long 1 BTC | Bid 1 BTC @ $47,500 |
| Entry price | $50,000 | — |
| Margin | $3,000 | $10,000 |
BTC drops to $47,500
Alice’s account
Close schedule
Alice has one position; the full 1 BTC long is scheduled for closure.
Execution
The long is closed (sold) into Bob’s resting bid at $47,500.
Liquidation fee
Settlement (margin arithmetic)
Alice’s margin starts at $3,000.
Final margin is positive — no bad debt.
Example 2 — ADL at bankruptcy price (no book liquidity)
Setup
| Charlie | Dana | |
|---|---|---|
| Direction | Long 1 BTC | Short 1 BTC |
| Entry price | $50,000 | $55,000 |
| Margin | $3,000 | $10,000 |
BTC drops to $46,000
Charlie’s account
Close schedule
Charlie’s full 1 BTC long is scheduled for closure.
Order book matching
No bids on the book — the full 1 BTC is unfilled.
ADL
Bankruptcy price for Charlie’s long:
Dana holds the most profitable short (entry $55,000, current oracle $46,000). Her position is force-closed at $47,000.
Charlie’s PnL at bankruptcy price:
Dana’s PnL at bankruptcy price:
Liquidation fee
No bad debt, no insurance fund impact. Dana receives the full PnL at the bankruptcy price, which is better than the oracle price for her.
Final state
| Balance | |
|---|---|
| Charlie | $0 (fully liquidated) |
| Dana | $18,000 (profit at bp) |
| Insurance fund | unchanged |
Example 3 — Book fill creates bad debt
Setup
| Charlie | Bob (maker) | |
|---|---|---|
| Direction | Long 1 BTC | Bid 1 BTC @ $46,000 |
| Entry price | $50,000 | — |
| Margin | $3,000 | $50,000 |
| Insurance fund | $500 |
BTC drops to $46,000
Charlie’s liquidation
Same equity and MM as Example 2. Liquidatable.
Order book matching
The bid at $46,000 fills Charlie’s full 1 BTC sell.
Liquidation fee
Bad debt
Charlie’s margin after PnL: .
The insurance fund goes negative. Future liquidation fees will replenish it.
Final state
| Balance | |
|---|---|
| Charlie | $0 (fully liquidated) |
| Insurance fund | −$500 (unresolved bad debt) |
| Vault | unchanged (isolated from losses) |
-
This does not perfectly rank by total PnL since it ignores accumulated funding fees, but is a reasonable and efficient approximation. ↩