Core Contracts

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

Incorrect typeShare Calculation Leading to Inflated Rewards

Summary

The typeShare calculation in the _calculateReward function is incorrect. It uses MAX_TYPE_WEIGHT instead of calculating the share relative to the total typeWeights. This causes reward calculations to be inflated.

Affected Code: GaugeController::CalculateReward

Vulnerability Details

In the current implementation, typeShare is calculated as:

uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) / MAX_TYPE_WEIGHT;

Since MAX_TYPE_WEIGHT is a constant (10000) and matches WEIGHT_PRECISION, the typeShare is always equal to typeWeights[g.gaugeType]. This results in inflated reward calculations.

The correct calculation should be based on the total type weights, like this:

uint256 totalTypeWeight = typeWeights[GaugeType.RWA] + typeWeights[GaugeType.RAAC];
uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) / totalTypeWeight;

This ensures typeShare reflects the actual proportion of a gauge type's weight relative to the total weight.

Example Scenario

If the typeWeights are adjusted to be:

  • typeWeights[GaugeType.RWA] = 7000

  • typeWeights[GaugeType.RAAC] = 5000

Under the current implementation, if a gauge belongs to RWA, the typeShare is 7000.

With the corrected implementation:

totalTypeWeight = 7000 + 5000 = 12000
typeShare = (7000 * 10000) / 12000 = 5833.33

If the weights are adjusted such that their sum does not equal 10000 and the adjustment is non-proportional, the current implementation inflates rewards, whereas the correct calculation would maintain an accurate distribution of typeShare.

Impact of TypeWeight Adjustments

Since typeWeights can be adjusted dynamically, this issue becomes more significant if weights are changed non-proportionally, which can occur during normal contract operation. Such adjustments would further distort reward calculations, potentially leading to unfair distribution.

Impact

The incorrect typeShare calculation inflates reward calculations and can lead to over-rewarding certain gauges.

Tools Used

Manual code review.

Recommendations

Update the typeShare calculation to:

uint256 totalTypeWeight = typeWeights[GaugeType.RWA] + typeWeights[GaugeType.RAAC];
uint256 typeShare = (typeWeights[g.gaugeType] * WEIGHT_PRECISION) / totalTypeWeight;
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 4 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.