Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

Incorrect Weight Scaling in `GaugeController` Leads to Inaccurate Time-Weighted Calculations

Summary

The GaugeController's addGauge function incorrectly passes unscaled weight values to the TimeWeightedAverage library's createPeriod function, which expects weights to be scaled by 1e18. This scaling mismatch results in significantly undervalued time-weighted calculations for gauge weights.

Vulnerability Details

In the GaugeController contract, gauges can be added with an initial weight of zero, which are then converted to a minimum weight of 1:

function addGauge(
address gauge,
GaugeType gaugeType,
uint256 initialWeight
) external onlyGaugeAdmin {
// Zero weight is allowed and converted to 1
@> uint256 periodWeight = initialWeight == 0 ? 1 : initialWeight;
TimeWeightedAverage.createPeriod(
period,
block.timestamp,
duration,
// Uses unscaled value
periodWeight,
// Should be scaled by 1e18
periodWeight
);
}

The TimeWeightedAverage library's weight parameter in createPeriod expects values scaled by 1e18, as documented in the library. This scaling is crucial for precise time-weighted calculations similar to how Curve and Balancer handle weights in their gauge systems

struct Period {
// ...
uint256 weight; // Weight applied to period (scaled by 1e18)
}

However, the GaugeController passes the raw periodWeight value without scaling it by 1e18 for both the initialValue and weight parameters.

The same unscaled value is used for both parameters.
The weight parameter should be scaled by 1e18

This scaling mismatch means that gauge weights are effectively divided by 1e18 in all time-weighted calculations, severely undervaluing their impact.

Impact

All time-weighted calculations in the gauge system are off by a factor of 1e18.

Tools Used

Manual Review

Recommendations

function addGauge(
address gauge,
GaugeType gaugeType,
uint256 initialWeight
) external onlyGaugeAdmin {
// [...]
uint256 baseWeight = initialWeight == 0 ? 1 : initialWeight;
// Scale by 1e18
uint256 scaledWeight = baseWeight * 1e18;
TimeWeightedAverage.createPeriod(
period,
block.timestamp,
duration,
baseWeight, // Use unscaled value for initial value
scaledWeight // Use scaled value for weight
);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController::addGauge uses unscaled value 1 for periodWeight when initialWeight is 0, causing gauge influence to be 10^18 times smaller than intended in TimeWeightedAverage calculations

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController::addGauge uses unscaled value 1 for periodWeight when initialWeight is 0, causing gauge influence to be 10^18 times smaller than intended in TimeWeightedAverage calculations

Support

FAQs

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