Dex-liquidation Customer Document

Published on Jul 14, 2023Updated on Apr 4, 20249 min read

1. Basic Field Definition & Description

Introduction to Margin Mode: To help users trade with confidence, single-currency cross margin is available on perpetual swaps. This allows users to trade different perpetual swaps simultaneously by transferring their assets to a cross margin account, and settle contracts in USDC during risk calculation. In the event of a shortfall in USDC equity, a partial or full reduction of a position in a perpetual contract may be triggered, and the entire equity may be lost.
Asset
Assets (trading account) under a single-currency margin are shown in the image below.

Term Definition
Maintenance margin required to hold positions
The amount of margin for current positions in a perpetual swap under an asset in the account. Maintenance margin required to hold positions = Contract Size * |Contract Quantity| * Contract Multiplier * Mark Price * Maintenance margin ratio for the quantity corresponding to the tier
Account Margin Ratio Risk index of USDC assets in the account. Margin Ratio = (USDC Cross Margin Balance + UPL of Cross Margin Positions - All Pending Order Fees) / (Maintenance Margin Required to Hold Positions + Pre-reduction Fees) Currently, the platform does not charge closing fees when users encounter liquidation. Thus, when liquidation has been triggered, the pre-reduction fee is 0.
Account Yields The total equity of all USDC assets (in cross margin account) in an account. Account Equity = USDC Account Balance + UPL of Cross Margin Positions
In Use The quantity of assets that are currently in use in an account, including pending orders in cross margins and positions in use.
__Buy/Sell Mode__ Perpetual swaps support buy/sell mode under single-currency margin. Illustrations are as follows:
Term Definition
Position Size For the buy/sell mode, the position size for the long positions are positive integers while the short positions are negative integers.
Yield UPL of Current Positions USDC Margin Contracts Yields Earn by Long Positions = Contract Size * |Contract Quantity| * Contract Multiplier * (Mark Price - Average Open Price) Yields Earn by Short Positions = Contract Size * |Contract Quantity| * Contract Multiplier * (Average Open Price - Mark Price)
Profits Profit / Margin for opening positions
Initial Margin USDC Margin Contracts Initial Margin = Contract Size * |Contract Quantity| * Contract Multiplier * Mark Price / Leverage
Maintenance Margin USDC Margin Contracts Maintenance Margin = Contract Size * |Contract Quantity| * Contract Multiplier * Maintenance Margin Ratio * Mark Price

2. Order Cancellation

Risk Assessment
The single-currency cross margin consists of two layers of risk assessments — Order Cancellation Assessment and Pre-liquidation Assessment. With these assessments in place, users can trade without worrying about insufficient margin which usually leads to cancellations to all pending orders, and partial or full reduction to the positions (or even liquidation).

Order Cancellation
Order cancellation cancels parts of the pending order when the user's account risk is higher than a certain level but has not reached the pre-liquidation risk level yet. This cancellation will restore the account back to the safe status and prevent users from reaching the pre-liquidation level abruptly and causing all pending orders to be canceled.

Order Cancellation Rules
When (account equity - frozen equity) < maintenance margin needed by the position + initial margin to open pending order + pending order fee, all orders will be canceled and pending orders with frozen equity will be increased (including perpetual order).

3. Liquidation Alerts

Pre-liquidation
Under single-currency margin mode, forced reduction is determined by whether the account margin ratio reaches 100%. While the account margin ratio under single-currency cross margin is an index calculated from the equity of cross margin account and maintenance margin of a certain currency. Generally speaking, the higher the account equity and the lower the maintenance margin, the lower the risk.

When account margin ratio ≤ 300%, a liquidation alert will be sent out and users need to be aware of the liquidation risk. 300% is a warning parameter, which OKX reserves the right to adjust according to the actual situation.

When account margin ratio ≤ 100%, orders will be canceled according to the following rules:

Business Line Mode Single-currency Cross Margin
Perpetual Buy/Sell Mode Cancel all unfilled pending orders (including strategy orders) for the cross margin of the current currency.
If the margin level is still ≤ 100% after pending orders are canceled, forced liquidation will be executed.

4. Forced Liquidation

Partial Reduction
This refers to a situation where a position does not need to be closed out in its entirety in order for the account to be restored to safety.

Full Liquidation
It is necessary to close all positions in order to restore the safety of the account.

Compensation
Even if all positions have been liquidated, the account still may not restore to its safety level. In this case the insurance fund account will compensate for the negative balance of the account by closing the position.

5. Liquidation

Choices of Liquidation Sequence

When selecting a closing bid, the position with the largest loss will be prioritized for reduction based on the P&L of each bid to facilitate risk management.

Long Position: Loss = (Average Open Price - Mark price when liquidation is triggered) * Size * |Quantity| * Contract Multiplier

Short Position: Loss = (Average Open Price - Mark price when liquidation is triggered) * Size * |Quantity| * Contract Multiplier

Tier-Lowering Rules
Liquidation engine will reduced positions by lowering tiers based on the selected bid and will cease operation until it reaches a certain tier, as well as when the account has been restored to its safety line (i.e., 100%).

Liquidation Price Calculation
Once the liquidation underlying has been confirmed, the position will be liquidated at the settlement price.

