Wrong rewards calculation in the GaugeController::_calculateReward happens due to the wrong assumption that every gauge weight should be included in the calculation of gauge shares
There are 2 types of gauges one being the RWAGauge (Real World Assets gauge) and the second one being the RAACGauge. When the GaugeController::distributeRewards function is called it relies on the _calculateReward function to get the reward that should be distributed to the corresponding gauge. By taking a look into the function, we see a big problem in the following line of code:
The problem is that the getTotalWeight function returns the gauge weight of all of the gauges, without applying a gauge type condition. Lets consider the following example for simplicity:
(we have 3 gauges, 1 RWAGauge and 2 RAACGauges)
The distributeRewards function is called on one of the RAACGauges
Then as of the active state of the code and considering that the 3 gauges have the same weight, the rewards will destributed as it follows:
1/3 for RAACGauge
1/3 for RAACGauge
1/3 for RWAGauge
This means that the RWAGauge gets counted into the RAACGauge reward calculations, lowering the allocations to RAACGauges and being unable to receive it because the allocation for RWAGauge is different. In this case, the RAACGauges will get 2/3 of the weekly allocation they should get, because of the RWAGauge that is accounted in those calculations. It is the same the other way around, which is bad because the different gauges are accounted for the emissions of the other type of gauge
This will lead to big reward miscalculation in both RWAGauge and RAACGauge and to not the whole monthly and weekly allocations being distributed to the correct gauges
Manual Review
When you get the gauge in the _calculateReward function, get its type and iterate trough the gauges mapping to get all of the active gauges from the same type and extract their weights in the totalWeight variable. From then on the calculation should be the same as the totalWeight now includes the weights of gauges from the corresponding type, rather than the total weight of all gauges
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.