Spot (beta live)

Derivatives (soon)

Contracts specification

Platform

Links

📈

Margin ratio & Liquidation

The **margin ratio** is used to assess the risk of a protocol user's position.

$k_{m}=\frac{M_{t}}{\sum{L}}$

$k_{m}$

– user's margin ratio

$M_{t}$

- total user margin, which includes the amount of uPnL and funding for all positions

$\sum{L}$

– sum of position's collateral$M_{t}=M+\sum{uPnl} - \sum{Fa}$

$M$

- user's margin

$\sum{uPnL}$

- sum of unrealized PnL

$\sum{Fa}$

- total funding amount
The following rules are used depending on the value of the margin ratio:

- If, after the user has made a trade, his$k_{m}$
- If 1 <$k_{m}$< 0.7, then the user cannot open new positions, but he is not subject to liquidation either.
- If$k_{m}$< 0.7, a partial liquidation of user positions is possible.
- A trader cannot withdraw funds from his account if$k_{m}$< 1 or if, as a result of his withdrawal,$k_{m}$falls below 1.
- If$k_{m}$

The commission for closing a position paid to the liquidator is 1.5% of the value of the closed position, and another 1% is sent to the insurance fund. On a separate tab of the interface, a list of users is created, ranked from lowest to highest by margin ratio.

Liquidation terms:

- If$k_{m}$< 0.7, the user's position can be liquidated.
- The$k_{m}$of the liquidator after liquidation must be > 1.
- The liquidator is not obliged to “buy back” the entire position of the liquidated person available for closing, the minimum liquidation is 1 contract.
- The user's position can be liquidated until his$k_{m}$becomes equal to 0.7, taking into account the penalty charged for liquidation.

$L_{p}=\frac{(-1*(M+uPnL-Fa))+0.7*Sm}{-(Tf*Mp)+Mp*0.1*0.7}*(\pm1)$

The result is rounded up to 4 decimals.

If the position is long, then the equation is multiplied by +1, if short, then -1.

The liquidator himself chooses the asset from the open positions of the user, which will be liquidated.

Only 1 asset can be liquidated for the execution of one liquidation contract.

Example:Alice has a long futures position worth 0.3 BTC. The BTC price is 33,330 USDC, the collateral for this position is 1,000 USDC. Alice's margin is 2,100 USDC and uPnL is -1,105 USDC. kM equals to (2,100 + (-1,105)) / 1000 = 0.995. Alice's position cannot be liquidated, but she cannot open new positions either.The BTC price drops to 31,990 USDC, Alice's uPnL becomes -1507 USDC, collateral equals to 959.7 USDC, and margin remains 2,100 USDC. kM equals to (2,100 + (-1507)) / 959.9 = 0.618.Bob's margin account is 200 USDC and he wants to liquidate Alice's position. Spin uses the liquidation formula for calculating the maximum available liquidation amount of Alice's BTC:$L_{p}=\frac{(-1*(2100+(-1507)))+0.7*959.7}{-(0.025*31990)+31990*0.1*0.7}=0.054732$The number is rounded up to 4 numbers after comma, and final$L_{p}=0.0548$Bob liquidates 0.0548 BTC of Alice's position and his position is increased to the same value fo Bob's position is: long 0.0548 BTC, his collateral is 175.305 USDC, uPnL is 0 USDC, margin account balance is 226.296 USDC, so kM = 1.291. Bob can close the position or continue holding it.Alice's position is: long 0.245 BTC, her collateral is 783.76 USDC, uPnL – 1230.72 USDC, margin account balance is 1779.73 USDC and kM = 0.7.

When the position is subject to liquidation, the smart contract checks all the necessary on-chain parameters. Information on the site is displayed off-chain.

The maximum allowable leverage is calculated based on the collateral. If the collateral is 10%, the maximum leverage is x10, because if this value is exceeded, the margin ratio will be insufficient to maintain the position, which may lead to liquidation.

Copy link

Contents