When _epoch is same as current epoch, user can't unstake immediately due to underflow in the unstake function
As per design of the protocol unstake feature, user are allowed to unstake immediately when _epoch they want to unstake is same as the current epoch
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L449-L494
During this process the amount passed in is subtracted from the newStaked at this point
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L470-L476
This process would always revert due to underflow because in the checkepochRollover modifier,
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L691-L724
newStaked is always set to 0
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L719
Which result in the revert due to underflow in the unstake process
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L474-L476
User can't unstake immediately in the current epoch
Manual review
A corrected logic should be implemented to allow user withdraw token when _epoch == currentEpoch
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.