@pear-protocol/types 1.4.0 → 1.6.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.
Files changed (41) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.js +1 -0
  3. package/dist/common/schema.d.ts +2 -0
  4. package/dist/common/schema.js +2 -1
  5. package/dist/fill/entities.d.ts +1 -0
  6. package/dist/fill/entities.js +8 -16
  7. package/dist/fill/responses.d.ts +2 -0
  8. package/dist/ladder/entities.d.ts +3 -0
  9. package/dist/ladder/responses.d.ts +9 -0
  10. package/dist/position/entities.d.ts +29 -0
  11. package/dist/position/entities.js +5 -7
  12. package/dist/position/responses.d.ts +18 -2
  13. package/dist/position/responses.js +4 -2
  14. package/dist/rebalance/entities.d.ts +64 -0
  15. package/dist/rebalance/entities.js +33 -0
  16. package/dist/rebalance/index.d.ts +2 -0
  17. package/dist/rebalance/index.js +2 -0
  18. package/dist/rebalance/payloads.d.ts +48 -2
  19. package/dist/rebalance/payloads.js +24 -2
  20. package/dist/rebalance/queries.d.ts +22 -0
  21. package/dist/rebalance/queries.js +20 -0
  22. package/dist/rebalance/responses.d.ts +82 -5
  23. package/dist/rebalance/responses.js +22 -4
  24. package/dist/saved-baskets/entities.d.ts +32 -0
  25. package/dist/saved-baskets/entities.js +18 -0
  26. package/dist/saved-baskets/index.d.ts +3 -0
  27. package/dist/saved-baskets/index.js +3 -0
  28. package/dist/saved-baskets/payloads.d.ts +39 -0
  29. package/dist/saved-baskets/payloads.js +16 -0
  30. package/dist/saved-baskets/responses.d.ts +73 -0
  31. package/dist/saved-baskets/responses.js +14 -0
  32. package/dist/schedule/entities.d.ts +5 -0
  33. package/dist/schedule/responses.d.ts +4 -0
  34. package/dist/sync/payloads.d.ts +251 -71
  35. package/dist/sync/payloads.js +84 -32
  36. package/dist/sync/responses.d.ts +7 -4
  37. package/dist/sync/responses.js +9 -4
  38. package/dist/trigger/entities/index.d.ts +10 -0
  39. package/dist/trigger/payloads/conditions.js +1 -2
  40. package/dist/trigger/responses.d.ts +6 -0
  41. package/package.json +1 -1
@@ -1,10 +1,87 @@
1
1
  import { z } from 'zod';
