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

# Liquidations

Liquidation is what happens when an account no longer has enough margin to support its open risk.

Notional currently supports cross margin and portfolio margin, so eligible collateral, unrealized PnL, open positions,
and open orders are evaluated together. A profitable position can help support a losing one, but a
large loss can also put the whole account at risk.

## Overview

Notional monitors account health with the cross-margin ratio:

$$
\text{Cross margin ratio} = \frac{\text{MMR}}{\text{Total margin value}}
$$

Lower is healthier. Liquidation can start when total margin value falls below maintenance margin,
which is the same as a ratio above 1.0.

Maintenance margin is calculated from each open perp position's mark-price notional:

$$
\text{MMR}_j = \frac{|\text{size}_j| \cdot \text{mark price}_j}{2 \cdot \text{max leverage}_j}
$$

The account's total maintenance margin is the sum across open positions. Total margin value includes
haircut-adjusted collateral value, unrealized PnL, and realized USDC liabilities.

| Cross-margin ratio | Trader expectation                                                       |
| -----------------: | ------------------------------------------------------------------------ |
|         Below 0.90 | Healthy after any liquidation action.                                    |
|  0.90 to below 1.0 | Close to liquidation. Reduce risk or add collateral.                     |
|   1.0 to below 1.5 | Partial liquidation can begin.                                           |
|      1.5 or higher | Account is deeply under maintenance margin and will be fully liquidated. |

## What Happens During Liquidation

The account is frozen during liquidation. User orders and withdrawals are blocked, but system
liquidation orders can still execute. Active TWAPs are canceled so new suborders do not continue while
the account is frozen.

## Partial Liquidations

Notional uses partial liquidation when the account is below maintenance but not deeply underwater.
Partial liquidation tries to restore the account above the liquidation threshold while preserving as
much value as possible.

| Step               | What the trader sees                                                                                     |
| ------------------ | -------------------------------------------------------------------------------------------------------- |
| Cancel open orders | Position-increasing orders are canceled first. If this restores health, liquidation stops.               |
| Close positions    | If the account is still unsafe, positions are closed one at a time with health checks after each action. |

Partial liquidation exits once the account is healthier than the liquidation line. The current exit
target is a cross-margin ratio below 0.90.

Notional's partial liquidation is account-level. It is not Hyperliquid's large-position rule where a
fixed percentage of a single oversized position is sent to the book. Today, Notional starts with the
largest maintenance-margin position and closes positions sequentially until the account is healthy or
needs escalation.

## Full Liquidation

If the account reaches the full-liquidation threshold, or partial liquidation cannot restore health,
Notional fully liquidates the account. Full liquidation cancels active orders, closes all positions,
and sells non-USDC collateral until liabilities are covered or no recoverable account value remains.

Full liquidation uses gradual execution to reduce market impact:

| Phase      | Behavior                                                                                          |
| ---------- | ------------------------------------------------------------------------------------------------- |
| Normal     | Sends 10% clips every 6 seconds, starting at 10 bps slippage and increasing up to 50 bps.         |
| Aggressive | If the normal phase cannot finish, sends the remaining size with wider slippage for a short time. |

Collateral sales are only automatic for collateral that has an executable Hyperliquid spot pair
against USDC. If an unsupported collateral asset cannot be sold automatically, liquidation continues
for the remaining positions and collateral, and operators must reconcile the retained asset.

## Computing Liquidation Price

Liquidation prices are estimates. In cross margin, the true trigger can move because the whole
account contributes to margin health.

For one cross-margin position, Notional solves for that position's mark price at which account
health reaches the liquidation threshold:

$$
\text{total margin value at that mark price} = \text{maintenance margin at that mark price}
$$

The shared solver uses:

$$
\text{liq price} =
\frac{\text{other MMR} - \text{total margin value} + \text{size} \cdot \text{mark price}}
{\text{size} - |\text{size}| \cdot \text{maintenance rate}}
$$

where:

$$
\text{maintenance rate} = \frac{1}{2 \cdot \text{max leverage}}
$$

`size` is positive for a long and negative for a short. `other MMR` is the maintenance margin from
the rest of the account. `total margin value` already includes unrealized PnL at the current mark
price.

The estimate can change after the position is opened because funding, realized losses, collateral
prices, other positions, and open orders all change account health. Cross-margin liquidation price is
not determined only by the leverage selected for one position.

## What Moves Liquidation Risk

Your liquidation risk can change even if you do not place a new order.

| Change                                             | Effect                                                |
| -------------------------------------------------- | ----------------------------------------------------- |
| Mark price moves against your positions            | Unrealized losses reduce total margin value.          |
| Collateral falls in value                          | Haircut-adjusted account value falls.                 |
| Open orders increase maintenance requirements      | Resting orders can consume margin before they fill.   |
| Funding, fees, interest, or realized losses accrue | Realized USDC liabilities reduce account health.      |
| You withdraw collateral                            | Less account value is available to support positions. |

Perp margin and liquidation calculations use mark prices. Your liquidation price can therefore move
as mark prices, funding, collateral values, open orders, and other positions change.

Notional uses fresh Hyperliquid mark prices first for perp margin and liquidation. If a fresh mark is
unavailable, the backend can use configured fallback sources. Spot collateral uses a separate
collateral-risk price path. Missing or stale collateral prices can block liquidation until pricing is
ready, because liquidating against bad collateral data is worse than waiting.
