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");