@nadohq/trigger-client 0.1.0-alpha.3 → 0.1.0-alpha.30

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.
Files changed (69) hide show
  1. package/dist/TriggerClient.cjs +74 -34
  2. package/dist/TriggerClient.cjs.map +1 -1
  3. package/dist/TriggerClient.d.cts +8 -4
  4. package/dist/TriggerClient.d.ts +8 -4
  5. package/dist/TriggerClient.js +73 -28
  6. package/dist/TriggerClient.js.map +1 -1
  7. package/dist/dataMappers.cjs +170 -67
  8. package/dist/dataMappers.cjs.map +1 -1
  9. package/dist/dataMappers.d.cts +22 -8
  10. package/dist/dataMappers.d.ts +22 -8
  11. package/dist/dataMappers.js +171 -66
  12. package/dist/dataMappers.js.map +1 -1
  13. package/dist/endpoints.cjs +2 -2
  14. package/dist/endpoints.cjs.map +1 -1
  15. package/dist/endpoints.d.cts +1 -1
  16. package/dist/endpoints.d.ts +1 -1
  17. package/dist/endpoints.js +2 -2
  18. package/dist/endpoints.js.map +1 -1
  19. package/dist/index.cjs +4 -4
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +9 -8
  22. package/dist/index.d.ts +9 -8
  23. package/dist/index.js +2 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/types/TriggerServerFailureError.cjs +1 -1
  26. package/dist/types/TriggerServerFailureError.cjs.map +1 -1
  27. package/dist/types/TriggerServerFailureError.d.cts +3 -2
  28. package/dist/types/TriggerServerFailureError.d.ts +3 -2
  29. package/dist/types/TriggerServerFailureError.js +1 -1
  30. package/dist/types/TriggerServerFailureError.js.map +1 -1
  31. package/dist/types/clientModelTypes.cjs +19 -0
  32. package/dist/types/clientModelTypes.cjs.map +1 -0
  33. package/dist/types/clientModelTypes.d.cts +67 -0
  34. package/dist/types/clientModelTypes.d.ts +67 -0
  35. package/dist/types/clientModelTypes.js +1 -0
  36. package/dist/types/clientModelTypes.js.map +1 -0
  37. package/dist/types/clientTypes.cjs.map +1 -1
  38. package/dist/types/clientTypes.d.cts +50 -24
  39. package/dist/types/clientTypes.d.ts +50 -24
  40. package/dist/types/index.cjs +4 -0
  41. package/dist/types/index.cjs.map +1 -1
  42. package/dist/types/index.d.cts +6 -5
  43. package/dist/types/index.d.ts +6 -5
  44. package/dist/types/index.js +2 -0
  45. package/dist/types/index.js.map +1 -1
  46. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  47. package/dist/types/serverExecuteTypes.d.cts +9 -15
  48. package/dist/types/serverExecuteTypes.d.ts +9 -15
  49. package/dist/types/serverModelTypes.cjs +19 -0
  50. package/dist/types/serverModelTypes.cjs.map +1 -0
  51. package/dist/types/serverModelTypes.d.cts +42 -0
  52. package/dist/types/serverModelTypes.d.ts +42 -0
  53. package/dist/types/serverModelTypes.js +1 -0
  54. package/dist/types/serverModelTypes.js.map +1 -0
  55. package/dist/types/serverQueryTypes.cjs.map +1 -1
  56. package/dist/types/serverQueryTypes.d.cts +48 -7
  57. package/dist/types/serverQueryTypes.d.ts +48 -7
  58. package/package.json +4 -5
  59. package/src/TriggerClient.ts +90 -29
  60. package/src/dataMappers.ts +225 -71
  61. package/src/endpoints.ts +2 -2
  62. package/src/index.ts +2 -2
  63. package/src/types/TriggerServerFailureError.ts +2 -2
  64. package/src/types/clientModelTypes.ts +95 -0
  65. package/src/types/clientTypes.ts +70 -41
  66. package/src/types/index.ts +2 -0
  67. package/src/types/serverExecuteTypes.ts +9 -24
  68. package/src/types/serverModelTypes.ts +55 -0
  69. package/src/types/serverQueryTypes.ts +75 -9
