QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: high
Invalid

Wrong calculation of `blockMultiplier` in `UpdateWeightRunner::_calculateMultiplerAndSetWeights` function

Summary

To calculate blockMultiplier, the protocol divides the distance between the updated weights and the current weight by the update interval. It seems the protocol incorrectly assumes that weight updates occur precisely at the update intervals. However, weight updates can happen at any time, not just at the designated intervals. Therefore, blockMultiplier should be calculated by dividing the distance by the time elapsed since the last update, rather than by the update interval.

Vulnerability Details

in UpdateWeightRunner::performUpdate there is a check for controlling the time of calling the function:

require(
block.timestamp - settings.timingSettings.lastPoolUpdateRun >= settings.timingSettings.updateInterval,
"Update not allowed"
);

This means that the update can happen at any time after the interval. Therefore, the time that has passed since the last update should be taken into account when calculating blockMultiplier.

Recommendations

  • Consider pass the last update time for multiplier calculation. change the add lastUpdate to CalculateMuliplierAndSetWeightsLocal structure and then :

_calculateMultiplerAndSetWeights(
CalculateMuliplierAndSetWeightsLocal({
currentWeights: currentWeights,
updatedWeights: updatedWeights,
updateInterval: int256(int40(_ruleSettings.timingSettings.updateInterval)),
+ lastUpdate: _ruleSettings.timingSettings.lastPoolUpdateRun,
absoluteWeightGuardRail18: int256(int64(_ruleSettings.absoluteWeightGuardRail)),
poolAddress: _poolAddress
})
);
  • Now change the blockMultiplier calculation like this:

- int256 blockMultiplier = (local.updatedWeights[i] - local.currentWeights[i]) / local.updateInterval;
+ int256 blockMultiplier = (local.updatedWeights[i] - local.currentWeights[i]) / int256(int40((block.timestamp - local.lastUpdate)));
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

pianist Submitter
7 months ago
n0kto Lead Judge
7 months ago
n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.