@polymarket/bindings 0.1.0-beta.2 → 0.1.0-beta.3

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/rfq.d.ts ADDED
@@ -0,0 +1,546 @@
1
+ import * as _polymarket_types from '@polymarket/types';
2
+ import { EvmAddress, HexString, EvmSignature, Erc1271Signature } from '@polymarket/types';
3
+ import { RfqId, RfqQuoteId, PositionId, ConditionId, DecimalString, EpochMilliseconds, OrderSide, TokenId, BaseUnits, RfqRequestorPublicId } from './index.js';
4
+ import { z } from 'zod';
5
+ import { S as SignatureType } from './signature-type-CrLAA9AN.js';
6
+
7
+ declare enum RfqDirection {
8
+ Buy = "BUY",
9
+ Sell = "SELL"
10
+ }
11
+ declare enum RfqSide {
12
+ Yes = "YES",
13
+ No = "NO"
14
+ }
15
+ declare enum RfqConfirmationDecision {
16
+ Confirm = "CONFIRM",
17
+ Decline = "DECLINE"
18
+ }
19
+ declare enum RfqExecutionStatus {
20
+ Matched = "MATCHED",
21
+ Mined = "MINED",
22
+ Confirmed = "CONFIRMED",
23
+ Retrying = "RETRYING",
24
+ Failed = "FAILED"
25
+ }
26
+ declare enum RfqRequestedSizeUnit {
27
+ Notional = "notional",
28
+ Shares = "shares"
29
+ }
30
+ declare enum RfqErrorCode {
31
+ AddressMismatch = "ADDRESS_MISMATCH",
32
+ CompetitionWindowClosed = "COMPETITION_WINDOW_CLOSED",
33
+ ContradictoryLegs = "CONTRADICTORY_LEGS",
34
+ ExpiredRfq = "EXPIRED_RFQ",
35
+ InvalidAcceptance = "INVALID_ACCEPTANCE",
36
+ InvalidConfirmation = "INVALID_CONFIRMATION",
37
+ InvalidExecutionResult = "INVALID_EXECUTION_RESULT",
38
+ InvalidIdentity = "INVALID_IDENTITY",
39
+ InvalidMessage = "INVALID_MESSAGE",
40
+ InvalidQuote = "INVALID_QUOTE",
41
+ InvalidRfq = "INVALID_RFQ",
42
+ InvalidRfqState = "INVALID_RFQ_STATE",
43
+ InvalidRole = "INVALID_ROLE",
44
+ LegMetadataUnavailable = "LEG_METADATA_UNAVAILABLE",
45
+ MakerAlreadyResponded = "MAKER_ALREADY_RESPONDED",
46
+ MakerNotRequired = "MAKER_NOT_REQUIRED",
47
+ QuoteMismatch = "QUOTE_MISMATCH",
48
+ QuoteUnavailable = "QUOTE_UNAVAILABLE",
49
+ RateLimited = "RATE_LIMITED",
50
+ RequestFailed = "REQUEST_FAILED",
51
+ ServiceUnavailable = "SERVICE_UNAVAILABLE",
52
+ TradeSubmissionFailed = "TRADE_SUBMISSION_FAILED",
53
+ Unauthenticated = "UNAUTHENTICATED",
54
+ UnauthorizedRole = "UNAUTHORIZED_ROLE",
55
+ UnknownRfq = "UNKNOWN_RFQ"
56
+ }
57
+ declare const RfqDirectionSchema: z.ZodEnum<typeof RfqDirection>;
58
+ declare const RfqSideSchema: z.ZodLiteral<RfqSide.Yes>;
59
+ declare const RfqConfirmationDecisionSchema: z.ZodEnum<typeof RfqConfirmationDecision>;
60
+ declare const RfqExecutionStatusSchema: z.ZodEnum<typeof RfqExecutionStatus>;
61
+ declare const RfqRequestedSizeUnitSchema: z.ZodEnum<typeof RfqRequestedSizeUnit>;
62
+ declare const RfqErrorCodeSchema: z.ZodEnum<typeof RfqErrorCode>;
63
+ type RfqRequestedSize = {
64
+ unit: RfqRequestedSizeUnit.Notional;
65
+ value: DecimalString;
66
+ } | {
67
+ unit: RfqRequestedSizeUnit.Shares;
68
+ value: DecimalString;
69
+ };
70
+ type RfqSignedOrder = {
71
+ salt: string;
72
+ maker: EvmAddress;
73
+ signer: EvmAddress;
74
+ tokenId: PositionId | TokenId;
75
+ makerAmount: BaseUnits;
76
+ takerAmount: BaseUnits;
77
+ side: RfqOrderSide;
78
+ signatureType: SignatureType;
79
+ timestamp: string;
80
+ builder?: HexString;
81
+ expiration?: string;
82
+ metadata?: HexString;
83
+ signature: EvmSignature | Erc1271Signature;
84
+ };
85
+ type RfqOrderSide = OrderSide | 0 | 1;
86
+ type RfqAuthMessage = {
87
+ type: 'auth';
88
+ auth: {
89
+ apiKey: string;
90
+ passphrase: string;
91
+ secret: string;
92
+ };
93
+ identity: {
94
+ signer_address: EvmAddress;
95
+ maker_address: EvmAddress;
96
+ signature_type: SignatureType;
97
+ };
98
+ };
99
+ declare enum RfqKnownInboundType {
100
+ Auth = "auth",
101
+ QuoteRequest = "RFQ_REQUEST",
102
+ QuoteAck = "ACK_RFQ_QUOTE",
103
+ QuoteCancelAck = "ACK_RFQ_QUOTE_CANCEL",
104
+ ConfirmationRequest = "RFQ_CONFIRMATION_REQUEST",
105
+ ConfirmationAck = "ACK_RFQ_CONFIRMATION_RESPONSE",
106
+ ExecutionUpdate = "RFQ_EXECUTION_UPDATE",
107
+ Error = "RFQ_ERROR"
108
+ }
109
+ declare const RfqKnownInboundMessageSchema: z.ZodObject<{
110
+ type: z.ZodEnum<typeof RfqKnownInboundType>;
111
+ }, z.core.$strip>;
112
+ declare const RfqAuthResponseMessageSchema: z.ZodObject<{
113
+ type: z.ZodLiteral<RfqKnownInboundType.Auth>;
114
+ success: z.ZodBoolean;
115
+ address: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>>;
116
+ role: z.ZodOptional<z.ZodString>;
117
+ error: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>;
119
+ type RfqAuthResponseMessage = z.infer<typeof RfqAuthResponseMessageSchema>;
120
+ declare const RfqQuoteRequestSchema: z.ZodPipe<z.ZodObject<{
121
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteRequest>;
122
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
123
+ requestor_public_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqRequestorPublicId, string>>;
124
+ leg_position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
125
+ condition_id: z.ZodPipe<z.ZodString, z.ZodTransform<ConditionId, string>>;
126
+ yes_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
127
+ no_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
128
+ direction: z.ZodEnum<typeof RfqDirection>;
129
+ side: z.ZodLiteral<RfqSide.Yes>;
130
+ requested_size: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
131
+ unit: z.ZodLiteral<RfqRequestedSizeUnit.Notional>;
132
+ value_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ unit: z.ZodLiteral<RfqRequestedSizeUnit.Shares>;
135
+ value_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
136
+ }, z.core.$strip>], "unit">, z.ZodTransform<{
137
+ unit: RfqRequestedSizeUnit.Notional;
138
+ value: DecimalString;
139
+ } | {
140
+ unit: RfqRequestedSizeUnit.Shares;
141
+ value: DecimalString;
142
+ }, {
143
+ unit: RfqRequestedSizeUnit.Notional;
144
+ value_e6: DecimalString;
145
+ } | {
146
+ unit: RfqRequestedSizeUnit.Shares;
147
+ value_e6: DecimalString;
148
+ }>>;
149
+ submission_deadline: z.ZodPipe<z.ZodNumber, z.ZodTransform<EpochMilliseconds, number>>;
150
+ }, z.core.$strip>, z.ZodTransform<{
151
+ conditionId: ConditionId;
152
+ direction: RfqDirection;
153
+ legPositionIds: PositionId[];
154
+ noPositionId: PositionId;
155
+ requestorPublicId: RfqRequestorPublicId;
156
+ requestedSize: {
157
+ unit: RfqRequestedSizeUnit.Notional;
158
+ value: DecimalString;
159
+ } | {
160
+ unit: RfqRequestedSizeUnit.Shares;
161
+ value: DecimalString;
162
+ };
163
+ rfqId: RfqId;
164
+ side: RfqSide.Yes;
165
+ submissionDeadline: EpochMilliseconds;
166
+ type: "quote_request";
167
+ yesPositionId: PositionId;
168
+ }, {
169
+ type: RfqKnownInboundType.QuoteRequest;
170
+ rfq_id: RfqId;
171
+ requestor_public_id: RfqRequestorPublicId;
172
+ leg_position_ids: PositionId[];
173
+ condition_id: ConditionId;
174
+ yes_position_id: PositionId;
175
+ no_position_id: PositionId;
176
+ direction: RfqDirection;
177
+ side: RfqSide.Yes;
178
+ requested_size: {
179
+ unit: RfqRequestedSizeUnit.Notional;
180
+ value: DecimalString;
181
+ } | {
182
+ unit: RfqRequestedSizeUnit.Shares;
183
+ value: DecimalString;
184
+ };
185
+ submission_deadline: EpochMilliseconds;
186
+ }>>;
187
+ type RfqQuoteRequest = z.infer<typeof RfqQuoteRequestSchema>;
188
+ type RfqQuoteMessage = {
189
+ type: 'RFQ_QUOTE';
190
+ rfq_id: RfqId;
191
+ price_e6: string;
192
+ size_e6: string;
193
+ signed_order: RfqSignedOrder;
194
+ };
195
+ type RfqQuoteCancelMessage = {
196
+ type: 'RFQ_QUOTE_CANCEL';
197
+ rfq_id: RfqId;
198
+ quote_id: RfqQuoteId;
199
+ signer_address: EvmAddress;
200
+ maker_address: EvmAddress;
201
+ };
202
+ declare const RfqQuoteAckSchema: z.ZodPipe<z.ZodObject<{
203
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteAck>;
204
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
205
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
206
+ }, z.core.$strip>, z.ZodTransform<{
207
+ quoteId: RfqQuoteId;
208
+ rfqId: RfqId;
209
+ type: "quote_ack";
210
+ }, {
211
+ type: RfqKnownInboundType.QuoteAck;
212
+ rfq_id: RfqId;
213
+ quote_id: RfqQuoteId;
214
+ }>>;
215
+ type RfqQuoteAck = z.infer<typeof RfqQuoteAckSchema>;
216
+ declare const RfqQuoteCancelAckSchema: z.ZodPipe<z.ZodObject<{
217
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteCancelAck>;
218
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
219
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
220
+ }, z.core.$strip>, z.ZodTransform<{
221
+ quoteId: RfqQuoteId;
222
+ rfqId: RfqId;
223
+ type: "quote_cancel_ack";
224
+ }, {
225
+ type: RfqKnownInboundType.QuoteCancelAck;
226
+ rfq_id: RfqId;
227
+ quote_id: RfqQuoteId;
228
+ }>>;
229
+ type RfqQuoteCancelAck = z.infer<typeof RfqQuoteCancelAckSchema>;
230
+ declare const RfqConfirmationRequestSchema: z.ZodPipe<z.ZodObject<{
231
+ type: z.ZodLiteral<RfqKnownInboundType.ConfirmationRequest>;
232
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
233
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
234
+ signer_address: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
235
+ maker_address: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
236
+ signature_type: z.ZodEnum<typeof SignatureType>;
237
+ leg_position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
238
+ condition_id: z.ZodPipe<z.ZodString, z.ZodTransform<ConditionId, string>>;
239
+ yes_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
240
+ no_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
241
+ direction: z.ZodEnum<typeof RfqDirection>;
242
+ side: z.ZodLiteral<RfqSide.Yes>;
243
+ fill_size_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
244
+ price_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
245
+ confirm_by: z.ZodPipe<z.ZodNumber, z.ZodTransform<EpochMilliseconds, number>>;
246
+ }, z.core.$strip>, z.ZodTransform<{
247
+ conditionId: ConditionId;
248
+ confirmBy: EpochMilliseconds;
249
+ direction: RfqDirection;
250
+ fillSize: DecimalString;
251
+ legPositionIds: PositionId[];
252
+ makerAddress: EvmAddress;
253
+ noPositionId: PositionId;
254
+ price: DecimalString;
255
+ quoteId: RfqQuoteId;
256
+ rfqId: RfqId;
257
+ side: RfqSide.Yes;
258
+ signatureType: SignatureType;
259
+ signerAddress: EvmAddress;
260
+ type: "confirmation_request";
261
+ yesPositionId: PositionId;
262
+ }, {
263
+ type: RfqKnownInboundType.ConfirmationRequest;
264
+ rfq_id: RfqId;
265
+ quote_id: RfqQuoteId;
266
+ signer_address: EvmAddress;
267
+ maker_address: EvmAddress;
268
+ signature_type: SignatureType;
269
+ leg_position_ids: PositionId[];
270
+ condition_id: ConditionId;
271
+ yes_position_id: PositionId;
272
+ no_position_id: PositionId;
273
+ direction: RfqDirection;
274
+ side: RfqSide.Yes;
275
+ fill_size_e6: DecimalString;
276
+ price_e6: DecimalString;
277
+ confirm_by: EpochMilliseconds;
278
+ }>>;
279
+ type RfqConfirmationRequest = z.infer<typeof RfqConfirmationRequestSchema>;
280
+ type RfqConfirmationResponseMessage = {
281
+ type: 'RFQ_CONFIRMATION_RESPONSE';
282
+ rfq_id: RfqId;
283
+ quote_id: RfqQuoteId;
284
+ decision: RfqConfirmationDecision;
285
+ };
286
+ declare const RfqConfirmationAckSchema: z.ZodPipe<z.ZodObject<{
287
+ type: z.ZodLiteral<RfqKnownInboundType.ConfirmationAck>;
288
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
289
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
290
+ decision: z.ZodEnum<typeof RfqConfirmationDecision>;
291
+ }, z.core.$strip>, z.ZodTransform<{
292
+ decision: RfqConfirmationDecision;
293
+ quoteId: RfqQuoteId;
294
+ rfqId: RfqId;
295
+ type: "confirmation_ack";
296
+ }, {
297
+ type: RfqKnownInboundType.ConfirmationAck;
298
+ rfq_id: RfqId;
299
+ quote_id: RfqQuoteId;
300
+ decision: RfqConfirmationDecision;
301
+ }>>;
302
+ type RfqConfirmationAck = z.infer<typeof RfqConfirmationAckSchema>;
303
+ declare const RfqExecutionUpdateSchema: z.ZodPipe<z.ZodObject<{
304
+ type: z.ZodLiteral<RfqKnownInboundType.ExecutionUpdate>;
305
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
306
+ status: z.ZodEnum<typeof RfqExecutionStatus>;
307
+ tx_hash: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<_polymarket_types.TxHash, string>>>;
308
+ }, z.core.$strip>, z.ZodTransform<{
309
+ type: "execution_update";
310
+ txHash?: _polymarket_types.TxHash | undefined;
311
+ rfqId: RfqId;
312
+ status: RfqExecutionStatus;
313
+ }, {
314
+ type: RfqKnownInboundType.ExecutionUpdate;
315
+ rfq_id: RfqId;
316
+ status: RfqExecutionStatus;
317
+ tx_hash?: _polymarket_types.TxHash | undefined;
318
+ }>>;
319
+ type RfqExecutionUpdate = z.infer<typeof RfqExecutionUpdateSchema>;
320
+ declare const RfqErrorMessageSchema: z.ZodPipe<z.ZodObject<{
321
+ type: z.ZodLiteral<RfqKnownInboundType.Error>;
322
+ request_type: z.ZodOptional<z.ZodString>;
323
+ rfq_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>>;
324
+ quote_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>>;
325
+ code: z.ZodEnum<typeof RfqErrorCode>;
326
+ error: z.ZodString;
327
+ request: z.ZodOptional<z.ZodUnknown>;
328
+ }, z.core.$strip>, z.ZodTransform<{
329
+ code: RfqErrorCode;
330
+ message: string;
331
+ quoteId: RfqQuoteId | undefined;
332
+ requestType: string | undefined;
333
+ rfqId: RfqId | undefined;
334
+ type: "rfq_error";
335
+ }, {
336
+ type: RfqKnownInboundType.Error;
337
+ code: RfqErrorCode;
338
+ error: string;
339
+ request_type?: string | undefined;
340
+ rfq_id?: RfqId | undefined;
341
+ quote_id?: RfqQuoteId | undefined;
342
+ request?: unknown;
343
+ }>>;
344
+ type RfqErrorMessage = z.infer<typeof RfqErrorMessageSchema>;
345
+ declare const RfqQuoterInboundMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
346
+ type: z.ZodLiteral<RfqKnownInboundType.Auth>;
347
+ success: z.ZodBoolean;
348
+ address: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>>;
349
+ role: z.ZodOptional<z.ZodString>;
350
+ error: z.ZodOptional<z.ZodString>;
351
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
352
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteRequest>;
353
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
354
+ requestor_public_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqRequestorPublicId, string>>;
355
+ leg_position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
356
+ condition_id: z.ZodPipe<z.ZodString, z.ZodTransform<ConditionId, string>>;
357
+ yes_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
358
+ no_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
359
+ direction: z.ZodEnum<typeof RfqDirection>;
360
+ side: z.ZodLiteral<RfqSide.Yes>;
361
+ requested_size: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
362
+ unit: z.ZodLiteral<RfqRequestedSizeUnit.Notional>;
363
+ value_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
364
+ }, z.core.$strip>, z.ZodObject<{
365
+ unit: z.ZodLiteral<RfqRequestedSizeUnit.Shares>;
366
+ value_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
367
+ }, z.core.$strip>], "unit">, z.ZodTransform<{
368
+ unit: RfqRequestedSizeUnit.Notional;
369
+ value: DecimalString;
370
+ } | {
371
+ unit: RfqRequestedSizeUnit.Shares;
372
+ value: DecimalString;
373
+ }, {
374
+ unit: RfqRequestedSizeUnit.Notional;
375
+ value_e6: DecimalString;
376
+ } | {
377
+ unit: RfqRequestedSizeUnit.Shares;
378
+ value_e6: DecimalString;
379
+ }>>;
380
+ submission_deadline: z.ZodPipe<z.ZodNumber, z.ZodTransform<EpochMilliseconds, number>>;
381
+ }, z.core.$strip>, z.ZodTransform<{
382
+ conditionId: ConditionId;
383
+ direction: RfqDirection;
384
+ legPositionIds: PositionId[];
385
+ noPositionId: PositionId;
386
+ requestorPublicId: RfqRequestorPublicId;
387
+ requestedSize: {
388
+ unit: RfqRequestedSizeUnit.Notional;
389
+ value: DecimalString;
390
+ } | {
391
+ unit: RfqRequestedSizeUnit.Shares;
392
+ value: DecimalString;
393
+ };
394
+ rfqId: RfqId;
395
+ side: RfqSide.Yes;
396
+ submissionDeadline: EpochMilliseconds;
397
+ type: "quote_request";
398
+ yesPositionId: PositionId;
399
+ }, {
400
+ type: RfqKnownInboundType.QuoteRequest;
401
+ rfq_id: RfqId;
402
+ requestor_public_id: RfqRequestorPublicId;
403
+ leg_position_ids: PositionId[];
404
+ condition_id: ConditionId;
405
+ yes_position_id: PositionId;
406
+ no_position_id: PositionId;
407
+ direction: RfqDirection;
408
+ side: RfqSide.Yes;
409
+ requested_size: {
410
+ unit: RfqRequestedSizeUnit.Notional;
411
+ value: DecimalString;
412
+ } | {
413
+ unit: RfqRequestedSizeUnit.Shares;
414
+ value: DecimalString;
415
+ };
416
+ submission_deadline: EpochMilliseconds;
417
+ }>>, z.ZodPipe<z.ZodObject<{
418
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteAck>;
419
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
420
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
421
+ }, z.core.$strip>, z.ZodTransform<{
422
+ quoteId: RfqQuoteId;
423
+ rfqId: RfqId;
424
+ type: "quote_ack";
425
+ }, {
426
+ type: RfqKnownInboundType.QuoteAck;
427
+ rfq_id: RfqId;
428
+ quote_id: RfqQuoteId;
429
+ }>>, z.ZodPipe<z.ZodObject<{
430
+ type: z.ZodLiteral<RfqKnownInboundType.QuoteCancelAck>;
431
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
432
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
433
+ }, z.core.$strip>, z.ZodTransform<{
434
+ quoteId: RfqQuoteId;
435
+ rfqId: RfqId;
436
+ type: "quote_cancel_ack";
437
+ }, {
438
+ type: RfqKnownInboundType.QuoteCancelAck;
439
+ rfq_id: RfqId;
440
+ quote_id: RfqQuoteId;
441
+ }>>, z.ZodPipe<z.ZodObject<{
442
+ type: z.ZodLiteral<RfqKnownInboundType.ConfirmationRequest>;
443
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
444
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
445
+ signer_address: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
446
+ maker_address: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
447
+ signature_type: z.ZodEnum<typeof SignatureType>;
448
+ leg_position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
449
+ condition_id: z.ZodPipe<z.ZodString, z.ZodTransform<ConditionId, string>>;
450
+ yes_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
451
+ no_position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
452
+ direction: z.ZodEnum<typeof RfqDirection>;
453
+ side: z.ZodLiteral<RfqSide.Yes>;
454
+ fill_size_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
455
+ price_e6: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
456
+ confirm_by: z.ZodPipe<z.ZodNumber, z.ZodTransform<EpochMilliseconds, number>>;
457
+ }, z.core.$strip>, z.ZodTransform<{
458
+ conditionId: ConditionId;
459
+ confirmBy: EpochMilliseconds;
460
+ direction: RfqDirection;
461
+ fillSize: DecimalString;
462
+ legPositionIds: PositionId[];
463
+ makerAddress: EvmAddress;
464
+ noPositionId: PositionId;
465
+ price: DecimalString;
466
+ quoteId: RfqQuoteId;
467
+ rfqId: RfqId;
468
+ side: RfqSide.Yes;
469
+ signatureType: SignatureType;
470
+ signerAddress: EvmAddress;
471
+ type: "confirmation_request";
472
+ yesPositionId: PositionId;
473
+ }, {
474
+ type: RfqKnownInboundType.ConfirmationRequest;
475
+ rfq_id: RfqId;
476
+ quote_id: RfqQuoteId;
477
+ signer_address: EvmAddress;
478
+ maker_address: EvmAddress;
479
+ signature_type: SignatureType;
480
+ leg_position_ids: PositionId[];
481
+ condition_id: ConditionId;
482
+ yes_position_id: PositionId;
483
+ no_position_id: PositionId;
484
+ direction: RfqDirection;
485
+ side: RfqSide.Yes;
486
+ fill_size_e6: DecimalString;
487
+ price_e6: DecimalString;
488
+ confirm_by: EpochMilliseconds;
489
+ }>>, z.ZodPipe<z.ZodObject<{
490
+ type: z.ZodLiteral<RfqKnownInboundType.ConfirmationAck>;
491
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
492
+ quote_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>;
493
+ decision: z.ZodEnum<typeof RfqConfirmationDecision>;
494
+ }, z.core.$strip>, z.ZodTransform<{
495
+ decision: RfqConfirmationDecision;
496
+ quoteId: RfqQuoteId;
497
+ rfqId: RfqId;
498
+ type: "confirmation_ack";
499
+ }, {
500
+ type: RfqKnownInboundType.ConfirmationAck;
501
+ rfq_id: RfqId;
502
+ quote_id: RfqQuoteId;
503
+ decision: RfqConfirmationDecision;
504
+ }>>, z.ZodPipe<z.ZodObject<{
505
+ type: z.ZodLiteral<RfqKnownInboundType.ExecutionUpdate>;
506
+ rfq_id: z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>;
507
+ status: z.ZodEnum<typeof RfqExecutionStatus>;
508
+ tx_hash: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<_polymarket_types.TxHash, string>>>;
509
+ }, z.core.$strip>, z.ZodTransform<{
510
+ type: "execution_update";
511
+ txHash?: _polymarket_types.TxHash | undefined;
512
+ rfqId: RfqId;
513
+ status: RfqExecutionStatus;
514
+ }, {
515
+ type: RfqKnownInboundType.ExecutionUpdate;
516
+ rfq_id: RfqId;
517
+ status: RfqExecutionStatus;
518
+ tx_hash?: _polymarket_types.TxHash | undefined;
519
+ }>>, z.ZodPipe<z.ZodObject<{
520
+ type: z.ZodLiteral<RfqKnownInboundType.Error>;
521
+ request_type: z.ZodOptional<z.ZodString>;
522
+ rfq_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>>;
523
+ quote_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>>;
524
+ code: z.ZodEnum<typeof RfqErrorCode>;
525
+ error: z.ZodString;
526
+ request: z.ZodOptional<z.ZodUnknown>;
527
+ }, z.core.$strip>, z.ZodTransform<{
528
+ code: RfqErrorCode;
529
+ message: string;
530
+ quoteId: RfqQuoteId | undefined;
531
+ requestType: string | undefined;
532
+ rfqId: RfqId | undefined;
533
+ type: "rfq_error";
534
+ }, {
535
+ type: RfqKnownInboundType.Error;
536
+ code: RfqErrorCode;
537
+ error: string;
538
+ request_type?: string | undefined;
539
+ rfq_id?: RfqId | undefined;
540
+ quote_id?: RfqQuoteId | undefined;
541
+ request?: unknown;
542
+ }>>]>;
543
+ type RfqQuoterInboundMessage = z.infer<typeof RfqQuoterInboundMessageSchema>;
544
+ type RfqQuoterOutboundMessage = RfqQuoteMessage | RfqQuoteCancelMessage | RfqConfirmationResponseMessage;
545
+
546
+ export { type RfqAuthMessage, type RfqAuthResponseMessage, RfqAuthResponseMessageSchema, type RfqConfirmationAck, RfqConfirmationAckSchema, RfqConfirmationDecision, RfqConfirmationDecisionSchema, type RfqConfirmationRequest, RfqConfirmationRequestSchema, type RfqConfirmationResponseMessage, RfqDirection, RfqDirectionSchema, RfqErrorCode, RfqErrorCodeSchema, type RfqErrorMessage, RfqErrorMessageSchema, RfqExecutionStatus, RfqExecutionStatusSchema, type RfqExecutionUpdate, RfqExecutionUpdateSchema, RfqId, RfqKnownInboundMessageSchema, RfqKnownInboundType, type RfqOrderSide, type RfqQuoteAck, RfqQuoteAckSchema, type RfqQuoteCancelAck, RfqQuoteCancelAckSchema, type RfqQuoteCancelMessage, RfqQuoteId, type RfqQuoteMessage, type RfqQuoteRequest, RfqQuoteRequestSchema, type RfqQuoterInboundMessage, RfqQuoterInboundMessageSchema, type RfqQuoterOutboundMessage, type RfqRequestedSize, RfqRequestedSizeUnit, RfqRequestedSizeUnitSchema, RfqRequestorPublicId, RfqSide, RfqSideSchema, type RfqSignedOrder };
package/dist/rfq.js ADDED
@@ -0,0 +1,2 @@
1
+ import {b as b$1}from'./chunk-HOD4LKZU.js';import {N as N$1,W,X,sa,U as U$1,xa,va,wa,Ba}from'./chunk-KZQH7LDK.js';import {z as z$1}from'zod';var A=(n=>(n.Buy="BUY",n.Sell="SELL",n))(A||{}),M=(n=>(n.Yes="YES",n.No="NO",n))(M||{}),y=(n=>(n.Confirm="CONFIRM",n.Decline="DECLINE",n))(y||{}),E=(p=>(p.Matched="MATCHED",p.Mined="MINED",p.Confirmed="CONFIRMED",p.Retrying="RETRYING",p.Failed="FAILED",p))(E||{}),h=(n=>(n.Notional="notional",n.Shares="shares",n))(h||{}),x=(i=>(i.AddressMismatch="ADDRESS_MISMATCH",i.CompetitionWindowClosed="COMPETITION_WINDOW_CLOSED",i.ContradictoryLegs="CONTRADICTORY_LEGS",i.ExpiredRfq="EXPIRED_RFQ",i.InvalidAcceptance="INVALID_ACCEPTANCE",i.InvalidConfirmation="INVALID_CONFIRMATION",i.InvalidExecutionResult="INVALID_EXECUTION_RESULT",i.InvalidIdentity="INVALID_IDENTITY",i.InvalidMessage="INVALID_MESSAGE",i.InvalidQuote="INVALID_QUOTE",i.InvalidRfq="INVALID_RFQ",i.InvalidRfqState="INVALID_RFQ_STATE",i.InvalidRole="INVALID_ROLE",i.LegMetadataUnavailable="LEG_METADATA_UNAVAILABLE",i.MakerAlreadyResponded="MAKER_ALREADY_RESPONDED",i.MakerNotRequired="MAKER_NOT_REQUIRED",i.QuoteMismatch="QUOTE_MISMATCH",i.QuoteUnavailable="QUOTE_UNAVAILABLE",i.RateLimited="RATE_LIMITED",i.RequestFailed="REQUEST_FAILED",i.ServiceUnavailable="SERVICE_UNAVAILABLE",i.TradeSubmissionFailed="TRADE_SUBMISSION_FAILED",i.Unauthenticated="UNAUTHENTICATED",i.UnauthorizedRole="UNAUTHORIZED_ROLE",i.UnknownRfq="UNKNOWN_RFQ",i))(x||{}),Q=z$1.enum(A),T=z$1.literal("YES"),g=z$1.enum(y),O=z$1.enum(E),K=z$1.enum(h),U=z$1.enum(x),_=z$1.string().regex(/^\d+$/).transform(e=>{let R=BigInt(e),n=R/1000000n,q=(R%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return N$1(`${n}${q===""?"":`.${q}`}`)}),D=z$1.discriminatedUnion("unit",[z$1.object({unit:z$1.literal("notional"),value_e6:_}),z$1.object({unit:z$1.literal("shares"),value_e6:_})]).transform(e=>({unit:e.unit,value:e.value_e6})),N=(o=>(o.Auth="auth",o.QuoteRequest="RFQ_REQUEST",o.QuoteAck="ACK_RFQ_QUOTE",o.QuoteCancelAck="ACK_RFQ_QUOTE_CANCEL",o.ConfirmationRequest="RFQ_CONFIRMATION_REQUEST",o.ConfirmationAck="ACK_RFQ_CONFIRMATION_RESPONSE",o.ExecutionUpdate="RFQ_EXECUTION_UPDATE",o.Error="RFQ_ERROR",o))(N||{}),s=z$1.object({type:z$1.enum(N)}),k=s.extend({type:z$1.literal("auth"),success:z$1.boolean(),address:W.optional(),role:z$1.string().optional(),error:z$1.string().optional()}),L=s.extend({type:z$1.literal("RFQ_REQUEST"),rfq_id:va,requestor_public_id:xa,leg_position_ids:z$1.array(sa),condition_id:U$1,yes_position_id:sa,no_position_id:sa,direction:Q,side:T,requested_size:D,submission_deadline:X}).transform(e=>({conditionId:e.condition_id,direction:e.direction,legPositionIds:e.leg_position_ids,noPositionId:e.no_position_id,requestorPublicId:e.requestor_public_id,requestedSize:e.requested_size,rfqId:e.rfq_id,side:e.side,submissionDeadline:e.submission_deadline,type:"quote_request",yesPositionId:e.yes_position_id})),C=s.extend({type:z$1.literal("ACK_RFQ_QUOTE"),rfq_id:va,quote_id:wa}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_ack"})),v=s.extend({type:z$1.literal("ACK_RFQ_QUOTE_CANCEL"),rfq_id:va,quote_id:wa}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_cancel_ack"})),F=s.extend({type:z$1.literal("RFQ_CONFIRMATION_REQUEST"),rfq_id:va,quote_id:wa,signer_address:W,maker_address:W,signature_type:b$1,leg_position_ids:z$1.array(sa),condition_id:U$1,yes_position_id:sa,no_position_id:sa,direction:Q,side:T,fill_size_e6:_,price_e6:_,confirm_by:X}).transform(e=>({conditionId:e.condition_id,confirmBy:e.confirm_by,direction:e.direction,fillSize:e.fill_size_e6,legPositionIds:e.leg_position_ids,makerAddress:e.maker_address,noPositionId:e.no_position_id,price:e.price_e6,quoteId:e.quote_id,rfqId:e.rfq_id,side:e.side,signatureType:e.signature_type,signerAddress:e.signer_address,type:"confirmation_request",yesPositionId:e.yes_position_id})),z=s.extend({type:z$1.literal("ACK_RFQ_CONFIRMATION_RESPONSE"),rfq_id:va,quote_id:wa,decision:g}).transform(e=>({decision:e.decision,quoteId:e.quote_id,rfqId:e.rfq_id,type:"confirmation_ack"})),b=s.extend({type:z$1.literal("RFQ_EXECUTION_UPDATE"),rfq_id:va,status:O,tx_hash:Ba.optional()}).transform(e=>({rfqId:e.rfq_id,status:e.status,...e.tx_hash===void 0?{}:{txHash:e.tx_hash},type:"execution_update"})),P=s.extend({type:z$1.literal("RFQ_ERROR"),request_type:z$1.string().optional(),rfq_id:va.optional(),quote_id:wa.optional(),code:U,error:z$1.string(),request:z$1.unknown().optional()}).transform(e=>({code:e.code,message:e.error,quoteId:e.quote_id,requestType:e.request_type,rfqId:e.rfq_id,type:"rfq_error"})),Y=z$1.union([k,L,C,v,F,z,b,P]);export{k as RfqAuthResponseMessageSchema,z as RfqConfirmationAckSchema,y as RfqConfirmationDecision,g as RfqConfirmationDecisionSchema,F as RfqConfirmationRequestSchema,A as RfqDirection,Q as RfqDirectionSchema,x as RfqErrorCode,U as RfqErrorCodeSchema,P as RfqErrorMessageSchema,E as RfqExecutionStatus,O as RfqExecutionStatusSchema,b as RfqExecutionUpdateSchema,s as RfqKnownInboundMessageSchema,N as RfqKnownInboundType,C as RfqQuoteAckSchema,v as RfqQuoteCancelAckSchema,L as RfqQuoteRequestSchema,Y as RfqQuoterInboundMessageSchema,h as RfqRequestedSizeUnit,K as RfqRequestedSizeUnitSchema,M as RfqSide,T as RfqSideSchema};//# sourceMappingURL=rfq.js.map
2
+ //# sourceMappingURL=rfq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rfq.ts"],"names":["RfqDirection","RfqSide","RfqConfirmationDecision","RfqExecutionStatus","RfqRequestedSizeUnit","RfqErrorCode","RfqDirectionSchema","z","RfqSideSchema","RfqConfirmationDecisionSchema","RfqExecutionStatusSchema","RfqRequestedSizeUnitSchema","RfqErrorCodeSchema","BigIntStringToDecimalStringSchema","value","scaledValue","whole","fraction","toDecimalString","RfqRequestedSizeSchema","size","RfqKnownInboundType","RfqKnownInboundMessageSchema","RfqAuthResponseMessageSchema","EvmAddressSchema","RfqQuoteRequestSchema","RfqIdSchema","RfqRequestorPublicIdSchema","PositionIdSchema","ConditionIdSchema","EpochMillisecondsSchema","message","RfqQuoteAckSchema","RfqQuoteIdSchema","RfqQuoteCancelAckSchema","RfqConfirmationRequestSchema","SignatureTypeSchema","RfqConfirmationAckSchema","RfqExecutionUp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YAAA,CACrB,KAAA,CAAOA,EAAQ,MAAA,CACf,IAAA,CAAM,WACR,CAAA,CAAE,CAAA,CAIWU,EAAgClC,GAAAA,CAAE,KAAA,CAAM,CACnDgB,CAAAA,CACAE,EACAO,CAAAA,CACAE,CAAAA,CACAC,EACAE,CAAAA,CACAC,CAAAA,CACAE,CACF,CAAC","file":"rfq.js","sourcesContent":["import type {\n Erc1271Signature,\n EvmSignature,\n HexString,\n} from '@polymarket/types';\nimport { z } from 'zod';\nimport { type SignatureType, SignatureTypeSchema } from './clob/signature-type';\nimport type { BaseUnits, DecimalString, EvmAddress, TokenId } from './shared';\nimport {\n ConditionIdSchema,\n EpochMillisecondsSchema,\n EvmAddressSchema,\n type OrderSide,\n type PositionId,\n PositionIdSchema,\n type RfqId,\n RfqIdSchema,\n type RfqQuoteId,\n RfqQuoteIdSchema,\n RfqRequestorPublicIdSchema,\n TxHashSchema,\n toDecimalString,\n} from './shared';\n\nexport type {\n RfqId,\n RfqQuoteId,\n RfqRequestorPublicId,\n} from './shared';\n\nexport enum RfqDirection {\n Buy = 'BUY',\n Sell = 'SELL',\n}\n\nexport enum RfqSide {\n Yes = 'YES',\n No = 'NO',\n}\n\nexport enum RfqConfirmationDecision {\n Confirm = 'CONFIRM',\n Decline = 'DECLINE',\n}\n\nexport enum RfqExecutionStatus {\n Matched = 'MATCHED',\n Mined = 'MINED',\n Confirmed = 'CONFIRMED',\n Retrying = 'RETRYING',\n Failed = 'FAILED',\n}\n\nexport enum RfqRequestedSizeUnit {\n Notional = 'notional',\n Shares = 'shares',\n}\n\nexport enum RfqErrorCode {\n AddressMismatch = 'ADDRESS_MISMATCH',\n CompetitionWindowClosed = 'COMPETITION_WINDOW_CLOSED',\n ContradictoryLegs = 'CONTRADICTORY_LEGS',\n ExpiredRfq = 'EXPIRED_RFQ',\n InvalidAcceptance = 'INVALID_ACCEPTANCE',\n InvalidConfirmation = 'INVALID_CONFIRMATION',\n InvalidExecutionResult = 'INVALID_EXECUTION_RESULT',\n InvalidIdentity = 'INVALID_IDENTITY',\n InvalidMessage = 'INVALID_MESSAGE',\n InvalidQuote = 'INVALID_QUOTE',\n InvalidRfq = 'INVALID_RFQ',\n InvalidRfqState = 'INVALID_RFQ_STATE',\n InvalidRole = 'INVALID_ROLE',\n LegMetadataUnavailable = 'LEG_METADATA_UNAVAILABLE',\n MakerAlreadyResponded = 'MAKER_ALREADY_RESPONDED',\n MakerNotRequired = 'MAKER_NOT_REQUIRED',\n QuoteMismatch = 'QUOTE_MISMATCH',\n QuoteUnavailable = 'QUOTE_UNAVAILABLE',\n RateLimited = 'RATE_LIMITED',\n RequestFailed = 'REQUEST_FAILED',\n ServiceUnavailable = 'SERVICE_UNAVAILABLE',\n TradeSubmissionFailed = 'TRADE_SUBMISSION_FAILED',\n Unauthenticated = 'UNAUTHENTICATED',\n UnauthorizedRole = 'UNAUTHORIZED_ROLE',\n UnknownRfq = 'UNKNOWN_RFQ',\n}\n\nexport const RfqDirectionSchema = z.enum(RfqDirection);\nexport const RfqSideSchema = z.literal(RfqSide.Yes);\nexport const RfqConfirmationDecisionSchema = z.enum(RfqConfirmationDecision);\nexport const RfqExecutionStatusSchema = z.enum(RfqExecutionStatus);\nexport const RfqRequestedSizeUnitSchema = z.enum(RfqRequestedSizeUnit);\nexport const RfqErrorCodeSchema = z.enum(RfqErrorCode);\n\nconst BigIntStringToDecimalStringSchema = z\n .string()\n .regex(/^\\d+$/)\n .transform((value) => {\n const scaledValue = BigInt(value);\n const whole = scaledValue / 1_000_000n;\n const fraction = (scaledValue % 1_000_000n)\n .toString()\n .padStart(6, '0')\n .replace(/0+$/, '');\n\n return toDecimalString(`${whole}${fraction === '' ? '' : `.${fraction}`}`);\n });\n\nexport type RfqRequestedSize =\n | {\n unit: RfqRequestedSizeUnit.Notional;\n value: DecimalString;\n }\n | {\n unit: RfqRequestedSizeUnit.Shares;\n value: DecimalString;\n };\n\nconst RfqRequestedSizeSchema = z\n .discriminatedUnion('unit', [\n z.object({\n unit: z.literal(RfqRequestedSizeUnit.Notional),\n value_e6: BigIntStringToDecimalStringSchema,\n }),\n z.object({\n unit: z.literal(RfqRequestedSizeUnit.Shares),\n value_e6: BigIntStringToDecimalStringSchema,\n }),\n ])\n .transform(\n (size): RfqRequestedSize => ({\n unit: size.unit,\n value: size.value_e6,\n }),\n ) satisfies z.ZodType<RfqRequestedSize>;\n\nexport type RfqSignedOrder = {\n salt: string;\n maker: EvmAddress;\n signer: EvmAddress;\n tokenId: PositionId | TokenId;\n makerAmount: BaseUnits;\n takerAmount: BaseUnits;\n side: RfqOrderSide;\n signatureType: SignatureType;\n timestamp: string;\n builder?: HexString;\n expiration?: string;\n metadata?: HexString;\n signature: EvmSignature | Erc1271Signature;\n};\n\nexport type RfqOrderSide = OrderSide | 0 | 1;\n\nexport type RfqAuthMessage = {\n type: 'auth';\n auth: {\n apiKey: string;\n passphrase: string;\n secret: string;\n };\n identity: {\n signer_address: EvmAddress;\n maker_address: EvmAddress;\n signature_type: SignatureType;\n };\n};\n\nexport enum RfqKnownInboundType {\n Auth = 'auth',\n QuoteRequest = 'RFQ_REQUEST',\n QuoteAck = 'ACK_RFQ_QUOTE',\n QuoteCancelAck = 'ACK_RFQ_QUOTE_CANCEL',\n ConfirmationRequest = 'RFQ_CONFIRMATION_REQUEST',\n ConfirmationAck = 'ACK_RFQ_CONFIRMATION_RESPONSE',\n ExecutionUpdate = 'RFQ_EXECUTION_UPDATE',\n Error = 'RFQ_ERROR',\n}\n\nexport const RfqKnownInboundMessageSchema = z.object({\n type: z.enum(RfqKnownInboundType),\n});\n\nexport const RfqAuthResponseMessageSchema = RfqKnownInboundMessageSchema.extend(\n {\n type: z.literal(RfqKnownInboundType.Auth),\n success: z.boolean(),\n address: EvmAddressSchema.optional(),\n role: z.string().optional(),\n error: z.string().optional(),\n },\n);\n\nexport type RfqAuthResponseMessage = z.infer<\n typeof RfqAuthResponseMessageSchema\n>;\n\nexport const RfqQuoteRequestSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.QuoteRequest),\n rfq_id: RfqIdSchema,\n requestor_public_id: RfqRequestorPublicIdSchema,\n leg_position_ids: z.array(PositionIdSchema),\n condition_id: ConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n requested_size: RfqRequestedSizeSchema,\n submission_deadline: EpochMillisecondsSchema,\n}).transform((message) => ({\n conditionId: message.condition_id,\n direction: message.direction,\n legPositionIds: message.leg_position_ids,\n noPositionId: message.no_position_id,\n requestorPublicId: message.requestor_public_id,\n requestedSize: message.requested_size,\n rfqId: message.rfq_id,\n side: message.side,\n submissionDeadline: message.submission_deadline,\n type: 'quote_request' as const,\n yesPositionId: message.yes_position_id,\n}));\n\nexport type RfqQuoteRequest = z.infer<typeof RfqQuoteRequestSchema>;\n\nexport type RfqQuoteMessage = {\n type: 'RFQ_QUOTE';\n rfq_id: RfqId;\n price_e6: string;\n size_e6: string;\n signed_order: RfqSignedOrder;\n};\n\nexport type RfqQuoteCancelMessage = {\n type: 'RFQ_QUOTE_CANCEL';\n rfq_id: RfqId;\n quote_id: RfqQuoteId;\n signer_address: EvmAddress;\n maker_address: EvmAddress;\n};\n\nexport const RfqQuoteAckSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.QuoteAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n}).transform((message) => ({\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'quote_ack' as const,\n}));\n\nexport type RfqQuoteAck = z.infer<typeof RfqQuoteAckSchema>;\n\nexport const RfqQuoteCancelAckSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.QuoteCancelAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n}).transform((message) => ({\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'quote_cancel_ack' as const,\n}));\n\nexport type RfqQuoteCancelAck = z.infer<typeof RfqQuoteCancelAckSchema>;\n\nexport const RfqConfirmationRequestSchema = RfqKnownInboundMessageSchema.extend(\n {\n type: z.literal(RfqKnownInboundType.ConfirmationRequest),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n signer_address: EvmAddressSchema,\n maker_address: EvmAddressSchema,\n signature_type: SignatureTypeSchema,\n leg_position_ids: z.array(PositionIdSchema),\n condition_id: ConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n fill_size_e6: BigIntStringToDecimalStringSchema,\n price_e6: BigIntStringToDecimalStringSchema,\n confirm_by: EpochMillisecondsSchema,\n },\n).transform((message) => ({\n conditionId: message.condition_id,\n confirmBy: message.confirm_by,\n direction: message.direction,\n fillSize: message.fill_size_e6,\n legPositionIds: message.leg_position_ids,\n makerAddress: message.maker_address,\n noPositionId: message.no_position_id,\n price: message.price_e6,\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n side: message.side,\n signatureType: message.signature_type,\n signerAddress: message.signer_address,\n type: 'confirmation_request' as const,\n yesPositionId: message.yes_position_id,\n}));\n\nexport type RfqConfirmationRequest = z.infer<\n typeof RfqConfirmationRequestSchema\n>;\n\nexport type RfqConfirmationResponseMessage = {\n type: 'RFQ_CONFIRMATION_RESPONSE';\n rfq_id: RfqId;\n quote_id: RfqQuoteId;\n decision: RfqConfirmationDecision;\n};\n\nexport const RfqConfirmationAckSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.ConfirmationAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n decision: RfqConfirmationDecisionSchema,\n}).transform((message) => ({\n decision: message.decision,\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'confirmation_ack' as const,\n}));\n\nexport type RfqConfirmationAck = z.infer<typeof RfqConfirmationAckSchema>;\n\nexport const RfqExecutionUpdateSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.ExecutionUpdate),\n rfq_id: RfqIdSchema,\n status: RfqExecutionStatusSchema,\n tx_hash: TxHashSchema.optional(),\n}).transform((message) => ({\n rfqId: message.rfq_id,\n status: message.status,\n ...(message.tx_hash === undefined ? {} : { txHash: message.tx_hash }),\n type: 'execution_update' as const,\n}));\n\nexport type RfqExecutionUpdate = z.infer<typeof RfqExecutionUpdateSchema>;\n\nexport const RfqErrorMessageSchema = RfqKnownInboundMessageSchema.extend({\n type: z.literal(RfqKnownInboundType.Error),\n request_type: z.string().optional(),\n rfq_id: RfqIdSchema.optional(),\n quote_id: RfqQuoteIdSchema.optional(),\n code: RfqErrorCodeSchema,\n error: z.string(),\n request: z.unknown().optional(),\n}).transform((message) => ({\n code: message.code,\n message: message.error,\n quoteId: message.quote_id,\n requestType: message.request_type,\n rfqId: message.rfq_id,\n type: 'rfq_error' as const,\n}));\n\nexport type RfqErrorMessage = z.infer<typeof RfqErrorMessageSchema>;\n\nexport const RfqQuoterInboundMessageSchema = z.union([\n RfqAuthResponseMessageSchema,\n RfqQuoteRequestSchema,\n RfqQuoteAckSchema,\n RfqQuoteCancelAckSchema,\n RfqConfirmationRequestSchema,\n RfqConfirmationAckSchema,\n RfqExecutionUpdateSchema,\n RfqErrorMessageSchema,\n]);\n\nexport type RfqQuoterInboundMessage = z.infer<\n typeof RfqQuoterInboundMessageSchema\n>;\n\nexport type RfqQuoterOutboundMessage =\n | RfqQuoteMessage\n | RfqQuoteCancelMessage\n | RfqConfirmationResponseMessage;\n"]}
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+
3
+ declare enum SignatureType {
4
+ /**
5
+ * ECDSA EIP712 signatures signed by EOAs
6
+ */
7
+ EOA = 0,
8
+ /**
9
+ * EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
10
+ */
11
+ POLY_PROXY = 1,
12
+ /**
13
+ * EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
14
+ */
15
+ POLY_GNOSIS_SAFE = 2,
16
+ /**
17
+ * EIP1271 signatures signed by smart contracts
18
+ */
19
+ POLY_1271 = 3
20
+ }
21
+ declare const SignatureTypeSchema: z.ZodEnum<typeof SignatureType>;
22
+
23
+ export { SignatureType as S, SignatureTypeSchema as a };