aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/CHANGELOG.json17
-rw-r--r--packages/order-utils/CHANGELOG.md17
-rw-r--r--packages/order-utils/src/market_utils.ts4
-rw-r--r--packages/order-utils/src/sorting_utils.ts2
-rw-r--r--packages/order-utils/src/types.ts2
-rw-r--r--packages/order-utils/test/market_utils_test.ts24
6 files changed, 46 insertions, 20 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index cd2a742d2..81782b501 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -24,8 +24,23 @@
"note":
"Export types: `SignedOrder`, `Order`, `OrderRelevantState`, `OrderState`, `ECSignature`, `ERC20AssetData`, `ERC721AssetData`, `AssetProxyId`, `SignerType`, `SignatureType`, `OrderStateValid`, `OrderStateInvalid`, `ExchangeContractErrs`, `TradeSide`, `TransferType`, `FindFeeOrdersThatCoverFeesForTargetOrdersOpts`, `FindOrdersThatCoverMakerAssetFillAmountOpts`, `FeeOrdersAndRemainingFeeAmount`, `OrdersAndRemainingFillAmount`, `Provider`, `JSONRPCRequestPayload`, `JSONRPCErrorCallback` and `JSONRPCResponsePayload`",
"pr": 924
+ },
+ {
+ "note":
+ "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api",
+ "pr": 997
+ },
+ {
+ "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic",
+ "pr": 997
+ },
+ {
+ "note":
+ "Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees",
+ "pr": 997
}
- ]
+ ],
+ "timestamp": 1535133899
},
{
"version": "1.0.1-rc.3",
diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md
index 0df2a6a75..7af51fc61 100644
--- a/packages/order-utils/CHANGELOG.md
+++ b/packages/order-utils/CHANGELOG.md
@@ -5,7 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
-## v1.0.1-rc.3 - _August 13, 2018_
+## v1.0.1-rc.4 - _August 24, 2018_
+
+ * Remove rounding error being thrown when maker amount is very small (#959)
+ * Added rateUtils and sortingUtils (#953)
+ * Update marketUtils api such that all optional parameters are bundled into one optional param and more defaults are provided (#954)
+ * Instead of exporting signature util methods individually, they are now exported as `signatureUtils` (#924)
+ * Export types: `SignedOrder`, `Order`, `OrderRelevantState`, `OrderState`, `ECSignature`, `ERC20AssetData`, `ERC721AssetData`, `AssetProxyId`, `SignerType`, `SignatureType`, `OrderStateValid`, `OrderStateInvalid`, `ExchangeContractErrs`, `TradeSide`, `TransferType`, `FindFeeOrdersThatCoverFeesForTargetOrdersOpts`, `FindOrdersThatCoverMakerAssetFillAmountOpts`, `FeeOrdersAndRemainingFeeAmount`, `OrdersAndRemainingFillAmount`, `Provider`, `JSONRPCRequestPayload`, `JSONRPCErrorCallback` and `JSONRPCResponsePayload` (#924)
+ * Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api (#997)
+ * Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic (#997)
+ * Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees (#997)
+
+## v1.0.1-rc.3 - _August 14, 2018_
* Update ecSignOrderHashAsync to return signature string with signature type byte. Removes messagePrefixOpts. (#914)
* Added a synchronous `createOrder` method in `orderFactory`, updated public interfaces to support some optional parameters (#936)
@@ -28,7 +39,7 @@ CHANGELOG
* Upgrade ethereumjs-abi dep including a fix so that addresses starting with 0 are properly decoded by `decodeERC20AssetData`
-## v1.0.0-rc.1 - _July 19, 2018_
+## v1.0.0-rc.1 - _July 20, 2018_
* Refactor to work with V2 of 0x protocol (#636)
* Export parseECSignature method (#684)
@@ -54,7 +65,7 @@ CHANGELOG
* Add orderStateUtils, a module for computing order state needed to decide if an order is still valid
-## v0.0.4 - _May 4, 2018_
+## v0.0.4 - _May 5, 2018_
* Dependencies updated
diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts
index 441c50e5c..4a664cb14 100644
--- a/packages/order-utils/src/market_utils.ts
+++ b/packages/order-utils/src/market_utils.ts
@@ -128,7 +128,7 @@ export const marketUtils = {
const makerAssetAmountAvailable = remainingFillableMakerAssetAmounts[index];
const feeToFillMakerAssetAmountAvailable = makerAssetAmountAvailable
.mul(order.takerFee)
- .div(order.makerAssetAmount);
+ .dividedToIntegerBy(order.makerAssetAmount);
return accFees.plus(feeToFillMakerAssetAmountAvailable);
},
constants.ZERO_AMOUNT,
@@ -142,7 +142,7 @@ export const marketUtils = {
},
);
return {
- resultOrders,
+ resultFeeOrders: resultOrders,
remainingFeeAmount: remainingFillAmount,
};
// TODO: add more orders here to cover rounding
diff --git a/packages/order-utils/src/sorting_utils.ts b/packages/order-utils/src/sorting_utils.ts
index 8811bcaf8..cd5163cf6 100644
--- a/packages/order-utils/src/sorting_utils.ts
+++ b/packages/order-utils/src/sorting_utils.ts
@@ -32,7 +32,7 @@ export const sortingUtils = {
* the makerAsset and WETH as the takerAsset.
* @return The input orders sorted by rate in ascending order
*/
- sortFeeOrdersByFeeAdjustedRate(feeOrders: Order[]): Order[] {
+ sortFeeOrdersByFeeAdjustedRate<T extends Order>(feeOrders: T[]): T[] {
assert.doesConformToSchema('feeOrders', feeOrders, schemas.ordersSchema);
const rateCalculator = rateUtils.getFeeAdjustedRateOfFeeOrder.bind(rateUtils);
const sortedOrders = sortOrders(feeOrders, rateCalculator);
diff --git a/packages/order-utils/src/types.ts b/packages/order-utils/src/types.ts
index 4088805dc..09292e557 100644
--- a/packages/order-utils/src/types.ts
+++ b/packages/order-utils/src/types.ts
@@ -71,7 +71,7 @@ export interface FindFeeOrdersThatCoverFeesForTargetOrdersOpts {
}
export interface FeeOrdersAndRemainingFeeAmount<T> {
- resultOrders: T[];
+ resultFeeOrders: T[];
remainingFeeAmount: BigNumber;
}
diff --git a/packages/order-utils/test/market_utils_test.ts b/packages/order-utils/test/market_utils_test.ts
index cce97e0e4..31986ba1a 100644
--- a/packages/order-utils/test/market_utils_test.ts
+++ b/packages/order-utils/test/market_utils_test.ts
@@ -140,11 +140,11 @@ describe('marketUtils', () => {
);
describe('no target orders', () => {
it('returns empty and zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
[],
inputFeeOrders,
);
- expect(resultOrders).to.be.empty;
+ expect(resultFeeOrders).to.be.empty;
expect(remainingFeeAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
});
@@ -163,14 +163,14 @@ describe('marketUtils', () => {
// generate remainingFillableMakerAssetAmounts that equal the makerAssetAmount
const remainingFillableMakerAssetAmounts = [makerAssetAmount, makerAssetAmount, makerAssetAmount];
it('returns empty and non-zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
inputOrders,
[],
{
remainingFillableMakerAssetAmounts,
},
);
- expect(resultOrders).to.be.empty;
+ expect(resultFeeOrders).to.be.empty;
expect(remainingFeeAmount).to.be.bignumber.equal(new BigNumber(30));
});
});
@@ -184,11 +184,11 @@ describe('marketUtils', () => {
3,
);
it('returns empty and zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
inputOrders,
inputFeeOrders,
);
- expect(resultOrders).to.be.empty;
+ expect(resultFeeOrders).to.be.empty;
expect(remainingFeeAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
});
@@ -205,11 +205,11 @@ describe('marketUtils', () => {
3,
);
it('returns input fee orders and zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
inputOrders,
inputFeeOrders,
);
- expect(resultOrders).to.be.deep.equal(inputFeeOrders);
+ expect(resultFeeOrders).to.be.deep.equal(inputFeeOrders);
expect(remainingFeeAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
});
@@ -231,14 +231,14 @@ describe('marketUtils', () => {
// 3. order is completely fillable
const remainingFillableMakerAssetAmounts = [constants.ZERO_AMOUNT, new BigNumber(5), makerAssetAmount];
it('returns first two input fee orders and zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
inputOrders,
inputFeeOrders,
{
remainingFillableMakerAssetAmounts,
},
);
- expect(resultOrders).to.be.deep.equal([inputFeeOrders[0], inputFeeOrders[1]]);
+ expect(resultFeeOrders).to.be.deep.equal([inputFeeOrders[0], inputFeeOrders[1]]);
expect(remainingFeeAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
});
@@ -255,11 +255,11 @@ describe('marketUtils', () => {
3,
);
it('returns input fee orders and non-zero remainingFeeAmount', async () => {
- const { resultOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
+ const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
inputOrders,
inputFeeOrders,
);
- expect(resultOrders).to.be.deep.equal(inputFeeOrders);
+ expect(resultFeeOrders).to.be.deep.equal(inputFeeOrders);
expect(remainingFeeAmount).to.be.bignumber.equal(new BigNumber(30));
});
});