pmxtjs 2.48.6 → 2.49.1

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 (129) 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/OrderLevel.d.ts +6 -0
  14. package/dist/esm/generated/src/models/OrderLevel.js +2 -0
  15. package/dist/esm/generated/src/models/Position.d.ts +33 -9
  16. package/dist/esm/generated/src/models/Position.js +12 -12
  17. package/dist/esm/generated/src/models/UnifiedSeries.d.ts +4 -4
  18. package/dist/esm/generated/src/models/UserTrade.d.ts +18 -0
  19. package/dist/esm/generated/src/models/UserTrade.js +6 -0
  20. package/dist/esm/generated/src/models/index.d.ts +1 -0
  21. package/dist/esm/generated/src/models/index.js +1 -0
  22. package/dist/esm/index.d.ts +2 -0
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/pmxt/client.d.ts +106 -5
  25. package/dist/esm/pmxt/client.js +400 -6
  26. package/dist/esm/pmxt/constants.d.ts +11 -0
  27. package/dist/esm/pmxt/constants.js +13 -0
  28. package/dist/esm/pmxt/errors.d.ts +3 -0
  29. package/dist/esm/pmxt/errors.js +9 -0
  30. package/dist/esm/pmxt/escrow.d.ts +39 -0
  31. package/dist/esm/pmxt/escrow.js +78 -0
  32. package/dist/esm/pmxt/feed-client.d.ts +3 -0
  33. package/dist/esm/pmxt/feed-client.js +11 -2
  34. package/dist/esm/pmxt/hosted-errors.d.ts +84 -0
  35. package/dist/esm/pmxt/hosted-errors.js +186 -0
  36. package/dist/esm/pmxt/hosted-mappers.d.ts +45 -0
  37. package/dist/esm/pmxt/hosted-mappers.js +291 -0
  38. package/dist/esm/pmxt/hosted-routing.d.ts +69 -0
  39. package/dist/esm/pmxt/hosted-routing.js +119 -0
  40. package/dist/esm/pmxt/hosted-typed-data.d.ts +36 -0
  41. package/dist/esm/pmxt/hosted-typed-data.js +580 -0
  42. package/dist/esm/pmxt/models.d.ts +46 -8
  43. package/dist/esm/pmxt/server-manager.d.ts +4 -0
  44. package/dist/esm/pmxt/server-manager.js +6 -0
  45. package/dist/esm/pmxt/signers.d.ts +57 -0
  46. package/dist/esm/pmxt/signers.js +50 -0
  47. package/dist/esm/pmxt/ws-client.js +2 -1
  48. package/dist/generated/src/models/Balance.d.ts +6 -0
  49. package/dist/generated/src/models/Balance.js +2 -0
  50. package/dist/generated/src/models/BuiltOrder.d.ts +6 -0
  51. package/dist/generated/src/models/BuiltOrder.js +2 -0
  52. package/dist/generated/src/models/ErrorDetail.d.ts +58 -2
  53. package/dist/generated/src/models/ErrorDetail.js +38 -0
  54. package/dist/generated/src/models/ExchangeOptions.d.ts +70 -0
  55. package/dist/generated/src/models/ExchangeOptions.js +60 -0
  56. package/dist/generated/src/models/MatchedMarketPair.d.ts +1 -1
  57. package/dist/generated/src/models/Order.d.ts +18 -0
  58. package/dist/generated/src/models/Order.js +6 -0
  59. package/dist/generated/src/models/OrderLevel.d.ts +6 -0
  60. package/dist/generated/src/models/OrderLevel.js +2 -0
  61. package/dist/generated/src/models/Position.d.ts +33 -9
  62. package/dist/generated/src/models/Position.js +12 -12
  63. package/dist/generated/src/models/UnifiedSeries.d.ts +4 -4
  64. package/dist/generated/src/models/UserTrade.d.ts +18 -0
  65. package/dist/generated/src/models/UserTrade.js +6 -0
  66. package/dist/generated/src/models/index.d.ts +1 -0
  67. package/dist/generated/src/models/index.js +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +1 -0
  70. package/dist/pmxt/client.d.ts +106 -5
  71. package/dist/pmxt/client.js +399 -5
  72. package/dist/pmxt/constants.d.ts +11 -0
  73. package/dist/pmxt/constants.js +14 -1
  74. package/dist/pmxt/errors.d.ts +3 -0
  75. package/dist/pmxt/errors.js +11 -1
  76. package/dist/pmxt/escrow.d.ts +39 -0
  77. package/dist/pmxt/escrow.js +82 -0
  78. package/dist/pmxt/feed-client.d.ts +3 -0
  79. package/dist/pmxt/feed-client.js +11 -2
  80. package/dist/pmxt/hosted-errors.d.ts +84 -0
  81. package/dist/pmxt/hosted-errors.js +201 -0
  82. package/dist/pmxt/hosted-mappers.d.ts +45 -0
  83. package/dist/pmxt/hosted-mappers.js +302 -0
  84. package/dist/pmxt/hosted-routing.d.ts +69 -0
  85. package/dist/pmxt/hosted-routing.js +126 -0
  86. package/dist/pmxt/hosted-typed-data.d.ts +36 -0
  87. package/dist/pmxt/hosted-typed-data.js +619 -0
  88. package/dist/pmxt/models.d.ts +46 -8
  89. package/dist/pmxt/server-manager.d.ts +4 -0
  90. package/dist/pmxt/server-manager.js +6 -0
  91. package/dist/pmxt/signers.d.ts +57 -0
  92. package/dist/pmxt/signers.js +55 -0
  93. package/dist/pmxt/ws-client.js +2 -1
  94. package/generated/.openapi-generator/FILES +2 -0
  95. package/generated/docs/Balance.md +2 -0
  96. package/generated/docs/BuiltOrder.md +2 -0
  97. package/generated/docs/ErrorDetail.md +9 -0
  98. package/generated/docs/ExchangeOptions.md +47 -0
  99. package/generated/docs/Order.md +6 -0
  100. package/generated/docs/OrderLevel.md +2 -0
  101. package/generated/docs/Position.md +9 -0
  102. package/generated/docs/UserTrade.md +6 -0
  103. package/generated/package.json +1 -1
  104. package/generated/src/models/Balance.ts +8 -0
  105. package/generated/src/models/BuiltOrder.ts +8 -0
  106. package/generated/src/models/ErrorDetail.ts +67 -2
  107. package/generated/src/models/ExchangeOptions.ts +115 -0
  108. package/generated/src/models/MatchedMarketPair.ts +1 -1
  109. package/generated/src/models/Order.ts +24 -0
  110. package/generated/src/models/OrderLevel.ts +8 -0
  111. package/generated/src/models/Position.ts +45 -17
  112. package/generated/src/models/UnifiedSeries.ts +4 -4
  113. package/generated/src/models/UserTrade.ts +24 -0
  114. package/generated/src/models/index.ts +1 -0
  115. package/index.ts +1 -0
  116. package/package.json +11 -2
  117. package/pmxt/client.ts +495 -9
  118. package/pmxt/constants.ts +15 -0
  119. package/pmxt/errors.ts +11 -0
  120. package/pmxt/escrow.ts +93 -0
  121. package/pmxt/feed-client.ts +14 -2
  122. package/pmxt/hosted-errors.ts +216 -0
  123. package/pmxt/hosted-mappers.ts +312 -0
  124. package/pmxt/hosted-routing.ts +165 -0
  125. package/pmxt/hosted-typed-data.ts +767 -0
  126. package/pmxt/models.ts +65 -8
  127. package/pmxt/server-manager.ts +7 -0
  128. package/pmxt/signers.ts +86 -0
  129. package/pmxt/ws-client.ts +2 -1
