When a user calls the stake() function, it will give them the activeDeposit, with that active deposit they can go through the unstakeAll(), but since they have not met the lockcycle requirement, totalStakedAmount won't get added with dr.staked, If that was the user's only activeDeposit or 1-3 (early) of them, The function will continue and begin adding zero values to (userData[msg.sender].totalStaked
,totalStaked
) and also send zero amount transfers/external calls + Unnecessary events (including duplicate events) on onUnstaked
and unstakeAll
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L570
There is no Zero Amount check after the iteration is done inside the function
The if (activeDeposits.length == 0) revert NoActiveDeposit()
is meant to remove the users who have never staked (Have no activedeposits), but there should also be a revert option for legit users trying to claim early to save their costs and clarity.
Users may become confused if they attempt to unstake tokens and the transaction appears successful without any feedback that it was not meant to be that way, Without an error message if they don't see their funds going through, they might try to call the function again which would also waste their costs with the external calls, its better to revert early if you have zero amount.
Likelihood: Medium ( users will call unstakeAll early)
Impact: Medium (occur pointless costs from the user)
Manual Review
Consider adding a check in unstakeAll()
that if the totalStakedAmount is still zero after the For Loop, it should revert
This should also help Events in Providing Accurate Information
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.