diff --git a/packages/sushi/src/router/data-fetcher.ts b/packages/sushi/src/router/data-fetcher.ts index 5edf79faf7..0ff8a63aff 100644 --- a/packages/sushi/src/router/data-fetcher.ts +++ b/packages/sushi/src/router/data-fetcher.ts @@ -277,20 +277,23 @@ export class DataFetcher { ? [currency0.wrapped, currency1.wrapped] : [currency1.wrapped, currency0.wrapped] try { - options?.fetchPoolsTimeout - ? await promiseTimeout( - Promise.allSettled( - this.providers.map((p) => + const len = (this.providers.length / 3) > 1 ? 3 : (this.providers.length / 2) > 1 ? 2: this.providers.length + for (let i = 0; i < len; i++) { + options?.fetchPoolsTimeout + ? await promiseTimeout( + Promise.allSettled( + this.providers.slice(len * i, len * (i + 1)).map((p) => + p.fetchPoolsForToken(token0, token1, excludePools, options), + ), + ), + options.fetchPoolsTimeout, + ) + : await Promise.allSettled( + this.providers.slice(len * i, len * (i + 1)).map((p) => p.fetchPoolsForToken(token0, token1, excludePools, options), ), - ), - options.fetchPoolsTimeout, - ) - : await Promise.allSettled( - this.providers.map((p) => - p.fetchPoolsForToken(token0, token1, excludePools, options), - ), - ) + ) + } } catch { /**/ } diff --git a/packages/sushi/src/tines/MultiRouter.ts b/packages/sushi/src/tines/MultiRouter.ts index 7e7a756638..4372bb30bb 100644 --- a/packages/sushi/src/tines/MultiRouter.ts +++ b/packages/sushi/src/tines/MultiRouter.ts @@ -104,14 +104,14 @@ export function findMultiRouteExactIn( // if (g.findBestPathExactIn(from, to, amountIn/100 + 10_000, 0)?.gasSpent === 0) return outSingle g.cleanTmpData() - const bestFlowNumber = calcBestFlowNumber( - outSingle, - amountIn, - g.getVert(from)?.gasPrice, - ) - if (bestFlowNumber === 1) return outSingle + // const bestFlowNumber = calcBestFlowNumber( + // outSingle, + // amountIn, + // g.getVert(from)?.gasPrice, + // ) + // if (bestFlowNumber === 1) return outSingle - const outMulti = g.findBestRouteExactIn(from, to, amountIn, bestFlowNumber) + const outMulti = g.findBestRouteExactIn(from, to, amountIn, [2, 3, 4]) return getBetterRouteExactIn(outSingle, outMulti) } catch (_e) { return NoWayMultiRoute(from, to)