pmxt-core 2.37.14 → 2.39.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 +14 -14
- package/dist/BaseExchange.js +19 -19
- package/dist/exchanges/baozi/index.d.ts +2 -2
- package/dist/exchanges/baozi/index.js +5 -5
- package/dist/exchanges/hyperliquid/auth.d.ts +30 -0
- package/dist/exchanges/hyperliquid/auth.js +145 -0
- package/dist/exchanges/hyperliquid/config.d.ts +17 -0
- package/dist/exchanges/hyperliquid/config.js +28 -0
- package/dist/exchanges/hyperliquid/errors.d.ts +18 -0
- package/dist/exchanges/hyperliquid/errors.js +61 -0
- package/dist/exchanges/hyperliquid/fetcher.d.ts +140 -0
- package/dist/exchanges/hyperliquid/fetcher.js +137 -0
- package/dist/exchanges/hyperliquid/index.d.ts +31 -0
- package/dist/exchanges/hyperliquid/index.js +219 -0
- package/dist/exchanges/hyperliquid/normalizer.d.ts +18 -0
- package/dist/exchanges/hyperliquid/normalizer.js +339 -0
- package/dist/exchanges/hyperliquid/utils.d.ts +41 -0
- package/dist/exchanges/hyperliquid/utils.js +76 -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 +6 -6
- package/dist/exchanges/kalshi/index.js +14 -14
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/limitless/index.d.ts +5 -5
- package/dist/exchanges/limitless/index.js +15 -12
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/myriad/index.d.ts +5 -5
- package/dist/exchanges/myriad/index.js +14 -14
- package/dist/exchanges/myriad/websocket.d.ts +2 -2
- package/dist/exchanges/myriad/websocket.js +12 -12
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/index.d.ts +4 -4
- package/dist/exchanges/opinion/index.js +9 -9
- 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/index.d.ts +6 -6
- package/dist/exchanges/polymarket/index.js +19 -19
- package/dist/exchanges/polymarket/websocket.d.ts +3 -3
- package/dist/exchanges/polymarket/websocket.js +21 -21
- package/dist/exchanges/polymarket_us/index.d.ts +3 -3
- package/dist/exchanges/polymarket_us/index.js +7 -7
- package/dist/exchanges/polymarket_us/websocket.d.ts +2 -2
- package/dist/exchanges/polymarket_us/websocket.js +6 -6
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/exchanges/probable/index.d.ts +4 -4
- package/dist/exchanges/probable/index.js +9 -9
- package/dist/exchanges/smarkets/index.d.ts +2 -2
- package/dist/exchanges/smarkets/index.js +5 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -1
- package/dist/router/Router.d.ts +1 -1
- package/dist/router/Router.js +3 -3
- package/dist/server/exchange-factory.js +6 -0
- package/dist/server/method-verbs.json +7 -7
- package/dist/server/openapi.yaml +18 -3
- package/package.json +4 -3
|
@@ -149,19 +149,19 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
149
149
|
.map((raw) => this.normalizer.normalizeEvent(raw))
|
|
150
150
|
.filter((e) => e !== null);
|
|
151
151
|
}
|
|
152
|
-
async fetchOHLCV(
|
|
153
|
-
const slug = await this.resolveSlug(
|
|
152
|
+
async fetchOHLCV(outcomeId, params) {
|
|
153
|
+
const slug = await this.resolveSlug(outcomeId);
|
|
154
154
|
const rawPrices = await this.fetcher.fetchRawOHLCV(slug, params);
|
|
155
155
|
return this.normalizer.normalizeOHLCV(rawPrices, params);
|
|
156
156
|
}
|
|
157
|
-
async fetchOrderBook(
|
|
158
|
-
const slug = await this.resolveSlug(
|
|
157
|
+
async fetchOrderBook(outcomeId, side) {
|
|
158
|
+
const slug = await this.resolveSlug(outcomeId);
|
|
159
159
|
const rawOrderBook = await this.fetcher.fetchRawOrderBook(slug);
|
|
160
|
-
const orderBook = this.normalizer.normalizeOrderBook(rawOrderBook,
|
|
160
|
+
const orderBook = this.normalizer.normalizeOrderBook(rawOrderBook, outcomeId);
|
|
161
161
|
// The Limitless API always returns the Yes-side order book regardless
|
|
162
162
|
// of which token is queried. If the caller asked for the No token,
|
|
163
163
|
// flip: noBid = 1 - yesAsk, noAsk = 1 - yesBid.
|
|
164
|
-
const isNoToken = side === 'no' || (!side && await this.isNoOutcome(
|
|
164
|
+
const isNoToken = side === 'no' || (!side && await this.isNoOutcome(outcomeId, slug));
|
|
165
165
|
if (isNoToken) {
|
|
166
166
|
return {
|
|
167
167
|
bids: orderBook.asks.map((level) => ({ price: 1 - level.price, size: level.size }))
|
|
@@ -187,12 +187,13 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
187
187
|
}
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
190
|
-
async fetchTrades(
|
|
190
|
+
async fetchTrades(outcomeId, params) {
|
|
191
191
|
if ('resolution' in params && params.resolution !== undefined) {
|
|
192
192
|
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
193
193
|
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
194
194
|
}
|
|
195
|
-
const
|
|
195
|
+
const slug = await this.resolveSlug(outcomeId);
|
|
196
|
+
const rawTrades = await this.fetcher.fetchRawTrades(slug, params);
|
|
196
197
|
return rawTrades.map((raw, i) => this.normalizer.normalizeTrade(raw, i));
|
|
197
198
|
}
|
|
198
199
|
async fetchMyTrades(params) {
|
|
@@ -358,13 +359,15 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
358
359
|
// ------------------------------------------------------------------------
|
|
359
360
|
// WebSocket
|
|
360
361
|
// ------------------------------------------------------------------------
|
|
361
|
-
async watchOrderBook(
|
|
362
|
+
async watchOrderBook(outcomeId, limit) {
|
|
363
|
+
const slug = await this.resolveSlug(outcomeId);
|
|
362
364
|
const ws = this.ensureWs();
|
|
363
|
-
return ws.watchOrderBook(
|
|
365
|
+
return ws.watchOrderBook(slug);
|
|
364
366
|
}
|
|
365
|
-
async watchTrades(
|
|
367
|
+
async watchTrades(outcomeId, address, since, limit) {
|
|
368
|
+
const slug = await this.resolveSlug(outcomeId);
|
|
366
369
|
const ws = this.ensureWs();
|
|
367
|
-
return ws.watchTrades(
|
|
370
|
+
return ws.watchTrades(slug, address);
|
|
368
371
|
}
|
|
369
372
|
/**
|
|
370
373
|
* Watch AMM price updates for a market address (Limitless only).
|
|
@@ -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-08T20:27:07.090Z
|
|
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-08T20:27:07.090Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.myriadApiSpec = {
|
|
@@ -23,9 +23,9 @@ export declare class MyriadExchange extends PredictionMarketExchange {
|
|
|
23
23
|
private ensureAuth;
|
|
24
24
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
25
25
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
26
|
-
fetchOHLCV(
|
|
27
|
-
fetchOrderBook(
|
|
28
|
-
fetchTrades(
|
|
26
|
+
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
27
|
+
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
28
|
+
fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
29
29
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
30
30
|
createOrder(params: CreateOrderParams): Promise<Order>;
|
|
31
31
|
cancelOrder(_orderId: string): Promise<Order>;
|
|
@@ -33,7 +33,7 @@ export declare class MyriadExchange extends PredictionMarketExchange {
|
|
|
33
33
|
fetchOpenOrders(_marketId?: string): Promise<Order[]>;
|
|
34
34
|
fetchPositions(): Promise<Position[]>;
|
|
35
35
|
fetchBalance(): Promise<Balance[]>;
|
|
36
|
-
watchOrderBook(
|
|
37
|
-
watchTrades(
|
|
36
|
+
watchOrderBook(outcomeId: string, _limit?: number): Promise<OrderBook>;
|
|
37
|
+
watchTrades(outcomeId: string, address?: string, _since?: number, _limit?: number): Promise<Trade[]>;
|
|
38
38
|
close(): Promise<void>;
|
|
39
39
|
}
|
|
@@ -79,25 +79,25 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
79
79
|
.map((raw) => this.normalizer.normalizeEvent(raw))
|
|
80
80
|
.filter((e) => e !== null);
|
|
81
81
|
}
|
|
82
|
-
async fetchOHLCV(
|
|
82
|
+
async fetchOHLCV(outcomeId, params) {
|
|
83
83
|
if (!params.resolution) {
|
|
84
84
|
throw new Error('fetchOHLCV requires a resolution parameter.');
|
|
85
85
|
}
|
|
86
|
-
const parts =
|
|
87
|
-
const
|
|
88
|
-
const rawMarket = await this.fetcher.fetchRawOHLCV(
|
|
89
|
-
return this.normalizer.normalizeOHLCV(rawMarket, params,
|
|
86
|
+
const parts = outcomeId.split(':');
|
|
87
|
+
const parsedOutcomeId = parts.length >= 3 ? parts[2] : undefined;
|
|
88
|
+
const rawMarket = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
89
|
+
return this.normalizer.normalizeOHLCV(rawMarket, params, parsedOutcomeId);
|
|
90
90
|
}
|
|
91
|
-
async fetchOrderBook(
|
|
92
|
-
const rawMarket = await this.fetcher.fetchRawOrderBook(
|
|
93
|
-
return this.normalizer.normalizeOrderBook(rawMarket,
|
|
91
|
+
async fetchOrderBook(outcomeId) {
|
|
92
|
+
const rawMarket = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
93
|
+
return this.normalizer.normalizeOrderBook(rawMarket, outcomeId);
|
|
94
94
|
}
|
|
95
|
-
async fetchTrades(
|
|
95
|
+
async fetchTrades(outcomeId, params) {
|
|
96
96
|
if ('resolution' in params && params.resolution !== undefined) {
|
|
97
97
|
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
98
98
|
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
99
99
|
}
|
|
100
|
-
const rawTrades = await this.fetcher.fetchRawTrades(
|
|
100
|
+
const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
|
|
101
101
|
return rawTrades.map((raw, i) => this.normalizer.normalizeTrade(raw, i));
|
|
102
102
|
}
|
|
103
103
|
async fetchMyTrades(params) {
|
|
@@ -178,19 +178,19 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
178
178
|
// ------------------------------------------------------------------------
|
|
179
179
|
// WebSocket (poll-based)
|
|
180
180
|
// ------------------------------------------------------------------------
|
|
181
|
-
async watchOrderBook(
|
|
181
|
+
async watchOrderBook(outcomeId, _limit) {
|
|
182
182
|
this.ensureAuth();
|
|
183
183
|
if (!this.ws) {
|
|
184
184
|
this.ws = new websocket_1.MyriadWebSocket(this.callApi.bind(this), (id) => this.fetchOrderBook(id));
|
|
185
185
|
}
|
|
186
|
-
return this.ws.watchOrderBook(
|
|
186
|
+
return this.ws.watchOrderBook(outcomeId);
|
|
187
187
|
}
|
|
188
|
-
async watchTrades(
|
|
188
|
+
async watchTrades(outcomeId, address, _since, _limit) {
|
|
189
189
|
this.ensureAuth();
|
|
190
190
|
if (!this.ws) {
|
|
191
191
|
this.ws = new websocket_1.MyriadWebSocket(this.callApi.bind(this), (id) => this.fetchOrderBook(id));
|
|
192
192
|
}
|
|
193
|
-
return this.ws.watchTrades(
|
|
193
|
+
return this.ws.watchTrades(outcomeId);
|
|
194
194
|
}
|
|
195
195
|
async close() {
|
|
196
196
|
if (this.ws) {
|
|
@@ -11,8 +11,8 @@ export declare class MyriadWebSocket {
|
|
|
11
11
|
private lastTradeTimestamp;
|
|
12
12
|
private closed;
|
|
13
13
|
constructor(callApi: (operationId: string, params?: Record<string, any>) => Promise<any>, fetchOrderBook: FetchOrderBookFn, pollInterval?: number);
|
|
14
|
-
watchOrderBook(
|
|
15
|
-
watchTrades(
|
|
14
|
+
watchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
15
|
+
watchTrades(outcomeId: string): Promise<Trade[]>;
|
|
16
16
|
close(): Promise<void>;
|
|
17
17
|
private startOrderBookPolling;
|
|
18
18
|
private startTradePolling;
|
|
@@ -20,29 +20,29 @@ class MyriadWebSocket {
|
|
|
20
20
|
this.fetchOrderBook = fetchOrderBook;
|
|
21
21
|
this.pollInterval = pollInterval || DEFAULT_POLL_INTERVAL;
|
|
22
22
|
}
|
|
23
|
-
async watchOrderBook(
|
|
23
|
+
async watchOrderBook(outcomeId) {
|
|
24
24
|
if (this.closed)
|
|
25
25
|
throw new Error('WebSocket connection is closed');
|
|
26
26
|
return new Promise((resolve) => {
|
|
27
|
-
if (!this.orderBookResolvers.has(
|
|
28
|
-
this.orderBookResolvers.set(
|
|
27
|
+
if (!this.orderBookResolvers.has(outcomeId)) {
|
|
28
|
+
this.orderBookResolvers.set(outcomeId, []);
|
|
29
29
|
}
|
|
30
|
-
this.orderBookResolvers.get(
|
|
31
|
-
if (!this.orderBookTimers.has(
|
|
32
|
-
this.startOrderBookPolling(
|
|
30
|
+
this.orderBookResolvers.get(outcomeId).push(resolve);
|
|
31
|
+
if (!this.orderBookTimers.has(outcomeId)) {
|
|
32
|
+
this.startOrderBookPolling(outcomeId);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
async watchTrades(
|
|
36
|
+
async watchTrades(outcomeId) {
|
|
37
37
|
if (this.closed)
|
|
38
38
|
throw new Error('WebSocket connection is closed');
|
|
39
39
|
return new Promise((resolve) => {
|
|
40
|
-
if (!this.tradeResolvers.has(
|
|
41
|
-
this.tradeResolvers.set(
|
|
40
|
+
if (!this.tradeResolvers.has(outcomeId)) {
|
|
41
|
+
this.tradeResolvers.set(outcomeId, []);
|
|
42
42
|
}
|
|
43
|
-
this.tradeResolvers.get(
|
|
44
|
-
if (!this.tradeTimers.has(
|
|
45
|
-
this.startTradePolling(
|
|
43
|
+
this.tradeResolvers.get(outcomeId).push(resolve);
|
|
44
|
+
if (!this.tradeTimers.has(outcomeId)) {
|
|
45
|
+
this.startTradePolling(outcomeId);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -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-08T20:27:07.094Z
|
|
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-08T20:27:07.094Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -21,8 +21,8 @@ export declare class OpinionExchange extends PredictionMarketExchange {
|
|
|
21
21
|
protected mapImplicitApiError(error: any): any;
|
|
22
22
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
23
23
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
24
|
-
fetchOHLCV(
|
|
25
|
-
fetchOrderBook(
|
|
24
|
+
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
25
|
+
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
26
26
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
27
27
|
fetchPositions(): Promise<Position[]>;
|
|
28
28
|
fetchOrder(orderId: string): Promise<Order>;
|
|
@@ -33,8 +33,8 @@ export declare class OpinionExchange extends PredictionMarketExchange {
|
|
|
33
33
|
submitOrder(built: BuiltOrder): Promise<Order>;
|
|
34
34
|
createOrder(params: CreateOrderParams): Promise<Order>;
|
|
35
35
|
cancelOrder(orderId: string): Promise<Order>;
|
|
36
|
-
watchOrderBook(
|
|
37
|
-
watchTrades(
|
|
36
|
+
watchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
37
|
+
watchTrades(outcomeId: string): Promise<Trade[]>;
|
|
38
38
|
close(): Promise<void>;
|
|
39
39
|
/**
|
|
40
40
|
* Resolve an ID (which may be a token/outcome ID or a numeric market ID string)
|
|
@@ -165,13 +165,13 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
165
165
|
await this.enrichPrices(allMarkets);
|
|
166
166
|
return events;
|
|
167
167
|
}
|
|
168
|
-
async fetchOHLCV(
|
|
169
|
-
const rawPoints = await this.fetcher.fetchRawOHLCV(
|
|
168
|
+
async fetchOHLCV(outcomeId, params) {
|
|
169
|
+
const rawPoints = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
170
170
|
return this.normalizer.normalizeOHLCV({ history: rawPoints }, params);
|
|
171
171
|
}
|
|
172
|
-
async fetchOrderBook(
|
|
173
|
-
const raw = await this.fetcher.fetchRawOrderBook(
|
|
174
|
-
return this.normalizer.normalizeOrderBook(raw,
|
|
172
|
+
async fetchOrderBook(outcomeId) {
|
|
173
|
+
const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
174
|
+
return this.normalizer.normalizeOrderBook(raw, outcomeId);
|
|
175
175
|
}
|
|
176
176
|
// -------------------------------------------------------------------------
|
|
177
177
|
// User Data (fetcher -> normalizer)
|
|
@@ -323,14 +323,14 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
323
323
|
// -------------------------------------------------------------------------
|
|
324
324
|
// WebSocket
|
|
325
325
|
// -------------------------------------------------------------------------
|
|
326
|
-
async watchOrderBook(
|
|
326
|
+
async watchOrderBook(outcomeId) {
|
|
327
327
|
const ws = this.ensureWebSocket();
|
|
328
|
-
const marketId = this.resolveMarketId(
|
|
328
|
+
const marketId = this.resolveMarketId(outcomeId);
|
|
329
329
|
return ws.watchOrderBook(marketId);
|
|
330
330
|
}
|
|
331
|
-
async watchTrades(
|
|
331
|
+
async watchTrades(outcomeId) {
|
|
332
332
|
const ws = this.ensureWebSocket();
|
|
333
|
-
const marketId = this.resolveMarketId(
|
|
333
|
+
const marketId = this.resolveMarketId(outcomeId);
|
|
334
334
|
return ws.watchTrades(marketId);
|
|
335
335
|
}
|
|
336
336
|
async close() {
|
|
@@ -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-08T20:27:07.017Z
|
|
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-08T20:27:07.017Z
|
|
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-08T20:27:07.042Z
|
|
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-08T20:27:07.042Z
|
|
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-08T20:27:07.038Z
|
|
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-08T20:27:07.038Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -26,9 +26,9 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
26
26
|
* a privateKey was provided (not apiKey/apiSecret/passphrase).
|
|
27
27
|
*/
|
|
28
28
|
initAuth(): Promise<void>;
|
|
29
|
-
fetchOHLCV(
|
|
30
|
-
fetchOrderBook(
|
|
31
|
-
fetchTrades(
|
|
29
|
+
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
30
|
+
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
31
|
+
fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
32
32
|
/**
|
|
33
33
|
* Pre-warm the SDK's internal caches for a market outcome.
|
|
34
34
|
*
|
|
@@ -49,9 +49,9 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
49
49
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
50
50
|
fetchPositions(address?: string): Promise<Position[]>;
|
|
51
51
|
fetchBalance(address?: string): Promise<Balance[]>;
|
|
52
|
-
watchOrderBook(
|
|
53
|
-
unwatchOrderBook(
|
|
54
|
-
watchTrades(
|
|
52
|
+
watchOrderBook(outcomeId: string, limit?: number): Promise<OrderBook>;
|
|
53
|
+
unwatchOrderBook(outcomeId: string): Promise<void>;
|
|
54
|
+
watchTrades(outcomeId: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
|
|
55
55
|
watchAddress(address: string, types?: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
|
|
56
56
|
unwatchAddress(address: string): Promise<void>;
|
|
57
57
|
close(): Promise<void>;
|
|
@@ -101,29 +101,29 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
101
101
|
};
|
|
102
102
|
this.cachedAddress = auth.getFunderAddress();
|
|
103
103
|
}
|
|
104
|
-
async fetchOHLCV(
|
|
105
|
-
(0, validation_1.validateIdFormat)(
|
|
106
|
-
(0, validation_1.validateOutcomeId)(
|
|
104
|
+
async fetchOHLCV(outcomeId, params) {
|
|
105
|
+
(0, validation_1.validateIdFormat)(outcomeId, 'OHLCV');
|
|
106
|
+
(0, validation_1.validateOutcomeId)(outcomeId, 'OHLCV');
|
|
107
107
|
if (!params.resolution) {
|
|
108
108
|
throw new Error('fetchOHLCV requires a resolution parameter. Use OHLCVParams with resolution specified.');
|
|
109
109
|
}
|
|
110
|
-
const raw = await this.fetcher.fetchRawOHLCV(
|
|
110
|
+
const raw = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
111
111
|
return this.normalizer.normalizeOHLCV(raw, params);
|
|
112
112
|
}
|
|
113
|
-
async fetchOrderBook(
|
|
114
|
-
(0, validation_1.validateIdFormat)(
|
|
115
|
-
(0, validation_1.validateOutcomeId)(
|
|
116
|
-
const raw = await this.fetcher.fetchRawOrderBook(
|
|
117
|
-
return this.normalizer.normalizeOrderBook(raw,
|
|
113
|
+
async fetchOrderBook(outcomeId) {
|
|
114
|
+
(0, validation_1.validateIdFormat)(outcomeId, 'OrderBook');
|
|
115
|
+
(0, validation_1.validateOutcomeId)(outcomeId, 'OrderBook');
|
|
116
|
+
const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
117
|
+
return this.normalizer.normalizeOrderBook(raw, outcomeId);
|
|
118
118
|
}
|
|
119
|
-
async fetchTrades(
|
|
120
|
-
(0, validation_1.validateIdFormat)(
|
|
121
|
-
(0, validation_1.validateOutcomeId)(
|
|
119
|
+
async fetchTrades(outcomeId, params) {
|
|
120
|
+
(0, validation_1.validateIdFormat)(outcomeId, 'Trades');
|
|
121
|
+
(0, validation_1.validateOutcomeId)(outcomeId, 'Trades');
|
|
122
122
|
if ('resolution' in params && params.resolution !== undefined) {
|
|
123
123
|
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
124
124
|
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
125
125
|
}
|
|
126
|
-
const rawTrades = await this.fetcher.fetchRawTrades(
|
|
126
|
+
const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
|
|
127
127
|
const mappedTrades = rawTrades.map((raw, i) => this.normalizer.normalizeTrade(raw, i));
|
|
128
128
|
if (params.limit && mappedTrades.length > params.limit) {
|
|
129
129
|
return mappedTrades.slice(0, params.limit);
|
|
@@ -411,14 +411,14 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
411
411
|
// ----------------------------------------------------------------------------
|
|
412
412
|
// WebSocket Methods
|
|
413
413
|
// ----------------------------------------------------------------------------
|
|
414
|
-
async watchOrderBook(
|
|
415
|
-
return this.ensureWs().watchOrderBook(
|
|
414
|
+
async watchOrderBook(outcomeId, limit) {
|
|
415
|
+
return this.ensureWs().watchOrderBook(outcomeId);
|
|
416
416
|
}
|
|
417
|
-
async unwatchOrderBook(
|
|
418
|
-
return this.ensureWs().unwatchOrderBook(
|
|
417
|
+
async unwatchOrderBook(outcomeId) {
|
|
418
|
+
return this.ensureWs().unwatchOrderBook(outcomeId);
|
|
419
419
|
}
|
|
420
|
-
async watchTrades(
|
|
421
|
-
return this.ensureWs().watchTrades(
|
|
420
|
+
async watchTrades(outcomeId, address, since, limit) {
|
|
421
|
+
return this.ensureWs().watchTrades(outcomeId, address);
|
|
422
422
|
}
|
|
423
423
|
async watchAddress(address, types = ['trades', 'positions', 'balances']) {
|
|
424
424
|
return this.ensureWs().watchAddress(address, types);
|
|
@@ -31,9 +31,9 @@ export declare class PolymarketWebSocket {
|
|
|
31
31
|
private config;
|
|
32
32
|
private initializationPromise?;
|
|
33
33
|
constructor(callApi: (operationId: string, params?: Record<string, any>) => Promise<any>, config?: PolymarketWebSocketConfig);
|
|
34
|
-
watchOrderBook(
|
|
35
|
-
unwatchOrderBook(
|
|
36
|
-
watchTrades(
|
|
34
|
+
watchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
35
|
+
unwatchOrderBook(outcomeId: string): Promise<void>;
|
|
36
|
+
watchTrades(outcomeId: string, address?: string): Promise<Trade[]>;
|
|
37
37
|
watchAddress(address: string, types: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
|
|
38
38
|
unwatchAddress(address: string): Promise<void>;
|
|
39
39
|
close(): Promise<void>;
|
|
@@ -68,55 +68,55 @@ class PolymarketWebSocket {
|
|
|
68
68
|
buildActivity: goldsky_1.buildPolymarketActivity,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
async watchOrderBook(
|
|
71
|
+
async watchOrderBook(outcomeId) {
|
|
72
72
|
await this.ensureInitialized();
|
|
73
73
|
// Subscribe to the asset if not already subscribed
|
|
74
74
|
const currentAssets = this.manager.getAssetIds();
|
|
75
|
-
if (!currentAssets.includes(
|
|
76
|
-
await this.manager.addSubscriptions([
|
|
75
|
+
if (!currentAssets.includes(outcomeId)) {
|
|
76
|
+
await this.manager.addSubscriptions([outcomeId]);
|
|
77
77
|
}
|
|
78
78
|
// Return a promise that resolves on the next orderbook update
|
|
79
79
|
const dataPromise = new Promise((resolve, reject) => {
|
|
80
|
-
if (!this.orderBookResolvers.has(
|
|
81
|
-
this.orderBookResolvers.set(
|
|
80
|
+
if (!this.orderBookResolvers.has(outcomeId)) {
|
|
81
|
+
this.orderBookResolvers.set(outcomeId, []);
|
|
82
82
|
}
|
|
83
|
-
this.orderBookResolvers.get(
|
|
83
|
+
this.orderBookResolvers.get(outcomeId).push({ resolve, reject });
|
|
84
84
|
});
|
|
85
|
-
return (0, watch_timeout_1.withWatchTimeout)(dataPromise, this.config.watchTimeoutMs ?? watch_timeout_1.DEFAULT_WATCH_TIMEOUT_MS, `watchOrderBook('${
|
|
85
|
+
return (0, watch_timeout_1.withWatchTimeout)(dataPromise, this.config.watchTimeoutMs ?? watch_timeout_1.DEFAULT_WATCH_TIMEOUT_MS, `watchOrderBook('${outcomeId}')`);
|
|
86
86
|
}
|
|
87
|
-
async unwatchOrderBook(
|
|
87
|
+
async unwatchOrderBook(outcomeId) {
|
|
88
88
|
if (!this.manager) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
await this.manager.removeSubscriptions([
|
|
91
|
+
await this.manager.removeSubscriptions([outcomeId]);
|
|
92
92
|
// Clear any pending resolvers for this asset
|
|
93
|
-
const resolvers = this.orderBookResolvers.get(
|
|
93
|
+
const resolvers = this.orderBookResolvers.get(outcomeId);
|
|
94
94
|
if (resolvers) {
|
|
95
|
-
this.orderBookResolvers = new Map([...this.orderBookResolvers].filter(([key]) => key !==
|
|
95
|
+
this.orderBookResolvers = new Map([...this.orderBookResolvers].filter(([key]) => key !== outcomeId));
|
|
96
96
|
}
|
|
97
97
|
// Remove the cached orderbook for this asset
|
|
98
|
-
if (this.orderBooks.has(
|
|
99
|
-
this.orderBooks = new Map([...this.orderBooks].filter(([key]) => key !==
|
|
98
|
+
if (this.orderBooks.has(outcomeId)) {
|
|
99
|
+
this.orderBooks = new Map([...this.orderBooks].filter(([key]) => key !== outcomeId));
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
async watchTrades(
|
|
102
|
+
async watchTrades(outcomeId, address) {
|
|
103
103
|
if (address) {
|
|
104
|
-
return this.watcher.watch(address, ['trades'],
|
|
104
|
+
return this.watcher.watch(address, ['trades'], outcomeId);
|
|
105
105
|
}
|
|
106
106
|
await this.ensureInitialized();
|
|
107
107
|
// Subscribe to the asset if not already subscribed
|
|
108
108
|
const currentAssets = this.manager.getAssetIds();
|
|
109
|
-
if (!currentAssets.includes(
|
|
110
|
-
await this.manager.addSubscriptions([
|
|
109
|
+
if (!currentAssets.includes(outcomeId)) {
|
|
110
|
+
await this.manager.addSubscriptions([outcomeId]);
|
|
111
111
|
}
|
|
112
112
|
// Return a promise that resolves on the next trade
|
|
113
113
|
const dataPromise = new Promise((resolve, reject) => {
|
|
114
|
-
if (!this.tradeResolvers.has(
|
|
115
|
-
this.tradeResolvers.set(
|
|
114
|
+
if (!this.tradeResolvers.has(outcomeId)) {
|
|
115
|
+
this.tradeResolvers.set(outcomeId, []);
|
|
116
116
|
}
|
|
117
|
-
this.tradeResolvers.get(
|
|
117
|
+
this.tradeResolvers.get(outcomeId).push({ resolve, reject });
|
|
118
118
|
});
|
|
119
|
-
return (0, watch_timeout_1.withWatchTimeout)(dataPromise, this.config.watchTimeoutMs ?? watch_timeout_1.DEFAULT_WATCH_TIMEOUT_MS, `watchTrades('${
|
|
119
|
+
return (0, watch_timeout_1.withWatchTimeout)(dataPromise, this.config.watchTimeoutMs ?? watch_timeout_1.DEFAULT_WATCH_TIMEOUT_MS, `watchTrades('${outcomeId}')`);
|
|
120
120
|
}
|
|
121
121
|
async watchAddress(address, types) {
|
|
122
122
|
return this.watcher.watch(address, types);
|
|
@@ -46,7 +46,7 @@ export declare class PolymarketUSExchange extends PredictionMarketExchange {
|
|
|
46
46
|
private slugFromId;
|
|
47
47
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
48
48
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
49
|
-
fetchOrderBook(
|
|
49
|
+
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
50
50
|
fetchBalance(_address?: string): Promise<Balance[]>;
|
|
51
51
|
fetchPositions(_address?: string): Promise<Position[]>;
|
|
52
52
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
@@ -62,7 +62,7 @@ export declare class PolymarketUSExchange extends PredictionMarketExchange {
|
|
|
62
62
|
* method calls `requireAuth()` up front.
|
|
63
63
|
*/
|
|
64
64
|
private ensureWs;
|
|
65
|
-
watchOrderBook(
|
|
66
|
-
watchTrades(
|
|
65
|
+
watchOrderBook(outcomeId: string, _limit?: number): Promise<OrderBook>;
|
|
66
|
+
watchTrades(outcomeId: string, _address?: string, _since?: number, _limit?: number): Promise<Trade[]>;
|
|
67
67
|
close(): Promise<void>;
|
|
68
68
|
}
|
|
@@ -166,11 +166,11 @@ class PolymarketUSExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
166
166
|
return events;
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
async fetchOrderBook(
|
|
169
|
+
async fetchOrderBook(outcomeId) {
|
|
170
170
|
return this.run(async () => {
|
|
171
|
-
const slug = this.slugFromId(
|
|
171
|
+
const slug = this.slugFromId(outcomeId);
|
|
172
172
|
const book = await this.client.markets.book(slug);
|
|
173
|
-
return this.normalizer.normalizeOrderBook(book,
|
|
173
|
+
return this.normalizer.normalizeOrderBook(book, outcomeId);
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
// -------------------------------------------------------------------------
|
|
@@ -321,11 +321,11 @@ class PolymarketUSExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
321
321
|
}
|
|
322
322
|
return this.wsWrapper;
|
|
323
323
|
}
|
|
324
|
-
async watchOrderBook(
|
|
325
|
-
return this.run(() => this.ensureWs().watchOrderBook(
|
|
324
|
+
async watchOrderBook(outcomeId, _limit) {
|
|
325
|
+
return this.run(() => this.ensureWs().watchOrderBook(outcomeId));
|
|
326
326
|
}
|
|
327
|
-
async watchTrades(
|
|
328
|
-
return this.run(() => this.ensureWs().watchTrades(
|
|
327
|
+
async watchTrades(outcomeId, _address, _since, _limit) {
|
|
328
|
+
return this.run(() => this.ensureWs().watchTrades(outcomeId));
|
|
329
329
|
}
|
|
330
330
|
// -------------------------------------------------------------------------
|
|
331
331
|
// Lifecycle
|
|
@@ -31,8 +31,8 @@ export declare class PolymarketUSWebSocket {
|
|
|
31
31
|
private readonly orderBookResolvers;
|
|
32
32
|
private readonly tradeResolvers;
|
|
33
33
|
constructor(client: PolymarketUSClient, normalizer: PolymarketUSNormalizer, config?: PolymarketUSWebSocketConfig);
|
|
34
|
-
watchOrderBook(
|
|
35
|
-
watchTrades(
|
|
34
|
+
watchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
35
|
+
watchTrades(outcomeId: string): Promise<Trade[]>;
|
|
36
36
|
close(): Promise<void>;
|
|
37
37
|
private ensureInitialized;
|
|
38
38
|
private handleMarketData;
|