Closed sherlock-admin4 closed 5 months ago
The process of withdrawing rewards and the process of withdrawing locked funds are independent of each other and work correctly. This issue is invalid because there's no impact, the user cannot double-claim rewards.
fandonov
high
The users balance is not set to 0 after he gets his rewards.
Summary
The user will still have the same
lockedWithMultiplier
balance even after he gets his rewards transferred to him via thegetReward
function.Vulnerability Detail
There is no check in the functions if the user called
exitLateById
orearlyExitById
prior to calling this function or if the 30-day period has passed, so the user will be able to call thegetReward
function whenever he wants because it's a public function. When the user calls thegetReward
function he wants to get his rewards. This function first calls the_updateReward
function which updates his earnings with the_earned
function. The problem lies here because he gets his earnings set to a specific amount with this mathearnings = rewardInfo.cumulatedReward * balance.lockedWithMultiplier - rewardDebt[_user][_rewardToken];
but thebalance.lockedWithMultiplier
is never set to 0 in this function so the user will still have his funds that are locked with a multiplier. This is the whole function:After this, the
getReward
function calls the_getReward
function which is represented in the next way:As we can see this function sets the
rewards
for the user to 0 but that still doesn't set hislockedWithMultiplier
balance to 0 so after some time if the user callsgetReward
again he will be able to withdraw a reward again.Impact
The user will be able to withdraw his rewards and still have the balance he previously had prior to getting his rewards.
Code Snippet
https://github.com/sherlock-audit/2024-05-gamma-staking/blob/703fd3604069489937037f20490ec8c492c0508e/StakingV2/src/Lock.sol#L526-L529
https://github.com/sherlock-audit/2024-05-gamma-staking/blob/703fd3604069489937037f20490ec8c492c0508e/StakingV2/src/Lock.sol#L614-L629
https://github.com/sherlock-audit/2024-05-gamma-staking/blob/703fd3604069489937037f20490ec8c492c0508e/StakingV2/src/Lock.sol#L455-L462
https://github.com/sherlock-audit/2024-05-gamma-staking/blob/703fd3604069489937037f20490ec8c492c0508e/StakingV2/src/Lock.sol#L538-L559
Tool used
Manual Review
Recommendation
Set the
lockedWithMultiplier
balance of the user to 0 after calculating the earnings in the_earned
functions.