I. Liquidation Concept
Liquidation occurs when the margin balance falls below the maintenance margin. The margin balance refers to the sum of wallet balance and unrealized profit and loss, while the maintenance margin is the minimum margin amount that users must maintain to avoid liquidation of their contract positions.
II. Liquidation Price and Bankruptcy Price (the difference between Liquidation Price and Bankruptcy Price is the Maintenance Margin)
The liquidation price is the price at which a position triggers forced liquidation. This threshold is influenced by multiple factors, including the leverage used, maintenance margin rate, current price of the cryptocurrency, and the user's account balance.
The bankruptcy price refers to the amount lost by the user, which equals the value of the collateral deposited or the price at the time of initial margin. From this price onwards, the margin balance of the user being liquidated will be zeroed.
As shown above, a position has both bankruptcy price and liquidation price. The difference between them is MM (maintenance margin surplus). When the price falls below the liquidation price, the user loses control of the position. The system initiates the liquidation process and takes over the user's position. At this point, the system internally proceeds with the liquidation process.
III. Liquidation Process
The liquidation process consists of two steps, called " Forced liquidation" and "ADL" (Auto-Deleveraging). Regardless of the step, users lose the value of their positions once liquidation is triggered. In other words, upon liquidation trigger, users immediately incur losses equivalent to all the position margin (PositionIm).
- Forced liquidation: When the system takes over the user's position, it places a liquidation order at the bankruptcy price on the market. If the order is executed at a price better than the market price, the remaining amount from the position goes into the risk fund. For the user, this amount is referred to as the liquidation fee.
- ADL (Auto-Deleveraging): When the system places orders to sell at the bankruptcy price in the market, but the market conditions deteriorate rapidly, making it impossible to execute the orders. After the orders exceed 9 seconds, they are executed against quantified accounts at the bankruptcy price.
IV. Example
Forced Liquidation
Using 5x leverage in isolated margin mode, a long position in ETC/USDT is established. The entry price is 22, and the position size is 10 ETC, as shown in the following image.
Liquidation Price Formula:
For a long position in a USDT-based contract, the liquidation price is rounded up to the nearest unit based on the price unit, with an ETCPriceUnit of 2.
pv -(im+ab)+mm + takerFee (fee calculated at liquidation price)=resValue
Formula derivation:
𝑙𝑖𝑞_𝑝𝑟𝑖𝑐𝑒= (pv - (im+ab) + mm)/(hv * cs *(1-takerRate))
Substituting the values into the formula:
The calculated result matches the current position result.
When the mark price falls below 17.71, liquidation is triggered. At this point, the system takes control of the user's position and places a sell order at a price of 17.6. Based on the current order book, it can be observed that it will match with the buy order at position 21 on the order book. Therefore, the execution price of the liquidation sell order will be 21.
The funds flow is as follows:
For the entire position, with an entry price of 22 and an exit price of 21, the realized P&L is: Realized P&L = (22 - 21) * 10 = 10 (loss)
The closing trading fee is calculated as:
Closing trading fee = 21 * 10 * 0.0006 = 0.126
The liquidation clearance fee is:
Liquidation clearance fee = positionIm - Realized P&L - Closing transaction fee Liquidation clearance fee = 44.132 - 0.126 - 10 = 34.006
Trading History
Realized P&L from closing position = -(22 - 21) * 10 = -10 (loss)
Trading fee = 21 * 10 * 0.0006 = 0.126
Position History:
Trading Fee = Opening Fee + Closing Fee
Opening Fee = 22 * 10 * 0.0006 = 0.132
Closing Fee = 21 * 10 * 0.0006 = 0.126
Total Fee = 0.132 + 0.126 = 0.258
Liquidation Fee as mentioned above = 34.006
Realized P&L from closing position as mentioned above = 10
Order History:
Order type: Liquidation Order
Realized P&L: 10
Liquidation Fee: 34.006
Closing Fee: 0.126 (Taker role)
ADL
Using 5X leverage for isolated short position, forming a position, with an entry price of 21 and a position size of 10 ETC, as shown in the diagram.
For inverse contract short positions, the liquidation price is rounded down based on advancing one unit in priceUnit.
After derivation:
𝑙𝑖𝑞_𝑝𝑟𝑖𝑐𝑒 = (PV+IM+ab -MM)/((1+takerRate)*hv*cs)
Substituting the values into the formula:
For inverse contract short position, the liquidation price is rounded down based on advancing one unit in priceUnit.
PV + (IM + ab - MM - takerFee (fee calculated at liquidation price)) = resValue
After derivation:
liquidation_price = (PV + IM + ab - MM) / ((1 + takerRate) * hv * cs)
Calculating with the formula:
The calculation result is consistent with the current position result.
When the mark price falls below 25.09, triggering liquidation, the system will take over the user's position and sell it at a price of 25.2. Based on the current order book, it can be observed that there are no matching orders, and ultimately, the transaction will be settled with the quantified account at the price of 25.2, forming a forced liquidation.
i. When the liquidation starts, orders are placed at a price of 25.2. After no matches in the order book, the order is cancelled, and an ADL forced liquidation order is initiated.
Fund Flow Distribution:
For the entire position, with an entry price of 21 and an exit price of 25.2, the realized position's
Realized P&L = (25.2 - 21) * 10 = 42 loss
Closing Fee = 25.2 * 10 * 0.0006 = 0.1512
Liquidation Fee = positionIm - Realized P&L - Closing Fee = 42.1512 - 42 - 0.1512 = 0
Loss is exactly covered, resulting in no liquidation fee.
Trading History
Realized P&L = (25.2 - 21) * 10 = 42 loss
Close Position Fee = 25.2 * 10 * 0.0006 = 0.1512
Position History
Realized P&L = (25.2 - 21) * 10 = 42 loss
Open Position Fee = 21 * 10 * 0.0006 = 0.126
Close Position Fee = 25.2 * 10 * 0.0006 = 0.1512
Total Fees = 0.126 + 0.1512 = 0.2772
Order History
Order Type: ADL (Auto-Deleveraging) Order
Realized P&L: 42
Liquidation Fee: 0
Close Position Fee: 0.1512 as taker
*The above liquidation rules apply to both futures trading and copy trading.
Comments
0 comments
Article is closed for comments.