Skip to content

Commit

Permalink
chore: duplicate logic into dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Jan 16, 2025
1 parent ffcb109 commit 765a205
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
28 changes: 28 additions & 0 deletions contracts/0.8.25/vaults/Dashboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,20 @@ contract Dashboard is AccessControlEnumerable {
_rebalanceVault(_ether);
}

/**
* @notice Pauses beacon chain deposits on the staking vault.
*/
function pauseBeaconChainDeposits() external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_pauseBeaconChainDeposits();
}

/**
* @notice Resumes beacon chain deposits on the staking vault.
*/
function resumeBeaconChainDeposits() external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
stakingVault.resumeBeaconChainDeposits();
}

// ==================== Internal Functions ====================

/**
Expand Down Expand Up @@ -514,6 +528,20 @@ contract Dashboard is AccessControlEnumerable {
stakingVault.rebalance(_ether);
}

/**
* @dev Pauses beacon chain deposits on the staking vault.
*/
function _pauseBeaconChainDeposits() internal {
stakingVault.pauseBeaconChainDeposits();
}

/**
* @dev Resumes beacon chain deposits on the staking vault.
*/
function _resumeBeaconChainDeposits() internal {
stakingVault.resumeBeaconChainDeposits();
}

// ==================== Events ====================

/// @notice Emitted when the contract is initialized
Expand Down
8 changes: 4 additions & 4 deletions contracts/0.8.25/vaults/Delegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ contract Delegation is Dashboard {
/**
* @notice Pauses deposits to beacon chain from the StakingVault.
*/
function pauseBeaconChainDeposits() external onlyRole(CURATOR_ROLE) {
IStakingVault(stakingVault).pauseBeaconChainDeposits();
function pauseBeaconChainDeposits() external override onlyRole(CURATOR_ROLE) {
_pauseBeaconChainDeposits();
}

/**
* @notice Resumes deposits to beacon chain from the StakingVault.
*/
function resumeBeaconChainDeposits() external onlyRole(CURATOR_ROLE) {
IStakingVault(stakingVault).resumeBeaconChainDeposits();
function resumeBeaconChainDeposits() external override onlyRole(CURATOR_ROLE) {
_resumeBeaconChainDeposits();
}

/**
Expand Down
49 changes: 47 additions & 2 deletions test/0.8.25/vaults/dashboard/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { ZeroAddress } from "ethers";
import { ethers } from "hardhat";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { setBalance } from "@nomicfoundation/hardhat-network-helpers";
import { setBalance, time } from "@nomicfoundation/hardhat-network-helpers";

import {
Dashboard,
Expand Down Expand Up @@ -992,4 +991,50 @@ describe("Dashboard", () => {
.withArgs(amount);
});
});

context("pauseBeaconChainDeposits", () => {
it("reverts if the caller is not a curator", async () => {
await expect(dashboard.connect(stranger).pauseBeaconChainDeposits()).to.be.revertedWithCustomError(
dashboard,
"AccessControlUnauthorizedAccount",
);
});

it("reverts if the beacon deposits are already paused", async () => {
await dashboard.pauseBeaconChainDeposits();

await expect(dashboard.pauseBeaconChainDeposits()).to.be.revertedWithCustomError(
vault,
"BeaconChainDepositsResumeExpected",
);
});

it("pauses the beacon deposits", async () => {
await expect(dashboard.pauseBeaconChainDeposits()).to.emit(vault, "BeaconChainDepositsPaused");
expect(await vault.beaconChainDepositsPaused()).to.be.true;
});
});

context("resumeBeaconChainDeposits", () => {
it("reverts if the caller is not a curator", async () => {
await expect(dashboard.connect(stranger).resumeBeaconChainDeposits()).to.be.revertedWithCustomError(
dashboard,
"AccessControlUnauthorizedAccount",
);
});

it("reverts if the beacon deposits are already resumed", async () => {
await expect(dashboard.resumeBeaconChainDeposits()).to.be.revertedWithCustomError(
vault,
"BeaconChainDepositsPauseExpected",
);
});

it("resumes the beacon deposits", async () => {
await dashboard.pauseBeaconChainDeposits();

await expect(dashboard.resumeBeaconChainDeposits()).to.emit(vault, "BeaconChainDepositsResumed");
expect(await vault.beaconChainDepositsPaused()).to.be.false;
});
});
});

0 comments on commit 765a205

Please sign in to comment.