@pear-protocol/types 1.0.0 → 1.2.0

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.
package/dist/bundle.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './instrument-precision';
10
10
  export * from './leverage';
11
11
  export * from './market';
12
12
  export * from './misc';
13
+ export * from './notification';
13
14
  export * from './order';
14
15
  export * from './portfolio';
15
16
  export * from './position';
package/dist/bundle.js CHANGED
@@ -10,6 +10,7 @@ export * from './instrument-precision';
10
10
  export * from './leverage';
11
11
  export * from './market';
12
12
  export * from './misc';
13
+ export * from './notification';
13
14
  export * from './order';
14
15
  export * from './portfolio';
15
16
  export * from './position';
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod';
2
+ export declare const NotificationCategory: z.ZodEnum<{
3
+ TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
4
+ STOP_LOSS_HIT: "STOP_LOSS_HIT";
5
+ TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
6
+ }>;
7
+ export type NotificationCategory = z.infer<typeof NotificationCategory>;
8
+ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ type: z.ZodLiteral<"take_profit">;
10
+ triggerId: z.ZodUUID;
11
+ positionId: z.ZodUUID;
12
+ connector: z.ZodEnum<{
13
+ hyperliquid: "hyperliquid";
14
+ binance: "binance";
15
+ bybit: "bybit";
16
+ okx: "okx";
17
+ lighter: "lighter";
18
+ }>;
19
+ }, z.core.$strip>, z.ZodObject<{
20
+ type: z.ZodLiteral<"stop_loss">;
21
+ triggerId: z.ZodUUID;
22
+ positionId: z.ZodUUID;
23
+ connector: z.ZodEnum<{
24
+ hyperliquid: "hyperliquid";
25
+ binance: "binance";
26
+ bybit: "bybit";
27
+ okx: "okx";
28
+ lighter: "lighter";
29
+ }>;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"trigger_order">;
32
+ triggerId: z.ZodUUID;
33
+ positionId: z.ZodUUID;
34
+ connector: z.ZodEnum<{
35
+ hyperliquid: "hyperliquid";
36
+ binance: "binance";
37
+ bybit: "bybit";
38
+ okx: "okx";
39
+ lighter: "lighter";
40
+ }>;
41
+ }, z.core.$strip>, z.ZodObject<{
42
+ type: z.ZodLiteral<"default_trigger">;
43
+ triggerId: z.ZodUUID;
44
+ connector: z.ZodEnum<{
45
+ hyperliquid: "hyperliquid";
46
+ binance: "binance";
47
+ bybit: "bybit";
48
+ okx: "okx";
49
+ lighter: "lighter";
50
+ }>;
51
+ }, z.core.$strip>], "type">;
52
+ export type NotificationParameters = z.output<typeof NotificationParameters>;
53
+ export declare const Notification: z.ZodObject<{
54
+ id: z.ZodUUID;
55
+ category: z.ZodEnum<{
56
+ TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
57
+ STOP_LOSS_HIT: "STOP_LOSS_HIT";
58
+ TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
59
+ }>;
60
+ parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
61
+ type: z.ZodLiteral<"take_profit">;
62
+ triggerId: z.ZodUUID;
63
+ positionId: z.ZodUUID;
64
+ connector: z.ZodEnum<{
65
+ hyperliquid: "hyperliquid";
66
+ binance: "binance";
67
+ bybit: "bybit";
68
+ okx: "okx";
69
+ lighter: "lighter";
70
+ }>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ type: z.ZodLiteral<"stop_loss">;
73
+ triggerId: z.ZodUUID;
74
+ positionId: z.ZodUUID;
75
+ connector: z.ZodEnum<{
76
+ hyperliquid: "hyperliquid";
77
+ binance: "binance";
78
+ bybit: "bybit";
79
+ okx: "okx";
80
+ lighter: "lighter";
81
+ }>;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ type: z.ZodLiteral<"trigger_order">;
84
+ triggerId: z.ZodUUID;
85
+ positionId: z.ZodUUID;
86
+ connector: z.ZodEnum<{
87
+ hyperliquid: "hyperliquid";
88
+ binance: "binance";
89
+ bybit: "bybit";
90
+ okx: "okx";
91
+ lighter: "lighter";
92
+ }>;
93
+ }, z.core.$strip>, z.ZodObject<{
94
+ type: z.ZodLiteral<"default_trigger">;
95
+ triggerId: z.ZodUUID;
96
+ connector: z.ZodEnum<{
97
+ hyperliquid: "hyperliquid";
98
+ binance: "binance";
99
+ bybit: "bybit";
100
+ okx: "okx";
101
+ lighter: "lighter";
102
+ }>;
103
+ }, z.core.$strip>], "type">;
104
+ isRead: z.ZodBoolean;
105
+ createdAt: z.ZodString;
106
+ updatedAt: z.ZodString;
107
+ }, z.core.$strip>;
108
+ export type Notification = z.output<typeof Notification>;
@@ -0,0 +1,61 @@
1
+ import { z } from 'zod';
2
+ import { Connector } from '../connector';
3
+
4
+ const NotificationCategory = z.enum(["TAKE_PROFIT_HIT", "STOP_LOSS_HIT", "TRIGGER_ORDER_HIT"]);
5
+ const TakeProfitNotificationParameters = z.object({
6
+ type: z.literal("take_profit"),
7
+ triggerId: z.uuid(),
8
+ positionId: z.uuid(),
9
+ connector: Connector
10
+ });
11
+ const StopLossNotificationParameters = z.object({
12
+ type: z.literal("stop_loss"),
13
+ triggerId: z.uuid(),
14
+ positionId: z.uuid(),
15
+ connector: Connector
16
+ });
17
+ const TriggerOrderNotificationParameters = z.object({
18
+ type: z.literal("trigger_order"),
19
+ triggerId: z.uuid(),
20
+ positionId: z.uuid(),
21
+ connector: Connector
22
+ });
23
+ const DefaultTriggerNotificationParameters = z.object({
24
+ type: z.literal("default_trigger"),
25
+ triggerId: z.uuid(),
26
+ connector: Connector
27
+ });
28
+ const NotificationParameters = z.discriminatedUnion("type", [
29
+ TakeProfitNotificationParameters,
30
+ StopLossNotificationParameters,
31
+ TriggerOrderNotificationParameters,
32
+ DefaultTriggerNotificationParameters
33
+ ]);
34
+ const Notification = z.object({
35
+ /**
36
+ * Notification UUID
37
+ */
38
+ id: z.uuid(),
39
+ /**
40
+ * What kind of notification this is
41
+ */
42
+ category: NotificationCategory,
43
+ /**
44
+ * Category-specific display payload
45
+ */
46
+ parameters: NotificationParameters,
47
+ /**
48
+ * Whether the user has read it
49
+ */
50
+ isRead: z.boolean(),
51
+ /**
52
+ * Created at timestamp
53
+ */
54
+ createdAt: z.string(),
55
+ /**
56
+ * Updated at timestamp
57
+ */
58
+ updatedAt: z.string()
59
+ });
60
+
61
+ export { Notification, NotificationCategory, NotificationParameters };
@@ -0,0 +1,4 @@
1
+ export * from './entities';
2
+ export * from './payloads';
3
+ export * from './queries';
4
+ export * from './responses';
@@ -0,0 +1,4 @@
1
+ export * from './entities';
2
+ export * from './payloads';
3
+ export * from './queries';
4
+ export * from './responses';
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Mark notifications as read. Provide exactly one selector: a single `id`, or a
4
+ * `timestamp` (epoch ms) to mark every notification created at or before it.
5
+ */
6
+ export declare const MarkNotificationsReadPayload: z.ZodUnion<readonly [z.ZodObject<{
7
+ id: z.ZodUUID;
8
+ }, z.core.$strict>, z.ZodObject<{
9
+ timestamp: z.ZodCoercedNumber<number>;
10
+ }, z.core.$strict>]>;
11
+ export type MarkNotificationsReadPayloadInput = z.input<typeof MarkNotificationsReadPayload>;
12
+ export type MarkNotificationsReadPayload = z.output<typeof MarkNotificationsReadPayload>;
13
+ /**
14
+ * Mark a single notification unread again.
15
+ */
16
+ export declare const MarkNotificationUnreadPayload: z.ZodObject<{
17
+ id: z.ZodUUID;
18
+ }, z.core.$strict>;
19
+ export type MarkNotificationUnreadPayloadInput = z.input<typeof MarkNotificationUnreadPayload>;
20
+ export type MarkNotificationUnreadPayload = z.output<typeof MarkNotificationUnreadPayload>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ const MarkNotificationsReadPayload = z.union([
4
+ z.strictObject({ id: z.uuid() }),
5
+ z.strictObject({ timestamp: z.coerce.number().int().positive() })
6
+ ]);
7
+ const MarkNotificationUnreadPayload = z.strictObject({ id: z.uuid() });
8
+
9
+ export { MarkNotificationUnreadPayload, MarkNotificationsReadPayload };
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export declare const NotificationListParams: z.ZodObject<{
3
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
4
+ startDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
5
+ endDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
6
+ scope: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
7
+ all: "all";
8
+ read: "read";
9
+ unread: "unread";
10
+ }>>>;
11
+ }, z.core.$strip>;
12
+ export type NotificationListParamsInput = z.input<typeof NotificationListParams>;
13
+ export type NotificationListParams = z.output<typeof NotificationListParams>;
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+
3
+ const NotificationListParams = z.object({
4
+ /**
5
+ * The maximum number of notifications to retrieve (newest first).
6
+ * Matches the V2 engine: max and default are both 100.
7
+ */
8
+ limit: z.coerce.number().int().positive().max(100).optional().default(100),
9
+ /**
10
+ * Only return notifications created at or after this date.
11
+ */
12
+ startDate: z.coerce.date().optional(),
13
+ /**
14
+ * Only return notifications created at or before this date.
15
+ */
16
+ endDate: z.coerce.date().optional(),
17
+ /**
18
+ * Filter by read state: `all` (default), only `read`, or only `unread`.
19
+ */
20
+ scope: z.enum(["all", "read", "unread"]).optional().default("all")
21
+ }).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
22
+ message: "startDate must be before endDate"
23
+ });
24
+
25
+ export { NotificationListParams };
@@ -0,0 +1,67 @@
1
+ import { z } from 'zod';
2
+ export declare const NotificationListResponse: z.ZodObject<{
3
+ notifications: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodUUID;
5
+ category: z.ZodEnum<{
6
+ TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
7
+ STOP_LOSS_HIT: "STOP_LOSS_HIT";
8
+ TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
9
+ }>;
10
+ parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
+ type: z.ZodLiteral<"take_profit">;
12
+ triggerId: z.ZodUUID;
13
+ positionId: z.ZodUUID;
14
+ connector: z.ZodEnum<{
15
+ hyperliquid: "hyperliquid";
16
+ binance: "binance";
17
+ bybit: "bybit";
18
+ okx: "okx";
19
+ lighter: "lighter";
20
+ }>;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ type: z.ZodLiteral<"stop_loss">;
23
+ triggerId: z.ZodUUID;
24
+ positionId: z.ZodUUID;
25
+ connector: z.ZodEnum<{
26
+ hyperliquid: "hyperliquid";
27
+ binance: "binance";
28
+ bybit: "bybit";
29
+ okx: "okx";
30
+ lighter: "lighter";
31
+ }>;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ type: z.ZodLiteral<"trigger_order">;
34
+ triggerId: z.ZodUUID;
35
+ positionId: z.ZodUUID;
36
+ connector: z.ZodEnum<{
37
+ hyperliquid: "hyperliquid";
38
+ binance: "binance";
39
+ bybit: "bybit";
40
+ okx: "okx";
41
+ lighter: "lighter";
42
+ }>;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ type: z.ZodLiteral<"default_trigger">;
45
+ triggerId: z.ZodUUID;
46
+ connector: z.ZodEnum<{
47
+ hyperliquid: "hyperliquid";
48
+ binance: "binance";
49
+ bybit: "bybit";
50
+ okx: "okx";
51
+ lighter: "lighter";
52
+ }>;
53
+ }, z.core.$strip>], "type">;
54
+ isRead: z.ZodBoolean;
55
+ createdAt: z.ZodString;
56
+ updatedAt: z.ZodString;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export type NotificationListResponse = z.output<typeof NotificationListResponse>;
60
+ export declare const MarkNotificationsReadResponse: z.ZodObject<{
61
+ updated: z.ZodNumber;
62
+ }, z.core.$strip>;
63
+ export type MarkNotificationsReadResponse = z.output<typeof MarkNotificationsReadResponse>;
64
+ export declare const MarkNotificationUnreadResponse: z.ZodObject<{
65
+ updated: z.ZodNumber;
66
+ }, z.core.$strip>;
67
+ export type MarkNotificationUnreadResponse = z.output<typeof MarkNotificationUnreadResponse>;
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { Notification } from './entities';
3
+
4
+ const NotificationListResponse = z.object({
5
+ notifications: z.array(Notification)
6
+ });
7
+ const MarkNotificationsReadResponse = z.object({
8
+ /**
9
+ * How many notifications were flipped from unread to read.
10
+ */
11
+ updated: z.number().int()
12
+ });
13
+ const MarkNotificationUnreadResponse = z.object({
14
+ /**
15
+ * How many notifications were flipped from read to unread.
16
+ */
17
+ updated: z.number().int()
18
+ });
19
+
20
+ export { MarkNotificationUnreadResponse, MarkNotificationsReadResponse, NotificationListResponse };
@@ -103,6 +103,44 @@ export declare const TcaFillMetricResponse: z.ZodObject<{
103
103
  }, z.core.$strip>>;