@@ -36,6 +36,10 @@ export declare class ServerManager {
36
36
  * Check if the server is running.
37
37
  */
38
38
  isServerRunning(): Promise<boolean>;
39
+ /**
40
+ * Backwards-compatible alias for `isServerRunning()`.
41
+ */
42
+ isServerAlive(): Promise<boolean>;
39
43
  /**
40
44
  * Wait for the server to be ready.
41
45
  * Requires a lock file to be present to avoid falsely matching an unrelated
@@ -98,6 +98,12 @@ export class ServerManager {
98
98
  return false;
99
99
  }
100
100
  }
101
+ /**
102
+ * Backwards-compatible alias for `isServerRunning()`.
103
+ */
104
+ async isServerAlive() {
105
+ return this.isServerRunning();
106
+ }
101
107
  /**
102
108
  * Wait for the server to be ready.
103
109
  * Requires a lock file to be present to avoid falsely matching an unrelated
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Signer helpers for hosted PMXT trading.
3
+ *
4
+ * `ethers` is an optional peer dependency — read-only SDK users do not need it
5
+ * installed. Hosted-mode signing imports it lazily via `require()` and throws
6
+ * a clear install hint when it's missing.
7
+ *
8
+ * Mirrors `sdks/python/pmxt/signers.py`.
9
+ */
10
+ /**
11
+ * EIP-712 typed data payload as accepted by ethers v6 / Web3 wallets.
12
+ * `EIP712Domain` is allowed inside `types` (and is the standard) but ethers
13
+ * strips it before signing — see {@link EthersSigner.signTypedData}.
14
+ */
15
+ export interface TypedData {
16
+ types: Record<string, Array<{
17
+ name: string;
18
+ type: string;
19
+ }>>;
20
+ primaryType: string;
21
+ domain: {
22
+ name: string;
23
+ version: string;
24
+ chainId: number;
25
+ verifyingContract: string;
26
+ };
27
+ message: Record<string, unknown>;
28
+ }
29
+ /**
30
+ * Pluggable signer abstraction. Implement this to integrate hardware wallets
31
+ * or remote signing services. {@link EthersSigner} is the built-in
32
+ * private-key implementation.
33
+ */
34
+ export interface Signer {
35
+ readonly address: string;
36
+ signTypedData(typedData: TypedData): Promise<string>;
37
+ }
38
+ /**
39
+ * Built-in signer backed by an ethers `Wallet`.
40
+ *
41
+ * `ethers` is imported lazily — a clear, install-hint-bearing error is thrown
42
+ * if the peer dependency is missing.
43
+ */
44
+ export declare class EthersSigner implements Signer {
45
+ private readonly _wallet;
46
+ readonly address: string;
47
+ constructor(privateKey: string);
48
+ signTypedData(typedData: TypedData): Promise<string>;
49
+ }
50
+ /**
51
+ * Convenience factory: build a {@link Signer} from a raw private key.
52
+ *
53
+ * Currently always returns an {@link EthersSigner}. Async for forward
54
+ * compatibility with key-loaders that may need to await (e.g. keystore
55
+ * decryption).
56
+ */
57
+ export declare function signerFromPrivateKey(privateKey: string): Promise<Signer>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Signer helpers for hosted PMXT trading.
3
+ *
4
+ * `ethers` is an optional peer dependency — read-only SDK users do not need it
5
+ * installed. Hosted-mode signing imports it lazily via `require()` and throws
6
+ * a clear install hint when it's missing.
7
+ *
8
+ * Mirrors `sdks/python/pmxt/signers.py`.
9
+ */
10
+ const ETHERS_INSTALL_HINT = "hosted trading requires the optional 'ethers' peer dependency. Install with: npm install ethers";
11
+ /**
12
+ * Built-in signer backed by an ethers `Wallet`.
13
+ *
14
+ * `ethers` is imported lazily — a clear, install-hint-bearing error is thrown
15
+ * if the peer dependency is missing.
16
+ */
17
+ export class EthersSigner {
18
+ _wallet; // ethers.Wallet
19
+ address;
20
+ constructor(privateKey) {
21
+ let ethers;
22
+ try {
23
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
24
+ ethers = require("ethers");
25
+ }
26
+ catch {
27
+ throw new Error(ETHERS_INSTALL_HINT);
28
+ }
29
+ this._wallet = new ethers.Wallet(privateKey);
30
+ this.address = this._wallet.address;
31
+ }
32
+ async signTypedData(typedData) {
33
+ // ethers expects `types` WITHOUT the EIP712Domain entry — it derives
34
+ // the domain hash from the `domain` argument.
35
+ const types = { ...typedData.types };
36
+ delete types["EIP712Domain"];
37
+ const sig = await this._wallet.signTypedData(typedData.domain, types, typedData.message);
38
+ return sig.startsWith("0x") ? sig : "0x" + sig;
39
+ }
40
+ }
41
+ /**
42
+ * Convenience factory: build a {@link Signer} from a raw private key.
43
+ *
44
+ * Currently always returns an {@link EthersSigner}. Async for forward
45
+ * compatibility with key-loaders that may need to await (e.g. keystore
46
+ * decryption).
47
+ */
48
+ export async function signerFromPrivateKey(privateKey) {
49
+ return new EthersSigner(privateKey);
50
+ }
@@ -7,6 +7,7 @@
7
7
  * does not support the /ws endpoint.
8
8
  */
9
9
  import { PmxtError } from "./errors.js";
10
+ import { logger } from "./logger.js";
10
11
  const MAX_QUEUED_MESSAGES_PER_SUBSCRIPTION = 100_000;
11
12
  /**
12
13
  * Multiplexed WebSocket client for the pmxt sidecar.
@@ -117,7 +118,7 @@ export class SidecarWsClient {
117
118
  }
118
119
  catch (err) {
119
120
  // Dispatch bug -- log and continue; don't kill the connection.
120
- console.error('[SidecarWsClient] dispatch error:', err);
121
+ logger.error('[SidecarWsClient] dispatch error:', { err });
121
122
  }
122
123
  };
123
124
  });
@@ -39,6 +39,12 @@ export interface Balance {
39
39
  * @memberof Balance
40
40
  */
41
41
  locked: number;
42
+ /**
43
+ * Hosted-mode: which venue this balance belongs to in a multi-venue response. Null when the balance is venue-agnostic.
44
+ * @type {string}
45
+ * @memberof Balance
46
+ */
47
+ venue?: string | null;
42
48
  }
