# Liquidations

*Updated as part of the unified margin rollout. A Spot Insolvency Deleveraging section has been appended. Perpetual liquidation behavior is unchanged.*

Pacifica employs a three-tiered liquidation process to manage positions that fall below the required maintenance margin. The multi-step approach minimizes market disruption while ensuring that a trader's collateral is used effectively to cover losses.

### Liquidation Price Formula

Liquidation occurs when a user's account equity falls below the maintenance margin of open positions.

Maintenance margin is ½ the initial margin requirement on all markets, defined by `1 / max_leverage` of the market.

```
liquidation_price = [price - (side * position_margin) / position_size] 
                    / (1 - side / max_leverage / 2)
```

`side = 1` for long, `-1` for short. `position_margin` is `account_equity` for cross-margin positions; `price` should be the current `mark_price` if `account_equity` already reflects unrealized PnL.

### Three-tiered liquidation process

1. **Market Liquidation.** When a user's account equity first falls below maintenance margin but remains above the backstop liquidation threshold (⅔ of maintenance margin), all open orders — including ones that would otherwise reduce exposure — are cancelled, and the positions are liquidated by sending market orders into the orderbook.

   During a market liquidation, positions are broken into smaller chunks, each placed as an IOC order as close to backstop liquidation price as possible (to prevent immediate backstop liquidation). The chunking strategy is dynamic and based on market leverage:

   ```
   Small positions (< $2,000 * max_leverage): 1 chunk (immediate)
   Large positions (>= $2,000 * max_leverage): 5 chunks
   ```

   `max(0.75%, maintenance_margin_ratio * 0.4)` of the value of positions liquidated in this manner is deducted by the liquidation engine. Large positions are sent with a small interval between chunks (average under 1 second). If enough of the position is closed to restore maintenance margin levels, the remainder stays with the trader as a partial liquidation.
2. **Backstop Liquidation.** If account equity falls below ⅔ of the maintenance margin, all open positions and remaining collateral are transferred to a Pacifica backstop liquidator. This prevents orderbook disruption during large market movements.
3. **Auto-Deleveraging.** If account equity falls below zero while maintaining an open position — caused by prior tiers having insufficient liquidity — Pacifica closes opposing profitable traders' positions based on risk priority to maintain overall market health.

Due to their experimental or volatile nature, the backstop liquidator does not take positions from the following markets: `URNM, GOLD, SILVER, PAXG, CL, COPPER, NATGAS, EURUSD, USDJPY, NVDA, TSLA, PLTR, SP500, GOOGL, CRCL, HOOD, MEGA, BP`.

### Spot Insolvency Deleveraging

*Added as part of the unified margin rollout.*

Unified margin accounts can hold negative USDC balances backed by spot collateral. A separate deleveraging path unwinds spot positions if an account's debt exceeds its collateral or if the money market is under stress. This is a seperate from perpetual liquidations.

Spot deleveraging runs in two modes:

1. **Account-level.** Triggered when an individual borrower's spot collateral value is no longer sufficient to support the USDC debt and/or any perpetual initial-margin requirement.
2. **Pool-level.** Triggered when money-market `utilization >= 95%`. Deleveraging proceeds from the largest borrowers first and aims to bring utilization back down to 90%.

In both modes, the system begins liquidating spot assets the account's behalf into the spot orderbook to repay USDC loans.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pacifica.gitbook.io/docs/trading-on-pacifica/liquidations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