104
104
  }, z.core.$strip>;
105
105
  export type TcaFillMetricResponse = z.output<typeof TcaFillMetricResponse>;
106
+ export declare const TcaExecutionSummaryLegResponse: z.ZodObject<{
107
+ symbol: z.ZodString;
108
+ side: z.ZodEnum<{
109
+ BUY: "BUY";
110
+ SELL: "SELL";
111
+ }>;
112
+ reduceOnly: z.ZodBoolean;
113
+ }, z.core.$strip>;
114
+ export type TcaExecutionSummaryLegResponse = z.output<typeof TcaExecutionSummaryLegResponse>;
115
+ export declare const TcaExecutionSummaryContextResponse: z.ZodObject<{
116
+ intent: z.ZodEnum<{
117
+ OPEN: "OPEN";
118
+ CLOSE: "CLOSE";
119
+ ADJUST: "ADJUST";
120
+ }>;
121
+ orderType: z.ZodEnum<{
122
+ MARKET: "MARKET";
123
+ }>;
124
+ executionStatus: z.ZodEnum<{
125
+ CANCELLED: "CANCELLED";
126
+ IDLE: "IDLE";
127
+ ACTIVE: "ACTIVE";
128
+ COMPLETED: "COMPLETED";
129
+ FAILED: "FAILED";
130
+ }>;
131
+ positionId: z.ZodOptional<z.ZodUUID>;
132
+ scheduleId: z.ZodOptional<z.ZodUUID>;
133
+ triggerId: z.ZodOptional<z.ZodUUID>;
134
+ legs: z.ZodArray<z.ZodObject<{
135
+ symbol: z.ZodString;
136
+ side: z.ZodEnum<{
137
+ BUY: "BUY";
138
+ SELL: "SELL";
139
+ }>;
140
+ reduceOnly: z.ZodBoolean;
141
+ }, z.core.$strip>>;
142
+ }, z.core.$strip>;
143
+ export type TcaExecutionSummaryContextResponse = z.output<typeof TcaExecutionSummaryContextResponse>;
106
144
  export declare const TcaExecutionSummaryResponse: z.ZodObject<{
107
145
  id: z.ZodUUID;
108
146
  executionId: z.ZodUUID;
@@ -114,6 +152,34 @@ export declare const TcaExecutionSummaryResponse: z.ZodObject<{
114
152
  okx: "okx";
115
153
  lighter: "lighter";
116
154
  }>;
155
+ executionContext: z.ZodOptional<z.ZodObject<{
156
+ intent: z.ZodEnum<{
157
+ OPEN: "OPEN";
158
+ CLOSE: "CLOSE";
159
+ ADJUST: "ADJUST";
160
+ }>;
161
+ orderType: z.ZodEnum<{
162
+ MARKET: "MARKET";
163
+ }>;
164
+ executionStatus: z.ZodEnum<{
165
+ CANCELLED: "CANCELLED";
166
+ IDLE: "IDLE";
167
+ ACTIVE: "ACTIVE";
168
+ COMPLETED: "COMPLETED";
169
+ FAILED: "FAILED";
170
+ }>;
171
+ positionId: z.ZodOptional<z.ZodUUID>;
172
+ scheduleId: z.ZodOptional<z.ZodUUID>;
173
+ triggerId: z.ZodOptional<z.ZodUUID>;
174
+ legs: z.ZodArray<z.ZodObject<{
175
+ symbol: z.ZodString;
176
+ side: z.ZodEnum<{
177
+ BUY: "BUY";
178
+ SELL: "SELL";
179
+ }>;
180
+ reduceOnly: z.ZodBoolean;
181
+ }, z.core.$strip>>;
182
+ }, z.core.$strip>>;
117
183
  notionalQuote: z.ZodOptional<z.ZodString>;
118
184
  notionalUsd: z.ZodOptional<z.ZodString>;
119
185
  weightedSlippageBps: z.ZodOptional<z.ZodString>;
@@ -139,6 +205,34 @@ export declare const TcaExecutionResponse: z.ZodObject<{
139
205
  okx: "okx";
140
206
  lighter: "lighter";
141
207
  }>;
208
+ executionContext: z.ZodOptional<z.ZodObject<{
209
+ intent: z.ZodEnum<{
210
+ OPEN: "OPEN";
211
+ CLOSE: "CLOSE";
212
+ ADJUST: "ADJUST";
213
+ }>;
214
+ orderType: z.ZodEnum<{
215
+ MARKET: "MARKET";
216
+ }>;
217
+ executionStatus: z.ZodEnum<{
218
+ CANCELLED: "CANCELLED";
219
+ IDLE: "IDLE";
220
+ ACTIVE: "ACTIVE";
221
+ COMPLETED: "COMPLETED";
222
+ FAILED: "FAILED";
223
+ }>;
224
+ positionId: z.ZodOptional<z.ZodUUID>;
225
+ scheduleId: z.ZodOptional<z.ZodUUID>;
226
+ triggerId: z.ZodOptional<z.ZodUUID>;
227
+ legs: z.ZodArray<z.ZodObject<{
228
+ symbol: z.ZodString;
229
+ side: z.ZodEnum<{
230
+ BUY: "BUY";
231
+ SELL: "SELL";
232
+ }>;
233
+ reduceOnly: z.ZodBoolean;
234
+ }, z.core.$strip>>;
235
+ }, z.core.$strip>>;
142
236
  notionalQuote: z.ZodOptional<z.ZodString>;
143
237
  notionalUsd: z.ZodOptional<z.ZodString>;
144
238
  weightedSlippageBps: z.ZodOptional<z.ZodString>;
@@ -307,6 +401,7 @@ export declare const TcaSummaryTotalsResponse: z.ZodObject<{
307
401
  fillCount: z.ZodNumber;
308
402
  notionalQuote: z.ZodOptional<z.ZodString>;
309
403
  notionalUsd: z.ZodOptional<z.ZodString>;
404
+ weightedSlippageBps: z.ZodOptional<z.ZodString>;
310
405
  totalSlippageUsd: z.ZodOptional<z.ZodString>;
311
406
  totalTradeFee: z.ZodOptional<z.ZodString>;
312
407
  totalPearFee: z.ZodOptional<z.ZodString>;
@@ -327,6 +422,34 @@ export declare const TcaSummaryResponse: z.ZodObject<{
327
422
  okx: "okx";
328
423
  lighter: "lighter";
329
424
  }>;
425
+ executionContext: z.ZodOptional<z.ZodObject<{
426
+ intent: z.ZodEnum<{
427
+ OPEN: "OPEN";
428
+ CLOSE: "CLOSE";
429
+ ADJUST: "ADJUST";
430
+ }>;
431
+ orderType: z.ZodEnum<{
432
+ MARKET: "MARKET";
433
+ }>;
434
+ executionStatus: z.ZodEnum<{
435
+ CANCELLED: "CANCELLED";
436
+ IDLE: "IDLE";
437
+ ACTIVE: "ACTIVE";
438
+ COMPLETED: "COMPLETED";
439
+ FAILED: "FAILED";
440
+ }>;
441
+ positionId: z.ZodOptional<z.ZodUUID>;
442
+ scheduleId: z.ZodOptional<z.ZodUUID>;
443
+ triggerId: z.ZodOptional<z.ZodUUID>;
444
+ legs: z.ZodArray<z.ZodObject<{
445
+ symbol: z.ZodString;
446
+ side: z.ZodEnum<{
447
+ BUY: "BUY";
448
+ SELL: "SELL";
449
+ }>;
450
+ reduceOnly: z.ZodBoolean;
451
+ }, z.core.$strip>>;
452
+ }, z.core.$strip>>;
330
453
  notionalQuote: z.ZodOptional<z.ZodString>;
331
454
  notionalUsd: z.ZodOptional<z.ZodString>;
332
455
  weightedSlippageBps: z.ZodOptional<z.ZodString>;
@@ -344,6 +467,7 @@ export declare const TcaSummaryResponse: z.ZodObject<{
344
467
  fillCount: z.ZodNumber;
345
468
  notionalQuote: z.ZodOptional<z.ZodString>;
346
469
  notionalUsd: z.ZodOptional<z.ZodString>;
470
+ weightedSlippageBps: z.ZodOptional<z.ZodString>;
347
471
  totalSlippageUsd: z.ZodOptional<z.ZodString>;
348
472
  totalTradeFee: z.ZodOptional<z.ZodString>;
349
473
  totalPearFee: z.ZodOptional<z.ZodString>;
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import { Side } from '../common/schema';
2
3
  import { Connector } from '../connector';
4
+ import { ExecutionStatus, ExecutionOrderType, ExecutionIntent } from '../execution/entities';
3
5
  import { TcaMetricStatus, TcaTimingGranularity } from './entities';
4
6
 
5
7
  const optionalNumeric = z.string().optional();
@@ -59,11 +61,26 @@ const TcaFillMetricResponse = z.object({
59
61
  updatedAt: z.iso.datetime(),
60
62
  benchmark: TcaBenchmarkResponse.optional()
61
63
  });
64
+ const TcaExecutionSummaryLegResponse = z.object({
65
+ symbol: z.string(),
66
+ side: Side,
67
+ reduceOnly: z.boolean()
68
+ });
69
+ const TcaExecutionSummaryContextResponse = z.object({
70
+ intent: ExecutionIntent,
71
+ orderType: ExecutionOrderType,
72
+ executionStatus: ExecutionStatus,
73
+ positionId: z.uuid().optional(),
74
+ scheduleId: z.uuid().optional(),
75
+ triggerId: z.uuid().optional(),
76
+ legs: z.array(TcaExecutionSummaryLegResponse)
77
+ });
62
78
  const TcaExecutionSummaryResponse = z.object({
63
79
  id: z.uuid(),
64
80
  executionId: z.uuid(),
65
81
  tradeAccountId: z.uuid(),
66
82
  connector: Connector,
83
+ executionContext: TcaExecutionSummaryContextResponse.optional(),
67
84
  notionalQuote: optionalNumeric,
68
85
  notionalUsd: optionalNumeric,
69
86
  weightedSlippageBps: optionalNumeric,
@@ -90,6 +107,7 @@ const TcaSummaryTotalsResponse = z.object({
90
107
  fillCount: z.number(),
91
108
  notionalQuote: optionalNumeric,
92
109
  notionalUsd: optionalNumeric,
110
+ weightedSlippageBps: optionalNumeric,
93
111
  totalSlippageUsd: optionalNumeric,
94
112
  totalTradeFee: optionalNumeric,
95
113
  totalPearFee: optionalNumeric,
@@ -102,4 +120,4 @@ const TcaSummaryResponse = z.object({
102
120
  totals: TcaSummaryTotalsResponse
103
121
  });
104
122
 
105
- export { TcaBenchmarkResponse, TcaExecutionResponse, TcaExecutionSummaryResponse, TcaFillMetricResponse, TcaPositionResponse, TcaSummaryResponse, TcaSummaryTotalsResponse };
123
+ export { TcaBenchmarkResponse, TcaExecutionResponse, TcaExecutionSummaryContextResponse, TcaExecutionSummaryLegResponse, TcaExecutionSummaryResponse, TcaFillMetricResponse, TcaPositionResponse, TcaSummaryResponse, TcaSummaryTotalsResponse };
@@ -30,7 +30,6 @@ export declare const CreateMarketOpen: z.ZodObject<{
30
30
  bracketType: z.ZodEnum<{
31
31
  STOP_LOSS: "STOP_LOSS";
32
32
  TAKE_PROFIT: "TAKE_PROFIT";
33
- NONE: "NONE";
34
33
  }>;
35
34
  condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
36
35
  type: z.ZodLiteral<"notional">;
@@ -167,7 +166,6 @@ export declare const CreateTradeOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
167
166
  bracketType: z.ZodEnum<{
168
167
  STOP_LOSS: "STOP_LOSS";
169
168
  TAKE_PROFIT: "TAKE_PROFIT";
170
- NONE: "NONE";
171
169
  }>;
172
170
  condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
173
171
  type: z.ZodLiteral<"notional">;
@@ -77,6 +77,16 @@ declare const BaseTrigger: z.ZodObject<{
77
77
  createdAt: z.ZodString;
78
78
  updatedAt: z.ZodString;
79
79
  }, z.core.$strip>;
80
+ export declare const TriggerMarketOpenAttachedTrigger: z.ZodObject<{
81
+ kind: z.ZodEnum<{
82
+ STATIC: "STATIC";
83
+ TRAILING: "TRAILING";
84
+ }>;
85
+ bracketType: z.ZodEnum<{
86
+ STOP_LOSS: "STOP_LOSS";
87
+ TAKE_PROFIT: "TAKE_PROFIT";
88
+ }>;
89
+ }, z.core.$strip>;
80
90
  export declare const TriggerMarketOpen: z.ZodObject<{
81
91
  id: z.ZodUUID;
82
92
  tradeAccountId: z.ZodUUID;
@@ -262,6 +272,16 @@ export declare const TriggerMarketOpen: z.ZodObject<{
262
272
  }>;
263
273
  amount: z.ZodString;
264
274
  }, z.core.$strip>>;
275
+ attachedTriggers: z.ZodArray<z.ZodObject<{
276
+ kind: z.ZodEnum<{
277
+ STATIC: "STATIC";
278
+ TRAILING: "TRAILING";
279
+ }>;
280
+ bracketType: z.ZodEnum<{
281
+ STOP_LOSS: "STOP_LOSS";
282
+ TAKE_PROFIT: "TAKE_PROFIT";
283
+ }>;
284
+ }, z.core.$strip>>;
265
285
  }, z.core.$strip>;
266
286
  }, z.core.$strip>;
267
287
  export declare const TriggerMarketAdjust: z.ZodObject<{
@@ -969,6 +989,16 @@ export declare const TriggerMarket: z.ZodDiscriminatedUnion<[z.ZodObject<{
969
989
  }>;
970
990
  amount: z.ZodString;
971
991
  }, z.core.$strip>>;
992
+ attachedTriggers: z.ZodArray<z.ZodObject<{
993
+ kind: z.ZodEnum<{
994
+ STATIC: "STATIC";
995
+ TRAILING: "TRAILING";
996
+ }>;
997
+ bracketType: z.ZodEnum<{
998
+ STOP_LOSS: "STOP_LOSS";
999
+ TAKE_PROFIT: "TAKE_PROFIT";
1000
+ }>;
1001
+ }, z.core.$strip>>;
972
1002
  }, z.core.$strip>;
973
1003
  }, z.core.$strip>, z.ZodObject<{
974
1004
  id: z.ZodUUID;
@@ -1674,6 +1704,16 @@ export declare const Trigger: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[
1674
1704
  }>;
1675
1705
  amount: z.ZodString;
1676
1706
  }, z.core.$strip>>;
1707
+ attachedTriggers: z.ZodArray<z.ZodObject<{
1708
+ kind: z.ZodEnum<{
1709
+ STATIC: "STATIC";
1710
+ TRAILING: "TRAILING";
1711
+ }>;
1712
+ bracketType: z.ZodEnum<{
1713
+ STOP_LOSS: "STOP_LOSS";
1714
+ TAKE_PROFIT: "TAKE_PROFIT";
1715
+ }>;
1716
+ }, z.core.$strip>>;
1677
1717
  }, z.core.$strip>;
1678
1718
  }, z.core.$strip>, z.ZodObject<{
1679
1719
  id: z.ZodUUID;
@@ -2195,6 +2235,7 @@ export declare const Trigger: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[
2195
2235
  }, z.core.$strip>>;
2196
2236
  }, z.core.$strip>], "intent">], "type">;
2197
2237
  export type BaseTrigger = z.output<typeof BaseTrigger>;
2238
+ export type TriggerMarketOpenAttachedTrigger = z.output<typeof TriggerMarketOpenAttachedTrigger>;
2198
2239
  export type TriggerMarketOpen = z.output<typeof TriggerMarketOpen>;
2199
2240
  export type TriggerMarketAdjust = z.output<typeof TriggerMarketAdjust>;
2200
2241
  export type TriggerMarketClose = z.output<typeof TriggerMarketClose>;
@@ -4,7 +4,7 @@ import { TradeLegPostOnly, TradeLeg } from '../../common/trade-legs';
4
4
  import { Connector } from '../../connector';
5
5
  import { Fill } from '../../fill';
6
6
  import { InstrumentId } from '../../instrument';
7
- import { TrailingMode, BracketType, TriggerStatus, TriggerCancelledReason } from '../common';
7
+ import { TrailingMode, BracketType, TriggerStatus, TriggerCancelledReason, TpSlBracketType } from '../common';
8
8
  import { TriggerConditionOpen, TriggerConditionAdjust, TriggerConditionClose } from './conditions';
9
9
 
10
10
  const Trailing = z.object({
@@ -80,6 +80,10 @@ const BaseTrigger = z.object({
80
80
  */
81
81
  updatedAt: z.string()
82
82
  });
83
+ const TriggerMarketOpenAttachedTrigger = z.object({
84
+ kind: z.enum(["STATIC", "TRAILING"]),
85
+ bracketType: TpSlBracketType
86
+ });
83
87
  const TriggerMarketOpen = BaseTrigger.extend({
84
88
  /**
85
89
  * Intent
@@ -98,7 +102,11 @@ const TriggerMarketOpen = BaseTrigger.extend({
98
102
  */
99
103
  context: z.object({
100
104
  type: z.literal("MARKET"),
101
- legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly)
105
+ legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly),
106
+ /**
107
+ * Close triggers configured to attach after this open trigger fires.
108
+ */
109
+ attachedTriggers: z.array(TriggerMarketOpenAttachedTrigger)
102
110
  })
103
111
  });
104
112
  const TriggerMarketAdjust = BaseTrigger.extend({
@@ -165,4 +173,4 @@ const TriggerMarket = z.discriminatedUnion("intent", [
165
173
  ]);
166
174
  const Trigger = z.discriminatedUnion("type", [TriggerMarket]);
167
175
 
168
- export { Trailing, Trigger, TriggerMarket, TriggerMarketAdjust, TriggerMarketClose, TriggerMarketOpen };
176
+ export { Trailing, Trigger, TriggerMarket, TriggerMarketAdjust, TriggerMarketClose, TriggerMarketOpen, TriggerMarketOpenAttachedTrigger };
@@ -0,0 +1 @@
1
+ export declare const MAX_ATTACH_TRIGGERS = 5;
@@ -0,0 +1,3 @@
1
+ const MAX_ATTACH_TRIGGERS = 5;
2
+
3
+ export { MAX_ATTACH_TRIGGERS };
@@ -7,6 +7,151 @@ export declare const TrailingConfig: z.ZodObject<{
7
7
  deltaValue: z.ZodNumber;
8
8
  activationValue: z.ZodOptional<z.ZodNumber>;
9
9
  }, z.core.$strip>;
10
+ export declare const AttachTriggerMarketCloseStatic: z.ZodObject<{
11
+ intent: z.ZodLiteral<"CLOSE">;
12
+ type: z.ZodLiteral<"MARKET">;
13
+ bracketType: z.ZodEnum<{
14
+ STOP_LOSS: "STOP_LOSS";
15
+ TAKE_PROFIT: "TAKE_PROFIT";
16
+ }>;
17
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
18
+ type: z.ZodLiteral<"notional">;
19
+ data: z.ZodObject<{
20
+ priceSource: z.ZodEnum<{
21
+ mid: "mid";
22
+ mark: "mark";
23
+ }>;
24
+ threshold: z.ZodNumber;
25
+ }, z.core.$strip>;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ type: z.ZodLiteral<"upnl">;
28
+ data: z.ZodObject<{
29
+ priceSource: z.ZodEnum<{
30
+ mid: "mid";
31
+ mark: "mark";
32
+ }>;
33
+ threshold: z.ZodNumber;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ type: z.ZodLiteral<"upnl_bps">;
37
+ data: z.ZodObject<{
38
+ priceSource: z.ZodEnum<{
39
+ mid: "mid";
40
+ mark: "mark";
41
+ }>;
42
+ threshold: z.ZodNumber;
43
+ }, z.core.$strip>;
44
+ }, z.core.$strip>], "type">;
45
+ }, z.core.$strip>;
46
+ export declare const AttachTriggerMarketCloseTrailing: z.ZodObject<{
47
+ intent: z.ZodLiteral<"CLOSE">;
48
+ type: z.ZodLiteral<"MARKET">;
49
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
50
+ type: z.ZodLiteral<"notional_trailing">;
51
+ data: z.ZodObject<{
52
+ priceSource: z.ZodEnum<{
53
+ mid: "mid";
54
+ mark: "mark";
55
+ }>;
56
+ }, z.core.$strip>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ type: z.ZodLiteral<"upnl_trailing">;
59
+ data: z.ZodObject<{
60
+ priceSource: z.ZodEnum<{
61
+ mid: "mid";
62
+ mark: "mark";
63
+ }>;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ type: z.ZodLiteral<"upnl_bps_trailing">;
67
+ data: z.ZodObject<{
68
+ priceSource: z.ZodEnum<{
69
+ mid: "mid";
70
+ mark: "mark";
71
+ }>;
72
+ }, z.core.$strip>;
73
+ }, z.core.$strip>], "type">;
74
+ trailing: z.ZodObject<{
75
+ mode: z.ZodEnum<{
76
+ RELATIVE_BPS: "RELATIVE_BPS";
77
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
78
+ }>;
79
+ deltaValue: z.ZodNumber;
80
+ activationValue: z.ZodOptional<z.ZodNumber>;
81
+ }, z.core.$strip>;
82
+ }, z.core.$strip>;
83
+ export declare const AttachTriggerMarketClose: z.ZodUnion<readonly [z.ZodObject<{
84
+ intent: z.ZodLiteral<"CLOSE">;
85
+ type: z.ZodLiteral<"MARKET">;
86
+ bracketType: z.ZodEnum<{
87
+ STOP_LOSS: "STOP_LOSS";
88
+ TAKE_PROFIT: "TAKE_PROFIT";
89
+ }>;
90
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
91
+ type: z.ZodLiteral<"notional">;
92
+ data: z.ZodObject<{
93
+ priceSource: z.ZodEnum<{
94
+ mid: "mid";
95
+ mark: "mark";
96
+ }>;
97
+ threshold: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ }, z.core.$strip>, z.ZodObject<{
100
+ type: z.ZodLiteral<"upnl">;
101
+ data: z.ZodObject<{
102
+ priceSource: z.ZodEnum<{
103
+ mid: "mid";
104
+ mark: "mark";
105
+ }>;
106
+ threshold: z.ZodNumber;
107
+ }, z.core.$strip>;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ type: z.ZodLiteral<"upnl_bps">;
110
+ data: z.ZodObject<{
111
+ priceSource: z.ZodEnum<{
112
+ mid: "mid";
113
+ mark: "mark";
114
+ }>;
115
+ threshold: z.ZodNumber;
116
+ }, z.core.$strip>;
117
+ }, z.core.$strip>], "type">;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ intent: z.ZodLiteral<"CLOSE">;
120
+ type: z.ZodLiteral<"MARKET">;
121
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
+ type: z.ZodLiteral<"notional_trailing">;
123
+ data: z.ZodObject<{
124
+ priceSource: z.ZodEnum<{
125
+ mid: "mid";
126
+ mark: "mark";
127
+ }>;
128
+ }, z.core.$strip>;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ type: z.ZodLiteral<"upnl_trailing">;
131
+ data: z.ZodObject<{
132
+ priceSource: z.ZodEnum<{
133
+ mid: "mid";
134
+ mark: "mark";
135
+ }>;
136
+ }, z.core.$strip>;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ type: z.ZodLiteral<"upnl_bps_trailing">;
139
+ data: z.ZodObject<{
140
+ priceSource: z.ZodEnum<{
141
+ mid: "mid";
142
+ mark: "mark";
143
+ }>;
144
+ }, z.core.$strip>;
145
+ }, z.core.$strip>], "type">;
146
+ trailing: z.ZodObject<{
147
+ mode: z.ZodEnum<{
148
+ RELATIVE_BPS: "RELATIVE_BPS";
149
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
150
+ }>;
151
+ deltaValue: z.ZodNumber;
152
+ activationValue: z.ZodOptional<z.ZodNumber>;
153
+ }, z.core.$strip>;
154
+ }, z.core.$strip>]>;
10
155
  export declare const CreateTriggerMarketOpen: z.ZodObject<{
11
156
  intent: z.ZodLiteral<"OPEN">;
12
157
  type: z.ZodLiteral<"MARKET">;
@@ -102,6 +247,78 @@ export declare const CreateTriggerMarketOpen: z.ZodObject<{
102
247
  threshold: z.ZodNumber;
103
248
  }, z.core.$strip>;
104
249
  }, z.core.$strip>], "type">;
