Skip to content

Commit

Permalink
chore: add .sh script, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustrian committed Sep 12, 2024
1 parent ec1b49d commit eb15f10
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 5 deletions.
43 changes: 38 additions & 5 deletions script/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deployment scripts
# Strategy deployment scripts

This folder contains the scripts neccessary to deploy strategies and Allo contracts to the blockchain.
This folder contains the scripts neccessary to deploy strategies to the blockchain.

# Usage

Expand All @@ -9,9 +9,42 @@ This folder contains the scripts neccessary to deploy strategies and Allo contra
3. Fill the necessary environment variables in `.env` file. You can use `.env.example` as a template.
4. Run the deployment script with:
```
forge script script/${SCRIPT_FILENAME}.sol:${SCRIPT_CONTRACT_NAME} --fork-url ${RPC_URL} --private-key ${PRIVATE_KEY} --broadcast
script/strategies/deployStrategy.sh ${CHAIN_NAME} ${STRATEGY_NAME}
```
For example:
```
forge script script/strategies/DeployDirectAllocation.sol:DeployDirectAllocation --fork-url https://eth-sepolia.public.blastapi.io --private-key 0x0000 --broadcast
```
script/strategies/deployStrategy.sh sepolia DeployDirectAllocation
```

# Supported networks

- fuji
- sepolia
- celo-testnet
- arbitrum-sepolia
- optimism-sepolia
- optimism-mainnet
- celo-mainnet
- arbitrum-mainnet
- base
- polygon
- mainnet
- avalanche
- scroll
- ftmTestnet
- fantom
- filecoin-mainnet
- filecoin-calibration
- sei-devnet
- sei-mainnet
- lukso-testnet
- lukso-mainnet
- zkSyncTestnet
- zkSyncMainnet

# Deployment to zkSync

1. Install [foundry-zksync](https://github.com/matter-labs/foundry-zksync)
2. Deploy as usual

For actions other than deployments, such as running tests or compiling contracts, run `forge` commands using `--zksync`.
54 changes: 54 additions & 0 deletions script/strategies/deployStrategy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Function to dynamically map chains to variables
# Relevant issue that would deprecate this script if solved: https://github.com/foundry-rs/foundry/issues/7726
# TODO: add networks
deploy() {
chain=$1
strategy=$2
case "$chain" in
"sepolia")
RPC_URL="$SEPOLIA_RPC_URL"
API_KEY="$ETHERSCAN_API_KEY"
;;
"mainnet")
RPC_URL="$MAINNET_RPC_URL"
API_KEY="$ETHERSCAN_API_KEY"
;;
*)
echo "Error: Unknown chain '$chain'"
exit 1
;;
esac

# Check if required variables are set
if [ -z "$RPC_URL" ] || [ -z "$API_KEY" ] || [ -z "$DEPLOYER_PRIVATE_KEY" ]; then
echo "Error: Missing environment variables."
exit 1
fi

# Deploy script with resolved variables
if [ "$chain" == "zkSyncMainnet" ] || [ "$chain" == "zkSyncTestnet" ]; then
forge script script/strategies/"$strategy".sol --zksync --rpc-url "$RPC_URL" --broadcast --private-key "$DEPLOYER_PRIVATE_KEY" --verify --etherscan-api-key "$API_KEY"
else
forge script script/strategies/"$strategy".sol --rpc-url "$RPC_URL" --broadcast --private-key "$DEPLOYER_PRIVATE_KEY" --verify --etherscan-api-key "$API_KEY"
fi
}

# Ensure the chain argument is provided
if [ -z "$1" ]; then
echo "<chain> not provided. Usage: script/strategies/deployStrategy.sh <chain> <strategy>"
exit 1
fi

# Ensure the strategy argument is provided
if [ -z "$2" ]; then
echo "<strategy> not provided. Usage: script/strategies/deployStrategy.sh <chain> <strategy>"
exit 1
fi

# Source the environment variables from the .env file
source .env

# Call the deploy function with the provided chain argument
deploy "$1" "$2"

0 comments on commit eb15f10

Please sign in to comment.