Skip to content

Commit 7ee71b5

Browse files
committed
feat: better params usage
1 parent 87c7a10 commit 7ee71b5

File tree

4 files changed

+111
-45
lines changed

4 files changed

+111
-45
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,19 @@ verifier_disable:
289289
@echo "Disabling verifier with ID: $(VERIFIER_ID)"
290290
@. contracts/scripts/.env && . contracts/scripts/disable_verifier.sh $(VERIFIER_ID)
291291

292-
TODO finish:
293292
strategies_get_weight:
294-
@echo "Getting strategy weight"
295-
@. contracts/scripts/.env && . contracts/scripts/get_strategy_weight.sh
293+
@echo "Getting weight of strategy: $(STRATEGY_INDEX)"
294+
@. contracts/scripts/.env && . contracts/scripts/get_strategy_weight.sh $(STRATEGY_INDEX)
296295

297296
strategies_update_weight:
298-
@echo "Updating strategy weight: "
299-
@. contracts/scripts/.env && . contracts/scripts/update_strategy_weight.sh
297+
@echo "Updating strategy weights: "
298+
@echo "STRATEGY_INDICES: $(STRATEGY_INDICES)"
299+
@echo "NEW_MULTIPLIERS: $(NEW_MULTIPLIERS)"
300+
@. contracts/scripts/.env && . contracts/scripts/update_strategy_weight.sh $(STRATEGY_INDICES) $(NEW_MULTIPLIERS)
300301

301302
strategies_remove:
302-
@echo "Removing strategy with ID: $(STRATEGY_ID)"
303-
@. contracts/scripts/.env && ./contracts/scripts/remove_strategy.sh
303+
@echo "Removing strategies: $(INDICES_TO_REMOVE)"
304+
@. contracts/scripts/.env && ./contracts/scripts/remove_strategy.sh $(INDICES_TO_REMOVE)
304305

305306
__BATCHER__:
306307

contracts/scripts/get_strategy_weight.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#!/bin/bash
22

3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
# At this point we are in contracts/scripts
6+
cd "$parent_path"
7+
8+
# At this point we are in contracts
9+
cd ../
10+
11+
if [ "$#" -ne 1 ]; then
12+
echo "Error: 1 arguments is required, STRATEGY_INDEX"
13+
exit 1
14+
fi
15+
16+
STRATEGY_INDEX=$1
17+
318
if [ -z "$OUTPUT_PATH" ]; then
419
echo "OUTPUT_PATH env var is not set"
520
exit 1
@@ -27,11 +42,10 @@ STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
2742
#
2843

2944
QUORUM_NUMER=0x0 #Aligned has only 1 quorum for now
30-
INDEX=$1
3145

3246
echo $STAKE_REGISTRY
3347

34-
cast call $STAKE_REGISTRY "strategyParamsByIndex(uint8,uint256)((address,uint96))" $QUORUM_NUMER $INDEX #--rpc-url $RPC_URL
48+
cast call $STAKE_REGISTRY "strategyParamsByIndex(uint8,uint256)((address,uint96))" $QUORUM_NUMER $STRATEGY_INDEX --rpc-url $RPC_URL
3549

3650
# Expected output:
3751
# (strategy_address, multiplier)
Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
#!/bin/bash
22

3-
if [ -z "$OUTPUT_PATH" ]; then
4-
echo "OUTPUT_PATH env var is not set"
5-
exit 1
6-
fi
3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
# At this point we are in contracts/scripts
6+
cd "$parent_path"
77

8-
if [ -z "$RPC_URL" ]; then
9-
echo "RPC_URL env var is not set"
10-
exit 1
11-
fi
8+
# At this point we are in contracts
9+
cd ../
1210

13-
if [ -z "$PRIVATE_KEY" ]; then
14-
echo "PRIVATE_KEY env var is not set"
15-
exit 1
11+
if [ "$#" -ne 1 ]; then
12+
echo "Error: 1 arguments is required, INDICES_TO_REMOVE"
13+
exit 1
1614
fi
1715

