@pear-protocol/types 2.2.0 → 2.3.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/bundle.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './auth';
2
2
  export * from './baskets/recommended';
3
3
  export * from './baskets/saved';
4
+ export * from './common/address';
4
5
  export * from './common/trade-legs';
5
6
  export * from './connector';
6
7
  export * from './execution';
package/dist/bundle.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './auth';
2
2
  export * from './baskets/recommended';
3
3
  export * from './baskets/saved';
4
+ export * from './common/address';
4
5
  export * from './common/trade-legs';
5
6
  export * from './connector';
6
7
  export * from './execution';
@@ -456,3 +456,123 @@ export declare const OpenPosition: z.ZodObject<{
456
456
  }, z.core.$strip>>>;
457
457
  }, z.core.$strip>;
458
458
  export type OpenPosition = z.output<typeof OpenPosition>;
459
+ /**
460
+ * The public, vault-scoped view of one open leg: what it has booked and what it still
461
+ * holds, with fees and funding withheld. Built by allowlist so a field added to
462
+ * `OpenPositionLeg` never reaches the public wire without a deliberate decision.
463
+ */
464
+ export declare const VaultOpenPositionLeg: z.ZodObject<{
465
+ side: z.ZodEnum<{
466
+ LONG: "LONG";
467
+ SHORT: "SHORT";
468
+ }>;
469
+ asset: z.ZodString;
470
+ realized: z.ZodObject<{
471
+ quantity: z.ZodString;
472
+ unpricedQuantity: z.ZodString;
473
+ exitVwap: z.ZodOptional<z.ZodString>;
474
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
475
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
476
+ }, z.core.$strip>;
477
+ remaining: z.ZodObject<{
478
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
479
+ entryVwap: z.ZodOptional<z.ZodString>;
480
+ }, z.core.$strip>;
481
+ }, z.core.$strip>;
482
+ export type VaultOpenPositionLeg = z.output<typeof VaultOpenPositionLeg>;
483
+ /**
484
+ * The public, vault-scoped view of one open position: position-level economics plus the
485
+ * reduced legs. No fee splits, no funding, no exposure sizing, no data-quality flags, no
486
+ * steps. Funding is withheld because attributing it replays the account's funding history
487
+ * since the position opened — a cost the anonymous route must not carry. Same allowlist
488
+ * rule as the leg — see `VaultOpenPositionLeg`.
489
+ */
490
+ export declare const VaultOpenPosition: z.ZodObject<{
491
+ status: z.ZodLiteral<"OPEN">;
492
+ connector: z.ZodEnum<{
493
+ hyperliquid: "hyperliquid";
494
+ binance: "binance";
495
+ bybit: "bybit";
496
+ okx: "okx";
497
+ lighter: "lighter";
498
+ lighter_rhc: "lighter_rhc";
499
+ }>;
500
+ updatedAt: z.ZodString;
501
+ positionId: z.ZodUUID;
502
+ openedAt: z.ZodString;
503
+ realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
504
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
505
+ legs: z.ZodArray<z.ZodObject<{
506
+ side: z.ZodEnum<{
507
+ LONG: "LONG";
508
+ SHORT: "SHORT";
509
+ }>;
510
+ asset: z.ZodString;
511
+ realized: z.ZodObject<{
512
+ quantity: z.ZodString;
513
+ unpricedQuantity: z.ZodString;
514
+ exitVwap: z.ZodOptional<z.ZodString>;
515
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
516
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
517
+ }, z.core.$strip>;
518
+ remaining: z.ZodObject<{
519
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
520
+ entryVwap: z.ZodOptional<z.ZodString>;
521
+ }, z.core.$strip>;
522
+ }, z.core.$strip>>;
523
+ }, z.core.$strip>;
524
+ export type VaultOpenPosition = z.output<typeof VaultOpenPosition>;
525
+ /**
526
+ * The public, vault-scoped view of one closed leg: entry, exit and PnL, with fees, funding
527
+ * and committed-cash figures withheld. Same allowlist rule as `VaultOpenPositionLeg`.
528
+ */
529
+ export declare const VaultClosedPositionLeg: z.ZodObject<{
530
+ side: z.ZodEnum<{
531
+ LONG: "LONG";
532
+ SHORT: "SHORT";
533
+ }>;
534
+ asset: z.ZodString;
535
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
536
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
537
+ entryVwap: z.ZodOptional<z.ZodString>;
538
+ exitVwap: z.ZodOptional<z.ZodString>;
539
+ }, z.core.$strip>;
540
+ export type VaultClosedPositionLeg = z.output<typeof VaultClosedPositionLeg>;
541
+ /**
542
+ * The public, vault-scoped view of one closed position: lifecycle, position-level PnL and
543
+ * the reduced legs. Funding is withheld for the same reason as on `VaultOpenPosition`;
544
+ * `netPnl` never folds it in, so the published figures stay exact without it.
545
+ */
546
+ export declare const VaultClosedPosition: z.ZodObject<{
547
+ status: z.ZodLiteral<"CLOSED">;
548
+ connector: z.ZodEnum<{
549
+ hyperliquid: "hyperliquid";
550
+ binance: "binance";
551
+ bybit: "bybit";
552
+ okx: "okx";
553
+ lighter: "lighter";
554
+ lighter_rhc: "lighter_rhc";
555
+ }>;
556
+ closedReason: z.ZodOptional<z.ZodEnum<{
557
+ NETTED: "NETTED";
558
+ USER: "USER";
559
+ LIQUIDATED: "LIQUIDATED";
560
+ }>>;
561
+ closedAt: z.ZodString;
562
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
563
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
564
+ positionId: z.ZodUUID;
565
+ openedAt: z.ZodString;
566
+ legs: z.ZodArray<z.ZodObject<{
567
+ side: z.ZodEnum<{
568
+ LONG: "LONG";
569
+ SHORT: "SHORT";
570
+ }>;
571
+ asset: z.ZodString;
572
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
573
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
574
+ entryVwap: z.ZodOptional<z.ZodString>;
575
+ exitVwap: z.ZodOptional<z.ZodString>;
576
+ }, z.core.$strip>>;
577
+ }, z.core.$strip>;
578
+ export type VaultClosedPosition = z.output<typeof VaultClosedPosition>;
@@ -372,5 +372,42 @@ const OpenPosition = z.object({
372
372
  */
373
373
  steps: z.array(PositionStep).optional()
374
374
  });
