@pear-protocol/types 2.5.0 → 2.7.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.
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const PortfolioResponse: z.ZodObject<{
3
+ hasProvisionalFills: z.ZodBoolean;
3
4
  realizedCashflow: z.ZodObject<{
4
5
  grossPnl: z.ZodNumber;
5
6
  tradeFees: z.ZodNumber;
@@ -120,6 +121,7 @@ export declare const PortfolioAnalyticsResponse: z.ZodObject<{
120
121
  startDate: z.ZodString;
121
122
  endDate: z.ZodString;
122
123
  }, z.core.$strip>;
124
+ hasProvisionalFills: z.ZodBoolean;
123
125
  realizedCashflow: z.ZodObject<{
124
126
  grossPnl: z.ZodNumber;
125
127
  tradeFees: z.ZodNumber;
@@ -2,6 +2,8 @@ import { z } from 'zod';
2
2
  import { PortfolioOpenSnapshot, PortfolioClosedPositionStats, PortfolioVolumeAmounts, PortfolioVolumeIntervals, PortfolioCashflowAmounts, PortfolioCashflowIntervals, PortfolioAnalyticsConfig, PortfolioVolumeSeriesPoint, PortfolioPairBreakdown, PortfolioCashflowSeriesPoint } from './entities';
3
3
 
4
4
  const PortfolioResponse = z.object({
5
+ /** Historical accounting or the current open snapshot still uses provisional fills. */
6
+ hasProvisionalFills: z.boolean(),
5
7
  realizedCashflow: PortfolioCashflowAmounts.extend({
6
8
  fundingSynced: z.boolean(),
7
9
  intervals: PortfolioCashflowIntervals.optional()
@@ -14,6 +16,8 @@ const PortfolioResponse = z.object({
14
16
  });
15
17
  const PortfolioAnalyticsResponse = z.object({
16
18
  config: PortfolioAnalyticsConfig,
19
+ /** Historical accounting or the current open snapshot still uses provisional fills. */
20
+ hasProvisionalFills: z.boolean(),
17
21
  realizedCashflow: PortfolioCashflowAmounts.extend({
18
22
  fundingSynced: z.boolean(),
19
23
  series: z.array(PortfolioCashflowSeriesPoint).optional()
@@ -259,6 +259,7 @@ export declare const ClosedPosition: z.ZodObject<{
259
259
  exitNotional: z.ZodString;
260
260
  exitNotionalComplete: z.ZodBoolean;
261
261
  hasSyntheticFills: z.ZodBoolean;
262
+ hasProvisionalFills: z.ZodBoolean;
262
263
  unstableHistoricalData: z.ZodBoolean;
263
264
  longAssets: z.ZodArray<z.ZodString>;
264
265
  shortAssets: z.ZodArray<z.ZodString>;
@@ -570,6 +571,7 @@ export declare const VaultClosedPosition: z.ZodObject<{
570
571
  netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
571
572
  positionId: z.ZodUUID;
572
573
  openedAt: z.ZodString;
574
+ hasProvisionalFills: z.ZodBoolean;
573
575
  legs: z.ZodArray<z.ZodObject<{
574
576
  side: z.ZodEnum<{
575
577
  LONG: "LONG";
@@ -220,6 +220,8 @@ const ClosedPosition = z.object({
220
220
  exitNotionalComplete: z.boolean(),
221
221
  /** Whether any fill on the position was a synthetic bridge fill (gap/gone reconstruction). */
222
222
  hasSyntheticFills: z.boolean(),
223
+ /** Whether any fill is still PROVISIONAL, so fees and net PnL may still settle. */
224
+ hasProvisionalFills: z.boolean(),
223
225
  /** Whether a backfilled fill made this position's historical metrics unreliable. */
224
226
  unstableHistoricalData: z.boolean(),
225
227
  longAssets: z.array(InstrumentId),
@@ -406,7 +408,8 @@ const VaultClosedPosition = ClosedPosition.pick({
406
408
  closedAt: true,
407
409
  closedReason: true,
408
410
  grossPnl: true,
409
- netPnl: true
411
+ netPnl: true,
412
+ hasProvisionalFills: true
410
413
  }).extend({
411
414
  legs: z.array(VaultClosedPositionLeg)
412
415
  });
@@ -126,6 +126,7 @@ export declare const ClosedPositionListResponse: z.ZodObject<{
126
126
  exitNotional: z.ZodString;
127
127
  exitNotionalComplete: z.ZodBoolean;
128
128
  hasSyntheticFills: z.ZodBoolean;
129
+ hasProvisionalFills: z.ZodBoolean;
129
130
  unstableHistoricalData: z.ZodBoolean;
130
131
  longAssets: z.ZodArray<z.ZodString>;
131
132
  shortAssets: z.ZodArray<z.ZodString>;
@@ -371,6 +372,7 @@ export declare const VaultClosedPositionListResponse: z.ZodObject<{
371
372
  netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
372
373
  positionId: z.ZodUUID;
373
374
  openedAt: z.ZodString;
375
+ hasProvisionalFills: z.ZodBoolean;
374
376
  legs: z.ZodArray<z.ZodObject<{
375
377
  side: z.ZodEnum<{
376
378
  LONG: "LONG";
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ export declare const BOUNDED_MARKET_MAX_TTL_MS = 10000;
2
3
  export declare const CreateMarketOpen: z.ZodObject<{
3
4
  type: z.ZodLiteral<"MARKET">;
4
5
  legs: z.ZodTuple<[z.ZodObject<{
@@ -100,6 +101,39 @@ export declare const CreateMarketOpen: z.ZodObject<{
100
101
  }, z.core.$strip>]>>;
101
102
  clientId: z.ZodOptional<z.ZodString>;
102
103
  }, z.core.$strip>;
104
+ /** Explicit price protection: legacy gateways reject this request type instead of stripping limits. */
105
+ export declare const CreateBoundedMarketOpen: z.ZodObject<{
106
+ type: z.ZodLiteral<"BOUNDED_MARKET">;
107
+ expiresAt: z.ZodNumber;
108
+ legs: z.ZodTuple<[z.ZodObject<{
109
+ symbol: z.ZodString;
110
+ id: z.ZodOptional<z.ZodString>;
111
+ side: z.ZodEnum<{
112
+ BUY: "BUY";
113
+ SELL: "SELL";
114
+ }>;
115
+ mode: z.ZodEnum<{
116
+ QUANTITY: "QUANTITY";
117
+ USD: "USD";
118
+ }>;
119
+ amount: z.ZodString;
120
+ limitPrice: z.ZodString;
121
+ }, z.core.$strip>], z.ZodObject<{
122
+ symbol: z.ZodString;
123
+ id: z.ZodOptional<z.ZodString>;
124
+ side: z.ZodEnum<{
125
+ BUY: "BUY";
126
+ SELL: "SELL";
127
+ }>;
128
+ mode: z.ZodEnum<{
129
+ QUANTITY: "QUANTITY";
130
+ USD: "USD";
131
+ }>;
132
+ amount: z.ZodString;
133
+ limitPrice: z.ZodString;
134
+ }, z.core.$strip>>;
135
+ clientId: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strip>;
103
137
  export declare const CreateMarketAdjust: z.ZodObject<{
104
138
  type: z.ZodLiteral<"MARKET">;
105
139
  legs: z.ZodTuple<[z.ZodObject<{
@@ -243,6 +277,37 @@ export declare const CreateTradeOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
243
277
  }, z.core.$strip>;
244
278
  }, z.core.$strip>]>>;
245
279
  clientId: z.ZodOptional<z.ZodString>;
280
+ }, z.core.$strip>, z.ZodObject<{
281
+ type: z.ZodLiteral<"BOUNDED_MARKET">;
282
+ expiresAt: z.ZodNumber;
283
+ legs: z.ZodTuple<[z.ZodObject<{
284
+ symbol: z.ZodString;
285
+ id: z.ZodOptional<z.ZodString>;
286
+ side: z.ZodEnum<{
287
+ BUY: "BUY";
288
+ SELL: "SELL";
289
+ }>;
290
+ mode: z.ZodEnum<{
291
+ QUANTITY: "QUANTITY";
292
+ USD: "USD";
293
+ }>;
294
+ amount: z.ZodString;
295
+ limitPrice: z.ZodString;
296
+ }, z.core.$strip>], z.ZodObject<{
297
+ symbol: z.ZodString;
298
+ id: z.ZodOptional<z.ZodString>;
299
+ side: z.ZodEnum<{
300
+ BUY: "BUY";
301
+ SELL: "SELL";
302
+ }>;
303
+ mode: z.ZodEnum<{
304
+ QUANTITY: "QUANTITY";
305
+ USD: "USD";
306
+ }>;
307
+ amount: z.ZodString;
308
+ limitPrice: z.ZodString;
309
+ }, z.core.$strip>>;
310
+ clientId: z.ZodOptional<z.ZodString>;
246
311
  }, z.core.$strip>], "type">;
247
312
  export declare const CreateTradeAdjust: z.ZodDiscriminatedUnion<[z.ZodObject<{
248
313
  type: z.ZodLiteral<"MARKET">;
@@ -288,6 +353,7 @@ export declare const CreateTradeCloseAll: z.ZodDiscriminatedUnion<[z.ZodObject<{
288
353
  clientId: z.ZodOptional<z.ZodString>;
289
354
  }, z.core.$strip>], "type">;
290
355
  export type CreateMarketOpen = z.output<typeof CreateMarketOpen>;
356
+ export type CreateBoundedMarketOpen = z.output<typeof CreateBoundedMarketOpen>;
291
357
  export type CreateMarketAdjust = z.output<typeof CreateMarketAdjust>;
292
358
  export type CreateMarketClose = z.output<typeof CreateMarketClose>;
293
359
  export type CreateMarketReverse = z.output<typeof CreateMarketReverse>;
@@ -1,9 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { ClientIdCode } from '../common/client-id';
3
3
  import { RefineMinimumOneSymbol, RefineUniqueSymbols } from '../common/refinement';
4
+ import { UnsignedDecimalString } from '../common/schema';
4
5
  import { TradeLegPostOnly, TradeLeg } from '../common/trade-legs';
5
6
  import { AttachTriggerMarketClose } from '../trigger';
6
7
 
8
+ const BOUNDED_MARKET_MAX_TTL_MS = 1e4;
9
+ const BoundedTradeLeg = TradeLegPostOnly.safeExtend({
10
+ limitPrice: UnsignedDecimalString.refine((value) => Number.isFinite(Number(value)) && Number(value) > 0)
11
+ });
7
12
  const CreateMarketOpen = z.object({
8
13
  type: z.literal("MARKET"),
9
14
  /**
@@ -21,6 +26,14 @@ const CreateMarketOpen = z.object({
21
26
  */
22
27
  clientId: ClientIdCode
23
28
  });
29
+ const CreateBoundedMarketOpen = z.object({
30
+ type: z.literal("BOUNDED_MARKET"),
31
+ expiresAt: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
32
+ legs: z.tuple([
33
+ BoundedTradeLeg
34
+ ]).rest(BoundedTradeLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols),
35
+ clientId: ClientIdCode
36
+ });
24
37
  const CreateMarketAdjust = z.object({
25
38
  type: z.literal("MARKET"),
26
39
  /**
@@ -56,7 +69,8 @@ const CreateMarketCloseAll = z.object({
56
69
  clientId: ClientIdCode
57
70
  });
58
71
  const CreateTradeOpen = z.discriminatedUnion("type", [
59
- CreateMarketOpen
72
+ CreateMarketOpen,
73
+ CreateBoundedMarketOpen
60
74
  ]);
61
75
  const CreateTradeAdjust = z.discriminatedUnion("type", [
62
76
  CreateMarketAdjust
@@ -71,4 +85,4 @@ const CreateTradeCloseAll = z.discriminatedUnion("type", [
71
85
  CreateMarketCloseAll
72
86
  ]);
73
87
 
74
- export { CreateMarketAdjust, CreateMarketClose, CreateMarketCloseAll, CreateMarketOpen, CreateMarketReverse, CreateTradeAdjust, CreateTradeClose, CreateTradeCloseAll, CreateTradeOpen, CreateTradeReverse };
88
+ export { BOUNDED_MARKET_MAX_TTL_MS, CreateBoundedMarketOpen, CreateMarketAdjust, CreateMarketClose, CreateMarketCloseAll, CreateMarketOpen, CreateMarketReverse, CreateTradeAdjust, CreateTradeClose, CreateTradeCloseAll, CreateTradeOpen, CreateTradeReverse };
@@ -1,4 +1,13 @@
1
1
  import { z } from 'zod';
2
+ /** An authenticated admission capability; old workers also reject the new persisted discriminant. */
3
+ export declare const TradeCapabilities: z.ZodObject<{
4
+ boundedMarketOpen: z.ZodObject<{
5
+ version: z.ZodLiteral<1>;
6
+ maxTtlMs: z.ZodLiteral<10000>;
7
+ connectors: z.ZodArray<z.ZodLiteral<"hyperliquid">>;
8
+ }, z.core.$strip>;
9
+ }, z.core.$strip>;
10
+ export type TradeCapabilities = z.output<typeof TradeCapabilities>;
2
11
  export declare const CreateTradeOpenResponse: z.ZodObject<{
3
12
  execution: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
4
13
  id: z.ZodUUID;
@@ -2,7 +2,15 @@ import { z } from 'zod';
2
2
  import { CursorResponse } from '../common';
3
3
  import { Execution } from '../execution/entities';
4
4
  import { TradeGroup } from './entities';
5
+ import { BOUNDED_MARKET_MAX_TTL_MS } from './payloads';
5
6
 
7
+ const TradeCapabilities = z.object({
8
+ boundedMarketOpen: z.object({
9
+ version: z.literal(1),
10
+ maxTtlMs: z.literal(BOUNDED_MARKET_MAX_TTL_MS),
11
+ connectors: z.array(z.literal("hyperliquid"))
12
+ })
13
+ });
6
14
  const CreateTradeOpenResponse = z.object({
7
15
  execution: Execution
8
16
  });
@@ -22,4 +30,4 @@ const TradeListResponse = CursorResponse.extend({
22
30
  groups: z.array(TradeGroup)
23
31
  });
24
32
 
25
- export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse, TradeListResponse };
33
+ export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse, TradeCapabilities, TradeListResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",