Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[asset-swapper] Fix getBatchMarketBuyOrdersAsync (#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz authored Mar 30, 2020
1 parent bf00e67 commit 7ca4aa0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
{
"note": "Fix quote optimizer bug not properly accounting for fees.",
"pr": 2526
},
{
"note": "Fix `getBatchMarketBuyOrdersAsync` throwing NO_OPTIMAL_PATH",
"pr": 2533
}
]
},
Expand Down
36 changes: 21 additions & 15 deletions packages/asset-swapper/src/utils/market_operation_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,27 @@ export class MarketOperationUtils {
const ethToTakerAssetRate = batchEthToTakerAssetRate[i];
const dexQuotes = batchDexQuotes[i];
const makerAmount = makerAmounts[i];
return this._generateOptimizedOrders({
orderFillableAmounts,
nativeOrders,
dexQuotes,
inputToken: makerToken,
outputToken: takerToken,
side: MarketOperation.Buy,
inputAmount: makerAmount,
ethToOutputRate: ethToTakerAssetRate,
bridgeSlippage: _opts.bridgeSlippage,
maxFallbackSlippage: _opts.maxFallbackSlippage,
excludedSources: _opts.excludedSources,
feeSchedule: _opts.feeSchedule,
allowFallback: _opts.allowFallback,
});
try {
return this._generateOptimizedOrders({
orderFillableAmounts,
nativeOrders,
dexQuotes,
inputToken: makerToken,
outputToken: takerToken,
side: MarketOperation.Buy,
inputAmount: makerAmount,
ethToOutputRate: ethToTakerAssetRate,
bridgeSlippage: _opts.bridgeSlippage,
maxFallbackSlippage: _opts.maxFallbackSlippage,
excludedSources: _opts.excludedSources,
feeSchedule: _opts.feeSchedule,
allowFallback: _opts.allowFallback,
});
} catch (e) {
// It's possible for one of the pairs to have no path
// rather than throw NO_OPTIMAL_PATH we return undefined
return undefined;
}
});
}

Expand Down

0 comments on commit 7ca4aa0

Please sign in to comment.