Guide

Auto-deleveraging: who gets closed when an account goes negative

Auto-deleveraging (ADL) is what an exchange falls back on when a liquidation comes too late and an account has already gone below zero. Somebody has to take that loss. On Hyperliquid (and on Functor's chain, which copies the rule) the traders on the other side are ranked by (mark price ÷ entry price) × (position value ÷ account value), and the ones with the highest score get closed first at the previous mark price. I think the surprising part is who that hits, because it's mostly people running a high multiple on a winning trade and hardly ever the ones sitting on the biggest profit.

When ADL happens

I'd guess most traders never see it happen to them. When an account falls to its maintenance margin the exchange first tries to close the position on the order book. If the book can't absorb it, the position is transferred to a backstop vault (on Functor that's the liquidity vault). ADL only comes in after both of those have failed, which usually means a sudden move against a thin book where an account goes straight through zero before anybody can take the position over. I've written up how that first trigger is worked out in the liquidation price guide, so here I'll stick to what happens after it.

At that point the account owes more than it holds, and somebody has to make up the gap. Hyperliquid's documentation calls ADL the final safeguard on the platform's solvency, and when I first read it I was surprised by how simple the idea is: the exchange closes positions on the profitable side against the underwater account, so that the books still balance and nobody is left holding bad debt.

The ranking key

I like that Hyperliquid publishes the exact sorting index it uses to decide who gets closed, because it means you can work out your own place in the queue. Functor's clearinghouse computes the very same number for every account that holds the opposite side:

key = (mark_price / entry_price) × (notional_position / account_value)

As I read it, the first part grows with how far the trade has gone your way, while the second part is really just the multiple you're running, measured against your whole account balance. Accounts are then closed from the highest key downwards until the underwater position is fully covered. On Functor any ties go to a fixed order by address, which matters more than it sounds, because every validator has to pick exactly the same people. The close itself happens at the previous mark price, and that's the only reason our chain keeps the previous mark in its state at all.

A worked example

The numbers below are invented for illustration, but the arithmetic is exactly what the chain does. Let's say BTC has jumped to a mark of $60,000, and a trader who was holding a 1.2 BTC short has gone below zero before the book or the vault could take the position over. There are three accounts holding longs on the other side:

TraderLongEntryAccount valueProfitMultipleKey
C0.5 BTC$59,000$3,000$50010x10.17
A1 BTC$50,000$15,000$10,0004x4.80
B2 BTC$40,000$120,000$40,0001x1.50

C has made the least money of the three, only $500, but C is running 10x, so C's key of 10.17 is by far the highest and C's whole 0.5 BTC is closed first. That leaves 0.7 BTC still to cover, which comes out of A's position, so A ends up holding 0.3 BTC. B has the biggest profit by a long way, $40,000, but at 1x B isn't touched at all. I'd say that's the most useful thing to take from the rule: if you want to stay out of an ADL queue, keeping your multiple low matters much more than how much you're up.

Being deleveraged isn't a loss in itself, because your position is closed at the previous mark and you keep the profit up to that price. What you lose is the rest of the trade, and if you had a hedge somewhere else, it's now unhedged.

Work out your own ADL score

You can put in your position and your account value to see the key the chain would give you. It only means something next to the other traders on the same side, so I've shown how it compares with the three accounts in the example above.

Your key is 3.27 (a multiple of 3.0x). In the example you'd be closed after C (10.17) and A (4.80), and before B (1.50).

Who pays for what's left

Closing the opposite positions flattens the underwater account, although its balance can still be negative afterwards. On Functor that shortfall is covered by the liquidity vault's cash first. Anything the vault can't cover is shared between the traders who were just deleveraged in proportion to how much of their position was closed. Traders who weren't in the queue never pay anything. Withdrawals from the affected accounts wait until that's settled, which follows dYdX's rule.

Also, if you want to see the full sequence from the book to the vault and then ADL, it's laid out on the tech page, and you can watch real liquidations on the testnet in the block explorer once they happen.

Questions

Can I be auto-deleveraged on a losing position?

I don't think it's likely in practice. The traders on the other side of an underwater account have usually made money from the same move, and the key rewards profit, so a losing position sits near the bottom of the queue and would only be reached if every winning position on that side had already been used up.

Does a lower multiple keep me out of ADL?

It lowers your place in the queue a lot, as trader B shows in the example. I'd be careful about saying it keeps you out entirely, though, because with no borrowed exposure at all you're still on the list in theory. You'd just be close to the end of it, behind everyone who's running a higher multiple on the same side, and I can't think of a realistic move that would reach you there.

How often does ADL happen?

Rarely, as far as I can tell, because the order book and the backstop vault take nearly every liquidation before it gets that far. It's meant for the moves that are too fast for both of them. On our testnet I've kept it mostly so the chain can never end up owing money it doesn't have, and I'd be quite surprised to see it fire there with mock funds.

Sources

The ranking key, the close at the previous mark price and the description of ADL as a final safeguard all come from Hyperliquid's page on auto-deleveraging, and the order of book, vault and then ADL is on their liquidations page. What Functor does with the remaining deficit (the vault first, then the deleveraged traders pro rata) is how our own clearinghouse is written, and the numbers in the example are my own, worked out with the key above, so if anything doesn't add up I'd like to hear about it on Telegram.