From 3c973ba9f64197fcc1a66f319e3d1aa33d96b6d7 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 17 Aug 2018 00:15:52 -0700 Subject: Remove marketSell and add to marketBuy implementation --- packages/order-utils/CHANGELOG.json | 4 ++++ packages/order-utils/src/market_utils.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 86f0da65a..4acb3d233 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -14,6 +14,10 @@ "note": "Update marketUtils api such that all optional parameters are bundled into one optional param and more defaults are provided", "pr": 954 + }, + { + "note": + "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api" } ] }, diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index a0a827546..7eae4c8fc 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -84,7 +84,7 @@ export const marketUtils = { orders: T[], feeOrders: T[], opts?: FindFeeOrdersThatCoverFeesForTargetOrdersOpts, - ): { resultOrders: T[]; remainingFeeAmount: BigNumber } { + ): { resultFeeOrders: T[]; remainingFeeAmount: BigNumber } { assert.doesConformToSchema('orders', orders, schemas.ordersSchema); assert.doesConformToSchema('feeOrders', feeOrders, schemas.ordersSchema); // try to get remainingFillableMakerAssetAmounts from opts, if it's not there, use makerAssetAmount values from orders @@ -137,7 +137,7 @@ export const marketUtils = { }, ); return { - resultOrders, + resultFeeOrders: resultOrders, remainingFeeAmount: remainingFillAmount, }; // TODO: add more orders here to cover rounding -- cgit v1.2.3 From e8a1950a7489e83f7f1a1127ee325f0c5c36483c Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 17 Aug 2018 13:00:54 -0700 Subject: Add ForwarderHelperImplConfig --- packages/order-utils/CHANGELOG.json | 3 +++ packages/order-utils/src/sorting_utils.ts | 2 +- packages/order-utils/test/market_utils_test.ts | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 4acb3d233..c4260bc2f 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -18,6 +18,9 @@ { "note": "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api" + }, + { + "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic" } ] }, 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(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/test/market_utils_test.ts b/packages/order-utils/test/market_utils_test.ts index 109420a02..0c0151e57 100644 --- a/packages/order-utils/test/market_utils_test.ts +++ b/packages/order-utils/test/market_utils_test.ts @@ -139,11 +139,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); }); }); @@ -162,14 +162,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)); }); }); @@ -183,11 +183,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); }); }); @@ -204,11 +204,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); }); }); @@ -230,14 +230,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); }); }); @@ -254,11 +254,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)); }); }); -- cgit v1.2.3 From 67d33ec10c3d2467d2d073d22bfe2957353a0cc8 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 21 Aug 2018 17:07:14 -0700 Subject: Fix rounding bug in marketUtils --- packages/order-utils/CHANGELOG.json | 11 +++++++++-- packages/order-utils/src/market_utils.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index c4260bc2f..55e0b499e 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -17,10 +17,17 @@ }, { "note": - "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api" + "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api", + "pr": 954 + }, + { + "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic", + "pr": 954 }, { - "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic" + "note": + "Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees", + "pr": 954 } ] }, diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index 7eae4c8fc..b31a2b135 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -123,7 +123,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, -- cgit v1.2.3 From cbcf8e8477cbb9061906866ea70dd885a185f358 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 22 Aug 2018 15:01:40 -0700 Subject: Add changelog entry and fix order-util changelog PR numbers --- packages/order-utils/CHANGELOG.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 55e0b499e..149086857 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -18,16 +18,16 @@ { "note": "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api", - "pr": 954 + "pr": 997 }, { "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic", - "pr": 954 + "pr": 997 }, { "note": "Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees", - "pr": 954 + "pr": 997 } ] }, -- cgit v1.2.3 From b38ef579fb75c777fac2eef3d4bcda2c97014f0b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 24 Aug 2018 19:11:10 +0100 Subject: Updated CHANGELOGS --- packages/order-utils/CHANGELOG.json | 3 ++- packages/order-utils/CHANGELOG.md | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 871bc50a1..81782b501 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -39,7 +39,8 @@ "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 -- cgit v1.2.3 From 7f585a15f526e0a61fd822cdefb7087fc6bb8934 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 24 Aug 2018 19:11:27 +0100 Subject: Publish - 0x.js@1.0.1-rc.4 - @0xproject/abi-gen@1.0.6 - @0xproject/assert@1.0.6 - @0xproject/base-contract@2.0.0 - @0xproject/connect@2.0.0-rc.1 - @0xproject/contract-wrappers@1.0.1-rc.4 - contracts@2.1.41 - @0xproject/dev-utils@1.0.5 - ethereum-types@1.0.5 - @0xproject/fill-scenarios@1.0.1-rc.4 - @0xproject/forwarder-helper@1.0.1-rc.1 - @0xproject/json-schemas@1.0.1-rc.5 - @0xproject/metacoin@0.0.16 - @0xproject/migrations@1.0.5 - @0xproject/monorepo-scripts@1.0.6 - @0xproject/order-utils@1.0.1-rc.4 - @0xproject/order-watcher@1.0.1-rc.4 - @0xproject/react-docs@1.0.6 - @0xproject/react-shared@1.0.7 - @0xproject/sol-compiler@1.1.0 - @0xproject/sol-cov@2.1.0 - @0xproject/sol-resolver@1.0.6 - @0xproject/sra-api@1.0.1-rc.5 - @0xproject/sra-report@1.0.6 - @0xproject/subproviders@2.0.0 - @0xproject/testnet-faucets@1.0.42 - @0xproject/tslint-config@1.0.6 - @0xproject/types@1.0.1-rc.5 - @0xproject/typescript-typings@1.0.5 - @0xproject/utils@1.0.6 - @0xproject/web3-wrapper@2.0.0 - @0xproject/website@0.0.45 --- packages/order-utils/package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 0d82affef..0a35251d7 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-utils", - "version": "1.0.1-rc.3", + "version": "1.0.1-rc.4", "engines": { "node": ">=6.12" }, @@ -40,8 +40,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.4", - "@0xproject/tslint-config": "^1.0.5", + "@0xproject/dev-utils": "^1.0.5", + "@0xproject/tslint-config": "^1.0.6", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "chai": "^4.0.1", @@ -59,16 +59,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.5", - "@0xproject/base-contract": "^2.0.0-rc.1", - "@0xproject/json-schemas": "^1.0.1-rc.4", - "@0xproject/types": "^1.0.1-rc.4", - "@0xproject/typescript-typings": "^1.0.4", - "@0xproject/utils": "^1.0.5", - "@0xproject/web3-wrapper": "^1.2.0", + "@0xproject/assert": "^1.0.6", + "@0xproject/base-contract": "^2.0.0", + "@0xproject/json-schemas": "^1.0.1-rc.5", + "@0xproject/types": "^1.0.1-rc.5", + "@0xproject/typescript-typings": "^1.0.5", + "@0xproject/utils": "^1.0.6", + "@0xproject/web3-wrapper": "^2.0.0", "@types/node": "^8.0.53", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.4", + "ethereum-types": "^1.0.5", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", -- cgit v1.2.3