From 56b34d86061996caa179a48547ffe048c16b8081 Mon Sep 17 00:00:00 2001 From: kifen Date: Wed, 15 Dec 2021 02:25:46 +0100 Subject: [PATCH] Emit event on updating allocation --- contracts/StakingGrayblock.sol | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/contracts/StakingGrayblock.sol b/contracts/StakingGrayblock.sol index b1de0b8..dd80be1 100644 --- a/contracts/StakingGrayblock.sol +++ b/contracts/StakingGrayblock.sol @@ -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);