From 0e196a59d953bafa21cf9f85609be5678ca85193 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Thu, 9 Apr 2020 15:52:15 +1000 Subject: [PATCH] Always use DFB in asset-swapper (#2542) * Always use DFB in asset-swapper * Clean up --- .../src/utils/market_operation_utils/orders.ts | 3 ++- packages/asset-swapper/test/market_operation_utils_test.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/asset-swapper/src/utils/market_operation_utils/orders.ts b/packages/asset-swapper/src/utils/market_operation_utils/orders.ts index 30c2f16d8c..018055f5fc 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/orders.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/orders.ts @@ -169,7 +169,8 @@ export function createOrdersFromPath(path: Fill[], opts: CreateOrderFromPathOpts } contiguousBridgeFills.push(collapsedPath[j]); } - if (contiguousBridgeFills.length === 1 || !opts.shouldBatchBridgeOrders) { + // Always use DexForwarderBridge unless configured not to + if (!opts.shouldBatchBridgeOrders) { orders.push(createBridgeOrder(contiguousBridgeFills[0], opts)); i += 1; } else { diff --git a/packages/asset-swapper/test/market_operation_utils_test.ts b/packages/asset-swapper/test/market_operation_utils_test.ts index 05635af16c..1809363c24 100644 --- a/packages/asset-swapper/test/market_operation_utils_test.ts +++ b/packages/asset-swapper/test/market_operation_utils_test.ts @@ -69,7 +69,11 @@ describe('MarketOperationUtils tests', () => { if (assetData.length === 74) { return ERC20BridgeSource.Native; } - const bridgeAddress = hexUtils.slice(assetData, 48, 68).toLowerCase(); + const bridgeData = assetDataUtils.decodeAssetDataOrThrow(assetData); + if (!assetDataUtils.isERC20BridgeAssetData(bridgeData)) { + throw new Error('AssetData is not ERC20BridgeAssetData'); + } + const { bridgeAddress } = bridgeData; switch (bridgeAddress) { case KYBER_BRIDGE_ADDRESS.toLowerCase(): return ERC20BridgeSource.Kyber;