fix: [asset-swapper] prevent error when multihop data is not present (#80)

* fix: [asset-swapper] prevent error when multihop is not present for a route

* Update changelog

Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
This commit is contained in:
Jacob Evans 2021-01-29 07:04:32 +10:00 committed by GitHub
parent e544a804c2
commit d6bc0a3368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -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",

View File

@ -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,

View File

@ -1,6 +1,5 @@
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { MarketOperation } from '../types';