pmxt-core 2.19.5 → 2.20.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.
Files changed (57) hide show
  1. package/dist/BaseExchange.d.ts +69 -30
  2. package/dist/BaseExchange.js +124 -82
  3. package/dist/exchanges/baozi/index.d.ts +2 -0
  4. package/dist/exchanges/baozi/index.js +2 -0
  5. package/dist/exchanges/baozi/price.d.ts +3 -0
  6. package/dist/exchanges/baozi/price.js +16 -0
  7. package/dist/exchanges/baozi/price.test.d.ts +1 -0
  8. package/dist/exchanges/baozi/price.test.js +33 -0
  9. package/dist/exchanges/baozi/utils.js +5 -9
  10. package/dist/exchanges/kalshi/api.d.ts +1 -1
  11. package/dist/exchanges/kalshi/api.js +1 -1
  12. package/dist/exchanges/kalshi/fetchOHLCV.js +5 -4
  13. package/dist/exchanges/kalshi/fetchOrderBook.js +21 -21
  14. package/dist/exchanges/kalshi/fetchTrades.js +2 -1
  15. package/dist/exchanges/kalshi/index.d.ts +3 -1
  16. package/dist/exchanges/kalshi/index.js +19 -16
  17. package/dist/exchanges/kalshi/price.d.ts +3 -0
  18. package/dist/exchanges/kalshi/price.js +14 -0
  19. package/dist/exchanges/kalshi/price.test.d.ts +1 -0
  20. package/dist/exchanges/kalshi/price.test.js +24 -0
  21. package/dist/exchanges/kalshi/utils.js +5 -4
  22. package/dist/exchanges/limitless/api.d.ts +1 -1
  23. package/dist/exchanges/limitless/api.js +1 -1
  24. package/dist/exchanges/limitless/index.d.ts +58 -19
  25. package/dist/exchanges/limitless/index.js +169 -101
  26. package/dist/exchanges/limitless/websocket.d.ts +10 -3
  27. package/dist/exchanges/limitless/websocket.js +71 -52
  28. package/dist/exchanges/myriad/api.d.ts +1 -1
  29. package/dist/exchanges/myriad/api.js +1 -1
  30. package/dist/exchanges/myriad/index.d.ts +3 -1
  31. package/dist/exchanges/myriad/index.js +7 -4
  32. package/dist/exchanges/myriad/price.d.ts +1 -0
  33. package/dist/exchanges/myriad/price.js +7 -0
  34. package/dist/exchanges/myriad/price.test.d.ts +1 -0
  35. package/dist/exchanges/myriad/price.test.js +17 -0
  36. package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
  37. package/dist/exchanges/polymarket/api-clob.js +1 -1
  38. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  39. package/dist/exchanges/polymarket/api-data.js +1 -1
  40. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  41. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  42. package/dist/exchanges/polymarket/index.d.ts +28 -15
  43. package/dist/exchanges/polymarket/index.js +217 -137
  44. package/dist/exchanges/polymarket/websocket.d.ts +11 -4
  45. package/dist/exchanges/polymarket/websocket.js +58 -36
  46. package/dist/exchanges/probable/api.d.ts +1 -1
  47. package/dist/exchanges/probable/api.js +1 -1
  48. package/dist/exchanges/probable/index.d.ts +2 -0
  49. package/dist/exchanges/probable/index.js +2 -0
  50. package/dist/subscriber/base.d.ts +82 -0
  51. package/dist/subscriber/base.js +2 -0
  52. package/dist/subscriber/external/goldsky.d.ts +96 -0
  53. package/dist/subscriber/external/goldsky.js +412 -0
  54. package/dist/subscriber/watcher.d.ts +85 -0
  55. package/dist/subscriber/watcher.js +178 -0
  56. package/dist/types.d.ts +5 -0
  57. package/package.json +3 -3
@@ -13,6 +13,7 @@ const errors_2 = require("../../errors");
13
13
  const utils_1 = require("./utils");
14
14
  const openapi_1 = require("../../utils/openapi");
15
15
  const api_1 = require("./api");
16
+ const price_1 = require("./price");
16
17
  class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
