🎛
Cross margin & Isolated margin
When opening a position, the trader chooses whether it will be opened using a cross or isolated margin.
If the user chooses the cross-margin mode, then all his collateral located in the margin account will be used to calculate the margin ratio. If a trader chooses an isolated margin, then the next step is to deposit collateral to a separate account (sub-account) for this position. Technically, the money remains in the same wallet, in the GUI the user sees a separate sub-account where the funds for this position are placed. The smart contract records the information that the user has opened a sub-account, the margin ratio for which is calculated separately from other positions.
By default, all positions are opened with cross-margin.
Cross-margin will be implemented in v1 of the protocol. When it is used and the margin ratio is to be calculated, the indicators of all positions are taken into account including their total uPnL and collateral.
Example: Bob deposited 10,000 USDC to his margin account and bought 1 BTC futures at 40,000 USDC and 10 ETH futures at 3,600 USDC. His margin ratio equals to:
$kM =\frac {10,000 + 0}{(0.1*40,000 *1) + (0.1 * 3,600 * 10) }= 1.316$
The BTC price dropped to 37,000 USDC, and the ETH price increased to 3750 USDC, so Bob's margin ratio is:
$kM = \frac{(10,000 + (-3,000 + 1500)}{(0.1*40,000 *1) + (0.1 * 3,750 * 10)}= 1.14$
Isolated margin (v3 functionality) is a more specific tool. When used (it is selected when opening a position and applies only to it), the margin ratio is calculated individually for this position. In the event of a sharp decrease in kM, only the collateral deposited on the sub-account for this position can be liquidated, the same applies for a cross-margin account, kM is counted separately, and liquidation will not affect positions on other accounts. 