diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-09-14 19:42:37 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-09-15 20:14:48 +0800 |
commit | 90674d9038b45644e82545558d9937b9eec498f9 (patch) | |
tree | 958330831f61442dcf934e5898470d7d92f513fd /packages/forwarder-helper/src/forwarder_helper_factory.ts | |
parent | c0a14a4a4110f3fedea6624376eae4c86c02cda8 (diff) | |
download | dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar.gz dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar.bz2 dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar.lz dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar.xz dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.tar.zst dexon-sol-tools-90674d9038b45644e82545558d9937b9eec498f9.zip |
Various clean up
Diffstat (limited to 'packages/forwarder-helper/src/forwarder_helper_factory.ts')
-rw-r--r-- | packages/forwarder-helper/src/forwarder_helper_factory.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index be38f2bd5..2b37ac98f 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -24,6 +24,7 @@ export const forwarderHelperFactory = { getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); + // TODO: Add assertion here for orders all having the same makerAsset and takerAsset const config: ForwarderHelperImplConfig = { orders, feeOrders, @@ -96,6 +97,7 @@ export const forwarderHelperFactory = { const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); // TODO: try catch these requests and throw a more domain specific error + // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); @@ -159,7 +161,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( ): OrdersAndRemainingFillableMakerAssetAmounts { const result = _.reduce( apiOrders, - (acc, apiOrder, index) => { + (acc, apiOrder) => { // get current accumulations const { orders, remainingFillableMakerAssetAmounts } = acc; // get order and metadata @@ -168,7 +170,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { return acc; } - // calculate remainingFillableMakerAssetAmount from api metadata + // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable const remainingFillableTakerAssetAmount = _.get( metaData, 'remainingTakerAssetAmount', @@ -215,7 +217,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( const { orders, remainingFillableMakerAssetAmounts } = acc; // get corresponding on-chain state for the order const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; - // if the order IS NOT fillable, do not add anything and continue iterating + // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { return acc; } |