- Collateral, borrows and perp position values are summed up to give the Health metric
- Health is used to determine liquidations and new position eligibility
- Oracle price is used to determine value of assets and liabilities
The health of an account is used to determine if one can open a new position or if one can be liquidated. There are two types of health, initial health used for opening new positions and maintenance health used for liquidations. They are both calculated as a weighted sum of the assets minus the liabilities but the maint. health uses slightly larger weights for assets and slightly smaller weights for the liabilities. Zero is used as the bright line for both i.e. if your init health falls below zero, you cannot open new positions and if your maint. health falls below zero you will be liquidated. They are calculated as follows:
If the health calculation is for determining liquidations, liability weight and asset weight will use the maintenance version. The quote currency, in the typical case USD, will always have all weights and prices equal to 1.
As an example, one asset might be BTC-PERP with
init_asset_weight = 0.9
init_liab_weight = 1.1
maint_asset_weight = 0.95
maint_liab_weight = 1.05
These correspond to a 10x initial leverage and 20x maintenance leverage.
Suppose a user deposits 10k USDC and goes long 10 BTC-PERP at 10k each. Then the user has 10 BTC-PERP in assets, and a net 90k in USD liabilities. The init health would be exactly 0 and the maint health would be:
maint_health = 10 * 10000 * maint_asset_weight - 90000 = 5000
Suppose the BTC-PERP mark price moves to $9400, then:
maint_health = 10 * 9400 * maint_asset_weight - 90000 = -700
Since the maint_health is now below zero, this account can be liquidated until init health is above zero.
A short position would have negative contract sizes and use