pmxt-core 2.40.5 → 2.41.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.
- package/API_REFERENCE.md +1 -1
- package/dist/exchanges/baozi/websocket.js +7 -2
- 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/errors.js +9 -0
- package/dist/exchanges/polymarket/index.js +5 -5
- package/dist/exchanges/polymarket/utils.js +9 -19
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/router/Router.js +4 -1
- package/dist/server/app.js +4 -8
- package/dist/server/utils/lock-file.js +4 -2
- package/dist/server/utils/port-manager.js +2 -2
- package/package.json +3 -3
package/API_REFERENCE.md
CHANGED
|
@@ -314,7 +314,7 @@ Both Polymarket and Kalshi support authenticated trading operations. You must pr
|
|
|
314
314
|
|
|
315
315
|
### Polymarket Authentication
|
|
316
316
|
|
|
317
|
-
Requires your **Polygon Private Key**. See [Setup Guide](https://github.com/
|
|
317
|
+
Requires your **Polygon Private Key**. See [Setup Guide](https://github.com/pmxt-dev/pmxt/blob/main/docs/SETUP_POLYMARKET.md) for details.
|
|
318
318
|
|
|
319
319
|
```typescript
|
|
320
320
|
import pmxt from 'pmxtjs';
|
|
@@ -44,8 +44,13 @@ class BaoziWebSocket {
|
|
|
44
44
|
};
|
|
45
45
|
this.resolveOrderBook(marketPubkey, orderBook);
|
|
46
46
|
}
|
|
47
|
-
catch {
|
|
48
|
-
//
|
|
47
|
+
catch (error) {
|
|
48
|
+
// Reject pending resolvers so callers fail fast
|
|
49
|
+
const rejecters = this.orderBookResolvers.get(marketPubkey) || [];
|
|
50
|
+
this.orderBookResolvers.set(marketPubkey, []);
|
|
51
|
+
for (const r of rejecters) {
|
|
52
|
+
r.reject(error instanceof Error ? error : new Error(String(error)));
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
}, 'confirmed');
|
|
51
56
|
this.subscriptions.set(marketPubkey, subId);
|
|
@@ -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-13T15:31:08.990Z
|
|
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-13T15:31:08.990Z
|
|
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-13T15:31:09.023Z
|
|
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-13T15:31:09.023Z
|
|
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-13T15:31:09.035Z
|
|
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-13T15:31:09.035Z
|
|
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-13T15:31:09.039Z
|
|
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-13T15:31:09.039Z
|
|
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-13T15:31:08.995Z
|
|
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-13T15:31:08.995Z
|
|
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-13T15:31:09.007Z
|
|
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-13T15:31:09.007Z
|
|
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-13T15:31:09.005Z
|
|
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-13T15:31:09.005Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -58,6 +58,15 @@ class PolymarketErrorMapper extends error_mapper_1.ErrorMapper {
|
|
|
58
58
|
*/
|
|
59
59
|
mapBadRequestError(message, data) {
|
|
60
60
|
const lowerMessage = message.toLowerCase();
|
|
61
|
+
// Signature type / maker address mismatch — the most common auth
|
|
62
|
+
// misconfiguration. Surface actionable guidance so users don't have
|
|
63
|
+
// to guess which signature_type to use.
|
|
64
|
+
if (lowerMessage.includes('maker address not allowed') ||
|
|
65
|
+
lowerMessage.includes('deposit wallet')) {
|
|
66
|
+
return new errors_1.AuthenticationError(`${message}. Your signature_type may be wrong for this account. ` +
|
|
67
|
+
`Try signature_type='deposit_wallet' (newest accounts), ` +
|
|
68
|
+
`'gnosis_safe' (2023-era accounts), or 'polyproxy' (legacy accounts).`, this.exchangeName);
|
|
69
|
+
}
|
|
61
70
|
// Authentication errors surfaced as 400
|
|
62
71
|
if (lowerMessage.includes('api key') ||
|
|
63
72
|
lowerMessage.includes('proxy') ||
|
|
@@ -413,11 +413,11 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
413
413
|
const msg = String(ordersError?.message ?? ordersError);
|
|
414
414
|
if (msg.includes('is not iterable')) {
|
|
415
415
|
throw new errors_1.AuthenticationError('Polymarket CLOB rejected the request to list open orders. ' +
|
|
416
|
-
'This usually means
|
|
417
|
-
'
|
|
418
|
-
'
|
|
419
|
-
'
|
|
420
|
-
'
|
|
416
|
+
'This usually means your signature_type is wrong for this account, ' +
|
|
417
|
+
'or the wallet has not completed Polymarket onboarding. ' +
|
|
418
|
+
"Try signature_type='deposit_wallet' (newest accounts), " +
|
|
419
|
+
"'gnosis_safe' (2023-era accounts), or 'polyproxy' (legacy accounts). " +
|
|
420
|
+
'If none work, visit https://polymarket.com to complete account setup.', 'Polymarket');
|
|
421
421
|
}
|
|
422
422
|
// Unexpected failure — surface through the standard mapper.
|
|
423
423
|
throw ordersError;
|
|
@@ -30,7 +30,7 @@ function mapMarketToUnified(event, market, options = {}) {
|
|
|
30
30
|
clobTokenIds = typeof market.clobTokenIds === 'string' ? JSON.parse(market.clobTokenIds) : (market.clobTokenIds || []);
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
|
-
|
|
33
|
+
console.warn(`Error parsing clobTokenIds for market ${market.id}:`, e);
|
|
34
34
|
}
|
|
35
35
|
// Extract candidate/option name from market question for better outcome labels
|
|
36
36
|
let candidateName = null;
|
|
@@ -145,15 +145,10 @@ async function paginateParallel(url, params, http, maxResults = 10000) {
|
|
|
145
145
|
}
|
|
146
146
|
// 3. Fetch remaining pages in parallel
|
|
147
147
|
const remainingPages = await Promise.all(offsets.map(async (offset) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return res.data || [];
|
|
153
|
-
}
|
|
154
|
-
catch (e) {
|
|
155
|
-
return []; // Swallow individual page errors to be robust
|
|
156
|
-
}
|
|
148
|
+
const res = await http.get(url, {
|
|
149
|
+
params: { ...params, limit: PAGE_SIZE, offset }
|
|
150
|
+
});
|
|
151
|
+
return res.data;
|
|
157
152
|
}));
|
|
158
153
|
return [firstPage, ...remainingPages].flat();
|
|
159
154
|
}
|
|
@@ -183,15 +178,10 @@ async function paginateSearchParallel(url, params, maxResults = 10000, http) {
|
|
|
183
178
|
pageNumbers.push(i);
|
|
184
179
|
}
|
|
185
180
|
const remainingPages = await Promise.all(pageNumbers.map(async (pageNum) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return res.data?.events || [];
|
|
191
|
-
}
|
|
192
|
-
catch (e) {
|
|
193
|
-
return []; // Swallow individual page errors to be robust
|
|
194
|
-
}
|
|
181
|
+
const res = await http.get(url, {
|
|
182
|
+
params: { ...params, page: pageNum }
|
|
183
|
+
});
|
|
184
|
+
return res.data?.events;
|
|
195
185
|
}));
|
|
196
186
|
return [firstPageEvents, ...remainingPages].flat();
|
|
197
187
|
}
|
|
@@ -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-13T15:31:09.028Z
|
|
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-13T15:31:09.028Z
|
|
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
|
@@ -156,7 +156,10 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
156
156
|
*/
|
|
157
157
|
async fetchMarketMatchesBrowse(params) {
|
|
158
158
|
const results = await this.client.browseMarketMatches(params);
|
|
159
|
-
|
|
159
|
+
if (!Array.isArray(results)) {
|
|
160
|
+
throw new Error(`browseMarketMatches returned unexpected type '${typeof results}'`);
|
|
161
|
+
}
|
|
162
|
+
return results;
|
|
160
163
|
}
|
|
161
164
|
/** @deprecated Use {@link fetchMarketMatches} instead. */
|
|
162
165
|
async fetchMatches(params) {
|
package/dist/server/app.js
CHANGED
|
@@ -20,14 +20,10 @@ function loadMethodVerbs() {
|
|
|
20
20
|
path_1.default.join(__dirname, "../../src/server/method-verbs.json"),
|
|
21
21
|
];
|
|
22
22
|
for (const file of candidates) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Fall through to the next candidate.
|
|
30
|
-
}
|
|
23
|
+
if (!fs_1.default.existsSync(file))
|
|
24
|
+
continue;
|
|
25
|
+
const raw = fs_1.default.readFileSync(file, "utf8");
|
|
26
|
+
return JSON.parse(raw);
|
|
31
27
|
}
|
|
32
28
|
console.warn("[pmxt-core] method-verbs.json not found — GET /api/:exchange/:method disabled. " +
|
|
33
29
|
"POST continues to work. Rebuild pmxt-core to regenerate.");
|
|
@@ -47,14 +47,14 @@ class PortManager {
|
|
|
47
47
|
throw new Error(`No available ports found in range ${startPort}-${startPort + 100}`);
|
|
48
48
|
}
|
|
49
49
|
isPortAvailable(port) {
|
|
50
|
-
return new Promise((resolve) => {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
51
|
const server = net.createServer();
|
|
52
52
|
server.once('error', (err) => {
|
|
53
53
|
if (err.code === 'EADDRINUSE') {
|
|
54
54
|
resolve(false);
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
|
|
57
|
+
reject(err);
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
server.once('listening', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.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,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.
|
|
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.
|
|
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.41.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.41.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",
|