In the stakeVested function, both newStaked and newVestedStaked are incremented by the staked amount _amount. This is problematic because the reward calculation logic in _checkEpochRollover uses these values to determine pendingRewardsPerToken, which may lead to incorrect reward distributions if newStaked is incremented erroneously.
The stakeVested function incorrectly increments both newStaked and newVestedStaked:
Since the function is designed for staking vested NFTs (which are associated with FJORD tokens), only newVestedStaked should be incremented. The incorrect increment of newStaked can lead to the following issues:
Duplicate Reward Calculation: newStaked and newVestedStaked are used in _checkEpochRollover to calculate pendingRewardsPerToken and rewardPerToken. If newStaked is incremented unnecessarily, the rewards calculation will erroneously include the amount twice.
Potential Miscalculation: The reward calculation might distribute rewards based on inflated totalStaked values if newStaked is not handled correctly.
Relevant Code in _checkEpochRollover:
Incorrectly incrementing newStaked may lead to:
Incorrect Reward Distribution: Users might receive incorrect amounts of rewards due to the inflation of totalStaked in the calculation.
Systemic Reward Errors: Over time, the rewards distributed could be significantly skewed, affecting all users relying on accurate reward calculations.
Manual Code Review
Ensure that newStaked is only incremented in scenarios where new tokens are being staked directly (not in cases where vested NFTs are involved). Modify the stakeVested function to only increment newVestedStaked, reflecting the nature of the staked asset. additionally, consider also modifying the function _unstakeVested to:
Remove Adjustments to newStaked: Since newStaked is intended for direct token staking, it should not be decremented when handling vested NFTs.
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.