QuantAMM

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

Calculation Error in contract `QuantammGradientBasedRule.sol::_calculateQuantAMMGradient:41` function of mulFactor

Summary

Calculation error in contract QuantammGradientBasedRule.sol function_calculateQuantAMMGradient variable `mulFactor`

https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/rules/base/QuantammGradientBasedRule.sol#L41

QuantAMMGradientBasedRule contract calculates gradients for QuantAMM rules that use covariance matrices to calculate the new weights of a pool

this function is abstract so this inherited and implemented to be used and other contract.

Vulnerability Details

if (_poolParameters.lambda.length == 1) {
unchecked {
@> locals.mulFactor = oneMinusLambda.pow(THREE).div(convertedLambda);
if (notDivisibleByTwo) {
--numberOfAssetsMinusOne;
}
}

Impact:

Miscalculation to the whole protocol weight calculation and more contract is dependent on this calculation.

Tools Used

Manual Review

Recommendations

This is right calculation is recommanded check this out:

if (_poolParameters.lambda.length == 1) {
unchecked {
- locals.mulFactor = oneMinusLambda.pow(THREE).div(convertedLambda);
+ locals.mulFactor = convertedLambda.pow(THREE).div(oneMinusLambda);
if (notDivisibleByTwo) {
--numberOfAssetsMinusOne;
}
}
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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