Incorrect performance fee calculation in `FeeManager`
The performance fee calculation in FeeManager.calculateFee uses an incorrect formula that multiplies the price difference by total shares without dividing by the current price, leading to incorrect fee shares. An attacker could potentially exploit this to cause incorrect fee distribution, but the report does not specify an attack path.
0xapple Follow with blockace, dan__vinci and 2 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-07-mellow-flexible-vaults-judging/issues/207
Found by
0xapple, blockace, dan__vinci, davies0212, lodelux
Summary
The performance fee calculation in FeeManager.calculateFee uses an incorrect formula that doesn't properly convert price differences to share amounts. The current implementation leads to incorrect fee calculations.
Root Cause
The root cause is in the performance fee calculation formula in FeeManger.calculateFee function :
shares = Math.mulDiv(minPriceD18_ - priceD18, $.performanceFeeD6 * totalShares, 1e24);
This formula incorrectly assumes that the price difference (minPriceD18_ - priceD18) can be directly multiplied by the total shares to calculate fee shares.
Following formula comparison will be help to understand issue:
- definition of price:
share = price * asset - current formula: `feeShare = priceDifference * totalShare
Example1: minPriceD18=100e18, priceD18=90e18, performanceFee=1e5(10%) feeShare = 10e18 * 1e5 * totalShare / 1e24 = totalShare This means that performance fee share is the same as total share. -> Incorrect result.
Example2:
Let's imagine that asset is USDC with decimal 6, and vault share price is $1.
In this case, priceD18 for USDC is 1e30, not 1e18 to ensure share decimal as 18.
Internal Pre-conditions
.
External Pre-conditions
.
Attack Path
.
Impact
Incorrect performance fees calculation.
PoC
.
Mitigation
The formula should be corrected to properly convert the price difference to share amounts by including priceD18 in the denominator:
shares = Math.mulDiv(minPriceD18_ - priceD18, $.performanceFeeD6 * totalShares, 1e6 * priceD18);
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/mellow-finance/flexible-vaults/pull/21/files
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 formula incorrectly assumes that the price difference can be directly multiplied by total shares to calculate fee shares, omitting the division by the current price.
Impact
Incorrect performance fees calculation, which could lead to unfair fee distribution.
What the attacker needed
None
The fix
The formula should be corrected to properly convert the price difference to share amounts by including `priceD18` in the denominator.
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 vault, a performance fee is taken as a percentage of the profit. The code that calculates how many shares to give as a fee used a formula that forgot to divide by the current share price, so the fee amount could be wrong. This means the fee could be too high or too low, which is unfair to users.
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.