@pear-protocol/types 1.8.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.
@@ -7,6 +7,6 @@ export declare const PaginatedResponse: z.ZodObject<{
7
7
  export type PaginatedResponse = z.output<typeof PaginatedResponse>;
8
8
  export declare const CursorResponse: z.ZodObject<{
9
9
  limit: z.ZodNumber;
10
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
10
+ nextCursor: z.ZodOptional<z.ZodString>;
11
11
  }, z.core.$strip>;
12
12
  export type CursorResponse = z.output<typeof CursorResponse>;
@@ -22,7 +22,7 @@ const CursorResponse = z.object({
22
22
  /**
23
23
  * The cursor to use for pagination.
24
24
  */
25
- nextCursor: z.string().or(z.undefined())
25
+ nextCursor: z.string().optional()
26
26
  });
27
27
 
28
28
  export { CursorResponse, PaginatedResponse };
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const ExecutionListResponse: z.ZodObject<{
3
3
  limit: z.ZodNumber;
4
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
4
+ nextCursor: z.ZodOptional<z.ZodString>;
5
5
  executions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
6
6
  id: z.ZodUUID;
7
7
  connector: z.ZodEnum<{
@@ -279,3 +279,281 @@ export declare const ExecutionListResponse: z.ZodObject<{
279
279
  }, z.core.$strip>], "intent">], "orderType">>;
280
280
  }, z.core.$strip>;
281
281
  export type ExecutionListResponse = z.output<typeof ExecutionListResponse>;