17
18
  has = {
18
19
  fetchMarkets: true,
@@ -26,6 +27,8 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
26
27
  fetchOpenOrders: 'emulated',
27
28
  fetchPositions: true,
28
29
  fetchBalance: 'emulated',
30
+ watchAddress: false,
31
+ unwatchAddress: false,
29
32
  watchOrderBook: 'emulated',
30
33
  watchTrades: 'emulated',
31
34
  fetchMyTrades: true,
@@ -119,7 +122,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
119
122
  return filtered.map((t, index) => ({
120
123
  id: `${t.blockNumber || t.timestamp}-${index}`,
121
124
  timestamp: (t.timestamp || 0) * 1000,
122
- price: t.shares > 0 ? Number(t.value) / Number(t.shares) : 0,
125
+ price: (0, price_1.resolveMyriadPrice)(t),
123
126
  amount: Number(t.shares || 0),
124
127
  side: t.action === 'buy' ? 'buy' : 'sell',
125
128
  }));
@@ -147,7 +150,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
147
150
  return tradeEvents.map((t, i) => ({
148
151
  id: `${t.blockNumber || t.timestamp}-${i}`,
149
152
  timestamp: (t.timestamp || 0) * 1000,
150
- price: t.shares > 0 ? Number(t.value) / Number(t.shares) : 0,
153
+ price: (0, price_1.resolveMyriadPrice)(t),
151
154
  amount: Number(t.shares || 0),
152
155
  side: t.action === 'buy' ? 'buy' : 'sell',
153
156
  }));
@@ -218,7 +221,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
218
221
  outcomeLabel: pos.outcomeTitle || `Outcome ${pos.outcomeId}`,
219
222
  size: Number(pos.shares || 0),
220
223
  entryPrice: Number(pos.price || 0),
221
- currentPrice: Number(pos.value || 0) / Math.max(Number(pos.shares || 1), 1),
224
+ currentPrice: (0, price_1.resolveMyriadPrice)(pos),
222
225
  unrealizedPnL: Number(pos.profit || 0),
223
226
  }));
224
227
  }
@@ -250,7 +253,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
250
253
  }
251
254
  return this.ws.watchOrderBook(id);
252
255
  }
