@agg-build/sdk 4.1.0 → 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.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.1.0",
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",