Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch dexes split #25

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions packages/sushi/src/router/data-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**/
}
Expand Down
14 changes: 7 additions & 7 deletions packages/sushi/src/tines/MultiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading