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

# Liquidation

{% hint style="info" %}
All calculations are located in our [Perps Metrics guide](/trading/perpetuals/perps-metrics-guide.md). Try our [Risk Engine Simulator](https://rails.xyz/demos) to further understand how Margin & Liquidation work on Rails.
{% endhint %}

Liquidation is triggered when an account (in cross-margin mode) or position (in isolated margin mode) can no longer meet the minimum margin requirement. Rails evaluates liquidation using the mark price. Mark-price movements change unrealized P\&L, equity, and margin health. Liquidation works differently in each margin mode. Explore all concepts below:

<table data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><strong>Isolated Margin Liquidation</strong></td><td><a href="/pages/6gsaeh5xe1xgf3xAwgrk#isolated-margin-liquidation">/pages/6gsaeh5xe1xgf3xAwgrk#isolated-margin-liquidation</a></td></tr><tr><td align="center"><strong>Cross-Margin Liquidation</strong></td><td><a href="/pages/6gsaeh5xe1xgf3xAwgrk#cross-margin-liquidation">/pages/6gsaeh5xe1xgf3xAwgrk#cross-margin-liquidation</a></td></tr><tr><td align="center"><strong>Avoiding Liquidation</strong></td><td><a href="/pages/6gsaeh5xe1xgf3xAwgrk#avoiding-liquidation">/pages/6gsaeh5xe1xgf3xAwgrk#avoiding-liquidation</a></td></tr></tbody></table>

{% hint style="info" %}
Liquidation fees may apply; see [Pricing & Fees](/trading/perpetuals/pricing-and-fees.md) for more information.
{% endhint %}

## Isolated Margin Liquidation <a href="#isolated-margin-liquidation" id="isolated-margin-liquidation"></a>

Isolated margin liquidation occurs when your [isolated position equity](/trading/perpetuals/perps-metrics-guide.md#isolated-position-equity) falls below the [minimum maintenance margin](/trading/perpetuals/perps-metrics-guide.md#maintenance-margin) required to support your position. At that point:

1. The affected isolated position is immediately closed.
2. Any remaining margin after covering losses is returned to your cross-margin balance.

{% hint style="success" %}
**All other positions are unaffected**, including other cross-margin and isolated margin positions.
{% endhint %}

<details>

<summary>Isolated Margin Liquidation Price Note</summary>

In isolated margin, the [liquidation price](/trading/perpetuals/perps-metrics-guide.md#liquidation-price) shown is more predictable because isolated position equity is self-contained. It can still change if you [add or remove margin](/trading/perpetuals/margin-modes.md#adjusting-isolated-position-margin) from the position.

</details>

## Cross-Margin Liquidation <a href="#cross-margin-liquidation" id="cross-margin-liquidation"></a>

Cross-margin liquidation is triggered when your cross-margin ratio reaches 100%. Rails also uses Proactive Order Cancellation and Partial Liquidation to limit worsening outcomes and protect your capital:

<table><thead><tr><th width="161.618896484375">Liquidation Stage</th><th width="187.55194091796875">Cross-Margin Ratio</th><th>Account Status</th></tr></thead><tbody><tr><td>Healthy</td><td>&#x3C; 90%</td><td>All orders remain active</td></tr><tr><td>Approaching liquidation</td><td>≥ 90% (simulated)</td><td><a href="#proactive-order-cancellation">Proactive Order Cancellation</a> is triggered</td></tr><tr><td>Liquidation Triggered</td><td>≥ 100%</td><td><p>Full Liquidation is triggered for small positions;</p><p><a href="#partial-liquidation">Partial Liquidation</a> triggered for large positions</p></td></tr></tbody></table>

<details>

<summary>Cross-Margin Liquidation Price Note</summary>

In **cross-margin** mode, the [liquidation price](/trading/perpetuals/perps-metrics-guide.md#liquidation-price) shown for any individual position is an **estimate** and will change dynamically because:

* Opening, closing, or modifying **any** cross-margin position affects [Total Cross Maintenance Margin](/trading/perpetuals/perps-metrics-guide.md#total-maintenance-margin).
* Mark-price movements of **any** held asset affect unrealized P\&L and therefore [Cross-Margin Equity](/trading/perpetuals/perps-metrics-guide.md#cross-margin-equity).
* [**Funding rate payments**](/trading/perpetuals/funding.md) accrue to or from your balance over time.
* Changes to **isolated positions** (e.g. adding margin or partial closes) affect your [Cross-Margin Balance](/trading/perpetuals/perps-metrics-guide.md#cross-margin-balance).

</details>

### Proactive Order Cancellation <a href="#proactive-order-cancellation" id="proactive-order-cancellation"></a>

To reduce the risk of immediate liquidation after an order fills, Rails uses a safety feature called **Proactive Order Cancellation** when your [Simulated Cross-Margin Ratio](/trading/perpetuals/perps-metrics-guide.md#simulated-cross-margin-ratio) reaches 90%**.** By canceling any orders that would increase your position size, Rails *<mark style="color:$info;">protects your account</mark> from the risk of immediate post-fill liquidation*.

* Orders that fully offset or reduce an existing position, including reduce-only orders, are not canceled by this mechanism.
* If you have multiple open orders to offset an open position, and their total quantity exceeds that of your open position, only the excess quantity is included in the order cancellation process.
* Open orders on isolated margin positions that increase exposure are included, as that margin would be moved from the cross-margin balance into isolated position margin upon order execution, and may trigger liquidation.

{% hint style="success" %}
Proactively canceled orders remain visible in the [Canceled Orders tab](/manage-account/portfolio-statements-and-exports/portfolio-dashboard.md#canceled-orders-tab) in your Portfolio Dashboard for 7 days after cancellation.
{% endhint %}

### Partial Liquidation

Once your cross-margin ratio reaches 100%, liquidation is triggered. Closing a large position with one market order can push execution into worse prices as the order moves through the order book. At Rails, large position thresholds are used to trigger liquidations in 20% increments to reduce the impact of [slippage](/support/troubleshooting-guide.md#what-is-slippage-and-why-does-it-happen).

Partial liquidation lowers the total maintenance margin required because the position becomes smaller. It does not change the maintenance margin rate, which stays fixed at 5%.

**Cross-Margin Liquidation Process:**

1. The liquidation engine starts closing each cross-margin position below the [partial liquidation thresholds](#large-position-thresholds) at the best available market price.
2. For positions above the partial liquidation thresholds, the engine closes **20% of the position**.
3. After each step, the system re-calculates your cross-margin ratio.
4. If your cross-margin ratio drops below 100%, liquidation stops and the rest of the position stays open.
5. If your cross-margin ratio stays at 100% or higher, the engine closes another 20%.
6. After each partial close, the engine waits a short time — currently **30 seconds** — before taking the next step. This gives the order book time to recover.
7. If your account enters liquidation again during that window, the market is moving too quickly for staged liquidation to help. In that case, the engine **immediately closes the rest of the position** instead of continuing in 20% steps.
8. Any remaining funds after covering losses are returned to your balance.

{% hint style="info" %}
**Isolated positions are always liquidated in full.** An isolated position uses its own dedicated margin. Closing part of it does not improve the margin health of the remaining positions.
{% endhint %}

#### **Large Position Thresholds**

The large-position threshold is set **per market** because order book depth differs across markets. More liquid markets such as BTC can support a higher threshold than thinner markets.

{% columns %}
{% column width="33.33333333333333%" %}
All markets use the default large-position threshold unless individually stated.

Thresholds are calibrated against live order book depth and may be adjusted over time.
{% endcolumn %}

{% column width="66.66666666666667%" %}

<table><thead><tr><th width="199.5859375">Market</th><th width="206.98828125">Large Position Threshold</th></tr></thead><tbody><tr><td>Default</td><td>25,000 USDT</td></tr><tr><td>BTC</td><td>37,500 USDT</td></tr></tbody></table>
{% endcolumn %}
{% endcolumns %}

## Avoiding Liquidation

Use the guidance below to help reduce liquidation risk in each margin mode.

{% tabs %}
{% tab title="Isolated Margin Mode" %}
To reduce liquidation risk in isolated margin mode:

* add margin to increase isolated position equity.
* reduce position size to lower the position’s maintenance margin requirement.
* set a stop-loss trigger order to close the position before liquidation.
  {% endtab %}

{% tab title="Cross-Margin Mode" %}
To reduce liquidation risk in cross-margin mode:

* deposit funds to increase your Total Balance and cross-margin equity.
* reduce position size to lower your Total Maintenance Margin.
* switch a position to isolated margin to free up cross-margin collateral.
* set a stop-loss trigger order to close positions automatically if the market moves against you.
  {% endtab %}
  {% endtabs %}
