pmxt-core 2.27.9 → 2.28.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.
Files changed (44) hide show
  1. package/dist/BaseExchange.d.ts +8 -0
  2. package/dist/BaseExchange.js +9 -0
  3. package/dist/exchanges/baozi/index.d.ts +1 -0
  4. package/dist/exchanges/baozi/index.js +1 -0
  5. package/dist/exchanges/kalshi/api.d.ts +1 -1
  6. package/dist/exchanges/kalshi/api.js +1 -1
  7. package/dist/exchanges/kalshi/index.d.ts +1 -0
  8. package/dist/exchanges/kalshi/index.js +1 -0
  9. package/dist/exchanges/limitless/api.d.ts +1 -1
  10. package/dist/exchanges/limitless/api.js +1 -1
  11. package/dist/exchanges/limitless/index.d.ts +1 -0
  12. package/dist/exchanges/limitless/index.js +1 -0
  13. package/dist/exchanges/metaculus/index.d.ts +1 -0
  14. package/dist/exchanges/metaculus/index.js +1 -0
  15. package/dist/exchanges/myriad/api.d.ts +1 -1
  16. package/dist/exchanges/myriad/api.js +1 -1
  17. package/dist/exchanges/myriad/index.d.ts +1 -0
  18. package/dist/exchanges/myriad/index.js +1 -0
  19. package/dist/exchanges/opinion/api.d.ts +1 -1
  20. package/dist/exchanges/opinion/api.js +1 -1
  21. package/dist/exchanges/opinion/index.d.ts +1 -0
  22. package/dist/exchanges/opinion/index.js +1 -0
  23. package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
  24. package/dist/exchanges/polymarket/api-clob.js +1 -1
  25. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  26. package/dist/exchanges/polymarket/api-data.js +1 -1
  27. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  28. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  29. package/dist/exchanges/polymarket/auth.js +31 -33
  30. package/dist/exchanges/polymarket/index.d.ts +2 -0
  31. package/dist/exchanges/polymarket/index.js +4 -0
  32. package/dist/exchanges/polymarket/websocket.d.ts +1 -0
  33. package/dist/exchanges/polymarket/websocket.js +15 -0
  34. package/dist/exchanges/polymarket_us/index.d.ts +1 -0
  35. package/dist/exchanges/polymarket_us/index.js +1 -0
  36. package/dist/exchanges/probable/api.d.ts +1 -1
  37. package/dist/exchanges/probable/api.js +1 -1
  38. package/dist/exchanges/probable/index.d.ts +1 -0
  39. package/dist/exchanges/probable/index.js +1 -0
  40. package/dist/exchanges/smarkets/index.d.ts +1 -0
  41. package/dist/exchanges/smarkets/index.js +1 -0
  42. package/dist/server/method-verbs.json +10 -0
  43. package/dist/server/openapi.yaml +31 -0
  44. package/package.json +5 -4
