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

# Margin Requirements

> IM = notional × 200 bps (2%), MM = notional × 100 bps (1%) — parameter tables for all margin thresholds, leverage tiers, and liquidation conditions

Pure parameter reference for margin thresholds. For conceptual explanation of the margin model, see [Margin Model](/protocol/margin-model).

## Margin Parameters

| Parameter                 | Config Key        | Default      | Unit         | Onchain          |
| ------------------------- | ----------------- | ------------ | ------------ | ---------------- |
| Initial Margin Factor     | `imFactorBps`     | 200 bps (2%) | Basis points | Stored in Config |
| Maintenance Margin Factor | `mmFactorBps`     | 100 bps (1%) | Basis points | Stored in Config |
| BPS Denominator           | `BPS_DENOMINATOR` | 10,000       | Constant     | Hardcoded        |

## Formulas

```
minIM = notional × imFactorBps / BPS_DENOMINATOR
mmThreshold = notional × mmFactorBps / BPS_DENOMINATOR
equity = lockedMargin + unrealizedPnL
liquidatable = equity < mmThreshold
```

## Invariant

```
imFactorBps > mmFactorBps    (enforced by Config.setMarginConfig())
```

Any attempt to set `mmFactorBps >= imFactorBps` reverts.

## Leverage Tiers

| Margin % | Margin (bps) | Leverage | Buffer to Liquidation | Example: 10,000 USDC Notional   |
| -------- | ------------ | -------- | --------------------- | ------------------------------- |
| 2%       | 200          | 50x      | \~1% adverse move     | 200 USDC margin, 100 USDC MM    |
| 5%       | 500          | 20x      | \~4% adverse move     | 500 USDC margin, 100 USDC MM    |
| 10%      | 1,000        | 10x      | \~9% adverse move     | 1,000 USDC margin, 100 USDC MM  |
| 20%      | 2,000        | 5x       | \~19% adverse move    | 2,000 USDC margin, 100 USDC MM  |
| 50%      | 5,000        | 2x       | \~49% adverse move    | 5,000 USDC margin, 100 USDC MM  |
| 100%     | 10,000       | 1x       | Cannot be liquidated  | 10,000 USDC margin, 100 USDC MM |

## Margin Operation Constraints

| Operation     | Condition                           | Description                            |
| ------------- | ----------------------------------- | -------------------------------------- |
| Open position | `margin >= minIM`                   | Must meet minimum initial margin       |
| Open position | `margin <= notional`                | Cannot exceed notional                 |
| Add margin    | `lockedMargin + amount <= notional` | Total cannot exceed notional           |
| Add margin    | Always allowed                      | Works even when liquidatable (rescue)  |
| Remove margin | `remaining >= minIM`                | Must maintain minimum IM               |
| Remove margin | `equity after > mmThreshold`        | Must not become liquidatable           |
| Remove margin | Position not liquidatable           | Cannot remove from underwater position |

## Liquidation Condition

```
positionEquity < mmThreshold
```

Strict less-than (`<`). A position with equity exactly equal to MM is **not** liquidatable.

## Snapshotted Fields

These values are captured at position open time and never change for that position:

| Field                           | Source | Description                                  |
| ------------------------------- | ------ | -------------------------------------------- |
| `snapshotImBps`                 | Config | IM factor when position was opened           |
| `snapshotMmBps`                 | Config | MM factor when position was opened           |
| `snapshotTradingFeeBps`         | Config | Trading fee when position was opened         |
| `snapshotLiquidationPenaltyBps` | Config | Liquidation penalty when position was opened |
| `snapshotOracleFee`             | Config | Oracle fee when position was opened          |

Admin changes to these parameters only affect positions opened after the change.

## Related Pages

<Columns cols={3}>
  <Card title="Margin Model" icon="shield-halved" href="/protocol/margin-model">
    Conceptual explanation of isolated margin, leverage, and equity.
  </Card>

  <Card title="Liquidation" icon="triangle-exclamation" href="/protocol/liquidation">
    Liquidation mechanics, penalty calculation, and keeper incentives.
  </Card>

  <Card title="Parameter Reference" icon="sliders" href="/protocol/parameter-reference">
    Complete list of all configurable protocol parameters.
  </Card>
</Columns>
