@pear-protocol/types 1.6.0 → 1.8.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/notification/entities.d.ts +265 -0
- package/dist/notification/entities.js +52 -6
- package/dist/notification/responses.d.ts +120 -0
- package/dist/position/queries.d.ts +2 -0
- package/dist/position/queries.js +2 -2
- package/dist/position/responses.d.ts +2 -0
- package/dist/position/responses.js +2 -1
- package/dist/statistics/entities.d.ts +7 -0
- package/dist/statistics/entities.js +7 -1
- package/dist/statistics/queries.d.ts +11 -0
- package/dist/statistics/queries.js +4 -1
- package/dist/statistics/responses.d.ts +9 -0
- package/dist/statistics/responses.js +5 -2
- package/package.json +1 -1
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What happened. The `*_HIT` categories mean the trigger fired and its order
|
|
4
|
+
* filled; the `*_FAILED` categories mean it fired but the order failed to
|
|
5
|
+
* execute; `ATTACHED_TRIGGER_DISCARDED` means requested close protection could
|
|
6
|
+
* not be placed after a position opened. Outcome lives here in the category;
|
|
7
|
+
* display details live in the `parameters` payload below.
|
|
8
|
+
*/
|
|
2
9
|
export declare const NotificationCategory: z.ZodEnum<{
|
|
3
10
|
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
4
11
|
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
5
12
|
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
13
|
+
TAKE_PROFIT_FAILED: "TAKE_PROFIT_FAILED";
|
|
14
|
+
STOP_LOSS_FAILED: "STOP_LOSS_FAILED";
|
|
15
|
+
TRIGGER_ORDER_FAILED: "TRIGGER_ORDER_FAILED";
|
|
16
|
+
ATTACHED_TRIGGER_DISCARDED: "ATTACHED_TRIGGER_DISCARDED";
|
|
6
17
|
}>;
|
|
7
18
|
export type NotificationCategory = z.infer<typeof NotificationCategory>;
|
|
19
|
+
export declare const NotificationMetric: z.ZodEnum<{
|
|
20
|
+
price: "price";
|
|
21
|
+
notional: "notional";
|
|
22
|
+
ratio: "ratio";
|
|
23
|
+
weighted_ratio: "weighted_ratio";
|
|
24
|
+
upnl: "upnl";
|
|
25
|
+
upnl_bps: "upnl_bps";
|
|
26
|
+
funding_rate: "funding_rate";
|
|
27
|
+
prediction_market: "prediction_market";
|
|
28
|
+
btc_dominance: "btc_dominance";
|
|
29
|
+
ratio_trailing: "ratio_trailing";
|
|
30
|
+
price_trailing: "price_trailing";
|
|
31
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
32
|
+
notional_trailing: "notional_trailing";
|
|
33
|
+
upnl_trailing: "upnl_trailing";
|
|
34
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
35
|
+
}>;
|
|
36
|
+
export type NotificationMetric = z.infer<typeof NotificationMetric>;
|
|
8
37
|
export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
38
|
type: z.ZodLiteral<"take_profit">;
|
|
10
39
|
triggerId: z.ZodUUID;
|
|
@@ -16,6 +45,25 @@ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
16
45
|
okx: "okx";
|
|
17
46
|
lighter: "lighter";
|
|
18
47
|
}>;
|
|
48
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
price: "price";
|
|
50
|
+
notional: "notional";
|
|
51
|
+
ratio: "ratio";
|
|
52
|
+
weighted_ratio: "weighted_ratio";
|
|
53
|
+
upnl: "upnl";
|
|
54
|
+
upnl_bps: "upnl_bps";
|
|
55
|
+
funding_rate: "funding_rate";
|
|
56
|
+
prediction_market: "prediction_market";
|
|
57
|
+
btc_dominance: "btc_dominance";
|
|
58
|
+
ratio_trailing: "ratio_trailing";
|
|
59
|
+
price_trailing: "price_trailing";
|
|
60
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
61
|
+
notional_trailing: "notional_trailing";
|
|
62
|
+
upnl_trailing: "upnl_trailing";
|
|
63
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
64
|
+
}>>;
|
|
65
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
19
67
|
}, z.core.$strip>, z.ZodObject<{
|
|
20
68
|
type: z.ZodLiteral<"stop_loss">;
|
|
21
69
|
triggerId: z.ZodUUID;
|
|
@@ -27,6 +75,25 @@ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
27
75
|
okx: "okx";
|
|
28
76
|
lighter: "lighter";
|
|
29
77
|
}>;
|
|
78
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
79
|
+
price: "price";
|
|
80
|
+
notional: "notional";
|
|
81
|
+
ratio: "ratio";
|
|
82
|
+
weighted_ratio: "weighted_ratio";
|
|
83
|
+
upnl: "upnl";
|
|
84
|
+
upnl_bps: "upnl_bps";
|
|
85
|
+
funding_rate: "funding_rate";
|
|
86
|
+
prediction_market: "prediction_market";
|
|
87
|
+
btc_dominance: "btc_dominance";
|
|
88
|
+
ratio_trailing: "ratio_trailing";
|
|
89
|
+
price_trailing: "price_trailing";
|
|
90
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
91
|
+
notional_trailing: "notional_trailing";
|
|
92
|
+
upnl_trailing: "upnl_trailing";
|
|
93
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
94
|
+
}>>;
|
|
95
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
30
97
|
}, z.core.$strip>, z.ZodObject<{
|
|
31
98
|
type: z.ZodLiteral<"trigger_order">;
|
|
32
99
|
triggerId: z.ZodUUID;
|
|
@@ -38,6 +105,25 @@ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
38
105
|
okx: "okx";
|
|
39
106
|
lighter: "lighter";
|
|
40
107
|
}>;
|
|
108
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
price: "price";
|
|
110
|
+
notional: "notional";
|
|
111
|
+
ratio: "ratio";
|
|
112
|
+
weighted_ratio: "weighted_ratio";
|
|
113
|
+
upnl: "upnl";
|
|
114
|
+
upnl_bps: "upnl_bps";
|
|
115
|
+
funding_rate: "funding_rate";
|
|
116
|
+
prediction_market: "prediction_market";
|
|
117
|
+
btc_dominance: "btc_dominance";
|
|
118
|
+
ratio_trailing: "ratio_trailing";
|
|
119
|
+
price_trailing: "price_trailing";
|
|
120
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
121
|
+
notional_trailing: "notional_trailing";
|
|
122
|
+
upnl_trailing: "upnl_trailing";
|
|
123
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
124
|
+
}>>;
|
|
125
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
41
127
|
}, z.core.$strip>, z.ZodObject<{
|
|
42
128
|
type: z.ZodLiteral<"default_trigger">;
|
|
43
129
|
triggerId: z.ZodUUID;
|
|
@@ -48,6 +134,65 @@ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
48
134
|
okx: "okx";
|
|
49
135
|
lighter: "lighter";
|
|
50
136
|
}>;
|
|
137
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
138
|
+
price: "price";
|
|
139
|
+
notional: "notional";
|
|
140
|
+
ratio: "ratio";
|
|
141
|
+
weighted_ratio: "weighted_ratio";
|
|
142
|
+
upnl: "upnl";
|
|
143
|
+
upnl_bps: "upnl_bps";
|
|
144
|
+
funding_rate: "funding_rate";
|
|
145
|
+
prediction_market: "prediction_market";
|
|
146
|
+
btc_dominance: "btc_dominance";
|
|
147
|
+
ratio_trailing: "ratio_trailing";
|
|
148
|
+
price_trailing: "price_trailing";
|
|
149
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
150
|
+
notional_trailing: "notional_trailing";
|
|
151
|
+
upnl_trailing: "upnl_trailing";
|
|
152
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
153
|
+
}>>;
|
|
154
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
155
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
+
type: z.ZodLiteral<"attached_trigger_discarded">;
|
|
158
|
+
positionId: z.ZodUUID;
|
|
159
|
+
positionKey: z.ZodString;
|
|
160
|
+
connector: z.ZodEnum<{
|
|
161
|
+
hyperliquid: "hyperliquid";
|
|
162
|
+
binance: "binance";
|
|
163
|
+
bybit: "bybit";
|
|
164
|
+
okx: "okx";
|
|
165
|
+
lighter: "lighter";
|
|
166
|
+
}>;
|
|
167
|
+
discarded: z.ZodArray<z.ZodObject<{
|
|
168
|
+
bracketType: z.ZodEnum<{
|
|
169
|
+
STOP_LOSS: "STOP_LOSS";
|
|
170
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
171
|
+
}>;
|
|
172
|
+
metric: z.ZodEnum<{
|
|
173
|
+
price: "price";
|
|
174
|
+
notional: "notional";
|
|
175
|
+
ratio: "ratio";
|
|
176
|
+
weighted_ratio: "weighted_ratio";
|
|
177
|
+
upnl: "upnl";
|
|
178
|
+
upnl_bps: "upnl_bps";
|
|
179
|
+
funding_rate: "funding_rate";
|
|
180
|
+
prediction_market: "prediction_market";
|
|
181
|
+
btc_dominance: "btc_dominance";
|
|
182
|
+
ratio_trailing: "ratio_trailing";
|
|
183
|
+
price_trailing: "price_trailing";
|
|
184
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
185
|
+
notional_trailing: "notional_trailing";
|
|
186
|
+
upnl_trailing: "upnl_trailing";
|
|
187
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
188
|
+
}>;
|
|
189
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
reason: z.ZodEnum<{
|
|
191
|
+
TRIGGER_LIMIT: "TRIGGER_LIMIT";
|
|
192
|
+
TRAILING_ALREADY_EXISTS: "TRAILING_ALREADY_EXISTS";
|
|
193
|
+
}>;
|
|
194
|
+
}, z.core.$strip>>;
|
|
195
|
+
activeTriggerLimit: z.ZodNumber;
|
|
51
196
|
}, z.core.$strip>], "type">;
|
|
52
197
|
export type NotificationParameters = z.output<typeof NotificationParameters>;
|
|
53
198
|
export declare const Notification: z.ZodObject<{
|
|
@@ -56,6 +201,10 @@ export declare const Notification: z.ZodObject<{
|
|
|
56
201
|
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
57
202
|
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
58
203
|
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
204
|
+
TAKE_PROFIT_FAILED: "TAKE_PROFIT_FAILED";
|
|
205
|
+
STOP_LOSS_FAILED: "STOP_LOSS_FAILED";
|
|
206
|
+
TRIGGER_ORDER_FAILED: "TRIGGER_ORDER_FAILED";
|
|
207
|
+
ATTACHED_TRIGGER_DISCARDED: "ATTACHED_TRIGGER_DISCARDED";
|
|
59
208
|
}>;
|
|
60
209
|
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
210
|
type: z.ZodLiteral<"take_profit">;
|
|
@@ -68,6 +217,25 @@ export declare const Notification: z.ZodObject<{
|
|
|
68
217
|
okx: "okx";
|
|
69
218
|
lighter: "lighter";
|
|
70
219
|
}>;
|
|
220
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
221
|
+
price: "price";
|
|
222
|
+
notional: "notional";
|
|
223
|
+
ratio: "ratio";
|
|
224
|
+
weighted_ratio: "weighted_ratio";
|
|
225
|
+
upnl: "upnl";
|
|
226
|
+
upnl_bps: "upnl_bps";
|
|
227
|
+
funding_rate: "funding_rate";
|
|
228
|
+
prediction_market: "prediction_market";
|
|
229
|
+
btc_dominance: "btc_dominance";
|
|
230
|
+
ratio_trailing: "ratio_trailing";
|
|
231
|
+
price_trailing: "price_trailing";
|
|
232
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
233
|
+
notional_trailing: "notional_trailing";
|
|
234
|
+
upnl_trailing: "upnl_trailing";
|
|
235
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
236
|
+
}>>;
|
|
237
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
238
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
71
239
|
}, z.core.$strip>, z.ZodObject<{
|
|
72
240
|
type: z.ZodLiteral<"stop_loss">;
|
|
73
241
|
triggerId: z.ZodUUID;
|
|
@@ -79,6 +247,25 @@ export declare const Notification: z.ZodObject<{
|
|
|
79
247
|
okx: "okx";
|
|
80
248
|
lighter: "lighter";
|
|
81
249
|
}>;
|
|
250
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
251
|
+
price: "price";
|
|
252
|
+
notional: "notional";
|
|
253
|
+
ratio: "ratio";
|
|
254
|
+
weighted_ratio: "weighted_ratio";
|
|
255
|
+
upnl: "upnl";
|
|
256
|
+
upnl_bps: "upnl_bps";
|
|
257
|
+
funding_rate: "funding_rate";
|
|
258
|
+
prediction_market: "prediction_market";
|
|
259
|
+
btc_dominance: "btc_dominance";
|
|
260
|
+
ratio_trailing: "ratio_trailing";
|
|
261
|
+
price_trailing: "price_trailing";
|
|
262
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
263
|
+
notional_trailing: "notional_trailing";
|
|
264
|
+
upnl_trailing: "upnl_trailing";
|
|
265
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
266
|
+
}>>;
|
|
267
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
268
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
82
269
|
}, z.core.$strip>, z.ZodObject<{
|
|
83
270
|
type: z.ZodLiteral<"trigger_order">;
|
|
84
271
|
triggerId: z.ZodUUID;
|
|
@@ -90,6 +277,25 @@ export declare const Notification: z.ZodObject<{
|
|
|
90
277
|
okx: "okx";
|
|
91
278
|
lighter: "lighter";
|
|
92
279
|
}>;
|
|
280
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
281
|
+
price: "price";
|
|
282
|
+
notional: "notional";
|
|
283
|
+
ratio: "ratio";
|
|
284
|
+
weighted_ratio: "weighted_ratio";
|
|
285
|
+
upnl: "upnl";
|
|
286
|
+
upnl_bps: "upnl_bps";
|
|
287
|
+
funding_rate: "funding_rate";
|
|
288
|
+
prediction_market: "prediction_market";
|
|
289
|
+
btc_dominance: "btc_dominance";
|
|
290
|
+
ratio_trailing: "ratio_trailing";
|
|
291
|
+
price_trailing: "price_trailing";
|
|
292
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
293
|
+
notional_trailing: "notional_trailing";
|
|
294
|
+
upnl_trailing: "upnl_trailing";
|
|
295
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
296
|
+
}>>;
|
|
297
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
298
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
93
299
|
}, z.core.$strip>, z.ZodObject<{
|
|
94
300
|
type: z.ZodLiteral<"default_trigger">;
|
|
95
301
|
triggerId: z.ZodUUID;
|
|
@@ -100,6 +306,65 @@ export declare const Notification: z.ZodObject<{
|
|
|
100
306
|
okx: "okx";
|
|
101
307
|
lighter: "lighter";
|
|
102
308
|
}>;
|
|
309
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
310
|
+
price: "price";
|
|
311
|
+
notional: "notional";
|
|
312
|
+
ratio: "ratio";
|
|
313
|
+
weighted_ratio: "weighted_ratio";
|
|
314
|
+
upnl: "upnl";
|
|
315
|
+
upnl_bps: "upnl_bps";
|
|
316
|
+
funding_rate: "funding_rate";
|
|
317
|
+
prediction_market: "prediction_market";
|
|
318
|
+
btc_dominance: "btc_dominance";
|
|
319
|
+
ratio_trailing: "ratio_trailing";
|
|
320
|
+
price_trailing: "price_trailing";
|
|
321
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
322
|
+
notional_trailing: "notional_trailing";
|
|
323
|
+
upnl_trailing: "upnl_trailing";
|
|
324
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
325
|
+
}>>;
|
|
326
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
327
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
328
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
329
|
+
type: z.ZodLiteral<"attached_trigger_discarded">;
|
|
330
|
+
positionId: z.ZodUUID;
|
|
331
|
+
positionKey: z.ZodString;
|
|
332
|
+
connector: z.ZodEnum<{
|
|
333
|
+
hyperliquid: "hyperliquid";
|
|
334
|
+
binance: "binance";
|
|
335
|
+
bybit: "bybit";
|
|
336
|
+
okx: "okx";
|
|
337
|
+
lighter: "lighter";
|
|
338
|
+
}>;
|
|
339
|
+
discarded: z.ZodArray<z.ZodObject<{
|
|
340
|
+
bracketType: z.ZodEnum<{
|
|
341
|
+
STOP_LOSS: "STOP_LOSS";
|
|
342
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
343
|
+
}>;
|
|
344
|
+
metric: z.ZodEnum<{
|
|
345
|
+
price: "price";
|
|
346
|
+
notional: "notional";
|
|
347
|
+
ratio: "ratio";
|
|
348
|
+
weighted_ratio: "weighted_ratio";
|
|
349
|
+
upnl: "upnl";
|
|
350
|
+
upnl_bps: "upnl_bps";
|
|
351
|
+
funding_rate: "funding_rate";
|
|
352
|
+
prediction_market: "prediction_market";
|
|
353
|
+
btc_dominance: "btc_dominance";
|
|
354
|
+
ratio_trailing: "ratio_trailing";
|
|
355
|
+
price_trailing: "price_trailing";
|
|
356
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
357
|
+
notional_trailing: "notional_trailing";
|
|
358
|
+
upnl_trailing: "upnl_trailing";
|
|
359
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
360
|
+
}>;
|
|
361
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
362
|
+
reason: z.ZodEnum<{
|
|
363
|
+
TRIGGER_LIMIT: "TRIGGER_LIMIT";
|
|
364
|
+
TRAILING_ALREADY_EXISTS: "TRAILING_ALREADY_EXISTS";
|
|
365
|
+
}>;
|
|
366
|
+
}, z.core.$strip>>;
|
|
367
|
+
activeTriggerLimit: z.ZodNumber;
|
|
103
368
|
}, z.core.$strip>], "type">;
|
|
104
369
|
isRead: z.ZodBoolean;
|
|
105
370
|
createdAt: z.ZodString;
|
|
@@ -1,35 +1,81 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Connector } from '../connector';
|
|
3
3
|
|
|
4
|
-
const NotificationCategory = z.enum([
|
|
4
|
+
const NotificationCategory = z.enum([
|
|
5
|
+
"TAKE_PROFIT_HIT",
|
|
6
|
+
"STOP_LOSS_HIT",
|
|
7
|
+
"TRIGGER_ORDER_HIT",
|
|
8
|
+
"TAKE_PROFIT_FAILED",
|
|
9
|
+
"STOP_LOSS_FAILED",
|
|
10
|
+
"TRIGGER_ORDER_FAILED",
|
|
11
|
+
"ATTACHED_TRIGGER_DISCARDED"
|
|
12
|
+
]);
|
|
13
|
+
const NotificationMetric = z.enum([
|
|
14
|
+
"ratio",
|
|
15
|
+
"price",
|
|
16
|
+
"weighted_ratio",
|
|
17
|
+
"notional",
|
|
18
|
+
"upnl",
|
|
19
|
+
"upnl_bps",
|
|
20
|
+
"ratio_trailing",
|
|
21
|
+
"price_trailing",
|
|
22
|
+
"weighted_ratio_trailing",
|
|
23
|
+
"notional_trailing",
|
|
24
|
+
"upnl_trailing",
|
|
25
|
+
"upnl_bps_trailing",
|
|
26
|
+
"funding_rate",
|
|
27
|
+
"prediction_market",
|
|
28
|
+
"btc_dominance"
|
|
29
|
+
]);
|
|
30
|
+
const TriggerNotificationEnrichment = {
|
|
31
|
+
metric: NotificationMetric.optional(),
|
|
32
|
+
level: z.number().optional(),
|
|
33
|
+
reason: z.string().max(255).optional()
|
|
34
|
+
};
|
|
5
35
|
const TakeProfitNotificationParameters = z.object({
|
|
6
36
|
type: z.literal("take_profit"),
|
|
7
37
|
triggerId: z.uuid(),
|
|
8
38
|
positionId: z.uuid(),
|
|
9
39
|
connector: Connector
|
|
10
|
-
});
|
|
40
|
+
}).extend(TriggerNotificationEnrichment);
|
|
11
41
|
const StopLossNotificationParameters = z.object({
|
|
12
42
|
type: z.literal("stop_loss"),
|
|
13
43
|
triggerId: z.uuid(),
|
|
14
44
|
positionId: z.uuid(),
|
|
15
45
|
connector: Connector
|
|
16
|
-
});
|
|
46
|
+
}).extend(TriggerNotificationEnrichment);
|
|
17
47
|
const TriggerOrderNotificationParameters = z.object({
|
|
18
48
|
type: z.literal("trigger_order"),
|
|
19
49
|
triggerId: z.uuid(),
|
|
20
50
|
positionId: z.uuid(),
|
|
21
51
|
connector: Connector
|
|
22
|
-
});
|
|
52
|
+
}).extend(TriggerNotificationEnrichment);
|
|
23
53
|
const DefaultTriggerNotificationParameters = z.object({
|
|
24
54
|
type: z.literal("default_trigger"),
|
|
25
55
|
triggerId: z.uuid(),
|
|
26
56
|
connector: Connector
|
|
57
|
+
}).extend(TriggerNotificationEnrichment);
|
|
58
|
+
const AttachedTriggerDiscardedNotificationParameters = z.object({
|
|
59
|
+
type: z.literal("attached_trigger_discarded"),
|
|
60
|
+
positionId: z.uuid(),
|
|
61
|
+
positionKey: z.string().min(1),
|
|
62
|
+
connector: Connector,
|
|
63
|
+
discarded: z.array(
|
|
64
|
+
z.object({
|
|
65
|
+
bracketType: z.enum(["STOP_LOSS", "TAKE_PROFIT"]),
|
|
66
|
+
metric: NotificationMetric,
|
|
67
|
+
level: z.number().optional(),
|
|
68
|
+
reason: z.enum(["TRIGGER_LIMIT", "TRAILING_ALREADY_EXISTS"])
|
|
69
|
+
})
|
|
70
|
+
).min(1),
|
|
71
|
+
activeTriggerLimit: z.number().int().positive()
|
|
27
72
|
});
|
|
28
73
|
const NotificationParameters = z.discriminatedUnion("type", [
|
|
29
74
|
TakeProfitNotificationParameters,
|
|
30
75
|
StopLossNotificationParameters,
|
|
31
76
|
TriggerOrderNotificationParameters,
|
|
32
|
-
DefaultTriggerNotificationParameters
|
|
77
|
+
DefaultTriggerNotificationParameters,
|
|
78
|
+
AttachedTriggerDiscardedNotificationParameters
|
|
33
79
|
]);
|
|
34
80
|
const Notification = z.object({
|
|
35
81
|
/**
|
|
@@ -58,4 +104,4 @@ const Notification = z.object({
|
|
|
58
104
|
updatedAt: z.string()
|
|
59
105
|
});
|
|
60
106
|
|
|
61
|
-
export { Notification, NotificationCategory, NotificationParameters };
|
|
107
|
+
export { Notification, NotificationCategory, NotificationMetric, NotificationParameters };
|
|
@@ -6,6 +6,10 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
6
6
|
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
7
7
|
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
8
8
|
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
9
|
+
TAKE_PROFIT_FAILED: "TAKE_PROFIT_FAILED";
|
|
10
|
+
STOP_LOSS_FAILED: "STOP_LOSS_FAILED";
|
|
11
|
+
TRIGGER_ORDER_FAILED: "TRIGGER_ORDER_FAILED";
|
|
12
|
+
ATTACHED_TRIGGER_DISCARDED: "ATTACHED_TRIGGER_DISCARDED";
|
|
9
13
|
}>;
|
|
10
14
|
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
15
|
type: z.ZodLiteral<"take_profit">;
|
|
@@ -18,6 +22,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
18
22
|
okx: "okx";
|
|
19
23
|
lighter: "lighter";
|
|
20
24
|
}>;
|
|
25
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
price: "price";
|
|
27
|
+
notional: "notional";
|
|
28
|
+
ratio: "ratio";
|
|
29
|
+
weighted_ratio: "weighted_ratio";
|
|
30
|
+
upnl: "upnl";
|
|
31
|
+
upnl_bps: "upnl_bps";
|
|
32
|
+
funding_rate: "funding_rate";
|
|
33
|
+
prediction_market: "prediction_market";
|
|
34
|
+
btc_dominance: "btc_dominance";
|
|
35
|
+
ratio_trailing: "ratio_trailing";
|
|
36
|
+
price_trailing: "price_trailing";
|
|
37
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
38
|
+
notional_trailing: "notional_trailing";
|
|
39
|
+
upnl_trailing: "upnl_trailing";
|
|
40
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
41
|
+
}>>;
|
|
42
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
21
44
|
}, z.core.$strip>, z.ZodObject<{
|
|
22
45
|
type: z.ZodLiteral<"stop_loss">;
|
|
23
46
|
triggerId: z.ZodUUID;
|
|
@@ -29,6 +52,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
29
52
|
okx: "okx";
|
|
30
53
|
lighter: "lighter";
|
|
31
54
|
}>;
|
|
55
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
price: "price";
|
|
57
|
+
notional: "notional";
|
|
58
|
+
ratio: "ratio";
|
|
59
|
+
weighted_ratio: "weighted_ratio";
|
|
60
|
+
upnl: "upnl";
|
|
61
|
+
upnl_bps: "upnl_bps";
|
|
62
|
+
funding_rate: "funding_rate";
|
|
63
|
+
prediction_market: "prediction_market";
|
|
64
|
+
btc_dominance: "btc_dominance";
|
|
65
|
+
ratio_trailing: "ratio_trailing";
|
|
66
|
+
price_trailing: "price_trailing";
|
|
67
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
68
|
+
notional_trailing: "notional_trailing";
|
|
69
|
+
upnl_trailing: "upnl_trailing";
|
|
70
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
71
|
+
}>>;
|
|
72
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
32
74
|
}, z.core.$strip>, z.ZodObject<{
|
|
33
75
|
type: z.ZodLiteral<"trigger_order">;
|
|
34
76
|
triggerId: z.ZodUUID;
|
|
@@ -40,6 +82,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
40
82
|
okx: "okx";
|
|
41
83
|
lighter: "lighter";
|
|
42
84
|
}>;
|
|
85
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
price: "price";
|
|
87
|
+
notional: "notional";
|
|
88
|
+
ratio: "ratio";
|
|
89
|
+
weighted_ratio: "weighted_ratio";
|
|
90
|
+
upnl: "upnl";
|
|
91
|
+
upnl_bps: "upnl_bps";
|
|
92
|
+
funding_rate: "funding_rate";
|
|
93
|
+
prediction_market: "prediction_market";
|
|
94
|
+
btc_dominance: "btc_dominance";
|
|
95
|
+
ratio_trailing: "ratio_trailing";
|
|
96
|
+
price_trailing: "price_trailing";
|
|
97
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
98
|
+
notional_trailing: "notional_trailing";
|
|
99
|
+
upnl_trailing: "upnl_trailing";
|
|
100
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
101
|
+
}>>;
|
|
102
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
43
104
|
}, z.core.$strip>, z.ZodObject<{
|
|
44
105
|
type: z.ZodLiteral<"default_trigger">;
|
|
45
106
|
triggerId: z.ZodUUID;
|
|
@@ -50,6 +111,65 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
50
111
|
okx: "okx";
|
|
51
112
|
lighter: "lighter";
|
|
52
113
|
}>;
|
|
114
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
115
|
+
price: "price";
|
|
116
|
+
notional: "notional";
|
|
117
|
+
ratio: "ratio";
|
|
118
|
+
weighted_ratio: "weighted_ratio";
|
|
119
|
+
upnl: "upnl";
|
|
120
|
+
upnl_bps: "upnl_bps";
|
|
121
|
+
funding_rate: "funding_rate";
|
|
122
|
+
prediction_market: "prediction_market";
|
|
123
|
+
btc_dominance: "btc_dominance";
|
|
124
|
+
ratio_trailing: "ratio_trailing";
|
|
125
|
+
price_trailing: "price_trailing";
|
|
126
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
127
|
+
notional_trailing: "notional_trailing";
|
|
128
|
+
upnl_trailing: "upnl_trailing";
|
|
129
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
130
|
+
}>>;
|
|
131
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"attached_trigger_discarded">;
|
|
135
|
+
positionId: z.ZodUUID;
|
|
136
|
+
positionKey: z.ZodString;
|
|
137
|
+
connector: z.ZodEnum<{
|
|
138
|
+
hyperliquid: "hyperliquid";
|
|
139
|
+
binance: "binance";
|
|
140
|
+
bybit: "bybit";
|
|
141
|
+
okx: "okx";
|
|
142
|
+
lighter: "lighter";
|
|
143
|
+
}>;
|
|
144
|
+
discarded: z.ZodArray<z.ZodObject<{
|
|
145
|
+
bracketType: z.ZodEnum<{
|
|
146
|
+
STOP_LOSS: "STOP_LOSS";
|
|
147
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
148
|
+
}>;
|
|
149
|
+
metric: z.ZodEnum<{
|
|
150
|
+
price: "price";
|
|
151
|
+
notional: "notional";
|
|
152
|
+
ratio: "ratio";
|
|
153
|
+
weighted_ratio: "weighted_ratio";
|
|
154
|
+
upnl: "upnl";
|
|
155
|
+
upnl_bps: "upnl_bps";
|
|
156
|
+
funding_rate: "funding_rate";
|
|
157
|
+
prediction_market: "prediction_market";
|
|
158
|
+
btc_dominance: "btc_dominance";
|
|
159
|
+
ratio_trailing: "ratio_trailing";
|
|
160
|
+
price_trailing: "price_trailing";
|
|
161
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
162
|
+
notional_trailing: "notional_trailing";
|
|
163
|
+
upnl_trailing: "upnl_trailing";
|
|
164
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
165
|
+
}>;
|
|
166
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
reason: z.ZodEnum<{
|
|
168
|
+
TRIGGER_LIMIT: "TRIGGER_LIMIT";
|
|
169
|
+
TRAILING_ALREADY_EXISTS: "TRAILING_ALREADY_EXISTS";
|
|
170
|
+
}>;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
activeTriggerLimit: z.ZodNumber;
|
|
53
173
|
}, z.core.$strip>], "type">;
|
|
54
174
|
isRead: z.ZodBoolean;
|
|
55
175
|
createdAt: z.ZodString;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const PositionListParams: z.ZodObject<{
|
|
3
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
|
|
4
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
3
5
|
connector: z.ZodOptional<z.ZodEnum<{
|
|
4
6
|
hyperliquid: "hyperliquid";
|
|
5
7
|
binance: "binance";
|
package/dist/position/queries.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { normalizeArray } from '../common';
|
|
2
|
+
import { normalizeArray, CursorFindParams } from '../common';
|
|
3
3
|
import { Connector } from '../connector';
|
|
4
4
|
|
|
5
5
|
const OrderBy = z.union([
|
|
@@ -10,7 +10,7 @@ const OrderBy = z.union([
|
|
|
10
10
|
]);
|
|
11
11
|
const StatusEnum = z.enum(["OPEN", "CLOSED"]);
|
|
12
12
|
const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
|
|
13
|
-
const PositionListParams =
|
|
13
|
+
const PositionListParams = CursorFindParams.extend({
|
|
14
14
|
/**
|
|
15
15
|
* Connector filter
|
|
16
16
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { CursorResponse } from '../common';
|
|
2
3
|
import { SignedDecimalString } from '../common/schema';
|
|
3
4
|
import { Connector } from '../connector';
|
|
4
5
|
import { InstrumentId } from '../instrument';
|
|
5
6
|
import { Position, PositionOrigin } from './entities';
|
|
6
7
|
|
|
7
|
-
const PositionListResponse =
|
|
8
|
+
const PositionListResponse = CursorResponse.extend({
|
|
8
9
|
positions: z.array(Position)
|
|
9
10
|
});
|
|
10
11
|
const OpenPositionLite = z.object({
|
|
@@ -14,3 +14,10 @@ export declare const OiStatistics: z.ZodObject<{
|
|
|
14
14
|
openPositions: z.ZodNumber;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
16
|
export type OiStatistics = z.output<typeof OiStatistics>;
|
|
17
|
+
export declare const StatisticsTotals: z.ZodObject<{
|
|
18
|
+
totalVolume: z.ZodNumber;
|
|
19
|
+
totalFees: z.ZodNumber;
|
|
20
|
+
totalTrades: z.ZodNumber;
|
|
21
|
+
totalUsers: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type StatisticsTotals = z.output<typeof StatisticsTotals>;
|
|
@@ -13,5 +13,11 @@ const OiStatistics = z.object({
|
|
|
13
13
|
openInterest: z.number(),
|
|
14
14
|
openPositions: z.number()
|
|
15
15
|
});
|
|
16
|
+
const StatisticsTotals = z.object({
|
|
17
|
+
totalVolume: z.number(),
|
|
18
|
+
totalFees: z.number(),
|
|
19
|
+
totalTrades: z.number(),
|
|
20
|
+
totalUsers: z.number()
|
|
21
|
+
});
|
|
16
22
|
|
|
17
|
-
export { OiStatistics, VolumeStatistics };
|
|
23
|
+
export { OiStatistics, StatisticsTotals, VolumeStatistics };
|
|
@@ -35,3 +35,14 @@ export declare const OiStatisticsQueryParams: z.ZodObject<{
|
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
export type OiStatisticsQueryParamsInput = z.input<typeof OiStatisticsQueryParams>;
|
|
37
37
|
export type OiStatisticsQueryParams = z.output<typeof OiStatisticsQueryParams>;
|
|
38
|
+
export declare const StatisticsTotalsQueryParams: z.ZodObject<{
|
|
39
|
+
connector: z.ZodEnum<{
|
|
40
|
+
hyperliquid: "hyperliquid";
|
|
41
|
+
binance: "binance";
|
|
42
|
+
bybit: "bybit";
|
|
43
|
+
okx: "okx";
|
|
44
|
+
lighter: "lighter";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type StatisticsTotalsQueryParamsInput = z.input<typeof StatisticsTotalsQueryParams>;
|
|
48
|
+
export type StatisticsTotalsQueryParams = z.output<typeof StatisticsTotalsQueryParams>;
|
|
@@ -17,5 +17,8 @@ const OiStatisticsQueryParams = z.object({
|
|
|
17
17
|
}).refine((data) => !data.startDate || data.startDate < data.endDate, {
|
|
18
18
|
message: "startDate must be before endDate"
|
|
19
19
|
});
|
|
20
|
+
const StatisticsTotalsQueryParams = z.object({
|
|
21
|
+
connector: Connector
|
|
22
|
+
});
|
|
20
23
|
|
|
21
|
-
export { OiStatisticsQueryParams, VolumeStatisticsQueryParams };
|
|
24
|
+
export { OiStatisticsQueryParams, StatisticsTotalsQueryParams, VolumeStatisticsQueryParams };
|
|
@@ -18,3 +18,12 @@ export declare const OiStatisticsResponse: z.ZodObject<{
|
|
|
18
18
|
}, z.core.$strip>>;
|
|
19
19
|
}, z.core.$strip>;
|
|
20
20
|
export type OiStatisticsResponse = z.output<typeof OiStatisticsResponse>;
|
|
21
|
+
export declare const StatisticsTotalsResponse: z.ZodObject<{
|
|
22
|
+
data: z.ZodObject<{
|
|
23
|
+
totalVolume: z.ZodNumber;
|
|
24
|
+
totalFees: z.ZodNumber;
|
|
25
|
+
totalTrades: z.ZodNumber;
|
|
26
|
+
totalUsers: z.ZodNumber;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type StatisticsTotalsResponse = z.output<typeof StatisticsTotalsResponse>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { VolumeStatistics, OiStatistics } from './entities';
|
|
2
|
+
import { VolumeStatistics, OiStatistics, StatisticsTotals } from './entities';
|
|
3
3
|
|
|
4
4
|
const VolumeStatisticsResponse = z.object({
|
|
5
5
|
data: z.array(VolumeStatistics)
|
|
@@ -7,5 +7,8 @@ const VolumeStatisticsResponse = z.object({
|
|
|
7
7
|
const OiStatisticsResponse = z.object({
|
|
8
8
|
data: z.array(OiStatistics)
|
|
9
9
|
});
|
|
10
|
+
const StatisticsTotalsResponse = z.object({
|
|
11
|
+
data: StatisticsTotals
|
|
12
|
+
});
|
|
10
13
|
|
|
11
|
-
export { OiStatisticsResponse, VolumeStatisticsResponse };
|
|
14
|
+
export { OiStatisticsResponse, StatisticsTotalsResponse, VolumeStatisticsResponse };
|