Users Lose the Boost Rewards if they ask for an Unlock Even When They have completed the Lock Duration time.
In the Stake Link protocol, any user can stake SDL and other allowed tokens to earn rewards, all users who stake in the protocol have the ability to earn boosted rewards by locking their stake for a certain amount of time, if the user decides to lock their stake to earn boosted rewards, they have to wait the lock duration time to claim their stake plus the boosted rewards earn during that time, this is the way it should work but the process has a problem that cause any user that lock their stake to lose their boosted rewards.
Let's see the process and the problem in the next scenario:
1.- A user stakes tokens in the protocol and locks their tokens for 1 year.
2.- After the deposit and lock of the stake the user starts to earn boosted rewards and in a year He will double their tokens, because the boosted rewards allow you to double your tokens if you lock them for a year.
3.- After the year passed the user can withdraw his tokens, to withdraw their stake the user has first to ask for an Unlock of their tokens by calling the function initiateUnlock, and when the expiry time for unlocking the tokens (half of the lock duration) the user can then call the withdraw function and He should get back their tokens and the boosted rewards earned, but this is not the case, because the initiateUnlock function set the boosted amount to 0 and subtract the boosted amount from the EffectiveBalances
4.- When the expiry time ends and the user calls the withdraw function, just the amount staked is sent to the user, and the locks mapping is deleted from the system.
This causes the user to lose the boosted rewards.
To validate this behavior I created the next Test in the test/core/sdlPool/sdl-pool-primary.test.ts.
This test show that any user lose the Boosted rewards when they ask for an unlock of their stake after the lock duration time is over.
High: The User loses all the Boosted Rewards even when they stake for the whole lock duration time.
Manual Code Review & Hardhat Tests.
The initiateUnlock function should check if the lock duration time of the user has ended or not, if the lock time has finished the boosted rewards should not be cleared and should be sum to the staked amount so the user can claim this boosted amount when He withdraws their stake, and if lock time hasn't ended then the function can work as it works now.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.