QuantAMM

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

lack of input sanitization breaks DifferenceMomentum weight calculation

Summary

In the DifferenceMomentumUpdateRule, kappa is a value used to detect aggressiveness. Assuming kappa has a scale from [-1, 1], where -1 is the least aggressive and 1 is the most aggressive, there might be cases where the kappa vector has values that sum to 0, including both positive and negative values.

Example with 4 kappa values:

  • [-0.5e18, 0.25e18, 0.2e18, 0.05e18]

In this scenario, while each individual value is valid, the sum of these values being 0 breaks the calculation due to the implementation logic:

File: DifferenceMomentumUpdateRule.sol
132: } else {
133: //vector logic separate to vector for efficiency
134: int256 sumKappa;
135: for (locals.i = 0; locals.i < locals.kappaStore.length; ) {
136: sumKappa += locals.kappaStore[locals.i];
137: unchecked {
138: ++locals.i;
139: }
140: }

Impact

A broken calculation occurs in the DifferenceMomentumUpdateRule when the kappa vector sums to 0.

Tools Used

Manual review.

Recommendations

To address this issue, use the absolute value for kappa:

++ absolutekappa[i] = !(kappa[i] > 0) ? -(kappa[i]) : kappa[i];
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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

Give us feedback!