- Install the dependencies
yarn install
For CI:
yarn install --frozen-lockfile
- Configure the environment variables
ETH_RPC_URL=https://ethereum-public.nodies.app
BASE_RPC_URL=https://base-public.nodies.app
SEPOLIA_RPC_URL=https://sepolia-public.nodies.app
ETH_WALLET_PRIVATE_KEY=<YOUR_NON_PRODUCTION_PRIVATE_KEY>
❗❗❗ IMPORTANT: Do not use production/mainnet private keys in your .env ❗❗❗
- Configure the bot's settings on our index file.
const config: BotConfig = {
chainId: 1, // Ethereum Mainnet
cronSchedule: "*/10 * * * * *", // Runs every 10 seconds
timeZone: "America/Los_Angeles",
maxSlippage: 50, // this is scaled by 10000, so 50 is 0.5%
maxImpact: 2, // this is scaled by 100, so 2 is 2%
swapFromToken: USDC_TOKEN_MAINNET,
swapToToken: USDC_TOKEN_MAINNET,
minProfit: 500, // in USD
};
- Run the bot 🤖
yarn start
- Fetches whitelisted markets from Morpho API
- Fetches liquidatable positions from Morpho API
- Swaps configurable asset to obtain loan tokens
- Checks existing allowances before approving tokens
- Liquidates profitable positions in Morpho Blue
- Swaps liquidated collateral tokens for configurable asset
- Flashbots Provider integration ⚡️🤖
- Periodical execution via cron job
- Chain, swap slippage and swap max impact are configurable
- This bot supports the following networks: Ethereum Mainnet, Ethereum Sepolia and Base Mainnet
- This bot has been tested on Sepolia, you can track the bot interactions here.
- This bot only executes full liquidations, but it can be modified to use a different strategy (i.e. partial liquidations)
- This bot can run in Sepolia, however, the swaps won't be executed because ParaSwap is not available on Sepolia. It will only fully liquidate the position; and it will not sell the seized collateral or calculate profits.
- The scripts used to deploy the contracts (oracle, tokens) and send the supply collateral/borrow transactions can be found here.
- Integrate a new indexer for positions morpho-markets
- Smart contracts executed liquidation w/ flash loans
- Add support for AWS Secrets Manager to pull private keys from it
- Reth Extension (ExEx) for live tracking of liquidatable positions as indexer
Morpho's liquidation bot example was a valuable reference for developing this bot, along with Morpho's docs.