Long Position: Settlement Price = Mark Price * (1 - Maintenance margin ratio for liquidated positions * margin ratio at the moment of liquidation)

Short Position: Settlement Price = Mark Price * (1 + Maintenance margin ratio for liquidated positions * margin ratio at the moment of liquidation)

The "Maintenance margin ratio for liquidated positions * margin ratio at the moment of liquidation" is a liquidation penalty. Be sure to add insurance fund to underwrite losses from extreme market volatility.

Extreme Liquidity Risk
When there is an extreme liquidity risk in the market, the liquidation order cannot be filled normally. Under such circumstances, the user's account is frozen until the position has been liquidated and the liquidity has been restored.

Funding Fee
Funding fee may be charged during liquidation, which is determined by the position status at the moment of liquidation.

For example:
1)Partial Liquidation
A user has 10,000 USDC at T0 (where T equals time), and he/she sells 10 BTC and buys 10 ETH perpetual contracts at the Mark price of 20,000 and 1,000 respectively.

Assuming the following: BTC contract size = 0.1; BTC contract multiplier = 1; ETH contract size = 1; ETH contract multiplier = 1; and user account equity = 10,000 at T0.
The tiers for BTC and ETH are as follows:

BTC ETH
Tier 1 1-5 (Maintenance Margin Ratio = 0.1) 1-10 (Maintenance Margin Ratio = 0.1)
Tier 2 6-10 (Maintenance Margin Ratio = 0.2) 11-20 (Maintenance Margin Ratio = 0.2)
Suppose that BTC is located at Tier 2 while ETH is at Tier 1, the maintenance margin ratio for corresponding tier is 0.2/0.1 and 0.1, the user requires a maintenance margin of 5,000 [(20,000 * 0.2) + (10,000 * 0.1)], and an account margin ratio of 200% (10,000/5,000) to hold his/her positions.

At T1, BTC's oracle price rose to 25,000 while ETH's oracle price fell to 800, the account equity has become 3,000 (10,000 - 5,000 - 2000), the user requires a maintenance margin of 5,800 [(25,000 * 0.2) + (8,000 * 0.1)], and an account margin ratio of 51.7% (20,000/5,800) to hold his/her positions.

Suppose the safety line (100%) has been triggered. The losses on BTC and ETH are 5,000 and 3,000 respectively, so the user chooses to liquidate BTC positions. Assuming that BTC's positions has been liquidated to the left open range of Tier 2, however the account is still unable to restore above the safety line, it will then continue to liquidate to Tier 1. Assuming that the number of liquidated positions at this point corresponds to Tier 1, a maintenance margin ratio of 0.1 and a closing price of 26,292.5 [(1 + 0.1 * 51.7%) * 25,000] is required for liquidation.

Upon the liquidation of five contracts, the account has been restored to its safety line with its account equity at 2,353; maintenance margin ratio at 2,050 to maintain its positions; and account margin ratio at 114.8 %.

2)Full Liquidation
A user has 10,000 USDC at T0 (where T equals to time), and he/she sells 1 BTC and buys 10 ETH perpetual contracts at the oracle price of 20,000 and 1,000 respectively.

Assuming the following: BTC contract size = 1; BTC contract multiplier = 1; ETH contract size = 1; ETH contract multiplier = 1; and user account equity = 10,000 at T0.

Suppose that both coins are located at Tier 1, the maintenance margin ratio for corresponding tier is 0.2 and 0.1, the user requires a maintenance margin of 5,000 [(20,000 * 0.2) + (10,000 * 0.1)], and an account margin ratio of 200% (10,000/5,000) to hold his/her positions.
At T1, BTC's mark price rose to 25,000 while ETH's mark price fell to 800, the account equity has become 3,000 (10,000 - 5,000 - 2000), the user requires a maintenance margin of 5,800 [(25,000 * 0.2) + (8,000 * 0.1)], and an account margin ratio of 51.7% (20,000/5,800) to hold his/her positions.

Suppose the safety line (100%) has been triggered. The losses on BTC and ETH are 5,000 and 3,000 respectively, so the user chooses to liquidate BTC positions. However, the user is left with 1 BTC contract positioning at Tier 1, a maintenance margin ratio of 0.2 and a closing price of 27,585 [(1 + 0.2 * 51.7%) * 25,000] is required for liquidation.

Upon the liquidation of one contract, the account has been restored to its safety line with its account equity at 2,870; maintenance margin ratio at 800 to maintain its positions; and account margin ratio at 358 %.

3)Compensation
A user has 10,000 USDC at T0 (where T equals to time), and he/she sells 1 BTC and buys 10 ETH perpetual contracts at the mark price of 20,000 and 1,000 respectively.
Assuming the following: BTC contract size = 1; BTC contract multiplier = 1; ETH contract size = 1; ETH contract multiplier = 1; and user account equity = 10,000 at T0.
Suppose that both coins are located at Tier 1, the maintenance margin ratio for corresponding tier is 0.2 and 0.1, the user requires a maintenance margin of 5,000 [(20,000 * 0.2) + (10,000 * 0.1)], and an account margin ratio of 200% (10,000/5,000) to hold his/her positions.
At T1, BTC's mark price rose to 26,000 while ETH's mark price fell to 400, the account equity has become -2,000, which shall be compensated using the insurance fund as all positions in the account have been liquidated .