Cross Margin
Each Citrex account can create 256 subaccounts, each of which behaves like a completely discrete account with its own margin.
Each subaccount is cross-margined, where each asset and position they hold contributes to an overall subaccount health. There are two types of health, maintenance and initial.
When a subaccount's initial health drops below 0, they are not allowed to open any positions which reduce their health further (closing positions or swapping to less risky ones).
When a subaccount's maintenance health drops below 0, they become liquidatable, meaning their positions can be forcibly closed by liquidators and/or the off-chain engine.
Margin Calculation
All of a subaccount's asset balances and all open derivative positions are taken into account. The function determines whether a subaccount has any spreads, defined by a short perp position offset entirely by a balance in the same spot asset. The function then calculates and sums the health on each of the spread, spot and derivative positions and deducts any core collateral debt to obtain the subaccount's health. The calculation of each of these constituents is described below:
Perp Health
Perpetual future health is calculated as follows:
perpHealth = quantity \times (markPrice \times riskWeight - avgEntryPrice) + funding
where quantity is a negative value for short positions.
For example, let's calculate the maintenance health on a 5 BTC-Perp short position that was entered at $38,000. The price of BTC is now $40,000 and the position has earned $500 in funding:
initialLongWeight = 0.9
maintenanceLongWeight = 0.95
initialShortWeight = 1.1
maintenanceShortWeight = 1.05
initialHealth = -5 \times (40,000 \times 1.05 - 38,000) + 500 = -$19,500
Max Leverage
Because of these weights, there is a limit to the max leverage a subaccount can achieve on an asset:
maxLongLeverage = 1 / (1 - riskWeight)
maxShortLeverage = 1 / (riskWeight - 1)
So for BTC-Perps, the max initial leverage would be:
maxLongLeverage = 1 / (1 - 0.9) = 10x
Spot Health
A balance in any spot asset deemed valid collateral will contribute to a subaccount's health as follows:
spotHealth = quantity \times riskWeight \times markPrice
For example, for a balance of 5 BTC at $40,000, if the risk weights are as follows:
initialLongWeight = 0.8
maintenanceLongWeight = 0.9
initialHealth = 5 \times 0.8 \times 40,000 = $160,000
Note that invalid collateral assets will have weight values of 0.
Spread Health
Spreads are delta-neutral positions where a short perp position in an asset is offset entirely by a spot position in that same asset. Because of this, spreads are less risky than their two constituent components in isolation. We therefore calculate health on spreads using different penalties that are more forgiving to the sub-account.
spreadHealth = quantity \times (spotPrice - perpPrice + perpEntryPrice - spreadPenalty \times (spotPrice + perpPrice) / 2) + funding
initialSpreadPenalty = 0.02
maintenanceSpreadPenalty = 0.01
So using the above spot and perp examples, the initial health on this same spread would be:
initialHealth = 5 \times (40,000 - 40,000 + 38,000 - 0.02 \times 40,000) + 500 = $186,500
As calculated above, the initial health on the sum of the two individual positions without spread weightings would be:
initialHealth = 180,000 - 19,500 = $160,500
Last updated