@pear-protocol/types 1.19.0 → 1.21.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.
@@ -13,11 +13,13 @@ export declare const LinkEmailRequest: z.ZodObject<{
13
13
  export declare const LinkWalletRequest: z.ZodObject<{
14
14
  address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
15
15
  signature: z.ZodString;
16
+ nonce: z.ZodOptional<z.ZodString>;
16
17
  }, z.core.$strip>;
17
18
  export declare const WalletLoginRequest: z.ZodObject<{
18
19
  method: z.ZodLiteral<"wallet">;
19
20
  address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
20
21
  signature: z.ZodString;
22
+ nonce: z.ZodOptional<z.ZodString>;
21
23
  accessCode: z.ZodOptional<z.ZodString>;
22
24
  }, z.core.$strip>;
23
25
  export declare const EmailLoginRequest: z.ZodObject<{
@@ -44,6 +46,7 @@ export declare const LoginRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
46
  method: z.ZodLiteral<"wallet">;
45
47
  address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
46
48
  signature: z.ZodString;
49
+ nonce: z.ZodOptional<z.ZodString>;
47
50
  accessCode: z.ZodOptional<z.ZodString>;
48
51
  }, z.core.$strip>, z.ZodObject<{
49
52
  method: z.ZodLiteral<"email">;
@@ -4,6 +4,7 @@ const EthereumAddress = z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereu
4
4
  const Email = z.email("Invalid email address").transform((val) => val.toLowerCase()).describe("Email address (lowercase)");
5
5
  const Password = z.string().min(8, "Password must be at least 8 characters").max(128, "Password must be at most 128 characters").describe("Password for authentication");
6
6
  const AccessCode = z.string().trim().max(64).optional().describe("Optional beta access code");
7
+ const SignedNonce = z.string().min(1).max(128).optional().describe("Nonce of the signed challenge, as returned by the nonce endpoint");
7
8
  const RequestNonceRequest = z.object({
8
9
  address: EthereumAddress
9
10
  }).describe("Request a nonce for wallet authentication");
@@ -17,12 +18,14 @@ const LinkEmailRequest = z.object({
17
18
  }).describe("Link email credentials to the authenticated account");
18
19
  const LinkWalletRequest = z.object({
19
20
  address: EthereumAddress,
20
- signature: z.string().min(1, "Signature is required").describe("Signature of the nonce message")
21
+ signature: z.string().min(1, "Signature is required").describe("Signature of the nonce message"),
22
+ nonce: SignedNonce
21
23
  }).describe("Link wallet credentials to the authenticated account");
22
24
  const WalletLoginRequest = z.object({
23
25
  method: z.literal("wallet").describe('Must be "wallet" for wallet authentication'),
24
26
  address: EthereumAddress,
25
27
  signature: z.string().min(1, "Signature is required").describe("Signature of the nonce message"),
28
+ nonce: SignedNonce,
26
29
  accessCode: AccessCode
27
30
  }).describe("Wallet-based authentication using nonce signature");
28
31
  const EmailLoginRequest = z.object({
@@ -26,6 +26,78 @@ export declare const Ladder: z.ZodObject<{
26
26
  ACTIVE: "ACTIVE";
27
27
  COMPLETED: "COMPLETED";
28
28
  }>;
29
+ attachTriggers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
30
+ intent: z.ZodLiteral<"CLOSE">;
31
+ type: z.ZodLiteral<"MARKET">;
32
+ bracketType: z.ZodEnum<{
33
+ STOP_LOSS: "STOP_LOSS";
34
+ TAKE_PROFIT: "TAKE_PROFIT";
35
+ }>;
36
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
37
+ type: z.ZodLiteral<"notional">;
38
+ data: z.ZodObject<{
39
+ priceSource: z.ZodEnum<{
40
+ mid: "mid";
41
+ mark: "mark";
42
+ }>;
43
+ threshold: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>, z.ZodObject<{
46
+ type: z.ZodLiteral<"upnl">;
47
+ data: z.ZodObject<{
48
+ priceSource: z.ZodEnum<{
49
+ mid: "mid";
50
+ mark: "mark";
51
+ }>;
52
+ threshold: z.ZodNumber;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>, z.ZodObject<{
55
+ type: z.ZodLiteral<"upnl_bps">;
56
+ data: z.ZodObject<{
57
+ priceSource: z.ZodEnum<{
58
+ mid: "mid";
59
+ mark: "mark";
60
+ }>;
61
+ threshold: z.ZodNumber;
62
+ }, z.core.$strip>;
63
+ }, z.core.$strip>], "type">;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ intent: z.ZodLiteral<"CLOSE">;
66
+ type: z.ZodLiteral<"MARKET">;
67
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
68
+ type: z.ZodLiteral<"notional_trailing">;
69
+ data: z.ZodObject<{
70
+ priceSource: z.ZodEnum<{
71
+ mid: "mid";
72
+ mark: "mark";
73
+ }>;
74
+ }, z.core.$strip>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ type: z.ZodLiteral<"upnl_trailing">;
77
+ data: z.ZodObject<{
78
+ priceSource: z.ZodEnum<{
79
+ mid: "mid";
80
+ mark: "mark";
81
+ }>;
82
+ }, z.core.$strip>;
83
+ }, z.core.$strip>, z.ZodObject<{
84
+ type: z.ZodLiteral<"upnl_bps_trailing">;
85
+ data: z.ZodObject<{
86
+ priceSource: z.ZodEnum<{
87
+ mid: "mid";
88
+ mark: "mark";
89
+ }>;
90
+ }, z.core.$strip>;
91
+ }, z.core.$strip>], "type">;
92
+ trailing: z.ZodObject<{
93
+ mode: z.ZodEnum<{
94
+ RELATIVE_BPS: "RELATIVE_BPS";
95
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
96
+ }>;
97
+ deltaValue: z.ZodNumber;
98
+ activationValue: z.ZodOptional<z.ZodNumber>;
99
+ }, z.core.$strip>;
100
+ }, z.core.$strip>]>>>;
29
101
  triggers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
30
102
  id: z.ZodUUID;
31
103
  tradeAccountId: z.ZodUUID;
@@ -95,6 +167,11 @@ export declare const Ladder: z.ZodObject<{
95
167
  TAKE_PROFIT: "TAKE_PROFIT";
96
168
  NONE: "NONE";
97
169
  }>;
170
+ semanticBracketType: z.ZodOptional<z.ZodEnum<{
171
+ STOP_LOSS: "STOP_LOSS";
172
+ TAKE_PROFIT: "TAKE_PROFIT";
173
+ NONE: "NONE";
174
+ }>>;
98
175
  createdAt: z.ZodString;
99
176
  updatedAt: z.ZodString;
100
177
  intent: z.ZodLiteral<"OPEN">;
@@ -296,6 +373,11 @@ export declare const Ladder: z.ZodObject<{
296
373
  TAKE_PROFIT: "TAKE_PROFIT";
297
374
  NONE: "NONE";
298
375
  }>;
376
+ semanticBracketType: z.ZodOptional<z.ZodEnum<{
377
+ STOP_LOSS: "STOP_LOSS";
378
+ TAKE_PROFIT: "TAKE_PROFIT";
379
+ NONE: "NONE";
380
+ }>>;
299
381
  createdAt: z.ZodString;
300
382
  updatedAt: z.ZodString;
301
383
  intent: z.ZodLiteral<"ADJUST">;
@@ -543,6 +625,11 @@ export declare const Ladder: z.ZodObject<{
543
625
  TAKE_PROFIT: "TAKE_PROFIT";
544
626
  NONE: "NONE";
545
627
  }>;
628
+ semanticBracketType: z.ZodOptional<z.ZodEnum<{
629
+ STOP_LOSS: "STOP_LOSS";
630
+ TAKE_PROFIT: "TAKE_PROFIT";
631
+ NONE: "NONE";
632
+ }>>;
546
633
  createdAt: z.ZodString;
547
634
  updatedAt: z.ZodString;
548
635
  intent: z.ZodLiteral<"CLOSE">;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { Connector } from '../connector';
3
3
  import { Trigger } from '../trigger';
4
+ import { AttachTriggerMarketCloseList } from '../trigger/payloads';
4
5
  import { LadderConfig } from './payloads';
5
6
 
6
7
  const LadderStatus = z.enum(["ACTIVE", "COMPLETED", "CANCELLED"]);
@@ -10,6 +11,7 @@ const Ladder = z.object({
10
11
  positionKey: z.string(),
11
12
  config: LadderConfig,
12
13
  status: LadderStatus,
14
+ attachTriggers: AttachTriggerMarketCloseList.optional(),
13
15
  triggers: z.array(Trigger),
14
16
  createdAt: z.string(),
15
17
  updatedAt: z.string()
@@ -111,6 +111,78 @@ export declare const CreateLadderMarketOpen: z.ZodObject<{
111
111
  levels: z.ZodInt;
112
112
  weighting: z.ZodDefault<z.ZodLiteral<"EQUAL">>;
113
113
  }, z.core.$strip>;
114
+ attachTriggers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
115
+ intent: z.ZodLiteral<"CLOSE">;
116
+ type: z.ZodLiteral<"MARKET">;
117
+ bracketType: z.ZodEnum<{
118
+ STOP_LOSS: "STOP_LOSS";
119
+ TAKE_PROFIT: "TAKE_PROFIT";
120
+ }>;
121
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
+ type: z.ZodLiteral<"notional">;
123
+ data: z.ZodObject<{
124
+ priceSource: z.ZodEnum<{
125
+ mid: "mid";
126
+ mark: "mark";
127
+ }>;
128
+ threshold: z.ZodNumber;
129
+ }, z.core.$strip>;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ type: z.ZodLiteral<"upnl">;
132
+ data: z.ZodObject<{
133
+ priceSource: z.ZodEnum<{
134
+ mid: "mid";
135
+ mark: "mark";
136
+ }>;
137
+ threshold: z.ZodNumber;
138
+ }, z.core.$strip>;
139
+ }, z.core.$strip>, z.ZodObject<{
140
+ type: z.ZodLiteral<"upnl_bps">;
141
+ data: z.ZodObject<{
142
+ priceSource: z.ZodEnum<{
143
+ mid: "mid";
144
+ mark: "mark";
145
+ }>;
146
+ threshold: z.ZodNumber;
147
+ }, z.core.$strip>;
148
+ }, z.core.$strip>], "type">;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ intent: z.ZodLiteral<"CLOSE">;
151
+ type: z.ZodLiteral<"MARKET">;
152
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
153
+ type: z.ZodLiteral<"notional_trailing">;
154
+ data: z.ZodObject<{
155
+ priceSource: z.ZodEnum<{
156
+ mid: "mid";
157
+ mark: "mark";
158
+ }>;
159
+ }, z.core.$strip>;
160
+ }, z.core.$strip>, z.ZodObject<{
161
+ type: z.ZodLiteral<"upnl_trailing">;
162
+ data: z.ZodObject<{
163
+ priceSource: z.ZodEnum<{
164
+ mid: "mid";
165
+ mark: "mark";
166
+ }>;
167
+ }, z.core.$strip>;
168
+ }, z.core.$strip>, z.ZodObject<{
169
+ type: z.ZodLiteral<"upnl_bps_trailing">;
170
+ data: z.ZodObject<{
171
+ priceSource: z.ZodEnum<{
172
+ mid: "mid";
173
+ mark: "mark";
174
+ }>;
175
+ }, z.core.$strip>;
176
+ }, z.core.$strip>], "type">;
177
+ trailing: z.ZodObject<{
178
+ mode: z.ZodEnum<{
179
+ RELATIVE_BPS: "RELATIVE_BPS";
180
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
181
+ }>;
182
+ deltaValue: z.ZodNumber;
183
+ activationValue: z.ZodOptional<z.ZodNumber>;
184
+ }, z.core.$strip>;
185
+ }, z.core.$strip>]>>>;
114
186
  payload: z.ZodObject<{
115
187
  type: z.ZodLiteral<"MARKET">;
116
188
  legs: z.ZodTuple<[z.ZodObject<{
@@ -137,7 +209,7 @@ export declare const CreateLadderMarketOpen: z.ZodObject<{
137
209
  amount: z.ZodString;
138
210
  }, z.core.$strip>>;
139
211
  }, z.core.$strip>;
140
- }, z.core.$strip>;
212
+ }, z.core.$strict>;
141
213
  export declare const CreateLadder: z.ZodDiscriminatedUnion<[z.ZodObject<{
142
214
  type: z.ZodLiteral<"MARKET">;
143
215
  intent: z.ZodLiteral<"OPEN">;
@@ -196,6 +268,78 @@ export declare const CreateLadder: z.ZodDiscriminatedUnion<[z.ZodObject<{
196
268
  levels: z.ZodInt;
197
269
  weighting: z.ZodDefault<z.ZodLiteral<"EQUAL">>;
198
270
  }, z.core.$strip>;
271
+ attachTriggers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
272
+ intent: z.ZodLiteral<"CLOSE">;
273
+ type: z.ZodLiteral<"MARKET">;
274
+ bracketType: z.ZodEnum<{
275
+ STOP_LOSS: "STOP_LOSS";
276
+ TAKE_PROFIT: "TAKE_PROFIT";
277
+ }>;
278
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
279
+ type: z.ZodLiteral<"notional">;
280
+ data: z.ZodObject<{
281
+ priceSource: z.ZodEnum<{
282
+ mid: "mid";
283
+ mark: "mark";
284
+ }>;
285
+ threshold: z.ZodNumber;
286
+ }, z.core.$strip>;
287
+ }, z.core.$strip>, z.ZodObject<{
288
+ type: z.ZodLiteral<"upnl">;
289
+ data: z.ZodObject<{
290
+ priceSource: z.ZodEnum<{
291
+ mid: "mid";
292
+ mark: "mark";
293
+ }>;
294
+ threshold: z.ZodNumber;
295
+ }, z.core.$strip>;
296
+ }, z.core.$strip>, z.ZodObject<{
297
+ type: z.ZodLiteral<"upnl_bps">;
298
+ data: z.ZodObject<{
299
+ priceSource: z.ZodEnum<{
300
+ mid: "mid";
301
+ mark: "mark";
302
+ }>;
303
+ threshold: z.ZodNumber;
304
+ }, z.core.$strip>;
305
+ }, z.core.$strip>], "type">;
306
+ }, z.core.$strip>, z.ZodObject<{
307
+ intent: z.ZodLiteral<"CLOSE">;
308
+ type: z.ZodLiteral<"MARKET">;
309
+ condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
310
+ type: z.ZodLiteral<"notional_trailing">;
311
+ data: z.ZodObject<{
312
+ priceSource: z.ZodEnum<{
313
+ mid: "mid";
314
+ mark: "mark";
315
+ }>;
316
+ }, z.core.$strip>;
317
+ }, z.core.$strip>, z.ZodObject<{
318
+ type: z.ZodLiteral<"upnl_trailing">;
319
+ data: z.ZodObject<{
320
+ priceSource: z.ZodEnum<{
321
+ mid: "mid";
322
+ mark: "mark";
323
+ }>;
324
+ }, z.core.$strip>;
325
+ }, z.core.$strip>, z.ZodObject<{
326
+ type: z.ZodLiteral<"upnl_bps_trailing">;
327
+ data: z.ZodObject<{
328
+ priceSource: z.ZodEnum<{
329
+ mid: "mid";
330
+ mark: "mark";
331
+ }>;
332
+ }, z.core.$strip>;
333
+ }, z.core.$strip>], "type">;
334
+ trailing: z.ZodObject<{
335
+ mode: z.ZodEnum<{
336
+ RELATIVE_BPS: "RELATIVE_BPS";
337
+ ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
338
+ }>;
339
+ deltaValue: z.ZodNumber;
340
+ activationValue: z.ZodOptional<z.ZodNumber>;
341
+ }, z.core.$strip>;
342
+ }, z.core.$strip>]>>>;
199
343
  payload: z.ZodObject<{
200
344
  type: z.ZodLiteral<"MARKET">;
201
345
  legs: z.ZodTuple<[z.ZodObject<{
@@ -222,7 +366,7 @@ export declare const CreateLadder: z.ZodDiscriminatedUnion<[z.ZodObject<{
222
366
  amount: z.ZodString;
223
367
  }, z.core.$strip>>;
224
368
  }, z.core.$strip>;
225
- }, z.core.$strip>], "type">;
369
+ }, z.core.$strict>], "type">;
226
370
  export type LadderConfig = z.output<typeof LadderConfig>;