43
49
  /**
44
50
  * Check if a given object implements the Balance interface.
@@ -44,6 +44,7 @@ function BalanceFromJSONTyped(json, ignoreDiscriminator) {
44
44
  'total': json['total'],
45
45
  'available': json['available'],
46
46
  'locked': json['locked'],
47
+ 'venue': json['venue'] == null ? undefined : json['venue'],
47
48
  };
48
49
  }
49
50
  function BalanceToJSON(json) {
@@ -58,5 +59,6 @@ function BalanceToJSONTyped(value, ignoreDiscriminator = false) {
58
59
  'total': value['total'],
59
60
  'available': value['available'],
60
61
  'locked': value['locked'],
62
+ 'venue': value['venue'],
61
63
  };
62
64
  }
@@ -49,6 +49,12 @@ export interface BuiltOrder {
49
49
  * @memberof BuiltOrder
50
50
  */
51
51
  raw: any | null;
52
+ /**
53
+ * Unix epoch (ms) when this built order expires server-side. Submitting after expiry returns BUILT_ORDER_EXPIRED.
54
+ * @type {number}
55
+ * @memberof BuiltOrder
56
+ */
57
+ expiry?: number | null;
52
58
  }
53
59
  /**
54
60
  * Check if a given object implements the BuiltOrder interface.
@@ -45,6 +45,7 @@ function BuiltOrderFromJSONTyped(json, ignoreDiscriminator) {
45
45
  'signedOrder': json['signedOrder'] == null ? undefined : json['signedOrder'],
46
46
  'tx': json['tx'] == null ? undefined : (0, BuiltOrderTx_1.BuiltOrderTxFromJSON)(json['tx']),
47
47
  'raw': json['raw'],
48
+ 'expiry': json['expiry'] == null ? undefined : json['expiry'],
48
49
  };
49
50
  }
50
51
  function BuiltOrderToJSON(json) {
@@ -60,5 +61,6 @@ function BuiltOrderToJSONTyped(value, ignoreDiscriminator = false) {
60
61
  'signedOrder': value['signedOrder'],
61
62
  'tx': (0, BuiltOrderTx_1.BuiltOrderTxToJSON)(value['tx']),
62
63
  'raw': value['raw'],
64
+ 'expiry': value['expiry'],
63
65
  };
64
66
  }
@@ -10,18 +10,74 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  /**
13
- *
13
+ * 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`.
14
14
  * @export
15
15
  * @interface ErrorDetail
16
16
  */
