QuantAMM

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

Inconsistent event data in `WeightsUpdated` emissions

Summary

The QuantAMMWeightedPool::setWeights and QuantAMMWeightedPool::_setInitialWeights functions both emit the WeightsUpdated event, but the data emitted is inconsistent. The QuantAMMWeightedPool::setWeights function includes the pool address and an array of both weight and multiplier metrics in the event data. In contrast, the QuantAMMWeightedPool::_setInitialWeights function emits the pool address and an array of only weight metrics.

QuantAMMWeightedPool::setWeights function:

function setWeights(
int256[] calldata _weights,
address _poolAddress,
uint40 _lastInterpolationTimePossible
) external override {
require(msg.sender == address(updateWeightRunner), "ONLYUPDW");
// _weights.length == _totalTokens * 2 (an array of both weight and multiplier metrics)
=> require(_weights.length == _totalTokens * 2, "WLDL");
...
=> emit WeightsUpdated(_poolAddress, _weights);
}

QuantAMMWeightedPool::_setInitialWeights function:

function _setInitialWeights(int256[] memory _weights) internal {
require(_normalizedFirstFourWeights == 0, "init");
require(_normalizedSecondFourWeights == 0, "init");
// _weights.length == _totalTokens (an array of only weight metrics)
=> InputHelpers.ensureInputLengthMatch(_totalTokens, _weights.length);
...
=> emit WeightsUpdated(address(this), _weights);
}

Impact

The inconsistency in emitted event data may lead to incorrect data indexing on off-chain services, potentially causing confusion or errors in data processing.

Recommendations

Update the QuantAMMWeightedPool::_setInitialWeights function:

function _setInitialWeights(int256[] memory _weights) internal {
require(_normalizedFirstFourWeights == 0, "init");
require(_normalizedSecondFourWeights == 0, "init");
InputHelpers.ensureInputLengthMatch(_totalTokens, _weights.length);
int256 normalizedSum;
int256[] memory _weightsAndBlockMultiplier = new int256[]();
...
- emit WeightsUpdated(address(this), _weights);
+ emit WeightsUpdated(address(this), _weightsAndBlockMultiplier);
}
Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_WeightsUpdated_event_is_used_inconsistently

Likelihood: Low, _setInitialWeights is only used once per pool and every other event will have the same format. Impact: Low, first WeightsUpdated event of a pool is emitted with incoherent data.

Support

FAQs

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

Give us feedback!