A concrete example of a liquidation bot designed for Curve LlamaLend showing how to identify & liquidate unhealthy positions, contributing to the platform stability while offering profit opportunities.
This bot iterates throught LlamaLend lending pools & check for unhealthy positions. When an unhealthy position is detected, it calculates if the liquidation is profitable by simulating a swap of collateral_token
to borrowed_token
.
If the liquidation is profitable, it proccess the liquidation in an atomic transaction like this :
- Flashloan
USDC
(Balancer => 0% fee) - Swap
USDC
tocrvUSD
- Uses
crvUSD
to liquidate & getcollateral_token
- Swap back
collateral_token
toUSDC
- Repay flashloan & keep profit
Example TX: https://arbiscan.io/tx/0xc62dcb45c27344cad148ebe006ac827574b512adb276e85e048752ca48f66d8d
1. Install dependencies
- Using npm:
npm i
2. Fill .env
An example is available in the .env.example
file.
PUBLIC_KEY=<public-key>
PRIVATE_KEY=<private-key>
ARB_RPC_URL=<arbitrum-rpc>
ARB_RPC_WSS=<arbitrum-rpc> //Not used in this demo
ETH_RPC_URL=<ethereum-rpc>
ETH_RPC_WSS=<ethereum-rpc> //Not used in this demo
TG_TOKEN='bot<api-key>' //Telegram notifications
TG_CHANNEL='-<channel-id>' //Telegram notifications
3. Run
- Arbitrum:
npm run start_arbitrum
- Ethereum:
npm run start_mainnet
Instead of swapping USDC
for crvUSD
on Ethereum mainnet, you can also call flashloan method from crvUSD FlashLender (0.01% fee)