Skip to content

Commit

Permalink
Merge pull request #48 from OlympusDAO/develop
Browse files Browse the repository at this point in the history
Release: Berachain, YRF 1.2
  • Loading branch information
0xJem authored Feb 12, 2025
2 parents be4aa21 + d53bfd5 commit 7303abb
Show file tree
Hide file tree
Showing 50 changed files with 2,593 additions and 564 deletions.
4 changes: 4 additions & 0 deletions .env.L2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CHAIN=
RPC_URL=
ETHERSCAN_KEY=
VERIFIER_URL=
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"gruntfuggly.todo-tree",
"ryanluker.vscode-coverage-gutters",
"github.vscode-github-actions",
"d-koppenhagen.file-tree-to-text-generator"
"d-koppenhagen.file-tree-to-text-generator",
"mads-hartmann.bash-ide-vscode",
"tamasfe.even-better-toml"
]
}
53 changes: 3 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,9 @@ Add `FORK_TEST_RPC_URL` to the .env file in order to run fork tests

Copy the `.env.deploy.example` file into one file per chain, e.g. `.env_deploy_goerli` and set the appropriate variables. This chain-specific environment file can then be called during deployment, e.g. `env $(cat .env_deploy_goerli | xargs) PRIVATE_KEY=<PRIVATE KEY> ./shell/deploy.sh`

## How To Deploy

1. Update the solidity deployment script `src/scripts/deployment/DeployV2.sol`.
- If necessary, add external dependencies (e.g. `sdai = ERC20(envAddress("external.tokens.sDAI"));`)
- Create a function to handle the deployment of the new contracts (e.g. `_deployBLVaultLusd()`)
- Add the new contracts to the `selectorMap` with their corresponding keys.
2. Update the configuration-input JSON file `src/scripts/deployment/deploy.json`
- Use the corresponding keys for the selectorMap in `#1.3`.
- Use any necessary configuration parameters.
- Create a copy the file under `src/scripts/deploy/savedDeployments/` and give it the same name as internal function created in `#1.2`.
3. If external dependencies are required, add them in `src/scripts/env.json`, so that they can be used in `DeployV2.sol`.
4. If necessary, update your `.env` file. It should, at least, have the same variables as in `.env.deploy.example`.
5. Run `shell/deploy.sh $DEPLOY_FILE_PATH` to run the deployment shell script (e.g. `shell/deploy.sh src/scripts/deploy/savedDeployments/rbs_v1_3.json`).
- If you want to broadcast the tx to the network, uncomment the line of the script containing `--broadcast`. Only do so after having tested the deployment.
6. After a successful deployment, update `src/scripts/env.json` with the new contract addresses.
7. Finally, use [olymsig](https://github.com/OlympusDAO/olymsig) (or [olymsig-testnet](https://github.com/OlympusDAO/olymsig-testnet) if testing the deployment) to plug the newly deployed contracts into `olympus-v3`.

## How To Verify

Sometimes the automatic etherscan verification fails when deploying a contract. If that's the case, follow the these steps to verify existing contracts:

1. Execute the `shell/verify_etherscan.sh` script with the following arguments:

- `CONTRACT_ADDRESS`: Address of the target contract to be verified.
- `CONTRACT_PATH`: Relative path to the target contract.
- `CONSTRUCTOR_ARGS`: Calldata of the constructor args. The preferred method is to manually encode the data, but `cast abi-encode "constructor(args)" "values"` can also be used.

2. This is an example execution of the shell script:

```shell
shell/verify_etherscan.sh 0x0AE561226896dA978EaDA0Bec4a7d3CfAE04f506 src/policies/Operator.sol:Operator 0x0000000000000000000000002286d7f9639e8158fad1169e76d1fbc38247f54b000000000000000000000000007f7a1cb838a872515c8ebd16be4b14ef43a22200000000000000000000000073df08ce9dcc8d74d22f23282c4d49f13b4c795e00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d50000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000083f20f44975d03b1b09e64809b757c47f942beea0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000003f48000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000384000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000007e90000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000015
```

Where the `CONSTRUCTOR_ARGS` have been decode in the following way:

```hex
constructor(address,address,address,uint256,uint256[2],uint256[2])"
0x
0000000000000000000000002286d7f9639e8158fad1169e76d1fbc38247f54b # address1
00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5 # address2
0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f # address3
0000000000000000000000000000000000000000000000000000000000000064 # uint256
00000000000000000000000000000000000000000000000000000000000003e8 # array1[0]
00000000000000000000000000000000000000000000000000000000000007d0 # array1[1]
00000000000000000000000000000000000000000000000000000000000003e8 # array2[0]
00000000000000000000000000000000000000000000000000000000000007d0 # array2[1]
```
Remember that you can use `chisel` to easily convert from decimals to hex
## Deployment

See [DEPLOY.md](src/scripts/DEPLOY.md) and [DEPLOY_L2.md](src/scripts/DEPLOY_L2.md) for more detailed steps.

## Boosted Liquidity Vault Setup

Expand Down
3 changes: 3 additions & 0 deletions deployments/.mainnet-1739165363.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"YieldRepurchaseFacility": "0x271e35a8555a62F6bA76508E85dfD76D580B0692"
}
66 changes: 66 additions & 0 deletions shell/L2/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Deploys an L2 installation of the Olympus protocol.
#
# Usage:
# ./deploy.sh --account <cast wallet> --broadcast <false> --verify <false> --resume <false> --env <env-file>
#
# Environment variables:
# RPC_URL
# CHAIN
# ETHERSCAN_KEY (only needed if verify is true)
# VERIFIER_URL (only needed for a custom verifier or on a fork)

