> For the complete documentation index, see [llms.txt](https://zion-exchange.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zion-exchange.gitbook.io/docs/trade/margining.md).

# Margining

When opening a position, users can select a **margin mode**:

| Margin Mode     | Description                                                                                                                       |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Cross Margin    | Default mode. Collateral is shared across all cross margin positions for **maximum capital efficiency**.                          |
| Isolated Margin | Collateral is restricted to a single asset. Liquidations in this asset do not affect other isolated or cross positions.           |
| Strict Isolated | Functions like isolated margin but collateral **cannot be removed**. Margin is released proportionally as the position is closed. |

***

#### Initial Margin & Leverage

* Users can choose leverage from **1x up to the asset’s maximum leverage**.

**Formula for Initial Margin:**

```
Initial_Margin = (Position_Size * Mark_Price) / Leverage
```

* **Cross Margin:** Initial margin is **locked** and cannot be withdrawn.
* **Isolated Margin:** Margin can be added or removed after opening the position.
* Unrealized PnL in cross positions can automatically be used as **initial margin for new positions**.
* In isolated positions, unrealized PnL applies **only to the open position**.

**Actions on positions with negative unrealized PnL:**

* Partially or fully close the position
* Add margin (if isolated)
* Deposit USDC (if cross)

***

#### Unrealized PnL & Transferable Margin

* Unrealized PnL can be withdrawn only if **remaining margin ≥ 10% of total position value**.

**Transferable Margin Formula:**

```
Transfer_Margin_Required = max(Initial_Margin_Required, 0.1 * Total_Position_Value)
```

> “Transfer” includes any action that removes margin outside of trading (withdrawals, spot wallet transfers, isolated margin transfers).

***

#### Maintenance Margin & Liquidations

* **Cross Positions:** Liquidated if account value (including unrealized PnL) <

```
Total_Open_Notional * Maintenance_Margin
```

* **Isolated Positions:** Liquidated using the same logic, calculated only with **isolated margin and isolated position notional value**.

| Parameter            | Value / Description                        |
| -------------------- | ------------------------------------------ |
| Maintenance Margin   | Half of initial margin at maximum leverage |
| Cross Liquidation    | Applies to all cross positions             |
| Isolated Liquidation | Applies only to that isolated position     |

***

#### Example: Initial Margin & Leverage

* Asset: BTC
* Mark Price: $10,000
* Position Size: 2 BTC
* Selected Leverage: 10x

**Calculation:**

```
Initial_Margin = (2 * 10,000) / 10
Initial_Margin = 2,000 USDC
```

* Cross margin: $2,000 locked across all cross positions
* Isolated margin: $2,000 allocated only to this BTC position

***

### Example: Unrealized PnL Transfer

* Cross margin position with unrealized PnL: $500
* Total cross margin position value: $10,000

**Minimum remaining margin:**

```
Minimum_Margin = max(Initial_Margin, 0.1 * Total_Position_Value)
Minimum_Margin = max(2000, 1000)
Minimum_Margin = 2,000 USDC
```

> Only $500 of unrealized PnL can be transferred if remaining margin stays above $2,000.
