Published

Every perp exchange I've built a liquidation calculator for so far shares one design: breach maintenance margin on a position, and that position closes. All of it, usually with a penalty on top. BULK's perpetual DEX, which leaned hard into "portfolio-wide risk management" as its pitch this year, does something different — it computes the smallest amount of notional it needs to trim, anywhere in the account, to get equity back above the maintenance requirement, and stops there. I built a calculator around that mechanism and ran two portfolios through it to see exactly how much smaller "smallest amount" actually is, and where it stops being small.

Case 1: the mild breach — 10.53% closed, 89.47% survives

Account: a $60,000 long BTC position (15x leverage, $4,000 posted margin) down 5% from a $60,000 entry to $57,000, and a $40,000 long ETH position (also 15x, $2,666.67 posted margin) down 2% from $3,000 to $2,940. Both carry a 3% maintenance rate. Total collateral posted: $6,666.67. Net unrealized loss: -$3,800.00 ($3,000 on BTC, $800 on ETH). Account equity: $2,866.67. Total maintenance requirement: $1,800 (BTC) + $1,200 (ETH) = $3,000.00. Health ratio: 2,866.67 ÷ 3,000 = 0.9556x — below the 1.0x minimum, liquidation triggers.

A full-liquidation exchange closes the entire $60,000 BTC position here (it's the one that breached), or in some designs the whole $100,000 account. The haircut engine instead targets a 1.02x restored ratio: M_target = 2,866.67 ÷ 1.02 = $2,810.46, so it needs to shed 3,000 − 2,810.46 = $189.54 of maintenance requirement. Since BTC's maintenance rate is 3%, that's 189.54 ÷ 0.03 = $6,318.08 of BTC notional — 10.53% of the position. The other 89.47% of BTC stays open. The ETH position, the smaller loser, isn't touched at all.

Case 2: the severe breach — the "winning" position gets cut too

Same shape, worse numbers. A $100,000 long BTC position (20x, $5,000 margin) drops 8% from $60,000 to $55,200, losing $8,000. A $50,000 long ETH position (20x, $2,500 margin) actually gains 2%, up $1,000. Collateral: $7,500. Net PnL: -$7,000. Equity: $500.00. Maintenance requirement: $2,500 (BTC) + $1,250 (ETH) = $3,750.00. Health ratio: 0.1333x — a severe breach, not a marginal one.

Targeting a 1.05x restored ratio needs M_target = 500 ÷ 1.05 = $476.19, a shortfall of 3,750 − 476.19 = $3,273.81 to shed. BTC's full maintenance-requirement capacity is only $2,500 (its entire position), so the engine closes 100% of the $100,000 BTC position — takes the full $2,500 — and still has $773.81 of shortfall left. It moves to ETH next, the only capacity remaining, and closes 773.81 ÷ 0.025 = $30,952.38 of it: 61.90% of a position that was profitable when the liquidation started. Total notional closed across the account: $130,952.38 — 130.95% of the original BTC position by itself, or about 87% of the original $150,000 combined account.

ScenarioHealth ratioBTC closedETH closedTotal notional closed
Case 1 — mild0.9556x10.53% ($6,318.08)0%$6,318.08
Case 2 — severe0.1333x100% ($100,000)61.90% ($30,952.38)$130,952.38

The part that isn't intuitive: the loser gets closed first, always

The engine I modeled works worst-loss-first — it fully exhausts the maintenance-requirement capacity of the biggest loser before touching anything else. That's why ETH survives untouched in Case 1 despite also being a loser: BTC alone had enough capacity ($1,800 of requirement, more than the $189.54 needed) to cover the shortfall. It's also why ETH gets cut in Case 2 even though it was profitable at the moment of liquidation — BTC's entire $2,500 of capacity wasn't enough, and closing notional reduces the maintenance requirement by notional × maintenance_rate regardless of whether that notional belongs to a winning or losing trade. A profitable position in the same account is not protected from a severe-enough shortfall elsewhere in the portfolio.

The one case where none of this math helps: equity at or below zero before any trimming starts. Both scenarios above had positive equity ($2,866.67 and $500.00) — the haircut mechanism only works in the range where there's still something to restore. Below zero, it's outright insolvency, and the whole account goes, exactly like a full-liquidation exchange. Run your own two-position account through the same worst-loss-first math on the portfolio margin partial liquidation calculator — it shows the same waterfall table these two cases came from, with your own numbers.

Trade where the calculators point
Share: 𝕏 Post Reddit