

The liquidation waterfall: collateral first, insurance for shortfall.
The collateral ratio
current_debt is the funding-adjusted debt (see Shorts). A position becomes liquidatable when:
maintenance_cr_bps = 12000, that is CR below 120%. Positions are opened at or above initial_cr_bps (150% by default), so there is a buffer zone between the tightest permitted open and the liquidation threshold.
Liquidation checks use the index TWAP, never the AMM spot price. Pushing the AMM around does not liquidate anyone; only the oracle index, which is itself EMA-smoothed and breaker-guarded, moves CR. See Circuit Breaker.
What happens in a liquidation
liquidate() is permissionless. In v1 it closes the full position in one call; there are no partial liquidations.
- The liquidator must hold the position’s full current debt in synth. The program transfers it from their wallet back into the market’s treasury reserve.
- The liquidator is paid from the position’s collateral:
- If collateral does not cover the target payout, the insurance fund tops up the difference, up to its available balance.
- Any collateral left after the payout is refunded to the position owner.
- The position’s debt and collateral are zeroed. The owner can later call
close_positionto reclaim rent.
liq_bonus_bps = 500, the liquidator earns a 5% premium over the debt value they repaid.
Sourcing the synth to repay
Liquidators need the debt amount in synth at execution time. The usual loop:- Detect an underwater position (watch
ShortChanged,IndexPushed, andFundingAccruedevents, or poll positions). - Buy the required synth on the market’s AMM.
- Call
liquidate()in the same transaction bundle. - Profit = payout minus synth cost minus fees.
Edge cases
- Frozen market. Liquidations are blocked while a market is frozen. A bad oracle print should never liquidate anyone, so the breaker pauses liquidations along with everything else.
- Stale index. Liquidations also require a fresh index: past
max_index_age_secswithout a push,liquidatereturnsIndexStale. Nobody should be liquidated against a price the oracle stopped standing behind. See the staleness guard. - Insurance exhausted. If collateral plus available insurance cannot reach the target payout, the liquidator receives whatever is available. Deeply underwater positions may briefly be unprofitable to liquidate; the bonus and the buffer between 150% and 120% exist to make that rare.
- Debt rounding. Funding scaling can leave the current debt a few base units off the originally drawn amount. Always compute the repay amount from on-chain state, not from your records.