250
+ attachTriggers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
251
+ intent: z.ZodLiteral<"CLOSE">;
252
+ type: z.ZodLiteral<"MARKET">;
253
+ bracketType: z.ZodEnum<{
254
+ STOP_LOSS: "STOP_LOSS";
255
+ TAKE_PROFIT: "TAKE_PROFIT";
256
+ }>;
257
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
258
+ type: z.ZodLiteral<"notional">;
259
+ data: z.ZodObject<{
260
+ priceSource: z.ZodEnum<{
261
+ mid: "mid";
262
+ mark: "mark";
263
+ }>;
264
+ threshold: z.ZodNumber;
265
+ }, z.core.$strip>;
266
+ }, z.core.$strip>, z.ZodObject<{
267
+ type: z.ZodLiteral<"upnl">;
268
+ data: z.ZodObject<{
269
+ priceSource: z.ZodEnum<{
270
+ mid: "mid";
271
+ mark: "mark";
272
+ }>;
273
+ threshold: z.ZodNumber;
274
+ }, z.core.$strip>;
275
+ }, z.core.$strip>, z.ZodObject<{
276
+ type: z.ZodLiteral<"upnl_bps">;
277
+ data: z.ZodObject<{
278
+ priceSource: z.ZodEnum<{
279
+ mid: "mid";
280
+ mark: "mark";
281
+ }>;
282
+ threshold: z.ZodNumber;
283
+ }, z.core.$strip>;
284
+ }, z.core.$strip>], "type">;
285
+ }, z.core.$strip>, z.ZodObject<{
286
+ intent: z.ZodLiteral<"CLOSE">;
287
+ type: z.ZodLiteral<"MARKET">;
288
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
289
+ type: z.ZodLiteral<"notional_trailing">;
290
+ data: z.ZodObject<{
291
+ priceSource: z.ZodEnum<{
292
+ mid: "mid";
293
+ mark: "mark";
294
+ }>;
295
+ }, z.core.$strip>;
296
+ }, z.core.$strip>, z.ZodObject<{
297
+ type: z.ZodLiteral<"upnl_trailing">;
298
+ data: z.ZodObject<{
299
+ priceSource: z.ZodEnum<{
300
+ mid: "mid";
301
+ mark: "mark";
302
+ }>;
303
+ }, z.core.$strip>;
304
+ }, z.core.$strip>, z.ZodObject<{
305
+ type: z.ZodLiteral<"upnl_bps_trailing">;
306
+ data: z.ZodObject<{
307
+ priceSource: z.ZodEnum<{
308
+ mid: "mid";
309
+ mark: "mark";
310
+ }>;
311
+ }, z.core.$strip>;
312
+ }, z.core.$strip>], "type">;
313
+ trailing: z.ZodObject<{
314
+ mode: z.ZodEnum<{
315
+ RELATIVE_BPS: "RELATIVE_BPS";
316
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
317
+ }>;
318
+ deltaValue: z.ZodNumber;
319
+ activationValue: z.ZodOptional<z.ZodNumber>;
320
+ }, z.core.$strip>;
321
+ }, z.core.$strip>]>>>;
105
322
  payload: z.ZodObject<{
106
323
  type: z.ZodLiteral<"MARKET">;
107
324
  legs: z.ZodTuple<[z.ZodObject<{
@@ -431,153 +648,6 @@ export declare const CreateTriggerMarketClose: z.ZodUnion<readonly [z.ZodObject<
431
648
  }, z.core.$strip>;
432
649
  clientId: z.ZodOptional<z.ZodString>;
433
650
  }, z.core.$strip>]>;
434
- export declare const AttachTriggerMarketCloseStatic: z.ZodObject<{
435
- intent: z.ZodLiteral<"CLOSE">;
436
- type: z.ZodLiteral<"MARKET">;
437
- bracketType: z.ZodEnum<{
438
- STOP_LOSS: "STOP_LOSS";
439
- TAKE_PROFIT: "TAKE_PROFIT";
440
- NONE: "NONE";
441
- }>;
442
- condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
443
- type: z.ZodLiteral<"notional">;
444
- data: z.ZodObject<{
445
- priceSource: z.ZodEnum<{
446
- mid: "mid";
447
- mark: "mark";
448
- }>;
449
- threshold: z.ZodNumber;
450
- }, z.core.$strip>;
451
- }, z.core.$strip>, z.ZodObject<{
452
- type: z.ZodLiteral<"upnl">;
453
- data: z.ZodObject<{
454
- priceSource: z.ZodEnum<{
455
- mid: "mid";
456
- mark: "mark";
457
- }>;
458
- threshold: z.ZodNumber;
459
- }, z.core.$strip>;
460
- }, z.core.$strip>, z.ZodObject<{
461
- type: z.ZodLiteral<"upnl_bps">;
462
- data: z.ZodObject<{
463
- priceSource: z.ZodEnum<{
464
- mid: "mid";
465
- mark: "mark";
466
- }>;
467
- threshold: z.ZodNumber;
468
- }, z.core.$strip>;
469
- }, z.core.$strip>], "type">;
470
- }, z.core.$strip>;
471
- export declare const AttachTriggerMarketCloseTrailing: z.ZodObject<{
472
- intent: z.ZodLiteral<"CLOSE">;
473
- type: z.ZodLiteral<"MARKET">;
474
- condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
475
- type: z.ZodLiteral<"notional_trailing">;
476
- data: z.ZodObject<{
477
- priceSource: z.ZodEnum<{
478
- mid: "mid";
479
- mark: "mark";
480
- }>;
481
- }, z.core.$strip>;
482
- }, z.core.$strip>, z.ZodObject<{
483
- type: z.ZodLiteral<"upnl_trailing">;
484
- data: z.ZodObject<{
485
- priceSource: z.ZodEnum<{
486
- mid: "mid";
487
- mark: "mark";
488
- }>;
489
- }, z.core.$strip>;
490
- }, z.core.$strip>, z.ZodObject<{
491
- type: z.ZodLiteral<"upnl_bps_trailing">;
492
- data: z.ZodObject<{
493
- priceSource: z.ZodEnum<{
494
- mid: "mid";
495
- mark: "mark";
496
- }>;
497
- }, z.core.$strip>;
498
- }, z.core.$strip>], "type">;
499
- trailing: z.ZodObject<{
500
- mode: z.ZodEnum<{
501
- RELATIVE_BPS: "RELATIVE_BPS";
502
- ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
503
- }>;
504
- deltaValue: z.ZodNumber;
505
- activationValue: z.ZodOptional<z.ZodNumber>;
506
- }, z.core.$strip>;
507
- }, z.core.$strip>;
508
- export declare const AttachTriggerMarketClose: z.ZodUnion<readonly [z.ZodObject<{
509
- intent: z.ZodLiteral<"CLOSE">;
510
- type: z.ZodLiteral<"MARKET">;
511
- bracketType: z.ZodEnum<{
512
- STOP_LOSS: "STOP_LOSS";
513
- TAKE_PROFIT: "TAKE_PROFIT";
514
- NONE: "NONE";
515
- }>;
516
- condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
517
- type: z.ZodLiteral<"notional">;
518
- data: z.ZodObject<{
519
- priceSource: z.ZodEnum<{
520
- mid: "mid";
521
- mark: "mark";
522
- }>;
523
- threshold: z.ZodNumber;
524
- }, z.core.$strip>;
525
- }, z.core.$strip>, z.ZodObject<{
526
- type: z.ZodLiteral<"upnl">;
527
- data: z.ZodObject<{
528
- priceSource: z.ZodEnum<{
529
- mid: "mid";
530
- mark: "mark";
531
- }>;
532
- threshold: z.ZodNumber;
533
- }, z.core.$strip>;
534
- }, z.core.$strip>, z.ZodObject<{
535
- type: z.ZodLiteral<"upnl_bps">;
536
- data: z.ZodObject<{
537
- priceSource: z.ZodEnum<{
538
- mid: "mid";
539
- mark: "mark";
540
- }>;
541
- threshold: z.ZodNumber;
542
- }, z.core.$strip>;
543
- }, z.core.$strip>], "type">;
544
- }, z.core.$strip>, z.ZodObject<{
545
- intent: z.ZodLiteral<"CLOSE">;
546
- type: z.ZodLiteral<"MARKET">;
547
- condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
548
- type: z.ZodLiteral<"notional_trailing">;
549
- data: z.ZodObject<{
550
- priceSource: z.ZodEnum<{
551
- mid: "mid";
552
- mark: "mark";
553
- }>;
554
- }, z.core.$strip>;
555
- }, z.core.$strip>, z.ZodObject<{
556
- type: z.ZodLiteral<"upnl_trailing">;
557
- data: z.ZodObject<{
558
- priceSource: z.ZodEnum<{
559
- mid: "mid";
560
- mark: "mark";
561
- }>;
562
- }, z.core.$strip>;
563
- }, z.core.$strip>, z.ZodObject<{
564
- type: z.ZodLiteral<"upnl_bps_trailing">;
565
- data: z.ZodObject<{
566
- priceSource: z.ZodEnum<{
567
- mid: "mid";
568
- mark: "mark";
569
- }>;
570
- }, z.core.$strip>;
571
- }, z.core.$strip>], "type">;
572
- trailing: z.ZodObject<{
573
- mode: z.ZodEnum<{
574
- RELATIVE_BPS: "RELATIVE_BPS";
575
- ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
576
- }>;
577
- deltaValue: z.ZodNumber;
578
- activationValue: z.ZodOptional<z.ZodNumber>;
579
- }, z.core.$strip>;
580
- }, z.core.$strip>]>;
581
651
  export declare const CreateTriggerOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
