The fjordStaking contract lets users stake their Fjord tokens at the current epoch and also unstake their past stakes. The problem arises in the unstaking part
of the code that doesn't consider the staking and unstaking (the previous ones) at the same epoch:
The function checks for unredeemedEpoch, and if it's equal to currentEpoch, sets the unredeemed epoch as 0.
unredeemedEpoch
is used in _redeem
, so if set it to 0, the current staked amount will not added to users stake amount.
Loss of rewards and stakes for users if they unstake their previously deposited assets exactly at the same epoch when they newly invested
A possible scenario for this issue can be in such a way:
Alice deposits 1e20
at the epoch 4
After 8 weeks, she makes another 1e20
staking. (ex: epoch 12)
She decides to unstake her stake for epoch 4 at epoch 12.
This makes the unredeemed epoch of Alice become 0.
so now _redeem
function doesn't include the second 1e20
to his stake amount.
After some time (e.g. 7 weeks) she can't even unstake because the code doesn't show any positive deposit for Alice
This test shows the unredeemed epoch of Alice becomes zero, in the case of staking and unstaking a previous epoch at the same epoch:
The test result is:
Manual review
it must check that is user unstaking current epoch or not.
Users that try to unstake tokens from an earlier epoch after they staked in the current epoch will have their ` unredeemedEpoch` set to 0, leading to them being unable to access the newly staked tokens. Impact: High – Tokens are lost Likelihood: Medium – It happens every time a user performs the respective sequence of calls. It’s not always but it’s also not a low likelihood scenario. It’s normal usage of the protocol, that doesn’t necessarily require special conditions.
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.