Core Contracts

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

Precision Loss in calculateVeAmount (),MockVeToken.sol

Summary

The calculateVeAmount function multiplies amount by lockDuration and then divides by 1461 days. However, in Solidity, division (/) always rounds down to the nearest whole number, which can cause a loss of precision.

Vulnerability Details

Since Solidity does not support floating-point arithmetic, when `amount * lockDuration` is divided by `1461 days`, any fractional value will be **rounded down**. This rounding can result in incorrect calculation.

function calculateVeAmount(uint256 amount, uint256 lockDuration) external pure override returns (uint256) {
return amount * lockDuration / 1461 days; // 4 years in days
}

Impact

Users could receive less VeAmount than what they expected.

Tools Used

Manual review

Recommendations

To prevent precision loss, we should scale up calculations before performing division. This can be achieved by multiplying with 1e18 before dividing.

function calculateVeAmount(uint256 amount, uint256 lockDuration) external pure override returns (uint256) {
return (amount * lockDuration * 1e18) / (1461 days * 1e18);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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