Skip to content

Commit

Permalink
Merge pull request #923 from lidofinance/another-round-of-renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
failingtwice authored Jan 16, 2025
2 parents 50d8b6e + 3588e47 commit 8cf3484
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 350 deletions.
287 changes: 138 additions & 149 deletions contracts/0.8.25/vaults/Delegation.sol

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions contracts/0.8.25/vaults/StakingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic
* @custom:report Latest report containing valuation and inOutDelta
* @custom:locked Amount of ether locked on StakingVault by VaultHub and cannot be withdrawn by owner
* @custom:inOutDelta Net difference between ether funded and withdrawn from StakingVault
* @custom:operator Address of the node operator
* @custom:nodeOperator Address of the node operator
*/
struct ERC7201Storage {
Report report;
uint128 locked;
int128 inOutDelta;
address operator;
address nodeOperator;
}

/**
Expand Down Expand Up @@ -115,14 +115,14 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic
}

/**
* @notice Initializes `StakingVault` with an owner, operator, and optional parameters
* @notice Initializes `StakingVault` with an owner, node operator, and optional parameters
* @param _owner Address that will own the vault
* @param _operator Address of the node operator
* @param _nodeOperator Address of the node operator
* @param - Additional initialization parameters
*/
function initialize(address _owner, address _operator, bytes calldata /* _params */ ) external onlyBeacon initializer {
function initialize(address _owner, address _nodeOperator, bytes calldata /* _params */ ) external onlyBeacon initializer {
__Ownable_init(_owner);
_getStorage().operator = _operator;
_getStorage().nodeOperator = _nodeOperator;
}

/**
Expand Down Expand Up @@ -242,8 +242,8 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic
* Node operator address is set in the initialization and can never be changed.
* @return Address of the node operator
*/
function operator() external view returns (address) {
return _getStorage().operator;
function nodeOperator() external view returns (address) {
return _getStorage().nodeOperator;
}

/**
Expand Down Expand Up @@ -316,7 +316,7 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic
) external {
if (_numberOfDeposits == 0) revert ZeroArgument("_numberOfDeposits");
if (!isBalanced()) revert Unbalanced();
if (msg.sender != _getStorage().operator) revert NotAuthorized("depositToBeaconChain", msg.sender);
if (msg.sender != _getStorage().nodeOperator) revert NotAuthorized("depositToBeaconChain", msg.sender);

_makeBeaconChainDeposits32ETH(_numberOfDeposits, bytes.concat(withdrawalCredentials()), _pubkeys, _signatures);
emit DepositedToBeaconChain(msg.sender, _numberOfDeposits, _numberOfDeposits * 32 ether);
Expand All @@ -325,7 +325,7 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic
/**
* @notice Requests validator exit from the beacon chain
* @param _pubkeys Concatenated validator public keys
* @dev Signals the operator to eject the specified validators from the beacon chain
* @dev Signals the node operator to eject the specified validators from the beacon chain
*/
function requestValidatorExit(bytes calldata _pubkeys) external onlyOwner {
emit ValidatorsExitRequest(msg.sender, _pubkeys);
Expand Down Expand Up @@ -422,7 +422,7 @@ contract StakingVault is IStakingVault, IBeaconProxy, BeaconChainDepositLogistic

/**
* @notice Emitted when a validator exit request is made
* @dev Signals `operator` to exit the validator
* @dev Signals `nodeOperator` to exit the validator
* @param sender Address that requested the validator exit
* @param pubkey Public key of the validator requested to exit
*/
Expand Down
42 changes: 21 additions & 21 deletions contracts/0.8.25/vaults/VaultFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ pragma solidity 0.8.25;
interface IDelegation {
struct InitialState {
address curator;
address staker;
address tokenMaster;
address operator;
address claimOperatorDueRole;
uint256 curatorFee;
uint256 operatorFee;
address minterBurner;
address funderWithdrawer;
address nodeOperatorManager;
address nodeOperatorFeeClaimer;
uint256 curatorFeeBP;
uint256 nodeOperatorFeeBP;
}

function DEFAULT_ADMIN_ROLE() external view returns (bytes32);

function CURATOR_ROLE() external view returns (bytes32);

function STAKER_ROLE() external view returns (bytes32);
function FUND_WITHDRAW_ROLE() external view returns (bytes32);

function TOKEN_MASTER_ROLE() external view returns (bytes32);
function MINT_BURN_ROLE() external view returns (bytes32);

function OPERATOR_ROLE() external view returns (bytes32);
function NODE_OPERATOR_MANAGER_ROLE() external view returns (bytes32);

function CLAIM_OPERATOR_DUE_ROLE() external view returns (bytes32);
function NODE_OPERATOR_FEE_CLAIMER_ROLE() external view returns (bytes32);

function initialize(address _stakingVault) external;

function setCuratorFee(uint256 _newCuratorFee) external;
function setCuratorFeeBP(uint256 _newCuratorFeeBP) external;

function setOperatorFee(uint256 _newOperatorFee) external;
function setNodeOperatorFeeBP(uint256 _newNodeOperatorFee) external;

function grantRole(bytes32 role, address account) external;

Expand Down Expand Up @@ -74,28 +74,28 @@ contract VaultFactory is UpgradeableBeacon {
delegation = IDelegation(Clones.clone(delegationImpl));

// initialize StakingVault
vault.initialize(address(delegation), _delegationInitialState.operator, _stakingVaultInitializerExtraParams);
vault.initialize(address(delegation), _delegationInitialState.nodeOperatorManager, _stakingVaultInitializerExtraParams);
// initialize Delegation
delegation.initialize(address(vault));

// grant roles to owner, manager, operator
delegation.grantRole(delegation.DEFAULT_ADMIN_ROLE(), msg.sender);
delegation.grantRole(delegation.CURATOR_ROLE(), _delegationInitialState.curator);
delegation.grantRole(delegation.STAKER_ROLE(), _delegationInitialState.staker);
delegation.grantRole(delegation.TOKEN_MASTER_ROLE(), _delegationInitialState.tokenMaster);
delegation.grantRole(delegation.OPERATOR_ROLE(), _delegationInitialState.operator);
delegation.grantRole(delegation.CLAIM_OPERATOR_DUE_ROLE(), _delegationInitialState.claimOperatorDueRole);
delegation.grantRole(delegation.FUND_WITHDRAW_ROLE(), _delegationInitialState.funderWithdrawer);
delegation.grantRole(delegation.MINT_BURN_ROLE(), _delegationInitialState.minterBurner);
delegation.grantRole(delegation.NODE_OPERATOR_MANAGER_ROLE(), _delegationInitialState.nodeOperatorManager);
delegation.grantRole(delegation.NODE_OPERATOR_FEE_CLAIMER_ROLE(), _delegationInitialState.nodeOperatorFeeClaimer);

// grant temporary roles to factory
delegation.grantRole(delegation.CURATOR_ROLE(), address(this));
delegation.grantRole(delegation.OPERATOR_ROLE(), address(this));
delegation.grantRole(delegation.NODE_OPERATOR_MANAGER_ROLE(), address(this));
// set fees
delegation.setCuratorFee(_delegationInitialState.curatorFee);
delegation.setOperatorFee(_delegationInitialState.operatorFee);
delegation.setCuratorFeeBP(_delegationInitialState.curatorFeeBP);
delegation.setNodeOperatorFeeBP(_delegationInitialState.nodeOperatorFeeBP);

// revoke temporary roles from factory
delegation.revokeRole(delegation.CURATOR_ROLE(), address(this));
delegation.revokeRole(delegation.OPERATOR_ROLE(), address(this));
delegation.revokeRole(delegation.NODE_OPERATOR_MANAGER_ROLE(), address(this));
delegation.revokeRole(delegation.DEFAULT_ADMIN_ROLE(), address(this));

emit VaultCreated(address(delegation), address(vault));
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.25/vaults/interfaces/IStakingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface IStakingVault {
function initialize(address _owner, address _operator, bytes calldata _params) external;
function getInitializedVersion() external view returns (uint64);
function vaultHub() external view returns (address);
function operator() external view returns (address);
function nodeOperator() external view returns (address);
function locked() external view returns (uint256);
function valuation() external view returns (uint256);
function isBalanced() external view returns (bool);
Expand Down
12 changes: 6 additions & 6 deletions lib/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export async function createVaultProxy(
): Promise<CreateVaultResponse> {
// Define the parameters for the struct
const initializationParams: DelegationInitializationParamsStruct = {
curatorFee: 100n,
operatorFee: 200n,
curatorFeeBP: 100n,
nodeOperatorFeeBP: 200n,
curator: await _owner.getAddress(),
staker: await _owner.getAddress(),
tokenMaster: await _owner.getAddress(),
operator: await _operator.getAddress(),
claimOperatorDueRole: await _owner.getAddress(),
funderWithdrawer: await _owner.getAddress(),
minterBurner: await _owner.getAddress(),
nodeOperatorManager: await _operator.getAddress(),
nodeOperatorFeeClaimer: await _owner.getAddress(),
};

const tx = await vaultFactory.connect(_owner).createVault(initializationParams, "0x");
Expand Down
8 changes: 4 additions & 4 deletions test/0.8.25/vaults/dashboard/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Snapshot } from "test/suite";
describe("Dashboard", () => {
let factoryOwner: HardhatEthersSigner;
let vaultOwner: HardhatEthersSigner;
let operator: HardhatEthersSigner;
let nodeOperator: HardhatEthersSigner;
let stranger: HardhatEthersSigner;

let steth: StETHPermit__HarnessForDashboard;
Expand All @@ -45,7 +45,7 @@ describe("Dashboard", () => {
const BP_BASE = 10_000n;

before(async () => {
[factoryOwner, vaultOwner, operator, stranger] = await ethers.getSigners();
[factoryOwner, vaultOwner, nodeOperator, stranger] = await ethers.getSigners();

steth = await ethers.deployContract("StETHPermit__HarnessForDashboard");
await steth.mock__setTotalShares(ether("1000000"));
Expand All @@ -67,7 +67,7 @@ describe("Dashboard", () => {
expect(await factory.implementation()).to.equal(vaultImpl);
expect(await factory.dashboardImpl()).to.equal(dashboardImpl);

const createVaultTx = await factory.connect(vaultOwner).createVault(operator);
const createVaultTx = await factory.connect(vaultOwner).createVault(nodeOperator);
const createVaultReceipt = await createVaultTx.wait();
if (!createVaultReceipt) throw new Error("Vault creation receipt not found");

Expand Down Expand Up @@ -139,7 +139,7 @@ describe("Dashboard", () => {
context("initialized state", () => {
it("post-initialization state is correct", async () => {
expect(await vault.owner()).to.equal(dashboard);
expect(await vault.operator()).to.equal(operator);
expect(await vault.nodeOperator()).to.equal(nodeOperator);
expect(await dashboard.isInitialized()).to.equal(true);
expect(await dashboard.stakingVault()).to.equal(vault);
expect(await dashboard.vaultHub()).to.equal(hub);
Expand Down
Loading

0 comments on commit 8cf3484

Please sign in to comment.