Skip to main content
This page is the mathematical backbone of Phoenix risk docs. The implementation sources for these formulas are:
  • the exchange risk view
  • Phoenix state margin utilities
  • the internal risk primer for the perp exchange design

System invariants

At a high level, the exchange is trying to preserve three things:
  • long and short open interest must balance
  • unrealized profits must be matched by liabilities elsewhere in the system
  • liabilities must remain collateralized

Effective collateral

Phoenix risk checks compare margin requirements against effective collateral, not just deposited collateral by itself. effective_collateral = deposited_collateral + discounted_unrealized_pnl + unsettled_funding Important details:
  • deposited collateral is the actual collateral balance on the trader account
  • positive unrealized PnL can be discounted by a market risk factor
  • negative unrealized PnL counts in full
  • unsettled funding is included before final settlement because it still changes risk

Unrealized PnL

For an open position: unrealized_pnl = position_size * (mark_price - entry_price) with signed size:
  • positive size for longs
  • negative size for shorts

Discounted unrealized PnL

Phoenix discounts positive uPnL for risk purposes.
  • positive uPnL: multiplied by the market’s uPnL risk factor
  • negative uPnL: no discount, full loss counts
This protects the system from giving full collateral credit to paper gains that depend on the current mark price. The discount is especially important for lower-liquidity assets, where mark prices can be easier to move or temporarily distorted. By discounting positive uPnL, Phoenix reduces the risk that a trader can use manipulated or unstable mark prices as collateral.

Initial margin

Initial margin is driven by leverage tiers. Conceptually: initial_margin = position_notional / max_leverage_for_that_size Phoenix uses tiered leverage that decreases as position size grows. The tier lookup is continuous enough that the docs should be read as “size-dependent leverage” rather than “one fixed leverage number forever.”

Maintenance margin and other thresholds

Phoenix derives its risk thresholds from initial margin using market-specific risk factors. See Market Parameters for current market-specific risk factors and leverage tiers. cancel_margin = initial_margin * cancel_order_risk_factor maintenance_margin = initial_margin * maintenance_risk_factor backstop_requirement = initial_margin * backstop_risk_factor high_risk_margin = initial_margin * high_risk_factor The main threshold for liquidation is maintenance margin. If effective collateral falls below maintenance margin, the account can be liquidated. The broader risk sequence is:
  • below cancel margin: risk-increasing limit orders can be cancelled
  • below maintenance margin: market liquidation can begin
  • below backstop requirement: distressed positions can be transferred to a backstop account
  • below high-risk margin: ADL can become available

Account health and risk score

A practical health score used across Phoenix state tooling is:
  • if maintenance_margin == 0, score is 0
  • if effective_collateral > 0, score is approximately (maintenance_margin / effective_collateral) * 1000
  • if effective_collateral <= 0, score becomes 1000 + underwater_penalty
Interpretation:
  • lower is healthier
  • near 1000 means the account is close to or through the liquidation boundary

Liquidation estimate for one position

The Phoenix state utilities solve liquidation price with the maintenance-ratio model: collateral + other_upnl + q * (P - entry) = other_mm + |q| * (maintenance / leverage) * P Where:
  • q is signed position size
  • P is the liquidation price being solved for
  • other_upnl is the portfolio contribution from other markets in the same account
  • other_mm is the maintenance margin from other markets in the same account
This is why cross-margin liquidation prices move when your other positions move, even if the market you are looking at has not changed much.