The bug is in the else block. There's a check require(amount > _left);, but this check is performed before the actual token transfer. This means that the check is using the amount parameter passed to the function, not the actual amount of tokens received.
This can lead to a situation where the function might proceed even if the actual transferred amount is less than _left, which could result in incorrect reward rate calculations or even underflow in extreme cases.
To fix this, the check should be moved after the token transfer and use the actual received amount:
This will ensure that the check is performed on the actual amount of tokens received, rather than the amount claimed to be sent, providing better security & accuracy in reward calculations.
Minato7namikazi
High
logic bug in
notifyRewardAmount
functionVulnerability Detail
The bug is in the
else
block. There's a checkrequire(amount > _left);
, but this check is performed before the actual token transfer. This means that the check is using theamount
parameter passed to the function, not the actual amount of tokens received.This can lead to a situation where the function might proceed even if the actual transferred amount is less than
_left
, which could result in incorrect reward rate calculations or even underflow in extreme cases.To fix this, the check should be moved after the token transfer and use the actual received amount:
This will ensure that the check is performed on the actual amount of tokens received, rather than the amount claimed to be sent, providing better security & accuracy in reward calculations.
Code Snippet
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/FvmGauge.sol#L539
Tool used
Manual Review
Duplicate of #259