The unstakeAll()
function can delete dr.staked
tokens because only check for dr.vestedStaked == 0
. This happens in this code block:
You can see that there is no check if dr.staked == 0
as in the unstake()
function.
The unstakeAll
function allow users to unstake all their staked FJORD tokens from all active epochs at once. This function simplifies the unstaking process by allowing users to withdraw all their staked tokens without having to manually specify each epoch individually.
We're interested in the following code block:
The current logic checks if there are no vested tokens staked (dr.vestedStaked == 0
). If this condition is true, it deletes the deposit from deposits[msg.sender][epoch]
and removes the epoch from _activeDeposits
.
The problem here is that the current code only checks for dr.vestedStaked == 0
but does not check dr.staked == 0
, there could be a scenario where dr.staked
is non-zero. This could lead to an incomplete cleanup, where the deposit record is deleted even though there are still non-vested tokens (dr.staked > 0
) associated with that epoch.
The user will lose access to their staked tokens if the deposit record is deleted prematurely.
This would not only result in a loss of tokens but also prevent the user from earning rewards on those tokens and from unstaking them in the future.
Visual Studio Code
The logic should check both dr.staked == 0
and dr.vestedStaked == 0
before deleting the deposit.
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.