Skip to content

Commit

Permalink
parallelize v2 and v3 get candidate pools in mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Aug 21, 2023
1 parent d5f1dfb commit eb57fe9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/routers/alpha-router/functions/get-candidate-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,11 @@ export async function getMixedRouteCandidatePools({
}> {
const beforeSubgraphPools = Date.now();
const { blockNumber, debugRouting } = routingConfig;
const { subgraphPools: V3subgraphPools, candidatePools: V3candidatePools } =
await getV3CandidatePools({
const [
{ subgraphPools: V3subgraphPools, candidatePools: V3candidatePools},
{ subgraphPools: V2subgraphPools, candidatePools: V2candidatePools}
] = await Promise.all([
getV3CandidatePools({
tokenIn,
tokenOut,
tokenProvider,
Expand All @@ -1013,9 +1016,8 @@ export async function getMixedRouteCandidatePools({
subgraphProvider: v3subgraphProvider,
routingConfig,
chainId,
});
const { subgraphPools: V2subgraphPools, candidatePools: V2candidatePools } =
await getV2CandidatePools({
}),
getV2CandidatePools({
tokenIn,
tokenOut,
tokenProvider,
Expand All @@ -1025,7 +1027,8 @@ export async function getMixedRouteCandidatePools({
subgraphProvider: v2subgraphProvider,
routingConfig,
chainId,
});
}),
])

metric.putMetric('MixedSubgraphPoolsLoad', Date.now() - beforeSubgraphPools, MetricLoggerUnit.Milliseconds);
const beforePoolsFiltered = Date.now();
Expand Down

0 comments on commit eb57fe9

Please sign in to comment.