Skip to content
Business logic Audit finding Intermediate

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.

WatchPug Follow

Originally disclosed on Code4rena

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.

https://github.com/code-423n4/2021-12-mellow/blob/6679e2dd118b33481ee81ad013ece4ea723327b5/mellow-vaults/contracts/LpIssuer.sol#L269-L271

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, received 1000 lpToken; the totalSupply of the lpToken is now: 1000;
  • 3 days later, baseTvl increased to 1,001 USDC, Bob deposited 1 USDC and trigegred _chargeFees():
  • Expected Result: strategyPerformanceTreasury to receive about 0.01 lpToken (1% of 1 USDC);
  • Actual Result: minLpPriceFactor is about 1.001, and strategyPerformanceTreasury will received 1001 lpToken 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);

MihanixA (Mellow Protocol) confirmed

The original report as published on Code4rena, by WatchPug. 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

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

  1. Alice deposits 1,000 USDC and receives 1,000 LP tokens.
  2. After 3 days, the vault's base TVL increases to 1,001 USDC.
  3. Bob deposits 1 USDC, triggering the fee charge.
  4. 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.

More by WatchPug

View all

197 more disclosed reports, best first.

More from Mellow Protocol contest

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.