QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: medium
Valid

Incorrect Profit Calculation for Fee in `UpliftOnlyExample.sol`

Summary

In the UpliftOnlyExample.sol contract, users pay an uplift fee on profits when they remove liquidity. However, the current formula for profit calculation is flawed:

localData.lpTokenDepositValueChange =
(int256(localData.lpTokenDepositValueNow) - int256(localData.lpTokenDepositValue)) /
int256(localData.lpTokenDepositValue);

This formula only charges the uplift fee when the user earns 100% profit, instead of charging for any profit made.

Vulnerability Details

  • The profit is incorrectly normalized by dividing by localData.lpTokenDepositValue.

  • As a result, when a user earns less than 100% profit, the calculated lpTokenDepositValueChange remains 0, and no uplift fee is applied.

Impact

  1. Loss of fee for the protocol.

Tools Used

Manual Review

Recommendations

  1. Correct the Profit Calculation Formula.

localData.lpTokenDepositValueChange =
(int256(localData.lpTokenDepositValueNow) - int256(localData.lpTokenDepositValue));
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_onAfterRemoveLiquidity_lpTokenDepositValueChange_rounding_error_100%_minimum

Likelihood: High, every call to the function (withdraw) Impact: Low/Medium, uplift fees will be applied only when the price of one asset is doubled but fixed fees will still be collected.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!