pmxt-core 2.37.9 → 2.37.12
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 +5 -0
- package/dist/BaseExchange.js +6 -0
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/kalshi/config.d.ts +3 -3
- package/dist/exchanges/kalshi/config.js +4 -4
- package/dist/exchanges/kalshi/index.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/limitless/auth.d.ts +1 -0
- package/dist/exchanges/limitless/auth.js +4 -2
- package/dist/exchanges/limitless/client.d.ts +1 -1
- package/dist/exchanges/limitless/client.js +3 -3
- package/dist/exchanges/limitless/fetcher.d.ts +7 -1
- package/dist/exchanges/limitless/fetcher.js +61 -16
- package/dist/exchanges/limitless/index.js +2 -2
- package/dist/exchanges/limitless/utils.d.ts +2 -1
- package/dist/exchanges/limitless/utils.js +3 -2
- package/dist/exchanges/metaculus/cancelOrder.d.ts +2 -0
- package/dist/exchanges/metaculus/cancelOrder.js +1 -1
- package/dist/exchanges/metaculus/createOrder.d.ts +2 -0
- package/dist/exchanges/metaculus/createOrder.js +1 -1
- package/dist/exchanges/metaculus/index.d.ts +1 -0
- package/dist/exchanges/metaculus/index.js +5 -1
- package/dist/exchanges/metaculus/utils.d.ts +2 -1
- package/dist/exchanges/metaculus/utils.js +3 -2
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/myriad/fetcher.d.ts +2 -1
- package/dist/exchanges/myriad/fetcher.js +9 -7
- package/dist/exchanges/myriad/index.js +3 -2
- package/dist/exchanges/myriad/utils.d.ts +2 -1
- package/dist/exchanges/myriad/utils.js +3 -2
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/config.d.ts +2 -1
- package/dist/exchanges/opinion/config.js +3 -2
- package/dist/exchanges/opinion/fetcher.d.ts +2 -1
- package/dist/exchanges/opinion/fetcher.js +10 -8
- package/dist/exchanges/opinion/index.js +3 -2
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/polymarket/auth.d.ts +1 -0
- package/dist/exchanges/polymarket/auth.js +7 -4
- package/dist/exchanges/polymarket/fetcher.js +1 -1
- package/dist/exchanges/polymarket/utils.d.ts +4 -4
- package/dist/exchanges/polymarket/utils.js +4 -4
- package/dist/exchanges/polymarket_us/config.d.ts +3 -3
- package/dist/exchanges/polymarket_us/config.js +4 -4
- package/dist/exchanges/polymarket_us/index.js +1 -1
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/exchanges/probable/fetcher.d.ts +2 -1
- package/dist/exchanges/probable/fetcher.js +9 -7
- package/dist/exchanges/probable/index.js +3 -2
- package/dist/exchanges/probable/utils.d.ts +2 -1
- package/dist/exchanges/probable/utils.js +3 -2
- package/dist/exchanges/smarkets/config.d.ts +3 -2
- package/dist/exchanges/smarkets/config.js +5 -4
- package/dist/exchanges/smarkets/fetcher.js +2 -1
- package/dist/exchanges/smarkets/index.js +1 -1
- package/dist/router/Router.d.ts +3 -1
- package/dist/router/Router.js +65 -0
- package/dist/router/Router.test.js +131 -1
- package/dist/router/types.d.ts +3 -0
- package/dist/server/app.js +10 -0
- package/dist/server/method-verbs.json +10 -0
- package/dist/server/openapi.yaml +99 -11
- package/package.json +3 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTRACTS = exports.NETWORKS = exports.BASE_URL = void 0;
|
|
3
|
+
exports.CONTRACTS = exports.NETWORKS = exports.BASE_URL = exports.DEFAULT_BASE_URL = void 0;
|
|
4
4
|
exports.mapMarketState = mapMarketState;
|
|
5
5
|
exports.mapStatusToMyriad = mapStatusToMyriad;
|
|
6
6
|
exports.mapMarketToUnified = mapMarketToUnified;
|
|
7
7
|
exports.mapQuestionToEvent = mapQuestionToEvent;
|
|
8
8
|
const market_utils_1 = require("../../utils/market-utils");
|
|
9
|
-
exports.
|
|
9
|
+
exports.DEFAULT_BASE_URL = 'https://api-v2.myriadprotocol.com';
|
|
10
|
+
exports.BASE_URL = process.env.MYRIAD_BASE_URL || exports.DEFAULT_BASE_URL;
|
|
10
11
|
// Mainnet network IDs
|
|
11
12
|
exports.NETWORKS = {
|
|
12
13
|
ABSTRACT: 2741,
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-08T16:05:46.438Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-08T16:05:46.438Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const DEFAULT_OPINION_API_URL = "https://openapi.opinion.trade/openapi";
|
|
2
|
+
export declare const OPINION_API_URL: string;
|
|
2
3
|
export declare const OPINION_WS_URL = "wss://ws.opinion.trade";
|
|
3
4
|
export declare const OPINION_MAX_PAGE_SIZE = 20;
|
|
4
5
|
export declare const OPINION_CHAIN_ID = 56;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPINION_DEFAULT_RPC_URL = exports.OPINION_CHAIN_ID = exports.OPINION_MAX_PAGE_SIZE = exports.OPINION_WS_URL = exports.OPINION_API_URL = void 0;
|
|
4
|
-
exports.
|
|
3
|
+
exports.OPINION_DEFAULT_RPC_URL = exports.OPINION_CHAIN_ID = exports.OPINION_MAX_PAGE_SIZE = exports.OPINION_WS_URL = exports.OPINION_API_URL = exports.DEFAULT_OPINION_API_URL = void 0;
|
|
4
|
+
exports.DEFAULT_OPINION_API_URL = "https://openapi.opinion.trade/openapi";
|
|
5
|
+
exports.OPINION_API_URL = process.env.OPINION_BASE_URL || exports.DEFAULT_OPINION_API_URL;
|
|
5
6
|
exports.OPINION_WS_URL = "wss://ws.opinion.trade";
|
|
6
7
|
exports.OPINION_MAX_PAGE_SIZE = 20;
|
|
7
8
|
// CLOB SDK chain constants
|
|
@@ -166,7 +166,8 @@ export interface OpinionRawOrder {
|
|
|
166
166
|
}
|
|
167
167
|
export declare class OpinionFetcher implements IExchangeFetcher<OpinionRawMarket, OpinionRawMarket> {
|
|
168
168
|
private readonly ctx;
|
|
169
|
-
|
|
169
|
+
private readonly apiUrl;
|
|
170
|
+
constructor(ctx: FetcherContext, apiUrl?: string);
|
|
170
171
|
fetchRawMarkets(params?: MarketFilterParams): Promise<OpinionRawMarket[]>;
|
|
171
172
|
fetchRawEvents(params: EventFetchParams): Promise<OpinionRawMarket[]>;
|
|
172
173
|
fetchRawMarketById(marketId: number): Promise<OpinionRawMarket | null>;
|
|
@@ -32,8 +32,10 @@ const MAX_PAGES = 500;
|
|
|
32
32
|
// ----------------------------------------------------------------------------
|
|
33
33
|
class OpinionFetcher {
|
|
34
34
|
ctx;
|
|
35
|
-
|
|
35
|
+
apiUrl;
|
|
36
|
+
constructor(ctx, apiUrl) {
|
|
36
37
|
this.ctx = ctx;
|
|
38
|
+
this.apiUrl = apiUrl || config_1.DEFAULT_OPINION_API_URL;
|
|
37
39
|
}
|
|
38
40
|
// -- Markets --------------------------------------------------------------
|
|
39
41
|
async fetchRawMarkets(params) {
|
|
@@ -99,7 +101,7 @@ class OpinionFetcher {
|
|
|
99
101
|
// -- Single market detail -------------------------------------------------
|
|
100
102
|
async fetchRawMarketById(marketId) {
|
|
101
103
|
try {
|
|
102
|
-
const response = await this.ctx.http.get(`${
|
|
104
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/market/${marketId}`, { headers: this.ctx.getHeaders() });
|
|
103
105
|
this.assertSuccess(response.data);
|
|
104
106
|
return response.data.result?.data ?? null;
|
|
105
107
|
}
|
|
@@ -110,7 +112,7 @@ class OpinionFetcher {
|
|
|
110
112
|
// -- Categorical market detail --------------------------------------------
|
|
111
113
|
async fetchRawCategoricalMarketById(marketId) {
|
|
112
114
|
try {
|
|
113
|
-
const response = await this.ctx.http.get(`${
|
|
115
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/market/categorical/${marketId}`, { headers: this.ctx.getHeaders() });
|
|
114
116
|
this.assertSuccess(response.data);
|
|
115
117
|
return response.data.result?.data ?? null;
|
|
116
118
|
}
|
|
@@ -121,7 +123,7 @@ class OpinionFetcher {
|
|
|
121
123
|
// -- Order book -----------------------------------------------------------
|
|
122
124
|
async fetchRawOrderBook(tokenId) {
|
|
123
125
|
try {
|
|
124
|
-
const response = await this.ctx.http.get(`${
|
|
126
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/token/orderbook`, {
|
|
125
127
|
params: { token_id: tokenId },
|
|
126
128
|
headers: this.ctx.getHeaders(),
|
|
127
129
|
});
|
|
@@ -142,7 +144,7 @@ class OpinionFetcher {
|
|
|
142
144
|
queryParams.start_at = params.startAt;
|
|
143
145
|
if (params.endAt !== undefined)
|
|
144
146
|
queryParams.end_at = params.endAt;
|
|
145
|
-
const response = await this.ctx.http.get(`${
|
|
147
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/token/price-history`, { params: queryParams, headers: this.ctx.getHeaders() });
|
|
146
148
|
this.assertSuccess(response.data);
|
|
147
149
|
return response.data.result?.history ?? [];
|
|
148
150
|
}
|
|
@@ -176,7 +178,7 @@ class OpinionFetcher {
|
|
|
176
178
|
// -- Latest price ---------------------------------------------------------
|
|
177
179
|
async fetchRawLatestPrice(tokenId) {
|
|
178
180
|
try {
|
|
179
|
-
const response = await this.ctx.http.get(`${
|
|
181
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/token/latest-price`, {
|
|
180
182
|
params: { token_id: tokenId },
|
|
181
183
|
headers: this.ctx.getHeaders(),
|
|
182
184
|
});
|
|
@@ -229,7 +231,7 @@ class OpinionFetcher {
|
|
|
229
231
|
// -- Single order detail (authenticated) ----------------------------------
|
|
230
232
|
async fetchRawOrderById(orderId) {
|
|
231
233
|
try {
|
|
232
|
-
const response = await this.ctx.http.get(`${
|
|
234
|
+
const response = await this.ctx.http.get(`${this.apiUrl}/order/${orderId}`, { headers: this.ctx.getHeaders() });
|
|
233
235
|
this.assertSuccess(response.data);
|
|
234
236
|
return response.data.result?.orderData ?? null;
|
|
235
237
|
}
|
|
@@ -253,7 +255,7 @@ class OpinionFetcher {
|
|
|
253
255
|
page,
|
|
254
256
|
limit: config_1.OPINION_MAX_PAGE_SIZE,
|
|
255
257
|
};
|
|
256
|
-
const response = await this.ctx.http.get(`${
|
|
258
|
+
const response = await this.ctx.http.get(`${this.apiUrl}${path}`, { params, headers: this.ctx.getHeaders() });
|
|
257
259
|
this.assertSuccess(response.data);
|
|
258
260
|
const result = response.data.result;
|
|
259
261
|
if (!result)
|
|
@@ -79,14 +79,15 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
79
79
|
if (credentials?.apiKey) {
|
|
80
80
|
this.auth = new auth_1.OpinionAuth(credentials);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const opinionBaseUrl = credentials?.baseUrl || config_1.DEFAULT_OPINION_API_URL;
|
|
83
|
+
const descriptor = (0, openapi_1.parseOpenApiSpec)(api_1.opinionApiSpec, opinionBaseUrl);
|
|
83
84
|
this.defineImplicitApi(descriptor);
|
|
84
85
|
const ctx = {
|
|
85
86
|
http: this.http,
|
|
86
87
|
callApi: this.callApi.bind(this),
|
|
87
88
|
getHeaders: () => this.auth?.getHeaders() ?? {},
|
|
88
89
|
};
|
|
89
|
-
this.fetcher = new fetcher_1.OpinionFetcher(ctx);
|
|
90
|
+
this.fetcher = new fetcher_1.OpinionFetcher(ctx, opinionBaseUrl);
|
|
90
91
|
this.normalizer = new normalizer_1.OpinionNormalizer();
|
|
91
92
|
}
|
|
92
93
|
get name() {
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-08T16:05:46.397Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-08T16:05:46.397Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-08T16:05:46.407Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-08T16:05:46.407Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-08T16:05:46.405Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-08T16:05:46.405Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -12,6 +12,7 @@ export declare class PolymarketAuth {
|
|
|
12
12
|
private apiCreds?;
|
|
13
13
|
private discoveredProxyAddress?;
|
|
14
14
|
private discoveredSignatureType?;
|
|
15
|
+
readonly host: string;
|
|
15
16
|
constructor(credentials: ExchangeCredentials);
|
|
16
17
|
/**
|
|
17
18
|
* Get or create API credentials using L1 authentication.
|
|
@@ -8,7 +8,7 @@ const clob_client_v2_1 = require("@polymarket/clob-client-v2");
|
|
|
8
8
|
const ethers_1 = require("ethers");
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const errors_1 = require("./errors");
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_POLYMARKET_HOST = process.env.POLYMARKET_CLOB_URL || 'https://clob.polymarket.com';
|
|
12
12
|
const POLYGON_CHAIN_ID = 137;
|
|
13
13
|
// Polymarket CLOB signature types — determines how the CLOB API
|
|
14
14
|
// resolves the on-chain address holding the user's funds.
|
|
@@ -26,8 +26,10 @@ class PolymarketAuth {
|
|
|
26
26
|
apiCreds;
|
|
27
27
|
discoveredProxyAddress;
|
|
28
28
|
discoveredSignatureType;
|
|
29
|
+
host;
|
|
29
30
|
constructor(credentials) {
|
|
30
31
|
this.credentials = credentials;
|
|
32
|
+
this.host = credentials.baseUrl || DEFAULT_POLYMARKET_HOST;
|
|
31
33
|
if (!credentials.privateKey) {
|
|
32
34
|
throw new Error('Polymarket requires a privateKey for authentication');
|
|
33
35
|
}
|
|
@@ -69,7 +71,7 @@ class PolymarketAuth {
|
|
|
69
71
|
}
|
|
70
72
|
// Otherwise, derive/create them using L1 auth
|
|
71
73
|
const l1Client = new clob_client_v2_1.ClobClient({
|
|
72
|
-
host:
|
|
74
|
+
host: this.host,
|
|
73
75
|
chain: POLYGON_CHAIN_ID,
|
|
74
76
|
signer: this.signer,
|
|
75
77
|
});
|
|
@@ -117,7 +119,8 @@ class PolymarketAuth {
|
|
|
117
119
|
try {
|
|
118
120
|
// Polymarket Data API / Profiles endpoint
|
|
119
121
|
// Path-based: https://data-api.polymarket.com/profiles/0x...
|
|
120
|
-
const
|
|
122
|
+
const dataApiUrl = process.env.POLYMARKET_DATA_URL || 'https://data-api.polymarket.com';
|
|
123
|
+
const response = await axios_1.default.get(`${dataApiUrl}/profiles/${address}`, {
|
|
121
124
|
headers: { 'User-Agent': 'pmxt (https://github.com/pmxt-dev/pmxt)' }
|
|
122
125
|
});
|
|
123
126
|
const profile = response.data;
|
|
@@ -224,7 +227,7 @@ class PolymarketAuth {
|
|
|
224
227
|
// Create L2-authenticated client
|
|
225
228
|
// console.log(`[PolymarketAuth] Initializing ClobClient | Signer: ${signerAddress} | Funder: ${finalProxyAddress} | SigType: ${finalSignatureType}`);
|
|
226
229
|
this.clobClient = new clob_client_v2_1.ClobClient({
|
|
227
|
-
host:
|
|
230
|
+
host: this.host,
|
|
228
231
|
chain: POLYGON_CHAIN_ID,
|
|
229
232
|
signer: this.signer,
|
|
230
233
|
creds: apiCreds,
|
|
@@ -57,7 +57,7 @@ function ensureDate(d) {
|
|
|
57
57
|
}
|
|
58
58
|
return new Date(d);
|
|
59
59
|
}
|
|
60
|
-
const GAMMA_MARKETS_URL = 'https://gamma-api.polymarket.com/markets';
|
|
60
|
+
const GAMMA_MARKETS_URL = process.env.POLYMARKET_GAMMA_MARKETS_URL || 'https://gamma-api.polymarket.com/markets';
|
|
61
61
|
class PolymarketFetcher {
|
|
62
62
|
ctx;
|
|
63
63
|
http;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnifiedMarket, CandleInterval } from '../../types';
|
|
2
|
-
export declare const GAMMA_API_URL
|
|
3
|
-
export declare const GAMMA_SEARCH_URL
|
|
4
|
-
export declare const CLOB_API_URL
|
|
5
|
-
export declare const DATA_API_URL
|
|
2
|
+
export declare const GAMMA_API_URL: string;
|
|
3
|
+
export declare const GAMMA_SEARCH_URL: string;
|
|
4
|
+
export declare const CLOB_API_URL: string;
|
|
5
|
+
export declare const DATA_API_URL: string;
|
|
6
6
|
export declare function mapMarketToUnified(event: any, market: any, options?: {
|
|
7
7
|
useQuestionAsCandidateFallback?: boolean;
|
|
8
8
|
}): UnifiedMarket | null;
|
|
@@ -6,10 +6,10 @@ exports.mapIntervalToFidelity = mapIntervalToFidelity;
|
|
|
6
6
|
exports.paginateParallel = paginateParallel;
|
|
7
7
|
exports.paginateSearchParallel = paginateSearchParallel;
|
|
8
8
|
const market_utils_1 = require("../../utils/market-utils");
|
|
9
|
-
exports.GAMMA_API_URL = 'https://gamma-api.polymarket.com/events';
|
|
10
|
-
exports.GAMMA_SEARCH_URL = 'https://gamma-api.polymarket.com/public-search';
|
|
11
|
-
exports.CLOB_API_URL = 'https://clob.polymarket.com';
|
|
12
|
-
exports.DATA_API_URL = 'https://data-api.polymarket.com';
|
|
9
|
+
exports.GAMMA_API_URL = process.env.POLYMARKET_GAMMA_URL || 'https://gamma-api.polymarket.com/events';
|
|
10
|
+
exports.GAMMA_SEARCH_URL = process.env.POLYMARKET_GAMMA_SEARCH_URL || 'https://gamma-api.polymarket.com/public-search';
|
|
11
|
+
exports.CLOB_API_URL = process.env.POLYMARKET_CLOB_URL || 'https://clob.polymarket.com';
|
|
12
|
+
exports.DATA_API_URL = process.env.POLYMARKET_DATA_URL || 'https://data-api.polymarket.com';
|
|
13
13
|
function mapMarketToUnified(event, market, options = {}) {
|
|
14
14
|
if (!market)
|
|
15
15
|
return null;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Hand-authored single source of truth for base URLs and config factory
|
|
5
5
|
* for the Polymarket US exchange adapter (wraps the polymarket-us SDK).
|
|
6
6
|
*/
|
|
7
|
-
export declare const POLYMARKET_US_API_BASE_URL
|
|
8
|
-
export declare const POLYMARKET_US_GATEWAY_BASE_URL
|
|
7
|
+
export declare const POLYMARKET_US_API_BASE_URL: string;
|
|
8
|
+
export declare const POLYMARKET_US_GATEWAY_BASE_URL: string;
|
|
9
9
|
export interface PolymarketUSConfig {
|
|
10
10
|
/** Base REST API URL */
|
|
11
11
|
apiUrl: string;
|
|
@@ -15,4 +15,4 @@ export interface PolymarketUSConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* Return a typed config object for the Polymarket US API.
|
|
17
17
|
*/
|
|
18
|
-
export declare function getPolymarketUSConfig(): PolymarketUSConfig;
|
|
18
|
+
export declare function getPolymarketUSConfig(baseUrlOverride?: string): PolymarketUSConfig;
|
|
@@ -9,14 +9,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.POLYMARKET_US_GATEWAY_BASE_URL = exports.POLYMARKET_US_API_BASE_URL = void 0;
|
|
10
10
|
exports.getPolymarketUSConfig = getPolymarketUSConfig;
|
|
11
11
|
// -- Base URL constants -------------------------------------------------------
|
|
12
|
-
exports.POLYMARKET_US_API_BASE_URL = "https://api.polymarket.us";
|
|
13
|
-
exports.POLYMARKET_US_GATEWAY_BASE_URL = "https://gateway.polymarket.us";
|
|
12
|
+
exports.POLYMARKET_US_API_BASE_URL = process.env.POLYMARKET_US_BASE_URL || "https://api.polymarket.us";
|
|
13
|
+
exports.POLYMARKET_US_GATEWAY_BASE_URL = process.env.POLYMARKET_US_GATEWAY_URL || "https://gateway.polymarket.us";
|
|
14
14
|
/**
|
|
15
15
|
* Return a typed config object for the Polymarket US API.
|
|
16
16
|
*/
|
|
17
|
-
function getPolymarketUSConfig() {
|
|
17
|
+
function getPolymarketUSConfig(baseUrlOverride) {
|
|
18
18
|
return {
|
|
19
|
-
apiUrl: exports.POLYMARKET_US_API_BASE_URL,
|
|
19
|
+
apiUrl: baseUrlOverride || exports.POLYMARKET_US_API_BASE_URL,
|
|
20
20
|
gatewayUrl: exports.POLYMARKET_US_GATEWAY_BASE_URL,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -57,7 +57,7 @@ class PolymarketUSExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
57
57
|
constructor(credentials) {
|
|
58
58
|
super(credentials);
|
|
59
59
|
this.rateLimit = 100;
|
|
60
|
-
this.config = (0, config_1.getPolymarketUSConfig)();
|
|
60
|
+
this.config = (0, config_1.getPolymarketUSConfig)(credentials?.baseUrl);
|
|
61
61
|
this.normalizer = new normalizer_1.PolymarketUSNormalizer();
|
|
62
62
|
this.client = new polymarket_us_1.PolymarketUS({
|
|
63
63
|
keyId: credentials?.apiKey,
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-08T16:05:46.428Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-08T16:05:46.428Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
|
@@ -77,7 +77,8 @@ export interface ProbableRawPosition {
|
|
|
77
77
|
}
|
|
78
78
|
export declare class ProbableFetcher implements IExchangeFetcher<ProbableRawMarket, ProbableRawEvent> {
|
|
79
79
|
private readonly ctx;
|
|
80
|
-
|
|
80
|
+
private readonly baseUrl;
|
|
81
|
+
constructor(ctx: FetcherContext, baseUrl?: string);
|
|
81
82
|
fetchRawMarkets(params?: MarketFetchParams): Promise<ProbableRawMarket[]>;
|
|
82
83
|
fetchRawEvents(params: EventFetchParams): Promise<ProbableRawEvent[]>;
|
|
83
84
|
fetchRawEventById(id: string): Promise<ProbableRawEvent | null>;
|
|
@@ -5,8 +5,10 @@ const utils_1 = require("./utils");
|
|
|
5
5
|
const errors_1 = require("./errors");
|
|
6
6
|
class ProbableFetcher {
|
|
7
7
|
ctx;
|
|
8
|
-
|
|
8
|
+
baseUrl;
|
|
9
|
+
constructor(ctx, baseUrl) {
|
|
9
10
|
this.ctx = ctx;
|
|
11
|
+
this.baseUrl = baseUrl || utils_1.DEFAULT_BASE_URL;
|
|
10
12
|
}
|
|
11
13
|
// -----------------------------------------------------------------------
|
|
12
14
|
// Markets
|
|
@@ -61,7 +63,7 @@ class ProbableFetcher {
|
|
|
61
63
|
const numericId = Number(id);
|
|
62
64
|
if (isNaN(numericId))
|
|
63
65
|
return null;
|
|
64
|
-
const response = await this.ctx.http.get(`${
|
|
66
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.EVENTS_PATH}${numericId}`);
|
|
65
67
|
return response.data || null;
|
|
66
68
|
}
|
|
67
69
|
catch (error) {
|
|
@@ -72,7 +74,7 @@ class ProbableFetcher {
|
|
|
72
74
|
}
|
|
73
75
|
async fetchRawEventBySlug(slug) {
|
|
74
76
|
try {
|
|
75
|
-
const response = await this.ctx.http.get(`${
|
|
77
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.EVENTS_PATH}slug/${slug}`);
|
|
76
78
|
return response.data || null;
|
|
77
79
|
}
|
|
78
80
|
catch (error) {
|
|
@@ -189,12 +191,12 @@ class ProbableFetcher {
|
|
|
189
191
|
const numericId = Number(cleanSlug);
|
|
190
192
|
if (!isNaN(numericId) && String(numericId) === cleanSlug) {
|
|
191
193
|
try {
|
|
192
|
-
const response = await this.ctx.http.get(`${
|
|
194
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.MARKETS_PATH}${numericId}`);
|
|
193
195
|
return response.data ? [response.data] : [];
|
|
194
196
|
}
|
|
195
197
|
catch (error) {
|
|
196
198
|
if (isMarketNotFoundError(error)) {
|
|
197
|
-
const response = await this.ctx.http.get(`${
|
|
199
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.MARKETS_PATH}`, {
|
|
198
200
|
params: { page: 1, limit: 100, active: true },
|
|
199
201
|
});
|
|
200
202
|
if (!response.data?.markets || !Array.isArray(response.data.markets)) {
|
|
@@ -231,7 +233,7 @@ class ProbableFetcher {
|
|
|
231
233
|
if (params?.eventId) {
|
|
232
234
|
queryParams.event_id = params.eventId;
|
|
233
235
|
}
|
|
234
|
-
const response = await this.ctx.http.get(`${
|
|
236
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.MARKETS_PATH}`, { params: queryParams });
|
|
235
237
|
if (!response.data?.markets || !Array.isArray(response.data.markets)) {
|
|
236
238
|
throw new Error(`Probable markets list: unexpected response shape. Expected { markets: [...] }.`);
|
|
237
239
|
}
|
|
@@ -321,7 +323,7 @@ class ProbableFetcher {
|
|
|
321
323
|
}
|
|
322
324
|
queryParams.sort = 'volume';
|
|
323
325
|
queryParams.ascending = false;
|
|
324
|
-
const response = await this.ctx.http.get(`${
|
|
326
|
+
const response = await this.ctx.http.get(`${this.baseUrl}${utils_1.EVENTS_PATH}`, { params: queryParams });
|
|
325
327
|
const data = response.data;
|
|
326
328
|
if (!Array.isArray(data)) {
|
|
327
329
|
throw new Error(`Probable events list: unexpected response shape (got ${typeof data}). Expected an array.`);
|
|
@@ -26,14 +26,15 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
26
26
|
if (credentials?.privateKey && credentials?.apiKey && credentials?.apiSecret && credentials?.passphrase) {
|
|
27
27
|
this.auth = new auth_1.ProbableAuth(credentials);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const probableBaseUrl = credentials?.baseUrl || utils_1.DEFAULT_BASE_URL;
|
|
30
|
+
const descriptor = (0, openapi_1.parseOpenApiSpec)(api_1.probableApiSpec, probableBaseUrl);
|
|
30
31
|
this.defineImplicitApi(descriptor);
|
|
31
32
|
const ctx = {
|
|
32
33
|
http: this.http,
|
|
33
34
|
callApi: this.callApi.bind(this),
|
|
34
35
|
getHeaders: () => ({ 'Content-Type': 'application/json' }),
|
|
35
36
|
};
|
|
36
|
-
this.fetcher = new fetcher_1.ProbableFetcher(ctx);
|
|
37
|
+
this.fetcher = new fetcher_1.ProbableFetcher(ctx, probableBaseUrl);
|
|
37
38
|
this.normalizer = new normalizer_1.ProbableNormalizer();
|
|
38
39
|
}
|
|
39
40
|
get name() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UnifiedMarket, UnifiedEvent } from '../../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const DEFAULT_BASE_URL = "https://market-api.probable.markets";
|
|
3
|
+
export declare const BASE_URL: string;
|
|
3
4
|
export declare const SEARCH_PATH = "/public/api/v1/public-search/";
|
|
4
5
|
export declare const EVENTS_PATH = "/public/api/v1/events/";
|
|
5
6
|
export declare const MARKETS_PATH = "/public/api/v1/markets/";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MARKETS_PATH = exports.EVENTS_PATH = exports.SEARCH_PATH = exports.BASE_URL = void 0;
|
|
3
|
+
exports.MARKETS_PATH = exports.EVENTS_PATH = exports.SEARCH_PATH = exports.BASE_URL = exports.DEFAULT_BASE_URL = void 0;
|
|
4
4
|
exports.mapMarketToUnified = mapMarketToUnified;
|
|
5
5
|
exports.mapEventToUnified = mapEventToUnified;
|
|
6
6
|
exports.enrichMarketsWithPrices = enrichMarketsWithPrices;
|
|
7
7
|
const market_utils_1 = require("../../utils/market-utils");
|
|
8
|
-
exports.
|
|
8
|
+
exports.DEFAULT_BASE_URL = 'https://market-api.probable.markets';
|
|
9
|
+
exports.BASE_URL = process.env.PROBABLE_BASE_URL || exports.DEFAULT_BASE_URL;
|
|
9
10
|
exports.SEARCH_PATH = '/public/api/v1/public-search/';
|
|
10
11
|
exports.EVENTS_PATH = '/public/api/v1/events/';
|
|
11
12
|
exports.MARKETS_PATH = '/public/api/v1/markets/';
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* into core/src/exchanges/smarkets/api.ts by `npm run fetch:openapi`.
|
|
11
11
|
* Do NOT put runtime config into api.ts -- it will be overwritten.
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const DEFAULT_SMARKETS_BASE_URL = "https://api.smarkets.com";
|
|
14
|
+
export declare const SMARKETS_BASE_URL: string;
|
|
14
15
|
export declare const SMARKETS_PATHS: {
|
|
15
16
|
SESSIONS: string;
|
|
16
17
|
SESSIONS_VERIFY: string;
|
|
@@ -38,4 +39,4 @@ export interface SmarketsApiConfig {
|
|
|
38
39
|
/**
|
|
39
40
|
* Return a typed config object for the Smarkets API.
|
|
40
41
|
*/
|
|
41
|
-
export declare function getSmarketsConfig(): SmarketsApiConfig;
|
|
42
|
+
export declare function getSmarketsConfig(baseUrlOverride?: string): SmarketsApiConfig;
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* Do NOT put runtime config into api.ts -- it will be overwritten.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.SMARKETS_PATHS = exports.SMARKETS_BASE_URL = void 0;
|
|
15
|
+
exports.SMARKETS_PATHS = exports.SMARKETS_BASE_URL = exports.DEFAULT_SMARKETS_BASE_URL = void 0;
|
|
16
16
|
exports.getSmarketsConfig = getSmarketsConfig;
|
|
17
17
|
// -- Base URL constant --------------------------------------------------------
|
|
18
|
-
exports.
|
|
18
|
+
exports.DEFAULT_SMARKETS_BASE_URL = "https://api.smarkets.com";
|
|
19
|
+
exports.SMARKETS_BASE_URL = process.env.SMARKETS_BASE_URL || exports.DEFAULT_SMARKETS_BASE_URL;
|
|
19
20
|
// -- Path constants -----------------------------------------------------------
|
|
20
21
|
exports.SMARKETS_PATHS = {
|
|
21
22
|
SESSIONS: "/v3/sessions/",
|
|
@@ -40,8 +41,8 @@ exports.SMARKETS_PATHS = {
|
|
|
40
41
|
/**
|
|
41
42
|
* Return a typed config object for the Smarkets API.
|
|
42
43
|
*/
|
|
43
|
-
function getSmarketsConfig() {
|
|
44
|
+
function getSmarketsConfig(baseUrlOverride) {
|
|
44
45
|
return {
|
|
45
|
-
apiUrl: exports.
|
|
46
|
+
apiUrl: baseUrlOverride || exports.DEFAULT_SMARKETS_BASE_URL,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -54,7 +54,8 @@ class SmarketsFetcher {
|
|
|
54
54
|
(0, validation_1.validateIdFormat)(id, 'OrderBook');
|
|
55
55
|
// get_quotes is marked as private in the spec but works without auth
|
|
56
56
|
// (returns delayed data). Use a direct HTTP call so it works without credentials.
|
|
57
|
-
const
|
|
57
|
+
const smarketsBase = process.env.SMARKETS_BASE_URL || 'https://api.smarkets.com';
|
|
58
|
+
const url = `${smarketsBase}/v3/markets/${encodeURIComponent(id)}/quotes/`;
|
|
58
59
|
const headers = {
|
|
59
60
|
...this.ctx.getHeaders(),
|
|
60
61
|
};
|
|
@@ -23,7 +23,7 @@ class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
23
23
|
constructor(credentials) {
|
|
24
24
|
super(credentials);
|
|
25
25
|
this.rateLimit = 100;
|
|
26
|
-
this.config = (0, config_1.getSmarketsConfig)();
|
|
26
|
+
this.config = (0, config_1.getSmarketsConfig)(credentials?.baseUrl);
|
|
27
27
|
// Smarkets API expects repeated keys for arrays (e.g. state=new&state=live)
|
|
28
28
|
// rather than the axios default bracket format (state[]=new&state[]=live)
|
|
29
29
|
this.http.defaults.paramsSerializer = (params) => {
|
package/dist/router/Router.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { PredictionMarketExchange, type MarketFetchParams, type EventFetchParams } from '../BaseExchange';
|
|
2
|
-
import type { UnifiedMarket, UnifiedEvent } from '../types';
|
|
2
|
+
import type { UnifiedMarket, UnifiedEvent, OrderBook } from '../types';
|
|
3
3
|
import type { RouterOptions, MatchResult, EventMatchResult, PriceComparison, ArbitrageOpportunity, MatchedMarketPair, MatchedPricePair, FetchMarketMatchesParams, FetchMatchesParams, FetchEventMatchesParams, FetchArbitrageParams, FetchMatchedMarketsParams, FetchMatchedPricesParams } from './types';
|
|
4
4
|
export declare class Router extends PredictionMarketExchange {
|
|
5
5
|
private readonly client;
|
|
6
|
+
private readonly exchanges;
|
|
6
7
|
constructor(options: RouterOptions);
|
|
7
8
|
get name(): string;
|
|
8
9
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
9
10
|
protected fetchEventsImpl(params?: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
11
|
+
fetchOrderBook(id: string, side?: 'yes' | 'no'): Promise<OrderBook>;
|
|
10
12
|
fetchMarketMatches(params?: FetchMarketMatchesParams): Promise<MatchResult[]>;
|
|
11
13
|
/**
|
|
12
14
|
* Browse mode: fetch all matched market pairs from the catalog.
|