From 1fba5a128d32b0c62ac5beaca9f185d1f9455f0c Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:12:50 +0100 Subject: [PATCH] Adjust QuoterV2 script to deploy w/o SynapseRouter --- script/router/BasicRouter.s.sol | 11 +++++++++++ script/router/quoter/DeployQuoterV2.s.sol | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/script/router/BasicRouter.s.sol b/script/router/BasicRouter.s.sol index caed81046..4eafbc369 100644 --- a/script/router/BasicRouter.s.sol +++ b/script/router/BasicRouter.s.sol @@ -22,4 +22,15 @@ abstract contract BasicRouterScript is BasicSynapseScript { synapseRouter = getDeploymentAddress(ROUTER_V1); } } + + /// @notice Returns deployment of the latest SynapseRouter contract on the active chain, if available. + /// Otherwise, returns address(0). + function tryGetLatestRouterDeployment() internal returns (address synapseRouter) { + // Check if SynapseRouterV2 is deployed + synapseRouter = tryGetDeploymentAddress(ROUTER_V2); + // Use SynapseRouter if SynapseRouterV2 is not deployed + if (synapseRouter == address(0)) { + synapseRouter = tryGetDeploymentAddress(ROUTER_V1); + } + } } diff --git a/script/router/quoter/DeployQuoterV2.s.sol b/script/router/quoter/DeployQuoterV2.s.sol index c6e8e1fa4..d4e1b39d3 100644 --- a/script/router/quoter/DeployQuoterV2.s.sol +++ b/script/router/quoter/DeployQuoterV2.s.sol @@ -23,7 +23,7 @@ contract DeployQuoterV2 is BasicRouterScript { /// Must follow this signature for the deploy script to work: /// `deployContract() internal returns (address deployedAt, bytes memory constructorArgs)` function deployQuoterV2() internal returns (address deployedAt, bytes memory constructorArgs) { - address synapseRouter = getLatestRouterDeployment(); + address synapseRouter = tryGetLatestRouterDeployment(); address defaultPoolCalc = getDeploymentAddress(DEFAULT_POOL_CALC); // We need specifically WGAS, so that on BNB chain we use WBNB address weth = getDeploymentAddress("WGAS");