diff --git a/certora/specs/EmergencyMode.spec b/certora/specs/EmergencyMode.spec index b32513a..4c399d0 100644 --- a/certora/specs/EmergencyMode.spec +++ b/certora/specs/EmergencyMode.spec @@ -24,12 +24,18 @@ definition isViewFunction(method f) returns bool = ( f.selector == sig:streamer.getAccount(address).selector || f.selector == sig:streamer.rewardsBalanceOf(address).selector || f.selector == sig:streamer.totalRewardsSupply().selector || - f.selector == sig:streamer.calculateAccountRewards(address).selector + f.selector == sig:streamer.calculateAccountRewards(address).selector || + f.selector == sig:streamer.lastRewardTime().selector || + f.selector == sig:streamer.rewardAmount().selector || + f.selector == sig:streamer.totalRewardsAccrued().selector || + f.selector == sig:streamer.rewardStartTime().selector || + f.selector == sig:streamer.rewardEndTime().selector ); definition isOwnableFunction(method f) returns bool = ( f.selector == sig:streamer.renounceOwnership().selector || - f.selector == sig:streamer.transferOwnership(address).selector + f.selector == sig:streamer.transferOwnership(address).selector || + f.selector == sig:streamer.setReward(uint256, uint256).selector ); definition isTrustedCodehashAccessFunction(method f) returns bool = ( diff --git a/src/RewardsStreamerMP.sol b/src/RewardsStreamerMP.sol index 8062fd4..08a4e00 100644 --- a/src/RewardsStreamerMP.sol +++ b/src/RewardsStreamerMP.sol @@ -261,7 +261,7 @@ contract RewardsStreamerMP is UUPSUpgradeable, IStakeManager, TrustedCodehashAcc rewardEndTime = block.timestamp + duration; } - function _calculateAccruedRewards() internal view returns (uint256) { + function _calculatePendingRewards() internal view returns (uint256) { if (rewardEndTime <= rewardStartTime) { // No active reward period return 0; @@ -300,7 +300,7 @@ contract RewardsStreamerMP is UUPSUpgradeable, IStakeManager, TrustedCodehashAcc return; } - uint256 newRewards = _calculateAccruedRewards(); + uint256 newRewards = _calculatePendingRewards(); if (newRewards == 0) { return; } @@ -367,7 +367,7 @@ contract RewardsStreamerMP is UUPSUpgradeable, IStakeManager, TrustedCodehashAcc } function totalRewardsSupply() public view returns (uint256) { - return totalRewardsAccrued + _calculateAccruedRewards(); + return totalRewardsAccrued + _calculatePendingRewards(); } function rewardsBalanceOf(address accountAddress) external view returns (uint256) { diff --git a/test/RewardsStreamerMP.t.sol b/test/RewardsStreamerMP.t.sol index 17a3e60..c4297a1 100644 --- a/test/RewardsStreamerMP.t.sol +++ b/test/RewardsStreamerMP.t.sol @@ -224,7 +224,6 @@ contract IntegrationTest is RewardsStreamerMPTest { // T3 vm.prank(admin); - // rewardToken.transfer(address(streamer), 1000e18); streamer.updateGlobalState(); checkStreamer( @@ -370,7 +369,6 @@ contract IntegrationTest is RewardsStreamerMPTest { // T6 vm.prank(admin); - // rewardToken.transfer(address(streamer), 1000e18); streamer.updateGlobalState(); checkStreamer( @@ -1996,6 +1994,7 @@ contract RewardsStreamerMP_RewardsTest is RewardsStreamerMPTest { // set other 2000 rewards for other 10 days vm.prank(admin); streamer.setReward(2000e18, 10 days); + // accrued is 1000 from the previous reward and still 0 for the new one assertEq(streamer.totalRewardsSupply(), 1000e18, "totalRewardsSupply should be 1000"); assertEq(streamer.totalRewardsAccrued(), 1000e18);