@agg-build/sdk 2.0.0 → 2.1.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/index.js CHANGED
@@ -20,6 +20,18 @@ var __spreadValues = (a, b) => {
20
20
  return a;
21
21
  };
22
22
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
23
35
  var __export = (target, all) => {
24
36
  for (var name in all)
25
37
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -1580,6 +1592,8 @@ var AggWebSocket = class {
1580
1592
 
1581
1593
  // src/client.ts
1582
1594
  var COOKIE_REFRESH_DELIVERY = "cookie-refresh";
1595
+ var DEFAULT_MIDPOINT_IDS_PER_REQUEST = 75;
1596
+ var MAX_MIDPOINT_IDS_PER_REQUEST = 200;
1583
1597
  var isUserProfile = (user) => {
1584
1598
  return "accounts" in user && "wallets" in user && "avatarUrl" in user;
1585
1599
  };
@@ -1613,6 +1627,17 @@ var normalizeSessionUser = (user, currentUser) => {
1613
1627
  walletAddress: null
1614
1628
  });
1615
1629
  };
1630
+ var resolveMidpointIdsPerRequest = (value) => {
1631
+ if (value == null || !Number.isFinite(value)) return DEFAULT_MIDPOINT_IDS_PER_REQUEST;
1632
+ return Math.min(MAX_MIDPOINT_IDS_PER_REQUEST, Math.max(1, Math.floor(value)));
1633
+ };
1634
+ var chunkArray = (items, size) => {
1635
+ const chunks = [];
1636
+ for (let index = 0; index < items.length; index += size) {
1637
+ chunks.push(items.slice(index, index + size));
1638
+ }
1639
+ return chunks;
1640
+ };
1616
1641
  var mapChartResolution = (resolution) => {
1617
1642
  switch (resolution) {
1618
1643
  case void 0:
@@ -1657,6 +1682,27 @@ var AggClient = class {
1657
1682
  this.restoreSession();
1658
1683
  this.initAuthChannel();
1659
1684
  }
1685
+ resolvePaperTradingAppId(appId) {
1686
+ const resolvedAppId = appId != null ? appId : this.appId;
1687
+ if (!resolvedAppId) {
1688
+ throw new Error(
1689
+ "Paper trading account methods require appId in client options or method options"
1690
+ );
1691
+ }
1692
+ return encodeURIComponent(resolvedAppId);
1693
+ }
1694
+ paperTradingAccountsPath(appId) {
1695
+ return `/apps/${this.resolvePaperTradingAppId(appId)}/paper-trading/accounts`;
1696
+ }
1697
+ paperTradingAccountPath(accountId, appId) {
1698
+ return `${this.paperTradingAccountsPath(appId)}/${encodeURIComponent(accountId)}`;
1699
+ }
1700
+ paperTradingListQuery(params = {}) {
1701
+ const query = {};
1702
+ if (params.limit != null) query.limit = String(params.limit);
1703
+ if (params.cursor) query.cursor = params.cursor;
1704
+ return Object.keys(query).length ? query : void 0;
1705
+ }
1660
1706
  withAuthPayload(payload) {
1661
1707
  var _a, _b, _c;
1662
1708
  if (typeof payload.earlyAccessCode === "string" && payload.earlyAccessCode.trim().length > 0) {
@@ -2286,6 +2332,100 @@ Issued At: ${issuedAt}`;
2286
2332
  });
2287
2333
  });
2288
2334
  }
2335
+ /** Create a server-managed paper trading account for an app. Requires adminKey or apiKey. */
2336
+ createPaperTradingAccount(params, options) {
2337
+ return __async(this, null, function* () {
2338
+ return this.request(this.paperTradingAccountsPath(options == null ? void 0 : options.appId), {
2339
+ method: "POST",
2340
+ body: JSON.stringify(params)
2341
+ });
2342
+ });
2343
+ }
2344
+ /** List server-managed paper trading accounts for an app. Requires adminKey or apiKey. */
2345
+ listPaperTradingAccounts() {
2346
+ return __async(this, arguments, function* (params = {}) {
2347
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2348
+ return this.request(this.paperTradingAccountsPath(appId), {
2349
+ query: this.paperTradingListQuery(listParams)
2350
+ });
2351
+ });
2352
+ }
2353
+ /** Fetch a server-managed paper trading account. Requires adminKey or apiKey. */
2354
+ getPaperTradingAccount(accountId, options) {
2355
+ return __async(this, null, function* () {
2356
+ return this.request(
2357
+ this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)
2358
+ );
2359
+ });
2360
+ }
2361
+ /** Set a paper trading account cash balance. Requires adminKey or apiKey. */
2362
+ setPaperTradingBalance(accountId, params, options) {
2363
+ return __async(this, null, function* () {
2364
+ return this.request(
2365
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/balance`,
2366
+ {
2367
+ method: "PATCH",
2368
+ body: JSON.stringify(params)
2369
+ }
2370
+ );
2371
+ });
2372
+ }
2373
+ /** Clear positions and reset cash for a paper trading account. Requires adminKey or apiKey. */
2374
+ resetPaperTradingAccount(_0) {
2375
+ return __async(this, arguments, function* (accountId, params = {}, options) {
2376
+ return this.request(
2377
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/reset`,
2378
+ {
2379
+ method: "POST",
2380
+ body: JSON.stringify(params)
2381
+ }
2382
+ );
2383
+ });
2384
+ }
2385
+ /** Place a direct simulated order in a paper trading account. Requires adminKey or apiKey. */
2386
+ placePaperTradingOrder(accountId, params, options) {
2387
+ return __async(this, null, function* () {
2388
+ return this.request(
2389
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/orders`,
2390
+ {
2391
+ method: "POST",
2392
+ body: JSON.stringify(params)
2393
+ }
2394
+ );
2395
+ });
2396
+ }
2397
+ /** List positions for a server-managed paper trading account. Requires adminKey or apiKey. */
2398
+ listPaperTradingPositions(_0) {
2399
+ return __async(this, arguments, function* (accountId, params = {}) {
2400
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2401
+ return this.request(
2402
+ `${this.paperTradingAccountPath(accountId, appId)}/positions`,
2403
+ {
2404
+ query: this.paperTradingListQuery(listParams)
2405
+ }
2406
+ );
2407
+ });
2408
+ }
2409
+ /** List orders for a server-managed paper trading account. Requires adminKey or apiKey. */
2410
+ listPaperTradingOrders(_0) {
2411
+ return __async(this, arguments, function* (accountId, params = {}) {
2412
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2413
+ return this.request(
2414
+ `${this.paperTradingAccountPath(accountId, appId)}/orders`,
2415
+ {
2416
+ query: this.paperTradingListQuery(listParams)
2417
+ }
2418
+ );
2419
+ });
2420
+ }
2421
+ /** Fetch account-level paper trading equity, P&L, and marked positions. Requires adminKey or apiKey. */
2422
+ getPaperTradingPortfolio(accountId, options) {
2423
+ return __async(this, null, function* () {
2424
+ return this.request(
2425
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/portfolio`
2426
+ );
2427
+ });
2428
+ }
2289
2429
  /** Cancel a pending managed execution by order id. */
2290
2430
  cancelManagedOrder(orderId, options) {
2291
2431
  return __async(this, null, function* () {
@@ -2458,6 +2598,61 @@ Issued At: ${issuedAt}`;
2458
2598
  return this.request("/app/config", init);
2459
2599
  });
2460
2600
  }
2601
+ buildNewsFeedQuery(options) {
2602
+ const query = {};
2603
+ if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
2604
+ if (options == null ? void 0 : options.since) query.since = options.since;
2605
+ if (options == null ? void 0 : options.before) query.before = options.before;
2606
+ if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
2607
+ return Object.keys(query).length > 0 ? query : void 0;
2608
+ }
2609
+ /** List available market news feeds and item counts. */
2610
+ getNewsFeeds(options) {
2611
+ return __async(this, null, function* () {
2612
+ return this.request("/news-feed", {
2613
+ signal: options == null ? void 0 : options.signal
2614
+ });
2615
+ });
2616
+ }
2617
+ /** Get the article-centric market news feed for a category. */
2618
+ getNewsFeed(category, options) {
2619
+ return __async(this, null, function* () {
2620
+ return this.request(`/news-feed/${encodeURIComponent(category)}`, {
2621
+ query: this.buildNewsFeedQuery(options),
2622
+ signal: options == null ? void 0 : options.signal
2623
+ });
2624
+ });
2625
+ }
2626
+ /** Get the market-centric market news feed for a category. */
2627
+ getNewsFeedMarkets(category, options) {
2628
+ return __async(this, null, function* () {
2629
+ return this.request(
2630
+ `/news-feed/${encodeURIComponent(category)}/markets`,
2631
+ {
2632
+ query: this.buildNewsFeedQuery(options),
2633
+ signal: options == null ? void 0 : options.signal
2634
+ }
2635
+ );
2636
+ });
2637
+ }
2638
+ /** Get news feed coverage and per-category counts. */
2639
+ getNewsFeedStatus(options) {
2640
+ return __async(this, null, function* () {
2641
+ return this.request("/news-feed/status", {
2642
+ signal: options == null ? void 0 : options.signal
2643
+ });
2644
+ });
2645
+ }
2646
+ /** Search recent news for specific markets and return market impact summaries. */
2647
+ getMarketNews(params, options) {
2648
+ return __async(this, null, function* () {
2649
+ return this.request("/news-feed/market-news", {
2650
+ method: "POST",
2651
+ body: JSON.stringify(params),
2652
+ signal: options == null ? void 0 : options.signal
2653
+ });
2654
+ });
2655
+ }
2461
2656
  /**
2462
2657
  * Search events or markets by query string. Supports cursor-based pagination.
2463
2658
  *
@@ -2569,14 +2764,27 @@ Issued At: ${issuedAt}`;
2569
2764
  }
2570
2765
  getMidpoints(paramsOrVenueMarketIds, options) {
2571
2766
  return __async(this, null, function* () {
2767
+ var _a;
2572
2768
  const venueMarketIds = Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds : paramsOrVenueMarketIds.venueMarketIds;
2573
2769
  const bestPrice = !Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds.bestPrice : options == null ? void 0 : options.bestPrice;
2574
- const query = { venueMarketIds };
2575
- if (bestPrice) query.bestPrice = "true";
2576
- return this.request("/midpoints", {
2577
- query,
2578
- signal: options == null ? void 0 : options.signal
2579
- });
2770
+ const maxMidpointIdsPerRequest = resolveMidpointIdsPerRequest(
2771
+ (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : Array.isArray(paramsOrVenueMarketIds) ? void 0 : paramsOrVenueMarketIds.maxMidpointIdsPerRequest
2772
+ );
2773
+ const requestBatch = (batchVenueMarketIds) => {
2774
+ const query = { venueMarketIds: batchVenueMarketIds };
2775
+ if (bestPrice) query.bestPrice = "true";
2776
+ return this.request("/midpoints", {
2777
+ query,
2778
+ signal: options == null ? void 0 : options.signal
2779
+ });
2780
+ };
2781
+ if (venueMarketIds.length <= maxMidpointIdsPerRequest) {
2782
+ return requestBatch(venueMarketIds);
2783
+ }
2784
+ const responses = yield Promise.all(
2785
+ chunkArray(venueMarketIds, maxMidpointIdsPerRequest).map((batch) => requestBatch(batch))
2786
+ );
2787
+ return { data: responses.flatMap((response) => response.data) };
2580
2788
  });
2581
2789
  }
2582
2790
  /** Get a single outcome-level orderbook from the engine. */
@@ -2680,6 +2888,19 @@ Issued At: ${issuedAt}`;
2680
2888
  });
2681
2889
  });
2682
2890
  }
2891
+ /**
2892
+ * Preview a withdrawal — real fee + receive estimate without creating one.
2893
+ * Optional: `withdrawManaged` does NOT require a prior preview, so partners
2894
+ * integrating against the SDK can ignore this entirely.
2895
+ */
2896
+ withdrawPreview(params) {
2897
+ return __async(this, null, function* () {
2898
+ return this.request("/execution/withdraw/preview", {
2899
+ method: "POST",
2900
+ body: JSON.stringify(params)
2901
+ });
2902
+ });
2903
+ }
2683
2904
  /**
2684
2905
  * Read the current persisted state of a withdrawal. Used as a backfill for
2685
2906
  * the WS lifecycle channel: the client polls this on hook mount and on WS
@@ -2712,6 +2933,19 @@ Issued At: ${issuedAt}`;
2712
2933
  return this.request("/execution/deposit-addresses");
2713
2934
  });
