pmxt-core 2.40.1 → 2.40.4

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
3
- * Generated at: 2026-05-08T23:06:00.095Z
3
+ * Generated at: 2026-05-09T16:59:10.770Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const kalshiApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.kalshiApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
6
- * Generated at: 2026-05-08T23:06:00.095Z
6
+ * Generated at: 2026-05-09T16:59:10.770Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
3
- * Generated at: 2026-05-08T23:06:00.134Z
3
+ * Generated at: 2026-05-09T16:59:10.809Z
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-08T23:06:00.134Z
6
+ * Generated at: 2026-05-09T16:59:10.809Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -225,20 +225,38 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
225
225
  type: params.type,
226
226
  onBehalfOf: params.onBehalfOf,
227
227
  });
228
- // Map response to Order object
229
- // The SDK returns OrderResponse with order.id
228
+ // Map response to Order object.
229
+ // The SDK returns OrderResponse: { order: CreatedOrder, makerMatches?: OrderMatch[] }
230
+ // For GTC orders that rest on the book, makerMatches is empty.
231
+ // For FOK/FAK orders (or GTC with immediate partial matches), makerMatches contains fills.
232
+ // Each OrderMatch.matchedSize is in USDC raw units (6 decimals).
233
+ const USDC_DECIMALS = 6;
234
+ const raw = response;
235
+ const matches = raw.makerMatches ?? raw.order?.makerMatches ?? [];
236
+ const filledRaw = matches.reduce((sum, m) => {
237
+ const size = typeof m.matchedSize === 'string'
238
+ ? parseFloat(m.matchedSize)
239
+ : (m.matchedSize ?? 0);
240
+ return sum + size;
241
+ }, 0);
242
+ const filled = filledRaw / Math.pow(10, USDC_DECIMALS);
243
+ const remaining = Math.max(0, params.amount - filled);
244
+ const orderFeeRateBps = raw.order?.feeRateBps
245
+ ?? raw.feeRateBps
246
+ ?? undefined;
230
247
  return {
231
- id: response.order.id || 'unknown',
248
+ id: raw.order?.id || raw.id || 'unknown',
232
249
  marketId: params.marketId,
233
250
  outcomeId: params.outcomeId,
234
251
  side: params.side,
235
252
  type: params.type,
236
253
  price: params.price,
237
254
  amount: params.amount,
238
- status: 'open',
239
- filled: 0,
240
- remaining: params.amount,
255
+ status: filled >= params.amount ? 'filled' : 'open',
256
+ filled,
257
+ remaining,
241
258
  timestamp: Date.now(),
259
+ ...(orderFeeRateBps != null ? { feeRateBps: orderFeeRateBps } : {}),
242
260
  };
243
261
  }