582
652
  intent: z.ZodLiteral<"OPEN">;
583
653
  type: z.ZodLiteral<"MARKET">;
@@ -673,6 +743,78 @@ export declare const CreateTriggerOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
673
743
  threshold: z.ZodNumber;
674
744
  }, z.core.$strip>;
675
745
  }, z.core.$strip>], "type">;
746
+ attachTriggers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
747
+ intent: z.ZodLiteral<"CLOSE">;
748
+ type: z.ZodLiteral<"MARKET">;
749
+ bracketType: z.ZodEnum<{
750
+ STOP_LOSS: "STOP_LOSS";
751
+ TAKE_PROFIT: "TAKE_PROFIT";
752
+ }>;
753
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
754
+ type: z.ZodLiteral<"notional">;
755
+ data: z.ZodObject<{
756
+ priceSource: z.ZodEnum<{
757
+ mid: "mid";
758
+ mark: "mark";
759
+ }>;
760
+ threshold: z.ZodNumber;
761
+ }, z.core.$strip>;
762
+ }, z.core.$strip>, z.ZodObject<{
763
+ type: z.ZodLiteral<"upnl">;
764
+ data: z.ZodObject<{
765
+ priceSource: z.ZodEnum<{
766
+ mid: "mid";
767
+ mark: "mark";
768
+ }>;
769
+ threshold: z.ZodNumber;
770
+ }, z.core.$strip>;
771
+ }, z.core.$strip>, z.ZodObject<{
772
+ type: z.ZodLiteral<"upnl_bps">;
773
+ data: z.ZodObject<{
774
+ priceSource: z.ZodEnum<{
775
+ mid: "mid";
776
+ mark: "mark";
777
+ }>;
778
+ threshold: z.ZodNumber;
779
+ }, z.core.$strip>;
780
+ }, z.core.$strip>], "type">;
781
+ }, z.core.$strip>, z.ZodObject<{
782
+ intent: z.ZodLiteral<"CLOSE">;
783
+ type: z.ZodLiteral<"MARKET">;
784
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
785
+ type: z.ZodLiteral<"notional_trailing">;
786
+ data: z.ZodObject<{
787
+ priceSource: z.ZodEnum<{
788
+ mid: "mid";
789
+ mark: "mark";
790
+ }>;
791
+ }, z.core.$strip>;
792
+ }, z.core.$strip>, z.ZodObject<{
793
+ type: z.ZodLiteral<"upnl_trailing">;
794
+ data: z.ZodObject<{
795
+ priceSource: z.ZodEnum<{
796
+ mid: "mid";
797
+ mark: "mark";
798
+ }>;
799
+ }, z.core.$strip>;
800
+ }, z.core.$strip>, z.ZodObject<{
801
+ type: z.ZodLiteral<"upnl_bps_trailing">;
802
+ data: z.ZodObject<{
803
+ priceSource: z.ZodEnum<{
804
+ mid: "mid";
805
+ mark: "mark";
806
+ }>;
807
+ }, z.core.$strip>;
808
+ }, z.core.$strip>], "type">;
809
+ trailing: z.ZodObject<{
810
+ mode: z.ZodEnum<{
811
+ RELATIVE_BPS: "RELATIVE_BPS";
812
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
813
+ }>;
814
+ deltaValue: z.ZodNumber;
815
+ activationValue: z.ZodOptional<z.ZodNumber>;
816
+ }, z.core.$strip>;
817
+ }, z.core.$strip>]>>>;
676
818
  payload: z.ZodObject<{
677
819
  type: z.ZodLiteral<"MARKET">;
678
820
  legs: z.ZodTuple<[z.ZodObject<{
@@ -861,3 +1003,4 @@ export type AttachTriggerMarketClose = z.output<typeof AttachTriggerMarketClose>
861
1003
  export type CreateTriggerOpen = z.output<typeof CreateTriggerOpen>;
862
1004
  export type CreateTriggerClose = z.output<typeof CreateTriggerClose>;
863
1005
  export type TrailingConfig = z.output<typeof TrailingConfig>;
1006
+ export declare function isAttachTriggerMarketCloseTrailing(attachedTrigger: AttachTriggerMarketClose): attachedTrigger is AttachTriggerMarketCloseTrailing;
@@ -2,20 +2,43 @@ import { z } from 'zod';
2
2
  import { ClientIdCode } from '../../common/client-id';
3
3
  import { RefineMinimumOneSymbol, RefineUniqueSymbols } from '../../common/refinement';
4
4
  import { TradeLegPostOnly } from '../../common/trade-legs';
5
- import { TrailingMode, BracketType } from '../common';
5
+ import { TrailingMode, TpSlBracketType, BracketType } from '../common';
6
6
  import { RefineStaticLogicalRules } from '../refinement/static.refinement';
7
7
  import { RefineTrailingConfig, RefineTrailingLogicalRules } from '../refinement/trailing.refinement';
8
- import { CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing, CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing } from './conditions';
8
+ import { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing } from './conditions';
9
+ import { MAX_ATTACH_TRIGGERS } from './config';
9
10
 
10
11
  const TrailingConfig = z.object({
11
12
  mode: TrailingMode,
12
13
  deltaValue: z.number(),
13
14
  activationValue: z.number().optional()
14
15
  }).superRefine(RefineTrailingConfig);
16
+ const AttachTriggerMarketCloseStatic = z.object({
17
+ intent: z.literal("CLOSE"),
18
+ type: z.literal("MARKET"),
19
+ bracketType: TpSlBracketType,
20
+ condition: CreateTriggerConditionAttachStatic
21
+ }).superRefine(RefineStaticLogicalRules);
22
+ const AttachTriggerMarketCloseTrailing = z.object({
23
+ intent: z.literal("CLOSE"),
24
+ type: z.literal("MARKET"),
25
+ condition: CreateTriggerConditionAttachTrailing,
26
+ trailing: TrailingConfig
27
+ }).superRefine(RefineTrailingLogicalRules);
28
+ const AttachTriggerMarketClose = z.union([AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing]);
15
29
  const CreateTriggerMarketOpen = z.object({
16
30
  intent: z.literal("OPEN"),
17
31
  type: z.literal("MARKET"),
18
32
  condition: CreateTriggerConditionOpen,
33
+ attachTriggers: z.array(AttachTriggerMarketClose).max(MAX_ATTACH_TRIGGERS, `A market-open trigger can attach at most ${MAX_ATTACH_TRIGGERS} close triggers.`).superRefine((attachTriggers, ctx) => {
34
+ const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
35
+ if (trailingCount > 1) {
36
+ ctx.addIssue({
37
+ code: "custom",
38
+ message: "A market-open trigger can attach at most one trailing close trigger."
39
+ });
40
+ }
41
+ }).optional(),
19
42
  payload: z.object({
20
43
  type: z.literal("MARKET"),
21
44
  legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
@@ -48,20 +71,10 @@ const CreateTriggerMarketCloseTrailing = z.object({
48
71
  clientId: ClientIdCode
49
72
  }).superRefine(RefineTrailingLogicalRules);
50
73
  const CreateTriggerMarketClose = z.union([CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing]);
51
- const AttachTriggerMarketCloseStatic = z.object({
52
- intent: z.literal("CLOSE"),
53
- type: z.literal("MARKET"),
54
- bracketType: BracketType,
55
- condition: CreateTriggerConditionAttachStatic
56
- }).superRefine(RefineStaticLogicalRules);
57
- const AttachTriggerMarketCloseTrailing = z.object({
58
- intent: z.literal("CLOSE"),
59
- type: z.literal("MARKET"),
60
- condition: CreateTriggerConditionAttachTrailing,
61
- trailing: TrailingConfig
62
- }).superRefine(RefineTrailingLogicalRules);
63
- const AttachTriggerMarketClose = z.union([AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing]);
64
74
  const CreateTriggerOpen = z.discriminatedUnion("type", [CreateTriggerMarketOpen]);
65
75
  const CreateTriggerClose = CreateTriggerMarketClose;
76
+ function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
77
+ return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
78
+ }
66
79
 
67
- export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig };
80
+ export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
@@ -187,6 +187,16 @@ export declare const TriggerListResponse: z.ZodObject<{
187
187
  }>;
188
188
  amount: z.ZodString;
189
189
  }, z.core.$strip>>;
190
+ attachedTriggers: z.ZodArray<z.ZodObject<{
191
+ kind: z.ZodEnum<{
192
+ STATIC: "STATIC";
193
+ TRAILING: "TRAILING";
194
+ }>;
195
+ bracketType: z.ZodEnum<{
196
+ STOP_LOSS: "STOP_LOSS";
197
+ TAKE_PROFIT: "TAKE_PROFIT";
198
+ }>;
199
+ }, z.core.$strip>>;
190
200
  }, z.core.$strip>;
191
201
  }, z.core.$strip>, z.ZodObject<{
192
202
  id: z.ZodUUID;
@@ -895,6 +905,16 @@ export declare const CreateTriggerResponse: z.ZodObject<{
895
905
  }>;
896
906
  amount: z.ZodString;
897
907
  }, z.core.$strip>>;
908
+ attachedTriggers: z.ZodArray<z.ZodObject<{
909
+ kind: z.ZodEnum<{
910
+ STATIC: "STATIC";
911
+ TRAILING: "TRAILING";
912
+ }>;
913
+ bracketType: z.ZodEnum<{
914
+ STOP_LOSS: "STOP_LOSS";
915
+ TAKE_PROFIT: "TAKE_PROFIT";
916
+ }>;
917
+ }, z.core.$strip>>;
898
918
  }, z.core.$strip>;
899
919
  }, z.core.$strip>, z.ZodObject<{
900
920
  id: z.ZodUUID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",