@pear-protocol/types 2.4.0 → 2.6.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/position/entities.d.ts +13 -5
- package/dist/position/entities.js +1 -0
- package/dist/position/responses.d.ts +1 -0
- package/dist/trade/payloads.d.ts +66 -0
- package/dist/trade/payloads.js +16 -2
- package/dist/trade/responses.d.ts +9 -0
- package/dist/trade/responses.js +9 -1
- package/package.json +1 -1
|
@@ -523,8 +523,14 @@ export declare const VaultOpenPosition: z.ZodObject<{
|
|
|
523
523
|
}, z.core.$strip>;
|
|
524
524
|
export type VaultOpenPosition = z.output<typeof VaultOpenPosition>;
|
|
525
525
|
/**
|
|
526
|
-
* The public, vault-scoped view of one closed leg: entry, exit and PnL,
|
|
527
|
-
* and
|
|
526
|
+
* The public, vault-scoped view of one closed leg: entry, exit, committed cash and PnL,
|
|
527
|
+
* with fees and funding withheld. Same allowlist rule as `VaultOpenPositionLeg`.
|
|
528
|
+
* `entryNotional` is this leg's peak committed cash, not an additive share of the position.
|
|
529
|
+
* For basket ratios, divide each leg's value by the sum of all leg entry notionals.
|
|
530
|
+
* "0" means committed cash is unknowable after an unpriced synthetic entry; clients
|
|
531
|
+
* must leave the basket quote unknown rather than treat that leg as weightless.
|
|
532
|
+
* Either VWAP is absent on a leg the ledger never priced, and absence binds the same
|
|
533
|
+
* way: quote the side that priced, and leave the side that did not unknown.
|
|
528
534
|
*/
|
|
529
535
|
export declare const VaultClosedPositionLeg: z.ZodObject<{
|
|
530
536
|
side: z.ZodEnum<{
|
|
@@ -534,14 +540,15 @@ export declare const VaultClosedPositionLeg: z.ZodObject<{
|
|
|
534
540
|
asset: z.ZodString;
|
|
535
541
|
grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
536
542
|
netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
543
|
+
entryNotional: z.ZodString;
|
|
537
544
|
entryVwap: z.ZodOptional<z.ZodString>;
|
|
538
545
|
exitVwap: z.ZodOptional<z.ZodString>;
|
|
539
546
|
}, z.core.$strip>;
|
|
540
547
|
export type VaultClosedPositionLeg = z.output<typeof VaultClosedPositionLeg>;
|
|
541
548
|
/**
|
|
542
|
-
* The public, vault-scoped view of one closed position: lifecycle, position-level PnL
|
|
543
|
-
*
|
|
544
|
-
* `netPnl` never folds it in
|
|
549
|
+
* The public, vault-scoped view of one closed position: lifecycle, position-level PnL,
|
|
550
|
+
* and reduced legs with the inputs needed to quote the basket. Funding is withheld for
|
|
551
|
+
* the same reason as on `VaultOpenPosition`; `netPnl` never folds it in.
|
|
545
552
|
*/
|
|
546
553
|
export declare const VaultClosedPosition: z.ZodObject<{
|
|
547
554
|
status: z.ZodLiteral<"CLOSED">;
|
|
@@ -571,6 +578,7 @@ export declare const VaultClosedPosition: z.ZodObject<{
|
|
|
571
578
|
asset: z.ZodString;
|
|
572
579
|
grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
573
580
|
netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
581
|
+
entryNotional: z.ZodString;
|
|
574
582
|
entryVwap: z.ZodOptional<z.ZodString>;
|
|
575
583
|
exitVwap: z.ZodOptional<z.ZodString>;
|
|
576
584
|
}, z.core.$strip>>;
|
|
@@ -379,6 +379,7 @@ export declare const VaultClosedPositionListResponse: z.ZodObject<{
|
|
|
379
379
|
asset: z.ZodString;
|
|
380
380
|
grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
381
381
|
netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
382
|
+
entryNotional: z.ZodString;
|
|
382
383
|
entryVwap: z.ZodOptional<z.ZodString>;
|
|
383
384
|
exitVwap: z.ZodOptional<z.ZodString>;
|
|
384
385
|
}, z.core.$strip>>;
|
package/dist/trade/payloads.d.ts
CHANGED
|
@@ -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>;
|
package/dist/trade/payloads.js
CHANGED
|
@@ -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;
|
package/dist/trade/responses.js
CHANGED
|
@@ -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 };
|