@@ -3,122 +3,276 @@ import {
3
3
  removeDecimals,
4
4
  toBigDecimal,
5
5
  toIntegerString,
6
- } from '@nadohq/utils';
6
+ unpackOrderAppendix,
7
+ } from '@nadohq/shared';
7
8
  import {
9
+ PriceTriggerCriteria,
10
+ PriceTriggerRequirementType,
11
+ TimeTriggerCriteria,
8
12
  TriggerCriteria,
9
13
  TriggerOrder,
10
14
  TriggerOrderInfo,
11
15
  TriggerOrderStatus,
12
16
  TriggerServerOrderInfo,
13
17
  TriggerServerOrderStatus,
18
+ TriggerServerPriceRequirement,
19
+ TriggerServerPriceTriggerCriteria,
20
+ TriggerServerTimeTriggerCriteria,
14
21
  TriggerServerTriggerCriteria,
22
+ TriggerServerTwapExecutionStatus,
23
+ TwapExecutionStatus,
15
24
  } from './types';
16
25
 
17
- export function mapTriggerServerOrderStatus(
26
+ /**
27
+ * Maps client-side trigger criteria to server-side trigger criteria format.
28
+ * Converts price and time triggers to their respective server representations
29
+ * with proper decimal scaling and field name transformations.
30
+ *
31
+ * @param criteria - The client-side trigger criteria (price or time based)
32
+ * @returns The server-formatted trigger criteria ready for API transmission
33
+ */
34
+ export function mapTriggerCriteria(
35
+ criteria: TriggerCriteria,
36
+ ): TriggerServerTriggerCriteria {
37
+ switch (criteria.type) {
38
+ case 'price':
39
+ return {
40
+ price_trigger: mapPriceTriggerCriteria(criteria.criteria),
41
+ };
42
+ case 'time':
43
+ return {
44
+ time_trigger: mapTimeTriggerCriteria(criteria.criteria),
45
+ };
46
+ }
47
+ }
48
+
49
+ function mapPriceTriggerCriteria(
50
+ criteria: PriceTriggerCriteria,
51
+ ): TriggerServerPriceTriggerCriteria {
52
+ const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));
53
+
54
+ const price_requirement = ((): TriggerServerPriceRequirement => {
55
+ switch (criteria.type) {
56
+ case 'oracle_price_above':
57
+ return { oracle_price_above: priceValue };
58
+ case 'oracle_price_below':
59
+ return { oracle_price_below: priceValue };
60
+ case 'last_price_above':
61
+ return { last_price_above: priceValue };
62
+ case 'last_price_below':
63
+ return { last_price_below: priceValue };
64
+ case 'mid_price_above':
65
+ return { mid_price_above: priceValue };
66
+ case 'mid_price_below':
67
+ return { mid_price_below: priceValue };
68
+ }
69
+ })();
70
+
71
+ return {
72
+ price_requirement,
73
+ dependency: criteria.dependency
74
+ ? {
75
+ digest: criteria.dependency.digest,
76
+ on_partial_fill: criteria.dependency.onPartialFill,
77
+ }
78
+ : undefined,
79
+ };
80
+ }
81
+
82
+ function mapTimeTriggerCriteria(
83
+ criteria: TimeTriggerCriteria,
84
+ ): TriggerServerTimeTriggerCriteria {
85
+ return {
86
+ interval: Number(criteria.interval),
87
+ amounts: criteria.amounts?.map((amount) => toIntegerString(amount)),
88
+ };
89
+ }
90
+
91
+ /**
92
+ * Maps complete server-side trigger order information to client-side format.
93
+ *
94
+ * @param info - The complete server-side trigger order information including order, status, and timestamps
95
+ * @returns The client-side trigger order information with converted values and normalized structure
96
+ */
97
+ export function mapServerOrderInfo(
98
+ info: TriggerServerOrderInfo,
99
+ ): TriggerOrderInfo {
100
+ const { order: serverOrder, status, updated_at, placed_at } = info;
101
+ const order: TriggerOrder = {
102
+ amount: toBigDecimal(serverOrder.order.amount),
103
+ expiration: Number(serverOrder.order.expiration),
104
+ nonce: serverOrder.order.nonce,
105
+ price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),
106
+ digest: serverOrder.digest,
107
+ productId: serverOrder.product_id,
108
+ triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger),
109
+ appendix: unpackOrderAppendix(serverOrder.order.appendix),
110
+ };
111
+ return {
112
+ serverOrder,
113
+ order,
114
+ status: mapTriggerServerOrderStatus(status),
115
+ updatedAt: updated_at,
116
+ placementTime: placed_at,
117
+ };
118
+ }
119
+
120
+ function mapTriggerServerOrderStatus(
18
121
  status: TriggerServerOrderStatus,
19
122
  ): TriggerOrderStatus {
20
- if (status === 'pending') {
123
+ if (status === 'triggering') {
21
124
  return {
22
- type: 'pending',
125
+ type: 'triggering',
126
+ };
127
+ } else if (status === 'waiting_price') {
128
+ return {
129
+ type: 'waiting_price',
130
+ };
131
+ } else if (status === 'waiting_dependency') {
132
+ return {
133
+ type: 'waiting_dependency',
23
134
  };
24
135
  } else if ('cancelled' in status) {
25
136
  return {
26
137
  type: 'cancelled',
27
138
  reason: status.cancelled,
28
139
  };
140
+ } else if ('triggered' in status) {
141
+ return {
142
+ type: 'triggered',
143
+ result: status.triggered,
144
+ };
29
145
  } else if ('internal_error' in status) {
30
146
  return {
31
147
  type: 'internal_error',
32
148
  error: status.internal_error,
33
149
  };
34
- } else if ('triggered' in status) {
150
+ } else if ('twap_executing' in status) {
35
151
  return {
36
- type: 'triggered',
37
- result: status.triggered,
152
+ type: 'twap_executing',
153
+ currentExecution: status.twap_executing.current_execution,
154
+ totalExecutions: status.twap_executing.total_executions,
155
+ };
156
+ } else if ('twap_completed' in status) {
157
+ return {
158
+ type: 'twap_completed',
159
+ executed: status.twap_completed.executed,
160
+ total: status.twap_completed.total,
38
161
  };
39
162
  }
40
163
  throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
41
164
  }
42
165
 
43
- export function mapTriggerCriteria(
44
- criteria: TriggerCriteria,
45
- ): TriggerServerTriggerCriteria {
46
- const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));
47
- switch (criteria.type) {
48
- case 'oracle_price_above':
49
- return { price_above: priceValue };
50
- case 'oracle_price_below':
51
- return { price_below: priceValue };
52
- case 'last_price_above':
53
- return { last_price_above: priceValue };
54
- case 'last_price_below':
55
- return { last_price_below: priceValue };
56
- case 'mid_price_above':
57
- return { mid_price_above: priceValue };
58
- case 'mid_price_below':
59
- return { mid_price_below: priceValue };
60
- }
61
- }
62
-
63
- export function mapServerTriggerCriteria(
166
+ function mapServerTriggerCriteria(
64
167
  criteria: TriggerServerTriggerCriteria,
65
168
  ): TriggerCriteria {
66
- if ('price_above' in criteria) {
169
+ if ('price_trigger' in criteria) {
67
170
  return {
68
- type: 'oracle_price_above',
69
- triggerPrice: removeDecimals(criteria.price_above),
171
+ type: 'price',
172
+ criteria: mapServerPriceTriggerCriteria(criteria.price_trigger),
70
173
  };
71
174
  }
72
- if ('price_below' in criteria) {
175
+ if ('time_trigger' in criteria) {
73
176
  return {
74
- type: 'oracle_price_below',
75
- triggerPrice: removeDecimals(criteria.price_below),
177
+ type: 'time',
178
+ criteria: mapServerTimeTriggerCriteria(criteria.time_trigger),
76
179
  };
77
180
  }
78
- if ('last_price_above' in criteria) {
181
+ throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
182
+ }
183
+
184
+ function mapServerPriceTriggerCriteria(
185
+ serverCriteria: TriggerServerPriceTriggerCriteria,
186
+ ): PriceTriggerCriteria {
187
+ const { price_requirement, dependency } = serverCriteria;
188
+
189
+ const { type, triggerPrice } = ((): {
190
+ type: PriceTriggerRequirementType;
191
+ triggerPrice: string;
192
+ } => {
193
+ if ('oracle_price_above' in price_requirement) {
194
+ return {
195
+ type: 'oracle_price_above',
196
+ triggerPrice: price_requirement.oracle_price_above,
197
+ };
198
+ } else if ('oracle_price_below' in price_requirement) {
199
+ return {
200
+ type: 'oracle_price_below',
201
+ triggerPrice: price_requirement.oracle_price_below,
202
+ };
203
+ } else if ('last_price_above' in price_requirement) {
204
+ return {
205
+ type: 'last_price_above',
206
+ triggerPrice: price_requirement.last_price_above,
207
+ };
208
+ } else if ('last_price_below' in price_requirement) {
209
+ return {
210
+ type: 'last_price_below',
211
+ triggerPrice: price_requirement.last_price_below,
212
+ };
213
+ } else if ('mid_price_above' in price_requirement) {
214
+ return {
215
+ type: 'mid_price_above',
216
+ triggerPrice: price_requirement.mid_price_above,
217
+ };
218
+ } else if ('mid_price_below' in price_requirement) {
219
+ return {
220
+ type: 'mid_price_below',
221
+ triggerPrice: price_requirement.mid_price_below,
222
+ };
223
+ } else {
224
+ throw new Error(
225
+ `Unknown price requirement: ${JSON.stringify(price_requirement)}`,
226
+ );
227
+ }
228
+ })();
229
+
230
+ return {
231
+ type,
232
+ triggerPrice: removeDecimals(triggerPrice),
233
+ dependency: dependency
234
+ ? {
235
+ digest: dependency.digest,
236
+ onPartialFill: dependency.on_partial_fill,
237
+ }
238
+ : undefined,
239
+ };
240
+ }
241
+
242
+ function mapServerTimeTriggerCriteria(
243
+ serverCriteria: TriggerServerTimeTriggerCriteria,
244
+ ): TimeTriggerCriteria {
245
+ return {
246
+ interval: toBigDecimal(serverCriteria.interval),
247
+ amounts: serverCriteria.amounts?.map((amount: string) =>
248
+ toBigDecimal(amount),
249
+ ),
250
+ };
251
+ }
252
+
253
+ export function mapTwapExecutionStatus(
254
+ status: TriggerServerTwapExecutionStatus,
255
+ ): TwapExecutionStatus {
256
+ if (status === 'pending') {
79
257
  return {
80
- type: 'last_price_above',
81
- triggerPrice: removeDecimals(criteria.last_price_above),
258
+ type: 'pending',
82
259
  };
83
- }
84
- if ('last_price_below' in criteria) {
260
+ } else if ('executed' in status) {
85
261
  return {
86
- type: 'last_price_below',
87
- triggerPrice: removeDecimals(criteria.last_price_below),
262
+ type: 'executed',
263
+ executedTime: status.executed.executed_time,
264
+ executeResponse: status.executed.execute_response,
88
265
  };
89
- }
90
- if ('mid_price_above' in criteria) {
266
+ } else if ('failed' in status) {
91
267
  return {
92
- type: 'mid_price_above',
93
- triggerPrice: removeDecimals(criteria.mid_price_above),
268
+ type: 'failed',
269
+ error: status.failed,
94
270
  };
95
- }
96
- if ('mid_price_below' in criteria) {
271
+ } else if ('cancelled' in status) {
97
272
  return {
98
- type: 'mid_price_below',
99
- triggerPrice: removeDecimals(criteria.mid_price_below),
273
+ type: 'cancelled',
274
+ reason: status.cancelled,
100
275
  };
101
276
  }
102
- throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
103
- }
104
-
105
- export function mapServerOrderInfo(
106
- info: TriggerServerOrderInfo,
107
- ): TriggerOrderInfo {
108
- const { order: serverOrder, status, updated_at } = info;
109
- const order: TriggerOrder = {
110
- amount: toBigDecimal(serverOrder.order.amount),
111
- expiration: toBigDecimal(serverOrder.order.expiration),
112
- nonce: serverOrder.order.nonce,
113
- price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),
114
- digest: serverOrder.digest,
115
- productId: serverOrder.product_id,
116
- triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger),
117
- };
118
- return {
119
- serverOrder,
120
- order,
121
- status: mapTriggerServerOrderStatus(status),
122
- updatedAt: updated_at,
123
- };
277
+ throw Error(`Unknown TWAP execution status: ${JSON.stringify(status)}`);
124
278
  }
package/src/endpoints.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  export const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
4
4
  local: 'http://localhost:80/trigger',
5
- arbitrumTestnet: 'https://trigger.sepolia-test.vertexprotocol.com/v1',
6
5
  arbitrum: 'https://trigger.prod.vertexprotocol.com/v1',
6
+ inkTestnet: 'https://trigger.test.nado-backend.xyz/v1',
7
7
  };
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types';
2
- export * from './TriggerClient';
3
1
  export * from './endpoints';
2
+ export * from './TriggerClient';
3
+ export * from './types';
@@ -1,5 +1,5 @@
1
- import { TriggerServerQueryFailureResponse } from './serverQueryTypes';
2
1
  import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';
2
+ import { TriggerServerQueryFailureResponse } from './serverQueryTypes';
3
3
 
4
4
  export class TriggerServerFailureError extends Error {
5
5
  constructor(
@@ -7,6 +7,6 @@ export class TriggerServerFailureError extends Error {
7
7
  | TriggerServerQueryFailureResponse
8
8
  | EngineServerExecuteFailureResult,
9
9
  ) {
10
- super();
10
+ super(`${responseData.error_code}: ${responseData.error}`);
11
11
  }
12
12
  }
@@ -0,0 +1,95 @@
1
+ import { EngineServerExecuteResult } from '@nadohq/engine-client';
2
+ import { BigDecimalish } from '@nadohq/shared';
3
+
4
+ /*
5
+ Price trigger
6
+ */
7
+
8
+ export type PriceTriggerRequirementType =
9
+ | 'oracle_price_above'
10
+ | 'oracle_price_below'
11
+ | 'last_price_above'
12
+ | 'last_price_below'
13
+ | 'mid_price_above'
14
+ | 'mid_price_below';
15
+
16
+ export interface PriceTriggerDependency {
17
+ /**
18
+ * Digest of the order that this trigger depends on.
19
+ */
20
+ digest: string;
21
+ /**
22
+ * Whether to trigger on partial fills.
23
+ */
24
+ onPartialFill: boolean;
25
+ }
26
+
27
+ export interface PriceTriggerCriteria {
28
+ type: PriceTriggerRequirementType;
29
+ triggerPrice: BigDecimalish;
30
+ dependency?: PriceTriggerDependency;
31
+ }
32
+
33
+ /*
34
+ Time trigger (for TWAP)
35
+ */
36
+
37
+ export interface TimeTriggerCriteria {
38
+ /**
39
+ * For TWAP: Trigger interval in seconds
40
+ */
41
+ interval: BigDecimalish;
42
+ /**
43
+ * For TWAP: By default, trigger service will split up orders as per total amount / interval
44
+ * If you want to specify the amounts for each interval, you can provide them here.
45
+ */
46
+ amounts?: BigDecimalish[];
47
+ }
48
+
49
+ /**
50
+ * All possible trigger conditions that can be used to place a trigger order.
51
+ */
52
+ export type TriggerCriteria =
53
+ | {
54
+ type: 'price';
55
+ criteria: PriceTriggerCriteria;
56
+ }
57
+ | {
58
+ type: 'time';
59
+ criteria: TimeTriggerCriteria;
60
+ };
61
+
62
+ export type TriggerCriteriaType = TriggerCriteria['type'];
63
+
64
+ export type TriggerOrderStatus =
65
+ | {
66
+ type: 'cancelled';
67
+ reason: string;
68
+ }
69
+ | {
70
+ type: 'triggered';
71
+ result: EngineServerExecuteResult;
72
+ }
73
+ | {
74
+ type: 'internal_error';
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;
95
+ };
@@ -1,49 +1,28 @@
1
1
  import {
2
+ EngineOrderParams,
3
+ EngineServerExecuteResult,
4
+ } from '@nadohq/engine-client';
5
+ import {
6
+ BigDecimal,
2
7
  EIP712CancelOrdersParams,
3
8
  EIP712CancelProductOrdersParams,
9
+ OrderAppendix,
4
10
  Subaccount,
5
- } from '@nadohq/contracts';
11
+ } from '@nadohq/shared';
12
+ import { TriggerCriteria, TriggerOrderStatus } from './clientModelTypes';
6
13
  import {
7
- EngineOrderParams,
8
- EngineServerExecuteResult,
9
- } from '@nadohq/engine-client';
10
- import { BigDecimal, BigDecimalish } from '@nadohq/utils';
11
- import { TriggerServerOrder } from './serverQueryTypes';
14
+ TriggerServerOrder,
15
+ TriggerServerStatusTypeFilter,
16
+ TriggerServerTriggerTypeFilter,
17
+ } from './serverQueryTypes';
12
18
 
