Compare commits

..

No commits in common. "169cb516a1fda3a730bb854f2bf1f73e8ca08288" and "4fb0b01e3c6d066bd37749049ef771dc0e1a9898" have entirely different histories.

4 changed files with 13 additions and 60 deletions

View File

@ -52,9 +52,6 @@ contract GhostStaking is IStaking, GhostAccessControlled {
end: _firstEpochTime, end: _firstEpochTime,
distribute: 0 distribute: 0
}); });
GhostWarmup newWarmup = new GhostWarmup(_ghst);
warmup = address(newWarmup);
} }
function stake( function stake(
@ -72,7 +69,6 @@ contract GhostStaking is IStaking, GhostAccessControlled {
uint48 expiry = epoch.number + warmupPeriod; uint48 expiry = epoch.number + warmupPeriod;
IGhostWarmup(warmup).addToWarmup(returnAmount, to, expiry); IGhostWarmup(warmup).addToWarmup(returnAmount, to, expiry);
} }
emit Staked(msg.sender, to, amount, isRebase, isClaim);
} }
function claim(address to, bool isRebase) public override returns (uint256 claimedAmount) { function claim(address to, bool isRebase) public override returns (uint256 claimedAmount) {
@ -116,7 +112,6 @@ contract GhostStaking is IStaking, GhostAccessControlled {
if (amount > IERC20(ftso).balanceOf(address(this))) revert InsufficientBalance(); if (amount > IERC20(ftso).balanceOf(address(this))) revert InsufficientBalance();
IERC20(ftso).safeTransfer(to, amount); IERC20(ftso).safeTransfer(to, amount);
emit Unstaked(msg.sender, to, amount, isTrigger, isRebase);
return amount; return amount;
} }
@ -185,6 +180,10 @@ contract GhostStaking is IStaking, GhostAccessControlled {
function setWarmupPeriod(uint256 _warmupPeriod) external onlyGovernor { function setWarmupPeriod(uint256 _warmupPeriod) external onlyGovernor {
// forge-lint: disable-next-line(unsafe-typecast) // forge-lint: disable-next-line(unsafe-typecast)
warmupPeriod = uint48(_warmupPeriod); warmupPeriod = uint48(_warmupPeriod);
if (warmup == address(0)) {
GhostWarmup newWarmup = new GhostWarmup(ghst);
warmup = address(newWarmup);
}
emit WarmupSet(_warmupPeriod); emit WarmupSet(_warmupPeriod);
} }
@ -198,6 +197,9 @@ contract GhostStaking is IStaking, GhostAccessControlled {
} }
function supplyInWarmup() public view override returns (uint256) { function supplyInWarmup() public view override returns (uint256) {
if (warmup == address(0)) {
return 0;
}
return IGHST(ghst).balanceFrom(IGhostWarmup(warmup).ghstInWarmup()); return IGHST(ghst).balanceFrom(IGhostWarmup(warmup).ghstInWarmup());
} }

View File

@ -6,22 +6,6 @@ interface IStaking {
error ExternalClaimsLocked(); error ExternalClaimsLocked();
error InsufficientBalance(); error InsufficientBalance();
event Staked(
address sender,
address receiver,
uint256 amount,
bool isRebase,
bool isClaim
);
event Unstaked(
address sender,
address receiver,
uint256 amount,
bool isTrigger,
bool isRebase
);
event DistributorSet(address distributor); event DistributorSet(address distributor);
event GatekeeperSet(address gatekeeper); event GatekeeperSet(address gatekeeper);
event WarmupSet(uint256 warmup); event WarmupSet(uint256 warmup);

View File

@ -90,6 +90,9 @@ contract GhostBondDepositoryTest is Test {
); );
vm.stopPrank(); vm.stopPrank();
vm.prank(GOVERNOR);
staking.setWarmupPeriod(0);
_createFirstBond(); _createFirstBond();
} }

View File

@ -46,22 +46,6 @@ contract StakingTest is Test {
uint256 public constant AMOUNT = 69; uint256 public constant AMOUNT = 69;
uint256 public constant BIG_AMOUNT = AMOUNT * 1e9; uint256 public constant BIG_AMOUNT = AMOUNT * 1e9;
event Staked(
address sender,
address receiver,
uint256 amount,
bool isRebase,
bool isClaim
);
event Unstaked(
address sender,
address receiver,
uint256 amount,
bool isTrigger,
bool isRebase
);
event DistributorSet(address distributor); event DistributorSet(address distributor);
event WarmupSet(uint256 warmup); event WarmupSet(uint256 warmup);
event Ghosted(bytes32 indexed receiver, uint256 indexed amount); event Ghosted(bytes32 indexed receiver, uint256 indexed amount);
@ -92,6 +76,9 @@ contract StakingTest is Test {
gatekeeper = new Gatekeeper(address(staking), 0, 0, 0, 0, 0); gatekeeper = new Gatekeeper(address(staking), 0, 0, 0, 0, 0);
calculator = new GhostBondingCalculator(address(ftso), 1, 1); calculator = new GhostBondingCalculator(address(ftso), 1, 1);
vm.stopPrank(); vm.stopPrank();
vm.prank(GOVERNOR);
staking.setWarmupPeriod(0);
} }
function test_correctAfterConstruction() public view { function test_correctAfterConstruction() public view {
@ -165,16 +152,6 @@ contract StakingTest is Test {
assertEq(lock, false); assertEq(lock, false);
} }
function test_stake_emitsStakedEvent() public {
_mintAndApprove(ALICE, AMOUNT);
vm.expectEmit(true, true, true, false, address(staking));
emit Staked(ALICE, ALICE, AMOUNT, true, true);
vm.prank(ALICE);
staking.stake(AMOUNT, ALICE, true, true);
}
function test_stake_exchangesFatsoToStinkyWhenClaimIsTrueAndRebasingIsTrue() public { function test_stake_exchangesFatsoToStinkyWhenClaimIsTrueAndRebasingIsTrue() public {
_mintAndApprove(ALICE, AMOUNT); _mintAndApprove(ALICE, AMOUNT);
@ -324,19 +301,6 @@ contract StakingTest is Test {
assertEq(staking.supplyInWarmup(), 0); assertEq(staking.supplyInWarmup(), 0);
} }
function test_unstake_emitsUnstakedEvent() public {
_prepareAndRoll(ALICE, AMOUNT, true, true);
uint256 aliceBalance = stnk.balanceOf(ALICE);
vm.startPrank(ALICE);
stnk.approve(address(staking), aliceBalance);
vm.expectEmit(true, true, true, false, address(staking));
emit Unstaked(ALICE, ALICE, aliceBalance, false, true);
staking.unstake(aliceBalance, ALICE, false, true);
vm.stopPrank();
}
function test_unstake_canRedeemStinkyToFatso() public { function test_unstake_canRedeemStinkyToFatso() public {
_prepareAndRoll(ALICE, AMOUNT, true, true); _prepareAndRoll(ALICE, AMOUNT, true, true);
uint256 aliceBalance = stnk.balanceOf(ALICE); uint256 aliceBalance = stnk.balanceOf(ALICE);