pmxt-core 2.43.8 → 2.43.10

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 (34) hide show
  1. package/dist/exchanges/baozi/fetcher.js +9 -8
  2. package/dist/exchanges/baozi/index.js +3 -2
  3. package/dist/exchanges/kalshi/api.d.ts +1 -1
  4. package/dist/exchanges/kalshi/api.js +1 -1
  5. package/dist/exchanges/kalshi/fetcher.js +2 -1
  6. package/dist/exchanges/kalshi/index.js +2 -1
  7. package/dist/exchanges/kalshi/websocket.js +12 -9
  8. package/dist/exchanges/limitless/api.d.ts +1 -1
  9. package/dist/exchanges/limitless/api.js +1 -1
  10. package/dist/exchanges/limitless/index.js +3 -2
  11. package/dist/exchanges/limitless/websocket.js +8 -7
  12. package/dist/exchanges/metaculus/createOrder.js +3 -2
  13. package/dist/exchanges/myriad/api.d.ts +1 -1
  14. package/dist/exchanges/myriad/api.js +1 -1
  15. package/dist/exchanges/myriad/index.js +2 -1
  16. package/dist/exchanges/myriad/websocket.js +3 -2
  17. package/dist/exchanges/opinion/api.d.ts +1 -1
  18. package/dist/exchanges/opinion/api.js +1 -1
  19. package/dist/exchanges/opinion/websocket.js +7 -6
  20. package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
  21. package/dist/exchanges/polymarket/api-clob.js +1 -1
  22. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  23. package/dist/exchanges/polymarket/api-data.js +1 -1
  24. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  25. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  26. package/dist/exchanges/polymarket/utils.js +3 -2
  27. package/dist/exchanges/probable/api.d.ts +1 -1
  28. package/dist/exchanges/probable/api.js +1 -1
  29. package/dist/exchanges/probable/index.js +3 -2
  30. package/dist/exchanges/smarkets/fetcher.js +3 -2
  31. package/dist/exchanges/smarkets/index.js +2 -1
  32. package/dist/server/ws-handler.js +5 -2
  33. package/dist/subscriber/external/goldsky.js +4 -3
  34. package/package.json +3 -3
@@ -6,6 +6,7 @@ exports.isRawRaceMarket = isRawRaceMarket;
6
6
  const web3_js_1 = require("@solana/web3.js");
7
7
  const utils_1 = require("./utils");
8
8
  const errors_1 = require("./errors");
9
+ const logger_1 = require("../../utils/logger");
9
10
  function isRawBooleanMarket(raw) {
10
11
  return 'parsed' in raw && 'yesPool' in raw.parsed;
11
12
  }
@@ -44,11 +45,11 @@ class BaoziFetcher {
44
45
  }
45
46
  catch (parseError) {
46
47
  booleanSkipped++;
47
- console.warn(`[Baozi] fetchRawMarkets: failed to parse boolean market account pubkey=${account.pubkey.toString()}:`, parseError);
48
+ logger_1.logger.warn(`Baozi fetchRawMarkets: failed to parse boolean market account pubkey=${account.pubkey.toString()}`, { error: String(parseError) });
48
49
  }
49
50
  }
50
51
  if (booleanSkipped > 0) {
51
- console.warn(`[Baozi] fetchRawMarkets: skipped ${booleanSkipped} malformed boolean market account(s) out of ${booleanAccounts.length}`);
52
+ logger_1.logger.warn(`Baozi fetchRawMarkets: skipped ${booleanSkipped} malformed boolean market account(s) out of ${booleanAccounts.length}`);
52
53
  }
53
54
  let raceSkipped = 0;
54
55
  for (const account of raceAccounts) {
@@ -58,11 +59,11 @@ class BaoziFetcher {
58
59
  }
59
60
  catch (parseError) {
60
61
  raceSkipped++;
61
- console.warn(`[Baozi] fetchRawMarkets: failed to parse race market account pubkey=${account.pubkey.toString()}:`, parseError);
62
+ logger_1.logger.warn(`Baozi fetchRawMarkets: failed to parse race market account pubkey=${account.pubkey.toString()}`, { error: String(parseError) });
62
63
  }
63
64
  }
64
65
  if (raceSkipped > 0) {
65
- console.warn(`[Baozi] fetchRawMarkets: skipped ${raceSkipped} malformed race market account(s) out of ${raceAccounts.length}`);
66
+ logger_1.logger.warn(`Baozi fetchRawMarkets: skipped ${raceSkipped} malformed race market account(s) out of ${raceAccounts.length}`);
66
67
  }
