Skip to content

Commit 9d135a7

Browse files
committed
fix 0 unit quote issue in binary search
1 parent cfbfbfa commit 9d135a7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/swapService/strategies/strategyBalmySDK.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,10 @@ export class StrategyBalmySDK {
304304
(currentAmountTo * 1000n) / overSwapTarget > 1005n
305305

306306
// single run to preselect sources
307-
const initialQuotes = (
308-
await Promise.all(
309-
unitQuotes.map((unitQuote) => {
307+
const initialQuotesSettled = await Promise.allSettled(
308+
unitQuotes
309+
.filter((unitQuote) => unitQuote.minBuyAmount.amount !== 0n)
310+
.map((unitQuote) => {
310311
const estimatedAmountIn = calculateEstimatedAmountFrom(
311312
unitQuote.minBuyAmount.amount,
312313
swapParamsExactIn.amount,
@@ -323,8 +324,10 @@ export class StrategyBalmySDK {
323324
},
324325
)
325326
}),
326-
)
327-
).flat()
327+
)
328+
const initialQuotes = initialQuotesSettled
329+
.filter((q) => q.status === "fulfilled")
330+
.flatMap((q) => q.value)
328331

329332
const allSettled = await Promise.allSettled(
330333
initialQuotes.map(async (initialQuote) =>

0 commit comments

Comments
 (0)