375
+ const VaultOpenPositionLeg = OpenPositionLeg.pick({
376
+ asset: true,
377
+ side: true,
378
+ realized: true,
379
+ remaining: true
380
+ });
381
+ const VaultOpenPosition = OpenPosition.pick({
382
+ positionId: true,
383
+ status: true,
384
+ connector: true,
385
+ openedAt: true,
386
+ updatedAt: true,
387
+ realizedGrossPnl: true,
388
+ netCashflow: true
389
+ }).extend({
390
+ legs: z.array(VaultOpenPositionLeg)
391
+ });
392
+ const VaultClosedPositionLeg = ClosedPositionLeg.pick({
393
+ asset: true,
394
+ side: true,
395
+ entryVwap: true,
396
+ exitVwap: true,
397
+ grossPnl: true,
398
+ netPnl: true
399
+ });
400
+ const VaultClosedPosition = ClosedPosition.pick({
401
+ positionId: true,
402
+ status: true,
403
+ connector: true,
404
+ openedAt: true,
405
+ closedAt: true,
406
+ closedReason: true,
407
+ grossPnl: true,
408
+ netPnl: true
409
+ }).extend({
410
+ legs: z.array(VaultClosedPositionLeg)
411
+ });
375
412
 
376
- export { ClosedPosition, ClosedPositionLeg, ClosedPositionLegSide, OpenPosition, OpenPositionLeg, Position, PositionClosedReason, PositionEntryPrices, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionStep, PositionStepLeg, PositionTotalFundingPayment };
413
+ export { ClosedPosition, ClosedPositionLeg, ClosedPositionLegSide, OpenPosition, OpenPositionLeg, Position, PositionClosedReason, PositionEntryPrices, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionStep, PositionStepLeg, PositionTotalFundingPayment, VaultClosedPosition, VaultClosedPositionLeg, VaultOpenPosition, VaultOpenPositionLeg };
@@ -50,3 +50,31 @@ export declare const OpenPositionListParams: z.ZodObject<{
50
50
  }, z.core.$strip>;
51
51
  export type OpenPositionListParamsInput = z.input<typeof OpenPositionListParams>;
