# ADL

### Execution Process

The execution follows a hybrid off-chain calculation and on-chain execution model:

1. Ranking (Off-Chain): Profitable positions are ranked based on factors such as profitability, leverage, and position size.&#x20;
2. Selection: The top-ranked positions are selected to cover the specific amount of bad debt (e.g., 2, 3, or 4 positions).
3. Execution (On-Chain): The bad debt position is closed against the selected counterparties.
   * Zero PnL Impact: The closure occurs at the counterparty's average entry price, ensuring the counterparty realizes 0 PnL on the trade.
   * Collateral: The bad debt position's collateral is distributed to the counterparties.

### Verifiability&#x20;

While ADL execution is permissioned and depends on decided offchain factors, being fully onchain allows for the ADL result to remain fully verifiable.&#x20;

#### Post-Execution Verification:

* All position data exists on-chain at the time of ADL.
* Anyone can reconstruct the position rankings as they existed at the moment of ADL.
* The community can verify that the admin selected the appropriate positions according to the published ranking criteria.
* Transparency: Index prices, position states, and all relevant data are immutably recorded on-chain.
* Accountability: While users cannot prevent ADL in real-time, any deviation from the published ranking algorithm is provably detectable after the fact. The community can reconstruct rankings and challenge improper executions.<br>

### Technical Implementation

The ADL ranking algorithm considers multiple factors:

* Profitability: Higher unrealized PnL increases ranking.
* Leverage: Higher effective leverage increases ranking.
* Position Size: Larger positions may be weighted in ranking.

For Profitable Positions: $$\text{ADL Ranking} = \text{PNL%} \times \text{Effective Leverage}$$

For Losing Positions: $$\text{ADL Ranking} = \frac{\text{PNL%}}{\text{Effective Leverage}}$$

Where: $$\text{PNL%} = \frac{\text{Unrealized PnL}}{|\text{Position Size} \times \text{Mark Price}|}$$

$$\text{Effective Leverage} = \frac{1}{\text{Position Margin Ratio}}$$

#### Socialized Losses Threshold Configuration

The bad debt thresholds that determine when to use socialized losses vs. ADL are configurable.

```
If bad_debt > max(M, open_interest × mark_price x α):
    Trigger ADL
Else:
    Use Socialized Losses
```

#### Verification Process

To verify ADL execution was proper:

* Query on-chain state at the block height of ADL execution.
* Reconstruct all position states (size, entry price, unrealized PnL, leverage).
* Apply the documented ranking algorithm.
* Compare the positions selected for ADL against the reconstructed ranking.
* Confirm the selected positions match the top-ranked positions for the required bad debt coverage.
