Skip to content

Commit

Permalink
Use treasury to start and stop mining
Browse files Browse the repository at this point in the history
  • Loading branch information
danhper committed Sep 23, 2024
1 parent 7bc2b53 commit 8c8c31d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/sGydStaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ contract sGydStaker is
LiquidityMining,
UUPSUpgradeable
{
error NotAuthorized();

modifier onlyTreasury() {
if (msg.sender != daoTreasury) revert NotAuthorized();
_;
}

constructor() {
_disableInitializers();
}
Expand Down Expand Up @@ -44,15 +51,11 @@ contract sGydStaker is
_unstake(receiver, shares);
}

function startMining(address rewardsFrom, uint256 amount, uint256 endTime)
external
override
onlyRole(DEFAULT_ADMIN_ROLE)
{
function startMining(address rewardsFrom, uint256 amount, uint256 endTime) external override onlyTreasury {
_startMining(rewardsFrom, amount, endTime);
}

function stopMining() external override onlyRole(DEFAULT_ADMIN_ROLE) {
function stopMining() external override onlyTreasury {
_stopMining();
}
}
4 changes: 2 additions & 2 deletions test/sGydStaker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ contract sGydStakerTest is UnitTest {
sgydStaker.claimRewards();

skip(18 hours);
vm.prank(admin);
vm.prank(treasury);
sgydStaker.stopMining();
_startMining(rewardAmount * 2);
skip(24 hours);
Expand Down Expand Up @@ -126,7 +126,7 @@ contract sGydStakerTest is UnitTest {
rewardToken.mint(treasury, rewardAmount);
vm.prank(treasury);
rewardToken.approve(address(sgydStaker), rewardAmount);
vm.prank(admin);
vm.prank(treasury);
sgydStaker.startMining(treasury, rewardAmount, block.timestamp + 1 days);
}
}

0 comments on commit 8c8c31d

Please sign in to comment.