How Liquidation Works
A technical guide to the liquidation process implementation in the Fixed-Rate Lending Protocol
Last updated
Was this helpful?
A technical guide to the liquidation process implementation in the Fixed-Rate Lending Protocol
Last updated
Was this helpful?
The liquidation process in the Fixed-Rate Lending Protocol involves identifying undercollateralized positions and executing liquidation calls through smart contract functions. This technical guide explains the implementation details of how liquidation works from a developer's perspective.
First of all, it is necessary to identify the target user through off-chain actions before executing liquidation. The function getCoverage()
is used for this purpose. A user becomes a target for liquidation if this function returns a value of 8000
or higher. For more details, refer to the documentation at .
To execute with liquidation, you must specify the currency of the collateral to be received, the currency of the debt to be liquidated, and its maturity. This is done by calling the function executeLiquidationCall()
. To maximize the profit of the liquidation in the case that users have collateral or debt in multiple currencies, you need to estimate each case and choose one of them through off-chain action. For more details of the function, refer to the documentation at .
Upon executing this process, the liquidator receives the liquidated debt and the collateral plus a 5% fee. However, if the liquidator's collateral coverage exceeds 80% at the end of the process, this liquidation process will fail.
When executing the liquidation process through a smart contract, functions executeOperationForCollateral()
for receiving collateral, and executeOperationForDebt()
for receiving debt, can be set as callback functions. For usage, please refer to the sample contract at .
During the liquidation process, these callback functions enable the handling of received collateral by swapping it through external services or unwinding the received debt. The process flow is as follows:
Coverage Threshold
The threshold value returned by getCoverage()
that makes a position eligible for liquidation
8000
Liquidation Fee
The additional collateral received by the liquidator
5%
Liquidator Coverage Limit
Maximum coverage value a liquidator can have after liquidation
80%
Callback Functions
Functions that can be implemented to handle received assets
executeOperationForCollateral()
, executeOperationForDebt()
A liquidator bot wants to find undercollateralized positions:
A liquidator wants to liquidate an undercollateralized position:
You should analyze all possible combinations of collateral and debt currencies for a target user and choose the one that maximizes your profit. This typically involves:
Fetching all collateral and debt positions for the user
Calculating the potential profit for each combination (collateral value × 1.05 - debt value)
Considering gas costs for each liquidation
Selecting the combination with the highest net profit
If a user has multiple collateral types, you can only liquidate one collateral type per liquidation call. You would need to make separate liquidation calls for each collateral type you want to liquidate. It's generally most profitable to start with the collateral type that has the highest value or the one with the highest liquidation fee relative to its debt.
Yes, you can implement custom liquidation strategies by creating your own smart contract that inherits from the base Liquidator contract. You can override the callback functions executeOperationForCollateral()
and executeOperationForDebt()
to implement custom logic for handling the received assets, such as immediately swapping them on a DEX or using them for other DeFi strategies.
The protocol checks if the target user's position is undercollateralized by calling getCoverage()
. If this function returns a value less than 8000, the liquidation call will revert. Additionally, the protocol checks if the liquidator's own position would become too collateralized after the liquidation (coverage > 80%), which prevents liquidators from accumulating too much collateral relative to their debt.
You can test your liquidation bot on a testnet or in a forked mainnet environment. To create test scenarios:
Set up a test account with collateral and debt positions
Manipulate the price oracle to simulate price movements that would make positions undercollateralized
Execute your liquidation bot against these test positions
Verify that the liquidation was successful and that you received the expected collateral and fee