Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whitelist init functionality to deployment script #75

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions script/deploy/Vault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity 0.8.25;

import {Script, console2} from "forge-std/Script.sol";

import {Vault} from "../../src/contracts/vault/Vault.sol";

import {IMigratablesFactory} from "../../src/interfaces/common/IMigratablesFactory.sol";
import {IVault} from "../../src/interfaces/vault/IVault.sol";
import {IVaultConfigurator} from "../../src/interfaces/IVaultConfigurator.sol";
Expand All @@ -21,7 +23,7 @@ contract VaultScript is Script {
address collateral,
address burner,
uint48 epochDuration,
bool depositWhitelist,
address[] calldata whitelistedDepositors,
uint256 depositLimit,
uint64 delegatorIndex,
address hook,
Expand All @@ -30,6 +32,9 @@ contract VaultScript is Script {
uint48 vetoDuration
) public {
vm.startBroadcast();
(,, address deployer) = vm.readCallers();

bool depositWhitelist = whitelistedDepositors.length != 0;

bytes memory vaultParams = abi.encode(
IVault.InitParams({
Expand All @@ -39,7 +44,7 @@ contract VaultScript is Script {
depositWhitelist: depositWhitelist,
isDepositLimit: depositLimit != 0,
depositLimit: depositLimit,
defaultAdminRoleHolder: owner,
defaultAdminRoleHolder: depositWhitelist ? deployer : owner,
depositWhitelistSetRoleHolder: owner,
depositorWhitelistRoleHolder: owner,
isDepositLimitSetRoleHolder: owner,
Expand Down Expand Up @@ -130,6 +135,18 @@ contract VaultScript is Script {
})
);

if (depositWhitelist) {
Vault(vault_).grantRole(Vault(vault_).DEFAULT_ADMIN_ROLE(), owner);
Vault(vault_).grantRole(Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer);

for (uint256 i; i < whitelistedDepositors.length; ++i) {
Vault(vault_).setDepositorWhitelistStatus(whitelistedDepositors[i], true);
}

Vault(vault_).renounceRole(Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer);
Vault(vault_).renounceRole(Vault(vault_).DEFAULT_ADMIN_ROLE(), deployer);
}

console2.log("Vault: ", vault_);
console2.log("Delegator: ", delegator_);
console2.log("Slasher: ", slasher_);
Expand Down
21 changes: 19 additions & 2 deletions script/deploy/VaultTokenized.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity 0.8.25;

import {Script, console2} from "forge-std/Script.sol";

import {Vault} from "../../src/contracts/vault/Vault.sol";

import {IMigratablesFactory} from "../../src/interfaces/common/IMigratablesFactory.sol";
import {IVault} from "../../src/interfaces/vault/IVault.sol";
import {IVaultTokenized} from "../../src/interfaces/vault/IVaultTokenized.sol";
Expand All @@ -22,7 +24,7 @@ contract VaultTokenizedScript is Script {
address collateral,
address burner,
uint48 epochDuration,
bool depositWhitelist,
address[] calldata whitelistedDepositors,
uint256 depositLimit,
string calldata name,
string calldata symbol,
Expand All @@ -33,6 +35,9 @@ contract VaultTokenizedScript is Script {
uint48 vetoDuration
) public {
vm.startBroadcast();
(,, address deployer) = vm.readCallers();

bool depositWhitelist = whitelistedDepositors.length != 0;

bytes memory vaultParams = abi.encode(
IVaultTokenized.InitParamsTokenized({
Expand All @@ -43,7 +48,7 @@ contract VaultTokenizedScript is Script {
depositWhitelist: depositWhitelist,
isDepositLimit: depositLimit != 0,
depositLimit: depositLimit,
defaultAdminRoleHolder: owner,
defaultAdminRoleHolder: depositWhitelist ? deployer : owner,
depositWhitelistSetRoleHolder: owner,
depositorWhitelistRoleHolder: owner,
isDepositLimitSetRoleHolder: owner,
Expand Down Expand Up @@ -137,6 +142,18 @@ contract VaultTokenizedScript is Script {
})
);

if (depositWhitelist) {
Vault(vault_).grantRole(Vault(vault_).DEFAULT_ADMIN_ROLE(), owner);
Vault(vault_).grantRole(Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer);

for (uint256 i; i < whitelistedDepositors.length; ++i) {
Vault(vault_).setDepositorWhitelistStatus(whitelistedDepositors[i], true);
}

Vault(vault_).renounceRole(Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer);
Vault(vault_).renounceRole(Vault(vault_).DEFAULT_ADMIN_ROLE(), deployer);
}

console2.log("Vault: ", vault_);
console2.log("Delegator: ", delegator_);
console2.log("Slasher: ", slasher_);
Expand Down
Loading