Core Contracts

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

if total weight is ever reduced to zero, all emissions are temporarily halted

The distributeRewards function calculates the reward share for a gauge based on its weight relative to the total weight of all gauges. The calculation depends on the getTotalWeight() function:

function _calculateReward(address gauge) internal view returns (uint256) {
Gauge storage g = gauges[gauge];
uint256 totalWeight = getTotalWeight();
if (totalWeight == 0) return 0; // @audit-info Prevents division by zero
uint256 gaugeShare = (g.weight * WEIGHT_PRECISION) / totalWeight;
uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) / MAX_TYPE_WEIGHT;
uint256 periodEmission = g.gaugeType == GaugeType.RWA ? _calculateRWAEmission() : _calculateRAACEmission();
return (periodEmission * gaugeShare * typeShare) / (WEIGHT_PRECISION * WEIGHT_PRECISION);
}

The function checks for totalWeight == 0 and returns 0, preventing a division by zero error inside _calculateReward. However, distributeRewards() itself does not check whether any valid weight exists before making an external reward transfer:

function distributeRewards(address gauge) external override nonReentrant whenNotPaused {
if (!isGauge(gauge)) revert GaugeNotFound();
if (!gauges[gauge].isActive) revert GaugeNotActive();
uint256 reward = _calculateReward(gauge);
if (reward == 0) return; // @audit-info Prevents empty transfers
IGauge(gauge).notifyRewardAmount(reward); // @audit-ok Unsafe external call with zero total weight
emit RewardDistributed(gauge, msg.sender, reward);
}

If all gauges have a weight of 0, _calculateReward() will always return 0, meaning no rewards are distributed. However, if reward emissions continue accumulating without valid distribution, the system may misallocate rewards later, leading to unexpected fund depletion or skewed emissions once weight is reintroduced.

Impact:

The primary impact is that if total weight is ever reduced to zero, all emissions are temporarily halted, potentially leading to stuck rewards and unexpected distribution issues when weight is reintroduced.

Mitigation:

Before calling notifyRewardAmount, validate that the total gauge weight is greater than zero at the beginning of distributeRewards() and implement a fallback mechanism to handle reward accumulation in such scenarios.

Updates

Lead Judging Commences

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