Core Contracts

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

wrong initialization of boostState.minBoost in constructor::BaseGauge.sol could lead to potential underflow in calculateBoost due to boostRange calculation

Summary

The calculateBoost function computes a boost multiplier based on a user’s veBalance relative to totalVeSupply, scaling between params.minBoost and params.maxBoost. The calculation boostRange = params.maxBoost - params.minBoost assumes maxBoost >= minBoost. However, the constructor initializes boostState.maxBoost = 25000 (2.5x in basis points) and boostState.minBoost = 1e18 (1 quintillion), where minBoost vastly exceeds maxBoost. Additionally, setBoostParameters allows the controller to set these values arbitrarily without enforcing maxBoost >= minBoost. In Solidity <0.8.0 (or unchecked arithmetic in ≥0.8.0), subtracting a larger minBoost from a smaller maxBoost causes an underflow, reverting the transaction and breaking boost calculations.

constructor() {
//...
boostState.maxBoost = 25000; // 2.5x in basis points (25,000)
boostState.minBoost = 1e18; // 1,000,000,000,000,000,000
// Other initializations...
}

calculateBoost

function calculateBoost(
uint256 veBalance,
uint256 totalVeSupply,
BoostParameters memory params
) internal pure returns (uint256) {
if (totalVeSupply == 0) {
return params.minBoost;
}
uint256 votingPowerRatio = (veBalance * 1e18) / totalVeSupply;
>> uint256 boostRange = params.maxBoost - params.minBoost;
uint256 boost = params.minBoost + ((votingPowerRatio * boostRange) / 1e18);
if (boost < params.minBoost) {
return params.minBoost;
}
if (boost > params.maxBoost) {
return params.maxBoost;
}
return boost;
}

Root Cause

  • Initialization Mismatch:

    • Constructor sets maxBoost = 25000 (25,000 basis points, 2.5x) and minBoost = 1e18 (1 quintillion), where minBoost > maxBoost by a massive margin (1e18 >> 25,000).

    • Likely a typo: minBoost might have intended 10000 (1x in basis points), but 1e18 is a common precision unit, misapplied here.

  • Underflow in Calculation: In Solidity <0.8.0, maxBoost - minBoost underflows if minBoost > maxBoost (e.g., 25000 - 1e18 wraps to a huge number), reverting the transaction. In ≥0.8.0, it reverts explicitly

Impact

Function Reverts: With minBoost = 1e18 and maxBoost = 25000, boostRange = 25000 - 1e18 underflows, causing calculateBoost to revert ( Solidity ≥0.8.0). A low severity as setBoostParameters::BaseGauge.solcan change the value to 10000

Tools Used

Manual

Recommendations

constructor() {
//..
boostState.maxBoost = 25000; // 2.5x
- boostState.minBoost = 1e18;
+ boostState.minBoost = 10000; // 1x, not 1e18
// Other initializations...}
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

boostState.minBoost is set to 1e18

Support

FAQs

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