67
68
  marketsCache.set(markets);
68
69
  return markets;
@@ -132,11 +133,11 @@ class BaoziFetcher {
132
133
  }
133
134
  catch (parseError) {
134
135
  boolPosSkipped++;
135
- console.warn(`[Baozi] fetchRawUserPositions: failed to parse boolean position account pubkey=${account.pubkey.toString()}:`, parseError);
136
+ logger_1.logger.warn(`Baozi fetchRawUserPositions: failed to parse boolean position account pubkey=${account.pubkey.toString()}`, { error: String(parseError) });
136
137
  }
137
138
  }
138
139
  if (boolPosSkipped > 0) {
139
- console.warn(`[Baozi] fetchRawUserPositions: skipped ${boolPosSkipped} malformed boolean position account(s) out of ${booleanAccounts.length}`);
140
+ logger_1.logger.warn(`Baozi fetchRawUserPositions: skipped ${boolPosSkipped} malformed boolean position account(s) out of ${booleanAccounts.length}`);
140
141
  }
141
142
  const racePositions = [];
142
143
  let racePosSkipped = 0;
@@ -147,11 +148,11 @@ class BaoziFetcher {
147
148
  }
148
149
  catch (parseError) {
149
150
  racePosSkipped++;
150
- console.warn(`[Baozi] fetchRawUserPositions: failed to parse race position account pubkey=${account.pubkey.toString()}:`, parseError);
151
+ logger_1.logger.warn(`Baozi fetchRawUserPositions: failed to parse race position account pubkey=${account.pubkey.toString()}`, { error: String(parseError) });
151
152
  }
152
153
  }
153
154
  if (racePosSkipped > 0) {
154
- console.warn(`[Baozi] fetchRawUserPositions: skipped ${racePosSkipped} malformed race position account(s) out of ${raceAccounts.length}`);
155
+ logger_1.logger.warn(`Baozi fetchRawUserPositions: skipped ${racePosSkipped} malformed race position account(s) out of ${raceAccounts.length}`);
155
156
  }
156
157
  return { booleanPositions, racePositions };
157
158
  }
@@ -10,6 +10,7 @@ const errors_2 = require("./errors");
10
10
  const fetcher_1 = require("./fetcher");
11
11
  const normalizer_1 = require("./normalizer");
12
12
  const utils_1 = require("./utils");
13
+ const logger_1 = require("../../utils/logger");
13
14
  class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
14
15
  capabilityOverrides = {
15
16
  fetchOHLCV: 'emulated',
@@ -109,7 +110,7 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
109
110
  }
110
111
  }
111
112
  catch (error) {
112
- console.warn(`[Baozi] fetchPositions: failed to fetch boolean market account for PDA=${marketPdaStr}:`, error);
113
+ logger_1.logger.warn(`Baozi fetchPositions: failed to fetch boolean market account for PDA=${marketPdaStr}`, { error: String(error) });
113
114
  throw error;
114
115
  }
115
116
  }
@@ -129,7 +130,7 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
129
130
  }
130
131
  }
131
132
  catch (error) {
132
- console.warn(`[Baozi] fetchPositions: failed to fetch race market account for PDA=${racePdaStr}:`, error);
133
+ logger_1.logger.warn(`Baozi fetchPositions: failed to fetch race market account for PDA=${racePdaStr}`, { error: String(error) });
133
134
  throw error;
134
135
  }
135
136
  }
@@ -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-05-22T21:57:50.589Z
3
+ * Generated at: 2026-05-23T11:16:20.597Z
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-05-22T21:57:50.589Z
6
+ * Generated at: 2026-05-23T11:16:20.597Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -5,6 +5,7 @@ const errors_1 = require("./errors");
5
5
  const errors_2 = require("../../errors");
6
6
  const validation_1 = require("../../utils/validation");
7
7
  const utils_1 = require("./utils");
8
+ const logger_1 = require("../../utils/logger");
8
9
  // ----------------------------------------------------------------------------
9
10
  // Fetcher
10
11
  // ----------------------------------------------------------------------------
@@ -231,7 +232,7 @@ class KalshiFetcher {
231
232
  }
