Skip to content

Commit

Permalink
feat: add whitelist init functionality to deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
1kresh committed Nov 6, 2024
1 parent 5061e30 commit 9aa6201
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
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
22 changes: 20 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,19 @@ 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

0 comments on commit 9aa6201

Please sign in to comment.