Wrong implementation of performanceFee can cause users to lose 50% to 100% of their funds
The performance fee calculation mints an excessive number of LP tokens to the treasury, far more than intended. This dilutes existing users' shares, causing them to lose 50% to 100% of their funds after a few fee charges.
Submitted by WatchPug
A certain amount of lp tokens (shares of the vault) will be minted to the strategyPerformanceTreasury as performanceFee, the amount is calculated based on the minLpPriceFactor.
However, the current formula for toMint is wrong, which issues more than 100% of the current totalSupply of the lp token to the strategyPerformanceTreasury each time. Causing users to lose 50% to 100% of their funds after a few times.
address treasury = strategyParams.strategyPerformanceTreasury;
uint256 toMint = (baseSupply * minLpPriceFactor) / CommonLibrary.DENOMINATOR;
_mint(treasury, toMint);
Proof of Concept
Given:
strategyParams.performanceFee:10e7(1%)- Alice deposited
1,000 USDC, received1000lpToken; the totalSupply of the lpToken is now:1000; - 3 days later,
baseTvlincreased to1,001 USDC, Bob deposited1 USDCand trigegred_chargeFees(): - Expected Result:
strategyPerformanceTreasuryto receive about0.01lpToken (1% of 1 USDC); - Actual Result:
minLpPriceFactoris about1.001, andstrategyPerformanceTreasurywill received1001lpToken as performanceFee; Alice lose 50% of deposited funds.
Recommendation
Change to:
address treasury = strategyParams.strategyPerformanceTreasury;
uint256 toMint = (baseSupply * (minLpPriceFactor - CommonLibrary.DENOMINATOR) * performanceFee / CommonLibrary.DENOMINATOR) / CommonLibrary.DENOMINATOR;
_mint(treasury, toMint);
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 formula for calculating the number of LP tokens to mint as performance fee incorrectly uses the entire minLpPriceFactor instead of only the profit portion and omits dividing by the fee denominator.
Impact
Users could lose 50% to 100% of their funds after a few fee charges due to excessive dilution.
What the attacker needed
Vault has a performance fee; profit is generated; a user triggers fee charge
The fix
The formula should be changed to calculate the fee based on the profit (minLpPriceFactor minus DENOMINATOR) multiplied by the performance fee and divided by DENOMINATOR squared.
How it was found
- Alice deposits 1,000 USDC and receives 1,000 LP tokens.
- After 3 days, the vault's base TVL increases to 1,001 USDC.
- Bob deposits 1 USDC, triggering the fee charge.
- The treasury receives 1,001 LP tokens as performance fee, diluting Alice's share by 50%.
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.
A vault charges a performance fee by giving the treasury some new shares (LP tokens). The formula for how many shares to give is wrong, so the treasury gets almost all the shares, making everyone else's shares worth much less.
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.