User will loss the Rewards for stacking if he redeem without claiming the reward
Summary
Rewards for staked tokens accumulate over time based on the duration of the staking period. However, Due to an Issue in code The Rewards can not be claimed more details in next section.
Vulnerability Detail
The Protocol Provide Rewards token as incentive for users to stake at thre platform. To stake token user will call createMintStakeTokenRequest and ROLE_KEEPER will call executeMintStakeToken Here we also update the rewards for staking via updateAccountFeeRewards.
It can be observed from above function that the realisedRewardsTokenAmount will only be update if stakeTokens>0. So in our case it will not be updated. after some time user creates a redeem request to redeem stack tokens. No in case of Redeem we update the rewards after redeeming.
Here We can see that When we redeem the Tokens the User stack tokens can be zero , So the realisedRewardsTokenAmount can not be updated in this case.
Now lets check what happens if user Tries to Claim Rewards Tokens he Will call ClaimRewards
aman
Medium
User will loss the Rewards for stacking if he redeem without claiming the reward
Summary
Rewards for staked tokens accumulate over time based on the duration of the staking period. However, Due to an Issue in code The Rewards can not be claimed more details in next section.
Vulnerability Detail
The Protocol Provide Rewards token as incentive for users to stake at thre platform. To stake token user will call
createMintStakeTokenRequest
andROLE_KEEPER
will callexecuteMintStakeToken
Here we also update the rewards for staking viaupdateAccountFeeRewards
.It can be observed from above function that the
realisedRewardsTokenAmount
will only be update ifstakeTokens>0
. So in our case it will not be updated. after some time user creates a redeem request to redeem stack tokens. No in case of Redeem we update the rewards after redeeming.Here We can see that When we redeem the Tokens the User stack tokens can be zero , So the
realisedRewardsTokenAmount
can not be updated in this case. Now lets check what happens if user Tries to Claim Rewards Tokens he Will callClaimRewards
In above code when
realisedRewardsTokenAmount==0
we can not Process it.Stake=0
so hisrealisedRewardsTokenAmount
will not be updated.stake=0
.realisedRewardsTokenAmount
will not be updated and remain0
.Impact
The User will loos the rewards token for staking.
Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/process/RedeemProcess.sol#L78
Tool used
Manual Review
Recommendation
First
updateAccountFeeRewards
then redeem tokens.Duplicate of #274