Liquidation

A liquidation is the venue closing a position because the equity behind it has fallen below the maintenance margin.

Definition

The maintenance margin is the minimum equity a position may stand on, and it is a share of the notional rather than of the margin posted: half the initial margin at the market's maximum leverage, so between 1.25% of the notional on a 40x market and 16.7% on a 3x one. Which equity is read depends on the mode. A cross position is liquidated when the account value, unrealized profit and loss included, is less than the maintenance margin times the total open notional. An isolated position follows the same rule with only its own margin and notional as inputs.

What happens then has an order. The positions are first attempted to be entirely closed by sending market orders to the book, for the full size, and they may fill fully or partly; if that brings the account back to meeting the requirement, any remaining collateral stays with the trader, and there is no clearance fee. If the equity drops below 2/3 of the maintenance margin without a successful liquidation through the book, the liquidator vault, a component strategy of HLP, takes the position over, and the maintenance margin is then not returned.

A large position is not thrown at the book whole. For a liquidatable position larger than 100k USDC (10k USDC on testnet), only 20% of it is sent as a market liquidation order, and after a block in which any of a user's positions is partially liquidated there is a cooldown of 30 seconds during which every market liquidation order for that user is for the entire position. Liquidations are measured on the mark price, not on the last trade you saw.

The liquidation price shown before entry is an estimate, and the documentation says it may be inaccurate because the book's liquidity changes. The price shown once you are in has the certainty of the entry price but still moves with funding payments and, on a cross account, with the unrealized profit and loss of your other positions. One result surprises people: that price is independent of the leverage set for a cross position, and depends on it for an isolated one.

Formula

liq_price = price - side * margin_available / position_size / (1 - l * side), where l = 1 / MAINTENANCE_LEVERAGE, side is 1 for a long and -1 for a short, and margin_available is account_value - maintenance_margin_required for a cross position or isolated_margin - maintenance_margin_required for an isolated one.

Example

An example, in round figures. An isolated long of 0.1 BTC entered at $100,000 at 10x posts $1,000 of margin. On a 40x market the maintenance margin is 1.25% of the $10,000 of notional, so $125, which leaves $875 of margin available and a maintenance leverage of 80, so l is 0.0125. The formula gives $875 divided by 0.1 BTC divided by 0.9875, about $8,861 below the entry: a liquidation near $91,139, a fall of 8.9%.