17
17
  export interface ErrorDetail {
18
18
  /**
19
- *
19
+ * Human-readable error message.
20
20
  * @type {string}
21
21
  * @memberof ErrorDetail
22
22
  */
23
23
  message?: string;
24
+ /**
25
+ * 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`).
26
+ * @type {string}
27
+ * @memberof ErrorDetail
28
+ */
29
+ code?: ErrorDetailCodeEnum;
30
+ /**
31
+ * 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.
32
+ * @type {boolean}
33
+ * @memberof ErrorDetail
34
+ */
35
+ retryable?: boolean;
36
+ /**
37
+ * Venue the error originated from, when known (e.g. 'polymarket', 'kalshi').
38
+ * @type {string}
39
+ * @memberof ErrorDetail
40
+ */
41
+ exchange?: string | null;
42
+ /**
43
+ * 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 }`.
44
+ * @type {{ [key: string]: any; }}
45
+ * @memberof ErrorDetail
46
+ */
47
+ detail?: {
48
+ [key: string]: any;
49
+ } | null;
24
50
  }
51
+ /**
52
+ * @export
53
+ */
54
+ export declare const ErrorDetailCodeEnum: {
55
+ readonly HostedTradingError: "HOSTED_TRADING_ERROR";
56
+ readonly InsufficientEscrowBalance: "INSUFFICIENT_ESCROW_BALANCE";
57
+ readonly OrderSizeTooSmall: "ORDER_SIZE_TOO_SMALL";
58
+ readonly InvalidApiKey: "INVALID_API_KEY";
59
+ readonly OutcomeNotFound: "OUTCOME_NOT_FOUND";
60
+ readonly CatalogUnavailable: "CATALOG_UNAVAILABLE";
61
+ readonly BuiltOrderExpired: "BUILT_ORDER_EXPIRED";
62
+ readonly InvalidSignature: "INVALID_SIGNATURE";
63
+ readonly NoLiquidity: "NO_LIQUIDITY";
64
+ readonly MissingWalletAddress: "MISSING_WALLET_ADDRESS";
65
+ readonly BadRequest: "BAD_REQUEST";
66
+ readonly AuthenticationError: "AUTHENTICATION_ERROR";
67
+ readonly PermissionDenied: "PERMISSION_DENIED";
68
+ readonly NotFound: "NOT_FOUND";
69
+ readonly OrderNotFound: "ORDER_NOT_FOUND";
70
+ readonly MarketNotFound: "MARKET_NOT_FOUND";
71
+ readonly EventNotFound: "EVENT_NOT_FOUND";
72
+ readonly RateLimitExceeded: "RATE_LIMIT_EXCEEDED";
73
+ readonly InvalidOrder: "INVALID_ORDER";
74
+ readonly InsufficientFunds: "INSUFFICIENT_FUNDS";
75
+ readonly ValidationError: "VALIDATION_ERROR";
76
+ readonly NetworkError: "NETWORK_ERROR";
77
+ readonly ExchangeNotAvailable: "EXCHANGE_NOT_AVAILABLE";
78
+ readonly NotSupported: "NOT_SUPPORTED";
79
+ };
80
+ export type ErrorDetailCodeEnum = typeof ErrorDetailCodeEnum[keyof typeof ErrorDetailCodeEnum];
25
81
  /**
26
82
  * Check if a given object implements the ErrorDetail interface.
27
83
  */
