@polymarket/bindings 0.1.0-beta.9 → 0.2.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/chunk-H6NL6UCA.js +2 -0
- package/dist/{chunk-GYP7YNXL.js.map → chunk-H6NL6UCA.js.map} +1 -1
- package/dist/chunk-N4P2EGRL.js +2 -0
- package/dist/chunk-N4P2EGRL.js.map +1 -0
- package/dist/chunk-QTXFNR2Y.js +2 -0
- package/dist/chunk-QTXFNR2Y.js.map +1 -0
- package/dist/clob/index.d.ts +153 -54
- package/dist/clob/index.js +1 -1
- package/dist/clob/index.js.map +1 -1
- package/dist/{rfq.d.ts → combos/index.d.ts} +182 -43
- package/dist/combos/index.js +2 -0
- package/dist/combos/index.js.map +1 -0
- package/dist/data/index.d.ts +1049 -915
- package/dist/data/index.js +1 -1
- package/dist/data/index.js.map +1 -1
- package/dist/gamma/index.d.ts +48 -1
- package/dist/gamma/index.js +1 -1
- package/dist/gamma/index.js.map +1 -1
- package/dist/index.d.ts +28 -9
- package/dist/index.js +1 -1
- package/dist/{orders-B7JX0nMz.d.ts → orders-ClcuI-yo.d.ts} +448 -4
- package/dist/perps/index.d.ts +406 -12
- package/dist/perps/index.js +1 -1
- package/dist/relayer/index.js +1 -1
- package/dist/relayer/index.js.map +1 -1
- package/dist/subscriptions/index.d.ts +382 -86
- package/dist/subscriptions/index.js +1 -1
- package/dist/subscriptions/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-GYP7YNXL.js +0 -2
- package/dist/chunk-KYFSCD3H.js +0 -2
- package/dist/chunk-KYFSCD3H.js.map +0 -1
- package/dist/chunk-VBHCYSM7.js +0 -2
- package/dist/chunk-VBHCYSM7.js.map +0 -1
- package/dist/rfq.js +0 -2
- package/dist/rfq.js.map +0 -1
|
@@ -1,8 +1,172 @@
|
|
|
1
1
|
import * as _polymarket_types from '@polymarket/types';
|
|
2
|
-
import {
|
|
3
|
-
import { MarketId, CtfConditionId, PositionId, DecimalString, PaginationCursor, RfqId, RfqQuoteId, ComboConditionId, EpochMilliseconds, OrderSide, TokenId, BaseUnits, RfqRequestorPublicId } from './index.js';
|
|
2
|
+
import { HexString, EvmAddress, EvmSignature, Erc1271Signature } from '@polymarket/types';
|
|
4
3
|
import { z } from 'zod';
|
|
5
|
-
import {
|
|
4
|
+
import { ComboConditionId, EventId, PositionId, DecimalString, MarketId, CtfConditionId, PaginationCursor, RfqId, RfqQuoteId, EpochMilliseconds, OrderSide, TokenId, BaseUnits, RfqRequestorPublicId } from '../index.js';
|
|
5
|
+
import { S as SignatureType } from '../signature-type-CrLAA9AN.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Known collateral-return plan operation kinds.
|
|
9
|
+
*
|
|
10
|
+
* The service evolves this set independently of released clients, so plan
|
|
11
|
+
* parsing accepts unknown kinds as plain strings; see
|
|
12
|
+
* {@link CollateralReturnOperationKind}.
|
|
13
|
+
*/
|
|
14
|
+
declare enum CollateralReturnKnownOperationKind {
|
|
15
|
+
Split = "split",
|
|
16
|
+
Merge = "merge",
|
|
17
|
+
Redeem = "redeem",
|
|
18
|
+
SplitOnCondition = "split_on_condition",
|
|
19
|
+
MergeOnCondition = "merge_on_condition",
|
|
20
|
+
SplitOnEvent = "split_on_event",
|
|
21
|
+
MergeOnEvent = "merge_on_event",
|
|
22
|
+
ConvertOnEvent = "convert_on_event",
|
|
23
|
+
Extract = "extract",
|
|
24
|
+
Inject = "inject",
|
|
25
|
+
ConvertToYesBasket = "convert_to_yes_basket",
|
|
26
|
+
MergeFromYesBasket = "merge_from_yes_basket",
|
|
27
|
+
Compress = "compress"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A collateral-return operation kind. Known kinds are enumerated in
|
|
31
|
+
* {@link CollateralReturnKnownOperationKind}; newly introduced kinds flow
|
|
32
|
+
* through as plain strings so plans keep parsing before a client release that
|
|
33
|
+
* enumerates them.
|
|
34
|
+
*/
|
|
35
|
+
type CollateralReturnOperationKind = CollateralReturnKnownOperationKind | (string & {});
|
|
36
|
+
type CollateralReturnOperation = {
|
|
37
|
+
kind: CollateralReturnOperationKind;
|
|
38
|
+
conditionId?: ComboConditionId;
|
|
39
|
+
eventId?: EventId;
|
|
40
|
+
positionId?: PositionId;
|
|
41
|
+
conditionIndex: number;
|
|
42
|
+
amount: DecimalString;
|
|
43
|
+
};
|
|
44
|
+
type CollateralReturnPositionAmount = {
|
|
45
|
+
positionId: PositionId;
|
|
46
|
+
amount: DecimalString;
|
|
47
|
+
};
|
|
48
|
+
type CollateralReturnPositionSummary = {
|
|
49
|
+
consumed: CollateralReturnPositionAmount[];
|
|
50
|
+
created: CollateralReturnPositionAmount[];
|
|
51
|
+
};
|
|
52
|
+
type CollateralReturnRouterCall = {
|
|
53
|
+
to: EvmAddress;
|
|
54
|
+
data: HexString;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The plan fields execution consumes: the plan identifier round-tripped to
|
|
58
|
+
* the service, the chain and wallet the plan was computed for, and the exact
|
|
59
|
+
* Router call the execution signs and submits.
|
|
60
|
+
*/
|
|
61
|
+
declare const CollateralReturnPlanSchema: z.ZodObject<{
|
|
62
|
+
planHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
63
|
+
chainId: z.ZodNumber;
|
|
64
|
+
wallet: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
|
|
65
|
+
routerCall: z.ZodPipe<z.ZodObject<{
|
|
66
|
+
to: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
|
|
67
|
+
data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
68
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnRouterCall, {
|
|
69
|
+
to: EvmAddress;
|
|
70
|
+
data: `0x${string}`;
|
|
71
|
+
}>>;
|
|
72
|
+
}, z.core.$loose>;
|
|
73
|
+
type CollateralReturnPlanResponse = {
|
|
74
|
+
planHash: HexString;
|
|
75
|
+
chainId: number;
|
|
76
|
+
wallet: EvmAddress;
|
|
77
|
+
blockNumber: bigint;
|
|
78
|
+
startingPusd: DecimalString;
|
|
79
|
+
netPusdOut: DecimalString;
|
|
80
|
+
finalPusd: DecimalString;
|
|
81
|
+
operations: CollateralReturnOperation[];
|
|
82
|
+
operationCount: number;
|
|
83
|
+
truncated: boolean;
|
|
84
|
+
estimatedCost: number;
|
|
85
|
+
requiredPusdInput: DecimalString;
|
|
86
|
+
requiredPositions: CollateralReturnPositionAmount[];
|
|
87
|
+
positionSummary: CollateralReturnPositionSummary;
|
|
88
|
+
candidatePositionIds: PositionId[];
|
|
89
|
+
routerCall: CollateralReturnRouterCall;
|
|
90
|
+
};
|
|
91
|
+
declare const CollateralReturnPlanResponseSchema: z.ZodPipe<z.ZodObject<{
|
|
92
|
+
plan_hash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
93
|
+
chain_id: z.ZodNumber;
|
|
94
|
+
wallet: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
|
|
95
|
+
block_number: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
96
|
+
starting_pusd: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
97
|
+
net_pusd_out: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
98
|
+
final_pusd: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
99
|
+
operations: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
100
|
+
kind: z.ZodPipe<z.ZodString, z.ZodTransform<CollateralReturnKnownOperationKind | (string & {}), string>>;
|
|
101
|
+
condition_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ComboConditionId, string>>>;
|
|
102
|
+
event_id: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>, z.ZodTransform<EventId, string>>>;
|
|
103
|
+
position_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
|
|
104
|
+
condition_index: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
105
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
106
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnOperation, {
|
|
107
|
+
kind: CollateralReturnKnownOperationKind | (string & {});
|
|
108
|
+
condition_index: number;
|
|
109
|
+
amount: DecimalString;
|
|
110
|
+
condition_id?: ComboConditionId | undefined;
|
|
111
|
+
event_id?: EventId | undefined;
|
|
112
|
+
position_id?: PositionId | undefined;
|
|
113
|
+
}>>>;
|
|
114
|
+
operation_count: z.ZodNumber;
|
|
115
|
+
truncated: z.ZodBoolean;
|
|
116
|
+
estimated_cost: z.ZodNumber;
|
|
117
|
+
required_pusd_input: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
118
|
+
required_positions: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
119
|
+
position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
|
|
120
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
121
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnPositionAmount, {
|
|
122
|
+
position_id: PositionId;
|
|
123
|
+
amount: DecimalString;
|
|
124
|
+
}>>>;
|
|
125
|
+
position_summary: z.ZodOptional<z.ZodPipe<z.ZodObject<{
|
|
126
|
+
consumed: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
127
|
+
position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
|
|
128
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
129
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnPositionAmount, {
|
|
130
|
+
position_id: PositionId;
|
|
131
|
+
amount: DecimalString;
|
|
132
|
+
}>>>;
|
|
133
|
+
created: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
134
|
+
position_id: z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>;
|
|
135
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>;
|
|
136
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnPositionAmount, {
|
|
137
|
+
position_id: PositionId;
|
|
138
|
+
amount: DecimalString;
|
|
139
|
+
}>>>;
|
|
140
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnPositionSummary, {
|
|
141
|
+
consumed: CollateralReturnPositionAmount[];
|
|
142
|
+
created: CollateralReturnPositionAmount[];
|
|
143
|
+
}>>>;
|
|
144
|
+
candidate_position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
|
|
145
|
+
router_call: z.ZodPipe<z.ZodObject<{
|
|
146
|
+
to: z.ZodPipe<z.ZodString, z.ZodTransform<EvmAddress, string>>;
|
|
147
|
+
data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
148
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnRouterCall, {
|
|
149
|
+
to: EvmAddress;
|
|
150
|
+
data: `0x${string}`;
|
|
151
|
+
}>>;
|
|
152
|
+
}, z.core.$strip>, z.ZodTransform<CollateralReturnPlanResponse, {
|
|
153
|
+
plan_hash: `0x${string}`;
|
|
154
|
+
chain_id: number;
|
|
155
|
+
wallet: EvmAddress;
|
|
156
|
+
block_number: bigint;
|
|
157
|
+
starting_pusd: DecimalString;
|
|
158
|
+
net_pusd_out: DecimalString;
|
|
159
|
+
final_pusd: DecimalString;
|
|
160
|
+
operations: CollateralReturnOperation[];
|
|
161
|
+
operation_count: number;
|
|
162
|
+
truncated: boolean;
|
|
163
|
+
estimated_cost: number;
|
|
164
|
+
required_pusd_input: DecimalString;
|
|
165
|
+
required_positions: CollateralReturnPositionAmount[];
|
|
166
|
+
candidate_position_ids: PositionId[];
|
|
167
|
+
router_call: CollateralReturnRouterCall;
|
|
168
|
+
position_summary?: CollateralReturnPositionSummary | undefined;
|
|
169
|
+
}>>;
|
|
6
170
|
|
|
7
171
|
declare enum RfqDirection {
|
|
8
172
|
Buy = "BUY",
|
|
@@ -27,7 +191,7 @@ declare enum RfqRequestedSizeUnit {
|
|
|
27
191
|
Notional = "notional",
|
|
28
192
|
Shares = "shares"
|
|
29
193
|
}
|
|
30
|
-
declare enum
|
|
194
|
+
declare enum RfqKnownErrorCode {
|
|
31
195
|
AddressMismatch = "ADDRESS_MISMATCH",
|
|
32
196
|
AllowanceValidationFailed = "ALLOWANCE_VALIDATION_FAILED",
|
|
33
197
|
BalanceValidationFailed = "BALANCE_VALIDATION_FAILED",
|
|
@@ -47,6 +211,7 @@ declare enum RfqErrorCode {
|
|
|
47
211
|
LegMetadataUnavailable = "LEG_METADATA_UNAVAILABLE",
|
|
48
212
|
MakerAlreadyResponded = "MAKER_ALREADY_RESPONDED",
|
|
49
213
|
MakerNotRequired = "MAKER_NOT_REQUIRED",
|
|
214
|
+
MakerQuoteLimited = "MAKER_QUOTE_LIMITED",
|
|
50
215
|
PreExecutionBalanceReservationFailed = "PRE_EXECUTION_BALANCE_RESERVATION_FAILED",
|
|
51
216
|
QuoteMismatch = "QUOTE_MISMATCH",
|
|
52
217
|
QuoteUnavailable = "QUOTE_UNAVAILABLE",
|
|
@@ -59,12 +224,12 @@ declare enum RfqErrorCode {
|
|
|
59
224
|
UnauthorizedRole = "UNAUTHORIZED_ROLE",
|
|
60
225
|
UnknownRfq = "UNKNOWN_RFQ"
|
|
61
226
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
227
|
+
/**
|
|
228
|
+
* An RFQ error code. Known codes are enumerated in {@link RfqKnownErrorCode};
|
|
229
|
+
* newly introduced codes flow through as plain strings so they can be handled
|
|
230
|
+
* before a client release that enumerates them.
|
|
231
|
+
*/
|
|
232
|
+
type RfqErrorCode = RfqKnownErrorCode | (string & {});
|
|
68
233
|
type ComboMarket = {
|
|
69
234
|
id: MarketId;
|
|
70
235
|
conditionId: CtfConditionId;
|
|
@@ -84,29 +249,6 @@ type ComboMarketOutcomes = {
|
|
|
84
249
|
yes: ComboMarketOutcome;
|
|
85
250
|
no: ComboMarketOutcome;
|
|
86
251
|
};
|
|
87
|
-
declare const ComboMarketSchema: z.ZodPipe<z.ZodObject<{
|
|
88
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<MarketId, string>>;
|
|
89
|
-
condition_id: z.ZodPipe<z.ZodString, z.ZodTransform<CtfConditionId, string>>;
|
|
90
|
-
position_ids: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<PositionId, string>>>;
|
|
91
|
-
slug: z.ZodString;
|
|
92
|
-
title: z.ZodString;
|
|
93
|
-
outcomes: z.ZodArray<z.ZodString>;
|
|
94
|
-
outcome_prices: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<DecimalString, string>>>;
|
|
95
|
-
image: z.ZodString;
|
|
96
|
-
volume: z.ZodNumber;
|
|
97
|
-
tags: z.ZodArray<z.ZodString>;
|
|
98
|
-
}, z.core.$strip>, z.ZodTransform<ComboMarket, {
|
|
99
|
-
id: MarketId;
|
|
100
|
-
condition_id: CtfConditionId;
|
|
101
|
-
position_ids: PositionId[];
|
|
102
|
-
slug: string;
|
|
103
|
-
title: string;
|
|
104
|
-
outcomes: string[];
|
|
105
|
-
outcome_prices: DecimalString[];
|
|
106
|
-
image: string;
|
|
107
|
-
volume: number;
|
|
108
|
-
tags: string[];
|
|
109
|
-
}>>;
|
|
110
252
|
declare const ListComboMarketsResponseSchema: z.ZodPipe<z.ZodObject<{
|
|
111
253
|
markets: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
112
254
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<MarketId, string>>;
|
|
@@ -187,9 +329,6 @@ declare enum RfqKnownInboundType {
|
|
|
187
329
|
Trade = "RFQ_TRADE",
|
|
188
330
|
Error = "RFQ_ERROR"
|
|
189
331
|
}
|
|
190
|
-
declare const RfqKnownInboundMessageSchema: z.ZodObject<{
|
|
191
|
-
type: z.ZodEnum<typeof RfqKnownInboundType>;
|
|
192
|
-
}, z.core.$strip>;
|
|
193
332
|
declare const RfqAuthResponseMessageSchema: z.ZodObject<{
|
|
194
333
|
type: z.ZodLiteral<RfqKnownInboundType.Auth>;
|
|
195
334
|
success: z.ZodBoolean;
|
|
@@ -439,11 +578,11 @@ declare const RfqErrorMessageSchema: z.ZodPipe<z.ZodObject<{
|
|
|
439
578
|
request_type: z.ZodOptional<z.ZodString>;
|
|
440
579
|
rfq_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>>;
|
|
441
580
|
quote_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>>;
|
|
442
|
-
code: z.
|
|
581
|
+
code: z.ZodPipe<z.ZodString, z.ZodTransform<(string & {}) | RfqKnownErrorCode, string>>;
|
|
443
582
|
error: z.ZodString;
|
|
444
583
|
request: z.ZodOptional<z.ZodUnknown>;
|
|
445
584
|
}, z.core.$strip>, z.ZodTransform<{
|
|
446
|
-
code:
|
|
585
|
+
code: (string & {}) | RfqKnownErrorCode;
|
|
447
586
|
errorId: string | undefined;
|
|
448
587
|
message: string;
|
|
449
588
|
quoteId: RfqQuoteId | undefined;
|
|
@@ -452,7 +591,7 @@ declare const RfqErrorMessageSchema: z.ZodPipe<z.ZodObject<{
|
|
|
452
591
|
type: "rfq_error";
|
|
453
592
|
}, {
|
|
454
593
|
type: RfqKnownInboundType.Error;
|
|
455
|
-
code:
|
|
594
|
+
code: (string & {}) | RfqKnownErrorCode;
|
|
456
595
|
error: string;
|
|
457
596
|
error_id?: string | undefined;
|
|
458
597
|
request_type?: string | undefined;
|
|
@@ -674,11 +813,11 @@ declare const RfqQuoterInboundMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
674
813
|
request_type: z.ZodOptional<z.ZodString>;
|
|
675
814
|
rfq_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqId, string>>>;
|
|
676
815
|
quote_id: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<RfqQuoteId, string>>>;
|
|
677
|
-
code: z.
|
|
816
|
+
code: z.ZodPipe<z.ZodString, z.ZodTransform<(string & {}) | RfqKnownErrorCode, string>>;
|
|
678
817
|
error: z.ZodString;
|
|
679
818
|
request: z.ZodOptional<z.ZodUnknown>;
|
|
680
819
|
}, z.core.$strip>, z.ZodTransform<{
|
|
681
|
-
code:
|
|
820
|
+
code: (string & {}) | RfqKnownErrorCode;
|
|
682
821
|
errorId: string | undefined;
|
|
683
822
|
message: string;
|
|
684
823
|
quoteId: RfqQuoteId | undefined;
|
|
@@ -687,7 +826,7 @@ declare const RfqQuoterInboundMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
687
826
|
type: "rfq_error";
|
|
688
827
|
}, {
|
|
689
828
|
type: RfqKnownInboundType.Error;
|
|
690
|
-
code:
|
|
829
|
+
code: (string & {}) | RfqKnownErrorCode;
|
|
691
830
|
error: string;
|
|
692
831
|
error_id?: string | undefined;
|
|
693
832
|
request_type?: string | undefined;
|
|
@@ -698,4 +837,4 @@ declare const RfqQuoterInboundMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
698
837
|
type RfqQuoterInboundMessage = z.infer<typeof RfqQuoterInboundMessageSchema>;
|
|
699
838
|
type RfqQuoterOutboundMessage = RfqQuoteMessage | RfqQuoteCancelMessage | RfqConfirmationResponseMessage;
|
|
700
839
|
|
|
701
|
-
export { type
|
|
840
|
+
export { CollateralReturnKnownOperationKind, type CollateralReturnOperation, type CollateralReturnOperationKind, type CollateralReturnPlanResponse, CollateralReturnPlanResponseSchema, CollateralReturnPlanSchema, type CollateralReturnPositionAmount, type CollateralReturnPositionSummary, type CollateralReturnRouterCall, type ComboMarket, type ComboMarketOutcome, type ComboMarketOutcomes, type ListComboMarketsResponse, ListComboMarketsResponseSchema, type RfqAuthMessage, type RfqAuthResponseMessage, type RfqConfirmationAck, RfqConfirmationDecision, type RfqConfirmationRequest, type RfqConfirmationResponseMessage, RfqDirection, type RfqErrorCode, type RfqErrorMessage, RfqExecutionStatus, type RfqExecutionUpdate, RfqId, RfqKnownErrorCode, RfqKnownInboundType, type RfqOrderSide, type RfqQuoteAck, type RfqQuoteCancelAck, type RfqQuoteCancelMessage, RfqQuoteId, type RfqQuoteMessage, type RfqQuoteRequest, type RfqQuoterInboundMessage, RfqQuoterInboundMessageSchema, type RfqQuoterOutboundMessage, type RfqRequestedSize, RfqRequestedSizeUnit, RfqRequestorPublicId, RfqSide, type RfqSignedOrder, type RfqTrade };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b}from'../chunk-HOD4LKZU.js';import {La,Aa,ja,Z as Z$1,aa,Ka,_,sa,za,ba,Fa,Da,Ea,Ja}from'../chunk-QTXFNR2Y.js';import {expectHexString}from'@polymarket/types';import {z as z$1}from'zod';var y=z$1.string().transform(e=>expectHexString(e)),Q=(n=>(n.Split="split",n.Merge="merge",n.Redeem="redeem",n.SplitOnCondition="split_on_condition",n.MergeOnCondition="merge_on_condition",n.SplitOnEvent="split_on_event",n.MergeOnEvent="merge_on_event",n.ConvertOnEvent="convert_on_event",n.Extract="extract",n.Inject="inject",n.ConvertToYesBasket="convert_to_yes_basket",n.MergeFromYesBasket="merge_from_yes_basket",n.Compress="compress",n))(Q||{}),O=z$1.string().transform(e=>e),P=z$1.object({kind:O,condition_id:Z$1.optional(),event_id:ja.optional(),position_id:Aa.optional(),condition_index:z$1.number().int().nonnegative().optional().default(0),amount:La}).transform(e=>({amount:e.amount,conditionId:e.condition_id,conditionIndex:e.condition_index,eventId:e.event_id,kind:e.kind,positionId:e.position_id})),S=z$1.object({position_id:Aa,amount:La}).transform(e=>({amount:e.amount,positionId:e.position_id})),L=z$1.object({consumed:z$1.array(S),created:z$1.array(S)}).transform(e=>({consumed:e.consumed,created:e.created})),T=z$1.object({to:aa,data:y}).transform(e=>({data:e.data,to:e.to})),ne=z$1.looseObject({planHash:y,chainId:z$1.number().int(),wallet:aa,routerCall:T}),re=z$1.object({plan_hash:y,chain_id:z$1.number().int(),wallet:aa,block_number:z$1.string().regex(/^\d+$/).transform(BigInt),starting_pusd:Ka,net_pusd_out:Ka,final_pusd:Ka,operations:z$1.array(P),operation_count:z$1.number().int(),truncated:z$1.boolean(),estimated_cost:z$1.number(),required_pusd_input:Ka,required_positions:z$1.array(S),position_summary:L.optional(),candidate_position_ids:z$1.array(Aa),router_call:T}).transform(e=>({blockNumber:e.block_number,candidatePositionIds:e.candidate_position_ids,chainId:e.chain_id,estimatedCost:e.estimated_cost,finalPusd:e.final_pusd,netPusdOut:e.net_pusd_out,operationCount:e.operation_count,operations:e.operations,planHash:e.plan_hash,positionSummary:e.position_summary??{consumed:[],created:[]},requiredPositions:e.required_positions,requiredPusdInput:e.required_pusd_input,routerCall:e.router_call,startingPusd:e.starting_pusd,truncated:e.truncated,wallet:e.wallet}));var M=(a=>(a.Buy="BUY",a.Sell="SELL",a))(M||{}),k=(a=>(a.Yes="YES",a.No="NO",a))(k||{}),N=(a=>(a.Confirm="CONFIRM",a.Decline="DECLINE",a))(N||{}),v=(m=>(m.Matched="MATCHED",m.Mined="MINED",m.Confirmed="CONFIRMED",m.Retrying="RETRYING",m.Failed="FAILED",m))(v||{}),U=(a=>(a.Notional="notional",a.Shares="shares",a))(U||{}),F=(i=>(i.AddressMismatch="ADDRESS_MISMATCH",i.AllowanceValidationFailed="ALLOWANCE_VALIDATION_FAILED",i.BalanceValidationFailed="BALANCE_VALIDATION_FAILED",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.InvalidSignature="INVALID_SIGNATURE",i.InternalError="INTERNAL_ERROR",i.LegMetadataUnavailable="LEG_METADATA_UNAVAILABLE",i.MakerAlreadyResponded="MAKER_ALREADY_RESPONDED",i.MakerNotRequired="MAKER_NOT_REQUIRED",i.MakerQuoteLimited="MAKER_QUOTE_LIMITED",i.PreExecutionBalanceReservationFailed="PRE_EXECUTION_BALANCE_RESERVATION_FAILED",i.QuoteMismatch="QUOTE_MISMATCH",i.QuoteUnavailable="QUOTE_UNAVAILABLE",i.RateLimited="RATE_LIMITED",i.RequestFailed="REQUEST_FAILED",i.ServiceUnavailable="SERVICE_UNAVAILABLE",i.SubmissionWindowClosed="SUBMISSION_WINDOW_CLOSED",i.TradeSubmissionFailed="TRADE_SUBMISSION_FAILED",i.Unauthenticated="UNAUTHENTICATED",i.UnauthorizedRole="UNAUTHORIZED_ROLE",i.UnknownRfq="UNKNOWN_RFQ",i))(F||{}),q=z$1.enum(M),A=z$1.literal("YES"),z=z$1.enum(N),j=z$1.enum(v),B=z$1.string().transform(e=>e),V=z$1.object({id:sa,condition_id:_,position_ids:z$1.array(Aa),slug:z$1.string(),title:z$1.string(),outcomes:z$1.array(z$1.string()),outcome_prices:z$1.array(Ka),image:z$1.string(),volume:z$1.number(),tags:z$1.array(z$1.string())}).superRefine((e,f)=>{e.outcomes.length!==2&&f.addIssue({code:"custom",message:`Expected binary combo market outcomes, received ${e.outcomes.length}.`,path:["outcomes"]}),e.position_ids.length!==e.outcomes.length&&f.addIssue({code:"custom",message:"Expected position_ids and outcomes to have matching lengths.",path:["position_ids"]}),e.outcome_prices.length!==e.outcomes.length&&f.addIssue({code:"custom",message:"Expected outcome_prices and outcomes to have matching lengths.",path:["outcome_prices"]});}).transform(e=>({conditionId:e.condition_id,id:e.id,image:e.image,outcomes:{yes:{label:e.outcomes[0],positionId:e.position_ids[0],price:e.outcome_prices[0]},no:{label:e.outcomes[1],positionId:e.position_ids[1],price:e.outcome_prices[1]}},slug:e.slug,tags:e.tags,title:e.title,volume:e.volume})),ue=z$1.object({markets:z$1.array(V),next_cursor:za.nullish()}).transform(e=>({markets:e.markets,nextCursor:e.next_cursor??void 0})),H=z$1.discriminatedUnion("unit",[z$1.object({unit:z$1.literal("notional"),value_e6:La}),z$1.object({unit:z$1.literal("shares"),value_e6:La})]).transform(e=>({unit:e.unit,value:e.value_e6})),Y=(d=>(d.Auth="auth",d.QuoteRequest="RFQ_REQUEST",d.QuoteAck="ACK_RFQ_QUOTE",d.QuoteCancelAck="ACK_RFQ_QUOTE_CANCEL",d.ConfirmationRequest="RFQ_CONFIRMATION_REQUEST",d.ConfirmationAck="ACK_RFQ_CONFIRMATION_RESPONSE",d.ExecutionUpdate="RFQ_EXECUTION_UPDATE",d.Trade="RFQ_TRADE",d.Error="RFQ_ERROR",d))(Y||{}),G=z$1.object({type:z$1.literal("auth"),success:z$1.boolean(),address:aa.optional(),role:z$1.string().optional(),error:z$1.string().optional()}),W=z$1.object({type:z$1.literal("RFQ_REQUEST"),rfq_id:Da,requestor_public_id:Fa,leg_position_ids:z$1.array(Aa),condition_id:Z$1,yes_position_id:Aa,no_position_id:Aa,direction:q,side:A,requested_size:H,submission_deadline:ba}).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})),X=z$1.object({type:z$1.literal("ACK_RFQ_QUOTE"),rfq_id:Da,quote_id:Ea}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_ack"})),Z=z$1.object({type:z$1.literal("ACK_RFQ_QUOTE_CANCEL"),rfq_id:Da,quote_id:Ea}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_cancel_ack"})),$=z$1.object({type:z$1.literal("RFQ_CONFIRMATION_REQUEST"),rfq_id:Da,quote_id:Ea,signer_address:aa,maker_address:aa,signature_type:b,leg_position_ids:z$1.array(Aa),condition_id:Z$1,yes_position_id:Aa,no_position_id:Aa,direction:q,side:A,fill_size_e6:La,price_e6:La,confirm_by:ba}).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})),J=z$1.object({type:z$1.literal("ACK_RFQ_CONFIRMATION_RESPONSE"),rfq_id:Da,quote_id:Ea,decision:z}).transform(e=>({decision:e.decision,quoteId:e.quote_id,rfqId:e.rfq_id,type:"confirmation_ack"})),w=z$1.object({type:z$1.literal("RFQ_EXECUTION_UPDATE"),rfq_id:Da,status:j,tx_hash:Ja.optional()}).transform(e=>({rfqId:e.rfq_id,status:e.status,...e.tx_hash===void 0?{}:{txHash:e.tx_hash},type:"execution_update"})),K=z$1.object({type:z$1.literal("RFQ_TRADE"),rfq_id:Da,requester_id:Fa,condition_id:Z$1,leg_position_ids:z$1.array(Aa),direction:q,side:A,price_e6:La,size_e6:La,executed_at:ba}).transform(e=>({conditionId:e.condition_id,direction:e.direction,executedAt:e.executed_at,legPositionIds:e.leg_position_ids,price:e.price_e6,requesterId:e.requester_id,rfqId:e.rfq_id,side:e.side,size:e.size_e6,type:"trade"})),ee=z$1.object({type:z$1.literal("RFQ_ERROR"),error_id:z$1.string().optional(),request_type:z$1.string().optional(),rfq_id:Da.optional(),quote_id:Ea.optional(),code:B,error:z$1.string(),request:z$1.unknown().optional()}).transform(e=>({code:e.code,errorId:e.error_id,message:e.error,quoteId:e.quote_id,requestType:e.request_type,rfqId:e.rfq_id,type:"rfq_error"})),le=z$1.discriminatedUnion("type",[G,W,X,Z,$,J,w,K,ee]);export{Q as CollateralReturnKnownOperationKind,re as CollateralReturnPlanResponseSchema,ne as CollateralReturnPlanSchema,ue as ListComboMarketsResponseSchema,N as RfqConfirmationDecision,M as RfqDirection,v as RfqExecutionStatus,F as RfqKnownErrorCode,Y as RfqKnownInboundType,le as RfqQuoterInboundMessageSchema,U as RfqRequestedSizeUnit,k as RfqSide};//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/combos/plan.ts","../../src/combos/rfq.ts"],"names":["HexStringSchema","z","value","expectHexString","CollateralReturnKnownOperationKind","CollateralReturnOperationKindSchema","CollateralReturnOperationSchema","ComboConditionIdSchema","EventIdSchema","PositionIdSchema","E6BigIntStringToDecimalStringSchema","operation","CollateralReturnPositionAmountSchema","position","CollateralReturnPositionSummarySchema","summary","CollateralReturnRouterCallSchema","EvmAddressSchema","call","CollateralReturnPlanSchema","CollateralReturnPlanResponseSchema","DecimalStringSchema","response","RfqDirection","RfqSide","RfqConfirmationDecision","RfqExecutionStatus","RfqRequestedSizeUnit","RfqKnownErrorCode","RfqDirectionSchema","RfqSideSchema","RfqConfirmationDecisionSchema","RfqExecutionStatusSchema","RfqErrorCodeSchema","ComboMarketSchema","MarketIdSchema","CtfConditionIdSchema","market","context","ListComboMarketsResponseSchema","PaginationCursorSchema","RfqRequestedSizeSchema","size","RfqKnownInboundType","RfqAuthResponseMessageSchema","RfqQuoteRequestSchema","RfqIdSchema","RfqRequestorPublicIdSchema","EpochMillisecondsSchema","message","RfqQuoteAckSchema","RfqQuoteIdSchema","RfqQuoteCancelAckSchema","RfqConfirmationRequestSchema","SignatureTypeSchema","RfqConfirmationAckSchema","RfqExecutionUpdateSchema","TxHashSchema","RfqTrad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AOhC,GAAAA,CAAE,MAAA,EAAO,CAChB,QAASA,GAAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EACvB,CAAC,CAAA,CACA,SAAA,CAAWgD,CAAAA,GAAa,CACvB,IAAA,CAAMA,CAAAA,CAAQ,IAAA,CACd,OAAA,CAASA,EAAQ,QAAA,CACjB,OAAA,CAASA,CAAAA,CAAQ,KAAA,CACjB,QAASA,CAAAA,CAAQ,QAAA,CACjB,WAAA,CAAaA,CAAAA,CAAQ,aACrB,KAAA,CAAOA,CAAAA,CAAQ,MAAA,CACf,IAAA,CAAM,WACR,CAAA,CAAE,CAAA,CAISW,EAAAA,CAAgC3D,GAAAA,CAAE,mBAAmB,MAAA,CAAQ,CACxE2C,CAAAA,CACAC,CAAAA,CACAK,EACAE,CAAAA,CACAC,CAAAA,CACAE,EACAC,CAAAA,CACAE,CAAAA,CACAC,EACF,CAAC","file":"index.js","sourcesContent":["import { expectHexString, type HexString } from '@polymarket/types';\nimport { z } from 'zod';\nimport type {\n ComboConditionId,\n DecimalString,\n EventId,\n EvmAddress,\n PositionId,\n} from '../shared';\nimport {\n ComboConditionIdSchema,\n DecimalStringSchema,\n E6BigIntStringToDecimalStringSchema,\n EventIdSchema,\n EvmAddressSchema,\n PositionIdSchema,\n} from '../shared';\n\nconst HexStringSchema = z.string().transform((value) => expectHexString(value));\n\n/**\n * Known collateral-return plan operation kinds.\n *\n * The service evolves this set independently of released clients, so plan\n * parsing accepts unknown kinds as plain strings; see\n * {@link CollateralReturnOperationKind}.\n */\nexport enum CollateralReturnKnownOperationKind {\n Split = 'split',\n Merge = 'merge',\n Redeem = 'redeem',\n SplitOnCondition = 'split_on_condition',\n MergeOnCondition = 'merge_on_condition',\n SplitOnEvent = 'split_on_event',\n MergeOnEvent = 'merge_on_event',\n ConvertOnEvent = 'convert_on_event',\n Extract = 'extract',\n Inject = 'inject',\n ConvertToYesBasket = 'convert_to_yes_basket',\n MergeFromYesBasket = 'merge_from_yes_basket',\n Compress = 'compress',\n}\n\n/**\n * A collateral-return operation kind. Known kinds are enumerated in\n * {@link CollateralReturnKnownOperationKind}; newly introduced kinds flow\n * through as plain strings so plans keep parsing before a client release that\n * enumerates them.\n */\nexport type CollateralReturnOperationKind =\n | CollateralReturnKnownOperationKind\n | (string & {});\n\nconst CollateralReturnOperationKindSchema = z\n .string()\n .transform((value): CollateralReturnOperationKind => value);\n\nexport type CollateralReturnOperation = {\n kind: CollateralReturnOperationKind;\n conditionId?: ComboConditionId;\n eventId?: EventId;\n positionId?: PositionId;\n conditionIndex: number;\n amount: DecimalString;\n};\n\nconst CollateralReturnOperationSchema = z\n .object({\n kind: CollateralReturnOperationKindSchema,\n condition_id: ComboConditionIdSchema.optional(),\n event_id: EventIdSchema.optional(),\n position_id: PositionIdSchema.optional(),\n // The wire format omits zero values, so an absent index means 0.\n condition_index: z.number().int().nonnegative().optional().default(0),\n amount: E6BigIntStringToDecimalStringSchema,\n })\n .transform(\n (operation): CollateralReturnOperation => ({\n amount: operation.amount,\n conditionId: operation.condition_id,\n conditionIndex: operation.condition_index,\n eventId: operation.event_id,\n kind: operation.kind,\n positionId: operation.position_id,\n }),\n );\n\nexport type CollateralReturnPositionAmount = {\n positionId: PositionId;\n amount: DecimalString;\n};\n\nconst CollateralReturnPositionAmountSchema = z\n .object({\n position_id: PositionIdSchema,\n amount: E6BigIntStringToDecimalStringSchema,\n })\n .transform(\n (position): CollateralReturnPositionAmount => ({\n amount: position.amount,\n positionId: position.position_id,\n }),\n );\n\nexport type CollateralReturnPositionSummary = {\n consumed: CollateralReturnPositionAmount[];\n created: CollateralReturnPositionAmount[];\n};\n\nconst CollateralReturnPositionSummarySchema = z\n .object({\n consumed: z.array(CollateralReturnPositionAmountSchema),\n created: z.array(CollateralReturnPositionAmountSchema),\n })\n .transform(\n (summary): CollateralReturnPositionSummary => ({\n consumed: summary.consumed,\n created: summary.created,\n }),\n );\n\nexport type CollateralReturnRouterCall = {\n to: EvmAddress;\n data: HexString;\n};\n\nconst CollateralReturnRouterCallSchema = z\n .object({\n to: EvmAddressSchema,\n data: HexStringSchema,\n })\n .transform(\n (call): CollateralReturnRouterCall => ({\n data: call.data,\n to: call.to,\n }),\n );\n\n/**\n * The plan fields execution consumes: the plan identifier round-tripped to\n * the service, the chain and wallet the plan was computed for, and the exact\n * Router call the execution signs and submits.\n */\nexport const CollateralReturnPlanSchema = z.looseObject({\n planHash: HexStringSchema,\n chainId: z.number().int(),\n wallet: EvmAddressSchema,\n routerCall: CollateralReturnRouterCallSchema,\n});\n\nexport type CollateralReturnPlanResponse = {\n planHash: HexString;\n chainId: number;\n wallet: EvmAddress;\n blockNumber: bigint;\n startingPusd: DecimalString;\n netPusdOut: DecimalString;\n finalPusd: DecimalString;\n operations: CollateralReturnOperation[];\n operationCount: number;\n truncated: boolean;\n estimatedCost: number;\n requiredPusdInput: DecimalString;\n requiredPositions: CollateralReturnPositionAmount[];\n positionSummary: CollateralReturnPositionSummary;\n candidatePositionIds: PositionId[];\n routerCall: CollateralReturnRouterCall;\n};\n\nexport const CollateralReturnPlanResponseSchema = z\n .object({\n plan_hash: HexStringSchema,\n chain_id: z.number().int(),\n wallet: EvmAddressSchema,\n block_number: z.string().regex(/^\\d+$/).transform(BigInt),\n starting_pusd: DecimalStringSchema,\n net_pusd_out: DecimalStringSchema,\n final_pusd: DecimalStringSchema,\n operations: z.array(CollateralReturnOperationSchema),\n operation_count: z.number().int(),\n truncated: z.boolean(),\n estimated_cost: z.number(),\n required_pusd_input: DecimalStringSchema,\n required_positions: z.array(CollateralReturnPositionAmountSchema),\n // Tolerate older service builds that predate the summary field.\n position_summary: CollateralReturnPositionSummarySchema.optional(),\n candidate_position_ids: z.array(PositionIdSchema),\n router_call: CollateralReturnRouterCallSchema,\n })\n .transform(\n (response): CollateralReturnPlanResponse => ({\n blockNumber: response.block_number,\n candidatePositionIds: response.candidate_position_ids,\n chainId: response.chain_id,\n estimatedCost: response.estimated_cost,\n finalPusd: response.final_pusd,\n netPusdOut: response.net_pusd_out,\n operationCount: response.operation_count,\n operations: response.operations,\n planHash: response.plan_hash,\n positionSummary: response.position_summary ?? {\n consumed: [],\n created: [],\n },\n requiredPositions: response.required_positions,\n requiredPusdInput: response.required_pusd_input,\n routerCall: response.router_call,\n startingPusd: response.starting_pusd,\n truncated: response.truncated,\n wallet: response.wallet,\n }),\n );\n","import type {\n Erc1271Signature,\n EvmSignature,\n HexString,\n} from '@polymarket/types';\nimport { z } from 'zod';\nimport {\n type SignatureType,\n SignatureTypeSchema,\n} from '../clob/signature-type';\nimport type {\n BaseUnits,\n CtfConditionId,\n DecimalString,\n EvmAddress,\n MarketId,\n TokenId,\n} from '../shared';\nimport {\n ComboConditionIdSchema,\n CtfConditionIdSchema,\n DecimalStringSchema,\n E6BigIntStringToDecimalStringSchema,\n EpochMillisecondsSchema,\n EvmAddressSchema,\n MarketIdSchema,\n type OrderSide,\n PaginationCursorSchema,\n type PositionId,\n PositionIdSchema,\n type RfqId,\n RfqIdSchema,\n type RfqQuoteId,\n RfqQuoteIdSchema,\n RfqRequestorPublicIdSchema,\n TxHashSchema,\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 RfqKnownErrorCode {\n AddressMismatch = 'ADDRESS_MISMATCH',\n AllowanceValidationFailed = 'ALLOWANCE_VALIDATION_FAILED',\n BalanceValidationFailed = 'BALANCE_VALIDATION_FAILED',\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 InvalidSignature = 'INVALID_SIGNATURE',\n InternalError = 'INTERNAL_ERROR',\n LegMetadataUnavailable = 'LEG_METADATA_UNAVAILABLE',\n MakerAlreadyResponded = 'MAKER_ALREADY_RESPONDED',\n MakerNotRequired = 'MAKER_NOT_REQUIRED',\n MakerQuoteLimited = 'MAKER_QUOTE_LIMITED',\n PreExecutionBalanceReservationFailed = 'PRE_EXECUTION_BALANCE_RESERVATION_FAILED',\n QuoteMismatch = 'QUOTE_MISMATCH',\n QuoteUnavailable = 'QUOTE_UNAVAILABLE',\n RateLimited = 'RATE_LIMITED',\n RequestFailed = 'REQUEST_FAILED',\n ServiceUnavailable = 'SERVICE_UNAVAILABLE',\n SubmissionWindowClosed = 'SUBMISSION_WINDOW_CLOSED',\n TradeSubmissionFailed = 'TRADE_SUBMISSION_FAILED',\n Unauthenticated = 'UNAUTHENTICATED',\n UnauthorizedRole = 'UNAUTHORIZED_ROLE',\n UnknownRfq = 'UNKNOWN_RFQ',\n}\n\n/**\n * An RFQ error code. Known codes are enumerated in {@link RfqKnownErrorCode};\n * newly introduced codes flow through as plain strings so they can be handled\n * before a client release that enumerates them.\n */\nexport type RfqErrorCode = RfqKnownErrorCode | (string & {});\n\nconst RfqDirectionSchema = z.enum(RfqDirection);\nconst RfqSideSchema = z.literal(RfqSide.Yes);\nconst RfqConfirmationDecisionSchema = z.enum(RfqConfirmationDecision);\nconst RfqExecutionStatusSchema = z.enum(RfqExecutionStatus);\n\n// Error codes evolve independently of released clients. Codes not yet\n// enumerated in RfqKnownErrorCode must still parse and flow through as-is.\nconst RfqErrorCodeSchema = z.string().transform((value): RfqErrorCode => value);\n\nexport type ComboMarket = {\n id: MarketId;\n conditionId: CtfConditionId;\n slug: string;\n title: string;\n outcomes: ComboMarketOutcomes;\n image: string;\n volume: number;\n tags: string[];\n};\n\nexport type ComboMarketOutcome = {\n label: string;\n positionId: PositionId;\n price: DecimalString;\n};\n\nexport type ComboMarketOutcomes = {\n yes: ComboMarketOutcome;\n no: ComboMarketOutcome;\n};\n\nconst ComboMarketSchema = z\n .object({\n id: MarketIdSchema,\n condition_id: CtfConditionIdSchema,\n position_ids: z.array(PositionIdSchema),\n slug: z.string(),\n title: z.string(),\n outcomes: z.array(z.string()),\n outcome_prices: z.array(DecimalStringSchema),\n image: z.string(),\n volume: z.number(),\n tags: z.array(z.string()),\n })\n .superRefine((market, context) => {\n if (market.outcomes.length !== 2) {\n context.addIssue({\n code: 'custom',\n message: `Expected binary combo market outcomes, received ${market.outcomes.length}.`,\n path: ['outcomes'],\n });\n }\n\n if (market.position_ids.length !== market.outcomes.length) {\n context.addIssue({\n code: 'custom',\n message: 'Expected position_ids and outcomes to have matching lengths.',\n path: ['position_ids'],\n });\n }\n\n if (market.outcome_prices.length !== market.outcomes.length) {\n context.addIssue({\n code: 'custom',\n message:\n 'Expected outcome_prices and outcomes to have matching lengths.',\n path: ['outcome_prices'],\n });\n }\n })\n .transform(\n (market): ComboMarket => ({\n conditionId: market.condition_id,\n id: market.id,\n image: market.image,\n outcomes: {\n yes: {\n label: market.outcomes[0] as string,\n positionId: market.position_ids[0] as PositionId,\n price: market.outcome_prices[0] as DecimalString,\n },\n no: {\n label: market.outcomes[1] as string,\n positionId: market.position_ids[1] as PositionId,\n price: market.outcome_prices[1] as DecimalString,\n },\n },\n slug: market.slug,\n tags: market.tags,\n title: market.title,\n volume: market.volume,\n }),\n );\n\nexport const ListComboMarketsResponseSchema = z\n .object({\n markets: z.array(ComboMarketSchema),\n next_cursor: PaginationCursorSchema.nullish(),\n })\n .transform((response) => ({\n markets: response.markets,\n nextCursor: response.next_cursor ?? undefined,\n }));\n\nexport type ListComboMarketsResponse = z.infer<\n typeof ListComboMarketsResponseSchema\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: E6BigIntStringToDecimalStringSchema,\n }),\n z.object({\n unit: z.literal(RfqRequestedSizeUnit.Shares),\n value_e6: E6BigIntStringToDecimalStringSchema,\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 Trade = 'RFQ_TRADE',\n Error = 'RFQ_ERROR',\n}\n\nconst RfqAuthResponseMessageSchema = z.object({\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\nexport type RfqAuthResponseMessage = z.infer<\n typeof RfqAuthResponseMessageSchema\n>;\n\nconst RfqQuoteRequestSchema = z\n .object({\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: ComboConditionIdSchema,\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 })\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\nconst RfqQuoteAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.QuoteAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n })\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\nconst RfqQuoteCancelAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.QuoteCancelAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n })\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\nconst RfqConfirmationRequestSchema = z\n .object({\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: ComboConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n fill_size_e6: E6BigIntStringToDecimalStringSchema,\n price_e6: E6BigIntStringToDecimalStringSchema,\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\nconst RfqConfirmationAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.ConfirmationAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n decision: RfqConfirmationDecisionSchema,\n })\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\nconst RfqExecutionUpdateSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.ExecutionUpdate),\n rfq_id: RfqIdSchema,\n status: RfqExecutionStatusSchema,\n tx_hash: TxHashSchema.optional(),\n })\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\nconst RfqTradeSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.Trade),\n rfq_id: RfqIdSchema,\n requester_id: RfqRequestorPublicIdSchema,\n condition_id: ComboConditionIdSchema,\n leg_position_ids: z.array(PositionIdSchema),\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n price_e6: E6BigIntStringToDecimalStringSchema,\n size_e6: E6BigIntStringToDecimalStringSchema,\n executed_at: EpochMillisecondsSchema,\n })\n .transform((message) => ({\n conditionId: message.condition_id,\n direction: message.direction,\n executedAt: message.executed_at,\n legPositionIds: message.leg_position_ids,\n price: message.price_e6,\n requesterId: message.requester_id,\n rfqId: message.rfq_id,\n side: message.side,\n size: message.size_e6,\n type: 'trade' as const,\n }));\n\nexport type RfqTrade = z.infer<typeof RfqTradeSchema>;\n\nconst RfqErrorMessageSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.Error),\n error_id: z.string().optional(),\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 })\n .transform((message) => ({\n code: message.code,\n errorId: message.error_id,\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.discriminatedUnion('type', [\n RfqAuthResponseMessageSchema,\n RfqQuoteRequestSchema,\n RfqQuoteAckSchema,\n RfqQuoteCancelAckSchema,\n RfqConfirmationRequestSchema,\n RfqConfirmationAckSchema,\n RfqExecutionUpdateSchema,\n RfqTradeSchema,\n RfqErrorMessageSchema,\n]);\n\nexport type RfqQuoterInboundMessage = z.infer<\n typeof RfqQuoterInboundMessageSchema\n>;\n\nexport type RfqQuoterOutboundMessage =\n | RfqQuoteMessage\n | RfqQuoteCancelMessage\n | RfqConfirmationResponseMessage;\n"]}
|