-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make targets to modify strategies (#1530)
Co-authored-by: PatStiles <[email protected]> Co-authored-by: avilagaston9 <[email protected]>
- Loading branch information
1 parent
bd6adf0
commit 0b0c9dd
Showing
15 changed files
with
403 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# cd to the directory of this script so that this can be run from anywhere | ||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
# At this point we are in contracts/scripts | ||
cd "$parent_path" | ||
|
||
# At this point we are in contracts | ||
cd ../ | ||
|
||
if [ -z "$OUTPUT_PATH" ]; then | ||
echo "OUTPUT_PATH env var is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$RPC_URL" ]; then | ||
echo "RPC_URL env var is not set" | ||
exit 1 | ||
fi | ||
|
||
ALIGNED_SERVICE_MANAGER=$(jq -r '.addresses.alignedLayerServiceManager' "$OUTPUT_PATH") | ||
|
||
## Using in this cast call: | ||
|
||
# /** | ||
# * @notice Returns the list of strategies that the AVS supports for restaking | ||
# * @dev This function is intended to be called off-chain | ||
# * @dev No guarantee is made on uniqueness of each element in the returned array. | ||
# * The off-chain service should do that validation separately | ||
# */ | ||
# function getRestakeableStrategies() external view returns (address[] memory) { | ||
|
||
cast call $ALIGNED_SERVICE_MANAGER "getRestakeableStrategies()(address[])" --rpc-url $RPC_URL | ||
|
||
# Expected output: | ||
# [addresses] | ||
# example: | ||
# [0xc5a5C42992dECbae36851359345FE25997F5C42d, 0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# cd to the directory of this script so that this can be run from anywhere | ||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
# At this point we are in contracts/scripts | ||
cd "$parent_path" | ||
|
||
# At this point we are in contracts | ||
cd ../ | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Error: 1 arguments is required, STRATEGY_INDEX" | ||
exit 1 | ||
fi | ||
|
||
STRATEGY_INDEX=$1 | ||
|
||
if [ -z "$OUTPUT_PATH" ]; then | ||
echo "OUTPUT_PATH env var is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$RPC_URL" ]; then | ||
echo "RPC_URL env var is not set" | ||
exit 1 | ||
fi | ||
|
||
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH") | ||
|
||
## Using in this cast call: | ||
|
||
# struct StrategyParams { | ||
# IStrategy strategy; (iface -> address) | ||
# uint96 multiplier; | ||
# } | ||
|
||
# /// @notice Returns the strategy and weight multiplier for the `index`'th strategy in the quorum `quorumNumber` | ||
# function strategyParamsByIndex( | ||
# uint8 quorumNumber, | ||
# uint256 index | ||
# ) public view returns (StrategyParams memory) | ||
# | ||
|
||
QUORUM_NUMER=0x0 #Aligned has only 1 quorum for now | ||
|
||
cast call $STAKE_REGISTRY "strategyParamsByIndex(uint8,uint256)((address,uint96))" $QUORUM_NUMER $STRATEGY_INDEX --rpc-url $RPC_URL | ||
|
||
# Expected output: | ||
# (strategy_address, multiplier) | ||
# example: | ||
# (0xc5a5C42992dECbae36851359345FE25997F5C42d, 1000000000000000000 [1e18]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
# cd to the directory of this script so that this can be run from anywhere | ||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
# At this point we are in contracts/scripts | ||
cd "$parent_path" | ||
|
||
# At this point we are in contracts | ||
cd ../ | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Error: 1 arguments is required, INDICES_TO_REMOVE" | ||
exit 1 | ||
fi | ||
|
||
INDICES_TO_REMOVE=$1 | ||
|
||
if [[ ! "$INDICES_TO_REMOVE" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then | ||
echo "The INDICES_TO_REMOVE doesn't match the required format: [0,1,...,n]" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$MULTISIG" ]; then | ||
echo "MULTISIG env var is not set" | ||
exit 1 | ||
fi | ||
if [ "$MULTISIG" = false ]; then | ||
if [ -z "$PRIVATE_KEY" ]; then | ||
echo "PRIVATE_KEY env var is not set" | ||
exit 1 | ||
fi | ||
if [ -z "$RPC_URL" ]; then | ||
echo "RPC_URL env var is not set" | ||
exit 1 | ||
fi | ||
if [ -z "$OUTPUT_PATH" ]; then | ||
echo "OUTPUT_PATH env var is not set" | ||
exit 1 | ||
fi | ||
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH") | ||
fi | ||
|
||
|
||
## Using in this cast call: | ||
|
||
# /** | ||
# * @notice This function is used for removing strategies and their associated weights from the | ||
# * mapping strategyParams for a specific @param quorumNumber. | ||
# * @dev higher indices should be *first* in the list of @param indicesToRemove, since otherwise | ||
# * the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove | ||
# */ | ||
# function removeStrategies(uint8 quorumNumber, uint256[] calldata indicesToRemove) external; | ||
|
||
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now | ||
|
||
data=$(cast calldata "removeStrategies(uint8, uint256[])()" $QUORUM_NUMBER $INDICES_TO_REMOVE) | ||
|
||
if [ "$MULTISIG" = false ]; then | ||
echo "Executing remove strategies transaction" | ||
|
||
cast send $STAKE_REGISTRY $data \ | ||
--rpc-url $RPC_URL \ | ||
--private-key $PRIVATE_KEY | ||
else | ||
echo "You can propose the remove strategies transaction with the multisig using this calldata:" | ||
echo $data | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
# cd to the directory of this script so that this can be run from anywhere | ||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
# At this point we are in contracts/scripts | ||
cd "$parent_path" | ||
|
||
# At this point we are in contracts | ||
cd ../ | ||
|
||
if [ "$#" -ne 2 ]; then | ||
echo "Error: 2 arguments are required, STRATEGY_INDICES and NEW_MULTIPLIERS" | ||
exit 1 | ||
fi | ||
|
||
STRATEGY_INDICES=$1 | ||
NEW_MULTIPLIERS=$2 | ||
|
||
|
||
if [[ ! "$STRATEGY_INDICES" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then | ||
echo "The STRATEGY_INDICES doesn't match the required format: [0,1,...,n]" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$NEW_MULTIPLIERS" ]; then | ||
echo "NEW_MULTIPLIERS env var is not set" | ||
exit 1 | ||
fi | ||
if [[ ! "$NEW_MULTIPLIERS" =~ ^\[[0-9]+(,[0-9]+)*\]$ ]]; then | ||
echo "The NEW_MULTIPLIERS doesn't match the required format: [0,1,...,n]" | ||
exit 1 | ||
fi | ||
|
||
count_elements() { | ||
local var="$1" | ||
# Remove brackets and count elements by splitting on commas | ||
echo "$var" | sed 's/[\[\]]//g' | awk -F',' '{print NF}' | ||
} | ||
count1=$(count_elements "$STRATEGY_INDICES") | ||
count2=$(count_elements "$NEW_MULTIPLIERS") | ||
|
||
|
||
if [[ $count1 -ne $count2 ]]; then | ||
echo "STRATEGY_INDICES and NEW_MULTIPLIERS have different numbers of elements:" | ||
echo "STRATEGY_INDICES: $STRATEGY_INDICES" | ||
echo "NEW_MULTIPLIERS: $NEW_MULTIPLIERS" | ||
exit 1 | ||
fi | ||
|
||
|
||
if [ -z "$MULTISIG" ]; then | ||
echo "MULTISIG env var is not set" | ||
exit 1 | ||
fi | ||
if [ "$MULTISIG" = false ]; then | ||
if [ -z "$PRIVATE_KEY" ]; then | ||
echo "PRIVATE_KEY env var is not set" | ||
exit 1 | ||
fi | ||
if [ -z "$RPC_URL" ]; then | ||
echo "RPC_URL env var is not set" | ||
exit 1 | ||
fi | ||
if [ -z "$OUTPUT_PATH" ]; then | ||
echo "OUTPUT_PATH env var is not set" | ||
exit 1 | ||
fi | ||
STAKE_REGISTRY=$(jq -r '.addresses.stakeRegistry' "$OUTPUT_PATH") | ||
fi | ||
|
||
|
||
## Using in this cast call: | ||
|
||
# /** | ||
# * @notice This function is used for modifying the weights of strategies that are already in the | ||
# * mapping strategyParams for a specific | ||
# * @param quorumNumber is the quorum number to change the strategy for | ||
# * @param strategyIndices are the indices of the strategies to change | ||
# * @param newMultipliers are the new multipliers for the strategies | ||
# */ | ||
# function modifyStrategyParams( | ||
# uint8 quorumNumber, | ||
# uint256[] calldata strategyIndices, | ||
# uint96[] calldata newMultipliers | ||
# ) external; | ||
|
||
QUORUM_NUMBER=0 #Aligned has only 1 quorum for now | ||
|
||
data=$(cast calldata "modifyStrategyParams(uint8, uint256[], uint96[])()" $QUORUM_NUMBER $STRATEGY_INDICES $NEW_MULTIPLIERS) | ||
|
||
if [ "$MULTISIG" = false ]; then | ||
echo "Executing modify strategy params transaction" | ||
|
||
cast send $STAKE_REGISTRY $data \ | ||
--rpc-url $RPC_URL \ | ||
--private-key $PRIVATE_KEY | ||
else | ||
echo "You can propose the modify strategy params transaction with the multisig using this calldata:" | ||
echo $data | ||
fi |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions
38
docs/0_internal/modify strategies/6_a_modify_strategies.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Modify Strategy Weight Multipliers | ||
This doc contains a guide on how to modify the strategy weight multipliers on Aligned. | ||
|
||
To run the make targets specified in this guide, you must first have the relevant following env vars under `contracts/scripts/.env`: | ||
``` | ||
RPC_URL=<rpc_url> | ||
PRIVATE_KEY=<private_key> | ||
OUTPUT_PATH=<deployment_output_path> | ||
MULTISIG=false | ||
``` | ||
|
||
## | ||
To view some relevant information you can: | ||
|
||
### Get all available strategies: | ||
|
||
``` | ||
make strategies_get_addresses | ||
``` | ||
|
||
### Get weight multiplier of a specific strategy: | ||
|
||
``` | ||
make strategies_get_weight STRATEGY_INDEX=<strategy_index> | ||
``` | ||
|
||
### Update the weight of any amount of stratefies | ||
|
||
``` | ||
make strategies_update_weight STRATEGY_INDICES="[0,1,...,n]" NEW_MULTIPLIERS="[0,1,...,n]" | ||
``` | ||
|
||
### Remove a strategy | ||
|
||
``` | ||
make strategies_remove INDICES_TO_REMOVE="[0,1,...,n]" | ||
``` | ||
|
54 changes: 54 additions & 0 deletions
54
docs/0_internal/modify strategies/6_b_1_propose_modify_strategies.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Propose the Transaction for Modify Strategy Weight Multipliers using Multisig | ||
|
||
If you want to modify the Strategy Weight Multipliers the contracts, you can propose the transaction using the multisig wallet. | ||
|
||
## Prerequisites | ||
|
||
- You need to have deployed the contracts following the [Deploy Contracts Guide](./2_deploy_contracts.md). | ||
|
||
## Propose transaction for Pause AlignedLayerServiceManager | ||
|
||
To propose the modify Strategy Weight Multipliers transaction you can follow the steps below: | ||
|
||
1. Go to [Safe](https://app.safe.global/home) | ||
|
||
2. Click on `New transaction` -> `Transaction Builder` | ||
|
||
![New transaction](../images/6_b_1_modify_strategies_1.png) | ||
|
||
![Transaction Builder](../images/6_b_1_modify_strategies_2.png) | ||
|
||
3. . Get the `StakeRegistry` address from ```contracts/script/output/mainnet/alignedlayer_deployment_output.json``` or ```contracts/script/output/holesky/alignedlayer_deployment_output.json``` or ```contracts/script/output/sepolia/alignedlayer_deployment_output.json``` | ||
|
||
4. Paste the `StakeRegistry` address on `Enter Address or ENS Name` | ||
|
||
5. As this is a Proxy contract, choose `Use Implementation ABI` | ||
|
||
![use implementation abi](../images/6_b_1_modify_strategies_3.png) | ||
|
||
6. In `contract method selector` choose `modifyStrategyParams` , and fill in the parameter values accordingly. | ||
|
||
Note: Aligned currently only has `quorumNumber: 0`, and you will replace `strategyIndices` with `newMultipliers` | ||
|
||
![choose modify strategy params](../images/6_b_1_modify_strategies_4.png) | ||
|
||
7. Click on `+ Add new transaction` | ||
|
||
You should see the new transaction to be executed | ||
|
||
8. Click on `Create batch` to create the transaction. | ||
|
||
9. Simulate the transaction by clicking on `Simulate` | ||
|
||
10. If everything is correct, click on `Send batch` to send the transaction. | ||
|
||
11. Simulate the transaction, and if everything is correct, click on `Sign`. | ||
|
||
![send batch](../images/6_b_1_modify_strategies_5.png) | ||
|
||
> [!NOTE] | ||
> In the `call` field, you will see `fallback`. | ||
12. Wait for the transaction to be executed. You can check the transaction status on the `Transactions` tab. | ||
|
||
If the transaction is correctly created, you have to wait until the required Multisig member signs the transaction to send it. For this, you can follow [the following guide](./6_b_2_approve_modify_strategies.md) |
Oops, something went wrong.