Root Dex
  • Root Dex
  • Why Choose Root Dex?
  • PvPool (PvP) Trading Mechanism
  • Contract Types
  • Position Modes
  • Pricing
  • Fees
  • Order Types
  • Maintenance Margin
  • Liquidation Mechanism
  • Slippage
  • REX TOKEN
Powered by GitBook
On this page
  • Liquidation Definition
  • Liquidation Execution
  • Liquidation Process

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:

Long:pl=poxn−M+Funding+Interest/(1−mm)xnLong: pl = {po x n - M + Funding + Interest} / {(1 - mm) x n}Long:pl=poxn−M+Funding+Interest/(1−mm)xn
Short:pl=poxn+M−Funding−Interest/(1+mm)xn Short: pl = {po x n + M - Funding - Interest} / {(1 + mm) x n}Short:pl=poxn+M−Funding−Interest/(1+mm)xn

For inverse / coin-based contracts:

Long:pl=(1+mm)xn/M+(1/po)xn−Funding−InterestLong: pl = {(1 + mm) x n} / {M + (1 / po) x n - Funding - Interest}Long:pl=(1+mm)xn/M+(1/po)xn−Funding−Interest
Short:pl=(1−mm)xn/(1/po)xn−M+Funding+InterestShort: pl = {(1 - mm) x n} / {(1 / po) x n - M + Funding + Interest}Short:pl=(1−mm)xn/(1/po)xn−M+Funding+Interest

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:

  1. 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

  2. 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.

PreviousMaintenance MarginNextSlippage

Last updated 1 year ago