QuantAMM

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

There is a wrong fee calculation in the `onAfterRemoveLiquidity` function in the `UpliftOnlyExample` contract.

Summary

The feePerLP is calculated incorrectly in the onAfterRemoveLiquidity function within the UpliftOnlyExample contract.

Vulnerability Details

In the onAfterRemoveLiquidity function, the feePerLP is incorrectly calculated using localData.lpTokenDepositValueChange. This is wrong because lpTokenDepositValueChange represents the change in the value of the LP tokens since the deposit, which should not be used for fee calculation.

The fee should be based on the deposited value, not the change in the deposit value of LP tokens, leading to an incorrect fee calculation.

https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-hooks/contracts/hooks-quantamm/UpliftOnlyExample.sol#L482

if (localData.lpTokenDepositValueChange > 0) {
feePerLP =
@ >> (uint256(localData.lpTokenDepositValueChange) * (uint256(feeDataArray[i].upliftFeeBps) * 1e18)) /
10000;
}

Impact

The feePerLP variable will be calculated incorrectly, resulting in an erroneous fee being applied.

Incorrect fee will be applied.

Tools Used

Manual Review

Recommendations

change the localData.lpTokenDepositValueChange to

1.localData.lpTokenDepositValueor

2.localData.lpTokenDepositValueNow.
Use one of the two value of lpTokenValue. As required.

if (localData.lpTokenDepositValueChange > 0) {
feePerLP =
- (uint256(localData.lpTokenDepositValueChange) * (uint256(feeDataArray[i].upliftFeeBps) * 1e18)) /
- 10000;
__________________________________________________________
+ (uint256(localData.lpTokenDepositValue) * (uint256(feeDataArray[i].upliftFeeBps) * 1e18)) /
+ 10000;
______________________or_____________________________
+ (uint256(localData.lpTokenDepositValueNow) * (uint256(feeDataArray[i].upliftFeeBps) * 1e18)) /
+ 10000;
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

saurabh_singh Submitter
10 months ago
saurabh_singh Submitter
10 months ago
n0kto Lead Judge
10 months ago
n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!