diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-08-16 06:20:25 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-08-23 06:39:03 +0800 |
commit | 2ef867f398db381ebd8ec715bd108b46d8fa60f3 (patch) | |
tree | 6edcb499c5a969e07f504821cde57a8ffe010fc7 | |
parent | 90f2813d0e3cf61c63b308d5cfe738b7beba8c94 (diff) | |
download | dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar.gz dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar.bz2 dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar.lz dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar.xz dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.tar.zst dexon-sol-tools-2ef867f398db381ebd8ec715bd108b46d8fa60f3.zip |
Add stubs for ForwarderHelper interface in ForwarderHelperImpl
-rw-r--r-- | packages/forwarder-helper/package.json | 18 | ||||
-rw-r--r-- | packages/forwarder-helper/src/forwarder_helper_impl.ts | 50 | ||||
-rw-r--r-- | packages/forwarder-helper/src/types.ts | 2 |
3 files changed, 58 insertions, 12 deletions
diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json index ad2b5f7cf..e79154a52 100644 --- a/packages/forwarder-helper/package.json +++ b/packages/forwarder-helper/package.json @@ -15,22 +15,21 @@ "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "test:circleci": "yarn test:coverage", - "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", + "run_mocha": + "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", "clean": "shx rm -rf lib test_temp scripts", "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", "manual:postpublish": "yarn build; node ./scripts/postpublish.js", "docs:stage": "node scripts/stage_docs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", - "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" + "upload_docs_json": + "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" }, "config": { "postpublish": { "assets": [], "docPublishConfigs": { - "extraFileIncludes": [ - "../types/src/index.ts", - "../ethereum-types/src/index.ts" - ], + "extraFileIncludes": ["../types/src/index.ts", "../ethereum-types/src/index.ts"], "s3BucketPath": "s3://doc-jsons/forwarder-helper/", "s3StagingBucketPath": "s3://staging-doc-jsons/forwarder-helper/" } @@ -47,7 +46,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", "dependencies": { - "@0xproject/types": "^0.8.2", + "@0xproject/order-utils": "^1.0.1-rc.3", + "@0xproject/types": "^1.0.1-rc.4", "@0xproject/typescript-typings": "^1.0.4", "@0xproject/utils": "^1.0.5", "@types/node": "^8.0.53" @@ -55,16 +55,12 @@ "devDependencies": { "@0xproject/monorepo-scripts": "^1.0.5", "@0xproject/tslint-config": "^1.0.5", - "@0xproject/utils": "^1.0.5", - "@types/lodash.foreach": "^4.5.3", - "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", - "lodash.foreach": "^4.5.0", "make-promises-safe": "^1.1.0", "mocha": "^4.1.0", "npm-run-all": "^4.1.2", diff --git a/packages/forwarder-helper/src/forwarder_helper_impl.ts b/packages/forwarder-helper/src/forwarder_helper_impl.ts index e69de29bb..1069bca73 100644 --- a/packages/forwarder-helper/src/forwarder_helper_impl.ts +++ b/packages/forwarder-helper/src/forwarder_helper_impl.ts @@ -0,0 +1,50 @@ +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +import { + ForwarderHelper, + MarketBuyOrdersInfo, + MarketBuyOrdersInfoRequest, + MarketSellOrdersInfo, + MarketSellOrdersInfoRequest, +} from './types'; + +export class ForwarderHelperImpl implements ForwarderHelper { + private _orders: SignedOrder[]; + private _feeOrders: SignedOrder[]; + private _remainingFillableMakerAssetAmountsIfExists?: BigNumber[]; + private _remainingFillableFeeAmountsIfExists?: BigNumber[]; + constructor( + orders: SignedOrder[], + feeOrders: SignedOrder[] = [] as SignedOrder[], + remainingFillableMakerAssetAmounts?: BigNumber[], + remainingFillableFeeAmounts?: BigNumber[], + ) { + this._orders = orders; + this._feeOrders = feeOrders; + this._remainingFillableMakerAssetAmountsIfExists = remainingFillableMakerAssetAmounts; + this._remainingFillableFeeAmountsIfExists = remainingFillableFeeAmounts; + } + public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo { + const { makerAssetFillAmount, feePercentage, acceptableEthAmountRange } = request; + return { + makerAssetFillAmount, + orders: this._orders, + feeOrders: this._feeOrders, + minEthAmount: new BigNumber(0), + maxEthAmount: new BigNumber(0), + feePercentage, + }; + } + public getMarketSellOrdersInfo(request: MarketSellOrdersInfoRequest): MarketSellOrdersInfo { + const { ethAmount, feePercentage, acceptableFillAmountRange } = request; + return { + ethAmount, + orders: this._orders, + feeOrders: this._feeOrders, + minFillAmount: new BigNumber(0), + maxFillAmount: new BigNumber(0), + feePercentage, + }; + } +} diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts index 23eaa1281..c6d4083a9 100644 --- a/packages/forwarder-helper/src/types.ts +++ b/packages/forwarder-helper/src/types.ts @@ -46,9 +46,9 @@ export interface MarketBuyOrdersInfo { makerAssetFillAmount: BigNumber; orders: SignedOrder[]; feeOrders: SignedOrder[]; - feePercentage?: BigNumber; minEthAmount: BigNumber; maxEthAmount: BigNumber; + feePercentage?: BigNumber; } /** |