From 54ddaa71f2b22ea08f7f991acaa80ccbf70e75e7 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Mon, 16 Sep 2024 12:38:38 +0200 Subject: [PATCH] change updateRewardIndex to count staked tokens and MP with the same weight --- src/RewardsStreamerMP.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/RewardsStreamerMP.sol b/src/RewardsStreamerMP.sol index 0d91ab6..78c4f33 100644 --- a/src/RewardsStreamerMP.sol +++ b/src/RewardsStreamerMP.sol @@ -139,7 +139,8 @@ contract RewardsStreamerMP is ReentrancyGuard { } function updateRewardIndex() public { - if (totalStaked == 0) { + uint256 totalWeight = totalStaked + totalMP; + if (totalWeight == 0) { return; } @@ -147,7 +148,7 @@ contract RewardsStreamerMP is ReentrancyGuard { uint256 newRewards = rewardBalance > accountedRewards ? rewardBalance - accountedRewards : 0; if (newRewards > 0) { - rewardIndex += (newRewards * SCALE_FACTOR) / totalStaked; + rewardIndex += (newRewards * SCALE_FACTOR) / totalWeight; accountedRewards += newRewards; } }