pmxt-core 2.7.0 → 2.9.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 +59 -0
- package/dist/BaseExchange.js +155 -0
- package/dist/exchanges/kalshi/api.d.ts +1763 -0
- package/dist/exchanges/kalshi/api.js +2554 -0
- package/dist/exchanges/kalshi/fetchEvents.d.ts +3 -2
- package/dist/exchanges/kalshi/fetchEvents.js +9 -16
- package/dist/exchanges/kalshi/fetchMarkets.d.ts +3 -2
- package/dist/exchanges/kalshi/fetchMarkets.js +27 -35
- package/dist/exchanges/kalshi/fetchOHLCV.d.ts +1 -2
- package/dist/exchanges/kalshi/fetchOHLCV.js +9 -11
- package/dist/exchanges/kalshi/index.d.ts +2 -1
- package/dist/exchanges/kalshi/index.js +161 -183
- package/dist/exchanges/kalshi/kalshi.test.js +51 -31
- package/dist/exchanges/limitless/api.d.ts +555 -0
- package/dist/exchanges/limitless/api.js +863 -0
- package/dist/exchanges/limitless/fetchEvents.d.ts +1 -2
- package/dist/exchanges/limitless/fetchEvents.js +9 -15
- package/dist/exchanges/limitless/fetchMarkets.d.ts +1 -2
- package/dist/exchanges/limitless/fetchMarkets.js +11 -18
- package/dist/exchanges/limitless/fetchOHLCV.d.ts +1 -2
- package/dist/exchanges/limitless/fetchOHLCV.js +2 -11
- package/dist/exchanges/limitless/fetchOrderBook.d.ts +1 -2
- package/dist/exchanges/limitless/fetchOrderBook.js +2 -11
- package/dist/exchanges/limitless/index.d.ts +1 -0
- package/dist/exchanges/limitless/index.js +28 -7
- package/dist/exchanges/limitless/websocket.d.ts +2 -1
- package/dist/exchanges/limitless/websocket.js +6 -4
- package/dist/exchanges/myriad/api.d.ts +294 -0
- package/dist/exchanges/myriad/api.js +690 -0
- package/dist/exchanges/myriad/fetchOHLCV.d.ts +1 -2
- package/dist/exchanges/myriad/fetchOHLCV.js +3 -11
- package/dist/exchanges/myriad/fetchOrderBook.d.ts +1 -2
- package/dist/exchanges/myriad/fetchOrderBook.js +3 -11
- package/dist/exchanges/myriad/index.d.ts +2 -0
- package/dist/exchanges/myriad/index.js +116 -103
- package/dist/exchanges/myriad/websocket.d.ts +2 -2
- package/dist/exchanges/myriad/websocket.js +28 -6
- package/dist/exchanges/polymarket/api-clob.d.ts +346 -0
- package/dist/exchanges/polymarket/api-clob.js +517 -0
- package/dist/exchanges/polymarket/api-data.d.ts +789 -0
- package/dist/exchanges/polymarket/api-data.js +860 -0
- package/dist/exchanges/polymarket/api-gamma.d.ts +556 -0
- package/dist/exchanges/polymarket/api-gamma.js +1161 -0
- package/dist/exchanges/polymarket/fetchEvents.js +0 -68
- package/dist/exchanges/polymarket/fetchMarkets.js +2 -2
- package/dist/exchanges/polymarket/fetchOHLCV.d.ts +1 -2
- package/dist/exchanges/polymarket/fetchOHLCV.js +4 -10
- package/dist/exchanges/polymarket/fetchOrderBook.d.ts +1 -2
- package/dist/exchanges/polymarket/fetchOrderBook.js +2 -10
- package/dist/exchanges/polymarket/fetchTrades.d.ts +1 -2
- package/dist/exchanges/polymarket/fetchTrades.js +2 -11
- package/dist/exchanges/polymarket/index.d.ts +10 -0
- package/dist/exchanges/polymarket/index.js +110 -5
- package/dist/exchanges/probable/api.d.ts +605 -0
- package/dist/exchanges/probable/api.js +887 -0
- package/dist/exchanges/probable/fetchEvents.d.ts +3 -3
- package/dist/exchanges/probable/fetchEvents.js +28 -25
- package/dist/exchanges/probable/fetchMarkets.d.ts +1 -1
- package/dist/exchanges/probable/fetchMarkets.js +25 -21
- package/dist/exchanges/probable/index.d.ts +1 -0
- package/dist/exchanges/probable/index.js +92 -10
- package/dist/exchanges/probable/utils.d.ts +1 -2
- package/dist/exchanges/probable/utils.js +4 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils/openapi.d.ts +9 -0
- package/dist/utils/openapi.js +59 -0
- package/package.json +4 -3
- package/dist/exchanges/kalshi/fetchOrderBook.d.ts +0 -3
- package/dist/exchanges/kalshi/fetchOrderBook.js +0 -59
- package/dist/exchanges/kalshi/fetchTrades.d.ts +0 -4
- package/dist/exchanges/kalshi/fetchTrades.js +0 -31
- package/dist/exchanges/limitless/fetchPositions.d.ts +0 -2
- package/dist/exchanges/limitless/fetchPositions.js +0 -34
- package/dist/exchanges/myriad/fetchTrades.d.ts +0 -4
- package/dist/exchanges/myriad/fetchTrades.js +0 -62
- package/dist/exchanges/polymarket/fetchPositions.d.ts +0 -2
- package/dist/exchanges/polymarket/fetchPositions.js +0 -34
- package/dist/exchanges/probable/fetchOHLCV.d.ts +0 -4
- package/dist/exchanges/probable/fetchOHLCV.js +0 -83
- package/dist/exchanges/probable/fetchOrderBook.d.ts +0 -3
- package/dist/exchanges/probable/fetchOrderBook.js +0 -37
- package/dist/exchanges/probable/fetchPositions.d.ts +0 -2
- package/dist/exchanges/probable/fetchPositions.js +0 -33
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { EventFetchParams } from '../../BaseExchange';
|
|
2
2
|
import { UnifiedEvent } from '../../types';
|
|
3
|
-
|
|
4
|
-
export declare function fetchEvents(params: EventFetchParams, http?: AxiosInstance): Promise<UnifiedEvent[]>;
|
|
3
|
+
export declare function fetchEvents(params: EventFetchParams, callApi: (operationId: string, params?: Record<string, any>) => Promise<any>): Promise<UnifiedEvent[]>;
|
|
@@ -32,18 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.fetchEvents = fetchEvents;
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
37
|
const utils_1 = require("./utils");
|
|
42
38
|
const errors_1 = require("./errors");
|
|
43
|
-
async function fetchEventBySlug(slug
|
|
39
|
+
async function fetchEventBySlug(slug) {
|
|
44
40
|
const { HttpClient, MarketFetcher } = await Promise.resolve().then(() => __importStar(require('@limitless-exchange/sdk')));
|
|
45
41
|
const httpClient = new HttpClient({ baseURL: utils_1.LIMITLESS_API_URL });
|
|
46
|
-
// TODO: Ideally inject
|
|
42
|
+
// TODO: Ideally inject http into HttpClient if supported, but SDK abstracts it.
|
|
47
43
|
// For now, single market fetch uses SDK's internal client.
|
|
48
44
|
const marketFetcher = new MarketFetcher(httpClient);
|
|
49
45
|
const market = await marketFetcher.getMarket(slug);
|
|
@@ -72,25 +68,23 @@ async function fetchEventBySlug(slug, http) {
|
|
|
72
68
|
tags: market.tags || []
|
|
73
69
|
};
|
|
74
70
|
}
|
|
75
|
-
async function fetchEvents(params,
|
|
71
|
+
async function fetchEvents(params, callApi) {
|
|
76
72
|
try {
|
|
77
73
|
// Handle eventId/slug lookup (same thing for Limitless)
|
|
78
74
|
if (params.eventId || params.slug) {
|
|
79
75
|
const slug = params.eventId || params.slug;
|
|
80
|
-
const event = await fetchEventBySlug(slug
|
|
76
|
+
const event = await fetchEventBySlug(slug);
|
|
81
77
|
return event ? [event] : [];
|
|
82
78
|
}
|
|
83
79
|
// NOTE: The Limitless /markets/search endpoint currently only returns active/funded markets.
|
|
84
80
|
// It does not include expired or resolved markets in search results.
|
|
85
81
|
// Consequently, status 'inactive' will likely return 0 results and 'all' will only show active markets.
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
similarityThreshold: 0.5
|
|
91
|
-
}
|
|
82
|
+
const data = await callApi('MarketSearchController_search', {
|
|
83
|
+
query: params.query,
|
|
84
|
+
limit: params?.limit || 10000,
|
|
85
|
+
similarityThreshold: 0.5,
|
|
92
86
|
});
|
|
93
|
-
let markets =
|
|
87
|
+
let markets = data?.markets || [];
|
|
94
88
|
// Filter by status based on expired/resolved state
|
|
95
89
|
// Active: not expired and not resolved
|
|
96
90
|
// Inactive: expired OR resolved (has winningOutcomeIndex)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { MarketFetchParams } from '../../BaseExchange';
|
|
2
2
|
import { UnifiedMarket } from '../../types';
|
|
3
|
-
|
|
4
|
-
export declare function fetchMarkets(params?: MarketFetchParams, apiKey?: string, http?: AxiosInstance): Promise<UnifiedMarket[]>;
|
|
3
|
+
export declare function fetchMarkets(params?: MarketFetchParams, apiKey?: string, callApi?: (operationId: string, params?: Record<string, any>) => Promise<any>): Promise<UnifiedMarket[]>;
|
|
@@ -32,15 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.fetchMarkets = fetchMarkets;
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
37
|
const utils_1 = require("./utils");
|
|
42
38
|
const errors_1 = require("./errors");
|
|
43
|
-
async function fetchMarkets(params, apiKey,
|
|
39
|
+
async function fetchMarkets(params, apiKey, callApi) {
|
|
44
40
|
// Limitless API currently only supports fetching active markets for lists
|
|
45
41
|
// Early return to avoid SDK initialization in tests
|
|
46
42
|
if (params?.status === 'inactive' || params?.status === 'closed') {
|
|
@@ -74,7 +70,7 @@ async function fetchMarkets(params, apiKey, http = axios_1.default) {
|
|
|
74
70
|
}
|
|
75
71
|
// Handle query-based search
|
|
76
72
|
if (params?.query) {
|
|
77
|
-
return await searchMarkets(params.query, params,
|
|
73
|
+
return await searchMarkets(params.query, params, callApi);
|
|
78
74
|
}
|
|
79
75
|
// Default: fetch active markets
|
|
80
76
|
return await fetchMarketsDefault(marketFetcher, params);
|
|
@@ -90,19 +86,16 @@ async function fetchMarketsBySlug(marketFetcher, slug) {
|
|
|
90
86
|
const unifiedMarket = (0, utils_1.mapMarketToUnified)(market);
|
|
91
87
|
return unifiedMarket ? [unifiedMarket] : [];
|
|
92
88
|
}
|
|
93
|
-
async function searchMarkets(query, params,
|
|
94
|
-
// SDK doesn't have a search method yet, use axios directly
|
|
89
|
+
async function searchMarkets(query, params, callApi) {
|
|
95
90
|
// NOTE: The Limitless /markets/search endpoint currently only returns active/funded markets.
|
|
96
91
|
// It does not include expired or resolved markets in search results.
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
similarityThreshold: params?.similarityThreshold || 0.5
|
|
103
|
-
}
|
|
92
|
+
const data = await callApi('MarketSearchController_search', {
|
|
93
|
+
query: query,
|
|
94
|
+
limit: params?.limit || 250000,
|
|
95
|
+
page: params?.page || 1,
|
|
96
|
+
similarityThreshold: params?.similarityThreshold || 0.5,
|
|
104
97
|
});
|
|
105
|
-
const rawResults =
|
|
98
|
+
const rawResults = data?.markets || [];
|
|
106
99
|
const allMarkets = [];
|
|
107
100
|
for (const res of rawResults) {
|
|
108
101
|
if (res.markets && Array.isArray(res.markets)) {
|
|
@@ -121,10 +114,10 @@ async function searchMarkets(query, params, http) {
|
|
|
121
114
|
}
|
|
122
115
|
return allMarkets
|
|
123
116
|
.filter((m) => m !== null && m.outcomes.length > 0)
|
|
124
|
-
.slice(0, params?.limit ||
|
|
117
|
+
.slice(0, params?.limit || 250000);
|
|
125
118
|
}
|
|
126
119
|
async function fetchMarketsDefault(marketFetcher, params) {
|
|
127
|
-
const limit = params?.limit ||
|
|
120
|
+
const limit = params?.limit || 250000;
|
|
128
121
|
const offset = params?.offset || 0;
|
|
129
122
|
// Map sort parameter to SDK's sortBy
|
|
130
123
|
let sortBy = 'lp_rewards';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
1
|
import { HistoryFilterParams, OHLCVParams } from '../../BaseExchange';
|
|
3
2
|
import { PriceCandle } from '../../types';
|
|
4
3
|
/**
|
|
5
4
|
* Fetch historical price data (candles) for a specific market.
|
|
6
5
|
* @param id - The market slug
|
|
7
6
|
*/
|
|
8
|
-
export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams,
|
|
7
|
+
export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams, callApi: (operationId: string, params?: Record<string, any>) => Promise<any>): Promise<PriceCandle[]>;
|
|
@@ -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.fetchOHLCV = fetchOHLCV;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
4
|
const utils_1 = require("./utils");
|
|
9
5
|
const validation_1 = require("../../utils/validation");
|
|
10
6
|
const errors_1 = require("./errors");
|
|
@@ -12,7 +8,7 @@ const errors_1 = require("./errors");
|
|
|
12
8
|
* Fetch historical price data (candles) for a specific market.
|
|
13
9
|
* @param id - The market slug
|
|
14
10
|
*/
|
|
15
|
-
async function fetchOHLCV(id, params,
|
|
11
|
+
async function fetchOHLCV(id, params, callApi) {
|
|
16
12
|
(0, validation_1.validateIdFormat)(id, 'OHLCV');
|
|
17
13
|
// Validate resolution is provided
|
|
18
14
|
if (!params.resolution) {
|
|
@@ -20,12 +16,7 @@ async function fetchOHLCV(id, params, http = axios_1.default) {
|
|
|
20
16
|
}
|
|
21
17
|
try {
|
|
22
18
|
const fidelity = (0, utils_1.mapIntervalToFidelity)(params.resolution);
|
|
23
|
-
|
|
24
|
-
const url = `${utils_1.LIMITLESS_API_URL}/markets/${id}/historical-price`;
|
|
25
|
-
const response = await http.get(url, {
|
|
26
|
-
params: { fidelity }
|
|
27
|
-
});
|
|
28
|
-
const data = response.data;
|
|
19
|
+
const data = await callApi('MarketOrderbookController_getHistoricalPrice', { slug: id, fidelity });
|
|
29
20
|
const prices = data.prices || [];
|
|
30
21
|
// Map price points to pmxt PriceCandle format
|
|
31
22
|
// The API returns price points, so we treat each point as a candle
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
1
|
import { OrderBook } from '../../types';
|
|
3
2
|
/**
|
|
4
3
|
* Fetch the current order book for a specific market.
|
|
5
4
|
* @param id - The market slug (preferred) or CLOB token ID
|
|
6
5
|
*/
|
|
7
|
-
export declare function fetchOrderBook(id: string,
|
|
6
|
+
export declare function fetchOrderBook(id: string, callApi: (operationId: string, params?: Record<string, any>) => Promise<any>): Promise<OrderBook>;
|
|
@@ -1,11 +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.fetchOrderBook = fetchOrderBook;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
4
|
const validation_1 = require("../../utils/validation");
|
|
10
5
|
// Limitless uses USDC with 6 decimals
|
|
11
6
|
const USDC_DECIMALS = 6;
|
|
@@ -20,14 +15,10 @@ function convertSize(rawSize) {
|
|
|
20
15
|
* Fetch the current order book for a specific market.
|
|
21
16
|
* @param id - The market slug (preferred) or CLOB token ID
|
|
22
17
|
*/
|
|
23
|
-
async function fetchOrderBook(id,
|
|
18
|
+
async function fetchOrderBook(id, callApi) {
|
|
24
19
|
(0, validation_1.validateIdFormat)(id, 'OrderBook');
|
|
25
20
|
try {
|
|
26
|
-
|
|
27
|
-
// If 'id' is a numeric token ID, this might fail unless we look up the slug.
|
|
28
|
-
const url = `${utils_1.LIMITLESS_API_URL}/markets/${id}/orderbook`;
|
|
29
|
-
const response = await http.get(url);
|
|
30
|
-
const data = response.data;
|
|
21
|
+
const data = await callApi('MarketOrderbookController_getOrderbook', { slug: id });
|
|
31
22
|
// Response format: { bids: [{price: 0.52, size: 100000000}], asks: [...] }
|
|
32
23
|
// Sizes are in smallest unit (USDC with 6 decimals), convert to human-readable
|
|
33
24
|
const bids = (data.bids || []).map((level) => ({
|
|
@@ -27,6 +27,7 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
|
|
|
27
27
|
private wsConfig?;
|
|
28
28
|
constructor(options?: ExchangeCredentials | LimitlessExchangeOptions);
|
|
29
29
|
get name(): string;
|
|
30
|
+
protected mapImplicitApiError(error: any): any;
|
|
30
31
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
31
32
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
32
33
|
fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
@@ -7,7 +7,6 @@ const fetchEvents_1 = require("./fetchEvents");
|
|
|
7
7
|
const fetchOHLCV_1 = require("./fetchOHLCV");
|
|
8
8
|
const fetchOrderBook_1 = require("./fetchOrderBook");
|
|
9
9
|
const fetchTrades_1 = require("./fetchTrades");
|
|
10
|
-
const fetchPositions_1 = require("./fetchPositions");
|
|
11
10
|
const auth_1 = require("./auth");
|
|
12
11
|
const client_1 = require("./client");
|
|
13
12
|
const websocket_1 = require("./websocket");
|
|
@@ -15,6 +14,8 @@ const errors_1 = require("./errors");
|
|
|
15
14
|
const errors_2 = require("../../errors");
|
|
16
15
|
const sdk_1 = require("@limitless-exchange/sdk");
|
|
17
16
|
const ethers_1 = require("ethers");
|
|
17
|
+
const openapi_1 = require("../../utils/openapi");
|
|
18
|
+
const api_1 = require("./api");
|
|
18
19
|
class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
19
20
|
has = {
|
|
20
21
|
fetchMarkets: true,
|
|
@@ -70,26 +71,35 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
70
71
|
console.warn('Failed to initialize Limitless auth:', error);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
// Register implicit API for Limitless REST endpoints
|
|
75
|
+
const apiDescriptor = (0, openapi_1.parseOpenApiSpec)(api_1.limitlessApiSpec);
|
|
76
|
+
this.defineImplicitApi(apiDescriptor);
|
|
73
77
|
}
|
|
74
78
|
get name() {
|
|
75
79
|
return 'Limitless';
|
|
76
80
|
}
|
|
77
81
|
// ----------------------------------------------------------------------------
|
|
82
|
+
// Implicit API Error Mapping
|
|
83
|
+
// ----------------------------------------------------------------------------
|
|
84
|
+
mapImplicitApiError(error) {
|
|
85
|
+
throw errors_1.limitlessErrorMapper.mapError(error);
|
|
86
|
+
}
|
|
87
|
+
// ----------------------------------------------------------------------------
|
|
78
88
|
// Implementation methods for CCXT-style API
|
|
79
89
|
// ----------------------------------------------------------------------------
|
|
80
90
|
async fetchMarketsImpl(params) {
|
|
81
91
|
// Pass API key if available for authenticated requests
|
|
82
92
|
const apiKey = this.auth?.getApiKey();
|
|
83
|
-
return (0, fetchMarkets_1.fetchMarkets)(params, apiKey, this.
|
|
93
|
+
return (0, fetchMarkets_1.fetchMarkets)(params, apiKey, this.callApi.bind(this));
|
|
84
94
|
}
|
|
85
95
|
async fetchEventsImpl(params) {
|
|
86
|
-
return (0, fetchEvents_1.fetchEvents)(params, this.
|
|
96
|
+
return (0, fetchEvents_1.fetchEvents)(params, this.callApi.bind(this));
|
|
87
97
|
}
|
|
88
98
|
async fetchOHLCV(id, params) {
|
|
89
|
-
return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.
|
|
99
|
+
return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.callApi.bind(this));
|
|
90
100
|
}
|
|
91
101
|
async fetchOrderBook(id) {
|
|
92
|
-
return (0, fetchOrderBook_1.fetchOrderBook)(id, this.
|
|
102
|
+
return (0, fetchOrderBook_1.fetchOrderBook)(id, this.callApi.bind(this));
|
|
93
103
|
}
|
|
94
104
|
async fetchTrades(id, params) {
|
|
95
105
|
// Deprecation warning
|
|
@@ -218,7 +228,18 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
218
228
|
async fetchPositions() {
|
|
219
229
|
const auth = this.ensureAuth();
|
|
220
230
|
const address = auth.getAddress();
|
|
221
|
-
|
|
231
|
+
const result = await this.callApi('PublicPortfolioController_getPositions', { account: address });
|
|
232
|
+
const data = result?.data || result || [];
|
|
233
|
+
return data.map((p) => ({
|
|
234
|
+
marketId: p.market?.slug || p.conditionId,
|
|
235
|
+
outcomeId: p.asset,
|
|
236
|
+
outcomeLabel: p.outcome || 'Unknown',
|
|
237
|
+
size: parseFloat(p.size || '0'),
|
|
238
|
+
entryPrice: parseFloat(p.avgPrice || '0'),
|
|
239
|
+
currentPrice: parseFloat(p.curPrice || '0'),
|
|
240
|
+
unrealizedPnL: parseFloat(p.cashPnl || '0'),
|
|
241
|
+
realizedPnL: parseFloat(p.realizedPnl || '0'),
|
|
242
|
+
}));
|
|
222
243
|
}
|
|
223
244
|
async fetchBalance() {
|
|
224
245
|
const auth = this.ensureAuth();
|
|
@@ -262,7 +283,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
262
283
|
...this.wsConfig,
|
|
263
284
|
apiKey: this.auth?.getApiKey(),
|
|
264
285
|
};
|
|
265
|
-
this.ws = new websocket_1.LimitlessWebSocket(wsConfig);
|
|
286
|
+
this.ws = new websocket_1.LimitlessWebSocket(this.callApi.bind(this), wsConfig);
|
|
266
287
|
}
|
|
267
288
|
return this.ws;
|
|
268
289
|
}
|
|
@@ -19,12 +19,13 @@ export interface LimitlessWebSocketConfig extends Partial<WebSocketConfig> {
|
|
|
19
19
|
export declare class LimitlessWebSocket {
|
|
20
20
|
private client;
|
|
21
21
|
private config;
|
|
22
|
+
private callApi;
|
|
22
23
|
private orderbookCallbacks;
|
|
23
24
|
private priceCallbacks;
|
|
24
25
|
private orderbookResolvers;
|
|
25
26
|
private orderbookBuffers;
|
|
26
27
|
private lastOrderbookTimestamps;
|
|
27
|
-
constructor(config?: LimitlessWebSocketConfig);
|
|
28
|
+
constructor(callApi: (operationId: string, params?: Record<string, any>) => Promise<any>, config?: LimitlessWebSocketConfig);
|
|
28
29
|
private setupEventHandlers;
|
|
29
30
|
/**
|
|
30
31
|
* Watch orderbook updates for a CLOB market.
|
|
@@ -23,12 +23,14 @@ function convertSize(rawSize) {
|
|
|
23
23
|
class LimitlessWebSocket {
|
|
24
24
|
client;
|
|
25
25
|
config;
|
|
26
|
+
callApi;
|
|
26
27
|
orderbookCallbacks = new Map();
|
|
27
28
|
priceCallbacks = new Map();
|
|
28
29
|
orderbookResolvers = new Map();
|
|
29
30
|
orderbookBuffers = new Map();
|
|
30
31
|
lastOrderbookTimestamps = new Map();
|
|
31
|
-
constructor(config = {}) {
|
|
32
|
+
constructor(callApi, config = {}) {
|
|
33
|
+
this.callApi = callApi;
|
|
32
34
|
this.config = config;
|
|
33
35
|
// Initialize SDK WebSocket client
|
|
34
36
|
const wsConfig = {
|
|
@@ -122,7 +124,7 @@ class LimitlessWebSocket {
|
|
|
122
124
|
if (!this.lastOrderbookTimestamps.has(marketSlug)) {
|
|
123
125
|
this.lastOrderbookTimestamps.set(marketSlug, Date.now());
|
|
124
126
|
try {
|
|
125
|
-
return await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug);
|
|
127
|
+
return await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug, this.callApi);
|
|
126
128
|
}
|
|
127
129
|
catch (err) {
|
|
128
130
|
console.warn(`[LimitlessWS] Failed to fetch initial snapshot:`, err);
|
|
@@ -139,7 +141,7 @@ class LimitlessWebSocket {
|
|
|
139
141
|
if (timeSinceLastUpdate > SNAPSHOT_REFRESH_INTERVAL) {
|
|
140
142
|
this.lastOrderbookTimestamps.set(marketSlug, Date.now());
|
|
141
143
|
try {
|
|
142
|
-
return await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug);
|
|
144
|
+
return await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug, this.callApi);
|
|
143
145
|
}
|
|
144
146
|
catch (err) {
|
|
145
147
|
console.warn(`[LimitlessWS] Failed to fetch refresh snapshot:`, err);
|
|
@@ -158,7 +160,7 @@ class LimitlessWebSocket {
|
|
|
158
160
|
// Timeout: fetch REST snapshot as fallback
|
|
159
161
|
try {
|
|
160
162
|
this.lastOrderbookTimestamps.set(marketSlug, Date.now());
|
|
161
|
-
const snapshot = await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug);
|
|
163
|
+
const snapshot = await (0, fetchOrderBook_1.fetchOrderBook)(marketSlug, this.callApi);
|
|
162
164
|
resolve(snapshot);
|
|
163
165
|
}
|
|
164
166
|
catch (err) {
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
|
|
3
|
+
* Generated at: 2026-02-18T15:48:13.507Z
|
|
4
|
+
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
|
+
*/
|
|
6
|
+
export declare const myriadApiSpec: {
|
|
7
|
+
openapi: string;
|
|
8
|
+
info: {
|
|
9
|
+
title: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
servers: {
|
|
13
|
+
url: string;
|
|
14
|
+
}[];
|
|
15
|
+
components: {
|
|
16
|
+
securitySchemes: {
|
|
17
|
+
ApiKeyHeader: {
|
|
18
|
+
type: string;
|
|
19
|
+
in: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
ApiKeyQuery: {
|
|
23
|
+
type: string;
|
|
24
|
+
in: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
security: ({
|
|
30
|
+
ApiKeyHeader: never[];
|
|
31
|
+
ApiKeyQuery?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
ApiKeyQuery: never[];
|
|
34
|
+
ApiKeyHeader?: undefined;
|
|
35
|
+
})[];
|
|
36
|
+
paths: {
|
|
37
|
+
"/questions": {
|
|
38
|
+
get: {
|
|
39
|
+
summary: string;
|
|
40
|
+
parameters: ({
|
|
41
|
+
name: string;
|
|
42
|
+
in: string;
|
|
43
|
+
schema: {
|
|
44
|
+
type: string;
|
|
45
|
+
default: number;
|
|
46
|
+
maximum?: undefined;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
name: string;
|
|
50
|
+
in: string;
|
|
51
|
+
schema: {
|
|
52
|
+
type: string;
|
|
53
|
+
default: number;
|
|
54
|
+
maximum: number;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
name: string;
|
|
58
|
+
in: string;
|
|
59
|
+
schema: {
|
|
60
|
+
type: string;
|
|
61
|
+
default?: undefined;
|
|
62
|
+
maximum?: undefined;
|
|
63
|
+
};
|
|
64
|
+
})[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
"/questions/{id}": {
|
|
68
|
+
get: {
|
|
69
|
+
summary: string;
|
|
70
|
+
parameters: {
|
|
71
|
+
name: string;
|
|
72
|
+
in: string;
|
|
73
|
+
required: boolean;
|
|
74
|
+
schema: {
|
|
75
|
+
type: string;
|
|
76
|
+
};
|
|
77
|
+
}[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
"/markets": {
|
|
81
|
+
get: {
|
|
82
|
+
summary: string;
|
|
83
|
+
parameters: ({
|
|
84
|
+
name: string;
|
|
85
|
+
in: string;
|
|
86
|
+
schema: {
|
|
87
|
+
type: string;
|
|
88
|
+
default: number;
|
|
89
|
+
enum?: undefined;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
name: string;
|
|
93
|
+
in: string;
|
|
94
|
+
schema: {
|
|
95
|
+
type: string;
|
|
96
|
+
enum: string[];
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
name: string;
|
|
101
|
+
in: string;
|
|
102
|
+
schema: {
|
|
103
|
+
type: string;
|
|
104
|
+
default?: undefined;
|
|
105
|
+
enum?: undefined;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
name: string;
|
|
109
|
+
in: string;
|
|
110
|
+
schema: {
|
|
111
|
+
type: string;
|
|
112
|
+
enum: string[];
|
|
113
|
+
default?: undefined;
|
|
114
|
+
};
|
|
115
|
+
})[];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
"/markets/{id}": {
|
|
119
|
+
get: {
|
|
120
|
+
summary: string;
|
|
121
|
+
parameters: ({
|
|
122
|
+
name: string;
|
|
123
|
+
in: string;
|
|
124
|
+
required: boolean;
|
|
125
|
+
schema: {
|
|
126
|
+
type: string;
|
|
127
|
+
};
|
|
128
|
+
} | {
|
|
129
|
+
name: string;
|
|
130
|
+
in: string;
|
|
131
|
+
schema: {
|
|
132
|
+
type: string;
|
|
133
|
+
};
|
|
134
|
+
required?: undefined;
|
|
135
|
+
})[];
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
"/markets/{id}/events": {
|
|
139
|
+
get: {
|
|
140
|
+
summary: string;
|
|
141
|
+
parameters: ({
|
|
142
|
+
name: string;
|
|
143
|
+
in: string;
|
|
144
|
+
required: boolean;
|
|
145
|
+
schema: {
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
name: string;
|
|
150
|
+
in: string;
|
|
151
|
+
schema: {
|
|
152
|
+
type: string;
|
|
153
|
+
};
|
|
154
|
+
required?: undefined;
|
|
155
|
+
})[];
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
"/markets/{id}/referrals": {
|
|
159
|
+
get: {
|
|
160
|
+
summary: string;
|
|
161
|
+
parameters: ({
|
|
162
|
+
name: string;
|
|
163
|
+
in: string;
|
|
164
|
+
required: boolean;
|
|
165
|
+
schema: {
|
|
166
|
+
type: string;
|
|
167
|
+
};
|
|
168
|
+
} | {
|
|
169
|
+
name: string;
|
|
170
|
+
in: string;
|
|
171
|
+
schema: {
|
|
172
|
+
type: string;
|
|
173
|
+
};
|
|
174
|
+
required?: undefined;
|
|
175
|
+
})[];
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
"/markets/{id}/holders": {
|
|
179
|
+
get: {
|
|
180
|
+
summary: string;
|
|
181
|
+
parameters: ({
|
|
182
|
+
name: string;
|
|
183
|
+
in: string;
|
|
184
|
+
required: boolean;
|
|
185
|
+
schema: {
|
|
186
|
+
type: string;
|
|
187
|
+
};
|
|
188
|
+
} | {
|
|
189
|
+
name: string;
|
|
190
|
+
in: string;
|
|
191
|
+
schema: {
|
|
192
|
+
type: string;
|
|
193
|
+
};
|
|
194
|
+
required?: undefined;
|
|
195
|
+
})[];
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
"/markets/quote": {
|
|
199
|
+
post: {
|
|
200
|
+
summary: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
"/markets/quote_with_fee": {
|
|
204
|
+
post: {
|
|
205
|
+
summary: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
"/markets/claim": {
|
|
209
|
+
post: {
|
|
210
|
+
summary: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
"/users/{address}/events": {
|
|
214
|
+
get: {
|
|
215
|
+
summary: string;
|
|
216
|
+
parameters: ({
|
|
217
|
+
name: string;
|
|
218
|
+
in: string;
|
|
219
|
+
required: boolean;
|
|
220
|
+
schema: {
|
|
221
|
+
type: string;
|
|
222
|
+
};
|
|
223
|
+
} | {
|
|
224
|
+
name: string;
|
|
225
|
+
in: string;
|
|
226
|
+
schema: {
|
|
227
|
+
type: string;
|
|
228
|
+
};
|
|
229
|
+
required?: undefined;
|
|
230
|
+
})[];
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
"/users/{address}/referrals": {
|
|
234
|
+
get: {
|
|
235
|
+
summary: string;
|
|
236
|
+
parameters: ({
|
|
237
|
+
name: string;
|
|
238
|
+
in: string;
|
|
239
|
+
required: boolean;
|
|
240
|
+
schema: {
|
|
241
|
+
type: string;
|
|
242
|
+
};
|
|
243
|
+
} | {
|
|
244
|
+
name: string;
|
|
245
|
+
in: string;
|
|
246
|
+
schema: {
|
|
247
|
+
type: string;
|
|
248
|
+
};
|
|
249
|
+
required?: undefined;
|
|
250
|
+
})[];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
"/users/{address}/portfolio": {
|
|
254
|
+
get: {
|
|
255
|
+
summary: string;
|
|
256
|
+
parameters: ({
|
|
257
|
+
name: string;
|
|
258
|
+
in: string;
|
|
259
|
+
required: boolean;
|
|
260
|
+
schema: {
|
|
261
|
+
type: string;
|
|
262
|
+
};
|
|
263
|
+
} | {
|
|
264
|
+
name: string;
|
|
265
|
+
in: string;
|
|
266
|
+
schema: {
|
|
267
|
+
type: string;
|
|
268
|
+
};
|
|
269
|
+
required?: undefined;
|
|
270
|
+
})[];
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
"/users/{address}/markets": {
|
|
274
|
+
get: {
|
|
275
|
+
summary: string;
|
|
276
|
+
parameters: ({
|
|
277
|
+
name: string;
|
|
278
|
+
in: string;
|
|
279
|
+
required: boolean;
|
|
280
|
+
schema: {
|
|
281
|
+
type: string;
|
|
282
|
+
};
|
|
283
|
+
} | {
|
|
284
|
+
name: string;
|
|
285
|
+
in: string;
|
|
286
|
+
schema: {
|
|
287
|
+
type: string;
|
|
288
|
+
};
|
|
289
|
+
required?: undefined;
|
|
290
|
+
})[];
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
};
|