We don't clear the variable rewardPerTokenStored
, and this variable will be used in next distribution period. This will impact the reward calculation.
In staking contract, we will calculate rewards based on function _rewardPerToken()
. We will calculate the rewards based on previous reward per token. The vulnerability is that we don't reset the variable rewardPerTokenStored
when last distribution period ended. We will calculate the price based on last distribution period rewardPerTokenStored
. This could cause incorrect reward results.
Add this test case into TempleGoldStaking.t.sol.
In below test case, Alice stake 100 ether in the first distribution period and withdraw all staking amount when the first distribution period finished. Bob stakes 100 ether in the second distribution. From the output of the test case, bob should earn double rewards compared with Alice's rewards.
Stakers may get more rewards if there is enough rewards or stakers cannot get their rewards.
Manual
Clear the related variables when one distribution period ends.
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.