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