AccountManager.liquidate() on undercollateralized accounts. Anyone can run one — no whitelist, no special permissions.
How Liquidation Works
When a margin account’s health factor drops to or below 1.1×:- Any caller can call
AccountManager.liquidate(smart_account) - The protocol repays all debt by drawing from the SmartAccount’s collateral
- Remaining collateral is swept to the trader
- The liquidator pays gas and receives no explicit bonus in the current version
Vanna V1 does not currently pay a liquidation bonus to the bot. The economic incentive is keeping the protocol healthy. A liquidation premium may be introduced in a future version.
Architecture of a Liquidation Bot
Step 1: Discover All Margin Accounts
Fetch the full list of accounts from AccountManager events (Mercury) or read from Registry:Via Mercury (recommended for production)
Via Registry Contract
Step 2: Check Health Factor for Each Account
Step 3: Execute Liquidation
Full Bot Loop
Handling Race Conditions
Multiple bots may attempt to liquidate the same account simultaneously. Theliquidate() function will succeed for one and fail for the others (the account is no longer unhealthy after the first liquidation).
Handle this gracefully:
Monitoring with Mercury Events
Set up event tracking to know when liquidations happen in real time:Bot Account Setup
Your bot needs a funded Stellar testnet account with enough XLM to pay transaction fees:liquidate() call costs ~0.001–0.01 XLM in fees. Keep the bot account funded.
Production Considerations
Related
- AccountManager Reference —
liquidate()function details - Risk Engine Reference — health factor computation
- Mercury Indexer — fetching liquidation events
- Math Reference — liquidation condition formula

