In the case of vestingPeriod
decreases, vestingRate
may be inflated and and can be larger than 1e18
.
This inflates the rewards to the stakers and causes the lack of reward tokens.
The relevant code for TempleGoldStaking.setVestingFactor()
is as follows:
The formula on L491
is based on the assumption that _stakeInfo.fullyVestedAt - _stakeInfo.stakeTime == vestingPeriod
.
However, when administrator decreases vestingPeriod
by calling of TemplateGoldStaking.setVestingPeriod
, _stakeInfo.fullyVestedAt - _stakeInfo.stakeTime
becomes greater than vestingPeriod
and thus the vestingRate
may be greater than 1e18
.
The vestingRate
is used to calculate the rewards amount for stakers in TempleGoldStaking._earned()
as follows.
Therefore, if vestingRate
is greater than 1e18
, the rewards amount to the stakers will be inflated.
Scenario:
At the begining, vestingPeriod
is 3 weeks
.
A staker stake some tokens and 2 weeks
elasped.
Administrator decreases vestingPeriod
to 1 weeks
.
The vestingRate
of the staker is calculated as ((block.timestamp - _stakeInfo.stakeTime) * 1e18 / vestingPeriod) = (2 weeks * 1e18 / 1 weeks) = 2e18
in L491
.
The staker calls TempleGoldStaking.getReward()
and takes away twice rewards from the staking pool.
This may cause lacks of reward tokens from TempleGoldStaking
.
When administrator decreases vestingPeriod
, the rewards to the stakers may be inflated and the lack of reward tokens may occur.
Manual Review
Modify the TempleGoldStaking._getVestingRate()
as follows.
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.