Refer details
totalSupply only updated in 2 places addStake()and _withdrawFor()
And when all token removed from staking contract in any point of time rewardData.rewardPerTokenStorednever reseted, So thats why next stakers could take benefits from this.
Let consider following senario
Alice stake 1000 Tokens
Fast forward in Time
Alice Wants to withdraw all of its token via withdraw()
updateReward() modifier called which further call _rewardPerToken()
Here you can see that if totalSupply == 0 it returns current stored rewardPerTokenStoredother wise it goes to second step, In our case it will goes through second step and return value from this function will be stored in Storage rewardDatastructure as seen top code segment.
As here Alice was single user and he stake withdraw
Now rewardDatastruct's rewardPerTokenStoredholds updated value, not get reseted.
When next User Bob comes and call for stake() he get benefited from this one, his claimable Reward will as per updateReward()modifier will Use this rewardPerTokenStored as base.
Later Users May get some extra benifits.
Manual Review
rewardData.rewardPerTokenStoredshould reseted when ever _totalSupplyof staking contract again becomes 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.