Trigger condition
An account is liquidatable whenever . Keepers compute health off-chain (using the same formulas asperps-math) and
submit a liquidate tx when it flips negative.
What happens in liquidate
1
Oracle validation
Fresh Pyth Hermes update; confidence and staleness must pass.
2
Health recheck on-chain
Reverts
NotLiquidatable if the account is healthy.3
Cancel resting orders
All the victim’s orders are removed; their reserved margin is forfeited
to the insurance vault, not refunded to the victim. This is part of the
penalty for being liquidated with open orders.
4
Close the full position
The position is closed entirely at oracle price (no slippage).
Realized PnL is computed and applied to the victim’s
collateral.5
Charge the liquidation fee
fee = closed_notional × 500 / 10_000 (5% default).6
Split the fee
- 50% transferred from
collateral_vaultto the liquidator’s token account. - 50% transferred to the
insurance_vault.
7
Settle bad debt
If the victim’s
collateral went negative (oracle moved so fast the fee
couldn’t be absorbed), the insurance fund covers the shortfall.
If the insurance fund is also insufficient, emit BadDebtDetected and
pause the market.Fee recipient
Liquidators receive the reward in the collateral mint (USDC), transferred to a token account they pass in asliquidator_token_account. Spec:
Why is the position closed fully?
V1 uses whole-position liquidation rather than partial unwinds. Rationale:- Simpler on-chain state, no “partially-liquidated” zombie accounts.
- Faster convergence back to solvency.
- Clearer keeper economics, the fee is computed on the full notional.
Insurance fund
The insurance fund is an SPL token account owned by the market PDA. It fills from:- 50% of every liquidation fee
- Forfeited margin of liquidated users’ resting orders
- Admin-seeded funds (one-time boot)
- Bad debt drains it during a liquidation
- V2 governance votes to redirect some funds (not implemented in V1)
BadDebtDetected and pauses. Admin
intervention is required to re-seed and resume.
Keeper economics
- Reward: 2.5% of closed notional (half the liquidation fee)
- Cost: Solana tx fee + RPC latency race
- Risk: Getting out-raced to the fill by another keeper

