QuantAMMGradientBasedRule - Incorrect Indexing in intermediateGradientStates[_poolParameters.pool] Causes Revert
The _calculateQuantAMMGradient function in the QuantAMMGradientBasedRule contract incorrectly uses the index i instead of locals.storageArrayIndex when updating intermediateGradientStates[_poolParameters.pool]. This results in an out-of-bounds error when the pool has more than 4 assets and lambda vector length greater than 1, causing the function to revert.
The _calculateQuantAMMGradient function is a key component of the QuantAMMGradientBasedRule, responsible for calculating gradient values for the pool's asset weights. The function relies on intermediateGradientStates, which is a mapping that stores quantum-packed gradient values.
Here's the implementation of the _calculateQuantAMMGradient function:
When _poolParameters.lambda.length > 1 and the pool contains more than 4 assets, the function incorrectly uses the index i instead of locals.storageArrayIndex to update intermediateGradientStates. This mismatch causes an out-of-bounds error, as the index i does not correspond to the correct array position for the packed gradient values.
Reversion of Operations: The function fails with an out-of-bounds revert, blocking all operations requiring gradient calculations.
Loss of Dynamic Updates: Pools cannot dynamically adjust asset weights using gradient-based strategies, degrading performance.
Inefficiency: Without proper calculations, the pool cannot utilize quantum-packed gradient values, leading to suboptimal asset management.
Manual Review
Replace i with locals.storageArrayIndex, so that it points to correct array position.
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.