@pear-protocol/types 1.33.0 → 2.1.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.
Files changed (47) hide show
  1. package/dist/auth/api-keys.d.ts +1 -0
  2. package/dist/auth/api-keys.js +2 -1
  3. package/dist/auth/entities.d.ts +1 -0
  4. package/dist/auth/entities.js +2 -1
  5. package/dist/auth/response.d.ts +2 -0
  6. package/dist/bundle.d.ts +1 -0
  7. package/dist/bundle.js +1 -0
  8. package/dist/fee/entities.d.ts +1 -0
  9. package/dist/fee/entities.js +2 -1
  10. package/dist/margin/index.d.ts +2 -0
  11. package/dist/margin/index.js +2 -0
  12. package/dist/margin/payloads.d.ts +7 -0
  13. package/dist/margin/payloads.js +20 -0
  14. package/dist/margin/response.d.ts +5 -0
  15. package/dist/margin/response.js +11 -0
  16. package/dist/portfolio/entities.d.ts +107 -150
  17. package/dist/portfolio/entities.js +51 -83
  18. package/dist/portfolio/queries.d.ts +0 -1
  19. package/dist/portfolio/queries.js +4 -5
  20. package/dist/portfolio/responses.d.ts +158 -149
  21. package/dist/portfolio/responses.js +20 -7
  22. package/dist/position/entities.d.ts +148 -13
  23. package/dist/position/entities.js +161 -12
  24. package/dist/position/queries.d.ts +17 -1
  25. package/dist/position/queries.js +42 -2
  26. package/dist/position/responses.d.ts +107 -3
  27. package/dist/position/responses.js +6 -3
  28. package/dist/statistics/queries.d.ts +8 -8
  29. package/dist/statistics/queries.js +3 -3
  30. package/dist/trade/entities.d.ts +284 -0
  31. package/dist/trade/entities.js +101 -0
  32. package/dist/trade/index.d.ts +2 -0
  33. package/dist/trade/index.js +2 -0
  34. package/dist/trade/queries.d.ts +8 -0
  35. package/dist/trade/queries.js +9 -0
  36. package/dist/trade/responses.d.ts +116 -0
  37. package/dist/trade/responses.js +6 -1
  38. package/dist/trade-accounts/entities.d.ts +4 -0
  39. package/dist/trade-accounts/entities.js +4 -0
  40. package/dist/trade-accounts/payloads.d.ts +12 -0
  41. package/dist/trade-accounts/payloads.js +10 -1
  42. package/dist/trade-accounts/response.d.ts +101 -0
  43. package/dist/trade-accounts/response.js +14 -1
  44. package/dist/users/entities.d.ts +1 -0
  45. package/dist/users/entities.js +2 -1
  46. package/dist/users/response.d.ts +1 -0
  47. package/package.json +1 -1
