pmxt-core 2.43.4 → 2.43.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseExchange.d.ts +8 -2
- package/dist/BaseExchange.js +20 -17
- package/dist/exchanges/gemini-titan/websocket.js +4 -3
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/polymarket/auth.js +7 -5
- package/dist/exchanges/polymarket/index.js +8 -4
- package/dist/exchanges/polymarket/websocket.js +12 -7
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/router/Router.js +6 -5
- package/dist/server/app.js +3 -6
- package/dist/server/openapi.yaml +4 -1
- package/dist/utils/logger.d.ts +18 -0
- package/dist/utils/logger.js +71 -0
- package/package.json +3 -3
package/dist/BaseExchange.d.ts
CHANGED
|
@@ -475,9 +475,15 @@ export declare abstract class PredictionMarketExchange {
|
|
|
475
475
|
/**
|
|
476
476
|
* Fetch the order book (bids/asks) for a specific outcome.
|
|
477
477
|
*
|
|
478
|
+
* Supports live and historical queries. For historical data, pass `since`
|
|
479
|
+
* to get a single snapshot, or `since` + `until` to get an array of fully
|
|
480
|
+
* reconstructed L2 books from the archive. Range queries return up to
|
|
481
|
+
* `limit` snapshots (default 100, max 1000).
|
|
482
|
+
*
|
|
478
483
|
* @param outcomeId - The Outcome ID (outcomeId) or market slug
|
|
479
|
-
* @param limit - Max number of bid/ask levels to return
|
|
480
|
-
*
|
|
484
|
+
* @param limit - Max number of bid/ask levels to return. For range
|
|
485
|
+
* queries (since + until), limits the number of snapshots returned
|
|
486
|
+
* (default 100, max 1000).
|
|
481
487
|
* @param params - Optional parameters:
|
|
482
488
|
* - `side`: 'yes' or 'no' — explicitly indicate the outcome side
|
|
483
489
|
* (required for exchanges like Limitless where the API returns a
|
package/dist/BaseExchange.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.PredictionMarketExchange = void 0;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const errors_1 = require("./errors");
|
|
9
9
|
const math_1 = require("./utils/math");
|
|
10
|
+
const logger_1 = require("./utils/logger");
|
|
10
11
|
const throttler_1 = require("./utils/throttler");
|
|
11
12
|
// ----------------------------------------------------------------------------
|
|
12
13
|
// Base Exchange Class
|
|
@@ -85,30 +86,27 @@ class PredictionMarketExchange {
|
|
|
85
86
|
// Request Interceptor
|
|
86
87
|
this.http.interceptors.request.use((config) => {
|
|
87
88
|
if (this.verbose) {
|
|
88
|
-
|
|
89
|
+
logger_1.logger.debug(`-> ${config.method?.toUpperCase()} ${config.url}`);
|
|
89
90
|
if (config.params)
|
|
90
|
-
|
|
91
|
+
logger_1.logger.debug('params:', { params: config.params });
|
|
91
92
|
if (config.data)
|
|
92
|
-
|
|
93
|
+
logger_1.logger.debug('body:', { body: config.data });
|
|
93
94
|
}
|
|
94
95
|
return config;
|
|
95
96
|
});
|
|
96
97
|
// Response Interceptor
|
|
97
98
|
this.http.interceptors.response.use((response) => {
|
|
98
99
|
if (this.verbose) {
|
|
99
|
-
|
|
100
|
-
// console.log('[pmxt] response:', JSON.stringify(response.data, null, 2));
|
|
101
|
-
// Commented out full body log to avoid spam, but headers might be useful
|
|
100
|
+
logger_1.logger.debug(`<- ${response.status} ${response.statusText} ${response.config.url}`);
|
|
102
101
|
}
|
|
103
102
|
return response;
|
|
104
103
|
}, (error) => {
|
|
105
104
|
if (this.verbose) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
105
|
+
logger_1.logger.debug(`REQUEST FAILED: ${error.config?.url}`, {
|
|
106
|
+
error: error.message,
|
|
107
|
+
status: error.response?.status,
|
|
108
|
+
data: error.response?.data,
|
|
109
|
+
});
|
|
112
110
|
}
|
|
113
111
|
return Promise.reject(error);
|
|
114
112
|
});
|
|
@@ -419,9 +417,15 @@ class PredictionMarketExchange {
|
|
|
419
417
|
/**
|
|
420
418
|
* Fetch the order book (bids/asks) for a specific outcome.
|
|
421
419
|
*
|
|
420
|
+
* Supports live and historical queries. For historical data, pass `since`
|
|
421
|
+
* to get a single snapshot, or `since` + `until` to get an array of fully
|
|
422
|
+
* reconstructed L2 books from the archive. Range queries return up to
|
|
423
|
+
* `limit` snapshots (default 100, max 1000).
|
|
424
|
+
*
|
|
422
425
|
* @param outcomeId - The Outcome ID (outcomeId) or market slug
|
|
423
|
-
* @param limit - Max number of bid/ask levels to return
|
|
424
|
-
*
|
|
426
|
+
* @param limit - Max number of bid/ask levels to return. For range
|
|
427
|
+
* queries (since + until), limits the number of snapshots returned
|
|
428
|
+
* (default 100, max 1000).
|
|
425
429
|
* @param params - Optional parameters:
|
|
426
430
|
* - `side`: 'yes' or 'no' — explicitly indicate the outcome side
|
|
427
431
|
* (required for exchanges like Limitless where the API returns a
|
|
@@ -461,8 +465,7 @@ class PredictionMarketExchange {
|
|
|
461
465
|
async fetchTrades(outcomeId, params) {
|
|
462
466
|
// Deprecation warning for resolution parameter
|
|
463
467
|
if ('resolution' in params && params.resolution !== undefined) {
|
|
464
|
-
|
|
465
|
-
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
468
|
+
logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. It will be removed in v3.0.0.');
|
|
466
469
|
}
|
|
467
470
|
throw new Error("Method fetchTrades not implemented.");
|
|
468
471
|
}
|
|
@@ -907,7 +910,7 @@ class PredictionMarketExchange {
|
|
|
907
910
|
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
908
911
|
*/
|
|
909
912
|
async fetchMatches(params) {
|
|
910
|
-
|
|
913
|
+
logger_1.logger.warn('fetchMatches is deprecated, use fetchMarketMatches instead');
|
|
911
914
|
return this.fetchMarketMatches(params);
|
|
912
915
|
}
|
|
913
916
|
/**
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GeminiWebSocket = 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
|
* Gemini Titan WebSocket for real-time order book and trade streaming.
|
|
@@ -105,7 +106,7 @@ class GeminiWebSocket {
|
|
|
105
106
|
clearTimeout(this.reconnectTimer);
|
|
106
107
|
this.reconnectTimer = setTimeout(() => {
|
|
107
108
|
this.connect().catch((err) => {
|
|
108
|
-
|
|
109
|
+
logger_1.logger.warn(`[gemini-titan] reconnect failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
109
110
|
});
|
|
110
111
|
}, this.config.reconnectIntervalMs ?? 5000);
|
|
111
112
|
}
|
|
@@ -225,7 +226,7 @@ class GeminiWebSocket {
|
|
|
225
226
|
this.subscribedDepthSymbols.add(symbol);
|
|
226
227
|
if (!this.isConnected) {
|
|
227
228
|
this.connect().catch((err) => {
|
|
228
|
-
|
|
229
|
+
logger_1.logger.warn(`[gemini-titan] connect failed during watchOrderBook('${symbol}'): ${err instanceof Error ? err.message : String(err)}`);
|
|
229
230
|
});
|
|
230
231
|
}
|
|
231
232
|
else {
|
|
@@ -246,7 +247,7 @@ class GeminiWebSocket {
|
|
|
246
247
|
this.subscribedTradeSymbols.add(symbol);
|
|
247
248
|
if (!this.isConnected) {
|
|
248
249
|
this.connect().catch((err) => {
|
|
249
|
-
|
|
250
|
+
logger_1.logger.warn(`[gemini-titan] connect failed during watchTrades('${symbol}'): ${err instanceof Error ? err.message : String(err)}`);
|
|
250
251
|
});
|
|
251
252
|
}
|
|
252
253
|
else {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.589Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.589Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.kalshiApiSpec = {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.625Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.625Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.limitlessApiSpec = {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.636Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.636Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.myriadApiSpec = {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.641Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.641Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.595Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.595Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.608Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.608Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.606Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.606Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -9,6 +9,7 @@ const viem_1 = require("viem");
|
|
|
9
9
|
const accounts_1 = require("viem/accounts");
|
|
10
10
|
const chains_1 = require("viem/chains");
|
|
11
11
|
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
const logger_1 = require("../../utils/logger");
|
|
12
13
|
const errors_1 = require("./errors");
|
|
13
14
|
const DEFAULT_POLYMARKET_HOST = process.env.POLYMARKET_CLOB_URL || 'https://clob.polymarket.com';
|
|
14
15
|
const POLYGON_CHAIN_ID = 137;
|
|
@@ -98,8 +99,7 @@ class PolymarketAuth {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
catch (deriveError) {
|
|
101
|
-
|
|
102
|
-
console.log('[PolymarketAuth] Attempting to create new API key...');
|
|
102
|
+
logger_1.logger.info('API key derivation failed, creating new key', { error: deriveError.message || String(deriveError) });
|
|
103
103
|
try {
|
|
104
104
|
creds = await l1Client.createApiKey();
|
|
105
105
|
}
|
|
@@ -108,7 +108,7 @@ class PolymarketAuth {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
if (!creds || !creds.key || !creds.secret || !creds.passphrase) {
|
|
111
|
-
|
|
111
|
+
logger_1.logger.error('Incomplete credentials after derivation', { hasKey: !!creds?.key, hasSecret: !!creds?.secret, hasPassphrase: !!creds?.passphrase });
|
|
112
112
|
throw new Error('Authentication failed: Derived credentials are incomplete.');
|
|
113
113
|
}
|
|
114
114
|
// console.log(`[PolymarketAuth] Successfully obtained API credentials for key ${creds.key.substring(0, 8)}...`);
|
|
@@ -149,7 +149,7 @@ class PolymarketAuth {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
catch (error) {
|
|
152
|
-
|
|
152
|
+
logger_1.logger.warn(`Proxy auto-discovery failed for ${address}`, { error: error instanceof Error ? error.message : String(error) });
|
|
153
153
|
}
|
|
154
154
|
// Fallback to EOA if discovery fails
|
|
155
155
|
return {
|
|
@@ -223,7 +223,9 @@ class PolymarketAuth {
|
|
|
223
223
|
// Discovery failure — fall through to default (Gnosis Safe) below.
|
|
224
224
|
// A network/HTTP error here does not block trading; we just lose
|
|
225
225
|
// the ability to auto-detect signatureType.
|
|
226
|
-
|
|
226
|
+
logger_1.logger.warn('Signature-type discovery failed; defaulting to Gnosis Safe', {
|
|
227
|
+
error: err instanceof Error ? err.message : String(err),
|
|
228
|
+
});
|
|
227
229
|
}
|
|
228
230
|
}
|
|
229
231
|
if (signatureType === undefined) {
|
|
@@ -14,6 +14,7 @@ const api_clob_1 = require("./api-clob");
|
|
|
14
14
|
const api_data_1 = require("./api-data");
|
|
15
15
|
const api_gamma_1 = require("./api-gamma");
|
|
16
16
|
const auth_1 = require("./auth");
|
|
17
|
+
const logger_1 = require("../../utils/logger");
|
|
17
18
|
const errors_2 = require("./errors");
|
|
18
19
|
const fetcher_1 = require("./fetcher");
|
|
19
20
|
const normalizer_1 = require("./normalizer");
|
|
@@ -135,8 +136,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
135
136
|
(0, validation_1.validateIdFormat)(outcomeId, 'Trades');
|
|
136
137
|
(0, validation_1.validateOutcomeId)(outcomeId, 'Trades');
|
|
137
138
|
if ('resolution' in params && params.resolution !== undefined) {
|
|
138
|
-
|
|
139
|
-
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
139
|
+
logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. It will be removed in v3.0.0.');
|
|
140
140
|
}
|
|
141
141
|
const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
|
|
142
142
|
const mappedTrades = rawTrades.map((raw, i) => this.normalizer.normalizeTrade(raw, i));
|
|
@@ -380,7 +380,9 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
380
380
|
// If balRes was an error envelope, fall through to on-chain.
|
|
381
381
|
}
|
|
382
382
|
catch (clobError) {
|
|
383
|
-
|
|
383
|
+
logger_1.logger.warn('CLOB balance request failed, falling through to on-chain', {
|
|
384
|
+
error: clobError instanceof Error ? clobError.message : String(clobError),
|
|
385
|
+
});
|
|
384
386
|
}
|
|
385
387
|
// On-Chain Fallback/Check (Robustness)
|
|
386
388
|
// Trigger when CLOB couldn't tell us, or reported a true zero (CLOB
|
|
@@ -395,7 +397,9 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
399
|
catch (err) {
|
|
398
|
-
|
|
400
|
+
logger_1.logger.warn('On-chain balance lookup failed; using CLOB balance only', {
|
|
401
|
+
error: err instanceof Error ? err.message : String(err),
|
|
402
|
+
});
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
405
|
// 2. Fetch open orders to calculate locked funds.
|
|
@@ -41,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.PolymarketWebSocket = void 0;
|
|
44
|
+
const logger_1 = require("../../utils/logger");
|
|
44
45
|
const goldsky_1 = require("../../subscriber/external/goldsky");
|
|
45
46
|
const watcher_1 = require("../../subscriber/watcher");
|
|
46
47
|
const watch_timeout_1 = require("../../utils/watch-timeout");
|
|
@@ -165,7 +166,7 @@ class PolymarketWebSocket {
|
|
|
165
166
|
const url = 'wss://ws-subscriptions-clob.polymarket.com/ws/user';
|
|
166
167
|
this.userWs = new WebSocket(url);
|
|
167
168
|
this.userWs.on('open', () => {
|
|
168
|
-
|
|
169
|
+
logger_1.logger.debug('[polymarket-ws] user channel connected');
|
|
169
170
|
this.sendUserSubscription(creds);
|
|
170
171
|
// Ping every 10 seconds to keep the connection alive.
|
|
171
172
|
if (this.userPingInterval)
|
|
@@ -186,7 +187,7 @@ class PolymarketWebSocket {
|
|
|
186
187
|
cb(event);
|
|
187
188
|
}
|
|
188
189
|
catch (e) {
|
|
189
|
-
|
|
190
|
+
logger_1.logger.error('[polymarket-ws] user callback error', { error: e instanceof Error ? e.message : String(e) });
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
}
|
|
@@ -196,11 +197,11 @@ class PolymarketWebSocket {
|
|
|
196
197
|
}
|
|
197
198
|
});
|
|
198
199
|
this.userWs.on('close', () => {
|
|
199
|
-
|
|
200
|
+
logger_1.logger.warn('[polymarket-ws] user channel disconnected, reconnecting in 5s');
|
|
200
201
|
this.scheduleUserReconnect(creds);
|
|
201
202
|
});
|
|
202
203
|
this.userWs.on('error', (err) => {
|
|
203
|
-
|
|
204
|
+
logger_1.logger.error('[polymarket-ws] user channel error', { error: err.message });
|
|
204
205
|
});
|
|
205
206
|
}
|
|
206
207
|
sendUserSubscription(creds) {
|
|
@@ -227,7 +228,7 @@ class PolymarketWebSocket {
|
|
|
227
228
|
await this.connectUserChannel(creds);
|
|
228
229
|
}
|
|
229
230
|
catch (e) {
|
|
230
|
-
|
|
231
|
+
logger_1.logger.error('[polymarket-ws] reconnect failed', { error: e.message });
|
|
231
232
|
this.scheduleUserReconnect(creds);
|
|
232
233
|
}
|
|
233
234
|
}
|
|
@@ -293,10 +294,14 @@ class PolymarketWebSocket {
|
|
|
293
294
|
this.handleTrade(msg);
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
|
-
catch {
|
|
297
|
+
catch (e) {
|
|
298
|
+
logger_1.logger.error('[polymarket-ws] market message handler error', {
|
|
299
|
+
error: e instanceof Error ? e.message : String(e),
|
|
300
|
+
});
|
|
301
|
+
}
|
|
297
302
|
});
|
|
298
303
|
this.ws.on('error', (err) => {
|
|
299
|
-
|
|
304
|
+
logger_1.logger.error('[polymarket-ws] WebSocket error', { error: err.message });
|
|
300
305
|
reject(err);
|
|
301
306
|
});
|
|
302
307
|
this.ws.on('close', () => {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-22T21:57:50.629Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-22T21:57:50.629Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
package/dist/router/Router.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Router = void 0;
|
|
4
4
|
const BaseExchange_1 = require("../BaseExchange");
|
|
5
|
+
const logger_1 = require("../utils/logger");
|
|
5
6
|
const client_1 = require("./client");
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
// Orderbook merge utilities
|
|
@@ -163,7 +164,7 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
163
164
|
}
|
|
164
165
|
/** @deprecated Use {@link fetchMarketMatches} instead. */
|
|
165
166
|
async fetchMatches(params) {
|
|
166
|
-
|
|
167
|
+
logger_1.logger.warn('fetchMatches is deprecated, use fetchMarketMatches instead');
|
|
167
168
|
return this.fetchMarketMatches(params);
|
|
168
169
|
}
|
|
169
170
|
// -----------------------------------------------------------------------
|
|
@@ -235,7 +236,7 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
235
236
|
}
|
|
236
237
|
/** @deprecated Use {@link fetchRelatedMarkets} instead. */
|
|
237
238
|
async fetchHedges(params) {
|
|
238
|
-
|
|
239
|
+
logger_1.logger.warn('fetchHedges is deprecated, use fetchRelatedMarkets instead');
|
|
239
240
|
return this.fetchRelatedMarkets(params);
|
|
240
241
|
}
|
|
241
242
|
// -----------------------------------------------------------------------
|
|
@@ -269,12 +270,12 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
269
270
|
}
|
|
270
271
|
/** @deprecated Use {@link fetchMatchedMarkets} instead. */
|
|
271
272
|
async fetchMatchedPrices(params) {
|
|
272
|
-
|
|
273
|
+
logger_1.logger.warn('fetchMatchedPrices is deprecated, use fetchMatchedMarkets instead');
|
|
273
274
|
return this.fetchMatchedMarkets(params);
|
|
274
275
|
}
|
|
275
276
|
/** @deprecated Use {@link fetchMatchedMarkets} instead. */
|
|
276
277
|
async fetchArbitrage(params) {
|
|
277
|
-
|
|
278
|
+
logger_1.logger.warn('fetchArbitrage is deprecated, use fetchMatchedPrices instead');
|
|
278
279
|
return this.fetchArbitrageInternal(params);
|
|
279
280
|
}
|
|
280
281
|
async fetchArbitrageInternal(params) {
|
|
@@ -288,7 +289,7 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
288
289
|
// callers are not silently given stale N+1 data.
|
|
289
290
|
const status = error?.status ?? error?.response?.status;
|
|
290
291
|
if (status === 404 || status === 501) {
|
|
291
|
-
|
|
292
|
+
logger_1.logger.warn('Router: bulk arbitrage endpoint unavailable, falling back to N+1 approach');
|
|
292
293
|
return this.fetchArbitrageFallback(params);
|
|
293
294
|
}
|
|
294
295
|
throw error;
|
package/dist/server/app.js
CHANGED
|
@@ -14,6 +14,7 @@ const ws_handler_1 = require("./ws-handler");
|
|
|
14
14
|
Object.defineProperty(exports, "createWebSocketHandler", { enumerable: true, get: function () { return ws_handler_1.createWebSocketHandler; } });
|
|
15
15
|
const exchange_factory_1 = require("./exchange-factory");
|
|
16
16
|
const errors_1 = require("../errors");
|
|
17
|
+
const logger_1 = require("../utils/logger");
|
|
17
18
|
function loadMethodVerbs() {
|
|
18
19
|
const candidates = [
|
|
19
20
|
path_1.default.join(__dirname, "method-verbs.json"),
|
|
@@ -25,8 +26,7 @@ function loadMethodVerbs() {
|
|
|
25
26
|
const raw = fs_1.default.readFileSync(file, "utf8");
|
|
26
27
|
return JSON.parse(raw);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
"POST continues to work. Rebuild pmxt-core to regenerate.");
|
|
29
|
+
logger_1.logger.warn("method-verbs.json not found — GET /api/:exchange/:method disabled. POST continues to work. Rebuild pmxt-core to regenerate.");
|
|
30
30
|
return {};
|
|
31
31
|
}
|
|
32
32
|
const METHOD_VERBS = loadMethodVerbs();
|
|
@@ -290,10 +290,7 @@ function createApp(options = {}) {
|
|
|
290
290
|
});
|
|
291
291
|
// Error handler
|
|
292
292
|
app.use((error, req, res, next) => {
|
|
293
|
-
|
|
294
|
-
if (error.stack) {
|
|
295
|
-
console.error(error.stack);
|
|
296
|
-
}
|
|
293
|
+
logger_1.logger.error('API Error', { message: error.message, stack: error.stack });
|
|
297
294
|
// Handle BaseError instances with full context
|
|
298
295
|
if (error instanceof errors_1.BaseError) {
|
|
299
296
|
const errorResponse = {
|
package/dist/server/openapi.yaml
CHANGED
|
@@ -684,7 +684,10 @@ paths:
|
|
|
684
684
|
properties:
|
|
685
685
|
data:
|
|
686
686
|
$ref: '#/components/schemas/OrderBook'
|
|
687
|
-
description:
|
|
687
|
+
description: >-
|
|
688
|
+
Fetch the order book (bids/asks) for a specific outcome. Supports live and historical queries. For historical
|
|
689
|
+
data, pass `since` to get a single snapshot, or `since` + `until` to get an array of fully reconstructed L2
|
|
690
|
+
books from the archive. Range queries return up to `limit` snapshots (default 100, max 1000).
|
|
688
691
|
'/api/{exchange}/fetchOrderBooks':
|
|
689
692
|
post:
|
|
690
693
|
summary: Fetch Order Books
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logger for pmxt-core.
|
|
3
|
+
*
|
|
4
|
+
* Thin abstraction over console that:
|
|
5
|
+
* - Attaches a `[pmxt]` prefix for easy filtering
|
|
6
|
+
* - Supports log levels (debug, info, warn, error)
|
|
7
|
+
* - Respects a configurable level threshold
|
|
8
|
+
* - Can be swapped for a real transport (pino, winston) later
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
11
|
+
export declare const logger: {
|
|
12
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
13
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
14
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
15
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
16
|
+
setLevel(level: LogLevel): void;
|
|
17
|
+
getLevel(): LogLevel;
|
|
18
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Structured logger for pmxt-core.
|
|
4
|
+
*
|
|
5
|
+
* Thin abstraction over console that:
|
|
6
|
+
* - Attaches a `[pmxt]` prefix for easy filtering
|
|
7
|
+
* - Supports log levels (debug, info, warn, error)
|
|
8
|
+
* - Respects a configurable level threshold
|
|
9
|
+
* - Can be swapped for a real transport (pino, winston) later
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.logger = void 0;
|
|
13
|
+
const LEVEL_PRIORITY = {
|
|
14
|
+
debug: 0,
|
|
15
|
+
info: 1,
|
|
16
|
+
warn: 2,
|
|
17
|
+
error: 3,
|
|
18
|
+
silent: 4,
|
|
19
|
+
};
|
|
20
|
+
let currentLevel = process.env.PMXT_LOG_LEVEL || 'info';
|
|
21
|
+
function shouldLog(level) {
|
|
22
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[currentLevel];
|
|
23
|
+
}
|
|
24
|
+
exports.logger = {
|
|
25
|
+
debug(message, context) {
|
|
26
|
+
if (!shouldLog('debug'))
|
|
27
|
+
return;
|
|
28
|
+
if (context) {
|
|
29
|
+
console.debug(`[pmxt] ${message}`, context);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.debug(`[pmxt] ${message}`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
info(message, context) {
|
|
36
|
+
if (!shouldLog('info'))
|
|
37
|
+
return;
|
|
38
|
+
if (context) {
|
|
39
|
+
console.info(`[pmxt] ${message}`, context);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.info(`[pmxt] ${message}`);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
warn(message, context) {
|
|
46
|
+
if (!shouldLog('warn'))
|
|
47
|
+
return;
|
|
48
|
+
if (context) {
|
|
49
|
+
console.warn(`[pmxt] ${message}`, context);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.warn(`[pmxt] ${message}`);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
error(message, context) {
|
|
56
|
+
if (!shouldLog('error'))
|
|
57
|
+
return;
|
|
58
|
+
if (context) {
|
|
59
|
+
console.error(`[pmxt] ${message}`, context);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.error(`[pmxt] ${message}`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
setLevel(level) {
|
|
66
|
+
currentLevel = level;
|
|
67
|
+
},
|
|
68
|
+
getLevel() {
|
|
69
|
+
return currentLevel;
|
|
70
|
+
},
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.43.
|
|
3
|
+
"version": "2.43.8",
|
|
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.
|
|
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.
|
|
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",
|
|
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",
|