Core Contracts

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

`BaseGauge::_updateWeights` skips periods due to incorrect `nextPeriodStart` calculation

Summary

The BaseGauge::_updateWeights function miscalculates the next period start time, leading to skipped periods.

Vulnerability Details

The BaseGauge::_updateWeights function behaves as follows:

  • when weightPeriod.startTime exists, it will use the following formula:

    uint256 nextPeriodStart = ((currentTime / duration) + 1) * duration;
  • This calculation advances the period by one additional period, instead of just moving to the next period.

Impact

This will cause incorrect period tracking and skipped periods.

Tools Used

Manual Review

Recommendations

In the BaseGauge::_updateWeights function, replace the incorrect nextPeriodStart calculation with the following formula:

if (weightPeriod.startTime == 0) {
// For initial period, start from next period boundary
// uint256 nextPeriodStart = ((currentTime / duration) + 1) * duration; // this is wrong
uint256 nextPeriodStart = ((currentTime / duration) * duration) + 1;
TimeWeightedAverage.createPeriod(
weightPeriod,
nextPeriodStart,
duration,
newWeight,
WEIGHT_PRECISION
);
} else {
// For subsequent periods, ensure we're creating a future period
//uint256 nextPeriodStart = ((currentTime / duration) + 1) * duration; - This is wrong
uint256 nextPeriodStart = ((currentTime / duration) * duration) + 1;
TimeWeightedAverage.createPeriod(
weightPeriod,
nextPeriodStart,
duration,
newWeight,
WEIGHT_PRECISION
);
}

This ensures that the gauge progresses one period at a time instead of skipping multiple periods.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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