diff --git a/src/Staking.sol b/src/Staking.sol index 982d861..83c9249 100644 --- a/src/Staking.sol +++ b/src/Staking.sol @@ -81,7 +81,7 @@ contract GhostStaking is IStaking, GhostAccessControlled { ) external override returns (uint256 returnAmount) { if (!unlocks[to] && to != msg.sender) revert ExternalDepositsLocked(); - returnAmount = amount + rebase(); + returnAmount = amount + this.rebase(); IERC20(ftso).safeTransferFrom(msg.sender, address(this), amount); if (isClaim && warmupPeriod == 0) { @@ -132,12 +132,14 @@ contract GhostStaking is IStaking, GhostAccessControlled { bool isTrigger, bool isRebase ) external override returns (uint256) { - amount += isTrigger ? rebase() : 0; + uint256 extraAmount = isTrigger ? this.rebase() : 0; + if (isRebase) { + amount += extraAmount; ISTNK(stnk).safeTransferFrom(msg.sender, address(this), amount); } else { IGHST(ghst).burn(msg.sender, amount); - amount = IGHST(ghst).balanceFrom(amount); + amount = IGHST(ghst).balanceFrom(amount) + extraAmount; } if (amount > IERC20(ftso).balanceOf(address(this))) revert InsufficientBalance(); @@ -213,7 +215,9 @@ contract GhostStaking is IStaking, GhostAccessControlled { if (distributor != address(0)) { IDistributor(distributor).distribute(); - bounty = IDistributor(distributor).retrieveBounty(); + if (msg.sender == address(this)) { + bounty = IDistributor(distributor).retrieveBounty(); + } } uint256 balance = IERC20(ftso).balanceOf(address(this)); diff --git a/test/staking/Staking.t.sol b/test/staking/Staking.t.sol index bc7c377..34b3fc5 100644 --- a/test/staking/Staking.t.sol +++ b/test/staking/Staking.t.sol @@ -576,7 +576,7 @@ contract StakingTest is Test { (,,, uint256 distribute) = staking.epoch(); assertEq(distribute, postBounty); assertEq(stnk.balanceOf(ALICE), postBounty); - assertEq(ftso.balanceOf(address(staking)), 2 * postBounty + bounty); + assertEq(ftso.balanceOf(address(staking)), 2 * postBounty); } function test_arbitraryAddressCouldNotAddGatekeeper(address someone, address maybeGatekeeper) public {