The condition for updating the intermediateGradientStates mapping in the QuantAMMGradientBasedRule::_setGradient function is incorrect, leading to unintended behavior in subsequent calls.
In the QuantAMMGradientBasedRule::_setGradient function, the logic to update the intermediateGradientStates[poolAddress] array relies on the condition:
QuantAMMGradientBasedRule::_setGradient function:
This condition is problematic because the length of the intermediateGradientStates[poolAddress] array after updating is calculated as .
For example:
If _initialValues.length == 8, the resulting intermediateGradientStates[poolAddress].length will be 4.
When _setGradient is called again, the condition _initialValues.length == storeLength (i.e., _initialValues.length == 4) is expected to pass. However, this condition fails because _initialValues.length should remain consistent with the original number of assets (_numberOfAssets) rather than shrinking after each update.
This incorrect condition results in the inability to correctly set new gradient values in subsequent calls.
Update the condition to ensure that it verifies the relationship between _initialValues.length and storeLength correctly.
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.
Impact: Medium/High, the breakglass function is unusable. Likelihood: Low/Medium, when `setIntermediateValuesManually` is called by the admin to correct the intermediate values in case of any problem.
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.