# Liquidation

Liquidation is the automatic closing of a position that can no longer support itself. It exists to stop a losing position from going past the collateral backing it.

## When a position is liquidated

A position is liquidated the moment its **equity** falls to or below the **maintenance margin**:

```
equity            = position margin + unrealized PnL + unrealized funding
maintenance margin = position value × maintenance margin rate
liquidation when:   equity ≤ maintenance margin
```

* **Position value** is measured against the **mark price**, not the last traded price. See [Mark & Oracle Price](/docs/perps/mechanics/mark-and-oracle).
* **Unrealized funding** is funding your position has accrued but not yet had banked into its margin. It counts toward equity just like unrealized PnL, so it affects your liquidation buffer even before it is realized. See [Funding](/docs/perps/mechanics/funding).
* Maintenance margin is a per-market setting (**2.5% of position value** on BTC-PERP-EL, **3.0%** on US500-PERP-EL), so it moves as the price moves.

The gap between your equity and the maintenance margin is your buffer. Higher leverage means a thinner buffer and a closer liquidation price. See [Margin & Leverage](/docs/perps/trading/margin-and-leverage).

## The bankruptcy price

Liquidation closes the position at its **bankruptcy price**: the price at which the remaining margin is exactly used up by the loss plus the liquidation fee. The fee is built into this price, so the closing always covers it.

## Liquidation fee

A **0.5% fee on position value** (a platform-wide setting on Elysia Perps) is taken from the position's remaining margin at liquidation. It is the only fee unique to liquidation (a normal close never incurs it), and it funds the insurance backstop described in **Risk & Security**.

## How a liquidation is carried out

![Three-stage liquidation cascade: order book first, then insurance fund, then auto-deleveraging as a last resort](/docs/perps/images/liquidation-cascade.png)

Liquidation runs through a **three-stage cascade**, stopping as soon as a stage succeeds:

1. **Order book**: the position is offered to the open market at the bankruptcy price.
2. **Insurance fund**: if the market can't absorb it, the insurance fund takes the position over at the bankruptcy price.
3. **Auto-deleveraging (ADL)**: as a last resort, the position is matched directly against traders holding the opposite side.

Stages 2 and 3, the insurance fund, and what ADL means for you are covered in [Liquidation Risk](/docs/perps/risk-and-security/liquidation-risk).

## Where to go next

* How to keep a safe buffer: [Margin & Leverage](/docs/perps/trading/margin-and-leverage).
* The insurance fund and ADL in depth: [Liquidation Risk](/docs/perps/risk-and-security/liquidation-risk).
