pmxtjs 2.49.0 → 2.49.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.
Files changed (62) hide show
  1. package/README.md +72 -10
  2. package/dist/esm/generated/src/models/Balance.d.ts +6 -0
  3. package/dist/esm/generated/src/models/Balance.js +2 -0
  4. package/dist/esm/generated/src/models/BuiltOrder.d.ts +6 -0
  5. package/dist/esm/generated/src/models/BuiltOrder.js +2 -0
  6. package/dist/esm/generated/src/models/ErrorDetail.d.ts +58 -2
  7. package/dist/esm/generated/src/models/ErrorDetail.js +37 -0
  8. package/dist/esm/generated/src/models/ExchangeOptions.d.ts +70 -0
  9. package/dist/esm/generated/src/models/ExchangeOptions.js +53 -0
  10. package/dist/esm/generated/src/models/MatchedMarketPair.d.ts +1 -1
  11. package/dist/esm/generated/src/models/Order.d.ts +18 -0
  12. package/dist/esm/generated/src/models/Order.js +6 -0
  13. package/dist/esm/generated/src/models/Position.d.ts +33 -9
  14. package/dist/esm/generated/src/models/Position.js +12 -12
  15. package/dist/esm/generated/src/models/UnifiedSeries.d.ts +4 -4
  16. package/dist/esm/generated/src/models/UserTrade.d.ts +18 -0
  17. package/dist/esm/generated/src/models/UserTrade.js +6 -0
  18. package/dist/esm/generated/src/models/index.d.ts +1 -0
  19. package/dist/esm/generated/src/models/index.js +1 -0
  20. package/dist/esm/pmxt/client.d.ts +3 -0
  21. package/dist/esm/pmxt/client.js +40 -5
  22. package/dist/generated/src/models/Balance.d.ts +6 -0
  23. package/dist/generated/src/models/Balance.js +2 -0
  24. package/dist/generated/src/models/BuiltOrder.d.ts +6 -0
  25. package/dist/generated/src/models/BuiltOrder.js +2 -0
  26. package/dist/generated/src/models/ErrorDetail.d.ts +58 -2
  27. package/dist/generated/src/models/ErrorDetail.js +38 -0
  28. package/dist/generated/src/models/ExchangeOptions.d.ts +70 -0
  29. package/dist/generated/src/models/ExchangeOptions.js +60 -0
  30. package/dist/generated/src/models/MatchedMarketPair.d.ts +1 -1
  31. package/dist/generated/src/models/Order.d.ts +18 -0
  32. package/dist/generated/src/models/Order.js +6 -0
  33. package/dist/generated/src/models/Position.d.ts +33 -9
  34. package/dist/generated/src/models/Position.js +12 -12
  35. package/dist/generated/src/models/UnifiedSeries.d.ts +4 -4
  36. package/dist/generated/src/models/UserTrade.d.ts +18 -0
  37. package/dist/generated/src/models/UserTrade.js +6 -0
  38. package/dist/generated/src/models/index.d.ts +1 -0
  39. package/dist/generated/src/models/index.js +1 -0
  40. package/dist/pmxt/client.d.ts +3 -0
  41. package/dist/pmxt/client.js +40 -5
  42. package/generated/.openapi-generator/FILES +2 -0
  43. package/generated/docs/Balance.md +2 -0
  44. package/generated/docs/BuiltOrder.md +2 -0
  45. package/generated/docs/ErrorDetail.md +9 -0
  46. package/generated/docs/ExchangeOptions.md +47 -0
  47. package/generated/docs/Order.md +6 -0
  48. package/generated/docs/Position.md +9 -0
  49. package/generated/docs/UserTrade.md +6 -0
  50. package/generated/package.json +1 -1
  51. package/generated/src/models/Balance.ts +8 -0
  52. package/generated/src/models/BuiltOrder.ts +8 -0
  53. package/generated/src/models/ErrorDetail.ts +67 -2
  54. package/generated/src/models/ExchangeOptions.ts +115 -0
  55. package/generated/src/models/MatchedMarketPair.ts +1 -1
  56. package/generated/src/models/Order.ts +24 -0
  57. package/generated/src/models/Position.ts +45 -17
  58. package/generated/src/models/UnifiedSeries.ts +4 -4
  59. package/generated/src/models/UserTrade.ts +24 -0
  60. package/generated/src/models/index.ts +1 -0
  61. package/package.json +2 -2
  62. package/pmxt/client.ts +47 -7