@@ -13,11 +13,41 @@
13
13
  * Do not edit the class manually.
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ErrorDetailCodeEnum = void 0;
16
17
  exports.instanceOfErrorDetail = instanceOfErrorDetail;
17
18
  exports.ErrorDetailFromJSON = ErrorDetailFromJSON;
18
19
  exports.ErrorDetailFromJSONTyped = ErrorDetailFromJSONTyped;
19
20
  exports.ErrorDetailToJSON = ErrorDetailToJSON;
20
21
  exports.ErrorDetailToJSONTyped = ErrorDetailToJSONTyped;
22
+ /**
23
+ * @export
24
+ */
25
+ exports.ErrorDetailCodeEnum = {
26
+ HostedTradingError: 'HOSTED_TRADING_ERROR',
27
+ InsufficientEscrowBalance: 'INSUFFICIENT_ESCROW_BALANCE',
28
+ OrderSizeTooSmall: 'ORDER_SIZE_TOO_SMALL',
29
+ InvalidApiKey: 'INVALID_API_KEY',
30
+ OutcomeNotFound: 'OUTCOME_NOT_FOUND',
31
+ CatalogUnavailable: 'CATALOG_UNAVAILABLE',
32
+ BuiltOrderExpired: 'BUILT_ORDER_EXPIRED',
33
+ InvalidSignature: 'INVALID_SIGNATURE',
34
+ NoLiquidity: 'NO_LIQUIDITY',
35
+ MissingWalletAddress: 'MISSING_WALLET_ADDRESS',
36
+ BadRequest: 'BAD_REQUEST',
37
+ AuthenticationError: 'AUTHENTICATION_ERROR',
38
+ PermissionDenied: 'PERMISSION_DENIED',
39
+ NotFound: 'NOT_FOUND',
40
+ OrderNotFound: 'ORDER_NOT_FOUND',
41
+ MarketNotFound: 'MARKET_NOT_FOUND',
42
+ EventNotFound: 'EVENT_NOT_FOUND',
43
+ RateLimitExceeded: 'RATE_LIMIT_EXCEEDED',
44
+ InvalidOrder: 'INVALID_ORDER',
45
+ InsufficientFunds: 'INSUFFICIENT_FUNDS',
46
+ ValidationError: 'VALIDATION_ERROR',
47
+ NetworkError: 'NETWORK_ERROR',
48
+ ExchangeNotAvailable: 'EXCHANGE_NOT_AVAILABLE',
49
+ NotSupported: 'NOT_SUPPORTED'
50
+ };
21
51
  /**
22
52
  * Check if a given object implements the ErrorDetail interface.
23
53
  */
