aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-16 05:51:32 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-23 06:39:03 +0800
commit90f2813d0e3cf61c63b308d5cfe738b7beba8c94 (patch)
treedde384dbb0366b8817924b215a76f1bd1c19e322
parentdd9c4b6e5d0f10bdaaae61f40bdf017e83e5f606 (diff)
downloaddexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar.gz
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar.bz2
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar.lz
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar.xz
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.tar.zst
dexon-sol-tools-90f2813d0e3cf61c63b308d5cfe738b7beba8c94.zip
Flesh out types
-rw-r--r--packages/forwarder-helper/package.json2
-rw-r--r--packages/forwarder-helper/src/types.ts80
-rw-r--r--yarn.lock6
3 files changed, 85 insertions, 3 deletions
diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json
index 7f7b595c2..ad2b5f7cf 100644
--- a/packages/forwarder-helper/package.json
+++ b/packages/forwarder-helper/package.json
@@ -47,7 +47,9 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md",
"dependencies": {
+ "@0xproject/types": "^0.8.2",
"@0xproject/typescript-typings": "^1.0.4",
+ "@0xproject/utils": "^1.0.5",
"@types/node": "^8.0.53"
},
"devDependencies": {
diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts
index e69de29bb..23eaa1281 100644
--- a/packages/forwarder-helper/src/types.ts
+++ b/packages/forwarder-helper/src/types.ts
@@ -0,0 +1,80 @@
+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;
+ /**
+ * Given a MarketSellOrdersInfoRequest, returns a MarketSellOrdersInfo containing all information relevant to fulfilling the request
+ * using the ForwarderContract marketSellOrdersWithEth function.
+ * @param request An object that conforms to MarketSellOrdersInfoRequest. See type definition for more information.
+ * @return An object that conforms to MarketSellOrdersInfo that satisfies the request. See type definition for more information.
+ */
+ getMarketSellOrdersInfo: (request: MarketSellOrdersInfoRequest) => MarketSellOrdersInfo;
+}
+
+export enum ForwarderHelperError {
+ InsufficientLiquidity = 'INSUFFICIENT_LIQUIDITY',
+ InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY',
+}
+
+/**
+ * makerAssetFillAmount: The amount of makerAsset requesting to be filled
+ * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations
+ * acceptableEthAmountRange: maximum difference between min and max eth cost
+ */
+export interface MarketBuyOrdersInfoRequest {
+ makerAssetFillAmount: BigNumber;
+ feePercentage?: BigNumber;
+ acceptableEthAmountRange?: 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[];
+ feePercentage?: BigNumber;
+ minEthAmount: BigNumber;
+ maxEthAmount: BigNumber;
+}
+
+/**
+ * ethAmount: The amount of eth used to fill
+ * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations
+ * acceptableFillAmountRange: maximum difference between min and max asset filled
+ */
+export interface MarketSellOrdersInfoRequest {
+ ethAmount: BigNumber;
+ feePercentage?: BigNumber;
+ acceptableFillAmountRange?: BigNumber;
+}
+
+/**
+ * ethAmount: The amount of eth used to fill
+ * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested ethAmount plus slippage
+ * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above
+ * minFillAmount: Amount of asset purchased in the worst case
+ * maxFillAmount: Amount of asset purchased in the best case
+ * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed thru directly from the request
+ */
+export interface MarketSellOrdersInfo {
+ ethAmount: BigNumber;
+ orders: SignedOrder[];
+ feeOrders: SignedOrder[];
+ minFillAmount: BigNumber;
+ maxFillAmount: BigNumber;
+ feePercentage?: BigNumber;
+}
diff --git a/yarn.lock b/yarn.lock
index 7e278ac8a..508e23a0f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5256,9 +5256,9 @@ ethereumjs-wallet@~0.6.0:
utf8 "^3.0.0"
uuid "^3.3.2"
-ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22:
- version "3.0.18"
- resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
+ethers@3.0.22:
+ version "3.0.22"
+ resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436"
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"