Compare commits
2 Commits
4fb0b01e3c
...
169cb516a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 169cb516a1 | |||
| 93b18e719d |
@ -52,6 +52,9 @@ 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(
|
||||||
@ -69,6 +72,7 @@ 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) {
|
||||||
@ -112,6 +116,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,10 +185,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +198,6 @@ 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,22 @@ 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);
|
||||||
|
|||||||
@ -90,9 +90,6 @@ contract GhostBondDepositoryTest is Test {
|
|||||||
);
|
);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
|
||||||
vm.prank(GOVERNOR);
|
|
||||||
staking.setWarmupPeriod(0);
|
|
||||||
|
|
||||||
_createFirstBond();
|
_createFirstBond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,22 @@ 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);
|
||||||
@ -76,9 +92,6 @@ 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 {
|
||||||
@ -152,6 +165,16 @@ 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);
|
||||||
|
|
||||||
@ -301,6 +324,19 @@ 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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user