aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/types.ts
blob: a7f02ff8d3f21514b60dcfa1575f1b37e5b4ff10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
}