253
- async watchTrades(id, _since, _limit) {
256
+ async watchTrades(id, address, _since, _limit) {
254
257
  this.ensureAuth();
255
258
  if (!this.ws) {
256
259
  this.ws = new websocket_1.MyriadWebSocket(this.callApi.bind(this));
@@ -0,0 +1 @@
1
+ export declare function resolveMyriadPrice(event: any): number;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveMyriadPrice = resolveMyriadPrice;
4
+ function resolveMyriadPrice(event) {
5
+ const shares = Math.max(Number(event.shares || 1), 1);
6
+ return Number(event.value || 0) / shares;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const price_1 = require("./price");
4
+ describe("resolveMyriadPrice", () => {
5
+ test("divides value by shares", () => {
6
+ expect((0, price_1.resolveMyriadPrice)({ value: 100, shares: 4 })).toBe(25);
7
+ });
8
+ test("treats missing shares as 1", () => {
9
+ expect((0, price_1.resolveMyriadPrice)({ value: 50 })).toBe(50);
10
+ });
11
+ test("treats zero shares as 1 to avoid division by zero", () => {
12
+ expect((0, price_1.resolveMyriadPrice)({ value: 80, shares: 0 })).toBe(80);
13
+ });
14
+ test("treats missing value as 0", () => {
15
+ expect((0, price_1.resolveMyriadPrice)({ shares: 5 })).toBe(0);
16
+ });
17
+ });
@@ -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-03-06T08:42:31.160Z
3
+ * Generated at: 2026-03-14T16:22:11.391Z
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-03-06T08:42:31.160Z
6
+ * Generated at: 2026-03-14T16:22:11.391Z
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-03-06T08:42:31.174Z
3
+ * Generated at: 2026-03-14T16:22:11.405Z
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-03-06T08:42:31.174Z
6
+ * Generated at: 2026-03-14T16:22:11.405Z
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-03-06T08:42:31.170Z
3
+ * Generated at: 2026-03-14T16:22:11.402Z
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-03-06T08:42:31.170Z
6
+ * Generated at: 2026-03-14T16:22:11.402Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -1,7 +1,11 @@
1
- import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, OHLCVParams, TradesParams, ExchangeCredentials, EventFetchParams, MyTradesParams } from '../../BaseExchange';
2
- import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, UserTrade, Order, Position, Balance, CreateOrderParams, BuiltOrder } from '../../types';
1
+ import { EventFetchParams, ExchangeCredentials, HistoryFilterParams, MarketFilterParams, MyTradesParams, OHLCVParams, PredictionMarketExchange, TradesParams } from '../../BaseExchange';
2
+ import { SubscribedAddressSnapshot, SubscriptionOption } from '../../subscriber/base';
3
+ import { buildPolymarketTradesActivity, POLYMARKET_DEFAULT_SUBSCRIPTION } from '../../subscriber/external/goldsky';
4
+ import { WatcherConfig } from '../../subscriber/watcher';
5
+ import { Balance, BuiltOrder, CreateOrderParams, Order, OrderBook, Position, PriceCandle, Trade, UnifiedEvent, UnifiedMarket, UserTrade } from '../../types';
3
6
  import { PolymarketWebSocketConfig } from './websocket';
4
- export type { PolymarketWebSocketConfig };
7
+ export type { PolymarketWebSocketConfig, WatcherConfig };
8
+ export { POLYMARKET_DEFAULT_SUBSCRIPTION, buildPolymarketTradesActivity };
5
9
  export interface PolymarketExchangeOptions {
6
10
  credentials?: ExchangeCredentials;
7
11
  websocket?: PolymarketWebSocketConfig;
@@ -19,6 +23,8 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
19
23
  fetchOpenOrders: true;
20
24
  fetchPositions: true;
21
25
  fetchBalance: true;
26
+ watchAddress: true;
27
+ unwatchAddress: true;
22
28
  watchOrderBook: true;
23
29
  watchTrades: true;
24
30
  fetchMyTrades: true;
@@ -31,6 +37,7 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
31
37
  private wsConfig?;
32
38
  private cachedApiCreds?;
33
39
  private cachedAddress?;
40
+ private ws?;
34
41
  constructor(options?: ExchangeCredentials | PolymarketExchangeOptions);
35
42
  get name(): string;
36
43
  /**
@@ -39,17 +46,9 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
39
46
  * a privateKey was provided (not apiKey/apiSecret/passphrase).
40
47
  */
41
48
  initAuth(): Promise<void>;
42
- protected sign(method: string, path: string, _params: Record<string, any>): Record<string, string>;
43
- protected mapImplicitApiError(error: any): any;
44
- protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
45
- protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
46
49
  fetchOHLCV(id: string, params: OHLCVParams): Promise<PriceCandle[]>;
47
50
  fetchOrderBook(id: string): Promise<OrderBook>;
48
51
  fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
49
- /**
50
- * Ensure authentication is initialized before trading operations.
51
- */
52
- private ensureAuth;
53
52
  /**
54
53
  * Pre-warm the SDK's internal caches for a market outcome.
55
54
  *
@@ -78,11 +77,25 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
78
77
  cancelOrder(orderId: string): Promise<Order>;
79
78
  fetchOrder(orderId: string): Promise<Order>;
80
79
  fetchOpenOrders(marketId?: string): Promise<Order[]>;
80
+ fetchUserTrades(address: string, params?: MyTradesParams): Promise<UserTrade[]>;
81
81
  fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
82
- fetchPositions(): Promise<Position[]>;
83
- fetchBalance(): Promise<Balance[]>;
84
- private ws?;
82
+ fetchPositions(address?: string): Promise<Position[]>;
83
+ fetchBalance(address?: string): Promise<Balance[]>;
85
84
  watchOrderBook(id: string, limit?: number): Promise<OrderBook>;
86
- watchTrades(id: string, since?: number, limit?: number): Promise<Trade[]>;
85
+ watchTrades(id: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
86
+ watchAddress(address: string, types?: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
87
+ unwatchAddress(address: string): Promise<void>;
87
88
  close(): Promise<void>;
89
+ protected sign(method: string, path: string, _params: Record<string, any>): Record<string, string>;
90
+ protected mapImplicitApiError(error: any): any;
91
+ protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
92
+ protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
93
+ /**
94
+ * Ensure authentication is initialized before trading operations.
95
+ */
96
+ private ensureAuth;
97
+ /** Fetch on-chain USDC balance on Polygon for any address without requiring credentials. */
98
+ private getAddressOnChainBalance;
99
+ private ensureWs;
100
+ private fetchWatchedAddressActivity;
88
101
  }