282
+ export declare const GetExecutionResponse: z.ZodObject<{
283
+ execution: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
284
+ id: z.ZodUUID;
285
+ connector: z.ZodEnum<{
286
+ hyperliquid: "hyperliquid";
287
+ binance: "binance";
288
+ bybit: "bybit";
289
+ okx: "okx";
290
+ lighter: "lighter";
291
+ }>;
292
+ status: z.ZodEnum<{
293
+ CANCELLED: "CANCELLED";
294
+ IDLE: "IDLE";
295
+ ACTIVE: "ACTIVE";
296
+ COMPLETED: "COMPLETED";
297
+ FAILED: "FAILED";
298
+ }>;
299
+ error: z.ZodOptional<z.ZodString>;
300
+ createdAt: z.ZodString;
301
+ updatedAt: z.ZodString;
302
+ orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
303
+ id: z.ZodUUID;
304
+ connector: z.ZodEnum<{
305
+ hyperliquid: "hyperliquid";
306
+ binance: "binance";
307
+ bybit: "bybit";
308
+ okx: "okx";
309
+ lighter: "lighter";
310
+ }>;
311
+ status: z.ZodEnum<{
312
+ PENDING: "PENDING";
313
+ PARTIAL: "PARTIAL";
314
+ FILLED: "FILLED";
315
+ CANCELLED: "CANCELLED";
316
+ REJECTED: "REJECTED";
317
+ }>;
318
+ error: z.ZodOptional<z.ZodString>;
319
+ createdAt: z.ZodString;
320
+ updatedAt: z.ZodString;
321
+ type: z.ZodLiteral<"MARKET">;
322
+ symbol: z.ZodString;
323
+ side: z.ZodEnum<{
324
+ BUY: "BUY";
325
+ SELL: "SELL";
326
+ }>;
327
+ reduceOnly: z.ZodBoolean;
328
+ leverage: z.ZodInt;
329
+ quantity: z.ZodString;
330
+ price: z.ZodString;
331
+ filledQuantity: z.ZodString;
332
+ filledPrice: z.ZodOptional<z.ZodString>;
333
+ }, z.core.$strip>], "type">>>;
334
+ intent: z.ZodLiteral<"OPEN">;
335
+ orderType: z.ZodLiteral<"MARKET">;
336
+ legs: z.ZodTuple<[z.ZodObject<{
337
+ symbol: z.ZodString;
338
+ side: z.ZodEnum<{
339
+ BUY: "BUY";
340
+ SELL: "SELL";
341
+ }>;
342
+ mode: z.ZodEnum<{
343
+ QUANTITY: "QUANTITY";
344
+ USD: "USD";
345
+ }>;
346
+ amount: z.ZodString;
347
+ reduceOnly: z.ZodBoolean;
348
+ }, z.core.$strip>], z.ZodObject<{
349
+ symbol: z.ZodString;
350
+ side: z.ZodEnum<{
351
+ BUY: "BUY";
352
+ SELL: "SELL";
353
+ }>;
354
+ mode: z.ZodEnum<{
355
+ QUANTITY: "QUANTITY";
356
+ USD: "USD";
357
+ }>;
358
+ amount: z.ZodString;
359
+ reduceOnly: z.ZodBoolean;
360
+ }, z.core.$strip>>;
361
+ }, z.core.$strip>, z.ZodObject<{
362
+ id: z.ZodUUID;
363
+ connector: z.ZodEnum<{
364
+ hyperliquid: "hyperliquid";
365
+ binance: "binance";
366
+ bybit: "bybit";
367
+ okx: "okx";
368
+ lighter: "lighter";
369
+ }>;
370
+ status: z.ZodEnum<{
371
+ CANCELLED: "CANCELLED";
372
+ IDLE: "IDLE";
373
+ ACTIVE: "ACTIVE";
374
+ COMPLETED: "COMPLETED";
375
+ FAILED: "FAILED";
376
+ }>;
377
+ error: z.ZodOptional<z.ZodString>;
378
+ createdAt: z.ZodString;
379
+ updatedAt: z.ZodString;
380
+ orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
381
+ id: z.ZodUUID;
382
+ connector: z.ZodEnum<{
383
+ hyperliquid: "hyperliquid";
384
+ binance: "binance";
385
+ bybit: "bybit";
386
+ okx: "okx";
387
+ lighter: "lighter";
388
+ }>;
389
+ status: z.ZodEnum<{
390
+ PENDING: "PENDING";
391
+ PARTIAL: "PARTIAL";
392
+ FILLED: "FILLED";
393
+ CANCELLED: "CANCELLED";
394
+ REJECTED: "REJECTED";
395
+ }>;
396
+ error: z.ZodOptional<z.ZodString>;
397
+ createdAt: z.ZodString;
398
+ updatedAt: z.ZodString;
399
+ type: z.ZodLiteral<"MARKET">;
400
+ symbol: z.ZodString;
401
+ side: z.ZodEnum<{
402
+ BUY: "BUY";
403
+ SELL: "SELL";
404
+ }>;
405
+ reduceOnly: z.ZodBoolean;
406
+ leverage: z.ZodInt;
407
+ quantity: z.ZodString;
408
+ price: z.ZodString;
409
+ filledQuantity: z.ZodString;
410
+ filledPrice: z.ZodOptional<z.ZodString>;
411
+ }, z.core.$strip>], "type">>>;
412
+ intent: z.ZodLiteral<"ADJUST">;
413
+ orderType: z.ZodLiteral<"MARKET">;
414
+ position: z.ZodObject<{
415
+ id: z.ZodUUID;
416
+ exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
417
+ }, z.core.$strip>;
418
+ legs: z.ZodTuple<[z.ZodObject<{
419
+ symbol: z.ZodString;
420
+ side: z.ZodEnum<{
421
+ BUY: "BUY";
422
+ SELL: "SELL";
423
+ }>;
424
+ mode: z.ZodEnum<{
425
+ QUANTITY: "QUANTITY";
426
+ USD: "USD";
427
+ }>;
428
+ amount: z.ZodString;
429
+ reduceOnly: z.ZodBoolean;
430
+ }, z.core.$strip>], z.ZodObject<{
431
+ symbol: z.ZodString;
432
+ side: z.ZodEnum<{
433
+ BUY: "BUY";
434
+ SELL: "SELL";
435
+ }>;
436
+ mode: z.ZodEnum<{
437
+ QUANTITY: "QUANTITY";
438
+ USD: "USD";
439
+ }>;
440
+ amount: z.ZodString;
441
+ reduceOnly: z.ZodBoolean;
442
+ }, z.core.$strip>>;
443
+ }, z.core.$strip>, z.ZodObject<{
444
+ id: z.ZodUUID;
445
+ connector: z.ZodEnum<{
446
+ hyperliquid: "hyperliquid";
447
+ binance: "binance";
448
+ bybit: "bybit";
449
+ okx: "okx";
450
+ lighter: "lighter";
451
+ }>;
452
+ status: z.ZodEnum<{
453
+ CANCELLED: "CANCELLED";
454
+ IDLE: "IDLE";
455
+ ACTIVE: "ACTIVE";
456
+ COMPLETED: "COMPLETED";
457
+ FAILED: "FAILED";
458
+ }>;
459
+ error: z.ZodOptional<z.ZodString>;
460
+ createdAt: z.ZodString;
461
+ updatedAt: z.ZodString;
462
+ orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
463
+ id: z.ZodUUID;
464
+ connector: z.ZodEnum<{
465
+ hyperliquid: "hyperliquid";
466
+ binance: "binance";
467
+ bybit: "bybit";
468
+ okx: "okx";
469
+ lighter: "lighter";
470
+ }>;
471
+ status: z.ZodEnum<{
472
+ PENDING: "PENDING";
473
+ PARTIAL: "PARTIAL";
474
+ FILLED: "FILLED";
475
+ CANCELLED: "CANCELLED";
476
+ REJECTED: "REJECTED";
477
+ }>;
478
+ error: z.ZodOptional<z.ZodString>;
479
+ createdAt: z.ZodString;
480
+ updatedAt: z.ZodString;
481
+ type: z.ZodLiteral<"MARKET">;
482
+ symbol: z.ZodString;
483
+ side: z.ZodEnum<{
484
+ BUY: "BUY";
485
+ SELL: "SELL";
486
+ }>;
487
+ reduceOnly: z.ZodBoolean;
488
+ leverage: z.ZodInt;
489
+ quantity: z.ZodString;
490
+ price: z.ZodString;
491
+ filledQuantity: z.ZodString;
492
+ filledPrice: z.ZodOptional<z.ZodString>;
493
+ }, z.core.$strip>], "type">>>;
494
+ intent: z.ZodLiteral<"CLOSE">;
495
+ orderType: z.ZodLiteral<"MARKET">;
496
+ position: z.ZodObject<{
497
+ id: z.ZodUUID;
498
+ exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
499
+ }, z.core.$strip>;
500
+ }, z.core.$strip>, z.ZodObject<{
501
+ id: z.ZodUUID;
502
+ connector: z.ZodEnum<{
503
+ hyperliquid: "hyperliquid";
504
+ binance: "binance";
505
+ bybit: "bybit";
506
+ okx: "okx";
507
+ lighter: "lighter";
508
+ }>;
509
+ status: z.ZodEnum<{
510
+ CANCELLED: "CANCELLED";
511
+ IDLE: "IDLE";
512
+ ACTIVE: "ACTIVE";
513
+ COMPLETED: "COMPLETED";
514
+ FAILED: "FAILED";
515
+ }>;
516
+ error: z.ZodOptional<z.ZodString>;
517
+ createdAt: z.ZodString;
518
+ updatedAt: z.ZodString;
519
+ orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
520
+ id: z.ZodUUID;
521
+ connector: z.ZodEnum<{
522
+ hyperliquid: "hyperliquid";
523
+ binance: "binance";
524
+ bybit: "bybit";
525
+ okx: "okx";
526
+ lighter: "lighter";
527
+ }>;
528
+ status: z.ZodEnum<{
529
+ PENDING: "PENDING";
530
+ PARTIAL: "PARTIAL";
531
+ FILLED: "FILLED";
532
+ CANCELLED: "CANCELLED";
533
+ REJECTED: "REJECTED";
534
+ }>;
535
+ error: z.ZodOptional<z.ZodString>;
536
+ createdAt: z.ZodString;
537
+ updatedAt: z.ZodString;
538
+ type: z.ZodLiteral<"MARKET">;
539
+ symbol: z.ZodString;
540
+ side: z.ZodEnum<{
541
+ BUY: "BUY";
542
+ SELL: "SELL";
543
+ }>;
544
+ reduceOnly: z.ZodBoolean;
545
+ leverage: z.ZodInt;
546
+ quantity: z.ZodString;
547
+ price: z.ZodString;
548
+ filledQuantity: z.ZodString;
549
+ filledPrice: z.ZodOptional<z.ZodString>;
550
+ }, z.core.$strip>], "type">>>;
551
+ intent: z.ZodLiteral<"REVERSE">;
552
+ orderType: z.ZodLiteral<"MARKET">;
553
+ position: z.ZodObject<{
554
+ id: z.ZodUUID;
555
+ exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
556
+ }, z.core.$strip>;
557
+ }, z.core.$strip>], "intent">], "orderType">;
558
+ }, z.core.$strip>;
559
+ export type GetExecutionResponse = z.output<typeof GetExecutionResponse>;
@@ -5,5 +5,6 @@ import { Execution } from './entities';
5
5
  const ExecutionListResponse = CursorResponse.extend({
6
6
  executions: z.array(Execution)
7
7
  });
