Skip to content

Commit

Permalink
Add patch for stakingrewards (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
alsco77 committed Oct 9, 2020
1 parent 816b2a6 commit 2722417
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/rewards/staking/StakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ contract StakingRewards is StakingTokenWrapper, RewardsDistributionRecipient {
onlyRewardsDistributor
updateReward(address(0))
{
require(_reward < 1e24, "Cannot notify with more than a million units");

uint256 currentTime = block.timestamp;
// If previous period over, reset rewardRate
if (currentTime >= periodFinish) {
Expand Down
2 changes: 2 additions & 0 deletions contracts/rewards/staking/StakingRewardsWithPlatformToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ contract StakingRewardsWithPlatformToken is StakingTokenWrapper, RewardsDistribu
onlyRewardsDistributor
updateReward(address(0))
{
require(_reward < 1e24, "Cannot notify with more than a million units");

uint256 newPlatformRewards = platformToken.balanceOf(address(this));
if(newPlatformRewards > 0){
platformToken.safeTransfer(address(platformTokenVendor), newPlatformRewards);
Expand Down
13 changes: 13 additions & 0 deletions test/rewards/TestStakingRewards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,19 @@ contract("StakingRewards", async (accounts) => {
});
});
});
context("funding with too much rewards", () => {
before(async () => {
stakingRewards = await redeployRewards();
});
it("should fail", async () => {
await expectRevert(
stakingRewards.notifyRewardAmount(simpleToExactAmount(1, 25), {
from: sa.fundManager,
}),
"Cannot notify with more than a million units",
);
});
});
context("staking before rewards are added", () => {
before(async () => {
stakingRewards = await redeployRewards();
Expand Down
14 changes: 14 additions & 0 deletions test/rewards/TestStakingRewardsWithPlatformToken.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,20 @@ contract("StakingRewardsWithPlatformToken", async (accounts) => {
});
});
});

context("funding with too much rewards", () => {
before(async () => {
stakingRewards = await redeployRewards();
});
it("should fail", async () => {
await expectRevert(
stakingRewards.notifyRewardAmount(simpleToExactAmount(1, 25), {
from: sa.fundManager,
}),
"Cannot notify with more than a million units",
);
});
});
context("staking before rewards are added", () => {
before(async () => {
stakingRewards = await redeployRewards();
Expand Down

0 comments on commit 2722417

Please sign in to comment.