Margin System
The margin system governs how perpetual positions are collateralized and when they become eligible for liquidation.
Margin modes
- Cross — the collateral held in the perp account jointly backs all cross positions. Profit on one position can cover loss on another.
- Isolated — each position locks its own margin. Loss is capped at the isolated margin; risk does not spill over to other positions.
Position modes
- One-Way — a single net position per instrument.
- Hedge — long and short positions in the same instrument can be held simultaneously.
Tiered margin
The maintenance margin rate (MMR) and maximum leverage are tiered by position size. Each instrument publishes its own tier table. Larger positions sit in a higher tier: higher MMR, lower max leverage.
| Field | Meaning |
|---|---|
| Tier | tier index, ordered by position size |
| Max leverage | maximum leverage allowed in this tier |
| Maintenance margin rate | maintenance margin rate (MMR) for this tier |
Core formulas
initial margin = size × mark price / leverage
maintenance margin = size × mark price × MMR
liquidation fee = size × mark price × taker fee rate
balance = available balance + balance frozen by open ordersThe margin ratio is evaluated at two levels. The account-level ratio governs cross liquidation; the position-level ratio governs isolated liquidation:
cross margin ratio = (balance + cross unrealized PnL)
─────────────────────────────────────────────
(cross maintenance margin + cross liquidation fee)
isolated margin ratio = (position margin + unrealized PnL)
─────────────────────────────────────
(maintenance margin + liquidation fee)Liquidation begins when the relevant ratio drops strictly below 1.0. The full procedure is described in Risk Engine.
Note that the cross numerator is balance plus cross unrealized PnL, not the account's full equity — equity also includes isolated margin and isolated unrealized PnL, and those do not back the cross check.
The estimated liquidation price and bankruptcy price both account for the fee charged to close the position. For an isolated long:
liquidation price = (position margin − size × entry price)
──────────────────────────────────────
(size × (MMR + fee rate − 1))
bankruptcy price = (position margin − size × entry price)
──────────────────────────────────────
(size × (fee rate − 1))For shorts, the sign of size × entry price flips and the denominators become size × (MMR + fee rate + 1) and size × (fee rate + 1). In cross mode, account balance replaces position margin; when several cross positions are open, bankruptcy prices are solved jointly rather than one position at a time — use the Info API calculators for those cases.
Deterministic margin
Margin is computed against immutable snapshots of the oracle and margin metadata. The calculator is therefore a pure function of position, price snapshot, and margin config — the same inputs always produce the same result on every node.