exiting early will cause accumulated rewards for staker to be lost
Summary
exiting early will cause accumulated rewards for staker to be lost, because after user calls earlyExitById his bal.lockWithMultiplier will be set to 0 causing his rewards in earned to get multiplied by 0 causing loss of funds for the user
After user calls earlyExitById his bal.lockWithMultiplier will be set to 0 causing his rewards in earned to get multiplied by 0 making unable for user to get his rewards
function _earned(
address _user,
address _rewardToken
) internal view returns (uint256 earnings) {
Reward memory rewardInfo = rewardData[_rewardToken]; // Retrieves reward data for the specified token.
Balances memory balance = balances[_user]; // Retrieves balance information for the user.
earnings = rewardInfo.cumulatedReward * balance.lockedWithMultiplier - rewardDebt[_user][_rewardToken]; // Calculates earnings by considering the accumulated reward and the reward debt.
}
valentin2304
high
exiting early will cause accumulated rewards for staker to be lost
Summary
exiting early will cause accumulated rewards for staker to be lost, because after user calls
earlyExitById
his bal.lockWithMultiplier will be set to 0 causing his rewards in earned to get multiplied by 0 causing loss of funds for the userVulnerability Detail
After user calls
earlyExitById
his bal.lockWithMultiplier will be set to 0 causing his rewards inearned
to get multiplied by 0 making unable for user to get his rewardsImpact
High
Code Snippet
https://github.com/sherlock-audit/2024-05-gamma-staking/blob/main/StakingV2/src/Lock.sol#L313
Tool used
Manual Review
Recommendation
Implement a check if the staker has called
exitEarlyById
or not