@pear-protocol/types 1.32.0 → 2.0.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.
@@ -71,11 +71,11 @@ const Position = z.object({
71
71
  createdAt: z.string(),
72
72
  updatedAt: z.string()
73
73
  });
74
- const ClosedTradeLegSide = z.enum([
74
+ const ClosedPositionLegSide = z.enum([
75
75
  "LONG",
76
76
  "SHORT"
77
77
  ]);
78
- const ClosedTradeStepLeg = z.discriminatedUnion("kind", [
78
+ const PositionStepLeg = z.discriminatedUnion("kind", [
79
79
  z.object({
80
80
  kind: z.literal("INCREASE"),
81
81
  asset: InstrumentId,
@@ -119,7 +119,7 @@ const ClosedTradeStepLeg = z.discriminatedUnion("kind", [
119
119
  pearFee: SignedDecimalString
120
120
  })
121
121
  ]);
122
- const ClosedTradeStep = z.object({
122
+ const PositionStep = z.object({
123
123
  /**
124
124
  * The execution that placed these fills. Absent when the fills recorded none, in
125
125
  * which case the step was grouped by fill time and is best effort.
@@ -129,11 +129,11 @@ const ClosedTradeStep = z.object({
129
129
  at: z.string(),
130
130
  /** Realized PnL this step booked: the sum of its reductions. "+0" for a pure increase. */
131
131
  grossPnl: SignedDecimalString,
132
- legs: z.array(ClosedTradeStepLeg)
132
+ legs: z.array(PositionStepLeg)
133
133
  });
134
- const ClosedTradeLeg = z.object({
134
+ const ClosedPositionLeg = z.object({
135
135
  asset: InstrumentId,
136
- side: ClosedTradeLegSide,
136
+ side: ClosedPositionLegSide,
137
137
  /** Size-weighted average price the leg opened at. Absent with no priced entry. */
138
138
  entryVwap: UnsignedDecimalString.optional(),
139
139
  /** Size-weighted average price the leg closed at. Absent when nothing closed at a known price. */
@@ -154,6 +154,11 @@ const ClosedTradeLeg = z.object({
154
154
  * wants the leg's all-in result adds the two.
155
155
  */
156
156
  funding: SignedDecimalString,
157
+ /**
158
+ * Peak cash this leg alone had committed at one time — the leg's ROI denominator.
159
+ * "0" is an omission sentinel, not free entry: a zero-price synthetic opened part of
160
+ * the leg's basis, so its committed cash is unknowable and no return divides by it.
161
+ */
157
162
  entryNotional: UnsignedDecimalString,
158
163
  /**
159
164
  * Size closed at a known price. With undeterminedSize this accounts for every unit
@@ -168,9 +173,11 @@ const ClosedTradeLeg = z.object({
168
173
  */
169
174
  undeterminedSize: UnsignedDecimalString
170
175
  });
171
- const ClosedTrade = z.object({
176
+ const ClosedPosition = z.object({
172
177
  positionId: z.uuid(),
173
178
  connector: Connector,
179
+ /** Lifecycle tag naming which history shape this row carries; each endpoint serves one of them. */
180
+ status: z.literal("CLOSED"),
174
181
  /** When the position opened. */
175
182
  openedAt: z.string(),
176
183
  /** When the position closed. Falls back to the last update for rows that never recorded a close. */
@@ -183,15 +190,20 @@ const ClosedTrade = z.object({
183
190
  tradeFees: SignedDecimalString,
184
191
  pearFees: SignedDecimalString,
185
192
  /**
186
- * Funding attributed to the whole trade (signed; negative = net paid).
193
+ * Funding attributed to the whole position (signed; negative = net paid).
187
194
  *
188
195
  * Totals every asset the position carried exposure on, which can exceed the sum of
189
196
  * the legs: funding follows exposure, and an asset with exposure but no confirmed
190
- * fill earns no leg. Summing the legs instead would understate what the trade paid.
197
+ * fill earns no leg. Summing the legs instead would understate what the position paid.
191
198
  *
192
199
  * Reported beside netPnl, never folded into it. See the leg field's note.
193
200
  */
194
201
  totalFunding: SignedDecimalString,
202
+ /**
203
+ * Peak cash the whole position had committed at one time — the ROI denominator.
204
+ * "0" is an omission sentinel, not free entry: a zero-price synthetic opened part of
205
+ * the basis, so committed cash is unknowable and clients must not divide by it.
206
+ */
195
207
  entryNotional: UnsignedDecimalString,
196
208
  /**
197
209
  * Proceeds of the priced closes. Understates whenever part of the position closed
@@ -212,7 +224,7 @@ const ClosedTrade = z.object({
212
224
  unstableHistoricalData: z.boolean(),
213
225
  longAssets: z.array(InstrumentId),
214
226
  shortAssets: z.array(InstrumentId),
215
- legs: z.array(ClosedTradeLeg),
227
+ legs: z.array(ClosedPositionLeg),
216
228
  /**
217
229
  * What happened to the position, oldest first: the open, every add, every reduction
218
230
  * and the close. `legs` says how each asset finished; this says how it got there.
@@ -221,7 +233,144 @@ const ClosedTrade = z.object({
221
233
  * per recorded action, so a heavily traded position produces a long one. `openedAt`
222
234
  * carries the open time that step 1 would otherwise have been the only source of.
223
235
  */
224
- steps: z.array(ClosedTradeStep).optional()
236
+ steps: z.array(PositionStep).optional()
237
+ });
238
+ const OpenPositionLeg = z.object({
239
+ asset: InstrumentId,
240
+ side: ClosedPositionLegSide,
241
+ /** Everything the leg has already closed. */
242
+ realized: z.object({
243
+ /**
244
+ * Size closed at a known price so far. With `unpricedQuantity` this accounts for
245
+ * every unit the leg has closed.
246
+ */
247
+ quantity: UnsignedDecimalString,
248
+ /**
249
+ * Closed size whose PnL is unpriceable, because it closed against a 0-price
250
+ * synthetic or against an entry basis that was itself unpriced. It contributes
251
+ * nothing to `grossPnl` or `exitVwap`.
252
+ */
253
+ unpricedQuantity: UnsignedDecimalString,
254
+ /** Size-weighted average price the leg has reduced at so far. Absent when nothing closed at a known price. */
255
+ exitVwap: UnsignedDecimalString.optional(),
256
+ /** PnL booked so far, before fees. */
257
+ grossPnl: SignedDecimalString,
258
+ /**
259
+ * PnL booked so far, after every fee charged to date. Entry fees are charged in
260
+ * full at entry — including on size that has not closed yet — so this understates
261
+ * until the leg is flat. Lead with `grossPnl` for a live reading.
262
+ */
263
+ netPnl: SignedDecimalString
264
+ }),
265
+ /**
266
+ * What the leg still holds: the inputs to an unrealized figure, never the figure itself.
267
+ */
268
+ remaining: z.object({
269
+ /**
270
+ * The quantity the leg still holds, signed the way `PositionExposure` signs
271
+ * exposure: `+6` for a long remainder, `-4` for a short one, so a consumer
272
+ * never has to recombine with `side` before doing arithmetic. "+0" is a real
273
+ * answer: a leg can walk to flat while the position it belongs to stays open.
274
+ */
275
+ quantity: SignedDecimalString,
276
+ /**
277
+ * Weighted-average price that remaining quantity was opened at. Absent when the
278
+ * leg is flat, and absent when what remains was opened against an unpriceable
279
+ * basis — `quantity` tells the two absences apart.
280
+ */
281
+ entryVwap: UnsignedDecimalString.optional()
282
+ }),
283
+ /** Signed: a venue maker rebate makes a fee negative. Charged across the leg's whole life. */
284
+ totalFees: SignedDecimalString,
285
+ tradeFees: SignedDecimalString,
286
+ pearFees: SignedDecimalString,
287
+ /**
288
+ * Funding attributed to this leg so far (signed; negative = net paid).
289
+ *
290
+ * Reported beside realized.netPnl, never folded into it — the same rule as
291
+ * ClosedPositionLeg. A caller that wants the leg's all-in result adds the two.
292
+ *
293
+ * Best-effort: funding payments carry no position id, so attribution walks
294
+ * exposure snapshots and under-attributes whenever untracked or external
295
+ * exposure shared the account. The account-level funding total is authoritative.
296
+ */
297
+ funding: SignedDecimalString
298
+ });
299
+ const OpenPosition = z.object({
300
+ positionId: z.uuid(),
301
+ connector: Connector,
302
+ /** Lifecycle tag naming which history shape this row carries; each endpoint serves one of them. */
303
+ status: z.literal("OPEN"),
304
+ /** When the position opened — the immutable primary sort key for this history. */
305
+ openedAt: z.string(),
306
+ /** The position's last update, independent of the page cursor. */
307
+ updatedAt: z.string(),
308
+ origin: PositionOrigin,
309
+ /**
310
+ * Realized PnL booked so far, before fees. Qualified because the position is still
311
+ * live, and revisable while it is — see netCashflow on reconciliation.
312
+ */
313
+ realizedGrossPnl: SignedDecimalString,
314
+ /**
315
+ * Cash booked so far: realized gross PnL minus every fee charged to date. Not a
316
+ * settled return on closed quantity — it books every fee charged so far, including
317
+ * entry fees on still-open size. Fee timing distorts it in two directions while
318
+ * open: entry fees are charged in full at entry (understates), and a provisional
319
+ * fill carries no fees yet (overstates). A provisional fill also revises its own
320
+ * price and quantity when it reconciles, so this and realizedGrossPnl can each
321
+ * change between two reads of a position that did not trade in between. Equals
322
+ * /positions/closed's netPnl once the position is flat. Lead with realizedGrossPnl
323
+ * for a live reading.
324
+ */
325
+ netCashflow: SignedDecimalString,
326
+ totalFees: SignedDecimalString,
327
+ tradeFees: SignedDecimalString,
328
+ pearFees: SignedDecimalString,
329
+ /**
330
+ * Funding attributed to the position so far (signed; negative = net paid).
331
+ *
332
+ * Totals every asset the position carried exposure on, which can exceed the sum
333
+ * of the legs: funding follows exposure, and an asset with exposure but no fill
334
+ * earns no leg. Reported beside netCashflow, never folded into it.
335
+ *
336
+ * Best-effort: funding payments carry no position id, so attribution walks
337
+ * exposure snapshots and under-attributes whenever untracked or external
338
+ * exposure shared the account. The account-level funding total is authoritative.
339
+ */
340
+ totalFunding: SignedDecimalString,
341
+ /**
342
+ * The exposure expressed in USD at the time the position was opened. It does not
343
+ * change on adjustments, and is only used for UI purposes — exactly the figure
344
+ * /positions reports.
345
+ */
346
+ initialExposureUSD: PositionInitialExposureUSD,
347
+ /** Whether any fill on the position was a synthetic bridge fill (gap/gone reconstruction). */
348
+ hasSyntheticFills: z.boolean(),
349
+ /**
350
+ * Whether any fill on the position is still PROVISIONAL — the runtime flag that
351
+ * this row's economics are still settling, since a UI cannot read a JSDoc caveat.
352
+ * Independent of hasSyntheticFills: a row can have either, both or neither.
353
+ */
354
+ hasProvisionalFills: z.boolean(),
355
+ /** Whether a backfilled fill made this position's historical metrics unreliable. */
356
+ unstableHistoricalData: z.boolean(),
357
+ /**
358
+ * Every asset the ledger recorded, each carrying its own side.
359
+ *
360
+ * Unlike ClosedPosition there is no separate longAssets / shortAssets pair: the two would
361
+ * restate exactly what the legs already say. They survive on the closed shape because
362
+ * portfolio analytics keys its pair breakdown on them; nothing keys anything on this
363
+ * endpoint. A caller wanting the basket sides groups the legs by `side`.
364
+ */
365
+ legs: z.array(OpenPositionLeg),
366
+ /**
367
+ * What has happened to the position so far, oldest first. The step shape is
368
+ * status-agnostic — it describes what a fill did, and an open position's history
369
+ * is made of the same actions — so both histories use PositionStep verbatim.
370
+ *
371
+ * Absent unless the request asks for it, because the array is unbounded.
372
+ */
373
+ steps: z.array(PositionStep).optional()
225
374
  });
226
375
 
227
- export { ClosedTrade, ClosedTradeLeg, ClosedTradeLegSide, ClosedTradeStep, ClosedTradeStepLeg, Position, PositionClosedReason, PositionEntryPrices, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionTotalFundingPayment };
376
+ export { ClosedPosition, ClosedPositionLeg, ClosedPositionLegSide, OpenPosition, OpenPositionLeg, Position, PositionClosedReason, PositionEntryPrices, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionStep, PositionStepLeg, PositionTotalFundingPayment };
@@ -18,7 +18,7 @@ export declare const PositionListParams: z.ZodObject<{
18
18
  export type PositionListParamsInput = z.input<typeof PositionListParams>;
19
19
  export type PositionListParams = z.output<typeof PositionListParams>;
20
20
  /**
21
- * Closed-trade history page.
21
+ * Closed-position history page.
22
22
  *
23
23
  * Ordering is fixed at newest-closed-first, so there is no `orderBy`: one order keeps
24
24
  * the cursor and the supporting index single-purpose. The connector comes from the
@@ -29,7 +29,23 @@ export declare const ClosedPositionListParams: z.ZodObject<{
29
29
  limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
30
30
  startDate: z.ZodOptional<z.ZodString>;
31
31
  endDate: z.ZodOptional<z.ZodString>;
32
+ positionId: z.ZodOptional<z.ZodUUID>;
32
33
  includeSteps: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCodec<z.ZodString, z.ZodBoolean>]>>>;
33
34
  }, z.core.$strip>;
34
35
  export type ClosedPositionListParamsInput = z.input<typeof ClosedPositionListParams>;
35
36
  export type ClosedPositionListParams = z.output<typeof ClosedPositionListParams>;
37
+ /**
38
+ * Open-position history page.
39
+ *
40
+ * Cursor-paginated like the closed history, ordered newest-created-first. No date
41
+ * bounds — an open position has no close time to bound by. The connector comes from
42
+ * the trade-account guard rather than the query.
43
+ */
44
+ export declare const OpenPositionListParams: z.ZodObject<{
45
+ cursor: z.ZodOptional<z.ZodString>;
46
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
47
+ positionId: z.ZodOptional<z.ZodUUID>;
48
+ includeSteps: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCodec<z.ZodString, z.ZodBoolean>]>>>;
49
+ }, z.core.$strip>;
50
+ export type OpenPositionListParamsInput = z.input<typeof OpenPositionListParams>;
51
+ export type OpenPositionListParams = z.output<typeof OpenPositionListParams>;
@@ -41,7 +41,42 @@ const ClosedPositionListParams = CursorFindParams.extend({
41
41
  startDate: z.string().optional(),
42
42
  endDate: z.string().optional(),
43
43
  /**
44
- * Whether to return each trade's `steps` timeline. Off by default because the array
44
+ * Narrows the page to one closed position. The only scope `includeSteps` may be
45
+ * asked at — see the refinement below.
46
+ */
47
+ positionId: z.uuid().optional(),
48
+ /**
49
+ * Whether to return each position's `steps` timeline. Off by default because the array
50
+ * is unbounded, and a caller listing history rarely needs every recorded action of
51
+ * every row. `openedAt` is always present, so omitting steps costs no timestamp.
52
+ *
53
+ * Accepts a real boolean from an SDK caller and its text form from a query string.
54
+ * Deliberately not `z.coerce.boolean()`, which reads the string "false" as true and
55
+ * so cannot be switched off from a URL at all.
56
+ */
57
+ includeSteps: z.union([
58
+ z.boolean(),
59
+ z.stringbool()
60
+ ]).optional().default(false)
61
+ }).refine((params) => !params.includeSteps || params.positionId !== void 0, {
62
+ path: [
63
+ "includeSteps"
64
+ ],
65
+ message: "includeSteps requires positionId"
66
+ });
67
+ const OpenPositionListParams = CursorFindParams.extend({
68
+ /**
69
+ * Capped below the shared 2000 because every row drags its fills along — one page
70
+ * of open positions can pull thousands of fill rows into one response.
71
+ */
72
+ limit: z.coerce.number().int().positive().max(200).optional().default(20),
73
+ /**
74
+ * Narrows the page to one open position. The only scope `includeSteps` may be
75
+ * asked at — see the refinement below.
76
+ */
77
+ positionId: z.uuid().optional(),
78
+ /**
79
+ * Whether to return each position's `steps` timeline. Off by default because the array
45
80
  * is unbounded, and a caller listing history rarely needs every recorded action of
46
81
  * every row. `openedAt` is always present, so omitting steps costs no timestamp.
47
82
  *
@@ -53,6 +88,11 @@ const ClosedPositionListParams = CursorFindParams.extend({
53
88
  z.boolean(),
54
89
  z.stringbool()
55
90
  ]).optional().default(false)
91
+ }).refine((params) => !params.includeSteps || params.positionId !== void 0, {
92
+ path: [
93
+ "includeSteps"
94
+ ],
95
+ message: "includeSteps requires positionId"
56
96
  });
57
97
 
58
- export { ClosedPositionListParams, PositionListParams };
98
+ export { ClosedPositionListParams, OpenPositionListParams, PositionListParams };
@@ -80,9 +80,9 @@ export declare const OpenPositionLiteListResponse: z.ZodObject<{
80
80
  export type OpenPositionLite = z.output<typeof OpenPositionLite>;
81
81
  export type OpenPositionLiteListResponse = z.output<typeof OpenPositionLiteListResponse>;
82
82
  /**
83
- * A page of closed trades.
83
+ * A page of closed positions.
84
84
  *
85
- * A page may hold fewer than `limit` trades and still return a `nextCursor`: closed
85
+ * A page may hold fewer than `limit` positions and still return a `nextCursor`: closed
86
86
  * positions with no confirmed fills are skipped during composition, exactly as
87
87
  * `/portfolio` skips them. Page until `nextCursor` is absent, never until a page
88
88
  * comes back short — stopping early silently truncates history.
@@ -90,7 +90,7 @@ export type OpenPositionLiteListResponse = z.output<typeof OpenPositionLiteListR
90
90
  export declare const ClosedPositionListResponse: z.ZodObject<{
91
91
  limit: z.ZodNumber;
92
92
  nextCursor: z.ZodOptional<z.ZodString>;
93
- trades: z.ZodArray<z.ZodObject<{
93
+ positions: z.ZodArray<z.ZodObject<{
94
94
  positionId: z.ZodUUID;
95
95
  connector: z.ZodEnum<{
96
96
  hyperliquid: "hyperliquid";
@@ -99,6 +99,7 @@ export declare const ClosedPositionListResponse: z.ZodObject<{
99
99
  okx: "okx";
100
100
  lighter: "lighter";
101
101
  }>;
102
+ status: z.ZodLiteral<"CLOSED">;
102
103
  openedAt: z.ZodString;
103
104
  closedAt: z.ZodString;
104
105
  closedReason: z.ZodOptional<z.ZodEnum<{
@@ -185,3 +186,106 @@ export declare const ClosedPositionListResponse: z.ZodObject<{
185
186
  }, z.core.$strip>>;
186
187
  }, z.core.$strip>;
187
188
  export type ClosedPositionListResponse = z.output<typeof ClosedPositionListResponse>;
189
+ /**
190
+ * A page of open positions, newest opened first.
191
+ *
192
+ * Every open position on the page yields exactly one row: a position whose fills
193
+ * are not visible yet (mid-sync, recovery) comes back as an explicit zero-state
194
+ * row rather than disappearing while `/positions` still lists it. Page until
195
+ * `nextCursor` is absent, never until a page comes back short.
196
+ */
197
+ export declare const OpenPositionListResponse: z.ZodObject<{
198
+ limit: z.ZodNumber;
199
+ nextCursor: z.ZodOptional<z.ZodString>;
200
+ positions: z.ZodArray<z.ZodObject<{
201
+ positionId: z.ZodUUID;
202
+ connector: z.ZodEnum<{
203
+ hyperliquid: "hyperliquid";
204
+ binance: "binance";
205
+ bybit: "bybit";
206
+ okx: "okx";
207
+ lighter: "lighter";
208
+ }>;
209
+ status: z.ZodLiteral<"OPEN">;
210
+ openedAt: z.ZodString;
211
+ updatedAt: z.ZodString;
212
+ origin: z.ZodEnum<{
213
+ PARTIAL: "PARTIAL";
214
+ PEAR: "PEAR";
215
+ EXTERNAL: "EXTERNAL";
216
+ }>;
217
+ realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
218
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
219
+ totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
220
+ tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
221
+ pearFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
222
+ totalFunding: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
223
+ initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
224
+ hasSyntheticFills: z.ZodBoolean;
225
+ hasProvisionalFills: z.ZodBoolean;
226
+ unstableHistoricalData: z.ZodBoolean;
227
+ legs: z.ZodArray<z.ZodObject<{
228
+ asset: z.ZodString;
229
+ side: z.ZodEnum<{
230
+ LONG: "LONG";
231
+ SHORT: "SHORT";
232
+ }>;
233
+ realized: z.ZodObject<{
234
+ quantity: z.ZodString;
235
+ unpricedQuantity: z.ZodString;
236
+ exitVwap: z.ZodOptional<z.ZodString>;
237
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
238
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
239
+ }, z.core.$strip>;
240
+ remaining: z.ZodObject<{
241
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
242
+ entryVwap: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$strip>;
244
+ totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
245
+ tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
246
+ pearFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
247
+ funding: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
248
+ }, z.core.$strip>>;
249
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
250
+ executionId: z.ZodOptional<z.ZodString>;
251
+ at: z.ZodString;
252
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
253
+ legs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
254
+ kind: z.ZodLiteral<"INCREASE">;
255
+ asset: z.ZodString;
256
+ side: z.ZodEnum<{
257
+ BUY: "BUY";
258
+ SELL: "SELL";
259
+ }>;
260
+ quantity: z.ZodString;
261
+ price: z.ZodString;
262
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
263
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
264
+ }, z.core.$strip>, z.ZodObject<{
265
+ kind: z.ZodLiteral<"REDUCE">;
266
+ asset: z.ZodString;
267
+ side: z.ZodEnum<{
268
+ BUY: "BUY";
269
+ SELL: "SELL";
270
+ }>;
271
+ quantity: z.ZodString;
272
+ price: z.ZodString;
273
+ entryBasis: z.ZodString;
274
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
275
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
276
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
277
+ }, z.core.$strip>, z.ZodObject<{
278
+ kind: z.ZodLiteral<"REDUCE_UNPRICED">;
279
+ asset: z.ZodString;
280
+ side: z.ZodEnum<{
281
+ BUY: "BUY";
282
+ SELL: "SELL";
283
+ }>;
284
+ quantity: z.ZodString;
285
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
286
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
287
+ }, z.core.$strip>], "kind">>;
288
+ }, z.core.$strip>>>;
289
+ }, z.core.$strip>>;
290
+ }, z.core.$strip>;
291
+ export type OpenPositionListResponse = z.output<typeof OpenPositionListResponse>;
@@ -3,7 +3,7 @@ import { CursorResponse } from '../common';
3
3
  import { SignedDecimalString } from '../common/schema';
4
4
  import { Connector } from '../connector';
5
5
  import { InstrumentId } from '../instrument';
6
- import { Position, PositionOrigin, ClosedTrade } from './entities';
6
+ import { Position, PositionOrigin, ClosedPosition, OpenPosition } from './entities';
7
7
 
8
8
  const PositionListResponse = CursorResponse.extend({
9
9
  positions: z.array(Position)
@@ -21,7 +21,10 @@ const OpenPositionLiteListResponse = z.object({
21
21
  positions: z.array(OpenPositionLite)
22
22
  });
23
23
  const ClosedPositionListResponse = CursorResponse.extend({
24
- trades: z.array(ClosedTrade)
24
+ positions: z.array(ClosedPosition)
25
+ });
26
+ const OpenPositionListResponse = CursorResponse.extend({
27
+ positions: z.array(OpenPosition)
25
28
  });
26
29
 
27
- export { ClosedPositionListResponse, OpenPositionLite, OpenPositionLiteListResponse, PositionListResponse };
30
+ export { ClosedPositionListResponse, OpenPositionListResponse, OpenPositionLite, OpenPositionLiteListResponse, PositionListResponse };
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  export declare const VolumeStatisticsQueryParams: z.ZodObject<{
3
- connector: z.ZodEnum<{
3
+ connector: z.ZodOptional<z.ZodEnum<{
4
4
  hyperliquid: "hyperliquid";
5
5
  binance: "binance";
6
6
  bybit: "bybit";
7
7
  okx: "okx";
8
8
  lighter: "lighter";
9
- }>;
9
+ }>>;
10
10
  resolution: z.ZodEnum<{
11
11
  "1h": "1h";
12
12
  "4h": "4h";
@@ -19,13 +19,13 @@ export declare const VolumeStatisticsQueryParams: z.ZodObject<{
19
19
  export type VolumeStatisticsQueryParamsInput = z.input<typeof VolumeStatisticsQueryParams>;
20
20
  export type VolumeStatisticsQueryParams = z.output<typeof VolumeStatisticsQueryParams>;
21
21
  export declare const OiStatisticsQueryParams: z.ZodObject<{
22
- connector: z.ZodEnum<{
22
+ connector: z.ZodOptional<z.ZodEnum<{
23
23
  hyperliquid: "hyperliquid";
24
24
  binance: "binance";
25
25
  bybit: "bybit";
26
26
  okx: "okx";
27
27
  lighter: "lighter";
28
- }>;
28
+ }>>;
29
29
  resolution: z.ZodEnum<{
30
30
  "1h": "1h";
31
31
  "4h": "4h";
@@ -38,22 +38,22 @@ export declare const OiStatisticsQueryParams: z.ZodObject<{
38
38
  export type OiStatisticsQueryParamsInput = z.input<typeof OiStatisticsQueryParams>;
39
39
  export type OiStatisticsQueryParams = z.output<typeof OiStatisticsQueryParams>;
40
40
  export declare const StatisticsTotalsQueryParams: z.ZodObject<{
41
- connector: z.ZodEnum<{
41
+ connector: z.ZodOptional<z.ZodEnum<{
42
42
  hyperliquid: "hyperliquid";
43
43
  binance: "binance";
44
44
  bybit: "bybit";
45
45
  okx: "okx";
46
46
  lighter: "lighter";
47
- }>;
47
+ }>>;
48
48
  clientId: z.ZodOptional<z.ZodString>;
49
49
  }, z.core.$strip>;
50
50
  export type StatisticsTotalsQueryParamsInput = z.input<typeof StatisticsTotalsQueryParams>;
51
51
  export type StatisticsTotalsQueryParams = z.output<typeof StatisticsTotalsQueryParams>;
52
52
  export declare const LeaderboardSortBy: z.ZodEnum<{
53
- trades: "trades";
54
53
  volume: "volume";
55
54
  totalNetPnl: "totalNetPnl";
56
55
  roi: "roi";
56
+ trades: "trades";
57
57
  }>;
58
58
  export type LeaderboardSortBy = z.infer<typeof LeaderboardSortBy>;
59
59
  export declare const LEADERBOARD_MAX_LIMIT = 200;
@@ -68,10 +68,10 @@ export declare const LeaderboardQueryParams: z.ZodObject<{
68
68
  }>>>>;
69
69
  asset: z.ZodOptional<z.ZodPipe<z.ZodTransform<string[] | (string[] & any[]) | undefined, string[]>, z.ZodArray<z.ZodString>>>;
70
70
  sortBy: z.ZodDefault<z.ZodEnum<{
71
- trades: "trades";
72
71
  volume: "volume";
73
72
  totalNetPnl: "totalNetPnl";
74
73
  roi: "roi";
74
+ trades: "trades";
75
75
  }>>;
76
76
  startDate: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<number>, z.ZodTransform<Date, number>>>;
77
77
  endDate: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<number>, z.ZodTransform<Date, number>>>;
@@ -3,7 +3,7 @@ import { normalizeArray } from '../common/array';
3
3
  import { Connector } from '../connector';
4
4
 
5
5
  const VolumeStatisticsQueryParams = z.object({
6
- connector: Connector,
6
+ connector: Connector.optional(),
7
7
  resolution: z.enum([
8
8
  "1h",
9
9
  "4h",
@@ -18,7 +18,7 @@ const VolumeStatisticsQueryParams = z.object({
18
18
  message: "startDate must be before endDate"
19
19
  });
20
20
  const OiStatisticsQueryParams = z.object({
21
- connector: Connector,
21
+ connector: Connector.optional(),
22
22
  resolution: z.enum([
23
23
  "1h",
24
24
  "4h",
@@ -33,7 +33,7 @@ const OiStatisticsQueryParams = z.object({
33
33
  message: "startDate must be before endDate"
34
34
  });
35
35
  const StatisticsTotalsQueryParams = z.object({
36
- connector: Connector,
36
+ connector: Connector.optional(),
37
37
  // Per-client scope; absent serves the global totals. The literal 'other'
38
38
  // selects the unattributed (NULL) bucket; an unknown code returns zero totals.
39
39
  clientId: z.string().trim().min(1).optional()