Core Contracts

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

Creation and update of period inside updateWeights() is faulty

Description

_updateWeights() simply creates a new period each time instead of updating weights when required. The else block is faulty and it's corrected logic ought to be:

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
- );
+ // If current period has ended, create new period
+ if (currentTime >= getCurrentPeriodStart() + duration) {
+ TimeWeightedAverage.createPeriod(
+ weightPeriod,
+ currentTime,
+ duration,
+ newWeight,
+ WEIGHT_PRECISION
+ );
+ return;
+ }
+
+ TimeWeightedAverage.updateValue(
+ weightPeriod,
+ newWeight,
+ block.timestamp
+ );
}
}

Impact

Weights aren't properly updated which can impact reward distribution.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
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.