Liquidation Conditions
When Can Accounts Be Liquidated?
An account becomes liquidatable when:twvUSD: Total weighted value (collateral × liquidation thresholds × quota limits)totalDebtUSD: Total debt including principal, base interest, quota interest, and fees
minHealthFactor = 10000 (100%).
Accounts can be liquidated as soon as health factor drops below 100%, even by a tiny amount. There’s no grace period or buffer.
Liquidation Types
Full Liquidation
Full liquidation closes the entire account:- Verify Liquidatable: Check that health factor < 100%
- Calculate Debt: Compute total debt with all interest and fees
- Execute Multicalls: Allow liquidator to perform operations:
- Calculate Payments: Determine amounts to pool, treasury, and liquidator
- Transfer Funds: Send payments to appropriate recipients
- Close Account: Return account to factory
- Emit Event: Log liquidation details
- ✅ External calls to adapters (swap collateral)
- ✅ Add collateral (liquidator can add funds)
- ✅ Withdraw collateral (liquidator extracts profit)
- ❌ Increase debt (cannot borrow during liquidation)
- ❌ Decrease debt (handled automatically)
- ❌ Update quota (not needed during liquidation)
Partial Liquidation
Partial liquidation allows targeted repayment:creditAccount: The account to partially liquidatetoken: Collateral token to seizerepaidAmount: Amount of underlying to repayminSeizedAmount: Minimum collateral to receive (slippage protection)to: Recipient of seized collateralpriceUpdates: Optional on-demand price updates
- Verify Liquidatable: Account must have HF < 100%
- Transfer Repayment: Liquidator sends
repaidAmountin underlying - Calculate Seized Amount:
- Apply Fee: Deduct protocol liquidation fee from seized amount
- Transfer Collateral: Send seized tokens to liquidator
- Update Debt: Decrease account debt by
repaidAmount - Verify Health: Account must remain liquidatable or become healthy
Partial liquidations must either:
- Restore account health factor to ≥ 100%, or
- Leave account still liquidatable
Liquidation Economics
Liquidation Parameters
Each credit manager has liquidation parameters:feeLiquidation: Protocol fee on collateral value (e.g., 1% = 100 bps)liquidationDiscount: Collateral discount (e.g., 95% = 9500 bps)- Discount = 1 - Premium
- 95% discount = 5% premium to liquidator
feeLiquidationExpired: Higher fee for expired accountsliquidationDiscountExpired: Lower discount (higher premium) for expired accounts- Used when credit facade has passed expiration date
Payment Calculation
Liquidation payments are calculated using thecalcLiquidationPayments function:
-
Total Debt:
-
Liquidation Fee:
-
Available Funds (after premium to liquidator):
-
Amount to Pool:
-
Determine Outcome:
Liquidation Examples
Example 1: Profitable Liquidation
Example 1: Profitable Liquidation
Initial State:Outcome:
- Debt: 8,000, interest: $1,000)
- Collateral: $10,000
- Liquidation fee: 1%
- Liquidation discount: 95% (5% premium)
- Health factor: 85% (liquidatable)
- ✅ Pool fully repaid
- ✅ Protocol earns fees
- ✅ Liquidator earns $500
- ✅ Borrower receives $400 back
Example 2: Break-Even Liquidation
Example 2: Break-Even Liquidation
Initial State:Outcome:
- Debt: 9,000, interest: $500)
- Collateral: $10,000
- Liquidation fee: 1%
- Liquidation discount: 95%
- Health factor: 90%
- ✅ Pool recovers debt + interest
- ❌ Protocol loses liquidation fee
- ✅ Liquidator earns $500
- ❌ Borrower receives nothing
Example 3: Underwater Liquidation
Example 3: Underwater Liquidation
Initial State:Outcome:
- Debt: 9,000, interest: $800)
- Collateral: $10,000
- Liquidation fee: 1%
- Liquidation discount: 95%
- Health factor: 98%
- ⚠️ Pool incurs $300 loss
- ❌ Protocol earns nothing
- ✅ Liquidator earns $500
- ❌ Borrower receives nothing
- Attempt to cover loss by burning treasury shares
- If treasury shares insufficient, pool incurs bad debt
- Bad debt dilutes all LPs proportionally
Example 4: Severe Undercollateralization
Example 4: Severe Undercollateralization
Initial State:Outcome:
- Debt: $9,500
- Collateral: $8,000 (market crash)
- Liquidation fee: 1%
- Liquidation discount: 95%
- Health factor: 84% (very underwater)
- ⚠️ Pool incurs $1,900 loss
- ❌ Substantial bad debt
- ✅ Liquidator earns $400
- ❌ Borrower loses everything
- LPs face tail risk
- Treasury shares provide first-loss buffer
- Conservative LTs are crucial
- Liquidations must happen quickly
Liquidator Operations
Liquidation Strategies
Liquidators typically use multicalls to optimize profit:- Price Updates: Use on-demand updates if prices are stale
- Collateral Conversion: Swap to underlying for efficient debt repayment
- Additional Funding: May need to add funds if collateral insufficient
- Profit Extraction: Withdraw excess collateral as profit
- Gas Optimization: Minimize number of operations
Liquidator Bots
Successful liquidation requires:- Monitoring: Continuously check account health factors
- Price Feeds: Track both protocol and market prices
- Gas Management: Use appropriate gas prices for urgency
- MEV Protection: Consider private mempools or MEV-share
- Capital Efficiency: Use flash loans or own reserves
- Add collateral
- Repay debt
- Swap positions
- Adjust quotas
- Execute protection strategies
- Automated liquidation protection
- Stop-loss mechanisms
- Rebalancing strategies
- Dynamic health management
Loss Handling
Treasury Share Buffer
When liquidations result in losses, the protocol attempts to cover them:- Protocol fees absorbed: Liquidation fee foregone
- Treasury shares burned: First-loss capital
- LP dilution: If treasury exhausted, all LPs share loss
Loss Policy
Credit facades can implement custom loss policies:- Use insurance funds
- Trigger emergency responses
- Notify external systems
- Implement custom recovery mechanisms
Liquidation Protection
Monitoring Health Factor
Users should actively monitor their accounts:- Check health factor regularly (every block in volatile markets)
- Set alerts for HF < 110% (10% buffer)
- Monitor collateral token prices
- Watch for LT ramping schedules
Protection Strategies
Maintain Buffer
- Keep health factor > 120%
- Leave room for price volatility
- Account for worst-case scenarios
- Consider correlation between assets
Use Bot Protection
- Grant bot permissions
- Set up automated monitoring
- Define trigger conditions
- Test protection mechanisms
Diversify Collateral
- Use multiple collateral types
- Avoid concentration in volatile assets
- Balance high and low LT tokens
- Consider correlation during stress
Active Management
- Repay debt during downturns
- Add collateral proactively
- Reduce exposure in high volatility
- Close positions before expiration
Emergency Actions
If health factor drops dangerously:Expired Account Liquidation
Some credit facades have expiration dates:- Accounts use
feeLiquidationExpiredandliquidationDiscountExpired - Typically less favorable to borrower (higher fees/premium)
- Encourages users to close before expiration
- Protects lenders from indefinite exposure
- Close positions before expiration
- Monitor expiration dates
- Understand expired liquidation terms
- Migrate to new facades if needed
Best Practices
For Borrowers
- Monitor health factor continuously
- Maintain adequate buffer (≥20%)
- Set up bot protection
- Avoid over-leverage
- Close positions during extreme volatility
- Understand liquidation costs
- Have emergency funds ready
For Liquidators
- Monitor accounts systematically
- Calculate profitability before acting
- Use flash loans for capital efficiency
- Optimize gas usage
- Handle multiple collateral types
- Account for slippage and fees
- Protect against MEV attacks
For Protocol Designers
- Set conservative liquidation thresholds
- Maintain healthy treasury buffer
- Monitor aggregate exposure
- Test liquidation parameters
- Consider tail risk scenarios
- Implement circuit breakers
- Audit liquidation logic thoroughly
Liquidations are a critical safety mechanism. Properly incentivized liquidators ensure the protocol remains solvent even during market stress.