The contracts MomentumUpdateRule.sol, DifferenceMomentumUpdateRule.sol, and PowerChannelUpdateRule.sol utilize a local variable sumKappa instead of the locals.sumKappa field defined in the QuantAMMMomentumLocals structure. Although the operation is commented as "vector logic separate to vector for efficiency," the locals.sumKappa is not updated after calculating the total sumKappa. This issue leads to data inconsistencies, prevents reusing the computed result stored in the structure and may introduce vulnerabilities if future logic assumes locals.sumKappa contains a valid updated value but instead relies on uninitialized or incorrect data.
pkg/pool-quantamm/contracts/rules/DifferenceMomentumUpdateRule.sol:_getWeights#L132-140
pkg/pool-quantamm/contracts/rules/MomentumUpdateRule.sol:_getWeights#L111-119
pkg/pool-quantamm/contracts/rules/PowerChannelUpdateRule.sol:_getWeights#L132-140
No update of sumKappa field of struct: The mismatch between the struct and local variable can cause silent errors, particularly if sumKappa is later needed elsewhere via the struct.
Maintainability and Readability: Using a local variable deviates from the structural design intent. Developers may mistakenly use QuantAMMMomentumLocals.sumKappa in other parts of the code, leading to incorrect values.
Data Inconsistency: Updates to QuantAMMMomentumLocals.sumKappa are not reflected, which can lead to errors when the struct is accessed elsewhere.
Maintainability Risks: Deviation from intended design may confuse future developers and increase the chance of bugs.
Manual Review
To address the issue, it is recommended to update the locals.sumKappa field in the structure after calculating sumKappa. This ensures that the computed value is stored within the structure and can be accessed reliably by subsequent operations:
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.