Core Contracts

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

Precision Loss in nextPeriod calculation leading start time of the period earlier than expected.

Summary

Precision loss in the nextPeriod calculation can cause the start time to be earlier than expected due to fractional parts being truncated.

Vulnerability Details

RAACGauge and RWAGauge both inherits BaseGauge.sol and which calculates the [nextPeriod](https://github.com/Cyfrin/2025-02-raac/blob/main/contracts/core/governance/gauges/BaseGauge.sol#L146) for creating new period for gauge voting and due to Precision loss in calculation leading to voting period start earlier than expected.

Looking at the below code snippet, nextPeriod is calculated with currentTime and _periodDuration in the code SLOC#145-146.

// File: contracts/core/governance/gauges/BaseGauge.sol
uint256 currentTime = block.timestamp;
uint256 nextPeriod = ((currentTime / _periodDuration) * _periodDuration) + _periodDuration;

let's Say currentTime is 1740115384 and _periodDuration is 7 days 604800 if we calculate this, nextPeriod will be 1740720184, where if we try in solidity, due to precision nextPeriod will be 1740614400.

Impact

Voting of RWAgauge and RAACGauge Starts earlier than expected time. If nextPeriod is earlier than expected, it could cause premature execution of time-sensitive actions, like rewards or checkpoints, leading to incorrect outcomes. This misalignment may result in missed opportunities or unintended consequences, such as rewards being distributed or gauge voting too soon.

Tools Used

  • Manual Review

  • Remix

Recommended Mitigation

  • Performing multiplication before division is generally better to avoid loss of precision. As such, consider performing multiplication before division.

or

apply this.

- uint256 nextPeriod = ((currentTime / _periodDuration) * _periodDuration) + _periodDuration;
+ uint256 nextPeriod = currentTime + _periodDuration;
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!