pmxt-core 2.6.0 → 2.8.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 (63) hide show
  1. package/dist/BaseExchange.d.ts +14 -0
  2. package/dist/BaseExchange.js +76 -0
  3. package/dist/exchanges/kalshi/fetchEvents.d.ts +2 -1
  4. package/dist/exchanges/kalshi/fetchEvents.js +6 -6
  5. package/dist/exchanges/kalshi/fetchMarkets.d.ts +2 -1
  6. package/dist/exchanges/kalshi/fetchMarkets.js +22 -24
  7. package/dist/exchanges/kalshi/fetchOHLCV.d.ts +2 -1
  8. package/dist/exchanges/kalshi/fetchOHLCV.js +2 -2
  9. package/dist/exchanges/kalshi/fetchOrderBook.d.ts +2 -1
  10. package/dist/exchanges/kalshi/fetchOrderBook.js +2 -2
  11. package/dist/exchanges/kalshi/fetchTrades.d.ts +2 -1
  12. package/dist/exchanges/kalshi/fetchTrades.js +2 -2
  13. package/dist/exchanges/kalshi/index.js +11 -15
  14. package/dist/exchanges/kalshi/kalshi.test.js +47 -18
  15. package/dist/exchanges/limitless/fetchEvents.d.ts +2 -1
  16. package/dist/exchanges/limitless/fetchEvents.js +6 -4
  17. package/dist/exchanges/limitless/fetchMarkets.d.ts +2 -1
  18. package/dist/exchanges/limitless/fetchMarkets.js +7 -7
  19. package/dist/exchanges/limitless/fetchOHLCV.d.ts +2 -1
  20. package/dist/exchanges/limitless/fetchOHLCV.js +2 -2
  21. package/dist/exchanges/limitless/fetchOrderBook.d.ts +2 -1
  22. package/dist/exchanges/limitless/fetchOrderBook.js +2 -2
  23. package/dist/exchanges/limitless/fetchTrades.d.ts +2 -1
  24. package/dist/exchanges/limitless/fetchTrades.js +5 -1
  25. package/dist/exchanges/limitless/index.js +5 -5
  26. package/dist/exchanges/myriad/fetchEvents.d.ts +2 -1
  27. package/dist/exchanges/myriad/fetchEvents.js +6 -6
  28. package/dist/exchanges/myriad/fetchMarkets.d.ts +2 -1
  29. package/dist/exchanges/myriad/fetchMarkets.js +10 -10
  30. package/dist/exchanges/myriad/fetchOHLCV.d.ts +2 -1
  31. package/dist/exchanges/myriad/fetchOHLCV.js +2 -2
  32. package/dist/exchanges/myriad/fetchOrderBook.d.ts +2 -1
  33. package/dist/exchanges/myriad/fetchOrderBook.js +2 -2
  34. package/dist/exchanges/myriad/fetchTrades.d.ts +2 -1
  35. package/dist/exchanges/myriad/fetchTrades.js +2 -2
  36. package/dist/exchanges/myriad/index.js +8 -12
  37. package/dist/exchanges/polymarket/fetchEvents.d.ts +2 -1
  38. package/dist/exchanges/polymarket/fetchEvents.js +8 -8
  39. package/dist/exchanges/polymarket/fetchMarkets.d.ts +2 -1
  40. package/dist/exchanges/polymarket/fetchMarkets.js +19 -19
  41. package/dist/exchanges/polymarket/fetchOHLCV.d.ts +2 -1
  42. package/dist/exchanges/polymarket/fetchOHLCV.js +2 -2
  43. package/dist/exchanges/polymarket/fetchOrderBook.d.ts +2 -1
  44. package/dist/exchanges/polymarket/fetchOrderBook.js +2 -2
  45. package/dist/exchanges/polymarket/fetchTrades.d.ts +2 -1
  46. package/dist/exchanges/polymarket/fetchTrades.js +2 -2
  47. package/dist/exchanges/polymarket/index.js +5 -5
  48. package/dist/exchanges/polymarket/utils.d.ts +2 -2
  49. package/dist/exchanges/polymarket/utils.js +7 -42
  50. package/dist/exchanges/probable/fetchEvents.d.ts +4 -3
  51. package/dist/exchanges/probable/fetchEvents.js +13 -13
  52. package/dist/exchanges/probable/fetchMarkets.d.ts +2 -1
  53. package/dist/exchanges/probable/fetchMarkets.js +16 -16
  54. package/dist/exchanges/probable/fetchOHLCV.d.ts +2 -1
  55. package/dist/exchanges/probable/fetchOHLCV.js +2 -2
  56. package/dist/exchanges/probable/fetchOrderBook.d.ts +2 -1
  57. package/dist/exchanges/probable/fetchOrderBook.js +2 -2
  58. package/dist/exchanges/probable/fetchTrades.d.ts +2 -2
  59. package/dist/exchanges/probable/fetchTrades.js +5 -1
  60. package/dist/exchanges/probable/index.js +7 -7
  61. package/dist/server/app.js +9 -0
  62. package/dist/types.d.ts +1 -0
  63. package/package.json +4 -4
