@agg-build/sdk 4.0.1 → 4.3.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
@@ -78,9 +78,12 @@ __export(index_exports, {
78
78
  CONFIRMED_MATCH_STATUSES: () => CONFIRMED_MATCH_STATUSES,
79
79
  CandleBuilder: () => CandleBuilder,
80
80
  Chain: () => Chain,
81
+ DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW: () => DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW,
82
+ DEFAULT_BALANCE_REFILL_MAX_FEE_RAW: () => DEFAULT_BALANCE_REFILL_MAX_FEE_RAW,
81
83
  IMAGE_SIZES: () => IMAGE_SIZES,
82
84
  INACTIVE_VENUES: () => INACTIVE_VENUES,
83
85
  ImageSize: () => ImageSize,
86
+ LIMIT_PRICE_RAW_SCALE: () => LIMIT_PRICE_RAW_SCALE,
84
87
  MarketStatus: () => MarketStatus,
85
88
  MatchStatus: () => MatchStatus,
86
89
  MatchType: () => MatchType,
@@ -91,7 +94,9 @@ __export(index_exports, {
91
94
  TradeSide: () => TradeSide,
92
95
  TurnstileChallengeError: () => TurnstileChallengeError,
93
96
  VENUES: () => VENUES,
97
+ VENUE_CHAIN_IDS: () => VENUE_CHAIN_IDS,
94
98
  Venue: () => Venue,
99
+ adjustLimitPriceRawToTick: () => adjustLimitPriceRawToTick,
95
100
  aggregateMidpoint: () => aggregateMidpoint,
96
101
  applyOrderbookDelta: () => applyOrderbookDelta,
97
102
  buildVenueUrl: () => buildVenueUrl,
@@ -102,10 +107,12 @@ __export(index_exports, {
102
107
  formatMarketQuestion: () => formatMarketQuestion,
103
108
  formatOutcomeLabel: () => formatOutcomeLabel,
104
109
  formatOutcomeTitle: () => formatOutcomeTitle,
110
+ getBalanceRefillMaximumRaw: () => getBalanceRefillMaximumRaw,
105
111
  getEffectiveDisabledVenues: () => getEffectiveDisabledVenues,
106
112
  getWalletAddressFromUserProfile: () => getWalletAddressFromUserProfile,
107
113
  hasShape: () => hasShape,
108
114
  isAggApiError: () => isAggApiError,
115
+ isBalanceRefillWithinDailyCap: () => isBalanceRefillWithinDailyCap,
109
116
  isEmail: () => isEmail,
110
117
  isEnum: () => isEnum,
111
118
  isFiniteNonNeg: () => isFiniteNonNeg,
@@ -136,6 +143,7 @@ var Venue = /* @__PURE__ */ ((Venue3) => {
136
143
  Venue3["probable"] = "probable";
137
144
  Venue3["myriad"] = "myriad";
138
145
  Venue3["hyperliquid"] = "hyperliquid";
146
+ Venue3["novig"] = "novig";
139
147
  return Venue3;
140
148
  })(Venue || {});
141
149
  var VENUES = [
@@ -146,9 +154,19 @@ var VENUES = [
146
154
  "predict" /* predict */,
147
155
  "probable" /* probable */,
148
156
  "myriad" /* myriad */,
149
- "hyperliquid" /* hyperliquid */
157
+ "hyperliquid" /* hyperliquid */,
158
+ "novig" /* novig */
150
159
  ];
160
+ var VENUE_CHAIN_IDS = {
161
+ ["kalshi" /* kalshi */]: 792703809,
162
+ ["polymarket" /* polymarket */]: 137,
163
+ ["limitless" /* limitless */]: 8453,
164
+ ["predict" /* predict */]: 56,
165
+ ["myriad" /* myriad */]: 56,
166
+ ["hyperliquid" /* hyperliquid */]: 1337
167
+ };
151
168
  var ACTIVE_VENUES = [
169
+ "kalshi" /* kalshi */,
152
170
  "polymarket" /* polymarket */,
153
171
  "limitless" /* limitless */,
154
172
  "opinion" /* opinion */,
@@ -157,7 +175,8 @@ var ACTIVE_VENUES = [
157
175
  "myriad" /* myriad */,
158
176
  "hyperliquid" /* hyperliquid */
159
177
  ];
160
- var INACTIVE_VENUES = ["kalshi" /* kalshi */];
178
+ var INACTIVE_VENUES = ["novig" /* novig */];
179
+ var DEFAULT_DISABLED_VENUES = ["novig" /* novig */];
161
180
  var ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
162
181
  var INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
163
182
  function normalizeVenue(venue) {
@@ -178,11 +197,13 @@ function isVenueDataVisible(venue, dataVisibleOverride = []) {
178
197
  const n = normalizeVenue(venue);
179
198
  return dataVisibleOverride.some((v) => normalizeVenue(v) === n);
180
199
  }
181
- function getEffectiveDisabledVenues(disabledVenues = [], dataVisibleVenues = []) {
182
- if (disabledVenues.length === 0 && dataVisibleVenues.length === 0) return [...INACTIVE_VENUES];
200
+ function getEffectiveDisabledVenues(disabledVenues, dataVisibleVenues = []) {
201
+ if (disabledVenues === void 0) {
202
+ const disabled2 = new Set(DEFAULT_DISABLED_VENUES);
203
+ for (const venue of dataVisibleVenues) disabled2.delete(normalizeVenue(venue));
204
+ return VENUES.filter((venue) => disabled2.has(venue));
205
+ }
183
206
  const disabled = new Set(disabledVenues.map(normalizeVenue));
184
- for (const venue of INACTIVE_VENUES) disabled.add(venue);
185
- for (const venue of dataVisibleVenues) disabled.delete(normalizeVenue(venue));
186
207
  return VENUES.filter((venue) => disabled.has(venue));
187
208
  }
188
209
 
@@ -705,11 +726,75 @@ function buildVenueUrl(venue, opts) {
705
726
  if (opts.eventSlug) return `https://probable.markets/event/${opts.eventSlug}`;
706
727
  return null;
707
728
  }
729
+ case "novig": {
730
+ if (opts.outcomeExternalId && opts.partnerId) {
731
+ return opts.platform === "native" ? `novigapp://events/${opts.outcomeExternalId}/${opts.partnerId}` : `https://novig.com/events/${opts.outcomeExternalId}/${opts.partnerId}`;
732
+ }
733
+ return null;
734
+ }
708
735
  default:
709
736
  return null;
710
737
  }
711
738
  }
712
739
 
740
+ // ../common/src/utils/limit-price-ticks.ts
741
+ var LIMIT_PRICE_RAW_SCALE = BigInt(1e6);
742
+ var resolveTickSizeRaw = (tickSize) => {
743
+ const scaledTick = tickSize * Number(LIMIT_PRICE_RAW_SCALE);
744
+ const roundedTick = Math.round(scaledTick);
745
+ if (!Number.isFinite(scaledTick) || roundedTick <= 0 || Math.abs(scaledTick - roundedTick) > 1e-6) {
746
+ throw new RangeError(`Unsupported limit-order tick size: ${tickSize}`);
747
+ }
748
+ return BigInt(roundedTick);
749
+ };
750
+ var adjustLimitPriceRawToTick = ({
751
+ limitPriceRaw,
752
+ side,
753
+ tickSize
754
+ }) => {
755
+ const originalPrice = BigInt(limitPriceRaw);
756
+ const originalPriceRaw = originalPrice.toString();
757
+ if (tickSize == null) {
758
+ return {
759
+ adjusted: false,
760
+ adjustedPriceRaw: originalPriceRaw,
761
+ originalPriceRaw,
762
+ tickSizeRaw: null
763
+ };
764
+ }
765
+ const tickSizeRaw = resolveTickSizeRaw(tickSize);
766
+ const remainder = originalPrice % tickSizeRaw;
767
+ if (remainder === BigInt(0)) {
768
+ return {
769
+ adjusted: false,
770
+ adjustedPriceRaw: originalPriceRaw,
771
+ originalPriceRaw,
772
+ tickSizeRaw: tickSizeRaw.toString()
773
+ };
774
+ }
775
+ const adjustedPrice = side === "buy" ? originalPrice - remainder : originalPrice + (tickSizeRaw - remainder);
776
+ return {
777
+ adjusted: true,
778
+ adjustedPriceRaw: adjustedPrice.toString(),
779
+ originalPriceRaw,
780
+ tickSizeRaw: tickSizeRaw.toString()
781
+ };
782
+ };
783
+
784
+ // ../common/src/utils/balance-refill.ts
785
+ var DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW = "1002000000";
786
+ var DEFAULT_BALANCE_REFILL_MAX_FEE_RAW = "2000000";
787
+ var getBalanceRefillMaximumRaw = (dailyCapRaw, maxFeeRaw) => {
788
+ const dailyCap = BigInt(dailyCapRaw);
789
+ const maximumFee = BigInt(maxFeeRaw);
790
+ if (dailyCap <= maximumFee) return "0";
791
+ return (dailyCap - maximumFee).toString();
792
+ };
793
+ var isBalanceRefillWithinDailyCap = (minimumRaw, refillAmountRaw, dailyCapRaw, maxFeeRaw) => {
794
+ const maximum = BigInt(getBalanceRefillMaximumRaw(dailyCapRaw, maxFeeRaw));
795
+ return BigInt(minimumRaw) <= maximum && BigInt(refillAmountRaw) <= maximum;
796
+ };
797
+
713
798
  // src/errors.ts
714
799
  var TurnstileChallengeError = class extends Error {
715
800
  constructor(siteKey) {
@@ -1662,6 +1747,7 @@ var AggWebSocket = class {
1662
1747
  var COOKIE_REFRESH_DELIVERY = "cookie-refresh";
1663
1748
  var DEFAULT_MIDPOINT_IDS_PER_REQUEST = 75;
1664
1749
  var MAX_MIDPOINT_IDS_PER_REQUEST = 75;
1750
+ var MAX_SPORTS_EVENT_IDS_PER_REQUEST = 25;
1665
1751
  var isUserProfile = (user) => {
1666
1752
  return "accounts" in user && "wallets" in user && "avatarUrl" in user;
1667
1753
  };
@@ -2375,7 +2461,9 @@ Issued At: ${issuedAt}`;
2375
2461
  const query = {};
2376
2462
  if (params.orderId) query.orderId = params.orderId;
2377
2463
  if (params.quoteId) query.quoteId = params.quoteId;
2464
+ if (params.externalId) query.externalId = params.externalId;
2378
2465
  if (params.status) query.status = params.status;
2466
+ if (params.orderType) query.orderType = params.orderType;
2379
2467
  if (params.mode) query.mode = params.mode;
2380
2468
  if (params.cursor) query.cursor = params.cursor;
2381
2469
  if (params.limit != null) query.limit = String(params.limit);
@@ -2576,6 +2664,7 @@ Issued At: ${issuedAt}`;
2576
2664
  if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
2577
2665
  if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
2578
2666
  if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
2667
+ if (options == null ? void 0 : options.aggKey) query.aggKey = options.aggKey;
2579
2668
  if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
2580
2669
  if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
2581
2670
  if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
@@ -2584,7 +2673,8 @@ Issued At: ${issuedAt}`;
2584
2673
  if (options == null ? void 0 : options.endDateFrom) query.endDateFrom = options.endDateFrom;
2585
2674
  if (options == null ? void 0 : options.grouped) query.grouped = "true";
2586
2675
  return this.request("/venue-events", {
2587
- query: Object.keys(query).length > 0 ? query : void 0
2676
+ query: Object.keys(query).length > 0 ? query : void 0,
2677
+ signal: options == null ? void 0 : options.signal
2588
2678
  });
2589
2679
  });
2590
2680
  }
@@ -2600,6 +2690,27 @@ Issued At: ${issuedAt}`;
2600
2690
  });
2601
2691
  });
2602
2692
  }
2693
+ /** Get normalized live score state for sports events. Requires appId or admin auth. */
2694
+ getSportsLive(eventIds, options) {
2695
+ return __async(this, null, function* () {
2696
+ const normalizedEventIds = normalizeRequestedVenueMarketIds(eventIds);
2697
+ if (normalizedEventIds.length === 0) {
2698
+ return { data: [], missingEventIds: [] };
2699
+ }
2700
+ const responses = yield Promise.all(
2701
+ chunkArray(normalizedEventIds, MAX_SPORTS_EVENT_IDS_PER_REQUEST).map(
2702
+ (eventIdChunk) => this.request("/sports/live", {
2703
+ query: { eventIds: eventIdChunk },
2704
+ signal: options == null ? void 0 : options.signal
2705
+ })
2706
+ )
2707
+ );
2708
+ return {
2709
+ data: responses.flatMap((response) => response.data),
2710
+ missingEventIds: [...new Set(responses.flatMap((response) => response.missingEventIds))]
2711
+ };
2712
+ });
2713
+ }
2603
2714
  /** List deterministic recurring crypto window markets across venues. Requires appId or admin auth. */
2604
2715
  listRecurringCryptoMarkets(options) {
2605
2716
  return __async(this, null, function* () {
@@ -3040,6 +3151,20 @@ Issued At: ${issuedAt}`;
3040
3151
  });
3041
3152
  });
3042
3153
  }
3154
+ /**
3155
+ * Place a market order directly on a named venue — no prior quote needed.
3156
+ * Always produces exactly one order. `externalId` is required and unique
3157
+ * within your app — two different users of the same app cannot share one —
3158
+ * so retrying a timed-out call with the same value is safe.
3159
+ */
3160
+ placeOrder(params) {
3161
+ return __async(this, null, function* () {
3162
+ return this.request("/execution/orders", {
3163
+ method: "POST",
3164
+ body: JSON.stringify(params)
3165
+ });
3166
+ });
3167
+ }
3043
3168
  /** Redeem resolved winning positions by venue market outcome ids. */
3044
3169
  redeem(body) {
3045
3170
  return __async(this, null, function* () {
@@ -3416,9 +3541,12 @@ function createAggClient(options) {
3416
3541
  CONFIRMED_MATCH_STATUSES,
3417
3542
  CandleBuilder,
3418
3543
  Chain,
3544
+ DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW,
3545
+ DEFAULT_BALANCE_REFILL_MAX_FEE_RAW,
3419
3546
  IMAGE_SIZES,
3420
3547
  INACTIVE_VENUES,
3421
3548
  ImageSize,
3549
+ LIMIT_PRICE_RAW_SCALE,
3422
3550
  MarketStatus,
3423
3551
  MatchStatus,
3424
3552
  MatchType,
@@ -3429,7 +3557,9 @@ function createAggClient(options) {
3429
3557
  TradeSide,
3430
3558
  TurnstileChallengeError,
3431
3559
  VENUES,
3560
+ VENUE_CHAIN_IDS,
3432
3561
  Venue,
3562
+ adjustLimitPriceRawToTick,
3433
3563
  aggregateMidpoint,
3434
3564
  applyOrderbookDelta,
3435
3565
  buildVenueUrl,
@@ -3440,10 +3570,12 @@ function createAggClient(options) {
3440
3570
  formatMarketQuestion,
3441
3571
  formatOutcomeLabel,
3442
3572
  formatOutcomeTitle,
3573
+ getBalanceRefillMaximumRaw,
3443
3574
  getEffectiveDisabledVenues,
3444
3575
  getWalletAddressFromUserProfile,
3445
3576
  hasShape,
3446
3577
  isAggApiError,
3578
+ isBalanceRefillWithinDailyCap,
3447
3579
  isEmail,
3448
3580
  isEnum,
3449
3581
  isFiniteNonNeg,
package/dist/index.mjs CHANGED
@@ -15,6 +15,7 @@ var Venue = /* @__PURE__ */ ((Venue3) => {
15
15
  Venue3["probable"] = "probable";
16
16
  Venue3["myriad"] = "myriad";
17
17
  Venue3["hyperliquid"] = "hyperliquid";
18
+ Venue3["novig"] = "novig";
18
19
  return Venue3;
19
20
  })(Venue || {});
20
21
  var VENUES = [
@@ -25,9 +26,19 @@ var VENUES = [
25
26
  "predict" /* predict */,
26
27
  "probable" /* probable */,
27
28
  "myriad" /* myriad */,
28
- "hyperliquid" /* hyperliquid */
29
+ "hyperliquid" /* hyperliquid */,
30
+ "novig" /* novig */
29
31
  ];
32
+ var VENUE_CHAIN_IDS = {
33
+ ["kalshi" /* kalshi */]: 792703809,
34
+ ["polymarket" /* polymarket */]: 137,
35
+ ["limitless" /* limitless */]: 8453,
36
+ ["predict" /* predict */]: 56,
37
+ ["myriad" /* myriad */]: 56,
38
+ ["hyperliquid" /* hyperliquid */]: 1337
39
+ };
30
40
  var ACTIVE_VENUES = [
41
+ "kalshi" /* kalshi */,
31
42
  "polymarket" /* polymarket */,
32
43
  "limitless" /* limitless */,
33
44
  "opinion" /* opinion */,
@@ -36,7 +47,8 @@ var ACTIVE_VENUES = [
36
47
  "myriad" /* myriad */,
37
48
  "hyperliquid" /* hyperliquid */
38
49
  ];
39
- var INACTIVE_VENUES = ["kalshi" /* kalshi */];
50
+ var INACTIVE_VENUES = ["novig" /* novig */];
51
+ var DEFAULT_DISABLED_VENUES = ["novig" /* novig */];
40
52
  var ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
41
53
  var INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
42
54
  function normalizeVenue(venue) {
@@ -57,11 +69,13 @@ function isVenueDataVisible(venue, dataVisibleOverride = []) {
57
69
  const n = normalizeVenue(venue);
58
70
  return dataVisibleOverride.some((v) => normalizeVenue(v) === n);
59
71
  }
60
- function getEffectiveDisabledVenues(disabledVenues = [], dataVisibleVenues = []) {
61
- if (disabledVenues.length === 0 && dataVisibleVenues.length === 0) return [...INACTIVE_VENUES];
72
+ function getEffectiveDisabledVenues(disabledVenues, dataVisibleVenues = []) {
73
+ if (disabledVenues === void 0) {
74
+ const disabled2 = new Set(DEFAULT_DISABLED_VENUES);
75
+ for (const venue of dataVisibleVenues) disabled2.delete(normalizeVenue(venue));
76
+ return VENUES.filter((venue) => disabled2.has(venue));
77
+ }
62
78
  const disabled = new Set(disabledVenues.map(normalizeVenue));
63
- for (const venue of INACTIVE_VENUES) disabled.add(venue);
64
- for (const venue of dataVisibleVenues) disabled.delete(normalizeVenue(venue));
65
79
  return VENUES.filter((venue) => disabled.has(venue));
66
80
  }
67
81
 
@@ -584,11 +598,75 @@ function buildVenueUrl(venue, opts) {
584
598
  if (opts.eventSlug) return `https://probable.markets/event/${opts.eventSlug}`;
585
599
  return null;
586
600
  }
601
+ case "novig": {
602
+ if (opts.outcomeExternalId && opts.partnerId) {
603
+ return opts.platform === "native" ? `novigapp://events/${opts.outcomeExternalId}/${opts.partnerId}` : `https://novig.com/events/${opts.outcomeExternalId}/${opts.partnerId}`;
604
+ }
605
+ return null;
606
+ }
587
607
  default:
588
608
  return null;
589
609
  }
590
610
  }
591
611
 
612
+ // ../common/src/utils/limit-price-ticks.ts
613
+ var LIMIT_PRICE_RAW_SCALE = BigInt(1e6);
614
+ var resolveTickSizeRaw = (tickSize) => {
615
+ const scaledTick = tickSize * Number(LIMIT_PRICE_RAW_SCALE);
616
+ const roundedTick = Math.round(scaledTick);
617
+ if (!Number.isFinite(scaledTick) || roundedTick <= 0 || Math.abs(scaledTick - roundedTick) > 1e-6) {
618
+ throw new RangeError(`Unsupported limit-order tick size: ${tickSize}`);
619
+ }
620
+ return BigInt(roundedTick);
621
+ };
622
+ var adjustLimitPriceRawToTick = ({
623
+ limitPriceRaw,
624
+ side,
625
+ tickSize
626
+ }) => {
627
+ const originalPrice = BigInt(limitPriceRaw);
628
+ const originalPriceRaw = originalPrice.toString();
629
+ if (tickSize == null) {
630
+ return {
631
+ adjusted: false,
632
+ adjustedPriceRaw: originalPriceRaw,
633
+ originalPriceRaw,
634
+ tickSizeRaw: null
635
+ };
636
+ }
637
+ const tickSizeRaw = resolveTickSizeRaw(tickSize);
638
+ const remainder = originalPrice % tickSizeRaw;
639
+ if (remainder === BigInt(0)) {
640
+ return {
641
+ adjusted: false,
642
+ adjustedPriceRaw: originalPriceRaw,
643
+ originalPriceRaw,
644
+ tickSizeRaw: tickSizeRaw.toString()
645
+ };
646
+ }
647
+ const adjustedPrice = side === "buy" ? originalPrice - remainder : originalPrice + (tickSizeRaw - remainder);
648
+ return {
649
+ adjusted: true,
650
+ adjustedPriceRaw: adjustedPrice.toString(),
651
+ originalPriceRaw,
652
+ tickSizeRaw: tickSizeRaw.toString()
653
+ };
654
+ };
655
+
656
+ // ../common/src/utils/balance-refill.ts
657
+ var DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW = "1002000000";
658
+ var DEFAULT_BALANCE_REFILL_MAX_FEE_RAW = "2000000";
659
+ var getBalanceRefillMaximumRaw = (dailyCapRaw, maxFeeRaw) => {
660
+ const dailyCap = BigInt(dailyCapRaw);
661
+ const maximumFee = BigInt(maxFeeRaw);
662
+ if (dailyCap <= maximumFee) return "0";
663
+ return (dailyCap - maximumFee).toString();
664
+ };
665
+ var isBalanceRefillWithinDailyCap = (minimumRaw, refillAmountRaw, dailyCapRaw, maxFeeRaw) => {
666
+ const maximum = BigInt(getBalanceRefillMaximumRaw(dailyCapRaw, maxFeeRaw));
667
+ return BigInt(minimumRaw) <= maximum && BigInt(refillAmountRaw) <= maximum;
668
+ };
669
+
592
670
  // src/errors.ts
593
671
  var TurnstileChallengeError = class extends Error {
594
672
  constructor(siteKey) {
@@ -1541,6 +1619,7 @@ var AggWebSocket = class {
1541
1619
  var COOKIE_REFRESH_DELIVERY = "cookie-refresh";
1542
1620
  var DEFAULT_MIDPOINT_IDS_PER_REQUEST = 75;
1543
1621
  var MAX_MIDPOINT_IDS_PER_REQUEST = 75;
1622
+ var MAX_SPORTS_EVENT_IDS_PER_REQUEST = 25;
1544
1623
  var isUserProfile = (user) => {
1545
1624
  return "accounts" in user && "wallets" in user && "avatarUrl" in user;
1546
1625
  };
@@ -2254,7 +2333,9 @@ Issued At: ${issuedAt}`;
2254
2333
  const query = {};
2255
2334
  if (params.orderId) query.orderId = params.orderId;
2256
2335
  if (params.quoteId) query.quoteId = params.quoteId;
2336
+ if (params.externalId) query.externalId = params.externalId;
2257
2337
  if (params.status) query.status = params.status;
2338
+ if (params.orderType) query.orderType = params.orderType;
2258
2339
  if (params.mode) query.mode = params.mode;
2259
2340
  if (params.cursor) query.cursor = params.cursor;
2260
2341
  if (params.limit != null) query.limit = String(params.limit);
@@ -2455,6 +2536,7 @@ Issued At: ${issuedAt}`;
2455
2536
  if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
2456
2537
  if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
2457
2538
  if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
2539
+ if (options == null ? void 0 : options.aggKey) query.aggKey = options.aggKey;
2458
2540
  if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
2459
2541
  if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
2460
2542
  if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
@@ -2463,7 +2545,8 @@ Issued At: ${issuedAt}`;
2463
2545
  if (options == null ? void 0 : options.endDateFrom) query.endDateFrom = options.endDateFrom;
2464
2546
  if (options == null ? void 0 : options.grouped) query.grouped = "true";
2465
2547
  return this.request("/venue-events", {
2466
- query: Object.keys(query).length > 0 ? query : void 0
2548
+ query: Object.keys(query).length > 0 ? query : void 0,
2549
+ signal: options == null ? void 0 : options.signal
2467
2550
  });
2468
2551
  });
2469
2552
  }
@@ -2479,6 +2562,27 @@ Issued At: ${issuedAt}`;
2479
2562
  });
2480
2563
  });
2481
2564
  }
2565
+ /** Get normalized live score state for sports events. Requires appId or admin auth. */
2566
+ getSportsLive(eventIds, options) {
2567
+ return __async(this, null, function* () {
2568
+ const normalizedEventIds = normalizeRequestedVenueMarketIds(eventIds);
2569
+ if (normalizedEventIds.length === 0) {
2570
+ return { data: [], missingEventIds: [] };
2571
+ }
2572
+ const responses = yield Promise.all(
2573
+ chunkArray(normalizedEventIds, MAX_SPORTS_EVENT_IDS_PER_REQUEST).map(
2574
+ (eventIdChunk) => this.request("/sports/live", {
2575
+ query: { eventIds: eventIdChunk },
2576
+ signal: options == null ? void 0 : options.signal
2577
+ })
2578
+ )
2579
+ );
2580
+ return {
2581
+ data: responses.flatMap((response) => response.data),
2582
+ missingEventIds: [...new Set(responses.flatMap((response) => response.missingEventIds))]
2583
+ };
2584
+ });
2585
+ }
2482
2586
  /** List deterministic recurring crypto window markets across venues. Requires appId or admin auth. */
2483
2587
  listRecurringCryptoMarkets(options) {
2484
2588
  return __async(this, null, function* () {
@@ -2919,6 +3023,20 @@ Issued At: ${issuedAt}`;
2919
3023
  });
2920
3024
  });
2921
3025
  }
3026
+ /**
3027
+ * Place a market order directly on a named venue — no prior quote needed.
3028
+ * Always produces exactly one order. `externalId` is required and unique
3029
+ * within your app — two different users of the same app cannot share one —
3030
+ * so retrying a timed-out call with the same value is safe.
3031
+ */
3032
+ placeOrder(params) {
3033
+ return __async(this, null, function* () {
3034
+ return this.request("/execution/orders", {
3035
+ method: "POST",
3036
+ body: JSON.stringify(params)
3037
+ });
3038
+ });
3039
+ }
2922
3040
  /** Redeem resolved winning positions by venue market outcome ids. */
2923
3041
  redeem(body) {
2924
3042
  return __async(this, null, function* () {
@@ -3294,9 +3412,12 @@ export {
3294
3412
  CONFIRMED_MATCH_STATUSES,
3295
3413
  CandleBuilder,
3296
3414
  Chain,
3415
+ DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW,
3416
+ DEFAULT_BALANCE_REFILL_MAX_FEE_RAW,
3297
3417
  IMAGE_SIZES,
3298
3418
  INACTIVE_VENUES,
3299
3419
  ImageSize,
3420
+ LIMIT_PRICE_RAW_SCALE,
3300
3421
  MarketStatus,
3301
3422
  MatchStatus,
3302
3423
  MatchType,
@@ -3307,7 +3428,9 @@ export {
3307
3428
  TradeSide,
3308
3429
  TurnstileChallengeError,
3309
3430
  VENUES,
3431
+ VENUE_CHAIN_IDS,
3310
3432
  Venue,
3433
+ adjustLimitPriceRawToTick,
3311
3434
  aggregateMidpoint,
3312
3435
  applyOrderbookDelta,
3313
3436
  buildVenueUrl,
@@ -3318,10 +3441,12 @@ export {
3318
3441
  formatMarketQuestion,
3319
3442
  formatOutcomeLabel,
3320
3443
  formatOutcomeTitle,
3444
+ getBalanceRefillMaximumRaw,
3321
3445
  getEffectiveDisabledVenues,
3322
3446
  getWalletAddressFromUserProfile,
3323
3447
  hasShape,
3324
3448
  isAggApiError,
3449
+ isBalanceRefillWithinDailyCap,
3325
3450
  isEmail,
3326
3451
  isEnum,
3327
3452
  isFiniteNonNeg,
package/dist/server.d.mts CHANGED
@@ -59,6 +59,8 @@ interface TradesPlacedEvent extends WebhookEventBase {
59
59
  userId: string;
60
60
  side: string;
61
61
  timestamp: string;
62
+ /** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
63
+ externalId: string | null;
62
64
  /**
63
65
  * @deprecated Never emitted by the server in 1.x — the SDK type lied
64
66
  * here for several releases. Reads always return `undefined`. The field
@@ -77,6 +79,8 @@ interface TradesFilledEvent extends WebhookEventBase {
77
79
  userId: string;
78
80
  status: string;
79
81
  timestamp: string;
82
+ /** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
83
+ externalId: string | null;
80
84
  /**
81
85
  * Post-execution accuracy data. All `*Raw` values are decimal strings in
82
86
  * 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
package/dist/server.d.ts CHANGED
@@ -59,6 +59,8 @@ interface TradesPlacedEvent extends WebhookEventBase {
59
59
  userId: string;
60
60
  side: string;
61
61
  timestamp: string;
62
+ /** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
63
+ externalId: string | null;
62
64
  /**
63
65
  * @deprecated Never emitted by the server in 1.x — the SDK type lied
64
66
  * here for several releases. Reads always return `undefined`. The field
@@ -77,6 +79,8 @@ interface TradesFilledEvent extends WebhookEventBase {
77
79
  userId: string;
78
80
  status: string;
79
81
  timestamp: string;
82
+ /** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
83
+ externalId: string | null;
80
84
  /**
81
85
  * Post-execution accuracy data. All `*Raw` values are decimal strings in
82
86
  * 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/sdk",
3
- "version": "4.0.1",
3
+ "version": "4.3.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",