diff --git a/contracts/0.8.25/vaults/StVaultOwnerWithDelegation.sol b/contracts/0.8.25/vaults/Delegation.sol similarity index 96% rename from contracts/0.8.25/vaults/StVaultOwnerWithDelegation.sol rename to contracts/0.8.25/vaults/Delegation.sol index 3e0c1052a..466a74a5a 100644 --- a/contracts/0.8.25/vaults/StVaultOwnerWithDelegation.sol +++ b/contracts/0.8.25/vaults/Delegation.sol @@ -12,7 +12,7 @@ import {Dashboard} from "./Dashboard.sol"; import {Math256} from "contracts/common/lib/Math256.sol"; /** - * @title StVaultOwnerWithDelegation + * @title Delegation * @notice This contract serves as an owner for `StakingVault` with additional delegation capabilities. * It extends `Dashboard` and implements `IReportReceiver`. * The contract provides administrative functions for managing the staking vault, @@ -26,7 +26,7 @@ import {Math256} from "contracts/common/lib/Math256.sol"; * @notice The term "fee" is used to express the fee percentage as basis points, e.g. 5%, * while "due" is the actual amount of the fee, e.g. 1 ether */ -contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { +contract Delegation is Dashboard, IReportReceiver { // ==================== Constants ==================== uint256 private constant BP_BASE = 10000; // Basis points base (100%) @@ -45,7 +45,7 @@ contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { * - vote on ownership transfer * - vote on performance fee changes */ - bytes32 public constant MANAGER_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.ManagerRole"); + bytes32 public constant MANAGER_ROLE = keccak256("Vault.Delegation.ManagerRole"); /** * @notice Role for the staker. @@ -53,7 +53,7 @@ contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { * - fund the vault * - withdraw from the vault */ - bytes32 public constant STAKER_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.StakerRole"); + bytes32 public constant STAKER_ROLE = keccak256("Vault.Delegation.StakerRole"); /** @notice Role for the operator * Operator can: @@ -62,14 +62,14 @@ contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { * - vote on ownership transfer * - set the Key Master role */ - bytes32 public constant OPERATOR_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.OperatorRole"); + bytes32 public constant OPERATOR_ROLE = keccak256("Vault.Delegation.OperatorRole"); /** * @notice Role for the key master. * Key master can: * - deposit validators to the beacon chain */ - bytes32 public constant KEY_MASTER_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.KeyMasterRole"); + bytes32 public constant KEY_MASTER_ROLE = keccak256("Vault.Delegation.KeyMasterRole"); /** * @notice Role for the token master. @@ -77,7 +77,7 @@ contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { * - mint stETH tokens * - burn stETH tokens */ - bytes32 public constant TOKEN_MASTER_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.TokenMasterRole"); + bytes32 public constant TOKEN_MASTER_ROLE = keccak256("Vault.Delegation.TokenMasterRole"); /** * @notice Role for the Lido DAO. @@ -86,7 +86,7 @@ contract StVaultOwnerWithDelegation is Dashboard, IReportReceiver { * - set the operator role * - vote on ownership transfer */ - bytes32 public constant LIDO_DAO_ROLE = keccak256("Vault.StVaultOwnerWithDelegation.LidoDAORole"); + bytes32 public constant LIDO_DAO_ROLE = keccak256("Vault.Delegation.LidoDAORole"); // ==================== State Variables ==================== diff --git a/contracts/0.8.25/vaults/VaultFactory.sol b/contracts/0.8.25/vaults/VaultFactory.sol index 143b727c1..834bac741 100644 --- a/contracts/0.8.25/vaults/VaultFactory.sol +++ b/contracts/0.8.25/vaults/VaultFactory.sol @@ -9,7 +9,7 @@ import {IStakingVault} from "./interfaces/IStakingVault.sol"; pragma solidity 0.8.25; -interface IStVaultOwnerWithDelegation { +interface IDelegation { struct InitializationParams { uint256 managementFee; uint256 performanceFee; @@ -37,59 +37,56 @@ interface IStVaultOwnerWithDelegation { } contract VaultFactory is UpgradeableBeacon { - address public immutable stVaultOwnerWithDelegationImpl; + address public immutable delegationImpl; /// @param _owner The address of the VaultFactory owner /// @param _stakingVaultImpl The address of the StakingVault implementation - /// @param _stVaultOwnerWithDelegationImpl The address of the StVaultOwnerWithDelegation implementation + /// @param _delegationImpl The address of the Delegation implementation constructor( address _owner, address _stakingVaultImpl, - address _stVaultOwnerWithDelegationImpl + address _delegationImpl ) UpgradeableBeacon(_stakingVaultImpl, _owner) { - if (_stVaultOwnerWithDelegationImpl == address(0)) revert ZeroArgument("_stVaultOwnerWithDelegation"); + if (_delegationImpl == address(0)) revert ZeroArgument("_delegation"); - stVaultOwnerWithDelegationImpl = _stVaultOwnerWithDelegationImpl; + delegationImpl = _delegationImpl; } - /// @notice Creates a new StakingVault and StVaultOwnerWithDelegation contracts + /// @notice Creates a new StakingVault and Delegation contracts /// @param _stakingVaultParams The params of vault initialization /// @param _initializationParams The params of vault initialization function createVault( bytes calldata _stakingVaultParams, - IStVaultOwnerWithDelegation.InitializationParams calldata _initializationParams, + IDelegation.InitializationParams calldata _initializationParams, address _lidoAgent - ) external returns (IStakingVault vault, IStVaultOwnerWithDelegation stVaultOwnerWithDelegation) { + ) external returns (IStakingVault vault, IDelegation delegation) { if (_initializationParams.manager == address(0)) revert ZeroArgument("manager"); if (_initializationParams.operator == address(0)) revert ZeroArgument("operator"); vault = IStakingVault(address(new BeaconProxy(address(this), ""))); - stVaultOwnerWithDelegation = IStVaultOwnerWithDelegation(Clones.clone(stVaultOwnerWithDelegationImpl)); + delegation = IDelegation(Clones.clone(delegationImpl)); - stVaultOwnerWithDelegation.initialize(address(this), address(vault)); + delegation.initialize(address(this), address(vault)); - stVaultOwnerWithDelegation.grantRole(stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), _lidoAgent); - stVaultOwnerWithDelegation.grantRole(stVaultOwnerWithDelegation.MANAGER_ROLE(), _initializationParams.manager); - stVaultOwnerWithDelegation.grantRole( - stVaultOwnerWithDelegation.OPERATOR_ROLE(), - _initializationParams.operator - ); - stVaultOwnerWithDelegation.grantRole(stVaultOwnerWithDelegation.DEFAULT_ADMIN_ROLE(), msg.sender); + delegation.grantRole(delegation.LIDO_DAO_ROLE(), _lidoAgent); + delegation.grantRole(delegation.MANAGER_ROLE(), _initializationParams.manager); + delegation.grantRole(delegation.OPERATOR_ROLE(), _initializationParams.operator); + delegation.grantRole(delegation.DEFAULT_ADMIN_ROLE(), msg.sender); - stVaultOwnerWithDelegation.grantRole(stVaultOwnerWithDelegation.MANAGER_ROLE(), address(this)); - stVaultOwnerWithDelegation.setManagementFee(_initializationParams.managementFee); - stVaultOwnerWithDelegation.setPerformanceFee(_initializationParams.performanceFee); + delegation.grantRole(delegation.MANAGER_ROLE(), address(this)); + delegation.setManagementFee(_initializationParams.managementFee); + delegation.setPerformanceFee(_initializationParams.performanceFee); //revoke roles from factory - stVaultOwnerWithDelegation.revokeRole(stVaultOwnerWithDelegation.MANAGER_ROLE(), address(this)); - stVaultOwnerWithDelegation.revokeRole(stVaultOwnerWithDelegation.DEFAULT_ADMIN_ROLE(), address(this)); - stVaultOwnerWithDelegation.revokeRole(stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), address(this)); + delegation.revokeRole(delegation.MANAGER_ROLE(), address(this)); + delegation.revokeRole(delegation.DEFAULT_ADMIN_ROLE(), address(this)); + delegation.revokeRole(delegation.LIDO_DAO_ROLE(), address(this)); - vault.initialize(address(stVaultOwnerWithDelegation), _stakingVaultParams); + vault.initialize(address(delegation), _stakingVaultParams); - emit VaultCreated(address(stVaultOwnerWithDelegation), address(vault)); - emit StVaultOwnerWithDelegationCreated(msg.sender, address(stVaultOwnerWithDelegation)); + emit VaultCreated(address(delegation), address(vault)); + emit DelegationCreated(msg.sender, address(delegation)); } /** @@ -100,11 +97,11 @@ contract VaultFactory is UpgradeableBeacon { event VaultCreated(address indexed owner, address indexed vault); /** - * @notice Event emitted on a StVaultOwnerWithDelegation creation - * @param admin The address of the StVaultOwnerWithDelegation admin - * @param stVaultOwnerWithDelegation The address of the created StVaultOwnerWithDelegation + * @notice Event emitted on a Delegation creation + * @param admin The address of the Delegation admin + * @param delegation The address of the created Delegation */ - event StVaultOwnerWithDelegationCreated(address indexed admin, address indexed stVaultOwnerWithDelegation); + event DelegationCreated(address indexed admin, address indexed delegation); error ZeroArgument(string); } diff --git a/lib/proxy.ts b/lib/proxy.ts index 60dd65110..ec9d9b31b 100644 --- a/lib/proxy.ts +++ b/lib/proxy.ts @@ -8,14 +8,14 @@ import { OssifiableProxy, OssifiableProxy__factory, StakingVault, - StVaultOwnerWithDelegation, + Delegation, VaultFactory, } from "typechain-types"; import { findEventsWithInterfaces } from "lib"; -import { IStVaultOwnerWithDelegation } from "../typechain-types/contracts/0.8.25/vaults/VaultFactory.sol/VaultFactory"; -import StVaultOwnerWithDelegationInitializationParamsStruct = IStVaultOwnerWithDelegation.InitializationParamsStruct; +import { IDelegation } from "../typechain-types/contracts/0.8.25/vaults/VaultFactory.sol/VaultFactory"; +import DelegationInitializationParamsStruct = IDelegation.InitializationParamsStruct; interface ProxifyArgs { impl: T; @@ -44,7 +44,7 @@ interface CreateVaultResponse { tx: ContractTransactionResponse; proxy: BeaconProxy; vault: StakingVault; - stVaultOwnerWithDelegation: StVaultOwnerWithDelegation; + delegation: Delegation; } export async function createVaultProxy( @@ -53,7 +53,7 @@ export async function createVaultProxy( _lidoAgent: HardhatEthersSigner, ): Promise { // Define the parameters for the struct - const initializationParams: StVaultOwnerWithDelegationInitializationParamsStruct = { + const initializationParams: DelegationInitializationParamsStruct = { managementFee: 100n, performanceFee: 200n, manager: await _owner.getAddress(), @@ -71,28 +71,28 @@ export async function createVaultProxy( const event = events[0]; const { vault } = event.args; - const stVaultOwnerWithDelegationEvents = findEventsWithInterfaces( + const delegationEvents = findEventsWithInterfaces( receipt, - "StVaultOwnerWithDelegationCreated", + "DelegationCreated", [vaultFactory.interface], ); - if (stVaultOwnerWithDelegationEvents.length === 0) throw new Error("StVaultOwnerWithDelegation creation event not found"); + if (delegationEvents.length === 0) throw new Error("Delegation creation event not found"); - const { stVaultOwnerWithDelegation: stVaultOwnerWithDelegationAddress } = stVaultOwnerWithDelegationEvents[0].args; + const { delegation: delegationAddress } = delegationEvents[0].args; const proxy = (await ethers.getContractAt("BeaconProxy", vault, _owner)) as BeaconProxy; const stakingVault = (await ethers.getContractAt("StakingVault", vault, _owner)) as StakingVault; - const stVaultOwnerWithDelegation = (await ethers.getContractAt( - "StVaultOwnerWithDelegation", - stVaultOwnerWithDelegationAddress, + const delegation = (await ethers.getContractAt( + "Delegation", + delegationAddress, _owner, - )) as StVaultOwnerWithDelegation; + )) as Delegation; return { tx, proxy, vault: stakingVault, - stVaultOwnerWithDelegation, + delegation, }; } diff --git a/lib/state-file.ts b/lib/state-file.ts index e791a09a8..2618ce3d7 100644 --- a/lib/state-file.ts +++ b/lib/state-file.ts @@ -90,7 +90,7 @@ export enum Sk { // Vaults stakingVaultImpl = "stakingVaultImpl", stakingVaultFactory = "stakingVaultFactory", - stVaultOwnerWithDelegationImpl = "stVaultOwnerWithDelegationImpl", + delegationImpl = "delegationImpl", } export function getAddress(contractKey: Sk, state: DeploymentState): string { diff --git a/scripts/scratch/steps/0145-deploy-vaults.ts b/scripts/scratch/steps/0145-deploy-vaults.ts index 645c03f60..0c377065f 100644 --- a/scripts/scratch/steps/0145-deploy-vaults.ts +++ b/scripts/scratch/steps/0145-deploy-vaults.ts @@ -23,8 +23,8 @@ export async function main() { ]); const impAddress = await imp.getAddress(); - // Deploy StVaultOwnerWithDelegation implementation contract - const room = await deployWithoutProxy(Sk.stVaultOwnerWithDelegationImpl, "StVaultOwnerWithDelegation", deployer, [lidoAddress]); + // Deploy Delegation implementation contract + const room = await deployWithoutProxy(Sk.delegationImpl, "Delegation", deployer, [lidoAddress]); const roomAddress = await room.getAddress(); // Deploy VaultFactory contract diff --git a/test/0.8.25/vaults/st-vault-owner-with-delegation-voting.test.ts b/test/0.8.25/vaults/st-vault-owner-with-delegation-voting.test.ts index 85130c896..8e3495b64 100644 --- a/test/0.8.25/vaults/st-vault-owner-with-delegation-voting.test.ts +++ b/test/0.8.25/vaults/st-vault-owner-with-delegation-voting.test.ts @@ -3,9 +3,9 @@ import { expect } from "chai"; import { ethers } from "hardhat"; import { advanceChainTime, certainAddress, days, proxify } from "lib"; import { Snapshot } from "test/suite"; -import { StakingVault__MockForVaultDelegationLayer, StVaultOwnerWithDelegation } from "typechain-types"; +import { StakingVault__MockForVaultDelegationLayer, Delegation } from "typechain-types"; -describe("StVaultOwnerWithDelegation:Voting", () => { +describe("Delegation:Voting", () => { let deployer: HardhatEthersSigner; let owner: HardhatEthersSigner; let manager: HardhatEthersSigner; @@ -14,7 +14,7 @@ describe("StVaultOwnerWithDelegation:Voting", () => { let stranger: HardhatEthersSigner; let stakingVault: StakingVault__MockForVaultDelegationLayer; - let stVaultOwnerWithDelegation: StVaultOwnerWithDelegation; + let delegation: Delegation; let originalState: string; @@ -23,18 +23,18 @@ describe("StVaultOwnerWithDelegation:Voting", () => { const steth = certainAddress("vault-delegation-layer-voting-steth"); stakingVault = await ethers.deployContract("StakingVault__MockForVaultDelegationLayer"); - const impl = await ethers.deployContract("StVaultOwnerWithDelegation", [steth]); + const impl = await ethers.deployContract("Delegation", [steth]); // use a regular proxy for now - [stVaultOwnerWithDelegation] = await proxify({ impl, admin: owner, caller: deployer }); + [delegation] = await proxify({ impl, admin: owner, caller: deployer }); - await stVaultOwnerWithDelegation.initialize(owner, stakingVault); - expect(await stVaultOwnerWithDelegation.isInitialized()).to.be.true; - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.DEFAULT_ADMIN_ROLE(), owner)).to.be.true; - expect(await stVaultOwnerWithDelegation.vaultHub()).to.equal(await stakingVault.vaultHub()); + await delegation.initialize(owner, stakingVault); + expect(await delegation.isInitialized()).to.be.true; + expect(await delegation.hasRole(await delegation.DEFAULT_ADMIN_ROLE(), owner)).to.be.true; + expect(await delegation.vaultHub()).to.equal(await stakingVault.vaultHub()); - await stakingVault.initialize(await stVaultOwnerWithDelegation.getAddress()); + await stakingVault.initialize(await delegation.getAddress()); - stVaultOwnerWithDelegation = stVaultOwnerWithDelegation.connect(owner); + delegation = delegation.connect(owner); }); beforeEach(async () => { @@ -47,135 +47,135 @@ describe("StVaultOwnerWithDelegation:Voting", () => { describe("setPerformanceFee", () => { it("reverts if the caller does not have the required role", async () => { - expect(stVaultOwnerWithDelegation.connect(stranger).setPerformanceFee(100)).to.be.revertedWithCustomError( - stVaultOwnerWithDelegation, + expect(delegation.connect(stranger).setPerformanceFee(100)).to.be.revertedWithCustomError( + delegation, "NotACommitteeMember", ); }); it("executes if called by all distinct committee members", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator); + await delegation.grantRole(await delegation.MANAGER_ROLE(), manager); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), operator); - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager)).to.be.true; - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator)).to.be.true; + expect(await delegation.hasRole(await delegation.MANAGER_ROLE(), manager)).to.be.true; + expect(await delegation.hasRole(await delegation.OPERATOR_ROLE(), operator)).to.be.true; - const previousFee = await stVaultOwnerWithDelegation.performanceFee(); + const previousFee = await delegation.performanceFee(); const newFee = previousFee + 1n; // remains unchanged - await stVaultOwnerWithDelegation.connect(manager).setPerformanceFee(newFee); - expect(await stVaultOwnerWithDelegation.performanceFee()).to.equal(previousFee); + await delegation.connect(manager).setPerformanceFee(newFee); + expect(await delegation.performanceFee()).to.equal(previousFee); // updated - await stVaultOwnerWithDelegation.connect(operator).setPerformanceFee(newFee); - expect(await stVaultOwnerWithDelegation.performanceFee()).to.equal(newFee); + await delegation.connect(operator).setPerformanceFee(newFee); + expect(await delegation.performanceFee()).to.equal(newFee); }); it("executes if called by a single member with all roles", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), manager); + await delegation.grantRole(await delegation.MANAGER_ROLE(), manager); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), manager); - const previousFee = await stVaultOwnerWithDelegation.performanceFee(); + const previousFee = await delegation.performanceFee(); const newFee = previousFee + 1n; // updated with a single transaction - await stVaultOwnerWithDelegation.connect(manager).setPerformanceFee(newFee); - expect(await stVaultOwnerWithDelegation.performanceFee()).to.equal(newFee); + await delegation.connect(manager).setPerformanceFee(newFee); + expect(await delegation.performanceFee()).to.equal(newFee); }) it("does not execute if the vote is expired", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator); + await delegation.grantRole(await delegation.MANAGER_ROLE(), manager); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), operator); - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager)).to.be.true; - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator)).to.be.true; + expect(await delegation.hasRole(await delegation.MANAGER_ROLE(), manager)).to.be.true; + expect(await delegation.hasRole(await delegation.OPERATOR_ROLE(), operator)).to.be.true; - const previousFee = await stVaultOwnerWithDelegation.performanceFee(); + const previousFee = await delegation.performanceFee(); const newFee = previousFee + 1n; // remains unchanged - await stVaultOwnerWithDelegation.connect(manager).setPerformanceFee(newFee); - expect(await stVaultOwnerWithDelegation.performanceFee()).to.equal(previousFee); + await delegation.connect(manager).setPerformanceFee(newFee); + expect(await delegation.performanceFee()).to.equal(previousFee); await advanceChainTime(days(7n) + 1n); // remains unchanged - await stVaultOwnerWithDelegation.connect(operator).setPerformanceFee(newFee); - expect(await stVaultOwnerWithDelegation.performanceFee()).to.equal(previousFee); + await delegation.connect(operator).setPerformanceFee(newFee); + expect(await delegation.performanceFee()).to.equal(previousFee); }); }); describe("transferStakingVaultOwnership", () => { it("reverts if the caller does not have the required role", async () => { - expect(stVaultOwnerWithDelegation.connect(stranger).transferStVaultOwnership(certainAddress("vault-delegation-layer-voting-new-owner"))).to.be.revertedWithCustomError( - stVaultOwnerWithDelegation, + expect(delegation.connect(stranger).transferStVaultOwnership(certainAddress("vault-delegation-layer-voting-new-owner"))).to.be.revertedWithCustomError( + delegation, "NotACommitteeMember", ); }); it("executes if called by all distinct committee members", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator); + await delegation.grantRole(await delegation.MANAGER_ROLE(), manager); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), operator); - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager)).to.be.true; - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator)).to.be.true; + expect(await delegation.hasRole(await delegation.MANAGER_ROLE(), manager)).to.be.true; + expect(await delegation.hasRole(await delegation.OPERATOR_ROLE(), operator)).to.be.true; const newOwner = certainAddress("vault-delegation-layer-voting-new-owner"); // remains unchanged - await stVaultOwnerWithDelegation.connect(manager).transferStVaultOwnership(newOwner); - expect(await stakingVault.owner()).to.equal(stVaultOwnerWithDelegation); + await delegation.connect(manager).transferStVaultOwnership(newOwner); + expect(await stakingVault.owner()).to.equal(delegation); // remains unchanged - await stVaultOwnerWithDelegation.connect(operator).transferStVaultOwnership(newOwner); - expect(await stakingVault.owner()).to.equal(stVaultOwnerWithDelegation); + await delegation.connect(operator).transferStVaultOwnership(newOwner); + expect(await stakingVault.owner()).to.equal(delegation); // updated - await stVaultOwnerWithDelegation.connect(lidoDao).transferStVaultOwnership(newOwner); + await delegation.connect(lidoDao).transferStVaultOwnership(newOwner); expect(await stakingVault.owner()).to.equal(newOwner); }); it("executes if called by a single member with all roles", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), lidoDao); + await delegation.grantRole(await delegation.MANAGER_ROLE(), lidoDao); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), lidoDao); const newOwner = certainAddress("vault-delegation-layer-voting-new-owner"); // updated with a single transaction - await stVaultOwnerWithDelegation.connect(lidoDao).transferStVaultOwnership(newOwner); + await delegation.connect(lidoDao).transferStVaultOwnership(newOwner); expect(await stakingVault.owner()).to.equal(newOwner); }) it("does not execute if the vote is expired", async () => { - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager); - await stVaultOwnerWithDelegation.grantRole(await stVaultOwnerWithDelegation.LIDO_DAO_ROLE(), lidoDao); - await stVaultOwnerWithDelegation.connect(lidoDao).grantRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator); + await delegation.grantRole(await delegation.MANAGER_ROLE(), manager); + await delegation.grantRole(await delegation.LIDO_DAO_ROLE(), lidoDao); + await delegation.connect(lidoDao).grantRole(await delegation.OPERATOR_ROLE(), operator); - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.MANAGER_ROLE(), manager)).to.be.true; - expect(await stVaultOwnerWithDelegation.hasRole(await stVaultOwnerWithDelegation.OPERATOR_ROLE(), operator)).to.be.true; + expect(await delegation.hasRole(await delegation.MANAGER_ROLE(), manager)).to.be.true; + expect(await delegation.hasRole(await delegation.OPERATOR_ROLE(), operator)).to.be.true; const newOwner = certainAddress("vault-delegation-layer-voting-new-owner"); // remains unchanged - await stVaultOwnerWithDelegation.connect(manager).transferStVaultOwnership(newOwner); - expect(await stakingVault.owner()).to.equal(stVaultOwnerWithDelegation); + await delegation.connect(manager).transferStVaultOwnership(newOwner); + expect(await stakingVault.owner()).to.equal(delegation); // remains unchanged - await stVaultOwnerWithDelegation.connect(operator).transferStVaultOwnership(newOwner); - expect(await stakingVault.owner()).to.equal(stVaultOwnerWithDelegation); + await delegation.connect(operator).transferStVaultOwnership(newOwner); + expect(await stakingVault.owner()).to.equal(delegation); await advanceChainTime(days(7n) + 1n); // remains unchanged - await stVaultOwnerWithDelegation.connect(lidoDao).transferStVaultOwnership(newOwner); - expect(await stakingVault.owner()).to.equal(stVaultOwnerWithDelegation); + await delegation.connect(lidoDao).transferStVaultOwnership(newOwner); + expect(await stakingVault.owner()).to.equal(delegation); }); }); }); diff --git a/test/0.8.25/vaults/stvault-owner-with-delegation.test.ts b/test/0.8.25/vaults/stvault-owner-with-delegation.test.ts index fda887f3d..ce3953e43 100644 --- a/test/0.8.25/vaults/stvault-owner-with-delegation.test.ts +++ b/test/0.8.25/vaults/stvault-owner-with-delegation.test.ts @@ -8,7 +8,7 @@ import { LidoLocator, StakingVault, StETH__HarnessForVaultHub, - StVaultOwnerWithDelegation, + Delegation, VaultFactory, VaultHub, } from "typechain-types"; @@ -18,7 +18,7 @@ import { certainAddress, createVaultProxy, ether } from "lib"; import { deployLidoLocator } from "test/deploy"; import { Snapshot } from "test/suite"; -describe("StVaultOwnerWithDelegation.sol", () => { +describe("Delegation.sol", () => { let deployer: HardhatEthersSigner; let admin: HardhatEthersSigner; let holder: HardhatEthersSigner; @@ -29,7 +29,7 @@ describe("StVaultOwnerWithDelegation.sol", () => { let depositContract: DepositContract__MockForBeaconChainDepositor; let vaultHub: VaultHub; let implOld: StakingVault; - let stVaultOwnerWithDelegation: StVaultOwnerWithDelegation; + let delegation: Delegation; let vaultFactory: VaultFactory; let steth: StETH__HarnessForVaultHub; @@ -53,8 +53,8 @@ describe("StVaultOwnerWithDelegation.sol", () => { // VaultHub vaultHub = await ethers.deployContract("Accounting", [admin, locator, steth, treasury], { from: deployer }); implOld = await ethers.deployContract("StakingVault", [vaultHub, depositContract], { from: deployer }); - stVaultOwnerWithDelegation = await ethers.deployContract("StVaultOwnerWithDelegation", [steth], { from: deployer }); - vaultFactory = await ethers.deployContract("VaultFactory", [admin, implOld, stVaultOwnerWithDelegation], { from: deployer }); + delegation = await ethers.deployContract("Delegation", [steth], { from: deployer }); + vaultFactory = await ethers.deployContract("VaultFactory", [admin, implOld, delegation], { from: deployer }); //add role to factory await vaultHub.connect(admin).grantRole(await vaultHub.VAULT_MASTER_ROLE(), admin); @@ -69,33 +69,33 @@ describe("StVaultOwnerWithDelegation.sol", () => { context("performanceDue", () => { it("performanceDue ", async () => { - const { stVaultOwnerWithDelegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); + const { delegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); - await stVaultOwnerWithDelegation.performanceDue(); + await delegation.performanceDue(); }); }); context("initialize", async () => { it("reverts if initialize from implementation", async () => { - await expect(stVaultOwnerWithDelegation.initialize(admin, implOld)).to.revertedWithCustomError( - stVaultOwnerWithDelegation, + await expect(delegation.initialize(admin, implOld)).to.revertedWithCustomError( + delegation, "NonProxyCallsForbidden", ); }); it("reverts if already initialized", async () => { - const { vault: vault1, stVaultOwnerWithDelegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); + const { vault: vault1, delegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); - await expect(stVaultOwnerWithDelegation.initialize(admin, vault1)).to.revertedWithCustomError( - stVaultOwnerWithDelegation, + await expect(delegation.initialize(admin, vault1)).to.revertedWithCustomError( + delegation, "AlreadyInitialized", ); }); it("initialize", async () => { - const { tx, stVaultOwnerWithDelegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); + const { tx, delegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); - await expect(tx).to.emit(stVaultOwnerWithDelegation, "Initialized"); + await expect(tx).to.emit(delegation, "Initialized"); }); }); }); diff --git a/test/0.8.25/vaults/vault.test.ts b/test/0.8.25/vaults/vault.test.ts index 510d9087a..608f9209a 100644 --- a/test/0.8.25/vaults/vault.test.ts +++ b/test/0.8.25/vaults/vault.test.ts @@ -9,7 +9,7 @@ import { StakingVault, StakingVault__factory, StETH__HarnessForVaultHub, - StVaultOwnerWithDelegation, + Delegation, VaultFactory, VaultHub__MockForVault, } from "typechain-types"; @@ -33,7 +33,7 @@ describe("StakingVault.sol", async () => { let stakingVault: StakingVault; let steth: StETH__HarnessForVaultHub; let vaultFactory: VaultFactory; - let stVaulOwnerWithDelegation: StVaultOwnerWithDelegation; + let stVaulOwnerWithDelegation: Delegation; let vaultProxy: StakingVault; let originalState: string; @@ -52,16 +52,16 @@ describe("StakingVault.sol", async () => { vaultCreateFactory = new StakingVault__factory(owner); stakingVault = await ethers.getContractFactory("StakingVault").then((f) => f.deploy(vaultHub, depositContract)); - stVaulOwnerWithDelegation = await ethers.deployContract("StVaultOwnerWithDelegation", [steth], { from: deployer }); + stVaulOwnerWithDelegation = await ethers.deployContract("Delegation", [steth], { from: deployer }); vaultFactory = await ethers.deployContract("VaultFactory", [deployer, stakingVault, stVaulOwnerWithDelegation], { from: deployer, }); - const { vault, stVaultOwnerWithDelegation } = await createVaultProxy(vaultFactory, owner, lidoAgent); + const { vault, delegation } = await createVaultProxy(vaultFactory, owner, lidoAgent); vaultProxy = vault; - delegatorSigner = await impersonate(await stVaultOwnerWithDelegation.getAddress(), ether("100.0")); + delegatorSigner = await impersonate(await delegation.getAddress(), ether("100.0")); }); beforeEach(async () => (originalState = await Snapshot.take())); diff --git a/test/0.8.25/vaults/vaultFactory.test.ts b/test/0.8.25/vaults/vaultFactory.test.ts index 64161862d..9bff2d3c2 100644 --- a/test/0.8.25/vaults/vaultFactory.test.ts +++ b/test/0.8.25/vaults/vaultFactory.test.ts @@ -12,7 +12,7 @@ import { StETH__HarnessForVaultHub, VaultFactory, VaultHub, - StVaultOwnerWithDelegation, + Delegation, } from "typechain-types"; import { certainAddress, createVaultProxy, ether } from "lib"; @@ -33,7 +33,7 @@ describe("VaultFactory.sol", () => { let vaultHub: VaultHub; let implOld: StakingVault; let implNew: StakingVault__HarnessForTestUpgrade; - let stVaultOwnerWithDelegation: StVaultOwnerWithDelegation; + let delegation: Delegation; let vaultFactory: VaultFactory; let steth: StETH__HarnessForVaultHub; @@ -60,8 +60,8 @@ describe("VaultFactory.sol", () => { implNew = await ethers.deployContract("StakingVault__HarnessForTestUpgrade", [vaultHub, depositContract], { from: deployer, }); - stVaultOwnerWithDelegation = await ethers.deployContract("StVaultOwnerWithDelegation", [steth], { from: deployer }); - vaultFactory = await ethers.deployContract("VaultFactory", [admin, implOld, stVaultOwnerWithDelegation], { from: deployer }); + delegation = await ethers.deployContract("Delegation", [steth], { from: deployer }); + vaultFactory = await ethers.deployContract("VaultFactory", [admin, implOld, delegation], { from: deployer }); //add role to factory await vaultHub.connect(admin).grantRole(await vaultHub.VAULT_MASTER_ROLE(), admin); @@ -87,10 +87,10 @@ describe("VaultFactory.sol", () => { .withArgs(ZeroAddress); }); - it("reverts if `_stVaultOwnerWithDelegation` is zero address", async () => { + it("reverts if `_delegation` is zero address", async () => { await expect(ethers.deployContract("VaultFactory", [admin, implOld, ZeroAddress], { from: deployer })) .to.be.revertedWithCustomError(vaultFactory, "ZeroArgument") - .withArgs("_stVaultOwnerWithDelegation"); + .withArgs("_delegation"); }); it("works and emit `OwnershipTransferred`, `Upgraded` events", async () => { @@ -113,17 +113,17 @@ describe("VaultFactory.sol", () => { context("createVault", () => { it("works with empty `params`", async () => { - const { tx, vault, stVaultOwnerWithDelegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); + const { tx, vault, delegation } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); await expect(tx) .to.emit(vaultFactory, "VaultCreated") - .withArgs(await stVaultOwnerWithDelegation.getAddress(), await vault.getAddress()); + .withArgs(await delegation.getAddress(), await vault.getAddress()); await expect(tx) - .to.emit(vaultFactory, "StVaultOwnerWithDelegationCreated") - .withArgs(await vaultOwner1.getAddress(), await stVaultOwnerWithDelegation.getAddress()); + .to.emit(vaultFactory, "DelegationCreated") + .withArgs(await vaultOwner1.getAddress(), await delegation.getAddress()); - expect(await stVaultOwnerWithDelegation.getAddress()).to.eq(await vault.owner()); + expect(await delegation.getAddress()).to.eq(await vault.owner()); expect(await vault.getBeacon()).to.eq(await vaultFactory.getAddress()); }); @@ -149,8 +149,8 @@ describe("VaultFactory.sol", () => { }; //create vault - const { vault: vault1, stVaultOwnerWithDelegation: delegator1 } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); - const { vault: vault2, stVaultOwnerWithDelegation: delegator2 } = await createVaultProxy(vaultFactory, vaultOwner2, lidoAgent); + const { vault: vault1, delegation: delegator1 } = await createVaultProxy(vaultFactory, vaultOwner1, lidoAgent); + const { vault: vault2, delegation: delegator2 } = await createVaultProxy(vaultFactory, vaultOwner2, lidoAgent); //owner of vault is delegator expect(await delegator1.getAddress()).to.eq(await vault1.owner()); diff --git a/test/integration/vaults-happy-path.integration.ts b/test/integration/vaults-happy-path.integration.ts index 391e2bf0f..93994e34c 100644 --- a/test/integration/vaults-happy-path.integration.ts +++ b/test/integration/vaults-happy-path.integration.ts @@ -4,7 +4,7 @@ import { ethers } from "hardhat"; import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; -import { StakingVault, StVaultOwnerWithDelegation } from "typechain-types"; +import { StakingVault, Delegation } from "typechain-types"; import { impersonate, log, trace, updateBalance } from "lib"; import { getProtocolContext, ProtocolContext } from "lib/protocol"; @@ -55,7 +55,7 @@ describe("Scenario: Staking Vaults Happy Path", () => { let vault101: StakingVault; let vault101Address: string; - let vault101AdminContract: StVaultOwnerWithDelegation; + let vault101AdminContract: Delegation; let vault101BeaconBalance = 0n; let vault101MintingMaximum = 0n; @@ -139,10 +139,10 @@ describe("Scenario: Staking Vaults Happy Path", () => { const { stakingVaultFactory } = ctx.contracts; const implAddress = await stakingVaultFactory.implementation(); - const adminContractImplAddress = await stakingVaultFactory.stVaultOwnerWithDelegationImpl(); + const adminContractImplAddress = await stakingVaultFactory.delegationImpl(); const vaultImpl = await ethers.getContractAt("StakingVault", implAddress); - const vaultFactoryAdminContract = await ethers.getContractAt("StVaultOwnerWithDelegation", adminContractImplAddress); + const vaultFactoryAdminContract = await ethers.getContractAt("Delegation", adminContractImplAddress); expect(await vaultImpl.VAULT_HUB()).to.equal(ctx.contracts.accounting.address); expect(await vaultImpl.DEPOSIT_CONTRACT()).to.equal(depositContract); @@ -168,7 +168,7 @@ describe("Scenario: Staking Vaults Happy Path", () => { expect(createVaultEvents.length).to.equal(1n); vault101 = await ethers.getContractAt("StakingVault", createVaultEvents[0].args?.vault); - vault101AdminContract = await ethers.getContractAt("StVaultOwnerWithDelegation", createVaultEvents[0].args?.owner); + vault101AdminContract = await ethers.getContractAt("Delegation", createVaultEvents[0].args?.owner); expect(await vault101AdminContract.hasRole(await vault101AdminContract.DEFAULT_ADMIN_ROLE(), alice)).to.be.true; expect(await vault101AdminContract.hasRole(await vault101AdminContract.MANAGER_ROLE(), alice)).to.be.true;