Skip to content

Commit

Permalink
feat: FBRv2 deploy, configure scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Jul 29, 2024
1 parent 112873d commit 9de0434
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
5 changes: 5 additions & 0 deletions script/configs/Create2Factory.salts.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"predictedAddress": "0x0000000000489d89D2B233D3375C045dfD05745F",
"salt": "0x0000000000000000000000000000000000000000a887a859fa44720198162f0e"
},
"FastBridgeRouterV2": {
"initCodeHash": "0xa51b9e280aa2f3031dee11ee332b050e56252928afbbead89d5b3c2e5c1750ef",
"predictedAddress": "0xd50042193Db100FE0040005e00D5010000007e45",
"salt": "0x00000000000000000000000000000000000000006137d2b1087774010a8fadb4"
},
"SynapseRouter": {
"initCodeHash": "0x4e3652671a68c0263a6844cbfabcab93d1a951bdc4b7983183b99f74308383e0",
"predictedAddress": "0x0000000000365b1d5B142732CF4d33BcddED21Fc",
Expand Down
26 changes: 26 additions & 0 deletions script/rfq-run.sh
Original file line number Diff line number Diff line change
@@ -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 <args...>
# - ./script/run.sh pathToScript chain <args...> 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 <args...>${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
Original file line number Diff line number Diff line change
@@ -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)));
Expand Down
20 changes: 20 additions & 0 deletions script/rfq/DeployFastBridgeRouterV2.s.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 9de0434

Please sign in to comment.