@@ -33,6 +63,10 @@ function ErrorDetailFromJSONTyped(json, ignoreDiscriminator) {
33
63
  }
34
64
  return {
35
65
  'message': json['message'] == null ? undefined : json['message'],
66
+ 'code': json['code'] == null ? undefined : json['code'],
67
+ 'retryable': json['retryable'] == null ? undefined : json['retryable'],
68
+ 'exchange': json['exchange'] == null ? undefined : json['exchange'],
69
+ 'detail': json['detail'] == null ? undefined : json['detail'],
36
70
  };
37
71
  }
38
72
  function ErrorDetailToJSON(json) {
@@ -44,5 +78,9 @@ function ErrorDetailToJSONTyped(value, ignoreDiscriminator = false) {
44
78
  }
45
79
  return {
46
80
  'message': value['message'],
81
+ 'code': value['code'],
82
+ 'retryable': value['retryable'],
83
+ 'exchange': value['exchange'],
84
+ 'detail': value['detail'],
47
85
  };
48
86
  }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * PMXT Sidecar API
3
+ * A unified local sidecar API for prediction markets (Polymarket, Kalshi, Limitless). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
4
+ *
5
+ * The version of the OpenAPI document: 0.4.4
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ /**
13
+ * Constructor-level options for venue clients (Polymarket, Kalshi, Opinion, etc.).
14
+ * Hosted mode is the default when pmxtApiKey is set; otherwise the SDK runs against
15
+ * a local sidecar with venue credentials.
16
+ * @export
17
+ * @interface ExchangeOptions
18
+ */
19
+ export interface ExchangeOptions {
20
+ /**
21
+ * PMXT customer API key. When set, the SDK routes to api.pmxt.dev (catalog) and trade.pmxt.dev (trading). Get one at pmxt.dev/dashboard.
22
+ * @type {string}
23
+ * @memberof ExchangeOptions
24
+ */
25
+ pmxtApiKey?: string;
26
+ /**
27
+ * EVM wallet address for hosted reads/writes. Required for endpoints that operate on a wallet (balances, positions, trades, open orders).
28
+ * @type {string}
29
+ * @memberof ExchangeOptions
30
+ */
31
+ walletAddress?: string | null;
32
+ /**
33
+ * Optional pre-built signer for hosted writes. If absent and privateKey is set, the SDK auto-wraps privateKey into a signer.
34
+ * @type {object}
35
+ * @memberof ExchangeOptions
36
+ */
37
+ signer?: object | null;
38
+ /**
39
+ * Private key. In hosted mode, used to derive an EIP-712 signer for writes (wraps into EthAccountSigner/EthersSigner). In self-hosted mode, used as the venue credential directly.
40
+ * @type {string}
41
+ * @memberof ExchangeOptions
42
+ */
43
+ privateKey?: string | null;
44
+ /**
45
+ * Explicit base URL override. When unset, the SDK uses api.pmxt.dev when pmxtApiKey is set, or the local sidecar otherwise.
46
+ * @type {string}
47
+ * @memberof ExchangeOptions
48
+ */
49
+ baseUrl?: string | null;
50
+ /**
51
+ * Venue-side API key (e.g. Polymarket CLOB key). Only relevant for self-hosted mode.
52
+ * @type {string}
53
+ * @memberof ExchangeOptions
54
+ */
55
+ apiKey?: string | null;
56
+ /**
57
+ * Auto-start the local sidecar when running self-hosted. Defaults to true when no pmxtApiKey is set, false when hosted.
58
+ * @type {boolean}
59
+ * @memberof ExchangeOptions
60
+ */
61
+ autoStartServer?: boolean | null;
62
+ }
63
+ /**
64
+ * Check if a given object implements the ExchangeOptions interface.
65
+ */
66
+ export declare function instanceOfExchangeOptions(value: object): value is ExchangeOptions;
67
+ export declare function ExchangeOptionsFromJSON(json: any): ExchangeOptions;
68
+ export declare function ExchangeOptionsFromJSONTyped(json: any, ignoreDiscriminator: boolean): ExchangeOptions;
69
+ export declare function ExchangeOptionsToJSON(json: any): ExchangeOptions;
70
+ export declare function ExchangeOptionsToJSONTyped(value?: ExchangeOptions | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * PMXT Sidecar API
6
+ * A unified local sidecar API for prediction markets (Polymarket, Kalshi, Limitless). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
7
+ *
8
+ * The version of the OpenAPI document: 0.4.4
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.instanceOfExchangeOptions = instanceOfExchangeOptions;
17
+ exports.ExchangeOptionsFromJSON = ExchangeOptionsFromJSON;
18
+ exports.ExchangeOptionsFromJSONTyped = ExchangeOptionsFromJSONTyped;
19
+ exports.ExchangeOptionsToJSON = ExchangeOptionsToJSON;
20
+ exports.ExchangeOptionsToJSONTyped = ExchangeOptionsToJSONTyped;
21
+ /**
22
+ * Check if a given object implements the ExchangeOptions interface.
23
+ */
24
+ function instanceOfExchangeOptions(value) {
25
+ return true;
26
+ }
27
+ function ExchangeOptionsFromJSON(json) {
28
+ return ExchangeOptionsFromJSONTyped(json, false);
29
+ }
30
+ function ExchangeOptionsFromJSONTyped(json, ignoreDiscriminator) {
31
+ if (json == null) {
32
+ return json;
33
+ }
34
+ return {
35
+ 'pmxtApiKey': json['pmxtApiKey'] == null ? undefined : json['pmxtApiKey'],
36
+ 'walletAddress': json['walletAddress'] == null ? undefined : json['walletAddress'],
37
+ 'signer': json['signer'] == null ? undefined : json['signer'],
38
+ 'privateKey': json['privateKey'] == null ? undefined : json['privateKey'],
39
+ 'baseUrl': json['baseUrl'] == null ? undefined : json['baseUrl'],
40
+ 'apiKey': json['apiKey'] == null ? undefined : json['apiKey'],
41
+ 'autoStartServer': json['autoStartServer'] == null ? undefined : json['autoStartServer'],
42
+ };
43
+ }
44
+ function ExchangeOptionsToJSON(json) {
45
+ return ExchangeOptionsToJSONTyped(json, false);
46
+ }
47
+ function ExchangeOptionsToJSONTyped(value, ignoreDiscriminator = false) {
48
+ if (value == null) {
49
+ return value;
50
+ }
51
+ return {
52
+ 'pmxtApiKey': value['pmxtApiKey'],
53
+ 'walletAddress': value['walletAddress'],
54
+ 'signer': value['signer'],
55
+ 'privateKey': value['privateKey'],
56
+ 'baseUrl': value['baseUrl'],
57
+ 'apiKey': value['apiKey'],
58
+ 'autoStartServer': value['autoStartServer'],
59
+ };
60
+ }
@@ -71,7 +71,7 @@ export interface MatchedMarketPair {
71
71
  */
72
72
  confidence?: number;
73
73
  /**
74
- *
74
+ * Why the two markets were matched.
75
75
  * @type {string}
76
76
  * @memberof MatchedMarketPair
77
77
  */
@@ -99,6 +99,24 @@ export interface Order {
99
99
  * @memberof Order
100
100
  */
101
101
  feeRateBps?: number;
102
+ /**
103
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
104
+ * @type {string}
105
+ * @memberof Order
106
+ */
107
+ txHash?: string | null;
108
+ /**
109
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
110
+ * @type {string}
111
+ * @memberof Order
112
+ */
113
+ chain?: string | null;
114
+ /**
115
+ * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
116
+ * @type {number}
117
+ * @memberof Order
118
+ */
119
+ blockNumber?: number | null;
102
120
  }
103
121
  /**
104
122
  * @export
@@ -91,6 +91,9 @@ function OrderFromJSONTyped(json, ignoreDiscriminator) {
91
91
  'timestamp': json['timestamp'],
92
92
  'fee': json['fee'] == null ? undefined : json['fee'],
93
93
  'feeRateBps': json['feeRateBps'] == null ? undefined : json['feeRateBps'],
94
+ 'txHash': json['txHash'] == null ? undefined : json['txHash'],
95
+ 'chain': json['chain'] == null ? undefined : json['chain'],
96
+ 'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
94
97
  };
95
98
  }
96
99
  function OrderToJSON(json) {
@@ -115,5 +118,8 @@ function OrderToJSONTyped(value, ignoreDiscriminator = false) {
115
118
  'timestamp': value['timestamp'],
116
119
  'fee': value['fee'],
117
120
  'feeRateBps': value['feeRateBps'],
121
+ 'txHash': value['txHash'],
122
+ 'chain': value['chain'],
123
+ 'blockNumber': value['blockNumber'],
118
124
  };
119
125
  }
@@ -27,6 +27,12 @@ export interface OrderLevel {
27
27
  * @memberof OrderLevel
28
28
  */
29
29
  size: number;
30
+ /**
31
+ *
32
+ * @type {number}
33
+ * @memberof OrderLevel
34
+ */
35
+ orderCount?: number;
30
36
  }
31
37
  /**
32
38
  * Check if a given object implements the OrderLevel interface.
@@ -38,6 +38,7 @@ function OrderLevelFromJSONTyped(json, ignoreDiscriminator) {
38
38
  return {
39
39
  'price': json['price'],
40
40
  'size': json['size'],
41
+ 'orderCount': json['orderCount'] == null ? undefined : json['orderCount'],
41
42
  };
42
43
  }
43
44
  function OrderLevelToJSON(json) {
@@ -50,5 +51,6 @@ function OrderLevelToJSONTyped(value, ignoreDiscriminator = false) {
50
51
  return {
51
52
  'price': value['price'],
52
53
  'size': value['size'],
54
+ 'orderCount': value['orderCount'],
53
55
  };
54
56
  }
@@ -10,7 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  /**
13
- *
13
+ * 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.
14
14
  * @export
15
15
  * @interface Position
16
16
  */
@@ -28,11 +28,11 @@ export interface Position {
28
28
  */
29
29
  outcomeId: string;
30
30
  /**
31
- * Human-readable label for the outcome held.
31
+ * Human-readable label for the outcome held. Optional in hosted mode.
32
32
  * @type {string}
33
33
  * @memberof Position
34
34
  */
35
- outcomeLabel: string;
35
+ outcomeLabel?: string | null;
36
36
  /**
37
37
  * Positive for long, negative for short
38
38
  * @type {number}
@@ -40,29 +40,53 @@ export interface Position {
40
40
  */
41
41
  size: number;
42
42
  /**
43
- * Average entry price for the position (probability between 0.0 and 1.0).
43
+ * Average entry price for the position (probability between 0.0 and 1.0). Optional in hosted mode when no fill history is available.
44
+ * @type {number}
45
+ * @memberof Position
46
+ */
47
+ entryPrice?: number | null;
48
+ /**
49
+ * Current mark price for the position (probability between 0.0 and 1.0). Optional in hosted mode when mark-to-market data is unavailable.
44
50
  * @type {number}
45
51
  * @memberof Position
46
52
  */
47
- entryPrice: number;
53
+ currentPrice?: number | null;
48
54
  /**
49
- * Current mark price for the position (probability between 0.0 and 1.0).
55
+ * Current market value of the position (size * currentPrice). Null when currentPrice is unavailable.
50
56
  * @type {number}
51
57
  * @memberof Position
52
58
  */
53
- currentPrice: number;
59
+ currentValue?: number | null;
54
60
  /**
55
- * Unrealized profit or loss at the current price (USD).
61
+ * Unrealized profit or loss at the current price (USD). Optional in hosted mode when mark-to-market data is unavailable.
56
62
  * @type {number}
57
63
  * @memberof Position
58
64
  */
59
- unrealizedPnL: number;
65
+ unrealizedPnL?: number | null;
60
66
  /**
61
67
  * Realized profit or loss booked so far (USD).
62
68
  * @type {number}
63
69
  * @memberof Position
64
70
  */
65
71
  realizedPnL?: number;
72
+ /**
73
+ * Populated in hosted mode after on-chain settlement (from the last fill); null for local-mode and for non-on-chain venues.
74
+ * @type {string}
75
+ * @memberof Position
76
+ */
77
+ txHash?: string | null;
78
+ /**
79
+ * Populated in hosted mode after on-chain settlement (from the last fill); null for local-mode and for non-on-chain venues.
80
+ * @type {string}
81
+ * @memberof Position
82
+ */
83
+ chain?: string | null;
84
+ /**
85
+ * Populated in hosted mode after on-chain settlement (from the last fill); null for local-mode and for non-on-chain venues.
86
+ * @type {number}
87
+ * @memberof Position
88
+ */
89
+ blockNumber?: number | null;
66
90
  }
67
91
  /**
68
92
  * Check if a given object implements the Position interface.