pmxt-core 2.35.6 → 2.35.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/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.d.ts +2 -2
- package/dist/exchanges/polymarket/auth.js +14 -3
- package/dist/exchanges/polymarket/errors.d.ts +18 -3
- package/dist/exchanges/polymarket/errors.js +48 -15
- package/dist/exchanges/polymarket/index.d.ts +1 -1
- package/dist/exchanges/polymarket/index.js +13 -15
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/package.json +4 -4
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.810Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.810Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.852Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.852Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.865Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.865Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.871Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.871Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.818Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.818Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.832Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.832Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.829Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.829Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ClobClient } from '@polymarket/clob-client';
|
|
2
|
-
import type { ApiKeyCreds } from '@polymarket/clob-client';
|
|
1
|
+
import { ClobClient } from '@polymarket/clob-client-v2';
|
|
2
|
+
import type { ApiKeyCreds } from '@polymarket/clob-client-v2';
|
|
3
3
|
import { ExchangeCredentials } from '../../BaseExchange';
|
|
4
4
|
/**
|
|
5
5
|
* Manages Polymarket authentication and CLOB client initialization.
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PolymarketAuth = void 0;
|
|
7
|
-
const
|
|
7
|
+
const clob_client_v2_1 = require("@polymarket/clob-client-v2");
|
|
8
8
|
const ethers_1 = require("ethers");
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const errors_1 = require("./errors");
|
|
@@ -68,7 +68,11 @@ class PolymarketAuth {
|
|
|
68
68
|
return this.apiCreds;
|
|
69
69
|
}
|
|
70
70
|
// Otherwise, derive/create them using L1 auth
|
|
71
|
-
const l1Client = new
|
|
71
|
+
const l1Client = new clob_client_v2_1.ClobClient({
|
|
72
|
+
host: POLYMARKET_HOST,
|
|
73
|
+
chain: POLYGON_CHAIN_ID,
|
|
74
|
+
signer: this.signer,
|
|
75
|
+
});
|
|
72
76
|
// Robust derivation strategy:
|
|
73
77
|
// 1. Try to DERIVE existing credentials first (most common case).
|
|
74
78
|
// 2. If that fails (e.g. 404 or 400), try to CREATE new ones.
|
|
@@ -219,7 +223,14 @@ class PolymarketAuth {
|
|
|
219
223
|
const finalSignatureType = signatureType;
|
|
220
224
|
// Create L2-authenticated client
|
|
221
225
|
// console.log(`[PolymarketAuth] Initializing ClobClient | Signer: ${signerAddress} | Funder: ${finalProxyAddress} | SigType: ${finalSignatureType}`);
|
|
222
|
-
this.clobClient = new
|
|
226
|
+
this.clobClient = new clob_client_v2_1.ClobClient({
|
|
227
|
+
host: POLYMARKET_HOST,
|
|
228
|
+
chain: POLYGON_CHAIN_ID,
|
|
229
|
+
signer: this.signer,
|
|
230
|
+
creds: apiCreds,
|
|
231
|
+
signatureType: finalSignatureType,
|
|
232
|
+
funderAddress: finalProxyAddress,
|
|
233
|
+
});
|
|
223
234
|
return this.clobClient;
|
|
224
235
|
}
|
|
225
236
|
/**
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import { ErrorMapper } from '../../utils/error-mapper';
|
|
2
|
-
import { BadRequest } from '../../errors';
|
|
2
|
+
import { BaseError, BadRequest } from '../../errors';
|
|
3
3
|
/**
|
|
4
4
|
* Polymarket-specific error mapper
|
|
5
5
|
*
|
|
6
|
-
* Handles CLOB
|
|
6
|
+
* Handles CLOB V2 error patterns. V2 returns `{ "error": "<message>" }` on all
|
|
7
|
+
* error responses. The base ErrorMapper already extracts `data.error` when it is
|
|
8
|
+
* a string, so no extractErrorMessage override is needed.
|
|
9
|
+
*
|
|
10
|
+
* V2-specific status codes handled here:
|
|
11
|
+
* 425 Too Early -- matching engine restarting (retryable)
|
|
12
|
+
* 503 Service Unavailable -- exchange paused / cancel-only mode
|
|
7
13
|
*/
|
|
8
14
|
export declare class PolymarketErrorMapper extends ErrorMapper {
|
|
9
15
|
constructor();
|
|
10
16
|
/**
|
|
11
17
|
* Override to handle Polymarket-specific error patterns
|
|
18
|
+
*
|
|
19
|
+
* V2 returns `{ "error": "<message>" }` as a plain string. The base class
|
|
20
|
+
* handles this natively via `data.error` (string path). We keep the legacy
|
|
21
|
+
* `errorMsg` path for any residual V1 responses (order submission still
|
|
22
|
+
* returns `errorMsg` in some batch flows).
|
|
12
23
|
*/
|
|
13
24
|
protected extractErrorMessage(error: any): string;
|
|
14
25
|
/**
|
|
15
|
-
* Override to
|
|
26
|
+
* Override to handle V2 status code 425 (Too Early -- matching engine restarting)
|
|
27
|
+
*/
|
|
28
|
+
protected mapByStatusCode(status: number, message: string, data: any, response?: any): BaseError;
|
|
29
|
+
/**
|
|
30
|
+
* Override to detect Polymarket-specific error patterns in 400 responses
|
|
16
31
|
*/
|
|
17
32
|
protected mapBadRequestError(message: string, data: any): BadRequest;
|
|
18
33
|
}
|
|
@@ -10,7 +10,13 @@ const errors_1 = require("../../errors");
|
|
|
10
10
|
/**
|
|
11
11
|
* Polymarket-specific error mapper
|
|
12
12
|
*
|
|
13
|
-
* Handles CLOB
|
|
13
|
+
* Handles CLOB V2 error patterns. V2 returns `{ "error": "<message>" }` on all
|
|
14
|
+
* error responses. The base ErrorMapper already extracts `data.error` when it is
|
|
15
|
+
* a string, so no extractErrorMessage override is needed.
|
|
16
|
+
*
|
|
17
|
+
* V2-specific status codes handled here:
|
|
18
|
+
* 425 Too Early -- matching engine restarting (retryable)
|
|
19
|
+
* 503 Service Unavailable -- exchange paused / cancel-only mode
|
|
14
20
|
*/
|
|
15
21
|
class PolymarketErrorMapper extends error_mapper_1.ErrorMapper {
|
|
16
22
|
constructor() {
|
|
@@ -18,38 +24,65 @@ class PolymarketErrorMapper extends error_mapper_1.ErrorMapper {
|
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* Override to handle Polymarket-specific error patterns
|
|
27
|
+
*
|
|
28
|
+
* V2 returns `{ "error": "<message>" }` as a plain string. The base class
|
|
29
|
+
* handles this natively via `data.error` (string path). We keep the legacy
|
|
30
|
+
* `errorMsg` path for any residual V1 responses (order submission still
|
|
31
|
+
* returns `errorMsg` in some batch flows).
|
|
21
32
|
*/
|
|
22
33
|
extractErrorMessage(error) {
|
|
23
|
-
// Handle Polymarket CLOB errors
|
|
24
34
|
if (axios_1.default.isAxiosError(error) && error.response?.data) {
|
|
25
35
|
const data = error.response.data;
|
|
26
|
-
//
|
|
36
|
+
// V2 format: { "error": "<message>" }
|
|
37
|
+
if (typeof data.error === 'string') {
|
|
38
|
+
return data.error;
|
|
39
|
+
}
|
|
40
|
+
// Legacy V1 format: { "errorMsg": "<message>" }
|
|
27
41
|
if (data.errorMsg) {
|
|
28
42
|
return data.errorMsg;
|
|
29
43
|
}
|
|
30
|
-
// Also check standard error paths
|
|
31
|
-
if (data.error?.message) {
|
|
32
|
-
return data.error.message;
|
|
33
|
-
}
|
|
34
|
-
if (data.message) {
|
|
35
|
-
return data.message;
|
|
36
|
-
}
|
|
37
44
|
}
|
|
38
45
|
return super.extractErrorMessage(error);
|
|
39
46
|
}
|
|
40
47
|
/**
|
|
41
|
-
* Override to
|
|
48
|
+
* Override to handle V2 status code 425 (Too Early -- matching engine restarting)
|
|
49
|
+
*/
|
|
50
|
+
mapByStatusCode(status, message, data, response) {
|
|
51
|
+
if (status === 425) {
|
|
52
|
+
return new errors_1.ExchangeNotAvailable(`Matching engine restarting: ${message}`, this.exchangeName);
|
|
53
|
+
}
|
|
54
|
+
return super.mapByStatusCode(status, message, data, response);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Override to detect Polymarket-specific error patterns in 400 responses
|
|
42
58
|
*/
|
|
43
59
|
mapBadRequestError(message, data) {
|
|
44
60
|
const lowerMessage = message.toLowerCase();
|
|
45
|
-
//
|
|
61
|
+
// Authentication errors surfaced as 400
|
|
46
62
|
if (lowerMessage.includes('api key') ||
|
|
47
63
|
lowerMessage.includes('proxy') ||
|
|
48
|
-
lowerMessage.includes('signature type')
|
|
64
|
+
lowerMessage.includes('signature type') ||
|
|
65
|
+
lowerMessage.includes('l1 request headers')) {
|
|
49
66
|
return new errors_1.AuthenticationError(message, this.exchangeName);
|
|
50
67
|
}
|
|
51
|
-
//
|
|
52
|
-
if (lowerMessage.includes('
|
|
68
|
+
// Trading disabled / cancel-only mode -- exchange-level unavailability
|
|
69
|
+
if (lowerMessage.includes('trading is currently disabled') ||
|
|
70
|
+
lowerMessage.includes('trading is currently cancel-only')) {
|
|
71
|
+
return new errors_1.ExchangeNotAvailable(message, this.exchangeName);
|
|
72
|
+
}
|
|
73
|
+
// Address banned or restricted
|
|
74
|
+
if (lowerMessage.includes('address banned') ||
|
|
75
|
+
lowerMessage.includes('closed only mode')) {
|
|
76
|
+
return new errors_1.PermissionDenied(message, this.exchangeName);
|
|
77
|
+
}
|
|
78
|
+
// Order validation errors
|
|
79
|
+
if (lowerMessage.includes('tick size') ||
|
|
80
|
+
lowerMessage.includes('post-only order') ||
|
|
81
|
+
lowerMessage.includes('duplicated') ||
|
|
82
|
+
lowerMessage.includes('size lower than') ||
|
|
83
|
+
lowerMessage.includes('invalid expiration') ||
|
|
84
|
+
lowerMessage.includes('fok order') ||
|
|
85
|
+
lowerMessage.includes('fak order')) {
|
|
53
86
|
return new errors_1.InvalidOrder(message, this.exchangeName);
|
|
54
87
|
}
|
|
55
88
|
// Fall back to base error mapping
|
|
@@ -63,7 +63,7 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
63
63
|
* Ensure authentication is initialized before trading operations.
|
|
64
64
|
*/
|
|
65
65
|
private ensureAuth;
|
|
66
|
-
/** Fetch on-chain
|
|
66
|
+
/** Fetch on-chain pUSD balance on Polygon for any address without requiring credentials. */
|
|
67
67
|
private getAddressOnChainBalance;
|
|
68
68
|
private ensureWs;
|
|
69
69
|
private fetchWatchedAddressActivity;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PolymarketExchange = exports.buildPolymarketTradesActivity = exports.POLYMARKET_DEFAULT_SUBSCRIPTION = void 0;
|
|
4
|
-
const
|
|
4
|
+
const clob_client_v2_1 = require("@polymarket/clob-client-v2");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const BaseExchange_1 = require("../../BaseExchange");
|
|
7
7
|
const errors_1 = require("../../errors");
|
|
@@ -152,8 +152,8 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
152
152
|
try {
|
|
153
153
|
const auth = this.ensureAuth();
|
|
154
154
|
const client = await auth.getClobClient();
|
|
155
|
-
const side = params.side.toUpperCase() === 'BUY' ?
|
|
156
|
-
const price = params.price || (side ===
|
|
155
|
+
const side = params.side.toUpperCase() === 'BUY' ? clob_client_v2_1.Side.BUY : clob_client_v2_1.Side.SELL;
|
|
156
|
+
const price = params.price || (side === clob_client_v2_1.Side.BUY ? 0.99 : 0.01);
|
|
157
157
|
const tickSize = params.tickSize ? params.tickSize.toString() : undefined;
|
|
158
158
|
const orderArgs = {
|
|
159
159
|
tokenID: params.outcomeId,
|
|
@@ -161,8 +161,6 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
161
161
|
side,
|
|
162
162
|
size: params.amount,
|
|
163
163
|
};
|
|
164
|
-
if (params.fee != null)
|
|
165
|
-
orderArgs.feeRateBps = params.fee;
|
|
166
164
|
const options = {};
|
|
167
165
|
if (tickSize)
|
|
168
166
|
options.tickSize = tickSize;
|
|
@@ -188,8 +186,8 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
188
186
|
if (!response || !response.success) {
|
|
189
187
|
throw new Error(`${response?.errorMsg || 'Order submission failed'} (Response: ${JSON.stringify(response)})`);
|
|
190
188
|
}
|
|
191
|
-
const side = built.params.side.toUpperCase() === 'BUY' ?
|
|
192
|
-
const price = built.params.price || (side ===
|
|
189
|
+
const side = built.params.side.toUpperCase() === 'BUY' ? clob_client_v2_1.Side.BUY : clob_client_v2_1.Side.SELL;
|
|
190
|
+
const price = built.params.price || (side === clob_client_v2_1.Side.BUY ? 0.99 : 0.01);
|
|
193
191
|
return {
|
|
194
192
|
id: response.orderID,
|
|
195
193
|
marketId: built.params.marketId,
|
|
@@ -334,7 +332,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
334
332
|
let clobBalanceAvailable = false;
|
|
335
333
|
try {
|
|
336
334
|
const balRes = await client.getBalanceAllowance({
|
|
337
|
-
asset_type:
|
|
335
|
+
asset_type: clob_client_v2_1.AssetType.COLLATERAL,
|
|
338
336
|
});
|
|
339
337
|
if (balRes && typeof balRes.balance === 'string') {
|
|
340
338
|
const rawBalance = parseFloat(balRes.balance);
|
|
@@ -378,7 +376,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
378
376
|
const openOrders = await client.getOpenOrders({});
|
|
379
377
|
if (Array.isArray(openOrders)) {
|
|
380
378
|
for (const order of openOrders) {
|
|
381
|
-
if (order.side ===
|
|
379
|
+
if (order.side === clob_client_v2_1.Side.BUY) {
|
|
382
380
|
const remainingSize = parseFloat(order.original_size) - parseFloat(order.size_matched);
|
|
383
381
|
const price = parseFloat(order.price);
|
|
384
382
|
locked += remainingSize * price;
|
|
@@ -528,7 +526,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
528
526
|
}
|
|
529
527
|
return this.auth;
|
|
530
528
|
}
|
|
531
|
-
/** Fetch on-chain
|
|
529
|
+
/** Fetch on-chain pUSD balance on Polygon for any address without requiring credentials. */
|
|
532
530
|
async getAddressOnChainBalance(address) {
|
|
533
531
|
const { ethers } = require('ethers');
|
|
534
532
|
if (!ethers.utils.isAddress(address)) {
|
|
@@ -540,14 +538,14 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
540
538
|
chainId: 137,
|
|
541
539
|
name: 'matic',
|
|
542
540
|
});
|
|
543
|
-
const
|
|
544
|
-
const
|
|
541
|
+
const pusdAddress = '0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB'; // pUSD (Polymarket USD)
|
|
542
|
+
const erc20Abi = [
|
|
545
543
|
'function balanceOf(address) view returns (uint256)',
|
|
546
544
|
'function decimals() view returns (uint8)',
|
|
547
545
|
];
|
|
548
|
-
const
|
|
549
|
-
const rawBalance = await
|
|
550
|
-
const decimals = await
|
|
546
|
+
const pusdContract = new ethers.Contract(pusdAddress, erc20Abi, provider);
|
|
547
|
+
const rawBalance = await pusdContract.balanceOf(address);
|
|
548
|
+
const decimals = await pusdContract.decimals();
|
|
551
549
|
const total = parseFloat(ethers.utils.formatUnits(rawBalance, decimals));
|
|
552
550
|
return [{ currency: 'USDC', total, available: total, locked: 0 }];
|
|
553
551
|
}
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-04-27T11:35:58.858Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-04-27T11:35:58.858Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.35.
|
|
3
|
+
"version": "2.35.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.35.
|
|
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.35.
|
|
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.35.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.35.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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@limitless-exchange/sdk": "^1.0.2",
|
|
49
49
|
"@opinion-labs/opinion-clob-sdk": "^0.6.0",
|
|
50
|
-
"@polymarket/clob-client": "^
|
|
50
|
+
"@polymarket/clob-client-v2": "^1.0.0",
|
|
51
51
|
"@prob/clob": "0.5.0",
|
|
52
52
|
"@solana/web3.js": "^1.98.4",
|
|
53
53
|
"@types/express": "^5.0.6",
|