Risk invariants
Phoenix margin is built around three practical invariants:- long and short open interest must balance
- unrealized profits must be matched by liabilities elsewhere in the system
- those liabilities must remain collateralized
Effective collateral
Effective collateral is the collateral value Phoenix uses for risk checks. It is similar to account equity, but Phoenix can discount positive unrealized PnL before treating it as usable collateral. Important details:- deposited collateral is the USDC collateral balance on the trader account
- positive unrealized PnL can be discounted by the market’s
uPnL risk factor - negative unrealized PnL counts in full
- unsettled funding is included because it changes account risk before final settlement
uPnL risk factor values.
Mark price and PnL
Position value is based on mark price, not the last trade price. Using mark price for PnL, margin, and liquidation checks helps prevent a single trade or thin order book from pushing accounts into unsafe states. See Mark Price for how Phoenix builds the mark.Position margin
For each market, Phoenix calculates margin from the absolute position size and the market’s leverage tier. The leverage tier is selected from the resulting position size. A fill that moves the total position into a different tier can change margin for the whole resulting position, not only the newest fill.Limit-order margin
Risk-increasing resting limit orders can require margin before they fill. Phoenix evaluates resting bids and resting asks separately for each market: This matters because a trader cannot fill every bid and every ask in the same market into the same final directional exposure. Phoenix therefore reserves margin for the worse side, not the sum of both sides. The margin increase for each side is based on the hypothetical position if those non-reduce-only orders fill: Notes:- reduce-only orders do not add margin
- orders that only reduce or close the current position do not add margin
- limit-order margin uses the market’s mark price and size, not the order’s limit price
limit_order_risk_factoris market- and tier-specific- limit-order margin is part of initial margin and can move an account toward the cancellation threshold before the order fills
Example portfolio
Assume a cross account has12,000 USDC deposited collateral and the following open positions:
Using the fallback market parameters for BTC and SOL, positive uPnL receives
100% collateral credit for trading risk checks. Assume unsettled funding is -50 USDC.
Now calculate position margin using the first leverage tier from phoenix/market-parameters-fallback.json. Values below include the quote-lot rounding used by the Rise margin calculator.
The account also has resting limit orders:
Assume ETH mark price is
3,000 and SOL mark price is 140. In the fallback parameters, ETH uses 20x first-tier max leverage, SOL uses 15x, and both markets use a 100% first-tier limit_order_risk_factor.
In the calculations below, denotes margin and denotes an increase in margin.
For ETH:
For SOL:
Buying reduces the short from to , so:
Selling increases the short from to , so:
Total initial margin:
The account is healthy because effective collateral is above initial margin:
Using the fallback threshold factors for these markets, the account’s risk thresholds would be:
Maintenance margin and other thresholds
Phoenix derives lower risk thresholds from initial margin using market-specific risk factors. These thresholds are the escalation ladder the protocol uses as an account becomes more dangerous to the system. Here, is the margin threshold and is its corresponding market-specific risk factor. Initial margin is the opening and healthy-account requirement. Maintenance margin is the main liquidation threshold. 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
Liquidation estimates
Liquidation price is an estimate, not a fixed promise. For a single position, Phoenix solves for the mark price where effective collateral would fall to the relevant maintenance requirement: Where:- is collateral
- is the unrealized PnL contribution from other markets in the same cross account
- is signed position size
- is the estimated liquidation price
- is the active leverage tier
- is the maintenance margin from other markets in the same cross account
- is the maintenance risk factor