@@ -26,16 +26,8 @@ function instanceOfPosition(value) {
26
26
  return false;
27
27
  if (!('outcomeId' in value) || value['outcomeId'] === undefined)
28
28
  return false;
29
- if (!('outcomeLabel' in value) || value['outcomeLabel'] === undefined)
30
- return false;
31
29
  if (!('size' in value) || value['size'] === undefined)
32
30
  return false;
33
- if (!('entryPrice' in value) || value['entryPrice'] === undefined)
34
- return false;
35
- if (!('currentPrice' in value) || value['currentPrice'] === undefined)
36
- return false;
37
- if (!('unrealizedPnL' in value) || value['unrealizedPnL'] === undefined)
38
- return false;
39
31
  return true;
40
32
  }
41
33
  function PositionFromJSON(json) {
@@ -48,12 +40,16 @@ function PositionFromJSONTyped(json, ignoreDiscriminator) {
48
40
  return {
49
41
  'marketId': json['marketId'],
50
42
  'outcomeId': json['outcomeId'],
51
- 'outcomeLabel': json['outcomeLabel'],
43
+ 'outcomeLabel': json['outcomeLabel'] == null ? undefined : json['outcomeLabel'],
52
44
  'size': json['size'],
53
- 'entryPrice': json['entryPrice'],
54
- 'currentPrice': json['currentPrice'],
55
- 'unrealizedPnL': json['unrealizedPnL'],
45
+ 'entryPrice': json['entryPrice'] == null ? undefined : json['entryPrice'],
46
+ 'currentPrice': json['currentPrice'] == null ? undefined : json['currentPrice'],
47
+ 'currentValue': json['currentValue'] == null ? undefined : json['currentValue'],
48
+ 'unrealizedPnL': json['unrealizedPnL'] == null ? undefined : json['unrealizedPnL'],
56
49
  'realizedPnL': json['realizedPnL'] == null ? undefined : json['realizedPnL'],
50
+ 'txHash': json['txHash'] == null ? undefined : json['txHash'],
51
+ 'chain': json['chain'] == null ? undefined : json['chain'],
52
+ 'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
57
53
  };
58
54
  }
59
55
  function PositionToJSON(json) {
@@ -70,7 +66,11 @@ function PositionToJSONTyped(value, ignoreDiscriminator = false) {
70
66
  'size': value['size'],
71
67
  'entryPrice': value['entryPrice'],
72
68
  'currentPrice': value['currentPrice'],
69
+ 'currentValue': value['currentValue'],
73
70
  'unrealizedPnL': value['unrealizedPnL'],
74
71
  'realizedPnL': value['realizedPnL'],
72
+ 'txHash': value['txHash'],
73
+ 'chain': value['chain'],
74
+ 'blockNumber': value['blockNumber'],
75
75
  };
76
76
  }
@@ -41,13 +41,13 @@ export interface UnifiedSeries {
41
41
  */
42
42
  title: string;
43
43
  /**
44
- *
44
+ * Long-form series description.
45
45
  * @type {string}
46
46
  * @memberof UnifiedSeries
47
47
  */
48
48
  description?: string | null;
49
49
  /**
50
- *
50
+ * Recurrence cadence the venue reports ('daily', 'weekly', 'annual', ...).
51
51
  * @type {string}
52
52
  * @memberof UnifiedSeries
53
53
  */
@@ -59,13 +59,13 @@ export interface UnifiedSeries {
59
59
  */
60
60
  events?: Array<UnifiedEvent>;
61
61
  /**
62
- *
62
+ * Canonical venue URL for the series.
63
63
  * @type {string}
64
64
  * @memberof UnifiedSeries
65
65
  */
66
66
  url?: string | null;
67
67
  /**
68
- *
68
+ * Venue-hosted image.
69
69
  * @type {string}
70
70
  * @memberof UnifiedSeries
71
71
  */
@@ -57,6 +57,24 @@ export interface UserTrade {
57
57
  * @memberof UserTrade
58
58
  */
59
59
  orderId?: string;
60
+ /**
61
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
62
+ * @type {string}
63
+ * @memberof UserTrade
64
+ */
65
+ txHash?: string | null;
66
+ /**
67
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
68
+ * @type {string}
69
+ * @memberof UserTrade
70
+ */
71
+ chain?: string | null;
72
+ /**
73
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
74
+ * @type {number}
75
+ * @memberof UserTrade
76
+ */
77
+ blockNumber?: number | null;
60
78
  }
61
79
  /**
62
80
  * @export
@@ -58,6 +58,9 @@ function UserTradeFromJSONTyped(json, ignoreDiscriminator) {
58
58
  'side': json['side'],
59
59
  'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
60
60
  'orderId': json['orderId'] == null ? undefined : json['orderId'],
61
+ 'txHash': json['txHash'] == null ? undefined : json['txHash'],
62
+ 'chain': json['chain'] == null ? undefined : json['chain'],
63
+ 'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
61
64
  };
62
65
  }
63
66
  function UserTradeToJSON(json) {
@@ -75,5 +78,8 @@ function UserTradeToJSONTyped(value, ignoreDiscriminator = false) {
75
78
  'side': value['side'],
76
79
  'outcomeId': value['outcomeId'],
77
80
  'orderId': value['orderId'],
81
+ 'txHash': value['txHash'],
82
+ 'chain': value['chain'],
83
+ 'blockNumber': value['blockNumber'],
78
84
  };
79
85
  }
@@ -21,6 +21,7 @@ export * from './EventFilterCriteriaTotalVolume';
21
21
  export * from './EventMatchResult';
22
22
  export * from './ExchangeCredentials';
23
23
  export * from './ExchangeCredentialsSignatureType';
24
+ export * from './ExchangeOptions';
24
25
  export * from './ExecutionPriceResult';
25
26
  export * from './FeedFetchHistoricalPrices200Response';
26
27
  export * from './FeedFetchOHLCV200Response';
@@ -39,6 +39,7 @@ __exportStar(require("./EventFilterCriteriaTotalVolume"), exports);
39
39
  __exportStar(require("./EventMatchResult"), exports);
40
40
  __exportStar(require("./ExchangeCredentials"), exports);
41
41
  __exportStar(require("./ExchangeCredentialsSignatureType"), exports);
42
+ __exportStar(require("./ExchangeOptions"), exports);
42
43
  __exportStar(require("./ExecutionPriceResult"), exports);
43
44
  __exportStar(require("./FeedFetchHistoricalPrices200Response"), exports);
44
45
  __exportStar(require("./FeedFetchOHLCV200Response"), exports);
@@ -72,6 +72,9 @@ export interface ExchangeOptions {
72
72
  */
73
73
  export declare abstract class Exchange {
74
74
  private static readonly OBDATA_WATCH_ALL_SOURCES;
75
+ private static readonly _UUID_RE;
76
+ /** True iff `value` parses as a canonical catalog UUID string. */
77
+ protected static _isCatalogUuid(value: string): boolean;
75
78
  exchangeName: string;
76
79
  pmxtApiKey?: string;
77
80
  protected apiKey?: string;
@@ -151,6 +151,14 @@ class Exchange {
151
151
  "kalshi",
152
152
  "opinion",
153
153
  ]);
154
+ // Match a canonical 8-4-4-4-12 UUID string. The hosted catalog emits
155
+ // UUIDs in this exact shape, so a regex is both faster and stricter
156
+ // than `crypto.randomUUID()`-style parsing.
157
+ static _UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
158
+ /** True iff `value` parses as a canonical catalog UUID string. */
159
+ static _isCatalogUuid(value) {
160
+ return Exchange._UUID_RE.test(value);
161
+ }
154
162
  // Public so structural interfaces like `HostedClientLike`
155
163
  // (./hosted-routing) can read the venue name and hosted credentials
156
164
  // without violating protected-access on this base class.
@@ -2205,12 +2213,17 @@ class Exchange {
2205
2213
  throw new errors_js_1.InvalidOrder("cannot specify both 'outcome' and 'marketId'/'outcomeId'");
2206
2214
  }
2207
2215
  const outcome = params.outcome;
2208
- if (!outcome.marketId) {
2209
- throw new errors_js_1.InvalidOrder("outcome.marketId is not set; ensure the outcome comes from a fetched market");
2216
+ if (!outcome.outcomeId) {
2217
+ throw new errors_js_1.InvalidOrder("outcome.outcomeId is not set; ensure the outcome comes from a fetched market");
2210
2218
  }
2211
- marketId = outcome.marketId;
2219
+ // marketId is optional in hosted mode -- backend derives it from
2220
+ // outcomeId (catalog UUID). Forward it when present for backcompat.
2221
+ marketId = outcome.marketId || undefined;
2212
2222
  outcomeId = outcome.outcomeId;
2213
2223
  }
2224
+ if (!outcomeId) {
2225
+ throw new errors_js_1.InvalidOrder("outcomeId is required (or pass an 'outcome' from a fetched market)");
2226
+ }
2214
2227
  const side = String(params.side);
2215
2228
  const orderType = String(params.type ?? "market");
2216
2229
  const denom = params["denom"];
@@ -2247,15 +2260,37 @@ class Exchange {
2247
2260
  }
2248
2261
  // to6dec throws InvalidOrder for sub-micro precision.
2249
2262
  const amount6dec = (0, hosted_mappers_js_1.to6dec)(params.amount).toString();
2263
+ // The supplied outcomeId may be a catalog UUID OR a venue-native id
2264
+ // (e.g. a Polymarket tokenId or an Opinion market hash). Catalog
2265
+ // UUIDs are forwarded as `outcome_id`; venue-native ids are
2266
+ // forwarded as `(venue, venue_outcome_id)` so the backend resolver
2267
+ // picks the right path. Either shape is accepted by the v0 trading
2268
+ // API.
2250
2269
  const body = {
2251
- market_id: marketId,
2252
- outcome_id: outcomeId,
2253
2270
  side,
2254
2271
  order_type: orderType,
2255
2272
  denom: resolvedDenom,
2256
2273
  amount: params.amount,
2257
2274
  amount_6dec: amount6dec,
2258
2275
  };
2276
+ if (Exchange._isCatalogUuid(outcomeId)) {
2277
+ body["outcome_id"] = outcomeId;
2278
+ // market_id is optional in hosted mode: backend derives it
2279
+ // from outcome_id (UUID) when omitted. Forward only when the
2280
+ // caller supplied a non-empty UUID -- "absent" and "null" are
2281
+ // not equivalent under some Pydantic configs on the backend.
2282
+ if (marketId && Exchange._isCatalogUuid(marketId)) {
2283
+ body["market_id"] = marketId;
2284
+ }
2285
+ }
2286
+ else {
2287
+ // Venue-native form: backend resolves the row from
2288
+ // (source_exchange, pmxt_id). marketId from a venue client is
2289
+ // itself venue-native and would fail backend UUID validation
2290
+ // if forwarded -- suppress it.
2291
+ body["venue"] = this.exchangeName;
2292
+ body["venue_outcome_id"] = outcomeId;
2293
+ }
2259
2294
  if (params.price !== undefined)
2260
2295
  body["price"] = params.price;
2261
2296
  const extra = params;
@@ -27,6 +27,7 @@ docs/EventFilterCriteriaTotalVolume.md
27
27
  docs/EventMatchResult.md
28
28
  docs/ExchangeCredentials.md
29
29
  docs/ExchangeCredentialsSignatureType.md
30
+ docs/ExchangeOptions.md
30
31
  docs/ExecutionPriceResult.md
31
32
  docs/FeedFetchHistoricalPrices200Response.md
32
33
  docs/FeedFetchOHLCV200Response.md
@@ -136,6 +137,7 @@ src/models/EventFilterCriteriaTotalVolume.ts
136
137
  src/models/EventMatchResult.ts
137
138
  src/models/ExchangeCredentials.ts
138
139
  src/models/ExchangeCredentialsSignatureType.ts
140
+ src/models/ExchangeOptions.ts
139
141
  src/models/ExecutionPriceResult.ts
140
142
  src/models/FeedFetchHistoricalPrices200Response.ts
141
143
  src/models/FeedFetchOHLCV200Response.ts
@@ -10,6 +10,7 @@ Name | Type
10
10
  `total` | number
11
11
  `available` | number
12
12
  `locked` | number
13
+ `venue` | string
13
14
 
14
15
  ## Example
15
16
 
@@ -22,6 +23,7 @@ const example = {
22
23
  "total": null,
23
24
  "available": null,
24
25
  "locked": null,
26
+ "venue": null,
25
27
  } satisfies Balance
26
28
 
27
29
  console.log(example)
@@ -11,6 +11,7 @@ Name | Type
11
11
  `signedOrder` | { [key: string]: any; }
12
12
  `tx` | [BuiltOrderTx](BuiltOrderTx.md)
13
13
  `raw` | any
14
+ `expiry` | number
14
15
 
15
16
  ## Example
16
17
 
@@ -24,6 +25,7 @@ const example = {
24
25
  "signedOrder": null,
25
26
  "tx": null,
26
27
  "raw": null,
28
+ "expiry": null,
27
29
  } satisfies BuiltOrder
28
30
 
29
31
  console.log(example)
@@ -1,12 +1,17 @@
1
1
 
2
2
  # ErrorDetail
3
3
 
4
+ Structured error envelope returned inside `BaseResponse.error` and `ErrorResponse.error`. Hosted-mode endpoints populate `code`, `retryable`, and optionally `exchange` / `detail`; legacy local-mode endpoints may still return only `message`.
4
5
 
5
6
  ## Properties
6
7
 
7
8
  Name | Type
8
9
  ------------ | -------------
9
10
  `message` | string
11
+ `code` | string
12
+ `retryable` | boolean
13
+ `exchange` | string
14
+ `detail` | { [key: string]: any; }
10
15
 
11
16
  ## Example
12
17
 
@@ -16,6 +21,10 @@ import type { ErrorDetail } from 'pmxtjs'
16
21
  // TODO: Update the object below with actual values
17
22
  const example = {
18
23
  "message": null,
24
+ "code": null,
25
+ "retryable": null,
26
+ "exchange": null,
27
+ "detail": null,
19
28
  } satisfies ErrorDetail
20
29
 
21
30
  console.log(example)
@@ -0,0 +1,47 @@
1
+
2
+ # ExchangeOptions
3
+
4
+ Constructor-level options for venue clients (Polymarket, Kalshi, Opinion, etc.). Hosted mode is the default when pmxtApiKey is set; otherwise the SDK runs against a local sidecar with venue credentials.
5
+
6
+ ## Properties
7
+
8
+ Name | Type
9
+ ------------ | -------------
10
+ `pmxtApiKey` | string
11
+ `walletAddress` | string
12
+ `signer` | object
13
+ `privateKey` | string
14
+ `baseUrl` | string
15
+ `apiKey` | string
16
+ `autoStartServer` | boolean
17
+
18
+ ## Example
19
+
20
+ ```typescript
21
+ import type { ExchangeOptions } from 'pmxtjs'
22
+
23
+ // TODO: Update the object below with actual values
24
+ const example = {
25
+ "pmxtApiKey": null,
26
+ "walletAddress": null,
27
+ "signer": null,
28
+ "privateKey": null,
29
+ "baseUrl": null,
30
+ "apiKey": null,
31
+ "autoStartServer": null,
32
+ } satisfies ExchangeOptions
33
+
34
+ console.log(example)
35
+
36
+ // Convert the instance to a JSON string
37
+ const exampleJSON: string = JSON.stringify(example)
38
+ console.log(exampleJSON)
39
+
40
+ // Parse the JSON string back to an object
41
+ const exampleParsed = JSON.parse(exampleJSON) as ExchangeOptions
42
+ console.log(exampleParsed)
43
+ ```
44
+
45
+ [[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
46
+
47
+
@@ -20,6 +20,9 @@ Name | Type
20
20
  `timestamp` | number
21
21
  `fee` | number
22
22
  `feeRateBps` | number
23
+ `txHash` | string
24
+ `chain` | string
25
+ `blockNumber` | number
23
26
 
24
27
  ## Example
25
28
 
@@ -42,6 +45,9 @@ const example = {
42
45
  "timestamp": null,
43
46
  "fee": null,
44
47
  "feeRateBps": null,
48
+ "txHash": null,
49
+ "chain": null,
50
+ "blockNumber": null,
45
51
  } satisfies Order
46
52
 
47
53
  console.log(example)
@@ -1,6 +1,7 @@
1
1
 
2
2
  # Position
3
3
 
4
+ A current position in a market. In hosted mode, `outcomeLabel`, `entryPrice`, `currentPrice` and `unrealizedPnL` may be null when the server cannot derive them (e.g. `with_mtm=false` or no fill history). Venue-direct callers continue to populate every field.
4
5
 
5
6
  ## Properties
6
7
 
@@ -12,8 +13,12 @@ Name | Type
12
13
  `size` | number
13
14
  `entryPrice` | number
14
15
  `currentPrice` | number
16
+ `currentValue` | number
15
17
  `unrealizedPnL` | number
16
18
  `realizedPnL` | number
19
+ `txHash` | string
20
+ `chain` | string
21
+ `blockNumber` | number
17
22
 
18
23
  ## Example
19
24
 
@@ -28,8 +33,12 @@ const example = {
28
33
  "size": null,
29
34
  "entryPrice": null,
30
35
  "currentPrice": null,
36
+ "currentValue": null,
31
37
  "unrealizedPnL": null,
32
38
  "realizedPnL": null,
39
+ "txHash": null,
40
+ "chain": null,
41
+ "blockNumber": null,
33
42
  } satisfies Position
34
43
 
35
44
  console.log(example)
@@ -13,6 +13,9 @@ Name | Type
13
13
  `side` | string
14
14
  `outcomeId` | string
15
15
  `orderId` | string
16
+ `txHash` | string
17
+ `chain` | string
18
+ `blockNumber` | number
16
19
 
17
20
  ## Example
18
21
 
@@ -28,6 +31,9 @@ const example = {
28
31
  "side": null,
29
32
  "outcomeId": null,
30
33
  "orderId": null,
34
+ "txHash": null,
35
+ "chain": null,
36
+ "blockNumber": null,
31
37
  } satisfies UserTrade
32
38
 
33
39
  console.log(example)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.49.0",
3
+ "version": "2.49.3",
4
4
  "description": "OpenAPI client for pmxtjs",
5
5
  "author": "OpenAPI-Generator",
6
6
  "repository": {
@@ -43,6 +43,12 @@ export interface Balance {
43
43
  * @memberof Balance
44
44
  */
45
45
  locked: number;
46
+ /**
47
+ * Hosted-mode: which venue this balance belongs to in a multi-venue response. Null when the balance is venue-agnostic.
48
+ * @type {string}
49
+ * @memberof Balance
50
+ */
51
+ venue?: string | null;
46
52
  }
47
53
 
48
54
  /**
@@ -70,6 +76,7 @@ export function BalanceFromJSONTyped(json: any, ignoreDiscriminator: boolean): B
70
76
  'total': json['total'],
71
77
  'available': json['available'],
72
78
  'locked': json['locked'],
79
+ 'venue': json['venue'] == null ? undefined : json['venue'],
73
80
  };
74
81
  }
75
82
 
@@ -88,6 +95,7 @@ export function BalanceToJSONTyped(value?: Balance | null, ignoreDiscriminator:
88
95
  'total': value['total'],
89
96
  'available': value['available'],
90
97
  'locked': value['locked'],
98
+ 'venue': value['venue'],
91
99
  };
92
100
  }
93
101
 
@@ -64,6 +64,12 @@ export interface BuiltOrder {
64
64
  * @memberof BuiltOrder
65
65
  */
66
66
  raw: any | null;
67
+ /**
68
+ * Unix epoch (ms) when this built order expires server-side. Submitting after expiry returns BUILT_ORDER_EXPIRED.
69
+ * @type {number}
70
+ * @memberof BuiltOrder
71
+ */
72
+ expiry?: number | null;
67
73
  }
68
74
 
69
75
  /**
@@ -91,6 +97,7 @@ export function BuiltOrderFromJSONTyped(json: any, ignoreDiscriminator: boolean)
91
97
  'signedOrder': json['signedOrder'] == null ? undefined : json['signedOrder'],
92
98
  'tx': json['tx'] == null ? undefined : BuiltOrderTxFromJSON(json['tx']),
93
99
  'raw': json['raw'],
100
+ 'expiry': json['expiry'] == null ? undefined : json['expiry'],
94
101
  };
95
102
  }
96
103
 
@@ -110,6 +117,7 @@ export function BuiltOrderToJSONTyped(value?: BuiltOrder | null, ignoreDiscrimin
110
117
  'signedOrder': value['signedOrder'],
111
118
  'tx': BuiltOrderTxToJSON(value['tx']),
112
119
  'raw': value['raw'],
120
+ 'expiry': value['expiry'],
113
121
  };
114
122
  }
115
123
 
@@ -14,19 +14,76 @@
14
14
 
15
15
  import { mapValues } from '../runtime';
16
16
  /**
17
- *
17
+ * Structured error envelope returned inside `BaseResponse.error` and `ErrorResponse.error`. Hosted-mode endpoints populate `code`, `retryable`, and optionally `exchange` / `detail`; legacy local-mode endpoints may still return only `message`.
18
18
  * @export
19
19
  * @interface ErrorDetail
20
20
  */
21
21
  export interface ErrorDetail {
22
22
  /**
23
- *
23
+ * Human-readable error message.
24
24
  * @type {string}
25
25
  * @memberof ErrorDetail
26
26
  */
27
27
  message?: string;
28
+ /**
29
+ * Stable machine-readable error code. Hosted-mode errors use the `HostedTradingError` family (e.g. `INSUFFICIENT_ESCROW_BALANCE`, `BUILT_ORDER_EXPIRED`); pre-hosted local errors use the legacy family (e.g. `BAD_REQUEST`, `NOT_FOUND`).
30
+ * @type {string}
31
+ * @memberof ErrorDetail
32
+ */
33
+ code?: ErrorDetailCodeEnum;
34
+ /**
35
+ * Hint for clients: when `true`, the same request may succeed on retry (e.g. transient network or rate-limit conditions); when `false`, the caller should not retry without modifying the request.
36
+ * @type {boolean}
37
+ * @memberof ErrorDetail
38
+ */
39
+ retryable?: boolean;
40
+ /**
41
+ * Venue the error originated from, when known (e.g. 'polymarket', 'kalshi').
42
+ * @type {string}
43
+ * @memberof ErrorDetail
44
+ */
45
+ exchange?: string | null;
46
+ /**
47
+ * Free-form hosted-mode detail blob. Shape depends on `code` — e.g. for `INSUFFICIENT_ESCROW_BALANCE` it may include `{ requested, available }`; for `ORDER_SIZE_TOO_SMALL` it may include `{ min }`; for `BUILT_ORDER_EXPIRED` it may include `{ expiry }`.
48
+ * @type {{ [key: string]: any; }}
49
+ * @memberof ErrorDetail
50
+ */
51
+ detail?: { [key: string]: any; } | null;
28
52
  }
29
53
 
54
+
55
+ /**
56
+ * @export
57
+ */
58
+ export const ErrorDetailCodeEnum = {
59
+ HostedTradingError: 'HOSTED_TRADING_ERROR',
60
+ InsufficientEscrowBalance: 'INSUFFICIENT_ESCROW_BALANCE',
61
+ OrderSizeTooSmall: 'ORDER_SIZE_TOO_SMALL',
62
+ InvalidApiKey: 'INVALID_API_KEY',
63
+ OutcomeNotFound: 'OUTCOME_NOT_FOUND',
64
+ CatalogUnavailable: 'CATALOG_UNAVAILABLE',
65
+ BuiltOrderExpired: 'BUILT_ORDER_EXPIRED',
66
+ InvalidSignature: 'INVALID_SIGNATURE',
67
+ NoLiquidity: 'NO_LIQUIDITY',
68
+ MissingWalletAddress: 'MISSING_WALLET_ADDRESS',
69
+ BadRequest: 'BAD_REQUEST',
70
+ AuthenticationError: 'AUTHENTICATION_ERROR',
71
+ PermissionDenied: 'PERMISSION_DENIED',
72
+ NotFound: 'NOT_FOUND',
73
+ OrderNotFound: 'ORDER_NOT_FOUND',
74
+ MarketNotFound: 'MARKET_NOT_FOUND',
75
+ EventNotFound: 'EVENT_NOT_FOUND',
76
+ RateLimitExceeded: 'RATE_LIMIT_EXCEEDED',
77
+ InvalidOrder: 'INVALID_ORDER',
78
+ InsufficientFunds: 'INSUFFICIENT_FUNDS',
79
+ ValidationError: 'VALIDATION_ERROR',
80
+ NetworkError: 'NETWORK_ERROR',
81
+ ExchangeNotAvailable: 'EXCHANGE_NOT_AVAILABLE',
82
+ NotSupported: 'NOT_SUPPORTED'
83
+ } as const;
84
+ export type ErrorDetailCodeEnum = typeof ErrorDetailCodeEnum[keyof typeof ErrorDetailCodeEnum];
85
+
86
+
30
87
  /**
31
88
  * Check if a given object implements the ErrorDetail interface.
32
89
  */
@@ -45,6 +102,10 @@ export function ErrorDetailFromJSONTyped(json: any, ignoreDiscriminator: boolean
45
102
  return {
46
103
 
47
104
  'message': json['message'] == null ? undefined : json['message'],
105
+ 'code': json['code'] == null ? undefined : json['code'],
106
+ 'retryable': json['retryable'] == null ? undefined : json['retryable'],
107
+ 'exchange': json['exchange'] == null ? undefined : json['exchange'],
108
+ 'detail': json['detail'] == null ? undefined : json['detail'],
48
109
  };
49
110
  }
50
111
 
@@ -60,6 +121,10 @@ export function ErrorDetailToJSONTyped(value?: ErrorDetail | null, ignoreDiscrim
60
121
  return {
61
122
 
62
123
  'message': value['message'],
124
+ 'code': value['code'],
125
+ 'retryable': value['retryable'],
126
+ 'exchange': value['exchange'],
127
+ 'detail': value['detail'],
63
128
  };
64
129
  }
65
130