Skip to content

Commit

Permalink
Emit event on updating allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kifen committed Dec 15, 2021
1 parent 7d3222c commit 56b34d8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions contracts/StakingGrayblock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,17 @@ contract GrayblockStaking is ReentrancyGuard, Ownable {

if (stakeInfos.size() == 0) {
accumulatedPoolReward.add(_amount);
return;
}

uint256 rewardAmount = _amount.add(accumulatedPoolReward);
for (uint256 i = 0; i < stakeInfos.size(); i++) {
address key = stakeInfos.getKeyAtIndex(i);
IterableMapping.StakeInfo storage stakeInfo = stakeInfos.values[
key
];
stakeInfo.rewardAmount = stakeInfo.rewardAmount.add(
rewardAmount.mul(stakeInfo.amount).div(totalStakedBalance)
);
} else {
uint256 rewardAmount = _amount.add(accumulatedPoolReward);
for (uint256 i = 0; i < stakeInfos.size(); i++) {
address key = stakeInfos.getKeyAtIndex(i);
IterableMapping.StakeInfo storage stakeInfo = stakeInfos.values[
key
];
stakeInfo.rewardAmount = stakeInfo.rewardAmount.add(
rewardAmount.mul(stakeInfo.amount).div(totalStakedBalance)
);
}
}

emit AllocationUpdated(_amount, accumulatedPoolReward);
Expand Down

0 comments on commit 56b34d8

Please sign in to comment.