@pear-protocol/types 2.5.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/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 };
|