13
19
  type WithOptionalNonce<T> = Omit<T, 'nonce'> & { nonce?: string };
14
20
 
15
- export type TriggerCriteriaType =
16
- | 'oracle_price_above'
17
- | 'oracle_price_below'
18
- | 'last_price_above'
19
- | 'last_price_below'
20
- | 'mid_price_above'
21
- | 'mid_price_below';
22
-
23
- export type TriggerCriteria = {
24
- type: TriggerCriteriaType;
25
- triggerPrice: BigDecimalish;
26
- };
27
-
28
- export type TriggerOrderStatus =
29
- | {
30
- type: 'pending';
31
- }
32
- | {
33
- type: 'cancelled';
34
- reason: string;
35
- }
36
- | {
37
- type: 'triggered';
38
- result: EngineServerExecuteResult;
39
- }
40
- | {
41
- type: 'internal_error';
42
- error: string;
43
- };
44
-
45
21
  interface SignatureParams {
46
- // Orderbook address for placement, endpoint address for cancellation & listing
22
+ /**
23
+ * Address derived from productId for placement (see getOrderVerifyingAddr)
24
+ * endpoint address for cancellation & listing
25
+ */
47
26
  verifyingAddr: string;
48
27
  chainId: number;
49
28
  }
@@ -59,10 +38,21 @@ export interface TriggerPlaceOrderParams extends SignatureParams {
59
38
  triggerCriteria: TriggerCriteria;
60
39
  // If not given, engine defaults to true (leverage/borrow enabled)
61
40
  spotLeverage?: boolean;
41
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
42
+ borrowMargin?: boolean;
62
43
  digest?: string;
63
44
  nonce?: string;
64
45
  }
