Skip to content

Commit 4f63510

Browse files
uri-99PatStilesavilagaston9
authored
feat: make targets to modify strategies (#1530)
Co-authored-by: PatStiles <[email protected]> Co-authored-by: avilagaston9 <[email protected]>
1 parent 76e4267 commit 4f63510

15 files changed

+403
-0
lines changed

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,24 @@ verifier_disable:
290290
@echo "Disabling verifier with ID: $(VERIFIER_ID)"
291291
@. contracts/scripts/.env && . contracts/scripts/disable_verifier.sh $(VERIFIER_ID)
292292

293+
strategies_get_weight:
294+
@echo "Getting weight of strategy: $(STRATEGY_INDEX)"
295+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/get_strategy_weight.sh $(STRATEGY_INDEX)
296+
297+
strategies_update_weight:
298+
@echo "Updating strategy weights: "
299+
@echo "STRATEGY_INDICES: $(STRATEGY_INDICES)"
300+
@echo "NEW_MULTIPLIERS: $(NEW_MULTIPLIERS)"
301+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/update_strategy_weight.sh $(STRATEGY_INDICES) $(NEW_MULTIPLIERS)
302+
303+
strategies_remove:
304+
@echo "Removing strategies: $(INDICES_TO_REMOVE)"
305+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/remove_strategy.sh $(INDICES_TO_REMOVE)
306+
307+
strategies_get_addresses:
308+
@echo "Getting strategy addresses"
309+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/get_restakeable_strategies.sh
310+
293311
__BATCHER__:
294312

295313
BURST_SIZE ?= 5
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
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 [ -z "$OUTPUT_PATH" ]; then
12+
echo "OUTPUT_PATH env var is not set"
13+
exit 1
14+
fi
15+
16+
if [ -z "$RPC_URL" ]; then
17+
echo "RPC_URL env var is not set"
18+
exit 1
19+
fi
20+
21+
ALIGNED_SERVICE_MANAGER=$(jq -r '.addresses.alignedLayerServiceManager' "$OUTPUT_PATH")
22+
23+
## Using in this cast call:
24+
25+
# /**
26+
# * @notice Returns the list of strategies that the AVS supports for restaking
27+
# * @dev This function is intended to be called off-chain
28+
# * @dev No guarantee is made on uniqueness of each element in the returned array.
29+
# * The off-chain service should do that validation separately
30+
# */
31+
# function getRestakeableStrategies() external view returns (address[] memory) {
32+
33+
cast call $ALIGNED_SERVICE_MANAGER "getRestakeableStrategies()(address[])" --rpc-url $RPC_URL
34+
35+
# Expected output:
36+
# [addresses]
37+
# example:
38+
# [0xc5a5C42992dECbae36851359345FE25997F5C42d, 0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
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+
18+
if [ -z "$OUTPUT_PATH" ]; then
19+
echo "OUTPUT_PATH env var is not set"
20+
exit 1
21+
fi
22+
23+
if [ -z "$RPC_URL" ]; then
24+
echo "RPC_URL env var is not set"
25+
exit 1
26+
fi
27+
28+
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH")
29+
30+
## Using in this cast call:
31+
32+
# struct StrategyParams {
33+
# IStrategy strategy; (iface -> address)
34+
# uint96 multiplier;
35+
# }
36+
37+
# /// @notice Returns the strategy and weight multiplier for the `index`'th strategy in the quorum `quorumNumber`
38+
# function strategyParamsByIndex(
39+
# uint8 quorumNumber,
40+
# uint256 index
41+
# ) public view returns (StrategyParams memory)
42+
#
43+
44+
QUORUM_NUMER=0x0 #Aligned has only 1 quorum for now
45+
46+
cast call $STAKE_REGISTRY "strategyParamsByIndex(uint8,uint256)((address,uint96))" $QUORUM_NUMER $STRATEGY_INDEX --rpc-url $RPC_URL
47+
48+
# Expected output:
49+
# (strategy_address, multiplier)
50+
# example:
51+
# (0xc5a5C42992dECbae36851359345FE25997F5C42d, 1000000000000000000 [1e18])
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
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, INDICES_TO_REMOVE"
13+
exit 1
14+
fi
15+
16+
INDICES_TO_REMOVE=$1
17+
18+
if [[ ! "$INDICES_TO_REMOVE" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then
19+
echo "The INDICES_TO_REMOVE doesn't match the required format: [0,1,...,n]"
20+
exit 1
21+
fi
22+
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+
43+
44+
## Using in this cast call:
45+
46+
# /**
47+
# * @notice This function is used for removing strategies and their associated weights from the
48+
# * mapping strategyParams for a specific @param quorumNumber.
49+
# * @dev higher indices should be *first* in the list of @param indicesToRemove, since otherwise
50+
# * the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove
51+
# */
52+
# function removeStrategies(uint8 quorumNumber, uint256[] calldata indicesToRemove) external;
53+
54+
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now
55+
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
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
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 2 ]; then
12+
echo "Error: 2 arguments are required, STRATEGY_INDICES and NEW_MULTIPLIERS"
13+
exit 1
14+
fi
15+
16+
STRATEGY_INDICES=$1
17+
NEW_MULTIPLIERS=$2
18+
19+
20+
if [[ ! "$STRATEGY_INDICES" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then
21+
echo "The STRATEGY_INDICES doesn't match the required format: [0,1,...,n]"
22+
exit 1
23+
fi
24+
25+
if [ -z "$NEW_MULTIPLIERS" ]; then
26+
echo "NEW_MULTIPLIERS env var is not set"
27+
exit 1
28+
fi
29+
if [[ ! "$NEW_MULTIPLIERS" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then
30+
echo "The NEW_MULTIPLIERS doesn't match the required format: [0,1,...,n]"
31+
exit 1
32+
fi
33+
34+
count_elements() {
35+
local var="$1"
36+
# Remove brackets and count elements by splitting on commas
37+
echo "$var" | sed 's/[\[\]]//g' | awk -F',' '{print NF}'
38+
}
39+
count1=$(count_elements "$STRATEGY_INDICES")
40+
count2=$(count_elements "$NEW_MULTIPLIERS")
41+
42+
43+
if [[ $count1 -ne $count2 ]]; then
44+
echo "STRATEGY_INDICES and NEW_MULTIPLIERS have different numbers of elements:"
45+
echo "STRATEGY_INDICES: $STRATEGY_INDICES"
46+
echo "NEW_MULTIPLIERS: $NEW_MULTIPLIERS"
47+
exit 1
48+
fi
49+
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+
71+
72+
## Using in this cast call:
73+
74+
# /**
75+
# * @notice This function is used for modifying the weights of strategies that are already in the
76+
# * mapping strategyParams for a specific
77+
# * @param quorumNumber is the quorum number to change the strategy for
78+
# * @param strategyIndices are the indices of the strategies to change
79+
# * @param newMultipliers are the new multipliers for the strategies
80+
# */
81+
# function modifyStrategyParams(
82+
# uint8 quorumNumber,
83+
# uint256[] calldata strategyIndices,
84+
# uint96[] calldata newMultipliers
85+
# ) external;
86+
87+
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now
88+
89+
data=$(cast calldata "modifyStrategyParams(uint8, uint256[], uint96[])()" $QUORUM_NUMBER $STRATEGY_INDICES $NEW_MULTIPLIERS)
90+
91+
if [ "$MULTISIG" = false ]; then
92+
echo "Executing modify strategy params transaction"
93+
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
1.8 MB
Loading
1.72 MB
Loading
153 KB
Loading
1.09 MB
Loading
636 KB
Loading

0 commit comments

Comments
 (0)