Description: When a user utilises FjordStaking::stakeVested
to receive rewards, the natspec suggests that the user should be able to partially claim rewards (with a penalty) or claim the full amount after the penalty period ends. However, if the user sets the parameter to false, it returns 0 reward points and locks the rewards away. If the user attempts to claim with a penalty (by setting the parameter to true), the function reverts, leaving the user unable to retrieve their rewards.
The user stakes assets using FjordStaking::stakeVested
and begins earning rewards.
After 7 weeks, the user expects to be able to claim the full reward, having surpassed the early claim period.
The user calls the claimReward
function, which executes successfully, but the return value is 0
, indicating no rewards were claimed.
The user waits another week, deciding to claim the rewards with a penalty, but when attempting to do so, the function reverts, resulting in no rewards being claimed.
Plug the following testing code in stakeVested.t.sol
.
This flaw in the code can cause users to lock away their assets without receiving any rewards, undermining the primary incentive for staking. It leads to a loss of rewards and erodes trust in the protocol.
Manual Review
I recommend attaching the isClaimEarly
flag to the userData
struct, associating it directly with each user. After the user has surpassed the 6-week period or double the claimCycle
, the boolean should be set to true
, allowing the user to access their full rewards.
Additionally, I suggest adding an if
statement to handle the isClaimEarly
condition. If isClaimEarly
is false
, the penalty amount should be applied; otherwise, the penalty should be set to 0
.
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.