Skip to content
Business logic Audit finding Intermediate

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.

0xjuan Follow

Originally disclosed on Code4rena

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 to fullValue * 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.

Revert mitigated:

PR here - fixed calculation.

Status: Mitigation Confirmed. Full details in reports from thank_you, b0g0 and ktg.


The original report as published on Code4rena, by 0xjuan. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by 0xjuan

View all

3 more disclosed reports, best first.

More from Revert Lend

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.