Skip to content

Commit

Permalink
Merge pull request #207 from Axis-Fi/dtl-testing
Browse files Browse the repository at this point in the history
Improvements from DTL testing
  • Loading branch information
0xJem authored Jun 15, 2024
2 parents 27ecd44 + 7dcd4f0 commit c318459
Show file tree
Hide file tree
Showing 40 changed files with 1,510 additions and 277 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ docs/

# Dotenv file
.env
.env.*

node_modules/

Expand Down
18 changes: 12 additions & 6 deletions script/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,27 @@ Notes:
To perform a deployment, run the following script:

```bash
./script/deploy/deploy.sh < sequence_file > [broadcast=false] [verify=false] [resume=false]
./script/deploy/deploy.sh --deployFile <file> --broadcast <true | false> --verify <true | false> --save <true | false> --resume <true | false>
```

For example, the following command will deploy using the specified sequence file, broadcast the changes and verify them using Etherscan:

```bash
./script/deploy/deploy.sh ./script/deploy/sequences/origin.json true true
./script/deploy/deploy.sh --deployFile ./script/deploy/sequences/origin.json --broadcast true --verify true
```

Following deployment, the addresses need to be manually added into `./script/env.json`.
It will also save the deployment addresses to a file and update `env.json`.

If any problems are faced during deployment (or verification), set the third boolean argument to `true` in order to resume the previous transaction. For example:
To not save the deployment addresses, set the `--save` argument to `false`. For example:

```bash
./script/deploy/deploy.sh ./script/deploy/sequences/origin.json true true true
./script/deploy/deploy.sh --deployFile ./script/deploy/sequences/origin.json --broadcast true --verify true --save false
```

If any problems are faced during deployment (or verification), set the `--resume` argument to `true` in order to resume the previous transaction. For example:

```bash
./script/deploy/deploy.sh --deployFile ./script/deploy/sequences/origin.json --broadcast true --verify true --save true --resume true
```

##### Blast-Specific Version
Expand All @@ -84,7 +90,7 @@ Deploying on Blast requires an AuctionHouse with additional constructor argument
Example command:

```bash
CHAIN="blast-sepolia" ./script/deploy/deploy.sh ./script/deploy/sequences/origin.json true true
CHAIN="blast-sepolia" ./script/deploy/deploy.sh --deployFile ./script/deploy/sequences/origin.json --broadcast true --verify true
```

#### Verification
Expand Down
76 changes: 56 additions & 20 deletions script/deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,65 @@
#!/bin/bash

# Usage:
# ./deploy.sh <deploy-file> <broadcast=false> <verify=false> <resume=false>
# ./deploy.sh --deployFile <deploy-file> --broadcast <false> --verify <false> --save <true> --resume <false> --envFile <.env>
#
# Environment variables:
# CHAIN: Chain name to deploy to. Corresponds to names in "./script/env.json".
# ETHERSCAN_API_KEY: API key for Etherscan verification. Should be specified in .env.
# RPC_URL: URL for the RPC node. Should be specified in .env.
# VERIFIER_URL: URL for the Etherscan API verifier. Should be specified when used on an unsupported chain.

# Load environment variables, but respect overrides
curenv=$(declare -p -x)
source .env
eval "$curenv"
# Iterate through named arguments
# Source: https://unix.stackexchange.com/a/388038
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
declare $v="$2"
fi

shift
done

# Get the name of the .env file or use the default
ENV_FILE=${envFile:-".env"}
echo "Sourcing environment variables from $ENV_FILE"

# Load environment file
set -a # Automatically export all variables
source $ENV_FILE
set +a # Disable automatic export

# Get command-line arguments
DEPLOY_FILE=$1
BROADCAST=${2:-false}
VERIFY=${3:-false}
RESUME=${4:-false}
# Apply defaults to command-line arguments
DEPLOY_FILE=$deployFile
BROADCAST=${broadcast:-false}
VERIFY=${verify:-false}
SAVE=${save:-true}
RESUME=${resume:-false}

