In TempleGoldStaking
, vestingRate
is used to introduce vesting for the tokens earned. However, there can be rounding issues due to in-correct order of multiplication and division.
The _earned
function calculates _perTokenReward
as following
_perTokenReward = _rewardPerToken() * vestingRate / 1e18;
vestingRate
is calculated using following formula:
vestingRate
formula involves division with vestingPeriod
and that result is multiplied with _rewardPerToken()
in _earned
function. Due to this, there can be minor precision loss.
Precision loss. This can result in low earning of user's reward token.
Manual review
Do all the multiplication before dividing the results. The above formula can be corrected as:
_perTokenReward = (_rewardPerToken() * (block.timestamp - _stakeInfo.stakeTime) * 1e18) / vestingPeriod / 1e18
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.