> For the complete documentation index, see [llms.txt](https://docs.txflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txflow.com/perp/liquidations.md).

# Liquidations

This article explains how liquidation works on TxFlow perpetuals: when it is triggered, what the system does to your positions and open orders, how the fill price is determined, and what you can do to avoid it.

### What Is Liquidation

When the margin in your account is no longer enough to support the risk of your open positions, the system automatically reduces or closes them for you. This process is called liquidation (also known as a forced close-out or getting liquidated). Its purpose is to close out your risk exposure before losses grow further, and to keep your account from going negative.

Liquidation is executed entirely by the system. Risk management therefore has to happen before the trigger.**All liquidation checks are based on the mark price, not the last traded price.** The mark price is a smoothed reference price, which prevents momentary wicks from causing a false trigger.

### When Liquidation Is Triggered

In one sentence: **liquidation triggers when your equity is no longer enough to cover "maintenance margin + liquidation fee"**.

Note that the threshold includes more than just maintenance margin — it also includes a liquidation fee (= position size \* mark price \* taker fee rate). The system reserves the fee it would cost to close the position, so the actual trigger point is slightly earlier than "equity < maintenance margin".

<table data-header-hidden><thead><tr><th width="148.171875"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Margin Mode</strong></td><td><strong>Evaluation Level</strong></td><td><strong>Trigger Condition</strong></td><td><strong>What Happens When Triggered</strong></td></tr><tr><td>Cross</td><td>Account level — all cross positions evaluated together</td><td>Account cross equity &#x3C; total cross maintenance margin + total cross liquidation fees</td><td>A single evaluation; every cross position in the account enters the liquidation queue at the same time</td></tr><tr><td>Isolated</td><td>Position level — each position evaluated independently</td><td>That position's margin + that position's unrealized PnL &#x3C; that position's maintenance margin + that position's liquidation fee</td><td>Only this one position is liquidated; other positions and your cross funds are unaffected</td></tr></tbody></table>

**Two things that are most often misunderstood:**

* **Cross margin is "one evaluation, everything queued".** The system does not compare position by position; it runs the calculation once at the account level. As soon as the account falls short, every cross position you hold enters the liquidation process at the same moment — even the ones that are currently in profit.
* **Isolated margin cannot rescue your cross account.** The cross evaluation only looks at your cross available balance and the unrealized PnL of your cross positions; margin you have moved into an isolated position does not count on the cross side — and vice versa. The two margin pools are isolated from each other.

### Partial Deleveraging vs. Full Liquidation

The system does not always close the whole position at once. It first looks at the margin tier the position currently sits in, then decides which path to take:

<table data-header-hidden><thead><tr><th width="217.45703125"></th><th width="264.80078125"></th><th></th></tr></thead><tbody><tr><td><strong>Current Tier</strong></td><td><strong>Handling</strong></td><td><strong>Notes</strong></td></tr><tr><td>Tier >= 3</td><td>Partial deleveraging (tier step-down)</td><td>Reduced only down to the size boundary of the previous tier; you keep the remaining position</td></tr><tr><td>Tier &#x3C; 3 (tiers 1 and 2)</td><td>Full liquidation</td><td>The entire position is closed</td></tr><tr><td>No tier information available</td><td>Full liquidation</td><td>Fallback handling; should not occur under normal conditions</td></tr></tbody></table>

#### How partial deleveraging is calculated

The higher the tier, the higher the required maintenance margin rate and the lower the allowed leverage. So **bringing the position down into a lower tier by itself reduces the maintenance margin requirement**, which pulls the account back into the safe zone — a better outcome for you than closing the position outright.

**Reduction size = current total position size - target size boundary of the previous tier**If the resulting reduction size is not positive, or the position is already in the lowest tier it can step down to (there is no lower tier available), the system falls back to full liquidation.<br>

### Your Fill Price Is the Bankruptcy Price

When a liquidation fills, the price you see is not the order-book price at that moment — it is the **bankruptcy price**.

**What the bankruptcy price means:** at this price, the loss on the position exactly consumes all of the margin backing it (the closing fee is already accounted for), and the balance left after the position is settled is zero.&#x20;

**"My liquidation price was well off the candle at that moment" is usually not a matching problem.** The estimated liquidation price is the **trigger point**, while the bankruptcy price is the price at which the maintenance margin has also been consumed. The gap between the two is, by construction, the size of the maintenance margin.

**How full liquidation and partial deleveraging differ on this point:**

* **Full liquidation:** the entire position is settled at the bankruptcy price, and all of the margin backing that position is consumed — none of it is returned.
* **Partial deleveraging:** only the portion that is reduced is settled at the bankruptcy price. The remaining position and the share of margin backing it stay in place, and you still hold the position.

### What Happens to Your Open Orders During Liquidation

**Full liquidation cancels more of your orders; partial deleveraging tries to keep your reduce-only orders** (orders that can only reduce a position, never open one).

| **Scenario**                             | **Orders That Are Cancelled**                                                                                                                           | **Orders That Are Kept**                                                                                              |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Full liquidation - Cross margin          | Every perpetual order in the account, including reduce-only orders, and including orders on other contracts as well as isolated-margin perpetual orders | Spot orders, prediction-market orders                                                                                 |
| Full liquidation - Isolated, One-Way     | All isolated-margin orders on that contract, including reduce-only orders                                                                               | Orders on other contracts, cross-margin orders, spot and prediction-market orders                                     |
| Full liquidation - Isolated, Hedge       | Isolated-margin orders on that contract in the same direction as the liquidated position, including reduce-only orders                                  | All orders in the opposite direction, plus orders on other contracts / cross-margin / spot / prediction-market orders |
| Partial deleveraging - Cross margin      | All non-reduce-only perpetual orders in the account                                                                                                     | All reduce-only orders, spot and prediction-market orders                                                             |
| Partial deleveraging - Isolated, One-Way | Non-reduce-only orders on that contract                                                                                                                 | Reduce-only orders on that contract, orders on other contracts                                                        |
| Partial deleveraging - Isolated, Hedge   | Position-opening orders on that contract in the same direction as the liquidated position                                                               | Reduce-only orders in the same direction, all orders in the opposite direction, orders on other contracts             |

**One point to watch closely:** during a full liquidation the cancellation scope is **every perpetual order in the account** — not limited to the single contract being liquidated, and not limited to cross-margin orders. If you have orders resting on other contracts at the same time, they will be cancelled along with the rest. **Spot and prediction-market orders are unaffected.**

In addition, before a partial deleveraging is executed the system checks your reduce-only orders: once the position has been reduced, if the total quantity of your reduce-only orders exceeds the position size still available to reduce, the excess is automatically resized or cancelled. This prevents reduce-only orders from opening a new position in the opposite direction.

### Auto-Deleveraging (ADL)

ADL (Auto-Deleveraging) is the last backstop in the liquidation process. It does not go through the order book; instead it offsets the position awaiting liquidation directly against opposite-side positions held by counterparties.

#### When does the process reach ADL

**ADL does not happen on every liquidation.** It is only triggered when one of the following three situations occurs:

1. **No backstop liquidator is available.** The position remains under your account, and the process skips both takeover and market disposal, going straight to ADL.
2. **Takeover fails.** For example, the position was already closed by another operation within the same block, so takeover cannot find it; market disposal is skipped and the process goes straight to ADL.
3. **Market disposal does not fill in full.** When the market cannot absorb the entire quantity at that moment, the remaining unfilled portion goes to ADL.

**If market disposal fills in full, the process ends there and no ADL occurs.** The vast majority of liquidations fall into this category.<br>

#### Who gets selected as an ADL counterparty

The system selects opposite-side positions following a fixed, reproducible priority order:

1. **Ordinary user positions are selected first.** Platform market-maker accounts and protocol vault positions are ranked last, so that they are touched as little as possible.
2. **Within the same account category, positions are ranked by a combined "unrealized profit x leverage" score,** so the more profitable and the more leveraged a position is, the higher it ranks.
3. **Exact ties are broken by account address in ascending order,** guaranteeing that the selection result is unique and reproducible.
4. **Allocation then runs down this order** until the quantity that needs to be reduced is covered — never more than that.

In other words, **high-leverage, high-unrealized-profit opposite-side positions are the most likely to be picked for ADL**. This is standard industry practice — positions like these are themselves the main source of system risk.<br>

### How to Reduce Your Chance of Being Liquidated

1. **Watch your margin ratio / margin level.** Do not wait until you are close to the threshold to act. Once liquidation starts it cannot be interrupted.
2. **Set stop-loss orders in advance, and mind where the trigger price sits.** The stop trigger price has to be set inside the estimated liquidation price; otherwise liquidation happens first and the stop-loss order never gets a chance to trigger — a very common outcome at high leverage.
3. **Stop-loss orders also trigger on the mark price.** There can be a spread between the mark price and the last traded price, so your stop may trigger even when the candles look like they never touched the trigger level.
4. **Reduce leverage or position size proactively.** Stepping down from a higher tier to a lower one directly reduces your maintenance margin requirement — a more direct effect than adding margin.
5. **Use isolated margin when you need to compartmentalize risk.** Under cross margin, the loss on one position consumes the cross funds of the whole account, and when the trigger fires every cross position is liquidated together.
6. **Adding margin must be done before the trigger.** Adding margin during liquidation cannot stop it.
