aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorF. Eugene Aumson <feuGeneA@users.noreply.github.com>2018-09-25 01:30:37 +0800
committerF. Eugene Aumson <feuGeneA@users.noreply.github.com>2018-09-25 01:30:37 +0800
commit2116548eed666c3c61277f17e996fee720301f31 (patch)
tree6f4b601b59659ac9134ffe4efed79c8a8a2750e0 /packages/order-utils
parent57fca16d7b1dc61c060c90fa440b1dc947aefb93 (diff)
parentb830c28d83a33c0170d4f150ee287ea97ccf7865 (diff)
downloaddexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.gz
dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.zst
dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.zip
Merge remote-tracking branch 'upstream/development' into sol-doc
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/CHANGELOG.json9
-rw-r--r--packages/order-utils/CHANGELOG.md4
-rw-r--r--packages/order-utils/package.json22
-rw-r--r--packages/order-utils/src/market_utils.ts39
-rw-r--r--packages/order-utils/src/types.ts2
5 files changed, 51 insertions, 25 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index d202d779c..5bf538c1f 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.2",
"changes": [
{
diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md
index 077f017db..e35867fa6 100644
--- a/packages/order-utils/CHANGELOG.md
+++ b/packages/order-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.3 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.2 - _September 19, 2018_
* Drastically reduce the bundle size by removing unused parts of included contract artifacts.
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index b3f93ff2e..c9620bffa 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-utils",
- "version": "1.0.2",
+ "version": "1.0.3",
"engines": {
"node": ">=6.12"
},
@@ -38,7 +38,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/dev-utils": "^1.0.8",
"@0xproject/tslint-config": "^1.0.7",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
@@ -57,16 +57,16 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "@types/node": "^8.0.53",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "@types/node": "*",
"bn.js": "^4.11.8",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts
index 4a664cb14..ed6af7d85 100644
--- a/packages/order-utils/src/market_utils.ts
+++ b/packages/order-utils/src/market_utils.ts
@@ -51,17 +51,23 @@ export const marketUtils = {
// iterate through the orders input from left to right until we have enough makerAsset to fill totalFillAmount
const result = _.reduce(
orders,
- ({ resultOrders, remainingFillAmount }, order, index) => {
+ ({ resultOrders, remainingFillAmount, ordersRemainingFillableMakerAssetAmounts }, order, index) => {
if (remainingFillAmount.lessThanOrEqualTo(constants.ZERO_AMOUNT)) {
- return { resultOrders, remainingFillAmount: constants.ZERO_AMOUNT };
+ return {
+ resultOrders,
+ remainingFillAmount: constants.ZERO_AMOUNT,
+ ordersRemainingFillableMakerAssetAmounts,
+ };
} else {
const makerAssetAmountAvailable = remainingFillableMakerAssetAmounts[index];
+ const shouldIncludeOrder = makerAssetAmountAvailable.gt(constants.ZERO_AMOUNT);
// if there is no makerAssetAmountAvailable do not append order to resultOrders
// if we have exceeded the total amount we want to fill set remainingFillAmount to 0
return {
- resultOrders: makerAssetAmountAvailable.gt(constants.ZERO_AMOUNT)
- ? _.concat(resultOrders, order)
- : resultOrders,
+ resultOrders: shouldIncludeOrder ? _.concat(resultOrders, order) : resultOrders,
+ ordersRemainingFillableMakerAssetAmounts: shouldIncludeOrder
+ ? _.concat(ordersRemainingFillableMakerAssetAmounts, makerAssetAmountAvailable)
+ : ordersRemainingFillableMakerAssetAmounts,
remainingFillAmount: BigNumber.max(
constants.ZERO_AMOUNT,
remainingFillAmount.minus(makerAssetAmountAvailable),
@@ -69,7 +75,11 @@ export const marketUtils = {
};
}
},
- { resultOrders: [] as T[], remainingFillAmount: totalFillAmount },
+ {
+ resultOrders: [] as T[],
+ remainingFillAmount: totalFillAmount,
+ ordersRemainingFillableMakerAssetAmounts: [] as BigNumber[],
+ },
);
return result;
},
@@ -133,17 +143,18 @@ export const marketUtils = {
},
constants.ZERO_AMOUNT,
);
- const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
- feeOrders,
- totalFeeAmount,
- {
- remainingFillableMakerAssetAmounts: remainingFillableFeeAmounts,
- slippageBufferAmount,
- },
- );
+ const {
+ resultOrders,
+ remainingFillAmount,
+ ordersRemainingFillableMakerAssetAmounts,
+ } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(feeOrders, totalFeeAmount, {
+ remainingFillableMakerAssetAmounts: remainingFillableFeeAmounts,
+ slippageBufferAmount,
+ });
return {
resultFeeOrders: resultOrders,
remainingFeeAmount: remainingFillAmount,
+ feeOrdersRemainingFillableMakerAssetAmounts: ordersRemainingFillableMakerAssetAmounts,
};
// TODO: add more orders here to cover rounding
// https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarding-contract-specification.md#over-buying-zrx
diff --git a/packages/order-utils/src/types.ts b/packages/order-utils/src/types.ts
index 09292e557..a843efaa4 100644
--- a/packages/order-utils/src/types.ts
+++ b/packages/order-utils/src/types.ts
@@ -72,10 +72,12 @@ export interface FindFeeOrdersThatCoverFeesForTargetOrdersOpts {
export interface FeeOrdersAndRemainingFeeAmount<T> {
resultFeeOrders: T[];
+ feeOrdersRemainingFillableMakerAssetAmounts: BigNumber[];
remainingFeeAmount: BigNumber;
}
export interface OrdersAndRemainingFillAmount<T> {
resultOrders: T[];
+ ordersRemainingFillableMakerAssetAmounts: BigNumber[];
remainingFillAmount: BigNumber;
}