Submitted by No12Samurai, also found by Toshii, 0xRobocop, kutugu, and Brenzee
This report highlights a vulnerability in the ProtocolRewardsPool contract. The getReward() function, designed to distribute rewards to users, uses an incorrect calculation method that can result in incorrect reward distribution.
In the ProtocolRewardsPool contract, a user can call the getReward() function to receive the rewards. The function first tries to pay the reward using eUSD token, and if a sufficient amount of tokens are not available, it will use peUSD, and stableToken in the next steps. However, the protocol compares the number of shares with the amount of reward to send the reward.  If one share corresponds to a value greater than 1 eUSD, which is typically the case, users can be overpaid when claiming rewards. This can result in a significant discrepancy between the actual reward amount and the amount distributed.
When a user invokes the ProtocolRewardsPool.getReward() function, the contract attempts to distribute the rewards using the EUSD token:
ProtocolRewardsPool.sol#L190-L218
To determine the available shares for rewarding users, the function calculates the shares of the eUSD token held by the contract and compares it with the total reward to be distributed.
Here is the code snippet illustrating this calculation:
However, the comparison of shares with the reward in this manner is incorrect.
Lets consider an example to understand the problem. Suppose rewards[msg.sender] is equal to $10 worth of eUSD, and the shares held by the contract are 9 shares. If each share corresponds to $10 worth eUSD, the contract mistakenly assumes it does not have enough balance to cover the entire reward, because it has 9 shares; however, having 9 shares is equivalent to having $90 worth of eUSD. Consequently, it first sends 9 shares, equivalent to $90 worth of eUSD, and then sends $1 worth peUSD. However, the sum of these sent values is $91 worth of eUSD, while the users actual reward is only $10 worth eUSD.
This issue can lead to incorrect reward distribution, causing users to receive significantly more or less rewards than they should.
Manual Review
To address this issue, it is recommended to replace the usage of eUSDShare with EUSD.getMintedEUSDByShares(eUSDShare) in the following lines:
This ensures that the correct amount of eUSD is transferred to the user while maintaining the accuracy of reward calculations.
Math
LybraFinance confirmed
0xean (judge) decreased severity to Medium and commented:
