aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/CHANGELOG.json9
-rw-r--r--packages/0x.js/CHANGELOG.md4
-rw-r--r--packages/0x.js/package.json34
-rw-r--r--packages/abi-gen/CHANGELOG.json9
-rw-r--r--packages/abi-gen/CHANGELOG.md4
-rw-r--r--packages/abi-gen/package.json10
-rw-r--r--packages/assert/CHANGELOG.json9
-rw-r--r--packages/assert/CHANGELOG.md4
-rw-r--r--packages/assert/package.json8
-rw-r--r--packages/asset-buyer/.npmignore (renamed from packages/forwarder-helper/.npmignore)0
-rw-r--r--packages/asset-buyer/CHANGELOG.json10
-rw-r--r--packages/asset-buyer/CHANGELOG.md1
-rw-r--r--packages/asset-buyer/README.md83
-rw-r--r--packages/asset-buyer/package.json (renamed from packages/forwarder-helper/package.json)27
-rw-r--r--packages/asset-buyer/src/asset_buyer.ts324
-rw-r--r--packages/asset-buyer/src/constants.ts20
-rw-r--r--packages/asset-buyer/src/globals.d.ts (renamed from packages/forwarder-helper/src/globals.d.ts)0
-rw-r--r--packages/asset-buyer/src/index.ts17
-rw-r--r--packages/asset-buyer/src/order_providers/basic_order_provider.ts32
-rw-r--r--packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts78
-rw-r--r--packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts133
-rw-r--r--packages/asset-buyer/src/types.ts86
-rw-r--r--packages/asset-buyer/src/utils/assert.ts51
-rw-r--r--packages/asset-buyer/src/utils/asset_data_utils.ts26
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts89
-rw-r--r--packages/asset-buyer/src/utils/order_provider_response_processor.ts202
-rw-r--r--packages/asset-buyer/src/utils/order_utils.ts30
-rw-r--r--packages/asset-buyer/test/utils/chai_setup.ts (renamed from packages/forwarder-helper/test/utils/chai_setup.ts)0
-rw-r--r--packages/asset-buyer/tsconfig.json (renamed from packages/forwarder-helper/tsconfig.json)0
-rw-r--r--packages/asset-buyer/tslint.json (renamed from packages/forwarder-helper/tslint.json)0
-rw-r--r--packages/asset-buyer/typedoc-tsconfig.json (renamed from packages/forwarder-helper/typedoc-tsconfig.json)0
-rw-r--r--packages/base-contract/CHANGELOG.json9
-rw-r--r--packages/base-contract/CHANGELOG.md4
-rw-r--r--packages/base-contract/package.json10
-rw-r--r--packages/connect/CHANGELOG.json9
-rw-r--r--packages/connect/CHANGELOG.md4
-rw-r--r--packages/connect/package.json14
-rw-r--r--packages/connect/src/http_client.ts2
-rw-r--r--packages/contract-wrappers/CHANGELOG.json9
-rw-r--r--packages/contract-wrappers/CHANGELOG.md4
-rw-r--r--packages/contract-wrappers/package.json32
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts18
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts17
-rw-r--r--packages/contract-wrappers/src/utils/constants.ts2
-rw-r--r--packages/contract-wrappers/src/utils/utils.ts6
-rw-r--r--packages/contract-wrappers/test/subscription_test.ts2
-rw-r--r--packages/contracts/package.json28
-rw-r--r--packages/contracts/test/multisig/multi_sig_with_time_lock.ts5
-rw-r--r--packages/contracts/test/utils/block_timestamp.ts7
-rw-r--r--packages/dev-utils/CHANGELOG.json9
-rw-r--r--packages/dev-utils/CHANGELOG.md4
-rw-r--r--packages/dev-utils/package.json14
-rw-r--r--packages/ethereum-types/CHANGELOG.json9
-rw-r--r--packages/ethereum-types/CHANGELOG.md4
-rw-r--r--packages/ethereum-types/package.json4
-rw-r--r--packages/ethereum-types/src/index.ts2
-rw-r--r--packages/fill-scenarios/CHANGELOG.json9
-rw-r--r--packages/fill-scenarios/CHANGELOG.md4
-rw-r--r--packages/fill-scenarios/package.json18
-rw-r--r--packages/forwarder-helper/CHANGELOG.json48
-rw-r--r--packages/forwarder-helper/CHANGELOG.md26
-rw-r--r--packages/forwarder-helper/README.md83
-rw-r--r--packages/forwarder-helper/src/constants.ts5
-rw-r--r--packages/forwarder-helper/src/forwarder_helper_factory.ts25
-rw-r--r--packages/forwarder-helper/src/forwarder_helper_impl.ts64
-rw-r--r--packages/forwarder-helper/src/index.ts2
-rw-r--r--packages/forwarder-helper/src/types.ts43
-rw-r--r--packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts92
-rw-r--r--packages/forwarder-helper/test/forwarder_helper_impl_test.ts136
-rw-r--r--packages/json-schemas/CHANGELOG.json9
-rw-r--r--packages/json-schemas/CHANGELOG.md4
-rw-r--r--packages/json-schemas/package.json8
-rw-r--r--packages/metacoin/package.json24
-rw-r--r--packages/migrations/CHANGELOG.json9
-rw-r--r--packages/migrations/CHANGELOG.md4
-rw-r--r--packages/migrations/package.json24
-rw-r--r--packages/monorepo-scripts/package.json4
-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
-rw-r--r--packages/order-watcher/CHANGELOG.json9
-rw-r--r--packages/order-watcher/CHANGELOG.md4
-rw-r--r--packages/order-watcher/package.json32
-rw-r--r--packages/order-watcher/src/order_watcher/event_watcher.ts19
-rw-r--r--packages/react-docs/CHANGELOG.json9
-rw-r--r--packages/react-docs/CHANGELOG.md4
-rw-r--r--packages/react-docs/package.json10
-rw-r--r--packages/react-shared/CHANGELOG.json9
-rw-r--r--packages/react-shared/CHANGELOG.md4
-rw-r--r--packages/react-shared/package.json6
-rw-r--r--packages/sol-compiler/CHANGELOG.json9
-rw-r--r--packages/sol-compiler/CHANGELOG.md4
-rw-r--r--packages/sol-compiler/package.json20
-rw-r--r--packages/sol-cov/CHANGELOG.json9
-rw-r--r--packages/sol-cov/CHANGELOG.md4
-rw-r--r--packages/sol-cov/package.json18
-rw-r--r--packages/sol-resolver/CHANGELOG.json9
-rw-r--r--packages/sol-resolver/CHANGELOG.md4
-rw-r--r--packages/sol-resolver/package.json6
-rw-r--r--packages/sra-report/CHANGELOG.json9
-rw-r--r--packages/sra-report/CHANGELOG.md4
-rw-r--r--packages/sra-report/package.json10
-rw-r--r--packages/sra-spec/CHANGELOG.json9
-rw-r--r--packages/sra-spec/CHANGELOG.md4
-rw-r--r--packages/sra-spec/package.json4
-rw-r--r--packages/subproviders/CHANGELOG.json9
-rw-r--r--packages/subproviders/CHANGELOG.md4
-rw-r--r--packages/subproviders/package.json16
-rw-r--r--packages/testnet-faucets/package.json14
-rw-r--r--packages/types/CHANGELOG.json18
-rw-r--r--packages/types/CHANGELOG.md4
-rw-r--r--packages/types/package.json6
-rw-r--r--packages/types/src/index.ts4
-rw-r--r--packages/typescript-typings/CHANGELOG.json9
-rw-r--r--packages/typescript-typings/CHANGELOG.md4
-rw-r--r--packages/typescript-typings/package.json4
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/CHANGELOG.md4
-rw-r--r--packages/utils/package.json10
-rw-r--r--packages/web3-wrapper/CHANGELOG.json21
-rw-r--r--packages/web3-wrapper/CHANGELOG.md4
-rw-r--r--packages/web3-wrapper/package.json12
-rw-r--r--packages/web3-wrapper/src/web3_wrapper.ts29
-rw-r--r--packages/web3-wrapper/test/web3_wrapper_test.ts34
-rw-r--r--packages/website/package.json25
-rw-r--r--packages/website/ts/blockchain.ts2
-rw-r--r--packages/website/ts/components/inputs/token_amount_input.tsx2
-rw-r--r--packages/website/ts/types.ts6
-rw-r--r--packages/website/ts/utils/analytics.ts3
-rw-r--r--packages/website/ts/utils/token_address_overrides.ts2
132 files changed, 1908 insertions, 821 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index 86cf7a916..391c5fa17 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.3",
"changes": [
{
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index a6f23e620..7031425ab 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.4 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.3 - _September 19, 2018_
* Drastically reduce the bundle size by removing unused parts of included contract artifacts.
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index bf929a835..c92e24c52 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,6 +1,6 @@
{
"name": "0x.js",
- "version": "1.0.3",
+ "version": "1.0.4",
"engines": {
"node": ">=6.12"
},
@@ -41,14 +41,14 @@
},
"license": "Apache-2.0",
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/migrations": "^1.0.9",
- "@0xproject/monorepo-scripts": "^1.0.8",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/migrations": "^1.0.10",
+ "@0xproject/monorepo-scripts": "^1.0.9",
"@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/web3-provider-engine": "^14.0.0",
"awesome-typescript-loader": "^3.1.3",
@@ -73,17 +73,17 @@
"webpack": "^3.1.0"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/contract-wrappers": "^1.0.3",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/order-watcher": "^1.0.3",
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/contract-wrappers": "^1.0.4",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/order-watcher": "^1.0.4",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"ethers": "3.0.22",
"lodash": "^4.17.5",
"web3-provider-engine": "14.0.6"
diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json
index 640f76f07..2ecacb05d 100644
--- a/packages/abi-gen/CHANGELOG.json
+++ b/packages/abi-gen/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md
index 3c65739c0..88ab42864 100644
--- a/packages/abi-gen/CHANGELOG.md
+++ b/packages/abi-gen/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index 79c550a33..6b8581ef3 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/abi-gen",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -30,10 +30,10 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": {
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
"chalk": "^2.3.0",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
"lodash": "^4.17.5",
@@ -48,7 +48,7 @@
"@types/glob": "5.0.35",
"@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/sleep": "^0.0.7",
"@types/tmp": "^0.0.33",
"@types/yargs": "^10.0.0",
diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json
index 53c892ef5..8a9b6afd6 100644
--- a/packages/assert/CHANGELOG.json
+++ b/packages/assert/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md
index 8b1437350..d39441338 100644
--- a/packages/assert/CHANGELOG.md
+++ b/packages/assert/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/assert/package.json b/packages/assert/package.json
index 23357dc99..629cb23e5 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/assert",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -44,9 +44,9 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
"lodash": "^4.17.5",
"valid-url": "^1.0.9"
},
diff --git a/packages/forwarder-helper/.npmignore b/packages/asset-buyer/.npmignore
index 5333847e7..5333847e7 100644
--- a/packages/forwarder-helper/.npmignore
+++ b/packages/asset-buyer/.npmignore
diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json
new file mode 100644
index 000000000..2e4db1f6e
--- /dev/null
+++ b/packages/asset-buyer/CHANGELOG.json
@@ -0,0 +1,10 @@
+[
+ {
+ "version": "1.0.0-rc.1",
+ "changes": [
+ {
+ "note": "Init"
+ }
+ ]
+ }
+]
diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/packages/asset-buyer/CHANGELOG.md
@@ -0,0 +1 @@
+
diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md
new file mode 100644
index 000000000..5f7f26f30
--- /dev/null
+++ b/packages/asset-buyer/README.md
@@ -0,0 +1,83 @@
+## @0xproject/asset-buyer
+
+Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or buy ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.
+
+In its more advanced and useful form, it integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone.
+
+## Installation
+
+```bash
+yarn add @0xproject/asset-buyer
+```
+
+**Import**
+
+```typescript
+import { AssetBuyer } from '@0xproject/asset-buyer';
+```
+
+or
+
+```javascript
+var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer;
+```
+
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
+## Contributing
+
+We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
+
+```bash
+PKG=@0xproject/asset-buyer yarn build
+```
+
+Or continuously rebuild on change:
+
+```bash
+PKG=@0xproject/asset-buyer yarn watch
+```
+
+### Clean
+
+```bash
+yarn clean
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
+```
diff --git a/packages/forwarder-helper/package.json b/packages/asset-buyer/package.json
index 305b3f6a7..2b5136e31 100644
--- a/packages/forwarder-helper/package.json
+++ b/packages/asset-buyer/package.json
@@ -1,10 +1,10 @@
{
- "name": "@0xproject/forwarder-helper",
- "version": "1.0.3",
+ "name": "@0xproject/asset-buyer",
+ "version": "1.0.0-rc.1",
"engines": {
"node": ">=6.12"
},
- "description": "Convenience object for working with the forwarder contract",
+ "description": "Convenience package for buying assets",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
@@ -34,21 +34,26 @@
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md",
+ "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md",
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@types/node": "^8.0.53",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/connect": "^2.0.2",
+ "@0xproject/contract-wrappers": "^1.0.4",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/order-utils": "^1.0.1",
+ "@0xproject/subproviders": "^2.0.2",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.6",
"lodash": "^4.17.10"
},
"devDependencies": {
"@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "^4.14.116",
"@types/mocha": "^2.2.42",
+ "@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts
new file mode 100644
index 000000000..409e34e74
--- /dev/null
+++ b/packages/asset-buyer/src/asset_buyer.ts
@@ -0,0 +1,324 @@
+import { ContractWrappers } from '@0xproject/contract-wrappers';
+import { schemas } from '@0xproject/json-schemas';
+import { SignedOrder } from '@0xproject/order-utils';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { Provider } from 'ethereum-types';
+import * as _ from 'lodash';
+
+import { constants } from './constants';
+import { BasicOrderProvider } from './order_providers/basic_order_provider';
+import { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider';
+import {
+ AssetBuyerError,
+ AssetBuyerOrdersAndFillableAmounts,
+ BuyQuote,
+ BuyQuoteRequestOpts,
+ OrderProvider,
+ OrderProviderResponse,
+} from './types';
+
+import { assert } from './utils/assert';
+import { assetDataUtils } from './utils/asset_data_utils';
+import { buyQuoteCalculator } from './utils/buy_quote_calculator';
+import { orderProviderResponseProcessor } from './utils/order_provider_response_processor';
+
+export class AssetBuyer {
+ public readonly provider: Provider;
+ public readonly assetData: string;
+ public readonly orderProvider: OrderProvider;
+ public readonly networkId: number;
+ public readonly orderRefreshIntervalMs: number;
+ public readonly expiryBufferSeconds: number;
+ private readonly _contractWrappers: ContractWrappers;
+ private _lastRefreshTimeIfExists?: number;
+ private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts;
+ /**
+ * Instantiates a new AssetBuyer instance given existing liquidity in the form of orders and feeOrders.
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param orders A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH).
+ * @param feeOrders A array of objects that conform to SignedOrder. All orders must have the same makerAssetData (ZRX) and takerAssetData (WETH). Defaults to an empty array.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
+ * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ *
+ * @return An instance of AssetBuyer
+ */
+ public static getAssetBuyerForProvidedOrders(
+ provider: Provider,
+ orders: SignedOrder[],
+ feeOrders: SignedOrder[] = [],
+ networkId: number = constants.MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
+ expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ ): AssetBuyer {
+ assert.isWeb3Provider('provider', provider);
+ assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema);
+ assert.doesConformToSchema('feeOrders', feeOrders, schemas.signedOrdersSchema);
+ assert.isNumber('networkId', networkId);
+ assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
+ assert.areValidProvidedOrders('orders', orders);
+ assert.areValidProvidedOrders('feeOrders', feeOrders);
+ assert.assert(orders.length !== 0, `Expected orders to contain at least one order`);
+ const assetData = orders[0].makerAssetData;
+ const orderProvider = new BasicOrderProvider(_.concat(orders, feeOrders));
+ const assetBuyer = new AssetBuyer(
+ provider,
+ assetData,
+ orderProvider,
+ networkId,
+ orderRefreshIntervalMs,
+ expiryBufferSeconds,
+ );
+ return assetBuyer;
+ }
+ /**
+ * Instantiates a new AssetBuyer instance given the desired assetData and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param assetData The assetData that identifies the desired asset to buy.
+ * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
+ * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ *
+ * @return An instance of AssetBuyer
+ */
+ public static getAssetBuyerForAssetData(
+ provider: Provider,
+ assetData: string,
+ sraApiUrl: string,
+ networkId: number = constants.MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
+ expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ ): AssetBuyer {
+ assert.isWeb3Provider('provider', provider);
+ assert.isHexString('assetData', assetData);
+ assert.isWebUri('sraApiUrl', sraApiUrl);
+ assert.isNumber('networkId', networkId);
+ assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
+ const orderProvider = new StandardRelayerAPIOrderProvider(sraApiUrl);
+ const assetBuyer = new AssetBuyer(
+ provider,
+ assetData,
+ orderProvider,
+ networkId,
+ orderRefreshIntervalMs,
+ expiryBufferSeconds,
+ );
+ return assetBuyer;
+ }
+ /**
+ * Instantiates a new AssetBuyer instance given the desired ERC20 token address and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param tokenAddress The ERC20 token address that identifies the desired asset to buy.
+ * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
+ * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ * @return An instance of AssetBuyer
+ */
+ public static getAssetBuyerForERC20TokenAddress(
+ provider: Provider,
+ tokenAddress: string,
+ sraApiUrl: string,
+ networkId: number = constants.MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
+ expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ ): AssetBuyer {
+ assert.isWeb3Provider('provider', provider);
+ assert.isETHAddressHex('tokenAddress', tokenAddress);
+ assert.isWebUri('sraApiUrl', sraApiUrl);
+ assert.isNumber('networkId', networkId);
+ assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
+ const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress);
+ const assetBuyer = AssetBuyer.getAssetBuyerForAssetData(
+ provider,
+ assetData,
+ sraApiUrl,
+ networkId,
+ orderRefreshIntervalMs,
+ expiryBufferSeconds,
+ );
+ return assetBuyer;
+ }
+ /**
+ * Instantiates a new AssetBuyer instance
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
+ * @param orderProvider An object that conforms to OrderProvider, see type for definition.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
+ * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ *
+ * @return An instance of AssetBuyer
+ */
+ constructor(
+ provider: Provider,
+ assetData: string,
+ orderProvider: OrderProvider,
+ networkId: number = constants.MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
+ expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ ) {
+ assert.isWeb3Provider('provider', provider);
+ assert.isString('assetData', assetData);
+ assert.isValidOrderProvider('orderProvider', orderProvider);
+ assert.isNumber('networkId', networkId);
+ assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
+ this.provider = provider;
+ this.assetData = assetData;
+ this.orderProvider = orderProvider;
+ this.networkId = networkId;
+ this.expiryBufferSeconds = expiryBufferSeconds;
+ this.orderRefreshIntervalMs = orderRefreshIntervalMs;
+ this._contractWrappers = new ContractWrappers(this.provider, {
+ networkId,
+ });
+ }
+ /**
+ * Get a `BuyQuote` containing all information relevant to fulfilling a buy.
+ * You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy.
+ * @param assetBuyAmount The amount of asset to buy.
+ * @param feePercentage The affiliate fee percentage. Defaults to 0.
+ * @param forceOrderRefresh If set to true, new orders and state will be fetched instead of waiting for
+ * the next orderRefreshIntervalMs. Defaults to false.
+ * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information.
+ */
+ public async getBuyQuoteAsync(assetBuyAmount: BigNumber, options: Partial<BuyQuoteRequestOpts>): Promise<BuyQuote> {
+ const { feePercentage, shouldForceOrderRefresh, slippagePercentage } = {
+ ...options,
+ ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS,
+ };
+ assert.isBigNumber('assetBuyAmount', assetBuyAmount);
+ assert.isValidPercentage('feePercentage', feePercentage);
+ assert.isBoolean('shouldForceOrderRefresh', shouldForceOrderRefresh);
+ // we should refresh if:
+ // we do not have any orders OR
+ // we are forced to OR
+ // we have some last refresh time AND that time was sufficiently long ago
+ const shouldRefresh =
+ _.isUndefined(this._currentOrdersAndFillableAmountsIfExists) ||
+ shouldForceOrderRefresh ||
+ (!_.isUndefined(this._lastRefreshTimeIfExists) &&
+ this._lastRefreshTimeIfExists + this.orderRefreshIntervalMs < Date.now());
+ let ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts;
+ if (shouldRefresh) {
+ ordersAndFillableAmounts = await this._getLatestOrdersAndFillableAmountsAsync();
+ this._lastRefreshTimeIfExists = Date.now();
+ this._currentOrdersAndFillableAmountsIfExists = ordersAndFillableAmounts;
+ } else {
+ // it is safe to cast to AssetBuyerOrdersAndFillableAmounts because shouldRefresh catches the undefined case above
+ ordersAndFillableAmounts = this
+ ._currentOrdersAndFillableAmountsIfExists as AssetBuyerOrdersAndFillableAmounts;
+ }
+ const buyQuote = buyQuoteCalculator.calculate(
+ ordersAndFillableAmounts,
+ assetBuyAmount,
+ feePercentage,
+ slippagePercentage,
+ );
+ return buyQuote;
+ }
+ /**
+ * Given a BuyQuote and desired rate, attempt to execute the buy.
+ * @param buyQuote An object that conforms to BuyQuote. See type definition for more information.
+ * @param rate The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate.
+ * @param takerAddress The address to perform the buy. Defaults to the first available address from the provider.
+ * @param feeRecipient The address where affiliate fees are sent. Defaults to null address (0x000...000).
+ * @return A promise of the txHash.
+ */
+ public async executeBuyQuoteAsync(
+ buyQuote: BuyQuote,
+ rate?: BigNumber,
+ takerAddress?: string,
+ feeRecipient: string = constants.NULL_ADDRESS,
+ ): Promise<string> {
+ assert.isValidBuyQuote('buyQuote', buyQuote);
+ if (!_.isUndefined(rate)) {
+ assert.isBigNumber('rate', rate);
+ }
+ if (!_.isUndefined(takerAddress)) {
+ assert.isETHAddressHex('takerAddress', takerAddress);
+ }
+ assert.isETHAddressHex('feeRecipient', feeRecipient);
+ const { orders, feeOrders, feePercentage, assetBuyAmount, maxRate } = buyQuote;
+ // if no takerAddress is provided, try to get one from the provider
+ let finalTakerAddress;
+ if (!_.isUndefined(takerAddress)) {
+ finalTakerAddress = takerAddress;
+ } else {
+ const web3Wrapper = new Web3Wrapper(this.provider);
+ const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
+ const firstAvailableAddress = _.head(availableAddresses);
+ if (!_.isUndefined(firstAvailableAddress)) {
+ finalTakerAddress = firstAvailableAddress;
+ } else {
+ throw new Error(AssetBuyerError.NoAddressAvailable);
+ }
+ }
+ // if no rate is provided, default to the maxRate from buyQuote
+ const desiredRate = rate || maxRate;
+ // calculate how much eth is required to buy assetBuyAmount at the desired rate
+ const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate);
+ const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync(
+ orders,
+ assetBuyAmount,
+ finalTakerAddress,
+ ethAmount,
+ feeOrders,
+ feePercentage,
+ feeRecipient,
+ );
+ return txHash;
+ }
+ /**
+ * Ask the order Provider for orders and process them.
+ */
+ private async _getLatestOrdersAndFillableAmountsAsync(): Promise<AssetBuyerOrdersAndFillableAmounts> {
+ const etherTokenAssetData = this._getEtherTokenAssetDataOrThrow();
+ const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow();
+ // construct order Provider requests
+ const targetOrderProviderRequest = {
+ makerAssetData: this.assetData,
+ takerAssetData: etherTokenAssetData,
+ networkId: this.networkId,
+ };
+ const feeOrderProviderRequest = {
+ makerAssetData: zrxTokenAssetData,
+ takerAssetData: etherTokenAssetData,
+ networkId: this.networkId,
+ };
+ const requests = [targetOrderProviderRequest, feeOrderProviderRequest];
+ // fetch orders and possible fillable amounts
+ const [targetOrderProviderResponse, feeOrderProviderResponse] = await Promise.all(
+ _.map(requests, async request => this.orderProvider.getOrdersAsync(request)),
+ );
+ // since the order provider is an injected dependency, validate that it respects the API
+ // ie. it should only return maker/taker assetDatas that are specified
+ orderProviderResponseProcessor.throwIfInvalidResponse(targetOrderProviderResponse, targetOrderProviderRequest);
+ orderProviderResponseProcessor.throwIfInvalidResponse(feeOrderProviderResponse, feeOrderProviderRequest);
+ // process the responses into one object
+ const ordersAndFillableAmounts = await orderProviderResponseProcessor.processAsync(
+ targetOrderProviderResponse,
+ feeOrderProviderResponse,
+ zrxTokenAssetData,
+ this.expiryBufferSeconds,
+ this._contractWrappers.orderValidator,
+ );
+ return ordersAndFillableAmounts;
+ }
+ /**
+ * Get the assetData that represents the WETH token.
+ * Will throw if WETH does not exist for the current network.
+ */
+ private _getEtherTokenAssetDataOrThrow(): string {
+ return assetDataUtils.getEtherTokenAssetDataOrThrow(this._contractWrappers);
+ }
+ /**
+ * Get the assetData that represents the ZRX token.
+ * Will throw if ZRX does not exist for the current network.
+ */
+ private _getZrxTokenAssetDataOrThrow(): string {
+ return assetDataUtils.getZrxTokenAssetDataOrThrow(this._contractWrappers);
+ }
+}
diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts
new file mode 100644
index 000000000..79b5d9052
--- /dev/null
+++ b/packages/asset-buyer/src/constants.ts
@@ -0,0 +1,20 @@
+import { BigNumber } from '@0xproject/utils';
+
+import { BuyQuoteRequestOpts } from './types';
+
+const DEFAULT_BUY_QUOTE_REQUEST_OPTS: BuyQuoteRequestOpts = {
+ feePercentage: 0,
+ shouldForceOrderRefresh: false,
+ slippagePercentage: 0.2, // 20% slippage protection
+};
+
+export const constants = {
+ ZERO_AMOUNT: new BigNumber(0),
+ NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
+ MAINNET_NETWORK_ID: 1,
+ DEFAULT_ORDER_REFRESH_INTERVAL_MS: 10000, // 10 seconds
+ ETHER_TOKEN_DECIMALS: 18,
+ DEFAULT_BUY_QUOTE_REQUEST_OPTS,
+ MAX_PER_PAGE: 10000,
+ DEFAULT_EXPIRY_BUFFER_SECONDS: 15,
+};
diff --git a/packages/forwarder-helper/src/globals.d.ts b/packages/asset-buyer/src/globals.d.ts
index 94e63a32d..94e63a32d 100644
--- a/packages/forwarder-helper/src/globals.d.ts
+++ b/packages/asset-buyer/src/globals.d.ts
diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts
new file mode 100644
index 000000000..8ef529ac0
--- /dev/null
+++ b/packages/asset-buyer/src/index.ts
@@ -0,0 +1,17 @@
+export { Provider } from 'ethereum-types';
+export { SignedOrder } from '@0xproject/types';
+export { BigNumber } from '@0xproject/utils';
+
+export { AssetBuyer } from './asset_buyer';
+export { BasicOrderProvider } from './order_providers/basic_order_provider';
+export { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider';
+export { StandardRelayerAPIAssetBuyerManager } from './standard_relayer_api_asset_buyer_manager';
+export {
+ AssetBuyerError,
+ BuyQuote,
+ OrderProvider,
+ OrderProviderRequest,
+ OrderProviderResponse,
+ SignedOrderWithRemainingFillableMakerAssetAmount,
+ StandardRelayerApiAssetBuyerManagerError,
+} from './types';
diff --git a/packages/asset-buyer/src/order_providers/basic_order_provider.ts b/packages/asset-buyer/src/order_providers/basic_order_provider.ts
new file mode 100644
index 000000000..9bb2d90ac
--- /dev/null
+++ b/packages/asset-buyer/src/order_providers/basic_order_provider.ts
@@ -0,0 +1,32 @@
+import { schemas } from '@0xproject/json-schemas';
+import { SignedOrder } from '@0xproject/types';
+import * as _ from 'lodash';
+
+import { OrderProvider, OrderProviderRequest, OrderProviderResponse } from '../types';
+import { assert } from '../utils/assert';
+
+export class BasicOrderProvider implements OrderProvider {
+ public readonly orders: SignedOrder[];
+ /**
+ * Instantiates a new BasicOrderProvider instance
+ * @param orders An array of objects that conform to SignedOrder to fetch from.
+ * @return An instance of BasicOrderProvider
+ */
+ constructor(orders: SignedOrder[]) {
+ assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema);
+ this.orders = orders;
+ }
+ /**
+ * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderProviderResponse that satisfies the request.
+ * @param orderProviderRequest An instance of OrderFetcherRequest. See type for more information.
+ * @return An instance of OrderProviderResponse. See type for more information.
+ */
+ public async getOrdersAsync(orderProviderRequest: OrderProviderRequest): Promise<OrderProviderResponse> {
+ assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest);
+ const { makerAssetData, takerAssetData } = orderProviderRequest;
+ const orders = _.filter(this.orders, order => {
+ return order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData;
+ });
+ return { orders };
+ }
+}
diff --git a/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts
new file mode 100644
index 000000000..be3e9da50
--- /dev/null
+++ b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts
@@ -0,0 +1,78 @@
+import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect';
+import * as _ from 'lodash';
+
+import {
+ AssetBuyerError,
+ OrderProvider,
+ OrderProviderRequest,
+ OrderProviderResponse,
+ SignedOrderWithRemainingFillableMakerAssetAmount,
+} from '../types';
+import { assert } from '../utils/assert';
+import { orderUtils } from '../utils/order_utils';
+
+export class StandardRelayerAPIOrderProvider implements OrderProvider {
+ public readonly apiUrl: string;
+ private readonly _sraClient: HttpClient;
+ /**
+ * Given an array of APIOrder objects from a standard relayer api, return an array
+ * of SignedOrderWithRemainingFillableMakerAssetAmounts
+ */
+ private static _getSignedOrderWithRemainingFillableMakerAssetAmountFromApi(
+ apiOrders: APIOrder[],
+ ): SignedOrderWithRemainingFillableMakerAssetAmount[] {
+ const result = _.map(apiOrders, apiOrder => {
+ const { order, metaData } = apiOrder;
+ // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable
+ const remainingFillableTakerAssetAmount = _.get(
+ metaData,
+ 'remainingTakerAssetAmount',
+ order.takerAssetAmount,
+ );
+ const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount(
+ order,
+ remainingFillableTakerAssetAmount,
+ );
+ const newOrder = {
+ ...order,
+ remainingFillableMakerAssetAmount,
+ };
+ return newOrder;
+ });
+ return result;
+ }
+ /**
+ * Instantiates a new StandardRelayerAPIOrderProvider instance
+ * @param apiUrl The standard relayer API base HTTP url you would like to source orders from.
+ * @return An instance of StandardRelayerAPIOrderProvider
+ */
+ constructor(apiUrl: string) {
+ assert.isWebUri('apiUrl', apiUrl);
+ this.apiUrl = apiUrl;
+ this._sraClient = new HttpClient(apiUrl);
+ }
+ /**
+ * Given an object that conforms to OrderProviderRequest, return the corresponding OrderProviderResponse that satisfies the request.
+ * @param orderProviderRequest An instance of OrderProviderRequest. See type for more information.
+ * @return An instance of OrderProviderResponse. See type for more information.
+ */
+ public async getOrdersAsync(orderProviderRequest: OrderProviderRequest): Promise<OrderProviderResponse> {
+ assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest);
+ const { makerAssetData, takerAssetData, networkId } = orderProviderRequest;
+ const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData };
+ const requestOpts = { networkId };
+ let orderbook: OrderbookResponse;
+ try {
+ orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest, requestOpts);
+ } catch (err) {
+ throw new Error(AssetBuyerError.StandardRelayerApiError);
+ }
+ const apiOrders = orderbook.asks.records;
+ const orders = StandardRelayerAPIOrderProvider._getSignedOrderWithRemainingFillableMakerAssetAmountFromApi(
+ apiOrders,
+ );
+ return {
+ orders,
+ };
+ }
+}
diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts
new file mode 100644
index 000000000..947c738a1
--- /dev/null
+++ b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts
@@ -0,0 +1,133 @@
+import { HttpClient } from '@0xproject/connect';
+import { ContractWrappers } from '@0xproject/contract-wrappers';
+import { ObjectMap } from '@0xproject/types';
+import { Provider } from 'ethereum-types';
+import * as _ from 'lodash';
+
+import { AssetBuyer } from './asset_buyer';
+import { constants } from './constants';
+import { assert } from './utils/assert';
+import { assetDataUtils } from './utils/asset_data_utils';
+
+import { OrderProvider, StandardRelayerApiAssetBuyerManagerError } from './types';
+
+export class StandardRelayerAPIAssetBuyerManager {
+ // Map of assetData to AssetBuyer for that assetData
+ private readonly _assetBuyerMap: ObjectMap<AssetBuyer>;
+ /**
+ * Returns an array of all assetDatas available at the provided sraApiUrl
+ * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
+ * @param pairedWithAssetData Optional filter argument to return assetDatas that only pair with this assetData value.
+ *
+ * @return An array of all assetDatas available at the provider sraApiUrl
+ */
+ public static async getAllAvailableAssetDatasAsync(
+ sraApiUrl: string,
+ pairedWithAssetData?: string,
+ ): Promise<string[]> {
+ const client = new HttpClient(sraApiUrl);
+ const params = {
+ assetDataA: pairedWithAssetData,
+ perPage: constants.MAX_PER_PAGE,
+ };
+ const assetPairsResponse = await client.getAssetPairsAsync(params);
+ return _.uniq(_.map(assetPairsResponse.records, pairsItem => pairsItem.assetDataB.assetData));
+ }
+ /**
+ * Instantiates a new StandardRelayerAPIAssetBuyerManager instance with all available assetDatas at the provided sraApiUrl
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
+ * @param orderProvider An object that conforms to OrderProvider, see type for definition.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states.
+ * Defaults to 10000ms (10s).
+ * @return An promise of an instance of StandardRelayerAPIAssetBuyerManager
+ */
+ public static async getAssetBuyerManagerWithAllAvailableAssetDatasAsync(
+ provider: Provider,
+ sraApiUrl: string,
+ orderProvider: OrderProvider,
+ networkId: number = constants.MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs?: number,
+ ): Promise<StandardRelayerAPIAssetBuyerManager> {
+ const contractWrappers = new ContractWrappers(provider, { networkId });
+ const etherTokenAssetData = assetDataUtils.getEtherTokenAssetDataOrThrow(contractWrappers);
+ const assetDatas = await StandardRelayerAPIAssetBuyerManager.getAllAvailableAssetDatasAsync(
+ sraApiUrl,
+ etherTokenAssetData,
+ );
+ return new StandardRelayerAPIAssetBuyerManager(
+ provider,
+ assetDatas,
+ orderProvider,
+ networkId,
+ orderRefreshIntervalMs,
+ );
+ }
+ /**
+ * Instantiates a new StandardRelayerAPIAssetBuyerManager instance
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param assetDatas The assetDatas of the desired assets to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
+ * @param orderProvider An object that conforms to OrderProvider, see type for definition.
+ * @param networkId The ethereum network id. Defaults to 1 (mainnet).
+ * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states.
+ * Defaults to 10000ms (10s).
+ * @return An instance of StandardRelayerAPIAssetBuyerManager
+ */
+ constructor(
+ provider: Provider,
+ assetDatas: string[],
+ orderProvider: OrderProvider,
+ networkId?: number,
+ orderRefreshIntervalMs?: number,
+ ) {
+ assert.assert(assetDatas.length > 0, `Expected 'assetDatas' to be a non-empty array.`);
+ this._assetBuyerMap = _.reduce(
+ assetDatas,
+ (accAssetBuyerMap: ObjectMap<AssetBuyer>, assetData: string) => {
+ accAssetBuyerMap[assetData] = new AssetBuyer(
+ provider,
+ assetData,
+ orderProvider,
+ networkId,
+ orderRefreshIntervalMs,
+ );
+ return accAssetBuyerMap;
+ },
+ {},
+ );
+ }
+ /**
+ * Get an AssetBuyer for the provided assetData
+ * @param assetData The desired assetData.
+ *
+ * @return An instance of AssetBuyer
+ */
+ public getAssetBuyerFromAssetData(assetData: string): AssetBuyer {
+ const assetBuyer = this._assetBuyerMap[assetData];
+ if (_.isUndefined(assetBuyer)) {
+ throw new Error(
+ `${StandardRelayerApiAssetBuyerManagerError.AssetBuyerNotFound}: For assetData ${assetData}`,
+ );
+ }
+ return assetBuyer;
+ }
+ /**
+ * Get an AssetBuyer for the provided ERC20 tokenAddress
+ * @param tokenAddress The desired tokenAddress.
+ *
+ * @return An instance of AssetBuyer
+ */
+ public getAssetBuyerFromERC20TokenAddress(tokenAddress: string): AssetBuyer {
+ const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress);
+ return this.getAssetBuyerFromAssetData(assetData);
+ }
+ /**
+ * Get a list of all the assetDatas that the instance supports
+ *
+ * @return An array of assetData strings
+ */
+ public getAssetDatas(): string[] {
+ return _.keys(this._assetBuyerMap);
+ }
+}
diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts
new file mode 100644
index 000000000..ee6858525
--- /dev/null
+++ b/packages/asset-buyer/src/types.ts
@@ -0,0 +1,86 @@
+import { SignedOrder } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
+
+/**
+ * makerAssetData: The assetData representing the desired makerAsset.
+ * takerAssetData: The assetData representing the desired takerAsset.
+ * networkId: The networkId that the desired orders should be for.
+ */
+export interface OrderProviderRequest {
+ makerAssetData: string;
+ takerAssetData: string;
+ networkId: number;
+}
+
+/**
+ * orders: An array of orders with optional remaining fillable makerAsset amounts. See type for more info.
+ */
+export interface OrderProviderResponse {
+ orders: SignedOrderWithRemainingFillableMakerAssetAmount[];
+}
+
+/**
+ * A normal SignedOrder with one extra optional property `remainingFillableMakerAssetAmount`
+ * remainingFillableMakerAssetAmount: The amount of the makerAsset that is available to be filled
+ */
+export interface SignedOrderWithRemainingFillableMakerAssetAmount extends SignedOrder {
+ remainingFillableMakerAssetAmount?: BigNumber;
+}
+/**
+ * Given an OrderProviderRequest, get an OrderProviderResponse.
+ */
+export interface OrderProvider {
+ getOrdersAsync: (orderProviderRequest: OrderProviderRequest) => Promise<OrderProviderResponse>;
+}
+
+/**
+ * assetData: String that represents a specific asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
+ * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested assetBuyAmount plus slippage.
+ * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above.
+ * minRate: Min rate that needs to be paid in order to execute the buy.
+ * maxRate: Max rate that can be paid in order to execute the buy.
+ * assetBuyAmount: The amount of asset to buy.
+ * feePercentage: Optional affiliate fee percentage used to calculate the eth amounts above.
+ */
+export interface BuyQuote {
+ assetData: string;
+ orders: SignedOrder[];
+ feeOrders: SignedOrder[];
+ minRate: BigNumber;
+ maxRate: BigNumber;
+ assetBuyAmount: BigNumber;
+ feePercentage?: number;
+}
+
+export interface BuyQuoteRequestOpts {
+ feePercentage: number;
+ shouldForceOrderRefresh: boolean;
+ slippagePercentage: number;
+}
+
+/**
+ * Possible errors thrown by an AssetBuyer instance or associated static methods.
+ */
+export enum AssetBuyerError {
+ NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND',
+ NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND',
+ StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR',
+ InsufficientAssetLiquidity = 'INSUFFICIENT_ASSET_LIQUIDITY',
+ InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY',
+ NoAddressAvailable = 'NO_ADDRESS_AVAILABLE',
+ InvalidOrderProviderResponse = 'INVALID_ORDER_PROVIDER_RESPONSE',
+}
+
+/**
+ * Possible errors thrown by an StandardRelayerApiAssetBuyerManager instance or associated static methods.
+ */
+export enum StandardRelayerApiAssetBuyerManagerError {
+ AssetBuyerNotFound = 'ASSET_BUYER_NOT_FOUND',
+}
+
+export interface AssetBuyerOrdersAndFillableAmounts {
+ orders: SignedOrder[];
+ feeOrders: SignedOrder[];
+ remainingFillableMakerAssetAmounts: BigNumber[];
+ remainingFillableFeeAmounts: BigNumber[];
+}
diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts
new file mode 100644
index 000000000..04f425237
--- /dev/null
+++ b/packages/asset-buyer/src/utils/assert.ts
@@ -0,0 +1,51 @@
+import { assert as sharedAssert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
+import { SignedOrder } from '@0xproject/types';
+import * as _ from 'lodash';
+
+import { BuyQuote, OrderProvider, OrderProviderRequest } from '../types';
+
+export const assert = {
+ ...sharedAssert,
+ isValidBuyQuote(variableName: string, buyQuote: BuyQuote): void {
+ sharedAssert.isHexString(`${variableName}.assetData`, buyQuote.assetData);
+ sharedAssert.doesConformToSchema(`${variableName}.orders`, buyQuote.orders, schemas.signedOrdersSchema);
+ sharedAssert.doesConformToSchema(`${variableName}.feeOrders`, buyQuote.feeOrders, schemas.signedOrdersSchema);
+ sharedAssert.isBigNumber(`${variableName}.minRate`, buyQuote.minRate);
+ sharedAssert.isBigNumber(`${variableName}.maxRate`, buyQuote.maxRate);
+ sharedAssert.isBigNumber(`${variableName}.assetBuyAmount`, buyQuote.assetBuyAmount);
+ if (!_.isUndefined(buyQuote.feePercentage)) {
+ sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage);
+ }
+ },
+ isValidOrderProvider(variableName: string, orderFetcher: OrderProvider): void {
+ sharedAssert.isFunction(`${variableName}.getOrdersAsync`, orderFetcher.getOrdersAsync);
+ },
+ isValidOrderProviderRequest(variableName: string, orderFetcherRequest: OrderProviderRequest): void {
+ sharedAssert.isHexString(`${variableName}.makerAssetData`, orderFetcherRequest.makerAssetData);
+ sharedAssert.isHexString(`${variableName}.takerAssetData`, orderFetcherRequest.takerAssetData);
+ sharedAssert.isNumber(`${variableName}.networkId`, orderFetcherRequest.networkId);
+ },
+ areValidProvidedOrders(variableName: string, orders: SignedOrder[]): void {
+ if (orders.length === 0) {
+ return;
+ }
+ const makerAssetData = orders[0].makerAssetData;
+ const takerAssetData = orders[0].takerAssetData;
+ const filteredOrders = _.filter(
+ orders,
+ order => order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData,
+ );
+ sharedAssert.assert(
+ orders.length === filteredOrders.length,
+ `Expected all orders in ${variableName} to have the same makerAssetData and takerAssetData.`,
+ );
+ },
+ isValidPercentage(variableName: string, percentage: number): void {
+ assert.isNumber(variableName, percentage);
+ assert.assert(
+ percentage >= 0 && percentage <= 1,
+ `Expected ${variableName} to be between 0 and 1, but is ${percentage}`,
+ );
+ },
+};
diff --git a/packages/asset-buyer/src/utils/asset_data_utils.ts b/packages/asset-buyer/src/utils/asset_data_utils.ts
new file mode 100644
index 000000000..d05ff2504
--- /dev/null
+++ b/packages/asset-buyer/src/utils/asset_data_utils.ts
@@ -0,0 +1,26 @@
+import { ContractWrappers } from '@0xproject/contract-wrappers';
+import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils';
+import * as _ from 'lodash';
+
+import { AssetBuyerError } from '../types';
+
+export const assetDataUtils = {
+ ...sharedAssetDataUtils,
+ getEtherTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string {
+ const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists();
+ if (_.isUndefined(etherTokenAddressIfExists)) {
+ throw new Error(AssetBuyerError.NoEtherTokenContractFound);
+ }
+ const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists);
+ return etherTokenAssetData;
+ },
+ getZrxTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string {
+ let zrxTokenAssetData: string;
+ try {
+ zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData();
+ } catch (err) {
+ throw new Error(AssetBuyerError.NoZrxTokenContractFound);
+ }
+ return zrxTokenAssetData;
+ },
+};
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
new file mode 100644
index 000000000..9946924ef
--- /dev/null
+++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
@@ -0,0 +1,89 @@
+import { marketUtils } from '@0xproject/order-utils';
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+
+import { constants } from '../constants';
+import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types';
+
+import { orderUtils } from './order_utils';
+
+// Calculates a buy quote for orders that have WETH as the takerAsset
+export const buyQuoteCalculator = {
+ calculate(
+ ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts,
+ assetBuyAmount: BigNumber,
+ feePercentage: number,
+ slippagePercentage: number,
+ ): BuyQuote {
+ const {
+ orders,
+ feeOrders,
+ remainingFillableMakerAssetAmounts,
+ remainingFillableFeeAmounts,
+ } = ordersAndFillableAmounts;
+ const slippageBufferAmount = assetBuyAmount.mul(slippagePercentage).round();
+ const {
+ resultOrders,
+ remainingFillAmount,
+ ordersRemainingFillableMakerAssetAmounts,
+ } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(orders, assetBuyAmount, {
+ remainingFillableMakerAssetAmounts,
+ slippageBufferAmount,
+ });
+ if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) {
+ throw new Error(AssetBuyerError.InsufficientAssetLiquidity);
+ }
+ // TODO(bmillman): optimization
+ // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to
+ // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage
+ const {
+ resultFeeOrders,
+ remainingFeeAmount,
+ feeOrdersRemainingFillableMakerAssetAmounts,
+ } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(resultOrders, feeOrders, {
+ remainingFillableMakerAssetAmounts,
+ remainingFillableFeeAmounts,
+ });
+ if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) {
+ throw new Error(AssetBuyerError.InsufficientZrxLiquidity);
+ }
+ const assetData = orders[0].makerAssetData;
+
+ // calculate minRate and maxRate by calculating min and max eth usage and then dividing into
+ // assetBuyAmount to get assetData / WETH, needs to take into account feePercentage as well
+ // minEthAmount = (sum(takerAssetAmount[i]) until sum(makerAssetAmount[i]) >= assetBuyAmount ) * (1 + feePercentage)
+ // maxEthAmount = (sum(takerAssetAmount[i]) until i == orders.length) * (1 + feePercentage)
+ const allOrders = _.concat(resultOrders, resultFeeOrders);
+ const allRemainingAmounts = _.concat(
+ ordersRemainingFillableMakerAssetAmounts,
+ feeOrdersRemainingFillableMakerAssetAmounts,
+ );
+ let minEthAmount = constants.ZERO_AMOUNT;
+ let maxEthAmount = constants.ZERO_AMOUNT;
+ let cumulativeMakerAmount = constants.ZERO_AMOUNT;
+ _.forEach(allOrders, (order, index) => {
+ const remainingFillableMakerAssetAmount = allRemainingAmounts[index];
+ const claimableTakerAssetAmount = orderUtils.calculateRemainingTakerAssetAmount(
+ order,
+ remainingFillableMakerAssetAmount,
+ );
+ // taker asset is always assumed to be WETH
+ maxEthAmount = maxEthAmount.plus(claimableTakerAssetAmount);
+ if (cumulativeMakerAmount.lessThan(assetBuyAmount)) {
+ minEthAmount = minEthAmount.plus(claimableTakerAssetAmount);
+ }
+ cumulativeMakerAmount = cumulativeMakerAmount.plus(remainingFillableMakerAssetAmount);
+ });
+ const feeAdjustedMinRate = minEthAmount.mul(feePercentage + 1).div(assetBuyAmount);
+ const feeAdjustedMaxRate = minEthAmount.mul(feePercentage + 1).div(assetBuyAmount);
+ return {
+ assetData,
+ orders: resultOrders,
+ feeOrders: resultFeeOrders,
+ minRate: feeAdjustedMinRate,
+ maxRate: feeAdjustedMaxRate,
+ assetBuyAmount,
+ feePercentage,
+ };
+ },
+};
diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
new file mode 100644
index 000000000..31fdcc182
--- /dev/null
+++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
@@ -0,0 +1,202 @@
+import { OrderAndTraderInfo, OrderStatus, OrderValidatorWrapper } from '@0xproject/contract-wrappers';
+import { sortingUtils } from '@0xproject/order-utils';
+import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator';
+import { SignedOrder } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+
+import { constants } from '../constants';
+import {
+ AssetBuyerError,
+ AssetBuyerOrdersAndFillableAmounts,
+ OrderProviderRequest,
+ OrderProviderResponse,
+ SignedOrderWithRemainingFillableMakerAssetAmount,
+} from '../types';
+
+import { orderUtils } from './order_utils';
+
+interface OrdersAndRemainingFillableMakerAssetAmounts {
+ orders: SignedOrder[];
+ remainingFillableMakerAssetAmounts: BigNumber[];
+}
+
+export const orderProviderResponseProcessor = {
+ throwIfInvalidResponse(response: OrderProviderResponse, request: OrderProviderRequest): void {
+ const { makerAssetData, takerAssetData } = request;
+ _.forEach(response.orders, order => {
+ if (order.makerAssetData !== makerAssetData || order.takerAssetData !== takerAssetData) {
+ throw new Error(AssetBuyerError.InvalidOrderProviderResponse);
+ }
+ });
+ },
+ /**
+ * Take the responses for the target orders to buy and fee orders and process them.
+ * Processing includes:
+ * - Drop orders that are expired or not open orders (null taker address)
+ * - If shouldValidateOnChain, attempt to grab fillable amounts from on-chain otherwise assume completely fillable
+ * - Sort by rate
+ */
+ async processAsync(
+ targetOrderProviderResponse: OrderProviderResponse,
+ feeOrderProviderResponse: OrderProviderResponse,
+ zrxTokenAssetData: string,
+ expiryBufferSeconds: number,
+ orderValidator?: OrderValidatorWrapper,
+ ): Promise<AssetBuyerOrdersAndFillableAmounts> {
+ // drop orders that are expired or not open
+ const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(
+ targetOrderProviderResponse.orders,
+ expiryBufferSeconds,
+ );
+ const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(
+ feeOrderProviderResponse.orders,
+ expiryBufferSeconds,
+ );
+ // set the orders to be sorted equal to the filtered orders
+ let unsortedTargetOrders = filteredTargetOrders;
+ let unsortedFeeOrders = filteredFeeOrders;
+ // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts
+ if (!_.isUndefined(orderValidator)) {
+ // TODO(bmillman): improvement
+ // try/catch these requests and throw a more domain specific error
+ // TODO(bmillman): optimization
+ // reduce this to once RPC call buy combining orders into one array and then splitting up the response
+ const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all(
+ _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => {
+ const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS);
+ return orderValidator.getOrdersAndTradersInfoAsync(ordersToBeValidated, takerAddresses);
+ }),
+ );
+ // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts
+ unsortedTargetOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
+ filteredTargetOrders,
+ targetOrdersAndTradersInfo,
+ zrxTokenAssetData,
+ );
+ // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts
+ unsortedFeeOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
+ filteredFeeOrders,
+ feeOrdersAndTradersInfo,
+ zrxTokenAssetData,
+ );
+ }
+ // sort orders by rate
+ // TODO(bmillman): optimization
+ // provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens
+ const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders);
+ const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders);
+ // unbundle orders and fillable amounts and compile final result
+ const targetOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedTargetOrders);
+ const feeOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedFeeOrders);
+ return {
+ orders: targetOrdersAndRemainingFillableMakerAssetAmounts.orders,
+ feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders,
+ remainingFillableMakerAssetAmounts:
+ targetOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts,
+ remainingFillableFeeAmounts:
+ feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts,
+ };
+ },
+};
+
+/**
+ * Given an array of orders, return a new array with expired and non open orders filtered out.
+ */
+function filterOutExpiredAndNonOpenOrders(
+ orders: SignedOrderWithRemainingFillableMakerAssetAmount[],
+ expiryBufferSeconds: number,
+): SignedOrderWithRemainingFillableMakerAssetAmount[] {
+ const result = _.filter(orders, order => {
+ return orderUtils.isOpenOrder(order) && !orderUtils.willOrderExpire(order, expiryBufferSeconds);
+ });
+ return result;
+}
+
+/**
+ * Given an array of orders and corresponding on-chain infos, return a subset of the orders
+ * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts.
+ */
+function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
+ inputOrders: SignedOrder[],
+ ordersAndTradersInfo: OrderAndTraderInfo[],
+ zrxAssetData: string,
+): SignedOrderWithRemainingFillableMakerAssetAmount[] {
+ // iterate through the input orders and find the ones that are still fillable
+ // for the orders that are still fillable, calculate the remaining fillable maker asset amount
+ const result = _.reduce(
+ inputOrders,
+ (accOrders, order, index) => {
+ // get corresponding on-chain state for the order
+ const { orderInfo, traderInfo } = ordersAndTradersInfo[index];
+ // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating
+ if (orderInfo.orderStatus !== OrderStatus.FILLABLE) {
+ return accOrders;
+ }
+ // if the order IS fillable, add the order and calculate the remaining fillable amount
+ const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]);
+ const transferrableFeeAssetAmount = BigNumber.min([
+ traderInfo.makerZrxAllowance,
+ traderInfo.makerZrxBalance,
+ ]);
+ const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount);
+ const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount(
+ order,
+ remainingTakerAssetAmount,
+ );
+ const remainingFillableCalculator = new RemainingFillableCalculator(
+ order.makerFee,
+ order.makerAssetAmount,
+ order.makerAssetData === zrxAssetData,
+ transferrableAssetAmount,
+ transferrableFeeAssetAmount,
+ remainingMakerAssetAmount,
+ );
+ const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable();
+ // if the order does not have any remaining fillable makerAsset, do not add anything to the accumulations and continue iterating
+ if (remainingFillableAmount.lte(constants.ZERO_AMOUNT)) {
+ return accOrders;
+ }
+ const orderWithRemainingFillableMakerAssetAmount = {
+ ...order,
+ remainingFillableMakerAssetAmount: remainingFillableAmount,
+ };
+ const newAccOrders = _.concat(accOrders, orderWithRemainingFillableMakerAssetAmount);
+ return newAccOrders;
+ },
+ [] as SignedOrderWithRemainingFillableMakerAssetAmount[],
+ );
+ return result;
+}
+
+/**
+ * Given an array of orders with remaining fillable maker asset amounts. Unbundle into an instance of OrdersAndRemainingFillableMakerAssetAmounts.
+ * If an order is missing a corresponding remainingFillableMakerAssetAmount, assume it is completely fillable.
+ */
+function unbundleOrdersWithAmounts(
+ ordersWithAmounts: SignedOrderWithRemainingFillableMakerAssetAmount[],
+): OrdersAndRemainingFillableMakerAssetAmounts {
+ const result = _.reduce(
+ ordersWithAmounts,
+ (acc, orderWithAmount) => {
+ const { orders, remainingFillableMakerAssetAmounts } = acc;
+ const { remainingFillableMakerAssetAmount, ...order } = orderWithAmount;
+ // if we are still missing a remainingFillableMakerAssetAmount, assume the order is completely fillable
+ const newRemainingAmount = remainingFillableMakerAssetAmount || order.makerAssetAmount;
+ // if remaining amount is less than or equal to zero, do not add it
+ if (newRemainingAmount.lte(constants.ZERO_AMOUNT)) {
+ return acc;
+ }
+ const newAcc = {
+ orders: _.concat(orders, order),
+ remainingFillableMakerAssetAmounts: _.concat(remainingFillableMakerAssetAmounts, newRemainingAmount),
+ };
+ return newAcc;
+ },
+ {
+ orders: [] as SignedOrder[],
+ remainingFillableMakerAssetAmounts: [] as BigNumber[],
+ },
+ );
+ return result;
+}
diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts
new file mode 100644
index 000000000..62166eb76
--- /dev/null
+++ b/packages/asset-buyer/src/utils/order_utils.ts
@@ -0,0 +1,30 @@
+import { SignedOrder } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
+
+import { constants } from '../constants';
+
+export const orderUtils = {
+ isOrderExpired(order: SignedOrder): boolean {
+ return orderUtils.willOrderExpire(order, 0);
+ },
+ willOrderExpire(order: SignedOrder, secondsFromNow: number): boolean {
+ const millisecondsInSecond = 1000;
+ const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round();
+ return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec.minus(secondsFromNow));
+ },
+ calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber {
+ if (remainingTakerAssetAmount.eq(0)) {
+ return constants.ZERO_AMOUNT;
+ }
+ return remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount);
+ },
+ calculateRemainingTakerAssetAmount(order: SignedOrder, remainingMakerAssetAmount: BigNumber): BigNumber {
+ if (remainingMakerAssetAmount.eq(0)) {
+ return constants.ZERO_AMOUNT;
+ }
+ return remainingMakerAssetAmount.times(order.takerAssetAmount).dividedToIntegerBy(order.makerAssetAmount);
+ },
+ isOpenOrder(order: SignedOrder): boolean {
+ return order.takerAddress === constants.NULL_ADDRESS;
+ },
+};
diff --git a/packages/forwarder-helper/test/utils/chai_setup.ts b/packages/asset-buyer/test/utils/chai_setup.ts
index 1a8733093..1a8733093 100644
--- a/packages/forwarder-helper/test/utils/chai_setup.ts
+++ b/packages/asset-buyer/test/utils/chai_setup.ts
diff --git a/packages/forwarder-helper/tsconfig.json b/packages/asset-buyer/tsconfig.json
index 2ee711adc..2ee711adc 100644
--- a/packages/forwarder-helper/tsconfig.json
+++ b/packages/asset-buyer/tsconfig.json
diff --git a/packages/forwarder-helper/tslint.json b/packages/asset-buyer/tslint.json
index ffaefe83a..ffaefe83a 100644
--- a/packages/forwarder-helper/tslint.json
+++ b/packages/asset-buyer/tslint.json
diff --git a/packages/forwarder-helper/typedoc-tsconfig.json b/packages/asset-buyer/typedoc-tsconfig.json
index c9b0af1ae..c9b0af1ae 100644
--- a/packages/forwarder-helper/typedoc-tsconfig.json
+++ b/packages/asset-buyer/typedoc-tsconfig.json
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index 89580ca90..723963f87 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "2.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "2.0.2",
"changes": [
diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md
index a81f7a3a7..c4ba59e26 100644
--- a/packages/base-contract/CHANGELOG.md
+++ b/packages/base-contract/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.3 - _September 21, 2018_
+
+ * Dependencies updated
+
## v2.0.2 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index 6542f48df..44b0807ba 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/base-contract",
- "version": "2.0.2",
+ "version": "2.0.3",
"engines": {
"node": ">=6.12"
},
@@ -40,10 +40,10 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"ethers": "3.0.22",
"lodash": "^4.17.5"
},
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
index c6e753261..f5ca80279 100644
--- a/packages/connect/CHANGELOG.json
+++ b/packages/connect/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "2.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1537369748,
"version": "2.0.1",
"changes": [
diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md
index 8e9ebe3e0..1f8116f88 100644
--- a/packages/connect/CHANGELOG.md
+++ b/packages/connect/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.2 - _September 21, 2018_
+
+ * Dependencies updated
+
## v2.0.1 - _September 19, 2018_
* Dependencies updated
diff --git a/packages/connect/package.json b/packages/connect/package.json
index 1308aa5b2..1575afe01 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
- "version": "2.0.1",
+ "version": "2.0.2",
"engines": {
"node": ">=6.12"
},
@@ -43,12 +43,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
"lodash": "^4.17.5",
"query-string": "^5.0.1",
"sinon": "^4.0.0",
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index 87d5c30be..bdcfdd8d2 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -29,7 +29,7 @@ const TRAILING_SLASHES_REGEX = /\/+$/;
/**
* This class includes all the functionality related to interacting with a set of HTTP endpoints
- * that implement the standard relayer API v0
+ * that implement the standard relayer API v2
*/
export class HttpClient implements Client {
private readonly _apiEndpointUrl: string;
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index a9e631157..2f8a02a1a 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.3",
"changes": [
{
diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md
index 69561213e..3757bd6ba 100644
--- a/packages/contract-wrappers/CHANGELOG.md
+++ b/packages/contract-wrappers/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.4 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.3 - _September 19, 2018_
* Drastically reduce the bundle size by removing unused parts of included contract artifacts.
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index ece5c9649..331ff1701 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/contract-wrappers",
- "version": "1.0.3",
+ "version": "1.0.4",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@@ -41,14 +41,14 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/migrations": "^1.0.9",
- "@0xproject/subproviders": "^2.0.2",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/migrations": "^1.0.10",
+ "@0xproject/subproviders": "^2.0.3",
"@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.2",
"@types/web3-provider-engine": "^14.0.0",
@@ -72,16 +72,16 @@
"web3-provider-engine": "14.0.6"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/fill-scenarios": "^1.0.2",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/fill-scenarios": "^1.0.3",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"ethereumjs-blockstream": "5.0.0",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
index 19de17c0a..19a882712 100644
--- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
@@ -2,6 +2,7 @@ import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import {
BlockParamLiteral,
+ BlockWithoutTransactionData,
ContractAbi,
ContractArtifact,
FilterObject,
@@ -174,7 +175,7 @@ export abstract class ContractWrapper {
throw new Error(ContractWrappersError.SubscriptionAlreadyPresent);
}
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
- this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
+ this._getBlockOrNullAsync.bind(this),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose),
);
@@ -194,6 +195,14 @@ export abstract class ContractWrapper {
this._onLogStateChanged.bind(this, isRemoved),
);
}
+ // This method only exists in order to comply with the expected interface of Blockstream's constructor
+ private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> {
+ const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper);
+ if (_.isUndefined(blockIfExists)) {
+ return null;
+ }
+ return blockIfExists;
+ }
// HACK: This should be a package-scoped method (which doesn't exist in TS)
// We don't want this method available in the public interface for all classes
// who inherit from ContractWrapper, and it is only used by the internal implementation
@@ -212,11 +221,14 @@ export abstract class ContractWrapper {
delete this._blockAndLogStreamerIfExists;
}
private async _reconcileBlockAsync(): Promise<void> {
- const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest);
+ const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest);
+ if (_.isUndefined(latestBlockIfExists)) {
+ return; // noop
+ }
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
- await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block);
+ await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block);
}
}
}
diff --git a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
index 13ef0fe01..906222731 100644
--- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
@@ -12,6 +12,7 @@ import { TransactionOpts } from '../types';
import { assert } from '../utils/assert';
import { calldataOptimizationUtils } from '../utils/calldata_optimization_utils';
import { constants } from '../utils/constants';
+import { utils } from '../utils/utils';
import { ContractWrapper } from './contract_wrapper';
import { ForwarderContract } from './generated/forwarder';
@@ -57,7 +58,7 @@ export class ForwarderWrapper extends ContractWrapper {
takerAddress: string,
ethAmount: BigNumber,
signedFeeOrders: SignedOrder[] = [],
- feePercentage: BigNumber = constants.ZERO_AMOUNT,
+ feePercentage: number = 0,
feeRecipientAddress: string = constants.NULL_ADDRESS,
txOpts: TransactionOpts = {},
): Promise<string> {
@@ -66,7 +67,7 @@ export class ForwarderWrapper extends ContractWrapper {
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
assert.isBigNumber('ethAmount', ethAmount);
assert.doesConformToSchema('signedFeeOrders', signedFeeOrders, schemas.signedOrdersSchema);
- assert.isBigNumber('feePercentage', feePercentage);
+ assert.isNumber('feePercentage', feePercentage);
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
// other assertions
@@ -76,6 +77,8 @@ export class ForwarderWrapper extends ContractWrapper {
this.getZRXTokenAddress(),
this.getEtherTokenAddress(),
);
+ // format feePercentage
+ const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
// lowercase input addresses
const normalizedTakerAddress = takerAddress.toLowerCase();
const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase();
@@ -89,7 +92,7 @@ export class ForwarderWrapper extends ContractWrapper {
_.map(optimizedMarketOrders, order => order.signature),
optimizedFeeOrders,
_.map(optimizedFeeOrders, order => order.signature),
- feePercentage,
+ formattedFeePercentage,
feeRecipientAddress,
{
value: ethAmount,
@@ -124,7 +127,7 @@ export class ForwarderWrapper extends ContractWrapper {
takerAddress: string,
ethAmount: BigNumber,
signedFeeOrders: SignedOrder[] = [],
- feePercentage: BigNumber = constants.ZERO_AMOUNT,
+ feePercentage: number = 0,
feeRecipientAddress: string = constants.NULL_ADDRESS,
txOpts: TransactionOpts = {},
): Promise<string> {
@@ -134,7 +137,7 @@ export class ForwarderWrapper extends ContractWrapper {
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
assert.isBigNumber('ethAmount', ethAmount);
assert.doesConformToSchema('signedFeeOrders', signedFeeOrders, schemas.signedOrdersSchema);
- assert.isBigNumber('feePercentage', feePercentage);
+ assert.isNumber('feePercentage', feePercentage);
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
// other assertions
@@ -144,6 +147,8 @@ export class ForwarderWrapper extends ContractWrapper {
this.getZRXTokenAddress(),
this.getEtherTokenAddress(),
);
+ // format feePercentage
+ const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
// lowercase input addresses
const normalizedTakerAddress = takerAddress.toLowerCase();
const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase();
@@ -158,7 +163,7 @@ export class ForwarderWrapper extends ContractWrapper {
_.map(optimizedMarketOrders, order => order.signature),
optimizedFeeOrders,
_.map(optimizedFeeOrders, order => order.signature),
- feePercentage,
+ formattedFeePercentage,
feeRecipientAddress,
{
value: ethAmount,
diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts
index 2df11538c..78441decf 100644
--- a/packages/contract-wrappers/src/utils/constants.ts
+++ b/packages/contract-wrappers/src/utils/constants.ts
@@ -12,4 +12,6 @@ export const constants = {
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
ZERO_AMOUNT: new BigNumber(0),
+ ONE_AMOUNT: new BigNumber(1),
+ ETHER_TOKEN_DECIMALS: 18,
};
diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts
index 689a7ee0a..f7949ec34 100644
--- a/packages/contract-wrappers/src/utils/utils.ts
+++ b/packages/contract-wrappers/src/utils/utils.ts
@@ -1,4 +1,7 @@
import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+
+import { constants } from './constants';
export const utils = {
getCurrentUnixTimestampSec(): BigNumber {
@@ -8,4 +11,7 @@ export const utils = {
getCurrentUnixTimestampMs(): BigNumber {
return new BigNumber(Date.now());
},
+ numberPercentageToEtherTokenAmountPercentage(percentage: number): BigNumber {
+ return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).mul(percentage);
+ },
};
diff --git a/packages/contract-wrappers/test/subscription_test.ts b/packages/contract-wrappers/test/subscription_test.ts
index 81b9012bd..68ef7225e 100644
--- a/packages/contract-wrappers/test/subscription_test.ts
+++ b/packages/contract-wrappers/test/subscription_test.ts
@@ -61,7 +61,7 @@ describe('SubscriptionTest', () => {
callback,
);
stubs = [
- Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockAsync').throws(
+ Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockIfExistsAsync').throws(
new Error('JSON RPC error'),
),
];
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 1c912d3a7..63de510b1 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
- "version": "2.1.44",
+ "version": "2.1.45",
"engines": {
"node": ">=6.12"
},
@@ -45,16 +45,16 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/sol-compiler": "^1.1.2",
- "@0xproject/sol-cov": "^2.1.2",
- "@0xproject/subproviders": "^2.0.2",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/sol-compiler": "^1.1.3",
+ "@0xproject/sol-cov": "^2.1.3",
+ "@0xproject/subproviders": "^2.0.3",
"@0xproject/tslint-config": "^1.0.7",
"@types/bn.js": "^4.11.0",
"@types/ethereumjs-abi": "^0.6.0",
"@types/lodash": "4.14.104",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
@@ -72,15 +72,15 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"@types/js-combinatorics": "^0.5.29",
"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/contracts/test/multisig/multi_sig_with_time_lock.ts b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
index 05d8bbb36..0b17c298b 100644
--- a/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
@@ -269,7 +269,10 @@ describe('MultiSigWalletWithTimeLock', () => {
expect(confirmRes.logs).to.have.length(2);
const blockNum = await web3Wrapper.getBlockNumberAsync();
- const blockInfo = await web3Wrapper.getBlockAsync(blockNum);
+ const blockInfo = await web3Wrapper.getBlockIfExistsAsync(blockNum);
+ if (_.isUndefined(blockInfo)) {
+ throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`);
+ }
const timestamp = new BigNumber(blockInfo.timestamp);
const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId));
diff --git a/packages/contracts/test/utils/block_timestamp.ts b/packages/contracts/test/utils/block_timestamp.ts
index 1159792c4..66c13eed1 100644
--- a/packages/contracts/test/utils/block_timestamp.ts
+++ b/packages/contracts/test/utils/block_timestamp.ts
@@ -35,6 +35,9 @@ export async function increaseTimeAndMineBlockAsync(seconds: number): Promise<nu
* @returns a new Promise which will resolve with the timestamp in seconds.
*/
export async function getLatestBlockTimestampAsync(): Promise<number> {
- const currentBlock = await web3Wrapper.getBlockAsync('latest');
- return currentBlock.timestamp;
+ const currentBlockIfExists = await web3Wrapper.getBlockIfExistsAsync('latest');
+ if (_.isUndefined(currentBlockIfExists)) {
+ throw new Error(`Unable to fetch latest block.`);
+ }
+ return currentBlockIfExists.timestamp;
}
diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json
index 839af99ac..e834eb1a3 100644
--- a/packages/dev-utils/CHANGELOG.json
+++ b/packages/dev-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.8",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.7",
"changes": [
diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md
index c1737c884..34f29418b 100644
--- a/packages/dev-utils/CHANGELOG.md
+++ b/packages/dev-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.8 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.7 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
index ff8bb3534..3ded87c05 100644
--- a/packages/dev-utils/package.json
+++ b/packages/dev-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
- "version": "1.0.7",
+ "version": "1.0.8",
"engines": {
"node": ">=6.12"
},
@@ -42,12 +42,12 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"lodash": "^4.17.5"
},
"publishConfig": {
diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json
index 5bb6965ee..20d33ea38 100644
--- a/packages/ethereum-types/CHANGELOG.json
+++ b/packages/ethereum-types/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.6",
"changes": [
diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md
index 0131f6319..0de27c2fb 100644
--- a/packages/ethereum-types/CHANGELOG.md
+++ b/packages/ethereum-types/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.7 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.6 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json
index afe480916..c1abfb79b 100644
--- a/packages/ethereum-types/package.json
+++ b/packages/ethereum-types/package.json
@@ -1,6 +1,6 @@
{
"name": "ethereum-types",
- "version": "1.0.6",
+ "version": "1.0.7",
"engines": {
"node": ">=6.12"
},
@@ -36,7 +36,7 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"bignumber.js": "~4.1.0"
},
"publishConfig": {
diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts
index 7bf1721a7..e75a2311c 100644
--- a/packages/ethereum-types/src/index.ts
+++ b/packages/ethereum-types/src/index.ts
@@ -238,7 +238,7 @@ export enum AbiType {
Fallback = 'fallback',
}
-export type ContractEventArg = string | BigNumber | number | boolean;
+export type ContractEventArg = any;
export interface DecodedLogArgs {
[argName: string]: ContractEventArg;
diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json
index dbcabe632..e378c7cf0 100644
--- a/packages/fill-scenarios/CHANGELOG.json
+++ b/packages/fill-scenarios/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/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md
index 409e5035c..16fbb4f34 100644
--- a/packages/fill-scenarios/CHANGELOG.md
+++ b/packages/fill-scenarios/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/fill-scenarios/package.json b/packages/fill-scenarios/package.json
index 4592ca091..474618a14 100644
--- a/packages/fill-scenarios/package.json
+++ b/packages/fill-scenarios/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/fill-scenarios",
- "version": "1.0.2",
+ "version": "1.0.3",
"description": "0x order fill scenario generator",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md",
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
+ "@0xproject/abi-gen": "^1.0.9",
"@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104",
"copyfiles": "^2.0.0",
@@ -37,13 +37,13 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"ethers": "3.0.22",
"lodash": "^4.17.5"
},
diff --git a/packages/forwarder-helper/CHANGELOG.json b/packages/forwarder-helper/CHANGELOG.json
deleted file mode 100644
index aef30e4d0..000000000
--- a/packages/forwarder-helper/CHANGELOG.json
+++ /dev/null
@@ -1,48 +0,0 @@
-[
- {
- "timestamp": 1537369748,
- "version": "1.0.3",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1537265493,
- "version": "1.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1536142250,
- "version": "1.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "1.0.1-rc.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1535377027
- },
- {
- "version": "1.0.1-rc.1",
- "changes": [
- {
- "note": "Add initial forwarderHelperFactory",
- "pr": 997
- }
- ],
- "timestamp": 1535133899
- }
-]
diff --git a/packages/forwarder-helper/CHANGELOG.md b/packages/forwarder-helper/CHANGELOG.md
deleted file mode 100644
index 4c26e6980..000000000
--- a/packages/forwarder-helper/CHANGELOG.md
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
-changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
-Edit the package's CHANGELOG.json file only.
--->
-
-CHANGELOG
-
-## v1.0.3 - _September 19, 2018_
-
- * Dependencies updated
-
-## v1.0.2 - _September 18, 2018_
-
- * Dependencies updated
-
-## v1.0.1 - _September 5, 2018_
-
- * Dependencies updated
-
-## v1.0.1-rc.2 - _August 27, 2018_
-
- * Dependencies updated
-
-## v1.0.1-rc.1 - _August 24, 2018_
-
- * Add initial forwarderHelperFactory (#997)
diff --git a/packages/forwarder-helper/README.md b/packages/forwarder-helper/README.md
deleted file mode 100644
index c74526910..000000000
--- a/packages/forwarder-helper/README.md
+++ /dev/null
@@ -1,83 +0,0 @@
-## @0xproject/forwarder-helper
-
-Provides convenience objects to help work with the Forwarder Contract
-
-### Read the [Documentation](https://0xproject.com/docs/forwarder-helper).
-
-## Installation
-
-```bash
-yarn add @0xproject/forwarder-helper
-```
-
-**Import**
-
-```typescript
-import { forwarderHelperFactory } from '@0xproject/forwarder-helper';
-```
-
-or
-
-```javascript
-var forwarderHelperFactory = require('@0xproject/forwarder-helper').forwarderHelperFactory;
-```
-
-If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-
-```json
-"compilerOptions": {
- "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
-}
-```
-
-## Contributing
-
-We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Build
-
-To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
-
-```bash
-PKG=@0xproject/forwarder-helper yarn build
-```
-
-Or continuously rebuild on change:
-
-```bash
-PKG=@0xproject/forwarder-helper yarn watch
-```
-
-### Clean
-
-```bash
-yarn clean
-```
-
-### Lint
-
-```bash
-yarn lint
-```
-
-### Run Tests
-
-```bash
-yarn test
-```
diff --git a/packages/forwarder-helper/src/constants.ts b/packages/forwarder-helper/src/constants.ts
deleted file mode 100644
index 0ad30e4c0..000000000
--- a/packages/forwarder-helper/src/constants.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { BigNumber } from '@0xproject/utils';
-
-export const constants = {
- ZERO_AMOUNT: new BigNumber(0),
-};
diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts
deleted file mode 100644
index 95f11f555..000000000
--- a/packages/forwarder-helper/src/forwarder_helper_factory.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { assert } from '@0xproject/assert';
-import { schemas } from '@0xproject/json-schemas';
-import { SignedOrder } from '@0xproject/types';
-
-import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_helper_impl';
-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 feeOrders 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 {
- assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema);
- assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema);
- const config: ForwarderHelperImplConfig = {
- orders,
- feeOrders,
- };
- const helper = new ForwarderHelperImpl(config);
- return helper;
- },
-};
diff --git a/packages/forwarder-helper/src/forwarder_helper_impl.ts b/packages/forwarder-helper/src/forwarder_helper_impl.ts
deleted file mode 100644
index a90edb0bb..000000000
--- a/packages/forwarder-helper/src/forwarder_helper_impl.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { marketUtils } from '@0xproject/order-utils';
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import * as _ from 'lodash';
-
-import { constants } from './constants';
-import { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfo, MarketBuyOrdersInfoRequest } from './types';
-import { forwarderHelperImplConfigUtils } from './utils/forwarder_helper_impl_config_utils';
-
-const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface
-
-export interface ForwarderHelperImplConfig {
- orders: SignedOrder[];
- feeOrders: SignedOrder[];
- remainingFillableMakerAssetAmounts?: BigNumber[];
- remainingFillableFeeAmounts?: BigNumber[];
-}
-
-export class ForwarderHelperImpl implements ForwarderHelper {
- public readonly config: ForwarderHelperImplConfig;
- constructor(config: ForwarderHelperImplConfig) {
- this.config = forwarderHelperImplConfigUtils.sortedConfig(config);
- }
- public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo {
- const { makerAssetFillAmount, feePercentage } = request;
- const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config;
- // TODO: make the slippage percentage customizable
- const slippageBufferAmount = makerAssetFillAmount.mul(SLIPPAGE_PERCENTAGE).round();
- const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
- orders,
- makerAssetFillAmount,
- {
- remainingFillableMakerAssetAmounts,
- slippageBufferAmount,
- },
- );
- if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) {
- throw new Error(ForwarderHelperError.InsufficientMakerAssetLiquidity);
- }
- // TODO: update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to
- // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage
- const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(
- resultOrders,
- feeOrders,
- {
- remainingFillableMakerAssetAmounts,
- remainingFillableFeeAmounts,
- },
- );
- if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) {
- throw new Error(ForwarderHelperError.InsufficientZrxLiquidity);
- }
- // TODO: calculate min and max eth usage
- // TODO: optimize orders call data
- return {
- makerAssetFillAmount,
- orders: resultOrders,
- feeOrders: resultFeeOrders,
- minEthAmount: constants.ZERO_AMOUNT,
- maxEthAmount: constants.ZERO_AMOUNT,
- feePercentage,
- };
- }
-}
diff --git a/packages/forwarder-helper/src/index.ts b/packages/forwarder-helper/src/index.ts
deleted file mode 100644
index eb3a34bd5..000000000
--- a/packages/forwarder-helper/src/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { forwarderHelperFactory } from './forwarder_helper_factory';
-export { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfoRequest, MarketBuyOrdersInfo } from './types';
diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts
deleted file mode 100644
index fb171cc90..000000000
--- a/packages/forwarder-helper/src/types.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-
-export interface ForwarderHelper {
- /**
- * Given a MarketBuyOrdersInfoRequest, returns a MarketBuyOrdersInfo containing all information relevant to fulfilling the request
- * using the ForwarderContract marketBuyOrdersWithEth function.
- * @param request An object that conforms to MarketBuyOrdersInfoRequest. See type definition for more information.
- * @return An object that conforms to MarketBuyOrdersInfo that satisfies the request. See type definition for more information.
- */
- getMarketBuyOrdersInfo: (request: MarketBuyOrdersInfoRequest) => MarketBuyOrdersInfo;
-}
-
-export enum ForwarderHelperError {
- InsufficientMakerAssetLiquidity = 'INSUFFICIENT_MAKER_ASSET_LIQUIDITY',
- InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY',
-}
-
-/**
- * makerAssetFillAmount: The amount of makerAsset requesting to be filled
- * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations
- */
-export interface MarketBuyOrdersInfoRequest {
- makerAssetFillAmount: BigNumber;
- feePercentage?: BigNumber;
-}
-
-/**
- * makerAssetFillAmount: The amount of makerAsset requesting to be filled
- * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested makerAssetFillAmount plus slippage
- * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above
- * minEthAmount: Amount of eth in wei to send with the tx for the most optimistic case
- * maxEthAmount: Amount of eth in wei to send with the tx for the worst case
- * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed thru directly from the request
- */
-export interface MarketBuyOrdersInfo {
- makerAssetFillAmount: BigNumber;
- orders: SignedOrder[];
- feeOrders: SignedOrder[];
- minEthAmount: BigNumber;
- maxEthAmount: BigNumber;
- feePercentage?: BigNumber;
-}
diff --git a/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts b/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts
deleted file mode 100644
index 253384f65..000000000
--- a/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import { sortingUtils } from '@0xproject/order-utils';
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import * as _ from 'lodash';
-
-import { ForwarderHelperImplConfig } from '../forwarder_helper_impl';
-
-interface SignedOrderWithAmount extends SignedOrder {
- remainingFillAmount: BigNumber;
-}
-
-export const forwarderHelperImplConfigUtils = {
- sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig {
- const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config;
- // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens
- const orderSorter = (ordersToSort: SignedOrder[]) => {
- return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort);
- };
- const sortOrdersResult = sortOrdersAndRemainingFillAmounts(
- orderSorter,
- orders,
- remainingFillableMakerAssetAmounts,
- );
- const feeOrderSorter = (ordersToSort: SignedOrder[]) => {
- return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort);
- };
- const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts(
- feeOrderSorter,
- feeOrders,
- remainingFillableFeeAmounts,
- );
- return {
- orders: sortOrdersResult.orders,
- feeOrders: sortFeeOrdersResult.orders,
- remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts,
- remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts,
- };
- },
-};
-
-type OrderSorter = (orders: SignedOrder[]) => SignedOrder[];
-
-function sortOrdersAndRemainingFillAmounts(
- orderSorter: OrderSorter,
- orders: SignedOrder[],
- remainingFillAmounts?: BigNumber[],
-): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } {
- if (!_.isUndefined(remainingFillAmounts)) {
- // Bundle orders together with their remainingFillAmounts so that we can sort them together
- const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts);
- // Sort
- const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[];
- // Unbundle after sorting
- const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts);
- return {
- orders: unbundledSortedOrderWithAmounts.orders,
- remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts,
- };
- } else {
- const sortedOrders = orderSorter(orders);
- return {
- orders: sortedOrders,
- };
- }
-}
-
-function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] {
- const ordersAndAmounts = _.map(orders, (order, index) => {
- return {
- ...order,
- remainingFillAmount: amounts[index],
- };
- });
- return ordersAndAmounts;
-}
-
-function unbundleSignedOrderWithAmounts(
- signedOrderWithAmounts: SignedOrderWithAmount[],
-): { orders: SignedOrder[]; amounts: BigNumber[] } {
- const orders = _.map(signedOrderWithAmounts, order => {
- const { remainingFillAmount, ...rest } = order;
- return rest;
- });
- const amounts = _.map(signedOrderWithAmounts, order => {
- const { remainingFillAmount } = order;
- return remainingFillAmount;
- });
- return {
- orders,
- amounts,
- };
-}
diff --git a/packages/forwarder-helper/test/forwarder_helper_impl_test.ts b/packages/forwarder-helper/test/forwarder_helper_impl_test.ts
deleted file mode 100644
index 3c3b6db92..000000000
--- a/packages/forwarder-helper/test/forwarder_helper_impl_test.ts
+++ /dev/null
@@ -1,136 +0,0 @@
-import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory';
-import { BigNumber } from '@0xproject/utils';
-import * as chai from 'chai';
-import * as _ from 'lodash';
-import 'mocha';
-
-import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '../src/forwarder_helper_impl';
-import { ForwarderHelperError } from '../src/types';
-
-import { chaiSetup } from './utils/chai_setup';
-
-chaiSetup.configure();
-const expect = chai.expect;
-
-describe('ForwarderHelperImpl', () => {
- // rate: 2 takerAsset / makerAsset
- const testOrder1 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(200),
- });
- // rate: 1 takerAsset / makerAsset
- const testOrder2 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(100),
- });
- // rate: 3 takerAsset / makerAsset
- const testOrder3 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(300),
- takerFee: new BigNumber(1),
- });
- // rate: 3 WETH / ZRX
- const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(300),
- });
- // rate: 2 WETH / ZRX
- const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(200),
- });
- // rate: 1 WETH / ZRX
- const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({
- makerAssetAmount: new BigNumber(100),
- takerAssetAmount: new BigNumber(100),
- });
- const inputForwarderHelperConfig: ForwarderHelperImplConfig = {
- orders: [testOrder1, testOrder2, testOrder3],
- feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3],
- remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)],
- remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)],
- };
- describe('#constructor', () => {
- const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = {
- orders: [testOrder1, testOrder2, testOrder3],
- feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3],
- };
- it('sorts orders', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]);
- });
- it('sorts fee orders', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]);
- });
- it('sorts remainingFillableMakerAssetAmounts', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined();
- expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal(
- new BigNumber(2),
- );
- expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal(
- new BigNumber(1),
- );
- expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal(
- new BigNumber(3),
- );
- });
- it('sorts remainingFillableFeeAmounts', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined();
- expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6));
- expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5));
- expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4));
- });
- it('remainingFillableMakerAssetAmounts is undefined if none provided', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts);
- expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined();
- });
- it('remainingFillableFeeAmounts is undefined if none provided', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts);
- expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined();
- });
- });
- describe('#getMarketBuyOrdersInfo', () => {
- it('throws if not enough makerAsset liquidity', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- expect(() => {
- // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer
- forwarderHelper.getMarketBuyOrdersInfo({
- makerAssetFillAmount: new BigNumber(6),
- });
- }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity);
- });
- it('throws if not enough ZRX liquidity', () => {
- const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = {
- orders: [testOrder1, testOrder2, testOrder3],
- feeOrders: [],
- };
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees);
- expect(() => {
- // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw
- forwarderHelper.getMarketBuyOrdersInfo({
- makerAssetFillAmount: new BigNumber(250),
- });
- }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity);
- });
- it('passes the makerAssetFillAmount from the request to the info response', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- const makerAssetFillAmount = new BigNumber(4);
- const info = forwarderHelper.getMarketBuyOrdersInfo({
- makerAssetFillAmount,
- });
- expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount);
- });
- it('passes the feePercentage from the request to the info response', () => {
- const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig);
- const feePercentage = new BigNumber(0.2);
- const info = forwarderHelper.getMarketBuyOrdersInfo({
- makerAssetFillAmount: new BigNumber(4),
- feePercentage,
- });
- expect(info.feePercentage).to.bignumber.equal(feePercentage);
- });
- });
-});
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index 09d7fb932..e3308f98b 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.1",
"changes": [
diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md
index b68c1a1f9..0817874ba 100644
--- a/packages/json-schemas/CHANGELOG.md
+++ b/packages/json-schemas/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.2 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.1 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 776f26664..3d5399d2a 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
- "version": "1.0.1",
+ "version": "1.0.2",
"engines": {
"node": ">=6.12"
},
@@ -38,14 +38,14 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": {
- "@0xproject/typescript-typings": "^2.0.0",
- "@types/node": "^8.0.53",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@types/node": "*",
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/tslint-config": "^1.0.7",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/utils": "^1.0.9",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json
index 9246c1961..9824da332 100644
--- a/packages/metacoin/package.json
+++ b/packages/metacoin/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/metacoin",
- "version": "0.0.18",
+ "version": "0.0.19",
"engines": {
"node": ">=6.12"
},
@@ -28,25 +28,25 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/sol-cov": "^2.1.2",
- "@0xproject/subproviders": "^2.0.2",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/sol-cov": "^2.1.3",
+ "@0xproject/subproviders": "^2.0.3",
"@0xproject/tslint-config": "^1.0.7",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.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/mocha": "^5.2.2",
"copyfiles": "^2.0.0",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethers": "3.0.22",
"lodash": "^4.17.5",
"run-s": "^0.0.0"
},
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/sol-compiler": "^1.1.2",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/sol-compiler": "^1.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index 84ec503bf..a25de1a77 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.10",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1537369748,
"version": "1.0.9",
"changes": [
diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md
index aff23b0cf..2a6aeb96d 100644
--- a/packages/migrations/CHANGELOG.md
+++ b/packages/migrations/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.10 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.9 - _September 19, 2018_
* Dependencies updated
diff --git a/packages/migrations/package.json b/packages/migrations/package.json
index 5938ac224..1229c78dc 100644
--- a/packages/migrations/package.json
+++ b/packages/migrations/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/migrations",
- "version": "1.0.9",
+ "version": "1.0.10",
"engines": {
"node": ">=6.12"
},
@@ -30,10 +30,10 @@
},
"license": "Apache-2.0",
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/dev-utils": "^1.0.8",
"@0xproject/tslint-config": "^1.0.7",
- "@0xproject/types": "^1.0.1",
+ "@0xproject/types": "^1.0.2",
"@types/yargs": "^10.0.0",
"copyfiles": "^2.0.0",
"make-promises-safe": "^1.1.0",
@@ -44,15 +44,15 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/sol-compiler": "^1.1.2",
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/sol-compiler": "^1.1.3",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"@ledgerhq/hw-app-eth": "^4.3.0",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethers": "3.0.22",
"lodash": "^4.17.5"
},
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index cddb6ec3d..e776569b1 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/monorepo-scripts",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -33,7 +33,7 @@
"devDependencies": {
"@types/glob": "^5.0.33",
"@types/mkdirp": "^0.5.2",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/opn": "^5.1.0",
"@types/rimraf": "^2.0.2",
"@types/semver": "5.5.0",
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;
}
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index 8d8aaf702..dec154f0f 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.3",
"changes": [
{
diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md
index e79bf638e..a4e1cc79f 100644
--- a/packages/order-watcher/CHANGELOG.md
+++ b/packages/order-watcher/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.4 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.3 - _September 19, 2018_
* Drastically reduce the bundle size by removing unused parts of included contract artifacts.
diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json
index a07e0f795..8ce57364f 100644
--- a/packages/order-watcher/package.json
+++ b/packages/order-watcher/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-watcher",
- "version": "1.0.3",
+ "version": "1.0.4",
"description": "An order watcher daemon that watches for order validity",
"keywords": [
"0x",
@@ -42,14 +42,14 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.8",
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/migrations": "^1.0.9",
+ "@0xproject/abi-gen": "^1.0.9",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/migrations": "^1.0.10",
"@0xproject/tslint-config": "^1.0.7",
"@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/sinon": "^2.2.2",
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
@@ -70,18 +70,18 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/base-contract": "^2.0.2",
- "@0xproject/contract-wrappers": "^1.0.3",
- "@0xproject/fill-scenarios": "^1.0.2",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/base-contract": "^2.0.3",
+ "@0xproject/contract-wrappers": "^1.0.4",
+ "@0xproject/fill-scenarios": "^1.0.3",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"bintrees": "^1.0.2",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-blockstream": "5.0.0",
"ethers": "3.0.22",
"lodash": "^4.17.5"
diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts
index 9509c75de..eca235e26 100644
--- a/packages/order-watcher/src/order_watcher/event_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/event_watcher.ts
@@ -1,6 +1,6 @@
import { intervalUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { BlockParamLiteral, LogEntry, Provider } from 'ethereum-types';
+import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types';
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
import * as _ from 'lodash';
@@ -62,7 +62,7 @@ export class EventWatcher {
throw new Error(OrderWatcherError.SubscriptionAlreadyPresent);
}
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
- this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
+ this._getBlockOrNullAsync.bind(this),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
this._onBlockAndLogStreamerError.bind(this),
);
@@ -82,6 +82,14 @@ export class EventWatcher {
this._onLogStateChangedAsync.bind(this, callback, isRemoved),
);
}
+ // This method only exists in order to comply with the expected interface of Blockstream's constructor
+ private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> {
+ const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper);
+ if (_.isUndefined(blockIfExists)) {
+ return null;
+ }
+ return blockIfExists;
+ }
private _stopBlockAndLogStream(): void {
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
throw new Error(OrderWatcherError.SubscriptionNotFound);
@@ -100,11 +108,14 @@ export class EventWatcher {
await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback);
}
private async _reconcileBlockAsync(): Promise<void> {
- const latestBlock = await this._web3Wrapper.getBlockAsync(this._stateLayer);
+ const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer);
+ if (_.isUndefined(latestBlockIfExists)) {
+ return; // noop
+ }
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
- await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block);
+ await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block);
}
}
private async _emitDifferencesAsync(
diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json
index d1e846bb1..c8a44aa9e 100644
--- a/packages/react-docs/CHANGELOG.json
+++ b/packages/react-docs/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md
index 679f00097..595b0cf98 100644
--- a/packages/react-docs/CHANGELOG.md
+++ b/packages/react-docs/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json
index a3e368355..19be6d04f 100644
--- a/packages/react-docs/package.json
+++ b/packages/react-docs/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/react-docs",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -23,7 +23,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/dev-utils": "^1.0.8",
"@0xproject/tslint-config": "^1.0.7",
"@types/compare-versions": "^3.0.0",
"copyfiles": "^2.0.0",
@@ -33,12 +33,12 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/react-shared": "^1.0.9",
+ "@0xproject/react-shared": "^1.0.10",
"@0xproject/types": "^1.0.1-rc.6",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/utils": "^1.0.9",
"@types/lodash": "4.14.104",
"@types/material-ui": "^0.20.0",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/react": "*",
"@types/react-dom": "*",
"@types/react-scroll": "1.5.3",
diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json
index 7f88a4db2..898ab26aa 100644
--- a/packages/react-shared/CHANGELOG.json
+++ b/packages/react-shared/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.10",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.9",
"changes": [
diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md
index bc524322c..f6878e43f 100644
--- a/packages/react-shared/CHANGELOG.md
+++ b/packages/react-shared/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.10 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.9 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 49b3a4ac3..458968c39 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/react-shared",
- "version": "1.0.9",
+ "version": "1.0.10",
"engines": {
"node": ">=6.12"
},
@@ -24,7 +24,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/dev-utils": "^1.0.8",
"@0xproject/tslint-config": "^1.0.7",
"copyfiles": "^2.0.0",
"make-promises-safe": "^1.1.0",
@@ -37,7 +37,7 @@
"@types/is-mobile": "0.3.0",
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/react": "*",
"@types/react-dom": "*",
"@types/react-scroll": "1.5.3",
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index 8c5c84ce8..9a1961b79 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.1.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.1.2",
"changes": [
diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md
index 8b0e12441..a5d1332f8 100644
--- a/packages/sol-compiler/CHANGELOG.md
+++ b/packages/sol-compiler/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.1.3 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.1.2 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index 8395eccb5..2ad0f9f09 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sol-compiler",
- "version": "1.1.2",
+ "version": "1.1.3",
"engines": {
"node": ">=6.12"
},
@@ -41,7 +41,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/dev-utils": "^1.0.8",
"@0xproject/tslint-config": "^1.0.7",
"@types/mkdirp": "^0.5.2",
"@types/require-from-string": "^1.2.0",
@@ -64,16 +64,16 @@
"zeppelin-solidity": "1.8.0"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/sol-resolver": "^1.0.8",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/sol-resolver": "^1.0.9",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"@types/yargs": "^11.0.0",
"chalk": "^2.3.0",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5",
"mkdirp": "^0.5.1",
diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json
index e57939f4f..5f49e0443 100644
--- a/packages/sol-cov/CHANGELOG.json
+++ b/packages/sol-cov/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "2.1.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "2.1.2",
"changes": [
diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md
index b41dc00e6..e1b898b19 100644
--- a/packages/sol-cov/CHANGELOG.md
+++ b/packages/sol-cov/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.1.3 - _September 21, 2018_
+
+ * Dependencies updated
+
## v2.1.2 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json
index f51a76155..f80ae78e0 100644
--- a/packages/sol-cov/package.json
+++ b/packages/sol-cov/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sol-cov",
- "version": "2.1.2",
+ "version": "2.1.3",
"engines": {
"node": ">=6.12"
},
@@ -41,13 +41,13 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": {
- "@0xproject/dev-utils": "^1.0.7",
- "@0xproject/sol-compiler": "^1.1.2",
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
- "ethereum-types": "^1.0.6",
+ "@0xproject/dev-utils": "^1.0.8",
+ "@0xproject/sol-compiler": "^1.1.3",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
+ "ethereum-types": "^1.0.7",
"ethereumjs-util": "^5.1.1",
"glob": "^7.1.2",
"istanbul": "^0.4.5",
@@ -64,7 +64,7 @@
"@types/loglevel": "^1.5.3",
"@types/mkdirp": "^0.5.1",
"@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/rimraf": "^2.0.2",
"@types/solidity-parser-antlr": "^0.2.0",
"chai": "^4.0.1",
diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json
index e7f5177f8..bfc7cb93b 100644
--- a/packages/sol-resolver/CHANGELOG.json
+++ b/packages/sol-resolver/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md
index c14ef9336..5bed9f43c 100644
--- a/packages/sol-resolver/CHANGELOG.md
+++ b/packages/sol-resolver/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json
index 2e0ce319c..da3f18788 100644
--- a/packages/sol-resolver/package.json
+++ b/packages/sol-resolver/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sol-resolver",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -30,8 +30,8 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
"lodash": "^4.17.5"
},
"publishConfig": {
diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json
index 4d9dc80f7..ee12caf34 100644
--- a/packages/sra-report/CHANGELOG.json
+++ b/packages/sra-report/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md
index d3c9251f3..5e75625df 100644
--- a/packages/sra-report/CHANGELOG.md
+++ b/packages/sra-report/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json
index 98d10be07..eebf0cc0b 100644
--- a/packages/sra-report/package.json
+++ b/packages/sra-report/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sra-report",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -33,13 +33,13 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md",
"dependencies": {
- "@0xproject/assert": "^1.0.8",
+ "@0xproject/assert": "^1.0.9",
"@0xproject/connect": "1.0.4",
"@0xproject/json-schemas": "^0.8.3",
"@0xproject/order-utils": "^0.0.9",
"@0xproject/types": "^0.8.2",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
"chalk": "^2.3.0",
"lodash": "^4.17.5",
"newman": "^3.9.3",
@@ -51,7 +51,7 @@
"@types/mocha": "^2.2.48",
"@types/newman": "^3.9.0",
"@types/nock": "^9.1.2",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json
index 715f1a2f1..e0b373191 100644
--- a/packages/sra-spec/CHANGELOG.json
+++ b/packages/sra-spec/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.1",
"changes": [
diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md
index 52b99f538..59f397bc6 100644
--- a/packages/sra-spec/CHANGELOG.md
+++ b/packages/sra-spec/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.2 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.1 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json
index 82559a089..3da886e34 100644
--- a/packages/sra-spec/package.json
+++ b/packages/sra-spec/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sra-spec",
- "version": "1.0.1",
+ "version": "1.0.2",
"engines": {
"node": ">=6.12"
},
@@ -34,7 +34,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md",
"dependencies": {
- "@0xproject/json-schemas": "^1.0.1"
+ "@0xproject/json-schemas": "^1.0.2"
},
"devDependencies": {
"@0xproject/tslint-config": "^1.0.7",
diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json
index 0df16acf2..2d3c37615 100644
--- a/packages/subproviders/CHANGELOG.json
+++ b/packages/subproviders/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "2.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "2.0.2",
"changes": [
diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md
index db75710d7..6e268d7ec 100644
--- a/packages/subproviders/CHANGELOG.md
+++ b/packages/subproviders/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.3 - _September 21, 2018_
+
+ * Dependencies updated
+
## v2.0.2 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index b96166d37..347c71726 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/subproviders",
- "version": "2.0.2",
+ "version": "2.0.3",
"engines": {
"node": ">=6.12"
},
@@ -28,11 +28,11 @@
}
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"@ledgerhq/hw-app-eth": "^4.3.0",
"@ledgerhq/hw-transport-u2f": "^4.3.0",
"@types/eth-lightwallet": "^3.0.0",
@@ -41,7 +41,7 @@
"bip39": "^2.5.0",
"bn.js": "^4.11.8",
"eth-lightwallet": "^3.0.1",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-tx": "^1.3.5",
"ethereumjs-util": "^5.1.1",
"ganache-core": "0xProject/ganache-core#monorepo-dep",
@@ -59,7 +59,7 @@
"@types/hdkey": "^0.7.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/web3-provider-engine": "^14.0.0",
"chai": "^4.0.1",
diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json
index d4e68559f..448186b34 100644
--- a/packages/testnet-faucets/package.json
+++ b/packages/testnet-faucets/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/testnet-faucets",
- "version": "1.0.46",
+ "version": "1.0.47",
"engines": {
"node": ">=6.12"
},
@@ -17,13 +17,13 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
- "0x.js": "^1.0.3",
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "0x.js": "^1.0.4",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"body-parser": "^1.17.1",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-tx": "^1.3.5",
"ethereumjs-util": "^5.1.1",
"express": "^4.15.2",
diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json
index 008ff8ff4..8b1346347 100644
--- a/packages/types/CHANGELOG.json
+++ b/packages/types/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "1.1.0",
+ "changes": [
+ {
+ "note": "Add ObjectMap type",
+ "pr": 1037
+ }
+ ]
+ },
+ {
+ "timestamp": 1537541580,
+ "version": "1.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.1",
"changes": [
{
diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md
index 759a93fb0..d89416fd6 100644
--- a/packages/types/CHANGELOG.md
+++ b/packages/types/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.2 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.1 - _September 5, 2018_
* Add AssetProxyOwner revert reasons (#1041)
diff --git a/packages/types/package.json b/packages/types/package.json
index 15f0a54b4..f1c04b39b 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/types",
- "version": "1.0.1",
+ "version": "1.0.2",
"engines": {
"node": ">=6.12"
},
@@ -30,9 +30,9 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"bignumber.js": "~4.1.0",
- "ethereum-types": "^1.0.6"
+ "ethereum-types": "^1.0.7"
},
"publishConfig": {
"access": "public"
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index e2333d5d0..872a51f87 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -240,6 +240,10 @@ export enum StatusCodes {
GatewayTimeout = 504,
}
+export interface ObjectMap<T> {
+ [key: string]: T;
+}
+
export interface TypeDocType {
type: TypeDocTypes;
value: string;
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index cef518859..f0b1a6c40 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "2.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "2.0.0",
"changes": [
{
diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md
index e19e01509..67e86bb82 100644
--- a/packages/typescript-typings/CHANGELOG.md
+++ b/packages/typescript-typings/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.1 - _September 21, 2018_
+
+ * Dependencies updated
+
## v2.0.0 - _September 5, 2018_
* Remove types for web3-provider-engine, newman, ganache-core, detect-node, eth-lightwallet (#1052)
diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json
index 4b521d6d0..6f8b7e256 100644
--- a/packages/typescript-typings/package.json
+++ b/packages/typescript-typings/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/typescript-typings",
- "version": "2.0.0",
+ "version": "2.0.1",
"engines": {
"node": ">=6.12"
},
@@ -26,7 +26,7 @@
"@types/bn.js": "^4.11.0",
"@types/react": "*",
"bignumber.js": "~4.1.0",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"popper.js": "1.14.3"
},
"devDependencies": {
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index c1b7db100..7449355ce 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1537541580,
+ "version": "1.0.9",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1536142250,
"version": "1.0.8",
"changes": [
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md
index 2452cf42e..aa2c08940 100644
--- a/packages/utils/CHANGELOG.md
+++ b/packages/utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.9 - _September 21, 2018_
+
+ * Dependencies updated
+
## v1.0.8 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 831b6c819..a3977cef6 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/utils",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@@ -41,13 +41,13 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@types/node": "^8.0.53",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@types/node": "*",
"abortcontroller-polyfill": "^1.1.9",
"bignumber.js": "~4.1.0",
"detect-node": "2.0.3",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
"isomorphic-fetch": "^2.2.1",
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json
index 57e6f7689..ce3f5e3be 100644
--- a/packages/web3-wrapper/CHANGELOG.json
+++ b/packages/web3-wrapper/CHANGELOG.json
@@ -1,5 +1,26 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note":
+ "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined.",
+ "pr": 1082
+ }
+ ]
+ },
+ {
+ "version": "2.0.3",
+ "changes": [
+ {
+ "note":
+ "Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined.",
+ "pr": 1079
+ }
+ ],
+ "timestamp": 1537541580
+ },
+ {
"timestamp": 1536142250,
"version": "2.0.2",
"changes": [
diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md
index 17f2b9f48..72aff4a95 100644
--- a/packages/web3-wrapper/CHANGELOG.md
+++ b/packages/web3-wrapper/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.3 - _September 21, 2018_
+
+ * Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined. (#1079)
+
## v2.0.2 - _September 5, 2018_
* Dependencies updated
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 05ea4da17..bcd640839 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/web3-wrapper",
- "version": "2.0.2",
+ "version": "2.0.3",
"engines": {
"node": ">=6.12"
},
@@ -53,11 +53,11 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/assert": "^1.0.8",
- "@0xproject/json-schemas": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "ethereum-types": "^1.0.6",
+ "@0xproject/assert": "^1.0.9",
+ "@0xproject/json-schemas": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "ethereum-types": "^1.0.7",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
"lodash": "^4.17.5"
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts
index ea78f8801..dc634a57f 100644
--- a/packages/web3-wrapper/src/web3_wrapper.ts
+++ b/packages/web3-wrapper/src/web3_wrapper.ts
@@ -329,23 +329,29 @@ export class Web3Wrapper {
/**
* Fetch a specific Ethereum block without transaction data
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
- * @returns The requested block without transaction data
+ * @returns The requested block without transaction data, or undefined if block was not found
+ * (e.g the node isn't fully synced, there was a block re-org and the requested block was uncles, etc...)
*/
- public async getBlockAsync(blockParam: string | BlockParam): Promise<BlockWithoutTransactionData> {
+ public async getBlockIfExistsAsync(
+ blockParam: string | BlockParam,
+ ): Promise<BlockWithoutTransactionData | undefined> {
Web3Wrapper._assertBlockParamOrString(blockParam);
const encodedBlockParam = marshaller.marshalBlockParam(blockParam);
const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber';
const shouldIncludeTransactionData = false;
- const blockWithoutTransactionDataWithHexValues = await this._sendRawPayloadAsync<
+ const blockWithoutTransactionDataWithHexValuesOrNull = await this._sendRawPayloadAsync<
BlockWithoutTransactionDataRPC
>({
method,
params: [encodedBlockParam, shouldIncludeTransactionData],
});
- const blockWithoutTransactionData = marshaller.unmarshalIntoBlockWithoutTransactionData(
- blockWithoutTransactionDataWithHexValues,
- );
- return blockWithoutTransactionData;
+ let blockWithoutTransactionDataIfExists;
+ if (!_.isNull(blockWithoutTransactionDataWithHexValuesOrNull)) {
+ blockWithoutTransactionDataIfExists = marshaller.unmarshalIntoBlockWithoutTransactionData(
+ blockWithoutTransactionDataWithHexValuesOrNull,
+ );
+ }
+ return blockWithoutTransactionDataIfExists;
}
/**
* Fetch a specific Ethereum block with transaction data
@@ -376,8 +382,11 @@ export class Web3Wrapper {
*/
public async getBlockTimestampAsync(blockParam: string | BlockParam): Promise<number> {
Web3Wrapper._assertBlockParamOrString(blockParam);
- const { timestamp } = await this.getBlockAsync(blockParam);
- return timestamp;
+ const blockIfExists = await this.getBlockIfExistsAsync(blockParam);
+ if (_.isUndefined(blockIfExists)) {
+ throw new Error(`Failed to fetch block with blockParam: ${JSON.stringify(blockParam)}`);
+ }
+ return blockIfExists.timestamp;
}
/**
* Retrieve the user addresses available through the backing provider
@@ -539,7 +548,7 @@ export class Web3Wrapper {
}
// Immediately check if the transaction has already been mined.
let transactionReceipt = await this.getTransactionReceiptAsync(txHash);
- if (!_.isNull(transactionReceipt)) {
+ if (!_.isNull(transactionReceipt) && !_.isNull(transactionReceipt.blockNumber)) {
const logsWithDecodedArgs = _.map(
transactionReceipt.logs,
this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder),
diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts
index b4fd8bb44..385c469bf 100644
--- a/packages/web3-wrapper/test/web3_wrapper_test.ts
+++ b/packages/web3-wrapper/test/web3_wrapper_test.ts
@@ -85,28 +85,40 @@ describe('Web3Wrapper tests', () => {
expect(typeof blockNumber).to.be.equal('number');
});
});
- describe('#getBlockAsync', () => {
+ describe('#getBlockIfExistsAsync', () => {
it('gets block when supplied a valid BlockParamLiteral value', async () => {
const blockParamLiteral = BlockParamLiteral.Earliest;
- const block = await web3Wrapper.getBlockAsync(blockParamLiteral);
- expect(block.number).to.be.equal(0);
- expect(utils.isBigNumber(block.difficulty)).to.equal(true);
- expect(_.isNumber(block.gasLimit)).to.equal(true);
+ const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral);
+ if (_.isUndefined(blockIfExists)) {
+ throw new Error('Expected block to exist');
+ }
+ expect(blockIfExists.number).to.be.equal(0);
+ expect(utils.isBigNumber(blockIfExists.difficulty)).to.equal(true);
+ expect(_.isNumber(blockIfExists.gasLimit)).to.equal(true);
});
it('gets block when supplied a block number', async () => {
const blockParamLiteral = 0;
- const block = await web3Wrapper.getBlockAsync(blockParamLiteral);
- expect(block.number).to.be.equal(0);
+ const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral);
+ if (_.isUndefined(blockIfExists)) {
+ throw new Error('Expected block to exist');
+ }
+ expect(blockIfExists.number).to.be.equal(0);
});
it('gets block when supplied a block hash', async () => {
const blockParamLiteral = 0;
- const block = await web3Wrapper.getBlockAsync(blockParamLiteral);
- const sameBlock = await web3Wrapper.getBlockAsync(block.hash as string);
- expect(sameBlock.number).to.be.equal(0);
+ const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral);
+ if (_.isUndefined(blockIfExists)) {
+ throw new Error('Expected block to exist');
+ }
+ const sameBlockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockIfExists.hash as string);
+ if (_.isUndefined(sameBlockIfExists)) {
+ throw new Error('Expected block to exist');
+ }
+ expect(sameBlockIfExists.number).to.be.equal(0);
});
it('should throw if supplied invalid blockParam value', async () => {
const invalidBlockParam = 'deadbeef';
- expect(web3Wrapper.getBlockAsync(invalidBlockParam)).to.eventually.to.be.rejected();
+ expect(web3Wrapper.getBlockIfExistsAsync(invalidBlockParam)).to.eventually.to.be.rejected();
});
});
describe('#getBlockWithTransactionDataAsync', () => {
diff --git a/packages/website/package.json b/packages/website/package.json
index 911a4ccba..65a0d4c10 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/website",
- "version": "0.0.49",
+ "version": "0.0.50",
"engines": {
"node": ">=6.12"
},
@@ -19,21 +19,22 @@
"license": "Apache-2.0",
"dependencies": {
"0x.js": "^0.38.6",
- "@0xproject/contract-wrappers": "^1.0.3",
- "@0xproject/order-utils": "^1.0.2",
- "@0xproject/react-docs": "^1.0.8",
- "@0xproject/react-shared": "^1.0.9",
- "@0xproject/subproviders": "^2.0.2",
- "@0xproject/types": "^1.0.1",
- "@0xproject/typescript-typings": "^2.0.0",
- "@0xproject/utils": "^1.0.8",
- "@0xproject/web3-wrapper": "^2.0.2",
+ "@0xproject/contract-wrappers": "^1.0.4",
+ "@0xproject/json-schemas": "^1.0.1",
+ "@0xproject/order-utils": "^1.0.3",
+ "@0xproject/react-docs": "^1.0.9",
+ "@0xproject/react-shared": "^1.0.10",
+ "@0xproject/subproviders": "^2.0.3",
+ "@0xproject/types": "^1.0.2",
+ "@0xproject/typescript-typings": "^2.0.1",
+ "@0xproject/utils": "^1.0.9",
+ "@0xproject/web3-wrapper": "^2.0.3",
"accounting": "^0.4.1",
"basscss": "^8.0.3",
"blockies": "^0.0.2",
"bowser": "^1.9.3",
"deep-equal": "^1.0.1",
- "ethereum-types": "^1.0.6",
+ "ethereum-types": "^1.0.7",
"ethereumjs-util": "^5.1.1",
"find-versions": "^2.0.0",
"jsonschema": "^1.2.0",
@@ -72,7 +73,7 @@
"@types/jsonschema": "^1.1.1",
"@types/lodash": "4.14.104",
"@types/material-ui": "^0.20.0",
- "@types/node": "^8.0.53",
+ "@types/node": "*",
"@types/numeral": "^0.0.22",
"@types/query-string": "^5.1.0",
"@types/react": "^16.4.2",
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index d3f2f3f7b..632a63016 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -228,7 +228,7 @@ export class Blockchain {
const tokenSymbolToAddressOverrides = tokenAddressOverrides[this.networkId];
let isTokenAddressInOverrides = false;
if (!_.isUndefined(tokenSymbolToAddressOverrides)) {
- isTokenAddressInOverrides = _.keys(tokenSymbolToAddressOverrides).includes(tokenAddress);
+ isTokenAddressInOverrides = _.values(tokenSymbolToAddressOverrides).includes(tokenAddress);
}
return !_.isUndefined(tokenIfExists) || isTokenAddressInOverrides;
}
diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx
index 93ef516cf..db093fb68 100644
--- a/packages/website/ts/components/inputs/token_amount_input.tsx
+++ b/packages/website/ts/components/inputs/token_amount_input.tsx
@@ -111,7 +111,7 @@ export class TokenAmountInput extends React.Component<TokenAmountInputProps, Tok
<span>
Insufficient allowance.{' '}
<Link
- to={`${WebsitePaths.Portal}/balances`}
+ to={`${WebsitePaths.Portal}/account`}
style={{ cursor: 'pointer', color: colors.darkestGrey }}
>
Set allowance
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 5fe9eef99..3c6d3df4d 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -1,4 +1,4 @@
-import { SignedOrder } from '@0xproject/types';
+import { ObjectMap, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Provider } from 'ethereum-types';
import * as React from 'react';
@@ -519,10 +519,6 @@ export interface OutdatedWrappedEtherByNetworkId {
export type ItemByAddress<T> = ObjectMap<T>;
-export interface ObjectMap<T> {
- [key: string]: T;
-}
-
export type TokenStateByAddress = ItemByAddress<TokenState>;
export interface TokenState {
diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts
index 62dbff2b9..3aae317b0 100644
--- a/packages/website/ts/utils/analytics.ts
+++ b/packages/website/ts/utils/analytics.ts
@@ -1,6 +1,7 @@
import { assetDataUtils } from '@0xproject/order-utils';
+import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
-import { ObjectMap, PortalOrder } from 'ts/types';
+import { PortalOrder } from 'ts/types';
import { utils } from 'ts/utils/utils';
export interface HeapAnalytics {
diff --git a/packages/website/ts/utils/token_address_overrides.ts b/packages/website/ts/utils/token_address_overrides.ts
index 8353358bc..e7e916273 100644
--- a/packages/website/ts/utils/token_address_overrides.ts
+++ b/packages/website/ts/utils/token_address_overrides.ts
@@ -1,4 +1,4 @@
-import { ObjectMap } from 'ts/types';
+import { ObjectMap } from '@0xproject/types';
import { constants } from 'ts/utils/constants';
// Map of networkId -> tokenSymbol -> tokenAddress