227
371
  export type LadderConditionOpen = z.output<typeof LadderConditionOpen>;
228
372
  export type CreateLadderMarketOpen = z.output<typeof CreateLadderMarketOpen>;
@@ -5,6 +5,7 @@ import { AssetWeight, Side } from '../common/schema';
5
5
  import { TradeLegPostOnly } from '../common/trade-legs';
6
6
  import { InstrumentId } from '../instrument';
7
7
  import { MetricTrack } from '../trigger/common';
8
+ import { AttachTriggerMarketCloseList } from '../trigger/payloads';
8
9
 
9
10
  const LadderThreshold = z.number().positive({
10
11
  message: "Threshold must be greater than 0"
@@ -56,17 +57,29 @@ const LadderConditionOpen = z.discriminatedUnion("type", [
56
57
  LadderPriceOpen,
57
58
  LadderWeightedRatioOpen
58
59
  ]);
60
+ const LadderAttachTriggers = AttachTriggerMarketCloseList.superRefine((attachTriggers, ctx) => {
61
+ attachTriggers.forEach((attachTrigger, index) => {
62
+ if (attachTrigger.condition.type === "notional" || attachTrigger.condition.type === "notional_trailing") {
63
+ ctx.addIssue({
64
+ code: "custom",
65
+ path: [index, "condition", "type"],
66
+ message: "Ladder brackets cannot use notional conditions; use upnl or upnl_bps."
67
+ });
68
+ }
69
+ });
70
+ });
59
71
  const CreateLadderMarketOpen = z.object({
60
72
  type: z.literal("MARKET"),
61
73
  intent: z.literal("OPEN"),
62
74
  clientId: ClientIdCode,
63
75
  condition: LadderConditionOpen,
64
76
  config: LadderConfig,
77
+ attachTriggers: LadderAttachTriggers.optional(),
65
78
  payload: z.object({
66
79
  type: z.literal("MARKET"),
67
80
  legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols)
68
81
  })
69
- });
82
+ }).strict();
70
83
  const CreateLadder = z.discriminatedUnion("type", [CreateLadderMarketOpen]);
71
84
 
72
85
  export { CreateLadder, CreateLadderMarketOpen, LadderConditionOpen, LadderConfig };