@@ -201,6 +201,8 @@ export interface ExchangeHas {
201
201
  unwatchAddress: ExchangeCapability;
202
202
  /** Whether this exchange supports streaming order book updates. */
203
203
  watchOrderBook: ExchangeCapability;
204
+ /** Whether this exchange supports unsubscribing from an order book stream. */
205
+ unwatchOrderBook: ExchangeCapability;
204
206
  /** Whether this exchange supports streaming trade updates. */
205
207
  watchTrades: ExchangeCapability;
206
208
  /** Whether this exchange supports fetching the authenticated user's trade history. */
@@ -492,6 +494,12 @@ export declare abstract class PredictionMarketExchange {
492
494
  * @returns Promise that resolves with the current orderbook state
493
495
  */
494
496
  watchOrderBook(id: string, limit?: number): Promise<OrderBook>;
497
+ /**
498
+ * Unsubscribe from a previously watched order book stream.
499
+ *
500
+ * @param id - The Outcome ID to stop watching
501
+ */
502
+ unwatchOrderBook(id: string): Promise<void>;
495
503
  /**
496
504
  * Watch trade executions in real-time via WebSocket.
497
505
  * Returns a promise that resolves with the next trade(s). Call repeatedly in a loop to stream updates (CCXT Pro pattern).
@@ -34,6 +34,7 @@ class PredictionMarketExchange {
34
34
  watchAddress: false,
35
35
  unwatchAddress: false,
36
36
  watchOrderBook: false,
37
+ unwatchOrderBook: false,
37
38
  watchTrades: false,
38
39
  fetchMyTrades: false,
39
40
  fetchClosedOrders: false,
@@ -668,6 +669,14 @@ class PredictionMarketExchange {
668
669
  async watchOrderBook(id, limit) {
669
670
  throw new Error(`watchOrderBook() is not supported by ${this.name}`);
670
671
  }
672
+ /**
673
+ * Unsubscribe from a previously watched order book stream.
674
+ *
675
+ * @param id - The Outcome ID to stop watching
676
+ */
677
+ async unwatchOrderBook(id) {
678
+ throw new Error(`unwatchOrderBook() is not supported by ${this.name}`);
679
+ }
671
680
  // ----------------------------------------------------------------------------
672
681
  // WebSocket Streaming Methods
673
682
  // ----------------------------------------------------------------------------
@@ -20,6 +20,7 @@ export declare class BaoziExchange extends PredictionMarketExchange {
20
20
  watchAddress: false;
21
21
  unwatchAddress: false;
22
22
  watchOrderBook: true;
23
+ unwatchOrderBook: false;
23
24
  watchTrades: false;
24
25
  fetchMyTrades: false;
25
26
  fetchClosedOrders: false;
@@ -26,6 +26,7 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
26
26
  watchAddress: false,
27
27
  unwatchAddress: false,
28
28
  watchOrderBook: true,
29
+ unwatchOrderBook: false,
29
30
  watchTrades: false,
30
31
  fetchMyTrades: false,
31
32
  fetchClosedOrders: false,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
3
- * Generated at: 2026-04-10T16:27:26.419Z
3
+ * Generated at: 2026-04-11T09:59:33.711Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const kalshiApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.kalshiApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
6
- * Generated at: 2026-04-10T16:27:26.419Z
6
+ * Generated at: 2026-04-11T09:59:33.711Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -26,6 +26,7 @@ export declare class KalshiExchange extends PredictionMarketExchange {
26
26
  watchAddress: false;
27
27
  unwatchAddress: false;
28
28
  watchOrderBook: true;
29
+ unwatchOrderBook: false;
29
30
  watchTrades: true;
30
31
  fetchMyTrades: true;
31
32
  fetchClosedOrders: true;
@@ -28,6 +28,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
28
28
  watchAddress: false,
29
29
  unwatchAddress: false,
30
30
  watchOrderBook: true,
31
+ unwatchOrderBook: false,
31
32
  watchTrades: true,
32
33
  fetchMyTrades: true,
33
34
  fetchClosedOrders: true,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
3
- * Generated at: 2026-04-10T16:27:26.467Z
3
+ * Generated at: 2026-04-11T09:59:33.748Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const limitlessApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.limitlessApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
6
- * Generated at: 2026-04-10T16:27:26.467Z
6
+ * Generated at: 2026-04-11T09:59:33.748Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -26,6 +26,7 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
26
26
  watchAddress: true;
27
27
  unwatchAddress: true;
28
28
  watchOrderBook: true;
29
+ unwatchOrderBook: false;
29
30
  watchTrades: true;
30
31
  fetchMyTrades: true;
31
32
  fetchClosedOrders: true;
@@ -32,6 +32,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
32
32
  watchAddress: true,
33
33
  unwatchAddress: true,
34
34
  watchOrderBook: true,
35
+ unwatchOrderBook: false,
35
36
  watchTrades: true,
36
37
  fetchMyTrades: true,
37
38
  fetchClosedOrders: true,
@@ -52,6 +52,7 @@ export declare class MetaculusExchange extends PredictionMarketExchange {
52
52
  watchAddress: false;
53
53
  unwatchAddress: false;
54
54
  watchOrderBook: false;
55
+ unwatchOrderBook: false;
55
56
  watchTrades: false;
56
57
  fetchMyTrades: false;
57
58
  fetchClosedOrders: false;
@@ -64,6 +64,7 @@ class MetaculusExchange extends BaseExchange_1.PredictionMarketExchange {
64
64
  watchAddress: false,
65
65
  unwatchAddress: false,
66
66
  watchOrderBook: false,
67
+ unwatchOrderBook: false,
67
68
  watchTrades: false,
68
69
  fetchMyTrades: false,
69
70
  fetchClosedOrders: false,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
3
- * Generated at: 2026-04-10T16:27:26.482Z
3
+ * Generated at: 2026-04-11T09:59:33.759Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const myriadApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.myriadApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
6
- * Generated at: 2026-04-10T16:27:26.482Z
6
+ * Generated at: 2026-04-11T09:59:33.759Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -16,6 +16,7 @@ export declare class MyriadExchange extends PredictionMarketExchange {
16
16
  watchAddress: false;
17
17
  unwatchAddress: false;
18
18
  watchOrderBook: "emulated";
19
+ unwatchOrderBook: false;
19
20
  watchTrades: "emulated";
20
21
  fetchMyTrades: true;
21
22
  fetchClosedOrders: false;
@@ -27,6 +27,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
27
27
  watchAddress: false,
28
28
  unwatchAddress: false,
29
29
  watchOrderBook: 'emulated',
30
+ unwatchOrderBook: false,
30
31
  watchTrades: 'emulated',
31
32
  fetchMyTrades: true,
32
33
  fetchClosedOrders: false,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
3
- * Generated at: 2026-04-10T16:27:26.487Z
3
+ * Generated at: 2026-04-11T09:59:33.763Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const opinionApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.opinionApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
6
- * Generated at: 2026-04-10T16:27:26.487Z
6
+ * Generated at: 2026-04-11T09:59:33.763Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -23,6 +23,7 @@ export declare class OpinionExchange extends PredictionMarketExchange {
23
23
  watchAddress: false;
24
24
  unwatchAddress: false;
25
25
  watchOrderBook: true;
26
+ unwatchOrderBook: false;
26
27
  watchTrades: true;
27
28
  fetchMyTrades: true;
28
29
  fetchClosedOrders: true;
@@ -67,6 +67,7 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
67
67
  watchAddress: false,
68
68
  unwatchAddress: false,
69
69
  watchOrderBook: true,
70
+ unwatchOrderBook: false,
70
71
  watchTrades: true,
71
72
  fetchMyTrades: true,
72
73
  fetchClosedOrders: true,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
3
- * Generated at: 2026-04-10T16:27:26.427Z
3
+ * Generated at: 2026-04-11T09:59:33.718Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketClobSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketClobSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
6
- * Generated at: 2026-04-10T16:27:26.427Z
6
+ * Generated at: 2026-04-11T09:59:33.718Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketClobSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
3
- * Generated at: 2026-04-10T16:27:26.445Z
3
+ * Generated at: 2026-04-11T09:59:33.732Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketDataSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketDataSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
6
- * Generated at: 2026-04-10T16:27:26.445Z
6
+ * Generated at: 2026-04-11T09:59:33.732Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketDataSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
3
- * Generated at: 2026-04-10T16:27:26.441Z
3
+ * Generated at: 2026-04-11T09:59:33.729Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketGammaSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketGammaSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
6
- * Generated at: 2026-04-10T16:27:26.441Z
6
+ * Generated at: 2026-04-11T09:59:33.729Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -10,6 +10,11 @@ const axios_1 = __importDefault(require("axios"));
10
10
  const errors_1 = require("./errors");
11
11
  const POLYMARKET_HOST = 'https://clob.polymarket.com';
12
12
  const POLYGON_CHAIN_ID = 137;
13
+ // Polymarket CLOB signature types — determines how the CLOB API
14
+ // resolves the on-chain address holding the user's funds.
15
+ const SIG_TYPE_EOA = 0;
16
+ const SIG_TYPE_POLY_PROXY = 1;
17
+ const SIG_TYPE_GNOSIS_SAFE = 2;
13
18
  /**
14
19
  * Manages Polymarket authentication and CLOB client initialization.
15
20
  * Handles both L1 (wallet-based) and L2 (API credentials) authentication.
@@ -101,7 +106,7 @@ class PolymarketAuth {
101
106
  if (this.discoveredProxyAddress) {
102
107
  return {
103
108
  proxyAddress: this.discoveredProxyAddress,
104
- signatureType: this.discoveredSignatureType ?? 0
109
+ signatureType: this.discoveredSignatureType ?? SIG_TYPE_EOA
105
110
  };
106
111
  }
107
112
  const address = this.signer.address;
@@ -118,7 +123,7 @@ class PolymarketAuth {
118
123
  // Determine signature type.
119
124
  // Polymarket usually uses 1 for their own proxy and 2 for Gnosis Safe (which is what their new profiles use).
120
125
  // If it's a proxy address but we don't know the type, 1 is a safe default for Polymarket.
121
- this.discoveredSignatureType = profile.isGnosisSafe ? 2 : 1;
126
+ this.discoveredSignatureType = profile.isGnosisSafe ? SIG_TYPE_GNOSIS_SAFE : SIG_TYPE_POLY_PROXY;
122
127
  // console.log(`[PolymarketAuth] Auto-discovered proxy for ${address}: ${this.discoveredProxyAddress} (Type: ${this.discoveredSignatureType})`);
123
128
  return {
124
129
  proxyAddress: this.discoveredProxyAddress,
@@ -132,7 +137,7 @@ class PolymarketAuth {
132
137
  // Fallback to EOA if discovery fails
133
138
  return {
134
139
  proxyAddress: address,
135
- signatureType: 0
140
+ signatureType: SIG_TYPE_EOA
136
141
  };
137
142
  }
138
143
  /**
@@ -140,23 +145,22 @@ class PolymarketAuth {
140
145
  */
141
146
  mapSignatureType(type) {
142
147
  if (type === undefined || type === null)
143
- return 0;
148
+ return SIG_TYPE_EOA;
144
149
  if (typeof type === 'number')
145
150
  return type;
146
151
  const normalized = type.toLowerCase().replace(/[^a-z0-9]/g, '');
147
152
  switch (normalized) {
148
153
  case 'eoa':
149
- return 0;
154
+ return SIG_TYPE_EOA;
150
155
  case 'polyproxy':
151
156
  case 'polymarketproxy':
152
- return 1;
157
+ return SIG_TYPE_POLY_PROXY;
153
158
  case 'gnosissafe':
154
159
  case 'safe':
155
- return 2;
160
+ return SIG_TYPE_GNOSIS_SAFE;
156
161
  default:
157
- // If it's a numeric string, parse it
158
162
  const parsed = parseInt(normalized);
159
- return isNaN(parsed) ? 0 : parsed;
163
+ return isNaN(parsed) ? SIG_TYPE_EOA : parsed;
160
164
  }
161
165
  }
162
166
  /**
@@ -168,26 +172,24 @@ class PolymarketAuth {
168
172
  if (this.clobClient) {
169
173
  return this.clobClient;
170
174
  }
171
- // 1. Determine proxy and signature type early.
175
+ // 1. Determine proxy and signature type.
172
176
  //
173
- // Important: if signatureType is not provided we MUST run discovery
174
- // even when funderAddress is provided. Previously this branch was
175
- // skipped whenever funderAddress was set, which silently defaulted
176
- // signatureType to 0 (EOA). For wallets whose funds live on a Gnosis
177
- // Safe (the modern Polymarket onboarding default) the CLOB then
178
- // reports balance "0" instead of the real value, with no error.
177
+ // Priority order:
178
+ // 1. Discovery (Polymarket Data API) authoritative when it works
179
+ // 2. User-provided signatureType respected as explicit override
180
+ // 3. Default: Gnosis Safe (2) correct for all Polymarket
181
+ // accounts created since 2023
182
+ //
183
+ // The previous default was EOA (0), which silently returned $0
184
+ // balances for the vast majority of wallets (#80).
179
185
  const sigTypeProvided = this.credentials.signatureType !== undefined && this.credentials.signatureType !== null;
180
186
  let proxyAddress = this.credentials.funderAddress || undefined;
181
187
  let signatureType = sigTypeProvided
182
188
  ? this.mapSignatureType(this.credentials.signatureType)
183
189
  : undefined;
184
- // Run discovery if either piece is missing. Note: discoverProxy()
185
- // returns a synthetic { proxyAddress: signerEOA, signatureType: 0 }
186
- // fallback when its HTTP call fails — that fallback should NOT be
187
- // used to populate signatureType when funderAddress is already set,
188
- // because it would silently assign EOA semantics to a Gnosis Safe.
189
- let discoverySucceeded = false;
190
+ // Run discovery when we need to fill in missing values.
190
191
  if (!proxyAddress || signatureType === undefined) {
192
+ let discoverySucceeded = false;
191
193
  try {
192
194
  const discovered = await this.discoverProxy();
193
195
  discoverySucceeded =
@@ -201,23 +203,19 @@ class PolymarketAuth {
201
203
  }
202
204
  }
203
205
  catch {
204
- // Discovery failure is handled by the heuristic below.
206
+ // Discovery failure fall through to default below.
205
207
  }
206
208
  }
209
+ if (signatureType === undefined) {
210
+ // Neither user nor discovery provided a value. Default to
211
+ // Gnosis Safe — the modern Polymarket standard.
212
+ signatureType = SIG_TYPE_GNOSIS_SAFE;
213
+ }
207
214
  // Get API credentials (L1 auth)
208
215
  const apiCreds = await this.getApiCredentials();
209
- // 3. Defaults
216
+ // Final addresses
210
217
  const signerAddress = this.signer.address;
211
218
  const finalProxyAddress = (proxyAddress || signerAddress);
212
- // If signature type is still unknown, infer from address relationship:
213
- // when the funder differs from the signer EOA, the funder must be a
214
- // proxy/safe — default to Gnosis Safe (2), which is what Polymarket
215
- // has created for new accounts since 2023. Users on the legacy
216
- // Polymarket Proxy (1) need to set signatureType explicitly.
217
- if (signatureType === undefined) {
218
- signatureType =
219
- finalProxyAddress.toLowerCase() !== signerAddress.toLowerCase() ? 2 : 0;
220
- }
221
219
  const finalSignatureType = signatureType;
222
220
  // Create L2-authenticated client
223
221
  // console.log(`[PolymarketAuth] Initializing ClobClient | Signer: ${signerAddress} | Funder: ${finalProxyAddress} | SigType: ${finalSignatureType}`);
@@ -26,6 +26,7 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
26
26
  watchAddress: true;
27
27
  unwatchAddress: true;
28
28
  watchOrderBook: true;
29
+ unwatchOrderBook: true;
29
30
  watchTrades: true;
30
31
  fetchMyTrades: true;
31
32
  fetchClosedOrders: false;
@@ -72,6 +73,7 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
72
73
  fetchPositions(address?: string): Promise<Position[]>;
73
74
  fetchBalance(address?: string): Promise<Balance[]>;
74
75
  watchOrderBook(id: string, limit?: number): Promise<OrderBook>;
76
+ unwatchOrderBook(id: string): Promise<void>;
75
77
  watchTrades(id: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
76
78
  watchAddress(address: string, types?: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
77
79
  unwatchAddress(address: string): Promise<void>;
@@ -34,6 +34,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
34
34
  watchAddress: true,
35
35
  unwatchAddress: true,
36
36
  watchOrderBook: true,
37
+ unwatchOrderBook: true,
37
38
  watchTrades: true,
38
39
  fetchMyTrades: true,
39
40
  fetchClosedOrders: false,
@@ -438,6 +439,9 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
438
439
  async watchOrderBook(id, limit) {
439
440
  return this.ensureWs().watchOrderBook(id);
440
441
  }
442
+ async unwatchOrderBook(id) {
443
+ return this.ensureWs().unwatchOrderBook(id);
444
+ }
441
445
  async watchTrades(id, address, since, limit) {
442
446
  return this.ensureWs().watchTrades(id, address);
443
447
  }
@@ -30,6 +30,7 @@ export declare class PolymarketWebSocket {
30
30
  private initializationPromise?;
31
31
  constructor(callApi: (operationId: string, params?: Record<string, any>) => Promise<any>, config?: PolymarketWebSocketConfig);
32
32
  watchOrderBook(id: string): Promise<OrderBook>;
33
+ unwatchOrderBook(id: string): Promise<void>;
33
34
  watchTrades(id: string, address?: string): Promise<Trade[]>;
34
35
  watchAddress(address: string, types: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
35
36
  unwatchAddress(address: string): Promise<void>;
@@ -82,6 +82,21 @@ class PolymarketWebSocket {
82
82
  this.orderBookResolvers.get(id).push({ resolve, reject });
83
83
  });
84
84
  }
85
+ async unwatchOrderBook(id) {
86
+ if (!this.manager) {
87
+ return;
88
+ }
89
+ await this.manager.removeSubscriptions([id]);
90
+ // Clear any pending resolvers for this asset
91
+ const resolvers = this.orderBookResolvers.get(id);
92
+ if (resolvers) {
93
+ this.orderBookResolvers = new Map([...this.orderBookResolvers].filter(([key]) => key !== id));
94
+ }
95
+ // Remove the cached orderbook for this asset
96
+ if (this.orderBooks.has(id)) {
97
+ this.orderBooks = new Map([...this.orderBooks].filter(([key]) => key !== id));
98
+ }
99
+ }
85
100
  async watchTrades(id, address) {
86
101
  if (address) {
87
102
  return this.watcher.watch(address, ['trades'], id);
@@ -35,6 +35,7 @@ export declare class PolymarketUSExchange extends PredictionMarketExchange {
35
35
  watchAddress: false;
36
36
  unwatchAddress: false;
37
37
  watchOrderBook: true;
38
+ unwatchOrderBook: false;
38
39
  watchTrades: true;
39
40
  fetchMyTrades: true;
40
41
  fetchClosedOrders: false;
@@ -59,6 +59,7 @@ class PolymarketUSExchange extends BaseExchange_1.PredictionMarketExchange {
59
59
  watchAddress: false,
60
60
  unwatchAddress: false,
61
61
  watchOrderBook: true,
62
+ unwatchOrderBook: false,
62
63
  watchTrades: true,
63
64
  fetchMyTrades: true,
64
65
  fetchClosedOrders: false,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
3
- * Generated at: 2026-04-10T16:27:26.474Z
3
+ * Generated at: 2026-04-11T09:59:33.754Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const probableApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probableApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
6
- * Generated at: 2026-04-10T16:27:26.474Z
6
+ * Generated at: 2026-04-11T09:59:33.754Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -17,6 +17,7 @@ export declare class ProbableExchange extends PredictionMarketExchange {
17
17
  watchAddress: false;
18
18
  unwatchAddress: false;
19
19
  watchOrderBook: true;
20
+ unwatchOrderBook: false;
20
21
  watchTrades: false;
21
22
  fetchMyTrades: true;
22
23
  fetchClosedOrders: false;
@@ -29,6 +29,7 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
29
29
  watchAddress: false,
30
30
  unwatchAddress: false,
31
31
  watchOrderBook: true,
32
+ unwatchOrderBook: false,
32
33
  watchTrades: false,
33
34
  fetchMyTrades: true,
34
35
  fetchClosedOrders: false,
@@ -16,6 +16,7 @@ export declare class SmarketsExchange extends PredictionMarketExchange {
16
16
  watchAddress: false;
17
17
  unwatchAddress: false;
18
18
  watchOrderBook: false;
19
+ unwatchOrderBook: false;
19
20
  watchTrades: false;
20
21
  fetchMyTrades: true;
21
22
  fetchClosedOrders: true;
@@ -27,6 +27,7 @@ class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
27
27
  watchAddress: false,
28
28
  unwatchAddress: false,
29
29
  watchOrderBook: false,
30
+ unwatchOrderBook: false,
30
31
  watchTrades: false,
31
32
  fetchMyTrades: true,
32
33
  fetchClosedOrders: true,
@@ -294,6 +294,16 @@
294
294
  }
295
295
  ]
296
296
  },
297
+ "unwatchOrderBook": {
298
+ "verb": "post",
299
+ "args": [
300
+ {
301
+ "name": "id",
302
+ "kind": "string",
303
+ "optional": false
304
+ }
305
+ ]
306
+ },
297
307
  "watchTrades": {
298
308
  "verb": "post",
299
309
  "args": [
@@ -1360,6 +1360,37 @@ paths:
1360
1360
  description: >-
1361
1361
  Watch order book updates in real-time via WebSocket. Returns a promise that resolves with the next order book
1362
1362
  update. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
1363
+ '/api/{exchange}/unwatchOrderBook':
1364
+ post:
1365
+ summary: Unwatch Order Book
1366
+ operationId: unwatchOrderBook
1367
+ parameters:
1368
+ - $ref: '#/components/parameters/ExchangeParam'
1369
+ requestBody:
1370
+ content:
1371
+ application/json:
1372
+ schema:
1373
+ title: UnwatchOrderBookRequest
1374
+ type: object
1375
+ properties:
1376
+ args:
1377
+ type: array
1378
+ maxItems: 1
1379
+ items:
1380
+ type: string
1381
+ minItems: 1
1382
+ credentials:
1383
+ $ref: '#/components/schemas/ExchangeCredentials'
1384
+ required:
1385
+ - args
1386
+ responses:
1387
+ '200':
1388
+ description: Unwatch Order Book response
1389
+ content:
1390
+ application/json:
1391
+ schema:
1392
+ $ref: '#/components/schemas/BaseResponse'
1393
+ description: Unsubscribe from a previously watched order book stream.
1363
1394
  '/api/{exchange}/watchTrades':
1364
1395
  post:
1365
1396
  summary: Watch Trades
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.27.9",
3
+ "version": "2.28.0",
4
4
  "description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,15 +29,16 @@
29
29
  "test": "jest -c jest.config.js",
30
30
  "server": "tsx watch src/server/index.ts",
31
31
  "server:prod": "node dist/server/index.js",
32
- "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.27.9,library=urllib3",
33
- "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.27.9,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
32
+ "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.28.0,library=urllib3",
33
+ "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.28.0,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
34
34
  "fetch:openapi": "node scripts/fetch-openapi-specs.js",
35
35
  "extract:jsdoc": "node ../scripts/extract-jsdoc.js",
36
36
  "generate:docs": "npm run extract:jsdoc && node ../scripts/generate-api-docs.js",
37
37
  "generate:openapi": "node scripts/generate-openapi.js",
38
38
  "generate:python-exchanges": "node scripts/generate-python-exchanges.js",
39
39
  "generate:compliance": "node scripts/generate-compliance.js",
40
- "generate:sdk:all": "npm run generate:openapi && npm run generate:sdk:python && npm run generate:python-exchanges && npm run generate:sdk:typescript && npm run generate:docs && npm run generate:compliance"
40
+ "generate:mintlify": "node ../scripts/generate-mintlify-docs.js",
41
+ "generate:sdk:all": "npm run generate:openapi && npm run generate:sdk:python && npm run generate:python-exchanges && npm run generate:sdk:typescript && npm run generate:docs && npm run generate:mintlify && npm run generate:compliance"
41
42
  },
42
43
  "keywords": [],
43
44
  "author": "",