Skip to content

Commit

Permalink
Allow non-duration change amount increase staking extends
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVF committed Apr 24, 2024
1 parent 820fccf commit 3784333
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions contracts/ExponentialStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/staking/ExponentialStaking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 3784333

Please sign in to comment.