# Auto-deleveraging(ADL)

When a trader's position is liquidated, the liquidation engine takes over the position. If the liquidation order cannot be filled at the bankruptcy price and the insurance funds run out, the ADL system automatically deleverages opposing traders' positions based on profit and leverage priority.

All orders at risk of ADL will be placed in a queue. The priority ranking of a trader's position is calculated based on both profit and leverage, with more profitable and higher-leveraged traders being deleveraged first. The priority formula is:

$$
Ranking = PnL Percentage\times  Effective Leverage
$$

Where:

* $$PnL Percentage = Unrealized PnL Percentage (ROI)$$
* $$Effective Leverage = \frac{Mark Value}{abs (Mark Value - Bankrupt Value) }$$
* $$Mark Value$$= Position Value at Mark Price
* $$Bankrupt Value$$= Position Value at Bankruptcy Price

{% hint style="success" %}

## **Join Our Community**

* **Twitter**: <https://twitter.com/nfex_official>
* **Discord**: <https://discord.gg/nfex>
* **Medium**: [https://medium.com/@nfex.official](https://medium.com/@nfex.official/)
  {% endhint %}


---

# 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://nfex.gitbook.io/docs/nfex-perpetual-guide/auto-deleveraging-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.
