QuantAMM

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

Dividing followed by multiplying will result in loss of precision.

Summary

There are multiple division-then-multiplication operations in the protocol, which will lead to loss of precision in the calculation results.

Vulnerability Details

https://github.com/Cyfrin/2024-12-quantamm/blob/main/pkg/pool-quantamm/contracts/rules/DifferenceMomentumUpdateRule.sol#L104-L110

In the function DifferenceMomentumUpdateRule.sol#_getWeights, the following code suffers from loss of precision:

locals.newWeights[locals.i] = ONE.div(locals.denominator).mul(locals.newWeights[locals.i]);
if (locals.kappaStore.length == 1) {
locals.normalizationFactor += locals.newWeights[locals.i];
} else {
locals.normalizationFactor += (locals.newWeights[locals.i].mul(locals.kappaStore[locals.i]));
}

This will cause newWeights and normalizationFactor to be smaller than expected.

Impact

loss of precision

Tools Used

VScode

Recommendations

Use the correct order of calculations and avoid dividing before multiplying.

Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

invalid_Rules_getWeights_precision_loss_div_mul

## [Low-24] Divide before multiply

Support

FAQs

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

Give us feedback!