From 9de0434836c27705165d48c085bb55d0fdf01503 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:12:50 +0200 Subject: [PATCH] feat: FBRv2 deploy, configure scripts --- script/configs/Create2Factory.salts.json | 5 ++++ script/rfq-run.sh | 26 +++++++++++++++++++ ....sol => ConfigureFastBridgeRouterV2.s.sol} | 24 ++++++++--------- script/rfq/DeployFastBridgeRouterV2.s.sol | 20 ++++++++++++++ 4 files changed, 62 insertions(+), 13 deletions(-) create mode 100755 script/rfq-run.sh rename script/rfq/{ConfigureFastBridgeRouter.t.sol => ConfigureFastBridgeRouterV2.s.sol} (61%) create mode 100644 script/rfq/DeployFastBridgeRouterV2.s.sol diff --git a/script/configs/Create2Factory.salts.json b/script/configs/Create2Factory.salts.json index 6a67b0080..b0a579f5b 100644 --- a/script/configs/Create2Factory.salts.json +++ b/script/configs/Create2Factory.salts.json @@ -9,6 +9,11 @@ "predictedAddress": "0x0000000000489d89D2B233D3375C045dfD05745F", "salt": "0x0000000000000000000000000000000000000000a887a859fa44720198162f0e" }, + "FastBridgeRouterV2": { + "initCodeHash": "0xa51b9e280aa2f3031dee11ee332b050e56252928afbbead89d5b3c2e5c1750ef", + "predictedAddress": "0xd50042193Db100FE0040005e00D5010000007e45", + "salt": "0x00000000000000000000000000000000000000006137d2b1087774010a8fadb4" + }, "SynapseRouter": { "initCodeHash": "0x4e3652671a68c0263a6844cbfabcab93d1a951bdc4b7983183b99f74308383e0", "predictedAddress": "0x0000000000365b1d5B142732CF4d33BcddED21Fc", diff --git a/script/rfq-run.sh b/script/rfq-run.sh new file mode 100755 index 000000000..0af50e48b --- /dev/null +++ b/script/rfq-run.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# This script runs an RFQ script for all chains with FastBridge deployment +# Usage: ./script/rfq-run.sh pathToScript +# - ./script/run.sh pathToScript chain will be run for all RFQ chains + +# Colors +RED="\033[0;31m" +NC="\033[0m" # No Color + +scriptFN=$1 +# Get the rest of the args +shift 1 +# Check that all required args exist +if [ -z "$scriptFN" ]; then + echo -e "${RED}Usage: ./script/rfq-run.sh pathToScript ${NC}" + exit 1 +fi + +# Find all FastBridge.json files in ./deployments +fastBridgeDeployments=$(find ./deployments -name FastBridge.json) +# Extract chain name from the list of filenames, sort alphabetically +chainNames=$(echo "$fastBridgeDeployments" | sed 's/.*\/\(.*\)\/FastBridge.json/\1/' | sort) + +for chainName in $chainNames; do + ./script/run.sh "$scriptFN" "$chainName" "$@" +done diff --git a/script/rfq/ConfigureFastBridgeRouter.t.sol b/script/rfq/ConfigureFastBridgeRouterV2.s.sol similarity index 61% rename from script/rfq/ConfigureFastBridgeRouter.t.sol rename to script/rfq/ConfigureFastBridgeRouterV2.s.sol index 75347e8d8..e20d1b1d5 100644 --- a/script/rfq/ConfigureFastBridgeRouter.t.sol +++ b/script/rfq/ConfigureFastBridgeRouterV2.s.sol @@ -1,40 +1,38 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.17; -import {FastBridgeRouter} from "../../contracts/rfq/FastBridgeRouter.sol"; +import {FastBridgeRouterV2} from "../../contracts/rfq/FastBridgeRouterV2.sol"; import {console2, BasicSynapseScript} from "../templates/BasicSynapse.s.sol"; -contract ConfigureFastBridgeRouter is BasicSynapseScript { - string public constant FAST_BRIDGE_ROUTER = "FastBridgeRouter"; - - FastBridgeRouter public fastBridgeRouter; +contract ConfigureFastBridgeRouterV2 is BasicSynapseScript { + FastBridgeRouterV2 public router; function setUp() internal override { super.setUp(); - address payable routerDeployment = payable(getDeploymentAddress(FAST_BRIDGE_ROUTER)); - fastBridgeRouter = FastBridgeRouter(routerDeployment); + address payable routerDeployment = payable(getDeploymentAddress("FastBridgeRouterV2")); + router = FastBridgeRouterV2(routerDeployment); } function run() external { // Setup the BasicSynapseScript setUp(); vm.startBroadcast(); - configureFastBridgeRouter(); + configureFastBridgeRouterV2(); vm.stopBroadcast(); } - function configureFastBridgeRouter() internal { + function configureFastBridgeRouterV2() internal { address fastBridge = getDeploymentAddress("FastBridge"); - if (fastBridgeRouter.fastBridge() != fastBridge) { - fastBridgeRouter.setFastBridge(fastBridge); + if (router.fastBridge() != fastBridge) { + router.setFastBridge(fastBridge); printLog(string.concat(unicode"✅ Fast bridge set to ", vm.toString(fastBridge))); } else { printLog(string.concat(unicode"🟡 Skipping: Fast bridge is already set to ", vm.toString(fastBridge))); } address swapQuoter = getDeploymentAddress("SwapQuoterV2"); - if (fastBridgeRouter.swapQuoter() != swapQuoter) { - fastBridgeRouter.setSwapQuoter(swapQuoter); + if (router.swapQuoter() != swapQuoter) { + router.setSwapQuoter(swapQuoter); printLog(string.concat(unicode"✅ SwapQuoter set to ", vm.toString(swapQuoter))); } else { printLog(string.concat(unicode"🟡 Skipping: SwapQuoter is already set to ", vm.toString(swapQuoter))); diff --git a/script/rfq/DeployFastBridgeRouterV2.s.sol b/script/rfq/DeployFastBridgeRouterV2.s.sol new file mode 100644 index 000000000..201d8af1a --- /dev/null +++ b/script/rfq/DeployFastBridgeRouterV2.s.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {BasicSynapseScript} from "../templates/BasicSynapse.s.sol"; + +contract DeployFastBridgeRouter is BasicSynapseScript { + function run() external { + // Setup the BasicSynapseScript + setUp(); + vm.startBroadcast(); + // Use `deployCreate2` as callback to deploy the contract with CREATE2 + // This will load deployment salt from the pre-saved list, if there's an entry for the contract + deployAndSave({ + contractName: "FastBridgeRouterV2", + constructorArgs: abi.encode(msg.sender), + deployCode: deployCreate2 + }); + vm.stopBroadcast(); + } +}