An example of TypeScript-based liquidation bot for the Kai Finance protocol (https://kai.finance). This bot monitors lp positions and executes liquidations when necessary.
The bot consists of three core components working in sequence:
- Rpc Position Monitor: Watches and polls the chain for liquidatable positions
- Liquidation Controller: Processes detected positions and makes execution decisions
- Flash Swap Executor: Handles the actual liquidation transactions using flash swaps
For detailed arhitecture reference, see the Kai Finance Liquidation Framework.
The implementation includes Prometheus metrics integration for monitoring
Install dependencies:
pnpm install
pnpm build
Add the environment variable PRIVATE_KEY
to get a keypair by following the Mysten Labs SDK guide
Run the bot using the following command:
pnpm start
Note: Execution of first poll might be slower until cache initialization
The bot exposes Prometheus metrics on port 9284. You can access the metrics at:
http://localhost:9284/metrics