pmxt-core 2.40.3 → 2.40.5

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-09T06:13:38.024Z
3
+ * Generated at: 2026-05-09T17:30:18.563Z
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-09T06:13:38.024Z
6
+ * Generated at: 2026-05-09T17:30:18.563Z
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-09T06:13:38.063Z
3
+ * Generated at: 2026-05-09T17:30:18.602Z
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-09T06:13:38.063Z
6
+ * Generated at: 2026-05-09T17:30:18.602Z
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-09T06:13:38.074Z
3
+ * Generated at: 2026-05-09T17:30:18.613Z
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-09T06:13:38.074Z
6
+ * Generated at: 2026-05-09T17:30:18.613Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -63,6 +63,10 @@ export declare class MyriadFetcher implements IExchangeFetcher<MyriadRawMarket,
63
63
  fetchRawMarkets(params?: MarketFilterParams): Promise<MyriadRawMarket[]>;
64
64
  fetchRawEvents(params: EventFetchParams): Promise<MyriadRawQuestion[]>;
65
65
  fetchRawOHLCV(id: string, _params: OHLCVParams): Promise<MyriadRawMarket>;
66
+ fetchClobOrderBook(networkId: string, marketId: string, outcome: number): Promise<{
67
+ bids: [string, string][];
68
+ asks: [string, string][];
69
+ } | null>;
66
70
  fetchRawOrderBook(id: string): Promise<MyriadRawMarket>;
67
71
  fetchRawTrades(id: string, params: TradesParams): Promise<MyriadRawTradeEvent[]>;
68
72
  fetchRawMyTrades(params: MyTradesParams, walletAddress: string): Promise<MyriadRawTradeEvent[]>;
@@ -118,6 +118,21 @@ class MyriadFetcher {
118
118
  throw errors_1.myriadErrorMapper.mapError(error);
119
119
  }
120
120
  }