@@ -0,0 +1,284 @@
1
+ import { z } from 'zod';
2
+ /** The basis state immediately before or after a fill. */
3
+ export declare const TradePositionState: z.ZodObject<{
4
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
5
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ kind: z.ZodLiteral<"FLAT">;
7
+ }, z.core.$strip>, z.ZodObject<{
8
+ kind: z.ZodLiteral<"PRICED">;
9
+ entryPrice: z.ZodString;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ kind: z.ZodLiteral<"UNPRICED">;
12
+ }, z.core.$strip>], "kind">;
13
+ }, z.core.$strip>;
14
+ export type TradePositionState = z.output<typeof TradePositionState>;
15
+ /** The priced or unpriceable quantity reduced by one fill. */
16
+ export declare const TradeRealization: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ kind: z.ZodLiteral<"PRICED">;
18
+ quantity: z.ZodString;
19
+ entryPrice: z.ZodString;
20
+ exitPrice: z.ZodString;
21
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ kind: z.ZodLiteral<"UNPRICED">;
24
+ quantity: z.ZodString;
25
+ }, z.core.$strip>], "kind">;
26
+ export type TradeRealization = z.output<typeof TradeRealization>;
27
+ /** The complete exposure effect of one fill, including flip quantities. */
28
+ export declare const TradePositionEffect: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ kind: z.ZodLiteral<"OPEN">;
30
+ openedQuantity: z.ZodString;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ kind: z.ZodLiteral<"INCREASE">;
33
+ increasedQuantity: z.ZodString;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ kind: z.ZodLiteral<"REDUCE">;
36
+ reducedQuantity: z.ZodString;
37
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ kind: z.ZodLiteral<"PRICED">;
39
+ quantity: z.ZodString;
40
+ entryPrice: z.ZodString;
41
+ exitPrice: z.ZodString;
42
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ kind: z.ZodLiteral<"UNPRICED">;
45
+ quantity: z.ZodString;
46
+ }, z.core.$strip>], "kind">;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ kind: z.ZodLiteral<"CLOSE">;
49
+ reducedQuantity: z.ZodString;
50
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
51
+ kind: z.ZodLiteral<"PRICED">;
52
+ quantity: z.ZodString;
53
+ entryPrice: z.ZodString;
54
+ exitPrice: z.ZodString;
55
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ kind: z.ZodLiteral<"UNPRICED">;
58
+ quantity: z.ZodString;
59
+ }, z.core.$strip>], "kind">;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ kind: z.ZodLiteral<"FLIP">;
62
+ reducedQuantity: z.ZodString;
63
+ openedQuantity: z.ZodString;
64
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ kind: z.ZodLiteral<"PRICED">;
66
+ quantity: z.ZodString;
67
+ entryPrice: z.ZodString;
68
+ exitPrice: z.ZodString;
69
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ kind: z.ZodLiteral<"UNPRICED">;
72
+ quantity: z.ZodString;
73
+ }, z.core.$strip>], "kind">;
74
+ }, z.core.$strip>], "kind">;
75
+ export type TradePositionEffect = z.output<typeof TradePositionEffect>;
76
+ /** One executed fill enriched with its position transition. */
77
+ export declare const TradeFill: z.ZodObject<{
78
+ id: z.ZodUUID;
79
+ positionId: z.ZodUUID;
80
+ symbol: z.ZodString;
81
+ connector: z.ZodEnum<{
82
+ hyperliquid: "hyperliquid";
83
+ binance: "binance";
84
+ bybit: "bybit";
85
+ okx: "okx";
86
+ lighter: "lighter";
87
+ }>;
88
+ side: z.ZodEnum<{
89
+ BUY: "BUY";
90
+ SELL: "SELL";
91
+ }>;
92
+ quantity: z.ZodString;
93
+ price: z.ZodString;
94
+ tradeFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
95
+ pearFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
96
+ timestamp: z.ZodISODateTime;
97
+ settlement: z.ZodEnum<{
98
+ PROVISIONAL: "PROVISIONAL";
99
+ CONFIRMED: "CONFIRMED";
100
+ }>;
101
+ executionId: z.ZodOptional<z.ZodUUID>;
102
+ positionEffect: z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ kind: z.ZodLiteral<"OPEN">;
104
+ openedQuantity: z.ZodString;
105
+ }, z.core.$strip>, z.ZodObject<{
106
+ kind: z.ZodLiteral<"INCREASE">;
107
+ increasedQuantity: z.ZodString;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"REDUCE">;
110
+ reducedQuantity: z.ZodString;
111
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
112
+ kind: z.ZodLiteral<"PRICED">;
113
+ quantity: z.ZodString;
114
+ entryPrice: z.ZodString;
115
+ exitPrice: z.ZodString;
116
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
117
+ }, z.core.$strip>, z.ZodObject<{
118
+ kind: z.ZodLiteral<"UNPRICED">;
119
+ quantity: z.ZodString;
120
+ }, z.core.$strip>], "kind">;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ kind: z.ZodLiteral<"CLOSE">;
123
+ reducedQuantity: z.ZodString;
124
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
125
+ kind: z.ZodLiteral<"PRICED">;
126
+ quantity: z.ZodString;
127
+ entryPrice: z.ZodString;
128
+ exitPrice: z.ZodString;
129
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ kind: z.ZodLiteral<"UNPRICED">;
132
+ quantity: z.ZodString;
133
+ }, z.core.$strip>], "kind">;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ kind: z.ZodLiteral<"FLIP">;
136
+ reducedQuantity: z.ZodString;
137
+ openedQuantity: z.ZodString;
138
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
139
+ kind: z.ZodLiteral<"PRICED">;
140
+ quantity: z.ZodString;
141
+ entryPrice: z.ZodString;
142
+ exitPrice: z.ZodString;
143
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
144
+ }, z.core.$strip>, z.ZodObject<{
145
+ kind: z.ZodLiteral<"UNPRICED">;
146
+ quantity: z.ZodString;
147
+ }, z.core.$strip>], "kind">;
148
+ }, z.core.$strip>], "kind">;
149
+ basisBefore: z.ZodObject<{
150
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
151
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
152
+ kind: z.ZodLiteral<"FLAT">;
153
+ }, z.core.$strip>, z.ZodObject<{
154
+ kind: z.ZodLiteral<"PRICED">;
155
+ entryPrice: z.ZodString;
156
+ }, z.core.$strip>, z.ZodObject<{
157
+ kind: z.ZodLiteral<"UNPRICED">;
158
+ }, z.core.$strip>], "kind">;
159
+ }, z.core.$strip>;
160
+ basisAfter: z.ZodObject<{
161
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
162
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
163
+ kind: z.ZodLiteral<"FLAT">;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ kind: z.ZodLiteral<"PRICED">;
166
+ entryPrice: z.ZodString;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ kind: z.ZodLiteral<"UNPRICED">;
169
+ }, z.core.$strip>], "kind">;
170
+ }, z.core.$strip>;
171
+ }, z.core.$strip>;
172
+ export type TradeFill = z.output<typeof TradeFill>;
173
+ /** A presentation group: one Pear execution or one ungrouped external fill. */
174
+ export declare const TradeGroup: z.ZodObject<{
175
+ id: z.ZodString;
176
+ executionId: z.ZodOptional<z.ZodUUID>;
177
+ scheduleId: z.ZodOptional<z.ZodUUID>;
178
+ triggerId: z.ZodOptional<z.ZodUUID>;
179
+ connector: z.ZodEnum<{
180
+ hyperliquid: "hyperliquid";
181
+ binance: "binance";
182
+ bybit: "bybit";
183
+ okx: "okx";
184
+ lighter: "lighter";
185
+ }>;
186
+ at: z.ZodISODateTime;
187
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
188
+ trades: z.ZodArray<z.ZodObject<{
189
+ id: z.ZodUUID;
190
+ positionId: z.ZodUUID;
191
+ symbol: z.ZodString;
192
+ connector: z.ZodEnum<{
193
+ hyperliquid: "hyperliquid";
194
+ binance: "binance";
195
+ bybit: "bybit";
196
+ okx: "okx";
197
+ lighter: "lighter";
198
+ }>;
199
+ side: z.ZodEnum<{
200
+ BUY: "BUY";
201
+ SELL: "SELL";
202
+ }>;
203
+ quantity: z.ZodString;
204
+ price: z.ZodString;
205
+ tradeFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
206
+ pearFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
207
+ timestamp: z.ZodISODateTime;
208
+ settlement: z.ZodEnum<{
209
+ PROVISIONAL: "PROVISIONAL";
210
+ CONFIRMED: "CONFIRMED";
211
+ }>;
212
+ executionId: z.ZodOptional<z.ZodUUID>;
213
+ positionEffect: z.ZodDiscriminatedUnion<[z.ZodObject<{
214
+ kind: z.ZodLiteral<"OPEN">;
215
+ openedQuantity: z.ZodString;
216
+ }, z.core.$strip>, z.ZodObject<{
217
+ kind: z.ZodLiteral<"INCREASE">;
218
+ increasedQuantity: z.ZodString;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ kind: z.ZodLiteral<"REDUCE">;
221
+ reducedQuantity: z.ZodString;
222
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
223
+ kind: z.ZodLiteral<"PRICED">;
224
+ quantity: z.ZodString;
225
+ entryPrice: z.ZodString;
226
+ exitPrice: z.ZodString;
227
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
228
+ }, z.core.$strip>, z.ZodObject<{
229
+ kind: z.ZodLiteral<"UNPRICED">;
230
+ quantity: z.ZodString;
231
+ }, z.core.$strip>], "kind">;
232
+ }, z.core.$strip>, z.ZodObject<{
233
+ kind: z.ZodLiteral<"CLOSE">;
234
+ reducedQuantity: z.ZodString;
235
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
236
+ kind: z.ZodLiteral<"PRICED">;
237
+ quantity: z.ZodString;
238
+ entryPrice: z.ZodString;
239
+ exitPrice: z.ZodString;
240
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
241
+ }, z.core.$strip>, z.ZodObject<{
242
+ kind: z.ZodLiteral<"UNPRICED">;
243
+ quantity: z.ZodString;
244
+ }, z.core.$strip>], "kind">;
245
+ }, z.core.$strip>, z.ZodObject<{
246
+ kind: z.ZodLiteral<"FLIP">;
247
+ reducedQuantity: z.ZodString;
248
+ openedQuantity: z.ZodString;
249
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
250
+ kind: z.ZodLiteral<"PRICED">;
251
+ quantity: z.ZodString;
252
+ entryPrice: z.ZodString;
253
+ exitPrice: z.ZodString;
254
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
255
+ }, z.core.$strip>, z.ZodObject<{
256
+ kind: z.ZodLiteral<"UNPRICED">;
257
+ quantity: z.ZodString;
258
+ }, z.core.$strip>], "kind">;
259
+ }, z.core.$strip>], "kind">;
260
+ basisBefore: z.ZodObject<{
261
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
262
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
263
+ kind: z.ZodLiteral<"FLAT">;
264
+ }, z.core.$strip>, z.ZodObject<{
265
+ kind: z.ZodLiteral<"PRICED">;
266
+ entryPrice: z.ZodString;
267
+ }, z.core.$strip>, z.ZodObject<{
268
+ kind: z.ZodLiteral<"UNPRICED">;
269
+ }, z.core.$strip>], "kind">;
270
+ }, z.core.$strip>;
271
+ basisAfter: z.ZodObject<{
272
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
273
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
274
+ kind: z.ZodLiteral<"FLAT">;
275
+ }, z.core.$strip>, z.ZodObject<{
276
+ kind: z.ZodLiteral<"PRICED">;
277
+ entryPrice: z.ZodString;
278
+ }, z.core.$strip>, z.ZodObject<{
279
+ kind: z.ZodLiteral<"UNPRICED">;
280
+ }, z.core.$strip>], "kind">;
281
+ }, z.core.$strip>;
282
+ }, z.core.$strip>>;
283
+ }, z.core.$strip>;
284
+ export type TradeGroup = z.output<typeof TradeGroup>;
@@ -0,0 +1,101 @@
1
+ import { z } from 'zod';
2
+ import { SignedDecimalString, UnsignedDecimalString } from '../common/schema';
3
+ import { Connector } from '../connector';
4
+ import { FillStatus } from '../fill';
5
+ import { InstrumentId } from '../instrument';
6
+
7
+ const TradePositionState = z.object({
8
+ signedQuantity: SignedDecimalString,
9
+ basis: z.discriminatedUnion("kind", [
10
+ z.object({
11
+ kind: z.literal("FLAT")
12
+ }),
13
+ z.object({
14
+ kind: z.literal("PRICED"),
15
+ entryPrice: UnsignedDecimalString
16
+ }),
17
+ z.object({
18
+ kind: z.literal("UNPRICED")
19
+ })
20
+ ])
21
+ });
22
+ const TradeRealization = z.discriminatedUnion("kind", [
23
+ z.object({
24
+ kind: z.literal("PRICED"),
25
+ quantity: UnsignedDecimalString,
26
+ entryPrice: UnsignedDecimalString,
27
+ exitPrice: UnsignedDecimalString,
28
+ grossPnl: SignedDecimalString
29
+ }),
30
+ z.object({
31
+ kind: z.literal("UNPRICED"),
32
+ quantity: UnsignedDecimalString
33
+ })
34
+ ]);
35
+ const TradePositionEffect = z.discriminatedUnion("kind", [
36
+ z.object({
37
+ kind: z.literal("OPEN"),
38
+ openedQuantity: UnsignedDecimalString
39
+ }),
40
+ z.object({
41
+ kind: z.literal("INCREASE"),
42
+ increasedQuantity: UnsignedDecimalString
43
+ }),
44
+ z.object({
45
+ kind: z.literal("REDUCE"),
46
+ reducedQuantity: UnsignedDecimalString,
47
+ realization: TradeRealization
48
+ }),
49
+ z.object({
50
+ kind: z.literal("CLOSE"),
51
+ reducedQuantity: UnsignedDecimalString,
52
+ realization: TradeRealization
53
+ }),
54
+ z.object({
55
+ kind: z.literal("FLIP"),
56
+ reducedQuantity: UnsignedDecimalString,
57
+ openedQuantity: UnsignedDecimalString,
58
+ realization: TradeRealization
59
+ })
60
+ ]);
61
+ const TradeFill = z.object({
62
+ id: z.uuid(),
63
+ positionId: z.uuid(),
64
+ symbol: InstrumentId,
65
+ connector: Connector,
66
+ side: z.enum([
67
+ "BUY",
68
+ "SELL"
69
+ ]),
70
+ quantity: UnsignedDecimalString,
71
+ price: UnsignedDecimalString,
72
+ /** Fee polarity is a charge: `+` is paid, `-` is a rebate — the opposite of `grossPnl`/`netCashflow`, where `+` is a gain. */
73
+ tradeFee: SignedDecimalString.optional(),
74
+ /** Same polarity as `tradeFee`: `+` is a charge paid to Pear. */
75
+ pearFee: SignedDecimalString.optional(),
76
+ /** Microsecond-precision UTC instant, rendered exactly like the group's `at`. */
77
+ timestamp: z.iso.datetime(),
78
+ /** RECONCILED rows are superseded and never listed, so only these two states can appear. */
79
+ settlement: FillStatus.extract([
80
+ "PROVISIONAL",
81
+ "CONFIRMED"
82
+ ]),
83
+ executionId: z.uuid().optional(),
84
+ positionEffect: TradePositionEffect,
85
+ basisBefore: TradePositionState,
86
+ basisAfter: TradePositionState
87
+ });
88
+ const TradeGroup = z.object({
89
+ id: z.string().regex(/^(execution|fill):[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/),
90
+ executionId: z.uuid().optional(),
91
+ scheduleId: z.uuid().optional(),
92
+ triggerId: z.uuid().optional(),
93
+ connector: Connector,
94
+ /** Earliest fill instant in the group at microsecond precision; the cursor key. */
95
+ at: z.iso.datetime(),
96
+ /** Priced realized PnL minus every fee in the group; `+` is a gain. */
97
+ netCashflow: SignedDecimalString,
98
+ trades: z.array(TradeFill)
99
+ });
100
+
101
+ export { TradeFill, TradeGroup, TradePositionEffect, TradePositionState, TradeRealization };
@@ -1,2 +1,4 @@
1
+ export * from './entities';
1
2
  export * from './payloads';
3
+ export * from './queries';
2
4
  export * from './responses';
@@ -1,2 +1,4 @@
1
+ export * from './entities';
1
2
  export * from './payloads';
3
+ export * from './queries';
2
4
  export * from './responses';
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ /** Cursor-paginated grouped Trade History query. */
3
+ export declare const TradeListParams: z.ZodObject<{
4
+ cursor: z.ZodOptional<z.ZodString>;
5
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
6
+ }, z.core.$strip>;
7
+ export type TradeListParamsInput = z.input<typeof TradeListParams>;
8
+ export type TradeListParams = z.output<typeof TradeListParams>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { CursorFindParams } from '../common';
3
+
4
+ const TradeListParams = CursorFindParams.extend({
5
+ /** Groups contain every fill in an execution, so keep pages bounded. */
6
+ limit: z.coerce.number().int().positive().max(100).optional().default(20)
7
+ });
8
+
9
+ export { TradeListParams };
@@ -1409,3 +1409,119 @@ export declare const CreateTradeCloseAllResponse: z.ZodObject<{
1409
1409
  }, z.core.$strip>], "intent">], "orderType">>;
