From 6bebb16c6ff0a915ec32f70de804398f8e42887e Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Mon, 16 Sep 2024 12:41:52 +0200 Subject: [PATCH] improve updateGlobalMP --- src/RewardsStreamerMP.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/RewardsStreamerMP.sol b/src/RewardsStreamerMP.sol index 5ce3544..4ea5b2f 100644 --- a/src/RewardsStreamerMP.sol +++ b/src/RewardsStreamerMP.sol @@ -177,13 +177,17 @@ contract RewardsStreamerMP is ReentrancyGuard { function updateGlobalMP() internal { if (potentialMP == 0) { + lastMPUpdatedTime = block.timestamp; return; } uint256 currentTime = block.timestamp; uint256 timeDiff = currentTime - lastMPUpdatedTime; - uint256 accruedMP = (timeDiff * totalStaked * MP_RATE_PER_YEAR) / (365 days); + if (timeDiff == 0) { + return; + } + uint256 accruedMP = (timeDiff * totalStaked * MP_RATE_PER_YEAR) / (365 days * SCALE_FACTOR); if (accruedMP > potentialMP) { accruedMP = potentialMP; }