# ADL

Auto-deleveraging (ADL) is the last line of defense employed by the risk engine to protect the solvency of markets. It kicks in when a position cannot be closed above the bankruptcy price and the insurance fund is insufficient to cover the capital shortfall. On Bluefin, a permissioned ADL worker automatically deleverages bankrupt positions against top-of-queue positions from the opposite side. The ADL queue prioritizes closing the most profitable and high-leverage traders to reduce counterparty risk.

## ADL Queue

The objective of the ADL queue is to pick out accounts with the highest PnL percentage and leverage. For each market, $$i$$ be the individual position for which the ADL Score is calculated.&#x20;

$$\text{PNL Score}*i = \begin{cases} \frac{ P*{index/oracle}-P\_{pos} }{P\_{pos}} \quad &\text{if Long}, \\\ \frac{-( P\_{index/oracle}-P\_{pos}) }{P\_{pos}} \quad &\text{if Short}.\end{cases}$$

$$\text{PNL Score}\_i = \max (0, \text{PNL Score}\_i)$$

$$\text{Leverage Score}\_i = 1/\text{max}(\text{MMR},\text{MR})$$

$$\text{ADL Score}\_i = \text{PNL Score}\_i \times \text{Leverage Score}\_i$$

$$\text{ADL Quantile} = rank(user.\text{ADL Score}\_i)/\text{Total User Count}$$


---

# 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://learn.bluefin.io/bluefin/bluefin-perps-exchange/trading/risk-engine/adl.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.
