Incorrect liquidation fee calculation during underwater liquidation, disincentivizing liquidators to participate
The liquidation fee for underwater positions was calculated as 10% of the position's full value rather than 10% of the debt, so as the collateral value fell further below the debt, the liquidator's reward shrank. This reduced the incentive for liquidators to participate, contrary to the protocol's stated design.
Submitted by 0xjuan
As stated in the Revert Lend Whitepaper, the liquidation fee for underwater positions is supposed to be 10% of the debt. However, the code within V3Vault::_calculateLiquidation (shown below) calculates the liquidation fee as 10% of the fullValue rather than 10% of the debt.
} else {
// all position value
liquidationValue = fullValue;
uint256 penaltyValue = fullValue * (Q32 - MAX_LIQUIDATION_PENALTY_X32) / Q32;
liquidatorCost = penaltyValue;
reserveCost = debt - penaltyValue;
}
Note:
fullValue * (Q32 - MAX_LIQUIDATION_PENALTY_X32) / Q32;is equivalent tofullValue * 90%.
The code snippet is here.
Impact
As the fullValue decreases below debt (since the position is underwater), liquidators are less-and-less incentivised to liquidate the position. This is because as fullValue decreases, the liquidation fee (10% of fullValue) also decreases.
This goes against the protocol’s intention (stated in the whitepaper) that the liquidation fee will be fixed at 10% of the debt for underwater positions, breaking core protocol functionality.
Proof of Concept
Code snippet from V3Vault._calculateLiquidation.
Recommended Mitigation Steps
Ensure that the liquidation fee is equal to 10% of the debt. Make the following changes in V3Vault::_calculateLiquidation():
else {
-// all position value
-liquidationValue = fullValue;
-uint256 penaltyValue = fullValue * (Q32 - MAX_LIQUIDATION_PENALTY_X32) / Q32;
-liquidatorCost = penaltyValue;
-reserveCost = debt - penaltyValue;
+uint256 penalty = debt * (MAX_LIQUIDATION_PENALTY_X32) / Q32; //[10% of debt]
+liquidatorCost = fullValue - penalty;
+liquidationValue = fullValue;
+reserveCost = debt - liquidatorCost; // Remaining to pay.
}
Assessed type
Error
kalinbas (Revert) confirmed, but disagreed with severity and commented:
Low severity.
ronnyx2017 (judge) decreased severity to Medium and commented:
According to the C4 rules, Medium is appropriate, as this disrupts certain designs in the economic model.
PR here - fixed calculation.
Status: Mitigation Confirmed. Full details in reports from thank_you, b0g0 and ktg.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The liquidation penalty was computed from the position's full value instead of the debt amount, so the fee shrank as the collateral value dropped below the debt.
Impact
Liquidators could be less incentivised to liquidate underwater positions as the collateral value falls, which may leave bad debt in the protocol and break the intended economic model.
What the attacker needed
Underwater position; liquidator participation
The fix
The calculation was fixed so that the liquidation fee is 10% of the debt, as confirmed by the mitigation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending protocol, if a borrower's collateral is worth less than what they owe, a liquidator can step in, repay the debt, and take the collateral plus a fee. The fee is meant to reward the liquidator for taking on the risk. Here, the fee was based on the collateral's value instead of the debt, so when the collateral was worth much less than the debt, the reward became tiny and liquidators had little reason to help.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.