Liquidations
How liquidations protect the protocol and its users
Liquidation Eligibility
A position becomes liquidatable when:
health_factor < 1.0This means the risk-adjusted collateral value no longer covers the debt.
Close Factor
The close factor determines how much of a position can be liquidated in a single transaction:
| Health Factor | Close Factor | Meaning |
|---|---|---|
| 0.95 - 1.0 | 50% | Partial liquidation |
| < 0.95 | 100% | Full liquidation allowed |
Partial liquidation gives borrowers a chance to recover their position before complete closure.
Liquidation Bonus
Liquidators receive a bonus as incentive to maintain protocol health:
| Asset | Liquidation Bonus |
|---|---|
| BTC | 10% |
| ETH | 10% |
| Stablecoins | 5% |
The bonus is paid in collateral tokens, meaning liquidators receive more collateral than the debt they repay.
Liquidation Math
Collateral Calculation
max_repay_amount = position.debt × close_factor
repay_value_usd = repay_amount × debt_asset_price
bonus_value_usd = repay_value_usd × liquidation_bonus
seized_value_usd = repay_value_usd + bonus_value_usd
seized_collateral = seized_value_usd / collateral_asset_priceProtocol Fee
The protocol takes a small fee from liquidations:
protocol_fee = seized_collateral × protocol_liquidation_fee (e.g., 2%)
liquidator_receives = seized_collateral - protocol_feeExample Liquidation
Underwater Position:
Borrower:
Collateral: 1 BTC @ $50,000 (LT = 80%)
Debt: $41,000 USDC
Health Factor: (50000 × 0.80) / 41000 = 0.976 (liquidatable)Liquidator Action:
Close factor: 50% (HF > 0.95)
Max repay: $41,000 × 50% = $20,500 USDC
Liquidation bonus: 10%
Bonus value: $20,500 × 0.10 = $2,050
Total seized value: $20,500 + $2,050 = $22,550
Seized BTC: $22,550 / $50,000 = 0.451 BTC
Protocol fee (2%): 0.451 × 0.02 = 0.009 BTC
Liquidator receives: 0.451 - 0.009 = 0.442 BTCResult:
Borrower after liquidation:
Collateral: 1 - 0.451 = 0.549 BTC
Debt: $41,000 - $20,500 = $20,500 USDC
New HF: (0.549 × 50000 × 0.80) / 20500 = 1.07 ✓ Safe
Liquidator profit:
Paid: $20,500 USDC
Received: 0.442 BTC = $22,100
Profit: $1,600 (7.8%)
Protocol:
Earned: 0.009 BTC = $450 (treasury shares)Liquidation Flow
Atomic State Updates
Liquidations update state atomically before any async operations:
- Burn borrower's debt shares - Reduces their debt
- Burn borrower's collateral shares - Seizes collateral
- Mint treasury shares - Protocol fee captured
- Record liquidation event - Audit trail
The actual asset transfers (debt repayment, collateral delivery) happen asynchronously via the WAL system.
Learn more about Write Ahead Logging here.
Finding Liquidatable Positions
Liquidators can query for underwater positions:
get_liquidatable_users(offset: u64, limit: u64) -> Vec<LiquidatableUser>Returns positions where health_factor < 1.0, including:
- User principal
- Current health factor
- Collateral positions
- Debt positions
- Maximum liquidatable amount
Liquidator Requirements
To execute a liquidation, the liquidator must:
- Have sufficient debt asset to repay the borrowed amount
- Sign the transaction with their wallet
- Specify collateral pool to receive seized assets
- Provide receiving address for the collateral
Liquidations are competitive. Successful liquidators typically run automated bots that monitor positions and execute quickly when opportunities arise.
Economic Security
The liquidation mechanism provides several security guarantees:
| Feature | Purpose |
|---|---|
| Overcollateralization | Positions start with buffer above liquidation threshold |
| Liquidation bonus | Incentivizes quick liquidation before bad debt |
| Protocol fee | Builds treasury for unexpected losses |
| Close factor | Allows partial recovery for borrowers |
| Price oracles | Accurate valuations for fair liquidations |