Liquidations

trading

A position is liquidated when its remaining collateral falls below the level needed to keep the pool solvent. The protocol closes the position at the oracle price, returns whatever collateral is left to the trader, and charges a small penalty that goes to the keeper and the pool.

Liquidations are how the pool stays whole. Because the DLP is the counterparty, every dollar of trader loss is a dollar of pool profit — but only if the position is closed before its collateral runs out. If a position were allowed to go past zero, the pool would absorb the shortfall.

The maintenance margin

Every position has a maintenance margin — the minimum collateral, as a fraction of size, that must back the position. For diviko perps this is fixed per market:

MarketMaintenance margin
ETH-PERP1.25%
BTC-PERP1.25%
SOL-PERP2.5%

A position is liquidatable the moment its remaining collateral, valued in USD at the current oracle price and net of accrued borrow fees, drops below maintenance margin × size.

The liquidation price

For a long position with collateral C, size S, entry price Pe, accrued fees F, and maintenance margin m:

liq_price_long  = P_e × (1 − (C − F − m × S) / S)
                = P_e × (1 − (C − F)/S + m)

For a short:

liq_price_short = P_e × (1 + (C − F − m × S) / S)
                = P_e × (1 + (C − F)/S − m)

Two consequences fall out of these formulas:

Worked example

An ETH long opened at $3,000 with 1 ETH ($3,000) of collateral at 10x has $30,000 of notional size. Maintenance margin is 1.25% × $30,000 = $375.

liquidatable when remaining collateral ≤ $375

at open, with no fees:
  buffer = $3,000 − $375 = $2,625 (8.75% of size)
  price can fall 8.75% before liquidation
  liq_price = $3,000 × (1 − 0.0875) = $2,737.50

After a week at an average 0.01%/hr borrow rate, ~$504 of fees have accrued. The buffer is now $3,000 − $504 − $375 = $2,121, so the liquidation price has risen to ~$2,787.90 — even though the trader has done nothing.

The execution flow

Liquidations are permissionless. Anyone running a keeper bot can call the liquidate entry point on a position. The protocol:

  1. Reads the current oracle price for the market.
  2. Recomputes the position's accrued fees up to the current block timestamp.
  3. Checks that the remaining collateral is at or below maintenance margin. If not, the call reverts and the keeper pays the gas with no penalty.
  4. Closes the position at the oracle price, settling the loss against the pool and releasing the reserved inventory.
  5. Charges the liquidation fee — a flat 1% of position size — taken from whatever collateral remains after the loss is settled.
  6. Pays the keeper an execution reward equal to 50% of the liquidation fee, and credits the rest to the pool.
  7. Returns any leftover collateral to the trader. In a clean liquidation this is whatever sits above zero after settling loss, borrow fees, and the liquidation fee. In a violent move it may be zero.

The keeper reward is what makes the system self-policing. As soon as a position becomes liquidatable, there is a strictly positive payoff for closing it, and competition among keepers compresses the window.

Bad debt

In a fast move, the price can gap past the liquidation level before any keeper has a chance to act. If the position closes underwater — that is, the loss exceeds the available collateral — the pool eats the difference. This is the structural risk that DLP holders are paid to bear.

Two mechanisms keep bad debt rare:

Per-market open-interest caps and per-side reserve caps cap the total bad-debt exposure the pool can take at any time, regardless of how many positions are liquidatable simultaneously.

Self-liquidation

If you choose to close a losing position manually, you pay only the closing fee (0.1% of size), not the liquidation penalty (1%). Most users in a clearly losing trade are better off closing themselves than waiting for a keeper.

You cannot "top up out of" a liquidation that has already triggered. Once the oracle has crossed your liquidation price, the position is liquidatable. Even if you submit a collateral add in the same block, a keeper can win the race. To be safe, keep effective leverage well below the maximum, especially around economic events.