QuantAMM

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

Precision loss in calculation of `UpliftOnlyExample.sol::onAfterRemoveLiquidity()`

Summary

The calculation of localData.lpTokenDepositValueChange in function onAfterRemoveLiquidity() will have unexpected behaviour. Unless the pool value increases in increments of 100%, value changes will be supressed:

localData.lpTokenDepositValueChange =
(int256(localData.lpTokenDepositValueNow) - int256(localData.lpTokenDepositValue)) /
int256(localData.lpTokenDepositValue);
  • If value increases by 90% -> localData.lpTokenDepositValueChange == 0

  • If value increases by 100% -> localData.lpTokenDepositValueChange == 1

  • If value increases by 190% -> localData.lpTokenDepositValueChange == 1

  • If value increases by 200% -> localData.lpTokenDepositValueChange == 2

  • If value increases by 290% -> localData.lpTokenDepositValueChange == 2

  • ... and so on

Impact

If pool value increases by 99% feePerLP will be charged as the base fee. All succeding fee variables will take into acocunt the base fee instead of a corresponding uplift fee: localData.feeAmount, localData.feePercentage, exitFee, localData.accruedQuantAMMFees[i], localData.accruedFees[i].

Recommendations

Consider measuring value changes in terms of BIPS.

Updates

Lead Judging Commences

n0kto Lead Judge 7 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.