65
46
 
47
+ export interface TriggerPlaceOrdersParams {
48
+ orders: TriggerPlaceOrderParams[];
49
+ /**
50
+ * If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
51
+ * If not provided, the default value is `false`.
52
+ */
53
+ cancelOnFailure?: boolean;
54
+ }
55
+
66
56
  export type TriggerCancelOrdersParams = SignatureParams &
67
57
  WithOptionalNonce<EIP712CancelOrdersParams>;
68
58
 
@@ -77,14 +67,18 @@ export interface TriggerListOrdersParams extends Subaccount, SignatureParams {
77
67
  // In millis, defaults to 90s in the future
78
68
  recvTime?: BigDecimal;
79
69
  // If not given, defaults to all products
80
- productId?: number;
81
- // Pending trigger orders only, ignores cancelled & triggered orders
82
- pending: boolean;
70
+ productIds?: number[];
83
71
  // In seconds
84
72
  maxUpdateTimeInclusive?: number;
85
73
  // When provided, the associated trigger orders are returned regardless of other filters
86
74
  digests?: string[];
87
75
  limit?: number;
76
+ // Filter by status types
77
+ statusTypes?: TriggerServerStatusTypeFilter[];
78
+ // Filter by trigger types
79
+ triggerTypes?: TriggerServerTriggerTypeFilter[];
80
+ // Filter by reduce-only orders
81
+ reduceOnly?: boolean;
88
82
  }
