diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index 3def916b4c..16aa584d17 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "5.8.2", + "changes": [ + { + "note": "Fix error when Multihop data is not present", + "pr": 80 + } + ] + }, { "timestamp": 1611648096, "version": "5.8.1", diff --git a/packages/asset-swapper/src/utils/market_operation_utils/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/index.ts index dd09dda91a..1329ad9b7a 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/index.ts @@ -204,12 +204,15 @@ export class MarketOperationUtils { : Promise.resolve([]); const [ - [tokenDecimals, orderFillableAmounts, ethToMakerAssetRate, ethToTakerAssetRate, dexQuotes, twoHopQuotes], + [tokenDecimals, orderFillableAmounts, ethToMakerAssetRate, ethToTakerAssetRate, dexQuotes, rawTwoHopQuotes], rfqtIndicativeQuotes, offChainBalancerQuotes, offChainCreamQuotes, ] = await Promise.all([samplerPromise, rfqtPromise, offChainBalancerPromise, offChainCreamPromise]); + // Filter out any invalid two hop quotes where we couldn't find a route + const twoHopQuotes = rawTwoHopQuotes.filter(q => q && q.fillData && q.fillData.firstHopSource); + const [makerTokenDecimals, takerTokenDecimals] = tokenDecimals; return { side: MarketOperation.Sell, @@ -321,11 +324,15 @@ export class MarketOperationUtils { : Promise.resolve([]); const [ - [tokenDecimals, orderFillableAmounts, ethToMakerAssetRate, ethToTakerAssetRate, dexQuotes, twoHopQuotes], + [tokenDecimals, orderFillableAmounts, ethToMakerAssetRate, ethToTakerAssetRate, dexQuotes, rawTwoHopQuotes], rfqtIndicativeQuotes, offChainBalancerQuotes, offChainCreamQuotes, ] = await Promise.all([samplerPromise, rfqtPromise, offChainBalancerPromise, offChainCreamPromise]); + + // Filter out any invalid two hop quotes where we couldn't find a route + const twoHopQuotes = rawTwoHopQuotes.filter(q => q && q.fillData && q.fillData.firstHopSource); + const [makerTokenDecimals, takerTokenDecimals] = tokenDecimals; return { side: MarketOperation.Buy, diff --git a/packages/asset-swapper/src/utils/quote_report_generator.ts b/packages/asset-swapper/src/utils/quote_report_generator.ts index 8a845bec39..088b941286 100644 --- a/packages/asset-swapper/src/utils/quote_report_generator.ts +++ b/packages/asset-swapper/src/utils/quote_report_generator.ts @@ -1,6 +1,5 @@ import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; -import * as _ from 'lodash'; import { MarketOperation } from '../types';