diff --git a/contracts/ExponentialStaking.sol b/contracts/ExponentialStaking.sol index 63fbecff..dd765b7a 100644 --- a/contracts/ExponentialStaking.sol +++ b/contracts/ExponentialStaking.sol @@ -16,7 +16,7 @@ import {RewardsSource} from "./RewardsSource.sol"; /// The balance received for staking (and thus the voting power and rewards /// distribution) goes up exponentially by the end of the staked period. contract ExponentialStaking is ERC20Votes { - uint256 public immutable epoch; // timestamp + uint256 public immutable epoch; // Start of staking program - timestamp ERC20 public immutable asset; // Must not allow reentrancy RewardsSource public immutable rewardsSource; uint256 public immutable minStakeDuration; // in seconds @@ -136,7 +136,8 @@ contract ExponentialStaking is ERC20Votes { // Update or create lockup if (lockupId != NEW_STAKE) { - require(newEnd > oldEnd, "Staking: New lockup must be longer"); + require(newEnd >= oldEnd, "Staking: New lockup must not be shorter"); + require(newPoints > oldPoints, "Staking: Must have increased amount or duration"); lockups[to][uint256(lockupId)] = lockup; } else { lockups[to].push(lockup); diff --git a/tests/staking/ExponentialStaking.t.sol b/tests/staking/ExponentialStaking.t.sol index 4bbb2be0..83b4adf1 100644 --- a/tests/staking/ExponentialStaking.t.sol +++ b/tests/staking/ExponentialStaking.t.sol @@ -186,7 +186,7 @@ contract ExponentialStakingTest is Test { vm.startPrank(bob); staking.stake(100 ether, 11 days, bob, false, NEW_STAKE); - vm.expectRevert("Staking: New lockup must be longer"); + vm.expectRevert("Staking: New lockup must not be shorter"); staking.stake(1 ether, 8 days, bob, false, 0); }