- 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
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 is0 - if
effective_collateral > 0, score is approximately(maintenance_margin / effective_collateral) * 1000 - if
effective_collateral <= 0, score becomes1000 + underwater_penalty
- lower is healthier
- near
1000means 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:
qis signed position sizePis the liquidation price being solved forother_upnlis the portfolio contribution from other markets in the same accountother_mmis the maintenance margin from other markets in the same account