@pear-protocol/types 1.31.0 → 1.33.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/baskets/recommended/entities.d.ts +36 -0
- package/dist/baskets/recommended/entities.js +22 -0
- package/dist/baskets/recommended/index.d.ts +2 -0
- package/dist/baskets/recommended/index.js +2 -0
- package/dist/baskets/recommended/responses.d.ts +28 -0
- package/dist/baskets/recommended/responses.js +8 -0
- package/dist/{saved-baskets → baskets/saved}/entities.d.ts +3 -0
- package/dist/{saved-baskets → baskets/saved}/entities.js +6 -3
- package/dist/{saved-baskets → baskets/saved}/payloads.d.ts +4 -0
- package/dist/{saved-baskets → baskets/saved}/payloads.js +1 -1
- package/dist/{saved-baskets → baskets/saved}/responses.d.ts +6 -0
- package/dist/bundle.d.ts +2 -1
- package/dist/bundle.js +2 -1
- package/dist/common/refinement.d.ts +9 -0
- package/dist/common/refinement.js +9 -1
- package/dist/common/trade-legs.d.ts +2 -0
- package/dist/common/trade-legs.js +7 -3
- package/dist/execution/entities.d.ts +13 -0
- package/dist/execution/entities.js +2 -0
- package/dist/execution/responses.d.ts +8 -0
- package/dist/ladder/entities.d.ts +549 -0
- package/dist/ladder/payloads.d.ts +4 -0
- package/dist/ladder/responses.d.ts +2039 -392
- package/dist/notification/entities.d.ts +176 -3
- package/dist/notification/entities.js +31 -0
- package/dist/notification/responses.d.ts +86 -0
- package/dist/schedule/entities.d.ts +3 -0
- package/dist/schedule/entities.js +2 -0
- package/dist/schedule/payloads.d.ts +2 -0
- package/dist/schedule/payloads.js +6 -29
- package/dist/schedule/responses.d.ts +2 -0
- package/dist/schedule/twap-config.d.ts +41 -0
- package/dist/schedule/twap-config.js +29 -0
- package/dist/trade/payloads.d.ts +8 -0
- package/dist/trade/responses.d.ts +20 -0
- package/dist/trigger/entities/index.d.ts +1707 -54
- package/dist/trigger/entities/index.js +55 -2
- package/dist/trigger/payloads/index.d.ts +898 -91
- package/dist/trigger/payloads/index.js +68 -5
- package/dist/trigger/responses.d.ts +1151 -53
- package/dist/users/entities.d.ts +2 -0
- package/dist/users/entities.js +3 -1
- package/dist/users/response.d.ts +2 -0
- package/dist/users/response.js +2 -0
- package/package.json +1 -1
- /package/dist/{saved-baskets → baskets/saved}/index.d.ts +0 -0
- /package/dist/{saved-baskets → baskets/saved}/index.js +0 -0
- /package/dist/{saved-baskets → baskets/saved}/responses.js +0 -0
|
@@ -5,9 +5,10 @@ import { z } from 'zod';
|
|
|
5
5
|
* execute; `ATTACHED_TRIGGER_DISCARDED` means requested close protection could
|
|
6
6
|
* not be placed after a position opened; the `AUTO_REBALANCE_*` categories cover
|
|
7
7
|
* an auto-rebalance config acting on, or stopping itself over, the position it
|
|
8
|
-
* watches; `
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* watches; the `TRIGGER_TWAP_*` categories describe a fired trigger starting,
|
|
9
|
+
* skipping, failing, or cancelling its TWAP; `TRIGGER_CANCELLED_MIS_SCALED`
|
|
10
|
+
* means the remediation sweep cancelled an unreachable stop loss. Outcome lives
|
|
11
|
+
* here in the category; display details live in the `parameters` payload below.
|
|
11
12
|
*/
|
|
12
13
|
export declare const NotificationCategory: z.ZodEnum<{
|
|
13
14
|
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
@@ -20,6 +21,10 @@ export declare const NotificationCategory: z.ZodEnum<{
|
|
|
20
21
|
AUTO_REBALANCE_EXECUTED: "AUTO_REBALANCE_EXECUTED";
|
|
21
22
|
AUTO_REBALANCE_FAILED: "AUTO_REBALANCE_FAILED";
|
|
22
23
|
AUTO_REBALANCE_PAUSED: "AUTO_REBALANCE_PAUSED";
|
|
24
|
+
TRIGGER_TWAP_STARTED: "TRIGGER_TWAP_STARTED";
|
|
25
|
+
TRIGGER_TWAP_SKIPPED: "TRIGGER_TWAP_SKIPPED";
|
|
26
|
+
TRIGGER_TWAP_FAILED: "TRIGGER_TWAP_FAILED";
|
|
27
|
+
TRIGGER_TWAP_POSITION_CHANGED: "TRIGGER_TWAP_POSITION_CHANGED";
|
|
23
28
|
TRIGGER_CANCELLED_MIS_SCALED: "TRIGGER_CANCELLED_MIS_SCALED";
|
|
24
29
|
}>;
|
|
25
30
|
export type NotificationCategory = z.infer<typeof NotificationCategory>;
|
|
@@ -333,6 +338,88 @@ export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
333
338
|
LIVE_BETA: "LIVE_BETA";
|
|
334
339
|
}>;
|
|
335
340
|
type: z.ZodLiteral<"auto_rebalance_paused">;
|
|
341
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
342
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
343
|
+
id: z.ZodString;
|
|
344
|
+
symbol: z.ZodString;
|
|
345
|
+
side: z.ZodEnum<{
|
|
346
|
+
BUY: "BUY";
|
|
347
|
+
SELL: "SELL";
|
|
348
|
+
}>;
|
|
349
|
+
}, z.core.$strip>>;
|
|
350
|
+
triggerId: z.ZodUUID;
|
|
351
|
+
positionId: z.ZodUUID;
|
|
352
|
+
connector: z.ZodEnum<{
|
|
353
|
+
hyperliquid: "hyperliquid";
|
|
354
|
+
binance: "binance";
|
|
355
|
+
bybit: "bybit";
|
|
356
|
+
okx: "okx";
|
|
357
|
+
lighter: "lighter";
|
|
358
|
+
}>;
|
|
359
|
+
type: z.ZodLiteral<"trigger_twap_started">;
|
|
360
|
+
scheduleId: z.ZodUUID;
|
|
361
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
362
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
363
|
+
id: z.ZodString;
|
|
364
|
+
symbol: z.ZodString;
|
|
365
|
+
side: z.ZodEnum<{
|
|
366
|
+
BUY: "BUY";
|
|
367
|
+
SELL: "SELL";
|
|
368
|
+
}>;
|
|
369
|
+
}, z.core.$strip>>;
|
|
370
|
+
triggerId: z.ZodUUID;
|
|
371
|
+
positionId: z.ZodUUID;
|
|
372
|
+
connector: z.ZodEnum<{
|
|
373
|
+
hyperliquid: "hyperliquid";
|
|
374
|
+
binance: "binance";
|
|
375
|
+
bybit: "bybit";
|
|
376
|
+
okx: "okx";
|
|
377
|
+
lighter: "lighter";
|
|
378
|
+
}>;
|
|
379
|
+
type: z.ZodLiteral<"trigger_twap_skipped">;
|
|
380
|
+
reason: z.ZodString;
|
|
381
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
382
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
383
|
+
id: z.ZodString;
|
|
384
|
+
symbol: z.ZodString;
|
|
385
|
+
side: z.ZodEnum<{
|
|
386
|
+
BUY: "BUY";
|
|
387
|
+
SELL: "SELL";
|
|
388
|
+
}>;
|
|
389
|
+
}, z.core.$strip>>;
|
|
390
|
+
triggerId: z.ZodUUID;
|
|
391
|
+
positionId: z.ZodUUID;
|
|
392
|
+
connector: z.ZodEnum<{
|
|
393
|
+
hyperliquid: "hyperliquid";
|
|
394
|
+
binance: "binance";
|
|
395
|
+
bybit: "bybit";
|
|
396
|
+
okx: "okx";
|
|
397
|
+
lighter: "lighter";
|
|
398
|
+
}>;
|
|
399
|
+
type: z.ZodLiteral<"trigger_twap_failed">;
|
|
400
|
+
scheduleId: z.ZodOptional<z.ZodUUID>;
|
|
401
|
+
reason: z.ZodString;
|
|
402
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
403
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
404
|
+
id: z.ZodString;
|
|
405
|
+
symbol: z.ZodString;
|
|
406
|
+
side: z.ZodEnum<{
|
|
407
|
+
BUY: "BUY";
|
|
408
|
+
SELL: "SELL";
|
|
409
|
+
}>;
|
|
410
|
+
}, z.core.$strip>>;
|
|
411
|
+
triggerId: z.ZodUUID;
|
|
412
|
+
positionId: z.ZodUUID;
|
|
413
|
+
connector: z.ZodEnum<{
|
|
414
|
+
hyperliquid: "hyperliquid";
|
|
415
|
+
binance: "binance";
|
|
416
|
+
bybit: "bybit";
|
|
417
|
+
okx: "okx";
|
|
418
|
+
lighter: "lighter";
|
|
419
|
+
}>;
|
|
420
|
+
type: z.ZodLiteral<"trigger_twap_position_changed">;
|
|
421
|
+
scheduleId: z.ZodUUID;
|
|
422
|
+
reason: z.ZodString;
|
|
336
423
|
}, z.core.$strip>, z.ZodObject<{
|
|
337
424
|
type: z.ZodLiteral<"trigger_cancelled_mis_scaled">;
|
|
338
425
|
triggerId: z.ZodUUID;
|
|
@@ -354,6 +441,10 @@ export declare const Notification: z.ZodObject<{
|
|
|
354
441
|
AUTO_REBALANCE_EXECUTED: "AUTO_REBALANCE_EXECUTED";
|
|
355
442
|
AUTO_REBALANCE_FAILED: "AUTO_REBALANCE_FAILED";
|
|
356
443
|
AUTO_REBALANCE_PAUSED: "AUTO_REBALANCE_PAUSED";
|
|
444
|
+
TRIGGER_TWAP_STARTED: "TRIGGER_TWAP_STARTED";
|
|
445
|
+
TRIGGER_TWAP_SKIPPED: "TRIGGER_TWAP_SKIPPED";
|
|
446
|
+
TRIGGER_TWAP_FAILED: "TRIGGER_TWAP_FAILED";
|
|
447
|
+
TRIGGER_TWAP_POSITION_CHANGED: "TRIGGER_TWAP_POSITION_CHANGED";
|
|
357
448
|
TRIGGER_CANCELLED_MIS_SCALED: "TRIGGER_CANCELLED_MIS_SCALED";
|
|
358
449
|
}>;
|
|
359
450
|
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -648,6 +739,88 @@ export declare const Notification: z.ZodObject<{
|
|
|
648
739
|
LIVE_BETA: "LIVE_BETA";
|
|
649
740
|
}>;
|
|
650
741
|
type: z.ZodLiteral<"auto_rebalance_paused">;
|
|
742
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
743
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
744
|
+
id: z.ZodString;
|
|
745
|
+
symbol: z.ZodString;
|
|
746
|
+
side: z.ZodEnum<{
|
|
747
|
+
BUY: "BUY";
|
|
748
|
+
SELL: "SELL";
|
|
749
|
+
}>;
|
|
750
|
+
}, z.core.$strip>>;
|
|
751
|
+
triggerId: z.ZodUUID;
|
|
752
|
+
positionId: z.ZodUUID;
|
|
753
|
+
connector: z.ZodEnum<{
|
|
754
|
+
hyperliquid: "hyperliquid";
|
|
755
|
+
binance: "binance";
|
|
756
|
+
bybit: "bybit";
|
|
757
|
+
okx: "okx";
|
|
758
|
+
lighter: "lighter";
|
|
759
|
+
}>;
|
|
760
|
+
type: z.ZodLiteral<"trigger_twap_started">;
|
|
761
|
+
scheduleId: z.ZodUUID;
|
|
762
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
763
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
764
|
+
id: z.ZodString;
|
|
765
|
+
symbol: z.ZodString;
|
|
766
|
+
side: z.ZodEnum<{
|
|
767
|
+
BUY: "BUY";
|
|
768
|
+
SELL: "SELL";
|
|
769
|
+
}>;
|
|
770
|
+
}, z.core.$strip>>;
|
|
771
|
+
triggerId: z.ZodUUID;
|
|
772
|
+
positionId: z.ZodUUID;
|
|
773
|
+
connector: z.ZodEnum<{
|
|
774
|
+
hyperliquid: "hyperliquid";
|
|
775
|
+
binance: "binance";
|
|
776
|
+
bybit: "bybit";
|
|
777
|
+
okx: "okx";
|
|
778
|
+
lighter: "lighter";
|
|
779
|
+
}>;
|
|
780
|
+
type: z.ZodLiteral<"trigger_twap_skipped">;
|
|
781
|
+
reason: z.ZodString;
|
|
782
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
783
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
784
|
+
id: z.ZodString;
|
|
785
|
+
symbol: z.ZodString;
|
|
786
|
+
side: z.ZodEnum<{
|
|
787
|
+
BUY: "BUY";
|
|
788
|
+
SELL: "SELL";
|
|
789
|
+
}>;
|
|
790
|
+
}, z.core.$strip>>;
|
|
791
|
+
triggerId: z.ZodUUID;
|
|
792
|
+
positionId: z.ZodUUID;
|
|
793
|
+
connector: z.ZodEnum<{
|
|
794
|
+
hyperliquid: "hyperliquid";
|
|
795
|
+
binance: "binance";
|
|
796
|
+
bybit: "bybit";
|
|
797
|
+
okx: "okx";
|
|
798
|
+
lighter: "lighter";
|
|
799
|
+
}>;
|
|
800
|
+
type: z.ZodLiteral<"trigger_twap_failed">;
|
|
801
|
+
scheduleId: z.ZodOptional<z.ZodUUID>;
|
|
802
|
+
reason: z.ZodString;
|
|
803
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
804
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
805
|
+
id: z.ZodString;
|
|
806
|
+
symbol: z.ZodString;
|
|
807
|
+
side: z.ZodEnum<{
|
|
808
|
+
BUY: "BUY";
|
|
809
|
+
SELL: "SELL";
|
|
810
|
+
}>;
|
|
811
|
+
}, z.core.$strip>>;
|
|
812
|
+
triggerId: z.ZodUUID;
|
|
813
|
+
positionId: z.ZodUUID;
|
|
814
|
+
connector: z.ZodEnum<{
|
|
815
|
+
hyperliquid: "hyperliquid";
|
|
816
|
+
binance: "binance";
|
|
817
|
+
bybit: "bybit";
|
|
818
|
+
okx: "okx";
|
|
819
|
+
lighter: "lighter";
|
|
820
|
+
}>;
|
|
821
|
+
type: z.ZodLiteral<"trigger_twap_position_changed">;
|
|
822
|
+
scheduleId: z.ZodUUID;
|
|
823
|
+
reason: z.ZodString;
|
|
651
824
|
}, z.core.$strip>, z.ZodObject<{
|
|
652
825
|
type: z.ZodLiteral<"trigger_cancelled_mis_scaled">;
|
|
653
826
|
triggerId: z.ZodUUID;
|
|
@@ -14,6 +14,10 @@ const NotificationCategory = z.enum([
|
|
|
14
14
|
"AUTO_REBALANCE_EXECUTED",
|
|
15
15
|
"AUTO_REBALANCE_FAILED",
|
|
16
16
|
"AUTO_REBALANCE_PAUSED",
|
|
17
|
+
"TRIGGER_TWAP_STARTED",
|
|
18
|
+
"TRIGGER_TWAP_SKIPPED",
|
|
19
|
+
"TRIGGER_TWAP_FAILED",
|
|
20
|
+
"TRIGGER_TWAP_POSITION_CHANGED",
|
|
17
21
|
"TRIGGER_CANCELLED_MIS_SCALED"
|
|
18
22
|
]);
|
|
19
23
|
const NotificationMetric = z.enum([
|
|
@@ -146,6 +150,29 @@ const TriggerCancelledMisScaledNotificationParameters = z.object({
|
|
|
146
150
|
storedBps: z.number(),
|
|
147
151
|
readingMarginPct: z.number()
|
|
148
152
|
});
|
|
153
|
+
const TriggerTWAPNotificationAnchor = PositionLegParameters.safeExtend({
|
|
154
|
+
triggerId: z.uuid(),
|
|
155
|
+
positionId: z.uuid(),
|
|
156
|
+
connector: Connector
|
|
157
|
+
});
|
|
158
|
+
const TriggerTWAPStartedNotificationParameters = TriggerTWAPNotificationAnchor.safeExtend({
|
|
159
|
+
type: z.literal("trigger_twap_started"),
|
|
160
|
+
scheduleId: z.uuid()
|
|
161
|
+
});
|
|
162
|
+
const TriggerTWAPSkippedNotificationParameters = TriggerTWAPNotificationAnchor.safeExtend({
|
|
163
|
+
type: z.literal("trigger_twap_skipped"),
|
|
164
|
+
reason: z.string().min(1).max(255)
|
|
165
|
+
});
|
|
166
|
+
const TriggerTWAPFailedNotificationParameters = TriggerTWAPNotificationAnchor.safeExtend({
|
|
167
|
+
type: z.literal("trigger_twap_failed"),
|
|
168
|
+
scheduleId: z.uuid().optional(),
|
|
169
|
+
reason: z.string().min(1).max(255)
|
|
170
|
+
});
|
|
171
|
+
const TriggerTWAPPositionChangedNotificationParameters = TriggerTWAPNotificationAnchor.safeExtend({
|
|
172
|
+
type: z.literal("trigger_twap_position_changed"),
|
|
173
|
+
scheduleId: z.uuid(),
|
|
174
|
+
reason: z.string().min(1).max(255)
|
|
175
|
+
});
|
|
149
176
|
const NotificationParameters = z.discriminatedUnion("type", [
|
|
150
177
|
TakeProfitNotificationParameters,
|
|
151
178
|
StopLossNotificationParameters,
|
|
@@ -155,6 +182,10 @@ const NotificationParameters = z.discriminatedUnion("type", [
|
|
|
155
182
|
AutoRebalanceExecutedNotificationParameters,
|
|
156
183
|
AutoRebalanceFailedNotificationParameters,
|
|
157
184
|
AutoRebalancePausedNotificationParameters,
|
|
185
|
+
TriggerTWAPStartedNotificationParameters,
|
|
186
|
+
TriggerTWAPSkippedNotificationParameters,
|
|
187
|
+
TriggerTWAPFailedNotificationParameters,
|
|
188
|
+
TriggerTWAPPositionChangedNotificationParameters,
|
|
158
189
|
TriggerCancelledMisScaledNotificationParameters
|
|
159
190
|
]);
|
|
160
191
|
const Notification = z.object({
|
|
@@ -13,6 +13,10 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
13
13
|
AUTO_REBALANCE_EXECUTED: "AUTO_REBALANCE_EXECUTED";
|
|
14
14
|
AUTO_REBALANCE_FAILED: "AUTO_REBALANCE_FAILED";
|
|
15
15
|
AUTO_REBALANCE_PAUSED: "AUTO_REBALANCE_PAUSED";
|
|
16
|
+
TRIGGER_TWAP_STARTED: "TRIGGER_TWAP_STARTED";
|
|
17
|
+
TRIGGER_TWAP_SKIPPED: "TRIGGER_TWAP_SKIPPED";
|
|
18
|
+
TRIGGER_TWAP_FAILED: "TRIGGER_TWAP_FAILED";
|
|
19
|
+
TRIGGER_TWAP_POSITION_CHANGED: "TRIGGER_TWAP_POSITION_CHANGED";
|
|
16
20
|
TRIGGER_CANCELLED_MIS_SCALED: "TRIGGER_CANCELLED_MIS_SCALED";
|
|
17
21
|
}>;
|
|
18
22
|
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -307,6 +311,88 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
307
311
|
LIVE_BETA: "LIVE_BETA";
|
|
308
312
|
}>;
|
|
309
313
|
type: z.ZodLiteral<"auto_rebalance_paused">;
|
|
314
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
315
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
316
|
+
id: z.ZodString;
|
|
317
|
+
symbol: z.ZodString;
|
|
318
|
+
side: z.ZodEnum<{
|
|
319
|
+
BUY: "BUY";
|
|
320
|
+
SELL: "SELL";
|
|
321
|
+
}>;
|
|
322
|
+
}, z.core.$strip>>;
|
|
323
|
+
triggerId: z.ZodUUID;
|
|
324
|
+
positionId: z.ZodUUID;
|
|
325
|
+
connector: z.ZodEnum<{
|
|
326
|
+
hyperliquid: "hyperliquid";
|
|
327
|
+
binance: "binance";
|
|
328
|
+
bybit: "bybit";
|
|
329
|
+
okx: "okx";
|
|
330
|
+
lighter: "lighter";
|
|
331
|
+
}>;
|
|
332
|
+
type: z.ZodLiteral<"trigger_twap_started">;
|
|
333
|
+
scheduleId: z.ZodUUID;
|
|
334
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
335
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
336
|
+
id: z.ZodString;
|
|
337
|
+
symbol: z.ZodString;
|
|
338
|
+
side: z.ZodEnum<{
|
|
339
|
+
BUY: "BUY";
|
|
340
|
+
SELL: "SELL";
|
|
341
|
+
}>;
|
|
342
|
+
}, z.core.$strip>>;
|
|
343
|
+
triggerId: z.ZodUUID;
|
|
344
|
+
positionId: z.ZodUUID;
|
|
345
|
+
connector: z.ZodEnum<{
|
|
346
|
+
hyperliquid: "hyperliquid";
|
|
347
|
+
binance: "binance";
|
|
348
|
+
bybit: "bybit";
|
|
349
|
+
okx: "okx";
|
|
350
|
+
lighter: "lighter";
|
|
351
|
+
}>;
|
|
352
|
+
type: z.ZodLiteral<"trigger_twap_skipped">;
|
|
353
|
+
reason: z.ZodString;
|
|
354
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
355
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
356
|
+
id: z.ZodString;
|
|
357
|
+
symbol: z.ZodString;
|
|
358
|
+
side: z.ZodEnum<{
|
|
359
|
+
BUY: "BUY";
|
|
360
|
+
SELL: "SELL";
|
|
361
|
+
}>;
|
|
362
|
+
}, z.core.$strip>>;
|
|
363
|
+
triggerId: z.ZodUUID;
|
|
364
|
+
positionId: z.ZodUUID;
|
|
365
|
+
connector: z.ZodEnum<{
|
|
366
|
+
hyperliquid: "hyperliquid";
|
|
367
|
+
binance: "binance";
|
|
368
|
+
bybit: "bybit";
|
|
369
|
+
okx: "okx";
|
|
370
|
+
lighter: "lighter";
|
|
371
|
+
}>;
|
|
372
|
+
type: z.ZodLiteral<"trigger_twap_failed">;
|
|
373
|
+
scheduleId: z.ZodOptional<z.ZodUUID>;
|
|
374
|
+
reason: z.ZodString;
|
|
375
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
376
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
377
|
+
id: z.ZodString;
|
|
378
|
+
symbol: z.ZodString;
|
|
379
|
+
side: z.ZodEnum<{
|
|
380
|
+
BUY: "BUY";
|
|
381
|
+
SELL: "SELL";
|
|
382
|
+
}>;
|
|
383
|
+
}, z.core.$strip>>;
|
|
384
|
+
triggerId: z.ZodUUID;
|
|
385
|
+
positionId: z.ZodUUID;
|
|
386
|
+
connector: z.ZodEnum<{
|
|
387
|
+
hyperliquid: "hyperliquid";
|
|
388
|
+
binance: "binance";
|
|
389
|
+
bybit: "bybit";
|
|
390
|
+
okx: "okx";
|
|
391
|
+
lighter: "lighter";
|
|
392
|
+
}>;
|
|
393
|
+
type: z.ZodLiteral<"trigger_twap_position_changed">;
|
|
394
|
+
scheduleId: z.ZodUUID;
|
|
395
|
+
reason: z.ZodString;
|
|
310
396
|
}, z.core.$strip>, z.ZodObject<{
|
|
311
397
|
type: z.ZodLiteral<"trigger_cancelled_mis_scaled">;
|
|
312
398
|
triggerId: z.ZodUUID;
|
|
@@ -29,6 +29,7 @@ export declare const ScheduleCancelledReason: z.ZodEnum<{
|
|
|
29
29
|
}>;
|
|
30
30
|
export type ScheduleCancelledReason = z.infer<typeof ScheduleCancelledReason>;
|
|
31
31
|
declare const TWAPOpenLeg: z.ZodObject<{
|
|
32
|
+
id: z.ZodOptional<z.ZodString>;
|
|
32
33
|
symbol: z.ZodString;
|
|
33
34
|
side: z.ZodEnum<{
|
|
34
35
|
BUY: "BUY";
|
|
@@ -192,6 +193,7 @@ export declare const TWAPOpen: z.ZodObject<{
|
|
|
192
193
|
sizeJitterBps: z.ZodInt;
|
|
193
194
|
}, z.core.$strip>;
|
|
194
195
|
legs: z.ZodArray<z.ZodObject<{
|
|
196
|
+
id: z.ZodOptional<z.ZodString>;
|
|
195
197
|
symbol: z.ZodString;
|
|
196
198
|
side: z.ZodEnum<{
|
|
197
199
|
BUY: "BUY";
|
|
@@ -360,6 +362,7 @@ export declare const Schedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
360
362
|
sizeJitterBps: z.ZodInt;
|
|
361
363
|
}, z.core.$strip>;
|
|
362
364
|
legs: z.ZodArray<z.ZodObject<{
|
|
365
|
+
id: z.ZodOptional<z.ZodString>;
|
|
363
366
|
symbol: z.ZodString;
|
|
364
367
|
side: z.ZodEnum<{
|
|
365
368
|
BUY: "BUY";
|
|
@@ -30,6 +30,8 @@ const ScheduleCancelledReason = z.enum([
|
|
|
30
30
|
"POSITION_REVERSED"
|
|
31
31
|
]);
|
|
32
32
|
const TWAPOpenLeg = z.object({
|
|
33
|
+
/** PHASE-1 LEG ID: mirrors `symbol` today; required in phase 3 when `symbol` becomes the ticker. */
|
|
34
|
+
id: InstrumentId.optional(),
|
|
33
35
|
/**
|
|
34
36
|
* Instrument ID
|
|
35
37
|
*/
|
|
@@ -10,6 +10,7 @@ export declare const CreateTWAPOpen: z.ZodObject<{
|
|
|
10
10
|
intent: z.ZodLiteral<"OPEN">;
|
|
11
11
|
executionType: z.ZodLiteral<"MARKET">;
|
|
12
12
|
legs: z.ZodArray<z.ZodObject<{
|
|
13
|
+
id: z.ZodOptional<z.ZodString>;
|
|
13
14
|
symbol: z.ZodString;
|
|
14
15
|
side: z.ZodEnum<{
|
|
15
16
|
BUY: "BUY";
|
|
@@ -46,6 +47,7 @@ export declare const CreateSchedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
46
47
|
intent: z.ZodLiteral<"OPEN">;
|
|
47
48
|
executionType: z.ZodLiteral<"MARKET">;
|
|
48
49
|
legs: z.ZodArray<z.ZodObject<{
|
|
50
|
+
id: z.ZodOptional<z.ZodString>;
|
|
49
51
|
symbol: z.ZodString;
|
|
50
52
|
side: z.ZodEnum<{
|
|
51
53
|
BUY: "BUY";
|
|
@@ -1,31 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ClientIdCode } from '../common/client-id';
|
|
3
|
-
import { RefineMinimumOneSymbol, RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
|
|
4
|
-
import { UnsignedDecimalString, AssetWeight, Side } from '../common/schema';
|
|
5
|
-
import { InstrumentId } from '../instrument';
|
|
6
3
|
import { TWAPRandomization, DEFAULT_TWAP_RANDOMIZATION } from './randomization';
|
|
4
|
+
import { FINAL_TWAP_SLICE_START_HEADROOM_SEC, TWAPSliceIntervalSec, TWAPTargetNotional, TWAPOpenLegs } from './twap-config';
|
|
7
5
|
|
|
8
|
-
const THIRTY_ONE_DAYS_SEC = 60 * 60 * 24 * 31;
|
|
9
|
-
const MIN_TWAP_WINDOW_SEC = 15;
|
|
10
|
-
const SliceIntervalSec = z.int().min(MIN_TWAP_WINDOW_SEC).max(THIRTY_ONE_DAYS_SEC);
|
|
11
|
-
const TargetNotional = UnsignedDecimalString.refine((value) => /[1-9]/.test(value), {
|
|
12
|
-
message: "Target notional must be greater than zero"
|
|
13
|
-
});
|
|
14
|
-
const TWAPOpenLeg = z.object({
|
|
15
|
-
/**
|
|
16
|
-
* Instrument ID
|
|
17
|
-
*/
|
|
18
|
-
symbol: InstrumentId,
|
|
19
|
-
/**
|
|
20
|
-
* Direction to take
|
|
21
|
-
*/
|
|
22
|
-
side: Side,
|
|
23
|
-
/**
|
|
24
|
-
* Share of the parent target notional allocated to this leg
|
|
25
|
-
*/
|
|
26
|
-
weight: AssetWeight
|
|
27
|
-
});
|
|
28
|
-
const TWAPOpenLegs = z.array(TWAPOpenLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
|
|
29
6
|
const BaseSchedule = z.object({
|
|
30
7
|
/**
|
|
31
8
|
* Start at date
|
|
@@ -41,8 +18,8 @@ const BaseSchedule = z.object({
|
|
|
41
18
|
randomization: TWAPRandomization.optional().default(DEFAULT_TWAP_RANDOMIZATION)
|
|
42
19
|
}).refine((data) => data.startAt && data.endAt && data.startAt < data.endAt, {
|
|
43
20
|
message: "Start at date must be before end at date"
|
|
44
|
-
}).refine((data) => data.endAt.getTime() - data.startAt.getTime() >=
|
|
45
|
-
message: `TWAP execution window must be at least ${
|
|
21
|
+
}).refine((data) => data.endAt.getTime() - data.startAt.getTime() >= FINAL_TWAP_SLICE_START_HEADROOM_SEC * 1e3, {
|
|
22
|
+
message: `TWAP execution window must be at least ${FINAL_TWAP_SLICE_START_HEADROOM_SEC} seconds`
|
|
46
23
|
});
|
|
47
24
|
const CreateTWAPOpen = BaseSchedule.safeExtend({
|
|
48
25
|
/**
|
|
@@ -64,11 +41,11 @@ const CreateTWAPOpen = BaseSchedule.safeExtend({
|
|
|
64
41
|
/**
|
|
65
42
|
* Target notional
|
|
66
43
|
*/
|
|
67
|
-
targetNotional:
|
|
44
|
+
targetNotional: TWAPTargetNotional,
|
|
68
45
|
/**
|
|
69
46
|
* Slice interval in seconds
|
|
70
47
|
*/
|
|
71
|
-
sliceIntervalSec:
|
|
48
|
+
sliceIntervalSec: TWAPSliceIntervalSec,
|
|
72
49
|
/**
|
|
73
50
|
* Attribution route code (client_ids.code)
|
|
74
51
|
*/
|
|
@@ -94,7 +71,7 @@ const CreateTWAPClose = BaseSchedule.safeExtend({
|
|
|
94
71
|
/**
|
|
95
72
|
* Slice interval in seconds
|
|
96
73
|
*/
|
|
97
|
-
sliceIntervalSec:
|
|
74
|
+
sliceIntervalSec: TWAPSliceIntervalSec,
|
|
98
75
|
/**
|
|
99
76
|
* Attribution route code (client_ids.code)
|
|
100
77
|
*/
|
|
@@ -80,6 +80,7 @@ export declare const ScheduleListResponse: z.ZodObject<{
|
|
|
80
80
|
sizeJitterBps: z.ZodInt;
|
|
81
81
|
}, z.core.$strip>;
|
|
82
82
|
legs: z.ZodArray<z.ZodObject<{
|
|
83
|
+
id: z.ZodOptional<z.ZodString>;
|
|
83
84
|
symbol: z.ZodString;
|
|
84
85
|
side: z.ZodEnum<{
|
|
85
86
|
BUY: "BUY";
|
|
@@ -250,6 +251,7 @@ export declare const CreateScheduleResponse: z.ZodObject<{
|
|
|
250
251
|
sizeJitterBps: z.ZodInt;
|
|
251
252
|
}, z.core.$strip>;
|
|
252
253
|
legs: z.ZodArray<z.ZodObject<{
|
|
254
|
+
id: z.ZodOptional<z.ZodString>;
|
|
253
255
|
symbol: z.ZodString;
|
|
254
256
|
side: z.ZodEnum<{
|
|
255
257
|
BUY: "BUY";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MAX_TWAP_DURATION_SEC: number;
|
|
3
|
+
export declare const MIN_TWAP_SLICE_INTERVAL_SEC = 15;
|
|
4
|
+
export declare const FINAL_TWAP_SLICE_START_HEADROOM_SEC = 15;
|
|
5
|
+
export declare const TWAPSliceIntervalSec: z.ZodInt;
|
|
6
|
+
export declare const TWAPTargetNotional: z.ZodString;
|
|
7
|
+
export declare const TWAPOpenLeg: z.ZodObject<{
|
|
8
|
+
id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
symbol: z.ZodString;
|
|
10
|
+
side: z.ZodEnum<{
|
|
11
|
+
BUY: "BUY";
|
|
12
|
+
SELL: "SELL";
|
|
13
|
+
}>;
|
|
14
|
+
weight: z.ZodNumber;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const TWAPOpenLegs: z.ZodArray<z.ZodObject<{
|
|
17
|
+
id: z.ZodOptional<z.ZodString>;
|
|
18
|
+
symbol: z.ZodString;
|
|
19
|
+
side: z.ZodEnum<{
|
|
20
|
+
BUY: "BUY";
|
|
21
|
+
SELL: "SELL";
|
|
22
|
+
}>;
|
|
23
|
+
weight: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
export declare const TriggerTWAPOpenLegs: z.ZodTuple<[z.ZodObject<{
|
|
26
|
+
id: z.ZodOptional<z.ZodString>;
|
|
27
|
+
symbol: z.ZodString;
|
|
28
|
+
side: z.ZodEnum<{
|
|
29
|
+
BUY: "BUY";
|
|
30
|
+
SELL: "SELL";
|
|
31
|
+
}>;
|
|
32
|
+
weight: z.ZodNumber;
|
|
33
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
34
|
+
id: z.ZodOptional<z.ZodString>;
|
|
35
|
+
symbol: z.ZodString;
|
|
36
|
+
side: z.ZodEnum<{
|
|
37
|
+
BUY: "BUY";
|
|
38
|
+
SELL: "SELL";
|
|
39
|
+
}>;
|
|
40
|
+
weight: z.ZodNumber;
|
|
41
|
+
}, z.core.$strict>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RefineLegIdMatchesSymbol, RefineMinimumOneSymbol, RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
|
|
3
|
+
import { UnsignedDecimalString, AssetWeight, Side } from '../common/schema';
|
|
4
|
+
import { InstrumentId } from '../instrument';
|
|
5
|
+
|
|
6
|
+
const MAX_TWAP_DURATION_SEC = 60 * 60 * 24 * 31;
|
|
7
|
+
const MIN_TWAP_SLICE_INTERVAL_SEC = 15;
|
|
8
|
+
const FINAL_TWAP_SLICE_START_HEADROOM_SEC = 15;
|
|
9
|
+
const TWAPSliceIntervalSec = z.int().min(MIN_TWAP_SLICE_INTERVAL_SEC).max(MAX_TWAP_DURATION_SEC);
|
|
10
|
+
const TWAPTargetNotional = UnsignedDecimalString.refine((value) => /[1-9]/.test(value), {
|
|
11
|
+
message: "Target notional must be greater than zero"
|
|
12
|
+
});
|
|
13
|
+
const TWAPOpenLeg = z.object({
|
|
14
|
+
/** PHASE-1 LEG ID: mirrors `symbol` today; required in phase 3 when `symbol` becomes the ticker. */
|
|
15
|
+
id: InstrumentId.optional(),
|
|
16
|
+
/** Instrument ID. */
|
|
17
|
+
symbol: InstrumentId,
|
|
18
|
+
/** Direction to take. */
|
|
19
|
+
side: Side,
|
|
20
|
+
/** Share of the parent target notional allocated to this leg. */
|
|
21
|
+
weight: AssetWeight
|
|
22
|
+
}).superRefine(RefineLegIdMatchesSymbol);
|
|
23
|
+
const TWAPOpenLegs = z.array(TWAPOpenLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
|
|
24
|
+
const TriggerTWAPOpenLeg = TWAPOpenLeg.strict();
|
|
25
|
+
const TriggerTWAPOpenLegs = z.tuple([
|
|
26
|
+
TriggerTWAPOpenLeg
|
|
27
|
+
]).rest(TriggerTWAPOpenLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
|
|
28
|
+
|
|
29
|
+
export { FINAL_TWAP_SLICE_START_HEADROOM_SEC, MAX_TWAP_DURATION_SEC, MIN_TWAP_SLICE_INTERVAL_SEC, TWAPOpenLeg, TWAPOpenLegs, TWAPSliceIntervalSec, TWAPTargetNotional, TriggerTWAPOpenLegs };
|
package/dist/trade/payloads.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const CreateMarketOpen: z.ZodObject<{
|
|
|
3
3
|
type: z.ZodLiteral<"MARKET">;
|
|
4
4
|
legs: z.ZodTuple<[z.ZodObject<{
|
|
5
5
|
symbol: z.ZodString;
|
|
6
|
+
id: z.ZodOptional<z.ZodString>;
|
|
6
7
|
side: z.ZodEnum<{
|
|
7
8
|
BUY: "BUY";
|
|
8
9
|
SELL: "SELL";
|
|
@@ -14,6 +15,7 @@ export declare const CreateMarketOpen: z.ZodObject<{
|
|
|
14
15
|
amount: z.ZodString;
|
|
15
16
|
}, z.core.$strip>], z.ZodObject<{
|
|
16
17
|
symbol: z.ZodString;
|
|
18
|
+
id: z.ZodOptional<z.ZodString>;
|
|
17
19
|
side: z.ZodEnum<{
|
|
18
20
|
BUY: "BUY";
|
|
19
21
|
SELL: "SELL";
|
|
@@ -101,6 +103,7 @@ export declare const CreateMarketOpen: z.ZodObject<{
|
|
|
101
103
|
export declare const CreateMarketAdjust: z.ZodObject<{
|
|
102
104
|
type: z.ZodLiteral<"MARKET">;
|
|
103
105
|
legs: z.ZodTuple<[z.ZodObject<{
|
|
106
|
+
id: z.ZodOptional<z.ZodString>;
|
|
104
107
|
symbol: z.ZodString;
|
|
105
108
|
side: z.ZodEnum<{
|
|
106
109
|
BUY: "BUY";
|
|
@@ -113,6 +116,7 @@ export declare const CreateMarketAdjust: z.ZodObject<{
|
|
|
113
116
|
amount: z.ZodString;
|
|
114
117
|
reduceOnly: z.ZodBoolean;
|
|
115
118
|
}, z.core.$strip>], z.ZodObject<{
|
|
119
|
+
id: z.ZodOptional<z.ZodString>;
|
|
116
120
|
symbol: z.ZodString;
|
|
117
121
|
side: z.ZodEnum<{
|
|
118
122
|
BUY: "BUY";
|
|
@@ -143,6 +147,7 @@ export declare const CreateTradeOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
143
147
|
type: z.ZodLiteral<"MARKET">;
|
|
144
148
|
legs: z.ZodTuple<[z.ZodObject<{
|
|
145
149
|
symbol: z.ZodString;
|
|
150
|
+
id: z.ZodOptional<z.ZodString>;
|
|
146
151
|
side: z.ZodEnum<{
|
|
147
152
|
BUY: "BUY";
|
|
148
153
|
SELL: "SELL";
|
|
@@ -154,6 +159,7 @@ export declare const CreateTradeOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
154
159
|
amount: z.ZodString;
|
|
155
160
|
}, z.core.$strip>], z.ZodObject<{
|
|
156
161
|
symbol: z.ZodString;
|
|
162
|
+
id: z.ZodOptional<z.ZodString>;
|
|
157
163
|
side: z.ZodEnum<{
|
|
158
164
|
BUY: "BUY";
|
|
159
165
|
SELL: "SELL";
|
|
@@ -241,6 +247,7 @@ export declare const CreateTradeOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
241
247
|
export declare const CreateTradeAdjust: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
242
248
|
type: z.ZodLiteral<"MARKET">;
|
|
243
249
|
legs: z.ZodTuple<[z.ZodObject<{
|
|
250
|
+
id: z.ZodOptional<z.ZodString>;
|
|
244
251
|
symbol: z.ZodString;
|
|
245
252
|
side: z.ZodEnum<{
|
|
246
253
|
BUY: "BUY";
|
|
@@ -253,6 +260,7 @@ export declare const CreateTradeAdjust: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
253
260
|
amount: z.ZodString;
|
|
254
261
|
reduceOnly: z.ZodBoolean;
|
|
255
262
|
}, z.core.$strip>], z.ZodObject<{
|
|
263
|
+
id: z.ZodOptional<z.ZodString>;
|
|
256
264
|
symbol: z.ZodString;
|
|
257
265
|
side: z.ZodEnum<{
|
|
258
266
|
BUY: "BUY";
|