Skip to content

Commit

Permalink
Adjust QuoterV2 script to deploy w/o SynapseRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Apr 25, 2024
1 parent 0a24c2f commit 1fba5a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions script/router/BasicRouter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion script/router/quoter/DeployQuoterV2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1fba5a1

Please sign in to comment.