@pear-protocol/types 2.13.0 → 2.14.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.
@@ -37,6 +37,114 @@ export declare const CopySubscription: z.ZodObject<{
37
37
  endedAt: z.ZodOptional<z.ZodString>;
38
38
  }, z.core.$strip>;
39
39
  export type CopySubscription = z.infer<typeof CopySubscription>;
40
+ /** Active position-lifetime USD totals; mark, basis, or exposure gaps can leave measured PnL partial. */
41
+ export declare const CopySubscriptionMetrics: z.ZodObject<{
42
+ volume: z.ZodString;
43
+ grossRealizedPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
44
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
45
+ fundingPayment: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
46
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
47
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
48
+ totalNetPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
49
+ }, z.core.$strip>;
50
+ export type CopySubscriptionMetrics = z.output<typeof CopySubscriptionMetrics>;
51
+ /** Current subscription with volume, gross PnL, attributed funding, signed fees, and net PnL. */
52
+ export declare const CopySubscriptionWithMetrics: z.ZodObject<{
53
+ id: z.ZodUUID;
54
+ leaderTradeAccountId: z.ZodUUID;
55
+ followerTradeAccountId: z.ZodUUID;
56
+ connector: z.ZodEnum<{
57
+ hyperliquid: "hyperliquid";
58
+ binance: "binance";
59
+ bybit: "bybit";
60
+ okx: "okx";
61
+ lighter: "lighter";
62
+ lighter_rhc: "lighter_rhc";
63
+ }>;
64
+ sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
66
+ }, z.core.$strip>], "mode">;
67
+ createdAt: z.ZodString;
68
+ endedAt: z.ZodOptional<z.ZodString>;
69
+ status: z.ZodLiteral<"ACTIVE">;
70
+ volume: z.ZodString;
71
+ grossRealizedPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
72
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
73
+ fundingPayment: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
74
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
75
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
76
+ totalNetPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
77
+ }, z.core.$strip>;
78
+ export type CopySubscriptionWithMetrics = z.output<typeof CopySubscriptionWithMetrics>;
79
+ /** Ended subscription with lifetime turnover only. */
80
+ export declare const CopyEndedSubscriptionWithVolume: z.ZodObject<{
81
+ id: z.ZodUUID;
82
+ leaderTradeAccountId: z.ZodUUID;
83
+ followerTradeAccountId: z.ZodUUID;
84
+ connector: z.ZodEnum<{
85
+ hyperliquid: "hyperliquid";
86
+ binance: "binance";
87
+ bybit: "bybit";
88
+ okx: "okx";
89
+ lighter: "lighter";
90
+ lighter_rhc: "lighter_rhc";
91
+ }>;
92
+ sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
93
+ mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
94
+ }, z.core.$strip>], "mode">;
95
+ createdAt: z.ZodString;
96
+ endedAt: z.ZodOptional<z.ZodString>;
97
+ status: z.ZodLiteral<"ENDED">;
98
+ volume: z.ZodString;
99
+ }, z.core.$strip>;
100
+ export type CopyEndedSubscriptionWithVolume = z.output<typeof CopyEndedSubscriptionWithVolume>;
101
+ /** Read shape selected by subscription status. */
102
+ export declare const CopySubscriptionRead: z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ id: z.ZodUUID;
104
+ leaderTradeAccountId: z.ZodUUID;
105
+ followerTradeAccountId: z.ZodUUID;
106
+ connector: z.ZodEnum<{
107
+ hyperliquid: "hyperliquid";
108
+ binance: "binance";
109
+ bybit: "bybit";
110
+ okx: "okx";
111
+ lighter: "lighter";
112
+ lighter_rhc: "lighter_rhc";
113
+ }>;
114
+ sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
115
+ mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
116
+ }, z.core.$strip>], "mode">;
117
+ createdAt: z.ZodString;
118
+ endedAt: z.ZodOptional<z.ZodString>;
119
+ status: z.ZodLiteral<"ACTIVE">;
120
+ volume: z.ZodString;
121
+ grossRealizedPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
122
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
123
+ fundingPayment: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
124
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
125
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
126
+ totalNetPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ id: z.ZodUUID;
129
+ leaderTradeAccountId: z.ZodUUID;
130
+ followerTradeAccountId: z.ZodUUID;
131
+ connector: z.ZodEnum<{
132
+ hyperliquid: "hyperliquid";
133
+ binance: "binance";
134
+ bybit: "bybit";
135
+ okx: "okx";
136
+ lighter: "lighter";
137
+ lighter_rhc: "lighter_rhc";
138
+ }>;
139
+ sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
+ mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
141
+ }, z.core.$strip>], "mode">;
142
+ createdAt: z.ZodString;
143
+ endedAt: z.ZodOptional<z.ZodString>;
144
+ status: z.ZodLiteral<"ENDED">;
145
+ volume: z.ZodString;
146
+ }, z.core.$strip>], "status">;
147
+ export type CopySubscriptionRead = z.output<typeof CopySubscriptionRead>;
40
148
  export declare const CopyActivityOutcome: z.ZodEnum<{
41
149
  COPIED: "COPIED";
42
150
  PARTIAL: "PARTIAL";
@@ -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
 
@@ -26,6 +26,27 @@ const CopySubscription = z.object({
26
26
  createdAt: z.string().describe("ISO 8601"),
27
27
  endedAt: z.string().optional().describe("ISO 8601; set once the follower unsubscribed")
28
28
  });
29
+ const CopySubscriptionMetrics = z.object({
30
+ volume: UnsignedDecimalString.describe("Lifetime executed USD turnover across opens and closes; excludes fees and funding"),
31
+ grossRealizedPnl: SignedDecimalString.describe("Gross realized USD PnL over attributed positions, including partial reductions; excludes fees and funding"),
32
+ grossUpnl: SignedDecimalString.describe("Gross unrealized USD PnL on OPEN attributed positions at current marks; missing marks or entry basis can make this total partial; excludes fees and funding"),
33
+ fundingPayment: SignedDecimalString.describe("Signed USD funding attributed from historical exposure snapshots and per-unit payments; absent snapshots contribute no measured funding"),
34
+ tradeFee: SignedDecimalString.describe("Signed USD trade fees on attributed position fills; negative values are rebates"),
35
+ pearFee: SignedDecimalString.describe("Signed USD Pear fees on attributed position fills; negative values are rebates"),
36
+ totalNetPnl: SignedDecimalString.describe("Gross realized plus gross unrealized plus fundingPayment minus tradeFee and pearFee in USD; mark, basis, or exposure gaps can make the measured total partial")
37
+ });
38
+ const CopySubscriptionWithMetrics = CopySubscription.extend({
39
+ ...CopySubscriptionMetrics.shape,
40
+ status: z.literal("ACTIVE")
41
+ });
42
+ const CopyEndedSubscriptionWithVolume = CopySubscription.extend({
43
+ status: z.literal("ENDED"),
44
+ volume: CopySubscriptionMetrics.shape.volume
45
+ });
46
+ const CopySubscriptionRead = z.discriminatedUnion("status", [
47
+ CopySubscriptionWithMetrics,
48
+ CopyEndedSubscriptionWithVolume
49
+ ]);
29
50
  const CopyActivityOutcome = z.enum([
30
51
  "COPIED",
31
52
  "PARTIAL",
@@ -110,4 +131,4 @@ const CopyFollower = z.object({
110
131
  xAvatarUrl: z.string().optional()
111
132
  });
112
133
 
113
- export { CopyActivity, CopyActivityLeg, CopyActivityOutcome, CopyActivityState, CopyExecutionSource, CopyFollower, CopyLeaderAction, CopySizing, CopySkipReason, CopySubscription, CopySubscriptionStatus };
134
+ export { CopyActivity, CopyActivityLeg, CopyActivityOutcome, CopyActivityState, CopyEndedSubscriptionWithVolume, CopyExecutionSource, CopyFollower, CopyLeaderAction, CopySizing, CopySkipReason, CopySubscription, CopySubscriptionMetrics, CopySubscriptionRead, CopySubscriptionStatus, CopySubscriptionWithMetrics };
@@ -1,4 +1,12 @@
1
1
  import { z } from 'zod';
2
+ export declare const CopySubscriptionListQuery: z.ZodObject<{
3
+ status: z.ZodOptional<z.ZodEnum<{
4
+ ACTIVE: "ACTIVE";
5
+ ENDED: "ENDED";
6
+ }>>;
7
+ }, z.core.$strip>;
8
+ export type CopySubscriptionListQueryInput = z.input<typeof CopySubscriptionListQuery>;
9
+ export type CopySubscriptionListQuery = z.output<typeof CopySubscriptionListQuery>;
2
10
  export declare const CopyActivityListParams: z.ZodObject<{
3
11
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
4
12
  }, z.core.$strip>;
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import { CopySubscriptionStatus } from './entities';
2
3
 
4
+ const CopySubscriptionListQuery = z.object({
5
+ status: CopySubscriptionStatus.optional()
6
+ });
3
7
  const CopyActivityListParams = z.object({
4
8
  limit: z.coerce.number().int().min(1).max(200).default(50)
5
9
  });
@@ -13,4 +17,4 @@ const CopyStatsParams = z.object({
13
17
  ]
14
18
  });
15
19
 
16
- export { CopyActivityListParams, CopyStatsParams };
20
+ export { CopyActivityListParams, CopyStatsParams, CopySubscriptionListQuery };
@@ -22,6 +22,13 @@ export declare const CopyStateResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
22
22
  createdAt: z.ZodString;
23
23
  endedAt: z.ZodOptional<z.ZodString>;
24
24
  status: z.ZodLiteral<"ACTIVE">;
25
+ volume: z.ZodString;
26
+ grossRealizedPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
27
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
28
+ fundingPayment: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
29
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
30
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
31
+ totalNetPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
25
32
  }, z.core.$strip>;
26
33
  }, z.core.$strip>], "state">;
