aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/asset-buyer/src/types.ts')
-rw-r--r--packages/asset-buyer/src/types.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts
new file mode 100644
index 000000000..a7f02ff8d
--- /dev/null
+++ b/packages/asset-buyer/src/types.ts
@@ -0,0 +1,49 @@
+import { SignedOrder } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
+
+export enum ForwarderHelperFactoryError {
+ NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND',
+ NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND',
+ StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR',
+}
+
+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;
+}