@pear-protocol/types 1.9.0 → 1.10.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const TriggerIntent = z.enum(["OPEN", "CLOSE"]);
|
|
3
|
+
const TriggerIntent = z.enum(["OPEN", "ADJUST", "CLOSE"]);
|
|
4
4
|
const TriggerStatus = z.enum(["ACTIVE", "TRIGGERED", "CANCELLED"]);
|
|
5
5
|
const TriggerCancelledReason = z.enum([
|
|
6
6
|
"POSITION_CLOSED",
|
|
@@ -332,7 +332,7 @@ export declare const CreateTriggerMarketOpen: z.ZodObject<{
|
|
|
332
332
|
USD: "USD";
|
|
333
333
|
}>;
|
|
334
334
|
amount: z.ZodString;
|
|
335
|
-
}, z.core.$
|
|
335
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
336
336
|
symbol: z.ZodString;
|
|
337
337
|
side: z.ZodEnum<{
|
|
338
338
|
BUY: "BUY";
|
|
@@ -343,10 +343,134 @@ export declare const CreateTriggerMarketOpen: z.ZodObject<{
|
|
|
343
343
|
USD: "USD";
|
|
344
344
|
}>;
|
|
345
345
|
amount: z.ZodString;
|
|
346
|
-
}, z.core.$
|
|
347
|
-
}, z.core.$
|
|
346
|
+
}, z.core.$strict>>;
|
|
347
|
+
}, z.core.$strict>;
|
|
348
348
|
clientId: z.ZodOptional<z.ZodString>;
|
|
349
|
-
}, z.core.$
|
|
349
|
+
}, z.core.$strict>;
|
|
350
|
+
export declare const CreateTriggerMarketAdjust: z.ZodObject<{
|
|
351
|
+
intent: z.ZodLiteral<"ADJUST">;
|
|
352
|
+
type: z.ZodLiteral<"MARKET">;
|
|
353
|
+
positionId: z.ZodUUID;
|
|
354
|
+
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
355
|
+
type: z.ZodLiteral<"ratio">;
|
|
356
|
+
data: z.ZodObject<{
|
|
357
|
+
priceSource: z.ZodEnum<{
|
|
358
|
+
mid: "mid";
|
|
359
|
+
mark: "mark";
|
|
360
|
+
}>;
|
|
361
|
+
symbol_a: z.ZodString;
|
|
362
|
+
symbol_b: z.ZodString;
|
|
363
|
+
track: z.ZodEnum<{
|
|
364
|
+
PEAK: "PEAK";
|
|
365
|
+
TROUGH: "TROUGH";
|
|
366
|
+
}>;
|
|
367
|
+
threshold: z.ZodNumber;
|
|
368
|
+
}, z.core.$strip>;
|
|
369
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
370
|
+
type: z.ZodLiteral<"price">;
|
|
371
|
+
data: z.ZodObject<{
|
|
372
|
+
priceSource: z.ZodEnum<{
|
|
373
|
+
mid: "mid";
|
|
374
|
+
mark: "mark";
|
|
375
|
+
}>;
|
|
376
|
+
symbol: z.ZodString;
|
|
377
|
+
track: z.ZodEnum<{
|
|
378
|
+
PEAK: "PEAK";
|
|
379
|
+
TROUGH: "TROUGH";
|
|
380
|
+
}>;
|
|
381
|
+
threshold: z.ZodNumber;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
384
|
+
type: z.ZodLiteral<"weighted_ratio">;
|
|
385
|
+
data: z.ZodObject<{
|
|
386
|
+
priceSource: z.ZodEnum<{
|
|
387
|
+
mid: "mid";
|
|
388
|
+
mark: "mark";
|
|
389
|
+
}>;
|
|
390
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
391
|
+
symbol: z.ZodString;
|
|
392
|
+
side: z.ZodEnum<{
|
|
393
|
+
BUY: "BUY";
|
|
394
|
+
SELL: "SELL";
|
|
395
|
+
}>;
|
|
396
|
+
weight: z.ZodNumber;
|
|
397
|
+
}, z.core.$strip>>;
|
|
398
|
+
track: z.ZodEnum<{
|
|
399
|
+
PEAK: "PEAK";
|
|
400
|
+
TROUGH: "TROUGH";
|
|
401
|
+
}>;
|
|
402
|
+
threshold: z.ZodNumber;
|
|
403
|
+
}, z.core.$strip>;
|
|
404
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
405
|
+
type: z.ZodLiteral<"funding_rate">;
|
|
406
|
+
data: z.ZodObject<{
|
|
407
|
+
connector: z.ZodEnum<{
|
|
408
|
+
hyperliquid: "hyperliquid";
|
|
409
|
+
binance: "binance";
|
|
410
|
+
bybit: "bybit";
|
|
411
|
+
okx: "okx";
|
|
412
|
+
lighter: "lighter";
|
|
413
|
+
}>;
|
|
414
|
+
symbol: z.ZodString;
|
|
415
|
+
track: z.ZodEnum<{
|
|
416
|
+
PEAK: "PEAK";
|
|
417
|
+
TROUGH: "TROUGH";
|
|
418
|
+
}>;
|
|
419
|
+
threshold: z.ZodNumber;
|
|
420
|
+
}, z.core.$strip>;
|
|
421
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
422
|
+
type: z.ZodLiteral<"prediction_market">;
|
|
423
|
+
data: z.ZodObject<{
|
|
424
|
+
source: z.ZodEnum<{
|
|
425
|
+
kalshi: "kalshi";
|
|
426
|
+
polymarket: "polymarket";
|
|
427
|
+
}>;
|
|
428
|
+
marketKey: z.ZodString;
|
|
429
|
+
track: z.ZodEnum<{
|
|
430
|
+
PEAK: "PEAK";
|
|
431
|
+
TROUGH: "TROUGH";
|
|
432
|
+
}>;
|
|
433
|
+
threshold: z.ZodNumber;
|
|
434
|
+
}, z.core.$strip>;
|
|
435
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
436
|
+
type: z.ZodLiteral<"btc_dominance">;
|
|
437
|
+
data: z.ZodObject<{
|
|
438
|
+
source: z.ZodLiteral<"coingecko">;
|
|
439
|
+
track: z.ZodEnum<{
|
|
440
|
+
PEAK: "PEAK";
|
|
441
|
+
TROUGH: "TROUGH";
|
|
442
|
+
}>;
|
|
443
|
+
threshold: z.ZodNumber;
|
|
444
|
+
}, z.core.$strip>;
|
|
445
|
+
}, z.core.$strip>], "type">;
|
|
446
|
+
payload: z.ZodObject<{
|
|
447
|
+
type: z.ZodLiteral<"MARKET">;
|
|
448
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
449
|
+
symbol: z.ZodString;
|
|
450
|
+
side: z.ZodEnum<{
|
|
451
|
+
BUY: "BUY";
|
|
452
|
+
SELL: "SELL";
|
|
453
|
+
}>;
|
|
454
|
+
mode: z.ZodEnum<{
|
|
455
|
+
QUANTITY: "QUANTITY";
|
|
456
|
+
USD: "USD";
|
|
457
|
+
}>;
|
|
458
|
+
amount: z.ZodString;
|
|
459
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
460
|
+
symbol: z.ZodString;
|
|
461
|
+
side: z.ZodEnum<{
|
|
462
|
+
BUY: "BUY";
|
|
463
|
+
SELL: "SELL";
|
|
464
|
+
}>;
|
|
465
|
+
mode: z.ZodEnum<{
|
|
466
|
+
QUANTITY: "QUANTITY";
|
|
467
|
+
USD: "USD";
|
|
468
|
+
}>;
|
|
469
|
+
amount: z.ZodString;
|
|
470
|
+
}, z.core.$strict>>;
|
|
471
|
+
}, z.core.$strict>;
|
|
472
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
473
|
+
}, z.core.$strict>;
|
|
350
474
|
export declare const CreateTriggerMarketCloseStatic: z.ZodObject<{
|
|
351
475
|
intent: z.ZodLiteral<"CLOSE">;
|
|
352
476
|
type: z.ZodLiteral<"MARKET">;
|
|
@@ -828,7 +952,7 @@ export declare const CreateTriggerOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
828
952
|
USD: "USD";
|
|
829
953
|
}>;
|
|
830
954
|
amount: z.ZodString;
|
|
831
|
-
}, z.core.$
|
|
955
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
832
956
|
symbol: z.ZodString;
|
|
833
957
|
side: z.ZodEnum<{
|
|
834
958
|
BUY: "BUY";
|
|
@@ -839,10 +963,133 @@ export declare const CreateTriggerOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
839
963
|
USD: "USD";
|
|
840
964
|
}>;
|
|
841
965
|
amount: z.ZodString;
|
|
842
|
-
}, z.core.$
|
|
843
|
-
}, z.core.$
|
|
966
|
+
}, z.core.$strict>>;
|
|
967
|
+
}, z.core.$strict>;
|
|
968
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
969
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
970
|
+
intent: z.ZodLiteral<"ADJUST">;
|
|
971
|
+
type: z.ZodLiteral<"MARKET">;
|
|
972
|
+
positionId: z.ZodUUID;
|
|
973
|
+
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
974
|
+
type: z.ZodLiteral<"ratio">;
|
|
975
|
+
data: z.ZodObject<{
|
|
976
|
+
priceSource: z.ZodEnum<{
|
|
977
|
+
mid: "mid";
|
|
978
|
+
mark: "mark";
|
|
979
|
+
}>;
|
|
980
|
+
symbol_a: z.ZodString;
|
|
981
|
+
symbol_b: z.ZodString;
|
|
982
|
+
track: z.ZodEnum<{
|
|
983
|
+
PEAK: "PEAK";
|
|
984
|
+
TROUGH: "TROUGH";
|
|
985
|
+
}>;
|
|
986
|
+
threshold: z.ZodNumber;
|
|
987
|
+
}, z.core.$strip>;
|
|
988
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
989
|
+
type: z.ZodLiteral<"price">;
|
|
990
|
+
data: z.ZodObject<{
|
|
991
|
+
priceSource: z.ZodEnum<{
|
|
992
|
+
mid: "mid";
|
|
993
|
+
mark: "mark";
|
|
994
|
+
}>;
|
|
995
|
+
symbol: z.ZodString;
|
|
996
|
+
track: z.ZodEnum<{
|
|
997
|
+
PEAK: "PEAK";
|
|
998
|
+
TROUGH: "TROUGH";
|
|
999
|
+
}>;
|
|
1000
|
+
threshold: z.ZodNumber;
|
|
1001
|
+
}, z.core.$strip>;
|
|
1002
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1003
|
+
type: z.ZodLiteral<"weighted_ratio">;
|
|
1004
|
+
data: z.ZodObject<{
|
|
1005
|
+
priceSource: z.ZodEnum<{
|
|
1006
|
+
mid: "mid";
|
|
1007
|
+
mark: "mark";
|
|
1008
|
+
}>;
|
|
1009
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
1010
|
+
symbol: z.ZodString;
|
|
1011
|
+
side: z.ZodEnum<{
|
|
1012
|
+
BUY: "BUY";
|
|
1013
|
+
SELL: "SELL";
|
|
1014
|
+
}>;
|
|
1015
|
+
weight: z.ZodNumber;
|
|
1016
|
+
}, z.core.$strip>>;
|
|
1017
|
+
track: z.ZodEnum<{
|
|
1018
|
+
PEAK: "PEAK";
|
|
1019
|
+
TROUGH: "TROUGH";
|
|
1020
|
+
}>;
|
|
1021
|
+
threshold: z.ZodNumber;
|
|
1022
|
+
}, z.core.$strip>;
|
|
1023
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1024
|
+
type: z.ZodLiteral<"funding_rate">;
|
|
1025
|
+
data: z.ZodObject<{
|
|
1026
|
+
connector: z.ZodEnum<{
|
|
1027
|
+
hyperliquid: "hyperliquid";
|
|
1028
|
+
binance: "binance";
|
|
1029
|
+
bybit: "bybit";
|
|
1030
|
+
okx: "okx";
|
|
1031
|
+
lighter: "lighter";
|
|
1032
|
+
}>;
|
|
1033
|
+
symbol: z.ZodString;
|
|
1034
|
+
track: z.ZodEnum<{
|
|
1035
|
+
PEAK: "PEAK";
|
|
1036
|
+
TROUGH: "TROUGH";
|
|
1037
|
+
}>;
|
|
1038
|
+
threshold: z.ZodNumber;
|
|
1039
|
+
}, z.core.$strip>;
|
|
1040
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1041
|
+
type: z.ZodLiteral<"prediction_market">;
|
|
1042
|
+
data: z.ZodObject<{
|
|
1043
|
+
source: z.ZodEnum<{
|
|
1044
|
+
kalshi: "kalshi";
|
|
1045
|
+
polymarket: "polymarket";
|
|
1046
|
+
}>;
|
|
1047
|
+
marketKey: z.ZodString;
|
|
1048
|
+
track: z.ZodEnum<{
|
|
1049
|
+
PEAK: "PEAK";
|
|
1050
|
+
TROUGH: "TROUGH";
|
|
1051
|
+
}>;
|
|
1052
|
+
threshold: z.ZodNumber;
|
|
1053
|
+
}, z.core.$strip>;
|
|
1054
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1055
|
+
type: z.ZodLiteral<"btc_dominance">;
|
|
1056
|
+
data: z.ZodObject<{
|
|
1057
|
+
source: z.ZodLiteral<"coingecko">;
|
|
1058
|
+
track: z.ZodEnum<{
|
|
1059
|
+
PEAK: "PEAK";
|
|
1060
|
+
TROUGH: "TROUGH";
|
|
1061
|
+
}>;
|
|
1062
|
+
threshold: z.ZodNumber;
|
|
1063
|
+
}, z.core.$strip>;
|
|
1064
|
+
}, z.core.$strip>], "type">;
|
|
1065
|
+
payload: z.ZodObject<{
|
|
1066
|
+
type: z.ZodLiteral<"MARKET">;
|
|
1067
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
1068
|
+
symbol: z.ZodString;
|
|
1069
|
+
side: z.ZodEnum<{
|
|
1070
|
+
BUY: "BUY";
|
|
1071
|
+
SELL: "SELL";
|
|
1072
|
+
}>;
|
|
1073
|
+
mode: z.ZodEnum<{
|
|
1074
|
+
QUANTITY: "QUANTITY";
|
|
1075
|
+
USD: "USD";
|
|
1076
|
+
}>;
|
|
1077
|
+
amount: z.ZodString;
|
|
1078
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
1079
|
+
symbol: z.ZodString;
|
|
1080
|
+
side: z.ZodEnum<{
|
|
1081
|
+
BUY: "BUY";
|
|
1082
|
+
SELL: "SELL";
|
|
1083
|
+
}>;
|
|
1084
|
+
mode: z.ZodEnum<{
|
|
1085
|
+
QUANTITY: "QUANTITY";
|
|
1086
|
+
USD: "USD";
|
|
1087
|
+
}>;
|
|
1088
|
+
amount: z.ZodString;
|
|
1089
|
+
}, z.core.$strict>>;
|
|
1090
|
+
}, z.core.$strict>;
|
|
844
1091
|
clientId: z.ZodOptional<z.ZodString>;
|
|
845
|
-
}, z.core.$
|
|
1092
|
+
}, z.core.$strict>], "intent">;
|
|
846
1093
|
export declare const CreateTriggerClose: z.ZodUnion<readonly [z.ZodObject<{
|
|
847
1094
|
intent: z.ZodLiteral<"CLOSE">;
|
|
848
1095
|
type: z.ZodLiteral<"MARKET">;
|
|
@@ -994,6 +1241,7 @@ export declare const CreateTriggerClose: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
994
1241
|
clientId: z.ZodOptional<z.ZodString>;
|
|
995
1242
|
}, z.core.$strip>]>;
|
|
996
1243
|
export type CreateTriggerMarketOpen = z.output<typeof CreateTriggerMarketOpen>;
|
|
1244
|
+
export type CreateTriggerMarketAdjust = z.output<typeof CreateTriggerMarketAdjust>;
|
|
997
1245
|
export type CreateTriggerMarketCloseStatic = z.output<typeof CreateTriggerMarketCloseStatic>;
|
|
998
1246
|
export type CreateTriggerMarketCloseTrailing = z.output<typeof CreateTriggerMarketCloseTrailing>;
|
|
999
1247
|
export type CreateTriggerMarketClose = z.output<typeof CreateTriggerMarketClose>;
|
|
@@ -8,6 +8,10 @@ import { RefineTrailingConfig, RefineTrailingLogicalRules } from '../refinement/
|
|
|
8
8
|
import { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing } from './conditions';
|
|
9
9
|
import { MAX_ATTACH_TRIGGERS } from './config';
|
|
10
10
|
|
|
11
|
+
const CreateTriggerMarketPayload = z.object({
|
|
12
|
+
type: z.literal("MARKET"),
|
|
13
|
+
legs: z.tuple([TradeLegPostOnly.strict()]).rest(TradeLegPostOnly.strict()).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
|
|
14
|
+
}).strict();
|
|
11
15
|
const TrailingConfig = z.object({
|
|
12
16
|
mode: TrailingMode,
|
|
13
17
|
deltaValue: z.number(),
|
|
@@ -39,15 +43,23 @@ const CreateTriggerMarketOpen = z.object({
|
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
45
|
}).optional(),
|
|
42
|
-
payload:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
payload: CreateTriggerMarketPayload,
|
|
47
|
+
/**
|
|
48
|
+
* Attribution route code (client_ids.code)
|
|
49
|
+
*/
|
|
50
|
+
clientId: ClientIdCode
|
|
51
|
+
}).strict();
|
|
52
|
+
const CreateTriggerMarketAdjust = z.object({
|
|
53
|
+
intent: z.literal("ADJUST"),
|
|
54
|
+
type: z.literal("MARKET"),
|
|
55
|
+
positionId: z.uuid(),
|
|
56
|
+
condition: CreateTriggerConditionOpen,
|
|
57
|
+
payload: CreateTriggerMarketPayload,
|
|
46
58
|
/**
|
|
47
59
|
* Attribution route code (client_ids.code)
|
|
48
60
|
*/
|
|
49
61
|
clientId: ClientIdCode
|
|
50
|
-
});
|
|
62
|
+
}).strict();
|
|
51
63
|
const CreateTriggerMarketCloseStatic = z.object({
|
|
52
64
|
intent: z.literal("CLOSE"),
|
|
53
65
|
type: z.literal("MARKET"),
|
|
@@ -71,10 +83,10 @@ const CreateTriggerMarketCloseTrailing = z.object({
|
|
|
71
83
|
clientId: ClientIdCode
|
|
72
84
|
}).superRefine(RefineTrailingLogicalRules);
|
|
73
85
|
const CreateTriggerMarketClose = z.union([CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing]);
|
|
74
|
-
const CreateTriggerOpen = z.discriminatedUnion("
|
|
86
|
+
const CreateTriggerOpen = z.discriminatedUnion("intent", [CreateTriggerMarketOpen, CreateTriggerMarketAdjust]);
|
|
75
87
|
const CreateTriggerClose = CreateTriggerMarketClose;
|
|
76
88
|
function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
|
|
77
89
|
return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|
|
92
|
+
export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketAdjust, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|