Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
chg: use SafeMath
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Ermolin committed Feb 8, 2021
1 parent 42ff695 commit 8ac7918
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/staking/stakeManager/StakeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ contract StakeManager is
uint256 _maxSkippedCheckpoints,
uint256 _checkpointRewardDelta
) public onlyGovernance {
require(_maxSkippedCheckpoints * _rewardDecreasePerCheckpoint <= CHK_REWARD_PRECISION);
require(_maxSkippedCheckpoints.mul(_rewardDecreasePerCheckpoint) <= CHK_REWARD_PRECISION);
require(_checkpointRewardDelta <= CHK_REWARD_PRECISION);

rewardDecreasePerCheckpoint = _rewardDecreasePerCheckpoint;
Expand Down Expand Up @@ -844,11 +844,11 @@ contract StakeManager is
uint256 _rewardDecreasePerCheckpoint = rewardDecreasePerCheckpoint;

// calculate reward for full intervals
reward = ckpReward * fullIntervals - ckpReward * ((fullIntervals - 1) * fullIntervals / 2 * _rewardDecreasePerCheckpoint) / CHK_REWARD_PRECISION;
reward = ckpReward.mul(fullIntervals).sub(ckpReward.mul(((fullIntervals - 1) * fullIntervals / 2).mul(_rewardDecreasePerCheckpoint)).div(CHK_REWARD_PRECISION));
// adjust block interval, in case last interval is not full
blockInterval -= fullIntervals * targetBlockInterval;
blockInterval = blockInterval.sub(fullIntervals.mul(targetBlockInterval));
// adjust checkpoint reward by the amount it suppose to decrease
ckpReward -= ckpReward * fullIntervals * _rewardDecreasePerCheckpoint / CHK_REWARD_PRECISION;
ckpReward = ckpReward.sub(ckpReward.mul(fullIntervals).mul(_rewardDecreasePerCheckpoint).div(CHK_REWARD_PRECISION));
}

// give proportionally less for the rest
Expand Down

0 comments on commit 8ac7918

Please sign in to comment.