QuantAMM

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

Not checking before assigning a value to the `updateInterval` variable when calling the `QuantAMMWeightedPool::initialize` function can lead to a division by zero error when calling the `UpdateWeightRunner::performUpdate` if `updateInterval` = 0

Summary

Not checking before assigning a value to the updateInterval variable when calling the QuantAMMWeightedPool::initialize function can lead to a division by zero error when calling the UpdateWeightRunner::performUpdate if updateInterval = 0.

Vulnerability Details

In QuantAMMWeightedPool::initialize function, while the other parameters of PoolSettings are checked properly, the function does not check _poolSettings.updateInterval.
This _poolSettings.updateInterval param will be pass through multiple calls:

  1. QuantAMMWeightedPool::_setRule

  2. UpdateWeightRunner::setRuleForPool
    And finally stored in mapping poolRuleSettings in UpdateWeightRunner contract (UpdateWeightRunner.sol#L256-L263).

poolRuleSettings[msg.sender] = PoolRuleSettings({
lambda: _poolSettings.lambda,
epsilonMax: _poolSettings.epsilonMax,
absoluteWeightGuardRail: _poolSettings.absoluteWeightGuardRail,
ruleParameters: _poolSettings.ruleParameters,
@> timingSettings: PoolTimingSettings({ updateInterval: _poolSettings.updateInterval, lastPoolUpdateRun: 0 }),
poolManager: _poolSettings.poolManager
});

And whenever the UpdateWeightRunner::performUpdate function is called, it will call _calculateMultiplerAndSetWeights function. If updateInterval has a value of 0, the following line of code in _calculateMultiplerAndSetWeights will revert due to a division by zero error (UpdateWeightRunner.sol#L472):

int256 blockMultiplier = (local.updatedWeights[i] - local.currentWeights[i]) / local.updateInterval;

Impact

Can not call performUpdate to set new weights to the pool.

Tools Used

  • Manual review.

Recommendations

  • Add a check for zero value before assigning a value to the updateInterval variable.

+ require(_poolSettings.updateInterval != 0);
updateInterval = _poolSettings.updateInterval;
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

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.

Support

FAQs

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

Give us feedback!