🦑Liquidation and Margin Details

This section deals with how the Liquidation price of a position is calculated with an example.

Liquidation on the ZKX exchange is an automated mechanism that ensures the financial stability and integrity of the platform by preventing excessive losses that could affect the overall liquidity of the platform. It occurs when a trader's margin balance is insufficient to support their leveraged positions.

When a trader engages in leveraged trading on the ZKX exchange, they are essentially borrowing funds to increase the size of their position. This practice can amplify profits but also magnify potential losses. To manage this risk, ZKX requires traders to maintain:

  1. A minimum margin balance, known as the Initial Margin(IM), IM is determined by the size of the position, its opening price, and the leverage used. (Check tables below.)

  2. ZKX has set a Maintenance Margin Fraction (MMF) that defines the percentage of the position's value needed to keep it open. It's the threshold below which the trader's position becomes at risk of liquidation. Currently, it is set at a constant value for each market 0.075 %. Refer to the section MMF in the table below.

  3. If market volatility causes the value of the Open position to drop, the exchange triggers a liquidation process to close the position and protect the system from further losses.

  4. Mark Price is used in calculating liquidations. Also, we use Mark Price for any conditional order execution/trigger. We model Mark Price as fair and tamper-resistant. For more information check the Pricing section in docs.

  5. The liquidation process takes into account the unrealized profit and loss (UPnL) of a position, the current leverage, and position size to arrive at the liquidation price — the specific price level at which liquidation is triggered. This price is calculated based on the initial margin, the maintenance margin requirements, UPnL, and the direction of the trade (long or short). Check the liquidation price formula and illustration in the table.

  6. The goal of ZKX’s liquidation policy is to maintain market stability and ensure traders can manage risk effectively. So we share some portion of this liquidation revenue with token stakers and the rest is transferred to our Insurance fund to manage and mitigate risk.

For further information and calculations, refer to the tables given below.

This section illustrates the entirety of the process of Liquidation with examples.

Details of Constant factors with example:

Description
Const
Formula
Example

Current balance

Balance

-

1000 USDC

Initial Margin Fraction, in percentage

MMF

A constant value for each market

0.075 %

Details of Positions with example:

Field
Description
Variable
Formula
Example. Position 1, Long
Example. Position 2, Short

Postion

A direction of a position: Long or Short

Dir

Long = 1 ; Short = -1

Dir = 1 (Long)

Dir = -1 (Short)

Position Size

Quantity of contract in position

Q

Input parameter

Q = 2

Q = 6

Avg Execution Price (avgExecutionPrice)

Average price paid to enter the position

OpPr

Input parameter

OpPr = 1000

OpPr = 100

Leverage

Current leverage of the position

Lev

Input parameter

Lev = 5

Lev = 2

Current Market price

Current Price

Price

Input parameter

Price = 1200

Price = 110

Initial Margin

Initial Margin

IM

IM=Q×OpPrLevIM = \frac{Q \times OpPr}{Lev}

IM=2×10005=400IM = \frac{2 \times 1000}{5} = 400

IM=6×1002=300IM = \frac{6 \times 100}{2} = 300

Maintenance Margin

Maintenance Margin

MM

MM=QPriceMMFMM = Q *Price *MMF *OpPr changed to Price

MM=2×1000×0.075=150MM = 2 \times 1000 \times 0.075 = 150

MM=6×100×0.075=45MM = 6 \times 100 \times 0.075 = 45

Unrealized Profit and Loss

Unrealized profit and LLoss of position

UPnL

UPnL=Dir×Q×(PriceOpPr)UPnL = Dir \times Q \times (Price - OpPr)

UPnL=1×2×(12001000)=400UPnL = 1 \times 2 \times (1200 - 1000) = 400

UPnL=1×6×(110100)=60UPnL = -1 \times 6 \times (110 - 100) = -60

Liquidation

Liquidation Price

LiqPrLiqPr

LiqPr=BalanceOpPr×Q×Dir+TotalUPnLUPnLTotalMM+MMQ×(MMFDir)LiqPr = \frac{\text{Balance} - OpPr \times Q \times Dir + TotalUPnL - UPnL - TotalMM + MM}{Q \times (MMF - Dir)}

LiqPr=(10001000×2×1+190200195+150)2×(0.0751)=10551.85570.2702703LiqPr = \frac{(1000 - 1000 \times 2 \times 1 + 190 - 200 - 195 + 150)}{2 \times (0.075 - 1)} = \frac{-1055}{-1.85} \approx 570.2702703

LiqPr=(1000100×6×(1)+190(10)195+45)6×(0.075(1))=16506.45255.8139535LiqPr = \frac{(1000 - 100 \times 6 \times (-1) + 190 - (-10) - 195 + 45)}{6 \times (0.075 - (-1))} = \frac{1650}{6.45} \approx 255.8139535

Account Information

Field
Variable
Formula
Example

Total positions count

Count

-

Count = 2

Total Initial Margin

TotalIM

TotalIM=i=1CountIMi\text{TotalIM} = \sum_{i=1}^{\text{Count}} IM_i

TotalIM=400+300=700TotalIM = 400 + 300 = 700

Total maintenance margin

TotalMM

TotalMM=i=1CountMMi\text{TotalMM} = \sum_{i=1}^{\text{Count}} MM_i

TotalMM=150+45=195TotalMM = 150 + 45 = 195

Total Unrealised PnL

TotalUPnL

TotalUPnL=i=1CountUPnLiTotalUPnL = \sum_{i=1}^{\text{Count}} UPnL_i

\begin{equation} TotalUPnL = 200 + (-10) = 190 \end{equation}

Total Margin

TotalMargin

TotalMargin=Balance+TotalUPnLTotalMargin = \text{Balance} + TotalUPnL

TotalMargin=1000+190=1190TotalMargin = 1000 + 190 = 1190

Available Margin

AvailableMargin

AvailableMargin=TotalMarginTotalIMAvailableMargin = TotalMargin - TotalIM

\begin{align*} \text{AvailableMargin} &= 1190 - 700 \\ &= \boxed{490} \end{align*}

Max withdrawable Balance

MaxWithdraw

MaxWithdraw=BalanceTotal Initial Margin+Total U PnL\text{MaxWithdraw} = \text{Balance} - \text{Total Initial Margin} + \text{Total U PnL}

MaxWithdraw=1000700+190=490\text{MaxWithdraw} = 1000 - 700 + 190 = \boxed{490}

Buy Info

Field
Variable
Formula
Example

Buying Power

BP

BP=(TotalMarginTotalIM)maxLeverageBP = (TotalMargin - TotalIM) * maxLeverage

BP=70020=14000BP = 700* 20 = 14000

Total Margin

Equity

Equity=TotalMarginEquity = TotalMargin

TotalMargin=1000+190=1190TotalMargin = 1000 +190 = 1190

Margin Usage %

MarginUsagePer

MarginUsagePer=(1AvailableMargin/TotalMargin)100MarginUsagePer =(1 - AvailableMargin/TotalMargin) * 100

MarginUsage=(14901190)×100=(10.4117)×100=58.82\text{MarginUsage} = \left( 1 - \frac{490}{1190} \right) \times 100 = \left( 1 - 0.4117\right) \times 100 = 58.82

Invested funds

Invested

Invested=i=1Count(leveragei×IMi)Invested = \sum_{i=1}^{\text{Count}} (\text{leverage}_i \times IM_i)

Last updated