|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [ -z "$OUTPUT_PATH" ]; then |
| 4 | + echo "OUTPUT_PATH env var is not set" |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +if [ -z "$RPC_URL" ]; then |
| 9 | + echo "RPC_URL env var is not set" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +if [ -z "$PRIVATE_KEY" ]; then |
| 14 | + echo "PRIVATE_KEY env var is not set" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +if [ -z "$STRATEGY_INDICES" ]; then |
| 19 | + echo "STRATEGY_INDICES env var is not set" |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | +if [[ ! "$STRATEGY_INDICES" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then |
| 23 | + echo "The STRATEGY_INDICES doesn't match the required format: [0,1,...,n]" |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +if [ -z "$NEW_MULTIPLIERS" ]; then |
| 28 | + echo "NEW_MULTIPLIERS env var is not set" |
| 29 | + exit 1 |
| 30 | +fi |
| 31 | +if [[ ! "$NEW_MULTIPLIERS" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then |
| 32 | + echo "The NEW_MULTIPLIERS doesn't match the required format: [0,1,...,n]" |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +count_elements() { |
| 37 | + local var="$1" |
| 38 | + # Remove brackets and count elements by splitting on commas |
| 39 | + echo "$var" | sed 's/[\[\]]//g' | awk -F',' '{print NF}' |
| 40 | +} |
| 41 | +count1=$(count_elements "$STRATEGY_INDICES") |
| 42 | +count2=$(count_elements "$NEW_MULTIPLIERS") |
| 43 | + |
| 44 | + |
| 45 | +if [[ $count1 -ne $count2 ]]; then |
| 46 | + echo "STRATEGY_INDICES and NEW_MULTIPLIERS have different numbers of elements:" |
| 47 | + echo "STRATEGY_INDICES: $STRATEGY_INDICES" |
| 48 | + echo "NEW_MULTIPLIERS: $NEW_MULTIPLIERS" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | + |
| 52 | +STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH") |
| 53 | + |
| 54 | +## Using in this cast call: |
| 55 | + |
| 56 | +# /** |
| 57 | +# * @notice This function is used for modifying the weights of strategies that are already in the |
| 58 | +# * mapping strategyParams for a specific |
| 59 | +# * @param quorumNumber is the quorum number to change the strategy for |
| 60 | +# * @param strategyIndices are the indices of the strategies to change |
| 61 | +# * @param newMultipliers are the new multipliers for the strategies |
| 62 | +# */ |
| 63 | +# function modifyStrategyParams( |
| 64 | +# uint8 quorumNumber, |
| 65 | +# uint256[] calldata strategyIndices, |
| 66 | +# uint96[] calldata newMultipliers |
| 67 | +# ) external; |
| 68 | + |
| 69 | +QUORUM_NUMBER=0 #Aligned has only 1 quorum for now |
| 70 | + |
| 71 | +echo $QUORUM_NUMBER |
| 72 | + |
| 73 | +echo $STAKE_REGISTRY |
| 74 | + |
| 75 | +cast send $STAKE_REGISTRY "modifyStrategyParams(uint8, uint256[], uint96[])()" $QUORUM_NUMBER $STRATEGY_INDICES $NEW_MULTIPLIERS --private-key $PRIVATE_KEY --rpc-url $RPC_URL |
0 commit comments