> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dyxy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Liquidations

> When and how positions are liquidated, and how to avoid it.

A liquidation is the forced closure of a position whose losses have used up too much of its margin. It protects the market from positions that can no longer cover their losses.

## When liquidation happens

A position is liquidated when its margin balance falls below the maintenance margin. In practice, this means the **mark price** reaches your **liquidation price**.

**Margin balance = collateral + realized PnL + unrealized PnL**

Liquidation uses the mark price, not the last traded price. The mark price combines prices from several major spot exchanges with funding data, so a single sharp trade or a thin moment in the order book cannot liquidate you on its own.

## What happens during a liquidation

**1. Open orders are cancelled**

All open orders in the affected margin are cancelled to free up margin.

**2. The position is reduced**

The engine closes the position, or part of it, against the market. If the remaining margin is enough after this step, the liquidation stops.

**3. The remainder is closed at the bankruptcy price**

If margin is still insufficient, the rest of the position is taken over by the insurance fund at the bankruptcy price, the price at which your margin reaches zero.

A liquidation fee applies to liquidated positions. Part of it goes to the insurance fund, which covers losses from positions that close below their bankruptcy price.

## Cross versus isolated

* **Isolated position.** Only the margin assigned to that position is lost.
* **Cross positions.** All cross positions share one margin balance. A large loss in one position lowers the liquidation buffer of all of them.

## How to avoid liquidation

> **Use lower leverage**
>
> The further your liquidation price is from the entry, the more volatility you can survive.

> **Set a stop loss**
>
> Close the position on your terms, well before the liquidation price.

> **Add margin**
>
> Adding margin to an isolated position moves its liquidation price further away.

> **Reduce size**
>
> Closing part of a position lowers the maintenance margin required.

> [!NOTE]
>
> Watch the margin ratio in your account panel. Above 80%, the position is close to liquidation.

## Degen mode

[Degen mode](https://docs.dyxy.io/trade/perps/degen-mode.md) positions follow the same principle on their own engine. At leverage up to 1000x, liquidation can occur after a price move of a fraction of a percent, often within seconds.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.