Skip to content

Commit

Permalink
fix: [L01] Dangerous maximum values for reward calculations (#45)
Browse files Browse the repository at this point in the history
* fix: [L01] Dangerous maximum values for reward calculations

Signed-off-by: nicholaspai <npai.nyc@gmail.com>

* set 1milx max multiplier

* Update contracts/AcceleratingDistributor.sol

Co-authored-by: Matt Rice <matthewcrice32@gmail.com>

* Update AcceleratingDistributor.sol

* Update AcceleratingDistributor.Admin.ts

Signed-off-by: nicholaspai <npai.nyc@gmail.com>
Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: Paul <108695806+pxrl@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 4, 2023
1 parent 5254dec commit 2e9794a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions contracts/AcceleratingDistributor.sol
Expand Up @@ -156,10 +156,10 @@ contract AcceleratingDistributor is ReentrancyGuard, Ownable, Multicall {
// payouts could eat into user balances. maxMultiplier is constrained to be at least 1e18 to enforce a minimum
// 1x multiplier and avoid potential underflows.
require(stakedToken != address(rewardToken), "Staked token is reward token");
require(maxMultiplier <= 1e24, "maxMultiplier too large"); // 1_000_000x multiplier.
require(maxMultiplier >= 1e18, "maxMultiplier less than 1e18");
require(maxMultiplier < 1e36, "maxMultiplier can not be set too large");
require(secondsToMaxMultiplier > 0, "secondsToMaxMultiplier must be greater than 0");
require(baseEmissionRate < 1e27, "baseEmissionRate can not be set too large");
require(secondsToMaxMultiplier > 0, "secondsToMaxMultiplier is 0");
require(baseEmissionRate <= 1e24, "baseEmissionRate too large"); // 1 million tokens per second.

StakingToken storage stakingToken = stakingTokens[stakedToken];

Expand Down
8 changes: 4 additions & 4 deletions test/AcceleratingDistributor.Admin.ts
Expand Up @@ -120,14 +120,14 @@ describe("AcceleratingDistributor: Admin Functions", async function () {
lpToken1.address,
true,
baseEmissionRate,
toWei(toWei(1)),
toWei(10000000),
secondsToMaxMultiplier
)
).to.be.revertedWith("maxMultiplier can not be set too large");
).to.be.revertedWith("maxMultiplier too large");

await expect(
distributor.configureStakingToken(lpToken1.address, true, baseEmissionRate, maxMultiplier, 0)
).to.be.revertedWith("secondsToMaxMultiplier must be greater than 0");
).to.be.revertedWith("secondsToMaxMultiplier is 0");

await expect(
distributor.configureStakingToken(
Expand All @@ -137,7 +137,7 @@ describe("AcceleratingDistributor: Admin Functions", async function () {
maxMultiplier,
secondsToMaxMultiplier
)
).to.be.revertedWith("baseEmissionRate can not be set too large");
).to.be.revertedWith("baseEmissionRate too large");

await expect(
distributor.configureStakingToken(lpToken1.address, true, baseEmissionRate, toWei(1), secondsToMaxMultiplier)
Expand Down

0 comments on commit 2e9794a

Please sign in to comment.