Core Contracts

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

unnecessary block in GaugeController::updatePeriod

There is an unnecessary block in updatePeriod function.

Now, in addGauge, period is initialized with the current timestamp

/**
* @notice Adds a new gauge to the system
* @dev Only callable by gauge admin
* @param gauge Address of gauge to add
* @param gaugeType Type of gauge (RWA/RAAC)
* @param initialWeight Initial gauge weight
*/
function addGauge(
address gauge,
GaugeType gaugeType,
uint256 initialWeight
) external onlyGaugeAdmin {
if (gauges[gauge].lastUpdateTime != 0) revert GaugeAlreadyExists();
if (gaugeType != GaugeType.RWA && gaugeType != GaugeType.RAAC) {
revert InvalidGaugeType();
}
// Use minimum weight (1) for period tracking if initialWeight is 0
uint256 periodWeight = initialWeight == 0 ? 1 : initialWeight;
uint256 duration = gaugeType == GaugeType.RWA ? 30 days : 7 days;
gauges[gauge] = Gauge({
weight: initialWeight,
typeWeight: 0,
lastUpdateTime: block.timestamp,
gaugeType: gaugeType,
isActive: true,
lastRewardTime: block.timestamp
});
// Initialize period with current timestamp
TimeWeightedAverage.Period storage period = gaugePeriods[gauge];
@> TimeWeightedAverage.createPeriod(
period,
block.timestamp, // Start from current timestamp
duration,
periodWeight,
periodWeight
);
_gaugeList.push(gauge);
emit GaugeAdded(gauge, gaugeType);
}

and then, in updatePeriod, we see a very similar block:

/**
* @notice Updates the time period for a gauge
* @dev Rolls over to new period if current period has elapsed
* @param gauge Address of the gauge to update
*/
function updatePeriod(address gauge) external override whenNotPaused {
Gauge storage g = gauges[gauge];
if (!g.isActive) revert GaugeNotActive();
TimeWeightedAverage.Period storage period = gaugePeriods[gauge];
uint256 duration = g.gaugeType == GaugeType.RWA ? 30 days : 7 days;
// If this is the first period, initialize it
//@audit this block is impossible to run
@> if (period.startTime == 0) {
TimeWeightedAverage.createPeriod(
period,
// Add 1 second to avoid timestamp collision
block.timestamp + 1,
duration,
0,
g.weight
);
emit PeriodRolled(gauge, block.timestamp, g.weight);
return;
}

That if clause cannot run, because the gauges are already added via a period start time of block timestamp, so they are never 0. If they are never can be 0, then that block is unnecessary.

Recommendation

Remove unnecessary block.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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