Core Contracts

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

New period will be created even if there is an existing period in the event weights are updated for time-weighted calculation

Summary

In BaseGauge.sol, the _updateWeights()function will update the weights for time-weighted calculation. The function is expected to trigger the creation of a new period only if no existing period exist. However, even if a period exists, a new period is being created instead of having its weights updated.

Vulnerability Details

function _updateWeights(uint256 newWeight) internal {
uint256 currentTime = block.timestamp;
uint256 duration = getPeriodDuration();
if (weightPeriod.startTime == 0) {
// For initial period, start from next period boundary
uint256 nextPeriodStart = ((currentTime / duration) + 1) * duration;
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;
TimeWeightedAverage.createPeriod(
weightPeriod,
nextPeriodStart,
duration,
newWeight,
WEIGHT_PRECISION
);
}
}

As seen in _updateWeights()function, both the logic in the if and else statements are identical.

Existing period will not have its weight updated correctly and instead attempt to create a new period. In the event there is an existing active period, the else statement will fail anyway, as there is a check in TimeWeightedAverage.createPeriod()function to ensure that no active period exists, as seen in the if statement below:

function createPeriod(
Period storage self,
uint256 startTime,
uint256 duration,
uint256 initialValue,
uint256 weight
) internal {
// Check if there's an active period
if (self.startTime != 0 && startTime < self.startTime + self.totalDuration) {
revert PeriodNotElapsed();
}

Impacts

Existing period will never be able to have its weight updated.

Tools Used

Manual

Recommendations

Ensure logic for scenario whereby if period exists, _updateWeights() function should update the period weight correctly instead of attempt to create a new period.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 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.