Skip to content

Commit e71e6c0

Browse files
committed
evm: on-chain quoter deploy scripts
1 parent 02a6b3f commit e71e6c0

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.19;
3+
4+
import {ExecutorQuoter, executorQuoterVersion} from "../src/ExecutorQuoter.sol";
5+
import "forge-std/Script.sol";
6+
7+
// DeployExecutorQuoter is a forge script to deploy the ExecutorQuoter contract. Use ./sh/deployExecutorQuoter.sh to invoke this.
8+
// e.g. anvil
9+
// EVM_CHAIN_ID=31337 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoter.sh
10+
// e.g. anvil --fork-url https://ethereum-rpc.publicnode.com
11+
// EVM_CHAIN_ID=1 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoter.sh
12+
contract DeployExecutorQuoter is Script {
13+
function test() public {} // Exclude this from coverage report.
14+
15+
function dryRun(address quoterAddress, address updaterAddress, uint8 srcTokenDecimals, bytes32 payeeAddress)
16+
public
17+
{
18+
_deploy(quoterAddress, updaterAddress, srcTokenDecimals, payeeAddress);
19+
}
20+
21+
function run(address quoterAddress, address updaterAddress, uint8 srcTokenDecimals, bytes32 payeeAddress)
22+
public
23+
returns (address deployedAddress)
24+
{
25+
vm.startBroadcast();
26+
(deployedAddress) = _deploy(quoterAddress, updaterAddress, srcTokenDecimals, payeeAddress);
27+
vm.stopBroadcast();
28+
}
29+
30+
function _deploy(address quoterAddress, address updaterAddress, uint8 srcTokenDecimals, bytes32 payeeAddress)
31+
internal
32+
returns (address deployedAddress)
33+
{
34+
bytes32 salt = keccak256(abi.encodePacked(executorQuoterVersion));
35+
ExecutorQuoter executorQuoter =
36+
new ExecutorQuoter{salt: salt}(quoterAddress, updaterAddress, srcTokenDecimals, payeeAddress);
37+
38+
return (address(executorQuoter));
39+
}
40+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.19;
3+
4+
import {ExecutorQuoterRouter, executorQuoterRouterVersion} from "../src/ExecutorQuoterRouter.sol";
5+
import "forge-std/Script.sol";
6+
7+
// DeployExecutorQuoterRouter is a forge script to deploy the ExecutorQuoterRouter contract. Use ./sh/deployExecutorQuoterRouter.sh to invoke this.
8+
// e.g. anvil
9+
// EVM_CHAIN_ID=31337 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoterRouter.sh
10+
// e.g. anvil --fork-url https://ethereum-rpc.publicnode.com
11+
// EVM_CHAIN_ID=1 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoterRouter.sh
12+
contract DeployExecutorQuoterRouter is Script {
13+
function test() public {} // Exclude this from coverage report.
14+
15+
function dryRun(address executor) public {
16+
_deploy(executor);
17+
}
18+
19+
function run(address executor) public returns (address deployedAddress) {
20+
vm.startBroadcast();
21+
(deployedAddress) = _deploy(executor);
22+
vm.stopBroadcast();
23+
}
24+
25+
function _deploy(address executor) internal returns (address deployedAddress) {
26+
bytes32 salt = keccak256(abi.encodePacked(executorQuoterRouterVersion));
27+
ExecutorQuoterRouter executorQuoterRouter = new ExecutorQuoterRouter{salt: salt}(executor);
28+
29+
return (address(executorQuoterRouter));
30+
}
31+
}

evm/sh/deployExecutorQuoter.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
#
4+
# This script deploys the Executor contract.
5+
# Usage: RPC_URL= MNEMONIC= QUOTER= UPDATER= SRC_DECIMALS= PAYEE_ADDRESS= EVM_CHAIN_ID= ./sh/deployExecutorQuoter.sh
6+
# anvil: EVM_CHAIN_ID=31337 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoter.sh
7+
8+
if [ "${RPC_URL}X" == "X" ]; then
9+
RPC_URL=http://localhost:8545
10+
fi
11+
12+
if [ "${MNEMONIC}X" == "X" ]; then
13+
MNEMONIC=0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d
14+
fi
15+
16+
if [ "${EVM_CHAIN_ID}X" == "X" ]; then
17+
EVM_CHAIN_ID=1337
18+
fi
19+
20+
if [ -n "${CREATE2_ADDRESS}" ]; then
21+
CREATE2_FLAG="--create2-deployer ${CREATE2_ADDRESS}"
22+
echo "Using custom CREATE2 deployer at: ${CREATE2_ADDRESS}"
23+
else
24+
CREATE2_FLAG=""
25+
echo "Using default CREATE2 deployer"
26+
fi
27+
28+
forge script ./script/DeployExecutorQuoter.s.sol:DeployExecutorQuoter \
29+
--sig "run(address, address, uint8, bytes32)" $QUOTER $UPDATER $SRC_DECIMALS $PAYEE_ADDRESS \
30+
--rpc-url "$RPC_URL" \
31+
--private-key "$MNEMONIC" \
32+
$CREATE2_FLAG \
33+
--broadcast ${FORGE_ARGS}
34+
35+
returnInfo=$(cat ./broadcast/DeployExecutorQuoter.s.sol/$EVM_CHAIN_ID/run-latest.json)
36+
37+
DEPLOYED_ADDRESS=$(jq -r '.returns.deployedAddress.value' <<< "$returnInfo")
38+
echo "Deployed ExecutorQuoter address: $DEPLOYED_ADDRESS"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
#
4+
# This script deploys the Executor contract.
5+
# Usage: RPC_URL= MNEMONIC= EXECUTOR= EVM_CHAIN_ID= ./sh/deployExecutorQuoterRouter.sh
6+
# anvil: EVM_CHAIN_ID=31337 MNEMONIC=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ./sh/deployExecutorQuoterRouter.sh
7+
8+
if [ "${RPC_URL}X" == "X" ]; then
9+
RPC_URL=http://localhost:8545
10+
fi
11+
12+
if [ "${MNEMONIC}X" == "X" ]; then
13+
MNEMONIC=0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d
14+
fi
15+
16+
if [ "${EVM_CHAIN_ID}X" == "X" ]; then
17+
EVM_CHAIN_ID=1337
18+
fi
19+
20+
if [ -n "${CREATE2_ADDRESS}" ]; then
21+
CREATE2_FLAG="--create2-deployer ${CREATE2_ADDRESS}"
22+
echo "Using custom CREATE2 deployer at: ${CREATE2_ADDRESS}"
23+
else
24+
CREATE2_FLAG=""
25+
echo "Using default CREATE2 deployer"
26+
fi
27+
28+
forge script ./script/DeployExecutorQuoterRouter.s.sol:DeployExecutorQuoterRouter \
29+
--sig "run(address)" $EXECUTOR \
30+
--rpc-url "$RPC_URL" \
31+
--private-key "$MNEMONIC" \
32+
$CREATE2_FLAG \
33+
--broadcast ${FORGE_ARGS}
34+
35+
returnInfo=$(cat ./broadcast/DeployExecutorQuoterRouter.s.sol/$EVM_CHAIN_ID/run-latest.json)
36+
37+
DEPLOYED_ADDRESS=$(jq -r '.returns.deployedAddress.value' <<< "$returnInfo")
38+
echo "Deployed ExecutorQuoterRouter address: $DEPLOYED_ADDRESS"

0 commit comments

Comments
 (0)