pmxt-core 2.42.5 → 2.43.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 +33 -12
- package/dist/BaseExchange.js +57 -17
- package/dist/exchanges/baozi/index.d.ts +2 -2
- package/dist/exchanges/baozi/index.js +2 -2
- package/dist/exchanges/gemini-titan/index.d.ts +2 -2
- package/dist/exchanges/gemini-titan/index.js +2 -2
- package/dist/exchanges/hyperliquid/index.d.ts +1 -1
- package/dist/exchanges/hyperliquid/index.js +1 -1
- package/dist/exchanges/kalshi/api.d.ts +32 -1
- package/dist/exchanges/kalshi/api.js +38 -1
- package/dist/exchanges/kalshi/fetcher.d.ts +11 -5
- package/dist/exchanges/kalshi/fetcher.js +12 -0
- package/dist/exchanges/kalshi/index.d.ts +7 -6
- package/dist/exchanges/kalshi/index.js +40 -31
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/limitless/index.d.ts +2 -2
- package/dist/exchanges/limitless/index.js +3 -2
- package/dist/exchanges/mock/index.d.ts +1 -1
- package/dist/exchanges/mock/index.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/myriad/index.d.ts +2 -2
- package/dist/exchanges/myriad/index.js +2 -2
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/index.d.ts +2 -2
- package/dist/exchanges/opinion/index.js +2 -2
- package/dist/exchanges/polymarket/api-clob.d.ts +14 -1
- package/dist/exchanges/polymarket/api-clob.js +20 -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/fetcher.d.ts +2 -0
- package/dist/exchanges/polymarket/fetcher.js +24 -0
- package/dist/exchanges/polymarket/index.d.ts +3 -2
- package/dist/exchanges/polymarket/index.js +17 -2
- package/dist/exchanges/polymarket/utils.d.ts +2 -1
- package/dist/exchanges/polymarket/utils.js +16 -7
- package/dist/exchanges/polymarket_us/index.d.ts +2 -2
- package/dist/exchanges/polymarket_us/index.js +2 -2
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/exchanges/probable/index.d.ts +2 -2
- package/dist/exchanges/probable/index.js +2 -2
- package/dist/exchanges/smarkets/index.d.ts +1 -1
- package/dist/exchanges/smarkets/index.js +1 -1
- package/dist/router/Router.d.ts +1 -1
- package/dist/router/Router.js +4 -4
- package/dist/router/e2e-orderbook.d.ts +1 -0
- package/dist/router/e2e-orderbook.js +58 -0
- package/dist/server/method-verbs.json +27 -2
- package/dist/server/openapi.yaml +50 -4
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KalshiExchange = void 0;
|
|
4
4
|
const BaseExchange_1 = require("../../BaseExchange");
|
|
5
|
-
const
|
|
6
|
-
const validation_1 = require("../../utils/validation");
|
|
7
|
-
const websocket_1 = require("./websocket");
|
|
8
|
-
const errors_1 = require("./errors");
|
|
9
|
-
const errors_2 = require("../../errors");
|
|
5
|
+
const errors_1 = require("../../errors");
|
|
10
6
|
const openapi_1 = require("../../utils/openapi");
|
|
11
7
|
const api_1 = require("./api");
|
|
8
|
+
const auth_1 = require("./auth");
|
|
12
9
|
const config_1 = require("./config");
|
|
10
|
+
const errors_2 = require("./errors");
|
|
13
11
|
const fetcher_1 = require("./fetcher");
|
|
14
12
|
const normalizer_1 = require("./normalizer");
|
|
13
|
+
const websocket_1 = require("./websocket");
|
|
15
14
|
class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
16
15
|
auth;
|
|
17
16
|
wsConfig;
|
|
@@ -22,7 +21,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
22
21
|
let credentials;
|
|
23
22
|
let wsConfig;
|
|
24
23
|
let demoMode = false;
|
|
25
|
-
if (options &&
|
|
24
|
+
if (options && 'credentials' in options) {
|
|
26
25
|
credentials = options.credentials;
|
|
27
26
|
wsConfig = options.websocket;
|
|
28
27
|
demoMode = options.demoMode || false;
|
|
@@ -48,22 +47,22 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
48
47
|
this.normalizer = new normalizer_1.KalshiNormalizer();
|
|
49
48
|
}
|
|
50
49
|
get name() {
|
|
51
|
-
return
|
|
50
|
+
return 'Kalshi';
|
|
52
51
|
}
|
|
53
52
|
// ----------------------------------------------------------------------------
|
|
54
53
|
// Implicit API Auth & Error Mapping
|
|
55
54
|
// ----------------------------------------------------------------------------
|
|
56
55
|
sign(method, path, _params) {
|
|
57
56
|
const auth = this.ensureAuth();
|
|
58
|
-
return auth.getHeaders(method,
|
|
57
|
+
return auth.getHeaders(method, '/trade-api/v2' + path);
|
|
59
58
|
}
|
|
60
59
|
mapImplicitApiError(error) {
|
|
61
|
-
throw
|
|
60
|
+
throw errors_2.kalshiErrorMapper.mapError(error);
|
|
62
61
|
}
|
|
63
62
|
ensureAuth() {
|
|
64
63
|
if (!this.auth) {
|
|
65
|
-
throw new
|
|
66
|
-
|
|
64
|
+
throw new errors_1.AuthenticationError('Trading operations require authentication. ' +
|
|
65
|
+
'Initialize KalshiExchange with credentials (apiKey and privateKey).', 'Kalshi');
|
|
67
66
|
}
|
|
68
67
|
return this.auth;
|
|
69
68
|
}
|
|
@@ -121,15 +120,25 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
121
120
|
const rawCandles = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
122
121
|
return this.normalizer.normalizeOHLCV(rawCandles, params);
|
|
123
122
|
}
|
|
124
|
-
async fetchOrderBook(outcomeId) {
|
|
125
|
-
(0, validation_1.validateIdFormat)(outcomeId, "OrderBook");
|
|
123
|
+
async fetchOrderBook(outcomeId, _limit, _params) {
|
|
126
124
|
const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
127
125
|
return this.normalizer.normalizeOrderBook(raw, outcomeId);
|
|
128
126
|
}
|
|
127
|
+
async fetchOrderBooks(outcomeIds) {
|
|
128
|
+
const raw = await this.fetcher.fetchRawOrderBooks(outcomeIds);
|
|
129
|
+
const byTicker = new Map(raw.map(ob => [ob.ticker, ob]));
|
|
130
|
+
const response = {};
|
|
131
|
+
outcomeIds.forEach((outcomeId) => {
|
|
132
|
+
const ob = byTicker.get(outcomeId.replace(/-NO$/, ''));
|
|
133
|
+
if (ob)
|
|
134
|
+
response[outcomeId] = this.normalizer.normalizeOrderBook(ob, outcomeId);
|
|
135
|
+
});
|
|
136
|
+
return response;
|
|
137
|
+
}
|
|
129
138
|
async fetchTrades(outcomeId, params) {
|
|
130
|
-
if (
|
|
139
|
+
if ('resolution' in params && params.resolution !== undefined) {
|
|
131
140
|
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
132
|
-
|
|
141
|
+
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
133
142
|
}
|
|
134
143
|
const rawTrades = await this.fetcher.fetchRawTrades(outcomeId, params);
|
|
135
144
|
return rawTrades.map((raw, i) => this.normalizer.normalizeTrade(raw, i));
|
|
@@ -192,14 +201,14 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
192
201
|
// Trading
|
|
193
202
|
// ----------------------------------------------------------------------------
|
|
194
203
|
async buildOrder(params) {
|
|
195
|
-
const isYesSide = params.side ===
|
|
204
|
+
const isYesSide = params.side === 'buy';
|
|
196
205
|
const body = {
|
|
197
206
|
ticker: params.marketId,
|
|
198
207
|
client_order_id: `pmxt-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
199
|
-
side: isYesSide ?
|
|
200
|
-
action: params.side ===
|
|
208
|
+
side: isYesSide ? 'yes' : 'no',
|
|
209
|
+
action: params.side === 'buy' ? 'buy' : 'sell',
|
|
201
210
|
count: params.amount,
|
|
202
|
-
type: params.type ===
|
|
211
|
+
type: params.type === 'limit' ? 'limit' : 'market',
|
|
203
212
|
};
|
|
204
213
|
if (params.price) {
|
|
205
214
|
const priceInCents = Math.round(params.price * 100);
|
|
@@ -213,7 +222,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
213
222
|
return { exchange: this.name, params, raw: body };
|
|
214
223
|
}
|
|
215
224
|
async submitOrder(built) {
|
|
216
|
-
const data = await this.callApi(
|
|
225
|
+
const data = await this.callApi('CreateOrder', built.raw);
|
|
217
226
|
return this.normalizer.normalizeOrder(data.order);
|
|
218
227
|
}
|
|
219
228
|
async createOrder(params) {
|
|
@@ -221,27 +230,27 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
221
230
|
return this.submitOrder(built);
|
|
222
231
|
}
|
|
223
232
|
async cancelOrder(orderId) {
|
|
224
|
-
const data = await this.callApi(
|
|
233
|
+
const data = await this.callApi('CancelOrder', { order_id: orderId });
|
|
225
234
|
const order = data.order;
|
|
226
235
|
return {
|
|
227
236
|
id: order.order_id,
|
|
228
237
|
marketId: order.ticker,
|
|
229
238
|
outcomeId: order.ticker,
|
|
230
|
-
side: order.side ===
|
|
231
|
-
type:
|
|
239
|
+
side: order.side === 'yes' ? 'buy' : 'sell',
|
|
240
|
+
type: 'limit',
|
|
232
241
|
amount: order.count,
|
|
233
|
-
status:
|
|
242
|
+
status: 'cancelled',
|
|
234
243
|
filled: order.count - (order.remaining_count || 0),
|
|
235
244
|
remaining: 0,
|
|
236
245
|
timestamp: new Date(order.created_time).getTime(),
|
|
237
246
|
};
|
|
238
247
|
}
|
|
239
248
|
async fetchOrder(orderId) {
|
|
240
|
-
const data = await this.callApi(
|
|
249
|
+
const data = await this.callApi('GetOrder', { order_id: orderId });
|
|
241
250
|
return this.normalizer.normalizeOrder(data.order);
|
|
242
251
|
}
|
|
243
252
|
async fetchOpenOrders(marketId) {
|
|
244
|
-
const queryParams = { status:
|
|
253
|
+
const queryParams = { status: 'resting' };
|
|
245
254
|
if (marketId)
|
|
246
255
|
queryParams.ticker = marketId;
|
|
247
256
|
const rawOrders = await this.fetcher.fetchRawOrders(queryParams);
|
|
@@ -251,7 +260,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
251
260
|
// WebSocket
|
|
252
261
|
// ----------------------------------------------------------------------------
|
|
253
262
|
ws;
|
|
254
|
-
async watchOrderBook(outcomeId, limit) {
|
|
263
|
+
async watchOrderBook(outcomeId, limit, _params = {}) {
|
|
255
264
|
const auth = this.ensureAuth();
|
|
256
265
|
if (!this.ws) {
|
|
257
266
|
const wsConfigWithUrl = {
|
|
@@ -260,10 +269,10 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
260
269
|
};
|
|
261
270
|
this.ws = new websocket_1.KalshiWebSocket(auth, wsConfigWithUrl);
|
|
262
271
|
}
|
|
263
|
-
const marketTicker = outcomeId.replace(/-NO$/,
|
|
272
|
+
const marketTicker = outcomeId.replace(/-NO$/, '');
|
|
264
273
|
return this.ws.watchOrderBook(marketTicker);
|
|
265
274
|
}
|
|
266
|
-
async watchOrderBooks(outcomeIds, limit) {
|
|
275
|
+
async watchOrderBooks(outcomeIds, limit, _params = {}) {
|
|
267
276
|
const auth = this.ensureAuth();
|
|
268
277
|
if (!this.ws) {
|
|
269
278
|
const wsConfigWithUrl = {
|
|
@@ -272,7 +281,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
272
281
|
};
|
|
273
282
|
this.ws = new websocket_1.KalshiWebSocket(auth, wsConfigWithUrl);
|
|
274
283
|
}
|
|
275
|
-
const marketTickers = outcomeIds.map((oid) => oid.replace(/-NO$/,
|
|
284
|
+
const marketTickers = outcomeIds.map((oid) => oid.replace(/-NO$/, ''));
|
|
276
285
|
return this.ws.watchOrderBooks(marketTickers);
|
|
277
286
|
}
|
|
278
287
|
async watchTrades(outcomeId, address, since, limit) {
|
|
@@ -284,7 +293,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
284
293
|
};
|
|
285
294
|
this.ws = new websocket_1.KalshiWebSocket(auth, wsConfigWithUrl);
|
|
286
295
|
}
|
|
287
|
-
const marketTicker = outcomeId.replace(/-NO$/,
|
|
296
|
+
const marketTicker = outcomeId.replace(/-NO$/, '');
|
|
288
297
|
return this.ws.watchTrades(marketTicker);
|
|
289
298
|
}
|
|
290
299
|
async close() {
|
|
@@ -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-22T18:51:26.901Z
|
|
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-22T18:51:26.901Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.limitlessApiSpec = {
|
|
@@ -28,7 +28,7 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
|
|
|
28
28
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
29
29
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
30
30
|
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
31
|
-
fetchOrderBook(outcomeId: string,
|
|
31
|
+
fetchOrderBook(outcomeId: string, limit?: number, params?: Record<string, any>): Promise<OrderBook>;
|
|
32
32
|
private isNoOutcome;
|
|
33
33
|
fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
34
34
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
@@ -40,7 +40,7 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
|
|
|
40
40
|
fetchAllOrders(params?: OrderHistoryParams): Promise<Order[]>;
|
|
41
41
|
fetchPositions(address?: string): Promise<Position[]>;
|
|
42
42
|
fetchBalance(address?: string): Promise<Balance[]>;
|
|
43
|
-
watchOrderBook(outcomeId: string, limit?: number): Promise<OrderBook>;
|
|
43
|
+
watchOrderBook(outcomeId: string, limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
44
44
|
watchTrades(outcomeId: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
|
|
45
45
|
/**
|
|
46
46
|
* Watch AMM price updates for a market address (Limitless only).
|
|
@@ -154,13 +154,14 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
154
154
|
const rawPrices = await this.fetcher.fetchRawOHLCV(slug, params);
|
|
155
155
|
return this.normalizer.normalizeOHLCV(rawPrices, params);
|
|
156
156
|
}
|
|
157
|
-
async fetchOrderBook(outcomeId,
|
|
157
|
+
async fetchOrderBook(outcomeId, limit, params) {
|
|
158
158
|
const slug = await this.resolveSlug(outcomeId);
|
|
159
159
|
const rawOrderBook = await this.fetcher.fetchRawOrderBook(slug);
|
|
160
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 side = params?.side;
|
|
164
165
|
const isNoToken = side === 'no' || (!side && await this.isNoOutcome(outcomeId, slug));
|
|
165
166
|
if (isNoToken) {
|
|
166
167
|
return {
|
|
@@ -374,7 +375,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
374
375
|
// ------------------------------------------------------------------------
|
|
375
376
|
// WebSocket
|
|
376
377
|
// ------------------------------------------------------------------------
|
|
377
|
-
async watchOrderBook(outcomeId, limit) {
|
|
378
|
+
async watchOrderBook(outcomeId, limit, _params = {}) {
|
|
378
379
|
const slug = await this.resolveSlug(outcomeId);
|
|
379
380
|
const ws = this.ensureWs();
|
|
380
381
|
return ws.watchOrderBook(slug);
|
|
@@ -28,7 +28,7 @@ export declare class MockExchange extends PredictionMarketExchange {
|
|
|
28
28
|
private _buildEvents;
|
|
29
29
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
30
30
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
31
|
-
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
31
|
+
fetchOrderBook(id: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
32
32
|
fetchOHLCV(id: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
33
33
|
fetchTrades(id: string, _params: TradesParams): Promise<Trade[]>;
|
|
34
34
|
fetchBalance(_address?: string): Promise<Balance[]>;
|
|
@@ -278,7 +278,7 @@ class MockExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
278
278
|
const limit = params?.limit;
|
|
279
279
|
return limit !== undefined ? events.slice(offset, offset + limit) : events.slice(offset);
|
|
280
280
|
}
|
|
281
|
-
async fetchOrderBook(id) {
|
|
281
|
+
async fetchOrderBook(id, _limit, _params) {
|
|
282
282
|
const f = new seededRng_1.SeededRng(id);
|
|
283
283
|
const midPrice = round(f.float(0.1, 0.9), 3);
|
|
284
284
|
const spread = round(f.float(0.005, 0.03), 3);
|
|
@@ -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-22T18:51:26.912Z
|
|
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-22T18:51:26.912Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.myriadApiSpec = {
|
|
@@ -24,7 +24,7 @@ export declare class MyriadExchange extends PredictionMarketExchange {
|
|
|
24
24
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
25
25
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
26
26
|
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
27
|
-
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
27
|
+
fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
28
28
|
fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
29
29
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
30
30
|
createOrder(params: CreateOrderParams): 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(outcomeId: string, _limit?: number): Promise<OrderBook>;
|
|
36
|
+
watchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
37
37
|
watchTrades(outcomeId: string, address?: string, _since?: number, _limit?: number): Promise<Trade[]>;
|
|
38
38
|
close(): Promise<void>;
|
|
39
39
|
}
|
|
@@ -88,7 +88,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
88
88
|
const rawMarket = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
89
89
|
return this.normalizer.normalizeOHLCV(rawMarket, params, parsedOutcomeId);
|
|
90
90
|
}
|
|
91
|
-
async fetchOrderBook(outcomeId) {
|
|
91
|
+
async fetchOrderBook(outcomeId, _limit, _params) {
|
|
92
92
|
const parts = outcomeId.split(':');
|
|
93
93
|
if (parts.length >= 3) {
|
|
94
94
|
const [networkId, marketId, oid] = parts;
|
|
@@ -193,7 +193,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
193
193
|
// ------------------------------------------------------------------------
|
|
194
194
|
// WebSocket (poll-based)
|
|
195
195
|
// ------------------------------------------------------------------------
|
|
196
|
-
async watchOrderBook(outcomeId, _limit) {
|
|
196
|
+
async watchOrderBook(outcomeId, _limit, _params = {}) {
|
|
197
197
|
this.ensureAuth();
|
|
198
198
|
if (!this.ws) {
|
|
199
199
|
this.ws = new websocket_1.MyriadWebSocket(this.callApi.bind(this), (id) => this.fetchOrderBook(id));
|
|
@@ -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-22T18:51:26.915Z
|
|
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-22T18:51:26.915Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -22,7 +22,7 @@ export declare class OpinionExchange extends PredictionMarketExchange {
|
|
|
22
22
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
23
23
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
24
24
|
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
25
|
-
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
25
|
+
fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
26
26
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
27
27
|
fetchPositions(): Promise<Position[]>;
|
|
28
28
|
fetchOrder(orderId: string): Promise<Order>;
|
|
@@ -33,7 +33,7 @@ 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(outcomeId: string): Promise<OrderBook>;
|
|
36
|
+
watchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
37
37
|
watchTrades(outcomeId: string): Promise<Trade[]>;
|
|
38
38
|
close(): Promise<void>;
|
|
39
39
|
/**
|
|
@@ -169,7 +169,7 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
169
169
|
const rawPoints = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
170
170
|
return this.normalizer.normalizeOHLCV({ history: rawPoints }, params);
|
|
171
171
|
}
|
|
172
|
-
async fetchOrderBook(outcomeId) {
|
|
172
|
+
async fetchOrderBook(outcomeId, _limit, _params) {
|
|
173
173
|
const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
174
174
|
return this.normalizer.normalizeOrderBook(raw, outcomeId);
|
|
175
175
|
}
|
|
@@ -323,7 +323,7 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
323
323
|
// -------------------------------------------------------------------------
|
|
324
324
|
// WebSocket
|
|
325
325
|
// -------------------------------------------------------------------------
|
|
326
|
-
async watchOrderBook(outcomeId) {
|
|
326
|
+
async watchOrderBook(outcomeId, _limit, _params = {}) {
|
|
327
327
|
const ws = this.ensureWebSocket();
|
|
328
328
|
const marketId = this.resolveMarketId(outcomeId);
|
|
329
329
|
return ws.watchOrderBook(marketId);
|
|
@@ -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-22T18:51:26.870Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketClobSpec: {
|
|
@@ -347,6 +347,19 @@ export declare const polymarketClobSpec: {
|
|
|
347
347
|
}[];
|
|
348
348
|
};
|
|
349
349
|
};
|
|
350
|
+
"/balance-allowance/update": {
|
|
351
|
+
get: {
|
|
352
|
+
operationId: string;
|
|
353
|
+
summary: string;
|
|
354
|
+
tags: string[];
|
|
355
|
+
security: {
|
|
356
|
+
L2Auth: never[];
|
|
357
|
+
}[];
|
|
358
|
+
parameters: {
|
|
359
|
+
$ref: string;
|
|
360
|
+
}[];
|
|
361
|
+
};
|
|
362
|
+
};
|
|
350
363
|
"/geoblock": {
|
|
351
364
|
get: {
|
|
352
365
|
operationId: string;
|
|
@@ -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-22T18:51:26.870Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketClobSpec = {
|
|
@@ -518,6 +518,25 @@ exports.polymarketClobSpec = {
|
|
|
518
518
|
]
|
|
519
519
|
}
|
|
520
520
|
},
|
|
521
|
+
"/balance-allowance/update": {
|
|
522
|
+
"get": {
|
|
523
|
+
"operationId": "updateBalanceAllowance",
|
|
524
|
+
"summary": "Update balance and allowance cache",
|
|
525
|
+
"tags": [
|
|
526
|
+
"Balances"
|
|
527
|
+
],
|
|
528
|
+
"security": [
|
|
529
|
+
{
|
|
530
|
+
"L2Auth": []
|
|
531
|
+
}
|
|
532
|
+
],
|
|
533
|
+
"parameters": [
|
|
534
|
+
{
|
|
535
|
+
"$ref": "#/components/parameters/L2Headers"
|
|
536
|
+
}
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
},
|
|
521
540
|
"/geoblock": {
|
|
522
541
|
"get": {
|
|
523
542
|
"operationId": "getGeoblock",
|
|
@@ -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-22T18:51:26.883Z
|
|
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-22T18:51:26.883Z
|
|
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-22T18:51:26.880Z
|
|
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-22T18:51:26.880Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -51,6 +51,7 @@ export interface PolymarketRawOrderBookLevel {
|
|
|
51
51
|
size: string;
|
|
52
52
|
}
|
|
53
53
|
export interface PolymarketRawOrderBook {
|
|
54
|
+
asset_id: string;
|
|
54
55
|
bids?: PolymarketRawOrderBookLevel[];
|
|
55
56
|
asks?: PolymarketRawOrderBookLevel[];
|
|
56
57
|
timestamp?: string | number;
|
|
@@ -88,6 +89,7 @@ export declare class PolymarketFetcher implements IExchangeFetcher<PolymarketRaw
|
|
|
88
89
|
history: PolymarketRawOHLCVPoint[];
|
|
89
90
|
}>;
|
|
90
91
|
fetchRawOrderBook(id: string): Promise<PolymarketRawOrderBook>;
|
|
92
|
+
fetchRawOrderBooks(ids: string[]): Promise<PolymarketRawOrderBook[]>;
|
|
91
93
|
fetchRawTrades(id: string, params: TradesParams): Promise<PolymarketRawTrade[]>;
|
|
92
94
|
fetchRawMyTrades(params: MyTradesParams, walletAddress: string): Promise<PolymarketRawTrade[]>;
|
|
93
95
|
fetchRawPositions(walletAddress: string): Promise<PolymarketRawPosition[]>;
|
|
@@ -161,6 +161,30 @@ class PolymarketFetcher {
|
|
|
161
161
|
throw mapped;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
async fetchRawOrderBooks(ids) {
|
|
165
|
+
try {
|
|
166
|
+
const payload = ids.map(id => ({ token_id: id }));
|
|
167
|
+
const books = await this.ctx.callApi('postBooks', payload);
|
|
168
|
+
if (books.length !== ids.length) {
|
|
169
|
+
const returned = new Set(books.map(b => b.asset_id));
|
|
170
|
+
const missing = ids.filter(id => !returned.has(id));
|
|
171
|
+
throw new errors_1.NotFound(`Order book not found for token IDs ${missing.join(', ')}`, 'Polymarket');
|
|
172
|
+
}
|
|
173
|
+
return books;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (error instanceof errors_1.NotFound)
|
|
177
|
+
throw error;
|
|
178
|
+
const mapped = errors_2.polymarketErrorMapper.mapError(error);
|
|
179
|
+
if (mapped instanceof errors_1.OrderNotFound) {
|
|
180
|
+
throw new errors_1.NotFound(`${mapped.message}. ` +
|
|
181
|
+
`fetchRawOrderBooks requires a list of outcome token IDs` +
|
|
182
|
+
`(market.yes.outcomeId or market.no.outcomeId from fetchMarkets), ` +
|
|
183
|
+
`not a market slug or condition ID.`, 'Polymarket');
|
|
184
|
+
}
|
|
185
|
+
throw mapped;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
164
188
|
// ------------------------------------------------------------------------
|
|
165
189
|
// Trades
|
|
166
190
|
// ------------------------------------------------------------------------
|
|
@@ -27,7 +27,8 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
27
27
|
*/
|
|
28
28
|
initAuth(): Promise<void>;
|
|
29
29
|
fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
|
|
30
|
-
fetchOrderBook(outcomeId: string): Promise<OrderBook>;
|
|
30
|
+
fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
31
|
+
fetchOrderBooks(outcomeIds: string[]): Promise<Record<string, OrderBook>>;
|
|
31
32
|
fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
32
33
|
/**
|
|
33
34
|
* Pre-warm the SDK's internal caches for a market outcome.
|
|
@@ -49,7 +50,7 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
49
50
|
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
50
51
|
fetchPositions(address?: string): Promise<Position[]>;
|
|
51
52
|
fetchBalance(address?: string): Promise<Balance[]>;
|
|
52
|
-
watchOrderBook(outcomeId: string, limit?: number): Promise<OrderBook>;
|
|
53
|
+
watchOrderBook(outcomeId: string, limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
|
|
53
54
|
unwatchOrderBook(outcomeId: string): Promise<void>;
|
|
54
55
|
watchTrades(outcomeId: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
|
|
55
56
|
watchAddress(address: string, types?: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
|
|
@@ -110,12 +110,27 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
110
110
|
const raw = await this.fetcher.fetchRawOHLCV(outcomeId, params);
|
|
111
111
|
return this.normalizer.normalizeOHLCV(raw, params);
|
|
112
112
|
}
|
|
113
|
-
async fetchOrderBook(outcomeId) {
|
|
113
|
+
async fetchOrderBook(outcomeId, _limit, _params) {
|
|
114
114
|
(0, validation_1.validateIdFormat)(outcomeId, 'OrderBook');
|
|
115
115
|
(0, validation_1.validateOutcomeId)(outcomeId, 'OrderBook');
|
|
116
116
|
const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
|
|
117
117
|
return this.normalizer.normalizeOrderBook(raw, outcomeId);
|
|
118
118
|
}
|
|
119
|
+
async fetchOrderBooks(outcomeIds) {
|
|
120
|
+
outcomeIds.forEach((outcomeId) => {
|
|
121
|
+
(0, validation_1.validateIdFormat)(outcomeId, 'OrderBook');
|
|
122
|
+
(0, validation_1.validateOutcomeId)(outcomeId, 'OrderBook');
|
|
123
|
+
});
|
|
124
|
+
const raw = await this.fetcher.fetchRawOrderBooks(outcomeIds);
|
|
125
|
+
const byAssetId = new Map(raw.map(item => [item.asset_id, item]));
|
|
126
|
+
const response = {};
|
|
127
|
+
outcomeIds.forEach((outcomeId) => {
|
|
128
|
+
const item = byAssetId.get(outcomeId);
|
|
129
|
+
if (item)
|
|
130
|
+
response[outcomeId] = this.normalizer.normalizeOrderBook(item, outcomeId);
|
|
131
|
+
});
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
119
134
|
async fetchTrades(outcomeId, params) {
|
|
120
135
|
(0, validation_1.validateIdFormat)(outcomeId, 'Trades');
|
|
121
136
|
(0, validation_1.validateOutcomeId)(outcomeId, 'Trades');
|
|
@@ -433,7 +448,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
433
448
|
// ----------------------------------------------------------------------------
|
|
434
449
|
// WebSocket Methods
|
|
435
450
|
// ----------------------------------------------------------------------------
|
|
436
|
-
async watchOrderBook(outcomeId, limit) {
|
|
451
|
+
async watchOrderBook(outcomeId, limit, _params = {}) {
|
|
437
452
|
return this.ensureWs().watchOrderBook(outcomeId);
|
|
438
453
|
}
|
|
439
454
|
async unwatchOrderBook(outcomeId) {
|
|
@@ -9,7 +9,8 @@ export declare function mapMarketToUnified(event: any, market: any, options?: {
|
|
|
9
9
|
export declare function mapIntervalToFidelity(interval: CandleInterval): number;
|
|
10
10
|
/**
|
|
11
11
|
* Fetch all results from Gamma API using parallel pagination for best DX.
|
|
12
|
-
* Polymarket Gamma API
|
|
12
|
+
* Polymarket Gamma API silently clamps responses to 100 items per request
|
|
13
|
+
* and rejects offsets above 10,000.
|
|
13
14
|
*/
|
|
14
15
|
export declare function paginateParallel(url: string, params: any, http: any, maxResults?: number): Promise<any[]>;
|
|
15
16
|
/**
|