Core Contracts

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

GaugeController::addGauge typeWeight is initialized as 0 which will cause _calculateReward return always 0 unless separately handled

GaugeController::addGauge when adding gauges, gives the typeWeight as 0 value by default. This might cause problems if the admin forgets, or is not fast enough to call setTypeWeight function to set the type weight. Becuase, type weights of a gauge is used in _calculateReward function’s typeShare calculation, and it end up returning the calculated rewards as 0 always.

Why? Because, here:

/**
* @notice Calculates reward amount for a gauge
* @dev Uses gauge weight and type weight to determine share
* @param gauge Address of gauge to calculate reward for
* @return Calculated reward amount
*/
function _calculateReward(address gauge) internal view returns (uint256) {
Gauge storage g = gauges[gauge];
uint256 totalWeight = getTotalWeight();
if (totalWeight == 0) return 0;
uint256 gaugeShare = (g.weight * WEIGHT_PRECISION) / totalWeight;
@> uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) /
MAX_TYPE_WEIGHT;
// Calculate period emissions based on gauge type
uint256 periodEmission = g.gaugeType == GaugeType.RWA
? _calculateRWAEmission()
: _calculateRAACEmission();
@> return
(periodEmission * gaugeShare * typeShare) /
(WEIGHT_PRECISION * WEIGHT_PRECISION);
}

if type weight of a gauge is zero, typeShare will return 0 as anything divided to 0 returns 0, which will end up the return statement return zero, as since typeShare is zero now, anything multiplied by it is zero, and then divided to it is zero.

In the case described, where the admin is not quick enough or forgets to set the weight to an applicable value, rewards will always be calculated as zero.

Recommendation

You could consider setting the weight to 1 at creation to avoid erroneous mistakes.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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