|
| 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 |
0 commit comments