Lending Liquidation Bot
Overview/ Background
Lending protocols expose contract methods or extrinsics to users to liquidate under-collateralized positions for a profit. The Lending protocol on Kintsugi / Interlay is no exception, and having a liquidation bot monitor existing borrowers ensures the health of the protocol.
Problem
this is why we are requesting for proposal for this project
- There is a problem with …. Borrowers may become liquidatable but there is no automated way of doing this. If the Loan-To-Value (LTV) ratio increases too quickly, borrowers will rationally run away with the borrowed funds. This is why it’s critical to have timely liquidations occur.
- There is a demand for …. An open-source bot that members of the community can run and perform liquidations instantly when a borrower’s LTV deteriorates.
- To support our initiative for….. Ensuring loans are well-collateralized to protect lenders.
Solution
An open-source lending liquidation bot, implemented in either TypeScript or Rust. forks https://github.com/interlay/bridge-bot and is easy to run.
Product Requirement
- Feature 1: Monitor the collateralization of borrowers and determine if the liquidation is at least as profitable as the threshold set by the user. The profitability estimation should consider slippage for buying the debt token as well as for selling the collateral token and an estimation of the transaction fees. If the liquidation is profitable enough, send
liquidateBorrow
extrinsics as soon as they can be liquidated. Thorough tests are a must.
- If implementing in TypeScript, you can fork ‣ and upgrade to the latest version of ‣. Then, use the
interbtc-api
library to send extrinsics and read chain state. It should be possible to reuse logic from the integration tests and docker setup in ‣.
- If implementing in Rust, you can use https://github.com/paritytech/subxt to communicate with the parachain. It should be possible to reuse the setup in https://github.com/interlay/interbtc-clients to write integration tests.
- Feature 2: Fee outbidding mechanism that scans the chain’s mempool for other pending liquidation transactions and outbids the fees it pays. This would effectively redistribute parts of the liquidation profits to collators. To prevent an outbidding loop, include a
max-fee
CLI flag. Thorough tests are a must.
- Feature 3: Create an easy to follow Readme that: 1) allows for easily setting up the bot; 2) explains how the bot works and how the code is structured in case someone wants to contribute. The readme also serves as a project report for the submission.
- Additional Requirements: Edge case fixes and additional functionality than those mentioned above are encouraged. The bot should be highly configurable using command-line arguments or a config file. The code must be properly refactored, such that it is easy to understand and extend.