High-Frequency Aave v3 Liquidator Bot with Flash Loans and MEV Protection
During sharp market downturns, positions worth tens of millions of dollars become available for liquidation on Aave v3. Bots that execute liquidations first earn a liquidation bonus (5–15% of the debt amount). Those who send transactions 200 ms later get a revert and lose only on gas. The gap between "succeeded" and "missed" lies in architectural decisions made months before the event. Profit depends on reaction speed: liquidating a $100k position can yield up to $15k bonus when the market drops 10%. Our engineers build bots that land in the first wave by optimizing both on-chain and off-chain components.
How Liquidation Works in Aave v3
A position becomes liquidatable when healthFactor < 1:
HF = Σ(collateral_i * liquidationThreshold_i) / totalDebt Liquidation threshold varies by asset: 82.5% for ETH, 75% for WBTC, 65% and lower for more volatile assets. When HF < 1, anyone calls liquidationCall() and receives collateral at a discount—the liquidation bonus. A key nuance in Aave v3: close factor = 0.5 when HF > 0.95, but if HF drops below 0.95, you can liquidate 100% of the debt in one call. This changes the profitability calculation.
Data Sources for Position Discovery
We use three approaches with different trade-offs between latency and completeness:
| Source | Latency | Completeness | Use Case |
|---|---|---|---|
| The Graph (subgraph) | 15–60 s | All positions | Background scan |
| Aave API (positions) | 5–30 s | All positions | Periodic polling |
Borrow events + recomputation |
Real-time | New positions | Add to watchlist |
Our architecture: a background scan via The Graph builds a database of all positions with HF < 1.3 (pre-liquidation watchlist), plus real-time monitoring via WebSocket for Borrow, Repay, LiquidationCall, ReserveDataUpdated events to update HF in the watchlist. When prices change, we recompute HF for the entire watchlist and immediately send transactions for positions where HF has fallen below 1.
Why Use Flash Loans?
liquidationCall requires the debt asset upfront. You don't need your own capital: use a flash loan from the same Aave pool. Borrow debtAsset → call liquidationCall → receive discounted collateral → swap part of the collateral via Uniswap v3 or Paraswap to repay the flash loan → keep the profit. All in one atomic transaction. If the profit is less than the gas cost, the transaction is reverted—you only lose gas.
The liquidator contract implements the IFlashLoanSimpleReceiver interface (Aave v3). In the executeOperation callback:
- Call
POOL.liquidationCall(collateralAsset, debtAsset, user, debtToCover, receiveAToken) - Check the amount of collateral received
- Swap via Uniswap v3 with slippage ≤0.5% (otherwise the liquidation is unprofitable)
- Repay flash loan + fee (0.05% for Aave v3)
MEV Protection and Competition Mitigation
Liquidations are highly competitive. Without prioritization, you risk sandwiches or front-running. Compare methods:
| Method | Effectiveness | Cost | Networks |
|---|---|---|---|
| Flashbots bundle | Eliminates front-running in 90% of cases | 0.1–0.5 ETH | Ethereum |
| Private RPC (bloXroute) | Protects against front-running but not reorgs | Subscription | Ethereum, BNB |
| Dynamic priorityFee | Simple and works, but competition is high | High gas | All EVM |
For comparison, a Flashbots bundle is 10 times more effective than a direct transaction under high competition. On Arbitrum and Polygon, Flashbots does not work, but latency is lower and competition is smaller—direct transactions with slightly higher gasPrice are usually sufficient. For details, see Flashbots documentation.
Bot Architecture
Liquidator Contract (Solidity). Implements IFlashLoanSimpleReceiver, integrates with Uniswap v3 Swap Router. Parameterized: supports multiple DEXs for swapping (fallback from Uniswap to Paraswap if slippage is high). Deployed via Foundry with forge script, verification on Etherscan automatically.
Off-chain Engine (Node.js/TypeScript + viem). Watchlist management, event monitoring, profitability calculation, transaction sending. Configuration via .env: HF thresholds, minimum profit, supported networks, Flashbots RPC.
Infrastructure. Own node or premium RPC (Alchemy Growth/Business tier) for stable WebSocket. Mandatory on Ethereum, optional on L2s.
Profitability calculation details
For each potential liquidation, we simulate: take the current on-chain state (via eth_call), execute liquidationCall and swap, compute profit minus gas. If profit/gas exceeds a set threshold (e.g., 2x), we send the transaction. The threshold is tuned to avoid wasting gas on zero or negative profit liquidations.
What's Included
- Audit of target networks and selection of optimal strategy
- Development of the liquidator smart contract with flash loan and multi-DEX swap
- Off-chain engine with monitoring and calculation
- Integration of MEV protection (Flashbots / private RPC)
- Deployment to chosen networks, contract verification
- Monitoring (Grafana dashboard: P&L, successful liquidations, gas)
- Delivery of source code, documentation, team training
Experience and Guarantees
Our team consists of blockchain engineers with extensive production experience in DeFi. Over many years in the market, we have delivered more than 30 projects automating DeFi, including liquidators for Aave, Compound, and MakerDAO. We provide a warranty on the correct operation of contracts and support clients post-launch. You can significantly reduce gas costs through optimization and earn a steady income from liquidations.
Timelines and Getting Started
A basic bot for one network (Ethereum or Polygon) with flash loan and Uniswap takes 1–1.5 weeks. A multi-network version with Flashbots, dynamic routing, and full monitoring takes 2–3 weeks. Pricing is discussed individually after analyzing your goals. Contact us—we'll assess your project for free within 1 day and propose a plan. Get a consultation right now: we'll help you launch your own liquidator and start earning from any market movements. Order the development of a liquidation bot and start capitalizing on market movements.