18-
if [ -z "$INDICES_TO_REMOVE" ]; then
19-
echo "INDICES_TO_REMOVE env var is not set"
20-
exit 1
21-
fi
16+
INDICES_TO_REMOVE=$1
17+
2218
if [[ ! "$INDICES_TO_REMOVE" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then
2319
echo "The INDICES_TO_REMOVE doesn't match the required format: [0,1,...,n]"
2420
exit 1
2521
fi
2622

27-
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
23+
if [ -z "$MULTISIG" ]; then
24+
echo "MULTISIG env var is not set"
25+
exit 1
26+
fi
27+
if [ "$MULTISIG" = false ]; then
28+
if [ -z "$PRIVATE_KEY" ]; then
29+
echo "PRIVATE_KEY env var is not set"
30+
exit 1
31+
fi
32+
if [ -z "$RPC_URL" ]; then
33+
echo "RPC_URL env var is not set"
34+
exit 1
35+
fi
36+
if [ -z "$OUTPUT_PATH" ]; then
37+
echo "OUTPUT_PATH env var is not set"
38+
exit 1
39+
fi
40+
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
41+
fi
42+
2843

2944
## Using in this cast call:
3045

@@ -38,4 +53,15 @@ STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
3853

3954
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now
4055

41-
cast send $STAKE_REGISTRY "removeStrategies(uint8, uint256[])()" $QUORUM_NUMBER $INDICES_TO_REMOVE --private-key $PRIVATE_KEY --rpc-url $RPC_URL
56+
data=$(cast calldata "removeStrategies(uint8, uint256[])()" $QUORUM_NUMBER $INDICES_TO_REMOVE)
57+
58+
if [ "$MULTISIG" = false ]; then
59+
echo "Executing remove strategies transaction"
60+
61+
cast send $STAKE_REGISTRY $data \
62+
--rpc-url $RPC_URL \
63+
--private-key $PRIVATE_KEY
64+
else
65+
echo "You can propose the remove strategies transaction with the multisig using this calldata:"
66+
echo $data
67+
fi

contracts/scripts/update_strategy_weight.sh

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
#!/bin/bash
22

3-
if [ -z "$OUTPUT_PATH" ]; then
4-
echo "OUTPUT_PATH env var is not set"
5-
exit 1
6-
fi
3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
# At this point we are in contracts/scripts
6+
cd "$parent_path"
77

8-
if [ -z "$RPC_URL" ]; then
9-
echo "RPC_URL env var is not set"
10-
exit 1
11-
fi
8+
# At this point we are in contracts
9+
cd ../
1210

13-
if [ -z "$PRIVATE_KEY" ]; then
14-
echo "PRIVATE_KEY env var is not set"
15-
exit 1
11+
if [ "$#" -ne 2 ]; then
12+
echo "Error: 2 arguments are required, STRATEGY_INDICES and NEW_MULTIPLIERS"
13+
exit 1
1614
fi
1715

18-
if [ -z "$STRATEGY_INDICES" ]; then
19-
echo "STRATEGY_INDICES env var is not set"
20-
exit 1
21-
fi
16+
STRATEGY_INDICES=$1
17+
NEW_MULTIPLIERS=$2
18+
19+
2220
if [[ ! "$STRATEGY_INDICES" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then
2321
echo "The STRATEGY_INDICES doesn't match the required format: [0,1,...,n]"
2422
exit 1
@@ -49,7 +47,27 @@ if [[ $count1 -ne $count2 ]]; then
4947
exit 1
5048
fi
5149

52-
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
50+
51+
if [ -z "$MULTISIG" ]; then
52+
echo "MULTISIG env var is not set"
53+
exit 1
54+
fi
55+
if [ "$MULTISIG" = false ]; then
56+
if [ -z "$PRIVATE_KEY" ]; then
57+
echo "PRIVATE_KEY env var is not set"
58+
exit 1
59+
fi
60+
if [ -z "$RPC_URL" ]; then
61+
echo "RPC_URL env var is not set"
62+
exit 1
63+
fi
64+
if [ -z "$OUTPUT_PATH" ]; then
65+
echo "OUTPUT_PATH env var is not set"
66+
exit 1
67+
fi
68+
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
69+
fi
70+
5371

5472
## Using in this cast call:
5573

@@ -68,8 +86,15 @@ STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
6886

6987
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now
7088

71-
echo $QUORUM_NUMBER
89+
data=$(cast calldata "modifyStrategyParams(uint8, uint256[], uint96[])()" $QUORUM_NUMBER $STRATEGY_INDICES $NEW_MULTIPLIERS)
7290

73-
echo $STAKE_REGISTRY
91+
if [ "$MULTISIG" = false ]; then
92+
echo "Executing modify strategy params transaction"
7493

75-
cast send $STAKE_REGISTRY "modifyStrategyParams(uint8, uint256[], uint96[])()" $QUORUM_NUMBER $STRATEGY_INDICES $NEW_MULTIPLIERS --private-key $PRIVATE_KEY --rpc-url $RPC_URL
94+
cast send $STAKE_REGISTRY $data \
95+
--rpc-url $RPC_URL \
96+
--private-key $PRIVATE_KEY
97+
else
98+
echo "You can propose the modify strategy params transaction with the multisig using this calldata:"
99+
echo $data
100+
fi

0 commit comments

Comments
 (0)