aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/forwarder-helper/src/forwarder_helper_factory.ts6
-rw-r--r--packages/forwarder-helper/src/forwarder_helper_impl.ts3
2 files changed, 9 insertions, 0 deletions
diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts
index f08e3ff04..0fb02e3a6 100644
--- a/packages/forwarder-helper/src/forwarder_helper_factory.ts
+++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts
@@ -4,6 +4,12 @@ import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_help
import { ForwarderHelper } from './types';
export const forwarderHelperFactory = {
+ /**
+ * Given an array of orders and an array of feeOrders
+ * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData
+ * @param orders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData
+ * @return A ForwarderHelper, see type for definition
+ */
getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper {
const config: ForwarderHelperImplConfig = {
orders,
diff --git a/packages/forwarder-helper/src/forwarder_helper_impl.ts b/packages/forwarder-helper/src/forwarder_helper_impl.ts
index 123c925f1..f21fab9fd 100644
--- a/packages/forwarder-helper/src/forwarder_helper_impl.ts
+++ b/packages/forwarder-helper/src/forwarder_helper_impl.ts
@@ -52,15 +52,18 @@ export class ForwarderHelperImpl implements ForwarderHelper {
}
private static _sortConfig(opts: ForwarderHelperImplConfig): ForwarderHelperImplConfig {
const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = opts;
+ // Bundle orders together with their remainingFillAmounts so that we can sort them together
const orderWithAmounts = ForwarderHelperImpl._createSignedOrderWithAmounts(
orders,
remainingFillableMakerAssetAmounts,
);
// TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens
const sortedOrderWithAmounts = sortingUtils.sortOrdersByFeeAdjustedRate(orderWithAmounts);
+ // Unbundle after sorting
const unbundledSortedOrderWithAmounts = ForwarderHelperImpl._unbundleSignedOrderWithAmounts(
sortedOrderWithAmounts,
);
+ // Do the same bundling + unbundling for feeOrder sorting
const feeOrderWithAmounts = ForwarderHelperImpl._createSignedOrderWithAmounts(
feeOrders,
remainingFillableFeeAmounts,