52
52
  export type OpenPositionListParams = z.output<typeof OpenPositionListParams>;
53
+ /**
54
+ * Public vault open-position page.
55
+ *
56
+ * The vault is named by the path, never by an account id, and the page cannot be
57
+ * narrowed to one position or asked for steps: the public surface is a bounded
58
+ * history read only. Strict so an attempt to pass a private-route filter is refused
59
+ * rather than silently ignored.
60
+ */
61
+ export declare const VaultOpenPositionListParams: z.ZodObject<{
62
+ cursor: z.ZodOptional<z.ZodString>;
63
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
64
+ }, z.core.$strict>;
65
+ export type VaultOpenPositionListParamsInput = z.input<typeof VaultOpenPositionListParams>;
66
+ export type VaultOpenPositionListParams = z.output<typeof VaultOpenPositionListParams>;
67
+ /**
68
+ * Public vault closed-position page.
69
+ *
70
+ * Keeps the private route's close-time bounds and cap; drops `positionId` and
71
+ * `includeSteps` for the same reason as the open sibling.
72
+ */
73
+ export declare const VaultClosedPositionListParams: z.ZodObject<{
74
+ cursor: z.ZodOptional<z.ZodString>;
75
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
76
+ startDate: z.ZodOptional<z.ZodString>;
77
+ endDate: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>;
79
+ export type VaultClosedPositionListParamsInput = z.input<typeof VaultClosedPositionListParams>;
80
+ export type VaultClosedPositionListParams = z.output<typeof VaultClosedPositionListParams>;
@@ -94,5 +94,16 @@ const OpenPositionListParams = CursorFindParams.extend({
94
94
  ],
95
95
  message: "includeSteps requires positionId"
96
96
  });
97
+ const VaultOpenPositionListParams = CursorFindParams.extend({
98
+ /** Same cap as the private open history: every row drags its fills along. */
99
+ limit: z.coerce.number().int().positive().max(200).optional().default(20)
100
+ }).strict();
101
+ const VaultClosedPositionListParams = CursorFindParams.extend({
102
+ /** Same cap as the private closed history: every row drags its fills along. */
103
+ limit: z.coerce.number().int().positive().max(200).optional().default(20),
104
+ /** Inclusive bounds on the close time, exactly as `ClosedPositionListParams` defines them. */
105
+ startDate: z.string().optional(),
106
+ endDate: z.string().optional()
107
+ }).strict();
97
108
 
98
- export { ClosedPositionListParams, OpenPositionListParams, PositionListParams };
109
+ export { ClosedPositionListParams, OpenPositionListParams, PositionListParams, VaultClosedPositionListParams, VaultOpenPositionListParams };
@@ -294,3 +294,94 @@ export declare const OpenPositionListResponse: z.ZodObject<{
294
294
  }, z.core.$strip>>;
295
295
  }, z.core.$strip>;
296
296
  export type OpenPositionListResponse = z.output<typeof OpenPositionListResponse>;
