> For the complete documentation index, see [llms.txt](https://edgex-1.gitbook.io/edgeX-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edgex-1.gitbook.io/edgeX-documentation/trading/adl-rules.md).

# ADL Rules

Auto-Deleveraging (ADL) Rules for Perpetual Contracts

#### Overview

1. Auto-Deleveraging (ADL) is a risk control mechanism for perpetual contracts. When a position goes bankrupt and incurs a loss that cannot be covered by its margin, the system auto-deleverage eligible profitable Counterparty Positions to cover the loss of the Bankrupt Position.
2. ADL is a risk management action executed automatically by the Risk Engine under uniform rules. It does not require counterparties to submit close orders.

#### Definitions

<table><thead><tr><th width="124.875">Term</th><th>Definition</th></tr></thead><tbody><tr><td>Bankrupt Position</td><td>A position that has been liquidated and whose margin is insufficient to cover its losses, resulting in negative equity in the account or position.</td></tr><tr><td>Counterparty Position</td><td>A position in the same contract as the Bankrupt Position, held in the opposite direction, that is eligible to be selected by the Risk Engine for ADL.</td></tr><tr><td>Unrealized Profit</td><td>The unrealized profit of a Counterparty Position at the time ADL is triggered, calculated by the Risk Engine based on the Mark Price and the protocol's settlement rules.</td></tr></tbody></table>

#### Trigger Conditions and Execution Principles

1. Once the system confirms that a position is bankrupt, it immediately determines the quantity of the Bankrupt Position to be covered and initiates the ADL process. ADL applies only to profitable opposing positions in the same contract as the Bankrupt Position. The scope of execution is determined by the valid open positions identified by the Risk Engine at the moment ADL is triggered.
2. The objective of ADL is to close out the Bankrupt Position. The system selects Counterparty Positions one at a time in ranking order and recalculates the remaining quantity to be closed after each execution, ensuring that the ADL quantity never exceeds the available position size of either the Bankrupt Position or the Counterparty Position.

#### ADL Ranking Rules

1. The protocol uses the Unrealized Profit of Counterparty Positions as the primary ADL ranking metric. The higher the Unrealized Profit, the higher the ADL ranking and the earlier the position is deleveraged. Positions with negative Unrealized Profit, or that otherwise do not meet the eligibility criteria, are excluded from the ADL candidate pool for that event.
2. Where multiple Counterparty Positions have the same Unrealized Profit, the final order is determined by secondary ranking factors preset in the Risk Engine (such as ROI or leverage), ensuring that the ranking is stable and reproducible.

#### ADL Quantity and Sequential Execution

1. Let Q\_bankruptcy be the remaining position size of the Bankrupt Position, and Q\_counterparty be the deleverageable position size of the selected Counterparty Position. The quantity of each ADL execution is: `Q_ADL = min(Q_bankruptcy, Q_counterparty)`
2. The system selects the first eligible Counterparty Position, starting from the highest ADL ranking.
3. The ADL quantity is determined using the formula above, and both the Bankrupt Position and the Counterparty Position are reduced by that quantity.
4. If the Bankrupt Position still has a remaining size, the system selects the next Counterparty Position in the ADL ranking and continues deleveraging.
5. The process repeats until the Bankrupt Position is fully closed.

#### ADL Price and Settlement

1. Under normal circumstances, ADL is executed at the Bankruptcy Price of the Bankrupt Position. This price is determined by the Risk Engine when ADL is triggered and is used for position changes and PnL settlement for that ADL execution.
2. In extreme market conditions or in the event of large-scale bankruptcies, to maintain protocol stability, ADL is executed at a fair price calculated by the Risk Engine at the time of bankruptcy. The Bankrupt Position then enters a pending ADL queue until it is matched with Counterparty Positions.
3. The deleveraged portion of a Counterparty Position is settled based on the actual ADL quantity, and that portion of the position is closed. Any remaining position that has not been deleveraged stays open under the existing contract rules. Funding fees, trading fees and other settlement items are handled in accordance with the protocol's prevailing perpetual contract rules.

#### User Impact and Disclosure

1. For users subject to ADL, the affected position size is forcibly reduced by the system, and unrealized PnL is converted into realized PnL at the Bankruptcy Price. Users do not need to place orders and cannot specify the quantity or price of the reduction during execution. The protocol will disclose the trigger time, contract, ADL quantity, execution price and settlement results in the position history, order history or risk event records.
2. These rules form part of the protocol's risk management rules for perpetual contracts. The protocol may amend these rules based on market risk, product parameters or regulatory requirements. Changes take effect as specified in the relevant announcement.
