# Auto Deleveraging

ADL is a last-resort feature that is activated only if the insurance fund’s equity falls to zero (its *bankruptcy price*) and the liquidator therefore cannot cover the deficit.

1. **Trigger** – When a liquidation would leave the insurance fund insolvent, ADL begins.
2. **Order-book sweep** – All open orders on the insurance-fund account are first cancelled.
3. **Counterparty ranking** – Accounts holding *opposite* positions are ranked in strict priority:
   1. Highest effective leverage
   2. Highest unrealised PnL
   3. Lowest account balance
   4. Newest account (higher account number)
4. **Forced position closure** – Starting from the top of the list, the engine closes just enough of each profitable position against the insurance fund at the current oracle mark (capped at the bankruptcy price) to offset the shortfall.
5. **No intermediate checks** – Once ADL starts it runs to completion even if the fund would briefly become solvent part-way through. When the insurance fund’s equity is ≥ 0 and it holds no positions, ADL stops.

***

**Example – ETH long unwound via ADL**

* Trader A is long 10 ETH from $4000.
* ETH crashes to $3600. A’s equity is now –$2000.
* The insurance fund has already reached its bankruptcy price, so it cannot absorb the loss – ADL triggers.
* The system ranks profitable shorts; Trader B is first on the list.
* The engine closes enough of B’s short at $3600 to transfer $2000 of PnL.
* Result: Trader A’s position is fully closed, Trader B’s short is partially reduced, the insurance fund carries zero bad debt, and trading continues.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ethereal.trade/trading/perpetual-futures/auto-deleveraging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
