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

Commit

Permalink
[asset-swapper] prune before dummy order creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Feb 5, 2020
1 parent f9c9b9f commit 3020266
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
1 change: 1 addition & 0 deletions packages/asset-swapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
15 changes: 7 additions & 8 deletions packages/asset-swapper/src/swap_quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -259,13 +264,7 @@ export class SwapQuoter {
),
];
} else {
return sortingUtils.sortOrders(
orderPrunerUtils.pruneForUsableSignedOrders(
orders,
this.permittedOrderFeeTypes,
this.expiryBufferMs,
),
);
return sortingUtils.sortOrders(prunedOrders);
}
});

Expand Down

0 comments on commit 3020266

Please sign in to comment.