Core Contracts

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

Incorrect gauge share & reward calculated inside GaugeController

Description

distributeRewards() internally calls _calculateReward() which calculates gaugeShare incorrectly. It ought to be:

File: contracts/core/governance/gauges/GaugeController.sol
360: function _calculateReward(address gauge) internal view returns (uint256) {
361: Gauge storage g = gauges[gauge];
362: uint256 totalWeight = getTotalWeight();
363: if (totalWeight == 0) return 0;
364:
- 365: uint256 gaugeShare = (g.weight * WEIGHT_PRECISION) / totalWeight;
+ 365: uint256 gaugeShare = (g.weight * WEIGHT_PRECISION) / getTotalWeightByType(g.gaugeType); // @audit : implement this new function
366: uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) / MAX_TYPE_WEIGHT;
367:
368: // Calculate period emissions based on gauge type
369: uint256 periodEmission = g.gaugeType == GaugeType.RWA ? _calculateRWAEmission() : _calculateRAACEmission();
370:
371: return (periodEmission * gaugeShare * typeShare) / (WEIGHT_PRECISION * WEIGHT_PRECISION);
372: }

This is because of the following; imagine:

  1. typeShare for RAAC is 50% and remaining for RWA gauge types

  2. There are 5 RAAC gauges with weight 25 each. And there are 3 RWA gauges with weight 25 each.

  3. Consider period emissions = 200

  4. RAAC gauges are entitled to 50% emissions i.e. 50% of 200 = 100

  5. The current RAAC gauge is eligible for gaugeWeight / totalRAACGaugeWeights or 25 / (5 * 25) or 1/5 of this i.e. 100/5 = 20. This should have been the returned value from _calculateReward().

Instead it does:

  1. 50% * emissions * gaugeWeight / totalWeightOfRAACplusRWAgauges = 50% * 200 * 25 / 200 = 12.5

  2. What this means is: First calculate reward for each gauge according to their share of weight, irrespective of gauge type AND THEN give them a fraction of that depending on their type. That's not how the setting is supposed to work.

Impact

Incorrect rewards distributed to gauges.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController::_calculateReward uses combined weight of all gauge types instead of type-specific weights, causing incorrect reward distribution between RWA and RAAC gauges

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController::_calculateReward uses combined weight of all gauge types instead of type-specific weights, causing incorrect reward distribution between RWA and RAAC gauges

Support

FAQs

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