244
262
  catch (error) {
@@ -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-08T23:06:00.146Z
3
+ * Generated at: 2026-05-09T16:59:10.821Z
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-08T23:06:00.146Z
6
+ * Generated at: 2026-05-09T16:59:10.821Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -83,20 +83,22 @@ class MyriadFetcher {
83
83
  if (params.slug) {
84
84
  return this.fetchRawQuestionById(params.slug);
85
85
  }
86
+ // Use /markets (complete endpoint) instead of /questions (only
87
+ // returns BNB-chain candle markets). Each market is wrapped as a
88
+ // synthetic single-market question for compatibility with the
89
+ // event-based ingest pipeline.
86
90
  const limit = params.limit || 100;
87
- const queryParams = {
88
- page: 1,
89
- limit: Math.min(limit, 100),
90
- };
91
- if (params.query) {
92
- queryParams.keyword = params.query;
93
- }
94
- const response = await this.ctx.http.get(`${this.baseUrl}/questions`, {
95
- params: queryParams,
96
- headers: this.ctx.getHeaders(),
91
+ const markets = await this.fetchRawMarkets({
92
+ limit,
93
+ status: params.status || 'active',
94
+ sort: 'volume',
95
+ query: params.query,
97
96
  });
98
- const questions = response.data.data || response.data.questions || [];
99
- return questions.slice(0, limit);
97
+ return markets.map((m) => ({
98
+ id: m.id,
99
+ title: m.title,
100
+ markets: [m],
101
+ }));
100
102
  }
101
103
  catch (error) {
102
104
  throw errors_1.myriadErrorMapper.mapError(error);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MyriadNormalizer = void 0;
4
4
  const market_utils_1 = require("../../utils/market-utils");
5
5
  const price_1 = require("./price");
6
+ const utils_1 = require("./utils");
6
7
  function selectTimeframe(interval) {
7
8
  switch (interval) {
8
9
  case '1m':
@@ -29,6 +30,7 @@ class MyriadNormalizer {
29
30
  price: Number(o.price) || 0,
30
31
  priceChange24h: o.priceChange24h != null ? Number(o.priceChange24h) : undefined,
31
32
  }));
33
+ const status = typeof raw.state === 'string' ? (0, utils_1.mapMarketState)(raw.state) : undefined;
32
34
  const um = {
33
35
  marketId: `${raw.networkId}:${raw.id}`,
34
36
  eventId: raw.questionId ? String(raw.questionId) : undefined,
@@ -42,6 +44,7 @@ class MyriadNormalizer {
42
44
  url: `https://myriad.markets/markets/${raw.slug || raw.id}`,
43
45
  image: raw.imageUrl,
44
46
  tags: raw.topics || [],
47
+ status,
45
48
  };
46
49
  (0, market_utils_1.addBinaryOutcomes)(um);
47
50
  return um;
@@ -51,9 +54,37 @@ class MyriadNormalizer {
51
54
  return null;
52
55
  const markets = [];
53
56
  for (const m of raw.markets || []) {
54
- const um = this.normalizeMarket(m);
55
- if (um)
56
- markets.push(um);
57
+ const rawOutcomes = m.outcomes || [];
58
+ // Binary markets (2 outcomes): keep as-is.
59
+ // Multi-outcome markets (>2): expand each outcome into a separate
60
+ // binary market with a specific title (e.g. "Premier League - Arsenal")
61
+ // so the matching engine can find cross-venue identity matches against
62
+ // venues like Polymarket that split each outcome into its own market.
63
+ if (rawOutcomes.length <= 2) {
64
+ const um = this.normalizeMarket(m);
65
+ if (um)
66
+ markets.push(um);
67
+ }
68
+ else {
69
+ const eventTitle = m.title || raw.title || '';
70
+ for (const outcome of rawOutcomes) {
71
+ const outcomeTitle = outcome.title || `Outcome ${outcome.id}`;
72
+ const syntheticMarket = {
73
+ ...m,
74
+ id: m.id,
75
+ title: `${eventTitle} - ${outcomeTitle}`,
76
+ outcomes: [
77
+ { ...outcome, title: outcomeTitle },
78
+ { id: -(outcome.id || 0), title: `Not ${outcomeTitle}`, price: 1 - (Number(outcome.price) || 0) },
79
+ ],
80
+ };
81
+ const um = this.normalizeMarket(syntheticMarket);
82
+ if (um) {
83
+ um.marketId = `${m.networkId}:${m.id}:${outcome.id}`;
84
+ markets.push(um);
85
+ }
86
+ }
87
+ }
57
88
  }
58
89
  return {
59
90
  id: String(raw.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-08T23:06:00.151Z
3
+ * Generated at: 2026-05-09T16:59:10.826Z
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-08T23:06:00.151Z
6
+ * Generated at: 2026-05-09T16:59:10.826Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
3
- * Generated at: 2026-05-08T23:06:00.102Z
3
+ * Generated at: 2026-05-09T16:59:10.779Z
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-08T23:06:00.102Z
6
+ * Generated at: 2026-05-09T16:59:10.779Z
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-08T23:06:00.118Z
3
+ * Generated at: 2026-05-09T16:59:10.793Z
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-08T23:06:00.118Z
6
+ * Generated at: 2026-05-09T16:59:10.793Z
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-08T23:06:00.115Z
3
+ * Generated at: 2026-05-09T16:59:10.791Z
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-08T23:06:00.115Z
6
+ * Generated at: 2026-05-09T16:59:10.791Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -188,6 +188,30 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
188
188
  }
189
189
  const side = built.params.side.toUpperCase() === 'BUY' ? clob_client_v2_1.Side.BUY : clob_client_v2_1.Side.SELL;
190
190
  const price = built.params.price || (side === clob_client_v2_1.Side.BUY ? 0.99 : 0.01);
191
+ // Extract actual fill data from the CLOB OrderResponse.
192
+ // response.status: 'MATCHED' | 'CONFIRMED' = immediately filled,
193
+ // 'LIVE' = resting on the book (filled: 0 is correct).
194
+ // takingAmount / makingAmount are string representations of raw USDC amounts (6 decimals).
195
+ const USDC_DECIMALS = 6;
196
+ const responseStatus = (response.status || '').toUpperCase();
197
+ const isImmediatelyFilled = responseStatus === 'MATCHED' || responseStatus === 'CONFIRMED';
198
+ let filled = 0;
199
+ if (isImmediatelyFilled) {
200
+ const takingRaw = typeof response.takingAmount === 'string'
201
+ ? parseFloat(response.takingAmount)
202
+ : (response.takingAmount ?? 0);
203
+ const makingRaw = typeof response.makingAmount === 'string'
204
+ ? parseFloat(response.makingAmount)
205
+ : (response.makingAmount ?? 0);
206
+ // For BUY: makingAmount is USDC spent, takingAmount is shares received.
207
+ // For SELL: makingAmount is shares sold, takingAmount is USDC received.
208
+ // `filled` should reflect the share size that executed.
209
+ filled = side === clob_client_v2_1.Side.BUY
210
+ ? takingRaw / Math.pow(10, USDC_DECIMALS)
211
+ : makingRaw / Math.pow(10, USDC_DECIMALS);
212
+ }
213
+ const remaining = Math.max(0, built.params.amount - filled);
214
+ const orderStatus = filled >= built.params.amount ? 'filled' : 'open';
191
215
  return {
192
216
  id: response.orderID,
193
217
  marketId: built.params.marketId,
@@ -196,9 +220,9 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
196
220
  type: built.params.type,
197
221
  price,
198
222
  amount: built.params.amount,
199
- status: 'open',
200
- filled: 0,
201
- remaining: built.params.amount,
223
+ status: orderStatus,
224
+ filled,
225
+ remaining,
202
226
  fee: built.params.fee,
203
227
  timestamp: Date.now(),
204
228
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
3
- * Generated at: 2026-05-08T23:06:00.139Z
3
+ * Generated at: 2026-05-09T16:59:10.815Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const probableApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probableApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
6
- * Generated at: 2026-05-08T23:06:00.139Z
6
+ * Generated at: 2026-05-09T16:59:10.815Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -2607,7 +2607,10 @@ components:
2607
2607
  description: Lifecycle status of the order.
2608
2608
  filled:
2609
2609
  type: number
2610
- description: Amount filled
2610
+ description: 'Amount filled (USDC cost for buys, shares for sells)'
2611
+ filledShares:
2612
+ type: number
2613
+ description: Amount filled in shares/contracts (if different from USDC-denominated `filled`).
2611
2614
  remaining:
2612
2615
  type: number
2613
2616
  description: Amount remaining
@@ -2617,6 +2620,9 @@ components:
2617
2620
  fee:
2618
2621
  type: number
2619
2622
  description: 'Fee paid for this order, if known.'
2623
+ feeRateBps:
2624
+ type: number
2625
+ description: Fee rate in basis points applied to this order (e.g. 100 = 1%).
2620
2626
  required:
2621
2627
  - id
2622
2628
  - marketId
package/dist/types.d.ts CHANGED
@@ -160,11 +160,15 @@ export interface Order {
160
160
  /** Lifecycle status of the order. */
161
161
  status: 'pending' | 'open' | 'filled' | 'cancelled' | 'rejected';
162
162
  filled: number;
163
+ /** Amount filled in shares/contracts (if different from USDC-denominated `filled`). */
164
+ filledShares?: number;
163
165
  remaining: number;
164
166
  /** Unix timestamp in milliseconds when the order was created. */
165
167
  timestamp: number;
166
168
  /** Fee paid for this order, if known. */
167
169
  fee?: number;
170
+ /** Fee rate in basis points applied to this order (e.g. 100 = 1%). */
171
+ feeRateBps?: number;
168
172
  }
169
173
  export interface Position {
170
174
  /** The market this position is held in. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.40.1",
3
+ "version": "2.40.4",
4
4
  "description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,8 +29,8 @@
29
29
  "test": "jest -c jest.config.js",
30
30
  "server": "tsx watch src/server/index.ts",
31
31
  "server:prod": "node dist/server/index.js",
32
- "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.40.1,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.40.1,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.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.40.4,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.40.4,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",