@@ -1,3 +1,4 @@
1
1
  import { EventFetchParams } from '../../BaseExchange';
2
2
  import { UnifiedEvent } from '../../types';
3
- export declare function fetchEvents(params: EventFetchParams): Promise<UnifiedEvent[]>;
3
+ import { AxiosInstance } from 'axios';
4
+ export declare function fetchEvents(params: EventFetchParams, http?: AxiosInstance): Promise<UnifiedEvent[]>;
@@ -40,9 +40,11 @@ exports.fetchEvents = fetchEvents;
40
40
  const axios_1 = __importDefault(require("axios"));
41
41
  const utils_1 = require("./utils");
42
42
  const errors_1 = require("./errors");
43
- async function fetchEventBySlug(slug) {
43
+ async function fetchEventBySlug(slug, http) {
44
44
  const { HttpClient, MarketFetcher } = await Promise.resolve().then(() => __importStar(require('@limitless-exchange/sdk')));
45
45
  const httpClient = new HttpClient({ baseURL: utils_1.LIMITLESS_API_URL });
46
+ // TODO: Ideally inject 'http' into HttpClient if supported, but SDK abstracts it.
47
+ // For now, single market fetch uses SDK's internal client.
46
48
  const marketFetcher = new MarketFetcher(httpClient);
47
49
  const market = await marketFetcher.getMarket(slug);
48
50
  if (!market)
@@ -70,18 +72,18 @@ async function fetchEventBySlug(slug) {
70
72
  tags: market.tags || []
71
73
  };
72
74
  }
73
- async function fetchEvents(params) {
75
+ async function fetchEvents(params, http = axios_1.default) {
74
76
  try {
75
77
  // Handle eventId/slug lookup (same thing for Limitless)
76
78
  if (params.eventId || params.slug) {
77
79
  const slug = params.eventId || params.slug;
78
- const event = await fetchEventBySlug(slug);
80
+ const event = await fetchEventBySlug(slug, http);
79
81
  return event ? [event] : [];
80
82
  }
81
83
  // NOTE: The Limitless /markets/search endpoint currently only returns active/funded markets.
82
84
  // It does not include expired or resolved markets in search results.
83
85
  // Consequently, status 'inactive' will likely return 0 results and 'all' will only show active markets.
84
- const response = await axios_1.default.get(`${utils_1.LIMITLESS_API_URL}/markets/search`, {
86
+ const response = await http.get(`${utils_1.LIMITLESS_API_URL}/markets/search`, {
85
87
  params: {
86
88
  query: params.query,
87
89
  limit: params?.limit || 10000,
@@ -1,3 +1,4 @@
1
1
  import { MarketFetchParams } from '../../BaseExchange';
2
2
  import { UnifiedMarket } from '../../types';
3
- export declare function fetchMarkets(params?: MarketFetchParams, apiKey?: string): Promise<UnifiedMarket[]>;
3
+ import { AxiosInstance } from 'axios';
4
+ export declare function fetchMarkets(params?: MarketFetchParams, apiKey?: string, http?: AxiosInstance): Promise<UnifiedMarket[]>;
@@ -40,7 +40,7 @@ exports.fetchMarkets = fetchMarkets;
40
40
  const axios_1 = __importDefault(require("axios"));
41
41
  const utils_1 = require("./utils");
42
42
  const errors_1 = require("./errors");
43
- async function fetchMarkets(params, apiKey) {
43
+ async function fetchMarkets(params, apiKey, http = axios_1.default) {
44
44
  // Limitless API currently only supports fetching active markets for lists
45
45
  // Early return to avoid SDK initialization in tests
46
46
  if (params?.status === 'inactive' || params?.status === 'closed') {
@@ -74,7 +74,7 @@ async function fetchMarkets(params, apiKey) {
74
74
  }
75
75
  // Handle query-based search
76
76
  if (params?.query) {
77
- return await searchMarkets(marketFetcher, params.query, params);
77
+ return await searchMarkets(params.query, params, http);
78
78
  }
79
79
  // Default: fetch active markets
80
80
  return await fetchMarketsDefault(marketFetcher, params);
@@ -90,14 +90,14 @@ async function fetchMarketsBySlug(marketFetcher, slug) {
90
90
  const unifiedMarket = (0, utils_1.mapMarketToUnified)(market);
91
91
  return unifiedMarket ? [unifiedMarket] : [];
92
92
  }
93
- async function searchMarkets(marketFetcher, query, params) {
93
+ async function searchMarkets(query, params, http) {
94
94
  // SDK doesn't have a search method yet, use axios directly
95
95
  // NOTE: The Limitless /markets/search endpoint currently only returns active/funded markets.
96
96
  // It does not include expired or resolved markets in search results.
97
- const response = await axios_1.default.get(`${utils_1.LIMITLESS_API_URL}/markets/search`, {
97
+ const response = await http.get(`${utils_1.LIMITLESS_API_URL}/markets/search`, {
98
98
  params: {
99
99
  query: query,
100
- limit: params?.limit || 10000,
100
+ limit: params?.limit || 250000,
101
101
  page: params?.page || 1,
102
102
  similarityThreshold: params?.similarityThreshold || 0.5
103
103
  }
@@ -121,10 +121,10 @@ async function searchMarkets(marketFetcher, query, params) {
121
121
  }
122
122
  return allMarkets
123
123
  .filter((m) => m !== null && m.outcomes.length > 0)
124
- .slice(0, params?.limit || 10000);
124
+ .slice(0, params?.limit || 250000);
125
125
  }
126
126
  async function fetchMarketsDefault(marketFetcher, params) {
127
- const limit = params?.limit || 10000;
127
+ const limit = params?.limit || 250000;
128
128
  const offset = params?.offset || 0;
129
129
  // Map sort parameter to SDK's sortBy
130
130
  let sortBy = 'lp_rewards';
@@ -1,7 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { HistoryFilterParams, OHLCVParams } from '../../BaseExchange';
2
3
  import { PriceCandle } from '../../types';
3
4
  /**
4
5
  * Fetch historical price data (candles) for a specific market.
5
6
  * @param id - The market slug
6
7
  */
7
- export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
8
+ export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams, http?: AxiosInstance): Promise<PriceCandle[]>;
@@ -12,7 +12,7 @@ const errors_1 = require("./errors");
12
12
  * Fetch historical price data (candles) for a specific market.
13
13
  * @param id - The market slug
14
14
  */
15
- async function fetchOHLCV(id, params) {
15
+ async function fetchOHLCV(id, params, http = axios_1.default) {
16
16
  (0, validation_1.validateIdFormat)(id, 'OHLCV');
17
17
  // Validate resolution is provided
18
18
  if (!params.resolution) {
@@ -22,7 +22,7 @@ async function fetchOHLCV(id, params) {
22
22
  const fidelity = (0, utils_1.mapIntervalToFidelity)(params.resolution);
23
23
  // New API endpoint: /markets/{slug}/historical-price
24
24
  const url = `${utils_1.LIMITLESS_API_URL}/markets/${id}/historical-price`;
25
- const response = await axios_1.default.get(url, {
25
+ const response = await http.get(url, {
26
26
  params: { fidelity }
27
27
  });
28
28
  const data = response.data;
@@ -1,6 +1,7 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { OrderBook } from '../../types';
2
3
  /**
3
4
  * Fetch the current order book for a specific market.
4
5
  * @param id - The market slug (preferred) or CLOB token ID
5
6
  */
6
- export declare function fetchOrderBook(id: string): Promise<OrderBook>;
7
+ export declare function fetchOrderBook(id: string, http?: AxiosInstance): Promise<OrderBook>;
@@ -20,13 +20,13 @@ function convertSize(rawSize) {
20
20
  * Fetch the current order book for a specific market.
21
21
  * @param id - The market slug (preferred) or CLOB token ID
22
22
  */
23
- async function fetchOrderBook(id) {
23
+ async function fetchOrderBook(id, http = axios_1.default) {
24
24
  (0, validation_1.validateIdFormat)(id, 'OrderBook');
25
25
  try {
26
26
  // New API uses slugs: /markets/{slug}/orderbook
27
27
  // If 'id' is a numeric token ID, this might fail unless we look up the slug.
28
28
  const url = `${utils_1.LIMITLESS_API_URL}/markets/${id}/orderbook`;
29
- const response = await axios_1.default.get(url);
29
+ const response = await http.get(url);
30
30
  const data = response.data;
31
31
  // Response format: { bids: [{price: 0.52, size: 100000000}], asks: [...] }
32
32
  // Sizes are in smallest unit (USDC with 6 decimals), convert to human-readable
@@ -1,7 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { HistoryFilterParams, TradesParams } from '../../BaseExchange';
2
3
  import { Trade } from '../../types';
3
4
  /**
4
5
  * Fetch trade history for a specific market or user.
5
6
  * @param id - The market slug or wallet address
6
7
  */
7
- export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
8
+ export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams, http?: AxiosInstance): Promise<Trade[]>;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.fetchTrades = fetchTrades;
7
+ const axios_1 = __importDefault(require("axios"));
4
8
  const errors_1 = require("./errors");
5
9
  /**
6
10
  * Fetch trade history for a specific market or user.
7
11
  * @param id - The market slug or wallet address
8
12
  */
9
- async function fetchTrades(id, params) {
13
+ async function fetchTrades(id, params, http = axios_1.default) {
10
14
  try {
11
15
  // Limitless API v1 does not provide a public endpoint to fetch trades for a specific market/outcome.
12
16
  // The previous implementation used /portfolio/trades which returns the *authenticated user's* trades,
@@ -80,16 +80,16 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
80
80
  async fetchMarketsImpl(params) {
81
81
  // Pass API key if available for authenticated requests
82
82
  const apiKey = this.auth?.getApiKey();
83
- return (0, fetchMarkets_1.fetchMarkets)(params, apiKey);
83
+ return (0, fetchMarkets_1.fetchMarkets)(params, apiKey, this.http);
84
84
  }
85
85
  async fetchEventsImpl(params) {
86
- return (0, fetchEvents_1.fetchEvents)(params);
86
+ return (0, fetchEvents_1.fetchEvents)(params, this.http);
87
87
  }
88
88
  async fetchOHLCV(id, params) {
89
- return (0, fetchOHLCV_1.fetchOHLCV)(id, params);
89
+ return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.http);
90
90
  }
91
91
  async fetchOrderBook(id) {
92
- return (0, fetchOrderBook_1.fetchOrderBook)(id);
92
+ return (0, fetchOrderBook_1.fetchOrderBook)(id, this.http);
93
93
  }
94
94
  async fetchTrades(id, params) {
95
95
  // Deprecation warning
@@ -97,7 +97,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
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
- return (0, fetchTrades_1.fetchTrades)(id, params);
100
+ return (0, fetchTrades_1.fetchTrades)(id, params, this.http);
101
101
  }
102
102
  // ----------------------------------------------------------------------------
103
103
  // Trading Methods
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { EventFetchParams } from '../../BaseExchange';
2
3
  import { UnifiedEvent } from '../../types';
3
- export declare function fetchEvents(params: EventFetchParams, headers?: Record<string, string>): Promise<UnifiedEvent[]>;
4
+ export declare function fetchEvents(params: EventFetchParams, headers?: Record<string, string>, http?: AxiosInstance): Promise<UnifiedEvent[]>;
@@ -7,13 +7,13 @@ exports.fetchEvents = fetchEvents;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const utils_1 = require("./utils");
9
9
  const errors_1 = require("./errors");
10
- async function fetchEvents(params, headers) {
10
+ async function fetchEvents(params, headers, http = axios_1.default) {
11
11
  try {
12
12
  if (params.eventId) {
13
- return await fetchQuestionById(params.eventId, headers);
13
+ return await fetchQuestionById(params.eventId, headers, http);
14
14
  }
15
15
  if (params.slug) {
16
- return await fetchQuestionById(params.slug, headers);
16
+ return await fetchQuestionById(params.slug, headers, http);
17
17
  }
18
18
  const limit = params.limit || 100;
19
19
  const queryParams = {
@@ -23,7 +23,7 @@ async function fetchEvents(params, headers) {
23
23
  if (params.query) {
24
24
  queryParams.keyword = params.query;
25
25
  }
26
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/questions`, {
26
+ const response = await http.get(`${utils_1.BASE_URL}/questions`, {
27
27
  params: queryParams,
28
28
  headers,
29
29
  });
@@ -40,8 +40,8 @@ async function fetchEvents(params, headers) {
40
40
  throw errors_1.myriadErrorMapper.mapError(error);
41
41
  }
42
42
  }
43
- async function fetchQuestionById(id, headers) {
44
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/questions/${id}`, { headers });
43
+ async function fetchQuestionById(id, headers, http) {
44
+ const response = await http.get(`${utils_1.BASE_URL}/questions/${id}`, { headers });
45
45
  const question = response.data.data || response.data;
46
46
  const event = (0, utils_1.mapQuestionToEvent)(question);
47
47
  return event ? [event] : [];
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { MarketFetchParams } from '../../BaseExchange';
2
3
  import { UnifiedMarket } from '../../types';
3
- export declare function fetchMarkets(params?: MarketFetchParams, headers?: Record<string, string>): Promise<UnifiedMarket[]>;
4
+ export declare function fetchMarkets(params?: MarketFetchParams, headers?: Record<string, string>, http?: AxiosInstance): Promise<UnifiedMarket[]>;
@@ -8,13 +8,13 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const utils_1 = require("./utils");
9
9
  const errors_1 = require("./errors");
10
10
  const MAX_PAGE_SIZE = 100;
11
- async function fetchMarkets(params, headers) {
11
+ async function fetchMarkets(params, headers, http = axios_1.default) {
12
12
  try {
13
13
  if (params?.marketId) {
14
- return await fetchMarketById(params.marketId, headers);
14
+ return await fetchMarketById(params.marketId, headers, http);
15
15
  }
16
16
  if (params?.slug) {
17
- return await fetchMarketBySlug(params.slug, headers);
17
+ return await fetchMarketBySlug(params.slug, headers, http);
18
18
  }
19
19
  const limit = params?.limit || 100;
20
20
  const queryParams = {
@@ -42,7 +42,7 @@ async function fetchMarkets(params, headers) {
42
42
  }
43
43
  // If we need more than one page, paginate
44
44
  if (limit <= MAX_PAGE_SIZE) {
45
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets`, {
45
+ const response = await http.get(`${utils_1.BASE_URL}/markets`, {
46
46
  params: queryParams,
47
47
  headers,
48
48
  });
@@ -56,7 +56,7 @@ async function fetchMarkets(params, headers) {
56
56
  while (page <= maxPages) {
57
57
  queryParams.page = page;
58
58
  queryParams.limit = MAX_PAGE_SIZE;
59
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets`, {
59
+ const response = await http.get(`${utils_1.BASE_URL}/markets`, {
60
60
  params: queryParams,
61
61
  headers,
62
62
  });
@@ -78,15 +78,15 @@ async function fetchMarkets(params, headers) {
78
78
  throw errors_1.myriadErrorMapper.mapError(error);
79
79
  }
80
80
  }
81
- async function fetchMarketById(marketId, headers) {
81
+ async function fetchMarketById(marketId, headers, http) {
82
82
  // marketId format: {networkId}:{id}
83
83
  const parts = marketId.split(':');
84
84
  if (parts.length !== 2) {
85
85
  // Try as slug
86
- return fetchMarketBySlug(marketId, headers);
86
+ return fetchMarketBySlug(marketId, headers, http);
87
87
  }
88
88
  const [networkId, id] = parts;
89
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets/${id}`, {
89
+ const response = await http.get(`${utils_1.BASE_URL}/markets/${id}`, {
90
90
  params: { network_id: Number(networkId) },
91
91
  headers,
92
92
  });
@@ -94,8 +94,8 @@ async function fetchMarketById(marketId, headers) {
94
94
  const um = (0, utils_1.mapMarketToUnified)(market);
95
95
  return um ? [um] : [];
96
96
  }
97
- async function fetchMarketBySlug(slug, headers) {
98
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets/${slug}`, { headers });
97
+ async function fetchMarketBySlug(slug, headers, http) {
98
+ const response = await http.get(`${utils_1.BASE_URL}/markets/${slug}`, { headers });
99
99
  const market = response.data.data || response.data;
100
100
  const um = (0, utils_1.mapMarketToUnified)(market);
101
101
  return um ? [um] : [];
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { OHLCVParams, HistoryFilterParams } from '../../BaseExchange';
2
3
  import { PriceCandle } from '../../types';
3
- export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams, headers?: Record<string, string>): Promise<PriceCandle[]>;
4
+ export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams, headers?: Record<string, string>, http?: AxiosInstance): Promise<PriceCandle[]>;
@@ -27,7 +27,7 @@ function selectTimeframe(interval) {
27
27
  return '7d';
28
28
  }
29
29
  }
30
- async function fetchOHLCV(id, params, headers) {
30
+ async function fetchOHLCV(id, params, headers, http = axios_1.default) {
31
31
  if (!params.resolution) {
32
32
  throw new Error('fetchOHLCV requires a resolution parameter.');
33
33
  }
@@ -41,7 +41,7 @@ async function fetchOHLCV(id, params, headers) {
41
41
  const networkId = parts[0];
42
42
  const marketId = parts[1];
43
43
  const outcomeId = parts.length >= 3 ? parts[2] : undefined;
44
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets/${marketId}`, {
44
+ const response = await http.get(`${utils_1.BASE_URL}/markets/${marketId}`, {
45
45
  params: { network_id: Number(networkId) },
46
46
  headers,
47
47
  });
@@ -1,2 +1,3 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { OrderBook } from '../../types';
2
- export declare function fetchOrderBook(id: string, headers?: Record<string, string>): Promise<OrderBook>;
3
+ export declare function fetchOrderBook(id: string, headers?: Record<string, string>, http?: AxiosInstance): Promise<OrderBook>;
@@ -10,7 +10,7 @@ const errors_1 = require("./errors");
10
10
  // Myriad is AMM-based -- there is no native order book.
11
11
  // We synthesize a minimal order book from the current outcome price
12
12
  // and quote data to give callers a consistent interface.
13
- async function fetchOrderBook(id, headers) {
13
+ async function fetchOrderBook(id, headers, http = axios_1.default) {
14
14
  try {
15
15
  // id format: {networkId}:{marketId}:{outcomeId}
16
16
  const parts = id.split(':');
@@ -19,7 +19,7 @@ async function fetchOrderBook(id, headers) {
19
19
  }
20
20
  const [networkId, marketId, outcomeId] = parts;
21
21
  // Fetch the market to get current prices
22
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets/${marketId}`, {
22
+ const response = await http.get(`${utils_1.BASE_URL}/markets/${marketId}`, {
23
23
  params: { network_id: Number(networkId) },
24
24
  headers,
25
25
  });
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { TradesParams, HistoryFilterParams } from '../../BaseExchange';
2
3
  import { Trade } from '../../types';
3
- export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams, headers?: Record<string, string>): Promise<Trade[]>;
4
+ export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams, headers?: Record<string, string>, http?: AxiosInstance): Promise<Trade[]>;
@@ -7,7 +7,7 @@ exports.fetchTrades = fetchTrades;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const utils_1 = require("./utils");
9
9
  const errors_1 = require("./errors");
10
- async function fetchTrades(id, params, headers) {
10
+ async function fetchTrades(id, params, headers, http = axios_1.default) {
11
11
  try {
12
12
  // id format: {networkId}:{marketId}:{outcomeId} or {networkId}:{marketId}
13
13
  const parts = id.split(':');
@@ -37,7 +37,7 @@ async function fetchTrades(id, params, headers) {
37
37
  if (params.end) {
38
38
  queryParams.until = Math.floor(ensureDate(params.end).getTime() / 1000);
39
39
  }
40
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/markets/${marketId}/events`, {
40
+ const response = await http.get(`${utils_1.BASE_URL}/markets/${marketId}/events`, {
41
41
  params: queryParams,
42
42
  headers,
43
43
  });
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MyriadExchange = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
4
  const BaseExchange_1 = require("../../BaseExchange");
9
5
  const fetchMarkets_1 = require("./fetchMarkets");
10
6
  const fetchEvents_1 = require("./fetchEvents");
@@ -59,23 +55,23 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
59
55
  // Market Data
60
56
  // ------------------------------------------------------------------------
61
57
  async fetchMarketsImpl(params) {
62
- return (0, fetchMarkets_1.fetchMarkets)(params, this.getHeaders());
58
+ return (0, fetchMarkets_1.fetchMarkets)(params, this.getHeaders(), this.http);
63
59
  }
64
60
  async fetchEventsImpl(params) {
65
- return (0, fetchEvents_1.fetchEvents)(params, this.getHeaders());
61
+ return (0, fetchEvents_1.fetchEvents)(params, this.getHeaders(), this.http);
66
62
  }
67
63
  async fetchOHLCV(id, params) {
68
- return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.getHeaders());
64
+ return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.getHeaders(), this.http);
69
65
  }
70
66
  async fetchOrderBook(id) {
71
- return (0, fetchOrderBook_1.fetchOrderBook)(id, this.getHeaders());
67
+ return (0, fetchOrderBook_1.fetchOrderBook)(id, this.getHeaders(), this.http);
72
68
  }
73
69
  async fetchTrades(id, params) {
74
70
  if ('resolution' in params && params.resolution !== undefined) {
75
71
  console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
76
72
  'It will be removed in v3.0.0. Please remove it from your code.');
77
73
  }
78
- return (0, fetchTrades_1.fetchTrades)(id, params, this.getHeaders());
74
+ return (0, fetchTrades_1.fetchTrades)(id, params, this.getHeaders(), this.http);
79
75
  }
80
76
  // ------------------------------------------------------------------------
81
77
  // Trading
@@ -109,7 +105,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
109
105
  // Use price as slippage tolerance for AMM
110
106
  quoteBody.slippage = 0.01;
111
107
  }
112
- const response = await axios_1.default.post(`${utils_1.BASE_URL}/markets/quote`, quoteBody, { headers });
108
+ const response = await this.http.post(`${utils_1.BASE_URL}/markets/quote`, quoteBody, { headers });
113
109
  const quote = response.data;
114
110
  return {
115
111
  id: `myriad-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
@@ -147,7 +143,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
147
143
  if (!walletAddress) {
148
144
  throw new errors_2.AuthenticationError('fetchPositions requires a wallet address. Pass privateKey as the wallet address in credentials.', 'Myriad');
149
145
  }
150
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/users/${walletAddress}/portfolio`, {
146
+ const response = await this.http.get(`${utils_1.BASE_URL}/users/${walletAddress}/portfolio`, {
151
147
  params: { limit: 100 },
152
148
  headers,
153
149
  });
@@ -177,7 +173,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
177
173
  if (!walletAddress) {
178
174
  throw new errors_2.AuthenticationError('fetchBalance requires a wallet address. Pass privateKey as the wallet address in credentials.', 'Myriad');
179
175
  }
180
- const response = await axios_1.default.get(`${utils_1.BASE_URL}/users/${walletAddress}/portfolio`, {
176
+ const response = await this.http.get(`${utils_1.BASE_URL}/users/${walletAddress}/portfolio`, {
181
177
  params: { limit: 100 },
182
178
  headers,
183
179
  });
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { EventFetchParams } from '../../BaseExchange';
2
3
  import { UnifiedEvent } from '../../types';
3
- export declare function fetchEvents(params: EventFetchParams): Promise<UnifiedEvent[]>;
4
+ export declare function fetchEvents(params: EventFetchParams, http?: AxiosInstance): Promise<UnifiedEvent[]>;
@@ -7,8 +7,8 @@ exports.fetchEvents = fetchEvents;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const utils_1 = require("./utils");
9
9
  const errors_1 = require("./errors");
10
- async function fetchEventByGammaId(id) {
11
- const response = await axios_1.default.get(utils_1.GAMMA_API_URL, {
10
+ async function fetchEventByGammaId(id, http) {
11
+ const response = await http.get(utils_1.GAMMA_API_URL, {
12
12
  params: { id }
13
13
  });
14
14
  const events = response.data;
@@ -37,8 +37,8 @@ async function fetchEventByGammaId(id) {
37
37
  };
38
38
  });
39
39
  }
40
- async function fetchEventBySlug(slug) {
41
- const response = await axios_1.default.get(utils_1.GAMMA_API_URL, {
40
+ async function fetchEventBySlug(slug, http) {
41
+ const response = await http.get(utils_1.GAMMA_API_URL, {
42
42
  params: { slug }
43
43
  });
44
44
  const events = response.data;
@@ -67,15 +67,15 @@ async function fetchEventBySlug(slug) {
67
67
  };
68
68
  });
69
69
  }
70
- async function fetchEvents(params) {
70
+ async function fetchEvents(params, http = axios_1.default) {
71
71
  try {
72
72
  // Handle eventId lookup (Gamma event ID)
73
73
  if (params.eventId) {
74
- return await fetchEventByGammaId(params.eventId);
74
+ return await fetchEventByGammaId(params.eventId, http);
75
75
  }
76
76
  // Handle slug lookup
77
77
  if (params.slug) {
78
- return await fetchEventBySlug(params.slug);
78
+ return await fetchEventBySlug(params.slug, http);
79
79
  }
80
80
  if (!params.query) {
81
81
  throw new Error("Query is required for Polymarket event search");
@@ -90,7 +90,7 @@ async function fetchEvents(params) {
90
90
  };
91
91
  const fetchWithStatus = async (eventStatus) => {
92
92
  const currentParams = { ...queryParams, events_status: eventStatus };
93
- return (0, utils_1.paginateSearchParallel)(utils_1.GAMMA_SEARCH_URL, currentParams, limit * 10);
93
+ return (0, utils_1.paginateSearchParallel)(utils_1.GAMMA_SEARCH_URL, currentParams, limit * 10, http);
94
94
  };
95
95
  // Client-side filtering logic
96
96
  // The API returns active events when querying for 'closed' status sometimes.
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios';
1
2
  import { MarketFetchParams } from '../../BaseExchange';
2
3
  import { UnifiedMarket } from '../../types';
3
- export declare function fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
4
+ export declare function fetchMarkets(params?: MarketFetchParams, http?: AxiosInstance): Promise<UnifiedMarket[]>;