QuantAMM

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

Natspac is not matching with code, and there is useless loop in `_getWeights`

Summary

There are some issues in the DifferenceMomentumUpdateRule, I discussed with sponsor but he was also not sure wether it's dead code, wrong natspac or what is going on, so he asked me to report it so here are the issues.

  1. The NatSpec comment for _setInitialIntermediateValues function claims it sets gradient values, but the code actually sets moving averages.

  2. There's a useless loop in _getWeights function that wastes extra gas on each call:

for (uint256 i; i < newShortMovingAverages.length;) {
unchecked {
++i;
}
}
  1. The parameter docs says there are 3 parameters including "Lambda Long", but the code only uses 2 parameters (kappa and lambda short).

Impact

  1. Wrong NatSpec: Developers might use the function incorrectly, thinking it handles gradients when it actually handles moving averages.

  2. Dead Code: Every call to _getWeights wastes gas by running an empty loop that does nothing.

  3. Parameter Mismatch: Developers will try to provide 3 parameters because docs say so, but the code only handles 2, leading to function calls failing.

Recommendation

  1. Either fix the NatSpec comment to say "moving averages" instead of "gradient", or modify the code to handle gradients if that was intended.

  2. Remove the empty loop in _getWeights since it serves no purpose and only wastes gas.

  3. Either:

    • Update parameterDescriptions to show only 2 parameters, or

    • Implement the missing "Lambda Long" parameter functionality in the code

The sponsor should clarify if the moving average vs gradient discrepancy is a docs error or implementation error to ensure the correct fix is applied.

Updates

Lead Judging Commences

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