In TempleGoldStaking, vestingRateis used to introduce vesting for the tokens earned. However, there can be rounding issues due to in-correct order of multiplication and division.
The _earnedfunction calculates _perTokenReward as following
_perTokenReward = _rewardPerToken() * vestingRate / 1e18;
vestingRateis calculated using following formula:
vestingRateformula involves division with vestingPeriodand that result is multiplied with _rewardPerToken()in _earnedfunction. 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.