aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/src/types.ts
blob: 55ec553dbd0dec54aa37570578200449739e20a6 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { BigNumber } from '@0x/utils';

export enum OrderError {
    InvalidSignature = 'INVALID_SIGNATURE',
    InvalidMetamaskSigner = "MetaMask provider must be wrapped in a MetamaskSubprovider (from the '@0x/subproviders' package) in order to work with this method.",
}

export enum TradeSide {
    Maker = 'maker',
    Taker = 'taker',
}

export enum TransferType {
    Trade = 'trade',
    Fee = 'fee',
}

export interface CreateOrderOpts {
    takerAddress?: string;
    senderAddress?: string;
    makerFee?: BigNumber;
    takerFee?: BigNumber;
    feeRecipientAddress?: string;
    salt?: BigNumber;
    expirationTimeSeconds?: BigNumber;
}

/**
 * remainingFillableMakerAssetAmount: An array of BigNumbers corresponding to the `orders` parameter.
 * You can use `OrderStateUtils` `@0x/order-utils` to perform blockchain lookups for these values.
 * Defaults to `makerAssetAmount` values from the orders param.
 * slippageBufferAmount: An additional amount of makerAsset to be covered by the result in case of trade collisions or partial fills.
 * Defaults to 0
 */
export interface FindOrdersThatCoverMakerAssetFillAmountOpts {
    remainingFillableMakerAssetAmounts?: BigNumber[];
    slippageBufferAmount?: BigNumber;
}

/**
 * remainingFillableMakerAssetAmount: An array of BigNumbers corresponding to the `orders` parameter.
 * You can use `OrderStateUtils` `@0x/order-utils` to perform blockchain lookups for these values.
 * Defaults to `makerAssetAmount` values from the orders param.
 * remainingFillableFeeAmounts: An array of BigNumbers corresponding to the feeOrders parameter.
 * You can use OrderStateUtils @0x/order-utils to perform blockchain lookups for these values.
 * Defaults to `makerAssetAmount` values from the feeOrders param.
 * slippageBufferAmount: An additional amount of fee to be covered by the result in case of trade collisions or partial fills.
 * Defaults to 0
 */
export interface FindFeeOrdersThatCoverFeesForTargetOrdersOpts {
    remainingFillableMakerAssetAmounts?: BigNumber[];
    remainingFillableFeeAmounts?: BigNumber[];
    slippageBufferAmount?: BigNumber;
}

export interface FeeOrdersAndRemainingFeeAmount<T> {
    resultFeeOrders: T[];
    feeOrdersRemainingFillableMakerAssetAmounts: BigNumber[];
    remainingFeeAmount: BigNumber;
}

export interface OrdersAndRemainingFillAmount<T> {
    resultOrders: T[];
    ordersRemainingFillableMakerAssetAmounts: BigNumber[];
    remainingFillAmount: BigNumber;
}