@agg-build/sdk 4.25.0 → 4.26.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/{agg-websocket-Bxt9PzTz.d.mts → agg-websocket-x_U4-orL.d.mts} +133 -14
- package/dist/{agg-websocket-Bxt9PzTz.d.ts → agg-websocket-x_U4-orL.d.ts} +133 -14
- package/dist/browser.d.mts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +129 -3
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-QXBVA5TW.mjs → chunk-CPMSVNBO.mjs} +129 -3
- package/dist/index.d.mts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +162 -10
- package/dist/index.mjs +34 -8
- package/dist/market-data.d.mts +2 -2
- package/dist/market-data.d.ts +2 -2
- package/dist/market-data.js +129 -3
- package/dist/market-data.mjs +1 -1
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AggWebSocket, a as AggWebSocketOptions, C as ChartBarsResponse, b as ChartHistoryManifest, c as ChartCandle, d as AggWebSocketDiagnostics, M as MarketDataEngine, O as OrderbookState, W as WsArbMarketUpdate, e as WsArbFeedBatch, f as AggWebSocketCallbacks } from './agg-websocket-
|
|
1
|
+
import { A as AggWebSocket, a as AggWebSocketOptions, C as ChartBarsResponse, b as ChartHistoryManifest, c as ChartCandle, d as AggWebSocketDiagnostics, M as MarketDataEngine, O as OrderbookState, W as WsArbMarketUpdate, e as WsArbFeedBatch, f as AggWebSocketCallbacks } from './agg-websocket-x_U4-orL.js';
|
|
2
2
|
|
|
3
3
|
/** The application owns the native module Worker URL so its static bundler fingerprints it. */
|
|
4
4
|
type MarketDataWorkerFactory = () => Worker;
|
package/dist/browser.js
CHANGED
|
@@ -776,6 +776,10 @@ var RECONNECT_BASE_MS = 1e3;
|
|
|
776
776
|
var RECONNECT_MAX_MS = 3e4;
|
|
777
777
|
var STALE_TIMEOUT_MS = 45e3;
|
|
778
778
|
var ORDERBOOK_DEBUG_TOP_LEVELS = 5;
|
|
779
|
+
var WATCHDOG_SILENCE_MS = 5 * 6e4;
|
|
780
|
+
var WATCHDOG_CHECK_INTERVAL_MS = 6e4;
|
|
781
|
+
var WATCHDOG_BATCH_MAX = 100;
|
|
782
|
+
var WATCHDOG_REQUEST_TIMEOUT_MS = 15e3;
|
|
779
783
|
var AggWebSocket = class {
|
|
780
784
|
constructor(options) {
|
|
781
785
|
this.ws = null;
|
|
@@ -801,6 +805,18 @@ var AggWebSocket = class {
|
|
|
801
805
|
this.books = /* @__PURE__ */ new Map();
|
|
802
806
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
803
807
|
this.resyncing = /* @__PURE__ */ new Set();
|
|
808
|
+
/**
|
|
809
|
+
* Per subscribed orderbook outcome: last time it made progress (subscribe,
|
|
810
|
+
* snapshot, applied delta) or was checked against REST (ms). Tracked from
|
|
811
|
+
* subscribe, not from the first snapshot, so a book that never arrives or
|
|
812
|
+
* is stuck resyncing is still found by the watchdog.
|
|
813
|
+
*/
|
|
814
|
+
this.bookCheckedAt = /* @__PURE__ */ new Map();
|
|
815
|
+
/** Outcomes the watchdog already resnapshotted; a repeat mismatch resubscribes. */
|
|
816
|
+
this.watchdogResnapshotted = /* @__PURE__ */ new Set();
|
|
817
|
+
this.watchdogTimer = null;
|
|
818
|
+
this.watchdogAbort = null;
|
|
819
|
+
this.watchdogPausedUntil = 0;
|
|
804
820
|
// ── Connection state ──
|
|
805
821
|
this.connecting = false;
|
|
806
822
|
this._connected = false;
|
|
@@ -816,6 +832,7 @@ var AggWebSocket = class {
|
|
|
816
832
|
this.callbacks = (_b = options.callbacks) != null ? _b : {};
|
|
817
833
|
this.initialToken = options.initialToken;
|
|
818
834
|
this.enableLogs = (_c = options.enableLogs) != null ? _c : false;
|
|
835
|
+
this.bookWatchdog = options.bookWatchdog;
|
|
819
836
|
}
|
|
820
837
|
// ── Public API ──
|
|
821
838
|
get connected() {
|
|
@@ -961,6 +978,7 @@ var AggWebSocket = class {
|
|
|
961
978
|
this.subs.set(outcomeId, sub);
|
|
962
979
|
}
|
|
963
980
|
if (sub.refCount === 0) {
|
|
981
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
964
982
|
this.pendingSubs.add(outcomeId);
|
|
965
983
|
this.ensureConnected();
|
|
966
984
|
if (this._connected) {
|
|
@@ -985,6 +1003,8 @@ var AggWebSocket = class {
|
|
|
985
1003
|
this.books.delete(outcomeId);
|
|
986
1004
|
}
|
|
987
1005
|
this.resyncing.delete(outcomeId);
|
|
1006
|
+
this.bookCheckedAt.delete(outcomeId);
|
|
1007
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
988
1008
|
if (this._connected) {
|
|
989
1009
|
if (this.pendingFlushSubs.has(outcomeId)) {
|
|
990
1010
|
this.pendingFlushSubs.delete(outcomeId);
|
|
@@ -1052,6 +1072,7 @@ var AggWebSocket = class {
|
|
|
1052
1072
|
}
|
|
1053
1073
|
/** Send a JWT to authenticate (or re-authenticate) the connection. */
|
|
1054
1074
|
authenticate(token) {
|
|
1075
|
+
this.initialToken = token;
|
|
1055
1076
|
if (this._connected) {
|
|
1056
1077
|
this.send({ action: "authenticate", token });
|
|
1057
1078
|
}
|
|
@@ -1083,6 +1104,7 @@ var AggWebSocket = class {
|
|
|
1083
1104
|
}
|
|
1084
1105
|
/** Permanently destroy. Cannot reconnect after this. */
|
|
1085
1106
|
destroy() {
|
|
1107
|
+
var _a;
|
|
1086
1108
|
this.destroyed = true;
|
|
1087
1109
|
for (const controller of this.historyControllers)
|
|
1088
1110
|
controller.abort(new Error("Market-data client disposed"));
|
|
@@ -1093,6 +1115,12 @@ var AggWebSocket = class {
|
|
|
1093
1115
|
this.subs.clear();
|
|
1094
1116
|
this.books.clear();
|
|
1095
1117
|
this.resyncing.clear();
|
|
1118
|
+
if (this.watchdogTimer) clearInterval(this.watchdogTimer);
|
|
1119
|
+
this.watchdogTimer = null;
|
|
1120
|
+
(_a = this.watchdogAbort) == null ? void 0 : _a.abort();
|
|
1121
|
+
this.watchdogAbort = null;
|
|
1122
|
+
this.bookCheckedAt.clear();
|
|
1123
|
+
this.watchdogResnapshotted.clear();
|
|
1096
1124
|
this.pendingSubs.clear();
|
|
1097
1125
|
this.pendingTradeSubs.clear();
|
|
1098
1126
|
this.pendingResnapshots.clear();
|
|
@@ -1276,11 +1304,21 @@ var AggWebSocket = class {
|
|
|
1276
1304
|
* ready to accept subscriptions. Now flush all pending subs.
|
|
1277
1305
|
*/
|
|
1278
1306
|
handleConnected(msg) {
|
|
1279
|
-
var _a, _b, _c, _d;
|
|
1307
|
+
var _a, _b, _c, _d, _e;
|
|
1280
1308
|
this._connected = true;
|
|
1281
|
-
|
|
1282
|
-
|
|
1309
|
+
if (this.bookWatchdog && !this.watchdogTimer && !this.destroyed) {
|
|
1310
|
+
this.watchdogTimer = setInterval(
|
|
1311
|
+
() => void this.checkSilentBooks(),
|
|
1312
|
+
(_a = this.bookWatchdog.checkIntervalMs) != null ? _a : WATCHDOG_CHECK_INTERVAL_MS
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
(_c = (_b = this.callbacks).onConnectionStateChange) == null ? void 0 : _c.call(_b, true);
|
|
1316
|
+
(_e = (_d = this.callbacks).onConnected) == null ? void 0 : _e.call(_d, msg);
|
|
1283
1317
|
const orderbookSet = new Set(this.activeOrderbookMarkets());
|
|
1318
|
+
const reconnectedAt = Date.now();
|
|
1319
|
+
for (const id of orderbookSet) {
|
|
1320
|
+
if (this.bookCheckedAt.has(id)) this.bookCheckedAt.set(id, reconnectedAt);
|
|
1321
|
+
}
|
|
1284
1322
|
this.pendingSubs.forEach((id) => orderbookSet.add(id));
|
|
1285
1323
|
this.pendingFlushSubs.forEach((id) => orderbookSet.add(id));
|
|
1286
1324
|
const orderbookIds = Array.from(orderbookSet);
|
|
@@ -1323,6 +1361,7 @@ var AggWebSocket = class {
|
|
|
1323
1361
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1324
1362
|
const book = snapshotToOrderbook(msg);
|
|
1325
1363
|
this.books.set(msg.outcomeId, new IndexedOrderbook(book));
|
|
1364
|
+
this.bookCheckedAt.set(msg.outcomeId, Date.now());
|
|
1326
1365
|
this.resyncing.delete(msg.outcomeId);
|
|
1327
1366
|
this.pendingResnapshots.delete(msg.outcomeId);
|
|
1328
1367
|
this.debugOrderbook("snapshot_applied", {
|
|
@@ -1392,6 +1431,8 @@ var AggWebSocket = class {
|
|
|
1392
1431
|
this.requestResnapshot(outcomeId);
|
|
1393
1432
|
return;
|
|
1394
1433
|
}
|
|
1434
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1435
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1395
1436
|
(_b = (_a = this.callbacks).onBookTick) == null ? void 0 : _b.call(_a, outcomeId, {
|
|
1396
1437
|
midpoint: msg.midpoint,
|
|
1397
1438
|
timestamp: msg.timestamp,
|
|
@@ -1414,6 +1455,8 @@ var AggWebSocket = class {
|
|
|
1414
1455
|
var _a, _b;
|
|
1415
1456
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1416
1457
|
this.books.delete(msg.outcomeId);
|
|
1458
|
+
this.bookCheckedAt.delete(msg.outcomeId);
|
|
1459
|
+
this.watchdogResnapshotted.delete(msg.outcomeId);
|
|
1417
1460
|
this.pendingResnapshots.delete(msg.outcomeId);
|
|
1418
1461
|
this.resyncing.delete(msg.outcomeId);
|
|
1419
1462
|
(_b = (_a = this.callbacks).onMarketResolved) == null ? void 0 : _b.call(_a, msg);
|
|
@@ -1433,6 +1476,89 @@ var AggWebSocket = class {
|
|
|
1433
1476
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1434
1477
|
(_b = (_a = this.callbacks).onRedeemEvent) == null ? void 0 : _b.call(_a, msg);
|
|
1435
1478
|
}
|
|
1479
|
+
// ── Book watchdog ──
|
|
1480
|
+
/**
|
|
1481
|
+
* Heartbeats prove the socket, not each stream. Every subscribed outcome
|
|
1482
|
+
* with no progress for `silenceMs` is checked against the REST `seq`:
|
|
1483
|
+
*
|
|
1484
|
+
* - book present, not resyncing, same `seq` → the market is just quiet;
|
|
1485
|
+
* - different `seq`, no book (snapshot never arrived, or a resubscribe's
|
|
1486
|
+
* snapshot was lost), or stuck resyncing (any recovery whose snapshot
|
|
1487
|
+
* was lost) → resnapshot, then resubscribe on the next overdue check;
|
|
1488
|
+
* - REST can't serve it (`null`) → counted as an attempt, so the next
|
|
1489
|
+
* batch moves on to other outcomes instead of retrying the same 100.
|
|
1490
|
+
*/
|
|
1491
|
+
checkSilentBooks() {
|
|
1492
|
+
return __async(this, null, function* () {
|
|
1493
|
+
var _a;
|
|
1494
|
+
const opts = this.bookWatchdog;
|
|
1495
|
+
if (!opts || !this._connected || this.watchdogAbort) return;
|
|
1496
|
+
const now = Date.now();
|
|
1497
|
+
if (now < this.watchdogPausedUntil) return;
|
|
1498
|
+
const silenceMs = (_a = opts.silenceMs) != null ? _a : WATCHDOG_SILENCE_MS;
|
|
1499
|
+
const silent = this.activeOrderbookMarkets().filter((id) => this.bookCheckedAt.has(id)).filter((id) => now - this.bookCheckedAt.get(id) >= silenceMs).sort((a, b) => this.bookCheckedAt.get(a) - this.bookCheckedAt.get(b)).slice(0, WATCHDOG_BATCH_MAX);
|
|
1500
|
+
if (silent.length === 0) return;
|
|
1501
|
+
const checkedAt = new Map(silent.map((id) => [id, this.bookCheckedAt.get(id)]));
|
|
1502
|
+
const abort = new AbortController();
|
|
1503
|
+
this.watchdogAbort = abort;
|
|
1504
|
+
const timeout = setTimeout(() => abort.abort(), WATCHDOG_REQUEST_TIMEOUT_MS);
|
|
1505
|
+
try {
|
|
1506
|
+
const url = new URL(`${opts.baseUrl.replace(/\/$/, "")}/orderbooks/outcomes`);
|
|
1507
|
+
url.searchParams.set("venueMarketOutcomeIds", silent.join(","));
|
|
1508
|
+
url.searchParams.set("depth", "1");
|
|
1509
|
+
const response = yield fetch(url, { headers: opts.headers, signal: abort.signal });
|
|
1510
|
+
if (!response.ok) {
|
|
1511
|
+
const retryAfterS = Number(response.headers.get("retry-after"));
|
|
1512
|
+
if (response.status === 429 && retryAfterS > 0) {
|
|
1513
|
+
this.watchdogPausedUntil = Date.now() + retryAfterS * 1e3;
|
|
1514
|
+
}
|
|
1515
|
+
this.emitDiagnostic({ type: "book_watchdog_error", status: response.status });
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const body = yield response.json();
|
|
1519
|
+
if (this.destroyed) return;
|
|
1520
|
+
silent.forEach((outcomeId, i) => {
|
|
1521
|
+
var _a2, _b;
|
|
1522
|
+
if (this.bookCheckedAt.get(outcomeId) !== checkedAt.get(outcomeId)) return;
|
|
1523
|
+
const server = (_a2 = body.data) == null ? void 0 : _a2[i];
|
|
1524
|
+
if (!server) {
|
|
1525
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
const book = this.books.get(outcomeId);
|
|
1529
|
+
if (book && !this.resyncing.has(outcomeId) && server.seq === book.seq) {
|
|
1530
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1531
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
const action = this.watchdogResnapshotted.has(outcomeId) ? "resubscribe" : "resnapshot";
|
|
1535
|
+
this.emitDiagnostic({
|
|
1536
|
+
type: "book_watchdog_resync",
|
|
1537
|
+
outcomeId,
|
|
1538
|
+
localSeq: (_b = book == null ? void 0 : book.seq) != null ? _b : null,
|
|
1539
|
+
serverSeq: server.seq,
|
|
1540
|
+
action
|
|
1541
|
+
});
|
|
1542
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1543
|
+
if (action === "resubscribe") {
|
|
1544
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1545
|
+
this.books.delete(outcomeId);
|
|
1546
|
+
this.resyncing.add(outcomeId);
|
|
1547
|
+
this.send({ action: "unsubscribe", channel: "orderbook", outcomeIds: [outcomeId] });
|
|
1548
|
+
this.sendSubscribe([outcomeId]);
|
|
1549
|
+
} else {
|
|
1550
|
+
this.watchdogResnapshotted.add(outcomeId);
|
|
1551
|
+
this.requestResnapshot(outcomeId, true);
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
} catch (e) {
|
|
1555
|
+
if (!this.destroyed) this.emitDiagnostic({ type: "book_watchdog_error", status: null });
|
|
1556
|
+
} finally {
|
|
1557
|
+
clearTimeout(timeout);
|
|
1558
|
+
if (this.watchdogAbort === abort) this.watchdogAbort = null;
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1436
1562
|
// ── Resnapshot ──
|
|
1437
1563
|
requestResnapshot(outcomeId, force = false) {
|
|
1438
1564
|
if (this.resyncing.has(outcomeId) && !force) return;
|
package/dist/browser.mjs
CHANGED
|
@@ -1213,6 +1213,10 @@ var RECONNECT_BASE_MS = 1e3;
|
|
|
1213
1213
|
var RECONNECT_MAX_MS = 3e4;
|
|
1214
1214
|
var STALE_TIMEOUT_MS = 45e3;
|
|
1215
1215
|
var ORDERBOOK_DEBUG_TOP_LEVELS = 5;
|
|
1216
|
+
var WATCHDOG_SILENCE_MS = 5 * 6e4;
|
|
1217
|
+
var WATCHDOG_CHECK_INTERVAL_MS = 6e4;
|
|
1218
|
+
var WATCHDOG_BATCH_MAX = 100;
|
|
1219
|
+
var WATCHDOG_REQUEST_TIMEOUT_MS = 15e3;
|
|
1216
1220
|
var AggWebSocket = class {
|
|
1217
1221
|
constructor(options) {
|
|
1218
1222
|
this.ws = null;
|
|
@@ -1238,6 +1242,18 @@ var AggWebSocket = class {
|
|
|
1238
1242
|
this.books = /* @__PURE__ */ new Map();
|
|
1239
1243
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
1240
1244
|
this.resyncing = /* @__PURE__ */ new Set();
|
|
1245
|
+
/**
|
|
1246
|
+
* Per subscribed orderbook outcome: last time it made progress (subscribe,
|
|
1247
|
+
* snapshot, applied delta) or was checked against REST (ms). Tracked from
|
|
1248
|
+
* subscribe, not from the first snapshot, so a book that never arrives or
|
|
1249
|
+
* is stuck resyncing is still found by the watchdog.
|
|
1250
|
+
*/
|
|
1251
|
+
this.bookCheckedAt = /* @__PURE__ */ new Map();
|
|
1252
|
+
/** Outcomes the watchdog already resnapshotted; a repeat mismatch resubscribes. */
|
|
1253
|
+
this.watchdogResnapshotted = /* @__PURE__ */ new Set();
|
|
1254
|
+
this.watchdogTimer = null;
|
|
1255
|
+
this.watchdogAbort = null;
|
|
1256
|
+
this.watchdogPausedUntil = 0;
|
|
1241
1257
|
// ── Connection state ──
|
|
1242
1258
|
this.connecting = false;
|
|
1243
1259
|
this._connected = false;
|
|
@@ -1253,6 +1269,7 @@ var AggWebSocket = class {
|
|
|
1253
1269
|
this.callbacks = (_b = options.callbacks) != null ? _b : {};
|
|
1254
1270
|
this.initialToken = options.initialToken;
|
|
1255
1271
|
this.enableLogs = (_c = options.enableLogs) != null ? _c : false;
|
|
1272
|
+
this.bookWatchdog = options.bookWatchdog;
|
|
1256
1273
|
}
|
|
1257
1274
|
// ── Public API ──
|
|
1258
1275
|
get connected() {
|
|
@@ -1398,6 +1415,7 @@ var AggWebSocket = class {
|
|
|
1398
1415
|
this.subs.set(outcomeId, sub);
|
|
1399
1416
|
}
|
|
1400
1417
|
if (sub.refCount === 0) {
|
|
1418
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1401
1419
|
this.pendingSubs.add(outcomeId);
|
|
1402
1420
|
this.ensureConnected();
|
|
1403
1421
|
if (this._connected) {
|
|
@@ -1422,6 +1440,8 @@ var AggWebSocket = class {
|
|
|
1422
1440
|
this.books.delete(outcomeId);
|
|
1423
1441
|
}
|
|
1424
1442
|
this.resyncing.delete(outcomeId);
|
|
1443
|
+
this.bookCheckedAt.delete(outcomeId);
|
|
1444
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1425
1445
|
if (this._connected) {
|
|
1426
1446
|
if (this.pendingFlushSubs.has(outcomeId)) {
|
|
1427
1447
|
this.pendingFlushSubs.delete(outcomeId);
|
|
@@ -1489,6 +1509,7 @@ var AggWebSocket = class {
|
|
|
1489
1509
|
}
|
|
1490
1510
|
/** Send a JWT to authenticate (or re-authenticate) the connection. */
|
|
1491
1511
|
authenticate(token) {
|
|
1512
|
+
this.initialToken = token;
|
|
1492
1513
|
if (this._connected) {
|
|
1493
1514
|
this.send({ action: "authenticate", token });
|
|
1494
1515
|
}
|
|
@@ -1520,6 +1541,7 @@ var AggWebSocket = class {
|
|
|
1520
1541
|
}
|
|
1521
1542
|
/** Permanently destroy. Cannot reconnect after this. */
|
|
1522
1543
|
destroy() {
|
|
1544
|
+
var _a;
|
|
1523
1545
|
this.destroyed = true;
|
|
1524
1546
|
for (const controller of this.historyControllers)
|
|
1525
1547
|
controller.abort(new Error("Market-data client disposed"));
|
|
@@ -1530,6 +1552,12 @@ var AggWebSocket = class {
|
|
|
1530
1552
|
this.subs.clear();
|
|
1531
1553
|
this.books.clear();
|
|
1532
1554
|
this.resyncing.clear();
|
|
1555
|
+
if (this.watchdogTimer) clearInterval(this.watchdogTimer);
|
|
1556
|
+
this.watchdogTimer = null;
|
|
1557
|
+
(_a = this.watchdogAbort) == null ? void 0 : _a.abort();
|
|
1558
|
+
this.watchdogAbort = null;
|
|
1559
|
+
this.bookCheckedAt.clear();
|
|
1560
|
+
this.watchdogResnapshotted.clear();
|
|
1533
1561
|
this.pendingSubs.clear();
|
|
1534
1562
|
this.pendingTradeSubs.clear();
|
|
1535
1563
|
this.pendingResnapshots.clear();
|
|
@@ -1713,11 +1741,21 @@ var AggWebSocket = class {
|
|
|
1713
1741
|
* ready to accept subscriptions. Now flush all pending subs.
|
|
1714
1742
|
*/
|
|
1715
1743
|
handleConnected(msg) {
|
|
1716
|
-
var _a, _b, _c, _d;
|
|
1744
|
+
var _a, _b, _c, _d, _e;
|
|
1717
1745
|
this._connected = true;
|
|
1718
|
-
|
|
1719
|
-
|
|
1746
|
+
if (this.bookWatchdog && !this.watchdogTimer && !this.destroyed) {
|
|
1747
|
+
this.watchdogTimer = setInterval(
|
|
1748
|
+
() => void this.checkSilentBooks(),
|
|
1749
|
+
(_a = this.bookWatchdog.checkIntervalMs) != null ? _a : WATCHDOG_CHECK_INTERVAL_MS
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1752
|
+
(_c = (_b = this.callbacks).onConnectionStateChange) == null ? void 0 : _c.call(_b, true);
|
|
1753
|
+
(_e = (_d = this.callbacks).onConnected) == null ? void 0 : _e.call(_d, msg);
|
|
1720
1754
|
const orderbookSet = new Set(this.activeOrderbookMarkets());
|
|
1755
|
+
const reconnectedAt = Date.now();
|
|
1756
|
+
for (const id of orderbookSet) {
|
|
1757
|
+
if (this.bookCheckedAt.has(id)) this.bookCheckedAt.set(id, reconnectedAt);
|
|
1758
|
+
}
|
|
1721
1759
|
this.pendingSubs.forEach((id) => orderbookSet.add(id));
|
|
1722
1760
|
this.pendingFlushSubs.forEach((id) => orderbookSet.add(id));
|
|
1723
1761
|
const orderbookIds = Array.from(orderbookSet);
|
|
@@ -1760,6 +1798,7 @@ var AggWebSocket = class {
|
|
|
1760
1798
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1761
1799
|
const book = snapshotToOrderbook(msg);
|
|
1762
1800
|
this.books.set(msg.outcomeId, new IndexedOrderbook(book));
|
|
1801
|
+
this.bookCheckedAt.set(msg.outcomeId, Date.now());
|
|
1763
1802
|
this.resyncing.delete(msg.outcomeId);
|
|
1764
1803
|
this.pendingResnapshots.delete(msg.outcomeId);
|
|
1765
1804
|
this.debugOrderbook("snapshot_applied", {
|
|
@@ -1829,6 +1868,8 @@ var AggWebSocket = class {
|
|
|
1829
1868
|
this.requestResnapshot(outcomeId);
|
|
1830
1869
|
return;
|
|
1831
1870
|
}
|
|
1871
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1872
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1832
1873
|
(_b = (_a = this.callbacks).onBookTick) == null ? void 0 : _b.call(_a, outcomeId, {
|
|
1833
1874
|
midpoint: msg.midpoint,
|
|
1834
1875
|
timestamp: msg.timestamp,
|
|
@@ -1851,6 +1892,8 @@ var AggWebSocket = class {
|
|
|
1851
1892
|
var _a, _b;
|
|
1852
1893
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1853
1894
|
this.books.delete(msg.outcomeId);
|
|
1895
|
+
this.bookCheckedAt.delete(msg.outcomeId);
|
|
1896
|
+
this.watchdogResnapshotted.delete(msg.outcomeId);
|
|
1854
1897
|
this.pendingResnapshots.delete(msg.outcomeId);
|
|
1855
1898
|
this.resyncing.delete(msg.outcomeId);
|
|
1856
1899
|
(_b = (_a = this.callbacks).onMarketResolved) == null ? void 0 : _b.call(_a, msg);
|
|
@@ -1870,6 +1913,89 @@ var AggWebSocket = class {
|
|
|
1870
1913
|
const msg = __spreadProps(__spreadValues({}, raw), { timestamp: raw.timestamp / 1e3 });
|
|
1871
1914
|
(_b = (_a = this.callbacks).onRedeemEvent) == null ? void 0 : _b.call(_a, msg);
|
|
1872
1915
|
}
|
|
1916
|
+
// ── Book watchdog ──
|
|
1917
|
+
/**
|
|
1918
|
+
* Heartbeats prove the socket, not each stream. Every subscribed outcome
|
|
1919
|
+
* with no progress for `silenceMs` is checked against the REST `seq`:
|
|
1920
|
+
*
|
|
1921
|
+
* - book present, not resyncing, same `seq` → the market is just quiet;
|
|
1922
|
+
* - different `seq`, no book (snapshot never arrived, or a resubscribe's
|
|
1923
|
+
* snapshot was lost), or stuck resyncing (any recovery whose snapshot
|
|
1924
|
+
* was lost) → resnapshot, then resubscribe on the next overdue check;
|
|
1925
|
+
* - REST can't serve it (`null`) → counted as an attempt, so the next
|
|
1926
|
+
* batch moves on to other outcomes instead of retrying the same 100.
|
|
1927
|
+
*/
|
|
1928
|
+
checkSilentBooks() {
|
|
1929
|
+
return __async(this, null, function* () {
|
|
1930
|
+
var _a;
|
|
1931
|
+
const opts = this.bookWatchdog;
|
|
1932
|
+
if (!opts || !this._connected || this.watchdogAbort) return;
|
|
1933
|
+
const now = Date.now();
|
|
1934
|
+
if (now < this.watchdogPausedUntil) return;
|
|
1935
|
+
const silenceMs = (_a = opts.silenceMs) != null ? _a : WATCHDOG_SILENCE_MS;
|
|
1936
|
+
const silent = this.activeOrderbookMarkets().filter((id) => this.bookCheckedAt.has(id)).filter((id) => now - this.bookCheckedAt.get(id) >= silenceMs).sort((a, b) => this.bookCheckedAt.get(a) - this.bookCheckedAt.get(b)).slice(0, WATCHDOG_BATCH_MAX);
|
|
1937
|
+
if (silent.length === 0) return;
|
|
1938
|
+
const checkedAt = new Map(silent.map((id) => [id, this.bookCheckedAt.get(id)]));
|
|
1939
|
+
const abort = new AbortController();
|
|
1940
|
+
this.watchdogAbort = abort;
|
|
1941
|
+
const timeout = setTimeout(() => abort.abort(), WATCHDOG_REQUEST_TIMEOUT_MS);
|
|
1942
|
+
try {
|
|
1943
|
+
const url = new URL(`${opts.baseUrl.replace(/\/$/, "")}/orderbooks/outcomes`);
|
|
1944
|
+
url.searchParams.set("venueMarketOutcomeIds", silent.join(","));
|
|
1945
|
+
url.searchParams.set("depth", "1");
|
|
1946
|
+
const response = yield fetch(url, { headers: opts.headers, signal: abort.signal });
|
|
1947
|
+
if (!response.ok) {
|
|
1948
|
+
const retryAfterS = Number(response.headers.get("retry-after"));
|
|
1949
|
+
if (response.status === 429 && retryAfterS > 0) {
|
|
1950
|
+
this.watchdogPausedUntil = Date.now() + retryAfterS * 1e3;
|
|
1951
|
+
}
|
|
1952
|
+
this.emitDiagnostic({ type: "book_watchdog_error", status: response.status });
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
const body = yield response.json();
|
|
1956
|
+
if (this.destroyed) return;
|
|
1957
|
+
silent.forEach((outcomeId, i) => {
|
|
1958
|
+
var _a2, _b;
|
|
1959
|
+
if (this.bookCheckedAt.get(outcomeId) !== checkedAt.get(outcomeId)) return;
|
|
1960
|
+
const server = (_a2 = body.data) == null ? void 0 : _a2[i];
|
|
1961
|
+
if (!server) {
|
|
1962
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const book = this.books.get(outcomeId);
|
|
1966
|
+
if (book && !this.resyncing.has(outcomeId) && server.seq === book.seq) {
|
|
1967
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1968
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
const action = this.watchdogResnapshotted.has(outcomeId) ? "resubscribe" : "resnapshot";
|
|
1972
|
+
this.emitDiagnostic({
|
|
1973
|
+
type: "book_watchdog_resync",
|
|
1974
|
+
outcomeId,
|
|
1975
|
+
localSeq: (_b = book == null ? void 0 : book.seq) != null ? _b : null,
|
|
1976
|
+
serverSeq: server.seq,
|
|
1977
|
+
action
|
|
1978
|
+
});
|
|
1979
|
+
this.bookCheckedAt.set(outcomeId, Date.now());
|
|
1980
|
+
if (action === "resubscribe") {
|
|
1981
|
+
this.watchdogResnapshotted.delete(outcomeId);
|
|
1982
|
+
this.books.delete(outcomeId);
|
|
1983
|
+
this.resyncing.add(outcomeId);
|
|
1984
|
+
this.send({ action: "unsubscribe", channel: "orderbook", outcomeIds: [outcomeId] });
|
|
1985
|
+
this.sendSubscribe([outcomeId]);
|
|
1986
|
+
} else {
|
|
1987
|
+
this.watchdogResnapshotted.add(outcomeId);
|
|
1988
|
+
this.requestResnapshot(outcomeId, true);
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1991
|
+
} catch (e) {
|
|
1992
|
+
if (!this.destroyed) this.emitDiagnostic({ type: "book_watchdog_error", status: null });
|
|
1993
|
+
} finally {
|
|
1994
|
+
clearTimeout(timeout);
|
|
1995
|
+
if (this.watchdogAbort === abort) this.watchdogAbort = null;
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1873
1999
|
// ── Resnapshot ──
|
|
1874
2000
|
requestResnapshot(outcomeId, force = false) {
|
|
1875
2001
|
if (this.resyncing.has(outcomeId) && !force) return;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as Venue, U as UserProfile, T as TradeSplit, g as VenueMarket, h as VenueMarketOutcome, i as Orderbook, j as TradeSide, k as AggClientOptions, l as AggClientSessionInput, m as AuthStatus, S as SiweMessageParams, n as SiwsMessageParams, o as AggAuthVerifyBody, p as AggAuthStartBody, q as AggAuthStartResult, r as AggLinkAccountBody, s as AggLinkAccountResult, t as AggLinkAccountWalletConfirmBody, u as AggLinkAccountConfirmResult, v as UpdateUserBody, P as PaginatedResponse, w as UserHolding, x as OrderListQuery, y as TradeExecutorOrderListResponse, E as ExecutionOrdersQuery, z as ExecutionOrderItem, B as ExecutionStatusQuery, D as ExecutionStatusResponse, F as UserActivityQuery, G as UserActivityItem, L as LeaderboardQuery, H as LeaderboardRow, I as LeaderboardSeriesQuery, J as LeaderboardSeries, K as ExecutionPositionsQuery, N as ExecutionPositionGroup, Q as ManagedBalancesParams, R as UnifiedBalanceResponse, X as UpsertVenueKey, Y as VenueKeySummary, Z as VenueKeyStatus, _ as CreatePaperTradingAccountParams, $ as PaperTradingAppOptions, a0 as PaperTradingAccount, a1 as PaperTradingAccountListParams, a2 as PaperTradingAccountsPage, a3 as SetPaperTradingBalanceParams, a4 as PaperTradingBalanceResponse, a5 as ResetPaperTradingAccountParams, a6 as PlacePaperTradingOrderParams, a7 as PaperTradingOrder, a8 as PaperTradingListParams, a9 as PaperTradingPositionsPage, aa as PaperTradingOrdersPage, ab as PaperTradingPortfolio, ac as CancelOrderSignature, ad as CancelManagedExecutionResponse, ae as CancelVenueOrderParams, af as MatchStatus, ag as MarketStatus, ah as RecurrenceFilter, ai as VenueEvent, aj as EventBootstrapResponse, ak as SportsLiveResponse, al as ListRecurringCryptoMarketsOptions, am as RecurringCryptoMarketsResponse, an as GetCryptoReferencePricesOptions, ao as CryptoReferencePricesResponse, ap as Category, aq as AppClientConfigResponse, ar as VenueGeoPolicyResponse, as as RpcTokenResponse, at as NewsFeedListResponse, au as NewsFeedPageOptions, av as NewsFeedArticleFeedResponse, aw as NewsFeedMarketFeedResponse, ax as NewsFeedStatusResponse, ay as NewsFeedMarketNewsParams, az as NewsFeedMarketNewsResponse, aA as SearchParams, aB as SearchResponse, aC as CorrelatedMarketsStatus, aD as CorrelatedMarketSignalBatch, aE as CorrelatedMarketQueryResult, aF as CorrelatedMarketCascadeResponse, aG as ResolveCorrelatedMarketsParams, aH as ResolveCorrelatedMarketsResponse, aI as ChartResolution, C as ChartBarsResponse, b as ChartHistoryManifest, aJ as BatchOrderbooksResponse, aK as BatchMidpointsResponse, aL as OutcomeOrderbookResponse, aM as SmartRouteParams, aN as SmartRouteResponse, f as AggWebSocketCallbacks, A as AggWebSocket,
|
|
2
|
-
export {
|
|
1
|
+
import { V as Venue, U as UserProfile, T as TradeSplit, g as VenueMarket, h as VenueMarketOutcome, i as Orderbook, j as TradeSide, k as AggClientOptions, l as AggClientSessionInput, m as AuthStatus, S as SiweMessageParams, n as SiwsMessageParams, o as AggAuthVerifyBody, p as AggAuthStartBody, q as AggAuthStartResult, r as AggLinkAccountBody, s as AggLinkAccountResult, t as AggLinkAccountWalletConfirmBody, u as AggLinkAccountConfirmResult, v as UpdateUserBody, P as PaginatedResponse, w as UserHolding, x as OrderListQuery, y as TradeExecutorOrderListResponse, E as ExecutionOrdersQuery, z as ExecutionOrderItem, B as ExecutionStatusQuery, D as ExecutionStatusResponse, F as UserActivityQuery, G as UserActivityItem, L as LeaderboardQuery, H as LeaderboardRow, I as LeaderboardSeriesQuery, J as LeaderboardSeries, K as ExecutionPositionsQuery, N as ExecutionPositionGroup, Q as ManagedBalancesParams, R as UnifiedBalanceResponse, X as UpsertVenueKey, Y as VenueKeySummary, Z as VenueKeyStatus, _ as CreatePaperTradingAccountParams, $ as PaperTradingAppOptions, a0 as PaperTradingAccount, a1 as PaperTradingAccountListParams, a2 as PaperTradingAccountsPage, a3 as SetPaperTradingBalanceParams, a4 as PaperTradingBalanceResponse, a5 as ResetPaperTradingAccountParams, a6 as PlacePaperTradingOrderParams, a7 as PaperTradingOrder, a8 as PaperTradingListParams, a9 as PaperTradingPositionsPage, aa as PaperTradingOrdersPage, ab as PaperTradingPortfolio, ac as CancelOrderSignature, ad as CancelManagedExecutionResponse, ae as CancelVenueOrderParams, af as MatchStatus, ag as MarketStatus, ah as RecurrenceFilter, ai as VenueEvent, aj as EventBootstrapResponse, ak as SportsLiveResponse, al as ListRecurringCryptoMarketsOptions, am as RecurringCryptoMarketsResponse, an as GetCryptoReferencePricesOptions, ao as CryptoReferencePricesResponse, ap as Category, aq as AppClientConfigResponse, ar as VenueGeoPolicyResponse, as as RpcTokenResponse, at as NewsFeedListResponse, au as NewsFeedPageOptions, av as NewsFeedArticleFeedResponse, aw as NewsFeedMarketFeedResponse, ax as NewsFeedStatusResponse, ay as NewsFeedMarketNewsParams, az as NewsFeedMarketNewsResponse, aA as SearchParams, aB as SearchResponse, aC as CorrelatedMarketsStatus, aD as CorrelatedMarketSignalBatch, aE as CorrelatedMarketQueryResult, aF as CorrelatedMarketCascadeResponse, aG as ResolveCorrelatedMarketsParams, aH as ResolveCorrelatedMarketsResponse, aI as ChartResolution, C as ChartBarsResponse, b as ChartHistoryManifest, aJ as BatchOrderbooksResponse, aK as BatchMidpointsResponse, aL as OutcomeOrderbookResponse, aM as SmartRouteParams, aN as SmartRouteResponse, f as AggWebSocketCallbacks, aO as BookWatchdogOptions, A as AggWebSocket, aP as ExecuteManagedParams, aQ as ExecuteManagedResponse, aR as PlaceLimitOrderParams, aS as PlaceLimitOrderResponse, aT as PlaceOrderParams, aU as PlaceOrderResponse, aV as RedeemRequest, aW as RedeemResponse, aX as BalanceRefillPolicy, aY as CreateBalanceRefillPolicyParams, aZ as UpdateBalanceRefillPolicyParams, a_ as BalanceRefillAttempt, a$ as WithdrawManagedParams, b0 as WithdrawManagedResponse, b1 as WithdrawPreviewParams, b2 as WithdrawPreviewResponse, b3 as WithdrawalQuoteParams, b4 as WithdrawalQuoteResponse, b5 as SyncBalancesResponse, b6 as DepositAddressesResponse, b7 as GetPositionsParams, b8 as PositionGroup, b9 as RampQuoteRequest, ba as RampQuote, bb as RampSessionRequest, bc as RampWidgetSession, bd as Candle, c as ChartCandle } from './agg-websocket-x_U4-orL.mjs';
|
|
2
|
+
export { be as ACTIVE_VENUES, bf as Account, bg as AccountProvider, bh as AccountType, bi as AggAuthDeliveryMode, bj as AggAuthPrivyVerifyBody, bk as AggAuthProviderType, bl as AggAuthWalletVerifyBody, bm as AggClientAuthOptions, bn as AggSessionUser, d as AggWebSocketDiagnostics, a as AggWebSocketOptions, bo as AggregatedOrderbookLevel, bp as AggregatedOrderbookResponse, bq as App, br as AppTradingMode, bs as AttributedOrderbook, bt as AttributedOrderbookLevel, bu as AuthCodeResponse, bv as AuthTokenResponse, bw as AuthUser, bx as BalanceCustody, by as BalanceRefillAttemptStatus, bz as BalanceRefillPolicyStatus, bA as BookQuality, bB as CONFIRMED_MATCH_STATUSES, bC as CandleBuilder, bD as CandleInterval, bE as CandleTail, bF as Chain, bG as ChartBarsMeta, bH as ChartVenueCandles, bI as ComputeSplitsRequest, bJ as ComputeSplitsResponse, bK as ComputeSplitsSelection, bL as CorrelatedMarketCascadeItem, bM as CorrelatedMarketSide, bN as CorrelatedMarketSignal, bO as CorrelatedMarketSignalDirection, bP as CreateApp, bQ as CryptoReferencePriceError, bR as CryptoReferencePriceExternalMarketInput, bS as CryptoReferencePriceMarketInput, bT as CryptoReferencePriceResult, bU as CryptoReferencePriceSource, bV as CryptoReferencePriceTarget, bW as DepositAddressesPendingResponse, bX as DepositAddressesReadyResponse, bY as DepositAddressesSupportedChain, bZ as DepositAddressesToken, b_ as DepositStep, b$ as DiagnosticCallback, c0 as DiagnosticEvent, c1 as ExecuteManagedRequest, c2 as ExecuteTradeRequest, c3 as ExecuteTradeResponse, c4 as ExecutionDagProgress, c5 as ExecutionDisplayGroupStatus, c6 as ExecutionDisplayStepKind, c7 as ExecutionMode, c8 as ExecutionOverallState, c9 as ExecutionStatusOrder, ca as ExecutionStatusStep, cb as GetBalanceQuery, cc as GetBalanceResponse, cd as GetHoldingsQuery, ce as GetHoldingsResponse, cf as GetOrdersParams, cg as GetOrdersQuery, ch as GetPositionsQuery, ci as HelloResponse, cj as HistoryRangeRequest, ck as INACTIVE_VENUES, cl as LeaderboardMetric, cm as LeaderboardSeriesPoint, cn as LeaderboardStats, co as LimitOrderTimeInForce, cp as MarkSource, cq as MarketPriceHistory, cr as MarketView, cs as MarketViewBatch, ct as MatchType, cu as MatchedMidpoint, cv as MatchedMidpointOutcome, cw as MatchedOrderbookMarket, cx as MatchedVenueMarketOutcomeRef, cy as MidpointItem, cz as MidpointRow, cA as NewsFeedArticleFeedItem, cB as NewsFeedArticleWithSummary, cC as NewsFeedLinkedMarket, cD as NewsFeedMarketFeedArticle, cE as NewsFeedMarketFeedItem, cF as NewsFeedMarketNewsResult, cG as NonceResponse, cH as NovigExecutionMode, cI as OPTIONAL_SIGNATURE_TIMEOUT_MS, cJ as OrderListItem, cK as OrderStatus, cL as OrderType, cM as OrderbookBatchItemError, cN as OrderbookBatchItemErrorCode, cO as OrderbookBatchItemStatus, cP as OrderbookHistoryPoint, cQ as OrderbookHistoryResponse, cR as OrderbookLevel, cS as OrderbookQuoteFill, cT as OrderbookQuoteParams, cU as OrderbookQuoteResponse, cV as OrderbookServiceUnavailableError, O as OrderbookState, cW as OrderbooksOnlyError, cX as OutcomeMidpoint, cY as OutcomeMidpointRow, cZ as PaperTradingBalanceAdjustment, c_ as PaperTradingLiquidityStatus, c$ as PaperTradingMarkSource, d0 as PaperTradingPosition, d1 as PersistedAuthSnapshot, d2 as PositionRedeemStatus, d3 as PricePoint, d4 as PriceSource, d5 as PricesHistoryResponse, d6 as ProphetxExecutionMode, d7 as RECURRENCE_CADENCES, d8 as RecurrenceCadence, d9 as RecurringCryptoComparisonPoint, da as RecurringCryptoComparisonPriceSource, db as RecurringCryptoDuration, dc as RecurringCryptoDurationInput, dd as RecurringCryptoMarketMetrics, de as RecurringCryptoOrderbookDepthLevel, df as RecurringCryptoOrderbookDepthSide, dg as RecurringCryptoOutcome, dh as RecurringCryptoOutcomeOrderbookDepth, di as RecurringCryptoPriceComparison, dj as RecurringCryptoReferencePrice, dk as RecurringCryptoResolution, dl as RecurringCryptoSourceConfidence, dm as RecurringCryptoVenueMarket, dn as RecurringCryptoWindowComparisons, dp as RecurringCryptoWindowMarket, dq as RedeemLegResult, dr as RedeemLegStatus, ds as RequestedOrderbookMarket, dt as ResolvedCorrelatedMarketsResponse, du as SELF_CUSTODY_FILL_TIMEOUT_MS, dv as SELF_CUSTODY_POLL_INTERVAL_MS, dw as ServerWallet, dx as SettlementDiff, dy as SettlementDifference, dz as SettlementSource, dA as SetupDepositAddressStep, dB as SetupVenueKeyStep, dC as SignatureRequest, dD as SignatureRequestType, dE as SignerFn, dF as SimpleOrderbookLevel, dG as SmartRouteAllocation, dH as SmartRouteBridgeStep, dI as SmartRouteFeeBreakdown, dJ as SmartRouteFill, dK as SmartRouteSettlementLeg, dL as SmartRouteSettlementPlan, dM as SmartRouteSetupCostLine, dN as SmartRouteSide, dO as SmartRouteStatus, dP as SmartRouteVenueFill, dQ as SportsGameStatus, dR as SportsLiveParticipant, dS as SportsLiveState, dT as TERMINAL_EXECUTION_STATES, dU as TimeInForce, dV as TradeExecutorOrder, dW as TradeStep, dX as UserActivityBridge, dY as UserActivityDeposit, dZ as UserActivityRedeem, d_ as UserActivityRedeemLeg, d$ as UserActivityTrade, e0 as UserActivityType, e1 as UserActivityUserOp, e2 as UserActivityWithdrawal, e3 as VENUES, e4 as VENUE_CHAIN_IDS, e5 as ValidateBalanceOnClientStep, e6 as ValidateManagedParams, e7 as ValidateManagedRequest, e8 as ValidateManagedResponse, e9 as ValidateTradeRequest, ea as ValidateTradeResponse, eb as VenueEventListItem, ec as VenueEventWithMarkets, ed as VenueGeoPolicyEntry, ee as VenueMarketListItem, ef as VenueMarketRef, eg as VenueOrderbookEntry, eh as VenueOrderbookLevel, ei as VenuePositionBalance, ej as VenuePriceInfo, ek as VenueSoloQuote, el as VerifyBody, em as VerifyResponse, en as WalletChainBalance, eo as WalletTokenBalance, ep as WithdrawManagedRequest, eq as WithdrawManagedSourceItem, er as WithdrawTokenSymbol, es as WithdrawalExpected, et as WithdrawalLeg, eu as WithdrawalLegStatus, ev as WithdrawalLegType, ew as WithdrawalLifecycleStatus, ex as WithdrawalSource, ey as WithdrawalSourceItem, ez as WithdrawalSourceStatus, eA as WithdrawalSourceTokenSymbol, e as WsArbFeedBatch, eB as WsArbFeedEntry, W as WsArbMarketUpdate, eC as WsAttributedLevel, eD as WsAuthenticated, eE as WsBalanceUpdate, eF as WsCandleInterval, eG as WsClientMessage, eH as WsConnected, eI as WsError, eJ as WsHeartbeat, eK as WsMarkSource, eL as WsMarketResolved, eM as WsOrderEvent, eN as WsOrderEventType, eO as WsOrderSubmitted, eP as WsOrderbookDelta, eQ as WsOrderbookSnapshot, eR as WsRedeemEvent, eS as WsServerMessage, eT as WsSubscribed, eU as WsTrade, eV as WsUnsubscribed, eW as WsVenueBook, eX as WsVenueInfo, eY as WsVenueLevel, eZ as WsWithdrawalLegStatus, e_ as WsWithdrawalLifecycleEvent, e$ as WsWithdrawalLifecycleLeg, f0 as WsWithdrawalLifecycleStatus, f1 as applyOrderbookDelta, f2 as computeChecksum, f3 as getEffectiveDisabledVenues, f4 as isVenueActive, f5 as isVenueDataVisible, f6 as isVenueInactive, f7 as snapshotToOrderbook } from './agg-websocket-x_U4-orL.mjs';
|
|
3
3
|
|
|
4
4
|
declare enum ImageSize {
|
|
5
5
|
sm = 44,
|
|
@@ -774,8 +774,9 @@ declare class AggClient {
|
|
|
774
774
|
*/
|
|
775
775
|
getLeaderboard(params?: LeaderboardQuery): Promise<PaginatedResponse<LeaderboardRow>>;
|
|
776
776
|
/**
|
|
777
|
-
* One user's
|
|
778
|
-
* most 366) with a running cumulative
|
|
777
|
+
* One user's (or, with no user, the whole app's) leaderboard stats per UTC
|
|
778
|
+
* day (default the last 30 days, at most 366) with a running cumulative
|
|
779
|
+
* realized P&L, optionally for a single category. Gross of fees;
|
|
779
780
|
* unrealized P&L is not included.
|
|
780
781
|
*/
|
|
781
782
|
getLeaderboardSeries(params: LeaderboardSeriesQuery): Promise<LeaderboardSeries>;
|
|
@@ -1095,6 +1096,12 @@ declare class AggClient {
|
|
|
1095
1096
|
*/
|
|
1096
1097
|
createWebSocket(callbacks?: AggWebSocketCallbacks, options?: {
|
|
1097
1098
|
enableLogs?: boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* Checks books with no update for 5 minutes against
|
|
1101
|
+
* `GET /orderbooks/outcomes` and heals any that drifted. On by default;
|
|
1102
|
+
* pass `false` to disable or an object to tune the timings.
|
|
1103
|
+
*/
|
|
1104
|
+
bookWatchdog?: false | Pick<BookWatchdogOptions, "silenceMs" | "checkIntervalMs">;
|
|
1098
1105
|
}): AggWebSocket;
|
|
1099
1106
|
/** Execute a previously quoted managed trade. Returns pending order IDs. */
|
|
1100
1107
|
executeManaged(params: ExecuteManagedParams): Promise<ExecuteManagedResponse>;
|
|
@@ -1339,4 +1346,4 @@ declare function prepareHostedVenueRoute(client: FundingClient & Pick<AggClient,
|
|
|
1339
1346
|
|
|
1340
1347
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
1341
1348
|
|
|
1342
|
-
export { AggApiError, type AggApiErrorInit, type AggApiFieldError, AggAuthStartBody, AggAuthStartResult, AggAuthVerifyBody, AggClient, AggClientOptions, AggClientSessionInput, AggLinkAccountBody, AggLinkAccountConfirmResult, AggLinkAccountResult, AggLinkAccountWalletConfirmBody, type AggRateLimitResponse, AggWebSocket, AggWebSocketCallbacks, AppClientConfigResponse, AuthStatus, BalanceRefillAttempt, BalanceRefillPolicy, BatchMidpointsResponse, BatchOrderbooksResponse, type BuildVenueUrlOpts, CancelManagedExecutionResponse, CancelOrderSignature, CancelVenueOrderParams, Candle, Category, ChartBarsResponse, ChartCandle, ChartHistoryManifest, ChartResolution, CorrelatedMarketCascadeResponse, CorrelatedMarketQueryResult, CorrelatedMarketSignalBatch, CorrelatedMarketsStatus, CreateBalanceRefillPolicyParams, CreatePaperTradingAccountParams, CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, DepositAddressesResponse, EventBootstrapResponse, ExecuteManagedParams, ExecuteManagedResponse, ExecutionOrderItem, ExecutionOrdersQuery, ExecutionPositionGroup, ExecutionPositionsQuery, ExecutionStatusQuery, ExecutionStatusResponse, GetCryptoReferencePricesOptions, GetPositionsParams, type HostedVenueAccount, type HostedVenueActivity, type HostedVenueActivityCode, type HostedVenueActivityQuery, type HostedVenueBalance, type HostedVenueDepositAddress, type HostedVenueFundingIntent, type HostedVenueFundingOptions, type HostedVenueWithdrawal, type HostedVenueWithdrawalRequest, IMAGE_SIZES, ImageSize, LIMIT_PRICE_RAW_SCALE, LeaderboardQuery, LeaderboardRow, LeaderboardSeries, LeaderboardSeriesQuery, type LimitPriceSide, type LimitPriceTickAdjustment, ListRecurringCryptoMarketsOptions, type LoadImmutableHistoryOptions, ManagedBalancesParams, MarketStatus, MatchStatus, NewsFeedArticleFeedResponse, NewsFeedListResponse, NewsFeedMarketFeedResponse, NewsFeedMarketNewsParams, NewsFeedMarketNewsResponse, NewsFeedPageOptions, NewsFeedStatusResponse, OrderListQuery, Orderbook, OutcomeOrderbookResponse, PaginatedResponse, PaperTradingAccount, PaperTradingAccountsPage, PaperTradingAppOptions, PaperTradingBalanceResponse, PaperTradingListParams, PaperTradingOrder, PaperTradingOrdersPage, PaperTradingPortfolio, PaperTradingPositionsPage, PlaceLimitOrderParams, PlaceLimitOrderResponse, PlacePaperTradingOrderParams, PositionGroup, type ProvisionHostedVenueAccountBody, type QuoteError, type QuoteErrorCode, RETINA_IMAGE_SIZES, RampQuote, RampQuoteRequest, RampSessionRequest, RampWidgetSession, RecurrenceFilter, RecurringCryptoMarketsResponse, RedeemRequest, RedeemResponse, ResetPaperTradingAccountParams, ResolveCorrelatedMarketsParams, ResolveCorrelatedMarketsResponse, RpcTokenResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, SearchParams, SearchResponse, SetPaperTradingBalanceParams, SmartRouteParams, SmartRouteResponse, type SplitsByAmountResult, SportsLiveResponse, SyncBalancesResponse, TradeExecutorOrderListResponse, TradeSide, TradeSplit, TurnstileChallengeError, UnifiedBalanceResponse, UpdateBalanceRefillPolicyParams, UpdateUserBody, UpsertVenueKey, UserActivityItem, UserActivityQuery, UserHolding, UserProfile, Venue, VenueEvent, VenueGeoPolicyResponse, VenueKeyStatus, VenueKeySummary, VenueMarket, type VenueMarketClusterNode, VenueMarketOutcome, WithdrawManagedParams, WithdrawManagedResponse, WithdrawPreviewParams, WithdrawPreviewResponse, WithdrawalQuoteParams, WithdrawalQuoteResponse, adjustLimitPriceRawToTick, aggregateMidpoint, buildVenueUrl, computeBestSplitsByAmount, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, loadImmutableHistory, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, orderbookCrc32, parse, parseEmail, parseEmailStrict, prepareHostedVenueFunding, prepareHostedVenueRoute, projectedOrderbookChecksum, retinaImageUrl, safeParse, sortVenues, toChecksumAddress };
|
|
1349
|
+
export { AggApiError, type AggApiErrorInit, type AggApiFieldError, AggAuthStartBody, AggAuthStartResult, AggAuthVerifyBody, AggClient, AggClientOptions, AggClientSessionInput, AggLinkAccountBody, AggLinkAccountConfirmResult, AggLinkAccountResult, AggLinkAccountWalletConfirmBody, type AggRateLimitResponse, AggWebSocket, AggWebSocketCallbacks, AppClientConfigResponse, AuthStatus, BalanceRefillAttempt, BalanceRefillPolicy, BatchMidpointsResponse, BatchOrderbooksResponse, BookWatchdogOptions, type BuildVenueUrlOpts, CancelManagedExecutionResponse, CancelOrderSignature, CancelVenueOrderParams, Candle, Category, ChartBarsResponse, ChartCandle, ChartHistoryManifest, ChartResolution, CorrelatedMarketCascadeResponse, CorrelatedMarketQueryResult, CorrelatedMarketSignalBatch, CorrelatedMarketsStatus, CreateBalanceRefillPolicyParams, CreatePaperTradingAccountParams, CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, DepositAddressesResponse, EventBootstrapResponse, ExecuteManagedParams, ExecuteManagedResponse, ExecutionOrderItem, ExecutionOrdersQuery, ExecutionPositionGroup, ExecutionPositionsQuery, ExecutionStatusQuery, ExecutionStatusResponse, GetCryptoReferencePricesOptions, GetPositionsParams, type HostedVenueAccount, type HostedVenueActivity, type HostedVenueActivityCode, type HostedVenueActivityQuery, type HostedVenueBalance, type HostedVenueDepositAddress, type HostedVenueFundingIntent, type HostedVenueFundingOptions, type HostedVenueWithdrawal, type HostedVenueWithdrawalRequest, IMAGE_SIZES, ImageSize, LIMIT_PRICE_RAW_SCALE, LeaderboardQuery, LeaderboardRow, LeaderboardSeries, LeaderboardSeriesQuery, type LimitPriceSide, type LimitPriceTickAdjustment, ListRecurringCryptoMarketsOptions, type LoadImmutableHistoryOptions, ManagedBalancesParams, MarketStatus, MatchStatus, NewsFeedArticleFeedResponse, NewsFeedListResponse, NewsFeedMarketFeedResponse, NewsFeedMarketNewsParams, NewsFeedMarketNewsResponse, NewsFeedPageOptions, NewsFeedStatusResponse, OrderListQuery, Orderbook, OutcomeOrderbookResponse, PaginatedResponse, PaperTradingAccount, PaperTradingAccountsPage, PaperTradingAppOptions, PaperTradingBalanceResponse, PaperTradingListParams, PaperTradingOrder, PaperTradingOrdersPage, PaperTradingPortfolio, PaperTradingPositionsPage, PlaceLimitOrderParams, PlaceLimitOrderResponse, PlacePaperTradingOrderParams, PositionGroup, type ProvisionHostedVenueAccountBody, type QuoteError, type QuoteErrorCode, RETINA_IMAGE_SIZES, RampQuote, RampQuoteRequest, RampSessionRequest, RampWidgetSession, RecurrenceFilter, RecurringCryptoMarketsResponse, RedeemRequest, RedeemResponse, ResetPaperTradingAccountParams, ResolveCorrelatedMarketsParams, ResolveCorrelatedMarketsResponse, RpcTokenResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, SearchParams, SearchResponse, SetPaperTradingBalanceParams, SmartRouteParams, SmartRouteResponse, type SplitsByAmountResult, SportsLiveResponse, SyncBalancesResponse, TradeExecutorOrderListResponse, TradeSide, TradeSplit, TurnstileChallengeError, UnifiedBalanceResponse, UpdateBalanceRefillPolicyParams, UpdateUserBody, UpsertVenueKey, UserActivityItem, UserActivityQuery, UserHolding, UserProfile, Venue, VenueEvent, VenueGeoPolicyResponse, VenueKeyStatus, VenueKeySummary, VenueMarket, type VenueMarketClusterNode, VenueMarketOutcome, WithdrawManagedParams, WithdrawManagedResponse, WithdrawPreviewParams, WithdrawPreviewResponse, WithdrawalQuoteParams, WithdrawalQuoteResponse, adjustLimitPriceRawToTick, aggregateMidpoint, buildVenueUrl, computeBestSplitsByAmount, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, loadImmutableHistory, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, orderbookCrc32, parse, parseEmail, parseEmailStrict, prepareHostedVenueFunding, prepareHostedVenueRoute, projectedOrderbookChecksum, retinaImageUrl, safeParse, sortVenues, toChecksumAddress };
|