297
+ /**
298
+ * A public page of one vault's open positions, newest opened first.
299
+ *
300
+ * `vaultAddress` echoes the resolved (lowercased) vault so a client paging several
301
+ * vaults can tell the pages apart. Same paging rule as the private history: page until
302
+ * `nextCursor` is absent, never until a page comes back short.
303
+ */
304
+ export declare const VaultOpenPositionListResponse: z.ZodObject<{
305
+ limit: z.ZodNumber;
306
+ nextCursor: z.ZodOptional<z.ZodString>;
307
+ vaultAddress: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
308
+ positions: z.ZodArray<z.ZodObject<{
309
+ status: z.ZodLiteral<"OPEN">;
310
+ connector: z.ZodEnum<{
311
+ hyperliquid: "hyperliquid";
312
+ binance: "binance";
313
+ bybit: "bybit";
314
+ okx: "okx";
315
+ lighter: "lighter";
316
+ lighter_rhc: "lighter_rhc";
317
+ }>;
318
+ updatedAt: z.ZodString;
319
+ positionId: z.ZodUUID;
320
+ openedAt: z.ZodString;
321
+ realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
322
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
323
+ legs: z.ZodArray<z.ZodObject<{
324
+ side: z.ZodEnum<{
325
+ LONG: "LONG";
326
+ SHORT: "SHORT";
327
+ }>;
328
+ asset: z.ZodString;
329
+ realized: z.ZodObject<{
330
+ quantity: z.ZodString;
331
+ unpricedQuantity: z.ZodString;
332
+ exitVwap: z.ZodOptional<z.ZodString>;
333
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
334
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
335
+ }, z.core.$strip>;
336
+ remaining: z.ZodObject<{
337
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
338
+ entryVwap: z.ZodOptional<z.ZodString>;
339
+ }, z.core.$strip>;
340
+ }, z.core.$strip>>;
341
+ }, z.core.$strip>>;
342
+ }, z.core.$strip>;
343
+ export type VaultOpenPositionListResponse = z.output<typeof VaultOpenPositionListResponse>;
344
+ /**
345
+ * A public page of one vault's closed positions, newest close first.
346
+ *
347
+ * A page may hold fewer than `limit` positions and still return a `nextCursor`, for the
348
+ * same reason as `ClosedPositionListResponse`. Page until `nextCursor` is absent.
349
+ */
350
+ export declare const VaultClosedPositionListResponse: z.ZodObject<{
351
+ limit: z.ZodNumber;
352
+ nextCursor: z.ZodOptional<z.ZodString>;
353
+ vaultAddress: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
354
+ positions: z.ZodArray<z.ZodObject<{
355
+ status: z.ZodLiteral<"CLOSED">;
356
+ connector: z.ZodEnum<{
357
+ hyperliquid: "hyperliquid";
358
+ binance: "binance";
359
+ bybit: "bybit";
360
+ okx: "okx";
361
+ lighter: "lighter";
362
+ lighter_rhc: "lighter_rhc";
363
+ }>;
364
+ closedReason: z.ZodOptional<z.ZodEnum<{
365
+ NETTED: "NETTED";
366
+ USER: "USER";
367
+ LIQUIDATED: "LIQUIDATED";
368
+ }>>;
369
+ closedAt: z.ZodString;
370
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
371
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
372
+ positionId: z.ZodUUID;
373
+ openedAt: z.ZodString;
374
+ legs: z.ZodArray<z.ZodObject<{
375
+ side: z.ZodEnum<{
376
+ LONG: "LONG";
377
+ SHORT: "SHORT";
378
+ }>;
379
+ asset: z.ZodString;
380
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
381
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
382
+ entryVwap: z.ZodOptional<z.ZodString>;
383
+ exitVwap: z.ZodOptional<z.ZodString>;
384
+ }, z.core.$strip>>;
385
+ }, z.core.$strip>>;
386
+ }, z.core.$strip>;
387
+ export type VaultClosedPositionListResponse = z.output<typeof VaultClosedPositionListResponse>;
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { CursorResponse } from '../common';
3
+ import { EthereumAddress } from '../common/address';
3
4
  import { SignedDecimalString } from '../common/schema';
4
5
  import { Connector } from '../connector';
5
6
  import { InstrumentId } from '../instrument';
6
- import { Position, PositionOrigin, ClosedPosition, OpenPosition } from './entities';
7
+ import { Position, PositionOrigin, ClosedPosition, OpenPosition, VaultOpenPosition, VaultClosedPosition } from './entities';
7
8
 
8
9
  const PositionListResponse = CursorResponse.extend({
9
10
  positions: z.array(Position)
@@ -26,5 +27,13 @@ const ClosedPositionListResponse = CursorResponse.extend({
26
27
  const OpenPositionListResponse = CursorResponse.extend({
27
28
  positions: z.array(OpenPosition)
28
29
  });
30
+ const VaultOpenPositionListResponse = CursorResponse.extend({
31
+ vaultAddress: EthereumAddress,
32
+ positions: z.array(VaultOpenPosition)
33
+ });
34
+ const VaultClosedPositionListResponse = CursorResponse.extend({
35
+ vaultAddress: EthereumAddress,
36
+ positions: z.array(VaultClosedPosition)
37
+ });
29
38
 
30
- export { ClosedPositionListResponse, OpenPositionListResponse, OpenPositionLite, OpenPositionLiteListResponse, PositionListResponse };
39
+ export { ClosedPositionListResponse, OpenPositionListResponse, OpenPositionLite, OpenPositionLiteListResponse, PositionListResponse, VaultClosedPositionListResponse, VaultOpenPositionListResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",