# Check that the CHAIN environment variable is set
if [ -z "$CHAIN" ]
then
echo "CHAIN environment variable is not set. Please set it in the .env file or provide it as an environment variable."
exit 1
fi

# Check if DEPLOY_FILE is set
if [ -z "$DEPLOY_FILE" ]
then
echo "No deploy file specified. Provide the relative path after the command."
echo "No deploy file specified. Provide the relative path after the --deployFile flag."
exit 1
fi

# Check if DEPLOY_FILE exists
if [ ! -f "$DEPLOY_FILE" ]
then
echo "Deploy file ($DEPLOY_FILE) not found. Provide the correct relative path after the command."
echo "Deploy file ($DEPLOY_FILE) not found. Provide the correct relative path after the --deployFile flag."
exit 1
fi

# Validate if SAVE is "true" or "false", otherwise throw an error
if [ "$SAVE" != "true" ] && [ "$SAVE" != "false" ]; then
echo "Invalid value for --save. Use 'true' or 'false'."
exit 1
fi

Expand All @@ -48,8 +77,8 @@ fi

echo "Using deploy script and contract: $DEPLOY_SCRIPT:$DEPLOY_CONTRACT"
echo "Using deployment configuration: $DEPLOY_FILE"
echo "Using RPC at URL: $RPC_URL"
echo "Using chain: $CHAIN"
echo "Using RPC at URL: $RPC_URL"
if [ -n "$VERIFIER_URL" ]; then
echo "Using verifier at URL: $VERIFIER_URL"
fi
Expand All @@ -60,9 +89,9 @@ echo ""
BROADCAST_FLAG=""
if [ "$BROADCAST" = "true" ] || [ "$BROADCAST" = "TRUE" ]; then
BROADCAST_FLAG="--broadcast"
echo "Broadcasting is enabled"
echo "Broadcast: enabled"
else
echo "Broadcasting is disabled"
echo "Broadcast: disabled"
fi

# Set VERIFY_FLAG based on VERIFY
Expand All @@ -88,22 +117,29 @@ if [ "$VERIFY" = "true" ] || [ "$VERIFY" = "TRUE" ]; then
VERIFY_FLAG="--verify --verifier $VERIFIER"
fi
fi
echo "Verification is enabled"
echo "Verification: enabled"
else
echo "Verification: disabled"
fi

# Report if SAVE is enabled
if [ "$SAVE" = "true" ]; then
echo "Save deployment: enabled"
else
echo "Verification is disabled"
echo "Save deployment: disabled"
fi

# Set RESUME_FLAG based on RESUME
RESUME_FLAG=""
if [ "$RESUME" = "true" ] || [ "$RESUME" = "TRUE" ]; then
RESUME_FLAG="--resume"
echo "Resuming is enabled"
echo "Resume: enabled"
else
echo "Resuming is disabled"
echo "Resume: disabled"
fi