8
+ const GetExecutionResponse = z.object({ execution: Execution });
8
9
 
9
- export { ExecutionListResponse };
10
+ export { ExecutionListResponse, GetExecutionResponse };
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const FillListResponse: z.ZodObject<{
3
3
  limit: z.ZodNumber;
4
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
4
+ nextCursor: z.ZodOptional<z.ZodString>;
5
5
  fills: z.ZodArray<z.ZodObject<{
6
6
  id: z.ZodUUID;
7
7
  cloid: z.ZodOptional<z.ZodString>;
@@ -1509,7 +1509,7 @@ export declare const LadderResponse: z.ZodObject<{
1509
1509
  export type LadderResponse = z.output<typeof LadderResponse>;
1510
1510
  export declare const LadderListResponse: z.ZodObject<{
1511
1511
  limit: z.ZodNumber;
1512
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
1512
+ nextCursor: z.ZodOptional<z.ZodString>;
1513
1513
  ladders: z.ZodArray<z.ZodObject<{
1514
1514
  id: z.ZodUUID;
1515
1515
  connector: z.ZodEnum<{
@@ -49,6 +49,14 @@ export type PositionInitialExposureUSD = z.infer<typeof PositionInitialExposureU
49
49
  */
50
50
  export declare const PositionTotalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
51
51
  export type PositionTotalFundingPayment = z.infer<typeof PositionTotalFundingPayment>;
52
+ /**
53
+ * Weighted-average entry (cost-basis) price for each asset in the position, derived from the
54
+ * fills ledger. An instrument is absent when it has no fill history to derive a cost basis from.
55
+ *
56
+ * @example { '0': '95000' } means BTC's cost basis is 95000 USD.
57
+ */
58
+ export declare const PositionEntryPrices: z.ZodRecord<z.ZodString, z.ZodString>;
59
+ export type PositionEntryPrices = z.infer<typeof PositionEntryPrices>;
52
60
  export declare const Position: z.ZodObject<{
53
61
  id: z.ZodUUID;
54
62
  tradeAccountId: z.ZodUUID;
@@ -77,6 +85,7 @@ export declare const Position: z.ZodObject<{
77
85
  totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
78
86
  closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
87
  initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
88
+ entryPrices: z.ZodRecord<z.ZodString, z.ZodString>;
80
89
  createdAt: z.ZodString;
81
90
  updatedAt: z.ZodString;
82
91
  }, z.core.$strip>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { SignedDecimalString } from '../common/schema';
2
+ import { SignedDecimalString, UnsignedDecimalString } from '../common/schema';
3
3
  import { Connector } from '../connector';
4
4
  import { InstrumentId } from '../instrument';
5
5
 
@@ -9,6 +9,7 @@ const PositionOrigin = z.enum(["PEAR", "EXTERNAL", "PARTIAL"]);
9
9
  const PositionExposure = z.record(InstrumentId, SignedDecimalString);
10
10
  const PositionInitialExposureUSD = z.record(InstrumentId, SignedDecimalString);
11
11
  const PositionTotalFundingPayment = z.record(InstrumentId, SignedDecimalString);
12
+ const PositionEntryPrices = z.record(InstrumentId, UnsignedDecimalString);
12
13
  const Position = z.object({
13
14
  /**
14
15
  * Position UUID
@@ -46,8 +47,14 @@ const Position = z.object({
46
47
  * on adjustments, and is only used for UI purposes.
47
48
  */
48
49
  initialExposureUSD: PositionInitialExposureUSD,
50
+ /**
51
+ * Per-instrument entry (cost-basis) price, derived from the fills ledger. Unlike
52
+ * initialExposureUSD, this DOES account for adjustments — it is the live weighted-average
53
+ * entry price of the current exposure.
54
+ */
55
+ entryPrices: PositionEntryPrices,
49
56
  createdAt: z.string(),
50
57
  updatedAt: z.string()
51
58
  });
52
59
 
53
- export { Position, PositionClosedReason, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionTotalFundingPayment };
60
+ export { Position, PositionClosedReason, PositionEntryPrices, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionTotalFundingPayment };
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const PositionListResponse: z.ZodObject<{
3
3
  limit: z.ZodNumber;
4
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
4
+ nextCursor: z.ZodOptional<z.ZodString>;
5
5
  positions: z.ZodArray<z.ZodObject<{
6
6
  id: z.ZodUUID;
7
7
  tradeAccountId: z.ZodUUID;
@@ -30,6 +30,7 @@ export declare const PositionListResponse: z.ZodObject<{
30
30
  totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
31
31
  closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
32
  initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
33
+ entryPrices: z.ZodRecord<z.ZodString, z.ZodString>;
33
34
  createdAt: z.ZodString;
34
35
  updatedAt: z.ZodString;
35
36
  }, z.core.$strip>>;
@@ -16,7 +16,7 @@ export declare const RebalanceManualResponse: z.ZodObject<{
16
16
  export type RebalanceManualResponse = z.output<typeof RebalanceManualResponse>;
17
17
  export declare const AutoRebalanceListResponse: z.ZodObject<{
18
18
  limit: z.ZodNumber;
19
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
19
+ nextCursor: z.ZodOptional<z.ZodString>;
20
20
  items: z.ZodArray<z.ZodObject<{
21
21
  id: z.ZodUUID;
22
22
  positionId: z.ZodUUID;
@@ -64,7 +64,7 @@ export declare const CreateAutoRebalanceResponse: z.ZodObject<{
64
64
  export type CreateAutoRebalanceResponse = z.output<typeof CreateAutoRebalanceResponse>;
65
65
  export declare const RebalanceEventListResponse: z.ZodObject<{
66
66
  limit: z.ZodNumber;
67
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
67
+ nextCursor: z.ZodOptional<z.ZodString>;
68
68
  items: z.ZodArray<z.ZodObject<{
69
69
  id: z.ZodUUID;
70
70
  autoRebalanceConfigId: z.ZodUUID;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- declare const CreateTWAPOpen: z.ZodObject<{
2
+ export declare const CreateTWAPOpen: z.ZodObject<{
3
3
  startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
4
4
  endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
5
5
  strategy: z.ZodLiteral<"TWAP">;
@@ -21,7 +21,7 @@ declare const CreateTWAPOpen: z.ZodObject<{
21
21
  sliceIntervalSec: z.ZodInt;
22
22
  clientId: z.ZodOptional<z.ZodString>;
23
23
  }, z.core.$strip>;
24
- declare const CreateTWAPClose: z.ZodObject<{
24
+ export declare const CreateTWAPClose: z.ZodObject<{
25
25
  startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
26
26
  endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
27
27
  strategy: z.ZodLiteral<"TWAP">;
@@ -73,4 +73,3 @@ export declare const CreateSchedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
73
73
  export type CreateTWAPOpen = z.output<typeof CreateTWAPOpen>;
74
74
  export type CreateTWAPClose = z.output<typeof CreateTWAPClose>;
75
75
  export type CreateSchedule = z.output<typeof CreateSchedule>;
76
- export {};
@@ -112,4 +112,4 @@ const CreateTWAPClose = BaseSchedule.safeExtend({
112
112
  });
113
113
  const CreateSchedule = z.discriminatedUnion("intent", [CreateTWAPOpen, CreateTWAPClose]);
114
114
 
115
- export { CreateSchedule };
115
+ export { CreateSchedule, CreateTWAPClose, CreateTWAPOpen };
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const ScheduleListResponse: z.ZodObject<{
3
3
  limit: z.ZodNumber;
4
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
4
+ nextCursor: z.ZodOptional<z.ZodString>;
5
5
  schedules: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
6
6
  id: z.ZodUUID;
7
7
  connector: z.ZodEnum<{
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  export declare const TriggerIntent: z.ZodEnum<{
3
3
  OPEN: "OPEN";
4
4
  CLOSE: "CLOSE";
5
+ ADJUST: "ADJUST";
5
6
  }>;
6
7
  export type TriggerIntent = z.infer<typeof TriggerIntent>;
7
8
  export declare const TriggerStatus: z.ZodEnum<{
@@ -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.$strip>], z.ZodObject<{
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.$strip>>;
347
- }, z.core.$strip>;
346
+ }, z.core.$strict>>;
347
+ }, z.core.$strict>;
348
348
  clientId: z.ZodOptional<z.ZodString>;
349
- }, z.core.$strip>;
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.$strip>], z.ZodObject<{
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.$strip>>;
843
- }, z.core.$strip>;
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.$strip>], "type">;
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: z.object({
43
- type: z.literal("MARKET"),
44
- legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
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("type", [CreateTriggerMarketOpen]);
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 };
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const TriggerListResponse: z.ZodObject<{
3
3
  limit: z.ZodNumber;
4
- nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
4
+ nextCursor: z.ZodOptional<z.ZodString>;
5
5
  triggers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
6
6
  id: z.ZodUUID;
7
7
  tradeAccountId: z.ZodUUID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",