aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-23 05:45:44 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-23 06:39:03 +0800
commita5c7ddcff54fcb9e88adfda15167836b00db877d (patch)
treeff09cc722ce3823a497f95239b1e40612de5ca94
parent6cef847a2759864de64d79ea02368bd85039e5ad (diff)
downloaddexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar.gz
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar.bz2
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar.lz
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar.xz
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.tar.zst
dexon-sol-tools-a5c7ddcff54fcb9e88adfda15167836b00db877d.zip
Add more comments
-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,