Skip to content
Business logic Audit finding Intermediate

Liquidation fee is incorrectly calculated, leading to unprofitable liquidations

The liquidation fee is calculated on the entire collateral amount paid to the liquidator rather than on the liquidator's profit, making most liquidations unprofitable. This can lead to bad debt and insolvency because no one is incentivised to liquidate.

0xKartikgiri00 Follow with A2-security, Bigsam and 13 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/91

Found by

0xKartikgiri00, A2-security, Bigsam, EgisSecurity, HHK, Oblivionis, Obsidian, Ryonen, S3v3ru5, ThePharmacist, X12, ZeroTrust, cryptomoon, hash, nfmelendez, ravikiran.web3

Summary

Incorrect liquidation fee calculation makes liquidations unprofitable, leading to insolvency.

Root Cause

During PositionManager.liquidate() , two things happen:

  1. An amount x of the position’s collateral is paid to the liquidator (link)
  2. The liquidator pays off the debt of the position (link)

During step 1, the liquidation fee is effectively calculated as liquidationFee.mulDiv(x, 1e18)

This is incorrect- the correct way would be to take the liquidation fee from the profit of the liquidator, rather than from the entire amount x

Due to this inaccuracy, a large majority of liquidations will be unprofitable:

Example scenario

Consider a situation where liquidation fee is 30% (as stated in the contest README)

Say LTV = 90%, Debt value = $90, Collateral value drops from $100 to $98

Now, since the position LTV (90/98) is greater than the set LTV (90/100), the position is liquidatable

A liquidator aims to pay off the debt and receive the $98 worth of collateral, effectively buying the collateral at a discount of ~8%

However, They will only receive 70% of the $98 (due to the 30% liquidation fee), so they can only receive $68.6

This is extremely unprofitable since they have to pay off $90 worth of debt, and only receive $68.6 as a reward.

The correct approach to calculating fee would be the following:

  1. Calculate liquidator profit = Reward - Cost = $98 - $90 = $8
  2. Calculate liquidator fee = feePercentage*profit = 30% of $8 = $2.4

This ensures that liquidations are still incentivised

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

Liquidations are unprofitable due to liquidation fee being calculated incorrectly.

This leads to bad debt and insolvency since there is no incentive to liquidate.

PoC

No response

Mitigation

Consider calculating the profit of the liquidation first, and take the fee based on that

Discussion

0xjuaan

Hi @cvetanovv I forgot to escalate this (hard to keep track of so many), but I think everyone would agree this is high severity

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/sentimentxyz/protocol-v2/pull/339

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

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

Likely the liquidation fee is applied to the full collateral amount paid to the liquidator instead of only to the liquidator's profit.

Impact

Liquidations become unprofitable, which could lead to bad debt and insolvency because there is no incentive to liquidate.

What the attacker needed

Position becomes liquidatable; liquidation fee > 0

The fix

The fee should be calculated on the liquidator's profit (reward minus cost) rather than on the entire collateral amount.

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 falls below a required value, a liquidator can repay the debt and receive some collateral as a reward. The report says the reward is reduced by a fee that is taken from the whole collateral amount, not just from the profit, so the liquidator often ends up paying more than they get back. This discourages people from liquidating, which can leave the protocol with bad debt.

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 0xKartikgiri00

View all

1 more disclosed report, best first.

More from Sentiment V2

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.