Skip to main content

Unified Margin Overview

Unified Margin (a.k.a. Portfolio Margin) is an opt-in account mode in which all of a user's open positions share a single margin pool. Offsetting positions (e.g. BTC long + ETH short) reduce the total margin requirement, improving capital efficiency.

A user is in exactly one mode at any time. Switching is explicit and has hard preconditions (see Switch Margin Mode).

Isolated (default)Unified
CollateralPer-positionSingle account-wide pool
Risk metricPer-position margin ratioAccount-level uniMMR
LiquidationPosition-by-positionCross-position waterfall
Best forSimple directional tradesHedged / multi-leg strategies

Key Concepts

uniMMR (Unified Maintenance Margin Ratio)

The single number that describes the health of a unified account:

uniMMR = total_equity / total_maintenance_margin
  • total_equity = wallet_balance + Σ position_collateral + Σ unrealized_pnl − Σ accumulated_fees
  • total_maintenance_margin = Σ MM_per_position

When a position is opened its margin is debited from the wallet balance into the position's collateral, so Σ position_collateral is added back to make equity reflect the user's total funds on the platform — not just the uncommitted cash.

When an account has no open positions uniMMR is null and the account is treated as safe.

Status machine

The backend risk worker evaluates every unified account every 2 s and transitions the account through the following ladder:

RangeStatusSide-effects
uniMMR > 2.00 or no positionsnormal
uniMMR ≤ 2.00warning_1Margin-call WS push
uniMMR ≤ 1.50warning_2Second margin-call
uniMMR ≤ 1.20reduce_onlyAll open orders auto-cancelled; new opening orders rejected
uniMMR ≤ 1.05liquidatingForced liquidation engine fires — one position per tick, starting from the worst-PnL

Status can recover automatically when uniMMR rises back above a threshold (except during an ongoing liquidation tick).

Independently of uniMMR: if any open position's symbol is missing a mark price, the account is forced to reduce_only (risk-conservative gate — trading stays restricted until prices recover). An account already in liquidating is not downgraded by this rule.

Tiered maintenance margin

Maintenance margin is computed per position using a symbol-specific tier table. A tier is a notional range with its own maint_margin_rate and a cumulative deduction that keeps the ladder continuous:

MM_position = notional × maint_margin_rate − cum_amount

The default ladder (applied when a symbol has no explicit tiers):

TierNotional cap (USD)MMRMax leverage
150,0000.40%125×
2250,0000.50%100×
31,000,0001.00%50×
45,000,0002.50%20×
520,000,0005.00%10×
650,000,00010.00%
7100,000,00012.50%
8200,000,00015.00%

Order gate

When a user in unified mode submits a new opening order, the server simulates the post-fill uniMMR. The order is rejected if:

  • Account status is reduce_only or liquidating, OR
  • available_balance − new_initial_margin < 0, OR
  • simulated_uniMMR < 1.10

Reducing / closing orders bypass the check.

Endpoint Map

MethodPathPurpose
POST/api/v1/account/margin-modeSwitch mode
GET/api/v1/unified/accountAccount snapshot
POST/api/v1/unified/risk/simulatePre-trade simulation
GET/api/v1/unified/liquidationsLiquidation history
WSchannel unified_accountLive push
GET/api/v1/admin/margin-tiersList all margin-tier rows
POST/api/v1/admin/margin-tiersUpsert a tier row by (symbol, tier)
DELETE/api/v1/admin/margin-tiersDelete a tier row by (symbol, tier)
POST/api/v1/admin/margin-tiers/reloadHot-reload the in-memory tier store from DB

All user-facing endpoints live under the standard https://api.prex.world host and require the same HMAC-SHA256 / JWT authentication as the rest of the /api/v1/* namespace.

The /admin/margin-tiers endpoints are operator-only and protected by X-API-Key (like the other /api/v1/admin/* routes). They manage the per-symbol maintenance-margin tier table; after editing tiers, call POST /admin/margin-tiers/reload — the new ladder takes effect immediately for all subsequent risk computations, no restart required.