In several update rule contracts (MomentumUpdateRule, PowerChannelUpdateRule, DifferenceMomentumUpdateRule), there is an inconsistent validation of weight values. When kappa is provided as a vector, weights are validated to be non-negative, but this validation is missing when kappa is a scalar value. This inconsistency could lead to negative intermediate weights, as well as weights which are greater than 100%.
The issue exists in multiple update rules. Here's an example from MomentumUpdateRule:
Calculation for new weight can be written as:
Negative weights can easily occur if kappa is big enough.. Example scenario producing negative weight:
This negative result would be accepted in the scalar kappa case but rejected in the vector kappa case.
While negative intermediate weights should be eventually corrected through clamping and normalization in _guardQuantAMMWeights, this inconsistency introduces several issues:
Inconsistent behavior between scalar and vector kappa modes
Unnecessary complexity in dealing with negative intermediates
Risk of unexpected behavior in normalization calculations
Makes code harder to reason about as weights should conceptually never be negative
Impact is rated as Medium because:
There are recovery mechanisms through clamping and normalization
No direct fund loss
But introduces unnecessary complexity and inconsistent validation, and skews the calculations
Manual review
Add consistent validation across both scalar and vector cases:
_clampWeights will check that these weights are positive and in the boundaries before writing them in storage.
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.