@nadohq/trigger-client 0.1.0-alpha.7 → 0.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,9 +62,6 @@ export type TriggerCriteria =
62
62
  export type TriggerCriteriaType = TriggerCriteria['type'];
63
63
 
64
64
  export type TriggerOrderStatus =
65
- | {
66
- type: 'pending';
67
- }
68
65
  | {
69
66
  type: 'cancelled';
70
67
  reason: string;
@@ -76,4 +73,23 @@ export type TriggerOrderStatus =
76
73
  | {
77
74
  type: 'internal_error';
78
75
  error: string;
76
+ }
77
+ | {
78
+ type: 'triggering';
79
+ }
80
+ | {
81
+ type: 'waiting_price';
82
+ }
83
+ | {
84
+ type: 'waiting_dependency';
85
+ }
86
+ | {
87
+ type: 'twap_executing';
88
+ currentExecution: number;
89
+ totalExecutions: number;
90
+ }
91
+ | {
92
+ type: 'twap_completed';
93
+ executed: number;
94
+ total: number;
79
95
  };
@@ -1,14 +1,18 @@
1
1
  import {
2
+ EngineOrderParams,
3
+ EngineServerExecuteResult,
4
+ } from '@nadohq/engine-client';
5
+ import {
6
+ BigDecimal,
2
7
  EIP712CancelOrdersParams,
3
8
  EIP712CancelProductOrdersParams,
4
9
  OrderAppendix,
5
10
  Subaccount,
6
11
  } from '@nadohq/shared';
7
- import { EngineOrderParams } from '@nadohq/engine-client';
8
- import { BigDecimal } from '@nadohq/shared';
9
12
  import { TriggerCriteria, TriggerOrderStatus } from './clientModelTypes';
10
13
  import {
11
14
  TriggerServerOrder,
15
+ TriggerServerStatusTypeFilter,
12
16
  TriggerServerTriggerTypeFilter,
13
17
  } from './serverQueryTypes';
14
18
 
@@ -55,13 +59,13 @@ export interface TriggerListOrdersParams extends Subaccount, SignatureParams {
55
59
  recvTime?: BigDecimal;
56
60
  // If not given, defaults to all products
57
61
  productId?: number;
58
- // Pending trigger orders only, ignores cancelled & triggered orders
59
- pending: boolean;
60
62
  // In seconds
61
63
  maxUpdateTimeInclusive?: number;
62
64
  // When provided, the associated trigger orders are returned regardless of other filters
63
65
  digests?: string[];
64
66
  limit?: number;
67
+ // Filter by status types
68
+ statusTypes?: TriggerServerStatusTypeFilter[];
65
69
  // Filter by trigger types
66
70
  triggerTypes?: TriggerServerTriggerTypeFilter[];
67
71
  // Filter by reduce-only orders
@@ -89,3 +93,36 @@ export interface TriggerOrderInfo {
89
93
  export interface TriggerListOrdersResponse {
90
94
  orders: TriggerOrderInfo[];
91
95
  }
96
+
97
+ export interface TriggerListTwapExecutionsParams {
98
+ digest: string;
99
+ }
100
+
101
+ export type TwapExecutionStatus =
102
+ | {
103
+ type: 'pending';
104
+ }
105
+ | {
106
+ type: 'executed';
107
+ executedTime: number;
108
+ executeResponse: EngineServerExecuteResult;
109
+ }
110
+ | {
111
+ type: 'failed';
112
+ error: string;
113
+ }
114
+ | {
115
+ type: 'cancelled';
116
+ reason: string;
117
+ };
118
+
119
+ export interface TwapExecutionInfo {
120
+ executionId: number;
121
+ scheduledTime: number;
122
+ status: TwapExecutionStatus;
123
+ updatedAt: number;
124
+ }
125
+
126
+ export interface TriggerListTwapExecutionsResponse {
127
+ executions: TwapExecutionInfo[];
128
+ }
@@ -38,7 +38,7 @@ export interface TriggerServerTimeTriggerCriteria {
38
38
  /**
39
39
  * Trigger interval in seconds
40
40
  */
41
- interval: string;
41
+ interval: number;
42
42
  /**
43
43
  * By default, trigger service will split up orders as per total amount / interval
44
44
  * If you want to specify the amounts for each interval, you can provide them here.
@@ -1,42 +1,68 @@
1
- import { EIP712ListTriggerOrdersValues, SignedTx } from '@nadohq/shared';
2
1
  import { EngineServerExecuteResult } from '@nadohq/engine-client';
2
+ import { EIP712ListTriggerOrdersValues, SignedTx } from '@nadohq/shared';
3
3
  import { TriggerServerPlaceOrderParams } from './serverExecuteTypes';
4
4
 
5
5
  export type TriggerServerOrderStatus =
6
- | 'pending'
7
6
  | {
8
- // Result from sending to engine
9
- triggered: EngineServerExecuteResult;
7
+ cancelled: TriggerServerCancelReason;
10
8
  }
11
9
  | {
12
- // Reason string
13
- cancelled: string;
10
+ triggered: EngineServerExecuteResult;
14
11
  }
15
12
  | {
16
- // Error message
17
13
  internal_error: string;
14
+ }
15
+ | 'triggering'
16
+ | 'waiting_price'
17
+ | 'waiting_dependency'
18
+ | {
19
+ twap_executing: {
20
+ current_execution: number;
21
+ total_executions: number;
22
+ };
23
+ }
24
+ | {
25
+ twap_completed: {
26
+ executed: number;
27
+ total: number;
28
+ };
18
29
  };
19
30
 
20
31
  /**
21
32
  * Request types
22
33
  */
23
34
 
24
- export type TriggerServerTriggerTypeFilter = 'price_trigger' | 'twap';
35
+ export type TriggerServerTriggerTypeFilter = 'price_trigger' | 'time_trigger';
36
+
37
+ export type TriggerServerStatusTypeFilter =
38
+ | 'cancelled'
39
+ | 'triggered'
40
+ | 'internal_error'
41
+ | 'triggering'
42
+ | 'waiting_price'
43
+ | 'waiting_dependency'
44
+ | 'twap_executing'
45
+ | 'twap_completed';
25
46
 
26
47
  export interface TriggerServerListTriggerOrdersParams
27
48
  extends SignedTx<EIP712ListTriggerOrdersValues> {
28
- pending: boolean;
29
49
  // If not given, defaults to all products
30
50
  product_id?: number;
31
51
  max_update_time?: number;
32
52
  digests?: string[];
33
53
  limit?: number;
34
54
  trigger_types?: TriggerServerTriggerTypeFilter[];
55
+ status_types?: TriggerServerStatusTypeFilter[];
35
56
  reduce_only?: boolean;
36
57
  }
37
58
 
59
+ export interface TriggerServerListTwapExecutionsParams {
60
+ digest: string;
61
+ }
62
+
38
63
  export interface TriggerServerQueryRequestByType {
39
64
  list_trigger_orders: TriggerServerListTriggerOrdersParams;
65
+ list_twap_executions: TriggerServerListTwapExecutionsParams;
40
66
  }
41
67
 
42
68
  export type TriggerServerQueryRequestType =
@@ -61,8 +87,43 @@ export interface TriggerServerListTriggerOrdersResponse {
61
87
  orders: TriggerServerOrderInfo[];
62
88
  }
63
89
 
90
+ export type TriggerServerCancelReason =
91
+ | 'user_requested'
92
+ | 'linked_signer_changed'
93
+ | 'expired'
94
+ | 'account_health'
95
+ | 'isolated_subaccount_closed'
96
+ | 'dependent_order_cancelled';
97
+
98
+ export type TriggerServerTwapExecutionStatus =
99
+ | 'pending'
100
+ | {
101
+ executed: {
102
+ executed_time: number;
103
+ execute_response: EngineServerExecuteResult;
104
+ };
105
+ }
106
+ | {
107
+ failed: string;
108
+ }
109
+ | {
110
+ cancelled: TriggerServerCancelReason;
111
+ };
112
+
113
+ export interface TriggerServerTwapExecutionInfo {
114
+ execution_id: number;
115
+ scheduled_time: number;
116
+ status: TriggerServerTwapExecutionStatus;
117
+ updated_at: number;
118
+ }
119
+
120
+ export interface TriggerServerTwapExecutionsResponse {
121
+ executions: TriggerServerTwapExecutionInfo[];
122
+ }
123
+
64
124
  export interface TriggerServerQueryResponseByType {
65
125
  list_trigger_orders: TriggerServerListTriggerOrdersResponse;
126
+ list_twap_executions: TriggerServerTwapExecutionsResponse;
66
127
  }
67
128
 
68
129
  export interface TriggerServerQuerySuccessResponse<