addGauge
initializes a new gauge and sets up a TimeWeightedAverage.Period
for tracking its weight over time. When initialWeight = 0
, it assigns periodWeight = 1
as a minimum value to ensure period tracking functions, as noted by the comment // Use minimum weight (1) for period tracking if initialWeight is 0.
However,
struct Period in TimeWeightedAverage.sol expects weight
scaled by 1e18 and calculateAverage::TimeWeightedAverage.sol
suggest that self.value (mapped to periodWeight) should be in 18-decimal precision (e.g., 1e18 for 1 unit). This mismatch—using 1 instead of 1e18—introduces an inconsistency in decimal scaling, leading to incorrect weight calculations in the time-weighted average system.
addGauge::GaugeController.sol
The use of 1 instead of 1e18 for periodWeight when initialWeight == 0 has the following consequences: grossly underestimated weight. self.value = 1 (instead of 1e18)
is used in calculateAverage
, making the gauge’s time-weighted average weight 10^18 times smaller than intended.
The gauge appears to have negligible weight (e.g., 1 wei vs. 1 unit), drastically underrepresenting its influence.
Manual review
Scale periodWeight to 18 Decimals
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.