# Deploy using script
forge script $DEPLOY_SCRIPT:$DEPLOY_CONTRACT --sig "deploy(string,string,bool)()" $CHAIN $DEPLOY_FILE $BROADCAST \
forge script $DEPLOY_SCRIPT:$DEPLOY_CONTRACT --sig "deploy(string,string,bool)()" $CHAIN $DEPLOY_FILE $SAVE \
--rpc-url $RPC_URL --private-key $DEPLOYER_PRIVATE_KEY --froms $DEPLOYER_ADDRESS --slow -vvv \
$BROADCAST_FLAG \
$VERIFY_FLAG \
Expand Down
34 changes: 17 additions & 17 deletions script/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x0000000000000000000000000000000000000000",
"router": "0x0000000000000000000000000000000000000000"
"factory": "0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9",
"router": "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24"
},
"uniswapV3": {
"factory": "0x0000000000000000000000000000000000000000"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
}
},
"arbitrum-sepolia": {
Expand All @@ -53,14 +53,14 @@
"PROTOCOL": "0xB47C8e4bEb28af80eDe5E5bF474927b110Ef2c0e"
},
"gUni": {
"factory": "0x39AC4439e6CB9427C073259e5742529cE46DD663"
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x6c4f747ba42136f3F12E70c975AbBc194CBD39E4",
"router": "0x909F26919989167d051312fBB0a1Df4CD93Bf70b"
},
"uniswapV3": {
"factory": "0x2dCC5a88A861FB73613153F82CF801cd09E72a5F"
"factory": "0x248AB79Bbb9bC29bB72f7Cd42F17e054Fc40188e"
}
},
"base-sepolia": {
Expand All @@ -87,7 +87,7 @@
"PROTOCOL": "0xB47C8e4bEb28af80eDe5E5bF474927b110Ef2c0e"
},
"gUni": {
"factory": "0x04974BcFC715c148818724d9Caab3Fe8d0391b8b"
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x5D7ddDFee9fB5709Ccdea49Acd51db3d73BC75Fa",
Expand Down Expand Up @@ -124,11 +124,11 @@
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x0000000000000000000000000000000000000000",
"router": "0x0000000000000000000000000000000000000000"
"factory": "0x5C346464d33F90bABaf70dB6388507CC889C1070",
"router": "0xBB66Eb1c5e875933D44DAe661dbD80e5D9B03035"
},
"uniswapV3": {
"factory": "0x0000000000000000000000000000000000000000"
"factory": "0x792edAdE80af5fC680d96a2eD80A44247D2Cf6Fd"
}
},
"blast-sepolia": {
Expand Down Expand Up @@ -160,7 +160,7 @@
"weth": "0x4200000000000000000000000000000000000023"
},
"gUni": {
"factory": "0xED28E5230E934cf9C843C08818D0639176040297"
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x9371C6e657681923708CA6F621DE5e93E5d46F7e",
Expand Down Expand Up @@ -192,11 +192,11 @@
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x0000000000000000000000000000000000000000",
"router": "0x0000000000000000000000000000000000000000"
"factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
"router": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
},
"uniswapV3": {
"factory": "0x0000000000000000000000000000000000000000"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
}
},
"mode-sepolia": {
Expand All @@ -223,7 +223,7 @@
"PROTOCOL": "0xB47C8e4bEb28af80eDe5E5bF474927b110Ef2c0e"
},
"gUni": {
"factory": "0x2dCC5a88A861FB73613153F82CF801cd09E72a5F"
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x85c0A59A492C084d84eDcD7a8b785eaF620a9B0d",
Expand Down Expand Up @@ -255,11 +255,11 @@
"factory": "0x0000000000000000000000000000000000000000"
},
"uniswapV2": {
"factory": "0x0000000000000000000000000000000000000000",
"router": "0x0000000000000000000000000000000000000000"
"factory": "0xB7f907f7A9eBC822a80BD25E224be42Ce0A698A0",
"router": "0x425141165d3DE9FEC831896C016617a52363b687"
},
"uniswapV3": {
"factory": "0x0000000000000000000000000000000000000000"
"factory": "0x0227628f3F023bb0B980b67D528571c95c6DaC1c"
}
},
"tests": {
Expand Down
16 changes: 16 additions & 0 deletions script/ops/test/FixedPriceBatch-BaseDTL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FixedPriceBatch - Uniswap DTL Testing

## How to Test

1. Create a virtual testnet on Tenderly
2. Store the environment variables in an environment file
3. Deploy the Axis stack
4. Create the auction
- You will need to provide the quote token, base token

## To Settle an Auction

Assumes you are using a Tenderly Virtual Testnet

1. Warp to the timestamp after the auction conclusion using the warp script
2. Run the settle auction script
Loading

0 comments on commit c318459

Please sign in to comment.