1410
1410
  }, z.core.$strip>;
1411
1411
  export type CreateTradeCloseAllResponse = z.output<typeof CreateTradeCloseAllResponse>;
1412
+ /** One cursor page of execution-grouped fill history. */
1413
+ export declare const TradeListResponse: z.ZodObject<{
1414
+ limit: z.ZodNumber;
1415
+ nextCursor: z.ZodOptional<z.ZodString>;
1416
+ groups: z.ZodArray<z.ZodObject<{
1417
+ id: z.ZodString;
1418
+ executionId: z.ZodOptional<z.ZodUUID>;
1419
+ scheduleId: z.ZodOptional<z.ZodUUID>;
1420
+ triggerId: z.ZodOptional<z.ZodUUID>;
1421
+ connector: z.ZodEnum<{
1422
+ hyperliquid: "hyperliquid";
1423
+ binance: "binance";
1424
+ bybit: "bybit";
1425
+ okx: "okx";
1426
+ lighter: "lighter";
1427
+ }>;
1428
+ at: z.ZodISODateTime;
1429
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1430
+ trades: z.ZodArray<z.ZodObject<{
1431
+ id: z.ZodUUID;
1432
+ positionId: z.ZodUUID;
1433
+ symbol: z.ZodString;
1434
+ connector: z.ZodEnum<{
1435
+ hyperliquid: "hyperliquid";
1436
+ binance: "binance";
1437
+ bybit: "bybit";
1438
+ okx: "okx";
1439
+ lighter: "lighter";
1440
+ }>;
1441
+ side: z.ZodEnum<{
1442
+ BUY: "BUY";
1443
+ SELL: "SELL";
1444
+ }>;
1445
+ quantity: z.ZodString;
1446
+ price: z.ZodString;
1447
+ tradeFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
1448
+ pearFee: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
1449
+ timestamp: z.ZodISODateTime;
1450
+ settlement: z.ZodEnum<{
1451
+ PROVISIONAL: "PROVISIONAL";
1452
+ CONFIRMED: "CONFIRMED";
1453
+ }>;
1454
+ executionId: z.ZodOptional<z.ZodUUID>;
1455
+ positionEffect: z.ZodDiscriminatedUnion<[z.ZodObject<{
1456
+ kind: z.ZodLiteral<"OPEN">;
1457
+ openedQuantity: z.ZodString;
1458
+ }, z.core.$strip>, z.ZodObject<{
1459
+ kind: z.ZodLiteral<"INCREASE">;
1460
+ increasedQuantity: z.ZodString;
1461
+ }, z.core.$strip>, z.ZodObject<{
1462
+ kind: z.ZodLiteral<"REDUCE">;
1463
+ reducedQuantity: z.ZodString;
1464
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
1465
+ kind: z.ZodLiteral<"PRICED">;
1466
+ quantity: z.ZodString;
1467
+ entryPrice: z.ZodString;
1468
+ exitPrice: z.ZodString;
1469
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1470
+ }, z.core.$strip>, z.ZodObject<{
1471
+ kind: z.ZodLiteral<"UNPRICED">;
1472
+ quantity: z.ZodString;
1473
+ }, z.core.$strip>], "kind">;
1474
+ }, z.core.$strip>, z.ZodObject<{
1475
+ kind: z.ZodLiteral<"CLOSE">;
1476
+ reducedQuantity: z.ZodString;
1477
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
1478
+ kind: z.ZodLiteral<"PRICED">;
1479
+ quantity: z.ZodString;
1480
+ entryPrice: z.ZodString;
1481
+ exitPrice: z.ZodString;
1482
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1483
+ }, z.core.$strip>, z.ZodObject<{
1484
+ kind: z.ZodLiteral<"UNPRICED">;
1485
+ quantity: z.ZodString;
1486
+ }, z.core.$strip>], "kind">;
1487
+ }, z.core.$strip>, z.ZodObject<{
1488
+ kind: z.ZodLiteral<"FLIP">;
1489
+ reducedQuantity: z.ZodString;
1490
+ openedQuantity: z.ZodString;
1491
+ realization: z.ZodDiscriminatedUnion<[z.ZodObject<{
1492
+ kind: z.ZodLiteral<"PRICED">;
1493
+ quantity: z.ZodString;
1494
+ entryPrice: z.ZodString;
1495
+ exitPrice: z.ZodString;
1496
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1497
+ }, z.core.$strip>, z.ZodObject<{
1498
+ kind: z.ZodLiteral<"UNPRICED">;
1499
+ quantity: z.ZodString;
1500
+ }, z.core.$strip>], "kind">;
1501
+ }, z.core.$strip>], "kind">;
1502
+ basisBefore: z.ZodObject<{
1503
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1504
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
1505
+ kind: z.ZodLiteral<"FLAT">;
1506
+ }, z.core.$strip>, z.ZodObject<{
1507
+ kind: z.ZodLiteral<"PRICED">;
1508
+ entryPrice: z.ZodString;
1509
+ }, z.core.$strip>, z.ZodObject<{
1510
+ kind: z.ZodLiteral<"UNPRICED">;
1511
+ }, z.core.$strip>], "kind">;
1512
+ }, z.core.$strip>;
1513
+ basisAfter: z.ZodObject<{
1514
+ signedQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
1515
+ basis: z.ZodDiscriminatedUnion<[z.ZodObject<{
1516
+ kind: z.ZodLiteral<"FLAT">;
1517
+ }, z.core.$strip>, z.ZodObject<{
1518
+ kind: z.ZodLiteral<"PRICED">;
1519
+ entryPrice: z.ZodString;
1520
+ }, z.core.$strip>, z.ZodObject<{
1521
+ kind: z.ZodLiteral<"UNPRICED">;
1522
+ }, z.core.$strip>], "kind">;
1523
+ }, z.core.$strip>;
1524
+ }, z.core.$strip>>;
1525
+ }, z.core.$strip>>;
1526
+ }, z.core.$strip>;
1527
+ export type TradeListResponse = z.output<typeof TradeListResponse>;
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import { CursorResponse } from '../common';
2
3
  import { Execution } from '../execution/entities';
