@agg-build/hooks 2.0.0 → 2.1.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/README.md +1 -1
- package/dist/{chunk-OBHXWQ6L.mjs → chunk-5P53A3NQ.mjs} +88 -27
- package/dist/{chunk-KXO3JOXF.mjs → chunk-AFZD3GIQ.mjs} +1 -1
- package/dist/{chunk-VLYLQSDD.mjs → chunk-FYEPQHKO.mjs} +42 -14
- package/dist/deposit.d.mts +5 -1
- package/dist/deposit.d.ts +5 -1
- package/dist/deposit.js +245 -181
- package/dist/deposit.mjs +176 -131
- package/dist/index.d.mts +50 -4
- package/dist/index.d.ts +50 -4
- package/dist/index.js +236 -141
- package/dist/index.mjs +48 -40
- package/dist/withdraw.d.mts +31 -2
- package/dist/withdraw.d.ts +31 -2
- package/dist/withdraw.js +106 -28
- package/dist/withdraw.mjs +4 -2
- package/package.json +2 -2
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: () =>
|
|
88
|
-
QueryClientProvider: () =>
|
|
87
|
+
QueryClient: () => import_react_query39.QueryClient,
|
|
88
|
+
QueryClientProvider: () => import_react_query39.QueryClientProvider,
|
|
89
89
|
RedeemRejectedError: () => RedeemRejectedError,
|
|
90
90
|
TradeSide: () => TradeSide,
|
|
91
91
|
TurnstileChallengeError: () => import_sdk4.TurnstileChallengeError,
|
|
@@ -179,7 +179,7 @@ __export(src_exports, {
|
|
|
179
179
|
useOrderbookQuote: () => useOrderbookQuote,
|
|
180
180
|
useOrders: () => useOrders,
|
|
181
181
|
usePositions: () => usePositions,
|
|
182
|
-
useQueryClient: () =>
|
|
182
|
+
useQueryClient: () => import_react_query39.useQueryClient,
|
|
183
183
|
useQuoteManaged: () => useQuoteManaged,
|
|
184
184
|
useRampQuotes: () => useRampQuotes,
|
|
185
185
|
useRampSession: () => useRampSession,
|
|
@@ -205,6 +205,7 @@ __export(src_exports, {
|
|
|
205
205
|
useWithdrawEstimate: () => useWithdrawEstimate,
|
|
206
206
|
useWithdrawFlow: () => useWithdrawFlow,
|
|
207
207
|
useWithdrawManaged: () => useWithdrawManaged,
|
|
208
|
+
useWithdrawPreview: () => useWithdrawPreview,
|
|
208
209
|
useWithdrawalLifecycle: () => useWithdrawalLifecycle,
|
|
209
210
|
userActivityQueryKeys: () => userActivityQueryKeys
|
|
210
211
|
});
|
|
@@ -332,7 +333,7 @@ var getVenueOrder = (venue) => {
|
|
|
332
333
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
333
334
|
|
|
334
335
|
// src/index.ts
|
|
335
|
-
var
|
|
336
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
336
337
|
|
|
337
338
|
// src/candle-store.ts
|
|
338
339
|
var import_sdk = require("@agg-build/sdk");
|
|
@@ -534,6 +535,8 @@ var enUsLabels = {
|
|
|
534
535
|
errorPrefix: "Error",
|
|
535
536
|
tabsAria: "Tabs",
|
|
536
537
|
hiddenTabsAria: "Hidden tabs",
|
|
538
|
+
scrollTabsLeft: "Scroll tabs left",
|
|
539
|
+
scrollTabsRight: "Scroll tabs right",
|
|
537
540
|
selectAria: "Select",
|
|
538
541
|
lineChartAria: "Line chart",
|
|
539
542
|
candlestickChartAria: "Candlestick chart",
|
|
@@ -696,6 +699,7 @@ var enUsLabels = {
|
|
|
696
699
|
networkReserveTooltipLineTwo: "Any unused amount stays in your balance.",
|
|
697
700
|
youReceive: "You'll receive",
|
|
698
701
|
confirm: "Confirm withdrawal",
|
|
702
|
+
calculatingFees: "Calculating fees\u2026",
|
|
699
703
|
successTitle: "Withdrawal submitted",
|
|
700
704
|
successDescription: (tokenSymbol) => `Your ${tokenSymbol} withdrawal is being processed and will arrive shortly.`,
|
|
701
705
|
// Terminal-state copy. The success step swaps `successTitle` /
|
|
@@ -779,6 +783,13 @@ var enUsLabels = {
|
|
|
779
783
|
categoryTabsAria: "Home page category tabs"
|
|
780
784
|
},
|
|
781
785
|
userProfile: {
|
|
786
|
+
balance: {
|
|
787
|
+
availableBalance: "Available Balance",
|
|
788
|
+
balanceByNetwork: "Balance by network",
|
|
789
|
+
paperModeNetwork: "Paper",
|
|
790
|
+
paperModeWarning: "Paper mode is enabled. These are simulated funds for paper trading.",
|
|
791
|
+
networkTooltipDescription: "Funds are stored across networks. We handle routing automatically, but keeping funds on the right network enables faster trades and lower fees. When depositing, you can choose your preferred network."
|
|
792
|
+
},
|
|
782
793
|
activity: {
|
|
783
794
|
depositType: "Deposit",
|
|
784
795
|
redeemType: "Claim",
|
|
@@ -1110,6 +1121,9 @@ var enUsLabels = {
|
|
|
1110
1121
|
buyingOutcome: (label) => `Buying ${label}`,
|
|
1111
1122
|
sellingOutcome: (label) => `Selling ${label}`,
|
|
1112
1123
|
findingBestRoute: "Finding the best route...",
|
|
1124
|
+
findingBestOdds: "Finding best odds\u2026",
|
|
1125
|
+
updatingRoute: "Updating route\u2026",
|
|
1126
|
+
refreshingQuotes: "Refreshing quotes\u2026",
|
|
1113
1127
|
checkingBalance: "Checking balance",
|
|
1114
1128
|
submittingOrderProgress: "Submitting order...",
|
|
1115
1129
|
orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
|
|
@@ -1450,7 +1464,8 @@ var defaultAggUiConfig = {
|
|
|
1450
1464
|
enableNotifications: true
|
|
1451
1465
|
},
|
|
1452
1466
|
market: {
|
|
1453
|
-
arbitrageThreshold: 0
|
|
1467
|
+
arbitrageThreshold: 0,
|
|
1468
|
+
maxMidpointIdsPerRequest: 75
|
|
1454
1469
|
},
|
|
1455
1470
|
chart: {
|
|
1456
1471
|
defaultChartTimeRange: "1D",
|
|
@@ -1459,7 +1474,10 @@ var defaultAggUiConfig = {
|
|
|
1459
1474
|
}
|
|
1460
1475
|
},
|
|
1461
1476
|
formatting: defaultFormatters,
|
|
1462
|
-
search: defaultAggUiSearchConfig
|
|
1477
|
+
search: defaultAggUiSearchConfig,
|
|
1478
|
+
trading: {
|
|
1479
|
+
executionMode: "live"
|
|
1480
|
+
}
|
|
1463
1481
|
};
|
|
1464
1482
|
var mergeAggUiSearchConfig = (config) => {
|
|
1465
1483
|
var _a, _b, _c;
|
|
@@ -1474,7 +1492,7 @@ var mergeAggUiSearchConfig = (config) => {
|
|
|
1474
1492
|
};
|
|
1475
1493
|
};
|
|
1476
1494
|
var mergeAggUiConfig = (persisted, config) => {
|
|
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;
|
|
1495
|
+
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;
|
|
1478
1496
|
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;
|
|
1479
1497
|
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;
|
|
1480
1498
|
const formatters = createFormatters(locale);
|
|
@@ -1499,21 +1517,25 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1499
1517
|
enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications
|
|
1500
1518
|
},
|
|
1501
1519
|
market: {
|
|
1502
|
-
arbitrageThreshold: (_D = (_C = config == null ? void 0 : config.market) == null ? void 0 : _C.arbitrageThreshold) != null ? _D : defaultAggUiConfig.market.arbitrageThreshold
|
|
1520
|
+
arbitrageThreshold: (_D = (_C = config == null ? void 0 : config.market) == null ? void 0 : _C.arbitrageThreshold) != null ? _D : defaultAggUiConfig.market.arbitrageThreshold,
|
|
1521
|
+
maxMidpointIdsPerRequest: (_F = (_E = config == null ? void 0 : config.market) == null ? void 0 : _E.maxMidpointIdsPerRequest) != null ? _F : defaultAggUiConfig.market.maxMidpointIdsPerRequest
|
|
1503
1522
|
},
|
|
1504
1523
|
chart: {
|
|
1505
|
-
defaultChartTimeRange: (
|
|
1506
|
-
selectedChartTimeRange: (
|
|
1524
|
+
defaultChartTimeRange: (_H = (_G = config == null ? void 0 : config.chart) == null ? void 0 : _G.defaultChartTimeRange) != null ? _H : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1525
|
+
selectedChartTimeRange: (_L = (_K = (_I = persisted.chart) == null ? void 0 : _I.selectedChartTimeRange) != null ? _K : (_J = config == null ? void 0 : config.chart) == null ? void 0 : _J.defaultChartTimeRange) != null ? _L : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1507
1526
|
setSelectedChartTimeRange: defaultAggUiConfig.chart.setSelectedChartTimeRange
|
|
1508
1527
|
},
|
|
1509
1528
|
formatting: {
|
|
1510
|
-
formatNumber: (
|
|
1511
|
-
formatPercent: (
|
|
1512
|
-
formatCurrency: (
|
|
1513
|
-
formatCompactCurrency: (
|
|
1514
|
-
formatDate: (
|
|
1529
|
+
formatNumber: (_N = (_M = config == null ? void 0 : config.formatting) == null ? void 0 : _M.formatNumber) != null ? _N : formatters.formatNumber,
|
|
1530
|
+
formatPercent: (_P = (_O = config == null ? void 0 : config.formatting) == null ? void 0 : _O.formatPercent) != null ? _P : formatters.formatPercent,
|
|
1531
|
+
formatCurrency: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatCurrency) != null ? _R : formatters.formatCurrency,
|
|
1532
|
+
formatCompactCurrency: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatCompactCurrency) != null ? _T : formatters.formatCompactCurrency,
|
|
1533
|
+
formatDate: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatDate) != null ? _V : formatters.formatDate
|
|
1515
1534
|
},
|
|
1516
1535
|
search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
|
|
1536
|
+
trading: {
|
|
1537
|
+
executionMode: (_X = (_W = config == null ? void 0 : config.trading) == null ? void 0 : _W.executionMode) != null ? _X : defaultAggUiConfig.trading.executionMode
|
|
1538
|
+
},
|
|
1517
1539
|
walletActions: config == null ? void 0 : config.walletActions,
|
|
1518
1540
|
solanaRpcUrl: config == null ? void 0 : config.solanaRpcUrl
|
|
1519
1541
|
};
|
|
@@ -1788,7 +1810,7 @@ var balanceQueryKeys = {
|
|
|
1788
1810
|
execution: () => executionKeys.balances(),
|
|
1789
1811
|
// Kept as an alias for backward compatibility with existing callers.
|
|
1790
1812
|
// The balance provider now uses the same canonical execution balances key.
|
|
1791
|
-
provider: () => executionKeys.balances(),
|
|
1813
|
+
provider: (mode) => executionKeys.balances(mode),
|
|
1792
1814
|
venue: (venuesKey) => ["venue-balances", venuesKey],
|
|
1793
1815
|
venuePrefix: () => ["venue-balances"]
|
|
1794
1816
|
};
|
|
@@ -1862,6 +1884,7 @@ var invalidateUserClaimState = (queryClient, options) => {
|
|
|
1862
1884
|
// src/core/providers/balance-provider.tsx
|
|
1863
1885
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1864
1886
|
var CHAIN_LABELS = {
|
|
1887
|
+
0: "Paper",
|
|
1865
1888
|
1: "Ethereum",
|
|
1866
1889
|
10: "Optimism",
|
|
1867
1890
|
56: "BNB",
|
|
@@ -1893,17 +1916,23 @@ var EMPTY_MANAGED_BALANCES = {
|
|
|
1893
1916
|
function AggBalanceProvider({ children }) {
|
|
1894
1917
|
const client = (0, import_react3.useContext)(AggClientContext);
|
|
1895
1918
|
const authContext = (0, import_react3.useContext)(AggAuthContext);
|
|
1919
|
+
const {
|
|
1920
|
+
trading: { executionMode }
|
|
1921
|
+
} = (0, import_react3.useContext)(AggUiContext);
|
|
1896
1922
|
if (!authContext) {
|
|
1897
1923
|
throw new Error("AggBalanceProvider must be used within an <AggAuthProvider>");
|
|
1898
1924
|
}
|
|
1899
1925
|
const { isAuthenticated } = authContext;
|
|
1926
|
+
const queryExecutionMode = executionMode === "paper" ? "paper" : void 0;
|
|
1900
1927
|
const balancesQuery = (0, import_react_query2.useQuery)({
|
|
1901
|
-
queryKey: balanceQueryKeys.provider(),
|
|
1928
|
+
queryKey: balanceQueryKeys.provider(queryExecutionMode),
|
|
1902
1929
|
queryFn: () => __async(null, null, function* () {
|
|
1903
1930
|
if (!client || !isAuthenticated) {
|
|
1904
1931
|
return EMPTY_MANAGED_BALANCES;
|
|
1905
1932
|
}
|
|
1906
|
-
return client.getManagedBalances(
|
|
1933
|
+
return client.getManagedBalances(
|
|
1934
|
+
queryExecutionMode ? { mode: queryExecutionMode } : void 0
|
|
1935
|
+
);
|
|
1907
1936
|
}),
|
|
1908
1937
|
enabled: Boolean(client && isAuthenticated),
|
|
1909
1938
|
staleTime: 60 * 1e3,
|
|
@@ -4412,6 +4441,13 @@ var isValidDestinationAddress = (address, chainId) => {
|
|
|
4412
4441
|
if (chainId === SOLANA_CHAIN_ID) return SOLANA_ADDRESS_REGEX.test(address);
|
|
4413
4442
|
return EVM_ADDRESS_REGEX.test(address);
|
|
4414
4443
|
};
|
|
4444
|
+
var detectDestinationAddressKind = (address) => {
|
|
4445
|
+
const trimmed = address.trim();
|
|
4446
|
+
if (!trimmed) return null;
|
|
4447
|
+
if (EVM_ADDRESS_REGEX.test(trimmed)) return "evm";
|
|
4448
|
+
if (SOLANA_ADDRESS_REGEX.test(trimmed)) return "solana";
|
|
4449
|
+
return null;
|
|
4450
|
+
};
|
|
4415
4451
|
var DEFAULT_WITHDRAW_SUMMARY = {
|
|
4416
4452
|
amountReceived: "",
|
|
4417
4453
|
network: "",
|
|
@@ -4449,7 +4485,7 @@ var parseTokenAmountToRaw = (amount, decimals) => {
|
|
|
4449
4485
|
};
|
|
4450
4486
|
var shortenAddress = (address) => address.length > 12 ? `${address.slice(0, 6)}...${address.slice(-4)}` : address;
|
|
4451
4487
|
function useWithdrawFlow(options) {
|
|
4452
|
-
var _a, _b;
|
|
4488
|
+
var _a, _b, _c, _d, _e;
|
|
4453
4489
|
const { open, onOpenChange } = options;
|
|
4454
4490
|
const { totalBalance } = useAggBalanceState();
|
|
4455
4491
|
const { balances } = useManagedBalances({ enabled: open });
|
|
@@ -4470,31 +4506,42 @@ function useWithdrawFlow(options) {
|
|
|
4470
4506
|
const [withdrawNetwork, setWithdrawNetwork] = (0, import_react13.useState)("");
|
|
4471
4507
|
const [withdrawSummary, setWithdrawSummary] = (0, import_react13.useState)(DEFAULT_WITHDRAW_SUMMARY);
|
|
4472
4508
|
const [withdrawalId, setWithdrawalId] = (0, import_react13.useState)(null);
|
|
4509
|
+
const [isMax, setIsMax] = (0, import_react13.useState)(false);
|
|
4510
|
+
const detectedAddressKind = (0, import_react13.useMemo)(
|
|
4511
|
+
() => detectDestinationAddressKind(withdrawDestination),
|
|
4512
|
+
[withdrawDestination]
|
|
4513
|
+
);
|
|
4473
4514
|
const networkOptions = (0, import_react13.useMemo)(
|
|
4474
|
-
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) =>
|
|
4475
|
-
value
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4515
|
+
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) => {
|
|
4516
|
+
const value = String(chain.chainId);
|
|
4517
|
+
const isSolana = chain.chainId === SOLANA_CHAIN_ID;
|
|
4518
|
+
const disabled = detectedAddressKind === "solana" ? !isSolana : detectedAddressKind === "evm" ? isSolana : false;
|
|
4519
|
+
return { value, label: chain.name, disabled };
|
|
4520
|
+
}),
|
|
4521
|
+
[supportedChains, detectedAddressKind]
|
|
4479
4522
|
);
|
|
4480
|
-
const
|
|
4523
|
+
const firstEnabledNetwork = (_d = (_c = (_a = networkOptions.find((option) => !option.disabled)) == null ? void 0 : _a.value) != null ? _c : (_b = networkOptions[0]) == null ? void 0 : _b.value) != null ? _d : "";
|
|
4524
|
+
const isCurrentNetworkSelectable = networkOptions.some(
|
|
4525
|
+
(option) => option.value === withdrawNetwork && !option.disabled
|
|
4526
|
+
);
|
|
4527
|
+
const resolvedWithdrawNetwork = isCurrentNetworkSelectable ? withdrawNetwork : firstEnabledNetwork;
|
|
4481
4528
|
(0, import_react13.useEffect)(() => {
|
|
4482
4529
|
if (!networkOptions.length) return;
|
|
4483
|
-
if (!
|
|
4484
|
-
setWithdrawNetwork(
|
|
4530
|
+
if (!isCurrentNetworkSelectable && firstEnabledNetwork) {
|
|
4531
|
+
setWithdrawNetwork(firstEnabledNetwork);
|
|
4485
4532
|
}
|
|
4486
|
-
}, [networkOptions,
|
|
4533
|
+
}, [networkOptions, isCurrentNetworkSelectable, firstEnabledNetwork]);
|
|
4487
4534
|
const tokenOptions = (0, import_react13.useMemo)(() => {
|
|
4488
|
-
var _a2, _b2,
|
|
4535
|
+
var _a2, _b2, _c2;
|
|
4489
4536
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
4490
4537
|
const supportedTokensForNetwork = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens) != null ? _b2 : [];
|
|
4491
4538
|
const withdrawableSymbols = new Set(supportedTokensForNetwork.map((token) => token.symbol));
|
|
4492
|
-
return ((
|
|
4539
|
+
return ((_c2 = balances == null ? void 0 : balances.cash) != null ? _c2 : []).filter((cashEntry) => withdrawableSymbols.has(cashEntry.tokenSymbol)).map((cashEntry) => ({
|
|
4493
4540
|
value: cashEntry.tokenSymbol,
|
|
4494
4541
|
label: cashEntry.tokenSymbol
|
|
4495
4542
|
}));
|
|
4496
4543
|
}, [balances, resolvedWithdrawNetwork, supportedChains]);
|
|
4497
|
-
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((
|
|
4544
|
+
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((_e = tokenOptions[0]) == null ? void 0 : _e.value) || "";
|
|
4498
4545
|
(0, import_react13.useEffect)(() => {
|
|
4499
4546
|
if (!tokenOptions.length) return;
|
|
4500
4547
|
if (!tokenOptions.some((option) => option.value === withdrawToken)) {
|
|
@@ -4506,9 +4553,9 @@ function useWithdrawFlow(options) {
|
|
|
4506
4553
|
[balances, resolvedWithdrawToken]
|
|
4507
4554
|
);
|
|
4508
4555
|
const selectedTokenDecimals = (0, import_react13.useMemo)(() => {
|
|
4509
|
-
var _a2, _b2,
|
|
4556
|
+
var _a2, _b2, _c2, _d2;
|
|
4510
4557
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
4511
|
-
return (
|
|
4558
|
+
return (_d2 = (_c2 = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens.find((token) => token.symbol === resolvedWithdrawToken)) == null ? void 0 : _b2.decimals) != null ? _c2 : selectedCashEntry == null ? void 0 : selectedCashEntry.decimals) != null ? _d2 : 6;
|
|
4512
4559
|
}, [
|
|
4513
4560
|
resolvedWithdrawNetwork,
|
|
4514
4561
|
resolvedWithdrawToken,
|
|
@@ -4533,6 +4580,7 @@ function useWithdrawFlow(options) {
|
|
|
4533
4580
|
setWithdrawNetwork("");
|
|
4534
4581
|
setWithdrawSummary(DEFAULT_WITHDRAW_SUMMARY);
|
|
4535
4582
|
setWithdrawalId(null);
|
|
4583
|
+
setIsMax(false);
|
|
4536
4584
|
}, []);
|
|
4537
4585
|
const handleWithdrawOpenChange = (0, import_react13.useCallback)(
|
|
4538
4586
|
(isOpen) => {
|
|
@@ -4572,19 +4620,19 @@ function useWithdrawFlow(options) {
|
|
|
4572
4620
|
}
|
|
4573
4621
|
return scaleBy(native, selectedTokenDecimals - selectedCashEntry.decimals);
|
|
4574
4622
|
})();
|
|
4575
|
-
if (BigInt(amountRaw) > balanceInDestFrame) {
|
|
4623
|
+
if (!isMax && BigInt(amountRaw) > balanceInDestFrame) {
|
|
4576
4624
|
throw new Error("Withdrawal amount exceeds your available balance.");
|
|
4577
4625
|
}
|
|
4578
4626
|
}
|
|
4579
4627
|
ws == null ? void 0 : ws.connect();
|
|
4580
4628
|
yield new Promise((resolve, reject) => {
|
|
4581
4629
|
withdrawMutation.mutate(
|
|
4582
|
-
{
|
|
4630
|
+
__spreadValues({
|
|
4583
4631
|
amountRaw,
|
|
4584
4632
|
tokenSymbol: resolvedWithdrawToken,
|
|
4585
4633
|
destinationAddress: trimmedDestination,
|
|
4586
4634
|
destinationChainId
|
|
4587
|
-
},
|
|
4635
|
+
}, isMax ? { max: true } : {}),
|
|
4588
4636
|
{
|
|
4589
4637
|
onSuccess: (data) => {
|
|
4590
4638
|
setWithdrawalId(data.withdrawalId);
|
|
@@ -4601,6 +4649,7 @@ function useWithdrawFlow(options) {
|
|
|
4601
4649
|
fees: "\u2014"
|
|
4602
4650
|
});
|
|
4603
4651
|
}), [
|
|
4652
|
+
isMax,
|
|
4604
4653
|
resolvedWithdrawNetwork,
|
|
4605
4654
|
resolvedWithdrawToken,
|
|
4606
4655
|
selectedCashEntry,
|
|
@@ -4624,13 +4673,18 @@ function useWithdrawFlow(options) {
|
|
|
4624
4673
|
selectedToken: resolvedWithdrawToken,
|
|
4625
4674
|
selectedNetwork: resolvedWithdrawNetwork,
|
|
4626
4675
|
purchaseSummary: withdrawSummary,
|
|
4627
|
-
withdrawalId
|
|
4676
|
+
withdrawalId,
|
|
4677
|
+
isMax
|
|
4628
4678
|
},
|
|
4629
4679
|
onWithdrawDestinationChange: setWithdrawDestination,
|
|
4630
|
-
onWithdrawAmountChange:
|
|
4680
|
+
onWithdrawAmountChange: (0, import_react13.useCallback)((v) => {
|
|
4681
|
+
setIsMax(false);
|
|
4682
|
+
setWithdrawAmount(v);
|
|
4683
|
+
}, []),
|
|
4631
4684
|
onWithdrawTokenChange: setWithdrawToken,
|
|
4632
4685
|
onWithdrawNetworkChange: setWithdrawNetwork,
|
|
4633
4686
|
onMaxClick: (0, import_react13.useCallback)(() => {
|
|
4687
|
+
setIsMax(true);
|
|
4634
4688
|
setWithdrawAmount(exactBalance === "0" ? "0" : exactBalance);
|
|
4635
4689
|
}, [exactBalance]),
|
|
4636
4690
|
onSelectWithdrawProvider: (0, import_react13.useCallback)(
|
|
@@ -4697,6 +4751,7 @@ var INITIAL_STATE2 = {
|
|
|
4697
4751
|
status: null,
|
|
4698
4752
|
requestedAmountRaw: null,
|
|
4699
4753
|
completedAmountRaw: null,
|
|
4754
|
+
feeRaw: null,
|
|
4700
4755
|
terminal: false,
|
|
4701
4756
|
lastLeg: null,
|
|
4702
4757
|
legs: [],
|
|
@@ -4727,16 +4782,17 @@ var mergeLegs = (prev, snapshot, delta) => {
|
|
|
4727
4782
|
return next;
|
|
4728
4783
|
};
|
|
4729
4784
|
var restToLifecycleState = (response) => {
|
|
4730
|
-
var _a, _b;
|
|
4785
|
+
var _a, _b, _c;
|
|
4731
4786
|
return {
|
|
4732
4787
|
pending: false,
|
|
4733
4788
|
status: response.status,
|
|
4734
4789
|
requestedAmountRaw: response.requested.amountRaw,
|
|
4735
4790
|
completedAmountRaw: (_a = response.completedAmountRaw) != null ? _a : null,
|
|
4791
|
+
feeRaw: (_b = response.expected.feeRaw) != null ? _b : null,
|
|
4736
4792
|
terminal: response.status === "completed" || response.status === "partial" || response.status === "failed",
|
|
4737
4793
|
lastLeg: null,
|
|
4738
4794
|
legs: response.legs.map(restLegToWsLeg),
|
|
4739
|
-
errorMessage: (
|
|
4795
|
+
errorMessage: (_c = response.errorMessage) != null ? _c : null,
|
|
4740
4796
|
// No server timestamp on the REST response — we use 0 as "older than any
|
|
4741
4797
|
// WS timestamp" so a subsequent WS event always wins. Callers that read
|
|
4742
4798
|
// `timestamp` should treat 0/null interchangeably as "unset".
|
|
@@ -4778,14 +4834,15 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
4778
4834
|
return (msg) => {
|
|
4779
4835
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
4780
4836
|
setState((prev) => {
|
|
4781
|
-
var _a, _b, _c, _d;
|
|
4837
|
+
var _a, _b, _c, _d, _e;
|
|
4782
4838
|
return {
|
|
4783
4839
|
pending: false,
|
|
4784
4840
|
status: msg.status,
|
|
4785
4841
|
requestedAmountRaw: (_a = msg.requestedAmountRaw) != null ? _a : prev.requestedAmountRaw,
|
|
4786
4842
|
completedAmountRaw: (_b = msg.completedAmountRaw) != null ? _b : prev.completedAmountRaw,
|
|
4843
|
+
feeRaw: (_c = msg.feeRaw) != null ? _c : null,
|
|
4787
4844
|
terminal: msg.terminal,
|
|
4788
|
-
lastLeg: (
|
|
4845
|
+
lastLeg: (_d = msg.leg) != null ? _d : null,
|
|
4789
4846
|
// `legs[]` is the cumulative server-known truth. Snapshots
|
|
4790
4847
|
// (`pending` / terminal rollup) carry a full `legs[]` and replace
|
|
4791
4848
|
// it. Intermediate per-leg deltas carry only `leg` (no `legs[]`)
|
|
@@ -4793,7 +4850,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
4793
4850
|
// (sourceChainId, destChainId, type) so the timeline UI doesn't
|
|
4794
4851
|
// collapse to empty between snapshots.
|
|
4795
4852
|
legs: mergeLegs(prev.legs, msg.legs, msg.leg),
|
|
4796
|
-
errorMessage: (
|
|
4853
|
+
errorMessage: (_e = msg.errorMessage) != null ? _e : null,
|
|
4797
4854
|
timestamp: msg.timestamp
|
|
4798
4855
|
};
|
|
4799
4856
|
});
|
|
@@ -4813,6 +4870,37 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
4813
4870
|
return { state, reset };
|
|
4814
4871
|
}
|
|
4815
4872
|
|
|
4873
|
+
// src/withdraw/use-withdraw-preview.ts
|
|
4874
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
4875
|
+
function useWithdrawPreview({
|
|
4876
|
+
amountRaw,
|
|
4877
|
+
tokenSymbol,
|
|
4878
|
+
destinationChainId,
|
|
4879
|
+
destinationAddress,
|
|
4880
|
+
max
|
|
4881
|
+
}) {
|
|
4882
|
+
const client = useAggClient();
|
|
4883
|
+
const enabled = !!amountRaw && BigInt(amountRaw || "0") > BigInt(0) && !!tokenSymbol && !!destinationChainId && !!destinationAddress;
|
|
4884
|
+
return (0, import_react_query17.useQuery)({
|
|
4885
|
+
queryKey: [
|
|
4886
|
+
"withdraw-preview",
|
|
4887
|
+
tokenSymbol,
|
|
4888
|
+
amountRaw,
|
|
4889
|
+
destinationChainId,
|
|
4890
|
+
destinationAddress,
|
|
4891
|
+
max != null ? max : false
|
|
4892
|
+
],
|
|
4893
|
+
enabled,
|
|
4894
|
+
staleTime: 15e3,
|
|
4895
|
+
queryFn: () => client.withdrawPreview(__spreadValues({
|
|
4896
|
+
amountRaw,
|
|
4897
|
+
tokenSymbol,
|
|
4898
|
+
destinationChainId,
|
|
4899
|
+
destinationAddress
|
|
4900
|
+
}, max ? { max: true } : {}))
|
|
4901
|
+
});
|
|
4902
|
+
}
|
|
4903
|
+
|
|
4816
4904
|
// src/index.ts
|
|
4817
4905
|
var import_sdk4 = require("@agg-build/sdk");
|
|
4818
4906
|
|
|
@@ -4930,7 +5018,7 @@ var requestAggAuthChooserOpen = () => {
|
|
|
4930
5018
|
};
|
|
4931
5019
|
|
|
4932
5020
|
// src/use-categories.ts
|
|
4933
|
-
var
|
|
5021
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
4934
5022
|
function useCategories(options) {
|
|
4935
5023
|
var _a, _b, _c, _d, _e, _f;
|
|
4936
5024
|
const client = useAggClient();
|
|
@@ -4938,7 +5026,7 @@ function useCategories(options) {
|
|
|
4938
5026
|
const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
|
|
4939
5027
|
const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
|
|
4940
5028
|
const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
|
|
4941
|
-
const query = (0,
|
|
5029
|
+
const query = (0, import_react_query18.useInfiniteQuery)({
|
|
4942
5030
|
queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
|
|
4943
5031
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
4944
5032
|
const res = yield client.getCategories(__spreadValues({
|
|
@@ -4970,7 +5058,7 @@ function useCategoryChildren(options) {
|
|
|
4970
5058
|
const parentIds = Array.from(
|
|
4971
5059
|
new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
|
|
4972
5060
|
);
|
|
4973
|
-
const queries = (0,
|
|
5061
|
+
const queries = (0, import_react_query18.useQueries)({
|
|
4974
5062
|
queries: parentIds.map((parentId) => ({
|
|
4975
5063
|
queryKey: [queryKeyScope, "parent", parentId, limit],
|
|
4976
5064
|
queryFn: () => __async(null, null, function* () {
|
|
@@ -5013,7 +5101,7 @@ function useDebouncedValue(value, delay) {
|
|
|
5013
5101
|
}
|
|
5014
5102
|
|
|
5015
5103
|
// src/use-execution-orders.ts
|
|
5016
|
-
var
|
|
5104
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
5017
5105
|
function useExecutionOrders(options = {}) {
|
|
5018
5106
|
var _a, _b;
|
|
5019
5107
|
const client = useAggClient();
|
|
@@ -5026,7 +5114,7 @@ function useExecutionOrders(options = {}) {
|
|
|
5026
5114
|
enabled = true,
|
|
5027
5115
|
refetchIntervalMs = false
|
|
5028
5116
|
} = options;
|
|
5029
|
-
const query = (0,
|
|
5117
|
+
const query = (0, import_react_query19.useInfiniteQuery)({
|
|
5030
5118
|
// quoteId + orderId are part of the cache key — different filters
|
|
5031
5119
|
// produce different result sets, so they have to vary the key.
|
|
5032
5120
|
queryKey: [
|
|
@@ -5062,7 +5150,7 @@ function useExecutionOrders(options = {}) {
|
|
|
5062
5150
|
}
|
|
5063
5151
|
|
|
5064
5152
|
// src/use-user-activity.ts
|
|
5065
|
-
var
|
|
5153
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
5066
5154
|
var DEFAULT_PENDING_REFETCH_INTERVAL_MS = 15e3;
|
|
5067
5155
|
var PENDING_ACTIVITY_STATUSES = /* @__PURE__ */ new Set([
|
|
5068
5156
|
"pending",
|
|
@@ -5096,7 +5184,7 @@ function useUserActivity(options = {}) {
|
|
|
5096
5184
|
enabled = true,
|
|
5097
5185
|
pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
|
|
5098
5186
|
} = options;
|
|
5099
|
-
const query = (0,
|
|
5187
|
+
const query = (0, import_react_query20.useInfiniteQuery)({
|
|
5100
5188
|
queryKey: userActivityQueryKeys.feed(type, limit),
|
|
5101
5189
|
queryFn: ({ pageParam }) => client.getUserActivity({
|
|
5102
5190
|
type,
|
|
@@ -5113,7 +5201,7 @@ function useUserActivity(options = {}) {
|
|
|
5113
5201
|
// flight (typically after a deposit / withdraw cache invalidation).
|
|
5114
5202
|
// Without this the feed flashes to the skeleton mid-session, which
|
|
5115
5203
|
// is worse UX than briefly showing slightly-stale rows.
|
|
5116
|
-
placeholderData:
|
|
5204
|
+
placeholderData: import_react_query20.keepPreviousData,
|
|
5117
5205
|
refetchInterval: (q) => {
|
|
5118
5206
|
if (pendingRefetchIntervalMs === false) return false;
|
|
5119
5207
|
const data = q.state.data;
|
|
@@ -5158,12 +5246,12 @@ function useExternalId(options = {}) {
|
|
|
5158
5246
|
}
|
|
5159
5247
|
|
|
5160
5248
|
// src/use-execution-positions.ts
|
|
5161
|
-
var
|
|
5249
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
5162
5250
|
function useExecutionPositions(options = {}) {
|
|
5163
5251
|
var _a, _b;
|
|
5164
5252
|
const client = useAggClient();
|
|
5165
5253
|
const { limit = 50, status, mode, enabled = true } = options;
|
|
5166
|
-
const query = (0,
|
|
5254
|
+
const query = (0, import_react_query21.useInfiniteQuery)({
|
|
5167
5255
|
queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
|
|
5168
5256
|
queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
|
|
5169
5257
|
limit,
|
|
@@ -5194,7 +5282,7 @@ var import_react23 = require("react");
|
|
|
5194
5282
|
var import_sdk3 = require("@agg-build/sdk");
|
|
5195
5283
|
|
|
5196
5284
|
// src/use-market-chart.ts
|
|
5197
|
-
var
|
|
5285
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
5198
5286
|
|
|
5199
5287
|
// src/market-data/subscription.ts
|
|
5200
5288
|
var import_react21 = require("react");
|
|
@@ -5279,7 +5367,7 @@ function useMarketChart(options) {
|
|
|
5279
5367
|
orderbook: true,
|
|
5280
5368
|
trades: true
|
|
5281
5369
|
});
|
|
5282
|
-
const queries = (0,
|
|
5370
|
+
const queries = (0, import_react_query22.useQueries)({
|
|
5283
5371
|
queries: outcomeIds.map((outcomeId) => ({
|
|
5284
5372
|
// Cache key is intentionally time-free. The rolling window's
|
|
5285
5373
|
// startTs/endTs advance on every bucket but the user expects the same
|
|
@@ -5314,7 +5402,7 @@ function useMarketChart(options) {
|
|
|
5314
5402
|
gcTime: 60 * 6e4,
|
|
5315
5403
|
refetchOnWindowFocus: false,
|
|
5316
5404
|
retry: 1,
|
|
5317
|
-
placeholderData:
|
|
5405
|
+
placeholderData: import_react_query22.keepPreviousData,
|
|
5318
5406
|
refetchInterval: refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false,
|
|
5319
5407
|
refetchIntervalInBackground: false
|
|
5320
5408
|
}))
|
|
@@ -5557,7 +5645,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
5557
5645
|
}
|
|
5558
5646
|
|
|
5559
5647
|
// src/use-live-market.ts
|
|
5560
|
-
var
|
|
5648
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
5561
5649
|
function outcomeOrderbookToState(response, marketId) {
|
|
5562
5650
|
var _a, _b, _c, _d;
|
|
5563
5651
|
const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
|
|
@@ -5607,7 +5695,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5607
5695
|
enabled: isLiveSubscriptionEnabled,
|
|
5608
5696
|
orderbook: true
|
|
5609
5697
|
});
|
|
5610
|
-
const query = (0,
|
|
5698
|
+
const query = (0, import_react_query23.useQuery)({
|
|
5611
5699
|
queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
|
|
5612
5700
|
queryFn: () => __async(null, null, function* () {
|
|
5613
5701
|
return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
|
|
@@ -5619,7 +5707,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5619
5707
|
isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
|
|
5620
5708
|
})
|
|
5621
5709
|
});
|
|
5622
|
-
const seedQuery = (0,
|
|
5710
|
+
const seedQuery = (0, import_react_query23.useQuery)({
|
|
5623
5711
|
queryKey: ["live-market-seed", canonicalMarketId],
|
|
5624
5712
|
queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
|
|
5625
5713
|
enabled: Boolean(canonicalMarketId),
|
|
@@ -5640,7 +5728,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
5640
5728
|
|
|
5641
5729
|
// src/use-live-outcome-prices.ts
|
|
5642
5730
|
var import_react26 = require("react");
|
|
5643
|
-
var
|
|
5731
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
5644
5732
|
var EMPTY_PRICES = /* @__PURE__ */ new Map();
|
|
5645
5733
|
var buildMidpointFingerprint = (outcomeIds, queries) => {
|
|
5646
5734
|
var _a, _b, _c;
|
|
@@ -5666,7 +5754,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
5666
5754
|
}
|
|
5667
5755
|
return [...ids].sort();
|
|
5668
5756
|
}, [venueMarkets]);
|
|
5669
|
-
const queries = (0,
|
|
5757
|
+
const queries = (0, import_react_query24.useQueries)({
|
|
5670
5758
|
queries: outcomeIds.map((id) => ({
|
|
5671
5759
|
queryKey: marketDataKeys.live(id),
|
|
5672
5760
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -5716,7 +5804,7 @@ function findLivePriceById(livePrices, id) {
|
|
|
5716
5804
|
|
|
5717
5805
|
// src/use-live-best-prices.ts
|
|
5718
5806
|
var import_react27 = require("react");
|
|
5719
|
-
var
|
|
5807
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
5720
5808
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
5721
5809
|
var extractOutcomeBestPrices = (state) => {
|
|
5722
5810
|
var _a, _b;
|
|
@@ -5758,7 +5846,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
5758
5846
|
}
|
|
5759
5847
|
return [...ids].sort();
|
|
5760
5848
|
}, [venueMarkets]);
|
|
5761
|
-
const queries = (0,
|
|
5849
|
+
const queries = (0, import_react_query25.useQueries)({
|
|
5762
5850
|
queries: outcomeIds.map((id) => ({
|
|
5763
5851
|
queryKey: marketDataKeys.live(id),
|
|
5764
5852
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -5852,7 +5940,7 @@ function useLiveTrades(canonicalMarketId) {
|
|
|
5852
5940
|
}
|
|
5853
5941
|
|
|
5854
5942
|
// src/use-midpoints.ts
|
|
5855
|
-
var
|
|
5943
|
+
var import_react_query26 = require("@tanstack/react-query");
|
|
5856
5944
|
var import_react28 = require("react");
|
|
5857
5945
|
var normalizeVenueMarketIds = (venueMarkets) => {
|
|
5858
5946
|
var _a;
|
|
@@ -5982,16 +6070,21 @@ var extractBestPrices = (data, venueMarkets) => {
|
|
|
5982
6070
|
}
|
|
5983
6071
|
return { bestPrices, bestPriceVenuesByOutcomeId: venuesByOutcome };
|
|
5984
6072
|
};
|
|
5985
|
-
function useMidpoints(venueMarkets) {
|
|
6073
|
+
function useMidpoints(venueMarkets, options) {
|
|
6074
|
+
var _a;
|
|
5986
6075
|
const client = useAggClient();
|
|
6076
|
+
const {
|
|
6077
|
+
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
6078
|
+
} = useAggUiConfig();
|
|
6079
|
+
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
5987
6080
|
const ids = (0, import_react28.useMemo)(() => normalizeVenueMarketIds(venueMarkets), [venueMarkets]);
|
|
5988
6081
|
const bestMidpointCandidateOutcomeIds = (0, import_react28.useMemo)(
|
|
5989
6082
|
() => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
|
|
5990
6083
|
[venueMarkets]
|
|
5991
6084
|
);
|
|
5992
|
-
const { data, isLoading } = (0,
|
|
5993
|
-
queryKey: ["midpoints", ids],
|
|
5994
|
-
queryFn: () => client.getMidpoints(ids, { bestPrice: true }),
|
|
6085
|
+
const { data, isLoading } = (0, import_react_query26.useQuery)({
|
|
6086
|
+
queryKey: ["midpoints", ids, maxMidpointIdsPerRequest],
|
|
6087
|
+
queryFn: () => client.getMidpoints(ids, { bestPrice: true, maxMidpointIdsPerRequest }),
|
|
5995
6088
|
enabled: ids.length > 0,
|
|
5996
6089
|
staleTime: Infinity,
|
|
5997
6090
|
gcTime: 30 * 6e4,
|
|
@@ -6000,13 +6093,13 @@ function useMidpoints(venueMarkets) {
|
|
|
6000
6093
|
refetchOnReconnect: false
|
|
6001
6094
|
});
|
|
6002
6095
|
const result = (0, import_react28.useMemo)(() => {
|
|
6003
|
-
var
|
|
6096
|
+
var _a2, _b, _c, _d, _e;
|
|
6004
6097
|
const map = /* @__PURE__ */ new Map();
|
|
6005
6098
|
const venueMap = /* @__PURE__ */ new Map();
|
|
6006
6099
|
if (!(data == null ? void 0 : data.data) || !venueMarkets) return { map, venueMap };
|
|
6007
6100
|
const itemByMarketId = new Map(data.data.map((item) => [item.venueMarketId, item]));
|
|
6008
6101
|
for (const item of data.data) {
|
|
6009
|
-
if (!((
|
|
6102
|
+
if (!((_a2 = item.outcomes) == null ? void 0 : _a2.length)) continue;
|
|
6010
6103
|
for (const o of item.outcomes) {
|
|
6011
6104
|
if (o.midpoint == null) continue;
|
|
6012
6105
|
map.set(o.venueMarketOutcomeId, o.midpoint);
|
|
@@ -6145,10 +6238,10 @@ var useRollingChartWindow = (options) => {
|
|
|
6145
6238
|
};
|
|
6146
6239
|
|
|
6147
6240
|
// src/use-market-orderbook.ts
|
|
6148
|
-
var
|
|
6241
|
+
var import_react_query27 = require("@tanstack/react-query");
|
|
6149
6242
|
function useMarketOrderbook(options) {
|
|
6150
6243
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
6151
|
-
const queryClient = (0,
|
|
6244
|
+
const queryClient = (0, import_react_query27.useQueryClient)();
|
|
6152
6245
|
const ws = useAggWebSocket();
|
|
6153
6246
|
const isConnected = useAggWebSocketConnectionState();
|
|
6154
6247
|
const {
|
|
@@ -6165,7 +6258,7 @@ function useMarketOrderbook(options) {
|
|
|
6165
6258
|
enabled: enabled && !!selectedOutcomeId,
|
|
6166
6259
|
orderbook: true
|
|
6167
6260
|
});
|
|
6168
|
-
const liveQueries = (0,
|
|
6261
|
+
const liveQueries = (0, import_react_query27.useQueries)({
|
|
6169
6262
|
queries: subscriptionIds.map((subscriptionId) => ({
|
|
6170
6263
|
queryKey: marketDataKeys.live(subscriptionId),
|
|
6171
6264
|
queryFn: () => createMarketLiveState(subscriptionId),
|
|
@@ -6289,7 +6382,7 @@ function useArbFeed() {
|
|
|
6289
6382
|
}
|
|
6290
6383
|
|
|
6291
6384
|
// src/use-order-book.ts
|
|
6292
|
-
var
|
|
6385
|
+
var import_react_query28 = require("@tanstack/react-query");
|
|
6293
6386
|
function useOrderBook(options) {
|
|
6294
6387
|
const client = useAggClient();
|
|
6295
6388
|
const { orderbooks, enabled = true, canonicalMarketId } = options;
|
|
@@ -6302,7 +6395,7 @@ function useOrderBook(options) {
|
|
|
6302
6395
|
venueMarketOutcomeId: outcome.id
|
|
6303
6396
|
})) : void 0
|
|
6304
6397
|
});
|
|
6305
|
-
const batchedResult = (0,
|
|
6398
|
+
const batchedResult = (0, import_react_query28.useQuery)({
|
|
6306
6399
|
queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
|
|
6307
6400
|
queryFn: ({ signal }) => client.getOrderbooks(
|
|
6308
6401
|
{
|
|
@@ -6315,7 +6408,7 @@ function useOrderBook(options) {
|
|
|
6315
6408
|
gcTime: 5 * 6e4,
|
|
6316
6409
|
refetchOnWindowFocus: false,
|
|
6317
6410
|
retry: 1,
|
|
6318
|
-
placeholderData:
|
|
6411
|
+
placeholderData: import_react_query28.keepPreviousData
|
|
6319
6412
|
});
|
|
6320
6413
|
const data = (() => {
|
|
6321
6414
|
var _a, _b;
|
|
@@ -6370,7 +6463,7 @@ function useOrderBook(options) {
|
|
|
6370
6463
|
}
|
|
6371
6464
|
|
|
6372
6465
|
// src/use-orderbook-quote.ts
|
|
6373
|
-
var
|
|
6466
|
+
var import_react_query29 = require("@tanstack/react-query");
|
|
6374
6467
|
var QUOTE_DEBOUNCE_MS = 300;
|
|
6375
6468
|
var createUnavailableOrderbookError = (message, code, retryable) => {
|
|
6376
6469
|
const error = new Error(message);
|
|
@@ -6432,7 +6525,7 @@ function useOrderbookQuote(options) {
|
|
|
6432
6525
|
const { marketId, side, size, enabled = true } = options;
|
|
6433
6526
|
const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
|
|
6434
6527
|
const shouldFetch = enabled && !!marketId && debouncedSize > 0;
|
|
6435
|
-
const query = (0,
|
|
6528
|
+
const query = (0, import_react_query29.useQuery)({
|
|
6436
6529
|
queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
|
|
6437
6530
|
queryFn: () => __async(null, null, function* () {
|
|
6438
6531
|
var _a2, _b, _c, _d;
|
|
@@ -6463,7 +6556,7 @@ function useOrderbookQuote(options) {
|
|
|
6463
6556
|
staleTime: 1e4,
|
|
6464
6557
|
gcTime: 5 * 6e4,
|
|
6465
6558
|
retry: 1,
|
|
6466
|
-
placeholderData:
|
|
6559
|
+
placeholderData: import_react_query29.keepPreviousData
|
|
6467
6560
|
});
|
|
6468
6561
|
return {
|
|
6469
6562
|
data: (_a = query.data) != null ? _a : null,
|
|
@@ -6474,12 +6567,12 @@ function useOrderbookQuote(options) {
|
|
|
6474
6567
|
}
|
|
6475
6568
|
|
|
6476
6569
|
// src/use-orders.ts
|
|
6477
|
-
var
|
|
6570
|
+
var import_react_query30 = require("@tanstack/react-query");
|
|
6478
6571
|
function useOrders(options = {}) {
|
|
6479
6572
|
var _a, _b, _c, _d;
|
|
6480
6573
|
const client = useAggClient();
|
|
6481
6574
|
const { userId, status, limit = 50, offset = 0, enabled = true } = options;
|
|
6482
|
-
const query = (0,
|
|
6575
|
+
const query = (0, import_react_query30.useQuery)({
|
|
6483
6576
|
queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
|
|
6484
6577
|
queryFn: () => client.getOrders({
|
|
6485
6578
|
userId,
|
|
@@ -6496,13 +6589,13 @@ function useOrders(options = {}) {
|
|
|
6496
6589
|
}
|
|
6497
6590
|
|
|
6498
6591
|
// src/use-search.ts
|
|
6499
|
-
var
|
|
6592
|
+
var import_react_query31 = require("@tanstack/react-query");
|
|
6500
6593
|
var import_react32 = require("react");
|
|
6501
6594
|
function useSearch(options) {
|
|
6502
6595
|
var _a, _b, _c;
|
|
6503
6596
|
const client = (0, import_react32.useContext)(AggClientContext);
|
|
6504
|
-
const queryClient = (0, import_react32.useContext)(
|
|
6505
|
-
const [fallbackQueryClient] = (0, import_react32.useState)(() => new
|
|
6597
|
+
const queryClient = (0, import_react32.useContext)(import_react_query31.QueryClientContext);
|
|
6598
|
+
const [fallbackQueryClient] = (0, import_react32.useState)(() => new import_react_query31.QueryClient());
|
|
6506
6599
|
const { q, type, categoryIds, limit = 20, enabled = true, deep = false } = options;
|
|
6507
6600
|
const isEnabled = enabled && q.length > 0;
|
|
6508
6601
|
(0, import_react32.useEffect)(() => {
|
|
@@ -6515,7 +6608,7 @@ function useSearch(options) {
|
|
|
6515
6608
|
if (isEnabled && !client) {
|
|
6516
6609
|
throw new Error("useSearch must be used within an <AggProvider>");
|
|
6517
6610
|
}
|
|
6518
|
-
const query = (0,
|
|
6611
|
+
const query = (0, import_react_query31.useInfiniteQuery)(
|
|
6519
6612
|
{
|
|
6520
6613
|
// deep is part of the key — TanStack treats deep vs light as
|
|
6521
6614
|
// independent queries so users can have both modes cached side-by-side.
|
|
@@ -6540,7 +6633,7 @@ function useSearch(options) {
|
|
|
6540
6633
|
if (!lastPage.hasMore) return void 0;
|
|
6541
6634
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
6542
6635
|
},
|
|
6543
|
-
placeholderData:
|
|
6636
|
+
placeholderData: import_react_query31.keepPreviousData,
|
|
6544
6637
|
enabled: isEnabled && !!client
|
|
6545
6638
|
},
|
|
6546
6639
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
@@ -6645,7 +6738,7 @@ function useMarketSearch(options) {
|
|
|
6645
6738
|
}
|
|
6646
6739
|
|
|
6647
6740
|
// src/use-smart-route.ts
|
|
6648
|
-
var
|
|
6741
|
+
var import_react_query32 = require("@tanstack/react-query");
|
|
6649
6742
|
var SMART_ROUTE_STALE_TIME_MS = 2e4;
|
|
6650
6743
|
function useSmartRoute(options) {
|
|
6651
6744
|
var _a, _b;
|
|
@@ -6667,7 +6760,7 @@ function useSmartRoute(options) {
|
|
|
6667
6760
|
staleTimeMs = SMART_ROUTE_STALE_TIME_MS
|
|
6668
6761
|
} = options;
|
|
6669
6762
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
6670
|
-
const query = (0,
|
|
6763
|
+
const query = (0, import_react_query32.useQuery)({
|
|
6671
6764
|
queryKey: [
|
|
6672
6765
|
"smart-route",
|
|
6673
6766
|
resolvedVenueMarketOutcomeId,
|
|
@@ -6704,25 +6797,34 @@ function useSmartRoute(options) {
|
|
|
6704
6797
|
gcTime: 6e4,
|
|
6705
6798
|
refetchOnWindowFocus: false,
|
|
6706
6799
|
retry: 1,
|
|
6707
|
-
placeholderData:
|
|
6800
|
+
placeholderData: import_react_query32.keepPreviousData
|
|
6708
6801
|
});
|
|
6709
6802
|
const error = query.error;
|
|
6803
|
+
let loadingReason = null;
|
|
6804
|
+
if (query.isFetching) {
|
|
6805
|
+
if (query.isLoading) {
|
|
6806
|
+
loadingReason = query.data != null ? "updating-route" : "finding-best-odds";
|
|
6807
|
+
} else {
|
|
6808
|
+
loadingReason = "refreshing-quotes";
|
|
6809
|
+
}
|
|
6810
|
+
}
|
|
6710
6811
|
return {
|
|
6711
6812
|
data: (_b = query.data) != null ? _b : null,
|
|
6712
6813
|
isLoading: query.isLoading,
|
|
6713
6814
|
isFetching: query.isFetching,
|
|
6714
6815
|
error: error instanceof Error ? error : error ? new Error(String(error)) : null,
|
|
6715
|
-
refetch: query.refetch
|
|
6816
|
+
refetch: query.refetch,
|
|
6817
|
+
loadingReason
|
|
6716
6818
|
};
|
|
6717
6819
|
}
|
|
6718
6820
|
|
|
6719
6821
|
// src/use-user-holdings.ts
|
|
6720
|
-
var
|
|
6822
|
+
var import_react_query33 = require("@tanstack/react-query");
|
|
6721
6823
|
function useUserHoldings(options) {
|
|
6722
6824
|
var _a, _b;
|
|
6723
6825
|
const client = useAggClient();
|
|
6724
6826
|
const { venue, venueMarketId, venueEventId, enabled = true } = options;
|
|
6725
|
-
const query = (0,
|
|
6827
|
+
const query = (0, import_react_query33.useInfiniteQuery)({
|
|
6726
6828
|
queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
|
|
6727
6829
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
6728
6830
|
return client.getUserHoldings({
|
|
@@ -6751,12 +6853,12 @@ function useUserHoldings(options) {
|
|
|
6751
6853
|
var import_react35 = require("react");
|
|
6752
6854
|
|
|
6753
6855
|
// src/use-venue-event.ts
|
|
6754
|
-
var
|
|
6856
|
+
var import_react_query34 = require("@tanstack/react-query");
|
|
6755
6857
|
function useVenueEvent(options) {
|
|
6756
6858
|
var _a;
|
|
6757
6859
|
const client = useAggClient();
|
|
6758
6860
|
const { eventId, enabled = true } = options;
|
|
6759
|
-
const query = (0,
|
|
6861
|
+
const query = (0, import_react_query34.useQuery)({
|
|
6760
6862
|
queryKey: ["venue-event", eventId],
|
|
6761
6863
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
6762
6864
|
return client.getVenueEventById(eventId, { signal });
|
|
@@ -6775,13 +6877,13 @@ function useVenueEvent(options) {
|
|
|
6775
6877
|
}
|
|
6776
6878
|
|
|
6777
6879
|
// src/use-venue-markets.ts
|
|
6778
|
-
var
|
|
6880
|
+
var import_react_query35 = require("@tanstack/react-query");
|
|
6779
6881
|
var import_react34 = require("react");
|
|
6780
6882
|
function useVenueMarkets(options) {
|
|
6781
6883
|
var _a, _b, _c, _d, _e;
|
|
6782
6884
|
const client = (0, import_react34.useContext)(AggClientContext);
|
|
6783
|
-
const queryClient = (0, import_react34.useContext)(
|
|
6784
|
-
const [fallbackQueryClient] = (0, import_react34.useState)(() => new
|
|
6885
|
+
const queryClient = (0, import_react34.useContext)(import_react_query35.QueryClientContext);
|
|
6886
|
+
const [fallbackQueryClient] = (0, import_react34.useState)(() => new import_react_query35.QueryClient());
|
|
6785
6887
|
const venue = options == null ? void 0 : options.venue;
|
|
6786
6888
|
const venueEventId = options == null ? void 0 : options.venueEventId;
|
|
6787
6889
|
const search = options == null ? void 0 : options.search;
|
|
@@ -6802,7 +6904,7 @@ function useVenueMarkets(options) {
|
|
|
6802
6904
|
if (enabled && !client) {
|
|
6803
6905
|
throw new Error("useVenueMarkets must be used within an <AggProvider>");
|
|
6804
6906
|
}
|
|
6805
|
-
const query = (0,
|
|
6907
|
+
const query = (0, import_react_query35.useInfiniteQuery)(
|
|
6806
6908
|
{
|
|
6807
6909
|
queryKey: [
|
|
6808
6910
|
"venue-markets",
|
|
@@ -6886,13 +6988,13 @@ function useEnrichedVenueEvent(options) {
|
|
|
6886
6988
|
}
|
|
6887
6989
|
|
|
6888
6990
|
// src/use-venue-events.ts
|
|
6889
|
-
var
|
|
6991
|
+
var import_react_query36 = require("@tanstack/react-query");
|
|
6890
6992
|
var import_react36 = require("react");
|
|
6891
6993
|
function useVenueEvents(options) {
|
|
6892
6994
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6893
6995
|
const client = (0, import_react36.useContext)(AggClientContext);
|
|
6894
|
-
const queryClient = (0, import_react36.useContext)(
|
|
6895
|
-
const [fallbackQueryClient] = (0, import_react36.useState)(() => new
|
|
6996
|
+
const queryClient = (0, import_react36.useContext)(import_react_query36.QueryClientContext);
|
|
6997
|
+
const [fallbackQueryClient] = (0, import_react36.useState)(() => new import_react_query36.QueryClient());
|
|
6896
6998
|
const venues = options == null ? void 0 : options.venues;
|
|
6897
6999
|
const search = options == null ? void 0 : options.search;
|
|
6898
7000
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
@@ -6918,7 +7020,7 @@ function useVenueEvents(options) {
|
|
|
6918
7020
|
if (enabled && !client) {
|
|
6919
7021
|
throw new Error("useVenueEvents must be used within an <AggProvider>");
|
|
6920
7022
|
}
|
|
6921
|
-
const query = (0,
|
|
7023
|
+
const query = (0, import_react_query36.useInfiniteQuery)(
|
|
6922
7024
|
{
|
|
6923
7025
|
queryKey: [
|
|
6924
7026
|
queryKeyScope,
|
|
@@ -6963,7 +7065,7 @@ function useVenueEvents(options) {
|
|
|
6963
7065
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
6964
7066
|
},
|
|
6965
7067
|
// TODO: RMIK - Comment out to show skeletons on category switch
|
|
6966
|
-
placeholderData:
|
|
7068
|
+
placeholderData: import_react_query36.keepPreviousData,
|
|
6967
7069
|
enabled: enabled && !!client
|
|
6968
7070
|
},
|
|
6969
7071
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
@@ -7005,26 +7107,12 @@ function useVenueEvents(options) {
|
|
|
7005
7107
|
}
|
|
7006
7108
|
|
|
7007
7109
|
// src/use-venue-market-midpoints.ts
|
|
7008
|
-
var
|
|
7009
|
-
var MAX_VENUE_MARKET_IDS_PER_REQUEST = 200;
|
|
7110
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
7010
7111
|
var normalizeVenueMarketIds2 = (venueMarketIds) => {
|
|
7011
7112
|
return [
|
|
7012
7113
|
...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
|
|
7013
7114
|
].sort((left, right) => left.localeCompare(right));
|
|
7014
7115
|
};
|
|
7015
|
-
var chunkVenueMarketIds = (venueMarketIds) => {
|
|
7016
|
-
if (venueMarketIds.length === 0) return [];
|
|
7017
|
-
const chunks = [];
|
|
7018
|
-
for (let index = 0; index < venueMarketIds.length; index += MAX_VENUE_MARKET_IDS_PER_REQUEST) {
|
|
7019
|
-
chunks.push(venueMarketIds.slice(index, index + MAX_VENUE_MARKET_IDS_PER_REQUEST));
|
|
7020
|
-
}
|
|
7021
|
-
return chunks;
|
|
7022
|
-
};
|
|
7023
|
-
var mergeMidpointResponses = (responses) => {
|
|
7024
|
-
return {
|
|
7025
|
-
data: responses.flatMap((response) => response.data)
|
|
7026
|
-
};
|
|
7027
|
-
};
|
|
7028
7116
|
var mapMidpointsByVenueMarketId = (rows) => {
|
|
7029
7117
|
const mappedMidpoints = /* @__PURE__ */ new Map();
|
|
7030
7118
|
rows.forEach((row) => {
|
|
@@ -7037,32 +7125,33 @@ var mapMidpointsByVenueMarketId = (rows) => {
|
|
|
7037
7125
|
return mappedMidpoints;
|
|
7038
7126
|
};
|
|
7039
7127
|
function useVenueMarketMidpoints(options) {
|
|
7040
|
-
var _a, _b, _c;
|
|
7128
|
+
var _a, _b, _c, _d;
|
|
7041
7129
|
const client = useAggClient();
|
|
7130
|
+
const {
|
|
7131
|
+
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
7132
|
+
} = useAggUiConfig();
|
|
7042
7133
|
const enabled = (_a = options.enabled) != null ? _a : true;
|
|
7043
7134
|
const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
|
|
7044
|
-
const
|
|
7045
|
-
|
|
7135
|
+
const maxMidpointIdsPerRequest = (_b = options.maxMidpointIdsPerRequest) != null ? _b : configuredMaxMidpointIdsPerRequest;
|
|
7136
|
+
const query = (0, import_react_query37.useQuery)({
|
|
7137
|
+
queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds, maxMidpointIdsPerRequest] : ["venue-market-midpoints", "__disabled__"],
|
|
7046
7138
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
7047
|
-
|
|
7048
|
-
if (venueMarketIdChunks.length === 0) {
|
|
7139
|
+
if (requestedVenueMarketIds.length === 0) {
|
|
7049
7140
|
return { data: [] };
|
|
7050
7141
|
}
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
})
|
|
7142
|
+
return client.getMidpoints(
|
|
7143
|
+
{ venueMarketIds: requestedVenueMarketIds, bestPrice: true },
|
|
7144
|
+
{ signal, maxMidpointIdsPerRequest }
|
|
7055
7145
|
);
|
|
7056
|
-
return mergeMidpointResponses(chunkResponses);
|
|
7057
7146
|
}),
|
|
7058
7147
|
enabled: enabled && requestedVenueMarketIds.length > 0,
|
|
7059
7148
|
staleTime: 1e4,
|
|
7060
7149
|
gcTime: 5 * 6e4,
|
|
7061
7150
|
refetchOnWindowFocus: false,
|
|
7062
7151
|
retry: 1,
|
|
7063
|
-
placeholderData:
|
|
7152
|
+
placeholderData: import_react_query37.keepPreviousData
|
|
7064
7153
|
});
|
|
7065
|
-
const midpointRows = (
|
|
7154
|
+
const midpointRows = (_d = (_c = query.data) == null ? void 0 : _c.data) != null ? _d : [];
|
|
7066
7155
|
const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
|
|
7067
7156
|
return __spreadProps(__spreadValues({}, query), {
|
|
7068
7157
|
midpointRows,
|
|
@@ -7164,8 +7253,13 @@ var buildCachedMidpointEntries = (requestedVenueMarketIds, rows) => {
|
|
|
7164
7253
|
}
|
|
7165
7254
|
return nextCacheEntries;
|
|
7166
7255
|
};
|
|
7167
|
-
function useViewportMidpoints(visibleMarkets) {
|
|
7256
|
+
function useViewportMidpoints(visibleMarkets, options) {
|
|
7257
|
+
var _a;
|
|
7168
7258
|
const client = useAggClient();
|
|
7259
|
+
const {
|
|
7260
|
+
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
7261
|
+
} = useAggUiConfig();
|
|
7262
|
+
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
7169
7263
|
const [cache, setCache] = (0, import_react37.useState)(() => /* @__PURE__ */ new Map());
|
|
7170
7264
|
const inFlightRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
|
|
7171
7265
|
const visibleRef = (0, import_react37.useRef)(visibleMarkets);
|
|
@@ -7179,10 +7273,10 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
7179
7273
|
if (!toFetch.length) return;
|
|
7180
7274
|
let cancelled = false;
|
|
7181
7275
|
for (const id of toFetch) inFlightRef.current.add(id);
|
|
7182
|
-
client.getMidpoints(toFetch, { bestPrice: true }).then((resp) => {
|
|
7183
|
-
var
|
|
7276
|
+
client.getMidpoints(toFetch, { bestPrice: true, maxMidpointIdsPerRequest }).then((resp) => {
|
|
7277
|
+
var _a2;
|
|
7184
7278
|
if (cancelled) return;
|
|
7185
|
-
const nextCacheEntries = buildCachedMidpointEntries(toFetch, (
|
|
7279
|
+
const nextCacheEntries = buildCachedMidpointEntries(toFetch, (_a2 = resp.data) != null ? _a2 : []);
|
|
7186
7280
|
setCache((prev) => {
|
|
7187
7281
|
const next = new Map(prev);
|
|
7188
7282
|
for (const [venueMarketId, entry] of nextCacheEntries) {
|
|
@@ -7197,15 +7291,15 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
7197
7291
|
return () => {
|
|
7198
7292
|
cancelled = true;
|
|
7199
7293
|
};
|
|
7200
|
-
}, [visibleFp, cache]);
|
|
7294
|
+
}, [visibleFp, cache, maxMidpointIdsPerRequest]);
|
|
7201
7295
|
const { prices, venueByOutcomeId } = (0, import_react37.useMemo)(() => {
|
|
7202
|
-
var
|
|
7296
|
+
var _a2, _b, _c, _d;
|
|
7203
7297
|
const map = /* @__PURE__ */ new Map();
|
|
7204
7298
|
const venueMap = /* @__PURE__ */ new Map();
|
|
7205
7299
|
for (const market of visibleMarkets) {
|
|
7206
7300
|
const entry = cache.get(market.id);
|
|
7207
7301
|
if (!entry) continue;
|
|
7208
|
-
const ownVenue = (
|
|
7302
|
+
const ownVenue = (_a2 = entry.venue) != null ? _a2 : market.venue;
|
|
7209
7303
|
for (const outcome of market.venueMarketOutcomes) {
|
|
7210
7304
|
let best = (_b = entry.ownOutcomes.get(outcome.id)) != null ? _b : null;
|
|
7211
7305
|
let bestVenue = best != null ? ownVenue : null;
|
|
@@ -7304,12 +7398,12 @@ function useVisibleIds(options = {}) {
|
|
|
7304
7398
|
}
|
|
7305
7399
|
|
|
7306
7400
|
// src/use-app-config.ts
|
|
7307
|
-
var
|
|
7401
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
7308
7402
|
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
7309
7403
|
var APP_CONFIG_QUERY_KEY = ["agg", "app-config"];
|
|
7310
7404
|
function useAppConfig() {
|
|
7311
7405
|
const client = useAggClient();
|
|
7312
|
-
const query = (0,
|
|
7406
|
+
const query = (0, import_react_query38.useQuery)({
|
|
7313
7407
|
queryKey: APP_CONFIG_QUERY_KEY,
|
|
7314
7408
|
queryFn: () => client.getAppConfig(),
|
|
7315
7409
|
staleTime: FIVE_MINUTES
|
|
@@ -7321,8 +7415,8 @@ function useAppConfig() {
|
|
|
7321
7415
|
});
|
|
7322
7416
|
}
|
|
7323
7417
|
function useCachedAppConfig() {
|
|
7324
|
-
const queryClient = (0,
|
|
7325
|
-
const query = (0,
|
|
7418
|
+
const queryClient = (0, import_react_query38.useQueryClient)();
|
|
7419
|
+
const query = (0, import_react_query38.useQuery)({
|
|
7326
7420
|
queryKey: APP_CONFIG_QUERY_KEY,
|
|
7327
7421
|
enabled: false,
|
|
7328
7422
|
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
@@ -7482,6 +7576,7 @@ var toAppConfigResult = (query) => {
|
|
|
7482
7576
|
useWithdrawEstimate,
|
|
7483
7577
|
useWithdrawFlow,
|
|
7484
7578
|
useWithdrawManaged,
|
|
7579
|
+
useWithdrawPreview,
|
|
7485
7580
|
useWithdrawalLifecycle,
|
|
7486
7581
|
userActivityQueryKeys
|
|
7487
7582
|
});
|