Skip to content

Commit

Permalink
Merge pull request symbioticfi#74 from symbioticfi/improve-script
Browse files Browse the repository at this point in the history
Allow hook input to scripts
  • Loading branch information
1kresh authored Nov 5, 2024
2 parents 629b9fa + eebdecb commit 5061e30
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
22 changes: 16 additions & 6 deletions script/deploy/Vault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ contract VaultScript is Script {
bool depositWhitelist,
uint256 depositLimit,
uint64 delegatorIndex,
address hook,
bool withSlasher,
uint64 slasherIndex,
uint48 vetoDuration
Expand All @@ -46,20 +47,29 @@ contract VaultScript is Script {
})
);

address[] memory networkLimitSetRoleHolders = new address[](1);
uint256 roleHolders = 1;
if (hook != address(0) && hook != owner) {
roleHolders = 2;
}
address[] memory networkLimitSetRoleHolders = new address[](roleHolders);
address[] memory operatorNetworkLimitSetRoleHolders = new address[](roleHolders);
address[] memory operatorNetworkSharesSetRoleHolders = new address[](roleHolders);
networkLimitSetRoleHolders[0] = owner;
address[] memory operatorNetworkLimitSetRoleHolders = new address[](1);
operatorNetworkLimitSetRoleHolders[0] = owner;
address[] memory operatorNetworkSharesSetRoleHolders = new address[](1);
operatorNetworkSharesSetRoleHolders[0] = owner;
if (roleHolders > 1) {
networkLimitSetRoleHolders[1] = hook;
operatorNetworkLimitSetRoleHolders[1] = hook;
operatorNetworkSharesSetRoleHolders[1] = hook;
}

bytes memory delegatorParams;
if (delegatorIndex == 0) {
delegatorParams = abi.encode(
INetworkRestakeDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand All @@ -71,7 +81,7 @@ contract VaultScript is Script {
IFullRestakeDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand All @@ -83,7 +93,7 @@ contract VaultScript is Script {
IOperatorSpecificDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand Down
22 changes: 16 additions & 6 deletions script/deploy/VaultTokenized.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract VaultTokenizedScript is Script {
string calldata name,
string calldata symbol,
uint64 delegatorIndex,
address hook,
bool withSlasher,
uint64 slasherIndex,
uint48 vetoDuration
Expand All @@ -53,20 +54,29 @@ contract VaultTokenizedScript is Script {
})
);

address[] memory networkLimitSetRoleHolders = new address[](1);
uint256 roleHolders = 1;
if (hook != address(0) && hook != owner) {
roleHolders = 2;
}
address[] memory networkLimitSetRoleHolders = new address[](roleHolders);
address[] memory operatorNetworkLimitSetRoleHolders = new address[](roleHolders);
address[] memory operatorNetworkSharesSetRoleHolders = new address[](roleHolders);
networkLimitSetRoleHolders[0] = owner;
address[] memory operatorNetworkLimitSetRoleHolders = new address[](1);
operatorNetworkLimitSetRoleHolders[0] = owner;
address[] memory operatorNetworkSharesSetRoleHolders = new address[](1);
operatorNetworkSharesSetRoleHolders[0] = owner;
if (roleHolders > 1) {
networkLimitSetRoleHolders[1] = hook;
operatorNetworkLimitSetRoleHolders[1] = hook;
operatorNetworkSharesSetRoleHolders[1] = hook;
}

bytes memory delegatorParams;
if (delegatorIndex == 0) {
delegatorParams = abi.encode(
INetworkRestakeDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand All @@ -78,7 +88,7 @@ contract VaultTokenizedScript is Script {
IFullRestakeDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand All @@ -90,7 +100,7 @@ contract VaultTokenizedScript is Script {
IOperatorSpecificDelegator.InitParams({
baseParams: IBaseDelegator.BaseParams({
defaultAdminRoleHolder: owner,
hook: address(0),
hook: hook,
hookSetRoleHolder: owner
}),
networkLimitSetRoleHolders: networkLimitSetRoleHolders,
Expand Down
4 changes: 2 additions & 2 deletions specs/Vault.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ _Common Vault_
Deployment script: [click](../script/deploy/Vault.s.sol)

```shell
forge script script/deploy/Vault.s.sol:VaultScript 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 1 false 0 0 false 0 0 --sig "run(address,address,address,address,uint48,bool,uint256,uint64,bool,uint64,uint48)" --broadcast --rpc-url=$ETH_RPC_URL
forge script script/deploy/Vault.s.sol:VaultScript 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 1 false 0 0 0x0000000000000000000000000000000000000000 false 0 0 --sig "run(address,address,address,address,uint48,bool,uint256,uint64,address,bool,uint64,uint48)" --broadcast --rpc-url=$ETH_RPC_URL
```

_Tokenized Vault_

Deployment script: [click](../script/deploy/VaultTokenized.s.sol)

```shell
forge script script/deploy/VaultTokenized.s.sol:VaultTokenizedScript 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 1 false 0 Test TEST 0 false 0 0 --sig "run(address,address,address,address,uint48,bool,uint256,string,string,uint64,bool,uint64,uint48)" --broadcast --rpc-url=$ETH_RPC_URL
forge script script/deploy/VaultTokenized.s.sol:VaultTokenizedScript 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 0x0000000000000000000000000000000000000000 1 false 0 Test TEST 0 0x0000000000000000000000000000000000000000 false 0 0 --sig "run(address,address,address,address,uint48,bool,uint256,string,string,uint64,address,bool,uint64,uint48)" --broadcast --rpc-url=$ETH_RPC_URL
```

0 comments on commit 5061e30

Please sign in to comment.