2714
2935
  }
2936
+ /**
2937
+ * Internal: record that a deposit tx was initiated via the in-app
2938
+ * connected-wallet flow, so the activity feed can label it correctly.
2939
+ * Best-effort — callers should not block the UX on this.
2940
+ */
2941
+ recordDepositIntent(body) {
2942
+ return __async(this, null, function* () {
2943
+ yield this.request(
2944
+ "/execution/deposit-intent",
2945
+ this.buildAuthRequestInit({ method: "POST", body: JSON.stringify(body) })
2946
+ );
2947
+ });
2948
+ }
2715
2949
  /** Get open positions grouped by matched market with per-venue breakdown. */
2716
2950
  getPositions(params) {
2717
2951
  return __async(this, null, function* () {
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  __async,
3
+ __objRest,
3
4
  __spreadProps,
4
5
  __spreadValues
5
- } from "./chunk-AXBFBHS2.mjs";
6
+ } from "./chunk-WNQUEZJF.mjs";
6
7
 
7
8
  // ../common/src/enums/venue.ts
8
9
  var Venue = /* @__PURE__ */ ((Venue3) => {
@@ -1478,6 +1479,8 @@ var AggWebSocket = class {
1478
1479
 
1479
1480
  // src/client.ts
1480
1481
  var COOKIE_REFRESH_DELIVERY = "cookie-refresh";
1482
+ var DEFAULT_MIDPOINT_IDS_PER_REQUEST = 75;
1483
+ var MAX_MIDPOINT_IDS_PER_REQUEST = 200;
1481
1484
  var isUserProfile = (user) => {
1482
1485
  return "accounts" in user && "wallets" in user && "avatarUrl" in user;
1483
1486
  };
@@ -1511,6 +1514,17 @@ var normalizeSessionUser = (user, currentUser) => {
1511
1514
  walletAddress: null
1512
1515
  });
1513
1516
  };
1517
+ var resolveMidpointIdsPerRequest = (value) => {
1518
+ if (value == null || !Number.isFinite(value)) return DEFAULT_MIDPOINT_IDS_PER_REQUEST;
1519
+ return Math.min(MAX_MIDPOINT_IDS_PER_REQUEST, Math.max(1, Math.floor(value)));
1520
+ };
1521
+ var chunkArray = (items, size) => {
1522
+ const chunks = [];
1523
+ for (let index = 0; index < items.length; index += size) {
1524
+ chunks.push(items.slice(index, index + size));
1525
+ }
1526
+ return chunks;
1527
+ };
1514
1528
  var mapChartResolution = (resolution) => {
1515
1529
  switch (resolution) {
1516
1530
  case void 0:
@@ -1555,6 +1569,27 @@ var AggClient = class {
1555
1569
  this.restoreSession();
1556
1570
  this.initAuthChannel();
1557
1571
  }
1572
+ resolvePaperTradingAppId(appId) {
1573
+ const resolvedAppId = appId != null ? appId : this.appId;
1574
+ if (!resolvedAppId) {
1575
+ throw new Error(
1576
+ "Paper trading account methods require appId in client options or method options"
1577
+ );
1578
+ }
1579
+ return encodeURIComponent(resolvedAppId);
1580
+ }
1581
+ paperTradingAccountsPath(appId) {
1582
+ return `/apps/${this.resolvePaperTradingAppId(appId)}/paper-trading/accounts`;
1583
+ }
1584
+ paperTradingAccountPath(accountId, appId) {
1585
+ return `${this.paperTradingAccountsPath(appId)}/${encodeURIComponent(accountId)}`;
1586
+ }
1587
+ paperTradingListQuery(params = {}) {
1588
+ const query = {};
1589
+ if (params.limit != null) query.limit = String(params.limit);
1590
+ if (params.cursor) query.cursor = params.cursor;
1591
+ return Object.keys(query).length ? query : void 0;
1592
+ }
1558
1593
  withAuthPayload(payload) {
1559
1594
  var _a, _b, _c;
1560
1595
  if (typeof payload.earlyAccessCode === "string" && payload.earlyAccessCode.trim().length > 0) {
@@ -2184,6 +2219,100 @@ Issued At: ${issuedAt}`;
2184
2219
  });
2185
2220
  });
2186
2221
  }
2222
+ /** Create a server-managed paper trading account for an app. Requires adminKey or apiKey. */
2223
+ createPaperTradingAccount(params, options) {
2224
+ return __async(this, null, function* () {
2225
+ return this.request(this.paperTradingAccountsPath(options == null ? void 0 : options.appId), {
2226
+ method: "POST",
2227
+ body: JSON.stringify(params)
2228
+ });
2229
+ });
2230
+ }
2231
+ /** List server-managed paper trading accounts for an app. Requires adminKey or apiKey. */
2232
+ listPaperTradingAccounts() {
2233
+ return __async(this, arguments, function* (params = {}) {
2234
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2235
+ return this.request(this.paperTradingAccountsPath(appId), {
2236
+ query: this.paperTradingListQuery(listParams)
2237
+ });
2238
+ });
2239
+ }
2240
+ /** Fetch a server-managed paper trading account. Requires adminKey or apiKey. */
2241
+ getPaperTradingAccount(accountId, options) {
2242
+ return __async(this, null, function* () {
2243
+ return this.request(
2244
+ this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)
2245
+ );
2246
+ });
2247
+ }
2248
+ /** Set a paper trading account cash balance. Requires adminKey or apiKey. */
2249
+ setPaperTradingBalance(accountId, params, options) {
2250
+ return __async(this, null, function* () {
2251
+ return this.request(
2252
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/balance`,
2253
+ {
2254
+ method: "PATCH",
2255
+ body: JSON.stringify(params)
2256
+ }
2257
+ );
2258
+ });
2259
+ }
2260
+ /** Clear positions and reset cash for a paper trading account. Requires adminKey or apiKey. */
2261
+ resetPaperTradingAccount(_0) {
2262
+ return __async(this, arguments, function* (accountId, params = {}, options) {
2263
+ return this.request(
2264
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/reset`,
2265
+ {
2266
+ method: "POST",
2267
+ body: JSON.stringify(params)
2268
+ }
2269
+ );
2270
+ });
2271
+ }
2272
+ /** Place a direct simulated order in a paper trading account. Requires adminKey or apiKey. */
2273
+ placePaperTradingOrder(accountId, params, options) {
2274
+ return __async(this, null, function* () {
2275
+ return this.request(
2276
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/orders`,
2277
+ {
2278
+ method: "POST",
2279
+ body: JSON.stringify(params)
2280
+ }
2281
+ );
2282
+ });
2283
+ }
2284
+ /** List positions for a server-managed paper trading account. Requires adminKey or apiKey. */
2285
+ listPaperTradingPositions(_0) {
2286
+ return __async(this, arguments, function* (accountId, params = {}) {
2287
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2288
+ return this.request(
2289
+ `${this.paperTradingAccountPath(accountId, appId)}/positions`,
2290
+ {
2291
+ query: this.paperTradingListQuery(listParams)
2292
+ }
2293
+ );
2294
+ });
2295
+ }
2296
+ /** List orders for a server-managed paper trading account. Requires adminKey or apiKey. */
2297
+ listPaperTradingOrders(_0) {
2298
+ return __async(this, arguments, function* (accountId, params = {}) {
2299
+ const _a = params, { appId } = _a, listParams = __objRest(_a, ["appId"]);
2300
+ return this.request(
2301
+ `${this.paperTradingAccountPath(accountId, appId)}/orders`,
2302
+ {
2303
+ query: this.paperTradingListQuery(listParams)
2304
+ }
2305
+ );
2306
+ });
2307
+ }
2308
+ /** Fetch account-level paper trading equity, P&L, and marked positions. Requires adminKey or apiKey. */
2309
+ getPaperTradingPortfolio(accountId, options) {
2310
+ return __async(this, null, function* () {
2311
+ return this.request(
2312
+ `${this.paperTradingAccountPath(accountId, options == null ? void 0 : options.appId)}/portfolio`
2313
+ );
2314
+ });
2315
+ }
2187
2316
  /** Cancel a pending managed execution by order id. */
2188
2317
  cancelManagedOrder(orderId, options) {
2189
2318
  return __async(this, null, function* () {
@@ -2356,6 +2485,61 @@ Issued At: ${issuedAt}`;
2356
2485
  return this.request("/app/config", init);
2357
2486
  });
2358
2487
  }
2488
+ buildNewsFeedQuery(options) {
2489
+ const query = {};
2490
+ if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
2491
+ if (options == null ? void 0 : options.since) query.since = options.since;
2492
+ if (options == null ? void 0 : options.before) query.before = options.before;
2493
+ if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
2494
+ return Object.keys(query).length > 0 ? query : void 0;
2495
+ }
2496
+ /** List available market news feeds and item counts. */
2497
+ getNewsFeeds(options) {
2498
+ return __async(this, null, function* () {
2499
+ return this.request("/news-feed", {
2500
+ signal: options == null ? void 0 : options.signal
2501
+ });
2502
+ });
2503
+ }
2504
+ /** Get the article-centric market news feed for a category. */
2505
+ getNewsFeed(category, options) {
2506
+ return __async(this, null, function* () {
2507
+ return this.request(`/news-feed/${encodeURIComponent(category)}`, {
2508
+ query: this.buildNewsFeedQuery(options),
2509
+ signal: options == null ? void 0 : options.signal
2510
+ });
2511
+ });
2512
+ }
2513
+ /** Get the market-centric market news feed for a category. */
2514
+ getNewsFeedMarkets(category, options) {
2515
+ return __async(this, null, function* () {
2516
+ return this.request(
2517
+ `/news-feed/${encodeURIComponent(category)}/markets`,
2518
+ {
2519
+ query: this.buildNewsFeedQuery(options),
2520
+ signal: options == null ? void 0 : options.signal
2521
+ }
2522
+ );
2523
+ });
2524
+ }
2525
+ /** Get news feed coverage and per-category counts. */
2526
+ getNewsFeedStatus(options) {
2527
+ return __async(this, null, function* () {
2528
+ return this.request("/news-feed/status", {
2529
+ signal: options == null ? void 0 : options.signal
2530
+ });
2531
+ });
2532
+ }
2533
+ /** Search recent news for specific markets and return market impact summaries. */
2534
+ getMarketNews(params, options) {
2535
+ return __async(this, null, function* () {
2536
+ return this.request("/news-feed/market-news", {
2537
+ method: "POST",
2538
+ body: JSON.stringify(params),
2539
+ signal: options == null ? void 0 : options.signal
2540
+ });
2541
+ });
2542
+ }
2359
2543
  /**
2360
2544
  * Search events or markets by query string. Supports cursor-based pagination.
2361
2545
  *
@@ -2467,14 +2651,27 @@ Issued At: ${issuedAt}`;
2467
2651
  }
2468
2652
  getMidpoints(paramsOrVenueMarketIds, options) {
2469
2653
  return __async(this, null, function* () {
2654
+ var _a;
2470
2655
  const venueMarketIds = Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds : paramsOrVenueMarketIds.venueMarketIds;
2471
2656
  const bestPrice = !Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds.bestPrice : options == null ? void 0 : options.bestPrice;
2472
- const query = { venueMarketIds };
2473
- if (bestPrice) query.bestPrice = "true";
2474
- return this.request("/midpoints", {
2475
- query,
2476
- signal: options == null ? void 0 : options.signal
2477
- });
2657
+ const maxMidpointIdsPerRequest = resolveMidpointIdsPerRequest(
2658
+ (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : Array.isArray(paramsOrVenueMarketIds) ? void 0 : paramsOrVenueMarketIds.maxMidpointIdsPerRequest
2659
+ );
2660
+ const requestBatch = (batchVenueMarketIds) => {
2661
+ const query = { venueMarketIds: batchVenueMarketIds };
2662
+ if (bestPrice) query.bestPrice = "true";
2663
+ return this.request("/midpoints", {
2664
+ query,
2665
+ signal: options == null ? void 0 : options.signal
2666
+ });
2667
+ };
2668
+ if (venueMarketIds.length <= maxMidpointIdsPerRequest) {
2669
+ return requestBatch(venueMarketIds);
2670
+ }
2671
+ const responses = yield Promise.all(
2672
+ chunkArray(venueMarketIds, maxMidpointIdsPerRequest).map((batch) => requestBatch(batch))
2673
+ );
2674
+ return { data: responses.flatMap((response) => response.data) };
2478
2675
  });
2479
2676
  }
2480
2677
  /** Get a single outcome-level orderbook from the engine. */
@@ -2578,6 +2775,19 @@ Issued At: ${issuedAt}`;
2578
2775
  });
2579
2776
  });
2580
2777
  }
2778
+ /**
2779
+ * Preview a withdrawal — real fee + receive estimate without creating one.
2780
+ * Optional: `withdrawManaged` does NOT require a prior preview, so partners
2781
+ * integrating against the SDK can ignore this entirely.
2782
+ */
2783
+ withdrawPreview(params) {
2784
+ return __async(this, null, function* () {
2785
+ return this.request("/execution/withdraw/preview", {
2786
+ method: "POST",
2787
+ body: JSON.stringify(params)
2788
+ });
2789
+ });
2790
+ }
2581
2791
  /**
2582
2792
  * Read the current persisted state of a withdrawal. Used as a backfill for
2583
2793
  * the WS lifecycle channel: the client polls this on hook mount and on WS
@@ -2610,6 +2820,19 @@ Issued At: ${issuedAt}`;
2610
2820
  return this.request("/execution/deposit-addresses");
2611
2821
  });
2612
2822
  }
2823
+ /**
2824
+ * Internal: record that a deposit tx was initiated via the in-app
2825
+ * connected-wallet flow, so the activity feed can label it correctly.
2826
+ * Best-effort — callers should not block the UX on this.
2827
+ */
2828
+ recordDepositIntent(body) {
2829
+ return __async(this, null, function* () {
2830
+ yield this.request(
2831
+ "/execution/deposit-intent",
2832
+ this.buildAuthRequestInit({ method: "POST", body: JSON.stringify(body) })
2833
+ );
2834
+ });
2835
+ }
2613
2836
  /** Get open positions grouped by matched market with per-venue breakdown. */
2614
2837
  getPositions(params) {
2615
2838
  return __async(this, null, function* () {
package/dist/server.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __async,
3
3
  __spreadProps,
4
4
  __spreadValues
5
- } from "./chunk-AXBFBHS2.mjs";
5
+ } from "./chunk-WNQUEZJF.mjs";
6
6
 
7
7
  // src/server.ts
8
8
  import { createHmac, timingSafeEqual } from "crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Vanilla TypeScript client for the AGG prediction market aggregator (auth, markets, orderbooks, charts, trading, managed execution, WebSockets). Works in browsers, Node.js, and React Native.",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",