The `_calculateReward` function incorrectly calculates a gauge’s share by using the total weight of all gauges in the contract, rather than limiting the calculation to only those gauges of the same type (RAAC or RWA). This error dilutes the gauge’s effective share, causing gauges to receive lower rewards than intended and potentially locking funds within the contract.
What Went Wrong:
The function calculates the gauge share as follows:
Here, totalWeight is the sum of weights for all gauges, regardless of their type. In cases where there are both RAAC and RWA gauges (for example, 3 RAAC and 4 RWA), the gauge share for a RAAC gauge should be computed using the total weight of RAAC gauges only—not the combined weight of RAAC and RWA gauges.
Why It Matters:
Using the total weight of all gauges dilutes the rewards intended for a specific gauge type, resulting in gauges receiving less than their rightful share. This miscalculation could lead to a significant loss of rewards over time, as excess funds remain locked in the contract without being distributed.
Under-Allocation of Rewards:
Gauges receive lower rewards than intended, weakening the incentive mechanism.
Locked Funds:
Misallocated rewards may remain in the contract, reducing available funds for distribution.
Economic Imbalance:
The flawed reward calculation can undermine stakeholder trust and affect the protocol’s overall economic stability.
Manual Code Review: We analyzed the reward calculation logic within _calculateReward and identified the misuse of the total gauge weight.
Modify the function to compute gauge share based on the total weight of gauges of the same type. For example:
where _getTotalWeightByType returns the sum of weights for gauges matching g.gaugeType.
Implement Comprehensive Testing:
Develop unit tests to ensure that reward calculations are correct for various distributions of RAAC and RWA gauges, ensuring that funds are allocated properly.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.