Build bots that monitor credit accounts and execute profitable liquidations.
Overview
Liquidation bots need to:
Find accounts with low health factors
Filter for liquidatable accounts
Compute optimal liquidation paths
Execute liquidations profitably
This guide covers each step with verified SDK patterns.
Understanding Liquidation
WHY: Know what you're building before writing code.
When Accounts Become Liquidatable
An account becomes liquidatable when its health factor drops below 1.0:
Health Factor = Total Weighted Collateral Value / Total Debt
Where:
- Weighted Value = Sum of (Token Balance * Price * Liquidation Threshold)
- Total Debt = Principal + Accrued Interest + Quota Fees
Health factor is scaled by 10000, so healthFactor < 10000 means liquidatable.
Liquidator receives premium (configured per Credit Manager)
Remaining funds go to account owner (if any)
The liquidator provides the multicall that handles collateral conversion. This is where profit comes from - efficient routing means better conversion rates.
Finding Liquidatable Accounts
WHY: Efficiently scan all accounts to find opportunities.
Using CreditAccountCompressor
The CreditAccountCompressor has built-in health factor filtering:
Filter by isLiquidatable
The isLiquidatable field accounts for additional protocol checks:
Pagination for Large Result Sets
The compressor returns paginated results. Iterate through all pages:
Account Analysis
WHY: Understand an account's composition before liquidating.
Collateral Breakdown
Estimating Profit
Building the Liquidation Multicall
WHY: The multicall handles collateral conversion and determines profit.