Users Who try to withdraw their Tokens after the Duration Lock has time Finished are Unable to Withdraw and have to Ask for an Unlock and Wait for the Expiry period, When They should not wait any more time.
In the Stake.link protocol any user can deposit SDL tokens and other tokens to stake and win rewards from the protocol, the users can stake tokens and if they don't lock the tokens deposited in the protocol, they can withdraw these tokens at any time they want, but if the user decides to lock their tokens for a determined time they win the rewards plus some extra rewards (Boosted rewards) this incentivize users to lock their tokens in the protocol.
When any User decides to withdraw his tokens, they can withdraw immediately if they didn't lock their tokens in the protocol, but if they lock their tokens they have to ask to unlock the tokens first, then they should wait for half of the Lock Duration time to be able to call the Withdraw function to get their tokens back, this is the process that the user should follow for withdrawing tokens from the protocol, but this process has a flag that causes that any user who locks their tokens in the protocol has to wait an unfair amount of time to withdraw their tokens from the protocol.
Follow me in the next example, where I show you guys this problem:
1.- A bunch of users deposit in the protocol SDL tokens and other tokens allowed by the protocol. but as they want to receive boosted rewards they lock their tokens for a couple of years or maybe the max lock duration of 4 years.
2.- The time starts passing and the users are winning rewards plus boosted rewards from the protocol and everything is great.
3.- Then more than 2 years have passed and the users who lock their tokens are urgently needing the money for any personal reasons, so they decide to withdraw the tokens from the protocol.
4.- Since the Lock Duration time they set in the beginning has ended, they try to withdraw the tokens immediately, but they notice they have to ask for an unlock of their tokens even when the lock time has expired.
5.- After they ask for the unlock they notice they have to wait 1 more year to be able to withdraw their tokens, and the users who lock for 4 years have to wait 2 more years to withdraw their tokens.
This behavior is undesirable and a problem that any user who has already finished their locking time shouldn't face.
The problem is caused because the withdraw function doesn't check if the lock duration time from the lock has passed.
To validate this behavior I created a test, you can add this test to the test/core/sdlPool/sdl-pool-primary.test.ts file.
This problem force users of the protocol to wait even more time than the lock duration time they set at the beginning, cause their tokens are locked by a half of the lock time duration even after the lock duration time of the user has expired, this is unfair and can be problematic for users.
Manual Code Review, Hardhat Test.
The recommendation would be to add a validation in the Withdraw function to check if the user has met the initially established lock duration time.
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.