The virtual function _getBaseWeight that is part of the BaseGauge contract is not overriden in the RAACGauge and RWAGauge contracts. This would return a bigger value than expected as the default logic is to return the weight of the whole gauge instead of the weight(the staked tokens) for the specified user for the given gauge.
Function in BaseGauge contract:
Due to missing override of the _getBaseWeight functionin the RAACGauge and RWAGauge contracts we are not getting the correct user weight for a specific gauge when calling the getUserWeight function. This would mean that the value of the rewards will be way bigger than expected when calculating inside of the earned function, as the total weight for a gauge is way bigger than the weight for a specific user that is staking in a gauge. This will then further cause issues when user tries to call getReward for the gauge as either the balance of the gauge will not be enough to cover this incorrect rewards amount or the user will get more rewards that he/she should be obligated to.
Function affected by incorrect value and that is used to calculate the user rewards in the gauge:
Users will be able to either withdraw more rewards token than they are obligated to or not be able to withdraw rewards at all if calculated rewards amount exceedes the gauge balance of reward tokens.
Manual Review
To get accurate user weight for the given gauge we need to override the _getBaseWeight function in the RAACGauge and RWAGauge contracts as so:
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.