pmxt-core 2.43.19 → 2.43.24
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/exchanges/baozi/errors.d.ts +1 -1
- package/dist/exchanges/baozi/errors.js +1 -1
- package/dist/exchanges/gemini-titan/errors.d.ts +3 -3
- package/dist/exchanges/gemini-titan/errors.js +1 -1
- package/dist/exchanges/gemini-titan/index.js +1 -1
- package/dist/exchanges/gemini-titan/normalizer.js +2 -2
- package/dist/exchanges/gemini-titan/websocket.js +16 -3
- package/dist/exchanges/hyperliquid/errors.d.ts +3 -3
- package/dist/exchanges/hyperliquid/errors.js +1 -1
- package/dist/exchanges/hyperliquid/index.js +1 -1
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/kalshi/auth.js +3 -0
- package/dist/exchanges/kalshi/errors.d.ts +2 -2
- package/dist/exchanges/kalshi/fetcher.d.ts +1 -0
- package/dist/exchanges/kalshi/fetcher.js +3 -3
- package/dist/exchanges/kalshi/index.js +1 -1
- package/dist/exchanges/kalshi/normalizer.d.ts +1 -1
- package/dist/exchanges/kalshi/normalizer.js +4 -4
- package/dist/exchanges/kalshi/websocket.d.ts +1 -0
- package/dist/exchanges/kalshi/websocket.js +29 -13
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/limitless/auth.js +3 -0
- package/dist/exchanges/limitless/client.js +9 -0
- package/dist/exchanges/limitless/errors.d.ts +2 -2
- package/dist/exchanges/limitless/index.js +1 -1
- package/dist/exchanges/limitless/normalizer.js +4 -2
- package/dist/exchanges/limitless/utils.js +3 -0
- package/dist/exchanges/limitless/websocket.js +37 -7
- package/dist/exchanges/metaculus/cancelOrder.d.ts +1 -1
- package/dist/exchanges/metaculus/cancelOrder.js +3 -3
- package/dist/exchanges/metaculus/errors.d.ts +3 -3
- package/dist/exchanges/mock/index.js +32 -15
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/myriad/errors.d.ts +2 -2
- package/dist/exchanges/myriad/websocket.js +16 -4
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/errors.d.ts +2 -2
- package/dist/exchanges/opinion/errors.js +4 -3
- package/dist/exchanges/opinion/fetcher.js +1 -1
- package/dist/exchanges/opinion/index.js +1 -1
- package/dist/exchanges/opinion/utils.d.ts +1 -1
- package/dist/exchanges/opinion/utils.js +2 -2
- package/dist/exchanges/opinion/websocket.js +35 -6
- 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.js +22 -3
- package/dist/exchanges/polymarket/errors.d.ts +3 -3
- package/dist/exchanges/polymarket/fetcher.js +3 -0
- package/dist/exchanges/polymarket/index.js +1 -1
- package/dist/exchanges/polymarket/normalizer.js +6 -4
- package/dist/exchanges/polymarket/websocket.d.ts +2 -0
- package/dist/exchanges/polymarket/websocket.js +53 -27
- package/dist/exchanges/polymarket_us/normalizer.js +3 -3
- package/dist/exchanges/polymarket_us/websocket.js +6 -0
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/exchanges/probable/errors.d.ts +2 -2
- package/dist/exchanges/probable/errors.js +1 -1
- package/dist/exchanges/probable/index.js +2 -2
- package/dist/exchanges/smarkets/auth.js +6 -0
- package/dist/exchanges/smarkets/errors.d.ts +3 -3
- package/dist/exchanges/smarkets/errors.js +7 -2
- package/dist/exchanges/smarkets/fetcher.js +16 -6
- package/dist/feeds/binance/binance-feed.js +20 -2
- package/dist/feeds/chainlink/chainlink-feed.js +18 -3
- package/dist/router/Router.js +1 -3
- package/dist/router/client.d.ts +16 -8
- package/dist/router/client.js +7 -3
- package/dist/server/index.js +6 -5
- package/dist/server/openapi.yaml +1 -1
- package/dist/subscriber/external/goldsky.d.ts +2 -1
- package/dist/subscriber/external/goldsky.js +33 -14
- package/dist/subscriber/watcher.js +6 -8
- package/dist/types.d.ts +1 -1
- package/dist/utils/error-mapper.d.ts +7 -7
- package/dist/utils/error-mapper.js +54 -47
- package/dist/utils/market-utils.js +4 -4
- package/dist/utils/throttler.d.ts +2 -0
- package/dist/utils/throttler.js +8 -0
- package/package.json +3 -3
|
@@ -78,7 +78,9 @@ const POLYMARKET_DEFAULT_SUBSCRIPTION = async (address, types, goldSkyFetch, bas
|
|
|
78
78
|
]);
|
|
79
79
|
const seen = new Set();
|
|
80
80
|
const trades = [];
|
|
81
|
-
|
|
81
|
+
const makerEvents = (makerData?.orderFilledEvents ?? []);
|
|
82
|
+
const takerEvents = (takerData?.orderFilledEvents ?? []);
|
|
83
|
+
for (const row of [...makerEvents, ...takerEvents]) {
|
|
82
84
|
if (!seen.has(row.id)) {
|
|
83
85
|
seen.add(row.id);
|
|
84
86
|
trades.push(row);
|
|
@@ -128,7 +130,8 @@ exports.LIMITLESS_DEFAULT_SUBSCRIPTION = LIMITLESS_DEFAULT_SUBSCRIPTION;
|
|
|
128
130
|
const buildPolymarketTradesActivity = (data, address, types) => {
|
|
129
131
|
if (!types.includes('trades'))
|
|
130
132
|
return null;
|
|
131
|
-
const
|
|
133
|
+
const record = data;
|
|
134
|
+
const filled = record?.orderFilledEvents;
|
|
132
135
|
if (!Array.isArray(filled) || filled.length === 0)
|
|
133
136
|
return null;
|
|
134
137
|
const addr = address.toLowerCase();
|
|
@@ -189,7 +192,8 @@ exports.buildPolymarketActivity = buildPolymarketActivity;
|
|
|
189
192
|
const buildLimitlessBalanceActivity = (data, address, types, lastActivity) => {
|
|
190
193
|
if (!types.includes('balances'))
|
|
191
194
|
return null;
|
|
192
|
-
const
|
|
195
|
+
const record = data;
|
|
196
|
+
const transfers = record?.transfers;
|
|
193
197
|
if (!Array.isArray(transfers) || transfers.length === 0)
|
|
194
198
|
return null;
|
|
195
199
|
const prev = lastActivity?.balances?.find(b => b.currency === 'USDC');
|
|
@@ -226,6 +230,7 @@ class GoldSkySubscriber {
|
|
|
226
230
|
pollTimers = new Map();
|
|
227
231
|
callbacks = new Map();
|
|
228
232
|
addressQueryTypes = new Map();
|
|
233
|
+
querying = new Set();
|
|
229
234
|
closed = false;
|
|
230
235
|
constructor(config) {
|
|
231
236
|
this.config = config;
|
|
@@ -241,7 +246,11 @@ class GoldSkySubscriber {
|
|
|
241
246
|
clearInterval(existing);
|
|
242
247
|
this.pollTimers.delete(address);
|
|
243
248
|
}
|
|
244
|
-
const timer = setInterval(() =>
|
|
249
|
+
const timer = setInterval(() => {
|
|
250
|
+
this.query(address).catch((err) => {
|
|
251
|
+
logger_1.logger.error(`GoldSkySubscriber: query failed for ${address}`, { error: String(err) });
|
|
252
|
+
});
|
|
253
|
+
}, this.pollMs);
|
|
245
254
|
this.pollTimers.set(address, timer);
|
|
246
255
|
}
|
|
247
256
|
unsubscribe(address) {
|
|
@@ -254,6 +263,7 @@ class GoldSkySubscriber {
|
|
|
254
263
|
this.abortControllers.delete(address);
|
|
255
264
|
this.callbacks.delete(address);
|
|
256
265
|
this.addressQueryTypes.delete(address);
|
|
266
|
+
this.querying.delete(address);
|
|
257
267
|
}
|
|
258
268
|
close() {
|
|
259
269
|
this.closed = true;
|
|
@@ -266,14 +276,22 @@ class GoldSkySubscriber {
|
|
|
266
276
|
const types = this.addressQueryTypes.get(address);
|
|
267
277
|
if (!callback || !types)
|
|
268
278
|
return;
|
|
269
|
-
this.
|
|
270
|
-
const controller = new AbortController();
|
|
271
|
-
this.abortControllers.set(address, controller);
|
|
272
|
-
const goldSkyFetch = (q) => this.runQuery(q, controller.signal);
|
|
273
|
-
const data = await this.config.buildSubscription(address, types, goldSkyFetch, this.config.baseUrl);
|
|
274
|
-
if (!data)
|
|
279
|
+
if (this.querying.has(address))
|
|
275
280
|
return;
|
|
276
|
-
|
|
281
|
+
this.querying.add(address);
|
|
282
|
+
try {
|
|
283
|
+
this.abortControllers.get(address)?.abort();
|
|
284
|
+
const controller = new AbortController();
|
|
285
|
+
this.abortControllers.set(address, controller);
|
|
286
|
+
const goldSkyFetch = (q) => this.runQuery(q, controller.signal);
|
|
287
|
+
const data = await this.config.buildSubscription(address, types, goldSkyFetch, this.config.baseUrl);
|
|
288
|
+
if (!data)
|
|
289
|
+
return;
|
|
290
|
+
callback(data);
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
this.querying.delete(address);
|
|
294
|
+
}
|
|
277
295
|
}
|
|
278
296
|
async runQuery(q, signal) {
|
|
279
297
|
const headers = { 'Content-Type': 'application/json' };
|
|
@@ -297,14 +315,15 @@ class GoldSkySubscriber {
|
|
|
297
315
|
return null;
|
|
298
316
|
}
|
|
299
317
|
const json = await res.json();
|
|
300
|
-
if (json
|
|
318
|
+
if (json.errors) {
|
|
301
319
|
logger_1.logger.warn(`GoldSkySubscriber: GraphQL errors from ${q.url}`, { errors: JSON.stringify(json.errors) });
|
|
302
320
|
return null;
|
|
303
321
|
}
|
|
304
|
-
return json
|
|
322
|
+
return json.data ?? null;
|
|
305
323
|
}
|
|
306
324
|
catch (err) {
|
|
307
|
-
|
|
325
|
+
const name = err instanceof Error ? err.name : undefined;
|
|
326
|
+
if (name !== 'AbortError' && name !== 'TimeoutError') {
|
|
308
327
|
logger_1.logger.warn(`GoldSkySubscriber: Fetch failed for ${q.url}`, { error: String(err) });
|
|
309
328
|
}
|
|
310
329
|
return null;
|
|
@@ -43,17 +43,15 @@ class AddressWatcher {
|
|
|
43
43
|
if (assetId) {
|
|
44
44
|
const assetKey = `${key} ${assetId}`;
|
|
45
45
|
return new Promise((resolve, reject) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.assetIdResolvers.get(assetKey).push({ resolve, reject });
|
|
46
|
+
const list = this.assetIdResolvers.get(assetKey) ?? [];
|
|
47
|
+
list.push({ resolve, reject });
|
|
48
|
+
this.assetIdResolvers.set(assetKey, list);
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
return new Promise((resolve, reject) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.resolvers.get(key).push({ resolve, reject });
|
|
52
|
+
const list = this.resolvers.get(key) ?? [];
|
|
53
|
+
list.push({ resolve, reject });
|
|
54
|
+
this.resolvers.set(key, list);
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
57
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ export interface Order {
|
|
|
160
160
|
price?: number;
|
|
161
161
|
amount: number;
|
|
162
162
|
/** Lifecycle status of the order. */
|
|
163
|
-
status: 'pending' | 'open' | 'filled' | '
|
|
163
|
+
status: 'pending' | 'open' | 'filled' | 'canceled' | 'rejected';
|
|
164
164
|
filled: number;
|
|
165
165
|
/** Amount filled in shares/contracts (if different from USDC-denominated `filled`). */
|
|
166
166
|
filledShares?: number;
|
|
@@ -12,7 +12,7 @@ export declare class ErrorMapper {
|
|
|
12
12
|
/**
|
|
13
13
|
* Main entry point for error mapping
|
|
14
14
|
*/
|
|
15
|
-
mapError(error:
|
|
15
|
+
mapError(error: unknown): BaseError;
|
|
16
16
|
/**
|
|
17
17
|
* Maps axios HTTP errors to appropriate error classes
|
|
18
18
|
*/
|
|
@@ -20,25 +20,25 @@ export declare class ErrorMapper {
|
|
|
20
20
|
/**
|
|
21
21
|
* Maps an HTTP status code to the appropriate error class
|
|
22
22
|
*/
|
|
23
|
-
protected mapByStatusCode(status: number, message: string, data:
|
|
23
|
+
protected mapByStatusCode(status: number, message: string, data: unknown, response?: unknown): BaseError;
|
|
24
24
|
/**
|
|
25
25
|
* Maps 400 errors to specific bad request subtypes
|
|
26
26
|
*/
|
|
27
|
-
protected mapBadRequestError(message: string, data:
|
|
27
|
+
protected mapBadRequestError(message: string, data: unknown): BadRequest;
|
|
28
28
|
/**
|
|
29
29
|
* Maps 404 errors to specific not found subtypes
|
|
30
30
|
*/
|
|
31
|
-
protected mapNotFoundError(message: string, data:
|
|
31
|
+
protected mapNotFoundError(message: string, data: unknown): NotFound;
|
|
32
32
|
/**
|
|
33
33
|
* Maps rate limit errors
|
|
34
34
|
*/
|
|
35
|
-
protected mapRateLimitError(message: string, response:
|
|
35
|
+
protected mapRateLimitError(message: string, response: unknown): RateLimitExceeded;
|
|
36
36
|
/**
|
|
37
37
|
* Extracts error message from various error formats
|
|
38
38
|
*/
|
|
39
|
-
protected extractErrorMessage(error:
|
|
39
|
+
protected extractErrorMessage(error: unknown): string;
|
|
40
40
|
/**
|
|
41
41
|
* Extracts a message string from a response data payload
|
|
42
42
|
*/
|
|
43
|
-
protected extractFromData(data:
|
|
43
|
+
protected extractFromData(data: unknown): string | undefined;
|
|
44
44
|
}
|
|
@@ -6,6 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ErrorMapper = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const errors_1 = require("../errors");
|
|
9
|
+
/** Type guard for plain error objects with numeric status codes. */
|
|
10
|
+
function isPlainErrorObject(value) {
|
|
11
|
+
return (typeof value === 'object' &&
|
|
12
|
+
value !== null &&
|
|
13
|
+
!Array.isArray(value) &&
|
|
14
|
+
!(value instanceof Error) &&
|
|
15
|
+
'status' in value &&
|
|
16
|
+
typeof value.status === 'number');
|
|
17
|
+
}
|
|
18
|
+
/** Type guard for Node.js-style errors with a `code` property. */
|
|
19
|
+
function isNodeError(value) {
|
|
20
|
+
return value instanceof Error && 'code' in value;
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Maps raw errors to PMXT unified error classes
|
|
11
24
|
*
|
|
@@ -33,15 +46,15 @@ class ErrorMapper {
|
|
|
33
46
|
return this.mapAxiosError(error);
|
|
34
47
|
}
|
|
35
48
|
// Handle plain objects with status/data (e.g., Polymarket clob-client)
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return this.mapByStatusCode(error.status, message, error.data, error);
|
|
40
|
-
}
|
|
49
|
+
if (isPlainErrorObject(error)) {
|
|
50
|
+
const message = this.extractErrorMessage(error);
|
|
51
|
+
return this.mapByStatusCode(error.status, message, error.data, error);
|
|
41
52
|
}
|
|
42
53
|
// Handle network errors
|
|
43
|
-
if (error
|
|
44
|
-
|
|
54
|
+
if (isNodeError(error)) {
|
|
55
|
+
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND' || error.code === 'ETIMEDOUT') {
|
|
56
|
+
return new errors_1.NetworkError(`Network error: ${error.message}`, this.exchangeName);
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
// Handle Error instances with attached HTTP metadata (common in third-party SDKs)
|
|
47
60
|
if (error instanceof Error) {
|
|
@@ -153,7 +166,10 @@ class ErrorMapper {
|
|
|
153
166
|
*/
|
|
154
167
|
mapRateLimitError(message, response) {
|
|
155
168
|
// Try to extract retry-after from headers
|
|
156
|
-
const
|
|
169
|
+
const headers = (typeof response === 'object' && response !== null && 'headers' in response
|
|
170
|
+
? response.headers
|
|
171
|
+
: undefined);
|
|
172
|
+
const retryAfter = headers?.['retry-after'];
|
|
157
173
|
const retryAfterSeconds = retryAfter ? parseInt(retryAfter, 10) : undefined;
|
|
158
174
|
return new errors_1.RateLimitExceeded(message, retryAfterSeconds, this.exchangeName);
|
|
159
175
|
}
|
|
@@ -168,44 +184,34 @@ class ErrorMapper {
|
|
|
168
184
|
if (typeof data === 'string') {
|
|
169
185
|
return data;
|
|
170
186
|
}
|
|
171
|
-
if (data
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
if (typeof data === 'object' && data !== null) {
|
|
188
|
+
const obj = data;
|
|
189
|
+
if (obj.error) {
|
|
190
|
+
if (typeof obj.error === 'string') {
|
|
191
|
+
return obj.error;
|
|
192
|
+
}
|
|
193
|
+
if (typeof obj.error === 'object' && obj.error !== null && 'message' in obj.error) {
|
|
194
|
+
return String(obj.error.message);
|
|
195
|
+
}
|
|
174
196
|
}
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
197
|
+
if (typeof obj.message === 'string') {
|
|
198
|
+
return obj.message;
|
|
199
|
+
}
|
|
200
|
+
if (typeof obj.errorMsg === 'string') {
|
|
201
|
+
return obj.errorMsg;
|
|
177
202
|
}
|
|
178
|
-
}
|
|
179
|
-
if (data.message) {
|
|
180
|
-
return data.message;
|
|
181
|
-
}
|
|
182
|
-
if (data.errorMsg) {
|
|
183
|
-
return data.errorMsg;
|
|
184
203
|
}
|
|
185
204
|
// Fallback to stringified data
|
|
186
205
|
return JSON.stringify(data);
|
|
187
206
|
}
|
|
188
207
|
// Plain object with status and data (e.g., Polymarket clob-client errors)
|
|
189
208
|
// These aren't AxiosError instances but have similar structure
|
|
190
|
-
if (
|
|
209
|
+
if (isPlainErrorObject(error)) {
|
|
191
210
|
const data = error.data;
|
|
192
211
|
if (data) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (data.error) {
|
|
197
|
-
if (typeof data.error === 'string') {
|
|
198
|
-
return data.error;
|
|
199
|
-
}
|
|
200
|
-
if (data.error.message) {
|
|
201
|
-
return data.error.message;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (data.message) {
|
|
205
|
-
return data.message;
|
|
206
|
-
}
|
|
207
|
-
if (data.errorMsg) {
|
|
208
|
-
return data.errorMsg;
|
|
212
|
+
const extracted = this.extractFromData(data);
|
|
213
|
+
if (extracted) {
|
|
214
|
+
return extracted;
|
|
209
215
|
}
|
|
210
216
|
}
|
|
211
217
|
// Check for message at top level
|
|
@@ -237,7 +243,7 @@ class ErrorMapper {
|
|
|
237
243
|
try {
|
|
238
244
|
return JSON.stringify(error, Object.getOwnPropertyNames(error));
|
|
239
245
|
}
|
|
240
|
-
catch
|
|
246
|
+
catch {
|
|
241
247
|
return String(error);
|
|
242
248
|
}
|
|
243
249
|
}
|
|
@@ -250,20 +256,21 @@ class ErrorMapper {
|
|
|
250
256
|
if (typeof data === 'string') {
|
|
251
257
|
return data;
|
|
252
258
|
}
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
259
|
+
if (typeof data === 'object' && data !== null) {
|
|
260
|
+
const obj = data;
|
|
261
|
+
if (obj.error) {
|
|
262
|
+
if (typeof obj.error === 'string') {
|
|
263
|
+
return obj.error;
|
|
257
264
|
}
|
|
258
|
-
if (
|
|
259
|
-
return
|
|
265
|
+
if (typeof obj.error === 'object' && obj.error !== null && 'message' in obj.error) {
|
|
266
|
+
return String(obj.error.message);
|
|
260
267
|
}
|
|
261
268
|
}
|
|
262
|
-
if (
|
|
263
|
-
return
|
|
269
|
+
if (typeof obj.message === 'string') {
|
|
270
|
+
return obj.message;
|
|
264
271
|
}
|
|
265
|
-
if (
|
|
266
|
-
return
|
|
272
|
+
if (typeof obj.errorMsg === 'string') {
|
|
273
|
+
return obj.errorMsg;
|
|
267
274
|
}
|
|
268
275
|
try {
|
|
269
276
|
return JSON.stringify(data);
|
|
@@ -46,11 +46,11 @@ function addBinaryOutcomes(market) {
|
|
|
46
46
|
// those are meaningful labels for financial markets.
|
|
47
47
|
const yesLabel = market.yes?.label.toLowerCase();
|
|
48
48
|
const noLabel = market.no?.label.toLowerCase();
|
|
49
|
-
if (market.title && yesLabel === 'yes') {
|
|
50
|
-
market.yes
|
|
49
|
+
if (market.title && market.yes && yesLabel === 'yes') {
|
|
50
|
+
market.yes = { ...market.yes, label: market.title };
|
|
51
51
|
}
|
|
52
|
-
if (market.title && noLabel === 'no') {
|
|
53
|
-
market.no.label
|
|
52
|
+
if (market.title && market.no && noLabel === 'no') {
|
|
53
|
+
market.no = { ...market.no, label: `Not ${market.title}` };
|
|
54
54
|
}
|
|
55
55
|
market.up = market.yes;
|
|
56
56
|
market.down = market.no;
|
|
@@ -6,10 +6,12 @@ export declare class Throttler {
|
|
|
6
6
|
private refillRate;
|
|
7
7
|
private capacity;
|
|
8
8
|
private delay;
|
|
9
|
+
private maxQueueDepth;
|
|
9
10
|
constructor(config: {
|
|
10
11
|
refillRate: number;
|
|
11
12
|
capacity: number;
|
|
12
13
|
delay: number;
|
|
14
|
+
maxQueueDepth?: number;
|
|
13
15
|
});
|
|
14
16
|
throttle(cost?: number): Promise<void>;
|
|
15
17
|
private loop;
|
package/dist/utils/throttler.js
CHANGED
|
@@ -9,13 +9,21 @@ class Throttler {
|
|
|
9
9
|
refillRate;
|
|
10
10
|
capacity;
|
|
11
11
|
delay;
|
|
12
|
+
maxQueueDepth;
|
|
12
13
|
constructor(config) {
|
|
13
14
|
this.refillRate = config.refillRate;
|
|
14
15
|
this.capacity = config.capacity;
|
|
15
16
|
this.delay = config.delay;
|
|
17
|
+
this.maxQueueDepth = config.maxQueueDepth ?? 1000;
|
|
16
18
|
}
|
|
17
19
|
async throttle(cost = 1) {
|
|
18
20
|
return new Promise((resolve) => {
|
|
21
|
+
if (this.queue.length >= this.maxQueueDepth) {
|
|
22
|
+
const dropped = this.queue.shift();
|
|
23
|
+
if (dropped) {
|
|
24
|
+
dropped.resolve();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
19
27
|
this.queue.push({ resolve, cost });
|
|
20
28
|
if (!this.running) {
|
|
21
29
|
this.running = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.43.
|
|
3
|
+
"version": "2.43.24",
|
|
4
4
|
"description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test": "jest -c jest.config.js",
|
|
30
30
|
"server": "tsx watch src/server/index.ts",
|
|
31
31
|
"server:prod": "node dist/server/index.js",
|
|
32
|
-
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.43.
|
|
33
|
-
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.43.
|
|
32
|
+
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.43.24,library=urllib3",
|
|
33
|
+
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.43.24,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
|
|
34
34
|
"fetch:openapi": "node scripts/fetch-openapi-specs.js",
|
|
35
35
|
"extract:jsdoc": "node ../scripts/extract-jsdoc.js",
|
|
36
36
|
"generate:docs": "npm run extract:jsdoc && node ../scripts/generate-api-docs.js",
|