# Exit if any error occurs
set -e

# Load named arguments
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $SCRIPT_DIR/../lib/arguments.sh
load_named_args "$@"

# Load environment variables
load_env

# Set sane defaults
BROADCAST=${broadcast:-false}
VERIFY=${verify:-false}
RESUME=${resume:-false}

# Validate named arguments
echo ""
echo "Validating arguments"
validate_text "$account" "No account specified. Provide the cast wallet after the --account flag."

# Validate environment variables
echo ""
echo "Validating environment variables"
validate_text "$CHAIN" "No chain specified. Specify the CHAIN in the $ENV_FILE file."
validate_text "$RPC_URL" "No RPC URL specified. Specify the RPC_URL in the $ENV_FILE file."

echo ""
echo "Summary:"
echo " Deploying from account: $account"
echo " Chain: $CHAIN"
echo " Using RPC at URL: $RPC_URL"

# Validate and set forge script flags
source $SCRIPT_DIR/../lib/forge.sh
set_broadcast_flag $BROADCAST
set_verify_flag $VERIFY $ETHERSCAN_KEY $VERIFIER_URL
set_resume_flag $RESUME
set_account_address $account

# Deploy using script
echo ""
echo "Running forge script"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "deploy(string)()" $CHAIN \
--rpc-url $RPC_URL --account $account --slow -vvv \
--sender $ACCOUNT_ADDRESS \
$BROADCAST_FLAG \
$VERIFY_FLAG \
$RESUME_FLAG

echo ""
echo "Deployment complete"
58 changes: 58 additions & 0 deletions shell/L2/grantRoles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# Grants roles.
#
# Usage:
# ./grantRoles.sh --account <cast wallet> --broadcast <false> --env <env-file>
#
# Environment variables:
# RPC_URL
# CHAIN

# Exit if any error occurs
set -e

# Load named arguments
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $SCRIPT_DIR/../lib/arguments.sh
load_named_args "$@"

# Load environment variables
load_env

# Set sane defaults
BROADCAST=${broadcast:-false}

# Validate named arguments
echo ""
echo "Validating arguments"
validate_text "$account" "No account specified. Provide the cast wallet after the --account flag."

# Validate environment variables
echo ""
echo "Validating environment variables"
validate_text "$CHAIN" "No chain specified. Specify the CHAIN in the $ENV_FILE file."
validate_text "$RPC_URL" "No RPC URL specified. Specify the RPC_URL in the $ENV_FILE file."

echo ""
echo "Summary:"
echo " Account: $account"
echo " Chain: $CHAIN"
echo " Using RPC at URL: $RPC_URL"

# Validate and set forge script flags
source $SCRIPT_DIR/../lib/forge.sh
set_broadcast_flag $BROADCAST
set_account_address $account

# Deploy using script
echo ""
echo "Running forge script"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "grantRoles(string)()" $CHAIN \
--rpc-url $RPC_URL --account $account --slow -vvv \
--sender $ACCOUNT_ADDRESS \
$BROADCAST_FLAG

