change updateRewardIndex to count staked tokens and MP with the same weight

This commit is contained in:
Andrea Franz
2024-09-16 12:38:38 +02:00
parent 90250c9ebc
commit 54ddaa71f2

View File

@@ -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;
}
}