27
34
  export type CopyStateResponse = z.output<typeof CopyStateResponse>;
@@ -190,7 +197,7 @@ export declare const CreateCopySubscriptionResponse: z.ZodObject<{
190
197
  }, z.core.$strip>;
191
198
  export type CreateCopySubscriptionResponse = z.output<typeof CreateCopySubscriptionResponse>;
192
199
  export declare const CopySubscriptionListResponse: z.ZodObject<{
193
- subscriptions: z.ZodArray<z.ZodObject<{
200
+ subscriptions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
194
201
  id: z.ZodUUID;
195
202
  leaderTradeAccountId: z.ZodUUID;
196
203
  followerTradeAccountId: z.ZodUUID;
@@ -202,16 +209,39 @@ export declare const CopySubscriptionListResponse: z.ZodObject<{
202
209
  lighter: "lighter";
203
210
  lighter_rhc: "lighter_rhc";
204
211
  }>;
205
- status: z.ZodEnum<{
206
- ACTIVE: "ACTIVE";
207
- ENDED: "ENDED";
212
+ sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
213
+ mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
214
+ }, z.core.$strip>], "mode">;
215
+ createdAt: z.ZodString;
216
+ endedAt: z.ZodOptional<z.ZodString>;
217
+ status: z.ZodLiteral<"ACTIVE">;
218
+ volume: z.ZodString;
219
+ grossRealizedPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
220
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
221
+ fundingPayment: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
222
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
223
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
224
+ totalNetPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
225
+ }, z.core.$strip>, z.ZodObject<{
226
+ id: z.ZodUUID;
227
+ leaderTradeAccountId: z.ZodUUID;
228
+ followerTradeAccountId: z.ZodUUID;
229
+ connector: z.ZodEnum<{
230
+ hyperliquid: "hyperliquid";
231
+ binance: "binance";
232
+ bybit: "bybit";
233
+ okx: "okx";
234
+ lighter: "lighter";
235
+ lighter_rhc: "lighter_rhc";
208
236
  }>;
209
237
  sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
210
238
  mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
211
239
  }, z.core.$strip>], "mode">;
