|
1 |
| -## Foundry |
| 1 | +# Cluster Deployment and Management |
2 | 2 |
|
3 |
| -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** |
| 3 | +This README explains how to manage a cluster using the provided scripts. |
4 | 4 |
|
5 |
| -Foundry consists of: |
| 5 | +## Overview |
6 | 6 |
|
7 |
| -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). |
8 |
| -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. |
9 |
| -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. |
10 |
| -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. |
| 7 | +A cluster is a collection of vaults that work together in the system. The `ManageClusterBase.s.sol` contract defined in the `evk-periphery` repository provides the base functionality for configuring and managing clusters, while specific cluster implementations (like example `Cluster.s.sol`) define the actual configuration for each cluster. |
11 | 8 |
|
12 |
| -## Documentation |
| 9 | +## Management Process |
13 | 10 |
|
14 |
| -https://book.getfoundry.sh/ |
| 11 | +Refer to the `defineCluster()` and `configureCluster()` functions in the specific cluster script file. If no vaults are deployed yet, they will get deployed when the management script is executed for the first time. If the vaults are already deployed, the management script will only apply the delta between the cluster script file configuration and the current state of the cluster. |
15 | 12 |
|
16 |
| -## Usage |
| 13 | +Edit the specific cluster file (e.g., `Cluster.s.sol`) to set up the desired configuration. Define assets, LTVs, oracle providers, supply caps, borrow caps, IRM parameters, and other settings. |
17 | 14 |
|
18 |
| -### Build |
| 15 | +Note that the cluster specific contracts depend on the `Addresses.s.sol` which defines the asset addresses. You might need to either expand the `AddressesEthereum` contract to include more addresses on mainnet or create a new dedicated contract for new network (i.e. `AddressesBase`) and allow the `Cluster` contract to inherit from it. |
19 | 16 |
|
20 |
| -```shell |
21 |
| -$ forge build |
| 17 | +The corresponding `.json` files in the scripts directory that are created when running the script are used as the deployed contracts addresses cache. They are used for further management of the cluster. They must be retained as this is how the existing contract addresses are being loaded into the cluster management script! |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +1. Ensure that you have up to date foundry version installed: |
| 22 | + |
| 23 | +```bash |
| 24 | +foundryup |
| 25 | +``` |
| 26 | + |
| 27 | +If you don't have foundry installed at all, before running `foundryup`, you need to first run: |
| 28 | + |
| 29 | +```bash |
| 30 | +curl -L https://foundry.paradigm.xyz | bash |
| 31 | +``` |
| 32 | + |
| 33 | +2. Clone the repository if you don't have it already: |
| 34 | + |
| 35 | +```bash |
| 36 | +git clone https://github.com/euler-xyz/euler-vault-scripts.git && cd euler-vault-scripts |
22 | 37 | ```
|
23 | 38 |
|
24 |
| -### Test |
| 39 | +3. Prepare the `.env` file by. Use `.env.example` as an example. Define the RPC URLs for all the chain IDs you need. |
25 | 40 |
|
26 |
| -```shell |
27 |
| -$ forge test |
| 41 | +4. Ensure that you have up to date dependencies installed: |
| 42 | + |
| 43 | +```bash |
| 44 | +install.sh |
28 | 45 | ```
|
29 | 46 |
|
30 |
| -### Format |
| 47 | +5. Compile the contracts: |
31 | 48 |
|
32 |
| -```shell |
33 |
| -$ forge fmt |
| 49 | +```bash |
| 50 | +forge clean && forge compile |
34 | 51 | ```
|
35 | 52 |
|
36 |
| -### Gas Snapshots |
| 53 | +## Run the script |
| 54 | + |
| 55 | +Use the `ExecuteSolidityScript.sh` script to run the management script. |
37 | 56 |
|
38 |
| -```shell |
39 |
| -$ forge snapshot |
| 57 | +Use the following command: |
| 58 | + |
| 59 | +```bash |
| 60 | +./script/ExecuteSolidityScript.sh script/clusters/<ClusterSpecificScript> [options] |
40 | 61 | ```
|
41 | 62 |
|
42 |
| -### Anvil |
| 63 | +Replace `<ClusterSpecificScript>` with the cluster specific file name, i.e. `Cluster.s.sol`. |
| 64 | + |
| 65 | +Options: |
| 66 | +- `--dry-run`: Simulates the script without actually executing transactions. |
| 67 | +- `--rpc-url URL|CHAIN_ID`: Must be used if `DEPLOYMENT_RPC_URL` not defined in `.env`. If `CHAIN_ID` passed, it will get resolved as per `.env`. |
| 68 | +- `--account ACCOUNT` or `--ledger`: Must be used if `DEPLOYER_KEY` not defined in `.env` and the transaction if not meant to be executed via Safe (no actual transaction executed on-chain). |
| 69 | +- `--batch-via-safe`: Creates a batch payload file that can be used to create a batch transaction via Safe. This option must be used in case the cluster is managed using Safe (even if not directly; i.e. Safe is a proposer on the timelock controller). |
| 70 | +- `--safe-address SAFE_ADDRESS`: Authorized Safe multisig address that will be used to create a batch transaction This option must be used in case the cluster is managed using Safe (even if not directly; i.e. Safe is a proposer on the timelock controller). |
| 71 | +- `--timelock-address`: Schedules the transactions in the timelock controller provided instead of trying to execute them immediately. This option must be used in case the timelock controller is installed as part of the governor contracts suite. |
| 72 | +- `--risk-steward-address`: Executes the transactions via the risk steward contract provided instead of trying to execute it directly. This option can be used in case the risk steward contract is installed as part of the governor contracts suite and the operation executed allows bypassing timelocks. |
| 73 | + |
| 74 | +Example - initial deployment: |
43 | 75 |
|
44 |
| -```shell |
45 |
| -$ anvil |
| 76 | +``` |
| 77 | +./script/ExecuteSolidityScript.sh ./script/clusters/Cluster.s.sol --account DEPLOYER --rpc-url 1 |
46 | 78 | ```
|
47 | 79 |
|
48 |
| -### Deploy |
| 80 | +Example - management of the deployed cluster after the governance transferred to the governance contracts suite (GovernorAccessControl + TimelockController + Safe): |
49 | 81 |
|
50 |
| -```shell |
51 |
| -$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> |
52 | 82 | ```
|
| 83 | +./script/ExecuteSolidityScript.sh ./script/clusters/Cluster.s.sol --batch-via-safe --safe-address DAO --timelock-address wildcard --rpc-url 1 |
| 84 | +``` |
| 85 | + |
| 86 | +## Important Notes |
| 87 | + |
| 88 | +Always try to use the `--dry-run` option first to simulate the transactions and check for any potential issues. |
| 89 | + |
| 90 | +# Emergency Vault Pause |
| 91 | + |
| 92 | +In case of a governor contract installed, this section assumes that the cluster is governed by the `GovernorAccessControlEmergency` contract with a Safe multisig having an appropriate emergency role granted to it. |
| 93 | + |
| 94 | +> **IMPORTANT**: Environment variables defined in the `.env` file take precedence over the command line arguments! |
53 | 95 |
|
54 |
| -### Cast |
| 96 | +## Steps |
55 | 97 |
|
56 |
| -```shell |
57 |
| -$ cast <subcommand> |
| 98 | +1. Ensure that you performed all the steps from the Prerequisites section. |
| 99 | + |
| 100 | +2. Run the script: |
| 101 | + |
| 102 | +Options: |
| 103 | +- `--rpc-url` required if `DEPLOYMENT_RPC_URL` not defined in `.env` |
| 104 | +- `--account ACCOUNT` or `--ledger` if `DEPLOYER_KEY` not defined in `.env` and the transaction if not meant to be executed via Safe |
| 105 | +- `--batch-via-safe` if operations must be executed via Safe multisig (typically should always be used) |
| 106 | +- `--safe-address SAFE_ADDRESS` authorized Safe multisig address |
| 107 | +- `--vault-address VAULT_ADDRESS` the vault being a subject of the emegency operation |
| 108 | +- `--emergency-ltv-collateral` should be used if you intend to disable the `VAULT_ADDRESS` from being used as collateral by modifying the borrow LTVs |
| 109 | +- `--emergency-ltv-borrowing` should be used if you intend to disable all collaterals on the `VAULT_ADDRESS` by modifying the borrow LTVs |
| 110 | +- `--emergency-caps` should be used if you intend to set the supply and the borrow caps of the `VAULT_ADDRESS` to zero |
| 111 | +- `--emergency-operations` should be used if you intend disable all the operations of the `VAULT_ADDRESS` |
| 112 | + |
| 113 | +```bash |
| 114 | +./script/ExecuteSolidityScript.sh PATH_TO_CLUSTER_SPECIFIC_SCRIPT --rpc-url RPC_URL --batch-via-safe --safe-address SAFE_ADDRESS --vault-address VAULT_ADDRESS [--emergency-ltv-collateral] [--emergency-ltv-borrowing] [--emergency-caps] [--emergency-caps] |
58 | 115 | ```
|
59 | 116 |
|
60 |
| -### Help |
| 117 | +Example command: |
61 | 118 |
|
62 |
| -```shell |
63 |
| -$ forge --help |
64 |
| -$ anvil --help |
65 |
| -$ cast --help |
| 119 | +```bash |
| 120 | +./script/ExecuteSolidityScript.sh script/clusters/Cluster.s.sol --rpc-url https://ethereum-rpc.publicnode.com --batch-via-safe --safe-address 0xB1345E7A4D35FB3E6bF22A32B3741Ae74E5Fba27 --vault-address 0xD8b27CF359b7D15710a5BE299AF6e7Bf904984C2 --emergency-ltv-collateral --emergency-caps |
66 | 121 | ```
|
| 122 | + |
| 123 | +3. Create the transaction in the Safe UI (if the transaction if meant to be executed via Safe) |
| 124 | + |
| 125 | +Use the Safe UI Transaction Builder tool to create the transaction. Load the `<payload file>` file created by the script that can be found under the following path: `deployments/[CLUSTER_SPECIFIC_DIRECTORY]/[CHAIN_ID]/output/SafeBatchBuilder_*.json`. |
| 126 | + |
| 127 | +4. Coordinate signing process with the other Safe multisig signers. |
| 128 | + |
| 129 | +5. Execute the transaction in the Safe UI. |
0 commit comments