> For the complete documentation index, see [llms.txt](https://docs.afx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afx.xyz/trading-rules/liquidation-process.md).

# Liquidation Process

AFX uses a multi-phase liquidation process to handle under-margined positions in an orderly manner, minimizing market impact and protecting other users.

## Phase 1: Trigger and Pre-Processing

When the Risk Engine detects that a position's margin ratio has reached 100%:

1. The account is flagged as "in liquidation."
2. All open orders in the **same direction** as the endangered position are cancelled. If cancelling these orders brings the margin ratio back below 95%, the liquidation stops.
3. If the margin ratio is still above the safe threshold after cancellation, the system proceeds to forcibly close the position.

**Tiered Liquidation:** For positions with a notional value exceeding 100,000 USDC, the system liquidates in steps — closing 20% of the position at a time, with a 30-second cooldown between each step. If the margin ratio recovers to the safe level after any step, the liquidation process stops.

The position is closed at market price. Any remaining margin after closing is returned to the user's account.

## Phase 2: Vault Takeover

If the liquidated position cannot be immediately closed in the market (e.g., due to insufficient liquidity), the **LP Vault** takes over the position.

1. The Vault calculates the notional value of the position using the Mark Price.
2. The positions taken over cannot exceed the Vault's limit; otherwise, ADL will be triggered directly.
3. The Vault collects a **liquidation fee** of 0.5% of the remaining maintenance margin from the liquidated position.

## Phase 3: Market Matching

1. The Vault's liquidation orders enter the matching engine.
2. Other market participants (market makers, regular traders) can take the other side of these orders.
3. Once filled, the Vault recovers the position margin and any remaining balance.

## Phase 4: ADL (if Vault is Overwhelmed)

If the Vault cannot fully close the position at a reasonable price (market depth is insufficient) or the Vault's balance becomes negative, the system triggers Auto-Deleveraging. See [ADL](/trading-rules/adl.md) for details.

## Fund Flow Summary

| Participant           | Outcome                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------ |
| Liquidated user       | Position closed; remaining margin (minus liquidation fee) returned. If fully depleted, balance goes to zero. |
| LP Vault              | Receives liquidation fee. Assumes temporary position risk during takeover.                                   |
| Market counterparties | Can fill liquidation orders at a discount.                                                                   |
| ADL targets           | Positions partially or fully reduced at the Vault's liquidation price (only in extreme cases).               |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.afx.xyz/trading-rules/liquidation-process.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.
