Liquidation Mechanism
Liquidation Definition
When a trader's total position value (position margin + unrealized PNL - borrowing fees - funding fees) falls below the maintenance margin requirement, this triggers liquidation and the keeper will finalize and close the position.
The formulas for calculating liquidation prices are as follows:
For linear / U-based contracts:
For inverse / coin-based contracts:
Po: Entry Price
M: Initial Margin
n: Number of Positions
Funding: Funding Fees
Interest: Borrowing Fees
mm: Maintenance Margin Rate
Liquidation Execution
Both the system and decentralized liquidation robots can execute liquidations on Root DEX.
When a liquidation is triggered, the system's liquidation robot will carry out the liquidation. If the system's liquidation robot is overloaded with too many liquidation requests, the decentralized liquidation robot can also execute the liquidation based on the price provided by the ChainLink oracle.
Community liquidators will receive 5 USDC as a reward every time a decentralized liquidation robot is used to execute a liquidation request. For details on the execution method, please refer to the technical documentation. After the liquidation is triggered and the transaction losses, borrowing fees, funding fees, and other expenses are deducted, the remaining margin will be automatically refunded to the trader's wallet address.
Liquidation Process
The maximum loss a trader can incur is their position margin. When the position is liquidated, the margin is deducted in the following order: Borrowing Fees >> Funding Fees >> Unrealized PNL >> Insurance Fund >> Margin returned to the trader. If the margin goes to 0 during the deduction process, the latter will receive 0.
Position Margin = Unrealized PNL + Insurance Fund (Initial Position Value x 0.2%) + Margin returned to the trader + Funding Fees + Borrowing Fees
For example, if a trader opens a long position with 100x leverage and 100 USDC as the initial margin when ETH is priced at 1,000 USDC, the position size is 10 ETH. Without considering borrowing and funding fees, the liquidation price for this position is
Pl = Entry Price x (1 - 1/L) / (1 - mm) = 994.97 USDC
When the liquidation robot executes the liquidation, the following two scenarios may occur:
When the price is 930 USDC, then The unrealized PNL is (930 - 1000) x 10 = -70 USDC The insurance fund is 930 x 10 x 0.002 = 18.6 USDC Assume 0 borrowing and funding fees, the margin returned to the trader is 100 - 70 - 18.6 = 11.4 USDC
When the price is 980 USDC, then The unrealized PNL is (980 - 1000) x 10 = -200 USDC After deducting borrowing and funding fees, all the remaining margin will be added to the fund pool.
Last updated