echo ""
echo "Grant roles complete"
61 changes: 61 additions & 0 deletions shell/L2/handoff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

# Transfers the ownership of the Bophades installation to the DAO multisig.
#
# Usage:
# ./handoff.sh --account <cast wallet> --broadcast <false> --resume <false> --env <env-file>
#
# Environment variables:
# RPC_URL
# CHAIN

# Exit if any error occurs
set -e

# Load named arguments
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $SCRIPT_DIR/../lib/arguments.sh
load_named_args "$@"

# Load environment variables
load_env

# Set sane defaults
BROADCAST=${broadcast:-false}
RESUME=${resume:-false}

# Validate named arguments
echo ""
echo "Validating arguments"
validate_text "$account" "No account specified. Provide the cast wallet after the --account flag."

# Validate environment variables
echo ""
echo "Validating environment variables"
validate_text "$RPC_URL" "No RPC URL specified. Specify the RPC_URL in the $ENV_FILE file."
validate_text "$CHAIN" "No chain specified. Specify the CHAIN in the $ENV_FILE file."

echo ""
echo "Summary:"
echo " Deploying from account: $account"
echo " Chain: $CHAIN"
echo " Using RPC at URL: $RPC_URL"

# Validate and set forge script flags
source $SCRIPT_DIR/../lib/forge.sh
set_broadcast_flag $BROADCAST
set_resume_flag $RESUME
set_account_address $account

# Deploy using script
echo ""
echo "Running forge script"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "handoffToMultisig(string)()" $CHAIN \
--rpc-url $RPC_URL --account $account --slow -vvv \
--sender $ACCOUNT_ADDRESS \
$BROADCAST_FLAG \
$RESUME_FLAG

echo ""
echo "Handoff complete"
62 changes: 62 additions & 0 deletions shell/L2/setupBridge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Sets up the bridge for a chain to trust messages from another chain.
#
# Usage:
# ./setupBridge.sh --account <cast wallet> --localChain <chain> --remoteChain <chain> --broadcast <false> --resume <false> --env <env-file>
#
# Environment variables:
# RPC_URL

# Exit if any error occurs
set -e

# Load named arguments
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $SCRIPT_DIR/../lib/arguments.sh
load_named_args "$@"

# Load environment variables
load_env

# Set sane defaults
BROADCAST=${broadcast:-false}
RESUME=${resume:-false}

# Validate named arguments
echo ""
echo "Validating arguments"
validate_text "$account" "No account specified. Provide the cast wallet after the --account flag."
validate_text "$localChain" "No local chain specified. Specify the localChain after the --localChain flag."
validate_text "$remoteChain" "No remote chain specified. Specify the remoteChain after the --remoteChain flag."

# Validate environment variables
echo ""
echo "Validating environment variables"
validate_text "$RPC_URL" "No RPC URL specified. Specify the RPC_URL in the $ENV_FILE file."

echo ""
echo "Summary:"
echo " Deploying from account: $account"
echo " Local chain: $localChain"
echo " Remote chain: $remoteChain"
echo " Using RPC at URL: $RPC_URL"

# Validate and set forge script flags
source $SCRIPT_DIR/../lib/forge.sh
set_broadcast_flag $BROADCAST
set_resume_flag $RESUME
set_account_address $account

# Deploy using script
echo ""
echo "Running forge script"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "setupBridge(string,string)()" $localChain $remoteChain \
--rpc-url $RPC_URL --account $account --slow -vvv \
--sender $ACCOUNT_ADDRESS \
$BROADCAST_FLAG \
$RESUME_FLAG

echo ""
echo "Setup complete"
29 changes: 29 additions & 0 deletions shell/L2/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Verifies the deployment.
#
# Usage:
# ./verify.sh --env <env-file>
#
# Environment variables:
# RPC_URL
# CHAIN

# Exit if any error occurs
set -e

# Deploy using script
echo ""
echo "Checking Berachain"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "verifyBerachain(string)()" "berachain" \
--rpc-url "https://rpc.berachain.com" --slow -vvv

echo ""
echo "Checking Mainnet"
forge script ./src/scripts/deploy/L2Deploy.s.sol:L2Deploy \
--sig "verifyMainnet(string)()" "mainnet" \
--rpc-url "https://eth.llamarpc.com" --slow -vvv

echo ""
echo "Verification complete"
Loading

0 comments on commit 7303abb

Please sign in to comment.