2
- export declare const RebalanceManuallyResponse: z.ZodObject<{
3
- plan: z.ZodUnion<readonly [z.ZodObject<{
2
+ export declare const RebalanceManualResponse: z.ZodObject<{
3
+ plan: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
4
  outcome: z.ZodLiteral<"full_rebalance">;
5
5
  }, z.core.$strip>, z.ZodObject<{
6
- outcome: z.ZodUnion<readonly [z.ZodLiteral<"partial_rebalance">, z.ZodLiteral<"no_rebalance">]>;
6
+ outcome: z.ZodLiteral<"partial_rebalance">;
7
7
  messages: z.ZodTuple<[z.ZodString], z.ZodString>;
8
- }, z.core.$strip>]>;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ outcome: z.ZodLiteral<"no_rebalance">;
10
+ messages: z.ZodTuple<[z.ZodString], z.ZodString>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ outcome: z.ZodLiteral<"failed">;
13
+ messages: z.ZodTuple<[z.ZodString], z.ZodString>;
14
+ }, z.core.$strip>], "outcome">;
15
+ }, z.core.$strip>;
16
+ export type RebalanceManualResponse = z.output<typeof RebalanceManualResponse>;
17
+ export declare const AutoRebalanceListResponse: z.ZodObject<{
18
+ limit: z.ZodNumber;
19
+ nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
20
+ items: z.ZodArray<z.ZodObject<{
21
+ id: z.ZodUUID;
22
+ positionId: z.ZodUUID;
23
+ status: z.ZodEnum<{
24
+ ACTIVE: "ACTIVE";
25
+ PAUSED: "PAUSED";
26
+ }>;
27
+ weightSource: z.ZodEnum<{
28
+ INITIAL_WEIGHT: "INITIAL_WEIGHT";
29
+ LIVE_BETA: "LIVE_BETA";
30
+ }>;
31
+ minimumDriftPct: z.ZodString;
32
+ timeframe: z.ZodOptional<z.ZodEnum<{
33
+ "1d": "1d";
34
+ "1h": "1h";
35
+ "4h": "4h";
36
+ }>>;
37
+ createdAt: z.ZodISODateTime;
38
+ updatedAt: z.ZodISODateTime;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>;
41
+ export type AutoRebalanceListResponse = z.output<typeof AutoRebalanceListResponse>;
42
+ export declare const CreateAutoRebalanceResponse: z.ZodObject<{
43
+ config: z.ZodObject<{
44
+ id: z.ZodUUID;
45
+ positionId: z.ZodUUID;
46
+ status: z.ZodEnum<{
47
+ ACTIVE: "ACTIVE";
48
+ PAUSED: "PAUSED";
49
+ }>;
50
+ weightSource: z.ZodEnum<{
51
+ INITIAL_WEIGHT: "INITIAL_WEIGHT";
52
+ LIVE_BETA: "LIVE_BETA";
53
+ }>;
54
+ minimumDriftPct: z.ZodString;
55
+ timeframe: z.ZodOptional<z.ZodEnum<{
56
+ "1d": "1d";
57
+ "1h": "1h";
58
+ "4h": "4h";
59
+ }>>;
60
+ createdAt: z.ZodISODateTime;
61
+ updatedAt: z.ZodISODateTime;
62
+ }, z.core.$strip>;
63
+ }, z.core.$strip>;
64
+ export type CreateAutoRebalanceResponse = z.output<typeof CreateAutoRebalanceResponse>;
65
+ export declare const RebalanceEventListResponse: z.ZodObject<{
66
+ limit: z.ZodNumber;
67
+ nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
68
+ items: z.ZodArray<z.ZodObject<{
69
+ id: z.ZodUUID;
70
+ autoRebalanceConfigId: z.ZodUUID;
71
+ positionId: z.ZodUUID;
72
+ weightSource: z.ZodEnum<{
73
+ INITIAL_WEIGHT: "INITIAL_WEIGHT";
74
+ LIVE_BETA: "LIVE_BETA";
75
+ }>;
76
+ driftPct: z.ZodString;
77
+ currentWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
78
+ targetWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
79
+ status: z.ZodEnum<{
80
+ FAILED: "FAILED";
81
+ SUCCESS: "SUCCESS";
82
+ }>;
83
+ error: z.ZodOptional<z.ZodString>;
84
+ createdAt: z.ZodISODateTime;
85
+ }, z.core.$strip>>;
9
86
  }, z.core.$strip>;
10
- export type RebalanceManuallyResponse = z.output<typeof RebalanceManuallyResponse>;
87
+ export type RebalanceEventListResponse = z.output<typeof RebalanceEventListResponse>;
@@ -1,15 +1,33 @@
1
1
  import { z } from 'zod';
2
+ import { CursorResponse } from '../common';
3
+ import { AutoRebalanceConfig, RebalanceEvent } from './entities';
2
4
 
3
- const RebalanceManuallyResponse = z.object({
4
- plan: z.union([
5
+ const RebalanceManualResponse = z.object({
6
+ plan: z.discriminatedUnion("outcome", [
5
7
  z.object({
6
8
  outcome: z.literal("full_rebalance")
7
9
  }),
8
10
  z.object({
9
- outcome: z.union([z.literal("partial_rebalance"), z.literal("no_rebalance")]),
11
+ outcome: z.literal("partial_rebalance"),
12
+ messages: z.tuple([z.string()]).rest(z.string())
13
+ }),
14
+ z.object({
15
+ outcome: z.literal("no_rebalance"),
16
+ messages: z.tuple([z.string()]).rest(z.string())
17
+ }),
18
+ // `failed` only occurs on background runs (dispatch/cron); MANUAL execution errors throw and surface as HTTP errors instead.
19
+ z.object({
20
+ outcome: z.literal("failed"),
10
21
  messages: z.tuple([z.string()]).rest(z.string())
11
22
  })
12
23
  ])
13
24
  });
25
+ const AutoRebalanceListResponse = CursorResponse.extend({
26
+ items: z.array(AutoRebalanceConfig)
27
+ });
28
+ const CreateAutoRebalanceResponse = z.object({ config: AutoRebalanceConfig });
29
+ const RebalanceEventListResponse = CursorResponse.extend({
30
+ items: z.array(RebalanceEvent)
31
+ });
14
32
 
15
- export { RebalanceManuallyResponse };
33
+ export { AutoRebalanceListResponse, CreateAutoRebalanceResponse, RebalanceEventListResponse, RebalanceManualResponse };
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare const SavedBasketLeg: z.ZodObject<{
3
+ symbol: z.ZodString;
4
+ side: z.ZodEnum<{
5
+ BUY: "BUY";
6
+ SELL: "SELL";
7
+ }>;
8
+ weight: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export declare const SavedBasket: z.ZodObject<{
11
+ id: z.ZodUUID;
12
+ name: z.ZodString;
13
+ legs: z.ZodTuple<[z.ZodObject<{
14
+ symbol: z.ZodString;
15
+ side: z.ZodEnum<{
16
+ BUY: "BUY";
17
+ SELL: "SELL";
18
+ }>;
19
+ weight: z.ZodNumber;
20
+ }, z.core.$strip>], z.ZodObject<{
21
+ symbol: z.ZodString;
22
+ side: z.ZodEnum<{
23
+ BUY: "BUY";
24
+ SELL: "SELL";
25
+ }>;
26
+ weight: z.ZodNumber;
27
+ }, z.core.$strip>>;
28
+ createdAt: z.ZodString;
29
+ updatedAt: z.ZodString;
30
+ }, z.core.$strip>;
31
+ export type SavedBasketLeg = z.infer<typeof SavedBasketLeg>;
32
+ export type SavedBasket = z.infer<typeof SavedBasket>;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { Side, AssetWeight } from '../common/schema';
3
+ import { InstrumentId } from '../instrument';
4
+
5
+ const SavedBasketLeg = z.object({
6
+ symbol: InstrumentId,
7
+ side: Side,
8
+ weight: AssetWeight.describe("Share of total gross notional as a fraction (legs sum to 1)")
9
+ });
10
+ const SavedBasket = z.object({
11
+ id: z.uuid(),
12
+ name: z.string(),
13
+ legs: z.tuple([SavedBasketLeg]).rest(SavedBasketLeg),
14
+ createdAt: z.string(),
15
+ updatedAt: z.string()
16
+ });
17
+
18
+ export { SavedBasket, SavedBasketLeg };
@@ -0,0 +1,3 @@
1
+ export * from './entities';
2
+ export * from './payloads';
3
+ export * from './responses';
@@ -0,0 +1,3 @@
1
+ export * from './entities';
2
+ export * from './payloads';
3
+ export * from './responses';
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const CreateSavedBasketPayload: z.ZodObject<{
3
+ name: z.ZodString;
4
+ legs: z.ZodTuple<[z.ZodObject<{
5
+ symbol: z.ZodString;
6
+ side: z.ZodEnum<{
7
+ BUY: "BUY";
8
+ SELL: "SELL";
9
+ }>;
10
+ weight: z.ZodNumber;
11
+ }, z.core.$strip>], z.ZodObject<{
12
+ symbol: z.ZodString;
13
+ side: z.ZodEnum<{
14
+ BUY: "BUY";
15
+ SELL: "SELL";
16
+ }>;
17
+ weight: z.ZodNumber;
18
+ }, z.core.$strip>>;
19
+ }, z.core.$strip>;
20
+ export declare const UpdateSavedBasketPayload: z.ZodObject<{
21
+ name: z.ZodOptional<z.ZodString>;
22
+ legs: z.ZodOptional<z.ZodTuple<[z.ZodObject<{
23
+ symbol: z.ZodString;
24
+ side: z.ZodEnum<{
25
+ BUY: "BUY";
26
+ SELL: "SELL";
27
+ }>;
28
+ weight: z.ZodNumber;
29
+ }, z.core.$strip>], z.ZodObject<{
30
+ symbol: z.ZodString;
31
+ side: z.ZodEnum<{
32
+ BUY: "BUY";
33
+ SELL: "SELL";
34
+ }>;
35
+ weight: z.ZodNumber;
36
+ }, z.core.$strip>>>;
37
+ }, z.core.$strip>;
38
+ export type CreateSavedBasketPayload = z.infer<typeof CreateSavedBasketPayload>;
39
+ export type UpdateSavedBasketPayload = z.infer<typeof UpdateSavedBasketPayload>;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
3
+ import { SavedBasketLeg } from './entities';
4
+
5
+ const SavedBasketName = z.string().trim().min(1, "Name is required").max(48).describe("Display name, unique per trade account (case-insensitive)");
6
+ const SavedBasketLegs = z.tuple([SavedBasketLeg]).rest(SavedBasketLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).refine((value) => value.length <= 20, "Basket must have at most 20 legs").describe("At least one leg, up to 20");
7
+ const CreateSavedBasketPayload = z.object({
8
+ name: SavedBasketName,
9
+ legs: SavedBasketLegs
10
+ }).describe("Save the current basket under a name");
11
+ const UpdateSavedBasketPayload = z.object({
12
+ name: SavedBasketName.optional(),
13
+ legs: SavedBasketLegs.optional()
14
+ }).refine((value) => value.name !== void 0 || value.legs !== void 0, "Provide a name or legs to update").describe("Rename a saved basket and/or replace its legs");
15
+
16
+ export { CreateSavedBasketPayload, UpdateSavedBasketPayload };
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ export declare const SavedBasketListResponse: z.ZodObject<{
3
+ baskets: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodUUID;
5
+ name: z.ZodString;
6
+ legs: z.ZodTuple<[z.ZodObject<{
7
+ symbol: z.ZodString;
8
+ side: z.ZodEnum<{
9
+ BUY: "BUY";
10
+ SELL: "SELL";
11
+ }>;
12
+ weight: z.ZodNumber;
13
+ }, z.core.$strip>], z.ZodObject<{
14
+ symbol: z.ZodString;
15
+ side: z.ZodEnum<{
16
+ BUY: "BUY";
17
+ SELL: "SELL";
18
+ }>;
19
+ weight: z.ZodNumber;
20
+ }, z.core.$strip>>;
21
+ createdAt: z.ZodString;
22
+ updatedAt: z.ZodString;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ export type SavedBasketListResponse = z.output<typeof SavedBasketListResponse>;
26
+ export declare const CreateSavedBasketResponse: z.ZodObject<{
27
+ basket: z.ZodObject<{
28
+ id: z.ZodUUID;
29
+ name: z.ZodString;
30
+ legs: z.ZodTuple<[z.ZodObject<{
31
+ symbol: z.ZodString;
32
+ side: z.ZodEnum<{
33
+ BUY: "BUY";
34
+ SELL: "SELL";
35
+ }>;
36
+ weight: z.ZodNumber;
37
+ }, z.core.$strip>], z.ZodObject<{
38
+ symbol: z.ZodString;
39
+ side: z.ZodEnum<{
40
+ BUY: "BUY";
41
+ SELL: "SELL";
42
+ }>;
43
+ weight: z.ZodNumber;
44
+ }, z.core.$strip>>;
45
+ createdAt: z.ZodString;
46
+ updatedAt: z.ZodString;
47
+ }, z.core.$strip>;
48
+ }, z.core.$strip>;
49
+ export type CreateSavedBasketResponse = z.output<typeof CreateSavedBasketResponse>;
50
+ export declare const UpdateSavedBasketResponse: z.ZodObject<{
51
+ basket: z.ZodObject<{
52
+ id: z.ZodUUID;
53
+ name: z.ZodString;
54
+ legs: z.ZodTuple<[z.ZodObject<{
55
+ symbol: z.ZodString;
56
+ side: z.ZodEnum<{
57
+ BUY: "BUY";
58
+ SELL: "SELL";
59
+ }>;
60
+ weight: z.ZodNumber;
61
+ }, z.core.$strip>], z.ZodObject<{
62
+ symbol: z.ZodString;
63
+ side: z.ZodEnum<{
64
+ BUY: "BUY";
65
+ SELL: "SELL";
66
+ }>;
67
+ weight: z.ZodNumber;
68
+ }, z.core.$strip>>;
69
+ createdAt: z.ZodString;
70
+ updatedAt: z.ZodString;
71
+ }, z.core.$strip>;
72
+ }, z.core.$strip>;
73
+ export type UpdateSavedBasketResponse = z.output<typeof UpdateSavedBasketResponse>;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { SavedBasket } from './entities';
3
+
4
+ const SavedBasketListResponse = z.object({
5
+ baskets: z.array(SavedBasket)
6
+ });
7
+ const CreateSavedBasketResponse = z.object({
8
+ basket: SavedBasket
9
+ });
10
+ const UpdateSavedBasketResponse = z.object({
11
+ basket: SavedBasket
12
+ });
13
+
14
+ export { CreateSavedBasketResponse, SavedBasketListResponse, UpdateSavedBasketResponse };
@@ -114,6 +114,7 @@ declare const BaseSchedule: z.ZodObject<{
114
114
  }>;
115
115
  reduceOnly: z.ZodBoolean;
116
116
  isExternal: z.ZodBoolean;
117
+ synthetic: z.ZodBoolean;
117
118
  quantity: z.ZodString;
118
119
  price: z.ZodString;
119
120
  usd: z.ZodString;
@@ -183,6 +184,7 @@ export declare const TWAPOpen: z.ZodObject<{
183
184
  }>;
184
185
  reduceOnly: z.ZodBoolean;
185
186
  isExternal: z.ZodBoolean;
187
+ synthetic: z.ZodBoolean;
186
188
  quantity: z.ZodString;
187
189
  price: z.ZodString;
188
190
  usd: z.ZodString;
@@ -269,6 +271,7 @@ export declare const TWAPClose: z.ZodObject<{
269
271
  }>;
270
272
  reduceOnly: z.ZodBoolean;
271
273
  isExternal: z.ZodBoolean;
274
+ synthetic: z.ZodBoolean;
272
275
  quantity: z.ZodString;
273
276
  price: z.ZodString;
274
277
  usd: z.ZodString;
@@ -347,6 +350,7 @@ export declare const Schedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
347
350
  }>;
348
351
  reduceOnly: z.ZodBoolean;
349
352
  isExternal: z.ZodBoolean;
353
+ synthetic: z.ZodBoolean;
350
354
  quantity: z.ZodString;
351
355
  price: z.ZodString;
352
356
  usd: z.ZodString;
@@ -432,6 +436,7 @@ export declare const Schedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
432
436
  }>;
433
437
  reduceOnly: z.ZodBoolean;
434
438
  isExternal: z.ZodBoolean;
439
+ synthetic: z.ZodBoolean;
435
440
  quantity: z.ZodString;
436
441
  price: z.ZodString;
437
442
  usd: z.ZodString;
@@ -59,6 +59,7 @@ export declare const ScheduleListResponse: z.ZodObject<{
59
59
  }>;
60
60
  reduceOnly: z.ZodBoolean;
61
61
  isExternal: z.ZodBoolean;
62
+ synthetic: z.ZodBoolean;
62
63
  quantity: z.ZodString;
63
64
  price: z.ZodString;
64
65
  usd: z.ZodString;
@@ -144,6 +145,7 @@ export declare const ScheduleListResponse: z.ZodObject<{
144
145
  }>;
145
146
  reduceOnly: z.ZodBoolean;
146
147
  isExternal: z.ZodBoolean;
148
+ synthetic: z.ZodBoolean;
147
149
  quantity: z.ZodString;
148
150
  price: z.ZodString;
149
151
  usd: z.ZodString;
@@ -225,6 +227,7 @@ export declare const CreateScheduleResponse: z.ZodObject<{
225
227
  }>;
226
228
  reduceOnly: z.ZodBoolean;
227
229
  isExternal: z.ZodBoolean;
230
+ synthetic: z.ZodBoolean;
228
231
  quantity: z.ZodString;
229
232
  price: z.ZodString;
230
233
  usd: z.ZodString;
@@ -310,6 +313,7 @@ export declare const CreateScheduleResponse: z.ZodObject<{
310
313
  }>;
311
314
  reduceOnly: z.ZodBoolean;
312
315
  isExternal: z.ZodBoolean;
316
+ synthetic: z.ZodBoolean;
313
317
  quantity: z.ZodString;
314
318
  price: z.ZodString;
315
319
  usd: z.ZodString;