Stacked Markets
What is a liquidation engine? How DEXs handle forced closures
Published May 29, 2026 · By Stacked Markets Research Team
- $6.7T - On-chain perp DEX volume in 2025, up 346% year-over-year
- 200,000 orders/sec - Hyperliquid's matching engine throughput with sub-second finality
- ~$200M - Notional size of the single position at the centre of the March 2025 BTC liquidation cascade on Hyperliquid
Contents
- The quick answer
- Why liquidation engines exist
- The three inputs every engine needs
- How liquidation price is calculated
- How CEX liquidation engines work
- How DEX liquidation engines differ
- Hyperliquid's liquidation engine specifically
- The liquidation cascade
- How to read your liquidation price in practice
- What "opaque" really means for your position
- Non-custodial execution and cascade risk
- FAQs
Most traders know liquidation means their position gets closed when margin runs out. Fewer understand the engine doing the closing - what it reads, what it decides, and who can actually see it. That gap matters more than most people admit, especially when markets move fast and positions stack up across the same asset.
On-chain perp DEX volume hit $6.7 trillion in 2025, up 346% year-over-year. Hyperliquid alone processes 200,000 orders per second with sub-second finality. At that scale, forced closure mechanics are not a theoretical concern. They are live operational risk every time you carry a leveraged position overnight.
This article covers how liquidation engines actually work - from the three core inputs to the cascade mechanics that wiped out billions in a single session in early 2025. It also covers where CEX and DEX engines diverge, and what Hyperliquid does specifically.
The quick answer
A liquidation engine is the automated system that monitors open leveraged positions, calculates whether each position still holds enough margin to stay solvent, and closes positions that fall below the minimum threshold.
It is not simply "forced closure." The engine runs continuously against every open position, every tick. It computes a margin ratio in real time, compares it against a maintenance margin floor, and triggers a closing sequence the moment that floor is breached.
That closing sequence involves price sourcing, order routing, loss absorption, and - in the worst cases - socialized loss distribution. Each step has a specific implementation that differs between platforms. Understanding those differences is the actual skill.
Why liquidation engines exist
Leveraged trading creates a solvency problem that does not exist in spot markets.
When you buy spot, the worst outcome is the asset goes to zero and you lose your principal. No one else is on the hook. In a leveraged perpetual futures position, you control a notional value many times your collateral. If the trade moves against you and you cannot cover the loss, the counterparty - or the platform - absorbs it.
Without a liquidation engine, a single large position going deeply negative could make the entire protocol insolvent. The engine exists to close positions before losses exceed posted margin, keeping the system solvent even when individual traders cannot cover their losses.
This is why maintenance margin exists as a buffer above zero. The engine does not wait until your margin is completely gone - it closes you out while enough remains to cover closing costs and protect the system.
The three inputs every engine needs
Every liquidation engine, on-chain or off, needs three inputs to function:
- Mark price - the reference price used to value your position for margin purposes. Deliberately not the last trade price, because last trade prices are manipulable. Mark price is typically derived from an index of external spot prices, with a dampening mechanism to prevent short-term spikes from triggering unnecessary liquidations.
- Maintenance margin - the minimum margin ratio a position must maintain to stay open. Expressed as a percentage of notional position value. Fall below it and the engine closes you.
- Margin ratio - your current margin divided by your notional position value, recalculated continuously as mark price moves. When this ratio drops to or below maintenance margin, liquidation triggers.
These three inputs are universal. What differs between platforms is how each one is sourced, computed, and made visible to traders.
How liquidation price is calculated
The liquidation price is the mark price at which your margin ratio hits the maintenance margin threshold. The formula varies slightly between isolated and cross margin, but the logic is the same.
Isolated margin example
Say you open a long BTC-PERP position with the following parameters:
- Entry price: $100,000
- Position size: 1 BTC
- Notional value: $100,000
- Collateral posted (isolated): $10,000 (10x leverage)
- Maintenance margin rate: 0.5%
Maintenance margin in dollar terms: $100,000 x 0.005 = $500
Your position can absorb losses down to the point where remaining margin equals $500. That means you can lose $9,500 before liquidation triggers ($10,000 collateral minus $500 maintenance margin).
Liquidation price (long): $100,000 - $9,500 = $90,500
If mark price reaches $90,500, the engine closes your position. The remaining ~$500 covers closing costs. If the position closes at a worse price than $90,500, the insurance fund absorbs the shortfall.
Cross margin: the key difference
In cross margin mode, your entire account balance backs all open positions. The liquidation calculation uses total account equity rather than per-position collateral. This gives you more buffer against any single position being liquidated - but it also means one bad position can drain margin from all your others simultaneously.
The formula is the same in structure: equity divided by total notional must stay above maintenance margin. But the denominator now includes every open position's notional value, and the numerator is your full account balance minus unrealized losses across all positions.
Cross margin is not inherently safer. It is a different risk distribution. A concentrated position in cross mode can still trigger a full account liquidation.
How CEX liquidation engines work
Centralized exchange liquidation engines run server-side. The code is not public. Mark price methodology is disclosed in documentation, but the live computation is not independently verifiable. Order routing during liquidation - whether the engine uses market orders, limit orders, or some combination - is at the exchange's discretion.
Most major CEXs use a tiered liquidation process: partial reductions first, then full closure, then any remaining loss passes to an insurance fund. Some exchanges have used auto-deleveraging (ADL), where profitable counterparty positions are forcibly reduced to cover losses from insolvent ones.
The practical problem is opacity. You cannot verify in real time that the mark price used to calculate your margin ratio is the same one that triggered your liquidation. You cannot confirm whether your position was closed at the best available price. You are trusting the exchange's stated methodology and their execution.
After FTX's collapse in 2022 and the exchange insolvencies that followed, that trust carries a real cost for experienced traders.
How DEX liquidation engines differ
On-chain liquidation engines execute through smart contracts. The logic is public. Mark price inputs come from on-chain oracles or protocol-defined price feeds. Every liquidation event is a transaction on the chain - visible, timestamped, and queryable by anyone.
That creates a level of verifiability CEX engines cannot match. You can check the mark price at the time of your liquidation. You can verify the engine applied the correct maintenance margin threshold. You can see exactly what price your position closed at and compare it to the order book at that moment.
The tradeoff is speed and flexibility. Smart contract execution adds latency compared to a server-side engine. On-chain engines also cannot easily implement discretionary partial fills or dynamic margin adjustments mid-liquidation the way a CEX can.
Better DEX designs address this with purpose-built infrastructure: fast finality chains, dedicated liquidation bots, and insurance fund mechanics that do not require discretionary intervention.
Hyperliquid's liquidation engine specifically
Hyperliquid's liquidation engine runs on its own L1 with sub-second finality. Mark price is computed as the median of three inputs: the oracle price (sourced from external spot markets), the last traded price on Hyperliquid, and the mid-price of the current order book. Using the median rather than any single source makes mark price resistant to short-term manipulation on any one venue.
When a position's margin ratio hits the maintenance threshold, the engine initiates closure. The sequence:
- Liquidation attempt at mark price - the engine tries to close the position at or near mark price through the order book.
- Insurance fund absorption - if the position closes at a price worse than the bankruptcy price (the point at which losses exceed posted margin), the insurance fund covers the shortfall. Hyperliquid maintains a protocol-owned insurance fund for exactly this purpose.
- HLP backstop - Hyperliquid Liquidity Provider (HLP) vaults act as backstop liquidity for liquidations the order book alone cannot absorb. HLP participants earn fees from this role but also bear the risk of absorbing losses in extreme conditions.
- Socialized loss as last resort - if the insurance fund is depleted and HLP cannot absorb the remaining loss, the protocol can socialize losses across profitable positions. This is the mechanism of last resort and is publicly documented.
Every step is on-chain and verifiable. You can query the insurance fund balance, track HLP positions, and audit individual liquidation transactions.
The liquidation cascade
A cascade happens when one forced closure moves price enough to trigger the next liquidation, which moves price further, triggering the next, and so on.
The mechanics are straightforward. A large long position gets liquidated. The engine sells into the order book to close it. That selling pressure pushes mark price lower. Other long positions just above their liquidation threshold now breach it. Their forced closures add more selling pressure. The cycle accelerates.
Cascades are most severe when open interest is concentrated in a narrow price range - when many positions share similar entry prices and similar leverage levels, their liquidation prices cluster together. A single move through that cluster triggers a chain reaction.
In March 2025, a BTC liquidation cascade on Hyperliquid drew significant attention. A single large position - reportedly around $200 million notional - was structured in a way that its forced closure created substantial market impact as it moved toward liquidation. The event made cascade mechanics visible to a much wider audience. Hyperliquid's insurance fund absorbed the shortfall and the protocol remained solvent, but the episode was a clear demonstration of how position size relative to available liquidity at the liquidation price is the real risk variable - not leverage ratio in isolation.
OI concentration is the thing to watch. When aggregate open interest in a single asset is heavily skewed in one direction, and a large portion of it sits within a tight leverage band, the conditions for a cascade exist. Reading OI distribution - not just total OI - is the relevant skill.
How to read your liquidation price in practice
Your trading interface should show you three things at all times: your current liquidation price, your current margin ratio, and the distance between current mark price and your liquidation price as a percentage.
When mark price is moving toward your liquidation price, you have three options:
- Add margin - increases your collateral, which raises the loss your position can absorb before hitting maintenance margin. This moves your liquidation price further from current mark price.
- Reduce position size - closing part of your position reduces notional value, which reduces the margin required to maintain it. This also moves your liquidation price.
- Close the position - the cleanest option if your thesis is wrong. Closing at a loss you choose is better than being closed by the engine at a price you do not control.
Margin ratio warnings are the signal to act. Most interfaces show a color-coded margin ratio shifting from green to yellow to red as you approach maintenance margin. Do not wait for red. By the time the interface shows red, you have very little distance left - and in a fast-moving market, the engine may trigger before your transaction clears.
In cross margin mode, a single position moving against you affects your margin ratio across all positions. Monitor total account equity, not just the individual position P&L.
What "opaque" really means for your position
When traders talk about opaque liquidation engines on CEXs, the specific concern is this: you cannot verify that the mark price used to liquidate you was computed correctly, that the closing price was the best available, or that the engine did not route your position in a way that benefited the exchange's internal book.
This is not hypothetical. Several exchanges have faced credible accusations of using liquidation engines to generate revenue - specifically by setting mark prices that trigger liquidations at prices favorable to the exchange's proprietary positions. None of these accusations have been definitively proven in court, but the structural incentive exists when the engine is server-side and the operator controls both the mark price computation and the order routing.
On-chain settlement removes that specific risk. The mark price computation is public. The order routing is a transaction on the chain. The liquidation price and the actual close price are both queryable. You can verify what happened to your position after the fact - and so can anyone else.
Verifiability does not eliminate liquidation risk. Your position can still be closed at a bad price during a cascade. But it eliminates the specific risk of an opaque engine acting against your interests without your knowledge.
Non-custodial execution and cascade risk
Trading on Hyperliquid's order book gives you the verifiable liquidation mechanics described above. The next question is what sits between you and that order book, and whether it gives you meaningful control over your risk exposure before a cascade starts.
Stacked Markets is a non-custodial trading terminal built directly on top of Hyperliquid's on-chain central limit order book. It holds no funds and no keys. Every order is wallet-signed by you and routed directly to Hyperliquid's matching engine. The liquidation engine you are subject to is Hyperliquid's - on-chain, deterministic, publicly verifiable.
What Stacked adds is the risk tooling layer Hyperliquid's native UI does not provide:
- Configurable leverage caps - set a maximum limit for your account so a lapse in discipline does not result in a position sitting dangerously close to its liquidation price.
- Notional position limits - cap your total exposure in dollar terms.
- Circuit breakers - halt order submission if you are sending orders too rapidly. Relevant during a cascade, when the instinct is to react fast and the correct action is often to stop and assess.
- IOC limit orders with slippage bounds - no market orders. Before you sign any order, the interface shows you the worst-case fill price. During a cascade, when the order book thins and spreads widen, you know the worst price you can be filled at before you commit.
Non-custodial is not a feature here. It is the architecture. Stacked Markets cannot access your funds, cannot close your positions on your behalf, and cannot override your wallet. That also means your risk management has to be configured before the cascade starts - not during it.
Trade on Hyperliquid's on-chain order book with verifiable settlement and risk controls you configure yourself. Stacked Markets holds no funds and no keys.
FAQs
- What is a liquidation engine in crypto?
A liquidation engine is the automated system that monitors leveraged positions, calculates margin ratios in real time, and closes positions that fall below the maintenance margin threshold. It exists to keep the trading platform solvent when individual traders cannot cover their losses.
- How is my liquidation price calculated?
Your liquidation price is the mark price at which your remaining margin equals the maintenance margin requirement. For a long position in isolated margin mode, it is your entry price minus the loss your collateral can absorb before hitting that floor. The exact formula depends on whether you are in isolated or cross margin mode.
- What is the difference between mark price and last trade price?
Mark price is a smoothed reference price used specifically for margin and liquidation calculations. It is derived from external spot market indexes and designed to resist short-term manipulation. Last trade price reflects the most recent transaction on the exchange and can spike sharply in low-liquidity conditions. Using mark price rather than last trade price prevents manipulation-triggered liquidations.
- What happens if my position is liquidated at a price worse than my bankruptcy price?
If the closing price is worse than the price at which your losses exceed your posted margin, the shortfall is absorbed by the protocol's insurance fund. If the insurance fund is insufficient, the protocol may use auto-deleveraging (ADL) or socialized loss mechanisms to distribute the remaining loss across profitable positions.
- How does a liquidation cascade happen?
A cascade starts when a large position is forcibly closed, creating selling (or buying) pressure that moves mark price. That move pushes other positions with nearby liquidation prices into the engine's trigger range. Their forced closures add more directional pressure, triggering the next layer. Cascades are most severe when open interest is concentrated in a tight leverage band.
- Is a DEX liquidation engine safer than a CEX engine?
Neither is inherently safer in terms of liquidation risk - your position can be closed at a bad price on either. The difference is verifiability. A DEX liquidation engine running on-chain lets you audit the mark price, the closing price, and the sequence of events after the fact. A CEX engine is server-side and not independently verifiable.
- How can I reduce my liquidation risk on a perp DEX?
The most direct controls: keep your margin ratio well above the maintenance threshold, use isolated margin for positions you want to ring-fence, set a maximum leverage limit before you open positions, and monitor open interest concentration in the assets you trade. On Stacked Markets, configurable leverage caps and notional position limits enforce these constraints at the terminal level, before an order reaches the book.
