The QuantAMMGradientBasedRule::_calculateQuantAMMGradient function incorrectly accesses intermediateGradientStates[_poolParameters.pool][i] using index i instead of locals.storageArrayIndex. This results in an array out-of-bound revert, disrupting the pool's weight update functionality for pools with 4 or more tokens that utilize vector lambdas
In the function QuantammGradientBasedRule::_calculateQuantAMMGradient, the locals.intermediateGradientState is assigned to an int256[] array corresponding to the number of tokens in the pool after unpacking intermediateGradientStates[_poolParameters.pool].
During the loop for pools with more than 4 tokens and using vector lambdas (lambdas with length != 1), the function incorrectly uses the index i instead of locals.storageArrayIndex to store the packed gradient value. Since i increments by 2 in each loop, while locals.storageArrayIndex increments by 1, this causes an out-of-bounds revert.
The pool's update weightage functionality is disrupted because the call reverts whenever the UpdateWeightRunner invokes UpdateRule::CalculateNewWeights() to compute new weights.
Proof of concept
Include this code block in UpdateWeightRunner.t.sol file. This issue affects any strategy which inherits `QuantAMMGradientBasedRule`. Using PowerChannel rule here as an example
This test will fail due to the array out-of-bounds access error.
This issue disrupts the main functionality of updating token weightage in pool, making this pool essentially a static weightage pool, for the pool with 4 tokens or more and using vector lambdas. As a result, the pool cannot benefit from strategy-based updates to dynamically adjust weights.
Manual
Foundry
Change the index i to locals.storageArrayIndex
Likelihood: Medium/High, assets>4, lambdas > 1. Impact: Medium/High, DoS update but pool works fine. Pool with 5 assets will use incorrect weights.
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.