121
+ async fetchClobOrderBook(networkId, marketId, outcome) {
122
+ try {
123
+ const response = await this.ctx.http.get(`${this.baseUrl}/markets/${marketId}/orderbook`, {
124
+ params: { network_id: Number(networkId), outcome },
125
+ headers: this.ctx.getHeaders(),
126
+ });
127
+ const data = response.data;
128
+ if (data.error)
129
+ return null;
130
+ return { bids: data.bids || [], asks: data.asks || [] };
131
+ }
132
+ catch {
133
+ return null;
134
+ }
135
+ }
121
136
  async fetchRawOrderBook(id) {
122
137
  try {
123
138
  const parts = id.split(':');
@@ -89,6 +89,21 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
89
89
  return this.normalizer.normalizeOHLCV(rawMarket, params, parsedOutcomeId);
90
90
  }
91
91
  async fetchOrderBook(outcomeId) {
92
+ const parts = outcomeId.split(':');
93
+ if (parts.length >= 3) {
94
+ const [networkId, marketId, oid] = parts;
95
+ const numericOid = Number(oid);
96
+ // CLOB markets expose a real orderbook endpoint.
97
+ // For binary markets outcome is 0 (YES) or 1 (NO).
98
+ // For AMM markets the endpoint returns an error and we fall back.
99
+ if (!isNaN(numericOid) && numericOid >= 0) {
100
+ const clob = await this.fetcher.fetchClobOrderBook(networkId, marketId, numericOid);
101
+ if (clob) {
102
+ return this.normalizer.normalizeClobOrderBook(clob);
103
+ }
104
+ }
105
+ }
106
+ // AMM fallback: emulate orderbook from spot prices
92
107
  const rawMarket = await this.fetcher.fetchRawOrderBook(outcomeId);
93
108
  return this.normalizer.normalizeOrderBook(rawMarket, outcomeId);
94
109
  }
@@ -7,6 +7,10 @@ export declare class MyriadNormalizer implements IExchangeNormalizer<MyriadRawMa
7
7
  normalizeEvent(raw: MyriadRawQuestion): UnifiedEvent | null;
8
8
  normalizeOHLCV(raw: MyriadRawMarket, params: OHLCVParams, outcomeId?: string): PriceCandle[];
9
9
  normalizeOrderBook(raw: MyriadRawMarket, id: string): OrderBook;
10
+ normalizeClobOrderBook(raw: {
11
+ bids: [string, string][];
12
+ asks: [string, string][];
13
+ }): OrderBook;
10
14
  normalizeTrade(raw: MyriadRawTradeEvent, index: number): Trade;
11
15
  normalizeUserTrade(raw: MyriadRawTradeEvent, index: number): UserTrade;
12
16
  normalizePosition(raw: MyriadRawPortfolioItem): Position;
@@ -140,11 +140,26 @@ class MyriadNormalizer {
140
140
  const parts = id.split(':');
141
141
  const outcomeId = parts.length >= 3 ? parts[2] : undefined;
142
142
  const outcomes = raw.outcomes || [];
143
- const outcome = outcomes.find((o) => String(o.id) === outcomeId) || outcomes[0];
144
- if (!outcome) {
143
+ if (!outcomes.length) {
145
144
  return { bids: [], asks: [], timestamp: Date.now() };
146
145
  }
147
- const price = Number(outcome.price) || 0;
146
+ const numericId = Number(outcomeId);
147
+ let price;
148
+ if (!isNaN(numericId) && numericId < 0) {
149
+ // Synthetic NO outcome (negative ID from normalizeEvent).
150
+ // The NO price is the sum of all other outcomes in the AMM pool.
151
+ const positiveId = -numericId;
152
+ price = outcomes
153
+ .filter((o) => Number(o.id) !== positiveId)
154
+ .reduce((sum, o) => sum + (Number(o.price) || 0), 0);
155
+ }
156
+ else {
157
+ const outcome = outcomes.find((o) => String(o.id) === outcomeId) || outcomes[0];
158
+ if (!outcome) {
159
+ return { bids: [], asks: [], timestamp: Date.now() };
160
+ }
161
+ price = Number(outcome.price) || 0;
162
+ }
148
163
  const liquidity = Number(raw.liquidity || 0);
149
164
  const size = liquidity > 0 ? liquidity : 1;
150
165
  return {
@@ -153,6 +168,20 @@ class MyriadNormalizer {
153
168
  timestamp: Date.now(),
154
169
  };
155
170
  }
171
+ normalizeClobOrderBook(raw) {
172
+ const WEI = 1e18;
173
+ return {
174
+ bids: raw.bids.map(([priceWei, sizeWei]) => ({
175
+ price: Number(priceWei) / WEI,
176
+ size: Number(sizeWei) / WEI,
177
+ })),
178
+ asks: raw.asks.map(([priceWei, sizeWei]) => ({
179
+ price: Number(priceWei) / WEI,
180
+ size: Number(sizeWei) / WEI,
181
+ })),
182
+ timestamp: Date.now(),
183
+ };
184
+ }
156
185
  normalizeTrade(raw, index) {
157
186
  return {
158
187
  id: `${raw.blockNumber || raw.timestamp}-${index}`,
@@ -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-09T06:13:38.077Z
3
+ * Generated at: 2026-05-09T17:30:18.616Z
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-09T06:13:38.077Z
6
+ * Generated at: 2026-05-09T17:30:18.616Z
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-09T06:13:38.032Z
3
+ * Generated at: 2026-05-09T17:30:18.571Z
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-09T06:13:38.032Z
6
+ * Generated at: 2026-05-09T17:30:18.571Z
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-09T06:13:38.046Z
3
+ * Generated at: 2026-05-09T17:30:18.584Z
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-09T06:13:38.046Z
6
+ * Generated at: 2026-05-09T17:30:18.584Z
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-09T06:13:38.043Z
3
+ * Generated at: 2026-05-09T17:30:18.581Z
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-09T06:13:38.043Z
6
+ * Generated at: 2026-05-09T17:30:18.581Z
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-09T06:13:38.068Z
3
+ * Generated at: 2026-05-09T17:30:18.608Z
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-09T06:13:38.068Z
6
+ * Generated at: 2026-05-09T17:30:18.608Z
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.3",
3
+ "version": "2.40.5",
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.3,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.3,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.5,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.5,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",