Collateral is held as USDC (displayed as USD throughout the product as it is redeemable 1:1 for USD), and the quote asset for all perpetual markets is USD. Cross-margining is used by default, meaning an account can open multiple positions that share the same collateral. Isolated margin can be achieved by creating separate accounts (using a new wallet address).
Each market has two risk parameters, the initial margin fraction and the maintenance margin fraction, which determine the maximum leverage available within that market. These are used to calculate the value that must be held by an account in order to open or increase positions (in the case of initial margin) or avoid liquidation (in the case of maintenance margin).
There is no distinction between realized and unrealized PnL for the purposes of margin calculations. Gains from one position will offset losses from another position within the same account, regardless of whether the profitable position is closed.
The margin requirement for a single position is calculated as follows:
Initial Margin Requirement = abs(S × P × I)
Maintenance Margin Requirement = abs(S × P × M)
Sis the size of the position (positive if long, negative if short)
Pis the oracle price for the market
Iis the initial margin fraction for the market
Mis the maintenance margin fraction for the market
The margin requirement for the account as a whole is the sum of the margin requirement over each market
i in which the account holds a position:
Total Initial Margin Requirement = Σ abs(Si × Pi × Ii) Total Maintenance Margin Requirement = Σ abs(Si × Pi × Mi)
The total margin requirement is compared against the total value of the account, which incorporates the quote asset (USDC) balance of the account as well as the value of the positions held by the account:
Total Account Value = Q + Σ (Si × Pi)
Qis the account's USDC balance (note that
Qmay be negative)
Pare as defined above (note that
Smay be negative)
An account cannot open new positions or increase the size of existing positions if it would lead the total account value of the account to drop below the total initial margin requirement. If the total account value ever falls below the total maintenance margin requirement, the account may be liquidated. Movements in the oracle index price may also cause an account to drop below the initial margin requirement and, eventually, the maintenance margin requirement.
Accounts which fall below the initial margin requirement are restricted from making withdrawals and certain trades until the account’s margin percentage is brought back to the initial margin requirement. These restrictions apply whether the “risky” account is a taker or a maker in the trade.