212
240
  createdAt: z.ZodString;
213
241
  endedAt: z.ZodOptional<z.ZodString>;
214
- }, z.core.$strip>>;
242
+ status: z.ZodLiteral<"ENDED">;
243
+ volume: z.ZodString;
244
+ }, z.core.$strip>], "status">>;
215
245
  }, z.core.$strip>;
216
246
  export type CopySubscriptionListResponse = z.output<typeof CopySubscriptionListResponse>;
217
247
  export declare const CopyActivityListResponse: z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { UnsignedDecimalString } from '../common/schema';
3
- import { CopySubscription, CopyFollower, CopySkipReason, CopyActivity, CopySubscriptionStatus } from './entities';
3
+ import { CopySubscriptionWithMetrics, CopyFollower, CopySubscription, CopySkipReason, CopySubscriptionRead, CopyActivity, CopySubscriptionStatus } from './entities';
4
4
 
5
5
  const CopyStateResponse = z.discriminatedUnion("state", [
6
6
  z.object({
@@ -8,9 +8,7 @@ const CopyStateResponse = z.discriminatedUnion("state", [
8
8
  }),
9
9
  z.object({
10
10
  state: z.literal("ACTIVE"),
11
- subscription: CopySubscription.extend({
12
- status: z.literal("ACTIVE")
13
- })
11
+ subscription: CopySubscriptionWithMetrics
14
12
  })
15
13
  ]);
16
14
  const CopyFollowersResponse = z.object({
@@ -52,7 +50,7 @@ const CreateCopySubscriptionResponse = CopySubscriptionResponse.extend({
52
50
  joinResults: z.array(CopyJoinResult)
53
51
  });
54
52
  const CopySubscriptionListResponse = z.object({
55
- subscriptions: z.array(CopySubscription)
53
+ subscriptions: z.array(CopySubscriptionRead)
56
54
  });
57
55
  const CopyActivityListResponse = z.object({
58
56
  activities: z.array(CopyActivity)
@@ -359,11 +359,10 @@ export declare const OpenPositionLeg: z.ZodObject<{
359
359
  }, z.core.$strip>;
360
360
  export type OpenPositionLeg = z.output<typeof OpenPositionLeg>;
361
361
  /**
362
- * The realized view of one open position: the part of it that has already been booked,
363
- * composed server-side from the same math /positions/closed uses.
362
+ * The lifetime economics of one open position, including booked realized PnL and
363
+ * gross unrealized PnL at live marks, composed server-side from shared position math.
364
364
  *
365
- * A pure ledger read — no mark price and therefore no unrealized PnL, which
366
- * /positions and /portfolio's openSnapshot already carry.
365
+ * Its gross unrealized PnL uses current marks where a priced entry basis is known.
367
366
  */
368
367
  export declare const OpenPosition: z.ZodObject<{
369
368
  positionId: z.ZodUUID;
@@ -384,6 +383,8 @@ export declare const OpenPosition: z.ZodObject<{
384
383
  EXTERNAL: "EXTERNAL";
385
384
  }>;
386
385
  realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
386
+ volume: z.ZodString;
387
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
387
388
  netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
388
389
  totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
389
390
  tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
@@ -313,6 +313,10 @@ const OpenPosition = z.object({
313
313
  * live, and revisable while it is — see netCashflow on reconciliation.
314
314
  */
315
315
  realizedGrossPnl: SignedDecimalString,
316
+ /** Lifetime executed USD turnover, including opening and closing fills. */
317
+ volume: UnsignedDecimalString.describe("Lifetime executed USD turnover across opening and closing fills"),
318
+ /** Gross unrealized PnL at current marks; missing marks or entry basis can make this total partial. */
319
+ grossUpnl: SignedDecimalString.describe("Gross unrealized USD PnL at current marks; missing marks or entry basis can make this total partial; excludes fees and funding"),
316
320
  /**
317
321
  * Cash booked so far: realized gross PnL minus every fee charged to date. Not a
318
322
  * settled return on closed quantity — it books every fee charged so far, including
@@ -224,6 +224,8 @@ export declare const OpenPositionListResponse: z.ZodObject<{
224
224
  EXTERNAL: "EXTERNAL";
225
225
  }>;
226
226
  realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
227
+ volume: z.ZodString;
228
+ grossUpnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
227
229
  netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
228
230
  totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
229
231
  tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",