@agg-build/hooks 2.4.4 → 2.5.1

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
@@ -84,8 +84,8 @@ __export(src_exports, {
84
84
  MarketStatus: () => MarketStatus,
85
85
  MatchStatus: () => MatchStatus,
86
86
  MatchType: () => MatchType,
87
- QueryClient: () => import_react_query39.QueryClient,
88
- QueryClientProvider: () => import_react_query39.QueryClientProvider,
87
+ QueryClient: () => import_react_query41.QueryClient,
88
+ QueryClientProvider: () => import_react_query41.QueryClientProvider,
89
89
  RedeemRejectedError: () => RedeemRejectedError,
90
90
  TradeSide: () => TradeSide,
91
91
  TurnstileChallengeError: () => import_sdk4.TurnstileChallengeError,
@@ -142,6 +142,7 @@ __export(src_exports, {
142
142
  useAppConfig: () => useAppConfig,
143
143
  useArbFeed: () => useArbFeed,
144
144
  useCachedAppConfig: () => useCachedAppConfig,
145
+ useCancelManagedOrder: () => useCancelManagedOrder,
145
146
  useCategories: () => useCategories,
146
147
  useCategoryChildren: () => useCategoryChildren,
147
148
  useDebouncedValue: () => useDebouncedValue,
@@ -181,8 +182,9 @@ __export(src_exports, {
181
182
  useOrderBook: () => useOrderBook,
182
183
  useOrderbookQuote: () => useOrderbookQuote,
183
184
  useOrders: () => useOrders,
185
+ usePlaceLimitOrder: () => usePlaceLimitOrder,
184
186
  usePositions: () => usePositions,
185
- useQueryClient: () => import_react_query39.useQueryClient,
187
+ useQueryClient: () => import_react_query41.useQueryClient,
186
188
  useQuoteManaged: () => useQuoteManaged,
187
189
  useRampQuotes: () => useRampQuotes,
188
190
  useRampSession: () => useRampSession,
@@ -225,6 +227,18 @@ var Venue = /* @__PURE__ */ ((Venue2) => {
225
227
  Venue2["hyperliquid"] = "hyperliquid";
226
228
  return Venue2;
227
229
  })(Venue || {});
230
+ var ACTIVE_VENUES = [
231
+ "polymarket" /* polymarket */,
232
+ "limitless" /* limitless */,
233
+ "opinion" /* opinion */,
234
+ "predict" /* predict */,
235
+ "probable" /* probable */,
236
+ "myriad" /* myriad */,
237
+ "hyperliquid" /* hyperliquid */
238
+ ];
239
+ var INACTIVE_VENUES = ["kalshi" /* kalshi */];
240
+ var ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
241
+ var INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
228
242
 
229
243
  // ../common/src/enums/market-status.ts
230
244
  var MatchStatus = /* @__PURE__ */ ((MatchStatus2) => {
@@ -335,7 +349,7 @@ var getVenueOrder = (venue) => {
335
349
  var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
336
350
 
337
351
  // src/index.ts
338
- var import_react_query39 = require("@tanstack/react-query");
352
+ var import_react_query41 = require("@tanstack/react-query");
339
353
 
340
354
  // src/candle-store.ts
341
355
  var import_sdk = require("@agg-build/sdk");
@@ -437,11 +451,17 @@ var parseAuthCallbackCode = (callbackUrl) => {
437
451
  const resolvedUrl = resolveAuthCallbackUrl(callbackUrl);
438
452
  return (_a = resolvedUrl == null ? void 0 : resolvedUrl.searchParams.get("code")) != null ? _a : null;
439
453
  };
454
+ var parseLinkConfirmToken = (callbackUrl) => {
455
+ var _a;
456
+ const resolvedUrl = resolveAuthCallbackUrl(callbackUrl);
457
+ return (_a = resolvedUrl == null ? void 0 : resolvedUrl.searchParams.get("link_confirm_token")) != null ? _a : null;
458
+ };
440
459
  var getAuthCallbackCleanupPath = (callbackUrl) => {
441
460
  const resolvedUrl = resolveAuthCallbackUrl(callbackUrl);
442
461
  if (!resolvedUrl) return null;
443
462
  const params = new URLSearchParams(resolvedUrl.search);
444
463
  params.delete("code");
464
+ params.delete("link_confirm_token");
445
465
  const search = params.toString();
446
466
  return `${resolvedUrl.pathname}${search ? `?${search}` : ""}`;
447
467
  };
@@ -454,6 +474,12 @@ var exchangeAuthCallbackCode = (client, callbackUrl) => __async(null, null, func
454
474
  user: result.user
455
475
  };
456
476
  });
477
+ var confirmLinkAccountCallback = (client, callbackUrl) => __async(null, null, function* () {
478
+ const token = parseLinkConfirmToken(callbackUrl);
479
+ if (!token) return null;
480
+ yield client.linkAccountConfirm(token);
481
+ return { cleanupPath: getAuthCallbackCleanupPath(callbackUrl) };
482
+ });
457
483
  var parseAuthCallbackTokens = (callbackUrl) => {
458
484
  var _a, _b;
459
485
  const resolvedUrl = resolveAuthCallbackUrl(callbackUrl);
@@ -785,8 +811,14 @@ var enUsLabels = {
785
811
  categoryTabsAria: "Home page category tabs"
786
812
  },
787
813
  userProfile: {
814
+ tabs: {
815
+ positions: "Positions",
816
+ openOrders: "Open orders",
817
+ activity: "Activity"
818
+ },
788
819
  balance: {
789
820
  availableBalance: "Available Balance",
821
+ reservedForOpenOrders: (amount) => `${amount} reserved for open orders`,
790
822
  balanceByNetwork: "Balance by network",
791
823
  paperModeNetwork: "Paper",
792
824
  paperModeWarning: "Paper mode is enabled. These are simulated funds for paper trading.",
@@ -869,6 +901,25 @@ var enUsLabels = {
869
901
  avgPrefix: "avg",
870
902
  nowPrefix: "now",
871
903
  finalPrefix: "final"
904
+ },
905
+ openOrders: {
906
+ marketHeader: "Market",
907
+ limitPriceHeader: "Limit price",
908
+ filledHeader: "Filled",
909
+ totalHeader: "Total",
910
+ filledShort: "Filled",
911
+ totalShort: "Total",
912
+ expirationHeader: "Expiration",
913
+ goodTilCanceled: "Good 'til canceled",
914
+ expired: "Expired",
915
+ cancel: "Cancel",
916
+ cancelOrderAria: (orderId) => `Cancel order ${orderId}`,
917
+ loading: "Loading open orders",
918
+ loadingMore: "Loading more open orders",
919
+ errorTitle: "Unable to load open orders",
920
+ errorDescription: "Please try again in a moment.",
921
+ emptyTitle: "No open orders",
922
+ emptyDescription: "Your open limit orders will appear here."
872
923
  }
873
924
  },
874
925
  eventList: {
@@ -1010,6 +1061,7 @@ var enUsLabels = {
1010
1061
  trading: {
1011
1062
  settlementSection: "Settlement",
1012
1063
  settlementDifferencesTitle: "Key differences across venues",
1064
+ settlementFullRulesTitle: "Full rules by venue",
1013
1065
  settlementCriticalDifferenceLabel: "Critical",
1014
1066
  settlementValueUnavailable: "Not provided",
1015
1067
  settlementLoading: "Loading settlement",
@@ -1066,6 +1118,7 @@ var enUsLabels = {
1066
1118
  orderDisabledNoOutcome: "Select an outcome to place an order.",
1067
1119
  orderDisabledNoEvent: "No event selected.",
1068
1120
  insufficientBalance: "Insufficient balance",
1121
+ lowLiquidityWarning: "This market has low liquidity, which may impact execution price for larger orders.",
1069
1122
  refreshQuote: "Refresh Quote",
1070
1123
  confirmOrder: "Confirm Order",
1071
1124
  withdrawSubmitted: "Withdrawal submitted",
@@ -1112,6 +1165,29 @@ var enUsLabels = {
1112
1165
  kycSuccessDone: "Done",
1113
1166
  outcome: (label) => `Outcome: ${label}`,
1114
1167
  smartRouting: "Smart Routing",
1168
+ orderTypeMarket: "Market",
1169
+ orderTypeLimit: "Limit",
1170
+ orderTypeAria: "Order type",
1171
+ limitPrice: "Limit price",
1172
+ limitPriceInputAria: "Limit price in cents",
1173
+ limitPriceInvalid: "Limit price must be greater than 0 and less than 100.",
1174
+ limitPriceDecreaseAria: "Decrease limit price",
1175
+ limitPriceIncreaseAria: "Increase limit price",
1176
+ expiration: "Expiration",
1177
+ expirationGoodTilCanceled: "Good 'til canceled",
1178
+ expirationFiveMinutes: "5m",
1179
+ expirationOneHour: "1h",
1180
+ expirationEndOfDay: "End of day (EST)",
1181
+ expirationCustom: "Custom",
1182
+ expirationMenuAria: "Choose expiration",
1183
+ expirationOptions: "Expiration options",
1184
+ expirationDateAria: "Limit order expiration date",
1185
+ expirationStartTime: "Start time",
1186
+ expirationStartTimeHint: "24-hour format",
1187
+ expirationCancel: "Cancel",
1188
+ expirationApply: "Apply",
1189
+ limitOrderPlacedTitle: "Limit order placed",
1190
+ limitOrderPlacedDescription: "Your limit order has been submitted.",
1115
1191
  orderSplitting: "Order Splitting",
1116
1192
  splitOrderDescription: "We split your order for the best price:",
1117
1193
  viewAllRoutes: (count) => `View all (${count})`,
@@ -1377,6 +1453,12 @@ var enUsLabels = {
1377
1453
  const venue = venueLabel ? ` on ${venueLabel}` : "";
1378
1454
  return `${action}${amount}${price}${venue}`.trim();
1379
1455
  },
1456
+ cancelledTitle: "Order canceled",
1457
+ cancelledMessage: "Your open order was canceled.",
1458
+ cancelPendingTitle: "Cancellation submitted",
1459
+ cancelPendingMessage: "Your cancellation request is being processed.",
1460
+ cancelFailedTitle: "Cancellation failed",
1461
+ cancelFailedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your open order could not be canceled. Please try again.",
1380
1462
  failedTitle: "Order failed",
1381
1463
  failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your order could not be completed. Please try again."
1382
1464
  },
@@ -1516,6 +1598,7 @@ var defaultAggUiConfig = {
1516
1598
  enableGradients: false,
1517
1599
  enableVenueEventDiscoveryFilters: false,
1518
1600
  enableNotifications: true,
1601
+ showLimitOrders: false,
1519
1602
  showSportsMarkets: false
1520
1603
  },
1521
1604
  market: {
@@ -1547,7 +1630,7 @@ var mergeAggUiSearchConfig = (config) => {
1547
1630
  };
1548
1631
  };
1549
1632
  var mergeAggUiConfig = (persisted, config) => {
1550
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z;
1633
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
1551
1634
  const locale = (_d = (_c = (_a = config == null ? void 0 : config.general) == null ? void 0 : _a.locale) != null ? _c : (_b = persisted.general) == null ? void 0 : _b.locale) != null ? _d : DEFAULT_LOCALE;
1552
1635
  const theme = (_h = (_g = (_e = config == null ? void 0 : config.general) == null ? void 0 : _e.theme) != null ? _g : (_f = persisted.general) == null ? void 0 : _f.theme) != null ? _h : defaultAggUiConfig.general.theme;
1553
1636
  const formatters = createFormatters(locale);
@@ -1570,27 +1653,28 @@ var mergeAggUiConfig = (persisted, config) => {
1570
1653
  enableGradients: (_x = (_w = config == null ? void 0 : config.features) == null ? void 0 : _w.enableGradients) != null ? _x : defaultAggUiConfig.features.enableGradients,
1571
1654
  enableVenueEventDiscoveryFilters: (_z = (_y = config == null ? void 0 : config.features) == null ? void 0 : _y.enableVenueEventDiscoveryFilters) != null ? _z : defaultAggUiConfig.features.enableVenueEventDiscoveryFilters,
1572
1655
  enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications,
1573
- showSportsMarkets: (_D = (_C = config == null ? void 0 : config.features) == null ? void 0 : _C.showSportsMarkets) != null ? _D : defaultAggUiConfig.features.showSportsMarkets
1656
+ showLimitOrders: (_D = (_C = config == null ? void 0 : config.features) == null ? void 0 : _C.showLimitOrders) != null ? _D : defaultAggUiConfig.features.showLimitOrders,
1657
+ showSportsMarkets: (_F = (_E = config == null ? void 0 : config.features) == null ? void 0 : _E.showSportsMarkets) != null ? _F : defaultAggUiConfig.features.showSportsMarkets
1574
1658
  },
1575
1659
  market: {
1576
- arbitrageThreshold: (_F = (_E = config == null ? void 0 : config.market) == null ? void 0 : _E.arbitrageThreshold) != null ? _F : defaultAggUiConfig.market.arbitrageThreshold,
1577
- maxMidpointIdsPerRequest: (_H = (_G = config == null ? void 0 : config.market) == null ? void 0 : _G.maxMidpointIdsPerRequest) != null ? _H : defaultAggUiConfig.market.maxMidpointIdsPerRequest
1660
+ arbitrageThreshold: (_H = (_G = config == null ? void 0 : config.market) == null ? void 0 : _G.arbitrageThreshold) != null ? _H : defaultAggUiConfig.market.arbitrageThreshold,
1661
+ maxMidpointIdsPerRequest: (_J = (_I = config == null ? void 0 : config.market) == null ? void 0 : _I.maxMidpointIdsPerRequest) != null ? _J : defaultAggUiConfig.market.maxMidpointIdsPerRequest
1578
1662
  },
1579
1663
  chart: {
1580
- defaultChartTimeRange: (_J = (_I = config == null ? void 0 : config.chart) == null ? void 0 : _I.defaultChartTimeRange) != null ? _J : defaultAggUiConfig.chart.defaultChartTimeRange,
1581
- selectedChartTimeRange: (_N = (_M = (_K = persisted.chart) == null ? void 0 : _K.selectedChartTimeRange) != null ? _M : (_L = config == null ? void 0 : config.chart) == null ? void 0 : _L.defaultChartTimeRange) != null ? _N : defaultAggUiConfig.chart.defaultChartTimeRange,
1664
+ defaultChartTimeRange: (_L = (_K = config == null ? void 0 : config.chart) == null ? void 0 : _K.defaultChartTimeRange) != null ? _L : defaultAggUiConfig.chart.defaultChartTimeRange,
1665
+ selectedChartTimeRange: (_P = (_O = (_M = persisted.chart) == null ? void 0 : _M.selectedChartTimeRange) != null ? _O : (_N = config == null ? void 0 : config.chart) == null ? void 0 : _N.defaultChartTimeRange) != null ? _P : defaultAggUiConfig.chart.defaultChartTimeRange,
1582
1666
  setSelectedChartTimeRange: defaultAggUiConfig.chart.setSelectedChartTimeRange
1583
1667
  },
1584
1668
  formatting: {
1585
- formatNumber: (_P = (_O = config == null ? void 0 : config.formatting) == null ? void 0 : _O.formatNumber) != null ? _P : formatters.formatNumber,
1586
- formatPercent: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatPercent) != null ? _R : formatters.formatPercent,
1587
- formatCurrency: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatCurrency) != null ? _T : formatters.formatCurrency,
1588
- formatCompactCurrency: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatCompactCurrency) != null ? _V : formatters.formatCompactCurrency,
1589
- formatDate: (_X = (_W = config == null ? void 0 : config.formatting) == null ? void 0 : _W.formatDate) != null ? _X : formatters.formatDate
1669
+ formatNumber: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatNumber) != null ? _R : formatters.formatNumber,
1670
+ formatPercent: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatPercent) != null ? _T : formatters.formatPercent,
1671
+ formatCurrency: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatCurrency) != null ? _V : formatters.formatCurrency,
1672
+ formatCompactCurrency: (_X = (_W = config == null ? void 0 : config.formatting) == null ? void 0 : _W.formatCompactCurrency) != null ? _X : formatters.formatCompactCurrency,
1673
+ formatDate: (_Z = (_Y = config == null ? void 0 : config.formatting) == null ? void 0 : _Y.formatDate) != null ? _Z : formatters.formatDate
1590
1674
  },
1591
1675
  search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
1592
1676
  trading: {
1593
- executionMode: (_Z = (_Y = config == null ? void 0 : config.trading) == null ? void 0 : _Y.executionMode) != null ? _Z : defaultAggUiConfig.trading.executionMode
1677
+ executionMode: (_$ = (__ = config == null ? void 0 : config.trading) == null ? void 0 : __.executionMode) != null ? _$ : defaultAggUiConfig.trading.executionMode
1594
1678
  },
1595
1679
  walletActions: config == null ? void 0 : config.walletActions,
1596
1680
  solanaRpcUrl: config == null ? void 0 : config.solanaRpcUrl
@@ -1779,6 +1863,14 @@ function AggAuthProvider({ children }) {
1779
1863
  }
1780
1864
  return resolvedUser2;
1781
1865
  }
1866
+ const confirmedLink = yield confirmLinkAccountCallback(client, callbackUrl);
1867
+ if (confirmedLink) {
1868
+ const resolvedUser2 = yield refreshCurrentUser(client);
1869
+ if (callbackUrl === void 0) {
1870
+ replaceAuthCallbackUrl(confirmedLink.cleanupPath);
1871
+ }
1872
+ return resolvedUser2;
1873
+ }
1782
1874
  const tokens = parseAuthCallbackTokens(callbackUrl);
1783
1875
  if (!tokens) return null;
1784
1876
  client.setSession(createAuthCallbackSession(tokens));
@@ -2022,31 +2114,73 @@ function AggBalanceProvider({ children }) {
2022
2114
  return sum + tokenAcrossChains;
2023
2115
  }, 0);
2024
2116
  }, [managedBalances]);
2025
- const balanceBreakdown = (0, import_react3.useMemo)(() => {
2026
- var _a, _b;
2027
- const byChain = /* @__PURE__ */ new Map();
2028
- const cash = managedBalances.cash;
2029
- for (const token of cash) {
2030
- if (!isUsdBasedToken(token.tokenSymbol)) continue;
2031
- for (const chain of token.chains) {
2032
- const current = (_a = byChain.get(chain.chainId)) != null ? _a : {
2033
- label: chainLabelFromId(chain.chainId),
2034
- balance: 0,
2035
- accountCount: 0
2036
- };
2037
- current.balance += toTokenUnits(chain.balanceRaw, (_b = chain.decimals) != null ? _b : token.decimals);
2038
- current.accountCount += 1;
2039
- byChain.set(chain.chainId, current);
2117
+ const availableBalance = (0, import_react3.useMemo)(() => {
2118
+ return managedBalances.cash.reduce((sum, token) => {
2119
+ if (!isUsdBasedToken(token.tokenSymbol)) return sum;
2120
+ if (token.availableRaw != null) {
2121
+ return sum + toTokenUnits(token.availableRaw, token.decimals);
2040
2122
  }
2041
- }
2042
- return Array.from(byChain.entries()).sort((a, b) => a[1].label.localeCompare(b[1].label)).map(([chainId, value2]) => ({
2043
- key: String(chainId),
2044
- label: value2.label,
2045
- balance: value2.balance,
2046
- accountCount: value2.accountCount,
2047
- venues: connectedVenues.length > 0 ? connectedVenues : void 0
2048
- }));
2049
- }, [connectedVenues, managedBalances]);
2123
+ return sum + token.chains.reduce(
2124
+ (chainSum, chain) => {
2125
+ var _a, _b;
2126
+ return chainSum + toTokenUnits((_a = chain.availableRaw) != null ? _a : chain.balanceRaw, (_b = chain.decimals) != null ? _b : token.decimals);
2127
+ },
2128
+ 0
2129
+ );
2130
+ }, 0);
2131
+ }, [managedBalances]);
2132
+ const reservedBalance = (0, import_react3.useMemo)(() => {
2133
+ return managedBalances.cash.reduce((sum, token) => {
2134
+ if (!isUsdBasedToken(token.tokenSymbol)) return sum;
2135
+ if (token.reservedRaw != null) {
2136
+ return sum + toTokenUnits(token.reservedRaw, token.decimals);
2137
+ }
2138
+ return sum + token.chains.reduce(
2139
+ (chainSum, chain) => {
2140
+ var _a, _b;
2141
+ return chainSum + toTokenUnits((_a = chain.heldRaw) != null ? _a : "0", (_b = chain.decimals) != null ? _b : token.decimals);
2142
+ },
2143
+ 0
2144
+ );
2145
+ }, 0);
2146
+ }, [managedBalances]);
2147
+ const buildBalanceBreakdown = (0, import_react3.useCallback)(
2148
+ (rawForChain) => {
2149
+ var _a, _b;
2150
+ const byChain = /* @__PURE__ */ new Map();
2151
+ const cash = managedBalances.cash;
2152
+ for (const token of cash) {
2153
+ if (!isUsdBasedToken(token.tokenSymbol)) continue;
2154
+ for (const chain of token.chains) {
2155
+ const current = (_a = byChain.get(chain.chainId)) != null ? _a : {
2156
+ label: chainLabelFromId(chain.chainId),
2157
+ balance: 0,
2158
+ accountCount: 0
2159
+ };
2160
+ current.balance += toTokenUnits(rawForChain(chain), (_b = chain.decimals) != null ? _b : token.decimals);
2161
+ current.accountCount += 1;
2162
+ byChain.set(chain.chainId, current);
2163
+ }
2164
+ }
2165
+ return Array.from(byChain.entries()).sort((a, b) => a[1].label.localeCompare(b[1].label)).map(([chainId, value2]) => ({
2166
+ key: String(chainId),
2167
+ label: value2.label,
2168
+ balance: value2.balance,
2169
+ accountCount: value2.accountCount,
2170
+ venues: connectedVenues.length > 0 ? connectedVenues : void 0
2171
+ }));
2172
+ },
2173
+ [connectedVenues, managedBalances.cash]
2174
+ );
2175
+ const balanceBreakdown = (0, import_react3.useMemo)(() => {
2176
+ return buildBalanceBreakdown((chain) => chain.balanceRaw);
2177
+ }, [buildBalanceBreakdown]);
2178
+ const availableBalanceBreakdown = (0, import_react3.useMemo)(() => {
2179
+ return buildBalanceBreakdown((chain) => {
2180
+ var _a;
2181
+ return (_a = chain.availableRaw) != null ? _a : chain.balanceRaw;
2182
+ });
2183
+ }, [buildBalanceBreakdown]);
2050
2184
  const positionsBalanceTotal = (0, import_react3.useMemo)(() => {
2051
2185
  const positions = managedBalances.positions;
2052
2186
  return positions.reduce(
@@ -2067,8 +2201,11 @@ function AggBalanceProvider({ children }) {
2067
2201
  return {
2068
2202
  managedBalances,
2069
2203
  totalBalance: 0,
2204
+ availableBalance: 0,
2205
+ reservedBalance: 0,
2070
2206
  positionsBalanceTotal: 0,
2071
2207
  balanceBreakdown: [],
2208
+ availableBalanceBreakdown: [],
2072
2209
  connectedVenues: [],
2073
2210
  isLoading: false,
2074
2211
  error: null,
@@ -2080,8 +2217,11 @@ function AggBalanceProvider({ children }) {
2080
2217
  return {
2081
2218
  managedBalances,
2082
2219
  totalBalance,
2220
+ availableBalance,
2221
+ reservedBalance,
2083
2222
  positionsBalanceTotal,
2084
2223
  balanceBreakdown,
2224
+ availableBalanceBreakdown,
2085
2225
  connectedVenues,
2086
2226
  isLoading: isBalancesLoading,
2087
2227
  error,
@@ -2090,6 +2230,8 @@ function AggBalanceProvider({ children }) {
2090
2230
  };
2091
2231
  }, [
2092
2232
  balanceBreakdown,
2233
+ availableBalance,
2234
+ availableBalanceBreakdown,
2093
2235
  balancesError,
2094
2236
  connectedVenues,
2095
2237
  isBalancesLoading,
@@ -2098,6 +2240,7 @@ function AggBalanceProvider({ children }) {
2098
2240
  positionsBalanceTotal,
2099
2241
  refetch,
2100
2242
  refetchConnectionStatus,
2243
+ reservedBalance,
2101
2244
  totalBalance
2102
2245
  ]);
2103
2246
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AggBalanceContext.Provider, { value, children });
@@ -3961,12 +4104,54 @@ function useExecuteManaged(options) {
3961
4104
  });
3962
4105
  }
3963
4106
 
3964
- // src/execution/use-withdraw-managed.ts
4107
+ // src/execution/use-place-limit-order.ts
3965
4108
  var import_react_query9 = require("@tanstack/react-query");
3966
- function useWithdrawManaged(options) {
4109
+ function usePlaceLimitOrder(options) {
3967
4110
  const client = useAggClient();
3968
4111
  const queryClient = (0, import_react_query9.useQueryClient)();
3969
4112
  return (0, import_react_query9.useMutation)({
4113
+ mutationFn: (params) => client.placeLimitOrder(params),
4114
+ onSuccess: (data) => {
4115
+ var _a;
4116
+ queryClient.invalidateQueries({ queryKey: executionKeys.ordersPrefix() });
4117
+ queryClient.invalidateQueries({ queryKey: ["execution-orders"] });
4118
+ queryClient.invalidateQueries({ queryKey: executionKeys.positionsPrefix() });
4119
+ invalidateBalanceQueries(queryClient);
4120
+ (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
4121
+ },
4122
+ onError: options == null ? void 0 : options.onError
4123
+ });
4124
+ }
4125
+
4126
+ // src/execution/use-cancel-managed-order.ts
4127
+ var import_react_query10 = require("@tanstack/react-query");
4128
+ function useCancelManagedOrder(options) {
4129
+ const client = useAggClient();
4130
+ const queryClient = (0, import_react_query10.useQueryClient)();
4131
+ return (0, import_react_query10.useMutation)({
4132
+ mutationFn: (orderId) => client.cancelManagedOrder(orderId),
4133
+ onSuccess: (data, orderId) => {
4134
+ var _a;
4135
+ queryClient.invalidateQueries({ queryKey: executionKeys.ordersPrefix() });
4136
+ queryClient.invalidateQueries({ queryKey: ["execution-orders"] });
4137
+ invalidatePositionQueries(queryClient);
4138
+ invalidateBalanceQueries(queryClient);
4139
+ invalidateUserActivityQueries(queryClient);
4140
+ (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, orderId);
4141
+ },
4142
+ onError: (error, orderId) => {
4143
+ var _a;
4144
+ (_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(options, error, orderId);
4145
+ }
4146
+ });
4147
+ }
4148
+
4149
+ // src/execution/use-withdraw-managed.ts
4150
+ var import_react_query11 = require("@tanstack/react-query");
4151
+ function useWithdrawManaged(options) {
4152
+ const client = useAggClient();
4153
+ const queryClient = (0, import_react_query11.useQueryClient)();
4154
+ return (0, import_react_query11.useMutation)({
3970
4155
  mutationFn: (params) => client.withdrawManaged(params),
3971
4156
  onSuccess: (data) => {
3972
4157
  var _a;
@@ -3978,11 +4163,11 @@ function useWithdrawManaged(options) {
3978
4163
  }
3979
4164
 
3980
4165
  // src/execution/use-managed-balances.ts
3981
- var import_react_query10 = require("@tanstack/react-query");
4166
+ var import_react_query12 = require("@tanstack/react-query");
3982
4167
  function useManagedBalances(options) {
3983
4168
  const client = useAggClient();
3984
4169
  const { enabled = true, mode } = options != null ? options : {};
3985
- const query = (0, import_react_query10.useQuery)({
4170
+ const query = (0, import_react_query12.useQuery)({
3986
4171
  queryKey: executionKeys.balances(mode),
3987
4172
  queryFn: () => client.getManagedBalances(mode ? { mode } : void 0),
3988
4173
  enabled,
@@ -3996,12 +4181,12 @@ function useManagedBalances(options) {
3996
4181
  }
3997
4182
 
3998
4183
  // src/execution/use-positions.ts
3999
- var import_react_query11 = require("@tanstack/react-query");
4184
+ var import_react_query13 = require("@tanstack/react-query");
4000
4185
  function usePositions(options) {
4001
4186
  var _a, _b, _c, _d;
4002
4187
  const client = useAggClient();
4003
4188
  const { enabled = true, cursor, limit, status, mode } = options != null ? options : {};
4004
- const query = (0, import_react_query11.useQuery)({
4189
+ const query = (0, import_react_query13.useQuery)({
4005
4190
  queryKey: executionKeys.positions(cursor, limit, status, mode),
4006
4191
  queryFn: () => client.getPositions(__spreadValues({ cursor, limit, status }, mode ? { mode } : {})),
4007
4192
  enabled,
@@ -4018,7 +4203,7 @@ function usePositions(options) {
4018
4203
 
4019
4204
  // src/execution/use-deposit-addresses.ts
4020
4205
  var import_react9 = require("react");
4021
- var import_react_query12 = require("@tanstack/react-query");
4206
+ var import_react_query14 = require("@tanstack/react-query");
4022
4207
  var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
4023
4208
  function getDepositAddress(chainId, data) {
4024
4209
  return chainId !== void 0 && SVM_CHAIN_IDS.has(chainId) ? data.svmAddress : data.evmAddress;
@@ -4042,7 +4227,7 @@ function useDepositAddresses(options) {
4042
4227
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
4043
4228
  };
4044
4229
  }, [enabled, poll, timeoutMs]);
4045
- const query = (0, import_react_query12.useQuery)({
4230
+ const query = (0, import_react_query14.useQuery)({
4046
4231
  queryKey: executionKeys.depositAddresses(),
4047
4232
  queryFn: () => client.getDepositAddresses(),
4048
4233
  enabled,
@@ -4074,11 +4259,11 @@ function useDepositAddresses(options) {
4074
4259
  }
4075
4260
 
4076
4261
  // src/execution/use-sync-balances.ts
4077
- var import_react_query13 = require("@tanstack/react-query");
4262
+ var import_react_query15 = require("@tanstack/react-query");
4078
4263
  function useSyncBalances(options) {
4079
4264
  const client = useAggClient();
4080
- const queryClient = (0, import_react_query13.useQueryClient)();
4081
- return (0, import_react_query13.useMutation)({
4265
+ const queryClient = (0, import_react_query15.useQueryClient)();
4266
+ return (0, import_react_query15.useMutation)({
4082
4267
  mutationFn: () => client.syncManagedBalances(),
4083
4268
  onSuccess: () => {
4084
4269
  var _a;
@@ -4609,7 +4794,7 @@ var computeClosedPositionTotals = (group) => {
4609
4794
  };
4610
4795
 
4611
4796
  // src/execution/use-redeem.ts
4612
- var import_react_query14 = require("@tanstack/react-query");
4797
+ var import_react_query16 = require("@tanstack/react-query");
4613
4798
  var RedeemRejectedError = class extends Error {
4614
4799
  constructor(message, response) {
4615
4800
  super(message);
@@ -4620,8 +4805,8 @@ var RedeemRejectedError = class extends Error {
4620
4805
  var isLegRejected = (status) => status === "ineligible" || status === "rejected";
4621
4806
  var useRedeem = () => {
4622
4807
  const client = useAggClient();
4623
- const queryClient = (0, import_react_query14.useQueryClient)();
4624
- return (0, import_react_query14.useMutation)({
4808
+ const queryClient = (0, import_react_query16.useQueryClient)();
4809
+ return (0, import_react_query16.useMutation)({
4625
4810
  mutationFn: (body) => __async(null, null, function* () {
4626
4811
  const response = yield client.redeem(body);
4627
4812
  if (response.results.length > 0 && response.results.every((r) => isLegRejected(r.status))) {
@@ -4643,7 +4828,7 @@ var useOnRedeemEvent2 = (listener) => {
4643
4828
  };
4644
4829
 
4645
4830
  // src/execution/use-redeem-eligible-count.ts
4646
- var import_react_query15 = require("@tanstack/react-query");
4831
+ var import_react_query17 = require("@tanstack/react-query");
4647
4832
  var CLAIMABLE_COUNT_PAGE_LIMIT = 100;
4648
4833
  var getClaimablePositionsCount = (client) => __async(null, null, function* () {
4649
4834
  var _a;
@@ -4668,7 +4853,7 @@ var useRedeemEligibleCount = () => {
4668
4853
  var _a;
4669
4854
  const client = useAggClient();
4670
4855
  const { isAuthenticated } = useAggAuthState();
4671
- const query = (0, import_react_query15.useQuery)({
4856
+ const query = (0, import_react_query17.useQuery)({
4672
4857
  queryKey: executionKeys.claimablePositionsCount(),
4673
4858
  queryFn: () => getClaimablePositionsCount(client),
4674
4859
  enabled: isAuthenticated,
@@ -5144,7 +5329,7 @@ function useWithdrawEstimate({
5144
5329
 
5145
5330
  // src/withdraw/use-withdrawal-lifecycle.ts
5146
5331
  var import_react15 = require("react");
5147
- var import_react_query16 = require("@tanstack/react-query");
5332
+ var import_react_query18 = require("@tanstack/react-query");
5148
5333
  var INITIAL_STATE2 = {
5149
5334
  pending: true,
5150
5335
  status: null,
@@ -5201,7 +5386,7 @@ var restToLifecycleState = (response) => {
5201
5386
  function useWithdrawalLifecycle(withdrawalId) {
5202
5387
  const client = useAggClient();
5203
5388
  const wsConnected = useAggWebSocketConnectionState();
5204
- const queryClient = (0, import_react_query16.useQueryClient)();
5389
+ const queryClient = (0, import_react_query18.useQueryClient)();
5205
5390
  const [state, setState] = (0, import_react15.useState)(INITIAL_STATE2);
5206
5391
  const stateRef = (0, import_react15.useRef)(state);
5207
5392
  stateRef.current = state;
@@ -5270,7 +5455,7 @@ function useWithdrawalLifecycle(withdrawalId) {
5270
5455
  }
5271
5456
 
5272
5457
  // src/withdraw/use-withdraw-preview.ts
5273
- var import_react_query17 = require("@tanstack/react-query");
5458
+ var import_react_query19 = require("@tanstack/react-query");
5274
5459
  function useWithdrawPreview({
5275
5460
  amountRaw,
5276
5461
  tokenSymbol,
@@ -5280,7 +5465,7 @@ function useWithdrawPreview({
5280
5465
  }) {
5281
5466
  const client = useAggClient();
5282
5467
  const enabled = !!amountRaw && BigInt(amountRaw || "0") > BigInt(0) && !!tokenSymbol && !!destinationChainId && !!destinationAddress;
5283
- return (0, import_react_query17.useQuery)({
5468
+ return (0, import_react_query19.useQuery)({
5284
5469
  queryKey: [
5285
5470
  "withdraw-preview",
5286
5471
  tokenSymbol,
@@ -5417,7 +5602,7 @@ var requestAggAuthChooserOpen = () => {
5417
5602
  };
5418
5603
 
5419
5604
  // src/use-categories.ts
5420
- var import_react_query18 = require("@tanstack/react-query");
5605
+ var import_react_query20 = require("@tanstack/react-query");
5421
5606
  function useCategories(options) {
5422
5607
  var _a, _b, _c, _d, _e, _f;
5423
5608
  const client = useAggClient();
@@ -5425,7 +5610,7 @@ function useCategories(options) {
5425
5610
  const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
5426
5611
  const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
5427
5612
  const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
5428
- const query = (0, import_react_query18.useInfiniteQuery)({
5613
+ const query = (0, import_react_query20.useInfiniteQuery)({
5429
5614
  queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
5430
5615
  queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
5431
5616
  const res = yield client.getCategories(__spreadValues({
@@ -5457,7 +5642,7 @@ function useCategoryChildren(options) {
5457
5642
  const parentIds = Array.from(
5458
5643
  new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
5459
5644
  );
5460
- const queries = (0, import_react_query18.useQueries)({
5645
+ const queries = (0, import_react_query20.useQueries)({
5461
5646
  queries: parentIds.map((parentId) => ({
5462
5647
  queryKey: [queryKeyScope, "parent", parentId, limit],
5463
5648
  queryFn: () => __async(null, null, function* () {
@@ -5500,7 +5685,7 @@ function useDebouncedValue(value, delay) {
5500
5685
  }
5501
5686
 
5502
5687
  // src/use-execution-orders.ts
5503
- var import_react_query19 = require("@tanstack/react-query");
5688
+ var import_react_query21 = require("@tanstack/react-query");
5504
5689
  function useExecutionOrders(options = {}) {
5505
5690
  var _a, _b;
5506
5691
  const client = useAggClient();
@@ -5513,7 +5698,7 @@ function useExecutionOrders(options = {}) {
5513
5698
  enabled = true,
5514
5699
  refetchIntervalMs = false
5515
5700
  } = options;
5516
- const query = (0, import_react_query19.useInfiniteQuery)({
5701
+ const query = (0, import_react_query21.useInfiniteQuery)({
5517
5702
  // quoteId + orderId are part of the cache key — different filters
5518
5703
  // produce different result sets, so they have to vary the key.
5519
5704
  queryKey: [
@@ -5549,7 +5734,7 @@ function useExecutionOrders(options = {}) {
5549
5734
  }
5550
5735
 
5551
5736
  // src/use-user-activity.ts
5552
- var import_react_query20 = require("@tanstack/react-query");
5737
+ var import_react_query22 = require("@tanstack/react-query");
5553
5738
  var DEFAULT_PENDING_REFETCH_INTERVAL_MS = 15e3;
5554
5739
  var PENDING_ACTIVITY_STATUSES = /* @__PURE__ */ new Set([
5555
5740
  "pending",
@@ -5583,7 +5768,7 @@ function useUserActivity(options = {}) {
5583
5768
  enabled = true,
5584
5769
  pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
5585
5770
  } = options;
5586
- const query = (0, import_react_query20.useInfiniteQuery)({
5771
+ const query = (0, import_react_query22.useInfiniteQuery)({
5587
5772
  queryKey: userActivityQueryKeys.feed(type, limit),
5588
5773
  queryFn: ({ pageParam }) => client.getUserActivity({
5589
5774
  type,
@@ -5600,7 +5785,7 @@ function useUserActivity(options = {}) {
5600
5785
  // flight (typically after a deposit / withdraw cache invalidation).
5601
5786
  // Without this the feed flashes to the skeleton mid-session, which
5602
5787
  // is worse UX than briefly showing slightly-stale rows.
5603
- placeholderData: import_react_query20.keepPreviousData,
5788
+ placeholderData: import_react_query22.keepPreviousData,
5604
5789
  refetchInterval: (q) => {
5605
5790
  if (pendingRefetchIntervalMs === false) return false;
5606
5791
  const data = q.state.data;
@@ -5645,12 +5830,12 @@ function useExternalId(options = {}) {
5645
5830
  }
5646
5831
 
5647
5832
  // src/use-execution-positions.ts
5648
- var import_react_query21 = require("@tanstack/react-query");
5833
+ var import_react_query23 = require("@tanstack/react-query");
5649
5834
  function useExecutionPositions(options = {}) {
5650
5835
  var _a, _b;
5651
5836
  const client = useAggClient();
5652
5837
  const { limit = 50, status, mode, enabled = true } = options;
5653
- const query = (0, import_react_query21.useInfiniteQuery)({
5838
+ const query = (0, import_react_query23.useInfiniteQuery)({
5654
5839
  queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
5655
5840
  queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
5656
5841
  limit,
@@ -5681,7 +5866,7 @@ var import_react23 = require("react");
5681
5866
  var import_sdk3 = require("@agg-build/sdk");
5682
5867
 
5683
5868
  // src/use-market-chart.ts
5684
- var import_react_query22 = require("@tanstack/react-query");
5869
+ var import_react_query24 = require("@tanstack/react-query");
5685
5870
 
5686
5871
  // src/market-data/subscription.ts
5687
5872
  var import_react21 = require("react");
@@ -5766,7 +5951,7 @@ function useMarketChart(options) {
5766
5951
  orderbook: true,
5767
5952
  trades: true
5768
5953
  });
5769
- const queries = (0, import_react_query22.useQueries)({
5954
+ const queries = (0, import_react_query24.useQueries)({
5770
5955
  queries: outcomeIds.map((outcomeId) => ({
5771
5956
  // Cache key is intentionally time-free. The rolling window's
5772
5957
  // startTs/endTs advance on every bucket but the user expects the same
@@ -5801,7 +5986,7 @@ function useMarketChart(options) {
5801
5986
  gcTime: 60 * 6e4,
5802
5987
  refetchOnWindowFocus: false,
5803
5988
  retry: 1,
5804
- placeholderData: import_react_query22.keepPreviousData,
5989
+ placeholderData: import_react_query24.keepPreviousData,
5805
5990
  refetchInterval: refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false,
5806
5991
  refetchIntervalInBackground: false
5807
5992
  }))
@@ -6044,7 +6229,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
6044
6229
  }
6045
6230
 
6046
6231
  // src/use-live-market.ts
6047
- var import_react_query23 = require("@tanstack/react-query");
6232
+ var import_react_query25 = require("@tanstack/react-query");
6048
6233
  function outcomeOrderbookToState(response, marketId) {
6049
6234
  var _a, _b, _c, _d;
6050
6235
  const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
@@ -6094,7 +6279,7 @@ function useLiveMarket(canonicalMarketId) {
6094
6279
  enabled: isLiveSubscriptionEnabled,
6095
6280
  orderbook: true
6096
6281
  });
6097
- const query = (0, import_react_query23.useQuery)({
6282
+ const query = (0, import_react_query25.useQuery)({
6098
6283
  queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
6099
6284
  queryFn: () => __async(null, null, function* () {
6100
6285
  return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
@@ -6106,7 +6291,7 @@ function useLiveMarket(canonicalMarketId) {
6106
6291
  isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
6107
6292
  })
6108
6293
  });
6109
- const seedQuery = (0, import_react_query23.useQuery)({
6294
+ const seedQuery = (0, import_react_query25.useQuery)({
6110
6295
  queryKey: ["live-market-seed", canonicalMarketId],
6111
6296
  queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
6112
6297
  enabled: Boolean(canonicalMarketId),
@@ -6127,7 +6312,7 @@ function useLiveMarket(canonicalMarketId) {
6127
6312
 
6128
6313
  // src/use-live-outcome-prices.ts
6129
6314
  var import_react26 = require("react");
6130
- var import_react_query24 = require("@tanstack/react-query");
6315
+ var import_react_query26 = require("@tanstack/react-query");
6131
6316
  var EMPTY_PRICES = /* @__PURE__ */ new Map();
6132
6317
  var buildMidpointFingerprint = (outcomeIds, queries) => {
6133
6318
  var _a, _b, _c;
@@ -6153,7 +6338,7 @@ function useLiveOutcomePrices(venueMarkets) {
6153
6338
  }
6154
6339
  return [...ids].sort();
6155
6340
  }, [venueMarkets]);
6156
- const queries = (0, import_react_query24.useQueries)({
6341
+ const queries = (0, import_react_query26.useQueries)({
6157
6342
  queries: outcomeIds.map((id) => ({
6158
6343
  queryKey: marketDataKeys.live(id),
6159
6344
  queryFn: () => createMarketLiveState(id),
@@ -6202,7 +6387,7 @@ function findLivePriceById(livePrices, id) {
6202
6387
 
6203
6388
  // src/use-live-best-prices.ts
6204
6389
  var import_react27 = require("react");
6205
- var import_react_query25 = require("@tanstack/react-query");
6390
+ var import_react_query27 = require("@tanstack/react-query");
6206
6391
  var EMPTY = /* @__PURE__ */ new Map();
6207
6392
  var EMPTY_CANDIDATES = /* @__PURE__ */ new Map();
6208
6393
  var extractOutcomeBestPrices = (state) => {
@@ -6245,7 +6430,7 @@ function useLiveBestPrices(venueMarkets) {
6245
6430
  }
6246
6431
  return [...ids].sort();
6247
6432
  }, [venueMarkets]);
6248
- const queries = (0, import_react_query25.useQueries)({
6433
+ const queries = (0, import_react_query27.useQueries)({
6249
6434
  queries: outcomeIds.map((id) => ({
6250
6435
  queryKey: marketDataKeys.live(id),
6251
6436
  queryFn: () => createMarketLiveState(id),
@@ -6464,7 +6649,7 @@ function useLiveBestPriceCandidates(venueMarkets) {
6464
6649
  }
6465
6650
  return [...ids].sort();
6466
6651
  }, [venueMarkets]);
6467
- const queries = (0, import_react_query25.useQueries)({
6652
+ const queries = (0, import_react_query27.useQueries)({
6468
6653
  queries: outcomeIds.map((id) => ({
6469
6654
  queryKey: marketDataKeys.live(id),
6470
6655
  queryFn: () => createMarketLiveState(id),
@@ -6508,7 +6693,7 @@ function useLiveTrades(canonicalMarketId) {
6508
6693
  }
6509
6694
 
6510
6695
  // src/use-midpoints.ts
6511
- var import_react_query26 = require("@tanstack/react-query");
6696
+ var import_react_query28 = require("@tanstack/react-query");
6512
6697
  var import_react28 = require("react");
6513
6698
  var normalizeVenueMarketIds = (venueMarkets) => {
6514
6699
  var _a;
@@ -6687,7 +6872,7 @@ function useMidpoints(venueMarkets, options) {
6687
6872
  () => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
6688
6873
  [venueMarkets]
6689
6874
  );
6690
- const { data, isLoading } = (0, import_react_query26.useQuery)({
6875
+ const { data, isLoading } = (0, import_react_query28.useQuery)({
6691
6876
  queryKey: ["midpoints", ids, maxMidpointIdsPerRequest],
6692
6877
  queryFn: () => client.getMidpoints(ids, { bestPrice: true, maxMidpointIdsPerRequest }),
6693
6878
  enabled: ids.length > 0,
@@ -6832,10 +7017,10 @@ var useRollingChartWindow = (options) => {
6832
7017
  };
6833
7018
 
6834
7019
  // src/use-market-orderbook.ts
6835
- var import_react_query27 = require("@tanstack/react-query");
7020
+ var import_react_query29 = require("@tanstack/react-query");
6836
7021
  function useMarketOrderbook(options) {
6837
7022
  var _a, _b, _c, _d, _e, _f, _g, _h;
6838
- const queryClient = (0, import_react_query27.useQueryClient)();
7023
+ const queryClient = (0, import_react_query29.useQueryClient)();
6839
7024
  const ws = useAggWebSocket();
6840
7025
  const isConnected = useAggWebSocketConnectionState();
6841
7026
  const {
@@ -6853,7 +7038,7 @@ function useMarketOrderbook(options) {
6853
7038
  enabled: enabled && !!selectedOutcomeId,
6854
7039
  orderbook: true
6855
7040
  });
6856
- const liveQueries = (0, import_react_query27.useQueries)({
7041
+ const liveQueries = (0, import_react_query29.useQueries)({
6857
7042
  queries: subscriptionIds.map((subscriptionId) => ({
6858
7043
  queryKey: marketDataKeys.live(subscriptionId),
6859
7044
  queryFn: () => createMarketLiveState(subscriptionId),
@@ -6977,7 +7162,7 @@ function useArbFeed() {
6977
7162
  }
6978
7163
 
6979
7164
  // src/use-order-book.ts
6980
- var import_react_query28 = require("@tanstack/react-query");
7165
+ var import_react_query30 = require("@tanstack/react-query");
6981
7166
  function useOrderBook(options) {
6982
7167
  const client = useAggClient();
6983
7168
  const { orderbooks, enabled = true, canonicalMarketId } = options;
@@ -6990,7 +7175,7 @@ function useOrderBook(options) {
6990
7175
  venueMarketOutcomeId: outcome.id
6991
7176
  })) : void 0
6992
7177
  });
6993
- const batchedResult = (0, import_react_query28.useQuery)({
7178
+ const batchedResult = (0, import_react_query30.useQuery)({
6994
7179
  queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
6995
7180
  queryFn: ({ signal }) => client.getOrderbooks(
6996
7181
  {
@@ -7003,7 +7188,7 @@ function useOrderBook(options) {
7003
7188
  gcTime: 5 * 6e4,
7004
7189
  refetchOnWindowFocus: false,
7005
7190
  retry: 1,
7006
- placeholderData: import_react_query28.keepPreviousData
7191
+ placeholderData: import_react_query30.keepPreviousData
7007
7192
  });
7008
7193
  const data = (() => {
7009
7194
  var _a, _b;
@@ -7058,7 +7243,7 @@ function useOrderBook(options) {
7058
7243
  }
7059
7244
 
7060
7245
  // src/use-orderbook-quote.ts
7061
- var import_react_query29 = require("@tanstack/react-query");
7246
+ var import_react_query31 = require("@tanstack/react-query");
7062
7247
  var QUOTE_DEBOUNCE_MS = 300;
7063
7248
  var createUnavailableOrderbookError = (message, code, retryable) => {
7064
7249
  const error = new Error(message);
@@ -7120,7 +7305,7 @@ function useOrderbookQuote(options) {
7120
7305
  const { marketId, side, size, enabled = true } = options;
7121
7306
  const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
7122
7307
  const shouldFetch = enabled && !!marketId && debouncedSize > 0;
7123
- const query = (0, import_react_query29.useQuery)({
7308
+ const query = (0, import_react_query31.useQuery)({
7124
7309
  queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
7125
7310
  queryFn: () => __async(null, null, function* () {
7126
7311
  var _a2, _b, _c, _d;
@@ -7151,7 +7336,7 @@ function useOrderbookQuote(options) {
7151
7336
  staleTime: 1e4,
7152
7337
  gcTime: 5 * 6e4,
7153
7338
  retry: 1,
7154
- placeholderData: import_react_query29.keepPreviousData
7339
+ placeholderData: import_react_query31.keepPreviousData
7155
7340
  });
7156
7341
  return {
7157
7342
  data: (_a = query.data) != null ? _a : null,
@@ -7162,12 +7347,12 @@ function useOrderbookQuote(options) {
7162
7347
  }
7163
7348
 
7164
7349
  // src/use-orders.ts
7165
- var import_react_query30 = require("@tanstack/react-query");
7350
+ var import_react_query32 = require("@tanstack/react-query");
7166
7351
  function useOrders(options = {}) {
7167
7352
  var _a, _b, _c, _d;
7168
7353
  const client = useAggClient();
7169
7354
  const { userId, status, limit = 50, offset = 0, enabled = true } = options;
7170
- const query = (0, import_react_query30.useQuery)({
7355
+ const query = (0, import_react_query32.useQuery)({
7171
7356
  queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
7172
7357
  queryFn: () => client.getOrders({
7173
7358
  userId,
@@ -7184,13 +7369,13 @@ function useOrders(options = {}) {
7184
7369
  }
7185
7370
 
7186
7371
  // src/use-search.ts
7187
- var import_react_query31 = require("@tanstack/react-query");
7372
+ var import_react_query33 = require("@tanstack/react-query");
7188
7373
  var import_react31 = require("react");
7189
7374
  function useSearch(options) {
7190
7375
  var _a, _b, _c, _d;
7191
7376
  const client = (0, import_react31.useContext)(AggClientContext);
7192
- const queryClient = (0, import_react31.useContext)(import_react_query31.QueryClientContext);
7193
- const [fallbackQueryClient] = (0, import_react31.useState)(() => new import_react_query31.QueryClient());
7377
+ const queryClient = (0, import_react31.useContext)(import_react_query33.QueryClientContext);
7378
+ const [fallbackQueryClient] = (0, import_react31.useState)(() => new import_react_query33.QueryClient());
7194
7379
  const { q, type, categoryIds, status, limit = 20, enabled = true, deep = false } = options;
7195
7380
  const isEnabled = enabled && q.length > 0;
7196
7381
  (0, import_react31.useEffect)(() => {
@@ -7203,7 +7388,7 @@ function useSearch(options) {
7203
7388
  if (isEnabled && !client) {
7204
7389
  throw new Error("useSearch must be used within an <AggProvider>");
7205
7390
  }
7206
- const query = (0, import_react_query31.useInfiniteQuery)(
7391
+ const query = (0, import_react_query33.useInfiniteQuery)(
7207
7392
  {
7208
7393
  // deep is part of the key — TanStack treats deep vs light as
7209
7394
  // independent queries so users can have both modes cached side-by-side.
@@ -7237,7 +7422,7 @@ function useSearch(options) {
7237
7422
  if (!lastPage.hasMore) return void 0;
7238
7423
  return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
7239
7424
  },
7240
- placeholderData: import_react_query31.keepPreviousData,
7425
+ placeholderData: import_react_query33.keepPreviousData,
7241
7426
  enabled: isEnabled && !!client
7242
7427
  },
7243
7428
  queryClient != null ? queryClient : fallbackQueryClient
@@ -7345,7 +7530,7 @@ function useMarketSearch(options) {
7345
7530
  }
7346
7531
 
7347
7532
  // src/use-smart-route.ts
7348
- var import_react_query32 = require("@tanstack/react-query");
7533
+ var import_react_query34 = require("@tanstack/react-query");
7349
7534
 
7350
7535
  // src/smart-route-refresh-policy.ts
7351
7536
  var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
@@ -7493,7 +7678,7 @@ function useSmartRoute(options) {
7493
7678
  const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
7494
7679
  const hasValidInput = (maxSpend != null ? maxSpend : 0) > 0 || (sellShares != null ? sellShares : 0) > 0;
7495
7680
  const queryEnabled = enabled && !!resolvedVenueMarketOutcomeId && hasValidInput;
7496
- const query = (0, import_react_query32.useQuery)({
7681
+ const query = (0, import_react_query34.useQuery)({
7497
7682
  queryKey: [
7498
7683
  "smart-route",
7499
7684
  resolvedVenueMarketOutcomeId,
@@ -7544,7 +7729,7 @@ function useSmartRoute(options) {
7544
7729
  refetchOnWindowFocus: false,
7545
7730
  refetchIntervalInBackground: false,
7546
7731
  retry: 1,
7547
- placeholderData: import_react_query32.keepPreviousData
7732
+ placeholderData: import_react_query34.keepPreviousData
7548
7733
  });
7549
7734
  const error = query.error;
7550
7735
  let loadingReason = null;
@@ -7566,12 +7751,12 @@ function useSmartRoute(options) {
7566
7751
  }
7567
7752
 
7568
7753
  // src/use-user-holdings.ts
7569
- var import_react_query33 = require("@tanstack/react-query");
7754
+ var import_react_query35 = require("@tanstack/react-query");
7570
7755
  function useUserHoldings(options) {
7571
7756
  var _a, _b;
7572
7757
  const client = useAggClient();
7573
7758
  const { venue, venueMarketId, venueEventId, enabled = true } = options;
7574
- const query = (0, import_react_query33.useInfiniteQuery)({
7759
+ const query = (0, import_react_query35.useInfiniteQuery)({
7575
7760
  queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
7576
7761
  queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
7577
7762
  return client.getUserHoldings({
@@ -7600,7 +7785,7 @@ function useUserHoldings(options) {
7600
7785
  var import_react34 = require("react");
7601
7786
 
7602
7787
  // src/use-venue-event.ts
7603
- var import_react_query34 = require("@tanstack/react-query");
7788
+ var import_react_query36 = require("@tanstack/react-query");
7604
7789
  var RESOLUTION_POLL_MS = 15e3;
7605
7790
  var RESOLUTION_POLL_MAX_PAST_END_MS = 60 * 6e4;
7606
7791
  function resolutionPollInterval(event) {
@@ -7618,7 +7803,7 @@ function useVenueEvent(options) {
7618
7803
  var _a;
7619
7804
  const client = useAggClient();
7620
7805
  const { eventId, enabled = true } = options;
7621
- const query = (0, import_react_query34.useQuery)({
7806
+ const query = (0, import_react_query36.useQuery)({
7622
7807
  queryKey: ["venue-event", eventId],
7623
7808
  queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
7624
7809
  return client.getVenueEventById(eventId, { signal });
@@ -7638,13 +7823,13 @@ function useVenueEvent(options) {
7638
7823
  }
7639
7824
 
7640
7825
  // src/use-venue-markets.ts
7641
- var import_react_query35 = require("@tanstack/react-query");
7826
+ var import_react_query37 = require("@tanstack/react-query");
7642
7827
  var import_react33 = require("react");
7643
7828
  function useVenueMarkets(options) {
7644
7829
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
7645
7830
  const client = (0, import_react33.useContext)(AggClientContext);
7646
- const queryClient = (0, import_react33.useContext)(import_react_query35.QueryClientContext);
7647
- const [fallbackQueryClient] = (0, import_react33.useState)(() => new import_react_query35.QueryClient());
7831
+ const queryClient = (0, import_react33.useContext)(import_react_query37.QueryClientContext);
7832
+ const [fallbackQueryClient] = (0, import_react33.useState)(() => new import_react_query37.QueryClient());
7648
7833
  const venue = options == null ? void 0 : options.venue;
7649
7834
  const venueEventId = options == null ? void 0 : options.venueEventId;
7650
7835
  const search = options == null ? void 0 : options.search;
@@ -7671,7 +7856,7 @@ function useVenueMarkets(options) {
7671
7856
  if (enabled && !client) {
7672
7857
  throw new Error("useVenueMarkets must be used within an <AggProvider>");
7673
7858
  }
7674
- const query = (0, import_react_query35.useInfiniteQuery)(
7859
+ const query = (0, import_react_query37.useInfiniteQuery)(
7675
7860
  {
7676
7861
  queryKey: [
7677
7862
  "venue-markets",
@@ -7782,13 +7967,13 @@ function useEnrichedVenueEvent(options) {
7782
7967
  }
7783
7968
 
7784
7969
  // src/use-venue-events.ts
7785
- var import_react_query36 = require("@tanstack/react-query");
7970
+ var import_react_query38 = require("@tanstack/react-query");
7786
7971
  var import_react35 = require("react");
7787
7972
  function useVenueEvents(options) {
7788
7973
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
7789
7974
  const client = (0, import_react35.useContext)(AggClientContext);
7790
- const queryClient = (0, import_react35.useContext)(import_react_query36.QueryClientContext);
7791
- const [fallbackQueryClient] = (0, import_react35.useState)(() => new import_react_query36.QueryClient());
7975
+ const queryClient = (0, import_react35.useContext)(import_react_query38.QueryClientContext);
7976
+ const [fallbackQueryClient] = (0, import_react35.useState)(() => new import_react_query38.QueryClient());
7792
7977
  const venues = options == null ? void 0 : options.venues;
7793
7978
  const search = options == null ? void 0 : options.search;
7794
7979
  const categoryIds = options == null ? void 0 : options.categoryIds;
@@ -7815,7 +8000,7 @@ function useVenueEvents(options) {
7815
8000
  if (enabled && !client) {
7816
8001
  throw new Error("useVenueEvents must be used within an <AggProvider>");
7817
8002
  }
7818
- const query = (0, import_react_query36.useInfiniteQuery)(
8003
+ const query = (0, import_react_query38.useInfiniteQuery)(
7819
8004
  {
7820
8005
  queryKey: [
7821
8006
  queryKeyScope,
@@ -7862,7 +8047,7 @@ function useVenueEvents(options) {
7862
8047
  return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
7863
8048
  },
7864
8049
  // TODO: RMIK - Comment out to show skeletons on category switch
7865
- placeholderData: import_react_query36.keepPreviousData,
8050
+ placeholderData: import_react_query38.keepPreviousData,
7866
8051
  enabled: enabled && !!client
7867
8052
  },
7868
8053
  queryClient != null ? queryClient : fallbackQueryClient
@@ -7904,7 +8089,7 @@ function useVenueEvents(options) {
7904
8089
  }
7905
8090
 
7906
8091
  // src/use-venue-market-midpoints.ts
7907
- var import_react_query37 = require("@tanstack/react-query");
8092
+ var import_react_query39 = require("@tanstack/react-query");
7908
8093
  var normalizeVenueMarketIds2 = (venueMarketIds) => {
7909
8094
  return [
7910
8095
  ...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
@@ -7943,7 +8128,7 @@ function useVenueMarketMidpoints(options) {
7943
8128
  const enabled = (_a = options.enabled) != null ? _a : true;
7944
8129
  const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
7945
8130
  const maxMidpointIdsPerRequest = (_b = options.maxMidpointIdsPerRequest) != null ? _b : configuredMaxMidpointIdsPerRequest;
7946
- const query = (0, import_react_query37.useQuery)({
8131
+ const query = (0, import_react_query39.useQuery)({
7947
8132
  queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds, maxMidpointIdsPerRequest] : ["venue-market-midpoints", "__disabled__"],
7948
8133
  queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
7949
8134
  if (requestedVenueMarketIds.length === 0) {
@@ -7959,7 +8144,7 @@ function useVenueMarketMidpoints(options) {
7959
8144
  gcTime: 5 * 6e4,
7960
8145
  refetchOnWindowFocus: false,
7961
8146
  retry: 1,
7962
- placeholderData: import_react_query37.keepPreviousData
8147
+ placeholderData: import_react_query39.keepPreviousData
7963
8148
  });
7964
8149
  const midpointRows = (_d = (_c = query.data) == null ? void 0 : _c.data) != null ? _d : [];
7965
8150
  const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
@@ -8210,12 +8395,12 @@ function useVisibleIds(options = {}) {
8210
8395
  }
8211
8396
 
8212
8397
  // src/use-app-config.ts
8213
- var import_react_query38 = require("@tanstack/react-query");
8398
+ var import_react_query40 = require("@tanstack/react-query");
8214
8399
  var FIVE_MINUTES = 5 * 60 * 1e3;
8215
8400
  var APP_CONFIG_QUERY_KEY = ["agg", "app-config"];
8216
8401
  function useAppConfig() {
8217
8402
  const client = useAggClient();
8218
- const query = (0, import_react_query38.useQuery)({
8403
+ const query = (0, import_react_query40.useQuery)({
8219
8404
  queryKey: APP_CONFIG_QUERY_KEY,
8220
8405
  queryFn: () => client.getAppConfig(),
8221
8406
  staleTime: FIVE_MINUTES
@@ -8227,8 +8412,8 @@ function useAppConfig() {
8227
8412
  });
8228
8413
  }
8229
8414
  function useCachedAppConfig() {
8230
- const queryClient = (0, import_react_query38.useQueryClient)();
8231
- const query = (0, import_react_query38.useQuery)({
8415
+ const queryClient = (0, import_react_query40.useQueryClient)();
8416
+ const query = (0, import_react_query40.useQuery)({
8232
8417
  queryKey: APP_CONFIG_QUERY_KEY,
8233
8418
  enabled: false,
8234
8419
  initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
@@ -8325,6 +8510,7 @@ var toAppConfigResult = (query) => {
8325
8510
  useAppConfig,
8326
8511
  useArbFeed,
8327
8512
  useCachedAppConfig,
8513
+ useCancelManagedOrder,
8328
8514
  useCategories,
8329
8515
  useCategoryChildren,
8330
8516
  useDebouncedValue,
@@ -8364,6 +8550,7 @@ var toAppConfigResult = (query) => {
8364
8550
  useOrderBook,
8365
8551
  useOrderbookQuote,
8366
8552
  useOrders,
8553
+ usePlaceLimitOrder,
8367
8554
  usePositions,
8368
8555
  useQueryClient,
8369
8556
  useQuoteManaged,