Liquidation
For liquidation and stability purposes, the mark price used for calculating margin fractions and liquidation thresholds will be the index price of the underlying for perpetual futures. This is to protect traders against large liquidation cascades or liquidity shortages.

Partial Liquidation Process

The partial liquidation process will only liquidate the trader until they are back above the margin requirements. This is different from full liquidations, where trader's entire position and collateral is liquidated against the book, which is both unfavourable for traders, and can lead to market instability.
Anyone can run a liquidator bot and earn liquidation rewards.
Here are example implementations of liquidator bots: - Rust: https://github.com/01protocol/zo-keeper - TypeScript: https://github.com/01protocol/ts-liquidator

If liquidatee OMF < CMF​

• Open orders will be cancelled per market until there are no more orders to cancel, or when the MF is no longer below the CMF

If liquidatee MF < MMF​

• Liquidatee's perp positions or spot positions will be liquidated based on notional size, until the liquidatee's MF is back above the MMF
• Perp position liquidations will reduce the trader's position, and charge a liquidation fee
• Spot position liquidations will reduce a borrower's debt, by liquidating a positive supply collateral (chosen by the liquidator). The liquidatee also incurs a liquidation fee.
• Liquidation fee is taken from the change in quote such that
$\delta Quote = \delta Base \times price \times (1 \pm liqFee)$
where
$liqFee = liqFee_{market}$
for perp positions and
$liqFee = \frac{1+liqFee_{borrowed}}{1-liqFee_{taken}} - 1$
for spot

Bankruptcy

If liquidatee's total account value is negative, and all orders are cancelled, all positions closed, and no collateral above dust threshold, then liquidatee is in bankruptcy.
• The net negative debt will be transferred from liquidatee to liquidator
• The value of the negative debt in USD, plus liquidation fee, will then be transferred from the insurance fund to the liquidator to compensate
• If the insurance fund is depleted, the loss will be socialized among all USDC depositors from their supply APY