The QuantAMMGradientBasedRule::_calculateQuantAMMGradient function calculates the new weights using the price gradients. However, the calculated weights are being set at the wrong indexes in the state variable.
Here, the i variable iterates with i = i + 2, causing one index to be skipped each time. As a result, the weights are stored incorrectly in the array, resulting in a pattern like this: [w1, 0, w2, 0, w3, 0, w4]. This is incorrect, and the wrong values are being updated in the state variable intermediateGradientStates.
The incorrect assignment of values in the state variable leads to inaccurate calculations, which can result in losses for both the protocol and its users.
Manual Review
To fix this issue, ensure the correct index is used for setting values in the intermediateGradientStates array. Use a separate storage index to avoid skipping array elements.
Replace the direct use of i as the index with 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.
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.