A bot that monitors Aave positions on Metis network and executes liquidations when positions become unhealthy, helping to maintain the health of the protocol while creating profit opportunities.
This bot continuously monitors Aave borrowers on the Metis network, identifies positions that have fallen below the health factor threshold, and executes liquidations using flash loans. It's designed to operate efficiently with minimal configuration, making it accessible for both small and large liquidators.
- Real-time Monitoring: Continuously checks borrower positions via The Graph API
- Health Factor Calculation: Computes health factors for monitored accounts
- Liquidation Automation: Automatically executes liquidations when profitable
- Flash Loan Integration: Uses flash loans to minimize capital requirements
- Configurable Settings: Adjust thresholds and parameters via environment variables
- Detailed Logging: Comprehensive logging for monitoring and debugging
- The bot queries Aave's subgraph for recent borrowers
- It calculates health factors for each borrower
- When it identifies positions below the liquidation threshold, it triggers the liquidation process
- The liquidation is executed using a flash loan to borrow the required debt asset
- The collateral is received, swapped (if necessary), and the flash loan is repaid
- Any profit remains in the liquidator's wallet
- Node.js (v14+)
- npm or yarn
- Metis wallet with METIS for gas
- Basic understanding of DeFi liquidations
- Clone the repository:
git clone https://github.com/cobibean/aave-liquidator-bot.git
cd aave-liquidator-bot
- Install dependencies:
npm install
- Create your environment file:
cp .env.example .env
This bot interacts with a custom AaveLiquidator smart contract that handles the flash loan and liquidation process. The contract code is maintained in a separate repository at:
https://github.com/cobibean/flashloan-smart-contracts
The compiled contract artifacts are included in this repository under the artifacts/
directory.
Edit your .env
file with the following parameters:
# RPC Configuration
RPC_URL=https://andromeda.metis.io/?owner=1088
# Contract Addresses
AAVE_LIQUIDATOR_ADDRESS=0x... # Your deployed liquidator contract
POOL_ADDRESS=0x... # Aave Pool contract on Metis
POOL_ADDRESSES_PROVIDER=0x... # Aave Pool Addresses Provider on Metis
DEBT_ASSET_ADDRESS=0x... # USDC address on Metis
# Bot Configuration
LIQUIDATION_THRESHOLD=1.0 # Health factor threshold for liquidation
# Security
PRIVATE_KEY= # Your wallet private key
# Optional
TEST_MODE=true # Set to false for actual liquidations
Run the bot:
node bot.js
For production use, consider using a process manager like PM2:
npm install -g pm2
pm2 start bot.js --name "aave-liquidator"
pm2 logs aave-liquidator
The bot outputs detailed logs showing:
- Borrowers being monitored
- Health factors being calculated
- Liquidation opportunities identified
- Execution of liquidations
- Profits from successful liquidations
Please refer to the SECURITY.md file for important security information.
This is an experimental project - use at your own risk. This bot interacts with real DeFi protocols and can execute liquidations with financial consequences. Never use private keys with real funds for testing.
This project is licensed under the MIT License - see the LICENSE file for details.