šŸ„‹Cross Margin

Each 100x 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 forceably 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(markPriceāˆ—riskWeightāˆ’avgEntryPrice)+fundingperpHealth = quantity(markPrice * riskWeight - avgEntryPrice) + funding

where quantity is a negative value for short positions.

For example, lets 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(40000 * 1.05 - 38000) + 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)maxLongLeverage = 1/(1- riskWeight)

maxShortLeverage=1/(riskWeightāˆ’1)maxShortLeverage = 1/(riskWeight -1)

So for BTC-Perps, the max initial leverage would be 1/(1āˆ’0.9)=10x1/(1-0.9) = 10x.

Sneak peek...

Spot Health

A balance in any spot asset deemed valid collateral will contribute to a subaccount's health as follows:

spotHealth=quantityāˆ—riskWeightāˆ—markPricespotHealth = quantity * riskWeight * 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 * 0.8 * 40000 = $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(spotPriceāˆ’perpPrice+perpEntryPriceāˆ’spreadPenalty((spotPrice+perpPrice)/2))+fundingspreadHealth = quantity(spotPrice - perpPrice + perpEntryPrice -spreadPenalty((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(40000 - 40000 + 38000 - 0.02(40000)) + 500 = $186,500

As calculated above, the initial health on the sum of the two individual positions without spread weightings would be:

ā€‹ i n i t i a l H e a l t h = 180000 āˆ’ 19500 = $ 160 , 500

Last updated