89
83
 
90
84
  export interface TriggerOrder {
@@ -92,9 +86,10 @@ export interface TriggerOrder {
92
86
  triggerCriteria: TriggerCriteria;
93
87
  price: BigDecimal;
94
88
  amount: BigDecimal;
95
- expiration: BigDecimal;
89
+ expiration: number;
96
90
  nonce: string;
97
91
  digest: string;
92
+ appendix: OrderAppendix;
98
93
  }
99
94
 
100
95
  export interface TriggerOrderInfo {
@@ -102,8 +97,42 @@ export interface TriggerOrderInfo {
102
97
  serverOrder: TriggerServerOrder;
103
98
  status: TriggerOrderStatus;
104
99
  updatedAt: number;
100
+ placementTime: number;
105
101
  }
106
102
 
107
103
  export interface TriggerListOrdersResponse {
108
104
  orders: TriggerOrderInfo[];
109
105
  }
106
+
107
+ export interface TriggerListTwapExecutionsParams {
108
+ digest: string;
109
+ }
110
+
111
+ export type TwapExecutionStatus =
112
+ | {
113
+ type: 'pending';
114
+ }
115
+ | {
116
+ type: 'executed';
117
+ executedTime: number;
118
+ executeResponse: EngineServerExecuteResult;
119
+ }
120
+ | {
121
+ type: 'failed';
122
+ error: string;
123
+ }
124
+ | {
125
+ type: 'cancelled';
126
+ reason: string;
127
+ };
128
+
129
+ export interface TwapExecutionInfo {
130
+ executionId: number;
131
+ scheduledTime: number;
132
+ status: TwapExecutionStatus;
133
+ updatedAt: number;
134
+ }
135
+
136
+ export interface TriggerListTwapExecutionsResponse {
137
+ executions: TwapExecutionInfo[];
138
+ }
@@ -1,4 +1,6 @@
1
+ export * from './clientModelTypes';
1
2
  export * from './clientTypes';
2
3
  export * from './serverExecuteTypes';
4
+ export * from './serverModelTypes';
3
5
  export * from './serverQueryTypes';
4
6
  export * from './TriggerServerFailureError';
@@ -1,32 +1,10 @@
1
- import { EIP712OrderValues } from '@nadohq/contracts';
2
1
  import {
3
2
  EngineServerExecuteFailureResult,
4
3
  EngineServerExecuteRequestByType,
5
4
  EngineServerExecuteSuccessResult,
6
5
  } from '@nadohq/engine-client';
7
-
8
- export type TriggerServerTriggerCriteria =
9
- // These trigger on fast oracle price
10
- | {
11
- price_above: string;
12
- }
13
- | {
14
- price_below: string;
15
- }
16
- // These trigger on last trade price
17
- | {
18
- last_price_above: string;
19
- }
20
- | {
21
- last_price_below: string;
22
- }
23
- // These trigger on mid-book price
24
- | {
25
- mid_price_above: string;
26
- }
27
- | {
28
- mid_price_below: string;
29
- };
6
+ import { EIP712OrderValues } from '@nadohq/shared';
7
+ import { TriggerServerTriggerCriteria } from './serverModelTypes';
30
8
 
31
9
  export interface TriggerServerPlaceOrderParams {
32
10
  id: number | null;
@@ -37,6 +15,7 @@ export interface TriggerServerPlaceOrderParams {
37
15
  digest: string | null;
38
16
  // Trigger service defaults this to true
39
17
  spot_leverage: boolean | null;
18
+ borrow_margin: boolean | null;
40
19
  }
41
20
 
42
21
  export type TriggerServerCancelOrdersParams =
@@ -45,8 +24,14 @@ export type TriggerServerCancelOrdersParams =
45
24
  export type TriggerServerCancelProductOrdersParams =
46
25
  EngineServerExecuteRequestByType['cancel_product_orders'];
47
26
 
27
+ export interface TriggerServerPlaceOrdersParams {
28
+ orders: TriggerServerPlaceOrderParams[];
29
+ cancel_on_failure: boolean | null;
30
+ }
31
+
48
32
  export interface TriggerServerExecuteRequestByType {
49
33
  place_order: TriggerServerPlaceOrderParams;
34
+ place_orders: TriggerServerPlaceOrdersParams;
50
35
  cancel_orders: TriggerServerCancelOrdersParams;
51
36
  cancel_product_orders: TriggerServerCancelProductOrdersParams;
52
37
  }