4
+ import { TradeGroup } from './entities';
3
5
 
4
6
  const CreateTradeOpenResponse = z.object({
5
7
  execution: Execution
@@ -16,5 +18,8 @@ const CreateTradeReverseResponse = z.object({
16
18
  const CreateTradeCloseAllResponse = z.object({
17
19
  executions: z.array(Execution)
18
20
  });
21
+ const TradeListResponse = CursorResponse.extend({
22
+ groups: z.array(TradeGroup)
23
+ });
19
24
 
20
- export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse };
25
+ export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse, TradeListResponse };
@@ -20,6 +20,10 @@ export declare const TradeAccount: z.ZodObject<{
20
20
  okx: "okx";
21
21
  lighter: "lighter";
22
22
  }>;
23
+ kind: z.ZodEnum<{
24
+ vault: "vault";
25
+ eoa: "eoa";
26
+ }>;
23
27
  exchangeIdentifier: z.ZodString;
24
28
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
25
29
  agentWalletAddress: z.ZodString;
@@ -17,6 +17,10 @@ const TradeAccount = z.object({
17
17
  id: z.uuid().describe("Trade account UUID"),
18
18
  alias: z.string().describe("User-defined trade account alias"),
19
19
  connector: Connector.describe("Exchange connector type"),
20
+ kind: z.enum([
21
+ "eoa",
22
+ "vault"
23
+ ]).describe("Whether the account trades an EOA or a Pear vault"),
20
24
  exchangeIdentifier: z.string().describe("User identifier on the exchange"),
21
25
  metadata: ConnectorMetadata.describe("Connector-specific metadata"),
22
26
  createdAt: z.string().describe("Creation timestamp (ISO 8601)"),
@@ -109,6 +109,16 @@ export declare const CreateTradeAccount: z.ZodDiscriminatedUnion<[z.ZodObject<{
109
109
  l1_address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
110
110
  }, z.core.$strip>;
111
111
  }, z.core.$strip>], "connector">;
112
+ /**
113
+ * Payload to create a Pear-vault-backed Hyperliquid trade account. The backend
114
+ * generates and approves the API wallet itself (via pear-vault-service), so
115
+ * the payload carries no credentials.
116
+ */
117
+ export declare const CreateVaultTradeAccount: z.ZodObject<{
118
+ vaultAddress: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
119
+ alias: z.ZodString;
120
+ idempotencyKey: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strip>;
112
122
  /**
113
123
  * Payload to update a trade account
114
124
  */
@@ -174,6 +184,8 @@ export type CreateLighterCredentials = z.infer<typeof CreateLighterCredentials>;
174
184
  export type CreateLighterMetadata = z.infer<typeof CreateLighterMetadata>;
175
185
  export type CreateTradeAccountInput = z.input<typeof CreateTradeAccount>;
176
186
  export type CreateTradeAccount = z.output<typeof CreateTradeAccount>;
187
+ export type CreateVaultTradeAccountInput = z.input<typeof CreateVaultTradeAccount>;
188
+ export type CreateVaultTradeAccount = z.output<typeof CreateVaultTradeAccount>;
177
189
  export type UpdateTradeAccountInput = z.input<typeof UpdateTradeAccount>;
178
190
  export type UpdateTradeAccount = z.output<typeof UpdateTradeAccount>;
179
191
  export {};
@@ -104,6 +104,15 @@ const CreateTradeAccount = z.discriminatedUnion("connector", [
104
104
  CreateOkxAccount,
105
105
  CreateLighterAccount
106
106
  ]);
107
+ const CreateVaultTradeAccount = z.object({
108
+ vaultAddress: EthereumAddress,
109
+ alias: AccountAlias,
110
+ /**
111
+ * Optional caller-supplied key. Reusing it attaches a transport retry to the first attempt;
112
+ * omitting it starts a new create attempt.
113
+ */
114
+ idempotencyKey: z.string().min(1).max(128).optional()
115
+ });
107
116
  const UpdateTradeAccount = z.discriminatedUnion("connector", [
108
117
  UpdateHyperliquidAccount,
109
118
  UpdateBinanceAccount,
@@ -112,4 +121,4 @@ const UpdateTradeAccount = z.discriminatedUnion("connector", [
112
121
  UpdateLighterAccount
113
122
  ]);
114
123
 
115
- export { CreateTradeAccount, UpdateTradeAccount };
124
+ export { CreateTradeAccount, CreateVaultTradeAccount, UpdateTradeAccount };