From 3020266862cf2e2c0f70745589b0a101ace4a44b Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Wed, 5 Feb 2020 14:42:28 +1000 Subject: [PATCH] [asset-swapper] prune before dummy order creation --- packages/asset-swapper/CHANGELOG.json | 8 ++++++++ packages/asset-swapper/package.json | 1 + packages/asset-swapper/src/swap_quoter.ts | 15 +++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index e36f11b51d..b0281d6ac0 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "4.1.1", + "changes": [ + { + "note": "Prune orders before creating a dummy order for the Sampler" + } + ] + }, { "version": "4.1.0", "changes": [ diff --git a/packages/asset-swapper/package.json b/packages/asset-swapper/package.json index c6e874a71c..d79a6b8780 100644 --- a/packages/asset-swapper/package.json +++ b/packages/asset-swapper/package.json @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn tsc -b", + "watch": "tsc -w -p tsconfig.json", "build:ci": "yarn build", "lint": "tslint --format stylish --project .", "fix": "tslint --fix --format stylish --project .", diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index 579744b5aa..64316c4b9d 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -250,7 +250,12 @@ export class SwapQuoter { const apiOrders = await this.orderbook.getBatchOrdersAsync(makerAssetDatas, [takerAssetData]); const allOrders = apiOrders.map(orders => orders.map(o => o.order)); const allPrunedOrders = allOrders.map((orders, i) => { - if (orders.length === 0) { + const prunedOrders = orderPrunerUtils.pruneForUsableSignedOrders( + orders, + this.permittedOrderFeeTypes, + this.expiryBufferMs, + ); + if (prunedOrders.length === 0) { return [ dummyOrderUtils.createDummyOrderForSampler( makerAssetDatas[i], @@ -259,13 +264,7 @@ export class SwapQuoter { ), ]; } else { - return sortingUtils.sortOrders( - orderPrunerUtils.pruneForUsableSignedOrders( - orders, - this.permittedOrderFeeTypes, - this.expiryBufferMs, - ), - ); + return sortingUtils.sortOrders(prunedOrders); } });