diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-09-24 19:17:38 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-09-24 19:17:38 +0800 |
commit | e4b664bafa24c2ee788a343edecd0124f784780d (patch) | |
tree | 54cb57eeba44a7140c326cb17624b3839c6e73d3 /packages/asset-buyer/src/utils/order_provider_response_processor.ts | |
parent | 7a5376621f2c2503c6415802984b4d8ae05db723 (diff) | |
download | dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar.gz dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar.bz2 dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar.lz dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar.xz dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.tar.zst dexon-sol-tools-e4b664bafa24c2ee788a343edecd0124f784780d.zip |
Add expiry buffer
Diffstat (limited to 'packages/asset-buyer/src/utils/order_provider_response_processor.ts')
-rw-r--r-- | packages/asset-buyer/src/utils/order_provider_response_processor.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index 9e54300b3..31fdcc182 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -41,11 +41,18 @@ export const orderProviderResponseProcessor = { targetOrderProviderResponse: OrderProviderResponse, feeOrderProviderResponse: OrderProviderResponse, zrxTokenAssetData: string, + expiryBufferSeconds: number, orderValidator?: OrderValidatorWrapper, ): Promise<AssetBuyerOrdersAndFillableAmounts> { // drop orders that are expired or not open - const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(targetOrderProviderResponse.orders); - const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(feeOrderProviderResponse.orders); + const filteredTargetOrders = filterOutExpiredAndNonOpenOrders( + targetOrderProviderResponse.orders, + expiryBufferSeconds, + ); + const filteredFeeOrders = filterOutExpiredAndNonOpenOrders( + feeOrderProviderResponse.orders, + expiryBufferSeconds, + ); // set the orders to be sorted equal to the filtered orders let unsortedTargetOrders = filteredTargetOrders; let unsortedFeeOrders = filteredFeeOrders; @@ -98,9 +105,10 @@ export const orderProviderResponseProcessor = { */ function filterOutExpiredAndNonOpenOrders( orders: SignedOrderWithRemainingFillableMakerAssetAmount[], + expiryBufferSeconds: number, ): SignedOrderWithRemainingFillableMakerAssetAmount[] { const result = _.filter(orders, order => { - return orderUtils.isOpenOrder(order) && !orderUtils.isOrderExpired(order); + return orderUtils.isOpenOrder(order) && !orderUtils.willOrderExpire(order, expiryBufferSeconds); }); return result; } |