@agg-build/hooks 1.2.12 → 1.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/{chunk-R6VANZRA.mjs → chunk-KXO3JOXF.mjs} +1 -1
- package/dist/{chunk-V34QGQBO.mjs → chunk-OBHXWQ6L.mjs} +1 -1
- package/dist/{chunk-2C7JR5OH.mjs → chunk-VLYLQSDD.mjs} +117 -55
- package/dist/deposit.js +48 -19
- package/dist/deposit.mjs +2 -2
- package/dist/index.d.mts +177 -59
- package/dist/index.d.ts +177 -59
- package/dist/index.js +484 -219
- package/dist/index.mjs +267 -74
- package/dist/withdraw.d.mts +3 -3
- package/dist/withdraw.d.ts +3 -3
- package/dist/withdraw.js +51 -22
- package/dist/withdraw.mjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -79,11 +79,13 @@ __export(src_exports, {
|
|
|
79
79
|
CONFIRMED_MATCH_STATUSES: () => CONFIRMED_MATCH_STATUSES,
|
|
80
80
|
DEFAULT_AGG_ROOT_CLASS_NAME: () => DEFAULT_AGG_ROOT_CLASS_NAME,
|
|
81
81
|
EventListStateProvider: () => EventListStateProvider,
|
|
82
|
+
MAX_PRICE_GAP_PCT: () => MAX_PRICE_GAP_PCT,
|
|
83
|
+
MIN_PRICE_GAP_PCT: () => MIN_PRICE_GAP_PCT,
|
|
82
84
|
MarketStatus: () => MarketStatus,
|
|
83
85
|
MatchStatus: () => MatchStatus,
|
|
84
86
|
MatchType: () => MatchType,
|
|
85
|
-
QueryClient: () =>
|
|
86
|
-
QueryClientProvider: () =>
|
|
87
|
+
QueryClient: () => import_react_query38.QueryClient,
|
|
88
|
+
QueryClientProvider: () => import_react_query38.QueryClientProvider,
|
|
87
89
|
RedeemRejectedError: () => RedeemRejectedError,
|
|
88
90
|
TradeSide: () => TradeSide,
|
|
89
91
|
TurnstileChallengeError: () => import_sdk4.TurnstileChallengeError,
|
|
@@ -97,12 +99,18 @@ __export(src_exports, {
|
|
|
97
99
|
getBuilder: () => getBuilder,
|
|
98
100
|
getDepositAddress: () => getDepositAddress,
|
|
99
101
|
getOrCreateBuilder: () => getOrCreateBuilder,
|
|
102
|
+
getVenueAvailabilityState: () => getVenueAvailabilityState,
|
|
103
|
+
getVisibleVenueIdsByConfig: () => getVisibleVenueIdsByConfig,
|
|
104
|
+
getVisibleVenuesByConfig: () => getVisibleVenuesByConfig,
|
|
100
105
|
getWalletAddressFromUserProfile: () => getWalletAddressFromUserProfile,
|
|
101
106
|
invalidateBalanceQueries: () => invalidateBalanceQueries,
|
|
102
107
|
invalidatePositionQueries: () => invalidatePositionQueries,
|
|
103
108
|
invalidateUserActivityQueries: () => invalidateUserActivityQueries,
|
|
109
|
+
invalidateUserClaimState: () => invalidateUserClaimState,
|
|
104
110
|
invalidateUserMoneyState: () => invalidateUserMoneyState,
|
|
111
|
+
isVenueDisabledByConfig: () => isVenueDisabledByConfig,
|
|
105
112
|
mergeBestPricesPreferringLive: () => mergeBestPricesPreferringLive,
|
|
113
|
+
normalizeVenueId: () => normalizeVenueId,
|
|
106
114
|
optimizedImageUrl: () => optimizedImageUrl,
|
|
107
115
|
parseEmail: () => parseEmail,
|
|
108
116
|
parseEmailStrict: () => parseEmailStrict,
|
|
@@ -130,7 +138,10 @@ __export(src_exports, {
|
|
|
130
138
|
useAggUiConfig: () => useAggUiConfig,
|
|
131
139
|
useAggWebSocket: () => useAggWebSocket,
|
|
132
140
|
useAppConfig: () => useAppConfig,
|
|
141
|
+
useArbFeed: () => useArbFeed,
|
|
142
|
+
useCachedAppConfig: () => useCachedAppConfig,
|
|
133
143
|
useCategories: () => useCategories,
|
|
144
|
+
useCategoryChildren: () => useCategoryChildren,
|
|
134
145
|
useDebouncedValue: () => useDebouncedValue,
|
|
135
146
|
useDepositAddresses: () => useDepositAddresses,
|
|
136
147
|
useEnrichedVenueEvent: () => useEnrichedVenueEvent,
|
|
@@ -153,6 +164,7 @@ __export(src_exports, {
|
|
|
153
164
|
useLiveOutcomePrices: () => useLiveOutcomePrices,
|
|
154
165
|
useLiveTrades: () => useLiveTrades,
|
|
155
166
|
useManagedBalances: () => useManagedBalances,
|
|
167
|
+
useMarketArb: () => useMarketArb,
|
|
156
168
|
useMarketChart: () => useMarketChart,
|
|
157
169
|
useMarketOrderbook: () => useMarketOrderbook,
|
|
158
170
|
useMarketSearch: () => useMarketSearch,
|
|
@@ -167,7 +179,7 @@ __export(src_exports, {
|
|
|
167
179
|
useOrderbookQuote: () => useOrderbookQuote,
|
|
168
180
|
useOrders: () => useOrders,
|
|
169
181
|
usePositions: () => usePositions,
|
|
170
|
-
useQueryClient: () =>
|
|
182
|
+
useQueryClient: () => import_react_query38.useQueryClient,
|
|
171
183
|
useQuoteManaged: () => useQuoteManaged,
|
|
172
184
|
useRampQuotes: () => useRampQuotes,
|
|
173
185
|
useRampSession: () => useRampSession,
|
|
@@ -320,7 +332,7 @@ var getVenueOrder = (venue) => {
|
|
|
320
332
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
321
333
|
|
|
322
334
|
// src/index.ts
|
|
323
|
-
var
|
|
335
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
324
336
|
|
|
325
337
|
// src/candle-store.ts
|
|
326
338
|
var import_sdk = require("@agg-build/sdk");
|
|
@@ -357,11 +369,23 @@ function evict() {
|
|
|
357
369
|
}
|
|
358
370
|
|
|
359
371
|
// src/core/providers/agg-provider.tsx
|
|
360
|
-
var
|
|
372
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
361
373
|
|
|
362
374
|
// src/core/providers/auth-provider.tsx
|
|
375
|
+
var import_react_query = require("@tanstack/react-query");
|
|
363
376
|
var import_react2 = require("react");
|
|
364
377
|
|
|
378
|
+
// src/current-user-query.ts
|
|
379
|
+
var CURRENT_USER_QUERY_KEY = ["current-user"];
|
|
380
|
+
var CURRENT_USER_STALE_TIME_MS = 6e4;
|
|
381
|
+
var fetchCurrentUserProfile = (queryClient, client, queryKey = CURRENT_USER_QUERY_KEY) => {
|
|
382
|
+
return queryClient.fetchQuery({
|
|
383
|
+
queryKey,
|
|
384
|
+
queryFn: () => client.getCurrentUser(),
|
|
385
|
+
staleTime: CURRENT_USER_STALE_TIME_MS
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
|
|
365
389
|
// src/core/providers/auth-utils.ts
|
|
366
390
|
var import_sdk2 = require("@agg-build/sdk");
|
|
367
391
|
var createPlaceholderUserProfile = (input) => {
|
|
@@ -689,11 +713,8 @@ var enUsLabels = {
|
|
|
689
713
|
loadingDescription: "This may take a few minutes. You can safely close this window and check the status later in your activity.",
|
|
690
714
|
summary: {
|
|
691
715
|
requestedWithdrawal: "Requested withdrawal",
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
-
// would imply receipt before the lifecycle has confirmed. Keep it
|
|
695
|
-
// honest as the submitted amount until the multi-stable quote
|
|
696
|
-
// layer (PR-E) populates `expected.outputRaw`.
|
|
716
|
+
// Calling this "Amount received" would imply receipt before the
|
|
717
|
+
// lifecycle has confirmed. Keep it honest as the submitted amount.
|
|
697
718
|
amountReceived: "Amount",
|
|
698
719
|
network: "Network",
|
|
699
720
|
toWallet: "To wallet",
|
|
@@ -741,9 +762,8 @@ var enUsLabels = {
|
|
|
741
762
|
}
|
|
742
763
|
},
|
|
743
764
|
summary: {
|
|
744
|
-
// Lifecycle-honest:
|
|
745
|
-
//
|
|
746
|
-
// a guaranteed net output.
|
|
765
|
+
// Lifecycle-honest: this is the submitted amount, not a guaranteed net
|
|
766
|
+
// output.
|
|
747
767
|
amountReceived: "Amount",
|
|
748
768
|
network: "Network"
|
|
749
769
|
}
|
|
@@ -754,14 +774,21 @@ var enUsLabels = {
|
|
|
754
774
|
},
|
|
755
775
|
home: {
|
|
756
776
|
trending: "Trending",
|
|
757
|
-
topMarkets: "
|
|
777
|
+
topMarkets: "Trending",
|
|
758
778
|
newMarkets: "New Markets",
|
|
759
779
|
categoryTabsAria: "Home page category tabs"
|
|
760
780
|
},
|
|
761
781
|
userProfile: {
|
|
762
782
|
activity: {
|
|
763
783
|
depositType: "Deposit",
|
|
784
|
+
redeemType: "Claim",
|
|
764
785
|
withdrawalType: "Withdrawal",
|
|
786
|
+
redeemStatusTitles: {
|
|
787
|
+
pending: "Processing claim",
|
|
788
|
+
completed: "Successful claim",
|
|
789
|
+
failed: "Failed claim",
|
|
790
|
+
canceled: "Canceled claim"
|
|
791
|
+
},
|
|
765
792
|
depositTitles: {
|
|
766
793
|
connectedWallet: "Deposit from connected wallet",
|
|
767
794
|
externalWallet: "Deposit from external wallet",
|
|
@@ -869,12 +896,14 @@ var enUsLabels = {
|
|
|
869
896
|
unavailableTitle: "Market unavailable",
|
|
870
897
|
unavailableDescription: "We could not load this market right now.",
|
|
871
898
|
arbitrage: "Arbitrage",
|
|
872
|
-
priceGap: "Price Gap",
|
|
873
899
|
volumeSuffix: "Vol.",
|
|
874
900
|
marketSingular: "Market",
|
|
875
901
|
marketPlural: "Markets",
|
|
876
902
|
venueSingular: "Venue",
|
|
877
|
-
venuePlural: "Venues"
|
|
903
|
+
venuePlural: "Venues",
|
|
904
|
+
matched: "Matched",
|
|
905
|
+
matchedCount: (count) => `${count} ${count === 1 ? "Match" : "Matches"}`,
|
|
906
|
+
priceGap: "Price Gap"
|
|
878
907
|
},
|
|
879
908
|
eventItemDetails: {
|
|
880
909
|
loading: "Loading market details",
|
|
@@ -986,8 +1015,8 @@ var enUsLabels = {
|
|
|
986
1015
|
})}\xA2 avg. price`,
|
|
987
1016
|
balance: (value) => `Balance ${value}`,
|
|
988
1017
|
shares: (value) => `${value.toLocaleString("en-US", {
|
|
989
|
-
minimumFractionDigits: Number.isInteger(value) ? 0 :
|
|
990
|
-
maximumFractionDigits:
|
|
1018
|
+
minimumFractionDigits: Number.isInteger(value) ? 0 : 1,
|
|
1019
|
+
maximumFractionDigits: 2
|
|
991
1020
|
})} shares`,
|
|
992
1021
|
maxShares: "Max",
|
|
993
1022
|
slippage: (value) => `Slippage: ${value}%`,
|
|
@@ -1071,9 +1100,11 @@ var enUsLabels = {
|
|
|
1071
1100
|
platformFee: "0% platform fees",
|
|
1072
1101
|
estimatedFees: "Estimated fees",
|
|
1073
1102
|
estimatedFeesTooltipAria: "Estimated fees breakdown",
|
|
1074
|
-
feeBreakdownVenueFees: "Venue
|
|
1075
|
-
feeBreakdownBridgeFees: "
|
|
1076
|
-
feeBreakdownExecutionGas: "
|
|
1103
|
+
feeBreakdownVenueFees: "Venue",
|
|
1104
|
+
feeBreakdownBridgeFees: "Bridging",
|
|
1105
|
+
feeBreakdownExecutionGas: "Gas",
|
|
1106
|
+
feeBreakdownAggMarket: "agg.market",
|
|
1107
|
+
feeBreakdownPlatformFeeBadge: "0% fee",
|
|
1077
1108
|
feeBreakdownTotalFees: "Total fees",
|
|
1078
1109
|
toWin: (tab) => tab === "buy" ? "To win" : "Payout",
|
|
1079
1110
|
buyingOutcome: (label) => `Buying ${label}`,
|
|
@@ -1309,6 +1340,19 @@ var enUsLabels = {
|
|
|
1309
1340
|
},
|
|
1310
1341
|
failedTitle: "Withdrawal failed",
|
|
1311
1342
|
failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your funds have been returned to your balance."
|
|
1343
|
+
},
|
|
1344
|
+
claim: {
|
|
1345
|
+
pendingTitle: "Claim started",
|
|
1346
|
+
pendingMessage: "Claiming your winnings.",
|
|
1347
|
+
submittedTitle: "Claim submitted",
|
|
1348
|
+
submittedMessage: "Your claim was submitted. It may take a little while to finish.",
|
|
1349
|
+
successTitle: "Claim complete",
|
|
1350
|
+
successMessage: "Your winnings have been claimed.",
|
|
1351
|
+
partialTitle: "Claim partially completed",
|
|
1352
|
+
partialMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Some winnings could not be claimed. Please try again.",
|
|
1353
|
+
failedTitle: "Claim failed",
|
|
1354
|
+
failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your winnings could not be claimed. Please try again.",
|
|
1355
|
+
missingOutcomeMessage: "This position is missing claimable outcome data. Please refresh."
|
|
1312
1356
|
}
|
|
1313
1357
|
}
|
|
1314
1358
|
};
|
|
@@ -1399,6 +1443,7 @@ var defaultAggUiConfig = {
|
|
|
1399
1443
|
features: {
|
|
1400
1444
|
enableAnimations: true,
|
|
1401
1445
|
enableLiveUpdates: true,
|
|
1446
|
+
enablePriceGap: false,
|
|
1402
1447
|
showFeesBreakdown: false,
|
|
1403
1448
|
enableGradients: false,
|
|
1404
1449
|
enableVenueEventDiscoveryFilters: false,
|
|
@@ -1429,7 +1474,7 @@ var mergeAggUiSearchConfig = (config) => {
|
|
|
1429
1474
|
};
|
|
1430
1475
|
};
|
|
1431
1476
|
var mergeAggUiConfig = (persisted, config) => {
|
|
1432
|
-
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;
|
|
1477
|
+
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;
|
|
1433
1478
|
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;
|
|
1434
1479
|
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;
|
|
1435
1480
|
const formatters = createFormatters(locale);
|
|
@@ -1447,25 +1492,26 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1447
1492
|
features: {
|
|
1448
1493
|
enableAnimations: (_p = (_o = config == null ? void 0 : config.features) == null ? void 0 : _o.enableAnimations) != null ? _p : defaultAggUiConfig.features.enableAnimations,
|
|
1449
1494
|
enableLiveUpdates: (_r = (_q = config == null ? void 0 : config.features) == null ? void 0 : _q.enableLiveUpdates) != null ? _r : defaultAggUiConfig.features.enableLiveUpdates,
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1495
|
+
enablePriceGap: (_t = (_s = config == null ? void 0 : config.features) == null ? void 0 : _s.enablePriceGap) != null ? _t : defaultAggUiConfig.features.enablePriceGap,
|
|
1496
|
+
showFeesBreakdown: (_v = (_u = config == null ? void 0 : config.features) == null ? void 0 : _u.showFeesBreakdown) != null ? _v : defaultAggUiConfig.features.showFeesBreakdown,
|
|
1497
|
+
enableGradients: (_x = (_w = config == null ? void 0 : config.features) == null ? void 0 : _w.enableGradients) != null ? _x : defaultAggUiConfig.features.enableGradients,
|
|
1498
|
+
enableVenueEventDiscoveryFilters: (_z = (_y = config == null ? void 0 : config.features) == null ? void 0 : _y.enableVenueEventDiscoveryFilters) != null ? _z : defaultAggUiConfig.features.enableVenueEventDiscoveryFilters,
|
|
1499
|
+
enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications
|
|
1454
1500
|
},
|
|
1455
1501
|
market: {
|
|
1456
|
-
arbitrageThreshold: (
|
|
1502
|
+
arbitrageThreshold: (_D = (_C = config == null ? void 0 : config.market) == null ? void 0 : _C.arbitrageThreshold) != null ? _D : defaultAggUiConfig.market.arbitrageThreshold
|
|
1457
1503
|
},
|
|
1458
1504
|
chart: {
|
|
1459
|
-
defaultChartTimeRange: (
|
|
1460
|
-
selectedChartTimeRange: (
|
|
1505
|
+
defaultChartTimeRange: (_F = (_E = config == null ? void 0 : config.chart) == null ? void 0 : _E.defaultChartTimeRange) != null ? _F : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1506
|
+
selectedChartTimeRange: (_J = (_I = (_G = persisted.chart) == null ? void 0 : _G.selectedChartTimeRange) != null ? _I : (_H = config == null ? void 0 : config.chart) == null ? void 0 : _H.defaultChartTimeRange) != null ? _J : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1461
1507
|
setSelectedChartTimeRange: defaultAggUiConfig.chart.setSelectedChartTimeRange
|
|
1462
1508
|
},
|
|
1463
1509
|
formatting: {
|
|
1464
|
-
formatNumber: (
|
|
1465
|
-
formatPercent: (
|
|
1466
|
-
formatCurrency: (
|
|
1467
|
-
formatCompactCurrency: (
|
|
1468
|
-
formatDate: (
|
|
1510
|
+
formatNumber: (_L = (_K = config == null ? void 0 : config.formatting) == null ? void 0 : _K.formatNumber) != null ? _L : formatters.formatNumber,
|
|
1511
|
+
formatPercent: (_N = (_M = config == null ? void 0 : config.formatting) == null ? void 0 : _M.formatPercent) != null ? _N : formatters.formatPercent,
|
|
1512
|
+
formatCurrency: (_P = (_O = config == null ? void 0 : config.formatting) == null ? void 0 : _O.formatCurrency) != null ? _P : formatters.formatCurrency,
|
|
1513
|
+
formatCompactCurrency: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatCompactCurrency) != null ? _R : formatters.formatCompactCurrency,
|
|
1514
|
+
formatDate: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatDate) != null ? _T : formatters.formatDate
|
|
1469
1515
|
},
|
|
1470
1516
|
search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
|
|
1471
1517
|
walletActions: config == null ? void 0 : config.walletActions,
|
|
@@ -1498,6 +1544,9 @@ var replaceAuthCallbackUrl = (cleanupPath) => {
|
|
|
1498
1544
|
};
|
|
1499
1545
|
function AggAuthProvider({ children }) {
|
|
1500
1546
|
const client = (0, import_react2.useContext)(AggClientContext);
|
|
1547
|
+
const queryClientFromContext = (0, import_react2.useContext)(import_react_query.QueryClientContext);
|
|
1548
|
+
const fallbackQueryClient = (0, import_react2.useMemo)(() => new import_react_query.QueryClient(), []);
|
|
1549
|
+
const queryClient = queryClientFromContext && "fetchQuery" in queryClientFromContext ? queryClientFromContext : fallbackQueryClient;
|
|
1501
1550
|
const snapshot = getClientAuthSnapshot(client);
|
|
1502
1551
|
const [isAuthenticated, setIsAuthenticated] = (0, import_react2.useState)(snapshot.isAuthenticated);
|
|
1503
1552
|
const [user, setUser] = (0, import_react2.useState)(snapshot.user);
|
|
@@ -1512,12 +1561,15 @@ function AggAuthProvider({ children }) {
|
|
|
1512
1561
|
return provider === "wallet" || provider === "solana_wallet";
|
|
1513
1562
|
});
|
|
1514
1563
|
}, [user]);
|
|
1515
|
-
const refreshCurrentUser = (0, import_react2.useCallback)(
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1564
|
+
const refreshCurrentUser = (0, import_react2.useCallback)(
|
|
1565
|
+
(targetClient) => __async(null, null, function* () {
|
|
1566
|
+
const fullUser = yield fetchCurrentUserProfile(queryClient, targetClient);
|
|
1567
|
+
setIsAuthenticated(true);
|
|
1568
|
+
setUser(fullUser);
|
|
1569
|
+
return fullUser;
|
|
1570
|
+
}),
|
|
1571
|
+
[queryClient]
|
|
1572
|
+
);
|
|
1521
1573
|
(0, import_react2.useEffect)(() => {
|
|
1522
1574
|
const state = getClientAuthSnapshot(client);
|
|
1523
1575
|
setIsAuthenticated(state.isAuthenticated);
|
|
@@ -1709,15 +1761,22 @@ function AggAuthProvider({ children }) {
|
|
|
1709
1761
|
}
|
|
1710
1762
|
|
|
1711
1763
|
// src/core/providers/balance-provider.tsx
|
|
1712
|
-
var
|
|
1764
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
1713
1765
|
var import_react3 = require("react");
|
|
1714
1766
|
|
|
1715
1767
|
// src/execution/query-keys.ts
|
|
1716
1768
|
var executionKeys = {
|
|
1717
1769
|
all: () => ["execution"],
|
|
1718
|
-
balances: () => ["execution", "balances"],
|
|
1719
|
-
positions: (cursor, limit, status) => ["execution", "positions", cursor != null ? cursor : null, limit != null ? limit : null, status != null ? status : null],
|
|
1770
|
+
balances: (mode) => mode ? ["execution", "balances", mode] : ["execution", "balances"],
|
|
1771
|
+
positions: (cursor, limit, status, mode) => mode ? ["execution", "positions", cursor != null ? cursor : null, limit != null ? limit : null, status != null ? status : null, mode] : ["execution", "positions", cursor != null ? cursor : null, limit != null ? limit : null, status != null ? status : null],
|
|
1720
1772
|
positionsPrefix: () => ["execution", "positions"],
|
|
1773
|
+
claimablePositionsCount: () => ["execution", "positions", "claimable-count"],
|
|
1774
|
+
/**
|
|
1775
|
+
* @deprecated Misnomer — claimable (redeemStatus "eligible") groups live in
|
|
1776
|
+
* the ACTIVE bucket, not closed (won-but-unclaimed stays Active until a
|
|
1777
|
+
* redeem stamps redeemedAt). Same key value as `claimablePositionsCount`;
|
|
1778
|
+
* kept so existing invalidation call sites keep matching.
|
|
1779
|
+
*/
|
|
1721
1780
|
claimableClosedPositionsCount: () => ["execution", "positions", "claimable-count"],
|
|
1722
1781
|
orders: (status, cursor, limit) => ["execution", "orders", status != null ? status : null, cursor != null ? cursor : null, limit != null ? limit : null],
|
|
1723
1782
|
ordersPrefix: () => ["execution", "orders"],
|
|
@@ -1768,7 +1827,8 @@ var shouldInvalidateBalancesForOrderEvent = (event, currentUserId) => {
|
|
|
1768
1827
|
return event.userId === currentUserId;
|
|
1769
1828
|
};
|
|
1770
1829
|
var userActivityQueryKeys = {
|
|
1771
|
-
all: () => ["user-activity"]
|
|
1830
|
+
all: () => ["user-activity"],
|
|
1831
|
+
feed: (type, limit) => ["user-activity", type != null ? type : "all", limit != null ? limit : 50]
|
|
1772
1832
|
};
|
|
1773
1833
|
var invalidateUserActivityQueries = (queryClient, options) => {
|
|
1774
1834
|
var _a;
|
|
@@ -1787,6 +1847,17 @@ var invalidateUserMoneyState = (queryClient, options) => {
|
|
|
1787
1847
|
invalidatePositionQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
|
|
1788
1848
|
invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
|
|
1789
1849
|
};
|
|
1850
|
+
var invalidateUserClaimState = (queryClient, options) => {
|
|
1851
|
+
var _a;
|
|
1852
|
+
const refetchType = (_a = options == null ? void 0 : options.refetchType) != null ? _a : "active";
|
|
1853
|
+
invalidateBalanceQueries(queryClient, { refetchType });
|
|
1854
|
+
invalidatePositionQueries(queryClient, { refetchType });
|
|
1855
|
+
queryClient.invalidateQueries({
|
|
1856
|
+
queryKey: executionKeys.claimablePositionsCount(),
|
|
1857
|
+
refetchType
|
|
1858
|
+
});
|
|
1859
|
+
invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
|
|
1860
|
+
};
|
|
1790
1861
|
|
|
1791
1862
|
// src/core/providers/balance-provider.tsx
|
|
1792
1863
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -1826,7 +1897,7 @@ function AggBalanceProvider({ children }) {
|
|
|
1826
1897
|
throw new Error("AggBalanceProvider must be used within an <AggAuthProvider>");
|
|
1827
1898
|
}
|
|
1828
1899
|
const { isAuthenticated } = authContext;
|
|
1829
|
-
const balancesQuery = (0,
|
|
1900
|
+
const balancesQuery = (0, import_react_query2.useQuery)({
|
|
1830
1901
|
queryKey: balanceQueryKeys.provider(),
|
|
1831
1902
|
queryFn: () => __async(null, null, function* () {
|
|
1832
1903
|
if (!client || !isAuthenticated) {
|
|
@@ -1994,7 +2065,7 @@ function useEventListState() {
|
|
|
1994
2065
|
|
|
1995
2066
|
// src/core/providers/ws-provider.tsx
|
|
1996
2067
|
var import_react6 = require("react");
|
|
1997
|
-
var
|
|
2068
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1998
2069
|
|
|
1999
2070
|
// src/market-data/chart-cache.ts
|
|
2000
2071
|
var MAX_CACHE_RETENTION_SECONDS = 7 * 30 * 24 * 60 * 60 + 14 * 24 * 60 * 60;
|
|
@@ -2581,7 +2652,7 @@ function useOnWithdrawalLifecycle(callback) {
|
|
|
2581
2652
|
function AggWebSocketProvider({ children }) {
|
|
2582
2653
|
const client = useAggClient();
|
|
2583
2654
|
const { enableWebsocketsLogs } = useAggUiConfig();
|
|
2584
|
-
const queryClient = (0,
|
|
2655
|
+
const queryClient = (0, import_react_query3.useQueryClient)();
|
|
2585
2656
|
const [ws, setWs] = (0, import_react6.useState)(null);
|
|
2586
2657
|
const [isConnected, setIsConnected] = (0, import_react6.useState)(false);
|
|
2587
2658
|
const [isClientAuthenticated, setIsClientAuthenticated] = (0, import_react6.useState)(client.isAuthenticated);
|
|
@@ -3574,7 +3645,7 @@ var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
|
3574
3645
|
var hasWarnedMissingQueryClient = false;
|
|
3575
3646
|
function useQueryClientCheck() {
|
|
3576
3647
|
try {
|
|
3577
|
-
(0,
|
|
3648
|
+
(0, import_react_query4.useQueryClient)();
|
|
3578
3649
|
} catch (e) {
|
|
3579
3650
|
if (!hasWarnedMissingQueryClient) {
|
|
3580
3651
|
hasWarnedMissingQueryClient = true;
|
|
@@ -3595,10 +3666,10 @@ var AggProvider = ({ client, config, children }) => {
|
|
|
3595
3666
|
};
|
|
3596
3667
|
|
|
3597
3668
|
// src/use-ramp-quotes.ts
|
|
3598
|
-
var
|
|
3669
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
3599
3670
|
function useRampQuotes() {
|
|
3600
3671
|
const client = useAggClient();
|
|
3601
|
-
return (0,
|
|
3672
|
+
return (0, import_react_query5.useMutation)({
|
|
3602
3673
|
mutationFn: (params) => __async(null, null, function* () {
|
|
3603
3674
|
return client.getRampQuotes(params);
|
|
3604
3675
|
})
|
|
@@ -3606,10 +3677,10 @@ function useRampQuotes() {
|
|
|
3606
3677
|
}
|
|
3607
3678
|
|
|
3608
3679
|
// src/use-ramp-session.ts
|
|
3609
|
-
var
|
|
3680
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
3610
3681
|
function useRampSession() {
|
|
3611
3682
|
const client = useAggClient();
|
|
3612
|
-
return (0,
|
|
3683
|
+
return (0, import_react_query6.useMutation)({
|
|
3613
3684
|
mutationFn: (params) => __async(null, null, function* () {
|
|
3614
3685
|
return client.createRampSession(params);
|
|
3615
3686
|
})
|
|
@@ -3620,10 +3691,10 @@ function useRampSession() {
|
|
|
3620
3691
|
var import_react13 = require("react");
|
|
3621
3692
|
|
|
3622
3693
|
// src/execution/use-quote-managed.ts
|
|
3623
|
-
var
|
|
3694
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
3624
3695
|
function useQuoteManaged(options) {
|
|
3625
3696
|
const client = useAggClient();
|
|
3626
|
-
return (0,
|
|
3697
|
+
return (0, import_react_query7.useMutation)({
|
|
3627
3698
|
mutationFn: (params) => client.quoteManaged(params),
|
|
3628
3699
|
onSuccess: options == null ? void 0 : options.onSuccess,
|
|
3629
3700
|
onError: options == null ? void 0 : options.onError
|
|
@@ -3631,11 +3702,11 @@ function useQuoteManaged(options) {
|
|
|
3631
3702
|
}
|
|
3632
3703
|
|
|
3633
3704
|
// src/execution/use-execute-managed.ts
|
|
3634
|
-
var
|
|
3705
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
3635
3706
|
function useExecuteManaged(options) {
|
|
3636
3707
|
const client = useAggClient();
|
|
3637
|
-
const queryClient = (0,
|
|
3638
|
-
return (0,
|
|
3708
|
+
const queryClient = (0, import_react_query8.useQueryClient)();
|
|
3709
|
+
return (0, import_react_query8.useMutation)({
|
|
3639
3710
|
mutationFn: (params) => client.executeManaged(params),
|
|
3640
3711
|
onSuccess: (data) => {
|
|
3641
3712
|
var _a;
|
|
@@ -3649,11 +3720,11 @@ function useExecuteManaged(options) {
|
|
|
3649
3720
|
}
|
|
3650
3721
|
|
|
3651
3722
|
// src/execution/use-withdraw-managed.ts
|
|
3652
|
-
var
|
|
3723
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
3653
3724
|
function useWithdrawManaged(options) {
|
|
3654
3725
|
const client = useAggClient();
|
|
3655
|
-
const queryClient = (0,
|
|
3656
|
-
return (0,
|
|
3726
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
3727
|
+
return (0, import_react_query9.useMutation)({
|
|
3657
3728
|
mutationFn: (params) => client.withdrawManaged(params),
|
|
3658
3729
|
onSuccess: (data) => {
|
|
3659
3730
|
var _a;
|
|
@@ -3665,13 +3736,13 @@ function useWithdrawManaged(options) {
|
|
|
3665
3736
|
}
|
|
3666
3737
|
|
|
3667
3738
|
// src/execution/use-managed-balances.ts
|
|
3668
|
-
var
|
|
3739
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
3669
3740
|
function useManagedBalances(options) {
|
|
3670
3741
|
const client = useAggClient();
|
|
3671
|
-
const { enabled = true } = options != null ? options : {};
|
|
3672
|
-
const query = (0,
|
|
3673
|
-
queryKey: executionKeys.balances(),
|
|
3674
|
-
queryFn: () => client.getManagedBalances(),
|
|
3742
|
+
const { enabled = true, mode } = options != null ? options : {};
|
|
3743
|
+
const query = (0, import_react_query10.useQuery)({
|
|
3744
|
+
queryKey: executionKeys.balances(mode),
|
|
3745
|
+
queryFn: () => client.getManagedBalances(mode ? { mode } : void 0),
|
|
3675
3746
|
enabled,
|
|
3676
3747
|
staleTime: 1e4,
|
|
3677
3748
|
gcTime: 5 * 6e4,
|
|
@@ -3683,14 +3754,14 @@ function useManagedBalances(options) {
|
|
|
3683
3754
|
}
|
|
3684
3755
|
|
|
3685
3756
|
// src/execution/use-positions.ts
|
|
3686
|
-
var
|
|
3757
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
3687
3758
|
function usePositions(options) {
|
|
3688
3759
|
var _a, _b, _c, _d;
|
|
3689
3760
|
const client = useAggClient();
|
|
3690
|
-
const { enabled = true, cursor, limit, status } = options != null ? options : {};
|
|
3691
|
-
const query = (0,
|
|
3692
|
-
queryKey: executionKeys.positions(cursor, limit, status),
|
|
3693
|
-
queryFn: () => client.getPositions({ cursor, limit, status }),
|
|
3761
|
+
const { enabled = true, cursor, limit, status, mode } = options != null ? options : {};
|
|
3762
|
+
const query = (0, import_react_query11.useQuery)({
|
|
3763
|
+
queryKey: executionKeys.positions(cursor, limit, status, mode),
|
|
3764
|
+
queryFn: () => client.getPositions(__spreadValues({ cursor, limit, status }, mode ? { mode } : {})),
|
|
3694
3765
|
enabled,
|
|
3695
3766
|
staleTime: 1e4,
|
|
3696
3767
|
gcTime: 5 * 6e4,
|
|
@@ -3705,7 +3776,7 @@ function usePositions(options) {
|
|
|
3705
3776
|
|
|
3706
3777
|
// src/execution/use-deposit-addresses.ts
|
|
3707
3778
|
var import_react9 = require("react");
|
|
3708
|
-
var
|
|
3779
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
3709
3780
|
var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
|
|
3710
3781
|
function getDepositAddress(chainId, data) {
|
|
3711
3782
|
return chainId !== void 0 && SVM_CHAIN_IDS.has(chainId) ? data.svmAddress : data.evmAddress;
|
|
@@ -3729,7 +3800,7 @@ function useDepositAddresses(options) {
|
|
|
3729
3800
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
3730
3801
|
};
|
|
3731
3802
|
}, [enabled, poll, timeoutMs]);
|
|
3732
|
-
const query = (0,
|
|
3803
|
+
const query = (0, import_react_query12.useQuery)({
|
|
3733
3804
|
queryKey: executionKeys.depositAddresses(),
|
|
3734
3805
|
queryFn: () => client.getDepositAddresses(),
|
|
3735
3806
|
enabled,
|
|
@@ -3761,11 +3832,11 @@ function useDepositAddresses(options) {
|
|
|
3761
3832
|
}
|
|
3762
3833
|
|
|
3763
3834
|
// src/execution/use-sync-balances.ts
|
|
3764
|
-
var
|
|
3835
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
3765
3836
|
function useSyncBalances(options) {
|
|
3766
3837
|
const client = useAggClient();
|
|
3767
|
-
const queryClient = (0,
|
|
3768
|
-
return (0,
|
|
3838
|
+
const queryClient = (0, import_react_query13.useQueryClient)();
|
|
3839
|
+
return (0, import_react_query13.useMutation)({
|
|
3769
3840
|
mutationFn: () => client.syncManagedBalances(),
|
|
3770
3841
|
onSuccess: () => {
|
|
3771
3842
|
var _a;
|
|
@@ -3794,7 +3865,8 @@ function mapOrderStatusToTerminalEvent(status) {
|
|
|
3794
3865
|
}
|
|
3795
3866
|
function useExecutionProgress({
|
|
3796
3867
|
orderIds,
|
|
3797
|
-
enabled
|
|
3868
|
+
enabled,
|
|
3869
|
+
mode
|
|
3798
3870
|
}) {
|
|
3799
3871
|
const [phase, setPhase] = (0, import_react10.useState)("idle");
|
|
3800
3872
|
const [submittedOrders, setSubmittedOrders] = (0, import_react10.useState)([]);
|
|
@@ -4002,7 +4074,10 @@ function useExecutionProgress({
|
|
|
4002
4074
|
pending.map((orderId) => __async(null, null, function* () {
|
|
4003
4075
|
var _a2, _b2;
|
|
4004
4076
|
try {
|
|
4005
|
-
const res = yield client.getExecutionOrders({
|
|
4077
|
+
const res = yield client.getExecutionOrders(__spreadValues({
|
|
4078
|
+
orderId,
|
|
4079
|
+
limit: 1
|
|
4080
|
+
}, mode ? { mode } : {}));
|
|
4006
4081
|
return (_b2 = (_a2 = res.data) == null ? void 0 : _a2[0]) != null ? _b2 : null;
|
|
4007
4082
|
} catch (e) {
|
|
4008
4083
|
return null;
|
|
@@ -4063,7 +4138,7 @@ function useExecutionProgress({
|
|
|
4063
4138
|
cancelled = true;
|
|
4064
4139
|
stopPolling();
|
|
4065
4140
|
};
|
|
4066
|
-
}, [client, isListening, orderIds]);
|
|
4141
|
+
}, [client, isListening, mode, orderIds]);
|
|
4067
4142
|
return { phase, submittedOrders, latestBalance, dagProgress, terminalOrderEvents };
|
|
4068
4143
|
}
|
|
4069
4144
|
|
|
@@ -4106,7 +4181,7 @@ var computeClosedPositionTotals = (group) => {
|
|
|
4106
4181
|
};
|
|
4107
4182
|
|
|
4108
4183
|
// src/execution/use-redeem.ts
|
|
4109
|
-
var
|
|
4184
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
4110
4185
|
var RedeemRejectedError = class extends Error {
|
|
4111
4186
|
constructor(message, response) {
|
|
4112
4187
|
super(message);
|
|
@@ -4117,8 +4192,8 @@ var RedeemRejectedError = class extends Error {
|
|
|
4117
4192
|
var isLegRejected = (status) => status === "ineligible" || status === "rejected";
|
|
4118
4193
|
var useRedeem = () => {
|
|
4119
4194
|
const client = useAggClient();
|
|
4120
|
-
const queryClient = (0,
|
|
4121
|
-
return (0,
|
|
4195
|
+
const queryClient = (0, import_react_query14.useQueryClient)();
|
|
4196
|
+
return (0, import_react_query14.useMutation)({
|
|
4122
4197
|
mutationFn: (body) => __async(null, null, function* () {
|
|
4123
4198
|
const response = yield client.redeem(body);
|
|
4124
4199
|
if (response.results.length > 0 && response.results.every((r) => isLegRejected(r.status))) {
|
|
@@ -4128,10 +4203,8 @@ var useRedeem = () => {
|
|
|
4128
4203
|
}
|
|
4129
4204
|
return response;
|
|
4130
4205
|
}),
|
|
4131
|
-
|
|
4132
|
-
queryClient
|
|
4133
|
-
queryClient.invalidateQueries({ queryKey: executionKeys.balances() });
|
|
4134
|
-
queryClient.invalidateQueries({ queryKey: executionKeys.claimableClosedPositionsCount() });
|
|
4206
|
+
onSettled: () => {
|
|
4207
|
+
invalidateUserClaimState(queryClient);
|
|
4135
4208
|
}
|
|
4136
4209
|
});
|
|
4137
4210
|
};
|
|
@@ -4142,15 +4215,15 @@ var useOnRedeemEvent2 = (listener) => {
|
|
|
4142
4215
|
};
|
|
4143
4216
|
|
|
4144
4217
|
// src/execution/use-redeem-eligible-count.ts
|
|
4145
|
-
var
|
|
4218
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
4146
4219
|
var CLAIMABLE_COUNT_PAGE_LIMIT = 100;
|
|
4147
|
-
var
|
|
4220
|
+
var getClaimablePositionsCount = (client) => __async(null, null, function* () {
|
|
4148
4221
|
var _a;
|
|
4149
4222
|
let total = 0;
|
|
4150
4223
|
let cursor;
|
|
4151
4224
|
do {
|
|
4152
4225
|
const page = yield client.getExecutionPositions({
|
|
4153
|
-
status: "
|
|
4226
|
+
status: "active",
|
|
4154
4227
|
limit: CLAIMABLE_COUNT_PAGE_LIMIT,
|
|
4155
4228
|
cursor
|
|
4156
4229
|
});
|
|
@@ -4167,9 +4240,9 @@ var useRedeemEligibleCount = () => {
|
|
|
4167
4240
|
var _a;
|
|
4168
4241
|
const client = useAggClient();
|
|
4169
4242
|
const { isAuthenticated } = useAggAuthState();
|
|
4170
|
-
const query = (0,
|
|
4171
|
-
queryKey: executionKeys.
|
|
4172
|
-
queryFn: () =>
|
|
4243
|
+
const query = (0, import_react_query15.useQuery)({
|
|
4244
|
+
queryKey: executionKeys.claimablePositionsCount(),
|
|
4245
|
+
queryFn: () => getClaimablePositionsCount(client),
|
|
4173
4246
|
enabled: isAuthenticated,
|
|
4174
4247
|
staleTime: 3e4,
|
|
4175
4248
|
refetchInterval: isAuthenticated ? 45e3 : false
|
|
@@ -4618,7 +4691,7 @@ function useWithdrawEstimate({
|
|
|
4618
4691
|
|
|
4619
4692
|
// src/withdraw/use-withdrawal-lifecycle.ts
|
|
4620
4693
|
var import_react15 = require("react");
|
|
4621
|
-
var
|
|
4694
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
4622
4695
|
var INITIAL_STATE2 = {
|
|
4623
4696
|
pending: true,
|
|
4624
4697
|
status: null,
|
|
@@ -4673,7 +4746,7 @@ var restToLifecycleState = (response) => {
|
|
|
4673
4746
|
function useWithdrawalLifecycle(withdrawalId) {
|
|
4674
4747
|
const client = useAggClient();
|
|
4675
4748
|
const wsConnected = useAggWebSocketConnectionState();
|
|
4676
|
-
const queryClient = (0,
|
|
4749
|
+
const queryClient = (0, import_react_query16.useQueryClient)();
|
|
4677
4750
|
const [state, setState] = (0, import_react15.useState)(INITIAL_STATE2);
|
|
4678
4751
|
const stateRef = (0, import_react15.useRef)(state);
|
|
4679
4752
|
stateRef.current = state;
|
|
@@ -4763,6 +4836,32 @@ function useGeoBlock() {
|
|
|
4763
4836
|
};
|
|
4764
4837
|
}
|
|
4765
4838
|
|
|
4839
|
+
// src/venue-availability.ts
|
|
4840
|
+
var normalizeVenueId = (venueId) => venueId.trim().toLowerCase();
|
|
4841
|
+
var getDisabledVenueSet = (disabledVenues) => {
|
|
4842
|
+
return new Set((disabledVenues != null ? disabledVenues : []).map(normalizeVenueId));
|
|
4843
|
+
};
|
|
4844
|
+
var isVenueDisabledByConfig = (venueId, disabledVenues) => {
|
|
4845
|
+
return getDisabledVenueSet(disabledVenues).has(normalizeVenueId(venueId));
|
|
4846
|
+
};
|
|
4847
|
+
var getVisibleVenuesByConfig = (venues, disabledVenues) => {
|
|
4848
|
+
const disabledVenueSet = getDisabledVenueSet(disabledVenues);
|
|
4849
|
+
return venues.filter((venue) => !disabledVenueSet.has(normalizeVenueId(venue.id)));
|
|
4850
|
+
};
|
|
4851
|
+
var getVisibleVenueIdsByConfig = (venueIds, disabledVenues) => {
|
|
4852
|
+
const disabledVenueSet = getDisabledVenueSet(disabledVenues);
|
|
4853
|
+
return venueIds.filter((venueId) => !disabledVenueSet.has(normalizeVenueId(venueId)));
|
|
4854
|
+
};
|
|
4855
|
+
var getVenueAvailabilityState = ({
|
|
4856
|
+
venueId,
|
|
4857
|
+
disabledVenues,
|
|
4858
|
+
isLocationBlocked
|
|
4859
|
+
}) => {
|
|
4860
|
+
if (isVenueDisabledByConfig(venueId, disabledVenues)) return "hidden";
|
|
4861
|
+
if (isLocationBlocked) return "geoblocked";
|
|
4862
|
+
return "available";
|
|
4863
|
+
};
|
|
4864
|
+
|
|
4766
4865
|
// src/use-agg-auth.ts
|
|
4767
4866
|
var import_react17 = require("react");
|
|
4768
4867
|
function useAggAuth(options = {}) {
|
|
@@ -4831,7 +4930,7 @@ var requestAggAuthChooserOpen = () => {
|
|
|
4831
4930
|
};
|
|
4832
4931
|
|
|
4833
4932
|
// src/use-categories.ts
|
|
4834
|
-
var
|
|
4933
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
4835
4934
|
function useCategories(options) {
|
|
4836
4935
|
var _a, _b, _c, _d, _e, _f;
|
|
4837
4936
|
const client = useAggClient();
|
|
@@ -4839,7 +4938,7 @@ function useCategories(options) {
|
|
|
4839
4938
|
const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
|
|
4840
4939
|
const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
|
|
4841
4940
|
const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
|
|
4842
|
-
const query = (0,
|
|
4941
|
+
const query = (0, import_react_query17.useInfiniteQuery)({
|
|
4843
4942
|
queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
|
|
4844
4943
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
4845
4944
|
const res = yield client.getCategories(__spreadValues({
|
|
@@ -4862,6 +4961,41 @@ function useCategories(options) {
|
|
|
4862
4961
|
hasNextPage
|
|
4863
4962
|
});
|
|
4864
4963
|
}
|
|
4964
|
+
function useCategoryChildren(options) {
|
|
4965
|
+
var _a, _b, _c, _d;
|
|
4966
|
+
const client = useAggClient();
|
|
4967
|
+
const queryKeyScope = (_a = options == null ? void 0 : options.queryKeyScope) != null ? _a : "category-children";
|
|
4968
|
+
const enabled = (_b = options == null ? void 0 : options.enabled) != null ? _b : true;
|
|
4969
|
+
const limit = (_c = options == null ? void 0 : options.limit) != null ? _c : 20;
|
|
4970
|
+
const parentIds = Array.from(
|
|
4971
|
+
new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
|
|
4972
|
+
);
|
|
4973
|
+
const queries = (0, import_react_query17.useQueries)({
|
|
4974
|
+
queries: parentIds.map((parentId) => ({
|
|
4975
|
+
queryKey: [queryKeyScope, "parent", parentId, limit],
|
|
4976
|
+
queryFn: () => __async(null, null, function* () {
|
|
4977
|
+
return client.getCategories({
|
|
4978
|
+
limit,
|
|
4979
|
+
cursor: void 0,
|
|
4980
|
+
parentId
|
|
4981
|
+
});
|
|
4982
|
+
}),
|
|
4983
|
+
enabled
|
|
4984
|
+
}))
|
|
4985
|
+
});
|
|
4986
|
+
const childrenByParentId = /* @__PURE__ */ new Map();
|
|
4987
|
+
queries.forEach((query, index) => {
|
|
4988
|
+
var _a2, _b2;
|
|
4989
|
+
const parentId = parentIds[index];
|
|
4990
|
+
if (!parentId) return;
|
|
4991
|
+
childrenByParentId.set(parentId, (_b2 = (_a2 = query.data) == null ? void 0 : _a2.data) != null ? _b2 : []);
|
|
4992
|
+
});
|
|
4993
|
+
return {
|
|
4994
|
+
queries,
|
|
4995
|
+
childrenByParentId,
|
|
4996
|
+
isLoading: queries.some((query) => query.isLoading)
|
|
4997
|
+
};
|
|
4998
|
+
}
|
|
4865
4999
|
|
|
4866
5000
|
// src/use-debounced-value.ts
|
|
4867
5001
|
var import_react19 = require("react");
|
|
@@ -4879,7 +5013,7 @@ function useDebouncedValue(value, delay) {
|
|
|
4879
5013
|
}
|
|
4880
5014
|
|
|
4881
5015
|
// src/use-execution-orders.ts
|
|
4882
|
-
var
|
|
5016
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
4883
5017
|
function useExecutionOrders(options = {}) {
|
|
4884
5018
|
var _a, _b;
|
|
4885
5019
|
const client = useAggClient();
|
|
@@ -4887,21 +5021,30 @@ function useExecutionOrders(options = {}) {
|
|
|
4887
5021
|
status,
|
|
4888
5022
|
orderId,
|
|
4889
5023
|
quoteId,
|
|
5024
|
+
mode,
|
|
4890
5025
|
limit = 50,
|
|
4891
5026
|
enabled = true,
|
|
4892
5027
|
refetchIntervalMs = false
|
|
4893
5028
|
} = options;
|
|
4894
|
-
const query = (0,
|
|
5029
|
+
const query = (0, import_react_query18.useInfiniteQuery)({
|
|
4895
5030
|
// quoteId + orderId are part of the cache key — different filters
|
|
4896
5031
|
// produce different result sets, so they have to vary the key.
|
|
4897
|
-
queryKey: [
|
|
4898
|
-
|
|
5032
|
+
queryKey: [
|
|
5033
|
+
"execution-orders",
|
|
5034
|
+
status != null ? status : "all",
|
|
5035
|
+
quoteId != null ? quoteId : null,
|
|
5036
|
+
orderId != null ? orderId : null,
|
|
5037
|
+
...mode ? [mode] : [],
|
|
5038
|
+
limit
|
|
5039
|
+
],
|
|
5040
|
+
queryFn: ({ pageParam }) => client.getExecutionOrders(__spreadProps(__spreadValues({
|
|
4899
5041
|
status,
|
|
4900
5042
|
orderId,
|
|
4901
|
-
quoteId
|
|
5043
|
+
quoteId
|
|
5044
|
+
}, mode ? { mode } : {}), {
|
|
4902
5045
|
limit,
|
|
4903
5046
|
cursor: pageParam
|
|
4904
|
-
}),
|
|
5047
|
+
})),
|
|
4905
5048
|
initialPageParam: void 0,
|
|
4906
5049
|
getNextPageParam: (lastPage) => {
|
|
4907
5050
|
var _a2;
|
|
@@ -4919,7 +5062,7 @@ function useExecutionOrders(options = {}) {
|
|
|
4919
5062
|
}
|
|
4920
5063
|
|
|
4921
5064
|
// src/use-user-activity.ts
|
|
4922
|
-
var
|
|
5065
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
4923
5066
|
var DEFAULT_PENDING_REFETCH_INTERVAL_MS = 15e3;
|
|
4924
5067
|
var PENDING_ACTIVITY_STATUSES = /* @__PURE__ */ new Set([
|
|
4925
5068
|
"pending",
|
|
@@ -4936,6 +5079,9 @@ var hasPendingActivity = (pages) => {
|
|
|
4936
5079
|
if (!pages) return false;
|
|
4937
5080
|
for (const page of pages) {
|
|
4938
5081
|
for (const item of page.data) {
|
|
5082
|
+
if (item.type === "redeem" && item.legs.length > 0 && item.legs.every((leg) => leg.status.toLowerCase() === "confirmed")) {
|
|
5083
|
+
continue;
|
|
5084
|
+
}
|
|
4939
5085
|
if (PENDING_ACTIVITY_STATUSES.has(item.status.toLowerCase())) return true;
|
|
4940
5086
|
}
|
|
4941
5087
|
}
|
|
@@ -4950,8 +5096,8 @@ function useUserActivity(options = {}) {
|
|
|
4950
5096
|
enabled = true,
|
|
4951
5097
|
pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
|
|
4952
5098
|
} = options;
|
|
4953
|
-
const query = (0,
|
|
4954
|
-
queryKey:
|
|
5099
|
+
const query = (0, import_react_query19.useInfiniteQuery)({
|
|
5100
|
+
queryKey: userActivityQueryKeys.feed(type, limit),
|
|
4955
5101
|
queryFn: ({ pageParam }) => client.getUserActivity({
|
|
4956
5102
|
type,
|
|
4957
5103
|
limit,
|
|
@@ -4967,7 +5113,7 @@ function useUserActivity(options = {}) {
|
|
|
4967
5113
|
// flight (typically after a deposit / withdraw cache invalidation).
|
|
4968
5114
|
// Without this the feed flashes to the skeleton mid-session, which
|
|
4969
5115
|
// is worse UX than briefly showing slightly-stale rows.
|
|
4970
|
-
placeholderData:
|
|
5116
|
+
placeholderData: import_react_query19.keepPreviousData,
|
|
4971
5117
|
refetchInterval: (q) => {
|
|
4972
5118
|
if (pendingRefetchIntervalMs === false) return false;
|
|
4973
5119
|
const data = q.state.data;
|
|
@@ -5012,18 +5158,19 @@ function useExternalId(options = {}) {
|
|
|
5012
5158
|
}
|
|
5013
5159
|
|
|
5014
5160
|
// src/use-execution-positions.ts
|
|
5015
|
-
var
|
|
5161
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
5016
5162
|
function useExecutionPositions(options = {}) {
|
|
5017
5163
|
var _a, _b;
|
|
5018
5164
|
const client = useAggClient();
|
|
5019
|
-
const { limit = 50, status, enabled = true } = options;
|
|
5020
|
-
const query = (0,
|
|
5021
|
-
queryKey: executionKeys.positions(null, limit, status != null ? status : null),
|
|
5022
|
-
queryFn: ({ pageParam }) => client.getExecutionPositions({
|
|
5165
|
+
const { limit = 50, status, mode, enabled = true } = options;
|
|
5166
|
+
const query = (0, import_react_query20.useInfiniteQuery)({
|
|
5167
|
+
queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
|
|
5168
|
+
queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
|
|
5023
5169
|
limit,
|
|
5024
|
-
status
|
|
5170
|
+
status
|
|
5171
|
+
}, mode ? { mode } : {}), {
|
|
5025
5172
|
cursor: pageParam
|
|
5026
|
-
}),
|
|
5173
|
+
})),
|
|
5027
5174
|
initialPageParam: void 0,
|
|
5028
5175
|
getNextPageParam: (lastPage) => {
|
|
5029
5176
|
var _a2;
|
|
@@ -5047,7 +5194,7 @@ var import_react23 = require("react");
|
|
|
5047
5194
|
var import_sdk3 = require("@agg-build/sdk");
|
|
5048
5195
|
|
|
5049
5196
|
// src/use-market-chart.ts
|
|
5050
|
-
var
|
|
5197
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
5051
5198
|
|
|
5052
5199
|
// src/market-data/subscription.ts
|
|
5053
5200
|
var import_react21 = require("react");
|
|
@@ -5132,7 +5279,7 @@ function useMarketChart(options) {
|
|
|
5132
5279
|
orderbook: true,
|
|
5133
5280
|
trades: true
|
|
5134
5281
|
});
|
|
5135
|
-
const queries = (0,
|
|
5282
|
+
const queries = (0, import_react_query21.useQueries)({
|
|
5136
5283
|
queries: outcomeIds.map((outcomeId) => ({
|
|
5137
5284
|
// Cache key is intentionally time-free. The rolling window's
|
|
5138
5285
|
// startTs/endTs advance on every bucket but the user expects the same
|
|
@@ -5167,7 +5314,7 @@ function useMarketChart(options) {
|
|
|
5167
5314
|
gcTime: 60 * 6e4,
|
|
5168
5315
|
refetchOnWindowFocus: false,
|
|
5169
5316
|
retry: 1,
|
|
5170
|
-
placeholderData:
|
|
5317
|
+
placeholderData: import_react_query21.keepPreviousData,
|
|
5171
5318
|
refetchInterval: refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false,
|
|
5172
5319
|
refetchIntervalInBackground: false
|
|
5173
5320
|
}))
|
|
@@ -5410,7 +5557,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
5410
5557
|
}
|
|
5411
5558
|
|
|
5412
5559
|
// src/use-live-market.ts
|
|
5413
|
-
var
|
|
5560
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
5414
5561
|
function outcomeOrderbookToState(response, marketId) {
|
|
5415
5562
|
var _a, _b, _c, _d;
|
|
5416
5563
|
const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
|
|
@@ -5460,7 +5607,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5460
5607
|
enabled: isLiveSubscriptionEnabled,
|
|
5461
5608
|
orderbook: true
|
|
5462
5609
|
});
|
|
5463
|
-
const query = (0,
|
|
5610
|
+
const query = (0, import_react_query22.useQuery)({
|
|
5464
5611
|
queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
|
|
5465
5612
|
queryFn: () => __async(null, null, function* () {
|
|
5466
5613
|
return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
|
|
@@ -5472,7 +5619,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5472
5619
|
isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
|
|
5473
5620
|
})
|
|
5474
5621
|
});
|
|
5475
|
-
const seedQuery = (0,
|
|
5622
|
+
const seedQuery = (0, import_react_query22.useQuery)({
|
|
5476
5623
|
queryKey: ["live-market-seed", canonicalMarketId],
|
|
5477
5624
|
queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
|
|
5478
5625
|
enabled: Boolean(canonicalMarketId),
|
|
@@ -5493,7 +5640,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5493
5640
|
|
|
5494
5641
|
// src/use-live-outcome-prices.ts
|
|
5495
5642
|
var import_react26 = require("react");
|
|
5496
|
-
var
|
|
5643
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
5497
5644
|
var EMPTY_PRICES = /* @__PURE__ */ new Map();
|
|
5498
5645
|
var buildMidpointFingerprint = (outcomeIds, queries) => {
|
|
5499
5646
|
var _a, _b, _c;
|
|
@@ -5519,7 +5666,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
5519
5666
|
}
|
|
5520
5667
|
return [...ids].sort();
|
|
5521
5668
|
}, [venueMarkets]);
|
|
5522
|
-
const queries = (0,
|
|
5669
|
+
const queries = (0, import_react_query23.useQueries)({
|
|
5523
5670
|
queries: outcomeIds.map((id) => ({
|
|
5524
5671
|
queryKey: marketDataKeys.live(id),
|
|
5525
5672
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -5569,7 +5716,7 @@ function findLivePriceById(livePrices, id) {
|
|
|
5569
5716
|
|
|
5570
5717
|
// src/use-live-best-prices.ts
|
|
5571
5718
|
var import_react27 = require("react");
|
|
5572
|
-
var
|
|
5719
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
5573
5720
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
5574
5721
|
var extractOutcomeBestPrices = (state) => {
|
|
5575
5722
|
var _a, _b;
|
|
@@ -5611,7 +5758,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
5611
5758
|
}
|
|
5612
5759
|
return [...ids].sort();
|
|
5613
5760
|
}, [venueMarkets]);
|
|
5614
|
-
const queries = (0,
|
|
5761
|
+
const queries = (0, import_react_query24.useQueries)({
|
|
5615
5762
|
queries: outcomeIds.map((id) => ({
|
|
5616
5763
|
queryKey: marketDataKeys.live(id),
|
|
5617
5764
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -5705,7 +5852,7 @@ function useLiveTrades(canonicalMarketId) {
|
|
|
5705
5852
|
}
|
|
5706
5853
|
|
|
5707
5854
|
// src/use-midpoints.ts
|
|
5708
|
-
var
|
|
5855
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
5709
5856
|
var import_react28 = require("react");
|
|
5710
5857
|
var normalizeVenueMarketIds = (venueMarkets) => {
|
|
5711
5858
|
var _a;
|
|
@@ -5842,7 +5989,7 @@ function useMidpoints(venueMarkets) {
|
|
|
5842
5989
|
() => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
|
|
5843
5990
|
[venueMarkets]
|
|
5844
5991
|
);
|
|
5845
|
-
const { data, isLoading } = (0,
|
|
5992
|
+
const { data, isLoading } = (0, import_react_query25.useQuery)({
|
|
5846
5993
|
queryKey: ["midpoints", ids],
|
|
5847
5994
|
queryFn: () => client.getMidpoints(ids, { bestPrice: true }),
|
|
5848
5995
|
enabled: ids.length > 0,
|
|
@@ -5998,10 +6145,10 @@ var useRollingChartWindow = (options) => {
|
|
|
5998
6145
|
};
|
|
5999
6146
|
|
|
6000
6147
|
// src/use-market-orderbook.ts
|
|
6001
|
-
var
|
|
6148
|
+
var import_react_query26 = require("@tanstack/react-query");
|
|
6002
6149
|
function useMarketOrderbook(options) {
|
|
6003
6150
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
6004
|
-
const queryClient = (0,
|
|
6151
|
+
const queryClient = (0, import_react_query26.useQueryClient)();
|
|
6005
6152
|
const ws = useAggWebSocket();
|
|
6006
6153
|
const isConnected = useAggWebSocketConnectionState();
|
|
6007
6154
|
const {
|
|
@@ -6018,7 +6165,7 @@ function useMarketOrderbook(options) {
|
|
|
6018
6165
|
enabled: enabled && !!selectedOutcomeId,
|
|
6019
6166
|
orderbook: true
|
|
6020
6167
|
});
|
|
6021
|
-
const liveQueries = (0,
|
|
6168
|
+
const liveQueries = (0, import_react_query26.useQueries)({
|
|
6022
6169
|
queries: subscriptionIds.map((subscriptionId) => ({
|
|
6023
6170
|
queryKey: marketDataKeys.live(subscriptionId),
|
|
6024
6171
|
queryFn: () => createMarketLiveState(subscriptionId),
|
|
@@ -6083,8 +6230,66 @@ function useMarketOrderbook(options) {
|
|
|
6083
6230
|
};
|
|
6084
6231
|
}
|
|
6085
6232
|
|
|
6233
|
+
// src/use-arb.ts
|
|
6234
|
+
var import_react31 = require("react");
|
|
6235
|
+
function useMarketArb(marketId) {
|
|
6236
|
+
const ws = useAggWebSocket();
|
|
6237
|
+
const [state, setState] = (0, import_react31.useState)({ arbReturn: null, isLive: false });
|
|
6238
|
+
(0, import_react31.useEffect)(() => {
|
|
6239
|
+
if (!ws || !marketId) return;
|
|
6240
|
+
const cached = ws.getArb(marketId);
|
|
6241
|
+
if (cached != null) {
|
|
6242
|
+
setState({ arbReturn: cached.arbReturn, isLive: true });
|
|
6243
|
+
}
|
|
6244
|
+
const off = ws.subscribeArb(marketId, (msg) => {
|
|
6245
|
+
setState({ arbReturn: msg.arbReturn, isLive: true });
|
|
6246
|
+
});
|
|
6247
|
+
return off;
|
|
6248
|
+
}, [ws, marketId]);
|
|
6249
|
+
return state;
|
|
6250
|
+
}
|
|
6251
|
+
var EMPTY_ARB_FEED = {
|
|
6252
|
+
byMarket: /* @__PURE__ */ new Map(),
|
|
6253
|
+
byEvent: /* @__PURE__ */ new Map()
|
|
6254
|
+
};
|
|
6255
|
+
function useArbFeed() {
|
|
6256
|
+
const ws = useAggWebSocket();
|
|
6257
|
+
const [state, setState] = (0, import_react31.useState)(EMPTY_ARB_FEED);
|
|
6258
|
+
const stateRef = (0, import_react31.useRef)(state);
|
|
6259
|
+
stateRef.current = state;
|
|
6260
|
+
(0, import_react31.useEffect)(() => {
|
|
6261
|
+
if (!ws) return;
|
|
6262
|
+
const off = ws.subscribeArbFeed((batch) => {
|
|
6263
|
+
setState((prev) => {
|
|
6264
|
+
const nextByMarket = new Map(prev.byMarket);
|
|
6265
|
+
for (const entry of batch.entries) {
|
|
6266
|
+
nextByMarket.set(entry.marketId, {
|
|
6267
|
+
arb: entry.arbReturn,
|
|
6268
|
+
eventId: entry.venueEventId
|
|
6269
|
+
});
|
|
6270
|
+
}
|
|
6271
|
+
const nextByEvent = /* @__PURE__ */ new Map();
|
|
6272
|
+
for (const { arb, eventId } of nextByMarket.values()) {
|
|
6273
|
+
if (eventId == null) continue;
|
|
6274
|
+
const current = nextByEvent.get(eventId);
|
|
6275
|
+
if (current == null || arb > current) {
|
|
6276
|
+
nextByEvent.set(eventId, arb);
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
return { byMarket: nextByMarket, byEvent: nextByEvent };
|
|
6280
|
+
});
|
|
6281
|
+
});
|
|
6282
|
+
return off;
|
|
6283
|
+
}, [ws]);
|
|
6284
|
+
const publicByMarket = /* @__PURE__ */ new Map();
|
|
6285
|
+
for (const [marketId, { arb }] of state.byMarket) {
|
|
6286
|
+
publicByMarket.set(marketId, arb);
|
|
6287
|
+
}
|
|
6288
|
+
return { byMarket: publicByMarket, byEvent: state.byEvent };
|
|
6289
|
+
}
|
|
6290
|
+
|
|
6086
6291
|
// src/use-order-book.ts
|
|
6087
|
-
var
|
|
6292
|
+
var import_react_query27 = require("@tanstack/react-query");
|
|
6088
6293
|
function useOrderBook(options) {
|
|
6089
6294
|
const client = useAggClient();
|
|
6090
6295
|
const { orderbooks, enabled = true, canonicalMarketId } = options;
|
|
@@ -6097,7 +6302,7 @@ function useOrderBook(options) {
|
|
|
6097
6302
|
venueMarketOutcomeId: outcome.id
|
|
6098
6303
|
})) : void 0
|
|
6099
6304
|
});
|
|
6100
|
-
const batchedResult = (0,
|
|
6305
|
+
const batchedResult = (0, import_react_query27.useQuery)({
|
|
6101
6306
|
queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
|
|
6102
6307
|
queryFn: ({ signal }) => client.getOrderbooks(
|
|
6103
6308
|
{
|
|
@@ -6110,7 +6315,7 @@ function useOrderBook(options) {
|
|
|
6110
6315
|
gcTime: 5 * 6e4,
|
|
6111
6316
|
refetchOnWindowFocus: false,
|
|
6112
6317
|
retry: 1,
|
|
6113
|
-
placeholderData:
|
|
6318
|
+
placeholderData: import_react_query27.keepPreviousData
|
|
6114
6319
|
});
|
|
6115
6320
|
const data = (() => {
|
|
6116
6321
|
var _a, _b;
|
|
@@ -6165,7 +6370,7 @@ function useOrderBook(options) {
|
|
|
6165
6370
|
}
|
|
6166
6371
|
|
|
6167
6372
|
// src/use-orderbook-quote.ts
|
|
6168
|
-
var
|
|
6373
|
+
var import_react_query28 = require("@tanstack/react-query");
|
|
6169
6374
|
var QUOTE_DEBOUNCE_MS = 300;
|
|
6170
6375
|
var createUnavailableOrderbookError = (message, code, retryable) => {
|
|
6171
6376
|
const error = new Error(message);
|
|
@@ -6227,7 +6432,7 @@ function useOrderbookQuote(options) {
|
|
|
6227
6432
|
const { marketId, side, size, enabled = true } = options;
|
|
6228
6433
|
const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
|
|
6229
6434
|
const shouldFetch = enabled && !!marketId && debouncedSize > 0;
|
|
6230
|
-
const query = (0,
|
|
6435
|
+
const query = (0, import_react_query28.useQuery)({
|
|
6231
6436
|
queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
|
|
6232
6437
|
queryFn: () => __async(null, null, function* () {
|
|
6233
6438
|
var _a2, _b, _c, _d;
|
|
@@ -6258,7 +6463,7 @@ function useOrderbookQuote(options) {
|
|
|
6258
6463
|
staleTime: 1e4,
|
|
6259
6464
|
gcTime: 5 * 6e4,
|
|
6260
6465
|
retry: 1,
|
|
6261
|
-
placeholderData:
|
|
6466
|
+
placeholderData: import_react_query28.keepPreviousData
|
|
6262
6467
|
});
|
|
6263
6468
|
return {
|
|
6264
6469
|
data: (_a = query.data) != null ? _a : null,
|
|
@@ -6269,12 +6474,12 @@ function useOrderbookQuote(options) {
|
|
|
6269
6474
|
}
|
|
6270
6475
|
|
|
6271
6476
|
// src/use-orders.ts
|
|
6272
|
-
var
|
|
6477
|
+
var import_react_query29 = require("@tanstack/react-query");
|
|
6273
6478
|
function useOrders(options = {}) {
|
|
6274
6479
|
var _a, _b, _c, _d;
|
|
6275
6480
|
const client = useAggClient();
|
|
6276
6481
|
const { userId, status, limit = 50, offset = 0, enabled = true } = options;
|
|
6277
|
-
const query = (0,
|
|
6482
|
+
const query = (0, import_react_query29.useQuery)({
|
|
6278
6483
|
queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
|
|
6279
6484
|
queryFn: () => client.getOrders({
|
|
6280
6485
|
userId,
|
|
@@ -6291,16 +6496,16 @@ function useOrders(options = {}) {
|
|
|
6291
6496
|
}
|
|
6292
6497
|
|
|
6293
6498
|
// src/use-search.ts
|
|
6294
|
-
var
|
|
6295
|
-
var
|
|
6499
|
+
var import_react_query30 = require("@tanstack/react-query");
|
|
6500
|
+
var import_react32 = require("react");
|
|
6296
6501
|
function useSearch(options) {
|
|
6297
6502
|
var _a, _b, _c;
|
|
6298
|
-
const client = (0,
|
|
6299
|
-
const queryClient = (0,
|
|
6300
|
-
const [fallbackQueryClient] = (0,
|
|
6503
|
+
const client = (0, import_react32.useContext)(AggClientContext);
|
|
6504
|
+
const queryClient = (0, import_react32.useContext)(import_react_query30.QueryClientContext);
|
|
6505
|
+
const [fallbackQueryClient] = (0, import_react32.useState)(() => new import_react_query30.QueryClient());
|
|
6301
6506
|
const { q, type, categoryIds, limit = 20, enabled = true, deep = false } = options;
|
|
6302
6507
|
const isEnabled = enabled && q.length > 0;
|
|
6303
|
-
(0,
|
|
6508
|
+
(0, import_react32.useEffect)(() => {
|
|
6304
6509
|
if (queryClient) return void 0;
|
|
6305
6510
|
fallbackQueryClient.mount();
|
|
6306
6511
|
return () => {
|
|
@@ -6310,7 +6515,7 @@ function useSearch(options) {
|
|
|
6310
6515
|
if (isEnabled && !client) {
|
|
6311
6516
|
throw new Error("useSearch must be used within an <AggProvider>");
|
|
6312
6517
|
}
|
|
6313
|
-
const query = (0,
|
|
6518
|
+
const query = (0, import_react_query30.useInfiniteQuery)(
|
|
6314
6519
|
{
|
|
6315
6520
|
// deep is part of the key — TanStack treats deep vs light as
|
|
6316
6521
|
// independent queries so users can have both modes cached side-by-side.
|
|
@@ -6335,7 +6540,7 @@ function useSearch(options) {
|
|
|
6335
6540
|
if (!lastPage.hasMore) return void 0;
|
|
6336
6541
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
6337
6542
|
},
|
|
6338
|
-
placeholderData:
|
|
6543
|
+
placeholderData: import_react_query30.keepPreviousData,
|
|
6339
6544
|
enabled: isEnabled && !!client
|
|
6340
6545
|
},
|
|
6341
6546
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
@@ -6354,7 +6559,7 @@ function useSearch(options) {
|
|
|
6354
6559
|
}
|
|
6355
6560
|
|
|
6356
6561
|
// src/use-market-search.ts
|
|
6357
|
-
var
|
|
6562
|
+
var import_react33 = require("react");
|
|
6358
6563
|
function useMarketSearch(options) {
|
|
6359
6564
|
var _a;
|
|
6360
6565
|
const {
|
|
@@ -6365,8 +6570,8 @@ function useMarketSearch(options) {
|
|
|
6365
6570
|
enableSuggestions = true,
|
|
6366
6571
|
minLength = 1
|
|
6367
6572
|
} = options;
|
|
6368
|
-
const [query, setQueryState] = (0,
|
|
6369
|
-
const [submittedQuery, setSubmittedQuery] = (0,
|
|
6573
|
+
const [query, setQueryState] = (0, import_react33.useState)("");
|
|
6574
|
+
const [submittedQuery, setSubmittedQuery] = (0, import_react33.useState)(null);
|
|
6370
6575
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
6371
6576
|
const trimmedDebounced = debouncedQuery.trim();
|
|
6372
6577
|
const suggestionsEnabled = enableSuggestions && trimmedDebounced.length >= minLength;
|
|
@@ -6387,10 +6592,10 @@ function useMarketSearch(options) {
|
|
|
6387
6592
|
enabled: submittedQ.length > 0,
|
|
6388
6593
|
deep: true
|
|
6389
6594
|
});
|
|
6390
|
-
const setQuery = (0,
|
|
6595
|
+
const setQuery = (0, import_react33.useCallback)((value) => {
|
|
6391
6596
|
setQueryState(value);
|
|
6392
6597
|
}, []);
|
|
6393
|
-
const submit = (0,
|
|
6598
|
+
const submit = (0, import_react33.useCallback)(
|
|
6394
6599
|
(q) => {
|
|
6395
6600
|
const target = (q != null ? q : query).trim();
|
|
6396
6601
|
if (target.length === 0) return;
|
|
@@ -6398,7 +6603,7 @@ function useMarketSearch(options) {
|
|
|
6398
6603
|
},
|
|
6399
6604
|
[query]
|
|
6400
6605
|
);
|
|
6401
|
-
const clear = (0,
|
|
6606
|
+
const clear = (0, import_react33.useCallback)(() => {
|
|
6402
6607
|
setQueryState("");
|
|
6403
6608
|
setSubmittedQuery(null);
|
|
6404
6609
|
}, []);
|
|
@@ -6440,7 +6645,7 @@ function useMarketSearch(options) {
|
|
|
6440
6645
|
}
|
|
6441
6646
|
|
|
6442
6647
|
// src/use-smart-route.ts
|
|
6443
|
-
var
|
|
6648
|
+
var import_react_query31 = require("@tanstack/react-query");
|
|
6444
6649
|
var SMART_ROUTE_STALE_TIME_MS = 2e4;
|
|
6445
6650
|
function useSmartRoute(options) {
|
|
6446
6651
|
var _a, _b;
|
|
@@ -6451,6 +6656,7 @@ function useSmartRoute(options) {
|
|
|
6451
6656
|
outcomeId,
|
|
6452
6657
|
side,
|
|
6453
6658
|
tradeSide,
|
|
6659
|
+
mode,
|
|
6454
6660
|
maxSpend,
|
|
6455
6661
|
sellShares,
|
|
6456
6662
|
chainBalances,
|
|
@@ -6461,12 +6667,13 @@ function useSmartRoute(options) {
|
|
|
6461
6667
|
staleTimeMs = SMART_ROUTE_STALE_TIME_MS
|
|
6462
6668
|
} = options;
|
|
6463
6669
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
6464
|
-
const query = (0,
|
|
6670
|
+
const query = (0, import_react_query31.useQuery)({
|
|
6465
6671
|
queryKey: [
|
|
6466
6672
|
"smart-route",
|
|
6467
6673
|
resolvedVenueMarketOutcomeId,
|
|
6468
6674
|
side != null ? side : null,
|
|
6469
6675
|
tradeSide != null ? tradeSide : null,
|
|
6676
|
+
...mode ? [mode] : [],
|
|
6470
6677
|
maxSpend != null ? maxSpend : null,
|
|
6471
6678
|
sellShares != null ? sellShares : null,
|
|
6472
6679
|
chainBalances ? JSON.stringify(chainBalances) : null,
|
|
@@ -6476,17 +6683,18 @@ function useSmartRoute(options) {
|
|
|
6476
6683
|
],
|
|
6477
6684
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
6478
6685
|
return client.getSmartRoute(
|
|
6479
|
-
{
|
|
6686
|
+
__spreadProps(__spreadValues({
|
|
6480
6687
|
venueMarketOutcomeId: resolvedVenueMarketOutcomeId,
|
|
6481
6688
|
side: side != null ? side : void 0,
|
|
6482
|
-
tradeSide: tradeSide != null ? tradeSide : void 0
|
|
6689
|
+
tradeSide: tradeSide != null ? tradeSide : void 0
|
|
6690
|
+
}, mode ? { mode } : {}), {
|
|
6483
6691
|
maxSpend,
|
|
6484
6692
|
sellShares,
|
|
6485
6693
|
chainBalances,
|
|
6486
6694
|
slipCapBps,
|
|
6487
6695
|
compareVenues,
|
|
6488
6696
|
deepEstimate
|
|
6489
|
-
},
|
|
6697
|
+
}),
|
|
6490
6698
|
{ signal }
|
|
6491
6699
|
);
|
|
6492
6700
|
}),
|
|
@@ -6496,7 +6704,7 @@ function useSmartRoute(options) {
|
|
|
6496
6704
|
gcTime: 6e4,
|
|
6497
6705
|
refetchOnWindowFocus: false,
|
|
6498
6706
|
retry: 1,
|
|
6499
|
-
placeholderData:
|
|
6707
|
+
placeholderData: import_react_query31.keepPreviousData
|
|
6500
6708
|
});
|
|
6501
6709
|
const error = query.error;
|
|
6502
6710
|
return {
|
|
@@ -6509,12 +6717,12 @@ function useSmartRoute(options) {
|
|
|
6509
6717
|
}
|
|
6510
6718
|
|
|
6511
6719
|
// src/use-user-holdings.ts
|
|
6512
|
-
var
|
|
6720
|
+
var import_react_query32 = require("@tanstack/react-query");
|
|
6513
6721
|
function useUserHoldings(options) {
|
|
6514
6722
|
var _a, _b;
|
|
6515
6723
|
const client = useAggClient();
|
|
6516
6724
|
const { venue, venueMarketId, venueEventId, enabled = true } = options;
|
|
6517
|
-
const query = (0,
|
|
6725
|
+
const query = (0, import_react_query32.useInfiniteQuery)({
|
|
6518
6726
|
queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
|
|
6519
6727
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
6520
6728
|
return client.getUserHoldings({
|
|
@@ -6540,15 +6748,15 @@ function useUserHoldings(options) {
|
|
|
6540
6748
|
}
|
|
6541
6749
|
|
|
6542
6750
|
// src/use-enriched-venue-event.ts
|
|
6543
|
-
var
|
|
6751
|
+
var import_react35 = require("react");
|
|
6544
6752
|
|
|
6545
6753
|
// src/use-venue-event.ts
|
|
6546
|
-
var
|
|
6754
|
+
var import_react_query33 = require("@tanstack/react-query");
|
|
6547
6755
|
function useVenueEvent(options) {
|
|
6548
6756
|
var _a;
|
|
6549
6757
|
const client = useAggClient();
|
|
6550
6758
|
const { eventId, enabled = true } = options;
|
|
6551
|
-
const query = (0,
|
|
6759
|
+
const query = (0, import_react_query33.useQuery)({
|
|
6552
6760
|
queryKey: ["venue-event", eventId],
|
|
6553
6761
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
6554
6762
|
return client.getVenueEventById(eventId, { signal });
|
|
@@ -6567,13 +6775,13 @@ function useVenueEvent(options) {
|
|
|
6567
6775
|
}
|
|
6568
6776
|
|
|
6569
6777
|
// src/use-venue-markets.ts
|
|
6570
|
-
var
|
|
6571
|
-
var
|
|
6778
|
+
var import_react_query34 = require("@tanstack/react-query");
|
|
6779
|
+
var import_react34 = require("react");
|
|
6572
6780
|
function useVenueMarkets(options) {
|
|
6573
6781
|
var _a, _b, _c, _d, _e;
|
|
6574
|
-
const client = (0,
|
|
6575
|
-
const queryClient = (0,
|
|
6576
|
-
const [fallbackQueryClient] = (0,
|
|
6782
|
+
const client = (0, import_react34.useContext)(AggClientContext);
|
|
6783
|
+
const queryClient = (0, import_react34.useContext)(import_react_query34.QueryClientContext);
|
|
6784
|
+
const [fallbackQueryClient] = (0, import_react34.useState)(() => new import_react_query34.QueryClient());
|
|
6577
6785
|
const venue = options == null ? void 0 : options.venue;
|
|
6578
6786
|
const venueEventId = options == null ? void 0 : options.venueEventId;
|
|
6579
6787
|
const search = options == null ? void 0 : options.search;
|
|
@@ -6584,7 +6792,7 @@ function useVenueMarkets(options) {
|
|
|
6584
6792
|
const limit = (_b = options == null ? void 0 : options.limit) != null ? _b : 20;
|
|
6585
6793
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
6586
6794
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
6587
|
-
(0,
|
|
6795
|
+
(0, import_react34.useEffect)(() => {
|
|
6588
6796
|
if (queryClient) return void 0;
|
|
6589
6797
|
fallbackQueryClient.mount();
|
|
6590
6798
|
return () => {
|
|
@@ -6594,7 +6802,7 @@ function useVenueMarkets(options) {
|
|
|
6594
6802
|
if (enabled && !client) {
|
|
6595
6803
|
throw new Error("useVenueMarkets must be used within an <AggProvider>");
|
|
6596
6804
|
}
|
|
6597
|
-
const query = (0,
|
|
6805
|
+
const query = (0, import_react_query34.useInfiniteQuery)(
|
|
6598
6806
|
{
|
|
6599
6807
|
queryKey: [
|
|
6600
6808
|
"venue-markets",
|
|
@@ -6664,7 +6872,7 @@ function useEnrichedVenueEvent(options) {
|
|
|
6664
6872
|
sortBy: "yesPrice",
|
|
6665
6873
|
sortDir: "desc"
|
|
6666
6874
|
});
|
|
6667
|
-
const enrichedEvent = (0,
|
|
6875
|
+
const enrichedEvent = (0, import_react35.useMemo)(() => {
|
|
6668
6876
|
if (!event) return void 0;
|
|
6669
6877
|
if (markets.length === 0) return event;
|
|
6670
6878
|
return mergeEventWithFullMarkets(event, markets);
|
|
@@ -6678,13 +6886,13 @@ function useEnrichedVenueEvent(options) {
|
|
|
6678
6886
|
}
|
|
6679
6887
|
|
|
6680
6888
|
// src/use-venue-events.ts
|
|
6681
|
-
var
|
|
6682
|
-
var
|
|
6889
|
+
var import_react_query35 = require("@tanstack/react-query");
|
|
6890
|
+
var import_react36 = require("react");
|
|
6683
6891
|
function useVenueEvents(options) {
|
|
6684
6892
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6685
|
-
const client = (0,
|
|
6686
|
-
const queryClient = (0,
|
|
6687
|
-
const [fallbackQueryClient] = (0,
|
|
6893
|
+
const client = (0, import_react36.useContext)(AggClientContext);
|
|
6894
|
+
const queryClient = (0, import_react36.useContext)(import_react_query35.QueryClientContext);
|
|
6895
|
+
const [fallbackQueryClient] = (0, import_react36.useState)(() => new import_react_query35.QueryClient());
|
|
6688
6896
|
const venues = options == null ? void 0 : options.venues;
|
|
6689
6897
|
const search = options == null ? void 0 : options.search;
|
|
6690
6898
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
@@ -6700,7 +6908,7 @@ function useVenueEvents(options) {
|
|
|
6700
6908
|
const maxYesPrice = options == null ? void 0 : options.maxYesPrice;
|
|
6701
6909
|
const endDateFrom = options == null ? void 0 : options.endDateFrom;
|
|
6702
6910
|
const initialPages = options == null ? void 0 : options.initialPages;
|
|
6703
|
-
(0,
|
|
6911
|
+
(0, import_react36.useEffect)(() => {
|
|
6704
6912
|
if (queryClient) return void 0;
|
|
6705
6913
|
fallbackQueryClient.mount();
|
|
6706
6914
|
return () => {
|
|
@@ -6710,7 +6918,7 @@ function useVenueEvents(options) {
|
|
|
6710
6918
|
if (enabled && !client) {
|
|
6711
6919
|
throw new Error("useVenueEvents must be used within an <AggProvider>");
|
|
6712
6920
|
}
|
|
6713
|
-
const query = (0,
|
|
6921
|
+
const query = (0, import_react_query35.useInfiniteQuery)(
|
|
6714
6922
|
{
|
|
6715
6923
|
queryKey: [
|
|
6716
6924
|
queryKeyScope,
|
|
@@ -6755,13 +6963,13 @@ function useVenueEvents(options) {
|
|
|
6755
6963
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
6756
6964
|
},
|
|
6757
6965
|
// TODO: RMIK - Comment out to show skeletons on category switch
|
|
6758
|
-
placeholderData:
|
|
6966
|
+
placeholderData: import_react_query35.keepPreviousData,
|
|
6759
6967
|
enabled: enabled && !!client
|
|
6760
6968
|
},
|
|
6761
6969
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
6762
6970
|
);
|
|
6763
|
-
const prefetchedRef = (0,
|
|
6764
|
-
(0,
|
|
6971
|
+
const prefetchedRef = (0, import_react36.useRef)(false);
|
|
6972
|
+
(0, import_react36.useEffect)(() => {
|
|
6765
6973
|
var _a2, _b2;
|
|
6766
6974
|
if (prefetchedRef.current) return;
|
|
6767
6975
|
if (!initialPages || initialPages <= 1) return;
|
|
@@ -6779,7 +6987,7 @@ function useVenueEvents(options) {
|
|
|
6779
6987
|
query.hasNextPage,
|
|
6780
6988
|
query.fetchNextPage
|
|
6781
6989
|
]);
|
|
6782
|
-
const events = (0,
|
|
6990
|
+
const events = (0, import_react36.useMemo)(
|
|
6783
6991
|
() => {
|
|
6784
6992
|
var _a2, _b2;
|
|
6785
6993
|
return (_b2 = (_a2 = query.data) == null ? void 0 : _a2.pages.flatMap((page) => page.data)) != null ? _b2 : [];
|
|
@@ -6797,7 +7005,7 @@ function useVenueEvents(options) {
|
|
|
6797
7005
|
}
|
|
6798
7006
|
|
|
6799
7007
|
// src/use-venue-market-midpoints.ts
|
|
6800
|
-
var
|
|
7008
|
+
var import_react_query36 = require("@tanstack/react-query");
|
|
6801
7009
|
var MAX_VENUE_MARKET_IDS_PER_REQUEST = 200;
|
|
6802
7010
|
var normalizeVenueMarketIds2 = (venueMarketIds) => {
|
|
6803
7011
|
return [
|
|
@@ -6833,7 +7041,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
6833
7041
|
const client = useAggClient();
|
|
6834
7042
|
const enabled = (_a = options.enabled) != null ? _a : true;
|
|
6835
7043
|
const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
|
|
6836
|
-
const query = (0,
|
|
7044
|
+
const query = (0, import_react_query36.useQuery)({
|
|
6837
7045
|
queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds] : ["venue-market-midpoints", "__disabled__"],
|
|
6838
7046
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
6839
7047
|
const venueMarketIdChunks = chunkVenueMarketIds(requestedVenueMarketIds);
|
|
@@ -6852,7 +7060,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
6852
7060
|
gcTime: 5 * 6e4,
|
|
6853
7061
|
refetchOnWindowFocus: false,
|
|
6854
7062
|
retry: 1,
|
|
6855
|
-
placeholderData:
|
|
7063
|
+
placeholderData: import_react_query36.keepPreviousData
|
|
6856
7064
|
});
|
|
6857
7065
|
const midpointRows = (_c = (_b = query.data) == null ? void 0 : _b.data) != null ? _c : [];
|
|
6858
7066
|
const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
|
|
@@ -6865,29 +7073,52 @@ function useVenueMarketMidpoints(options) {
|
|
|
6865
7073
|
|
|
6866
7074
|
// src/utils/compute-price-gaps.ts
|
|
6867
7075
|
var MIN_PRICE_GAP_PCT = 3;
|
|
6868
|
-
|
|
7076
|
+
var MAX_PRICE_GAP_PCT = 50;
|
|
7077
|
+
var normalizeMidpoint = (value) => {
|
|
7078
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
7079
|
+
if (value <= 0) return void 0;
|
|
7080
|
+
if (value > 1) return void 0;
|
|
7081
|
+
return value;
|
|
7082
|
+
};
|
|
7083
|
+
var collectMarketMidpoints = (market, midpointsByVenueMarketId) => {
|
|
6869
7084
|
var _a;
|
|
6870
|
-
const
|
|
6871
|
-
const
|
|
7085
|
+
const midpoints = [];
|
|
7086
|
+
const marketMidpoint = normalizeMidpoint(midpointsByVenueMarketId.get(market.id));
|
|
7087
|
+
if (marketMidpoint != null) {
|
|
7088
|
+
midpoints.push(marketMidpoint);
|
|
7089
|
+
}
|
|
7090
|
+
for (const matchedMarket of (_a = market.matchedVenueMarkets) != null ? _a : []) {
|
|
7091
|
+
const matchedMidpoint = normalizeMidpoint(midpointsByVenueMarketId.get(matchedMarket.id));
|
|
7092
|
+
if (matchedMidpoint == null) continue;
|
|
7093
|
+
midpoints.push(matchedMidpoint);
|
|
7094
|
+
}
|
|
7095
|
+
return midpoints;
|
|
7096
|
+
};
|
|
7097
|
+
var computePriceGapPct = (midpoints) => {
|
|
7098
|
+
if (midpoints.length < 2) return void 0;
|
|
7099
|
+
const minMidpoint = Math.min(...midpoints);
|
|
7100
|
+
const maxMidpoint = Math.max(...midpoints);
|
|
7101
|
+
if (minMidpoint <= 0 || maxMidpoint <= minMidpoint) return void 0;
|
|
7102
|
+
const gapPct = (maxMidpoint - minMidpoint) * 100;
|
|
7103
|
+
if (gapPct < MIN_PRICE_GAP_PCT) return void 0;
|
|
7104
|
+
if (gapPct > MAX_PRICE_GAP_PCT) return void 0;
|
|
7105
|
+
return gapPct;
|
|
7106
|
+
};
|
|
7107
|
+
var computePriceGaps = ({
|
|
7108
|
+
markets,
|
|
7109
|
+
midpointsByVenueMarketId
|
|
7110
|
+
}) => {
|
|
7111
|
+
const gapsByVenueMarketId = /* @__PURE__ */ new Map();
|
|
6872
7112
|
for (const market of markets) {
|
|
6873
|
-
const
|
|
6874
|
-
if (
|
|
6875
|
-
|
|
6876
|
-
if (siblings.length === 0) continue;
|
|
6877
|
-
let maxGap = 0;
|
|
6878
|
-
for (const sibling of siblings) {
|
|
6879
|
-
const siblingMidpoint = midpointsByVenueMarketId.get(sibling.id);
|
|
6880
|
-
if (siblingMidpoint == null || siblingMidpoint <= 0) continue;
|
|
6881
|
-
const gap = Math.abs(ownMidpoint - siblingMidpoint) / ownMidpoint * 100;
|
|
6882
|
-
if (gap > maxGap) maxGap = gap;
|
|
6883
|
-
}
|
|
6884
|
-
if (maxGap >= MIN_PRICE_GAP_PCT) result.set(market.id, maxGap);
|
|
7113
|
+
const gapPct = computePriceGapPct(collectMarketMidpoints(market, midpointsByVenueMarketId));
|
|
7114
|
+
if (gapPct == null) continue;
|
|
7115
|
+
gapsByVenueMarketId.set(market.id, gapPct);
|
|
6885
7116
|
}
|
|
6886
|
-
return
|
|
6887
|
-
}
|
|
7117
|
+
return gapsByVenueMarketId;
|
|
7118
|
+
};
|
|
6888
7119
|
|
|
6889
7120
|
// src/use-viewport-midpoints.ts
|
|
6890
|
-
var
|
|
7121
|
+
var import_react37 = require("react");
|
|
6891
7122
|
var buildOutcomeMidpointMap = (outcomes) => {
|
|
6892
7123
|
const m = /* @__PURE__ */ new Map();
|
|
6893
7124
|
if (!outcomes) return m;
|
|
@@ -6935,15 +7166,15 @@ var buildCachedMidpointEntries = (requestedVenueMarketIds, rows) => {
|
|
|
6935
7166
|
};
|
|
6936
7167
|
function useViewportMidpoints(visibleMarkets) {
|
|
6937
7168
|
const client = useAggClient();
|
|
6938
|
-
const [cache, setCache] = (0,
|
|
6939
|
-
const inFlightRef = (0,
|
|
6940
|
-
const visibleRef = (0,
|
|
7169
|
+
const [cache, setCache] = (0, import_react37.useState)(() => /* @__PURE__ */ new Map());
|
|
7170
|
+
const inFlightRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
|
|
7171
|
+
const visibleRef = (0, import_react37.useRef)(visibleMarkets);
|
|
6941
7172
|
visibleRef.current = visibleMarkets;
|
|
6942
|
-
const visibleFp = (0,
|
|
7173
|
+
const visibleFp = (0, import_react37.useMemo)(
|
|
6943
7174
|
() => [...new Set(visibleMarkets.map((m) => m.id))].sort().join("|"),
|
|
6944
7175
|
[visibleMarkets]
|
|
6945
7176
|
);
|
|
6946
|
-
(0,
|
|
7177
|
+
(0, import_react37.useEffect)(() => {
|
|
6947
7178
|
const toFetch = resolveUncachedVisibleMarketIds(visibleRef.current, cache, inFlightRef.current);
|
|
6948
7179
|
if (!toFetch.length) return;
|
|
6949
7180
|
let cancelled = false;
|
|
@@ -6967,7 +7198,7 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
6967
7198
|
cancelled = true;
|
|
6968
7199
|
};
|
|
6969
7200
|
}, [visibleFp, cache]);
|
|
6970
|
-
const { prices, venueByOutcomeId } = (0,
|
|
7201
|
+
const { prices, venueByOutcomeId } = (0, import_react37.useMemo)(() => {
|
|
6971
7202
|
var _a, _b, _c, _d;
|
|
6972
7203
|
const map = /* @__PURE__ */ new Map();
|
|
6973
7204
|
const venueMap = /* @__PURE__ */ new Map();
|
|
@@ -7000,15 +7231,15 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
7000
7231
|
}
|
|
7001
7232
|
|
|
7002
7233
|
// src/use-visible-ids.ts
|
|
7003
|
-
var
|
|
7234
|
+
var import_react38 = require("react");
|
|
7004
7235
|
function useVisibleIds(options = {}) {
|
|
7005
7236
|
const { rootMargin = "0px", threshold = 0 } = options;
|
|
7006
|
-
const [visibleIds, setVisibleIds] = (0,
|
|
7007
|
-
const observerRef = (0,
|
|
7008
|
-
const elementsRef = (0,
|
|
7009
|
-
const elementIdRef = (0,
|
|
7010
|
-
const callbackRefsRef = (0,
|
|
7011
|
-
(0,
|
|
7237
|
+
const [visibleIds, setVisibleIds] = (0, import_react38.useState)(() => /* @__PURE__ */ new Set());
|
|
7238
|
+
const observerRef = (0, import_react38.useRef)(null);
|
|
7239
|
+
const elementsRef = (0, import_react38.useRef)(/* @__PURE__ */ new Map());
|
|
7240
|
+
const elementIdRef = (0, import_react38.useRef)(/* @__PURE__ */ new WeakMap());
|
|
7241
|
+
const callbackRefsRef = (0, import_react38.useRef)(/* @__PURE__ */ new Map());
|
|
7242
|
+
(0, import_react38.useEffect)(() => {
|
|
7012
7243
|
if (typeof IntersectionObserver === "undefined") return;
|
|
7013
7244
|
const observer = new IntersectionObserver(
|
|
7014
7245
|
(entries) => {
|
|
@@ -7040,7 +7271,7 @@ function useVisibleIds(options = {}) {
|
|
|
7040
7271
|
observerRef.current = null;
|
|
7041
7272
|
};
|
|
7042
7273
|
}, [rootMargin, threshold]);
|
|
7043
|
-
const register = (0,
|
|
7274
|
+
const register = (0, import_react38.useCallback)((id) => {
|
|
7044
7275
|
const existing = callbackRefsRef.current.get(id);
|
|
7045
7276
|
if (existing) return existing;
|
|
7046
7277
|
const callback = (el) => {
|
|
@@ -7073,16 +7304,38 @@ function useVisibleIds(options = {}) {
|
|
|
7073
7304
|
}
|
|
7074
7305
|
|
|
7075
7306
|
// src/use-app-config.ts
|
|
7076
|
-
var
|
|
7307
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
7077
7308
|
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
7309
|
+
var APP_CONFIG_QUERY_KEY = ["agg", "app-config"];
|
|
7078
7310
|
function useAppConfig() {
|
|
7079
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7080
7311
|
const client = useAggClient();
|
|
7081
|
-
const query = (0,
|
|
7082
|
-
queryKey:
|
|
7312
|
+
const query = (0, import_react_query37.useQuery)({
|
|
7313
|
+
queryKey: APP_CONFIG_QUERY_KEY,
|
|
7083
7314
|
queryFn: () => client.getAppConfig(),
|
|
7084
7315
|
staleTime: FIVE_MINUTES
|
|
7085
7316
|
});
|
|
7317
|
+
return toAppConfigResult({
|
|
7318
|
+
data: query.data,
|
|
7319
|
+
isLoading: query.isLoading,
|
|
7320
|
+
error: query.error
|
|
7321
|
+
});
|
|
7322
|
+
}
|
|
7323
|
+
function useCachedAppConfig() {
|
|
7324
|
+
const queryClient = (0, import_react_query37.useQueryClient)();
|
|
7325
|
+
const query = (0, import_react_query37.useQuery)({
|
|
7326
|
+
queryKey: APP_CONFIG_QUERY_KEY,
|
|
7327
|
+
enabled: false,
|
|
7328
|
+
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
7329
|
+
staleTime: FIVE_MINUTES
|
|
7330
|
+
});
|
|
7331
|
+
return toAppConfigResult({
|
|
7332
|
+
data: query.data,
|
|
7333
|
+
isLoading: query.isLoading,
|
|
7334
|
+
error: query.error
|
|
7335
|
+
});
|
|
7336
|
+
}
|
|
7337
|
+
var toAppConfigResult = (query) => {
|
|
7338
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7086
7339
|
return {
|
|
7087
7340
|
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
7088
7341
|
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
@@ -7091,7 +7344,7 @@ function useAppConfig() {
|
|
|
7091
7344
|
isLoading: query.isLoading,
|
|
7092
7345
|
error: query.error
|
|
7093
7346
|
};
|
|
7094
|
-
}
|
|
7347
|
+
};
|
|
7095
7348
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7096
7349
|
0 && (module.exports = {
|
|
7097
7350
|
AUTH_CHOOSER_OPEN_EVENT,
|
|
@@ -7103,6 +7356,8 @@ function useAppConfig() {
|
|
|
7103
7356
|
CONFIRMED_MATCH_STATUSES,
|
|
7104
7357
|
DEFAULT_AGG_ROOT_CLASS_NAME,
|
|
7105
7358
|
EventListStateProvider,
|
|
7359
|
+
MAX_PRICE_GAP_PCT,
|
|
7360
|
+
MIN_PRICE_GAP_PCT,
|
|
7106
7361
|
MarketStatus,
|
|
7107
7362
|
MatchStatus,
|
|
7108
7363
|
MatchType,
|
|
@@ -7121,12 +7376,18 @@ function useAppConfig() {
|
|
|
7121
7376
|
getBuilder,
|
|
7122
7377
|
getDepositAddress,
|
|
7123
7378
|
getOrCreateBuilder,
|
|
7379
|
+
getVenueAvailabilityState,
|
|
7380
|
+
getVisibleVenueIdsByConfig,
|
|
7381
|
+
getVisibleVenuesByConfig,
|
|
7124
7382
|
getWalletAddressFromUserProfile,
|
|
7125
7383
|
invalidateBalanceQueries,
|
|
7126
7384
|
invalidatePositionQueries,
|
|
7127
7385
|
invalidateUserActivityQueries,
|
|
7386
|
+
invalidateUserClaimState,
|
|
7128
7387
|
invalidateUserMoneyState,
|
|
7388
|
+
isVenueDisabledByConfig,
|
|
7129
7389
|
mergeBestPricesPreferringLive,
|
|
7390
|
+
normalizeVenueId,
|
|
7130
7391
|
optimizedImageUrl,
|
|
7131
7392
|
parseEmail,
|
|
7132
7393
|
parseEmailStrict,
|
|
@@ -7154,7 +7415,10 @@ function useAppConfig() {
|
|
|
7154
7415
|
useAggUiConfig,
|
|
7155
7416
|
useAggWebSocket,
|
|
7156
7417
|
useAppConfig,
|
|
7418
|
+
useArbFeed,
|
|
7419
|
+
useCachedAppConfig,
|
|
7157
7420
|
useCategories,
|
|
7421
|
+
useCategoryChildren,
|
|
7158
7422
|
useDebouncedValue,
|
|
7159
7423
|
useDepositAddresses,
|
|
7160
7424
|
useEnrichedVenueEvent,
|
|
@@ -7177,6 +7441,7 @@ function useAppConfig() {
|
|
|
7177
7441
|
useLiveOutcomePrices,
|
|
7178
7442
|
useLiveTrades,
|
|
7179
7443
|
useManagedBalances,
|
|
7444
|
+
useMarketArb,
|
|
7180
7445
|
useMarketChart,
|
|
7181
7446
|
useMarketOrderbook,
|
|
7182
7447
|
useMarketSearch,
|