@agg-build/hooks 4.7.4 → 4.9.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-HDPVTROR.mjs → chunk-25XGLYBT.mjs} +972 -822
- package/dist/{chunk-FPBMOHIA.mjs → chunk-5EXR5PKK.mjs} +1 -1
- package/dist/{chunk-DUZ3EJUK.mjs → chunk-PUI2EGWE.mjs} +1 -1
- package/dist/deposit.js +54 -1
- package/dist/deposit.mjs +2 -2
- package/dist/index.d.mts +205 -5
- package/dist/index.d.ts +205 -5
- package/dist/index.js +648 -457
- package/dist/index.mjs +128 -84
- package/dist/withdraw.js +58 -1
- package/dist/withdraw.mjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -84,14 +84,15 @@ __export(src_exports, {
|
|
|
84
84
|
MarketStatus: () => MarketStatus,
|
|
85
85
|
MatchStatus: () => MatchStatus,
|
|
86
86
|
MatchType: () => MatchType,
|
|
87
|
-
QueryClient: () =>
|
|
88
|
-
QueryClientProvider: () =>
|
|
87
|
+
QueryClient: () => import_react_query47.QueryClient,
|
|
88
|
+
QueryClientProvider: () => import_react_query47.QueryClientProvider,
|
|
89
89
|
RedeemRejectedError: () => RedeemRejectedError,
|
|
90
90
|
SPORTS_LIVE_POLL_INTERVAL_MS: () => SPORTS_LIVE_POLL_INTERVAL_MS,
|
|
91
91
|
SPORTS_SCHEDULED_POLL_INTERVAL_MS: () => SPORTS_SCHEDULED_POLL_INTERVAL_MS,
|
|
92
92
|
TradeSide: () => TradeSide,
|
|
93
93
|
TurnstileChallengeError: () => import_sdk4.TurnstileChallengeError,
|
|
94
94
|
Venue: () => Venue,
|
|
95
|
+
appConfigQueryKey: () => appConfigQueryKey,
|
|
95
96
|
buildLiveBestPriceCandidates: () => buildLiveBestPriceCandidates,
|
|
96
97
|
computeClosedPositionTotals: () => computeClosedPositionTotals,
|
|
97
98
|
computePriceGaps: () => computePriceGaps,
|
|
@@ -133,6 +134,7 @@ __export(src_exports, {
|
|
|
133
134
|
resolveRecurringCryptoTimeline: () => resolveRecurringCryptoTimeline,
|
|
134
135
|
resolveRollingWindow: () => resolveRollingWindow,
|
|
135
136
|
resolveTradingStateKind: () => resolveTradingStateKind,
|
|
137
|
+
sharedKycQueryKeys: () => sharedKycQueryKeys,
|
|
136
138
|
sortVenues: () => sortVenues,
|
|
137
139
|
sportsLiveQueryKey: () => sportsLiveQueryKey,
|
|
138
140
|
sportsLiveRefetchInterval: () => sportsLiveRefetchInterval,
|
|
@@ -193,9 +195,10 @@ __export(src_exports, {
|
|
|
193
195
|
useOrderBook: () => useOrderBook,
|
|
194
196
|
useOrderbookQuote: () => useOrderbookQuote,
|
|
195
197
|
useOrders: () => useOrders,
|
|
198
|
+
usePaperOnboarding: () => usePaperOnboarding,
|
|
196
199
|
usePlaceLimitOrder: () => usePlaceLimitOrder,
|
|
197
200
|
usePositions: () => usePositions,
|
|
198
|
-
useQueryClient: () =>
|
|
201
|
+
useQueryClient: () => import_react_query47.useQueryClient,
|
|
199
202
|
useRampQuotes: () => useRampQuotes,
|
|
200
203
|
useRampSession: () => useRampSession,
|
|
201
204
|
useRecurringCryptoMarkets: () => useRecurringCryptoMarkets,
|
|
@@ -203,10 +206,12 @@ __export(src_exports, {
|
|
|
203
206
|
useRedeemEligibleCount: () => useRedeemEligibleCount,
|
|
204
207
|
useRedeemLifecycle: () => useRedeemLifecycle,
|
|
205
208
|
useRedeemLifecycles: () => useRedeemLifecycles,
|
|
209
|
+
useResolvedExecutionMode: () => useResolvedExecutionMode,
|
|
206
210
|
useRollingChartWindow: () => useRollingChartWindow,
|
|
207
211
|
useSdkLabels: () => useSdkLabels,
|
|
208
212
|
useSdkUiConfig: () => useSdkUiConfig,
|
|
209
213
|
useSearch: () => useSearch,
|
|
214
|
+
useSharedKyc: () => useSharedKyc,
|
|
210
215
|
useSmartRoute: () => useSmartRoute,
|
|
211
216
|
useSportsLive: () => useSportsLive,
|
|
212
217
|
useSyncBalances: () => useSyncBalances,
|
|
@@ -253,9 +258,10 @@ var ACTIVE_VENUES = [
|
|
|
253
258
|
"probable" /* probable */,
|
|
254
259
|
"myriad" /* myriad */,
|
|
255
260
|
"hyperliquid" /* hyperliquid */,
|
|
256
|
-
"novig" /* novig
|
|
261
|
+
"novig" /* novig */,
|
|
262
|
+
"prophetx" /* prophetx */
|
|
257
263
|
];
|
|
258
|
-
var INACTIVE_VENUES = [
|
|
264
|
+
var INACTIVE_VENUES = [];
|
|
259
265
|
var ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
|
|
260
266
|
var INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
|
|
261
267
|
|
|
@@ -368,7 +374,7 @@ var getVenueOrder = (venue) => {
|
|
|
368
374
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
369
375
|
|
|
370
376
|
// src/index.ts
|
|
371
|
-
var
|
|
377
|
+
var import_react_query47 = require("@tanstack/react-query");
|
|
372
378
|
|
|
373
379
|
// src/candle-store.ts
|
|
374
380
|
var import_sdk = require("@agg-build/sdk");
|
|
@@ -405,7 +411,7 @@ function evict() {
|
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
// src/core/providers/agg-provider.tsx
|
|
408
|
-
var
|
|
414
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
409
415
|
|
|
410
416
|
// src/core/providers/auth-provider.tsx
|
|
411
417
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -1228,7 +1234,7 @@ var enUsLabels = {
|
|
|
1228
1234
|
venueMinOrderSize: "Order size is below the venue minimum. Try a larger amount.",
|
|
1229
1235
|
sourceBalanceChanged: "Your balance changed since the quote. Refresh and try again, or pick a smaller amount.",
|
|
1230
1236
|
venueMarketResolved: "This market just resolved. Pick a different market or wait for the next round.",
|
|
1231
|
-
dflowWalletUnverified: "
|
|
1237
|
+
dflowWalletUnverified: "This route is unavailable for your wallet. Check your account connection and try again.",
|
|
1232
1238
|
venueNoQuotePath: "No active quote path for this market right now. Try a different size, or wait a moment and re-quote.",
|
|
1233
1239
|
solanaBlockhashExpired: "Solana transaction expired before submission. Please re-quote and try again.",
|
|
1234
1240
|
venueRateLimited: "The venue is rate-limiting requests right now. Please wait a moment and try again.",
|
|
@@ -1272,6 +1278,25 @@ var enUsLabels = {
|
|
|
1272
1278
|
kycSuccessTitle: "Verification successful",
|
|
1273
1279
|
kycSuccessDescription: "Your identity has been confirmed and you now have full access to trade on Kalshi markets.",
|
|
1274
1280
|
kycSuccessDone: "Done",
|
|
1281
|
+
sharedKyc: {
|
|
1282
|
+
required: "KYC required",
|
|
1283
|
+
completeToTrade: "Complete KYC to trade",
|
|
1284
|
+
checkingStatus: "Checking verification status",
|
|
1285
|
+
modal: {
|
|
1286
|
+
ariaLabel: "Identity verification",
|
|
1287
|
+
title: "Verify Your Identity",
|
|
1288
|
+
freeDescription: "Complete a one-time identity verification to trade all KYC-required venues.",
|
|
1289
|
+
pendingTitle: "Verification pending",
|
|
1290
|
+
pendingDescription: "Your verification is being reviewed. Check back for approval before trading.",
|
|
1291
|
+
checkStatus: "Check verification status",
|
|
1292
|
+
startVerification: "Start verification",
|
|
1293
|
+
doItLater: "Do it later",
|
|
1294
|
+
successTitle: "Verification successful",
|
|
1295
|
+
successDescription: "Your identity has been verified. You can now trade on all KYC-required venues.",
|
|
1296
|
+
done: "Done",
|
|
1297
|
+
error: "We couldn't confirm your verification."
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1275
1300
|
connectKalshi: "Connect to trade Kalshi",
|
|
1276
1301
|
tradingAccessVenues: "Venues",
|
|
1277
1302
|
tradingAccessAvailable: "Available",
|
|
@@ -1316,9 +1341,13 @@ var enUsLabels = {
|
|
|
1316
1341
|
insufficientVenueInventory: (sharesLabel, priceLabel) => `Only ${sharesLabel} \xB7 ${priceLabel}`,
|
|
1317
1342
|
viewAllRoutes: (count) => `View all (${count})`,
|
|
1318
1343
|
venueUnavailableInRegion: "Unavailable in your region",
|
|
1344
|
+
venueTemporarilyUnavailable: "Temporarily unavailable",
|
|
1319
1345
|
verified: "Verified",
|
|
1320
1346
|
platformFee: "0% platform fees",
|
|
1321
1347
|
estimatedFees: "Estimated fees",
|
|
1348
|
+
executionReserve: "Execution reserve",
|
|
1349
|
+
executionReserveTooltipAria: "Why funds are reserved",
|
|
1350
|
+
executionReserveDescription: "Held for price movement or possible venue charges, not a confirmed fee. Unused funds are returned after execution.",
|
|
1322
1351
|
estimatedFeesTooltipAria: "Estimated fees breakdown",
|
|
1323
1352
|
feeBreakdownVenueFees: "Venue",
|
|
1324
1353
|
feeBreakdownBridgeFees: "Bridging",
|
|
@@ -1593,6 +1622,35 @@ var enUsLabels = {
|
|
|
1593
1622
|
bannerAria: "Site header",
|
|
1594
1623
|
logoAria: "Home"
|
|
1595
1624
|
},
|
|
1625
|
+
paperTrading: {
|
|
1626
|
+
badge: "Paper trading",
|
|
1627
|
+
badgeTooltip: "Trade real prediction markets with simulated funds. No real money at risk.",
|
|
1628
|
+
profile: {
|
|
1629
|
+
buyingPower: "Paper Buying Power",
|
|
1630
|
+
earnings: "Paper Earnings",
|
|
1631
|
+
earningsCaption: "Keep what you earn"
|
|
1632
|
+
},
|
|
1633
|
+
onboarding: {
|
|
1634
|
+
stepEyebrow: ({ current, total }) => `STEP ${current} OF ${total}`,
|
|
1635
|
+
skip: "Skip",
|
|
1636
|
+
back: "Back",
|
|
1637
|
+
next: "Next",
|
|
1638
|
+
// Figma reads "Get Strated" (node 4772:31236) — a typo, not copy.
|
|
1639
|
+
done: "Get started",
|
|
1640
|
+
realMarkets: {
|
|
1641
|
+
title: "Real markets, real prices",
|
|
1642
|
+
body: "Follow live prediction markets and trade using real-time market prices from leading venues."
|
|
1643
|
+
},
|
|
1644
|
+
zeroRisk: {
|
|
1645
|
+
title: "Paper trading, zero risk",
|
|
1646
|
+
body: ({ amount }) => `Start with ${amount} in simulated funds. No deposit, no real money, and no risk.`
|
|
1647
|
+
},
|
|
1648
|
+
readyToTrade: {
|
|
1649
|
+
title: "You're ready to trade",
|
|
1650
|
+
body: "Pick a market, make your prediction, and track your performance."
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
},
|
|
1596
1654
|
notifications: {
|
|
1597
1655
|
order: {
|
|
1598
1656
|
filledTitle: "Order filled",
|
|
@@ -1847,6 +1905,7 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1847
1905
|
// src/core/providers/contexts.ts
|
|
1848
1906
|
var AggClientContext = (0, import_react.createContext)(null);
|
|
1849
1907
|
var AggUiContext = (0, import_react.createContext)(defaultAggUiConfig);
|
|
1908
|
+
var AggExecutionModeContext = (0, import_react.createContext)(null);
|
|
1850
1909
|
var AggLabelsContext = (0, import_react.createContext)(defaultAggUiConfig.general.labels);
|
|
1851
1910
|
var AggAuthContext = (0, import_react.createContext)(null);
|
|
1852
1911
|
var AggBalanceContext = (0, import_react.createContext)(null);
|
|
@@ -2095,7 +2154,7 @@ function AggAuthProvider({ children }) {
|
|
|
2095
2154
|
|
|
2096
2155
|
// src/core/providers/balance-provider.tsx
|
|
2097
2156
|
var import_react_query2 = require("@tanstack/react-query");
|
|
2098
|
-
var
|
|
2157
|
+
var import_react4 = require("react");
|
|
2099
2158
|
|
|
2100
2159
|
// src/execution/query-keys.ts
|
|
2101
2160
|
var executionKeys = {
|
|
@@ -2193,6 +2252,25 @@ var invalidateUserClaimState = (queryClient, options) => {
|
|
|
2193
2252
|
invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
|
|
2194
2253
|
};
|
|
2195
2254
|
|
|
2255
|
+
// src/use-resolved-execution-mode.ts
|
|
2256
|
+
var import_react3 = require("react");
|
|
2257
|
+
function useResolvedExecutionMode(override) {
|
|
2258
|
+
var _a;
|
|
2259
|
+
const serverConfig = (0, import_react3.useContext)(AggExecutionModeContext);
|
|
2260
|
+
const tradingMode = serverConfig == null ? void 0 : serverConfig.tradingMode;
|
|
2261
|
+
const isLoading = (_a = serverConfig == null ? void 0 : serverConfig.isLoading) != null ? _a : false;
|
|
2262
|
+
const {
|
|
2263
|
+
trading: { executionMode: configuredExecutionMode }
|
|
2264
|
+
} = useAggUiConfig();
|
|
2265
|
+
const localMode = override != null ? override : configuredExecutionMode;
|
|
2266
|
+
const executionMode = tradingMode != null ? tradingMode : localMode === "paper" ? "paper" : "live";
|
|
2267
|
+
return {
|
|
2268
|
+
executionMode,
|
|
2269
|
+
isPaperMode: executionMode === "paper",
|
|
2270
|
+
isResolving: tradingMode === void 0 && isLoading
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2196
2274
|
// src/core/providers/balance-provider.tsx
|
|
2197
2275
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2198
2276
|
var CHAIN_LABELS = {
|
|
@@ -2227,11 +2305,9 @@ var EMPTY_MANAGED_BALANCES = {
|
|
|
2227
2305
|
};
|
|
2228
2306
|
function AggBalanceProvider({ children }) {
|
|
2229
2307
|
var _a;
|
|
2230
|
-
const client = (0,
|
|
2231
|
-
const authContext = (0,
|
|
2232
|
-
const {
|
|
2233
|
-
trading: { executionMode }
|
|
2234
|
-
} = (0, import_react3.useContext)(AggUiContext);
|
|
2308
|
+
const client = (0, import_react4.useContext)(AggClientContext);
|
|
2309
|
+
const authContext = (0, import_react4.useContext)(AggAuthContext);
|
|
2310
|
+
const { executionMode } = useResolvedExecutionMode();
|
|
2235
2311
|
if (!authContext) {
|
|
2236
2312
|
throw new Error("AggBalanceProvider must be used within an <AggAuthProvider>");
|
|
2237
2313
|
}
|
|
@@ -2249,15 +2325,19 @@ function AggBalanceProvider({ children }) {
|
|
|
2249
2325
|
}),
|
|
2250
2326
|
enabled: Boolean(client && isAuthenticated),
|
|
2251
2327
|
staleTime: 60 * 1e3,
|
|
2328
|
+
// A matched fill can precede settlement and the API's next balance snapshot.
|
|
2329
|
+
// Keep visible clients converging even if that first invalidation reads old cash.
|
|
2330
|
+
refetchInterval: queryExecutionMode === "paper" ? false : 5e3,
|
|
2331
|
+
refetchIntervalInBackground: false,
|
|
2252
2332
|
refetchOnWindowFocus: "always",
|
|
2253
2333
|
refetchOnReconnect: "always"
|
|
2254
2334
|
});
|
|
2255
2335
|
const managedBalancesData = balancesQuery.data;
|
|
2256
|
-
const managedBalances = (0,
|
|
2336
|
+
const managedBalances = (0, import_react4.useMemo)(
|
|
2257
2337
|
() => managedBalancesData != null ? managedBalancesData : EMPTY_MANAGED_BALANCES,
|
|
2258
2338
|
[managedBalancesData]
|
|
2259
2339
|
);
|
|
2260
|
-
const connectedVenues = (0,
|
|
2340
|
+
const connectedVenues = (0, import_react4.useMemo)(() => {
|
|
2261
2341
|
return Array.from(new Set(managedBalances.positions.map((position) => position.venue))).sort(
|
|
2262
2342
|
(a, b) => a.localeCompare(b)
|
|
2263
2343
|
);
|
|
@@ -2265,7 +2345,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2265
2345
|
const balancesError = managedBalancesData === void 0 ? balancesQuery.error : null;
|
|
2266
2346
|
const isBalancesLoading = balancesQuery.isLoading;
|
|
2267
2347
|
const refetchBalances = balancesQuery.refetch;
|
|
2268
|
-
const totalBalance = (0,
|
|
2348
|
+
const totalBalance = (0, import_react4.useMemo)(() => {
|
|
2269
2349
|
const cash = managedBalances.cash;
|
|
2270
2350
|
return cash.reduce((sum, token) => {
|
|
2271
2351
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
@@ -2279,7 +2359,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2279
2359
|
return sum + tokenAcrossChains;
|
|
2280
2360
|
}, 0);
|
|
2281
2361
|
}, [managedBalances]);
|
|
2282
|
-
const availableBalance = (0,
|
|
2362
|
+
const availableBalance = (0, import_react4.useMemo)(() => {
|
|
2283
2363
|
return managedBalances.cash.reduce((sum, token) => {
|
|
2284
2364
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
2285
2365
|
if (token.availableRaw != null) {
|
|
@@ -2294,7 +2374,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2294
2374
|
);
|
|
2295
2375
|
}, 0);
|
|
2296
2376
|
}, [managedBalances]);
|
|
2297
|
-
const reservedBalance = (0,
|
|
2377
|
+
const reservedBalance = (0, import_react4.useMemo)(() => {
|
|
2298
2378
|
return managedBalances.cash.reduce((sum, token) => {
|
|
2299
2379
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
2300
2380
|
if (token.reservedRaw != null) {
|
|
@@ -2309,7 +2389,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2309
2389
|
);
|
|
2310
2390
|
}, 0);
|
|
2311
2391
|
}, [managedBalances]);
|
|
2312
|
-
const buildBalanceBreakdown = (0,
|
|
2392
|
+
const buildBalanceBreakdown = (0, import_react4.useCallback)(
|
|
2313
2393
|
(rawForChain) => {
|
|
2314
2394
|
var _a2, _b;
|
|
2315
2395
|
const byChain = /* @__PURE__ */ new Map();
|
|
@@ -2337,16 +2417,16 @@ function AggBalanceProvider({ children }) {
|
|
|
2337
2417
|
},
|
|
2338
2418
|
[connectedVenues, managedBalances.cash]
|
|
2339
2419
|
);
|
|
2340
|
-
const balanceBreakdown = (0,
|
|
2420
|
+
const balanceBreakdown = (0, import_react4.useMemo)(() => {
|
|
2341
2421
|
return buildBalanceBreakdown((chain) => chain.balanceRaw);
|
|
2342
2422
|
}, [buildBalanceBreakdown]);
|
|
2343
|
-
const availableBalanceBreakdown = (0,
|
|
2423
|
+
const availableBalanceBreakdown = (0, import_react4.useMemo)(() => {
|
|
2344
2424
|
return buildBalanceBreakdown((chain) => {
|
|
2345
2425
|
var _a2;
|
|
2346
2426
|
return (_a2 = chain.availableRaw) != null ? _a2 : chain.balanceRaw;
|
|
2347
2427
|
});
|
|
2348
2428
|
}, [buildBalanceBreakdown]);
|
|
2349
|
-
const positionsBalanceTotal = (0,
|
|
2429
|
+
const positionsBalanceTotal = (0, import_react4.useMemo)(() => {
|
|
2350
2430
|
const positions = managedBalances.positions;
|
|
2351
2431
|
const actualPositionsBalance = positions.reduce(
|
|
2352
2432
|
(sum, position) => sum + (Number.isFinite(position.balance) ? position.balance : 0),
|
|
@@ -2357,15 +2437,15 @@ function AggBalanceProvider({ children }) {
|
|
|
2357
2437
|
const kalshiVenueCash = (_a = managedBalances.venueCash) == null ? void 0 : _a.find((item) => item.venue === "kalshi");
|
|
2358
2438
|
const kalshiBalance = kalshiVenueCash ? kalshiVenueCash.balanceCents / 100 : null;
|
|
2359
2439
|
const kalshiPortfolioValue = (kalshiVenueCash == null ? void 0 : kalshiVenueCash.portfolioValueCents) == null ? null : kalshiVenueCash.portfolioValueCents / 100;
|
|
2360
|
-
const refetch = (0,
|
|
2440
|
+
const refetch = (0, import_react4.useCallback)(() => {
|
|
2361
2441
|
if (!isAuthenticated) return;
|
|
2362
2442
|
void refetchBalances();
|
|
2363
2443
|
}, [isAuthenticated, refetchBalances]);
|
|
2364
|
-
const refetchConnectionStatus = (0,
|
|
2444
|
+
const refetchConnectionStatus = (0, import_react4.useCallback)(() => {
|
|
2365
2445
|
if (!client || !isAuthenticated) return;
|
|
2366
2446
|
void client.getCurrentUser();
|
|
2367
2447
|
}, [client, isAuthenticated]);
|
|
2368
|
-
const value = (0,
|
|
2448
|
+
const value = (0, import_react4.useMemo)(() => {
|
|
2369
2449
|
if (!isAuthenticated) {
|
|
2370
2450
|
return {
|
|
2371
2451
|
managedBalances,
|
|
@@ -2430,21 +2510,87 @@ function AggClientProvider({ client, children }) {
|
|
|
2430
2510
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AggClientContext.Provider, { value: client != null ? client : null, children });
|
|
2431
2511
|
}
|
|
2432
2512
|
|
|
2433
|
-
// src/core/providers/
|
|
2434
|
-
var
|
|
2513
|
+
// src/core/providers/execution-mode-provider.tsx
|
|
2514
|
+
var import_react5 = require("react");
|
|
2515
|
+
|
|
2516
|
+
// src/use-app-config.ts
|
|
2517
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
2518
|
+
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
2519
|
+
var NO_APP_SCOPE = "__no-app__";
|
|
2520
|
+
var appConfigQueryKey = (appId) => ["agg", "app-config", appId != null ? appId : NO_APP_SCOPE];
|
|
2521
|
+
function useAppConfig() {
|
|
2522
|
+
const client = useAggClient();
|
|
2523
|
+
const query = (0, import_react_query3.useQuery)({
|
|
2524
|
+
queryKey: appConfigQueryKey(client.appId),
|
|
2525
|
+
queryFn: () => client.getAppConfig(),
|
|
2526
|
+
staleTime: FIVE_MINUTES,
|
|
2527
|
+
// Skipped entirely while the tab is unfocused — query-core only fires the
|
|
2528
|
+
// interval when `refetchIntervalInBackground` is set or the window is
|
|
2529
|
+
// focused — so a background tab costs nothing.
|
|
2530
|
+
refetchInterval: FIVE_MINUTES
|
|
2531
|
+
});
|
|
2532
|
+
return toAppConfigResult({
|
|
2533
|
+
data: query.data,
|
|
2534
|
+
isLoading: query.isLoading,
|
|
2535
|
+
error: query.error
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
function useCachedAppConfig() {
|
|
2539
|
+
const queryClient = (0, import_react_query3.useQueryClient)();
|
|
2540
|
+
const client = useOptionalAggClient();
|
|
2541
|
+
const queryKey = appConfigQueryKey(client == null ? void 0 : client.appId);
|
|
2542
|
+
const query = (0, import_react_query3.useQuery)({
|
|
2543
|
+
queryKey,
|
|
2544
|
+
enabled: false,
|
|
2545
|
+
initialData: () => queryClient.getQueryData(queryKey),
|
|
2546
|
+
staleTime: FIVE_MINUTES
|
|
2547
|
+
});
|
|
2548
|
+
return toAppConfigResult({
|
|
2549
|
+
data: query.data,
|
|
2550
|
+
isLoading: query.isLoading,
|
|
2551
|
+
error: query.error
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
var toAppConfigResult = (query) => {
|
|
2555
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2556
|
+
return {
|
|
2557
|
+
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
2558
|
+
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
2559
|
+
earlyAccessEnabled: (_f = (_e = query.data) == null ? void 0 : _e.earlyAccessEnabled) != null ? _f : false,
|
|
2560
|
+
authOptions: (_h = (_g = query.data) == null ? void 0 : _g.authOptions) != null ? _h : [],
|
|
2561
|
+
tradingMode: (_i = query.data) == null ? void 0 : _i.tradingMode,
|
|
2562
|
+
paperStartingBalance: (_j = query.data) == null ? void 0 : _j.paperStartingBalance,
|
|
2563
|
+
isLoading: query.isLoading,
|
|
2564
|
+
error: query.error
|
|
2565
|
+
};
|
|
2566
|
+
};
|
|
2567
|
+
|
|
2568
|
+
// src/core/providers/execution-mode-provider.tsx
|
|
2435
2569
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2570
|
+
function AggExecutionModeProvider({ children }) {
|
|
2571
|
+
const { tradingMode, paperStartingBalance, isLoading } = useAppConfig();
|
|
2572
|
+
const value = (0, import_react5.useMemo)(
|
|
2573
|
+
() => ({ tradingMode, paperStartingBalance, isLoading }),
|
|
2574
|
+
[tradingMode, paperStartingBalance, isLoading]
|
|
2575
|
+
);
|
|
2576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AggExecutionModeContext.Provider, { value, children });
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// src/core/providers/event-list-state-context.tsx
|
|
2580
|
+
var import_react6 = require("react");
|
|
2581
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2436
2582
|
var STALENESS_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
2437
2583
|
var MAX_INITIAL_PAGES = 10;
|
|
2438
|
-
var EventListStateContext = (0,
|
|
2584
|
+
var EventListStateContext = (0, import_react6.createContext)(null);
|
|
2439
2585
|
function EventListStateProvider({ children }) {
|
|
2440
|
-
const snapshotRef = (0,
|
|
2441
|
-
const capture = (0,
|
|
2586
|
+
const snapshotRef = (0, import_react6.useRef)(null);
|
|
2587
|
+
const capture = (0, import_react6.useCallback)((state) => {
|
|
2442
2588
|
snapshotRef.current = __spreadProps(__spreadValues({}, state), {
|
|
2443
2589
|
loadedPageCount: Math.min(state.loadedPageCount, MAX_INITIAL_PAGES),
|
|
2444
2590
|
capturedAt: Date.now()
|
|
2445
2591
|
});
|
|
2446
2592
|
}, []);
|
|
2447
|
-
const consume = (0,
|
|
2593
|
+
const consume = (0, import_react6.useCallback)(() => {
|
|
2448
2594
|
const snapshot = snapshotRef.current;
|
|
2449
2595
|
snapshotRef.current = null;
|
|
2450
2596
|
if (!snapshot) return null;
|
|
@@ -2452,17 +2598,17 @@ function EventListStateProvider({ children }) {
|
|
|
2452
2598
|
if (age > STALENESS_THRESHOLD_MS) return null;
|
|
2453
2599
|
return snapshot;
|
|
2454
2600
|
}, []);
|
|
2455
|
-
const value = (0,
|
|
2601
|
+
const value = (0, import_react6.useRef)({ capture, consume });
|
|
2456
2602
|
value.current.capture = capture;
|
|
2457
2603
|
value.current.consume = consume;
|
|
2458
|
-
const stableValue = (0,
|
|
2604
|
+
const stableValue = (0, import_react6.useRef)({
|
|
2459
2605
|
capture: (...args) => value.current.capture(...args),
|
|
2460
2606
|
consume: () => value.current.consume()
|
|
2461
2607
|
}).current;
|
|
2462
|
-
return /* @__PURE__ */ (0,
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EventListStateContext.Provider, { value: stableValue, children });
|
|
2463
2609
|
}
|
|
2464
2610
|
function useEventListState() {
|
|
2465
|
-
const context = (0,
|
|
2611
|
+
const context = (0, import_react6.useContext)(EventListStateContext);
|
|
2466
2612
|
if (!context) {
|
|
2467
2613
|
throw new Error("useEventListState must be used within an <AggProvider>");
|
|
2468
2614
|
}
|
|
@@ -2470,8 +2616,8 @@ function useEventListState() {
|
|
|
2470
2616
|
}
|
|
2471
2617
|
|
|
2472
2618
|
// src/core/providers/ws-provider.tsx
|
|
2473
|
-
var
|
|
2474
|
-
var
|
|
2619
|
+
var import_react8 = require("react");
|
|
2620
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
2475
2621
|
|
|
2476
2622
|
// src/market-data/chart-cache.ts
|
|
2477
2623
|
var MAX_CACHE_RETENTION_SECONDS = 7 * 30 * 24 * 60 * 60 + 14 * 24 * 60 * 60;
|
|
@@ -3013,25 +3159,25 @@ var marketDataKeys = {
|
|
|
3013
3159
|
};
|
|
3014
3160
|
|
|
3015
3161
|
// src/core/providers/hooks.ts
|
|
3016
|
-
var
|
|
3162
|
+
var import_react7 = require("react");
|
|
3017
3163
|
var useAggClient = () => {
|
|
3018
|
-
const client = (0,
|
|
3164
|
+
const client = (0, import_react7.useContext)(AggClientContext);
|
|
3019
3165
|
if (!client) {
|
|
3020
3166
|
throw new Error("useAggClient must be used within an <AggProvider>");
|
|
3021
3167
|
}
|
|
3022
3168
|
return client;
|
|
3023
3169
|
};
|
|
3024
3170
|
var useOptionalAggClient = () => {
|
|
3025
|
-
return (0,
|
|
3171
|
+
return (0, import_react7.useContext)(AggClientContext);
|
|
3026
3172
|
};
|
|
3027
3173
|
var useAggUiConfig = () => {
|
|
3028
|
-
return (0,
|
|
3174
|
+
return (0, import_react7.useContext)(AggUiContext);
|
|
3029
3175
|
};
|
|
3030
3176
|
var useAggLabels = () => {
|
|
3031
|
-
return (0,
|
|
3177
|
+
return (0, import_react7.useContext)(AggLabelsContext);
|
|
3032
3178
|
};
|
|
3033
3179
|
var useAggAuthContext = () => {
|
|
3034
|
-
const context = (0,
|
|
3180
|
+
const context = (0, import_react7.useContext)(AggAuthContext);
|
|
3035
3181
|
if (!context) {
|
|
3036
3182
|
throw new Error("useAggAuthContext must be used within an <AggProvider>");
|
|
3037
3183
|
}
|
|
@@ -3039,7 +3185,7 @@ var useAggAuthContext = () => {
|
|
|
3039
3185
|
};
|
|
3040
3186
|
var useAggAuthState = useAggAuthContext;
|
|
3041
3187
|
var useAggBalanceContext = () => {
|
|
3042
|
-
const context = (0,
|
|
3188
|
+
const context = (0, import_react7.useContext)(AggBalanceContext);
|
|
3043
3189
|
if (!context) {
|
|
3044
3190
|
throw new Error("useAggBalanceContext must be used within an <AggProvider>");
|
|
3045
3191
|
}
|
|
@@ -3052,10 +3198,10 @@ var useSdkLabels = useAggLabels;
|
|
|
3052
3198
|
var useLabels = useAggLabels;
|
|
3053
3199
|
|
|
3054
3200
|
// src/core/providers/ws-provider.tsx
|
|
3055
|
-
var
|
|
3056
|
-
var AggWebSocketContext = (0,
|
|
3057
|
-
var AggWebSocketConnectionContext = (0,
|
|
3058
|
-
var AggWsUserEventContext = (0,
|
|
3201
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3202
|
+
var AggWebSocketContext = (0, import_react8.createContext)(null);
|
|
3203
|
+
var AggWebSocketConnectionContext = (0, import_react8.createContext)(false);
|
|
3204
|
+
var AggWsUserEventContext = (0, import_react8.createContext)(null);
|
|
3059
3205
|
var snapshotUnavailableOutcomeIdPattern = /snapshot unavailable for\s+([^\s]+)/i;
|
|
3060
3206
|
var ORDERBOOK_DEBUG_TOP_LEVELS = 5;
|
|
3061
3207
|
var resolveSnapshotUnavailableOutcomeId = (errorMessage) => {
|
|
@@ -3072,17 +3218,17 @@ var debugOrderbook = (enabled, event, payload) => {
|
|
|
3072
3218
|
console.debug(`[AggHooks][ws-provider] ${event}`, payload);
|
|
3073
3219
|
};
|
|
3074
3220
|
function useAggWebSocket() {
|
|
3075
|
-
return (0,
|
|
3221
|
+
return (0, import_react8.useContext)(AggWebSocketContext);
|
|
3076
3222
|
}
|
|
3077
3223
|
function useAggWebSocketConnectionState() {
|
|
3078
|
-
return (0,
|
|
3224
|
+
return (0, import_react8.useContext)(AggWebSocketConnectionContext);
|
|
3079
3225
|
}
|
|
3080
3226
|
function useOnOrderSubmitted(callback) {
|
|
3081
|
-
const listeners = (0,
|
|
3082
|
-
const callbackRef = (0,
|
|
3227
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3228
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3083
3229
|
callbackRef.current = callback;
|
|
3084
3230
|
const hasCallback = callback !== null;
|
|
3085
|
-
(0,
|
|
3231
|
+
(0, import_react8.useEffect)(() => {
|
|
3086
3232
|
if (!listeners || !callbackRef.current) return;
|
|
3087
3233
|
const handler = (msg) => {
|
|
3088
3234
|
var _a;
|
|
@@ -3092,11 +3238,11 @@ function useOnOrderSubmitted(callback) {
|
|
|
3092
3238
|
}, [listeners, hasCallback]);
|
|
3093
3239
|
}
|
|
3094
3240
|
function useOnBalanceUpdate(callback) {
|
|
3095
|
-
const listeners = (0,
|
|
3096
|
-
const callbackRef = (0,
|
|
3241
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3242
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3097
3243
|
callbackRef.current = callback;
|
|
3098
3244
|
const hasCallback = callback !== null;
|
|
3099
|
-
(0,
|
|
3245
|
+
(0, import_react8.useEffect)(() => {
|
|
3100
3246
|
if (!listeners || !callbackRef.current) return;
|
|
3101
3247
|
const handler = (msg) => {
|
|
3102
3248
|
var _a;
|
|
@@ -3106,11 +3252,11 @@ function useOnBalanceUpdate(callback) {
|
|
|
3106
3252
|
}, [listeners, hasCallback]);
|
|
3107
3253
|
}
|
|
3108
3254
|
function useOnOrderEvent(callback) {
|
|
3109
|
-
const listeners = (0,
|
|
3110
|
-
const callbackRef = (0,
|
|
3255
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3256
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3111
3257
|
callbackRef.current = callback;
|
|
3112
3258
|
const hasCallback = callback !== null;
|
|
3113
|
-
(0,
|
|
3259
|
+
(0, import_react8.useEffect)(() => {
|
|
3114
3260
|
if (!listeners || !callbackRef.current) return;
|
|
3115
3261
|
const handler = (msg) => {
|
|
3116
3262
|
var _a;
|
|
@@ -3120,11 +3266,11 @@ function useOnOrderEvent(callback) {
|
|
|
3120
3266
|
}, [listeners, hasCallback]);
|
|
3121
3267
|
}
|
|
3122
3268
|
function useOnRedeemEvent(callback) {
|
|
3123
|
-
const listeners = (0,
|
|
3124
|
-
const callbackRef = (0,
|
|
3269
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3270
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3125
3271
|
callbackRef.current = callback;
|
|
3126
3272
|
const hasCallback = callback !== null;
|
|
3127
|
-
(0,
|
|
3273
|
+
(0, import_react8.useEffect)(() => {
|
|
3128
3274
|
if (!listeners || !callbackRef.current) return;
|
|
3129
3275
|
const handler = (msg) => {
|
|
3130
3276
|
var _a;
|
|
@@ -3134,11 +3280,11 @@ function useOnRedeemEvent(callback) {
|
|
|
3134
3280
|
}, [listeners, hasCallback]);
|
|
3135
3281
|
}
|
|
3136
3282
|
function useOnWithdrawalLifecycle(callback) {
|
|
3137
|
-
const listeners = (0,
|
|
3138
|
-
const callbackRef = (0,
|
|
3283
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3284
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3139
3285
|
callbackRef.current = callback;
|
|
3140
3286
|
const hasCallback = callback !== null;
|
|
3141
|
-
(0,
|
|
3287
|
+
(0, import_react8.useEffect)(() => {
|
|
3142
3288
|
if (!listeners || !callbackRef.current) return;
|
|
3143
3289
|
const handler = (msg) => {
|
|
3144
3290
|
var _a;
|
|
@@ -3150,27 +3296,27 @@ function useOnWithdrawalLifecycle(callback) {
|
|
|
3150
3296
|
function AggWebSocketProvider({ children }) {
|
|
3151
3297
|
const client = useAggClient();
|
|
3152
3298
|
const { enableWebsocketsLogs } = useAggUiConfig();
|
|
3153
|
-
const queryClient = (0,
|
|
3154
|
-
const [ws, setWs] = (0,
|
|
3155
|
-
const [isConnected, setIsConnected] = (0,
|
|
3156
|
-
const [isClientAuthenticated, setIsClientAuthenticated] = (0,
|
|
3157
|
-
const wsRef = (0,
|
|
3158
|
-
const resyncDeadlineByMarketRef = (0,
|
|
3159
|
-
const lastBalanceInvalidationAtRef = (0,
|
|
3160
|
-
(0,
|
|
3299
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
3300
|
+
const [ws, setWs] = (0, import_react8.useState)(null);
|
|
3301
|
+
const [isConnected, setIsConnected] = (0, import_react8.useState)(false);
|
|
3302
|
+
const [isClientAuthenticated, setIsClientAuthenticated] = (0, import_react8.useState)(client.isAuthenticated);
|
|
3303
|
+
const wsRef = (0, import_react8.useRef)(null);
|
|
3304
|
+
const resyncDeadlineByMarketRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
3305
|
+
const lastBalanceInvalidationAtRef = (0, import_react8.useRef)(0);
|
|
3306
|
+
(0, import_react8.useEffect)(() => {
|
|
3161
3307
|
setIsClientAuthenticated(client.isAuthenticated);
|
|
3162
3308
|
return client.onAuthStateChange((authenticated) => {
|
|
3163
3309
|
setIsClientAuthenticated(authenticated);
|
|
3164
3310
|
});
|
|
3165
3311
|
}, [client]);
|
|
3166
|
-
const orderSubmittedListenersRef = (0,
|
|
3167
|
-
const balanceUpdateListenersRef = (0,
|
|
3168
|
-
const orderEventListenersRef = (0,
|
|
3169
|
-
const redeemEventListenersRef = (0,
|
|
3170
|
-
const withdrawalLifecycleListenersRef = (0,
|
|
3312
|
+
const orderSubmittedListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3313
|
+
const balanceUpdateListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3314
|
+
const orderEventListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3315
|
+
const redeemEventListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3316
|
+
const withdrawalLifecycleListenersRef = (0, import_react8.useRef)(
|
|
3171
3317
|
/* @__PURE__ */ new Set()
|
|
3172
3318
|
);
|
|
3173
|
-
const userEventListeners = (0,
|
|
3319
|
+
const userEventListeners = (0, import_react8.useMemo)(
|
|
3174
3320
|
() => ({
|
|
3175
3321
|
addOrderSubmittedListener: (cb) => {
|
|
3176
3322
|
orderSubmittedListenersRef.current.add(cb);
|
|
@@ -3205,7 +3351,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3205
3351
|
}),
|
|
3206
3352
|
[]
|
|
3207
3353
|
);
|
|
3208
|
-
const syncOrderbookQueries = (0,
|
|
3354
|
+
const syncOrderbookQueries = (0, import_react8.useCallback)(
|
|
3209
3355
|
(marketId, updater) => {
|
|
3210
3356
|
var _a;
|
|
3211
3357
|
const queries = queryClient.getQueryCache().findAll({
|
|
@@ -3221,7 +3367,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3221
3367
|
},
|
|
3222
3368
|
[queryClient]
|
|
3223
3369
|
);
|
|
3224
|
-
const syncChartQueries = (0,
|
|
3370
|
+
const syncChartQueries = (0, import_react8.useCallback)(
|
|
3225
3371
|
(marketId, updater) => {
|
|
3226
3372
|
const queries = queryClient.getQueryCache().findAll({
|
|
3227
3373
|
queryKey: marketDataKeys.chartPrefix(marketId)
|
|
@@ -3235,7 +3381,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3235
3381
|
},
|
|
3236
3382
|
[queryClient]
|
|
3237
3383
|
);
|
|
3238
|
-
const syncLiveQuery = (0,
|
|
3384
|
+
const syncLiveQuery = (0, import_react8.useCallback)(
|
|
3239
3385
|
(marketId, updater) => {
|
|
3240
3386
|
queryClient.setQueryData(marketDataKeys.live(marketId), (previous) => {
|
|
3241
3387
|
return updater(previous);
|
|
@@ -3243,19 +3389,19 @@ function AggWebSocketProvider({ children }) {
|
|
|
3243
3389
|
},
|
|
3244
3390
|
[queryClient]
|
|
3245
3391
|
);
|
|
3246
|
-
const invalidateBalanceCaches = (0,
|
|
3392
|
+
const invalidateBalanceCaches = (0, import_react8.useCallback)(() => {
|
|
3247
3393
|
const now = Date.now();
|
|
3248
3394
|
if (now - lastBalanceInvalidationAtRef.current < 750) return;
|
|
3249
3395
|
lastBalanceInvalidationAtRef.current = now;
|
|
3250
3396
|
invalidateBalanceQueries(queryClient);
|
|
3251
3397
|
}, [queryClient]);
|
|
3252
|
-
const invalidatePositionCaches = (0,
|
|
3398
|
+
const invalidatePositionCaches = (0, import_react8.useCallback)(() => {
|
|
3253
3399
|
invalidatePositionQueries(queryClient);
|
|
3254
3400
|
}, [queryClient]);
|
|
3255
|
-
const invalidateActivityCaches = (0,
|
|
3401
|
+
const invalidateActivityCaches = (0, import_react8.useCallback)(() => {
|
|
3256
3402
|
invalidateUserActivityQueries(queryClient);
|
|
3257
3403
|
}, [queryClient]);
|
|
3258
|
-
const invalidateResolutionCaches = (0,
|
|
3404
|
+
const invalidateResolutionCaches = (0, import_react8.useCallback)(
|
|
3259
3405
|
(resolution) => {
|
|
3260
3406
|
const { outcomeId } = resolution;
|
|
3261
3407
|
syncLiveQuery(outcomeId, (previous) => {
|
|
@@ -3311,7 +3457,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3311
3457
|
},
|
|
3312
3458
|
[queryClient, syncLiveQuery]
|
|
3313
3459
|
);
|
|
3314
|
-
const callbacks = (0,
|
|
3460
|
+
const callbacks = (0, import_react8.useMemo)(
|
|
3315
3461
|
() => ({
|
|
3316
3462
|
onSnapshot: (marketId, book) => {
|
|
3317
3463
|
const orderbook = createMarketOrderbookDataFromState(book);
|
|
@@ -3512,7 +3658,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3512
3658
|
syncOrderbookQueries
|
|
3513
3659
|
]
|
|
3514
3660
|
);
|
|
3515
|
-
(0,
|
|
3661
|
+
(0, import_react8.useEffect)(() => {
|
|
3516
3662
|
let instance = null;
|
|
3517
3663
|
const resyncDeadlineByMarket = resyncDeadlineByMarketRef.current;
|
|
3518
3664
|
try {
|
|
@@ -3538,11 +3684,11 @@ function AggWebSocketProvider({ children }) {
|
|
|
3538
3684
|
setIsConnected(false);
|
|
3539
3685
|
};
|
|
3540
3686
|
}, [callbacks, client, enableWebsocketsLogs, isClientAuthenticated]);
|
|
3541
|
-
return /* @__PURE__ */ (0,
|
|
3687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWebSocketConnectionContext.Provider, { value: isConnected, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWsUserEventContext.Provider, { value: userEventListeners, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWebSocketContext.Provider, { value: ws, children }) }) });
|
|
3542
3688
|
}
|
|
3543
3689
|
|
|
3544
3690
|
// src/core/providers/ui-provider.tsx
|
|
3545
|
-
var
|
|
3691
|
+
var import_react10 = require("react");
|
|
3546
3692
|
|
|
3547
3693
|
// src/core/ui-config/constants.ts
|
|
3548
3694
|
var DEFAULT_AGG_ROOT_CLASS_NAME = "agg-root";
|
|
@@ -3619,8 +3765,8 @@ var applyThemeToDocument = (theme) => {
|
|
|
3619
3765
|
};
|
|
3620
3766
|
|
|
3621
3767
|
// src/core/providers/event-trading-context.tsx
|
|
3622
|
-
var
|
|
3623
|
-
var
|
|
3768
|
+
var import_react9 = require("react");
|
|
3769
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3624
3770
|
var OPEN_TRADING_STATE = {
|
|
3625
3771
|
kind: "open",
|
|
3626
3772
|
status: "open" /* open */,
|
|
@@ -3955,24 +4101,24 @@ var initialState = {
|
|
|
3955
4101
|
outcome: null,
|
|
3956
4102
|
tradeSide: TradeSide.Buy
|
|
3957
4103
|
};
|
|
3958
|
-
var EventTradingContext = (0,
|
|
4104
|
+
var EventTradingContext = (0, import_react9.createContext)(void 0);
|
|
3959
4105
|
var useEventTradingContext = () => {
|
|
3960
|
-
return (0,
|
|
4106
|
+
return (0, import_react9.useContext)(EventTradingContext);
|
|
3961
4107
|
};
|
|
3962
4108
|
var EventTradingProvider = ({
|
|
3963
4109
|
children,
|
|
3964
4110
|
enableLogs = false
|
|
3965
4111
|
}) => {
|
|
3966
4112
|
var _a, _b;
|
|
3967
|
-
const [state, rawDispatch] = (0,
|
|
3968
|
-
const stateRef = (0,
|
|
3969
|
-
const pendingAtomicSelectionRef = (0,
|
|
4113
|
+
const [state, rawDispatch] = (0, import_react9.useReducer)(tradingReducer, initialState);
|
|
4114
|
+
const stateRef = (0, import_react9.useRef)(state);
|
|
4115
|
+
const pendingAtomicSelectionRef = (0, import_react9.useRef)(null);
|
|
3970
4116
|
stateRef.current = state;
|
|
3971
4117
|
const pendingAtomicSelection = pendingAtomicSelectionRef.current;
|
|
3972
4118
|
if (pendingAtomicSelection && ((_a = state.market) == null ? void 0 : _a.id) === pendingAtomicSelection.marketId && ((_b = state.outcome) == null ? void 0 : _b.id) === pendingAtomicSelection.outcomeId) {
|
|
3973
4119
|
pendingAtomicSelectionRef.current = null;
|
|
3974
4120
|
}
|
|
3975
|
-
const dispatch = (0,
|
|
4121
|
+
const dispatch = (0, import_react9.useCallback)(
|
|
3976
4122
|
(action) => {
|
|
3977
4123
|
const prev = stateRef.current;
|
|
3978
4124
|
rawDispatch(action);
|
|
@@ -3981,19 +4127,19 @@ var EventTradingProvider = ({
|
|
|
3981
4127
|
},
|
|
3982
4128
|
[enableLogs]
|
|
3983
4129
|
);
|
|
3984
|
-
const initializeFromEvent = (0,
|
|
4130
|
+
const initializeFromEvent = (0, import_react9.useCallback)(
|
|
3985
4131
|
(event) => dispatch({ type: "INITIALIZE_EVENT", event }),
|
|
3986
4132
|
[dispatch]
|
|
3987
4133
|
);
|
|
3988
|
-
const syncEvent = (0,
|
|
4134
|
+
const syncEvent = (0, import_react9.useCallback)(
|
|
3989
4135
|
(event) => dispatch({ type: "SYNC_EVENT", event }),
|
|
3990
4136
|
[dispatch]
|
|
3991
4137
|
);
|
|
3992
|
-
const selectMarket = (0,
|
|
4138
|
+
const selectMarket = (0, import_react9.useCallback)(
|
|
3993
4139
|
(marketId, market) => dispatch({ type: "SELECT_MARKET", marketId, market }),
|
|
3994
4140
|
[dispatch]
|
|
3995
4141
|
);
|
|
3996
|
-
const selectOutcome = (0,
|
|
4142
|
+
const selectOutcome = (0, import_react9.useCallback)(
|
|
3997
4143
|
(outcomeId) => {
|
|
3998
4144
|
var _a2, _b2;
|
|
3999
4145
|
if (((_a2 = stateRef.current.outcome) == null ? void 0 : _a2.id) === outcomeId) return;
|
|
@@ -4002,7 +4148,7 @@ var EventTradingProvider = ({
|
|
|
4002
4148
|
},
|
|
4003
4149
|
[dispatch]
|
|
4004
4150
|
);
|
|
4005
|
-
const selectMarketAndOutcome = (0,
|
|
4151
|
+
const selectMarketAndOutcome = (0, import_react9.useCallback)(
|
|
4006
4152
|
(marketId, outcomeId) => {
|
|
4007
4153
|
var _a2, _b2, _c, _d;
|
|
4008
4154
|
if (((_a2 = stateRef.current.market) == null ? void 0 : _a2.id) === marketId && ((_b2 = stateRef.current.outcome) == null ? void 0 : _b2.id) === outcomeId) {
|
|
@@ -4016,11 +4162,11 @@ var EventTradingProvider = ({
|
|
|
4016
4162
|
},
|
|
4017
4163
|
[dispatch]
|
|
4018
4164
|
);
|
|
4019
|
-
const setTradeSide = (0,
|
|
4165
|
+
const setTradeSide = (0, import_react9.useCallback)(
|
|
4020
4166
|
(tradeSide) => dispatch({ type: "SET_TRADE_SIDE", tradeSide }),
|
|
4021
4167
|
[dispatch]
|
|
4022
4168
|
);
|
|
4023
|
-
const value = (0,
|
|
4169
|
+
const value = (0, import_react9.useMemo)(
|
|
4024
4170
|
() => {
|
|
4025
4171
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
4026
4172
|
return {
|
|
@@ -4050,11 +4196,11 @@ var EventTradingProvider = ({
|
|
|
4050
4196
|
setTradeSide
|
|
4051
4197
|
]
|
|
4052
4198
|
);
|
|
4053
|
-
return /* @__PURE__ */ (0,
|
|
4199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EventTradingContext.Provider, { value, children });
|
|
4054
4200
|
};
|
|
4055
4201
|
|
|
4056
4202
|
// src/core/providers/ui-provider.tsx
|
|
4057
|
-
var
|
|
4203
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
4058
4204
|
var hasWarnedMissingAggStyles = false;
|
|
4059
4205
|
var warnIfAggStylesAreMissing = () => {
|
|
4060
4206
|
if (hasWarnedMissingAggStyles) return;
|
|
@@ -4087,29 +4233,29 @@ var getSearchStateAfterSelect = (selectedEvent) => {
|
|
|
4087
4233
|
};
|
|
4088
4234
|
};
|
|
4089
4235
|
var AggUiProvider = ({ config, children }) => {
|
|
4090
|
-
const persisted = (0,
|
|
4091
|
-
const mergedConfig = (0,
|
|
4092
|
-
const [selectedChartTimeRange, setSelectedChartTimeRange] = (0,
|
|
4236
|
+
const persisted = (0, import_react10.useMemo)(() => loadPersistedConfig(), []);
|
|
4237
|
+
const mergedConfig = (0, import_react10.useMemo)(() => mergeAggUiConfig(persisted, config), [persisted, config]);
|
|
4238
|
+
const [selectedChartTimeRange, setSelectedChartTimeRange] = (0, import_react10.useState)(
|
|
4093
4239
|
mergedConfig.chart.selectedChartTimeRange
|
|
4094
4240
|
);
|
|
4095
|
-
const handleSetSelectedChartTimeRange = (0,
|
|
4241
|
+
const handleSetSelectedChartTimeRange = (0, import_react10.useCallback)((range) => {
|
|
4096
4242
|
setSelectedChartTimeRange(range);
|
|
4097
4243
|
}, []);
|
|
4098
|
-
const [searchValue, setSearchValue] = (0,
|
|
4099
|
-
const [searchResult, setSearchResult] = (0,
|
|
4100
|
-
const [isShowingAllResults, setIsShowingAllResults] = (0,
|
|
4244
|
+
const [searchValue, setSearchValue] = (0, import_react10.useState)(mergedConfig.search.value);
|
|
4245
|
+
const [searchResult, setSearchResult] = (0, import_react10.useState)(mergedConfig.search.result);
|
|
4246
|
+
const [isShowingAllResults, setIsShowingAllResults] = (0, import_react10.useState)(
|
|
4101
4247
|
mergedConfig.search.isShowingAllResults
|
|
4102
4248
|
);
|
|
4103
|
-
(0,
|
|
4249
|
+
(0, import_react10.useEffect)(() => {
|
|
4104
4250
|
setSearchValue(mergedConfig.search.value);
|
|
4105
4251
|
}, [mergedConfig.search.value]);
|
|
4106
|
-
(0,
|
|
4252
|
+
(0, import_react10.useEffect)(() => {
|
|
4107
4253
|
setSearchResult(mergedConfig.search.result);
|
|
4108
4254
|
}, [mergedConfig.search.result]);
|
|
4109
|
-
(0,
|
|
4255
|
+
(0, import_react10.useEffect)(() => {
|
|
4110
4256
|
setIsShowingAllResults(mergedConfig.search.isShowingAllResults);
|
|
4111
4257
|
}, [mergedConfig.search.isShowingAllResults]);
|
|
4112
|
-
const handleSearchChange = (0,
|
|
4258
|
+
const handleSearchChange = (0, import_react10.useCallback)(
|
|
4113
4259
|
(value) => {
|
|
4114
4260
|
var _a, _b;
|
|
4115
4261
|
setSearchValue(value);
|
|
@@ -4119,7 +4265,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4119
4265
|
},
|
|
4120
4266
|
[mergedConfig.search]
|
|
4121
4267
|
);
|
|
4122
|
-
const handleSearchSelect = (0,
|
|
4268
|
+
const handleSearchSelect = (0, import_react10.useCallback)(
|
|
4123
4269
|
(value) => {
|
|
4124
4270
|
var _a, _b;
|
|
4125
4271
|
const nextSearchState = getSearchStateAfterSelect(value);
|
|
@@ -4130,17 +4276,17 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4130
4276
|
},
|
|
4131
4277
|
[mergedConfig.search]
|
|
4132
4278
|
);
|
|
4133
|
-
const handleOpenResults = (0,
|
|
4279
|
+
const handleOpenResults = (0, import_react10.useCallback)(() => {
|
|
4134
4280
|
var _a, _b;
|
|
4135
4281
|
setIsShowingAllResults(true);
|
|
4136
4282
|
(_b = (_a = mergedConfig.search).openResults) == null ? void 0 : _b.call(_a);
|
|
4137
4283
|
}, [mergedConfig.search]);
|
|
4138
|
-
const handleCloseResults = (0,
|
|
4284
|
+
const handleCloseResults = (0, import_react10.useCallback)(() => {
|
|
4139
4285
|
var _a, _b;
|
|
4140
4286
|
setIsShowingAllResults(false);
|
|
4141
4287
|
(_b = (_a = mergedConfig.search).closeResults) == null ? void 0 : _b.call(_a);
|
|
4142
4288
|
}, [mergedConfig.search]);
|
|
4143
|
-
const resolvedConfig = (0,
|
|
4289
|
+
const resolvedConfig = (0, import_react10.useMemo)(() => {
|
|
4144
4290
|
return __spreadProps(__spreadValues({}, mergedConfig), {
|
|
4145
4291
|
chart: __spreadProps(__spreadValues({}, mergedConfig.chart), {
|
|
4146
4292
|
selectedChartTimeRange,
|
|
@@ -4168,7 +4314,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4168
4314
|
searchValue,
|
|
4169
4315
|
selectedChartTimeRange
|
|
4170
4316
|
]);
|
|
4171
|
-
(0,
|
|
4317
|
+
(0, import_react10.useEffect)(() => {
|
|
4172
4318
|
persistConfig({
|
|
4173
4319
|
locale: resolvedConfig.general.locale,
|
|
4174
4320
|
theme: resolvedConfig.general.theme,
|
|
@@ -4179,10 +4325,10 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4179
4325
|
resolvedConfig.general.theme,
|
|
4180
4326
|
resolvedConfig.chart.selectedChartTimeRange
|
|
4181
4327
|
]);
|
|
4182
|
-
(0,
|
|
4328
|
+
(0, import_react10.useEffect)(() => {
|
|
4183
4329
|
applyThemeToDocument(resolvedConfig.general.theme);
|
|
4184
4330
|
}, [resolvedConfig.general.theme]);
|
|
4185
|
-
(0,
|
|
4331
|
+
(0, import_react10.useEffect)(() => {
|
|
4186
4332
|
warnIfAggStylesAreMissing();
|
|
4187
4333
|
}, []);
|
|
4188
4334
|
const resolvedRootClassName = [
|
|
@@ -4191,7 +4337,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4191
4337
|
resolvedConfig.general.rootClassName
|
|
4192
4338
|
].filter(Boolean).join(" ");
|
|
4193
4339
|
logConfig(resolvedConfig, resolvedConfig.enableLogs);
|
|
4194
|
-
return /* @__PURE__ */ (0,
|
|
4340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AggLabelsContext.Provider, { value: resolvedConfig.general.labels, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AggUiContext.Provider, { value: resolvedConfig, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EventTradingProvider, { enableLogs: resolvedConfig.enableLogs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4195
4341
|
"div",
|
|
4196
4342
|
{
|
|
4197
4343
|
className: resolvedRootClassName,
|
|
@@ -4204,11 +4350,11 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4204
4350
|
};
|
|
4205
4351
|
|
|
4206
4352
|
// src/core/providers/agg-provider.tsx
|
|
4207
|
-
var
|
|
4353
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4208
4354
|
var hasWarnedMissingQueryClient = false;
|
|
4209
4355
|
function useQueryClientCheck() {
|
|
4210
4356
|
try {
|
|
4211
|
-
(0,
|
|
4357
|
+
(0, import_react_query5.useQueryClient)();
|
|
4212
4358
|
} catch (e) {
|
|
4213
4359
|
if (!hasWarnedMissingQueryClient) {
|
|
4214
4360
|
hasWarnedMissingQueryClient = true;
|
|
@@ -4225,14 +4371,14 @@ var AggProvider = ({ client, config, children }) => {
|
|
|
4225
4371
|
"AggProvider requires a valid AggClient instance. Create one with createAggClient() and pass it via the 'client' prop."
|
|
4226
4372
|
);
|
|
4227
4373
|
}
|
|
4228
|
-
return /* @__PURE__ */ (0,
|
|
4374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggClientProvider, { client, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggUiProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggExecutionModeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EventListStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggWebSocketProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggAuthProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggBalanceProvider, { children }) }) }) }) }) }) });
|
|
4229
4375
|
};
|
|
4230
4376
|
|
|
4231
4377
|
// src/use-ramp-quotes.ts
|
|
4232
|
-
var
|
|
4378
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
4233
4379
|
function useRampQuotes() {
|
|
4234
4380
|
const client = useAggClient();
|
|
4235
|
-
return (0,
|
|
4381
|
+
return (0, import_react_query6.useMutation)({
|
|
4236
4382
|
mutationFn: (params) => __async(null, null, function* () {
|
|
4237
4383
|
return client.getRampQuotes(params);
|
|
4238
4384
|
})
|
|
@@ -4240,10 +4386,10 @@ function useRampQuotes() {
|
|
|
4240
4386
|
}
|
|
4241
4387
|
|
|
4242
4388
|
// src/use-ramp-session.ts
|
|
4243
|
-
var
|
|
4389
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
4244
4390
|
function useRampSession() {
|
|
4245
4391
|
const client = useAggClient();
|
|
4246
|
-
return (0,
|
|
4392
|
+
return (0, import_react_query7.useMutation)({
|
|
4247
4393
|
mutationFn: (params) => __async(null, null, function* () {
|
|
4248
4394
|
return client.createRampSession(params);
|
|
4249
4395
|
})
|
|
@@ -4251,14 +4397,14 @@ function useRampSession() {
|
|
|
4251
4397
|
}
|
|
4252
4398
|
|
|
4253
4399
|
// src/withdraw/use-withdraw-flow.ts
|
|
4254
|
-
var
|
|
4400
|
+
var import_react15 = require("react");
|
|
4255
4401
|
|
|
4256
4402
|
// src/execution/use-execute-managed.ts
|
|
4257
|
-
var
|
|
4403
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
4258
4404
|
function useExecuteManaged(options) {
|
|
4259
4405
|
const client = useAggClient();
|
|
4260
|
-
const queryClient = (0,
|
|
4261
|
-
return (0,
|
|
4406
|
+
const queryClient = (0, import_react_query8.useQueryClient)();
|
|
4407
|
+
return (0, import_react_query8.useMutation)({
|
|
4262
4408
|
mutationFn: (params) => client.executeManaged(params),
|
|
4263
4409
|
onSuccess: (data) => {
|
|
4264
4410
|
var _a;
|
|
@@ -4272,11 +4418,11 @@ function useExecuteManaged(options) {
|
|
|
4272
4418
|
}
|
|
4273
4419
|
|
|
4274
4420
|
// src/execution/use-place-limit-order.ts
|
|
4275
|
-
var
|
|
4421
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
4276
4422
|
function usePlaceLimitOrder(options) {
|
|
4277
4423
|
const client = useAggClient();
|
|
4278
|
-
const queryClient = (0,
|
|
4279
|
-
return (0,
|
|
4424
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
4425
|
+
return (0, import_react_query9.useMutation)({
|
|
4280
4426
|
mutationFn: (params) => client.placeLimitOrder(params),
|
|
4281
4427
|
onSuccess: (data) => {
|
|
4282
4428
|
var _a;
|
|
@@ -4291,11 +4437,11 @@ function usePlaceLimitOrder(options) {
|
|
|
4291
4437
|
}
|
|
4292
4438
|
|
|
4293
4439
|
// src/execution/use-cancel-managed-order.ts
|
|
4294
|
-
var
|
|
4440
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
4295
4441
|
function useCancelManagedOrder(options) {
|
|
4296
4442
|
const client = useAggClient();
|
|
4297
|
-
const queryClient = (0,
|
|
4298
|
-
return (0,
|
|
4443
|
+
const queryClient = (0, import_react_query10.useQueryClient)();
|
|
4444
|
+
return (0, import_react_query10.useMutation)({
|
|
4299
4445
|
mutationFn: (orderId) => client.cancelManagedOrder(orderId),
|
|
4300
4446
|
onSuccess: (data, orderId) => {
|
|
4301
4447
|
var _a;
|
|
@@ -4314,11 +4460,11 @@ function useCancelManagedOrder(options) {
|
|
|
4314
4460
|
}
|
|
4315
4461
|
|
|
4316
4462
|
// src/execution/use-withdraw-managed.ts
|
|
4317
|
-
var
|
|
4463
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
4318
4464
|
function useWithdrawManaged(options) {
|
|
4319
4465
|
const client = useAggClient();
|
|
4320
|
-
const queryClient = (0,
|
|
4321
|
-
return (0,
|
|
4466
|
+
const queryClient = (0, import_react_query11.useQueryClient)();
|
|
4467
|
+
return (0, import_react_query11.useMutation)({
|
|
4322
4468
|
mutationFn: (params) => client.withdrawManaged(params),
|
|
4323
4469
|
onSuccess: (data) => {
|
|
4324
4470
|
var _a;
|
|
@@ -4330,15 +4476,19 @@ function useWithdrawManaged(options) {
|
|
|
4330
4476
|
}
|
|
4331
4477
|
|
|
4332
4478
|
// src/execution/use-managed-balances.ts
|
|
4333
|
-
var
|
|
4479
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
4334
4480
|
function useManagedBalances(options) {
|
|
4335
4481
|
const client = useAggClient();
|
|
4336
4482
|
const { enabled = true, mode } = options != null ? options : {};
|
|
4337
|
-
const query = (0,
|
|
4483
|
+
const query = (0, import_react_query12.useQuery)({
|
|
4338
4484
|
queryKey: executionKeys.balances(mode),
|
|
4339
4485
|
queryFn: () => client.getManagedBalances(mode ? { mode } : void 0),
|
|
4340
4486
|
enabled,
|
|
4341
4487
|
staleTime: 1e4,
|
|
4488
|
+
// A matched fill can precede settlement and the API's next balance snapshot.
|
|
4489
|
+
// Keep visible clients converging even if that first invalidation reads old cash.
|
|
4490
|
+
refetchInterval: mode === "paper" ? false : 5e3,
|
|
4491
|
+
refetchIntervalInBackground: false,
|
|
4342
4492
|
gcTime: 5 * 6e4,
|
|
4343
4493
|
retry: 1
|
|
4344
4494
|
});
|
|
@@ -4348,12 +4498,12 @@ function useManagedBalances(options) {
|
|
|
4348
4498
|
}
|
|
4349
4499
|
|
|
4350
4500
|
// src/execution/use-positions.ts
|
|
4351
|
-
var
|
|
4501
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
4352
4502
|
function usePositions(options) {
|
|
4353
4503
|
var _a, _b, _c, _d;
|
|
4354
4504
|
const client = useAggClient();
|
|
4355
4505
|
const { enabled = true, cursor, limit, status, mode } = options != null ? options : {};
|
|
4356
|
-
const query = (0,
|
|
4506
|
+
const query = (0, import_react_query13.useQuery)({
|
|
4357
4507
|
queryKey: executionKeys.positions(cursor, limit, status, mode),
|
|
4358
4508
|
queryFn: () => client.getPositions(__spreadValues({ cursor, limit, status }, mode ? { mode } : {})),
|
|
4359
4509
|
enabled,
|
|
@@ -4369,8 +4519,8 @@ function usePositions(options) {
|
|
|
4369
4519
|
}
|
|
4370
4520
|
|
|
4371
4521
|
// src/execution/use-deposit-addresses.ts
|
|
4372
|
-
var
|
|
4373
|
-
var
|
|
4522
|
+
var import_react11 = require("react");
|
|
4523
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
4374
4524
|
var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
|
|
4375
4525
|
function getDepositAddress(chainId, data) {
|
|
4376
4526
|
return chainId !== void 0 && SVM_CHAIN_IDS.has(chainId) ? data.svmAddress : data.evmAddress;
|
|
@@ -4384,9 +4534,9 @@ function useDepositAddresses(options) {
|
|
|
4384
4534
|
refetchIntervalMs = 5e3,
|
|
4385
4535
|
timeoutMs = 6e4
|
|
4386
4536
|
} = options != null ? options : {};
|
|
4387
|
-
const [isTimedOut, setIsTimedOut] = (0,
|
|
4388
|
-
const timeoutRef = (0,
|
|
4389
|
-
(0,
|
|
4537
|
+
const [isTimedOut, setIsTimedOut] = (0, import_react11.useState)(false);
|
|
4538
|
+
const timeoutRef = (0, import_react11.useRef)(null);
|
|
4539
|
+
(0, import_react11.useEffect)(() => {
|
|
4390
4540
|
if (!enabled || !poll) return void 0;
|
|
4391
4541
|
setIsTimedOut(false);
|
|
4392
4542
|
timeoutRef.current = setTimeout(() => setIsTimedOut(true), timeoutMs);
|
|
@@ -4394,7 +4544,7 @@ function useDepositAddresses(options) {
|
|
|
4394
4544
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
4395
4545
|
};
|
|
4396
4546
|
}, [enabled, poll, timeoutMs]);
|
|
4397
|
-
const query = (0,
|
|
4547
|
+
const query = (0, import_react_query14.useQuery)({
|
|
4398
4548
|
queryKey: executionKeys.depositAddresses(),
|
|
4399
4549
|
queryFn: () => client.getDepositAddresses(),
|
|
4400
4550
|
enabled,
|
|
@@ -4410,9 +4560,9 @@ function useDepositAddresses(options) {
|
|
|
4410
4560
|
});
|
|
4411
4561
|
const isReady = ((_a = query.data) == null ? void 0 : _a.ready) === true;
|
|
4412
4562
|
const readyData = isReady ? query.data : void 0;
|
|
4413
|
-
const evmAddress = (0,
|
|
4414
|
-
const svmAddress = (0,
|
|
4415
|
-
const supportedChains = (0,
|
|
4563
|
+
const evmAddress = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.evmAddress, [readyData]);
|
|
4564
|
+
const svmAddress = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.svmAddress, [readyData]);
|
|
4565
|
+
const supportedChains = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.supportedChains, [readyData]);
|
|
4416
4566
|
return __spreadProps(__spreadValues({}, query), {
|
|
4417
4567
|
isReady,
|
|
4418
4568
|
isTimedOut,
|
|
@@ -4426,11 +4576,11 @@ function useDepositAddresses(options) {
|
|
|
4426
4576
|
}
|
|
4427
4577
|
|
|
4428
4578
|
// src/execution/use-sync-balances.ts
|
|
4429
|
-
var
|
|
4579
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
4430
4580
|
function useSyncBalances(options) {
|
|
4431
4581
|
const client = useAggClient();
|
|
4432
|
-
const queryClient = (0,
|
|
4433
|
-
return (0,
|
|
4582
|
+
const queryClient = (0, import_react_query15.useQueryClient)();
|
|
4583
|
+
return (0, import_react_query15.useMutation)({
|
|
4434
4584
|
mutationFn: () => client.syncManagedBalances(),
|
|
4435
4585
|
onSuccess: () => {
|
|
4436
4586
|
var _a;
|
|
@@ -4442,7 +4592,7 @@ function useSyncBalances(options) {
|
|
|
4442
4592
|
}
|
|
4443
4593
|
|
|
4444
4594
|
// src/execution/use-execution-progress.ts
|
|
4445
|
-
var
|
|
4595
|
+
var import_react12 = require("react");
|
|
4446
4596
|
var TERMINAL_ORDER_STATUSES = /* @__PURE__ */ new Set([
|
|
4447
4597
|
"filled",
|
|
4448
4598
|
"partial_fill",
|
|
@@ -4575,20 +4725,20 @@ function useExecutionProgress({
|
|
|
4575
4725
|
enabled,
|
|
4576
4726
|
mode
|
|
4577
4727
|
}) {
|
|
4578
|
-
const [phase, setPhase] = (0,
|
|
4579
|
-
const [submittedOrders, setSubmittedOrders] = (0,
|
|
4580
|
-
const [latestBalance, setLatestBalance] = (0,
|
|
4581
|
-
const [dagProgress, setDagProgress] = (0,
|
|
4582
|
-
const [terminalOrderEvents, setTerminalOrderEvents] = (0,
|
|
4583
|
-
const [executionSteps, setExecutionSteps] = (0,
|
|
4584
|
-
const [rawExecutionSteps, setRawExecutionSteps] = (0,
|
|
4585
|
-
const [executionOrders, setExecutionOrders] = (0,
|
|
4586
|
-
const orderIdSetRef = (0,
|
|
4587
|
-
const submittedOrderVenueByIdRef = (0,
|
|
4588
|
-
(0,
|
|
4728
|
+
const [phase, setPhase] = (0, import_react12.useState)("idle");
|
|
4729
|
+
const [submittedOrders, setSubmittedOrders] = (0, import_react12.useState)([]);
|
|
4730
|
+
const [latestBalance, setLatestBalance] = (0, import_react12.useState)(null);
|
|
4731
|
+
const [dagProgress, setDagProgress] = (0, import_react12.useState)(null);
|
|
4732
|
+
const [terminalOrderEvents, setTerminalOrderEvents] = (0, import_react12.useState)([]);
|
|
4733
|
+
const [executionSteps, setExecutionSteps] = (0, import_react12.useState)([]);
|
|
4734
|
+
const [rawExecutionSteps, setRawExecutionSteps] = (0, import_react12.useState)([]);
|
|
4735
|
+
const [executionOrders, setExecutionOrders] = (0, import_react12.useState)([]);
|
|
4736
|
+
const orderIdSetRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
4737
|
+
const submittedOrderVenueByIdRef = (0, import_react12.useRef)(/* @__PURE__ */ new Map());
|
|
4738
|
+
(0, import_react12.useEffect)(() => {
|
|
4589
4739
|
orderIdSetRef.current = new Set(orderIds != null ? orderIds : []);
|
|
4590
4740
|
}, [orderIds]);
|
|
4591
|
-
(0,
|
|
4741
|
+
(0, import_react12.useEffect)(() => {
|
|
4592
4742
|
if (enabled && orderIds && orderIds.length > 0) {
|
|
4593
4743
|
setPhase("pending");
|
|
4594
4744
|
setSubmittedOrders([]);
|
|
@@ -4613,7 +4763,7 @@ function useExecutionProgress({
|
|
|
4613
4763
|
submittedOrderVenueByIdRef.current = /* @__PURE__ */ new Map();
|
|
4614
4764
|
}
|
|
4615
4765
|
}, [enabled, orderIds]);
|
|
4616
|
-
const handleOrderSubmitted = (0,
|
|
4766
|
+
const handleOrderSubmitted = (0, import_react12.useCallback)((msg) => {
|
|
4617
4767
|
if (!orderIdSetRef.current.has(msg.orderId)) return;
|
|
4618
4768
|
const trimmedVenue = msg.venue.trim();
|
|
4619
4769
|
if (trimmedVenue) {
|
|
@@ -4622,7 +4772,7 @@ function useExecutionProgress({
|
|
|
4622
4772
|
setSubmittedOrders((prev) => [...prev, msg]);
|
|
4623
4773
|
setPhase("order_submitted");
|
|
4624
4774
|
}, []);
|
|
4625
|
-
const handleBalanceUpdate = (0,
|
|
4775
|
+
const handleBalanceUpdate = (0, import_react12.useCallback)((msg) => {
|
|
4626
4776
|
setLatestBalance(msg);
|
|
4627
4777
|
setPhase((current) => {
|
|
4628
4778
|
if (current === "order_submitted" || current === "pending") {
|
|
@@ -4631,7 +4781,7 @@ function useExecutionProgress({
|
|
|
4631
4781
|
return current;
|
|
4632
4782
|
});
|
|
4633
4783
|
}, []);
|
|
4634
|
-
const handleOrderEvent = (0,
|
|
4784
|
+
const handleOrderEvent = (0, import_react12.useCallback)((msg) => {
|
|
4635
4785
|
var _a, _b, _c;
|
|
4636
4786
|
if (!orderIdSetRef.current.has(msg.orderId)) return;
|
|
4637
4787
|
const trimmedVenue = msg.venue.trim();
|
|
@@ -4853,9 +5003,9 @@ function useExecutionProgress({
|
|
|
4853
5003
|
useOnBalanceUpdate(isListening ? handleBalanceUpdate : null);
|
|
4854
5004
|
useOnOrderEvent(isListening ? handleOrderEvent : null);
|
|
4855
5005
|
const client = useAggClient();
|
|
4856
|
-
const terminalOrderIdsRef = (0,
|
|
4857
|
-
const pollInFlightRef = (0,
|
|
4858
|
-
const buildSubmittedOrdersFromStatus = (0,
|
|
5006
|
+
const terminalOrderIdsRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
5007
|
+
const pollInFlightRef = (0, import_react12.useRef)(false);
|
|
5008
|
+
const buildSubmittedOrdersFromStatus = (0, import_react12.useCallback)(
|
|
4859
5009
|
(orders) => {
|
|
4860
5010
|
return orders.map((order) => {
|
|
4861
5011
|
var _a, _b;
|
|
@@ -4872,7 +5022,7 @@ function useExecutionProgress({
|
|
|
4872
5022
|
},
|
|
4873
5023
|
[]
|
|
4874
5024
|
);
|
|
4875
|
-
const buildTerminalEventsFromStatus = (0,
|
|
5025
|
+
const buildTerminalEventsFromStatus = (0, import_react12.useCallback)(
|
|
4876
5026
|
(status, fallbackOrderIds, fallbackTimestamp) => {
|
|
4877
5027
|
const terminalEvents = status.orders.map((order) => {
|
|
4878
5028
|
var _a, _b;
|
|
@@ -4916,7 +5066,7 @@ function useExecutionProgress({
|
|
|
4916
5066
|
},
|
|
4917
5067
|
[]
|
|
4918
5068
|
);
|
|
4919
|
-
const setFatalPollingFailure = (0,
|
|
5069
|
+
const setFatalPollingFailure = (0, import_react12.useCallback)((message, failedOrderIds) => {
|
|
4920
5070
|
setDagProgress((prev) => {
|
|
4921
5071
|
var _a, _b, _c, _d, _e, _f;
|
|
4922
5072
|
return {
|
|
@@ -4948,10 +5098,10 @@ function useExecutionProgress({
|
|
|
4948
5098
|
);
|
|
4949
5099
|
});
|
|
4950
5100
|
}, []);
|
|
4951
|
-
(0,
|
|
5101
|
+
(0, import_react12.useEffect)(() => {
|
|
4952
5102
|
terminalOrderIdsRef.current = new Set(terminalOrderEvents.map((e) => e.orderId));
|
|
4953
5103
|
}, [terminalOrderEvents]);
|
|
4954
|
-
(0,
|
|
5104
|
+
(0, import_react12.useEffect)(() => {
|
|
4955
5105
|
if (!isStatusPolling || !quoteId) return;
|
|
4956
5106
|
let cancelled = false;
|
|
4957
5107
|
let timeout = null;
|
|
@@ -5065,7 +5215,7 @@ function useExecutionProgress({
|
|
|
5065
5215
|
quoteId,
|
|
5066
5216
|
setFatalPollingFailure
|
|
5067
5217
|
]);
|
|
5068
|
-
(0,
|
|
5218
|
+
(0, import_react12.useEffect)(() => {
|
|
5069
5219
|
if (isStatusPolling) return;
|
|
5070
5220
|
if (!isListening || !(orderIds == null ? void 0 : orderIds.length)) return;
|
|
5071
5221
|
let cancelled = false;
|
|
@@ -5158,13 +5308,13 @@ function useExecutionProgress({
|
|
|
5158
5308
|
}
|
|
5159
5309
|
|
|
5160
5310
|
// src/execution/use-balance-refill-policies.ts
|
|
5161
|
-
var
|
|
5311
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
5162
5312
|
function useBalanceRefillPolicies(options) {
|
|
5163
5313
|
var _a, _b;
|
|
5164
5314
|
const client = useAggClient();
|
|
5165
|
-
const queryClient = (0,
|
|
5315
|
+
const queryClient = (0, import_react_query16.useQueryClient)();
|
|
5166
5316
|
const queryKey = executionKeys.balanceRefillPolicies();
|
|
5167
|
-
const query = (0,
|
|
5317
|
+
const query = (0, import_react_query16.useQuery)({
|
|
5168
5318
|
queryKey,
|
|
5169
5319
|
queryFn: () => client.getBalanceRefillPolicies(),
|
|
5170
5320
|
enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
|
|
@@ -5179,13 +5329,13 @@ function useBalanceRefillPolicies(options) {
|
|
|
5179
5329
|
)) ? 5e3 : false;
|
|
5180
5330
|
}
|
|
5181
5331
|
});
|
|
5182
|
-
const createPolicy = (0,
|
|
5332
|
+
const createPolicy = (0, import_react_query16.useMutation)({
|
|
5183
5333
|
mutationFn: (params) => client.createBalanceRefillPolicy(params),
|
|
5184
5334
|
onSuccess: (policy) => {
|
|
5185
5335
|
queryClient.setQueryData(queryKey, [policy]);
|
|
5186
5336
|
}
|
|
5187
5337
|
});
|
|
5188
|
-
const updatePolicy = (0,
|
|
5338
|
+
const updatePolicy = (0, import_react_query16.useMutation)({
|
|
5189
5339
|
mutationFn: ({
|
|
5190
5340
|
policyId,
|
|
5191
5341
|
params
|
|
@@ -5243,7 +5393,7 @@ var computeClosedPositionTotals = (group) => {
|
|
|
5243
5393
|
};
|
|
5244
5394
|
|
|
5245
5395
|
// src/execution/use-redeem.ts
|
|
5246
|
-
var
|
|
5396
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
5247
5397
|
var RedeemRejectedError = class extends Error {
|
|
5248
5398
|
constructor(message, response) {
|
|
5249
5399
|
super(message);
|
|
@@ -5254,10 +5404,11 @@ var RedeemRejectedError = class extends Error {
|
|
|
5254
5404
|
var isLegRejected = (status) => status === "ineligible" || status === "rejected";
|
|
5255
5405
|
var useRedeem = () => {
|
|
5256
5406
|
const client = useAggClient();
|
|
5257
|
-
const queryClient = (0,
|
|
5258
|
-
|
|
5407
|
+
const queryClient = (0, import_react_query17.useQueryClient)();
|
|
5408
|
+
const { executionMode } = useResolvedExecutionMode();
|
|
5409
|
+
return (0, import_react_query17.useMutation)({
|
|
5259
5410
|
mutationFn: (body) => __async(null, null, function* () {
|
|
5260
|
-
const response = yield client.redeem(body);
|
|
5411
|
+
const response = yield client.redeem(__spreadValues({ mode: executionMode }, body));
|
|
5261
5412
|
if (response.results.length > 0 && response.results.every((r) => isLegRejected(r.status))) {
|
|
5262
5413
|
const reasons = response.results.map((r) => r.reason).filter((r) => Boolean(r));
|
|
5263
5414
|
const message = reasons.length > 0 ? reasons.join("; ") : "Redeem rejected";
|
|
@@ -5277,7 +5428,7 @@ var useOnRedeemEvent2 = (listener) => {
|
|
|
5277
5428
|
};
|
|
5278
5429
|
|
|
5279
5430
|
// src/execution/use-redeem-eligible-count.ts
|
|
5280
|
-
var
|
|
5431
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
5281
5432
|
var CLAIMABLE_COUNT_PAGE_LIMIT = 100;
|
|
5282
5433
|
var getClaimablePositionsCount = (client) => __async(null, null, function* () {
|
|
5283
5434
|
var _a;
|
|
@@ -5302,7 +5453,7 @@ var useRedeemEligibleCount = () => {
|
|
|
5302
5453
|
var _a;
|
|
5303
5454
|
const client = useAggClient();
|
|
5304
5455
|
const { isAuthenticated } = useAggAuthState();
|
|
5305
|
-
const query = (0,
|
|
5456
|
+
const query = (0, import_react_query18.useQuery)({
|
|
5306
5457
|
queryKey: executionKeys.claimablePositionsCount(),
|
|
5307
5458
|
queryFn: () => getClaimablePositionsCount(client),
|
|
5308
5459
|
enabled: isAuthenticated,
|
|
@@ -5314,10 +5465,10 @@ var useRedeemEligibleCount = () => {
|
|
|
5314
5465
|
};
|
|
5315
5466
|
|
|
5316
5467
|
// src/execution/use-redeem-lifecycle.ts
|
|
5317
|
-
var
|
|
5468
|
+
var import_react14 = require("react");
|
|
5318
5469
|
|
|
5319
5470
|
// src/execution/use-redeem-lifecycles.ts
|
|
5320
|
-
var
|
|
5471
|
+
var import_react13 = require("react");
|
|
5321
5472
|
var computeDerivedState = (legs, expectedCount) => {
|
|
5322
5473
|
const legCount = Object.keys(legs).length;
|
|
5323
5474
|
let allTerminal = legCount === expectedCount;
|
|
@@ -5368,21 +5519,21 @@ var seedState = (input) => {
|
|
|
5368
5519
|
};
|
|
5369
5520
|
};
|
|
5370
5521
|
function useRedeemLifecycles(inputs) {
|
|
5371
|
-
const inputsByRedeemId = (0,
|
|
5522
|
+
const inputsByRedeemId = (0, import_react13.useMemo)(() => {
|
|
5372
5523
|
const map = {};
|
|
5373
5524
|
for (const input of inputs) {
|
|
5374
5525
|
map[input.redeemId] = input;
|
|
5375
5526
|
}
|
|
5376
5527
|
return map;
|
|
5377
5528
|
}, [inputs]);
|
|
5378
|
-
const [stateMap, setStateMap] = (0,
|
|
5529
|
+
const [stateMap, setStateMap] = (0, import_react13.useState)(() => {
|
|
5379
5530
|
const next = {};
|
|
5380
5531
|
for (const [id, input] of Object.entries(inputsByRedeemId)) {
|
|
5381
5532
|
next[id] = seedState(input);
|
|
5382
5533
|
}
|
|
5383
5534
|
return next;
|
|
5384
5535
|
});
|
|
5385
|
-
(0,
|
|
5536
|
+
(0, import_react13.useEffect)(() => {
|
|
5386
5537
|
setStateMap((prev) => {
|
|
5387
5538
|
let changed = false;
|
|
5388
5539
|
const next = {};
|
|
@@ -5400,7 +5551,7 @@ function useRedeemLifecycles(inputs) {
|
|
|
5400
5551
|
});
|
|
5401
5552
|
}, [inputsByRedeemId]);
|
|
5402
5553
|
useOnRedeemEvent(
|
|
5403
|
-
(0,
|
|
5554
|
+
(0, import_react13.useMemo)(() => {
|
|
5404
5555
|
if (Object.keys(inputsByRedeemId).length === 0) return null;
|
|
5405
5556
|
return (event) => {
|
|
5406
5557
|
const input = inputsByRedeemId[event.redeemId];
|
|
@@ -5445,7 +5596,7 @@ var INITIAL_STATE = {
|
|
|
5445
5596
|
};
|
|
5446
5597
|
function useRedeemLifecycle(input) {
|
|
5447
5598
|
var _a;
|
|
5448
|
-
const inputs = (0,
|
|
5599
|
+
const inputs = (0, import_react14.useMemo)(() => input ? [input] : [], [input]);
|
|
5449
5600
|
const map = useRedeemLifecycles(inputs);
|
|
5450
5601
|
if (!input) return INITIAL_STATE;
|
|
5451
5602
|
return (_a = map[input.redeemId]) != null ? _a : INITIAL_STATE;
|
|
@@ -5526,25 +5677,25 @@ function useWithdrawFlow(options) {
|
|
|
5526
5677
|
const withdrawMutation = useWithdrawManaged();
|
|
5527
5678
|
const syncBalances = useSyncBalances();
|
|
5528
5679
|
const ws = useAggWebSocket();
|
|
5529
|
-
(0,
|
|
5680
|
+
(0, import_react15.useEffect)(() => {
|
|
5530
5681
|
if (!open) return;
|
|
5531
5682
|
syncBalances.mutate(void 0, {
|
|
5532
5683
|
onError: () => {
|
|
5533
5684
|
}
|
|
5534
5685
|
});
|
|
5535
5686
|
}, [open]);
|
|
5536
|
-
const [withdrawDestination, setWithdrawDestination] = (0,
|
|
5537
|
-
const [withdrawAmount, setWithdrawAmount] = (0,
|
|
5538
|
-
const [withdrawToken, setWithdrawToken] = (0,
|
|
5539
|
-
const [withdrawNetwork, setWithdrawNetwork] = (0,
|
|
5540
|
-
const [withdrawSummary, setWithdrawSummary] = (0,
|
|
5541
|
-
const [withdrawalId, setWithdrawalId] = (0,
|
|
5542
|
-
const [isMax, setIsMax] = (0,
|
|
5543
|
-
const detectedAddressKind = (0,
|
|
5687
|
+
const [withdrawDestination, setWithdrawDestination] = (0, import_react15.useState)("");
|
|
5688
|
+
const [withdrawAmount, setWithdrawAmount] = (0, import_react15.useState)("");
|
|
5689
|
+
const [withdrawToken, setWithdrawToken] = (0, import_react15.useState)("USDC");
|
|
5690
|
+
const [withdrawNetwork, setWithdrawNetwork] = (0, import_react15.useState)("");
|
|
5691
|
+
const [withdrawSummary, setWithdrawSummary] = (0, import_react15.useState)(DEFAULT_WITHDRAW_SUMMARY);
|
|
5692
|
+
const [withdrawalId, setWithdrawalId] = (0, import_react15.useState)(null);
|
|
5693
|
+
const [isMax, setIsMax] = (0, import_react15.useState)(false);
|
|
5694
|
+
const detectedAddressKind = (0, import_react15.useMemo)(
|
|
5544
5695
|
() => detectDestinationAddressKind(withdrawDestination),
|
|
5545
5696
|
[withdrawDestination]
|
|
5546
5697
|
);
|
|
5547
|
-
const networkOptions = (0,
|
|
5698
|
+
const networkOptions = (0, import_react15.useMemo)(
|
|
5548
5699
|
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) => {
|
|
5549
5700
|
const value = String(chain.chainId);
|
|
5550
5701
|
const isSolana = chain.chainId === SOLANA_CHAIN_ID;
|
|
@@ -5558,13 +5709,13 @@ function useWithdrawFlow(options) {
|
|
|
5558
5709
|
(option) => option.value === withdrawNetwork && !option.disabled
|
|
5559
5710
|
);
|
|
5560
5711
|
const resolvedWithdrawNetwork = isCurrentNetworkSelectable ? withdrawNetwork : firstEnabledNetwork;
|
|
5561
|
-
(0,
|
|
5712
|
+
(0, import_react15.useEffect)(() => {
|
|
5562
5713
|
if (!networkOptions.length) return;
|
|
5563
5714
|
if (!isCurrentNetworkSelectable && firstEnabledNetwork) {
|
|
5564
5715
|
setWithdrawNetwork(firstEnabledNetwork);
|
|
5565
5716
|
}
|
|
5566
5717
|
}, [networkOptions, isCurrentNetworkSelectable, firstEnabledNetwork]);
|
|
5567
|
-
const tokenOptions = (0,
|
|
5718
|
+
const tokenOptions = (0, import_react15.useMemo)(() => {
|
|
5568
5719
|
var _a2, _b2, _c2;
|
|
5569
5720
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
5570
5721
|
const supportedTokensForNetwork = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens) != null ? _b2 : [];
|
|
@@ -5575,17 +5726,17 @@ function useWithdrawFlow(options) {
|
|
|
5575
5726
|
}));
|
|
5576
5727
|
}, [balances, resolvedWithdrawNetwork, supportedChains]);
|
|
5577
5728
|
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((_e = tokenOptions[0]) == null ? void 0 : _e.value) || "";
|
|
5578
|
-
(0,
|
|
5729
|
+
(0, import_react15.useEffect)(() => {
|
|
5579
5730
|
if (!tokenOptions.length) return;
|
|
5580
5731
|
if (!tokenOptions.some((option) => option.value === withdrawToken)) {
|
|
5581
5732
|
setWithdrawToken(tokenOptions[0].value);
|
|
5582
5733
|
}
|
|
5583
5734
|
}, [tokenOptions, withdrawToken]);
|
|
5584
|
-
const selectedCashEntry = (0,
|
|
5735
|
+
const selectedCashEntry = (0, import_react15.useMemo)(
|
|
5585
5736
|
() => balances == null ? void 0 : balances.cash.find((cashEntry) => cashEntry.tokenSymbol === resolvedWithdrawToken),
|
|
5586
5737
|
[balances, resolvedWithdrawToken]
|
|
5587
5738
|
);
|
|
5588
|
-
const selectedTokenDecimals = (0,
|
|
5739
|
+
const selectedTokenDecimals = (0, import_react15.useMemo)(() => {
|
|
5589
5740
|
var _a2, _b2, _c2, _d2;
|
|
5590
5741
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
5591
5742
|
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;
|
|
@@ -5595,18 +5746,18 @@ function useWithdrawFlow(options) {
|
|
|
5595
5746
|
selectedCashEntry == null ? void 0 : selectedCashEntry.decimals,
|
|
5596
5747
|
supportedChains
|
|
5597
5748
|
]);
|
|
5598
|
-
const exactBalance = (0,
|
|
5749
|
+
const exactBalance = (0, import_react15.useMemo)(() => {
|
|
5599
5750
|
if (!selectedCashEntry) return "0";
|
|
5600
5751
|
return formatRawTokenAmount(selectedCashEntry.totalRaw, selectedCashEntry.decimals);
|
|
5601
5752
|
}, [selectedCashEntry]);
|
|
5602
|
-
const balanceDisplay = (0,
|
|
5753
|
+
const balanceDisplay = (0, import_react15.useMemo)(() => {
|
|
5603
5754
|
if (!selectedCashEntry) return `0.00 ${resolvedWithdrawToken || withdrawToken}`;
|
|
5604
5755
|
return `${formatRawTokenAmountForDisplay(
|
|
5605
5756
|
selectedCashEntry.totalRaw,
|
|
5606
5757
|
selectedCashEntry.decimals
|
|
5607
5758
|
)} ${resolvedWithdrawToken}`;
|
|
5608
5759
|
}, [resolvedWithdrawToken, selectedCashEntry, withdrawToken]);
|
|
5609
|
-
const resetFlowState = (0,
|
|
5760
|
+
const resetFlowState = (0, import_react15.useCallback)(() => {
|
|
5610
5761
|
setWithdrawDestination("");
|
|
5611
5762
|
setWithdrawAmount("");
|
|
5612
5763
|
setWithdrawToken("USDC");
|
|
@@ -5615,17 +5766,17 @@ function useWithdrawFlow(options) {
|
|
|
5615
5766
|
setWithdrawalId(null);
|
|
5616
5767
|
setIsMax(false);
|
|
5617
5768
|
}, []);
|
|
5618
|
-
const handleWithdrawOpenChange = (0,
|
|
5769
|
+
const handleWithdrawOpenChange = (0, import_react15.useCallback)(
|
|
5619
5770
|
(isOpen) => {
|
|
5620
5771
|
if (!isOpen) resetFlowState();
|
|
5621
5772
|
onOpenChange(isOpen);
|
|
5622
5773
|
},
|
|
5623
5774
|
[onOpenChange, resetFlowState]
|
|
5624
5775
|
);
|
|
5625
|
-
(0,
|
|
5776
|
+
(0, import_react15.useEffect)(() => {
|
|
5626
5777
|
if (!open) resetFlowState();
|
|
5627
5778
|
}, [open, resetFlowState]);
|
|
5628
|
-
const handleWithdrawProvider = (0,
|
|
5779
|
+
const handleWithdrawProvider = (0, import_react15.useCallback)(() => __async(null, null, function* () {
|
|
5629
5780
|
var _a2, _b2;
|
|
5630
5781
|
const destinationChainId = Number(resolvedWithdrawNetwork);
|
|
5631
5782
|
const trimmedDestination = withdrawDestination.trim();
|
|
@@ -5710,34 +5861,34 @@ function useWithdrawFlow(options) {
|
|
|
5710
5861
|
isMax
|
|
5711
5862
|
},
|
|
5712
5863
|
onWithdrawDestinationChange: setWithdrawDestination,
|
|
5713
|
-
onWithdrawAmountChange: (0,
|
|
5864
|
+
onWithdrawAmountChange: (0, import_react15.useCallback)((v) => {
|
|
5714
5865
|
setIsMax(false);
|
|
5715
5866
|
setWithdrawAmount(v);
|
|
5716
5867
|
}, []),
|
|
5717
5868
|
onWithdrawTokenChange: setWithdrawToken,
|
|
5718
5869
|
onWithdrawNetworkChange: setWithdrawNetwork,
|
|
5719
|
-
onMaxClick: (0,
|
|
5870
|
+
onMaxClick: (0, import_react15.useCallback)(() => {
|
|
5720
5871
|
setIsMax(true);
|
|
5721
5872
|
setWithdrawAmount(exactBalance === "0" ? "0" : exactBalance);
|
|
5722
5873
|
}, [exactBalance]),
|
|
5723
|
-
onSelectWithdrawProvider: (0,
|
|
5874
|
+
onSelectWithdrawProvider: (0, import_react15.useCallback)(
|
|
5724
5875
|
(_providerId) => __async(null, null, function* () {
|
|
5725
5876
|
return handleWithdrawProvider();
|
|
5726
5877
|
}),
|
|
5727
5878
|
[handleWithdrawProvider]
|
|
5728
5879
|
),
|
|
5729
|
-
onDoneWithdraw: (0,
|
|
5880
|
+
onDoneWithdraw: (0, import_react15.useCallback)(() => handleWithdrawOpenChange(false), [handleWithdrawOpenChange])
|
|
5730
5881
|
};
|
|
5731
5882
|
}
|
|
5732
5883
|
|
|
5733
5884
|
// src/withdraw/use-withdraw-estimate.ts
|
|
5734
|
-
var
|
|
5885
|
+
var import_react16 = require("react");
|
|
5735
5886
|
function useWithdrawEstimate({
|
|
5736
5887
|
amount,
|
|
5737
5888
|
selectedToken,
|
|
5738
5889
|
selectedNetwork
|
|
5739
5890
|
}) {
|
|
5740
|
-
return (0,
|
|
5891
|
+
return (0, import_react16.useMemo)(() => {
|
|
5741
5892
|
const numAmount = Number(amount);
|
|
5742
5893
|
if (!amount || isNaN(numAmount) || numAmount <= 0 || !selectedToken || !selectedNetwork) {
|
|
5743
5894
|
return null;
|
|
@@ -5777,8 +5928,8 @@ function useWithdrawEstimate({
|
|
|
5777
5928
|
}
|
|
5778
5929
|
|
|
5779
5930
|
// src/withdraw/use-withdrawal-lifecycle.ts
|
|
5780
|
-
var
|
|
5781
|
-
var
|
|
5931
|
+
var import_react17 = require("react");
|
|
5932
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
5782
5933
|
var INITIAL_STATE2 = {
|
|
5783
5934
|
pending: true,
|
|
5784
5935
|
status: null,
|
|
@@ -5835,15 +5986,15 @@ var restToLifecycleState = (response) => {
|
|
|
5835
5986
|
function useWithdrawalLifecycle(withdrawalId) {
|
|
5836
5987
|
const client = useAggClient();
|
|
5837
5988
|
const wsConnected = useAggWebSocketConnectionState();
|
|
5838
|
-
const queryClient = (0,
|
|
5839
|
-
const [state, setState] = (0,
|
|
5840
|
-
const stateRef = (0,
|
|
5989
|
+
const queryClient = (0, import_react_query19.useQueryClient)();
|
|
5990
|
+
const [state, setState] = (0, import_react17.useState)(INITIAL_STATE2);
|
|
5991
|
+
const stateRef = (0, import_react17.useRef)(state);
|
|
5841
5992
|
stateRef.current = state;
|
|
5842
|
-
const balanceRefetchedForRef = (0,
|
|
5843
|
-
(0,
|
|
5993
|
+
const balanceRefetchedForRef = (0, import_react17.useRef)(null);
|
|
5994
|
+
(0, import_react17.useEffect)(() => {
|
|
5844
5995
|
setState(INITIAL_STATE2);
|
|
5845
5996
|
}, [withdrawalId]);
|
|
5846
|
-
(0,
|
|
5997
|
+
(0, import_react17.useEffect)(() => {
|
|
5847
5998
|
if (!withdrawalId) return;
|
|
5848
5999
|
let cancelled = false;
|
|
5849
6000
|
(() => __async(null, null, function* () {
|
|
@@ -5862,7 +6013,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5862
6013
|
cancelled = true;
|
|
5863
6014
|
};
|
|
5864
6015
|
}, [client, withdrawalId, wsConnected]);
|
|
5865
|
-
const handler = (0,
|
|
6016
|
+
const handler = (0, import_react17.useMemo)(() => {
|
|
5866
6017
|
if (!withdrawalId) return null;
|
|
5867
6018
|
return (msg) => {
|
|
5868
6019
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
@@ -5890,7 +6041,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5890
6041
|
};
|
|
5891
6042
|
}, [withdrawalId]);
|
|
5892
6043
|
useOnWithdrawalLifecycle(handler);
|
|
5893
|
-
(0,
|
|
6044
|
+
(0, import_react17.useEffect)(() => {
|
|
5894
6045
|
if (!withdrawalId) return;
|
|
5895
6046
|
if (!state.terminal) return;
|
|
5896
6047
|
if (balanceRefetchedForRef.current === withdrawalId) return;
|
|
@@ -5899,12 +6050,12 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5899
6050
|
client.syncManagedBalances().catch(() => {
|
|
5900
6051
|
});
|
|
5901
6052
|
}, [client, queryClient, state.terminal, withdrawalId]);
|
|
5902
|
-
const reset = (0,
|
|
6053
|
+
const reset = (0, import_react17.useCallback)(() => setState(INITIAL_STATE2), []);
|
|
5903
6054
|
return { state, reset };
|
|
5904
6055
|
}
|
|
5905
6056
|
|
|
5906
6057
|
// src/withdraw/use-withdraw-preview.ts
|
|
5907
|
-
var
|
|
6058
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
5908
6059
|
function useWithdrawPreview({
|
|
5909
6060
|
amountRaw,
|
|
5910
6061
|
tokenSymbol,
|
|
@@ -5914,7 +6065,7 @@ function useWithdrawPreview({
|
|
|
5914
6065
|
}) {
|
|
5915
6066
|
const client = useAggClient();
|
|
5916
6067
|
const enabled = !!amountRaw && BigInt(amountRaw || "0") > BigInt(0) && !!tokenSymbol && !!destinationChainId && !!destinationAddress;
|
|
5917
|
-
return (0,
|
|
6068
|
+
return (0, import_react_query20.useQuery)({
|
|
5918
6069
|
queryKey: [
|
|
5919
6070
|
"withdraw-preview",
|
|
5920
6071
|
tokenSymbol,
|
|
@@ -5938,7 +6089,7 @@ function useWithdrawPreview({
|
|
|
5938
6089
|
var import_sdk4 = require("@agg-build/sdk");
|
|
5939
6090
|
|
|
5940
6091
|
// src/use-geo-block.ts
|
|
5941
|
-
var
|
|
6092
|
+
var import_react18 = require("react");
|
|
5942
6093
|
var DEFAULT_STATE = {
|
|
5943
6094
|
isLocationBlocked: false,
|
|
5944
6095
|
isTradingBlocked: false,
|
|
@@ -5946,7 +6097,7 @@ var DEFAULT_STATE = {
|
|
|
5946
6097
|
};
|
|
5947
6098
|
function useGeoBlock() {
|
|
5948
6099
|
var _a, _b;
|
|
5949
|
-
const authContext = (0,
|
|
6100
|
+
const authContext = (0, import_react18.useContext)(AggAuthContext);
|
|
5950
6101
|
if (process.env.NEXT_PUBLIC_GEO_BLOCK_DISABLE === "true") return DEFAULT_STATE;
|
|
5951
6102
|
const isBlocked = (_b = (_a = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a.isLocationBlocked) != null ? _b : false;
|
|
5952
6103
|
if (!isBlocked) return DEFAULT_STATE;
|
|
@@ -5986,22 +6137,56 @@ var getVenueAvailabilityState = ({
|
|
|
5986
6137
|
};
|
|
5987
6138
|
|
|
5988
6139
|
// src/use-venue-key-status.ts
|
|
5989
|
-
var
|
|
6140
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
5990
6141
|
var venueKeyQueryKeys = {
|
|
5991
6142
|
all: ["agg", "venue-keys"],
|
|
5992
6143
|
status: (venue) => [...venueKeyQueryKeys.all, venue, "status"]
|
|
5993
6144
|
};
|
|
5994
6145
|
var useVenueKeyStatus = (venue, enabled = true) => {
|
|
5995
6146
|
const client = useAggClient();
|
|
5996
|
-
return (0,
|
|
6147
|
+
return (0, import_react_query21.useQuery)({
|
|
5997
6148
|
queryKey: venueKeyQueryKeys.status(venue),
|
|
5998
6149
|
queryFn: () => client.getVenueKeyStatus(venue),
|
|
5999
6150
|
enabled
|
|
6000
6151
|
});
|
|
6001
6152
|
};
|
|
6002
6153
|
|
|
6154
|
+
// src/use-shared-kyc.ts
|
|
6155
|
+
var import_react19 = require("react");
|
|
6156
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
6157
|
+
var sharedKycQueryKeys = {
|
|
6158
|
+
status: (userId) => ["agg", "shared-kyc", userId]
|
|
6159
|
+
};
|
|
6160
|
+
var useSharedKyc = () => {
|
|
6161
|
+
var _a, _b;
|
|
6162
|
+
const client = useAggClient();
|
|
6163
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
6164
|
+
const userId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
|
|
6165
|
+
const query = (0, import_react_query22.useQuery)({
|
|
6166
|
+
queryKey: sharedKycQueryKeys.status(userId),
|
|
6167
|
+
queryFn: () => client.getSharedKycStatus(),
|
|
6168
|
+
enabled: isAuthenticated && userId !== null,
|
|
6169
|
+
staleTime: 15e3,
|
|
6170
|
+
retry: false
|
|
6171
|
+
});
|
|
6172
|
+
const { refetch } = query;
|
|
6173
|
+
const refreshStatus = (0, import_react19.useCallback)(() => __async(null, null, function* () {
|
|
6174
|
+
var _a2;
|
|
6175
|
+
if (!isAuthenticated || !userId) return "unverified";
|
|
6176
|
+
const result = yield refetch({ cancelRefetch: false });
|
|
6177
|
+
if (result.error) throw result.error;
|
|
6178
|
+
return ((_a2 = result.data) == null ? void 0 : _a2.verified) === true ? "verified" : "unverified";
|
|
6179
|
+
}), [isAuthenticated, userId, refetch]);
|
|
6180
|
+
const initiateVerification = (0, import_react19.useCallback)(
|
|
6181
|
+
({ venue, redirectUri }) => client.initiateKyc(venue, redirectUri),
|
|
6182
|
+
[client]
|
|
6183
|
+
);
|
|
6184
|
+
const status = !isAuthenticated ? "unverified" : !userId || query.isPending ? "loading" : ((_b = query.data) == null ? void 0 : _b.verified) === true ? "verified" : "unverified";
|
|
6185
|
+
return { status, refreshStatus, initiateVerification };
|
|
6186
|
+
};
|
|
6187
|
+
|
|
6003
6188
|
// src/use-agg-auth.ts
|
|
6004
|
-
var
|
|
6189
|
+
var import_react20 = require("react");
|
|
6005
6190
|
function useAggAuth(options = {}) {
|
|
6006
6191
|
const {
|
|
6007
6192
|
isAuthenticated,
|
|
@@ -6011,7 +6196,7 @@ function useAggAuth(options = {}) {
|
|
|
6011
6196
|
signIn: signInWithProvider,
|
|
6012
6197
|
signOut
|
|
6013
6198
|
} = useAggAuthContext();
|
|
6014
|
-
const signIn = (0,
|
|
6199
|
+
const signIn = (0, import_react20.useCallback)(
|
|
6015
6200
|
(statement) => __async(null, null, function* () {
|
|
6016
6201
|
if (!options.signMessage) {
|
|
6017
6202
|
throw new Error(
|
|
@@ -6035,11 +6220,11 @@ function useAggAuth(options = {}) {
|
|
|
6035
6220
|
}
|
|
6036
6221
|
|
|
6037
6222
|
// src/use-link-account.ts
|
|
6038
|
-
var
|
|
6223
|
+
var import_react21 = require("react");
|
|
6039
6224
|
function useLinkAccount() {
|
|
6040
6225
|
const client = useAggClient();
|
|
6041
|
-
const [isLoading, setIsLoading] = (0,
|
|
6042
|
-
const [error, setError] = (0,
|
|
6226
|
+
const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
|
|
6227
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
6043
6228
|
const run = (fn) => {
|
|
6044
6229
|
setIsLoading(true);
|
|
6045
6230
|
setError(null);
|
|
@@ -6049,11 +6234,11 @@ function useLinkAccount() {
|
|
|
6049
6234
|
throw err;
|
|
6050
6235
|
}).finally(() => setIsLoading(false));
|
|
6051
6236
|
};
|
|
6052
|
-
const startLink = (0,
|
|
6237
|
+
const startLink = (0, import_react21.useCallback)(
|
|
6053
6238
|
(body) => run(() => client.linkAccount(body)),
|
|
6054
6239
|
[client]
|
|
6055
6240
|
);
|
|
6056
|
-
const confirmLink = (0,
|
|
6241
|
+
const confirmLink = (0, import_react21.useCallback)(
|
|
6057
6242
|
(input) => run(() => client.linkAccountConfirm(input)),
|
|
6058
6243
|
[client]
|
|
6059
6244
|
);
|
|
@@ -6068,7 +6253,7 @@ var requestAggAuthChooserOpen = () => {
|
|
|
6068
6253
|
};
|
|
6069
6254
|
|
|
6070
6255
|
// src/use-categories.ts
|
|
6071
|
-
var
|
|
6256
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
6072
6257
|
function useCategories(options) {
|
|
6073
6258
|
var _a, _b, _c, _d, _e, _f;
|
|
6074
6259
|
const client = useAggClient();
|
|
@@ -6076,7 +6261,7 @@ function useCategories(options) {
|
|
|
6076
6261
|
const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
|
|
6077
6262
|
const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
|
|
6078
6263
|
const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
|
|
6079
|
-
const query = (0,
|
|
6264
|
+
const query = (0, import_react_query23.useInfiniteQuery)({
|
|
6080
6265
|
queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
|
|
6081
6266
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
6082
6267
|
const res = yield client.getCategories(__spreadValues({
|
|
@@ -6108,7 +6293,7 @@ function useCategoryChildren(options) {
|
|
|
6108
6293
|
const parentIds = Array.from(
|
|
6109
6294
|
new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
|
|
6110
6295
|
);
|
|
6111
|
-
const queries = (0,
|
|
6296
|
+
const queries = (0, import_react_query23.useQueries)({
|
|
6112
6297
|
queries: parentIds.map((parentId) => ({
|
|
6113
6298
|
queryKey: [queryKeyScope, "parent", parentId, limit],
|
|
6114
6299
|
queryFn: () => __async(null, null, function* () {
|
|
@@ -6136,10 +6321,10 @@ function useCategoryChildren(options) {
|
|
|
6136
6321
|
}
|
|
6137
6322
|
|
|
6138
6323
|
// src/use-debounced-value.ts
|
|
6139
|
-
var
|
|
6324
|
+
var import_react22 = require("react");
|
|
6140
6325
|
function useDebouncedValue(value, delay) {
|
|
6141
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
6142
|
-
(0,
|
|
6326
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react22.useState)(value);
|
|
6327
|
+
(0, import_react22.useEffect)(() => {
|
|
6143
6328
|
const timeoutId = window.setTimeout(() => {
|
|
6144
6329
|
setDebouncedValue(value);
|
|
6145
6330
|
}, delay);
|
|
@@ -6151,7 +6336,7 @@ function useDebouncedValue(value, delay) {
|
|
|
6151
6336
|
}
|
|
6152
6337
|
|
|
6153
6338
|
// src/use-execution-orders.ts
|
|
6154
|
-
var
|
|
6339
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
6155
6340
|
function useExecutionOrders(options = {}) {
|
|
6156
6341
|
var _a, _b;
|
|
6157
6342
|
const client = useAggClient();
|
|
@@ -6165,7 +6350,7 @@ function useExecutionOrders(options = {}) {
|
|
|
6165
6350
|
enabled = true,
|
|
6166
6351
|
refetchIntervalMs = false
|
|
6167
6352
|
} = options;
|
|
6168
|
-
const query = (0,
|
|
6353
|
+
const query = (0, import_react_query24.useInfiniteQuery)({
|
|
6169
6354
|
// quoteId + orderId are part of the cache key — different filters
|
|
6170
6355
|
// produce different result sets, so they have to vary the key.
|
|
6171
6356
|
queryKey: [
|
|
@@ -6203,7 +6388,7 @@ function useExecutionOrders(options = {}) {
|
|
|
6203
6388
|
}
|
|
6204
6389
|
|
|
6205
6390
|
// src/use-user-activity.ts
|
|
6206
|
-
var
|
|
6391
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
6207
6392
|
var DEFAULT_PENDING_REFETCH_INTERVAL_MS = 15e3;
|
|
6208
6393
|
var PENDING_ACTIVITY_STATUSES = /* @__PURE__ */ new Set([
|
|
6209
6394
|
"pending",
|
|
@@ -6237,7 +6422,7 @@ function useUserActivity(options = {}) {
|
|
|
6237
6422
|
enabled = true,
|
|
6238
6423
|
pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
|
|
6239
6424
|
} = options;
|
|
6240
|
-
const query = (0,
|
|
6425
|
+
const query = (0, import_react_query25.useInfiniteQuery)({
|
|
6241
6426
|
queryKey: userActivityQueryKeys.feed(type, limit),
|
|
6242
6427
|
queryFn: ({ pageParam }) => client.getUserActivity({
|
|
6243
6428
|
type,
|
|
@@ -6254,7 +6439,7 @@ function useUserActivity(options = {}) {
|
|
|
6254
6439
|
// flight (typically after a deposit / withdraw cache invalidation).
|
|
6255
6440
|
// Without this the feed flashes to the skeleton mid-session, which
|
|
6256
6441
|
// is worse UX than briefly showing slightly-stale rows.
|
|
6257
|
-
placeholderData:
|
|
6442
|
+
placeholderData: import_react_query25.keepPreviousData,
|
|
6258
6443
|
refetchInterval: (q) => {
|
|
6259
6444
|
if (pendingRefetchIntervalMs === false) return false;
|
|
6260
6445
|
const data = q.state.data;
|
|
@@ -6270,13 +6455,13 @@ function useUserActivity(options = {}) {
|
|
|
6270
6455
|
}
|
|
6271
6456
|
|
|
6272
6457
|
// src/use-external-id.ts
|
|
6273
|
-
var
|
|
6458
|
+
var import_react23 = require("react");
|
|
6274
6459
|
function useExternalId(options = {}) {
|
|
6275
6460
|
const client = useAggClient();
|
|
6276
6461
|
const { onSuccess, onError: onErrorCb } = options;
|
|
6277
|
-
const [isLoading, setIsLoading] = (0,
|
|
6278
|
-
const [error, setError] = (0,
|
|
6279
|
-
const linkExternalId = (0,
|
|
6462
|
+
const [isLoading, setIsLoading] = (0, import_react23.useState)(false);
|
|
6463
|
+
const [error, setError] = (0, import_react23.useState)(null);
|
|
6464
|
+
const linkExternalId = (0, import_react23.useCallback)(
|
|
6280
6465
|
(assertion) => __async(null, null, function* () {
|
|
6281
6466
|
setIsLoading(true);
|
|
6282
6467
|
setError(null);
|
|
@@ -6299,12 +6484,12 @@ function useExternalId(options = {}) {
|
|
|
6299
6484
|
}
|
|
6300
6485
|
|
|
6301
6486
|
// src/use-execution-positions.ts
|
|
6302
|
-
var
|
|
6487
|
+
var import_react_query26 = require("@tanstack/react-query");
|
|
6303
6488
|
function useExecutionPositions(options = {}) {
|
|
6304
6489
|
var _a, _b;
|
|
6305
6490
|
const client = useAggClient();
|
|
6306
6491
|
const { limit = 50, status, mode, enabled = true } = options;
|
|
6307
|
-
const query = (0,
|
|
6492
|
+
const query = (0, import_react_query26.useInfiniteQuery)({
|
|
6308
6493
|
queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
|
|
6309
6494
|
queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
|
|
6310
6495
|
limit,
|
|
@@ -6328,17 +6513,17 @@ function useExecutionPositions(options = {}) {
|
|
|
6328
6513
|
}
|
|
6329
6514
|
|
|
6330
6515
|
// src/use-live-candle-overlay.ts
|
|
6331
|
-
var
|
|
6516
|
+
var import_react27 = require("react");
|
|
6332
6517
|
|
|
6333
6518
|
// src/use-live-candles.ts
|
|
6334
|
-
var
|
|
6519
|
+
var import_react26 = require("react");
|
|
6335
6520
|
var import_sdk3 = require("@agg-build/sdk");
|
|
6336
6521
|
|
|
6337
6522
|
// src/use-market-chart.ts
|
|
6338
|
-
var
|
|
6523
|
+
var import_react_query27 = require("@tanstack/react-query");
|
|
6339
6524
|
|
|
6340
6525
|
// src/market-data/subscription.ts
|
|
6341
|
-
var
|
|
6526
|
+
var import_react24 = require("react");
|
|
6342
6527
|
function useMarketDataSubscription({
|
|
6343
6528
|
marketId,
|
|
6344
6529
|
additionalMarketIds,
|
|
@@ -6347,7 +6532,7 @@ function useMarketDataSubscription({
|
|
|
6347
6532
|
trades = false
|
|
6348
6533
|
}) {
|
|
6349
6534
|
const ws = useAggWebSocket();
|
|
6350
|
-
const allIds = (0,
|
|
6535
|
+
const allIds = (0, import_react24.useMemo)(() => {
|
|
6351
6536
|
const ids = /* @__PURE__ */ new Set();
|
|
6352
6537
|
if (marketId) ids.add(marketId);
|
|
6353
6538
|
if (additionalMarketIds) {
|
|
@@ -6358,7 +6543,7 @@ function useMarketDataSubscription({
|
|
|
6358
6543
|
return [...ids];
|
|
6359
6544
|
}, [marketId, additionalMarketIds]);
|
|
6360
6545
|
const stableKey = allIds.join("|");
|
|
6361
|
-
(0,
|
|
6546
|
+
(0, import_react24.useEffect)(() => {
|
|
6362
6547
|
if (!ws || !allIds.length || !enabled || !orderbook && !trades) return;
|
|
6363
6548
|
const unsubscribers = [];
|
|
6364
6549
|
for (const id of allIds) {
|
|
@@ -6420,7 +6605,7 @@ function useMarketChart(options) {
|
|
|
6420
6605
|
orderbook: true,
|
|
6421
6606
|
trades: true
|
|
6422
6607
|
});
|
|
6423
|
-
const queries = (0,
|
|
6608
|
+
const queries = (0, import_react_query27.useQueries)({
|
|
6424
6609
|
queries: outcomeIds.map((outcomeId) => ({
|
|
6425
6610
|
// Cache key is intentionally time-free. The rolling window's
|
|
6426
6611
|
// startTs/endTs advance on every bucket but the user expects the same
|
|
@@ -6455,7 +6640,7 @@ function useMarketChart(options) {
|
|
|
6455
6640
|
gcTime: 60 * 6e4,
|
|
6456
6641
|
refetchOnWindowFocus: false,
|
|
6457
6642
|
retry: 1,
|
|
6458
|
-
placeholderData:
|
|
6643
|
+
placeholderData: import_react_query27.keepPreviousData,
|
|
6459
6644
|
refetchInterval: refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false,
|
|
6460
6645
|
refetchIntervalInBackground: false
|
|
6461
6646
|
}))
|
|
@@ -6486,13 +6671,13 @@ function useMarketChart(options) {
|
|
|
6486
6671
|
}
|
|
6487
6672
|
|
|
6488
6673
|
// src/use-live-market-stores.ts
|
|
6489
|
-
var
|
|
6674
|
+
var import_react25 = require("react");
|
|
6490
6675
|
function useLiveMarketStores(venueMarketIds) {
|
|
6491
6676
|
const ws = useAggWebSocket();
|
|
6492
|
-
const [, forceRender] = (0,
|
|
6493
|
-
const subsRef = (0,
|
|
6494
|
-
const stableKey = (0,
|
|
6495
|
-
(0,
|
|
6677
|
+
const [, forceRender] = (0, import_react25.useReducer)((c) => c + 1, 0);
|
|
6678
|
+
const subsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
6679
|
+
const stableKey = (0, import_react25.useMemo)(() => venueMarketIds.slice().sort().join("|"), [venueMarketIds]);
|
|
6680
|
+
(0, import_react25.useEffect)(() => {
|
|
6496
6681
|
if (!ws || venueMarketIds.length === 0) return;
|
|
6497
6682
|
const current = subsRef.current;
|
|
6498
6683
|
const desired = new Set(venueMarketIds);
|
|
@@ -6529,7 +6714,7 @@ function candleToLive(c, source) {
|
|
|
6529
6714
|
function useLiveCandles(options) {
|
|
6530
6715
|
var _a;
|
|
6531
6716
|
const { market, interval = "5m", mode = "venue", startTs, endTs } = options;
|
|
6532
|
-
const venueMarketIds = (0,
|
|
6717
|
+
const venueMarketIds = (0, import_react26.useMemo)(() => {
|
|
6533
6718
|
if (!market) return [];
|
|
6534
6719
|
if (mode === "venue") return [market.id];
|
|
6535
6720
|
const ids = [market.id];
|
|
@@ -6549,7 +6734,7 @@ function useLiveCandles(options) {
|
|
|
6549
6734
|
endTs: endTs != null ? endTs : null,
|
|
6550
6735
|
enabled: !!restMarketId && startTs != null && endTs != null
|
|
6551
6736
|
});
|
|
6552
|
-
const liveData = (0,
|
|
6737
|
+
const liveData = (0, import_react26.useMemo)(() => {
|
|
6553
6738
|
if (builders2.length === 0) return { closed: [], forming: null };
|
|
6554
6739
|
if (mode === "venue" || builders2.length === 1) {
|
|
6555
6740
|
return {
|
|
@@ -6562,7 +6747,7 @@ function useLiveCandles(options) {
|
|
|
6562
6747
|
forming: (0, import_sdk3.mergeCandles)(builders2.map((b) => b.getForming(interval)))
|
|
6563
6748
|
};
|
|
6564
6749
|
}, [builders2, interval, mode]);
|
|
6565
|
-
const candles = (0,
|
|
6750
|
+
const candles = (0, import_react26.useMemo)(() => {
|
|
6566
6751
|
const byTime = /* @__PURE__ */ new Map();
|
|
6567
6752
|
if (chartData) {
|
|
6568
6753
|
const venueEntries = Object.values(chartData.venues);
|
|
@@ -6587,7 +6772,7 @@ function useLiveCandles(options) {
|
|
|
6587
6772
|
merged.sort((a, b) => a.time - b.time);
|
|
6588
6773
|
return merged;
|
|
6589
6774
|
}, [chartData, liveData.closed]);
|
|
6590
|
-
const liveCandle = (0,
|
|
6775
|
+
const liveCandle = (0, import_react26.useMemo)(() => {
|
|
6591
6776
|
if (!liveData.forming) return null;
|
|
6592
6777
|
return candleToLive(liveData.forming, "live");
|
|
6593
6778
|
}, [liveData.forming]);
|
|
@@ -6635,7 +6820,7 @@ function useLiveCandleOverlay(options) {
|
|
|
6635
6820
|
startTs,
|
|
6636
6821
|
endTs
|
|
6637
6822
|
});
|
|
6638
|
-
const scaleCandle = (0,
|
|
6823
|
+
const scaleCandle = (0, import_react27.useCallback)(
|
|
6639
6824
|
(candle) => ({
|
|
6640
6825
|
time: candle.time,
|
|
6641
6826
|
open: candle.o * scale,
|
|
@@ -6646,8 +6831,8 @@ function useLiveCandleOverlay(options) {
|
|
|
6646
6831
|
}),
|
|
6647
6832
|
[scale]
|
|
6648
6833
|
);
|
|
6649
|
-
const scaledCandles = (0,
|
|
6650
|
-
const liveCandle = (0,
|
|
6834
|
+
const scaledCandles = (0, import_react27.useMemo)(() => rawCandles.map(scaleCandle), [rawCandles, scaleCandle]);
|
|
6835
|
+
const liveCandle = (0, import_react27.useMemo)(() => rawLive ? scaleCandle(rawLive) : null, [rawLive, scaleCandle]);
|
|
6651
6836
|
return {
|
|
6652
6837
|
liveCandle,
|
|
6653
6838
|
scaledCandles,
|
|
@@ -6658,7 +6843,7 @@ function useLiveCandleOverlay(options) {
|
|
|
6658
6843
|
}
|
|
6659
6844
|
|
|
6660
6845
|
// src/use-event-orderbook-data.ts
|
|
6661
|
-
var
|
|
6846
|
+
var import_react28 = require("react");
|
|
6662
6847
|
function extractSelectedOutcomeIds(selectedMarket) {
|
|
6663
6848
|
var _a, _b, _c;
|
|
6664
6849
|
if (!selectedMarket) return [];
|
|
@@ -6678,17 +6863,17 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
6678
6863
|
const {
|
|
6679
6864
|
features: { enableLiveUpdates }
|
|
6680
6865
|
} = useAggUiConfig();
|
|
6681
|
-
const selectedMarket = (0,
|
|
6866
|
+
const selectedMarket = (0, import_react28.useMemo)(() => {
|
|
6682
6867
|
var _a;
|
|
6683
6868
|
if (!selectedMarketId || !(venueMarkets == null ? void 0 : venueMarkets.length)) return null;
|
|
6684
6869
|
return (_a = venueMarkets.find((m) => m.id === selectedMarketId)) != null ? _a : null;
|
|
6685
6870
|
}, [venueMarkets, selectedMarketId]);
|
|
6686
|
-
const selectedOutcomeIds = (0,
|
|
6871
|
+
const selectedOutcomeIds = (0, import_react28.useMemo)(
|
|
6687
6872
|
() => extractSelectedOutcomeIds(selectedMarket),
|
|
6688
6873
|
[selectedMarket]
|
|
6689
6874
|
);
|
|
6690
6875
|
const selectedKey = selectedOutcomeIds.join("|");
|
|
6691
|
-
(0,
|
|
6876
|
+
(0, import_react28.useEffect)(() => {
|
|
6692
6877
|
if (!ws || !enableLiveUpdates || !selectedOutcomeIds.length) return;
|
|
6693
6878
|
const unsubscribers = selectedOutcomeIds.map((id) => ws.subscribe(id, "orderbook"));
|
|
6694
6879
|
return () => {
|
|
@@ -6698,7 +6883,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
6698
6883
|
}
|
|
6699
6884
|
|
|
6700
6885
|
// src/use-live-market.ts
|
|
6701
|
-
var
|
|
6886
|
+
var import_react_query28 = require("@tanstack/react-query");
|
|
6702
6887
|
function outcomeOrderbookToState(response, marketId) {
|
|
6703
6888
|
var _a, _b, _c, _d;
|
|
6704
6889
|
const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
|
|
@@ -6748,7 +6933,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6748
6933
|
enabled: isLiveSubscriptionEnabled,
|
|
6749
6934
|
orderbook: true
|
|
6750
6935
|
});
|
|
6751
|
-
const query = (0,
|
|
6936
|
+
const query = (0, import_react_query28.useQuery)({
|
|
6752
6937
|
queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
|
|
6753
6938
|
queryFn: () => __async(null, null, function* () {
|
|
6754
6939
|
return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
|
|
@@ -6760,7 +6945,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6760
6945
|
isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
|
|
6761
6946
|
})
|
|
6762
6947
|
});
|
|
6763
|
-
const seedQuery = (0,
|
|
6948
|
+
const seedQuery = (0, import_react_query28.useQuery)({
|
|
6764
6949
|
queryKey: ["live-market-seed", canonicalMarketId],
|
|
6765
6950
|
queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
|
|
6766
6951
|
enabled: Boolean(canonicalMarketId),
|
|
@@ -6780,8 +6965,8 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6780
6965
|
}
|
|
6781
6966
|
|
|
6782
6967
|
// src/use-live-outcome-prices.ts
|
|
6783
|
-
var
|
|
6784
|
-
var
|
|
6968
|
+
var import_react29 = require("react");
|
|
6969
|
+
var import_react_query29 = require("@tanstack/react-query");
|
|
6785
6970
|
var EMPTY_PRICES = /* @__PURE__ */ new Map();
|
|
6786
6971
|
var buildMidpointFingerprint = (outcomeIds, queries) => {
|
|
6787
6972
|
var _a, _b, _c;
|
|
@@ -6796,7 +6981,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6796
6981
|
const {
|
|
6797
6982
|
features: { enableLiveUpdates }
|
|
6798
6983
|
} = useAggUiConfig();
|
|
6799
|
-
const outcomeIds = (0,
|
|
6984
|
+
const outcomeIds = (0, import_react29.useMemo)(() => {
|
|
6800
6985
|
var _a, _b;
|
|
6801
6986
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
6802
6987
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -6810,7 +6995,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6810
6995
|
}
|
|
6811
6996
|
return [...ids].sort();
|
|
6812
6997
|
}, [venueMarkets]);
|
|
6813
|
-
const queries = (0,
|
|
6998
|
+
const queries = (0, import_react_query29.useQueries)({
|
|
6814
6999
|
queries: outcomeIds.map((id) => ({
|
|
6815
7000
|
queryKey: marketDataKeys.live(id),
|
|
6816
7001
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -6821,11 +7006,11 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6821
7006
|
}))
|
|
6822
7007
|
});
|
|
6823
7008
|
const fingerprint = buildMidpointFingerprint(outcomeIds, queries);
|
|
6824
|
-
const prevRef = (0,
|
|
7009
|
+
const prevRef = (0, import_react29.useRef)({
|
|
6825
7010
|
fingerprint: "",
|
|
6826
7011
|
prices: EMPTY_PRICES
|
|
6827
7012
|
});
|
|
6828
|
-
const data = (0,
|
|
7013
|
+
const data = (0, import_react29.useMemo)(() => {
|
|
6829
7014
|
var _a, _b, _c;
|
|
6830
7015
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return EMPTY_PRICES;
|
|
6831
7016
|
if (fingerprint === prevRef.current.fingerprint) {
|
|
@@ -6852,8 +7037,8 @@ function findLivePriceById(livePrices, id) {
|
|
|
6852
7037
|
}
|
|
6853
7038
|
|
|
6854
7039
|
// src/use-live-best-prices.ts
|
|
6855
|
-
var
|
|
6856
|
-
var
|
|
7040
|
+
var import_react30 = require("react");
|
|
7041
|
+
var import_react_query30 = require("@tanstack/react-query");
|
|
6857
7042
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
6858
7043
|
var EMPTY_CANDIDATES = /* @__PURE__ */ new Map();
|
|
6859
7044
|
var extractOutcomeBestPrices = (state) => {
|
|
@@ -6882,7 +7067,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6882
7067
|
const {
|
|
6883
7068
|
features: { enableLiveUpdates }
|
|
6884
7069
|
} = useAggUiConfig();
|
|
6885
|
-
const outcomeIds = (0,
|
|
7070
|
+
const outcomeIds = (0, import_react30.useMemo)(() => {
|
|
6886
7071
|
var _a, _b;
|
|
6887
7072
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
6888
7073
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -6896,7 +7081,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6896
7081
|
}
|
|
6897
7082
|
return [...ids].sort();
|
|
6898
7083
|
}, [venueMarkets]);
|
|
6899
|
-
const queries = (0,
|
|
7084
|
+
const queries = (0, import_react_query30.useQueries)({
|
|
6900
7085
|
queries: outcomeIds.map((id) => ({
|
|
6901
7086
|
queryKey: marketDataKeys.live(id),
|
|
6902
7087
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -6907,11 +7092,11 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6907
7092
|
}))
|
|
6908
7093
|
});
|
|
6909
7094
|
const fingerprint = buildFingerprint(outcomeIds, queries);
|
|
6910
|
-
const prevRef = (0,
|
|
7095
|
+
const prevRef = (0, import_react30.useRef)({
|
|
6911
7096
|
fingerprint: "",
|
|
6912
7097
|
result: EMPTY
|
|
6913
7098
|
});
|
|
6914
|
-
return (0,
|
|
7099
|
+
return (0, import_react30.useMemo)(() => {
|
|
6915
7100
|
var _a, _b, _c, _d;
|
|
6916
7101
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length) || !enableLiveUpdates) return EMPTY;
|
|
6917
7102
|
if (fingerprint === prevRef.current.fingerprint) return prevRef.current.result;
|
|
@@ -7101,7 +7286,7 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7101
7286
|
const {
|
|
7102
7287
|
features: { enableLiveUpdates }
|
|
7103
7288
|
} = useAggUiConfig();
|
|
7104
|
-
const outcomeIds = (0,
|
|
7289
|
+
const outcomeIds = (0, import_react30.useMemo)(() => {
|
|
7105
7290
|
var _a, _b;
|
|
7106
7291
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
7107
7292
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -7115,7 +7300,7 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7115
7300
|
}
|
|
7116
7301
|
return [...ids].sort();
|
|
7117
7302
|
}, [venueMarkets]);
|
|
7118
|
-
const queries = (0,
|
|
7303
|
+
const queries = (0, import_react_query30.useQueries)({
|
|
7119
7304
|
queries: outcomeIds.map((id) => ({
|
|
7120
7305
|
queryKey: marketDataKeys.live(id),
|
|
7121
7306
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -7126,11 +7311,11 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7126
7311
|
}))
|
|
7127
7312
|
});
|
|
7128
7313
|
const fingerprint = buildCandidateFingerprint(outcomeIds, queries);
|
|
7129
|
-
const prevRef = (0,
|
|
7314
|
+
const prevRef = (0, import_react30.useRef)({
|
|
7130
7315
|
fingerprint: "",
|
|
7131
7316
|
result: EMPTY_CANDIDATES
|
|
7132
7317
|
});
|
|
7133
|
-
return (0,
|
|
7318
|
+
return (0, import_react30.useMemo)(() => {
|
|
7134
7319
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length) || !enableLiveUpdates) return EMPTY_CANDIDATES;
|
|
7135
7320
|
if (fingerprint === prevRef.current.fingerprint) return prevRef.current.result;
|
|
7136
7321
|
const states = outcomeIds.map((_, i) => {
|
|
@@ -7159,8 +7344,8 @@ function useLiveTrades(canonicalMarketId) {
|
|
|
7159
7344
|
}
|
|
7160
7345
|
|
|
7161
7346
|
// src/use-midpoints.ts
|
|
7162
|
-
var
|
|
7163
|
-
var
|
|
7347
|
+
var import_react_query31 = require("@tanstack/react-query");
|
|
7348
|
+
var import_react31 = require("react");
|
|
7164
7349
|
var normalizeVenueMarketIds = (venueMarkets) => {
|
|
7165
7350
|
var _a;
|
|
7166
7351
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -7333,12 +7518,12 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7333
7518
|
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
7334
7519
|
} = useAggUiConfig();
|
|
7335
7520
|
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
7336
|
-
const ids = (0,
|
|
7337
|
-
const bestMidpointCandidateOutcomeIds = (0,
|
|
7521
|
+
const ids = (0, import_react31.useMemo)(() => normalizeVenueMarketIds(venueMarkets), [venueMarkets]);
|
|
7522
|
+
const bestMidpointCandidateOutcomeIds = (0, import_react31.useMemo)(
|
|
7338
7523
|
() => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
|
|
7339
7524
|
[venueMarkets]
|
|
7340
7525
|
);
|
|
7341
|
-
const { data, isLoading } = (0,
|
|
7526
|
+
const { data, isLoading } = (0, import_react_query31.useQuery)({
|
|
7342
7527
|
queryKey: ["midpoints", ids, maxMidpointIdsPerRequest],
|
|
7343
7528
|
queryFn: () => client.getMidpoints(ids, { bestPrice: true, maxMidpointIdsPerRequest }),
|
|
7344
7529
|
enabled: ids.length > 0,
|
|
@@ -7348,7 +7533,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7348
7533
|
refetchOnWindowFocus: false,
|
|
7349
7534
|
refetchOnReconnect: false
|
|
7350
7535
|
});
|
|
7351
|
-
const result = (0,
|
|
7536
|
+
const result = (0, import_react31.useMemo)(() => {
|
|
7352
7537
|
var _a2, _b, _c, _d, _e, _f;
|
|
7353
7538
|
const map = /* @__PURE__ */ new Map();
|
|
7354
7539
|
const currentMap = /* @__PURE__ */ new Map();
|
|
@@ -7401,7 +7586,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7401
7586
|
}
|
|
7402
7587
|
return { map, currentMap, venueMap };
|
|
7403
7588
|
}, [data, venueMarkets]);
|
|
7404
|
-
const { bestMidpoint, bestMidpointVenue } = (0,
|
|
7589
|
+
const { bestMidpoint, bestMidpointVenue } = (0, import_react31.useMemo)(() => {
|
|
7405
7590
|
let value;
|
|
7406
7591
|
let venue;
|
|
7407
7592
|
for (const outcomeId of bestMidpointCandidateOutcomeIds) {
|
|
@@ -7422,7 +7607,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7422
7607
|
}
|
|
7423
7608
|
return { bestMidpoint: value, bestMidpointVenue: venue };
|
|
7424
7609
|
}, [bestMidpointCandidateOutcomeIds, result.map, result.venueMap]);
|
|
7425
|
-
const { bestPrices, bestPriceVenuesByOutcomeId } = (0,
|
|
7610
|
+
const { bestPrices, bestPriceVenuesByOutcomeId } = (0, import_react31.useMemo)(
|
|
7426
7611
|
() => extractBestPrices(data == null ? void 0 : data.data, venueMarkets),
|
|
7427
7612
|
[data == null ? void 0 : data.data, venueMarkets]
|
|
7428
7613
|
);
|
|
@@ -7440,7 +7625,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7440
7625
|
}
|
|
7441
7626
|
|
|
7442
7627
|
// src/use-rolling-chart-window.ts
|
|
7443
|
-
var
|
|
7628
|
+
var import_react32 = require("react");
|
|
7444
7629
|
var RANGE_SECONDS_BY_RANGE = {
|
|
7445
7630
|
"1H": 60 * 60,
|
|
7446
7631
|
"6H": 6 * 60 * 60,
|
|
@@ -7471,26 +7656,26 @@ var useRollingChartWindow = (options) => {
|
|
|
7471
7656
|
var _a;
|
|
7472
7657
|
const tickMs = (_a = options.tickMs) != null ? _a : 1e3;
|
|
7473
7658
|
const optionsNowMs = options.nowMs;
|
|
7474
|
-
const nowMs = (0,
|
|
7475
|
-
const [nowSec, setNowSec] = (0,
|
|
7476
|
-
(0,
|
|
7659
|
+
const nowMs = (0, import_react32.useMemo)(() => optionsNowMs != null ? optionsNowMs : (() => Date.now()), [optionsNowMs]);
|
|
7660
|
+
const [nowSec, setNowSec] = (0, import_react32.useState)(() => Math.floor(nowMs() / 1e3));
|
|
7661
|
+
(0, import_react32.useEffect)(() => {
|
|
7477
7662
|
setNowSec(Math.floor(nowMs() / 1e3));
|
|
7478
7663
|
const handle = setInterval(() => {
|
|
7479
7664
|
setNowSec(Math.floor(nowMs() / 1e3));
|
|
7480
7665
|
}, tickMs);
|
|
7481
7666
|
return () => clearInterval(handle);
|
|
7482
7667
|
}, [tickMs, nowMs]);
|
|
7483
|
-
return (0,
|
|
7668
|
+
return (0, import_react32.useMemo)(
|
|
7484
7669
|
() => resolveRollingWindow({ range: options.range, nowSec, interval: options.interval }),
|
|
7485
7670
|
[options.range, options.interval, nowSec]
|
|
7486
7671
|
);
|
|
7487
7672
|
};
|
|
7488
7673
|
|
|
7489
7674
|
// src/use-market-orderbook.ts
|
|
7490
|
-
var
|
|
7675
|
+
var import_react_query32 = require("@tanstack/react-query");
|
|
7491
7676
|
function useMarketOrderbook(options) {
|
|
7492
7677
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7493
|
-
const queryClient = (0,
|
|
7678
|
+
const queryClient = (0, import_react_query32.useQueryClient)();
|
|
7494
7679
|
const ws = useAggWebSocket();
|
|
7495
7680
|
const isConnected = useAggWebSocketConnectionState();
|
|
7496
7681
|
const {
|
|
@@ -7508,7 +7693,7 @@ function useMarketOrderbook(options) {
|
|
|
7508
7693
|
enabled: enabled && !!selectedOutcomeId,
|
|
7509
7694
|
orderbook: true
|
|
7510
7695
|
});
|
|
7511
|
-
const liveQueries = (0,
|
|
7696
|
+
const liveQueries = (0, import_react_query32.useQueries)({
|
|
7512
7697
|
queries: subscriptionIds.map((subscriptionId) => ({
|
|
7513
7698
|
queryKey: marketDataKeys.live(subscriptionId),
|
|
7514
7699
|
queryFn: () => createMarketLiveState(subscriptionId),
|
|
@@ -7574,11 +7759,11 @@ function useMarketOrderbook(options) {
|
|
|
7574
7759
|
}
|
|
7575
7760
|
|
|
7576
7761
|
// src/use-arb.ts
|
|
7577
|
-
var
|
|
7762
|
+
var import_react33 = require("react");
|
|
7578
7763
|
function useMarketArb(marketId) {
|
|
7579
7764
|
const ws = useAggWebSocket();
|
|
7580
|
-
const [state, setState] = (0,
|
|
7581
|
-
(0,
|
|
7765
|
+
const [state, setState] = (0, import_react33.useState)({ arbReturn: null, isLive: false });
|
|
7766
|
+
(0, import_react33.useEffect)(() => {
|
|
7582
7767
|
if (!ws || !marketId) return;
|
|
7583
7768
|
const cached = ws.getArb(marketId);
|
|
7584
7769
|
if (cached != null) {
|
|
@@ -7597,10 +7782,10 @@ var EMPTY_ARB_FEED = {
|
|
|
7597
7782
|
};
|
|
7598
7783
|
function useArbFeed() {
|
|
7599
7784
|
const ws = useAggWebSocket();
|
|
7600
|
-
const [state, setState] = (0,
|
|
7601
|
-
const stateRef = (0,
|
|
7785
|
+
const [state, setState] = (0, import_react33.useState)(EMPTY_ARB_FEED);
|
|
7786
|
+
const stateRef = (0, import_react33.useRef)(state);
|
|
7602
7787
|
stateRef.current = state;
|
|
7603
|
-
(0,
|
|
7788
|
+
(0, import_react33.useEffect)(() => {
|
|
7604
7789
|
if (!ws) return;
|
|
7605
7790
|
const off = ws.subscribeArbFeed((batch) => {
|
|
7606
7791
|
setState((prev) => {
|
|
@@ -7632,7 +7817,7 @@ function useArbFeed() {
|
|
|
7632
7817
|
}
|
|
7633
7818
|
|
|
7634
7819
|
// src/use-order-book.ts
|
|
7635
|
-
var
|
|
7820
|
+
var import_react_query33 = require("@tanstack/react-query");
|
|
7636
7821
|
function useOrderBook(options) {
|
|
7637
7822
|
const client = useAggClient();
|
|
7638
7823
|
const { orderbooks, enabled = true, canonicalMarketId } = options;
|
|
@@ -7645,7 +7830,7 @@ function useOrderBook(options) {
|
|
|
7645
7830
|
venueMarketOutcomeId: outcome.id
|
|
7646
7831
|
})) : void 0
|
|
7647
7832
|
});
|
|
7648
|
-
const batchedResult = (0,
|
|
7833
|
+
const batchedResult = (0, import_react_query33.useQuery)({
|
|
7649
7834
|
queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
|
|
7650
7835
|
queryFn: ({ signal }) => client.getOrderbooks(
|
|
7651
7836
|
{
|
|
@@ -7658,7 +7843,7 @@ function useOrderBook(options) {
|
|
|
7658
7843
|
gcTime: 5 * 6e4,
|
|
7659
7844
|
refetchOnWindowFocus: false,
|
|
7660
7845
|
retry: 1,
|
|
7661
|
-
placeholderData:
|
|
7846
|
+
placeholderData: import_react_query33.keepPreviousData
|
|
7662
7847
|
});
|
|
7663
7848
|
const data = (() => {
|
|
7664
7849
|
var _a, _b;
|
|
@@ -7713,7 +7898,7 @@ function useOrderBook(options) {
|
|
|
7713
7898
|
}
|
|
7714
7899
|
|
|
7715
7900
|
// src/use-orderbook-quote.ts
|
|
7716
|
-
var
|
|
7901
|
+
var import_react_query34 = require("@tanstack/react-query");
|
|
7717
7902
|
var QUOTE_DEBOUNCE_MS = 300;
|
|
7718
7903
|
var createUnavailableOrderbookError = (message, code, retryable) => {
|
|
7719
7904
|
const error = new Error(message);
|
|
@@ -7775,7 +7960,7 @@ function useOrderbookQuote(options) {
|
|
|
7775
7960
|
const { marketId, side, size, enabled = true } = options;
|
|
7776
7961
|
const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
|
|
7777
7962
|
const shouldFetch = enabled && !!marketId && debouncedSize > 0;
|
|
7778
|
-
const query = (0,
|
|
7963
|
+
const query = (0, import_react_query34.useQuery)({
|
|
7779
7964
|
queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
|
|
7780
7965
|
queryFn: () => __async(null, null, function* () {
|
|
7781
7966
|
var _a2, _b, _c, _d;
|
|
@@ -7806,7 +7991,7 @@ function useOrderbookQuote(options) {
|
|
|
7806
7991
|
staleTime: 1e4,
|
|
7807
7992
|
gcTime: 5 * 6e4,
|
|
7808
7993
|
retry: 1,
|
|
7809
|
-
placeholderData:
|
|
7994
|
+
placeholderData: import_react_query34.keepPreviousData
|
|
7810
7995
|
});
|
|
7811
7996
|
return {
|
|
7812
7997
|
data: (_a = query.data) != null ? _a : null,
|
|
@@ -7817,12 +8002,12 @@ function useOrderbookQuote(options) {
|
|
|
7817
8002
|
}
|
|
7818
8003
|
|
|
7819
8004
|
// src/use-orders.ts
|
|
7820
|
-
var
|
|
8005
|
+
var import_react_query35 = require("@tanstack/react-query");
|
|
7821
8006
|
function useOrders(options = {}) {
|
|
7822
8007
|
var _a, _b, _c, _d;
|
|
7823
8008
|
const client = useAggClient();
|
|
7824
8009
|
const { userId, status, limit = 50, offset = 0, enabled = true } = options;
|
|
7825
|
-
const query = (0,
|
|
8010
|
+
const query = (0, import_react_query35.useQuery)({
|
|
7826
8011
|
queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
|
|
7827
8012
|
queryFn: () => client.getOrders({
|
|
7828
8013
|
userId,
|
|
@@ -7839,16 +8024,16 @@ function useOrders(options = {}) {
|
|
|
7839
8024
|
}
|
|
7840
8025
|
|
|
7841
8026
|
// src/use-search.ts
|
|
7842
|
-
var
|
|
7843
|
-
var
|
|
8027
|
+
var import_react_query36 = require("@tanstack/react-query");
|
|
8028
|
+
var import_react34 = require("react");
|
|
7844
8029
|
function useSearch(options) {
|
|
7845
8030
|
var _a, _b, _c, _d;
|
|
7846
|
-
const client = (0,
|
|
7847
|
-
const queryClient = (0,
|
|
7848
|
-
const [fallbackQueryClient] = (0,
|
|
8031
|
+
const client = (0, import_react34.useContext)(AggClientContext);
|
|
8032
|
+
const queryClient = (0, import_react34.useContext)(import_react_query36.QueryClientContext);
|
|
8033
|
+
const [fallbackQueryClient] = (0, import_react34.useState)(() => new import_react_query36.QueryClient());
|
|
7849
8034
|
const { q, type, categoryIds, status, limit = 20, enabled = true, deep = false } = options;
|
|
7850
8035
|
const isEnabled = enabled && q.length > 0;
|
|
7851
|
-
(0,
|
|
8036
|
+
(0, import_react34.useEffect)(() => {
|
|
7852
8037
|
if (queryClient) return void 0;
|
|
7853
8038
|
fallbackQueryClient.mount();
|
|
7854
8039
|
return () => {
|
|
@@ -7858,7 +8043,7 @@ function useSearch(options) {
|
|
|
7858
8043
|
if (isEnabled && !client) {
|
|
7859
8044
|
throw new Error("useSearch must be used within an <AggProvider>");
|
|
7860
8045
|
}
|
|
7861
|
-
const query = (0,
|
|
8046
|
+
const query = (0, import_react_query36.useInfiniteQuery)(
|
|
7862
8047
|
{
|
|
7863
8048
|
// deep is part of the key — TanStack treats deep vs light as
|
|
7864
8049
|
// independent queries so users can have both modes cached side-by-side.
|
|
@@ -7892,7 +8077,7 @@ function useSearch(options) {
|
|
|
7892
8077
|
if (!lastPage.hasMore) return void 0;
|
|
7893
8078
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
7894
8079
|
},
|
|
7895
|
-
placeholderData:
|
|
8080
|
+
placeholderData: import_react_query36.keepPreviousData,
|
|
7896
8081
|
enabled: isEnabled && !!client
|
|
7897
8082
|
},
|
|
7898
8083
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
@@ -7911,7 +8096,7 @@ function useSearch(options) {
|
|
|
7911
8096
|
}
|
|
7912
8097
|
|
|
7913
8098
|
// src/use-market-search.ts
|
|
7914
|
-
var
|
|
8099
|
+
var import_react35 = require("react");
|
|
7915
8100
|
function useMarketSearch(options) {
|
|
7916
8101
|
var _a;
|
|
7917
8102
|
const {
|
|
@@ -7923,8 +8108,8 @@ function useMarketSearch(options) {
|
|
|
7923
8108
|
enableSuggestions = true,
|
|
7924
8109
|
minLength = 1
|
|
7925
8110
|
} = options;
|
|
7926
|
-
const [query, setQueryState] = (0,
|
|
7927
|
-
const [submittedQuery, setSubmittedQuery] = (0,
|
|
8111
|
+
const [query, setQueryState] = (0, import_react35.useState)("");
|
|
8112
|
+
const [submittedQuery, setSubmittedQuery] = (0, import_react35.useState)(null);
|
|
7928
8113
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
7929
8114
|
const trimmedDebounced = debouncedQuery.trim();
|
|
7930
8115
|
const suggestionsEnabled = enableSuggestions && trimmedDebounced.length >= minLength;
|
|
@@ -7947,10 +8132,10 @@ function useMarketSearch(options) {
|
|
|
7947
8132
|
enabled: submittedQ.length > 0,
|
|
7948
8133
|
deep: true
|
|
7949
8134
|
});
|
|
7950
|
-
const setQuery = (0,
|
|
8135
|
+
const setQuery = (0, import_react35.useCallback)((value) => {
|
|
7951
8136
|
setQueryState(value);
|
|
7952
8137
|
}, []);
|
|
7953
|
-
const submit = (0,
|
|
8138
|
+
const submit = (0, import_react35.useCallback)(
|
|
7954
8139
|
(q) => {
|
|
7955
8140
|
const target = (q != null ? q : query).trim();
|
|
7956
8141
|
if (target.length === 0) return;
|
|
@@ -7958,7 +8143,7 @@ function useMarketSearch(options) {
|
|
|
7958
8143
|
},
|
|
7959
8144
|
[query]
|
|
7960
8145
|
);
|
|
7961
|
-
const clear = (0,
|
|
8146
|
+
const clear = (0, import_react35.useCallback)(() => {
|
|
7962
8147
|
setQueryState("");
|
|
7963
8148
|
setSubmittedQuery(null);
|
|
7964
8149
|
}, []);
|
|
@@ -8000,7 +8185,7 @@ function useMarketSearch(options) {
|
|
|
8000
8185
|
}
|
|
8001
8186
|
|
|
8002
8187
|
// src/use-smart-route.ts
|
|
8003
|
-
var
|
|
8188
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
8004
8189
|
|
|
8005
8190
|
// src/smart-route-refresh-policy.ts
|
|
8006
8191
|
var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
|
|
@@ -8150,7 +8335,7 @@ function useSmartRoute(options) {
|
|
|
8150
8335
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
8151
8336
|
const hasValidInput = (maxSpend != null ? maxSpend : 0) > 0 || (sellShares != null ? sellShares : 0) > 0;
|
|
8152
8337
|
const queryEnabled = enabled && !!resolvedVenueMarketOutcomeId && hasValidInput;
|
|
8153
|
-
const query = (0,
|
|
8338
|
+
const query = (0, import_react_query37.useQuery)({
|
|
8154
8339
|
queryKey: [
|
|
8155
8340
|
"smart-route",
|
|
8156
8341
|
resolvedVenueMarketOutcomeId,
|
|
@@ -8209,7 +8394,7 @@ function useSmartRoute(options) {
|
|
|
8209
8394
|
// a different amount or position snapshot. Never expose it under a new
|
|
8210
8395
|
// sell key while the replacement request is in flight. BUY retains the
|
|
8211
8396
|
// existing no-flicker behavior.
|
|
8212
|
-
placeholderData: tradeSide === "sell" ? void 0 :
|
|
8397
|
+
placeholderData: tradeSide === "sell" ? void 0 : import_react_query37.keepPreviousData
|
|
8213
8398
|
});
|
|
8214
8399
|
const error = query.error;
|
|
8215
8400
|
let loadingReason = null;
|
|
@@ -8231,7 +8416,7 @@ function useSmartRoute(options) {
|
|
|
8231
8416
|
}
|
|
8232
8417
|
|
|
8233
8418
|
// src/use-limit-order-venue-quotes.ts
|
|
8234
|
-
var
|
|
8419
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
8235
8420
|
var getIsDocumentVisible2 = () => {
|
|
8236
8421
|
if (typeof document === "undefined") return true;
|
|
8237
8422
|
return document.visibilityState !== "hidden";
|
|
@@ -8286,7 +8471,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8286
8471
|
const hasRequiredAccount = tradeSide === "buy" || Boolean(accountId);
|
|
8287
8472
|
const queryEnabled = enabled && hasValidInput && hasRequiredAccount;
|
|
8288
8473
|
const serializedChainBalances = chainBalances ? JSON.stringify(chainBalances) : null;
|
|
8289
|
-
const tickMetadataQuery = (0,
|
|
8474
|
+
const tickMetadataQuery = (0, import_react_query38.useQuery)({
|
|
8290
8475
|
queryKey: ["orderbooks", marketId != null ? marketId : "__disabled__", "limit-order-ticks"],
|
|
8291
8476
|
queryFn: ({ signal }) => client.getOrderbooks({ venueMarketIds: [marketId] }, { signal }),
|
|
8292
8477
|
enabled: enabled && Boolean(marketId),
|
|
@@ -8295,7 +8480,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8295
8480
|
refetchOnWindowFocus: false,
|
|
8296
8481
|
retry: 1
|
|
8297
8482
|
});
|
|
8298
|
-
const queries = (0,
|
|
8483
|
+
const queries = (0, import_react_query38.useQueries)({
|
|
8299
8484
|
queries: uniqueRequests.map((request) => ({
|
|
8300
8485
|
queryKey: [
|
|
8301
8486
|
"smart-route",
|
|
@@ -8327,7 +8512,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8327
8512
|
);
|
|
8328
8513
|
}),
|
|
8329
8514
|
enabled: queryEnabled,
|
|
8330
|
-
placeholderData:
|
|
8515
|
+
placeholderData: import_react_query38.keepPreviousData,
|
|
8331
8516
|
staleTime: staleTimeMs,
|
|
8332
8517
|
refetchInterval: (queryState) => {
|
|
8333
8518
|
var _a2, _b2, _c, _d;
|
|
@@ -8377,7 +8562,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8377
8562
|
};
|
|
8378
8563
|
|
|
8379
8564
|
// src/use-venue-sell-quotes.ts
|
|
8380
|
-
var
|
|
8565
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
8381
8566
|
var getIsDocumentVisible3 = () => {
|
|
8382
8567
|
if (typeof document === "undefined") return true;
|
|
8383
8568
|
return document.visibilityState !== "hidden";
|
|
@@ -8408,7 +8593,7 @@ var useVenueSellQuotes = (options) => {
|
|
|
8408
8593
|
refreshContext
|
|
8409
8594
|
} = options;
|
|
8410
8595
|
const uniqueRequests = getUniqueVenueRequests2(requests);
|
|
8411
|
-
const queries = (0,
|
|
8596
|
+
const queries = (0, import_react_query39.useQueries)({
|
|
8412
8597
|
queries: uniqueRequests.map((request) => {
|
|
8413
8598
|
const hasValidInput = request.requestedSellShares > 0 && request.sellShares > 0 && request.availableShares > 0;
|
|
8414
8599
|
const queryEnabled = enabled && !!venueMarketOutcomeId && !!accountId && hasValidInput;
|
|
@@ -8491,12 +8676,12 @@ var useVenueSellQuotes = (options) => {
|
|
|
8491
8676
|
};
|
|
8492
8677
|
|
|
8493
8678
|
// src/use-user-holdings.ts
|
|
8494
|
-
var
|
|
8679
|
+
var import_react_query40 = require("@tanstack/react-query");
|
|
8495
8680
|
function useUserHoldings(options) {
|
|
8496
8681
|
var _a, _b;
|
|
8497
8682
|
const client = useAggClient();
|
|
8498
8683
|
const { venue, venueMarketId, venueEventId, enabled = true } = options;
|
|
8499
|
-
const query = (0,
|
|
8684
|
+
const query = (0, import_react_query40.useInfiniteQuery)({
|
|
8500
8685
|
queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
|
|
8501
8686
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
8502
8687
|
return client.getUserHoldings({
|
|
@@ -8522,13 +8707,13 @@ function useUserHoldings(options) {
|
|
|
8522
8707
|
}
|
|
8523
8708
|
|
|
8524
8709
|
// src/use-enriched-venue-event.ts
|
|
8525
|
-
var
|
|
8710
|
+
var import_react37 = require("react");
|
|
8526
8711
|
|
|
8527
8712
|
// src/use-venue-event.ts
|
|
8528
|
-
var
|
|
8713
|
+
var import_react_query42 = require("@tanstack/react-query");
|
|
8529
8714
|
|
|
8530
8715
|
// src/use-recurring-crypto-markets.ts
|
|
8531
|
-
var
|
|
8716
|
+
var import_react_query41 = require("@tanstack/react-query");
|
|
8532
8717
|
var RESOLVING_POLL_INTERVAL_MS = 15e3;
|
|
8533
8718
|
var FALLBACK_VENUE_EVENT_PAGE_LIMIT = 100;
|
|
8534
8719
|
var FALLBACK_VENUE_EVENT_MAX_PAGES = 5;
|
|
@@ -9022,7 +9207,7 @@ var useRecurringCryptoMarkets = ({
|
|
|
9022
9207
|
const client = useAggClient();
|
|
9023
9208
|
const identity = event ? resolveRecurringCryptoIdentity(event) : null;
|
|
9024
9209
|
const isEnabled = enabled && event != null && identity != null;
|
|
9025
|
-
const query = (0,
|
|
9210
|
+
const query = (0, import_react_query41.useQuery)({
|
|
9026
9211
|
queryKey: [
|
|
9027
9212
|
"recurring-crypto-markets",
|
|
9028
9213
|
event == null ? void 0 : event.id,
|
|
@@ -9084,7 +9269,7 @@ function useVenueEvent(options) {
|
|
|
9084
9269
|
var _a;
|
|
9085
9270
|
const client = useAggClient();
|
|
9086
9271
|
const { eventId, enabled = true, cluster } = options;
|
|
9087
|
-
const query = (0,
|
|
9272
|
+
const query = (0, import_react_query42.useQuery)({
|
|
9088
9273
|
queryKey: ["venue-event", eventId, cluster === false ? "no-cluster" : ""],
|
|
9089
9274
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
9090
9275
|
return client.getVenueEventById(eventId, { signal, cluster });
|
|
@@ -9104,13 +9289,13 @@ function useVenueEvent(options) {
|
|
|
9104
9289
|
}
|
|
9105
9290
|
|
|
9106
9291
|
// src/use-venue-markets.ts
|
|
9107
|
-
var
|
|
9108
|
-
var
|
|
9292
|
+
var import_react_query43 = require("@tanstack/react-query");
|
|
9293
|
+
var import_react36 = require("react");
|
|
9109
9294
|
function useVenueMarkets(options) {
|
|
9110
9295
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9111
|
-
const client = (0,
|
|
9112
|
-
const queryClient = (0,
|
|
9113
|
-
const [fallbackQueryClient] = (0,
|
|
9296
|
+
const client = (0, import_react36.useContext)(AggClientContext);
|
|
9297
|
+
const queryClient = (0, import_react36.useContext)(import_react_query43.QueryClientContext);
|
|
9298
|
+
const [fallbackQueryClient] = (0, import_react36.useState)(() => new import_react_query43.QueryClient());
|
|
9114
9299
|
const venue = options == null ? void 0 : options.venue;
|
|
9115
9300
|
const venueEventId = options == null ? void 0 : options.venueEventId;
|
|
9116
9301
|
const cluster = options == null ? void 0 : options.cluster;
|
|
@@ -9128,7 +9313,7 @@ function useVenueMarkets(options) {
|
|
|
9128
9313
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
9129
9314
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
9130
9315
|
const context = options == null ? void 0 : options.context;
|
|
9131
|
-
(0,
|
|
9316
|
+
(0, import_react36.useEffect)(() => {
|
|
9132
9317
|
if (queryClient) return void 0;
|
|
9133
9318
|
fallbackQueryClient.mount();
|
|
9134
9319
|
return () => {
|
|
@@ -9138,7 +9323,7 @@ function useVenueMarkets(options) {
|
|
|
9138
9323
|
if (enabled && !client) {
|
|
9139
9324
|
throw new Error("useVenueMarkets must be used within an <AggProvider>");
|
|
9140
9325
|
}
|
|
9141
|
-
const query = (0,
|
|
9326
|
+
const query = (0, import_react_query43.useInfiniteQuery)(
|
|
9142
9327
|
{
|
|
9143
9328
|
queryKey: [
|
|
9144
9329
|
"venue-markets",
|
|
@@ -9198,7 +9383,7 @@ function useVenueMarkets(options) {
|
|
|
9198
9383
|
const hasNextPage = !!query.hasNextPage;
|
|
9199
9384
|
const { fetchNextPage, isFetchingNextPage } = query;
|
|
9200
9385
|
const fetchAll = (_k = options == null ? void 0 : options.fetchAll) != null ? _k : false;
|
|
9201
|
-
(0,
|
|
9386
|
+
(0, import_react36.useEffect)(() => {
|
|
9202
9387
|
if (!fetchAll || !hasNextPage || isFetchingNextPage) return;
|
|
9203
9388
|
void fetchNextPage();
|
|
9204
9389
|
}, [fetchAll, hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
@@ -9249,7 +9434,7 @@ function useEnrichedVenueEvent(options) {
|
|
|
9249
9434
|
});
|
|
9250
9435
|
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
9251
9436
|
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
|
9252
|
-
const enrichedEvent = (0,
|
|
9437
|
+
const enrichedEvent = (0, import_react37.useMemo)(() => {
|
|
9253
9438
|
if (!event) return void 0;
|
|
9254
9439
|
if (markets.length === 0) return event;
|
|
9255
9440
|
return mergeEventWithFullMarkets(event, markets);
|
|
@@ -9263,13 +9448,13 @@ function useEnrichedVenueEvent(options) {
|
|
|
9263
9448
|
}
|
|
9264
9449
|
|
|
9265
9450
|
// src/use-venue-events.ts
|
|
9266
|
-
var
|
|
9267
|
-
var
|
|
9451
|
+
var import_react_query44 = require("@tanstack/react-query");
|
|
9452
|
+
var import_react38 = require("react");
|
|
9268
9453
|
function useVenueEvents(options) {
|
|
9269
9454
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9270
|
-
const client = (0,
|
|
9271
|
-
const queryClient = (0,
|
|
9272
|
-
const [fallbackQueryClient] = (0,
|
|
9455
|
+
const client = (0, import_react38.useContext)(AggClientContext);
|
|
9456
|
+
const queryClient = (0, import_react38.useContext)(import_react_query44.QueryClientContext);
|
|
9457
|
+
const [fallbackQueryClient] = (0, import_react38.useState)(() => new import_react_query44.QueryClient());
|
|
9273
9458
|
const venues = options == null ? void 0 : options.venues;
|
|
9274
9459
|
const search = options == null ? void 0 : options.search;
|
|
9275
9460
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
@@ -9286,7 +9471,7 @@ function useVenueEvents(options) {
|
|
|
9286
9471
|
const endDateFrom = options == null ? void 0 : options.endDateFrom;
|
|
9287
9472
|
const grouped = options == null ? void 0 : options.grouped;
|
|
9288
9473
|
const initialPages = options == null ? void 0 : options.initialPages;
|
|
9289
|
-
(0,
|
|
9474
|
+
(0, import_react38.useEffect)(() => {
|
|
9290
9475
|
if (queryClient) return void 0;
|
|
9291
9476
|
fallbackQueryClient.mount();
|
|
9292
9477
|
return () => {
|
|
@@ -9296,7 +9481,7 @@ function useVenueEvents(options) {
|
|
|
9296
9481
|
if (enabled && !client) {
|
|
9297
9482
|
throw new Error("useVenueEvents must be used within an <AggProvider>");
|
|
9298
9483
|
}
|
|
9299
|
-
const query = (0,
|
|
9484
|
+
const query = (0, import_react_query44.useInfiniteQuery)(
|
|
9300
9485
|
{
|
|
9301
9486
|
queryKey: [
|
|
9302
9487
|
queryKeyScope,
|
|
@@ -9343,13 +9528,13 @@ function useVenueEvents(options) {
|
|
|
9343
9528
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
9344
9529
|
},
|
|
9345
9530
|
// TODO: RMIK - Comment out to show skeletons on category switch
|
|
9346
|
-
placeholderData:
|
|
9531
|
+
placeholderData: import_react_query44.keepPreviousData,
|
|
9347
9532
|
enabled: enabled && !!client
|
|
9348
9533
|
},
|
|
9349
9534
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
9350
9535
|
);
|
|
9351
|
-
const prefetchedRef = (0,
|
|
9352
|
-
(0,
|
|
9536
|
+
const prefetchedRef = (0, import_react38.useRef)(false);
|
|
9537
|
+
(0, import_react38.useEffect)(() => {
|
|
9353
9538
|
var _a2, _b2;
|
|
9354
9539
|
if (prefetchedRef.current) return;
|
|
9355
9540
|
if (!initialPages || initialPages <= 1) return;
|
|
@@ -9367,7 +9552,7 @@ function useVenueEvents(options) {
|
|
|
9367
9552
|
query.hasNextPage,
|
|
9368
9553
|
query.fetchNextPage
|
|
9369
9554
|
]);
|
|
9370
|
-
const events = (0,
|
|
9555
|
+
const events = (0, import_react38.useMemo)(
|
|
9371
9556
|
() => {
|
|
9372
9557
|
var _a2, _b2;
|
|
9373
9558
|
return (_b2 = (_a2 = query.data) == null ? void 0 : _a2.pages.flatMap((page) => page.data)) != null ? _b2 : [];
|
|
@@ -9385,7 +9570,7 @@ function useVenueEvents(options) {
|
|
|
9385
9570
|
}
|
|
9386
9571
|
|
|
9387
9572
|
// src/use-sports-live.ts
|
|
9388
|
-
var
|
|
9573
|
+
var import_react_query45 = require("@tanstack/react-query");
|
|
9389
9574
|
var SPORTS_LIVE_POLL_INTERVAL_MS = 5e3;
|
|
9390
9575
|
var SPORTS_SCHEDULED_POLL_INTERVAL_MS = 3e4;
|
|
9391
9576
|
var sportsLiveQueryKey = (sortedEventIds) => ["sports-live", ...sortedEventIds];
|
|
@@ -9405,7 +9590,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
9405
9590
|
const sortedEventIds = [
|
|
9406
9591
|
...new Set(eventIds.map((eventId) => eventId.trim()).filter(Boolean))
|
|
9407
9592
|
].sort();
|
|
9408
|
-
const query = (0,
|
|
9593
|
+
const query = (0, import_react_query45.useQuery)({
|
|
9409
9594
|
queryKey: sportsLiveQueryKey(sortedEventIds),
|
|
9410
9595
|
queryFn: ({ signal }) => client.getSportsLive(sortedEventIds, { signal }),
|
|
9411
9596
|
enabled: enabled && sortedEventIds.length > 0,
|
|
@@ -9425,7 +9610,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
9425
9610
|
};
|
|
9426
9611
|
|
|
9427
9612
|
// src/use-venue-market-midpoints.ts
|
|
9428
|
-
var
|
|
9613
|
+
var import_react_query46 = require("@tanstack/react-query");
|
|
9429
9614
|
var normalizeVenueMarketIds2 = (venueMarketIds) => {
|
|
9430
9615
|
return [
|
|
9431
9616
|
...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
|
|
@@ -9464,7 +9649,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
9464
9649
|
const enabled = (_a = options.enabled) != null ? _a : true;
|
|
9465
9650
|
const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
|
|
9466
9651
|
const maxMidpointIdsPerRequest = (_b = options.maxMidpointIdsPerRequest) != null ? _b : configuredMaxMidpointIdsPerRequest;
|
|
9467
|
-
const query = (0,
|
|
9652
|
+
const query = (0, import_react_query46.useQuery)({
|
|
9468
9653
|
queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds, maxMidpointIdsPerRequest] : ["venue-market-midpoints", "__disabled__"],
|
|
9469
9654
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
9470
9655
|
if (requestedVenueMarketIds.length === 0) {
|
|
@@ -9480,7 +9665,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
9480
9665
|
gcTime: 5 * 6e4,
|
|
9481
9666
|
refetchOnWindowFocus: false,
|
|
9482
9667
|
retry: 1,
|
|
9483
|
-
placeholderData:
|
|
9668
|
+
placeholderData: import_react_query46.keepPreviousData
|
|
9484
9669
|
});
|
|
9485
9670
|
const midpointRows = (_d = (_c = query.data) == null ? void 0 : _c.data) != null ? _d : [];
|
|
9486
9671
|
const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
|
|
@@ -9540,7 +9725,7 @@ var computePriceGaps = ({
|
|
|
9540
9725
|
};
|
|
9541
9726
|
|
|
9542
9727
|
// src/use-viewport-midpoints.ts
|
|
9543
|
-
var
|
|
9728
|
+
var import_react39 = require("react");
|
|
9544
9729
|
var buildOutcomeMidpointMap = (outcomes) => {
|
|
9545
9730
|
const m = /* @__PURE__ */ new Map();
|
|
9546
9731
|
if (!outcomes) return m;
|
|
@@ -9593,15 +9778,15 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9593
9778
|
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
9594
9779
|
} = useAggUiConfig();
|
|
9595
9780
|
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
9596
|
-
const [cache, setCache] = (0,
|
|
9597
|
-
const inFlightRef = (0,
|
|
9598
|
-
const visibleRef = (0,
|
|
9781
|
+
const [cache, setCache] = (0, import_react39.useState)(() => /* @__PURE__ */ new Map());
|
|
9782
|
+
const inFlightRef = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
|
|
9783
|
+
const visibleRef = (0, import_react39.useRef)(visibleMarkets);
|
|
9599
9784
|
visibleRef.current = visibleMarkets;
|
|
9600
|
-
const visibleFp = (0,
|
|
9785
|
+
const visibleFp = (0, import_react39.useMemo)(
|
|
9601
9786
|
() => [...new Set(visibleMarkets.map((m) => m.id))].sort().join("|"),
|
|
9602
9787
|
[visibleMarkets]
|
|
9603
9788
|
);
|
|
9604
|
-
(0,
|
|
9789
|
+
(0, import_react39.useEffect)(() => {
|
|
9605
9790
|
const toFetch = resolveUncachedVisibleMarketIds(visibleRef.current, cache, inFlightRef.current);
|
|
9606
9791
|
if (!toFetch.length) return;
|
|
9607
9792
|
let cancelled = false;
|
|
@@ -9625,7 +9810,7 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9625
9810
|
cancelled = true;
|
|
9626
9811
|
};
|
|
9627
9812
|
}, [visibleFp, cache, maxMidpointIdsPerRequest]);
|
|
9628
|
-
const { prices, venueByOutcomeId } = (0,
|
|
9813
|
+
const { prices, venueByOutcomeId } = (0, import_react39.useMemo)(() => {
|
|
9629
9814
|
var _a2, _b, _c, _d;
|
|
9630
9815
|
const map = /* @__PURE__ */ new Map();
|
|
9631
9816
|
const venueMap = /* @__PURE__ */ new Map();
|
|
@@ -9658,15 +9843,15 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9658
9843
|
}
|
|
9659
9844
|
|
|
9660
9845
|
// src/use-visible-ids.ts
|
|
9661
|
-
var
|
|
9846
|
+
var import_react40 = require("react");
|
|
9662
9847
|
function useVisibleIds(options = {}) {
|
|
9663
9848
|
const { rootMargin = "0px", threshold = 0 } = options;
|
|
9664
|
-
const [visibleIds, setVisibleIds] = (0,
|
|
9665
|
-
const observerRef = (0,
|
|
9666
|
-
const elementsRef = (0,
|
|
9667
|
-
const elementIdRef = (0,
|
|
9668
|
-
const callbackRefsRef = (0,
|
|
9669
|
-
(0,
|
|
9849
|
+
const [visibleIds, setVisibleIds] = (0, import_react40.useState)(() => /* @__PURE__ */ new Set());
|
|
9850
|
+
const observerRef = (0, import_react40.useRef)(null);
|
|
9851
|
+
const elementsRef = (0, import_react40.useRef)(/* @__PURE__ */ new Map());
|
|
9852
|
+
const elementIdRef = (0, import_react40.useRef)(/* @__PURE__ */ new WeakMap());
|
|
9853
|
+
const callbackRefsRef = (0, import_react40.useRef)(/* @__PURE__ */ new Map());
|
|
9854
|
+
(0, import_react40.useEffect)(() => {
|
|
9670
9855
|
if (typeof IntersectionObserver === "undefined") return;
|
|
9671
9856
|
const observer = new IntersectionObserver(
|
|
9672
9857
|
(entries) => {
|
|
@@ -9698,7 +9883,7 @@ function useVisibleIds(options = {}) {
|
|
|
9698
9883
|
observerRef.current = null;
|
|
9699
9884
|
};
|
|
9700
9885
|
}, [rootMargin, threshold]);
|
|
9701
|
-
const register = (0,
|
|
9886
|
+
const register = (0, import_react40.useCallback)((id) => {
|
|
9702
9887
|
const existing = callbackRefsRef.current.get(id);
|
|
9703
9888
|
if (existing) return existing;
|
|
9704
9889
|
const callback = (el) => {
|
|
@@ -9730,48 +9915,49 @@ function useVisibleIds(options = {}) {
|
|
|
9730
9915
|
return { visibleIds, register };
|
|
9731
9916
|
}
|
|
9732
9917
|
|
|
9733
|
-
// src/use-
|
|
9734
|
-
var
|
|
9735
|
-
var
|
|
9736
|
-
var
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
data: query.data,
|
|
9746
|
-
isLoading: query.isLoading,
|
|
9747
|
-
error: query.error
|
|
9748
|
-
});
|
|
9749
|
-
}
|
|
9750
|
-
function useCachedAppConfig() {
|
|
9751
|
-
const queryClient = (0, import_react_query45.useQueryClient)();
|
|
9752
|
-
const query = (0, import_react_query45.useQuery)({
|
|
9753
|
-
queryKey: APP_CONFIG_QUERY_KEY,
|
|
9754
|
-
enabled: false,
|
|
9755
|
-
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
9756
|
-
staleTime: FIVE_MINUTES
|
|
9757
|
-
});
|
|
9758
|
-
return toAppConfigResult({
|
|
9759
|
-
data: query.data,
|
|
9760
|
-
isLoading: query.isLoading,
|
|
9761
|
-
error: query.error
|
|
9762
|
-
});
|
|
9763
|
-
}
|
|
9764
|
-
var toAppConfigResult = (query) => {
|
|
9765
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9766
|
-
return {
|
|
9767
|
-
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
9768
|
-
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
9769
|
-
earlyAccessEnabled: (_f = (_e = query.data) == null ? void 0 : _e.earlyAccessEnabled) != null ? _f : false,
|
|
9770
|
-
authOptions: (_h = (_g = query.data) == null ? void 0 : _g.authOptions) != null ? _h : [],
|
|
9771
|
-
isLoading: query.isLoading,
|
|
9772
|
-
error: query.error
|
|
9773
|
-
};
|
|
9918
|
+
// src/use-paper-onboarding.ts
|
|
9919
|
+
var import_react41 = require("react");
|
|
9920
|
+
var STORAGE_KEY2 = "agg_paper_onboarding_seen";
|
|
9921
|
+
var isBrowser2 = () => typeof window !== "undefined" && "localStorage" in window;
|
|
9922
|
+
var seenKey = (userId) => `${STORAGE_KEY2}:${userId}`;
|
|
9923
|
+
var hasSeen = (userId) => {
|
|
9924
|
+
if (!isBrowser2()) return false;
|
|
9925
|
+
try {
|
|
9926
|
+
return window.localStorage.getItem(seenKey(userId)) === "1";
|
|
9927
|
+
} catch (e) {
|
|
9928
|
+
return true;
|
|
9929
|
+
}
|
|
9774
9930
|
};
|
|
9931
|
+
var markSeen = (userId) => {
|
|
9932
|
+
if (!isBrowser2()) return;
|
|
9933
|
+
try {
|
|
9934
|
+
window.localStorage.setItem(seenKey(userId), "1");
|
|
9935
|
+
} catch (e) {
|
|
9936
|
+
}
|
|
9937
|
+
};
|
|
9938
|
+
function usePaperOnboarding() {
|
|
9939
|
+
const { isPaperMode, isResolving } = useResolvedExecutionMode();
|
|
9940
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
9941
|
+
const userId = user == null ? void 0 : user.id;
|
|
9942
|
+
const [dismissed, setDismissed] = (0, import_react41.useState)(false);
|
|
9943
|
+
const [seen, setSeen] = (0, import_react41.useState)(null);
|
|
9944
|
+
(0, import_react41.useEffect)(() => {
|
|
9945
|
+
if (!userId) {
|
|
9946
|
+
setSeen(null);
|
|
9947
|
+
return;
|
|
9948
|
+
}
|
|
9949
|
+
setSeen(hasSeen(userId));
|
|
9950
|
+
}, [userId]);
|
|
9951
|
+
(0, import_react41.useEffect)(() => {
|
|
9952
|
+
setDismissed(false);
|
|
9953
|
+
}, [userId]);
|
|
9954
|
+
const dismiss = (0, import_react41.useCallback)(() => {
|
|
9955
|
+
setDismissed(true);
|
|
9956
|
+
if (userId) markSeen(userId);
|
|
9957
|
+
}, [userId]);
|
|
9958
|
+
const isOpen = isPaperMode && !isResolving && isAuthenticated && Boolean(userId) && seen === false && !dismissed;
|
|
9959
|
+
return { isOpen, dismiss };
|
|
9960
|
+
}
|
|
9775
9961
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9776
9962
|
0 && (module.exports = {
|
|
9777
9963
|
AUTH_CHOOSER_OPEN_EVENT,
|
|
@@ -9796,6 +9982,7 @@ var toAppConfigResult = (query) => {
|
|
|
9796
9982
|
TradeSide,
|
|
9797
9983
|
TurnstileChallengeError,
|
|
9798
9984
|
Venue,
|
|
9985
|
+
appConfigQueryKey,
|
|
9799
9986
|
buildLiveBestPriceCandidates,
|
|
9800
9987
|
computeClosedPositionTotals,
|
|
9801
9988
|
computePriceGaps,
|
|
@@ -9837,6 +10024,7 @@ var toAppConfigResult = (query) => {
|
|
|
9837
10024
|
resolveRecurringCryptoTimeline,
|
|
9838
10025
|
resolveRollingWindow,
|
|
9839
10026
|
resolveTradingStateKind,
|
|
10027
|
+
sharedKycQueryKeys,
|
|
9840
10028
|
sortVenues,
|
|
9841
10029
|
sportsLiveQueryKey,
|
|
9842
10030
|
sportsLiveRefetchInterval,
|
|
@@ -9897,6 +10085,7 @@ var toAppConfigResult = (query) => {
|
|
|
9897
10085
|
useOrderBook,
|
|
9898
10086
|
useOrderbookQuote,
|
|
9899
10087
|
useOrders,
|
|
10088
|
+
usePaperOnboarding,
|
|
9900
10089
|
usePlaceLimitOrder,
|
|
9901
10090
|
usePositions,
|
|
9902
10091
|
useQueryClient,
|
|
@@ -9907,10 +10096,12 @@ var toAppConfigResult = (query) => {
|
|
|
9907
10096
|
useRedeemEligibleCount,
|
|
9908
10097
|
useRedeemLifecycle,
|
|
9909
10098
|
useRedeemLifecycles,
|
|
10099
|
+
useResolvedExecutionMode,
|
|
9910
10100
|
useRollingChartWindow,
|
|
9911
10101
|
useSdkLabels,
|
|
9912
10102
|
useSdkUiConfig,
|
|
9913
10103
|
useSearch,
|
|
10104
|
+
useSharedKyc,
|
|
9914
10105
|
useSmartRoute,
|
|
9915
10106
|
useSportsLive,
|
|
9916
10107
|
useSyncBalances,
|