232
233
  catch (err) {
233
234
  // Non-critical — tags are enrichment only.
234
- console.warn('[kalshi] series tag fetch failed', {
235
+ logger_1.logger.warn('kalshi: series tag fetch failed', {
235
236
  series_ticker: event.series_ticker,
236
237
  error: err instanceof Error ? err.message : String(err),
237
238
  });
@@ -4,6 +4,7 @@ exports.KalshiExchange = void 0;
4
4
  const BaseExchange_1 = require("../../BaseExchange");
5
5
  const errors_1 = require("../../errors");
6
6
  const openapi_1 = require("../../utils/openapi");
7
+ const logger_1 = require("../../utils/logger");
7
8
  const api_1 = require("./api");
8
9
  const auth_1 = require("./auth");
9
10
  const config_1 = require("./config");
@@ -137,7 +138,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
137
138
  }
138
139
  async fetchTrades(outcomeId, params) {
139
140
  if ('resolution' in params && params.resolution !== undefined) {
140
- console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
141
+ logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
141
142
  'It will be removed in v3.0.0. Please remove it from your code.');
142
143
  }
143
144
  const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.KalshiWebSocket = void 0;
7
7
  const ws_1 = __importDefault(require("ws"));
8
+ const logger_1 = require("../../utils/logger");
8
9
  const watch_timeout_1 = require("../../utils/watch-timeout");
9
10
  /**
10
11
  * Kalshi WebSocket implementation for real-time order book and trade streaming.
@@ -47,7 +48,7 @@ class KalshiWebSocket {
47
48
  // Extract path from URL for signature
48
49
  const url = new URL(this.wsUrl);
49
50
  const path = url.pathname;
50
- console.log(`Kalshi WS: Connecting to ${this.wsUrl} (using path ${path} for signature)`);
51
+ logger_1.logger.info(`Kalshi WS: Connecting to ${this.wsUrl} (using path ${path} for signature)`);
51
52
  // Get authentication headers
52
53
  const headers = this.auth.getHeaders("GET", path);
53
54
  this.ws = new ws_1.default(this.wsUrl, { headers });
@@ -55,7 +56,7 @@ class KalshiWebSocket {
55
56
  this.isConnected = true;
56
57
  this.isConnecting = false;
57
58
  this.connectionPromise = undefined;
58
- console.log("Kalshi WebSocket connected");
59
+ logger_1.logger.info("Kalshi WebSocket connected");
59
60
  // Resubscribe to all tickers if reconnecting
60
61
  if (this.subscribedOrderBookTickers.size > 0) {
61
62
  this.subscribeToOrderbook(Array.from(this.subscribedOrderBookTickers));
@@ -71,18 +72,18 @@ class KalshiWebSocket {
71
72
  this.handleMessage(message);
72
73
  }
73
74
  catch (error) {
74
- console.error("Error parsing Kalshi WebSocket message:", error);
75
+ logger_1.logger.error("Error parsing Kalshi WebSocket message", { error: String(error) });
75
76
  }
76
77
  });
77
78
  this.ws.on("error", (error) => {
78
- console.error("Kalshi WebSocket error:", error);
79
+ logger_1.logger.error("Kalshi WebSocket error", { error: String(error) });
79
80
  this.isConnecting = false;
80
81
  this.connectionPromise = undefined;
81
82
  reject(error);
82
83
  });
83
84
  this.ws.on("close", () => {
84
85
  if (!this.isTerminated) {
85
- console.log("Kalshi WebSocket closed");
86
+ logger_1.logger.info("Kalshi WebSocket closed");
86
87
  this.scheduleReconnect();
87
88
  }
88
89
  this.isConnected = false;
@@ -106,8 +107,8 @@ class KalshiWebSocket {
106
107
  clearTimeout(this.reconnectTimer);
107
108
  }
108
109
  this.reconnectTimer = setTimeout(() => {
109
- console.log("Attempting to reconnect Kalshi WebSocket...");
110
- this.connect().catch(console.error);
110
+ logger_1.logger.info("Attempting to reconnect Kalshi WebSocket...");
111
+ this.connect().catch((err) => logger_1.logger.error("Kalshi WebSocket reconnect failed", { error: String(err) }));
111
112
  }, this.config.reconnectIntervalMs || 5000);
112
113
  }
113
114
  subscribeToOrderbook(marketTickers) {
@@ -161,10 +162,12 @@ class KalshiWebSocket {
161
162
  this.handleTrade(data);
162
163
  break;
163
164
  case "error":
164
- console.error("Kalshi WebSocket error:", message.msg || message.error || message.data);
165
+ logger_1.logger.error("Kalshi WebSocket error", {
166
+ detail: String(message.msg || message.error || message.data),
167
+ });
165
168
  break;
166
169
  case "subscribed":
167
- console.log("Kalshi subscription confirmed:", JSON.stringify(message));
170
+ logger_1.logger.info("Kalshi subscription confirmed", { message });
168
171
  break;
169
172
  case "pong":
170
173
  // Ignore keep-alive
@@ -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-05-22T21:57:50.625Z
3
+ * Generated at: 2026-05-23T11:16:20.638Z
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-05-22T21:57:50.625Z
6
+ * Generated at: 2026-05-23T11:16:20.638Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -17,6 +17,7 @@ const fetcher_1 = require("./fetcher");
17
17
  const normalizer_1 = require("./normalizer");
18
18
  const utils_1 = require("./utils");
19
19
  const websocket_1 = require("./websocket");
20
+ const logger_1 = require("../../utils/logger");
20
21
  class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
21
22
  capabilityOverrides = {
22
23
  fetchOrder: false,
@@ -86,7 +87,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
86
87
  catch (error) {
87
88
  // If auth initialization fails, continue without it
88
89
  // Some methods (like fetchMarkets) work without auth
89
- console.warn('Failed to initialize Limitless auth:', error);
90
+ logger_1.logger.warn('Failed to initialize Limitless auth', { error: String(error) });
90
91
  }
91
92
  }
92
93
  // Register implicit API for Limitless REST endpoints
@@ -190,7 +191,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
190
191
  }
191
192
  async fetchTrades(outcomeId, params) {
192
193
  if ('resolution' in params && params.resolution !== undefined) {
193
- console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
194
+ logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
194
195
  'It will be removed in v3.0.0. Please remove it from your code.');
195
196
  }
196
197
  const slug = await this.resolveSlug(outcomeId);
@@ -4,6 +4,7 @@ exports.LimitlessWebSocket = void 0;
4
4
  const sdk_1 = require("@limitless-exchange/sdk");
5
5
  const goldsky_1 = require("../../subscriber/external/goldsky");
6
6
  const watcher_1 = require("../../subscriber/watcher");
7
+ const logger_1 = require("../../utils/logger");
7
8
  // Limitless uses USDC with 6 decimals
8
9
  const USDC_DECIMALS = 6;
9
10
  const USDC_SCALE = Math.pow(10, USDC_DECIMALS);
@@ -90,7 +91,7 @@ class LimitlessWebSocket {
90
91
  return await this.fetchOrderBookSnapshot(marketSlug);
91
92
  }
92
93
  catch (err) {
93
- console.warn(`[LimitlessWS] Failed to fetch initial snapshot:`, err);
94
+ logger_1.logger.warn('LimitlessWS: Failed to fetch initial snapshot', { error: String(err) });
94
95
  }
95
96
  }
96
97
  // 3. Wait for WebSocket update with timeout fallback
@@ -107,7 +108,7 @@ class LimitlessWebSocket {
107
108
  return await this.fetchOrderBookSnapshot(marketSlug);
108
109
  }
109
110
  catch (err) {
110
- console.warn(`[LimitlessWS] Failed to fetch refresh snapshot:`, err);
111
+ logger_1.logger.warn('LimitlessWS: Failed to fetch refresh snapshot', { error: String(err) });
111
112
  }
112
113
  }
113
114
  // Wait for WebSocket update with timeout
@@ -127,7 +128,7 @@ class LimitlessWebSocket {
127
128
  resolve(snapshot);
128
129
  }
129
130
  catch (err) {
130
- console.warn(`[LimitlessWS] Failed to fetch timeout fallback snapshot:`, err);
131
+ logger_1.logger.warn('LimitlessWS: Failed to fetch timeout fallback snapshot', { error: String(err) });
131
132
  // Resolve with empty orderbook rather than rejecting
132
133
  resolve(this.getEmptyOrderbook());
133
134
  }
@@ -191,7 +192,7 @@ class LimitlessWebSocket {
191
192
  * Legacy method - watch trades (not directly supported, falls back to orderbook)
192
193
  */
193
194
  async watchTrades(marketSlug, address) {
194
- console.warn('[LimitlessWS] watchTrades is not directly supported. ' +
195
+ logger_1.logger.warn('LimitlessWS: watchTrades is not directly supported. ' +
195
196
  'Use watchOrderBook() for real-time orderbook updates or fetchOHLCV() for historical data.');
196
197
  return [];
197
198
  }
@@ -277,13 +278,13 @@ class LimitlessWebSocket {
277
278
  });
278
279
  // Handle connection events
279
280
  this.client.on('connect', () => {
280
- console.log('[LimitlessWS] Connected to WebSocket');
281
+ logger_1.logger.info('LimitlessWS: Connected to WebSocket');
281
282
  });
282
283
  this.client.on('disconnect', (reason) => {
283
- console.log(`[LimitlessWS] Disconnected from WebSocket: ${reason}`);
284
+ logger_1.logger.info(`LimitlessWS: Disconnected from WebSocket: ${reason}`);
284
285
  });
285
286
  this.client.on('error', (error) => {
286
- console.error('[LimitlessWS] WebSocket error:', error);
287
+ logger_1.logger.error('LimitlessWS: WebSocket error', { error: String(error) });
287
288
  });
288
289
  }
289
290
  transformOrderbookData(orderbook) {
@@ -6,6 +6,7 @@ exports.redistributeProbabilities = redistributeProbabilities;
6
6
  exports.createOrder = createOrder;
7
7
  const errors_1 = require("../../errors");
8
8
  const errors_2 = require("./errors");
9
+ const logger_1 = require("../../utils/logger");
9
10
  /**
10
11
  * Parse a Metaculus outcomeId into its components.
11
12
  *
@@ -210,11 +211,11 @@ async function createOrder(params, ctx) {
210
211
  const probability = validateProbability(params.price);
211
212
  // 5. Log warnings for params that don't apply to Metaculus
212
213
  if (params.side && params.side !== "buy") {
213
- console.warn(`[pmxt/Metaculus] Ignoring side="${params.side}" -- Metaculus forecasts are probability submissions, not buy/sell. `
214
+ logger_1.logger.warn(`Metaculus: Ignoring side="${params.side}" -- Metaculus forecasts are probability submissions, not buy/sell. `
214
215
  + "Set the probability via the `price` parameter instead.");
215
216
  }
216
217
  if (params.type && params.type !== "market") {
217
- console.warn(`[pmxt/Metaculus] Ignoring type="${params.type}" -- Metaculus forecasts execute instantly (no limit orders).`);
218
+ logger_1.logger.warn(`Metaculus: Ignoring type="${params.type}" -- Metaculus forecasts execute instantly (no limit orders).`);
218
219
  }
219
220
  // 6. Build the forecast payload
220
221
  let payload;
@@ -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-05-22T21:57:50.636Z
3
+ * Generated at: 2026-05-23T11:16:20.649Z
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-05-22T21:57:50.636Z
6
+ * Generated at: 2026-05-23T11:16:20.649Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -11,6 +11,7 @@ const openapi_1 = require("../../utils/openapi");
11
11
  const api_1 = require("./api");
12
12
  const fetcher_1 = require("./fetcher");
13
13
  const normalizer_1 = require("./normalizer");
14
+ const logger_1 = require("../../utils/logger");
14
15
  class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
15
16
  capabilityOverrides = {
16
17
  fetchOrderBook: 'emulated',
@@ -109,7 +110,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
109
110
  }
110
111
  async fetchTrades(outcomeId, params) {
111
112
  if ('resolution' in params && params.resolution !== undefined) {
112
- console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
113
+ logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
113
114
  'It will be removed in v3.0.0. Please remove it from your code.');
114
115
  }
115
116
  const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MyriadWebSocket = void 0;
4
+ const logger_1 = require("../../utils/logger");
4
5
  // Myriad API v2 does not expose a WebSocket endpoint.
5
6
  // We implement a poll-based fallback that resolves promises
6
7
  // on each polling interval, matching the CCXT Pro async pattern.
@@ -85,7 +86,7 @@ class MyriadWebSocket {
85
86
  catch (error) {
86
87
  const failures = (this.orderBookFailureCount.get(id) || 0) + 1;
87
88
  this.orderBookFailureCount.set(id, failures);
88
- console.warn(`[Myriad] watchOrderBook poll failed for outcomeId=${id} (consecutive failures: ${failures}):`, error);
89
+ logger_1.logger.warn(`Myriad watchOrderBook poll failed for outcomeId=${id} (consecutive failures: ${failures})`, { error: String(error) });
89
90
  if (failures >= MAX_CONSECUTIVE_FAILURES) {
90
91
  const timer = this.orderBookTimers.get(id);
91
92
  if (timer)
@@ -149,7 +150,7 @@ class MyriadWebSocket {
149
150
  catch (error) {
150
151
  const failures = (this.tradeFailureCount.get(id) || 0) + 1;
151
152
  this.tradeFailureCount.set(id, failures);
152
- console.warn(`[Myriad] watchTrades poll failed for outcomeId=${id} (consecutive failures: ${failures}):`, error);
153
+ logger_1.logger.warn(`Myriad watchTrades poll failed for outcomeId=${id} (consecutive failures: ${failures})`, { error: String(error) });
153
154
  if (failures >= MAX_CONSECUTIVE_FAILURES) {
154
155
  const timer = this.tradeTimers.get(id);
155
156
  if (timer)
@@ -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-05-22T21:57:50.641Z
3
+ * Generated at: 2026-05-23T11:16:20.654Z
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-05-22T21:57:50.641Z
6
+ * Generated at: 2026-05-23T11:16:20.654Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.OpinionWebSocket = void 0;
7
7
  const ws_1 = __importDefault(require("ws"));
8
+ const logger_1 = require("../../utils/logger");
8
9
  const watch_timeout_1 = require("../../utils/watch-timeout");
9
10
  /**
10
11
  * Opinion Trade WebSocket implementation for real-time order book and trade streaming.
@@ -52,7 +53,7 @@ class OpinionWebSocket {
52
53
  this.isConnected = true;
53
54
  this.isConnecting = false;
54
55
  this.connectionPromise = undefined;
55
- console.log("Opinion WebSocket connected");
56
+ logger_1.logger.info("Opinion WebSocket connected");
56
57
  this.resubscribeAll();
57
58
  resolve();
58
59
  });
@@ -62,18 +63,18 @@ class OpinionWebSocket {
62
63
  this.handleMessage(message);
63
64
  }
64
65
  catch (error) {
65
- console.error("Error parsing Opinion WebSocket message:", error);
66
+ logger_1.logger.error("Error parsing Opinion WebSocket message", { error: String(error) });
66
67
  }
67
68
  });
68
69
  this.ws.on("error", (error) => {
69
- console.error("Opinion WebSocket error:", error);
70
+ logger_1.logger.error("Opinion WebSocket error", { error: String(error) });
70
71
  this.isConnecting = false;
71
72
  this.connectionPromise = undefined;
72
73
  reject(error);
73
74
  });
74
75
  this.ws.on("close", () => {
75
76
  if (!this.isTerminated) {
76
- console.log("Opinion WebSocket closed, scheduling reconnect");
77
+ logger_1.logger.info("Opinion WebSocket closed, scheduling reconnect");
77
78
  this.scheduleReconnect();
78
79
  }
79
80
  this.isConnected = false;
@@ -97,8 +98,8 @@ class OpinionWebSocket {
97
98
  clearTimeout(this.reconnectTimer);
98
99
  }
99
100
  this.reconnectTimer = setTimeout(() => {
100
- console.log("Attempting to reconnect Opinion WebSocket...");
101
- this.connect().catch(console.error);
101
+ logger_1.logger.info("Attempting to reconnect Opinion WebSocket...");
102
+ this.connect().catch((err) => logger_1.logger.error("Opinion WebSocket reconnect failed", { error: String(err) }));
102
103
  }, this.config.reconnectIntervalMs ?? 5000);
103
104
  }
104
105
  resubscribeAll() {
@@ -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-05-22T21:57:50.595Z
3
+ * Generated at: 2026-05-23T11:16:20.604Z
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-05-22T21:57:50.595Z
6
+ * Generated at: 2026-05-23T11:16:20.604Z
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-05-22T21:57:50.608Z
3
+ * Generated at: 2026-05-23T11:16:20.619Z
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-05-22T21:57:50.608Z
6
+ * Generated at: 2026-05-23T11:16:20.619Z
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-05-22T21:57:50.606Z
3
+ * Generated at: 2026-05-23T11:16:20.616Z
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-05-22T21:57:50.606Z
6
+ * Generated at: 2026-05-23T11:16:20.616Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -6,6 +6,7 @@ exports.mapIntervalToFidelity = mapIntervalToFidelity;
6
6
  exports.paginateParallel = paginateParallel;
7
7
  exports.paginateSearchParallel = paginateSearchParallel;
8
8
  const market_utils_1 = require("../../utils/market-utils");
9
+ const logger_1 = require("../../utils/logger");
9
10
  exports.GAMMA_API_URL = process.env.POLYMARKET_GAMMA_URL || 'https://gamma-api.polymarket.com/events';
10
11
  exports.GAMMA_SEARCH_URL = process.env.POLYMARKET_GAMMA_SEARCH_URL || 'https://gamma-api.polymarket.com/public-search';
11
12
  exports.CLOB_API_URL = process.env.POLYMARKET_CLOB_URL || 'https://clob.polymarket.com';
@@ -25,7 +26,7 @@ function mapMarketToUnified(event, market, options = {}) {
25
26
  outcomePrices = (typeof market.outcomePrices === 'string' ? JSON.parse(market.outcomePrices) : market.outcomePrices) || [];
26
27
  }
27
28
  catch (e) {
28
- console.warn(`Error parsing outcomes for market ${market.id}:`, e);
29
+ logger_1.logger.warn(`Error parsing outcomes for market ${market.id}`, { error: String(e) });
29
30
  }
30
31
  // Extract CLOB token IDs for granular operations
31
32
  let clobTokenIds = [];
@@ -33,7 +34,7 @@ function mapMarketToUnified(event, market, options = {}) {
33
34
  clobTokenIds = (typeof market.clobTokenIds === 'string' ? JSON.parse(market.clobTokenIds) : market.clobTokenIds) || [];
34
35
  }
35
36
  catch (e) {
36
- console.warn(`Error parsing clobTokenIds for market ${market.id}:`, e);
37
+ logger_1.logger.warn(`Error parsing clobTokenIds for market ${market.id}`, { error: String(e) });
37
38
  }
38
39
  // Extract candidate/option name from market question for better outcome labels
39
40
  let candidateName = null;
@@ -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-05-22T21:57:50.629Z
3
+ * Generated at: 2026-05-23T11:16:20.642Z
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-05-22T21:57:50.629Z
6
+ * Generated at: 2026-05-23T11:16:20.642Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -12,6 +12,7 @@ const api_1 = require("./api");
12
12
  const utils_1 = require("./utils");
13
13
  const fetcher_1 = require("./fetcher");
14
14
  const normalizer_1 = require("./normalizer");
15
+ const logger_1 = require("../../utils/logger");
15
16
  const BSC_USDT_ADDRESS = '0x55d398326f99059fF775485246999027B3197955';
16
17
  class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
17
18
  auth;
@@ -331,7 +332,7 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
331
332
  total = parseFloat(formatUnits(balance, 18));
332
333
  }
333
334
  catch (chainError) {
334
- console.warn('[Probable] fetchBalance: on-chain USDT balance fetch failed:', chainError);
335
+ logger_1.logger.warn('Probable fetchBalance: on-chain USDT balance fetch failed', { error: String(chainError) });
335
336
  throw chainError;
336
337
  }
337
338
  // Calculate locked from open BUY orders
@@ -345,7 +346,7 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
345
346
  }
346
347
  }
347
348
  catch (ordersError) {
348
- console.warn('[Probable] fetchBalance: failed to fetch open orders for locked balance calculation:', ordersError);
349
+ logger_1.logger.warn('Probable fetchBalance: failed to fetch open orders for locked balance calculation', { error: String(ordersError) });
349
350
  throw ordersError;
350
351
  }
351
352
  return [{
@@ -4,6 +4,7 @@ exports.SmarketsFetcher = void 0;
4
4
  const errors_1 = require("./errors");
5
5
  const errors_2 = require("../../errors");
6
6
  const validation_1 = require("../../utils/validation");
7
+ const logger_1 = require("../../utils/logger");
7
8
  // ----------------------------------------------------------------------------
8
9
  // Fetcher
9
10
  // ----------------------------------------------------------------------------
@@ -315,8 +316,8 @@ class SmarketsFetcher {
315
316
  }
316
317
  catch (err) {
317
318
  // Volumes are non-critical; return empty on failure but log it.
318
- console.warn('[smarkets] volume fetch failed for batch', {
319
- marketIds: batch,
319
+ logger_1.logger.warn('smarkets: volume fetch failed for batch', {
320
+ marketIds: batch.join(','),
320
321
  error: err instanceof Error ? err.message : String(err),
321
322
  });
322
323
  return [];
@@ -11,6 +11,7 @@ const config_1 = require("./config");
11
11
  const fetcher_1 = require("./fetcher");
12
12
  const normalizer_1 = require("./normalizer");
13
13
  const price_1 = require("./price");
14
+ const logger_1 = require("../../utils/logger");
14
15
  class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
15
16
  capabilityOverrides = {
16
17
  fetchPositions: 'emulated',
@@ -164,7 +165,7 @@ class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
164
165
  }
165
166
  async fetchTrades(outcomeId, params) {
166
167
  if ('resolution' in params && params.resolution !== undefined) {
167
- console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
168
+ logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
168
169
  'It will be removed in v3.0.0. Please remove it from your code.');
169
170
  }
170
171
  const rawActivity = await this.fetcher.fetchRawTradeActivity(outcomeId, params);
@@ -4,6 +4,7 @@ exports.createWebSocketHandler = createWebSocketHandler;
4
4
  const ws_1 = require("ws");
5
5
  const errors_1 = require("../errors");
6
6
  const exchange_factory_1 = require("./exchange-factory");
7
+ const logger_1 = require("../utils/logger");
7
8
  // ---------------------------------------------------------------------------
8
9
  // Streaming methods
9
10
  // ---------------------------------------------------------------------------
@@ -197,7 +198,9 @@ function createWebSocketHandler(options = {}) {
197
198
  for (const [, exchange] of state.exchanges) {
198
199
  if (typeof exchange.close === "function") {
199
200
  exchange.close().catch((err) => {
200
- console.warn('[ws-handler] exchange close() failed', { error: err instanceof Error ? err.message : String(err) });
201
+ logger_1.logger.warn('ws-handler: exchange close() failed', {
202
+ error: err instanceof Error ? err.message : String(err),
203
+ });
201
204
  });
202
205
  }
203
206
  }
@@ -259,7 +262,7 @@ function handleSubscribe(ws, state, msg, exchangeName) {
259
262
  streamFn(exchange, method, args || [], id, ws, abortController.signal).catch((err) => {
260
263
  // Unexpected stream rejection (programming error — exchange errors are
261
264
  // caught and reported to the client inside streamSingle/streamBatch).
262
- console.warn('[ws-handler] stream ended with unexpected error', {
265
+ logger_1.logger.warn('ws-handler: stream ended with unexpected error', {
263
266
  exchange: exchangeName,
264
267
  method,
265
268
  id,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GoldSkySubscriber = exports.buildLimitlessBalanceActivity = exports.buildPolymarketActivity = exports.buildPolymarketTradesActivity = exports.LIMITLESS_DEFAULT_SUBSCRIPTION = exports.POLYMARKET_DEFAULT_SUBSCRIPTION = void 0;
4
+ const logger_1 = require("../../utils/logger");
4
5
  // ----------------------------------------------------------------------------
5
6
  // Polymarket endpoints
6
7
  // ----------------------------------------------------------------------------
@@ -284,19 +285,19 @@ class GoldSkySubscriber {
284
285
  signal,
285
286
  });
286
287
  if (!res.ok) {
287
- console.warn(`[GoldSkySubscriber] HTTP ${res.status} from ${q.url}`);
288
+ logger_1.logger.warn(`GoldSkySubscriber: HTTP ${res.status} from ${q.url}`);
288
289
  return null;
289
290
  }
290
291
  const json = await res.json();
291
292
  if (json?.errors) {
292
- console.warn(`[GoldSkySubscriber] GraphQL errors from ${q.url}:`, JSON.stringify(json.errors));
293
+ logger_1.logger.warn(`GoldSkySubscriber: GraphQL errors from ${q.url}`, { errors: JSON.stringify(json.errors) });
293
294
  return null;
294
295
  }
295
296
  return json?.data ?? null;
296
297
  }
297
298
  catch (err) {
298
299
  if (err?.name !== 'AbortError') {
299
- console.warn(`[GoldSkySubscriber] Fetch failed for ${q.url}:`, err);
300
+ logger_1.logger.warn(`GoldSkySubscriber: Fetch failed for ${q.url}`, { error: String(err) });
300
301
  }
301
302
  return null;
302
303
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.43.8",
3
+ "version": "2.43.10",
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,8 +29,8 @@
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.43.8,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.43.8,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.43.10,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.43.10,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",