mirror of
https://github.com/vacp2p/staking-reward-streamer.git
synced 2026-01-09 21:18:01 -05:00
add currentRewardIndex to return the live index used in updateRewardIndex
This commit is contained in:
@@ -85,10 +85,20 @@ contract StakingContract {
|
||||
return;
|
||||
}
|
||||
|
||||
(uint256 newRewards, uint256 newRewardIndex) = currentRewardIndex();
|
||||
if (newRewards > 0) {
|
||||
rewardIndex = newRewardIndex;
|
||||
accountedRewards += newRewards;
|
||||
}
|
||||
}
|
||||
|
||||
function currentRewardIndex() public view returns (uint256, uint256) {
|
||||
uint256 newRewards = rewardBalance > accountedRewards ? rewardBalance - accountedRewards : 0;
|
||||
if (newRewards > 0) {
|
||||
rewardIndex += (newRewards * SCALE_FACTOR) / currentTotalMP();
|
||||
accountedRewards += newRewards;
|
||||
uint256 newRewardIndex = rewardIndex + (newRewards * SCALE_FACTOR) / currentTotalMP();
|
||||
return (newRewards, newRewardIndex);
|
||||
} else {
|
||||
return (0, rewardIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user