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