@agg-build/hooks 4.7.4 → 4.10.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-FPBMOHIA.mjs → chunk-7DCOWPUQ.mjs} +1 -1
- package/dist/{chunk-DUZ3EJUK.mjs → chunk-MIWXPZNP.mjs} +1 -1
- package/dist/{chunk-HDPVTROR.mjs → chunk-SFSGE25P.mjs} +1000 -831
- package/dist/deposit.js +56 -1
- package/dist/deposit.mjs +2 -2
- package/dist/index.d.mts +211 -10
- package/dist/index.d.ts +211 -10
- package/dist/index.js +718 -471
- package/dist/index.mjs +179 -98
- package/dist/withdraw.js +60 -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,
|
|
@@ -237,6 +242,7 @@ var Venue = /* @__PURE__ */ ((Venue2) => {
|
|
|
237
242
|
Venue2["limitless"] = "limitless";
|
|
238
243
|
Venue2["opinion"] = "opinion";
|
|
239
244
|
Venue2["predict"] = "predict";
|
|
245
|
+
Venue2["pred"] = "pred";
|
|
240
246
|
Venue2["probable"] = "probable";
|
|
241
247
|
Venue2["myriad"] = "myriad";
|
|
242
248
|
Venue2["hyperliquid"] = "hyperliquid";
|
|
@@ -250,12 +256,14 @@ var ACTIVE_VENUES = [
|
|
|
250
256
|
"limitless" /* limitless */,
|
|
251
257
|
"opinion" /* opinion */,
|
|
252
258
|
"predict" /* predict */,
|
|
259
|
+
"pred" /* pred */,
|
|
253
260
|
"probable" /* probable */,
|
|
254
261
|
"myriad" /* myriad */,
|
|
255
262
|
"hyperliquid" /* hyperliquid */,
|
|
256
|
-
"novig" /* novig
|
|
263
|
+
"novig" /* novig */,
|
|
264
|
+
"prophetx" /* prophetx */
|
|
257
265
|
];
|
|
258
|
-
var INACTIVE_VENUES = [
|
|
266
|
+
var INACTIVE_VENUES = [];
|
|
259
267
|
var ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
|
|
260
268
|
var INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
|
|
261
269
|
|
|
@@ -357,6 +365,7 @@ var VENUE_SORT_ORDER = [
|
|
|
357
365
|
"opinion" /* opinion */,
|
|
358
366
|
"limitless" /* limitless */,
|
|
359
367
|
"predict" /* predict */,
|
|
368
|
+
"pred" /* pred */,
|
|
360
369
|
"myriad" /* myriad */,
|
|
361
370
|
"hyperliquid" /* hyperliquid */
|
|
362
371
|
];
|
|
@@ -368,7 +377,7 @@ var getVenueOrder = (venue) => {
|
|
|
368
377
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
369
378
|
|
|
370
379
|
// src/index.ts
|
|
371
|
-
var
|
|
380
|
+
var import_react_query47 = require("@tanstack/react-query");
|
|
372
381
|
|
|
373
382
|
// src/candle-store.ts
|
|
374
383
|
var import_sdk = require("@agg-build/sdk");
|
|
@@ -405,7 +414,7 @@ function evict() {
|
|
|
405
414
|
}
|
|
406
415
|
|
|
407
416
|
// src/core/providers/agg-provider.tsx
|
|
408
|
-
var
|
|
417
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
409
418
|
|
|
410
419
|
// src/core/providers/auth-provider.tsx
|
|
411
420
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -599,6 +608,7 @@ var enUsLabels = {
|
|
|
599
608
|
kalshi: "Kalshi",
|
|
600
609
|
opinion: "Opinion",
|
|
601
610
|
predict: "Predict",
|
|
611
|
+
pred: "PRED",
|
|
602
612
|
limitless: "Limitless",
|
|
603
613
|
probable: "Probable",
|
|
604
614
|
myriad: "Myriad",
|
|
@@ -1228,7 +1238,7 @@ var enUsLabels = {
|
|
|
1228
1238
|
venueMinOrderSize: "Order size is below the venue minimum. Try a larger amount.",
|
|
1229
1239
|
sourceBalanceChanged: "Your balance changed since the quote. Refresh and try again, or pick a smaller amount.",
|
|
1230
1240
|
venueMarketResolved: "This market just resolved. Pick a different market or wait for the next round.",
|
|
1231
|
-
dflowWalletUnverified: "
|
|
1241
|
+
dflowWalletUnverified: "This route is unavailable for your wallet. Check your account connection and try again.",
|
|
1232
1242
|
venueNoQuotePath: "No active quote path for this market right now. Try a different size, or wait a moment and re-quote.",
|
|
1233
1243
|
solanaBlockhashExpired: "Solana transaction expired before submission. Please re-quote and try again.",
|
|
1234
1244
|
venueRateLimited: "The venue is rate-limiting requests right now. Please wait a moment and try again.",
|
|
@@ -1272,6 +1282,25 @@ var enUsLabels = {
|
|
|
1272
1282
|
kycSuccessTitle: "Verification successful",
|
|
1273
1283
|
kycSuccessDescription: "Your identity has been confirmed and you now have full access to trade on Kalshi markets.",
|
|
1274
1284
|
kycSuccessDone: "Done",
|
|
1285
|
+
sharedKyc: {
|
|
1286
|
+
required: "KYC required",
|
|
1287
|
+
completeToTrade: "Complete KYC to trade",
|
|
1288
|
+
checkingStatus: "Checking verification status",
|
|
1289
|
+
modal: {
|
|
1290
|
+
ariaLabel: "Identity verification",
|
|
1291
|
+
title: "Verify Your Identity",
|
|
1292
|
+
freeDescription: "Complete a one-time identity verification to trade all KYC-required venues.",
|
|
1293
|
+
pendingTitle: "Verification pending",
|
|
1294
|
+
pendingDescription: "Your verification is being reviewed. Check back for approval before trading.",
|
|
1295
|
+
checkStatus: "Check verification status",
|
|
1296
|
+
startVerification: "Start verification",
|
|
1297
|
+
doItLater: "Do it later",
|
|
1298
|
+
successTitle: "Verification successful",
|
|
1299
|
+
successDescription: "Your identity has been verified. You can now trade on all KYC-required venues.",
|
|
1300
|
+
done: "Done",
|
|
1301
|
+
error: "We couldn't confirm your verification."
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1275
1304
|
connectKalshi: "Connect to trade Kalshi",
|
|
1276
1305
|
tradingAccessVenues: "Venues",
|
|
1277
1306
|
tradingAccessAvailable: "Available",
|
|
@@ -1316,9 +1345,13 @@ var enUsLabels = {
|
|
|
1316
1345
|
insufficientVenueInventory: (sharesLabel, priceLabel) => `Only ${sharesLabel} \xB7 ${priceLabel}`,
|
|
1317
1346
|
viewAllRoutes: (count) => `View all (${count})`,
|
|
1318
1347
|
venueUnavailableInRegion: "Unavailable in your region",
|
|
1348
|
+
venueTemporarilyUnavailable: "Temporarily unavailable",
|
|
1319
1349
|
verified: "Verified",
|
|
1320
1350
|
platformFee: "0% platform fees",
|
|
1321
1351
|
estimatedFees: "Estimated fees",
|
|
1352
|
+
executionReserve: "Execution reserve",
|
|
1353
|
+
executionReserveTooltipAria: "Why funds are reserved",
|
|
1354
|
+
executionReserveDescription: "Held for price movement or possible venue charges, not a confirmed fee. Unused funds are returned after execution.",
|
|
1322
1355
|
estimatedFeesTooltipAria: "Estimated fees breakdown",
|
|
1323
1356
|
feeBreakdownVenueFees: "Venue",
|
|
1324
1357
|
feeBreakdownBridgeFees: "Bridging",
|
|
@@ -1349,6 +1382,7 @@ var enUsLabels = {
|
|
|
1349
1382
|
depositingFunds: (amount, tokenSymbol, destinationChain) => `Depositing ${amount} ${tokenSymbol} to ${destinationChain}...`,
|
|
1350
1383
|
fundsDeposited: (amount, tokenSymbol, destinationChain) => `Deposited ${amount} ${tokenSymbol} to ${destinationChain}`,
|
|
1351
1384
|
fillingOnVenue: (venueLabel) => `Filling on ${venueLabel}...`,
|
|
1385
|
+
orderStillSettling: "Still settling. This can take a bit \u2014 check your activity feed. You can keep trading.",
|
|
1352
1386
|
venueFilledAtPriceWithAmount: (venueLabel, amountLabel, priceLabel) => `${venueLabel} filled ${amountLabel} at ${priceLabel}`,
|
|
1353
1387
|
executionShares: (value) => `${value} shares`,
|
|
1354
1388
|
confirmTransactionInWallet: "Confirm the transaction in your wallet",
|
|
@@ -1593,6 +1627,35 @@ var enUsLabels = {
|
|
|
1593
1627
|
bannerAria: "Site header",
|
|
1594
1628
|
logoAria: "Home"
|
|
1595
1629
|
},
|
|
1630
|
+
paperTrading: {
|
|
1631
|
+
badge: "Paper trading",
|
|
1632
|
+
badgeTooltip: "Trade real prediction markets with simulated funds. No real money at risk.",
|
|
1633
|
+
profile: {
|
|
1634
|
+
buyingPower: "Paper Buying Power",
|
|
1635
|
+
earnings: "Paper Earnings",
|
|
1636
|
+
earningsCaption: "Keep what you earn"
|
|
1637
|
+
},
|
|
1638
|
+
onboarding: {
|
|
1639
|
+
stepEyebrow: ({ current, total }) => `STEP ${current} OF ${total}`,
|
|
1640
|
+
skip: "Skip",
|
|
1641
|
+
back: "Back",
|
|
1642
|
+
next: "Next",
|
|
1643
|
+
// Figma reads "Get Strated" (node 4772:31236) — a typo, not copy.
|
|
1644
|
+
done: "Get started",
|
|
1645
|
+
realMarkets: {
|
|
1646
|
+
title: "Real markets, real prices",
|
|
1647
|
+
body: "Follow live prediction markets and trade using real-time market prices from leading venues."
|
|
1648
|
+
},
|
|
1649
|
+
zeroRisk: {
|
|
1650
|
+
title: "Paper trading, zero risk",
|
|
1651
|
+
body: ({ amount }) => `Start with ${amount} in simulated funds. No deposit, no real money, and no risk.`
|
|
1652
|
+
},
|
|
1653
|
+
readyToTrade: {
|
|
1654
|
+
title: "You're ready to trade",
|
|
1655
|
+
body: "Pick a market, make your prediction, and track your performance."
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1596
1659
|
notifications: {
|
|
1597
1660
|
order: {
|
|
1598
1661
|
filledTitle: "Order filled",
|
|
@@ -1847,6 +1910,7 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1847
1910
|
// src/core/providers/contexts.ts
|
|
1848
1911
|
var AggClientContext = (0, import_react.createContext)(null);
|
|
1849
1912
|
var AggUiContext = (0, import_react.createContext)(defaultAggUiConfig);
|
|
1913
|
+
var AggExecutionModeContext = (0, import_react.createContext)(null);
|
|
1850
1914
|
var AggLabelsContext = (0, import_react.createContext)(defaultAggUiConfig.general.labels);
|
|
1851
1915
|
var AggAuthContext = (0, import_react.createContext)(null);
|
|
1852
1916
|
var AggBalanceContext = (0, import_react.createContext)(null);
|
|
@@ -2095,7 +2159,7 @@ function AggAuthProvider({ children }) {
|
|
|
2095
2159
|
|
|
2096
2160
|
// src/core/providers/balance-provider.tsx
|
|
2097
2161
|
var import_react_query2 = require("@tanstack/react-query");
|
|
2098
|
-
var
|
|
2162
|
+
var import_react4 = require("react");
|
|
2099
2163
|
|
|
2100
2164
|
// src/execution/query-keys.ts
|
|
2101
2165
|
var executionKeys = {
|
|
@@ -2193,6 +2257,25 @@ var invalidateUserClaimState = (queryClient, options) => {
|
|
|
2193
2257
|
invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
|
|
2194
2258
|
};
|
|
2195
2259
|
|
|
2260
|
+
// src/use-resolved-execution-mode.ts
|
|
2261
|
+
var import_react3 = require("react");
|
|
2262
|
+
function useResolvedExecutionMode(override) {
|
|
2263
|
+
var _a;
|
|
2264
|
+
const serverConfig = (0, import_react3.useContext)(AggExecutionModeContext);
|
|
2265
|
+
const tradingMode = serverConfig == null ? void 0 : serverConfig.tradingMode;
|
|
2266
|
+
const isLoading = (_a = serverConfig == null ? void 0 : serverConfig.isLoading) != null ? _a : false;
|
|
2267
|
+
const {
|
|
2268
|
+
trading: { executionMode: configuredExecutionMode }
|
|
2269
|
+
} = useAggUiConfig();
|
|
2270
|
+
const localMode = override != null ? override : configuredExecutionMode;
|
|
2271
|
+
const executionMode = tradingMode != null ? tradingMode : localMode === "paper" ? "paper" : "live";
|
|
2272
|
+
return {
|
|
2273
|
+
executionMode,
|
|
2274
|
+
isPaperMode: executionMode === "paper",
|
|
2275
|
+
isResolving: tradingMode === void 0 && isLoading
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2196
2279
|
// src/core/providers/balance-provider.tsx
|
|
2197
2280
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2198
2281
|
var CHAIN_LABELS = {
|
|
@@ -2227,11 +2310,9 @@ var EMPTY_MANAGED_BALANCES = {
|
|
|
2227
2310
|
};
|
|
2228
2311
|
function AggBalanceProvider({ children }) {
|
|
2229
2312
|
var _a;
|
|
2230
|
-
const client = (0,
|
|
2231
|
-
const authContext = (0,
|
|
2232
|
-
const {
|
|
2233
|
-
trading: { executionMode }
|
|
2234
|
-
} = (0, import_react3.useContext)(AggUiContext);
|
|
2313
|
+
const client = (0, import_react4.useContext)(AggClientContext);
|
|
2314
|
+
const authContext = (0, import_react4.useContext)(AggAuthContext);
|
|
2315
|
+
const { executionMode } = useResolvedExecutionMode();
|
|
2235
2316
|
if (!authContext) {
|
|
2236
2317
|
throw new Error("AggBalanceProvider must be used within an <AggAuthProvider>");
|
|
2237
2318
|
}
|
|
@@ -2249,15 +2330,19 @@ function AggBalanceProvider({ children }) {
|
|
|
2249
2330
|
}),
|
|
2250
2331
|
enabled: Boolean(client && isAuthenticated),
|
|
2251
2332
|
staleTime: 60 * 1e3,
|
|
2333
|
+
// A matched fill can precede settlement and the API's next balance snapshot.
|
|
2334
|
+
// Keep visible clients converging even if that first invalidation reads old cash.
|
|
2335
|
+
refetchInterval: queryExecutionMode === "paper" ? false : 5e3,
|
|
2336
|
+
refetchIntervalInBackground: false,
|
|
2252
2337
|
refetchOnWindowFocus: "always",
|
|
2253
2338
|
refetchOnReconnect: "always"
|
|
2254
2339
|
});
|
|
2255
2340
|
const managedBalancesData = balancesQuery.data;
|
|
2256
|
-
const managedBalances = (0,
|
|
2341
|
+
const managedBalances = (0, import_react4.useMemo)(
|
|
2257
2342
|
() => managedBalancesData != null ? managedBalancesData : EMPTY_MANAGED_BALANCES,
|
|
2258
2343
|
[managedBalancesData]
|
|
2259
2344
|
);
|
|
2260
|
-
const connectedVenues = (0,
|
|
2345
|
+
const connectedVenues = (0, import_react4.useMemo)(() => {
|
|
2261
2346
|
return Array.from(new Set(managedBalances.positions.map((position) => position.venue))).sort(
|
|
2262
2347
|
(a, b) => a.localeCompare(b)
|
|
2263
2348
|
);
|
|
@@ -2265,7 +2350,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2265
2350
|
const balancesError = managedBalancesData === void 0 ? balancesQuery.error : null;
|
|
2266
2351
|
const isBalancesLoading = balancesQuery.isLoading;
|
|
2267
2352
|
const refetchBalances = balancesQuery.refetch;
|
|
2268
|
-
const totalBalance = (0,
|
|
2353
|
+
const totalBalance = (0, import_react4.useMemo)(() => {
|
|
2269
2354
|
const cash = managedBalances.cash;
|
|
2270
2355
|
return cash.reduce((sum, token) => {
|
|
2271
2356
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
@@ -2279,7 +2364,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2279
2364
|
return sum + tokenAcrossChains;
|
|
2280
2365
|
}, 0);
|
|
2281
2366
|
}, [managedBalances]);
|
|
2282
|
-
const availableBalance = (0,
|
|
2367
|
+
const availableBalance = (0, import_react4.useMemo)(() => {
|
|
2283
2368
|
return managedBalances.cash.reduce((sum, token) => {
|
|
2284
2369
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
2285
2370
|
if (token.availableRaw != null) {
|
|
@@ -2294,7 +2379,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2294
2379
|
);
|
|
2295
2380
|
}, 0);
|
|
2296
2381
|
}, [managedBalances]);
|
|
2297
|
-
const reservedBalance = (0,
|
|
2382
|
+
const reservedBalance = (0, import_react4.useMemo)(() => {
|
|
2298
2383
|
return managedBalances.cash.reduce((sum, token) => {
|
|
2299
2384
|
if (!isUsdBasedToken(token.tokenSymbol)) return sum;
|
|
2300
2385
|
if (token.reservedRaw != null) {
|
|
@@ -2309,7 +2394,7 @@ function AggBalanceProvider({ children }) {
|
|
|
2309
2394
|
);
|
|
2310
2395
|
}, 0);
|
|
2311
2396
|
}, [managedBalances]);
|
|
2312
|
-
const buildBalanceBreakdown = (0,
|
|
2397
|
+
const buildBalanceBreakdown = (0, import_react4.useCallback)(
|
|
2313
2398
|
(rawForChain) => {
|
|
2314
2399
|
var _a2, _b;
|
|
2315
2400
|
const byChain = /* @__PURE__ */ new Map();
|
|
@@ -2337,16 +2422,16 @@ function AggBalanceProvider({ children }) {
|
|
|
2337
2422
|
},
|
|
2338
2423
|
[connectedVenues, managedBalances.cash]
|
|
2339
2424
|
);
|
|
2340
|
-
const balanceBreakdown = (0,
|
|
2425
|
+
const balanceBreakdown = (0, import_react4.useMemo)(() => {
|
|
2341
2426
|
return buildBalanceBreakdown((chain) => chain.balanceRaw);
|
|
2342
2427
|
}, [buildBalanceBreakdown]);
|
|
2343
|
-
const availableBalanceBreakdown = (0,
|
|
2428
|
+
const availableBalanceBreakdown = (0, import_react4.useMemo)(() => {
|
|
2344
2429
|
return buildBalanceBreakdown((chain) => {
|
|
2345
2430
|
var _a2;
|
|
2346
2431
|
return (_a2 = chain.availableRaw) != null ? _a2 : chain.balanceRaw;
|
|
2347
2432
|
});
|
|
2348
2433
|
}, [buildBalanceBreakdown]);
|
|
2349
|
-
const positionsBalanceTotal = (0,
|
|
2434
|
+
const positionsBalanceTotal = (0, import_react4.useMemo)(() => {
|
|
2350
2435
|
const positions = managedBalances.positions;
|
|
2351
2436
|
const actualPositionsBalance = positions.reduce(
|
|
2352
2437
|
(sum, position) => sum + (Number.isFinite(position.balance) ? position.balance : 0),
|
|
@@ -2357,15 +2442,15 @@ function AggBalanceProvider({ children }) {
|
|
|
2357
2442
|
const kalshiVenueCash = (_a = managedBalances.venueCash) == null ? void 0 : _a.find((item) => item.venue === "kalshi");
|
|
2358
2443
|
const kalshiBalance = kalshiVenueCash ? kalshiVenueCash.balanceCents / 100 : null;
|
|
2359
2444
|
const kalshiPortfolioValue = (kalshiVenueCash == null ? void 0 : kalshiVenueCash.portfolioValueCents) == null ? null : kalshiVenueCash.portfolioValueCents / 100;
|
|
2360
|
-
const refetch = (0,
|
|
2445
|
+
const refetch = (0, import_react4.useCallback)(() => {
|
|
2361
2446
|
if (!isAuthenticated) return;
|
|
2362
2447
|
void refetchBalances();
|
|
2363
2448
|
}, [isAuthenticated, refetchBalances]);
|
|
2364
|
-
const refetchConnectionStatus = (0,
|
|
2449
|
+
const refetchConnectionStatus = (0, import_react4.useCallback)(() => {
|
|
2365
2450
|
if (!client || !isAuthenticated) return;
|
|
2366
2451
|
void client.getCurrentUser();
|
|
2367
2452
|
}, [client, isAuthenticated]);
|
|
2368
|
-
const value = (0,
|
|
2453
|
+
const value = (0, import_react4.useMemo)(() => {
|
|
2369
2454
|
if (!isAuthenticated) {
|
|
2370
2455
|
return {
|
|
2371
2456
|
managedBalances,
|
|
@@ -2430,21 +2515,87 @@ function AggClientProvider({ client, children }) {
|
|
|
2430
2515
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AggClientContext.Provider, { value: client != null ? client : null, children });
|
|
2431
2516
|
}
|
|
2432
2517
|
|
|
2433
|
-
// src/core/providers/
|
|
2434
|
-
var
|
|
2518
|
+
// src/core/providers/execution-mode-provider.tsx
|
|
2519
|
+
var import_react5 = require("react");
|
|
2520
|
+
|
|
2521
|
+
// src/use-app-config.ts
|
|
2522
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
2523
|
+
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
2524
|
+
var NO_APP_SCOPE = "__no-app__";
|
|
2525
|
+
var appConfigQueryKey = (appId) => ["agg", "app-config", appId != null ? appId : NO_APP_SCOPE];
|
|
2526
|
+
function useAppConfig() {
|
|
2527
|
+
const client = useAggClient();
|
|
2528
|
+
const query = (0, import_react_query3.useQuery)({
|
|
2529
|
+
queryKey: appConfigQueryKey(client.appId),
|
|
2530
|
+
queryFn: () => client.getAppConfig(),
|
|
2531
|
+
staleTime: FIVE_MINUTES,
|
|
2532
|
+
// Skipped entirely while the tab is unfocused — query-core only fires the
|
|
2533
|
+
// interval when `refetchIntervalInBackground` is set or the window is
|
|
2534
|
+
// focused — so a background tab costs nothing.
|
|
2535
|
+
refetchInterval: FIVE_MINUTES
|
|
2536
|
+
});
|
|
2537
|
+
return toAppConfigResult({
|
|
2538
|
+
data: query.data,
|
|
2539
|
+
isLoading: query.isLoading,
|
|
2540
|
+
error: query.error
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
function useCachedAppConfig() {
|
|
2544
|
+
const queryClient = (0, import_react_query3.useQueryClient)();
|
|
2545
|
+
const client = useOptionalAggClient();
|
|
2546
|
+
const queryKey = appConfigQueryKey(client == null ? void 0 : client.appId);
|
|
2547
|
+
const query = (0, import_react_query3.useQuery)({
|
|
2548
|
+
queryKey,
|
|
2549
|
+
enabled: false,
|
|
2550
|
+
initialData: () => queryClient.getQueryData(queryKey),
|
|
2551
|
+
staleTime: FIVE_MINUTES
|
|
2552
|
+
});
|
|
2553
|
+
return toAppConfigResult({
|
|
2554
|
+
data: query.data,
|
|
2555
|
+
isLoading: query.isLoading,
|
|
2556
|
+
error: query.error
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
var toAppConfigResult = (query) => {
|
|
2560
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2561
|
+
return {
|
|
2562
|
+
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
2563
|
+
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
2564
|
+
earlyAccessEnabled: (_f = (_e = query.data) == null ? void 0 : _e.earlyAccessEnabled) != null ? _f : false,
|
|
2565
|
+
authOptions: (_h = (_g = query.data) == null ? void 0 : _g.authOptions) != null ? _h : [],
|
|
2566
|
+
tradingMode: (_i = query.data) == null ? void 0 : _i.tradingMode,
|
|
2567
|
+
paperStartingBalance: (_j = query.data) == null ? void 0 : _j.paperStartingBalance,
|
|
2568
|
+
isLoading: query.isLoading,
|
|
2569
|
+
error: query.error
|
|
2570
|
+
};
|
|
2571
|
+
};
|
|
2572
|
+
|
|
2573
|
+
// src/core/providers/execution-mode-provider.tsx
|
|
2435
2574
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2575
|
+
function AggExecutionModeProvider({ children }) {
|
|
2576
|
+
const { tradingMode, paperStartingBalance, isLoading } = useAppConfig();
|
|
2577
|
+
const value = (0, import_react5.useMemo)(
|
|
2578
|
+
() => ({ tradingMode, paperStartingBalance, isLoading }),
|
|
2579
|
+
[tradingMode, paperStartingBalance, isLoading]
|
|
2580
|
+
);
|
|
2581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AggExecutionModeContext.Provider, { value, children });
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
// src/core/providers/event-list-state-context.tsx
|
|
2585
|
+
var import_react6 = require("react");
|
|
2586
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2436
2587
|
var STALENESS_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
2437
2588
|
var MAX_INITIAL_PAGES = 10;
|
|
2438
|
-
var EventListStateContext = (0,
|
|
2589
|
+
var EventListStateContext = (0, import_react6.createContext)(null);
|
|
2439
2590
|
function EventListStateProvider({ children }) {
|
|
2440
|
-
const snapshotRef = (0,
|
|
2441
|
-
const capture = (0,
|
|
2591
|
+
const snapshotRef = (0, import_react6.useRef)(null);
|
|
2592
|
+
const capture = (0, import_react6.useCallback)((state) => {
|
|
2442
2593
|
snapshotRef.current = __spreadProps(__spreadValues({}, state), {
|
|
2443
2594
|
loadedPageCount: Math.min(state.loadedPageCount, MAX_INITIAL_PAGES),
|
|
2444
2595
|
capturedAt: Date.now()
|
|
2445
2596
|
});
|
|
2446
2597
|
}, []);
|
|
2447
|
-
const consume = (0,
|
|
2598
|
+
const consume = (0, import_react6.useCallback)(() => {
|
|
2448
2599
|
const snapshot = snapshotRef.current;
|
|
2449
2600
|
snapshotRef.current = null;
|
|
2450
2601
|
if (!snapshot) return null;
|
|
@@ -2452,17 +2603,17 @@ function EventListStateProvider({ children }) {
|
|
|
2452
2603
|
if (age > STALENESS_THRESHOLD_MS) return null;
|
|
2453
2604
|
return snapshot;
|
|
2454
2605
|
}, []);
|
|
2455
|
-
const value = (0,
|
|
2606
|
+
const value = (0, import_react6.useRef)({ capture, consume });
|
|
2456
2607
|
value.current.capture = capture;
|
|
2457
2608
|
value.current.consume = consume;
|
|
2458
|
-
const stableValue = (0,
|
|
2609
|
+
const stableValue = (0, import_react6.useRef)({
|
|
2459
2610
|
capture: (...args) => value.current.capture(...args),
|
|
2460
2611
|
consume: () => value.current.consume()
|
|
2461
2612
|
}).current;
|
|
2462
|
-
return /* @__PURE__ */ (0,
|
|
2613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EventListStateContext.Provider, { value: stableValue, children });
|
|
2463
2614
|
}
|
|
2464
2615
|
function useEventListState() {
|
|
2465
|
-
const context = (0,
|
|
2616
|
+
const context = (0, import_react6.useContext)(EventListStateContext);
|
|
2466
2617
|
if (!context) {
|
|
2467
2618
|
throw new Error("useEventListState must be used within an <AggProvider>");
|
|
2468
2619
|
}
|
|
@@ -2470,8 +2621,8 @@ function useEventListState() {
|
|
|
2470
2621
|
}
|
|
2471
2622
|
|
|
2472
2623
|
// src/core/providers/ws-provider.tsx
|
|
2473
|
-
var
|
|
2474
|
-
var
|
|
2624
|
+
var import_react8 = require("react");
|
|
2625
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
2475
2626
|
|
|
2476
2627
|
// src/market-data/chart-cache.ts
|
|
2477
2628
|
var MAX_CACHE_RETENTION_SECONDS = 7 * 30 * 24 * 60 * 60 + 14 * 24 * 60 * 60;
|
|
@@ -3013,25 +3164,25 @@ var marketDataKeys = {
|
|
|
3013
3164
|
};
|
|
3014
3165
|
|
|
3015
3166
|
// src/core/providers/hooks.ts
|
|
3016
|
-
var
|
|
3167
|
+
var import_react7 = require("react");
|
|
3017
3168
|
var useAggClient = () => {
|
|
3018
|
-
const client = (0,
|
|
3169
|
+
const client = (0, import_react7.useContext)(AggClientContext);
|
|
3019
3170
|
if (!client) {
|
|
3020
3171
|
throw new Error("useAggClient must be used within an <AggProvider>");
|
|
3021
3172
|
}
|
|
3022
3173
|
return client;
|
|
3023
3174
|
};
|
|
3024
3175
|
var useOptionalAggClient = () => {
|
|
3025
|
-
return (0,
|
|
3176
|
+
return (0, import_react7.useContext)(AggClientContext);
|
|
3026
3177
|
};
|
|
3027
3178
|
var useAggUiConfig = () => {
|
|
3028
|
-
return (0,
|
|
3179
|
+
return (0, import_react7.useContext)(AggUiContext);
|
|
3029
3180
|
};
|
|
3030
3181
|
var useAggLabels = () => {
|
|
3031
|
-
return (0,
|
|
3182
|
+
return (0, import_react7.useContext)(AggLabelsContext);
|
|
3032
3183
|
};
|
|
3033
3184
|
var useAggAuthContext = () => {
|
|
3034
|
-
const context = (0,
|
|
3185
|
+
const context = (0, import_react7.useContext)(AggAuthContext);
|
|
3035
3186
|
if (!context) {
|
|
3036
3187
|
throw new Error("useAggAuthContext must be used within an <AggProvider>");
|
|
3037
3188
|
}
|
|
@@ -3039,7 +3190,7 @@ var useAggAuthContext = () => {
|
|
|
3039
3190
|
};
|
|
3040
3191
|
var useAggAuthState = useAggAuthContext;
|
|
3041
3192
|
var useAggBalanceContext = () => {
|
|
3042
|
-
const context = (0,
|
|
3193
|
+
const context = (0, import_react7.useContext)(AggBalanceContext);
|
|
3043
3194
|
if (!context) {
|
|
3044
3195
|
throw new Error("useAggBalanceContext must be used within an <AggProvider>");
|
|
3045
3196
|
}
|
|
@@ -3052,10 +3203,10 @@ var useSdkLabels = useAggLabels;
|
|
|
3052
3203
|
var useLabels = useAggLabels;
|
|
3053
3204
|
|
|
3054
3205
|
// src/core/providers/ws-provider.tsx
|
|
3055
|
-
var
|
|
3056
|
-
var AggWebSocketContext = (0,
|
|
3057
|
-
var AggWebSocketConnectionContext = (0,
|
|
3058
|
-
var AggWsUserEventContext = (0,
|
|
3206
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3207
|
+
var AggWebSocketContext = (0, import_react8.createContext)(null);
|
|
3208
|
+
var AggWebSocketConnectionContext = (0, import_react8.createContext)(false);
|
|
3209
|
+
var AggWsUserEventContext = (0, import_react8.createContext)(null);
|
|
3059
3210
|
var snapshotUnavailableOutcomeIdPattern = /snapshot unavailable for\s+([^\s]+)/i;
|
|
3060
3211
|
var ORDERBOOK_DEBUG_TOP_LEVELS = 5;
|
|
3061
3212
|
var resolveSnapshotUnavailableOutcomeId = (errorMessage) => {
|
|
@@ -3072,17 +3223,17 @@ var debugOrderbook = (enabled, event, payload) => {
|
|
|
3072
3223
|
console.debug(`[AggHooks][ws-provider] ${event}`, payload);
|
|
3073
3224
|
};
|
|
3074
3225
|
function useAggWebSocket() {
|
|
3075
|
-
return (0,
|
|
3226
|
+
return (0, import_react8.useContext)(AggWebSocketContext);
|
|
3076
3227
|
}
|
|
3077
3228
|
function useAggWebSocketConnectionState() {
|
|
3078
|
-
return (0,
|
|
3229
|
+
return (0, import_react8.useContext)(AggWebSocketConnectionContext);
|
|
3079
3230
|
}
|
|
3080
3231
|
function useOnOrderSubmitted(callback) {
|
|
3081
|
-
const listeners = (0,
|
|
3082
|
-
const callbackRef = (0,
|
|
3232
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3233
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3083
3234
|
callbackRef.current = callback;
|
|
3084
3235
|
const hasCallback = callback !== null;
|
|
3085
|
-
(0,
|
|
3236
|
+
(0, import_react8.useEffect)(() => {
|
|
3086
3237
|
if (!listeners || !callbackRef.current) return;
|
|
3087
3238
|
const handler = (msg) => {
|
|
3088
3239
|
var _a;
|
|
@@ -3092,11 +3243,11 @@ function useOnOrderSubmitted(callback) {
|
|
|
3092
3243
|
}, [listeners, hasCallback]);
|
|
3093
3244
|
}
|
|
3094
3245
|
function useOnBalanceUpdate(callback) {
|
|
3095
|
-
const listeners = (0,
|
|
3096
|
-
const callbackRef = (0,
|
|
3246
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3247
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3097
3248
|
callbackRef.current = callback;
|
|
3098
3249
|
const hasCallback = callback !== null;
|
|
3099
|
-
(0,
|
|
3250
|
+
(0, import_react8.useEffect)(() => {
|
|
3100
3251
|
if (!listeners || !callbackRef.current) return;
|
|
3101
3252
|
const handler = (msg) => {
|
|
3102
3253
|
var _a;
|
|
@@ -3106,11 +3257,11 @@ function useOnBalanceUpdate(callback) {
|
|
|
3106
3257
|
}, [listeners, hasCallback]);
|
|
3107
3258
|
}
|
|
3108
3259
|
function useOnOrderEvent(callback) {
|
|
3109
|
-
const listeners = (0,
|
|
3110
|
-
const callbackRef = (0,
|
|
3260
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3261
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3111
3262
|
callbackRef.current = callback;
|
|
3112
3263
|
const hasCallback = callback !== null;
|
|
3113
|
-
(0,
|
|
3264
|
+
(0, import_react8.useEffect)(() => {
|
|
3114
3265
|
if (!listeners || !callbackRef.current) return;
|
|
3115
3266
|
const handler = (msg) => {
|
|
3116
3267
|
var _a;
|
|
@@ -3120,11 +3271,11 @@ function useOnOrderEvent(callback) {
|
|
|
3120
3271
|
}, [listeners, hasCallback]);
|
|
3121
3272
|
}
|
|
3122
3273
|
function useOnRedeemEvent(callback) {
|
|
3123
|
-
const listeners = (0,
|
|
3124
|
-
const callbackRef = (0,
|
|
3274
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3275
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3125
3276
|
callbackRef.current = callback;
|
|
3126
3277
|
const hasCallback = callback !== null;
|
|
3127
|
-
(0,
|
|
3278
|
+
(0, import_react8.useEffect)(() => {
|
|
3128
3279
|
if (!listeners || !callbackRef.current) return;
|
|
3129
3280
|
const handler = (msg) => {
|
|
3130
3281
|
var _a;
|
|
@@ -3134,11 +3285,11 @@ function useOnRedeemEvent(callback) {
|
|
|
3134
3285
|
}, [listeners, hasCallback]);
|
|
3135
3286
|
}
|
|
3136
3287
|
function useOnWithdrawalLifecycle(callback) {
|
|
3137
|
-
const listeners = (0,
|
|
3138
|
-
const callbackRef = (0,
|
|
3288
|
+
const listeners = (0, import_react8.useContext)(AggWsUserEventContext);
|
|
3289
|
+
const callbackRef = (0, import_react8.useRef)(callback);
|
|
3139
3290
|
callbackRef.current = callback;
|
|
3140
3291
|
const hasCallback = callback !== null;
|
|
3141
|
-
(0,
|
|
3292
|
+
(0, import_react8.useEffect)(() => {
|
|
3142
3293
|
if (!listeners || !callbackRef.current) return;
|
|
3143
3294
|
const handler = (msg) => {
|
|
3144
3295
|
var _a;
|
|
@@ -3150,27 +3301,27 @@ function useOnWithdrawalLifecycle(callback) {
|
|
|
3150
3301
|
function AggWebSocketProvider({ children }) {
|
|
3151
3302
|
const client = useAggClient();
|
|
3152
3303
|
const { enableWebsocketsLogs } = useAggUiConfig();
|
|
3153
|
-
const queryClient = (0,
|
|
3154
|
-
const [ws, setWs] = (0,
|
|
3155
|
-
const [isConnected, setIsConnected] = (0,
|
|
3156
|
-
const [isClientAuthenticated, setIsClientAuthenticated] = (0,
|
|
3157
|
-
const wsRef = (0,
|
|
3158
|
-
const resyncDeadlineByMarketRef = (0,
|
|
3159
|
-
const lastBalanceInvalidationAtRef = (0,
|
|
3160
|
-
(0,
|
|
3304
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
3305
|
+
const [ws, setWs] = (0, import_react8.useState)(null);
|
|
3306
|
+
const [isConnected, setIsConnected] = (0, import_react8.useState)(false);
|
|
3307
|
+
const [isClientAuthenticated, setIsClientAuthenticated] = (0, import_react8.useState)(client.isAuthenticated);
|
|
3308
|
+
const wsRef = (0, import_react8.useRef)(null);
|
|
3309
|
+
const resyncDeadlineByMarketRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
3310
|
+
const lastBalanceInvalidationAtRef = (0, import_react8.useRef)(0);
|
|
3311
|
+
(0, import_react8.useEffect)(() => {
|
|
3161
3312
|
setIsClientAuthenticated(client.isAuthenticated);
|
|
3162
3313
|
return client.onAuthStateChange((authenticated) => {
|
|
3163
3314
|
setIsClientAuthenticated(authenticated);
|
|
3164
3315
|
});
|
|
3165
3316
|
}, [client]);
|
|
3166
|
-
const orderSubmittedListenersRef = (0,
|
|
3167
|
-
const balanceUpdateListenersRef = (0,
|
|
3168
|
-
const orderEventListenersRef = (0,
|
|
3169
|
-
const redeemEventListenersRef = (0,
|
|
3170
|
-
const withdrawalLifecycleListenersRef = (0,
|
|
3317
|
+
const orderSubmittedListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3318
|
+
const balanceUpdateListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3319
|
+
const orderEventListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3320
|
+
const redeemEventListenersRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
3321
|
+
const withdrawalLifecycleListenersRef = (0, import_react8.useRef)(
|
|
3171
3322
|
/* @__PURE__ */ new Set()
|
|
3172
3323
|
);
|
|
3173
|
-
const userEventListeners = (0,
|
|
3324
|
+
const userEventListeners = (0, import_react8.useMemo)(
|
|
3174
3325
|
() => ({
|
|
3175
3326
|
addOrderSubmittedListener: (cb) => {
|
|
3176
3327
|
orderSubmittedListenersRef.current.add(cb);
|
|
@@ -3205,7 +3356,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3205
3356
|
}),
|
|
3206
3357
|
[]
|
|
3207
3358
|
);
|
|
3208
|
-
const syncOrderbookQueries = (0,
|
|
3359
|
+
const syncOrderbookQueries = (0, import_react8.useCallback)(
|
|
3209
3360
|
(marketId, updater) => {
|
|
3210
3361
|
var _a;
|
|
3211
3362
|
const queries = queryClient.getQueryCache().findAll({
|
|
@@ -3221,7 +3372,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3221
3372
|
},
|
|
3222
3373
|
[queryClient]
|
|
3223
3374
|
);
|
|
3224
|
-
const syncChartQueries = (0,
|
|
3375
|
+
const syncChartQueries = (0, import_react8.useCallback)(
|
|
3225
3376
|
(marketId, updater) => {
|
|
3226
3377
|
const queries = queryClient.getQueryCache().findAll({
|
|
3227
3378
|
queryKey: marketDataKeys.chartPrefix(marketId)
|
|
@@ -3235,7 +3386,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3235
3386
|
},
|
|
3236
3387
|
[queryClient]
|
|
3237
3388
|
);
|
|
3238
|
-
const syncLiveQuery = (0,
|
|
3389
|
+
const syncLiveQuery = (0, import_react8.useCallback)(
|
|
3239
3390
|
(marketId, updater) => {
|
|
3240
3391
|
queryClient.setQueryData(marketDataKeys.live(marketId), (previous) => {
|
|
3241
3392
|
return updater(previous);
|
|
@@ -3243,19 +3394,19 @@ function AggWebSocketProvider({ children }) {
|
|
|
3243
3394
|
},
|
|
3244
3395
|
[queryClient]
|
|
3245
3396
|
);
|
|
3246
|
-
const invalidateBalanceCaches = (0,
|
|
3397
|
+
const invalidateBalanceCaches = (0, import_react8.useCallback)(() => {
|
|
3247
3398
|
const now = Date.now();
|
|
3248
3399
|
if (now - lastBalanceInvalidationAtRef.current < 750) return;
|
|
3249
3400
|
lastBalanceInvalidationAtRef.current = now;
|
|
3250
3401
|
invalidateBalanceQueries(queryClient);
|
|
3251
3402
|
}, [queryClient]);
|
|
3252
|
-
const invalidatePositionCaches = (0,
|
|
3403
|
+
const invalidatePositionCaches = (0, import_react8.useCallback)(() => {
|
|
3253
3404
|
invalidatePositionQueries(queryClient);
|
|
3254
3405
|
}, [queryClient]);
|
|
3255
|
-
const invalidateActivityCaches = (0,
|
|
3406
|
+
const invalidateActivityCaches = (0, import_react8.useCallback)(() => {
|
|
3256
3407
|
invalidateUserActivityQueries(queryClient);
|
|
3257
3408
|
}, [queryClient]);
|
|
3258
|
-
const invalidateResolutionCaches = (0,
|
|
3409
|
+
const invalidateResolutionCaches = (0, import_react8.useCallback)(
|
|
3259
3410
|
(resolution) => {
|
|
3260
3411
|
const { outcomeId } = resolution;
|
|
3261
3412
|
syncLiveQuery(outcomeId, (previous) => {
|
|
@@ -3311,7 +3462,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3311
3462
|
},
|
|
3312
3463
|
[queryClient, syncLiveQuery]
|
|
3313
3464
|
);
|
|
3314
|
-
const callbacks = (0,
|
|
3465
|
+
const callbacks = (0, import_react8.useMemo)(
|
|
3315
3466
|
() => ({
|
|
3316
3467
|
onSnapshot: (marketId, book) => {
|
|
3317
3468
|
const orderbook = createMarketOrderbookDataFromState(book);
|
|
@@ -3512,7 +3663,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
3512
3663
|
syncOrderbookQueries
|
|
3513
3664
|
]
|
|
3514
3665
|
);
|
|
3515
|
-
(0,
|
|
3666
|
+
(0, import_react8.useEffect)(() => {
|
|
3516
3667
|
let instance = null;
|
|
3517
3668
|
const resyncDeadlineByMarket = resyncDeadlineByMarketRef.current;
|
|
3518
3669
|
try {
|
|
@@ -3538,11 +3689,11 @@ function AggWebSocketProvider({ children }) {
|
|
|
3538
3689
|
setIsConnected(false);
|
|
3539
3690
|
};
|
|
3540
3691
|
}, [callbacks, client, enableWebsocketsLogs, isClientAuthenticated]);
|
|
3541
|
-
return /* @__PURE__ */ (0,
|
|
3692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWebSocketConnectionContext.Provider, { value: isConnected, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWsUserEventContext.Provider, { value: userEventListeners, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AggWebSocketContext.Provider, { value: ws, children }) }) });
|
|
3542
3693
|
}
|
|
3543
3694
|
|
|
3544
3695
|
// src/core/providers/ui-provider.tsx
|
|
3545
|
-
var
|
|
3696
|
+
var import_react10 = require("react");
|
|
3546
3697
|
|
|
3547
3698
|
// src/core/ui-config/constants.ts
|
|
3548
3699
|
var DEFAULT_AGG_ROOT_CLASS_NAME = "agg-root";
|
|
@@ -3619,8 +3770,8 @@ var applyThemeToDocument = (theme) => {
|
|
|
3619
3770
|
};
|
|
3620
3771
|
|
|
3621
3772
|
// src/core/providers/event-trading-context.tsx
|
|
3622
|
-
var
|
|
3623
|
-
var
|
|
3773
|
+
var import_react9 = require("react");
|
|
3774
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3624
3775
|
var OPEN_TRADING_STATE = {
|
|
3625
3776
|
kind: "open",
|
|
3626
3777
|
status: "open" /* open */,
|
|
@@ -3955,24 +4106,24 @@ var initialState = {
|
|
|
3955
4106
|
outcome: null,
|
|
3956
4107
|
tradeSide: TradeSide.Buy
|
|
3957
4108
|
};
|
|
3958
|
-
var EventTradingContext = (0,
|
|
4109
|
+
var EventTradingContext = (0, import_react9.createContext)(void 0);
|
|
3959
4110
|
var useEventTradingContext = () => {
|
|
3960
|
-
return (0,
|
|
4111
|
+
return (0, import_react9.useContext)(EventTradingContext);
|
|
3961
4112
|
};
|
|
3962
4113
|
var EventTradingProvider = ({
|
|
3963
4114
|
children,
|
|
3964
4115
|
enableLogs = false
|
|
3965
4116
|
}) => {
|
|
3966
4117
|
var _a, _b;
|
|
3967
|
-
const [state, rawDispatch] = (0,
|
|
3968
|
-
const stateRef = (0,
|
|
3969
|
-
const pendingAtomicSelectionRef = (0,
|
|
4118
|
+
const [state, rawDispatch] = (0, import_react9.useReducer)(tradingReducer, initialState);
|
|
4119
|
+
const stateRef = (0, import_react9.useRef)(state);
|
|
4120
|
+
const pendingAtomicSelectionRef = (0, import_react9.useRef)(null);
|
|
3970
4121
|
stateRef.current = state;
|
|
3971
4122
|
const pendingAtomicSelection = pendingAtomicSelectionRef.current;
|
|
3972
4123
|
if (pendingAtomicSelection && ((_a = state.market) == null ? void 0 : _a.id) === pendingAtomicSelection.marketId && ((_b = state.outcome) == null ? void 0 : _b.id) === pendingAtomicSelection.outcomeId) {
|
|
3973
4124
|
pendingAtomicSelectionRef.current = null;
|
|
3974
4125
|
}
|
|
3975
|
-
const dispatch = (0,
|
|
4126
|
+
const dispatch = (0, import_react9.useCallback)(
|
|
3976
4127
|
(action) => {
|
|
3977
4128
|
const prev = stateRef.current;
|
|
3978
4129
|
rawDispatch(action);
|
|
@@ -3981,19 +4132,19 @@ var EventTradingProvider = ({
|
|
|
3981
4132
|
},
|
|
3982
4133
|
[enableLogs]
|
|
3983
4134
|
);
|
|
3984
|
-
const initializeFromEvent = (0,
|
|
4135
|
+
const initializeFromEvent = (0, import_react9.useCallback)(
|
|
3985
4136
|
(event) => dispatch({ type: "INITIALIZE_EVENT", event }),
|
|
3986
4137
|
[dispatch]
|
|
3987
4138
|
);
|
|
3988
|
-
const syncEvent = (0,
|
|
4139
|
+
const syncEvent = (0, import_react9.useCallback)(
|
|
3989
4140
|
(event) => dispatch({ type: "SYNC_EVENT", event }),
|
|
3990
4141
|
[dispatch]
|
|
3991
4142
|
);
|
|
3992
|
-
const selectMarket = (0,
|
|
4143
|
+
const selectMarket = (0, import_react9.useCallback)(
|
|
3993
4144
|
(marketId, market) => dispatch({ type: "SELECT_MARKET", marketId, market }),
|
|
3994
4145
|
[dispatch]
|
|
3995
4146
|
);
|
|
3996
|
-
const selectOutcome = (0,
|
|
4147
|
+
const selectOutcome = (0, import_react9.useCallback)(
|
|
3997
4148
|
(outcomeId) => {
|
|
3998
4149
|
var _a2, _b2;
|
|
3999
4150
|
if (((_a2 = stateRef.current.outcome) == null ? void 0 : _a2.id) === outcomeId) return;
|
|
@@ -4002,7 +4153,7 @@ var EventTradingProvider = ({
|
|
|
4002
4153
|
},
|
|
4003
4154
|
[dispatch]
|
|
4004
4155
|
);
|
|
4005
|
-
const selectMarketAndOutcome = (0,
|
|
4156
|
+
const selectMarketAndOutcome = (0, import_react9.useCallback)(
|
|
4006
4157
|
(marketId, outcomeId) => {
|
|
4007
4158
|
var _a2, _b2, _c, _d;
|
|
4008
4159
|
if (((_a2 = stateRef.current.market) == null ? void 0 : _a2.id) === marketId && ((_b2 = stateRef.current.outcome) == null ? void 0 : _b2.id) === outcomeId) {
|
|
@@ -4016,11 +4167,11 @@ var EventTradingProvider = ({
|
|
|
4016
4167
|
},
|
|
4017
4168
|
[dispatch]
|
|
4018
4169
|
);
|
|
4019
|
-
const setTradeSide = (0,
|
|
4170
|
+
const setTradeSide = (0, import_react9.useCallback)(
|
|
4020
4171
|
(tradeSide) => dispatch({ type: "SET_TRADE_SIDE", tradeSide }),
|
|
4021
4172
|
[dispatch]
|
|
4022
4173
|
);
|
|
4023
|
-
const value = (0,
|
|
4174
|
+
const value = (0, import_react9.useMemo)(
|
|
4024
4175
|
() => {
|
|
4025
4176
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
4026
4177
|
return {
|
|
@@ -4050,11 +4201,11 @@ var EventTradingProvider = ({
|
|
|
4050
4201
|
setTradeSide
|
|
4051
4202
|
]
|
|
4052
4203
|
);
|
|
4053
|
-
return /* @__PURE__ */ (0,
|
|
4204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EventTradingContext.Provider, { value, children });
|
|
4054
4205
|
};
|
|
4055
4206
|
|
|
4056
4207
|
// src/core/providers/ui-provider.tsx
|
|
4057
|
-
var
|
|
4208
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
4058
4209
|
var hasWarnedMissingAggStyles = false;
|
|
4059
4210
|
var warnIfAggStylesAreMissing = () => {
|
|
4060
4211
|
if (hasWarnedMissingAggStyles) return;
|
|
@@ -4087,29 +4238,29 @@ var getSearchStateAfterSelect = (selectedEvent) => {
|
|
|
4087
4238
|
};
|
|
4088
4239
|
};
|
|
4089
4240
|
var AggUiProvider = ({ config, children }) => {
|
|
4090
|
-
const persisted = (0,
|
|
4091
|
-
const mergedConfig = (0,
|
|
4092
|
-
const [selectedChartTimeRange, setSelectedChartTimeRange] = (0,
|
|
4241
|
+
const persisted = (0, import_react10.useMemo)(() => loadPersistedConfig(), []);
|
|
4242
|
+
const mergedConfig = (0, import_react10.useMemo)(() => mergeAggUiConfig(persisted, config), [persisted, config]);
|
|
4243
|
+
const [selectedChartTimeRange, setSelectedChartTimeRange] = (0, import_react10.useState)(
|
|
4093
4244
|
mergedConfig.chart.selectedChartTimeRange
|
|
4094
4245
|
);
|
|
4095
|
-
const handleSetSelectedChartTimeRange = (0,
|
|
4246
|
+
const handleSetSelectedChartTimeRange = (0, import_react10.useCallback)((range) => {
|
|
4096
4247
|
setSelectedChartTimeRange(range);
|
|
4097
4248
|
}, []);
|
|
4098
|
-
const [searchValue, setSearchValue] = (0,
|
|
4099
|
-
const [searchResult, setSearchResult] = (0,
|
|
4100
|
-
const [isShowingAllResults, setIsShowingAllResults] = (0,
|
|
4249
|
+
const [searchValue, setSearchValue] = (0, import_react10.useState)(mergedConfig.search.value);
|
|
4250
|
+
const [searchResult, setSearchResult] = (0, import_react10.useState)(mergedConfig.search.result);
|
|
4251
|
+
const [isShowingAllResults, setIsShowingAllResults] = (0, import_react10.useState)(
|
|
4101
4252
|
mergedConfig.search.isShowingAllResults
|
|
4102
4253
|
);
|
|
4103
|
-
(0,
|
|
4254
|
+
(0, import_react10.useEffect)(() => {
|
|
4104
4255
|
setSearchValue(mergedConfig.search.value);
|
|
4105
4256
|
}, [mergedConfig.search.value]);
|
|
4106
|
-
(0,
|
|
4257
|
+
(0, import_react10.useEffect)(() => {
|
|
4107
4258
|
setSearchResult(mergedConfig.search.result);
|
|
4108
4259
|
}, [mergedConfig.search.result]);
|
|
4109
|
-
(0,
|
|
4260
|
+
(0, import_react10.useEffect)(() => {
|
|
4110
4261
|
setIsShowingAllResults(mergedConfig.search.isShowingAllResults);
|
|
4111
4262
|
}, [mergedConfig.search.isShowingAllResults]);
|
|
4112
|
-
const handleSearchChange = (0,
|
|
4263
|
+
const handleSearchChange = (0, import_react10.useCallback)(
|
|
4113
4264
|
(value) => {
|
|
4114
4265
|
var _a, _b;
|
|
4115
4266
|
setSearchValue(value);
|
|
@@ -4119,7 +4270,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4119
4270
|
},
|
|
4120
4271
|
[mergedConfig.search]
|
|
4121
4272
|
);
|
|
4122
|
-
const handleSearchSelect = (0,
|
|
4273
|
+
const handleSearchSelect = (0, import_react10.useCallback)(
|
|
4123
4274
|
(value) => {
|
|
4124
4275
|
var _a, _b;
|
|
4125
4276
|
const nextSearchState = getSearchStateAfterSelect(value);
|
|
@@ -4130,17 +4281,17 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4130
4281
|
},
|
|
4131
4282
|
[mergedConfig.search]
|
|
4132
4283
|
);
|
|
4133
|
-
const handleOpenResults = (0,
|
|
4284
|
+
const handleOpenResults = (0, import_react10.useCallback)(() => {
|
|
4134
4285
|
var _a, _b;
|
|
4135
4286
|
setIsShowingAllResults(true);
|
|
4136
4287
|
(_b = (_a = mergedConfig.search).openResults) == null ? void 0 : _b.call(_a);
|
|
4137
4288
|
}, [mergedConfig.search]);
|
|
4138
|
-
const handleCloseResults = (0,
|
|
4289
|
+
const handleCloseResults = (0, import_react10.useCallback)(() => {
|
|
4139
4290
|
var _a, _b;
|
|
4140
4291
|
setIsShowingAllResults(false);
|
|
4141
4292
|
(_b = (_a = mergedConfig.search).closeResults) == null ? void 0 : _b.call(_a);
|
|
4142
4293
|
}, [mergedConfig.search]);
|
|
4143
|
-
const resolvedConfig = (0,
|
|
4294
|
+
const resolvedConfig = (0, import_react10.useMemo)(() => {
|
|
4144
4295
|
return __spreadProps(__spreadValues({}, mergedConfig), {
|
|
4145
4296
|
chart: __spreadProps(__spreadValues({}, mergedConfig.chart), {
|
|
4146
4297
|
selectedChartTimeRange,
|
|
@@ -4168,7 +4319,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4168
4319
|
searchValue,
|
|
4169
4320
|
selectedChartTimeRange
|
|
4170
4321
|
]);
|
|
4171
|
-
(0,
|
|
4322
|
+
(0, import_react10.useEffect)(() => {
|
|
4172
4323
|
persistConfig({
|
|
4173
4324
|
locale: resolvedConfig.general.locale,
|
|
4174
4325
|
theme: resolvedConfig.general.theme,
|
|
@@ -4179,10 +4330,10 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4179
4330
|
resolvedConfig.general.theme,
|
|
4180
4331
|
resolvedConfig.chart.selectedChartTimeRange
|
|
4181
4332
|
]);
|
|
4182
|
-
(0,
|
|
4333
|
+
(0, import_react10.useEffect)(() => {
|
|
4183
4334
|
applyThemeToDocument(resolvedConfig.general.theme);
|
|
4184
4335
|
}, [resolvedConfig.general.theme]);
|
|
4185
|
-
(0,
|
|
4336
|
+
(0, import_react10.useEffect)(() => {
|
|
4186
4337
|
warnIfAggStylesAreMissing();
|
|
4187
4338
|
}, []);
|
|
4188
4339
|
const resolvedRootClassName = [
|
|
@@ -4191,7 +4342,7 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4191
4342
|
resolvedConfig.general.rootClassName
|
|
4192
4343
|
].filter(Boolean).join(" ");
|
|
4193
4344
|
logConfig(resolvedConfig, resolvedConfig.enableLogs);
|
|
4194
|
-
return /* @__PURE__ */ (0,
|
|
4345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AggLabelsContext.Provider, { value: resolvedConfig.general.labels, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AggUiContext.Provider, { value: resolvedConfig, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EventTradingProvider, { enableLogs: resolvedConfig.enableLogs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4195
4346
|
"div",
|
|
4196
4347
|
{
|
|
4197
4348
|
className: resolvedRootClassName,
|
|
@@ -4204,11 +4355,11 @@ var AggUiProvider = ({ config, children }) => {
|
|
|
4204
4355
|
};
|
|
4205
4356
|
|
|
4206
4357
|
// src/core/providers/agg-provider.tsx
|
|
4207
|
-
var
|
|
4358
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4208
4359
|
var hasWarnedMissingQueryClient = false;
|
|
4209
4360
|
function useQueryClientCheck() {
|
|
4210
4361
|
try {
|
|
4211
|
-
(0,
|
|
4362
|
+
(0, import_react_query5.useQueryClient)();
|
|
4212
4363
|
} catch (e) {
|
|
4213
4364
|
if (!hasWarnedMissingQueryClient) {
|
|
4214
4365
|
hasWarnedMissingQueryClient = true;
|
|
@@ -4225,14 +4376,14 @@ var AggProvider = ({ client, config, children }) => {
|
|
|
4225
4376
|
"AggProvider requires a valid AggClient instance. Create one with createAggClient() and pass it via the 'client' prop."
|
|
4226
4377
|
);
|
|
4227
4378
|
}
|
|
4228
|
-
return /* @__PURE__ */ (0,
|
|
4379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggClientProvider, { client, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggUiProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggExecutionModeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EventListStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggWebSocketProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggAuthProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AggBalanceProvider, { children }) }) }) }) }) }) });
|
|
4229
4380
|
};
|
|
4230
4381
|
|
|
4231
4382
|
// src/use-ramp-quotes.ts
|
|
4232
|
-
var
|
|
4383
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
4233
4384
|
function useRampQuotes() {
|
|
4234
4385
|
const client = useAggClient();
|
|
4235
|
-
return (0,
|
|
4386
|
+
return (0, import_react_query6.useMutation)({
|
|
4236
4387
|
mutationFn: (params) => __async(null, null, function* () {
|
|
4237
4388
|
return client.getRampQuotes(params);
|
|
4238
4389
|
})
|
|
@@ -4240,10 +4391,10 @@ function useRampQuotes() {
|
|
|
4240
4391
|
}
|
|
4241
4392
|
|
|
4242
4393
|
// src/use-ramp-session.ts
|
|
4243
|
-
var
|
|
4394
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
4244
4395
|
function useRampSession() {
|
|
4245
4396
|
const client = useAggClient();
|
|
4246
|
-
return (0,
|
|
4397
|
+
return (0, import_react_query7.useMutation)({
|
|
4247
4398
|
mutationFn: (params) => __async(null, null, function* () {
|
|
4248
4399
|
return client.createRampSession(params);
|
|
4249
4400
|
})
|
|
@@ -4251,17 +4402,31 @@ function useRampSession() {
|
|
|
4251
4402
|
}
|
|
4252
4403
|
|
|
4253
4404
|
// src/withdraw/use-withdraw-flow.ts
|
|
4254
|
-
var
|
|
4405
|
+
var import_react15 = require("react");
|
|
4255
4406
|
|
|
4256
4407
|
// src/execution/use-execute-managed.ts
|
|
4257
|
-
var
|
|
4408
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
4258
4409
|
function useExecuteManaged(options) {
|
|
4259
4410
|
const client = useAggClient();
|
|
4260
|
-
const queryClient = (0,
|
|
4261
|
-
return (0,
|
|
4411
|
+
const queryClient = (0, import_react_query8.useQueryClient)();
|
|
4412
|
+
return (0, import_react_query8.useMutation)({
|
|
4262
4413
|
mutationFn: (params) => client.executeManaged(params),
|
|
4263
4414
|
onSuccess: (data) => {
|
|
4264
4415
|
var _a;
|
|
4416
|
+
queryClient.setQueriesData({ queryKey: ["smart-route"] }, (route) => {
|
|
4417
|
+
var _a2;
|
|
4418
|
+
if (!route) return route;
|
|
4419
|
+
const consumedPrimary = route.quoteId === data.quoteId;
|
|
4420
|
+
const consumedComparison = (_a2 = route.venueSoloQuotes) == null ? void 0 : _a2.some(
|
|
4421
|
+
(quote) => quote.quoteId === data.quoteId
|
|
4422
|
+
);
|
|
4423
|
+
if (!consumedPrimary && !consumedComparison) return route;
|
|
4424
|
+
return __spreadValues(__spreadValues(__spreadValues({}, route), consumedPrimary ? { quoteId: "" } : {}), consumedComparison ? {
|
|
4425
|
+
venueSoloQuotes: route.venueSoloQuotes.map(
|
|
4426
|
+
(quote) => quote.quoteId === data.quoteId ? __spreadProps(__spreadValues({}, quote), { quoteId: "" }) : quote
|
|
4427
|
+
)
|
|
4428
|
+
} : {});
|
|
4429
|
+
});
|
|
4265
4430
|
queryClient.invalidateQueries({ queryKey: executionKeys.ordersPrefix() });
|
|
4266
4431
|
queryClient.invalidateQueries({ queryKey: executionKeys.positionsPrefix() });
|
|
4267
4432
|
invalidateBalanceQueries(queryClient);
|
|
@@ -4272,11 +4437,11 @@ function useExecuteManaged(options) {
|
|
|
4272
4437
|
}
|
|
4273
4438
|
|
|
4274
4439
|
// src/execution/use-place-limit-order.ts
|
|
4275
|
-
var
|
|
4440
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
4276
4441
|
function usePlaceLimitOrder(options) {
|
|
4277
4442
|
const client = useAggClient();
|
|
4278
|
-
const queryClient = (0,
|
|
4279
|
-
return (0,
|
|
4443
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
4444
|
+
return (0, import_react_query9.useMutation)({
|
|
4280
4445
|
mutationFn: (params) => client.placeLimitOrder(params),
|
|
4281
4446
|
onSuccess: (data) => {
|
|
4282
4447
|
var _a;
|
|
@@ -4291,11 +4456,11 @@ function usePlaceLimitOrder(options) {
|
|
|
4291
4456
|
}
|
|
4292
4457
|
|
|
4293
4458
|
// src/execution/use-cancel-managed-order.ts
|
|
4294
|
-
var
|
|
4459
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
4295
4460
|
function useCancelManagedOrder(options) {
|
|
4296
4461
|
const client = useAggClient();
|
|
4297
|
-
const queryClient = (0,
|
|
4298
|
-
return (0,
|
|
4462
|
+
const queryClient = (0, import_react_query10.useQueryClient)();
|
|
4463
|
+
return (0, import_react_query10.useMutation)({
|
|
4299
4464
|
mutationFn: (orderId) => client.cancelManagedOrder(orderId),
|
|
4300
4465
|
onSuccess: (data, orderId) => {
|
|
4301
4466
|
var _a;
|
|
@@ -4314,11 +4479,11 @@ function useCancelManagedOrder(options) {
|
|
|
4314
4479
|
}
|
|
4315
4480
|
|
|
4316
4481
|
// src/execution/use-withdraw-managed.ts
|
|
4317
|
-
var
|
|
4482
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
4318
4483
|
function useWithdrawManaged(options) {
|
|
4319
4484
|
const client = useAggClient();
|
|
4320
|
-
const queryClient = (0,
|
|
4321
|
-
return (0,
|
|
4485
|
+
const queryClient = (0, import_react_query11.useQueryClient)();
|
|
4486
|
+
return (0, import_react_query11.useMutation)({
|
|
4322
4487
|
mutationFn: (params) => client.withdrawManaged(params),
|
|
4323
4488
|
onSuccess: (data) => {
|
|
4324
4489
|
var _a;
|
|
@@ -4330,15 +4495,19 @@ function useWithdrawManaged(options) {
|
|
|
4330
4495
|
}
|
|
4331
4496
|
|
|
4332
4497
|
// src/execution/use-managed-balances.ts
|
|
4333
|
-
var
|
|
4498
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
4334
4499
|
function useManagedBalances(options) {
|
|
4335
4500
|
const client = useAggClient();
|
|
4336
4501
|
const { enabled = true, mode } = options != null ? options : {};
|
|
4337
|
-
const query = (0,
|
|
4502
|
+
const query = (0, import_react_query12.useQuery)({
|
|
4338
4503
|
queryKey: executionKeys.balances(mode),
|
|
4339
4504
|
queryFn: () => client.getManagedBalances(mode ? { mode } : void 0),
|
|
4340
4505
|
enabled,
|
|
4341
4506
|
staleTime: 1e4,
|
|
4507
|
+
// A matched fill can precede settlement and the API's next balance snapshot.
|
|
4508
|
+
// Keep visible clients converging even if that first invalidation reads old cash.
|
|
4509
|
+
refetchInterval: mode === "paper" ? false : 5e3,
|
|
4510
|
+
refetchIntervalInBackground: false,
|
|
4342
4511
|
gcTime: 5 * 6e4,
|
|
4343
4512
|
retry: 1
|
|
4344
4513
|
});
|
|
@@ -4348,12 +4517,12 @@ function useManagedBalances(options) {
|
|
|
4348
4517
|
}
|
|
4349
4518
|
|
|
4350
4519
|
// src/execution/use-positions.ts
|
|
4351
|
-
var
|
|
4520
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
4352
4521
|
function usePositions(options) {
|
|
4353
4522
|
var _a, _b, _c, _d;
|
|
4354
4523
|
const client = useAggClient();
|
|
4355
4524
|
const { enabled = true, cursor, limit, status, mode } = options != null ? options : {};
|
|
4356
|
-
const query = (0,
|
|
4525
|
+
const query = (0, import_react_query13.useQuery)({
|
|
4357
4526
|
queryKey: executionKeys.positions(cursor, limit, status, mode),
|
|
4358
4527
|
queryFn: () => client.getPositions(__spreadValues({ cursor, limit, status }, mode ? { mode } : {})),
|
|
4359
4528
|
enabled,
|
|
@@ -4369,8 +4538,8 @@ function usePositions(options) {
|
|
|
4369
4538
|
}
|
|
4370
4539
|
|
|
4371
4540
|
// src/execution/use-deposit-addresses.ts
|
|
4372
|
-
var
|
|
4373
|
-
var
|
|
4541
|
+
var import_react11 = require("react");
|
|
4542
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
4374
4543
|
var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
|
|
4375
4544
|
function getDepositAddress(chainId, data) {
|
|
4376
4545
|
return chainId !== void 0 && SVM_CHAIN_IDS.has(chainId) ? data.svmAddress : data.evmAddress;
|
|
@@ -4384,9 +4553,9 @@ function useDepositAddresses(options) {
|
|
|
4384
4553
|
refetchIntervalMs = 5e3,
|
|
4385
4554
|
timeoutMs = 6e4
|
|
4386
4555
|
} = options != null ? options : {};
|
|
4387
|
-
const [isTimedOut, setIsTimedOut] = (0,
|
|
4388
|
-
const timeoutRef = (0,
|
|
4389
|
-
(0,
|
|
4556
|
+
const [isTimedOut, setIsTimedOut] = (0, import_react11.useState)(false);
|
|
4557
|
+
const timeoutRef = (0, import_react11.useRef)(null);
|
|
4558
|
+
(0, import_react11.useEffect)(() => {
|
|
4390
4559
|
if (!enabled || !poll) return void 0;
|
|
4391
4560
|
setIsTimedOut(false);
|
|
4392
4561
|
timeoutRef.current = setTimeout(() => setIsTimedOut(true), timeoutMs);
|
|
@@ -4394,7 +4563,7 @@ function useDepositAddresses(options) {
|
|
|
4394
4563
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
4395
4564
|
};
|
|
4396
4565
|
}, [enabled, poll, timeoutMs]);
|
|
4397
|
-
const query = (0,
|
|
4566
|
+
const query = (0, import_react_query14.useQuery)({
|
|
4398
4567
|
queryKey: executionKeys.depositAddresses(),
|
|
4399
4568
|
queryFn: () => client.getDepositAddresses(),
|
|
4400
4569
|
enabled,
|
|
@@ -4410,9 +4579,9 @@ function useDepositAddresses(options) {
|
|
|
4410
4579
|
});
|
|
4411
4580
|
const isReady = ((_a = query.data) == null ? void 0 : _a.ready) === true;
|
|
4412
4581
|
const readyData = isReady ? query.data : void 0;
|
|
4413
|
-
const evmAddress = (0,
|
|
4414
|
-
const svmAddress = (0,
|
|
4415
|
-
const supportedChains = (0,
|
|
4582
|
+
const evmAddress = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.evmAddress, [readyData]);
|
|
4583
|
+
const svmAddress = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.svmAddress, [readyData]);
|
|
4584
|
+
const supportedChains = (0, import_react11.useMemo)(() => readyData == null ? void 0 : readyData.supportedChains, [readyData]);
|
|
4416
4585
|
return __spreadProps(__spreadValues({}, query), {
|
|
4417
4586
|
isReady,
|
|
4418
4587
|
isTimedOut,
|
|
@@ -4426,11 +4595,11 @@ function useDepositAddresses(options) {
|
|
|
4426
4595
|
}
|
|
4427
4596
|
|
|
4428
4597
|
// src/execution/use-sync-balances.ts
|
|
4429
|
-
var
|
|
4598
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
4430
4599
|
function useSyncBalances(options) {
|
|
4431
4600
|
const client = useAggClient();
|
|
4432
|
-
const queryClient = (0,
|
|
4433
|
-
return (0,
|
|
4601
|
+
const queryClient = (0, import_react_query15.useQueryClient)();
|
|
4602
|
+
return (0, import_react_query15.useMutation)({
|
|
4434
4603
|
mutationFn: () => client.syncManagedBalances(),
|
|
4435
4604
|
onSuccess: () => {
|
|
4436
4605
|
var _a;
|
|
@@ -4442,7 +4611,7 @@ function useSyncBalances(options) {
|
|
|
4442
4611
|
}
|
|
4443
4612
|
|
|
4444
4613
|
// src/execution/use-execution-progress.ts
|
|
4445
|
-
var
|
|
4614
|
+
var import_react12 = require("react");
|
|
4446
4615
|
var TERMINAL_ORDER_STATUSES = /* @__PURE__ */ new Set([
|
|
4447
4616
|
"filled",
|
|
4448
4617
|
"partial_fill",
|
|
@@ -4575,20 +4744,20 @@ function useExecutionProgress({
|
|
|
4575
4744
|
enabled,
|
|
4576
4745
|
mode
|
|
4577
4746
|
}) {
|
|
4578
|
-
const [phase, setPhase] = (0,
|
|
4579
|
-
const [submittedOrders, setSubmittedOrders] = (0,
|
|
4580
|
-
const [latestBalance, setLatestBalance] = (0,
|
|
4581
|
-
const [dagProgress, setDagProgress] = (0,
|
|
4582
|
-
const [terminalOrderEvents, setTerminalOrderEvents] = (0,
|
|
4583
|
-
const [executionSteps, setExecutionSteps] = (0,
|
|
4584
|
-
const [rawExecutionSteps, setRawExecutionSteps] = (0,
|
|
4585
|
-
const [executionOrders, setExecutionOrders] = (0,
|
|
4586
|
-
const orderIdSetRef = (0,
|
|
4587
|
-
const submittedOrderVenueByIdRef = (0,
|
|
4588
|
-
(0,
|
|
4747
|
+
const [phase, setPhase] = (0, import_react12.useState)("idle");
|
|
4748
|
+
const [submittedOrders, setSubmittedOrders] = (0, import_react12.useState)([]);
|
|
4749
|
+
const [latestBalance, setLatestBalance] = (0, import_react12.useState)(null);
|
|
4750
|
+
const [dagProgress, setDagProgress] = (0, import_react12.useState)(null);
|
|
4751
|
+
const [terminalOrderEvents, setTerminalOrderEvents] = (0, import_react12.useState)([]);
|
|
4752
|
+
const [executionSteps, setExecutionSteps] = (0, import_react12.useState)([]);
|
|
4753
|
+
const [rawExecutionSteps, setRawExecutionSteps] = (0, import_react12.useState)([]);
|
|
4754
|
+
const [executionOrders, setExecutionOrders] = (0, import_react12.useState)([]);
|
|
4755
|
+
const orderIdSetRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
4756
|
+
const submittedOrderVenueByIdRef = (0, import_react12.useRef)(/* @__PURE__ */ new Map());
|
|
4757
|
+
(0, import_react12.useEffect)(() => {
|
|
4589
4758
|
orderIdSetRef.current = new Set(orderIds != null ? orderIds : []);
|
|
4590
4759
|
}, [orderIds]);
|
|
4591
|
-
(0,
|
|
4760
|
+
(0, import_react12.useEffect)(() => {
|
|
4592
4761
|
if (enabled && orderIds && orderIds.length > 0) {
|
|
4593
4762
|
setPhase("pending");
|
|
4594
4763
|
setSubmittedOrders([]);
|
|
@@ -4613,7 +4782,7 @@ function useExecutionProgress({
|
|
|
4613
4782
|
submittedOrderVenueByIdRef.current = /* @__PURE__ */ new Map();
|
|
4614
4783
|
}
|
|
4615
4784
|
}, [enabled, orderIds]);
|
|
4616
|
-
const handleOrderSubmitted = (0,
|
|
4785
|
+
const handleOrderSubmitted = (0, import_react12.useCallback)((msg) => {
|
|
4617
4786
|
if (!orderIdSetRef.current.has(msg.orderId)) return;
|
|
4618
4787
|
const trimmedVenue = msg.venue.trim();
|
|
4619
4788
|
if (trimmedVenue) {
|
|
@@ -4622,7 +4791,7 @@ function useExecutionProgress({
|
|
|
4622
4791
|
setSubmittedOrders((prev) => [...prev, msg]);
|
|
4623
4792
|
setPhase("order_submitted");
|
|
4624
4793
|
}, []);
|
|
4625
|
-
const handleBalanceUpdate = (0,
|
|
4794
|
+
const handleBalanceUpdate = (0, import_react12.useCallback)((msg) => {
|
|
4626
4795
|
setLatestBalance(msg);
|
|
4627
4796
|
setPhase((current) => {
|
|
4628
4797
|
if (current === "order_submitted" || current === "pending") {
|
|
@@ -4631,7 +4800,7 @@ function useExecutionProgress({
|
|
|
4631
4800
|
return current;
|
|
4632
4801
|
});
|
|
4633
4802
|
}, []);
|
|
4634
|
-
const handleOrderEvent = (0,
|
|
4803
|
+
const handleOrderEvent = (0, import_react12.useCallback)((msg) => {
|
|
4635
4804
|
var _a, _b, _c;
|
|
4636
4805
|
if (!orderIdSetRef.current.has(msg.orderId)) return;
|
|
4637
4806
|
const trimmedVenue = msg.venue.trim();
|
|
@@ -4853,9 +5022,9 @@ function useExecutionProgress({
|
|
|
4853
5022
|
useOnBalanceUpdate(isListening ? handleBalanceUpdate : null);
|
|
4854
5023
|
useOnOrderEvent(isListening ? handleOrderEvent : null);
|
|
4855
5024
|
const client = useAggClient();
|
|
4856
|
-
const terminalOrderIdsRef = (0,
|
|
4857
|
-
const pollInFlightRef = (0,
|
|
4858
|
-
const buildSubmittedOrdersFromStatus = (0,
|
|
5025
|
+
const terminalOrderIdsRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
5026
|
+
const pollInFlightRef = (0, import_react12.useRef)(false);
|
|
5027
|
+
const buildSubmittedOrdersFromStatus = (0, import_react12.useCallback)(
|
|
4859
5028
|
(orders) => {
|
|
4860
5029
|
return orders.map((order) => {
|
|
4861
5030
|
var _a, _b;
|
|
@@ -4872,7 +5041,7 @@ function useExecutionProgress({
|
|
|
4872
5041
|
},
|
|
4873
5042
|
[]
|
|
4874
5043
|
);
|
|
4875
|
-
const buildTerminalEventsFromStatus = (0,
|
|
5044
|
+
const buildTerminalEventsFromStatus = (0, import_react12.useCallback)(
|
|
4876
5045
|
(status, fallbackOrderIds, fallbackTimestamp) => {
|
|
4877
5046
|
const terminalEvents = status.orders.map((order) => {
|
|
4878
5047
|
var _a, _b;
|
|
@@ -4916,7 +5085,7 @@ function useExecutionProgress({
|
|
|
4916
5085
|
},
|
|
4917
5086
|
[]
|
|
4918
5087
|
);
|
|
4919
|
-
const setFatalPollingFailure = (0,
|
|
5088
|
+
const setFatalPollingFailure = (0, import_react12.useCallback)((message, failedOrderIds) => {
|
|
4920
5089
|
setDagProgress((prev) => {
|
|
4921
5090
|
var _a, _b, _c, _d, _e, _f;
|
|
4922
5091
|
return {
|
|
@@ -4948,10 +5117,10 @@ function useExecutionProgress({
|
|
|
4948
5117
|
);
|
|
4949
5118
|
});
|
|
4950
5119
|
}, []);
|
|
4951
|
-
(0,
|
|
5120
|
+
(0, import_react12.useEffect)(() => {
|
|
4952
5121
|
terminalOrderIdsRef.current = new Set(terminalOrderEvents.map((e) => e.orderId));
|
|
4953
5122
|
}, [terminalOrderEvents]);
|
|
4954
|
-
(0,
|
|
5123
|
+
(0, import_react12.useEffect)(() => {
|
|
4955
5124
|
if (!isStatusPolling || !quoteId) return;
|
|
4956
5125
|
let cancelled = false;
|
|
4957
5126
|
let timeout = null;
|
|
@@ -5065,7 +5234,7 @@ function useExecutionProgress({
|
|
|
5065
5234
|
quoteId,
|
|
5066
5235
|
setFatalPollingFailure
|
|
5067
5236
|
]);
|
|
5068
|
-
(0,
|
|
5237
|
+
(0, import_react12.useEffect)(() => {
|
|
5069
5238
|
if (isStatusPolling) return;
|
|
5070
5239
|
if (!isListening || !(orderIds == null ? void 0 : orderIds.length)) return;
|
|
5071
5240
|
let cancelled = false;
|
|
@@ -5158,13 +5327,13 @@ function useExecutionProgress({
|
|
|
5158
5327
|
}
|
|
5159
5328
|
|
|
5160
5329
|
// src/execution/use-balance-refill-policies.ts
|
|
5161
|
-
var
|
|
5330
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
5162
5331
|
function useBalanceRefillPolicies(options) {
|
|
5163
5332
|
var _a, _b;
|
|
5164
5333
|
const client = useAggClient();
|
|
5165
|
-
const queryClient = (0,
|
|
5334
|
+
const queryClient = (0, import_react_query16.useQueryClient)();
|
|
5166
5335
|
const queryKey = executionKeys.balanceRefillPolicies();
|
|
5167
|
-
const query = (0,
|
|
5336
|
+
const query = (0, import_react_query16.useQuery)({
|
|
5168
5337
|
queryKey,
|
|
5169
5338
|
queryFn: () => client.getBalanceRefillPolicies(),
|
|
5170
5339
|
enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
|
|
@@ -5179,13 +5348,13 @@ function useBalanceRefillPolicies(options) {
|
|
|
5179
5348
|
)) ? 5e3 : false;
|
|
5180
5349
|
}
|
|
5181
5350
|
});
|
|
5182
|
-
const createPolicy = (0,
|
|
5351
|
+
const createPolicy = (0, import_react_query16.useMutation)({
|
|
5183
5352
|
mutationFn: (params) => client.createBalanceRefillPolicy(params),
|
|
5184
5353
|
onSuccess: (policy) => {
|
|
5185
5354
|
queryClient.setQueryData(queryKey, [policy]);
|
|
5186
5355
|
}
|
|
5187
5356
|
});
|
|
5188
|
-
const updatePolicy = (0,
|
|
5357
|
+
const updatePolicy = (0, import_react_query16.useMutation)({
|
|
5189
5358
|
mutationFn: ({
|
|
5190
5359
|
policyId,
|
|
5191
5360
|
params
|
|
@@ -5243,7 +5412,7 @@ var computeClosedPositionTotals = (group) => {
|
|
|
5243
5412
|
};
|
|
5244
5413
|
|
|
5245
5414
|
// src/execution/use-redeem.ts
|
|
5246
|
-
var
|
|
5415
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
5247
5416
|
var RedeemRejectedError = class extends Error {
|
|
5248
5417
|
constructor(message, response) {
|
|
5249
5418
|
super(message);
|
|
@@ -5254,10 +5423,11 @@ var RedeemRejectedError = class extends Error {
|
|
|
5254
5423
|
var isLegRejected = (status) => status === "ineligible" || status === "rejected";
|
|
5255
5424
|
var useRedeem = () => {
|
|
5256
5425
|
const client = useAggClient();
|
|
5257
|
-
const queryClient = (0,
|
|
5258
|
-
|
|
5426
|
+
const queryClient = (0, import_react_query17.useQueryClient)();
|
|
5427
|
+
const { executionMode } = useResolvedExecutionMode();
|
|
5428
|
+
return (0, import_react_query17.useMutation)({
|
|
5259
5429
|
mutationFn: (body) => __async(null, null, function* () {
|
|
5260
|
-
const response = yield client.redeem(body);
|
|
5430
|
+
const response = yield client.redeem(__spreadValues({ mode: executionMode }, body));
|
|
5261
5431
|
if (response.results.length > 0 && response.results.every((r) => isLegRejected(r.status))) {
|
|
5262
5432
|
const reasons = response.results.map((r) => r.reason).filter((r) => Boolean(r));
|
|
5263
5433
|
const message = reasons.length > 0 ? reasons.join("; ") : "Redeem rejected";
|
|
@@ -5277,7 +5447,7 @@ var useOnRedeemEvent2 = (listener) => {
|
|
|
5277
5447
|
};
|
|
5278
5448
|
|
|
5279
5449
|
// src/execution/use-redeem-eligible-count.ts
|
|
5280
|
-
var
|
|
5450
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
5281
5451
|
var CLAIMABLE_COUNT_PAGE_LIMIT = 100;
|
|
5282
5452
|
var getClaimablePositionsCount = (client) => __async(null, null, function* () {
|
|
5283
5453
|
var _a;
|
|
@@ -5302,7 +5472,7 @@ var useRedeemEligibleCount = () => {
|
|
|
5302
5472
|
var _a;
|
|
5303
5473
|
const client = useAggClient();
|
|
5304
5474
|
const { isAuthenticated } = useAggAuthState();
|
|
5305
|
-
const query = (0,
|
|
5475
|
+
const query = (0, import_react_query18.useQuery)({
|
|
5306
5476
|
queryKey: executionKeys.claimablePositionsCount(),
|
|
5307
5477
|
queryFn: () => getClaimablePositionsCount(client),
|
|
5308
5478
|
enabled: isAuthenticated,
|
|
@@ -5314,10 +5484,10 @@ var useRedeemEligibleCount = () => {
|
|
|
5314
5484
|
};
|
|
5315
5485
|
|
|
5316
5486
|
// src/execution/use-redeem-lifecycle.ts
|
|
5317
|
-
var
|
|
5487
|
+
var import_react14 = require("react");
|
|
5318
5488
|
|
|
5319
5489
|
// src/execution/use-redeem-lifecycles.ts
|
|
5320
|
-
var
|
|
5490
|
+
var import_react13 = require("react");
|
|
5321
5491
|
var computeDerivedState = (legs, expectedCount) => {
|
|
5322
5492
|
const legCount = Object.keys(legs).length;
|
|
5323
5493
|
let allTerminal = legCount === expectedCount;
|
|
@@ -5368,21 +5538,21 @@ var seedState = (input) => {
|
|
|
5368
5538
|
};
|
|
5369
5539
|
};
|
|
5370
5540
|
function useRedeemLifecycles(inputs) {
|
|
5371
|
-
const inputsByRedeemId = (0,
|
|
5541
|
+
const inputsByRedeemId = (0, import_react13.useMemo)(() => {
|
|
5372
5542
|
const map = {};
|
|
5373
5543
|
for (const input of inputs) {
|
|
5374
5544
|
map[input.redeemId] = input;
|
|
5375
5545
|
}
|
|
5376
5546
|
return map;
|
|
5377
5547
|
}, [inputs]);
|
|
5378
|
-
const [stateMap, setStateMap] = (0,
|
|
5548
|
+
const [stateMap, setStateMap] = (0, import_react13.useState)(() => {
|
|
5379
5549
|
const next = {};
|
|
5380
5550
|
for (const [id, input] of Object.entries(inputsByRedeemId)) {
|
|
5381
5551
|
next[id] = seedState(input);
|
|
5382
5552
|
}
|
|
5383
5553
|
return next;
|
|
5384
5554
|
});
|
|
5385
|
-
(0,
|
|
5555
|
+
(0, import_react13.useEffect)(() => {
|
|
5386
5556
|
setStateMap((prev) => {
|
|
5387
5557
|
let changed = false;
|
|
5388
5558
|
const next = {};
|
|
@@ -5400,7 +5570,7 @@ function useRedeemLifecycles(inputs) {
|
|
|
5400
5570
|
});
|
|
5401
5571
|
}, [inputsByRedeemId]);
|
|
5402
5572
|
useOnRedeemEvent(
|
|
5403
|
-
(0,
|
|
5573
|
+
(0, import_react13.useMemo)(() => {
|
|
5404
5574
|
if (Object.keys(inputsByRedeemId).length === 0) return null;
|
|
5405
5575
|
return (event) => {
|
|
5406
5576
|
const input = inputsByRedeemId[event.redeemId];
|
|
@@ -5445,7 +5615,7 @@ var INITIAL_STATE = {
|
|
|
5445
5615
|
};
|
|
5446
5616
|
function useRedeemLifecycle(input) {
|
|
5447
5617
|
var _a;
|
|
5448
|
-
const inputs = (0,
|
|
5618
|
+
const inputs = (0, import_react14.useMemo)(() => input ? [input] : [], [input]);
|
|
5449
5619
|
const map = useRedeemLifecycles(inputs);
|
|
5450
5620
|
if (!input) return INITIAL_STATE;
|
|
5451
5621
|
return (_a = map[input.redeemId]) != null ? _a : INITIAL_STATE;
|
|
@@ -5526,25 +5696,25 @@ function useWithdrawFlow(options) {
|
|
|
5526
5696
|
const withdrawMutation = useWithdrawManaged();
|
|
5527
5697
|
const syncBalances = useSyncBalances();
|
|
5528
5698
|
const ws = useAggWebSocket();
|
|
5529
|
-
(0,
|
|
5699
|
+
(0, import_react15.useEffect)(() => {
|
|
5530
5700
|
if (!open) return;
|
|
5531
5701
|
syncBalances.mutate(void 0, {
|
|
5532
5702
|
onError: () => {
|
|
5533
5703
|
}
|
|
5534
5704
|
});
|
|
5535
5705
|
}, [open]);
|
|
5536
|
-
const [withdrawDestination, setWithdrawDestination] = (0,
|
|
5537
|
-
const [withdrawAmount, setWithdrawAmount] = (0,
|
|
5538
|
-
const [withdrawToken, setWithdrawToken] = (0,
|
|
5539
|
-
const [withdrawNetwork, setWithdrawNetwork] = (0,
|
|
5540
|
-
const [withdrawSummary, setWithdrawSummary] = (0,
|
|
5541
|
-
const [withdrawalId, setWithdrawalId] = (0,
|
|
5542
|
-
const [isMax, setIsMax] = (0,
|
|
5543
|
-
const detectedAddressKind = (0,
|
|
5706
|
+
const [withdrawDestination, setWithdrawDestination] = (0, import_react15.useState)("");
|
|
5707
|
+
const [withdrawAmount, setWithdrawAmount] = (0, import_react15.useState)("");
|
|
5708
|
+
const [withdrawToken, setWithdrawToken] = (0, import_react15.useState)("USDC");
|
|
5709
|
+
const [withdrawNetwork, setWithdrawNetwork] = (0, import_react15.useState)("");
|
|
5710
|
+
const [withdrawSummary, setWithdrawSummary] = (0, import_react15.useState)(DEFAULT_WITHDRAW_SUMMARY);
|
|
5711
|
+
const [withdrawalId, setWithdrawalId] = (0, import_react15.useState)(null);
|
|
5712
|
+
const [isMax, setIsMax] = (0, import_react15.useState)(false);
|
|
5713
|
+
const detectedAddressKind = (0, import_react15.useMemo)(
|
|
5544
5714
|
() => detectDestinationAddressKind(withdrawDestination),
|
|
5545
5715
|
[withdrawDestination]
|
|
5546
5716
|
);
|
|
5547
|
-
const networkOptions = (0,
|
|
5717
|
+
const networkOptions = (0, import_react15.useMemo)(
|
|
5548
5718
|
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) => {
|
|
5549
5719
|
const value = String(chain.chainId);
|
|
5550
5720
|
const isSolana = chain.chainId === SOLANA_CHAIN_ID;
|
|
@@ -5558,13 +5728,13 @@ function useWithdrawFlow(options) {
|
|
|
5558
5728
|
(option) => option.value === withdrawNetwork && !option.disabled
|
|
5559
5729
|
);
|
|
5560
5730
|
const resolvedWithdrawNetwork = isCurrentNetworkSelectable ? withdrawNetwork : firstEnabledNetwork;
|
|
5561
|
-
(0,
|
|
5731
|
+
(0, import_react15.useEffect)(() => {
|
|
5562
5732
|
if (!networkOptions.length) return;
|
|
5563
5733
|
if (!isCurrentNetworkSelectable && firstEnabledNetwork) {
|
|
5564
5734
|
setWithdrawNetwork(firstEnabledNetwork);
|
|
5565
5735
|
}
|
|
5566
5736
|
}, [networkOptions, isCurrentNetworkSelectable, firstEnabledNetwork]);
|
|
5567
|
-
const tokenOptions = (0,
|
|
5737
|
+
const tokenOptions = (0, import_react15.useMemo)(() => {
|
|
5568
5738
|
var _a2, _b2, _c2;
|
|
5569
5739
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
5570
5740
|
const supportedTokensForNetwork = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens) != null ? _b2 : [];
|
|
@@ -5575,17 +5745,17 @@ function useWithdrawFlow(options) {
|
|
|
5575
5745
|
}));
|
|
5576
5746
|
}, [balances, resolvedWithdrawNetwork, supportedChains]);
|
|
5577
5747
|
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((_e = tokenOptions[0]) == null ? void 0 : _e.value) || "";
|
|
5578
|
-
(0,
|
|
5748
|
+
(0, import_react15.useEffect)(() => {
|
|
5579
5749
|
if (!tokenOptions.length) return;
|
|
5580
5750
|
if (!tokenOptions.some((option) => option.value === withdrawToken)) {
|
|
5581
5751
|
setWithdrawToken(tokenOptions[0].value);
|
|
5582
5752
|
}
|
|
5583
5753
|
}, [tokenOptions, withdrawToken]);
|
|
5584
|
-
const selectedCashEntry = (0,
|
|
5754
|
+
const selectedCashEntry = (0, import_react15.useMemo)(
|
|
5585
5755
|
() => balances == null ? void 0 : balances.cash.find((cashEntry) => cashEntry.tokenSymbol === resolvedWithdrawToken),
|
|
5586
5756
|
[balances, resolvedWithdrawToken]
|
|
5587
5757
|
);
|
|
5588
|
-
const selectedTokenDecimals = (0,
|
|
5758
|
+
const selectedTokenDecimals = (0, import_react15.useMemo)(() => {
|
|
5589
5759
|
var _a2, _b2, _c2, _d2;
|
|
5590
5760
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
5591
5761
|
return (_d2 = (_c2 = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens.find((token) => token.symbol === resolvedWithdrawToken)) == null ? void 0 : _b2.decimals) != null ? _c2 : selectedCashEntry == null ? void 0 : selectedCashEntry.decimals) != null ? _d2 : 6;
|
|
@@ -5595,18 +5765,18 @@ function useWithdrawFlow(options) {
|
|
|
5595
5765
|
selectedCashEntry == null ? void 0 : selectedCashEntry.decimals,
|
|
5596
5766
|
supportedChains
|
|
5597
5767
|
]);
|
|
5598
|
-
const exactBalance = (0,
|
|
5768
|
+
const exactBalance = (0, import_react15.useMemo)(() => {
|
|
5599
5769
|
if (!selectedCashEntry) return "0";
|
|
5600
5770
|
return formatRawTokenAmount(selectedCashEntry.totalRaw, selectedCashEntry.decimals);
|
|
5601
5771
|
}, [selectedCashEntry]);
|
|
5602
|
-
const balanceDisplay = (0,
|
|
5772
|
+
const balanceDisplay = (0, import_react15.useMemo)(() => {
|
|
5603
5773
|
if (!selectedCashEntry) return `0.00 ${resolvedWithdrawToken || withdrawToken}`;
|
|
5604
5774
|
return `${formatRawTokenAmountForDisplay(
|
|
5605
5775
|
selectedCashEntry.totalRaw,
|
|
5606
5776
|
selectedCashEntry.decimals
|
|
5607
5777
|
)} ${resolvedWithdrawToken}`;
|
|
5608
5778
|
}, [resolvedWithdrawToken, selectedCashEntry, withdrawToken]);
|
|
5609
|
-
const resetFlowState = (0,
|
|
5779
|
+
const resetFlowState = (0, import_react15.useCallback)(() => {
|
|
5610
5780
|
setWithdrawDestination("");
|
|
5611
5781
|
setWithdrawAmount("");
|
|
5612
5782
|
setWithdrawToken("USDC");
|
|
@@ -5615,17 +5785,17 @@ function useWithdrawFlow(options) {
|
|
|
5615
5785
|
setWithdrawalId(null);
|
|
5616
5786
|
setIsMax(false);
|
|
5617
5787
|
}, []);
|
|
5618
|
-
const handleWithdrawOpenChange = (0,
|
|
5788
|
+
const handleWithdrawOpenChange = (0, import_react15.useCallback)(
|
|
5619
5789
|
(isOpen) => {
|
|
5620
5790
|
if (!isOpen) resetFlowState();
|
|
5621
5791
|
onOpenChange(isOpen);
|
|
5622
5792
|
},
|
|
5623
5793
|
[onOpenChange, resetFlowState]
|
|
5624
5794
|
);
|
|
5625
|
-
(0,
|
|
5795
|
+
(0, import_react15.useEffect)(() => {
|
|
5626
5796
|
if (!open) resetFlowState();
|
|
5627
5797
|
}, [open, resetFlowState]);
|
|
5628
|
-
const handleWithdrawProvider = (0,
|
|
5798
|
+
const handleWithdrawProvider = (0, import_react15.useCallback)(() => __async(null, null, function* () {
|
|
5629
5799
|
var _a2, _b2;
|
|
5630
5800
|
const destinationChainId = Number(resolvedWithdrawNetwork);
|
|
5631
5801
|
const trimmedDestination = withdrawDestination.trim();
|
|
@@ -5710,34 +5880,34 @@ function useWithdrawFlow(options) {
|
|
|
5710
5880
|
isMax
|
|
5711
5881
|
},
|
|
5712
5882
|
onWithdrawDestinationChange: setWithdrawDestination,
|
|
5713
|
-
onWithdrawAmountChange: (0,
|
|
5883
|
+
onWithdrawAmountChange: (0, import_react15.useCallback)((v) => {
|
|
5714
5884
|
setIsMax(false);
|
|
5715
5885
|
setWithdrawAmount(v);
|
|
5716
5886
|
}, []),
|
|
5717
5887
|
onWithdrawTokenChange: setWithdrawToken,
|
|
5718
5888
|
onWithdrawNetworkChange: setWithdrawNetwork,
|
|
5719
|
-
onMaxClick: (0,
|
|
5889
|
+
onMaxClick: (0, import_react15.useCallback)(() => {
|
|
5720
5890
|
setIsMax(true);
|
|
5721
5891
|
setWithdrawAmount(exactBalance === "0" ? "0" : exactBalance);
|
|
5722
5892
|
}, [exactBalance]),
|
|
5723
|
-
onSelectWithdrawProvider: (0,
|
|
5893
|
+
onSelectWithdrawProvider: (0, import_react15.useCallback)(
|
|
5724
5894
|
(_providerId) => __async(null, null, function* () {
|
|
5725
5895
|
return handleWithdrawProvider();
|
|
5726
5896
|
}),
|
|
5727
5897
|
[handleWithdrawProvider]
|
|
5728
5898
|
),
|
|
5729
|
-
onDoneWithdraw: (0,
|
|
5899
|
+
onDoneWithdraw: (0, import_react15.useCallback)(() => handleWithdrawOpenChange(false), [handleWithdrawOpenChange])
|
|
5730
5900
|
};
|
|
5731
5901
|
}
|
|
5732
5902
|
|
|
5733
5903
|
// src/withdraw/use-withdraw-estimate.ts
|
|
5734
|
-
var
|
|
5904
|
+
var import_react16 = require("react");
|
|
5735
5905
|
function useWithdrawEstimate({
|
|
5736
5906
|
amount,
|
|
5737
5907
|
selectedToken,
|
|
5738
5908
|
selectedNetwork
|
|
5739
5909
|
}) {
|
|
5740
|
-
return (0,
|
|
5910
|
+
return (0, import_react16.useMemo)(() => {
|
|
5741
5911
|
const numAmount = Number(amount);
|
|
5742
5912
|
if (!amount || isNaN(numAmount) || numAmount <= 0 || !selectedToken || !selectedNetwork) {
|
|
5743
5913
|
return null;
|
|
@@ -5777,8 +5947,8 @@ function useWithdrawEstimate({
|
|
|
5777
5947
|
}
|
|
5778
5948
|
|
|
5779
5949
|
// src/withdraw/use-withdrawal-lifecycle.ts
|
|
5780
|
-
var
|
|
5781
|
-
var
|
|
5950
|
+
var import_react17 = require("react");
|
|
5951
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
5782
5952
|
var INITIAL_STATE2 = {
|
|
5783
5953
|
pending: true,
|
|
5784
5954
|
status: null,
|
|
@@ -5835,15 +6005,15 @@ var restToLifecycleState = (response) => {
|
|
|
5835
6005
|
function useWithdrawalLifecycle(withdrawalId) {
|
|
5836
6006
|
const client = useAggClient();
|
|
5837
6007
|
const wsConnected = useAggWebSocketConnectionState();
|
|
5838
|
-
const queryClient = (0,
|
|
5839
|
-
const [state, setState] = (0,
|
|
5840
|
-
const stateRef = (0,
|
|
6008
|
+
const queryClient = (0, import_react_query19.useQueryClient)();
|
|
6009
|
+
const [state, setState] = (0, import_react17.useState)(INITIAL_STATE2);
|
|
6010
|
+
const stateRef = (0, import_react17.useRef)(state);
|
|
5841
6011
|
stateRef.current = state;
|
|
5842
|
-
const balanceRefetchedForRef = (0,
|
|
5843
|
-
(0,
|
|
6012
|
+
const balanceRefetchedForRef = (0, import_react17.useRef)(null);
|
|
6013
|
+
(0, import_react17.useEffect)(() => {
|
|
5844
6014
|
setState(INITIAL_STATE2);
|
|
5845
6015
|
}, [withdrawalId]);
|
|
5846
|
-
(0,
|
|
6016
|
+
(0, import_react17.useEffect)(() => {
|
|
5847
6017
|
if (!withdrawalId) return;
|
|
5848
6018
|
let cancelled = false;
|
|
5849
6019
|
(() => __async(null, null, function* () {
|
|
@@ -5862,7 +6032,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5862
6032
|
cancelled = true;
|
|
5863
6033
|
};
|
|
5864
6034
|
}, [client, withdrawalId, wsConnected]);
|
|
5865
|
-
const handler = (0,
|
|
6035
|
+
const handler = (0, import_react17.useMemo)(() => {
|
|
5866
6036
|
if (!withdrawalId) return null;
|
|
5867
6037
|
return (msg) => {
|
|
5868
6038
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
@@ -5890,7 +6060,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5890
6060
|
};
|
|
5891
6061
|
}, [withdrawalId]);
|
|
5892
6062
|
useOnWithdrawalLifecycle(handler);
|
|
5893
|
-
(0,
|
|
6063
|
+
(0, import_react17.useEffect)(() => {
|
|
5894
6064
|
if (!withdrawalId) return;
|
|
5895
6065
|
if (!state.terminal) return;
|
|
5896
6066
|
if (balanceRefetchedForRef.current === withdrawalId) return;
|
|
@@ -5899,12 +6069,12 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
5899
6069
|
client.syncManagedBalances().catch(() => {
|
|
5900
6070
|
});
|
|
5901
6071
|
}, [client, queryClient, state.terminal, withdrawalId]);
|
|
5902
|
-
const reset = (0,
|
|
6072
|
+
const reset = (0, import_react17.useCallback)(() => setState(INITIAL_STATE2), []);
|
|
5903
6073
|
return { state, reset };
|
|
5904
6074
|
}
|
|
5905
6075
|
|
|
5906
6076
|
// src/withdraw/use-withdraw-preview.ts
|
|
5907
|
-
var
|
|
6077
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
5908
6078
|
function useWithdrawPreview({
|
|
5909
6079
|
amountRaw,
|
|
5910
6080
|
tokenSymbol,
|
|
@@ -5914,7 +6084,7 @@ function useWithdrawPreview({
|
|
|
5914
6084
|
}) {
|
|
5915
6085
|
const client = useAggClient();
|
|
5916
6086
|
const enabled = !!amountRaw && BigInt(amountRaw || "0") > BigInt(0) && !!tokenSymbol && !!destinationChainId && !!destinationAddress;
|
|
5917
|
-
return (0,
|
|
6087
|
+
return (0, import_react_query20.useQuery)({
|
|
5918
6088
|
queryKey: [
|
|
5919
6089
|
"withdraw-preview",
|
|
5920
6090
|
tokenSymbol,
|
|
@@ -5938,7 +6108,7 @@ function useWithdrawPreview({
|
|
|
5938
6108
|
var import_sdk4 = require("@agg-build/sdk");
|
|
5939
6109
|
|
|
5940
6110
|
// src/use-geo-block.ts
|
|
5941
|
-
var
|
|
6111
|
+
var import_react18 = require("react");
|
|
5942
6112
|
var DEFAULT_STATE = {
|
|
5943
6113
|
isLocationBlocked: false,
|
|
5944
6114
|
isTradingBlocked: false,
|
|
@@ -5946,7 +6116,7 @@ var DEFAULT_STATE = {
|
|
|
5946
6116
|
};
|
|
5947
6117
|
function useGeoBlock() {
|
|
5948
6118
|
var _a, _b;
|
|
5949
|
-
const authContext = (0,
|
|
6119
|
+
const authContext = (0, import_react18.useContext)(AggAuthContext);
|
|
5950
6120
|
if (process.env.NEXT_PUBLIC_GEO_BLOCK_DISABLE === "true") return DEFAULT_STATE;
|
|
5951
6121
|
const isBlocked = (_b = (_a = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a.isLocationBlocked) != null ? _b : false;
|
|
5952
6122
|
if (!isBlocked) return DEFAULT_STATE;
|
|
@@ -5986,22 +6156,56 @@ var getVenueAvailabilityState = ({
|
|
|
5986
6156
|
};
|
|
5987
6157
|
|
|
5988
6158
|
// src/use-venue-key-status.ts
|
|
5989
|
-
var
|
|
6159
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
5990
6160
|
var venueKeyQueryKeys = {
|
|
5991
6161
|
all: ["agg", "venue-keys"],
|
|
5992
6162
|
status: (venue) => [...venueKeyQueryKeys.all, venue, "status"]
|
|
5993
6163
|
};
|
|
5994
6164
|
var useVenueKeyStatus = (venue, enabled = true) => {
|
|
5995
6165
|
const client = useAggClient();
|
|
5996
|
-
return (0,
|
|
6166
|
+
return (0, import_react_query21.useQuery)({
|
|
5997
6167
|
queryKey: venueKeyQueryKeys.status(venue),
|
|
5998
6168
|
queryFn: () => client.getVenueKeyStatus(venue),
|
|
5999
6169
|
enabled
|
|
6000
6170
|
});
|
|
6001
6171
|
};
|
|
6002
6172
|
|
|
6173
|
+
// src/use-shared-kyc.ts
|
|
6174
|
+
var import_react19 = require("react");
|
|
6175
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
6176
|
+
var sharedKycQueryKeys = {
|
|
6177
|
+
status: (userId) => ["agg", "shared-kyc", userId]
|
|
6178
|
+
};
|
|
6179
|
+
var useSharedKyc = () => {
|
|
6180
|
+
var _a, _b;
|
|
6181
|
+
const client = useAggClient();
|
|
6182
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
6183
|
+
const userId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
|
|
6184
|
+
const query = (0, import_react_query22.useQuery)({
|
|
6185
|
+
queryKey: sharedKycQueryKeys.status(userId),
|
|
6186
|
+
queryFn: () => client.getSharedKycStatus(),
|
|
6187
|
+
enabled: isAuthenticated && userId !== null,
|
|
6188
|
+
staleTime: 15e3,
|
|
6189
|
+
retry: false
|
|
6190
|
+
});
|
|
6191
|
+
const { refetch } = query;
|
|
6192
|
+
const refreshStatus = (0, import_react19.useCallback)(() => __async(null, null, function* () {
|
|
6193
|
+
var _a2;
|
|
6194
|
+
if (!isAuthenticated || !userId) return "unverified";
|
|
6195
|
+
const result = yield refetch({ cancelRefetch: false });
|
|
6196
|
+
if (result.error) throw result.error;
|
|
6197
|
+
return ((_a2 = result.data) == null ? void 0 : _a2.verified) === true ? "verified" : "unverified";
|
|
6198
|
+
}), [isAuthenticated, userId, refetch]);
|
|
6199
|
+
const initiateVerification = (0, import_react19.useCallback)(
|
|
6200
|
+
({ venue, redirectUri }) => client.initiateKyc(venue, redirectUri),
|
|
6201
|
+
[client]
|
|
6202
|
+
);
|
|
6203
|
+
const status = !isAuthenticated ? "unverified" : !userId || query.isPending ? "loading" : ((_b = query.data) == null ? void 0 : _b.verified) === true ? "verified" : "unverified";
|
|
6204
|
+
return { status, refreshStatus, initiateVerification };
|
|
6205
|
+
};
|
|
6206
|
+
|
|
6003
6207
|
// src/use-agg-auth.ts
|
|
6004
|
-
var
|
|
6208
|
+
var import_react20 = require("react");
|
|
6005
6209
|
function useAggAuth(options = {}) {
|
|
6006
6210
|
const {
|
|
6007
6211
|
isAuthenticated,
|
|
@@ -6011,7 +6215,7 @@ function useAggAuth(options = {}) {
|
|
|
6011
6215
|
signIn: signInWithProvider,
|
|
6012
6216
|
signOut
|
|
6013
6217
|
} = useAggAuthContext();
|
|
6014
|
-
const signIn = (0,
|
|
6218
|
+
const signIn = (0, import_react20.useCallback)(
|
|
6015
6219
|
(statement) => __async(null, null, function* () {
|
|
6016
6220
|
if (!options.signMessage) {
|
|
6017
6221
|
throw new Error(
|
|
@@ -6035,11 +6239,11 @@ function useAggAuth(options = {}) {
|
|
|
6035
6239
|
}
|
|
6036
6240
|
|
|
6037
6241
|
// src/use-link-account.ts
|
|
6038
|
-
var
|
|
6242
|
+
var import_react21 = require("react");
|
|
6039
6243
|
function useLinkAccount() {
|
|
6040
6244
|
const client = useAggClient();
|
|
6041
|
-
const [isLoading, setIsLoading] = (0,
|
|
6042
|
-
const [error, setError] = (0,
|
|
6245
|
+
const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
|
|
6246
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
6043
6247
|
const run = (fn) => {
|
|
6044
6248
|
setIsLoading(true);
|
|
6045
6249
|
setError(null);
|
|
@@ -6049,11 +6253,11 @@ function useLinkAccount() {
|
|
|
6049
6253
|
throw err;
|
|
6050
6254
|
}).finally(() => setIsLoading(false));
|
|
6051
6255
|
};
|
|
6052
|
-
const startLink = (0,
|
|
6256
|
+
const startLink = (0, import_react21.useCallback)(
|
|
6053
6257
|
(body) => run(() => client.linkAccount(body)),
|
|
6054
6258
|
[client]
|
|
6055
6259
|
);
|
|
6056
|
-
const confirmLink = (0,
|
|
6260
|
+
const confirmLink = (0, import_react21.useCallback)(
|
|
6057
6261
|
(input) => run(() => client.linkAccountConfirm(input)),
|
|
6058
6262
|
[client]
|
|
6059
6263
|
);
|
|
@@ -6068,7 +6272,7 @@ var requestAggAuthChooserOpen = () => {
|
|
|
6068
6272
|
};
|
|
6069
6273
|
|
|
6070
6274
|
// src/use-categories.ts
|
|
6071
|
-
var
|
|
6275
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
6072
6276
|
function useCategories(options) {
|
|
6073
6277
|
var _a, _b, _c, _d, _e, _f;
|
|
6074
6278
|
const client = useAggClient();
|
|
@@ -6076,7 +6280,7 @@ function useCategories(options) {
|
|
|
6076
6280
|
const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
|
|
6077
6281
|
const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
|
|
6078
6282
|
const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
|
|
6079
|
-
const query = (0,
|
|
6283
|
+
const query = (0, import_react_query23.useInfiniteQuery)({
|
|
6080
6284
|
queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
|
|
6081
6285
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
6082
6286
|
const res = yield client.getCategories(__spreadValues({
|
|
@@ -6108,7 +6312,7 @@ function useCategoryChildren(options) {
|
|
|
6108
6312
|
const parentIds = Array.from(
|
|
6109
6313
|
new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
|
|
6110
6314
|
);
|
|
6111
|
-
const queries = (0,
|
|
6315
|
+
const queries = (0, import_react_query23.useQueries)({
|
|
6112
6316
|
queries: parentIds.map((parentId) => ({
|
|
6113
6317
|
queryKey: [queryKeyScope, "parent", parentId, limit],
|
|
6114
6318
|
queryFn: () => __async(null, null, function* () {
|
|
@@ -6136,10 +6340,10 @@ function useCategoryChildren(options) {
|
|
|
6136
6340
|
}
|
|
6137
6341
|
|
|
6138
6342
|
// src/use-debounced-value.ts
|
|
6139
|
-
var
|
|
6343
|
+
var import_react22 = require("react");
|
|
6140
6344
|
function useDebouncedValue(value, delay) {
|
|
6141
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
6142
|
-
(0,
|
|
6345
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react22.useState)(value);
|
|
6346
|
+
(0, import_react22.useEffect)(() => {
|
|
6143
6347
|
const timeoutId = window.setTimeout(() => {
|
|
6144
6348
|
setDebouncedValue(value);
|
|
6145
6349
|
}, delay);
|
|
@@ -6151,7 +6355,7 @@ function useDebouncedValue(value, delay) {
|
|
|
6151
6355
|
}
|
|
6152
6356
|
|
|
6153
6357
|
// src/use-execution-orders.ts
|
|
6154
|
-
var
|
|
6358
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
6155
6359
|
function useExecutionOrders(options = {}) {
|
|
6156
6360
|
var _a, _b;
|
|
6157
6361
|
const client = useAggClient();
|
|
@@ -6165,7 +6369,7 @@ function useExecutionOrders(options = {}) {
|
|
|
6165
6369
|
enabled = true,
|
|
6166
6370
|
refetchIntervalMs = false
|
|
6167
6371
|
} = options;
|
|
6168
|
-
const query = (0,
|
|
6372
|
+
const query = (0, import_react_query24.useInfiniteQuery)({
|
|
6169
6373
|
// quoteId + orderId are part of the cache key — different filters
|
|
6170
6374
|
// produce different result sets, so they have to vary the key.
|
|
6171
6375
|
queryKey: [
|
|
@@ -6203,7 +6407,7 @@ function useExecutionOrders(options = {}) {
|
|
|
6203
6407
|
}
|
|
6204
6408
|
|
|
6205
6409
|
// src/use-user-activity.ts
|
|
6206
|
-
var
|
|
6410
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
6207
6411
|
var DEFAULT_PENDING_REFETCH_INTERVAL_MS = 15e3;
|
|
6208
6412
|
var PENDING_ACTIVITY_STATUSES = /* @__PURE__ */ new Set([
|
|
6209
6413
|
"pending",
|
|
@@ -6237,7 +6441,7 @@ function useUserActivity(options = {}) {
|
|
|
6237
6441
|
enabled = true,
|
|
6238
6442
|
pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
|
|
6239
6443
|
} = options;
|
|
6240
|
-
const query = (0,
|
|
6444
|
+
const query = (0, import_react_query25.useInfiniteQuery)({
|
|
6241
6445
|
queryKey: userActivityQueryKeys.feed(type, limit),
|
|
6242
6446
|
queryFn: ({ pageParam }) => client.getUserActivity({
|
|
6243
6447
|
type,
|
|
@@ -6254,7 +6458,7 @@ function useUserActivity(options = {}) {
|
|
|
6254
6458
|
// flight (typically after a deposit / withdraw cache invalidation).
|
|
6255
6459
|
// Without this the feed flashes to the skeleton mid-session, which
|
|
6256
6460
|
// is worse UX than briefly showing slightly-stale rows.
|
|
6257
|
-
placeholderData:
|
|
6461
|
+
placeholderData: import_react_query25.keepPreviousData,
|
|
6258
6462
|
refetchInterval: (q) => {
|
|
6259
6463
|
if (pendingRefetchIntervalMs === false) return false;
|
|
6260
6464
|
const data = q.state.data;
|
|
@@ -6270,13 +6474,13 @@ function useUserActivity(options = {}) {
|
|
|
6270
6474
|
}
|
|
6271
6475
|
|
|
6272
6476
|
// src/use-external-id.ts
|
|
6273
|
-
var
|
|
6477
|
+
var import_react23 = require("react");
|
|
6274
6478
|
function useExternalId(options = {}) {
|
|
6275
6479
|
const client = useAggClient();
|
|
6276
6480
|
const { onSuccess, onError: onErrorCb } = options;
|
|
6277
|
-
const [isLoading, setIsLoading] = (0,
|
|
6278
|
-
const [error, setError] = (0,
|
|
6279
|
-
const linkExternalId = (0,
|
|
6481
|
+
const [isLoading, setIsLoading] = (0, import_react23.useState)(false);
|
|
6482
|
+
const [error, setError] = (0, import_react23.useState)(null);
|
|
6483
|
+
const linkExternalId = (0, import_react23.useCallback)(
|
|
6280
6484
|
(assertion) => __async(null, null, function* () {
|
|
6281
6485
|
setIsLoading(true);
|
|
6282
6486
|
setError(null);
|
|
@@ -6299,12 +6503,12 @@ function useExternalId(options = {}) {
|
|
|
6299
6503
|
}
|
|
6300
6504
|
|
|
6301
6505
|
// src/use-execution-positions.ts
|
|
6302
|
-
var
|
|
6506
|
+
var import_react_query26 = require("@tanstack/react-query");
|
|
6303
6507
|
function useExecutionPositions(options = {}) {
|
|
6304
6508
|
var _a, _b;
|
|
6305
6509
|
const client = useAggClient();
|
|
6306
6510
|
const { limit = 50, status, mode, enabled = true } = options;
|
|
6307
|
-
const query = (0,
|
|
6511
|
+
const query = (0, import_react_query26.useInfiniteQuery)({
|
|
6308
6512
|
queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
|
|
6309
6513
|
queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
|
|
6310
6514
|
limit,
|
|
@@ -6328,17 +6532,17 @@ function useExecutionPositions(options = {}) {
|
|
|
6328
6532
|
}
|
|
6329
6533
|
|
|
6330
6534
|
// src/use-live-candle-overlay.ts
|
|
6331
|
-
var
|
|
6535
|
+
var import_react27 = require("react");
|
|
6332
6536
|
|
|
6333
6537
|
// src/use-live-candles.ts
|
|
6334
|
-
var
|
|
6538
|
+
var import_react26 = require("react");
|
|
6335
6539
|
var import_sdk3 = require("@agg-build/sdk");
|
|
6336
6540
|
|
|
6337
6541
|
// src/use-market-chart.ts
|
|
6338
|
-
var
|
|
6542
|
+
var import_react_query27 = require("@tanstack/react-query");
|
|
6339
6543
|
|
|
6340
6544
|
// src/market-data/subscription.ts
|
|
6341
|
-
var
|
|
6545
|
+
var import_react24 = require("react");
|
|
6342
6546
|
function useMarketDataSubscription({
|
|
6343
6547
|
marketId,
|
|
6344
6548
|
additionalMarketIds,
|
|
@@ -6347,7 +6551,7 @@ function useMarketDataSubscription({
|
|
|
6347
6551
|
trades = false
|
|
6348
6552
|
}) {
|
|
6349
6553
|
const ws = useAggWebSocket();
|
|
6350
|
-
const allIds = (0,
|
|
6554
|
+
const allIds = (0, import_react24.useMemo)(() => {
|
|
6351
6555
|
const ids = /* @__PURE__ */ new Set();
|
|
6352
6556
|
if (marketId) ids.add(marketId);
|
|
6353
6557
|
if (additionalMarketIds) {
|
|
@@ -6358,7 +6562,7 @@ function useMarketDataSubscription({
|
|
|
6358
6562
|
return [...ids];
|
|
6359
6563
|
}, [marketId, additionalMarketIds]);
|
|
6360
6564
|
const stableKey = allIds.join("|");
|
|
6361
|
-
(0,
|
|
6565
|
+
(0, import_react24.useEffect)(() => {
|
|
6362
6566
|
if (!ws || !allIds.length || !enabled || !orderbook && !trades) return;
|
|
6363
6567
|
const unsubscribers = [];
|
|
6364
6568
|
for (const id of allIds) {
|
|
@@ -6420,7 +6624,7 @@ function useMarketChart(options) {
|
|
|
6420
6624
|
orderbook: true,
|
|
6421
6625
|
trades: true
|
|
6422
6626
|
});
|
|
6423
|
-
const queries = (0,
|
|
6627
|
+
const queries = (0, import_react_query27.useQueries)({
|
|
6424
6628
|
queries: outcomeIds.map((outcomeId) => ({
|
|
6425
6629
|
// Cache key is intentionally time-free. The rolling window's
|
|
6426
6630
|
// startTs/endTs advance on every bucket but the user expects the same
|
|
@@ -6455,7 +6659,7 @@ function useMarketChart(options) {
|
|
|
6455
6659
|
gcTime: 60 * 6e4,
|
|
6456
6660
|
refetchOnWindowFocus: false,
|
|
6457
6661
|
retry: 1,
|
|
6458
|
-
placeholderData:
|
|
6662
|
+
placeholderData: import_react_query27.keepPreviousData,
|
|
6459
6663
|
refetchInterval: refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false,
|
|
6460
6664
|
refetchIntervalInBackground: false
|
|
6461
6665
|
}))
|
|
@@ -6486,13 +6690,13 @@ function useMarketChart(options) {
|
|
|
6486
6690
|
}
|
|
6487
6691
|
|
|
6488
6692
|
// src/use-live-market-stores.ts
|
|
6489
|
-
var
|
|
6693
|
+
var import_react25 = require("react");
|
|
6490
6694
|
function useLiveMarketStores(venueMarketIds) {
|
|
6491
6695
|
const ws = useAggWebSocket();
|
|
6492
|
-
const [, forceRender] = (0,
|
|
6493
|
-
const subsRef = (0,
|
|
6494
|
-
const stableKey = (0,
|
|
6495
|
-
(0,
|
|
6696
|
+
const [, forceRender] = (0, import_react25.useReducer)((c) => c + 1, 0);
|
|
6697
|
+
const subsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
6698
|
+
const stableKey = (0, import_react25.useMemo)(() => venueMarketIds.slice().sort().join("|"), [venueMarketIds]);
|
|
6699
|
+
(0, import_react25.useEffect)(() => {
|
|
6496
6700
|
if (!ws || venueMarketIds.length === 0) return;
|
|
6497
6701
|
const current = subsRef.current;
|
|
6498
6702
|
const desired = new Set(venueMarketIds);
|
|
@@ -6529,7 +6733,7 @@ function candleToLive(c, source) {
|
|
|
6529
6733
|
function useLiveCandles(options) {
|
|
6530
6734
|
var _a;
|
|
6531
6735
|
const { market, interval = "5m", mode = "venue", startTs, endTs } = options;
|
|
6532
|
-
const venueMarketIds = (0,
|
|
6736
|
+
const venueMarketIds = (0, import_react26.useMemo)(() => {
|
|
6533
6737
|
if (!market) return [];
|
|
6534
6738
|
if (mode === "venue") return [market.id];
|
|
6535
6739
|
const ids = [market.id];
|
|
@@ -6549,7 +6753,7 @@ function useLiveCandles(options) {
|
|
|
6549
6753
|
endTs: endTs != null ? endTs : null,
|
|
6550
6754
|
enabled: !!restMarketId && startTs != null && endTs != null
|
|
6551
6755
|
});
|
|
6552
|
-
const liveData = (0,
|
|
6756
|
+
const liveData = (0, import_react26.useMemo)(() => {
|
|
6553
6757
|
if (builders2.length === 0) return { closed: [], forming: null };
|
|
6554
6758
|
if (mode === "venue" || builders2.length === 1) {
|
|
6555
6759
|
return {
|
|
@@ -6562,7 +6766,7 @@ function useLiveCandles(options) {
|
|
|
6562
6766
|
forming: (0, import_sdk3.mergeCandles)(builders2.map((b) => b.getForming(interval)))
|
|
6563
6767
|
};
|
|
6564
6768
|
}, [builders2, interval, mode]);
|
|
6565
|
-
const candles = (0,
|
|
6769
|
+
const candles = (0, import_react26.useMemo)(() => {
|
|
6566
6770
|
const byTime = /* @__PURE__ */ new Map();
|
|
6567
6771
|
if (chartData) {
|
|
6568
6772
|
const venueEntries = Object.values(chartData.venues);
|
|
@@ -6587,7 +6791,7 @@ function useLiveCandles(options) {
|
|
|
6587
6791
|
merged.sort((a, b) => a.time - b.time);
|
|
6588
6792
|
return merged;
|
|
6589
6793
|
}, [chartData, liveData.closed]);
|
|
6590
|
-
const liveCandle = (0,
|
|
6794
|
+
const liveCandle = (0, import_react26.useMemo)(() => {
|
|
6591
6795
|
if (!liveData.forming) return null;
|
|
6592
6796
|
return candleToLive(liveData.forming, "live");
|
|
6593
6797
|
}, [liveData.forming]);
|
|
@@ -6635,7 +6839,7 @@ function useLiveCandleOverlay(options) {
|
|
|
6635
6839
|
startTs,
|
|
6636
6840
|
endTs
|
|
6637
6841
|
});
|
|
6638
|
-
const scaleCandle = (0,
|
|
6842
|
+
const scaleCandle = (0, import_react27.useCallback)(
|
|
6639
6843
|
(candle) => ({
|
|
6640
6844
|
time: candle.time,
|
|
6641
6845
|
open: candle.o * scale,
|
|
@@ -6646,8 +6850,8 @@ function useLiveCandleOverlay(options) {
|
|
|
6646
6850
|
}),
|
|
6647
6851
|
[scale]
|
|
6648
6852
|
);
|
|
6649
|
-
const scaledCandles = (0,
|
|
6650
|
-
const liveCandle = (0,
|
|
6853
|
+
const scaledCandles = (0, import_react27.useMemo)(() => rawCandles.map(scaleCandle), [rawCandles, scaleCandle]);
|
|
6854
|
+
const liveCandle = (0, import_react27.useMemo)(() => rawLive ? scaleCandle(rawLive) : null, [rawLive, scaleCandle]);
|
|
6651
6855
|
return {
|
|
6652
6856
|
liveCandle,
|
|
6653
6857
|
scaledCandles,
|
|
@@ -6658,7 +6862,7 @@ function useLiveCandleOverlay(options) {
|
|
|
6658
6862
|
}
|
|
6659
6863
|
|
|
6660
6864
|
// src/use-event-orderbook-data.ts
|
|
6661
|
-
var
|
|
6865
|
+
var import_react28 = require("react");
|
|
6662
6866
|
function extractSelectedOutcomeIds(selectedMarket) {
|
|
6663
6867
|
var _a, _b, _c;
|
|
6664
6868
|
if (!selectedMarket) return [];
|
|
@@ -6678,17 +6882,17 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
6678
6882
|
const {
|
|
6679
6883
|
features: { enableLiveUpdates }
|
|
6680
6884
|
} = useAggUiConfig();
|
|
6681
|
-
const selectedMarket = (0,
|
|
6885
|
+
const selectedMarket = (0, import_react28.useMemo)(() => {
|
|
6682
6886
|
var _a;
|
|
6683
6887
|
if (!selectedMarketId || !(venueMarkets == null ? void 0 : venueMarkets.length)) return null;
|
|
6684
6888
|
return (_a = venueMarkets.find((m) => m.id === selectedMarketId)) != null ? _a : null;
|
|
6685
6889
|
}, [venueMarkets, selectedMarketId]);
|
|
6686
|
-
const selectedOutcomeIds = (0,
|
|
6890
|
+
const selectedOutcomeIds = (0, import_react28.useMemo)(
|
|
6687
6891
|
() => extractSelectedOutcomeIds(selectedMarket),
|
|
6688
6892
|
[selectedMarket]
|
|
6689
6893
|
);
|
|
6690
6894
|
const selectedKey = selectedOutcomeIds.join("|");
|
|
6691
|
-
(0,
|
|
6895
|
+
(0, import_react28.useEffect)(() => {
|
|
6692
6896
|
if (!ws || !enableLiveUpdates || !selectedOutcomeIds.length) return;
|
|
6693
6897
|
const unsubscribers = selectedOutcomeIds.map((id) => ws.subscribe(id, "orderbook"));
|
|
6694
6898
|
return () => {
|
|
@@ -6698,7 +6902,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
6698
6902
|
}
|
|
6699
6903
|
|
|
6700
6904
|
// src/use-live-market.ts
|
|
6701
|
-
var
|
|
6905
|
+
var import_react_query28 = require("@tanstack/react-query");
|
|
6702
6906
|
function outcomeOrderbookToState(response, marketId) {
|
|
6703
6907
|
var _a, _b, _c, _d;
|
|
6704
6908
|
const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
|
|
@@ -6748,7 +6952,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6748
6952
|
enabled: isLiveSubscriptionEnabled,
|
|
6749
6953
|
orderbook: true
|
|
6750
6954
|
});
|
|
6751
|
-
const query = (0,
|
|
6955
|
+
const query = (0, import_react_query28.useQuery)({
|
|
6752
6956
|
queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
|
|
6753
6957
|
queryFn: () => __async(null, null, function* () {
|
|
6754
6958
|
return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
|
|
@@ -6760,7 +6964,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6760
6964
|
isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
|
|
6761
6965
|
})
|
|
6762
6966
|
});
|
|
6763
|
-
const seedQuery = (0,
|
|
6967
|
+
const seedQuery = (0, import_react_query28.useQuery)({
|
|
6764
6968
|
queryKey: ["live-market-seed", canonicalMarketId],
|
|
6765
6969
|
queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
|
|
6766
6970
|
enabled: Boolean(canonicalMarketId),
|
|
@@ -6780,8 +6984,8 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
6780
6984
|
}
|
|
6781
6985
|
|
|
6782
6986
|
// src/use-live-outcome-prices.ts
|
|
6783
|
-
var
|
|
6784
|
-
var
|
|
6987
|
+
var import_react29 = require("react");
|
|
6988
|
+
var import_react_query29 = require("@tanstack/react-query");
|
|
6785
6989
|
var EMPTY_PRICES = /* @__PURE__ */ new Map();
|
|
6786
6990
|
var buildMidpointFingerprint = (outcomeIds, queries) => {
|
|
6787
6991
|
var _a, _b, _c;
|
|
@@ -6796,7 +7000,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6796
7000
|
const {
|
|
6797
7001
|
features: { enableLiveUpdates }
|
|
6798
7002
|
} = useAggUiConfig();
|
|
6799
|
-
const outcomeIds = (0,
|
|
7003
|
+
const outcomeIds = (0, import_react29.useMemo)(() => {
|
|
6800
7004
|
var _a, _b;
|
|
6801
7005
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
6802
7006
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -6810,7 +7014,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6810
7014
|
}
|
|
6811
7015
|
return [...ids].sort();
|
|
6812
7016
|
}, [venueMarkets]);
|
|
6813
|
-
const queries = (0,
|
|
7017
|
+
const queries = (0, import_react_query29.useQueries)({
|
|
6814
7018
|
queries: outcomeIds.map((id) => ({
|
|
6815
7019
|
queryKey: marketDataKeys.live(id),
|
|
6816
7020
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -6821,11 +7025,11 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6821
7025
|
}))
|
|
6822
7026
|
});
|
|
6823
7027
|
const fingerprint = buildMidpointFingerprint(outcomeIds, queries);
|
|
6824
|
-
const prevRef = (0,
|
|
7028
|
+
const prevRef = (0, import_react29.useRef)({
|
|
6825
7029
|
fingerprint: "",
|
|
6826
7030
|
prices: EMPTY_PRICES
|
|
6827
7031
|
});
|
|
6828
|
-
const data = (0,
|
|
7032
|
+
const data = (0, import_react29.useMemo)(() => {
|
|
6829
7033
|
var _a, _b, _c;
|
|
6830
7034
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return EMPTY_PRICES;
|
|
6831
7035
|
if (fingerprint === prevRef.current.fingerprint) {
|
|
@@ -6852,8 +7056,8 @@ function findLivePriceById(livePrices, id) {
|
|
|
6852
7056
|
}
|
|
6853
7057
|
|
|
6854
7058
|
// src/use-live-best-prices.ts
|
|
6855
|
-
var
|
|
6856
|
-
var
|
|
7059
|
+
var import_react30 = require("react");
|
|
7060
|
+
var import_react_query30 = require("@tanstack/react-query");
|
|
6857
7061
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
6858
7062
|
var EMPTY_CANDIDATES = /* @__PURE__ */ new Map();
|
|
6859
7063
|
var extractOutcomeBestPrices = (state) => {
|
|
@@ -6882,7 +7086,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6882
7086
|
const {
|
|
6883
7087
|
features: { enableLiveUpdates }
|
|
6884
7088
|
} = useAggUiConfig();
|
|
6885
|
-
const outcomeIds = (0,
|
|
7089
|
+
const outcomeIds = (0, import_react30.useMemo)(() => {
|
|
6886
7090
|
var _a, _b;
|
|
6887
7091
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
6888
7092
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -6896,7 +7100,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6896
7100
|
}
|
|
6897
7101
|
return [...ids].sort();
|
|
6898
7102
|
}, [venueMarkets]);
|
|
6899
|
-
const queries = (0,
|
|
7103
|
+
const queries = (0, import_react_query30.useQueries)({
|
|
6900
7104
|
queries: outcomeIds.map((id) => ({
|
|
6901
7105
|
queryKey: marketDataKeys.live(id),
|
|
6902
7106
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -6907,11 +7111,11 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
6907
7111
|
}))
|
|
6908
7112
|
});
|
|
6909
7113
|
const fingerprint = buildFingerprint(outcomeIds, queries);
|
|
6910
|
-
const prevRef = (0,
|
|
7114
|
+
const prevRef = (0, import_react30.useRef)({
|
|
6911
7115
|
fingerprint: "",
|
|
6912
7116
|
result: EMPTY
|
|
6913
7117
|
});
|
|
6914
|
-
return (0,
|
|
7118
|
+
return (0, import_react30.useMemo)(() => {
|
|
6915
7119
|
var _a, _b, _c, _d;
|
|
6916
7120
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length) || !enableLiveUpdates) return EMPTY;
|
|
6917
7121
|
if (fingerprint === prevRef.current.fingerprint) return prevRef.current.result;
|
|
@@ -7101,7 +7305,7 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7101
7305
|
const {
|
|
7102
7306
|
features: { enableLiveUpdates }
|
|
7103
7307
|
} = useAggUiConfig();
|
|
7104
|
-
const outcomeIds = (0,
|
|
7308
|
+
const outcomeIds = (0, import_react30.useMemo)(() => {
|
|
7105
7309
|
var _a, _b;
|
|
7106
7310
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return [];
|
|
7107
7311
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -7115,7 +7319,7 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7115
7319
|
}
|
|
7116
7320
|
return [...ids].sort();
|
|
7117
7321
|
}, [venueMarkets]);
|
|
7118
|
-
const queries = (0,
|
|
7322
|
+
const queries = (0, import_react_query30.useQueries)({
|
|
7119
7323
|
queries: outcomeIds.map((id) => ({
|
|
7120
7324
|
queryKey: marketDataKeys.live(id),
|
|
7121
7325
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -7126,11 +7330,11 @@ function useLiveBestPriceCandidates(venueMarkets) {
|
|
|
7126
7330
|
}))
|
|
7127
7331
|
});
|
|
7128
7332
|
const fingerprint = buildCandidateFingerprint(outcomeIds, queries);
|
|
7129
|
-
const prevRef = (0,
|
|
7333
|
+
const prevRef = (0, import_react30.useRef)({
|
|
7130
7334
|
fingerprint: "",
|
|
7131
7335
|
result: EMPTY_CANDIDATES
|
|
7132
7336
|
});
|
|
7133
|
-
return (0,
|
|
7337
|
+
return (0, import_react30.useMemo)(() => {
|
|
7134
7338
|
if (!(venueMarkets == null ? void 0 : venueMarkets.length) || !enableLiveUpdates) return EMPTY_CANDIDATES;
|
|
7135
7339
|
if (fingerprint === prevRef.current.fingerprint) return prevRef.current.result;
|
|
7136
7340
|
const states = outcomeIds.map((_, i) => {
|
|
@@ -7159,8 +7363,8 @@ function useLiveTrades(canonicalMarketId) {
|
|
|
7159
7363
|
}
|
|
7160
7364
|
|
|
7161
7365
|
// src/use-midpoints.ts
|
|
7162
|
-
var
|
|
7163
|
-
var
|
|
7366
|
+
var import_react_query31 = require("@tanstack/react-query");
|
|
7367
|
+
var import_react31 = require("react");
|
|
7164
7368
|
var normalizeVenueMarketIds = (venueMarkets) => {
|
|
7165
7369
|
var _a;
|
|
7166
7370
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -7333,12 +7537,12 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7333
7537
|
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
7334
7538
|
} = useAggUiConfig();
|
|
7335
7539
|
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
7336
|
-
const ids = (0,
|
|
7337
|
-
const bestMidpointCandidateOutcomeIds = (0,
|
|
7540
|
+
const ids = (0, import_react31.useMemo)(() => normalizeVenueMarketIds(venueMarkets), [venueMarkets]);
|
|
7541
|
+
const bestMidpointCandidateOutcomeIds = (0, import_react31.useMemo)(
|
|
7338
7542
|
() => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
|
|
7339
7543
|
[venueMarkets]
|
|
7340
7544
|
);
|
|
7341
|
-
const { data, isLoading } = (0,
|
|
7545
|
+
const { data, isLoading } = (0, import_react_query31.useQuery)({
|
|
7342
7546
|
queryKey: ["midpoints", ids, maxMidpointIdsPerRequest],
|
|
7343
7547
|
queryFn: () => client.getMidpoints(ids, { bestPrice: true, maxMidpointIdsPerRequest }),
|
|
7344
7548
|
enabled: ids.length > 0,
|
|
@@ -7348,7 +7552,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7348
7552
|
refetchOnWindowFocus: false,
|
|
7349
7553
|
refetchOnReconnect: false
|
|
7350
7554
|
});
|
|
7351
|
-
const result = (0,
|
|
7555
|
+
const result = (0, import_react31.useMemo)(() => {
|
|
7352
7556
|
var _a2, _b, _c, _d, _e, _f;
|
|
7353
7557
|
const map = /* @__PURE__ */ new Map();
|
|
7354
7558
|
const currentMap = /* @__PURE__ */ new Map();
|
|
@@ -7401,7 +7605,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7401
7605
|
}
|
|
7402
7606
|
return { map, currentMap, venueMap };
|
|
7403
7607
|
}, [data, venueMarkets]);
|
|
7404
|
-
const { bestMidpoint, bestMidpointVenue } = (0,
|
|
7608
|
+
const { bestMidpoint, bestMidpointVenue } = (0, import_react31.useMemo)(() => {
|
|
7405
7609
|
let value;
|
|
7406
7610
|
let venue;
|
|
7407
7611
|
for (const outcomeId of bestMidpointCandidateOutcomeIds) {
|
|
@@ -7422,7 +7626,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7422
7626
|
}
|
|
7423
7627
|
return { bestMidpoint: value, bestMidpointVenue: venue };
|
|
7424
7628
|
}, [bestMidpointCandidateOutcomeIds, result.map, result.venueMap]);
|
|
7425
|
-
const { bestPrices, bestPriceVenuesByOutcomeId } = (0,
|
|
7629
|
+
const { bestPrices, bestPriceVenuesByOutcomeId } = (0, import_react31.useMemo)(
|
|
7426
7630
|
() => extractBestPrices(data == null ? void 0 : data.data, venueMarkets),
|
|
7427
7631
|
[data == null ? void 0 : data.data, venueMarkets]
|
|
7428
7632
|
);
|
|
@@ -7440,7 +7644,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
7440
7644
|
}
|
|
7441
7645
|
|
|
7442
7646
|
// src/use-rolling-chart-window.ts
|
|
7443
|
-
var
|
|
7647
|
+
var import_react32 = require("react");
|
|
7444
7648
|
var RANGE_SECONDS_BY_RANGE = {
|
|
7445
7649
|
"1H": 60 * 60,
|
|
7446
7650
|
"6H": 6 * 60 * 60,
|
|
@@ -7471,26 +7675,27 @@ var useRollingChartWindow = (options) => {
|
|
|
7471
7675
|
var _a;
|
|
7472
7676
|
const tickMs = (_a = options.tickMs) != null ? _a : 1e3;
|
|
7473
7677
|
const optionsNowMs = options.nowMs;
|
|
7474
|
-
const nowMs = (0,
|
|
7475
|
-
const [nowSec, setNowSec] = (0,
|
|
7476
|
-
(0,
|
|
7678
|
+
const nowMs = (0, import_react32.useMemo)(() => optionsNowMs != null ? optionsNowMs : (() => Date.now()), [optionsNowMs]);
|
|
7679
|
+
const [nowSec, setNowSec] = (0, import_react32.useState)(() => Math.floor(nowMs() / 1e3));
|
|
7680
|
+
(0, import_react32.useEffect)(() => {
|
|
7477
7681
|
setNowSec(Math.floor(nowMs() / 1e3));
|
|
7478
7682
|
const handle = setInterval(() => {
|
|
7479
7683
|
setNowSec(Math.floor(nowMs() / 1e3));
|
|
7480
7684
|
}, tickMs);
|
|
7481
7685
|
return () => clearInterval(handle);
|
|
7482
7686
|
}, [tickMs, nowMs]);
|
|
7483
|
-
return (0,
|
|
7687
|
+
return (0, import_react32.useMemo)(
|
|
7484
7688
|
() => resolveRollingWindow({ range: options.range, nowSec, interval: options.interval }),
|
|
7485
7689
|
[options.range, options.interval, nowSec]
|
|
7486
7690
|
);
|
|
7487
7691
|
};
|
|
7488
7692
|
|
|
7489
7693
|
// src/use-market-orderbook.ts
|
|
7490
|
-
var
|
|
7694
|
+
var import_react_query32 = require("@tanstack/react-query");
|
|
7491
7695
|
function useMarketOrderbook(options) {
|
|
7492
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
7493
|
-
const queryClient = (0,
|
|
7696
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7697
|
+
const queryClient = (0, import_react_query32.useQueryClient)();
|
|
7698
|
+
const client = useAggClient();
|
|
7494
7699
|
const ws = useAggWebSocket();
|
|
7495
7700
|
const isConnected = useAggWebSocketConnectionState();
|
|
7496
7701
|
const {
|
|
@@ -7508,7 +7713,7 @@ function useMarketOrderbook(options) {
|
|
|
7508
7713
|
enabled: enabled && !!selectedOutcomeId,
|
|
7509
7714
|
orderbook: true
|
|
7510
7715
|
});
|
|
7511
|
-
const liveQueries = (0,
|
|
7716
|
+
const liveQueries = (0, import_react_query32.useQueries)({
|
|
7512
7717
|
queries: subscriptionIds.map((subscriptionId) => ({
|
|
7513
7718
|
queryKey: marketDataKeys.live(subscriptionId),
|
|
7514
7719
|
queryFn: () => createMarketLiveState(subscriptionId),
|
|
@@ -7519,12 +7724,30 @@ function useMarketOrderbook(options) {
|
|
|
7519
7724
|
refetchOnReconnect: false
|
|
7520
7725
|
}))
|
|
7521
7726
|
});
|
|
7727
|
+
const seedQueries = (0, import_react_query32.useQueries)({
|
|
7728
|
+
queries: subscriptionIds.map((subscriptionId) => ({
|
|
7729
|
+
queryKey: ["market-orderbook-seed", subscriptionId],
|
|
7730
|
+
queryFn: ({ signal }) => client.getOutcomeOrderbook(subscriptionId, { signal }),
|
|
7731
|
+
enabled: enabled && !!subscriptionId,
|
|
7732
|
+
staleTime: 5e3,
|
|
7733
|
+
gcTime: 6e4,
|
|
7734
|
+
refetchOnWindowFocus: false,
|
|
7735
|
+
retry: 1
|
|
7736
|
+
}))
|
|
7737
|
+
});
|
|
7522
7738
|
const liveStates = subscriptionIds.map((subscriptionId, index) => {
|
|
7523
7739
|
var _a2, _b2;
|
|
7524
7740
|
return (_b2 = (_a2 = liveQueries[index]) == null ? void 0 : _a2.data) != null ? _b2 : createMarketLiveState(subscriptionId);
|
|
7525
7741
|
});
|
|
7526
|
-
const
|
|
7527
|
-
|
|
7742
|
+
const seededOrderbooks = subscriptionIds.map((subscriptionId, index) => {
|
|
7743
|
+
var _a2, _b2, _c2, _d2;
|
|
7744
|
+
const liveBook = (_b2 = (_a2 = liveStates[index]) == null ? void 0 : _a2.orderbook) != null ? _b2 : null;
|
|
7745
|
+
if (liveBook) return liveBook;
|
|
7746
|
+
const seed = (_c2 = seedQueries[index]) == null ? void 0 : _c2.data;
|
|
7747
|
+
return ((_d2 = seed == null ? void 0 : seed.orderbook) == null ? void 0 : _d2.bids) && seed.orderbook.asks ? outcomeOrderbookToState(seed, subscriptionId) : null;
|
|
7748
|
+
});
|
|
7749
|
+
const primaryOrderbook = (_c = seededOrderbooks[0]) != null ? _c : null;
|
|
7750
|
+
const primarySnapshotVersion = (_e = (_d = liveStates[0]) == null ? void 0 : _d.orderbookSnapshotVersion) != null ? _e : 0;
|
|
7528
7751
|
const data = primaryOrderbook ? applyOrderbookDepth(
|
|
7529
7752
|
createMarketOrderbookDataFromState(primaryOrderbook, {
|
|
7530
7753
|
snapshotVersion: primarySnapshotVersion
|
|
@@ -7532,14 +7755,15 @@ function useMarketOrderbook(options) {
|
|
|
7532
7755
|
depth
|
|
7533
7756
|
) : null;
|
|
7534
7757
|
const dataById = Object.fromEntries(
|
|
7535
|
-
|
|
7536
|
-
|
|
7758
|
+
seededOrderbooks.flatMap((orderbook, index) => {
|
|
7759
|
+
var _a2;
|
|
7760
|
+
if (!orderbook) return [];
|
|
7537
7761
|
return [
|
|
7538
7762
|
[
|
|
7539
7763
|
subscriptionIds[index],
|
|
7540
7764
|
applyOrderbookDepth(
|
|
7541
|
-
createMarketOrderbookDataFromState(
|
|
7542
|
-
snapshotVersion:
|
|
7765
|
+
createMarketOrderbookDataFromState(orderbook, {
|
|
7766
|
+
snapshotVersion: (_a2 = liveStates[index]) == null ? void 0 : _a2.orderbookSnapshotVersion
|
|
7543
7767
|
}),
|
|
7544
7768
|
depth
|
|
7545
7769
|
)
|
|
@@ -7547,14 +7771,15 @@ function useMarketOrderbook(options) {
|
|
|
7547
7771
|
];
|
|
7548
7772
|
})
|
|
7549
7773
|
);
|
|
7550
|
-
const hasAnyOrderbook =
|
|
7551
|
-
const
|
|
7774
|
+
const hasAnyOrderbook = seededOrderbooks.some((orderbook) => orderbook != null);
|
|
7775
|
+
const seedLoading = seedQueries.some((query) => query.isLoading);
|
|
7776
|
+
const liveOrderbookErrorMessage = enabled && liveEnabled && !hasAnyOrderbook ? (_g = (_f = liveStates.find(
|
|
7552
7777
|
(liveState) => typeof liveState.orderbookError === "string" && liveState.orderbookError.length > 0
|
|
7553
|
-
)) == null ? void 0 :
|
|
7778
|
+
)) == null ? void 0 : _f.orderbookError) != null ? _g : null : null;
|
|
7554
7779
|
return {
|
|
7555
7780
|
data,
|
|
7556
7781
|
dataById,
|
|
7557
|
-
isLoading: enabled &&
|
|
7782
|
+
isLoading: enabled && !hasAnyOrderbook && liveOrderbookErrorMessage == null && (isConnected || seedLoading),
|
|
7558
7783
|
error: liveOrderbookErrorMessage ? new Error(liveOrderbookErrorMessage) : null,
|
|
7559
7784
|
isLive: Boolean(liveEnabled && selectedOutcomeId && isConnected),
|
|
7560
7785
|
refetch: () => __async(null, null, function* () {
|
|
@@ -7574,11 +7799,11 @@ function useMarketOrderbook(options) {
|
|
|
7574
7799
|
}
|
|
7575
7800
|
|
|
7576
7801
|
// src/use-arb.ts
|
|
7577
|
-
var
|
|
7802
|
+
var import_react33 = require("react");
|
|
7578
7803
|
function useMarketArb(marketId) {
|
|
7579
7804
|
const ws = useAggWebSocket();
|
|
7580
|
-
const [state, setState] = (0,
|
|
7581
|
-
(0,
|
|
7805
|
+
const [state, setState] = (0, import_react33.useState)({ arbReturn: null, isLive: false });
|
|
7806
|
+
(0, import_react33.useEffect)(() => {
|
|
7582
7807
|
if (!ws || !marketId) return;
|
|
7583
7808
|
const cached = ws.getArb(marketId);
|
|
7584
7809
|
if (cached != null) {
|
|
@@ -7597,10 +7822,10 @@ var EMPTY_ARB_FEED = {
|
|
|
7597
7822
|
};
|
|
7598
7823
|
function useArbFeed() {
|
|
7599
7824
|
const ws = useAggWebSocket();
|
|
7600
|
-
const [state, setState] = (0,
|
|
7601
|
-
const stateRef = (0,
|
|
7825
|
+
const [state, setState] = (0, import_react33.useState)(EMPTY_ARB_FEED);
|
|
7826
|
+
const stateRef = (0, import_react33.useRef)(state);
|
|
7602
7827
|
stateRef.current = state;
|
|
7603
|
-
(0,
|
|
7828
|
+
(0, import_react33.useEffect)(() => {
|
|
7604
7829
|
if (!ws) return;
|
|
7605
7830
|
const off = ws.subscribeArbFeed((batch) => {
|
|
7606
7831
|
setState((prev) => {
|
|
@@ -7632,7 +7857,7 @@ function useArbFeed() {
|
|
|
7632
7857
|
}
|
|
7633
7858
|
|
|
7634
7859
|
// src/use-order-book.ts
|
|
7635
|
-
var
|
|
7860
|
+
var import_react_query33 = require("@tanstack/react-query");
|
|
7636
7861
|
function useOrderBook(options) {
|
|
7637
7862
|
const client = useAggClient();
|
|
7638
7863
|
const { orderbooks, enabled = true, canonicalMarketId } = options;
|
|
@@ -7645,7 +7870,7 @@ function useOrderBook(options) {
|
|
|
7645
7870
|
venueMarketOutcomeId: outcome.id
|
|
7646
7871
|
})) : void 0
|
|
7647
7872
|
});
|
|
7648
|
-
const batchedResult = (0,
|
|
7873
|
+
const batchedResult = (0, import_react_query33.useQuery)({
|
|
7649
7874
|
queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
|
|
7650
7875
|
queryFn: ({ signal }) => client.getOrderbooks(
|
|
7651
7876
|
{
|
|
@@ -7658,7 +7883,7 @@ function useOrderBook(options) {
|
|
|
7658
7883
|
gcTime: 5 * 6e4,
|
|
7659
7884
|
refetchOnWindowFocus: false,
|
|
7660
7885
|
retry: 1,
|
|
7661
|
-
placeholderData:
|
|
7886
|
+
placeholderData: import_react_query33.keepPreviousData
|
|
7662
7887
|
});
|
|
7663
7888
|
const data = (() => {
|
|
7664
7889
|
var _a, _b;
|
|
@@ -7713,7 +7938,7 @@ function useOrderBook(options) {
|
|
|
7713
7938
|
}
|
|
7714
7939
|
|
|
7715
7940
|
// src/use-orderbook-quote.ts
|
|
7716
|
-
var
|
|
7941
|
+
var import_react_query34 = require("@tanstack/react-query");
|
|
7717
7942
|
var QUOTE_DEBOUNCE_MS = 300;
|
|
7718
7943
|
var createUnavailableOrderbookError = (message, code, retryable) => {
|
|
7719
7944
|
const error = new Error(message);
|
|
@@ -7775,7 +8000,7 @@ function useOrderbookQuote(options) {
|
|
|
7775
8000
|
const { marketId, side, size, enabled = true } = options;
|
|
7776
8001
|
const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
|
|
7777
8002
|
const shouldFetch = enabled && !!marketId && debouncedSize > 0;
|
|
7778
|
-
const query = (0,
|
|
8003
|
+
const query = (0, import_react_query34.useQuery)({
|
|
7779
8004
|
queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
|
|
7780
8005
|
queryFn: () => __async(null, null, function* () {
|
|
7781
8006
|
var _a2, _b, _c, _d;
|
|
@@ -7806,7 +8031,7 @@ function useOrderbookQuote(options) {
|
|
|
7806
8031
|
staleTime: 1e4,
|
|
7807
8032
|
gcTime: 5 * 6e4,
|
|
7808
8033
|
retry: 1,
|
|
7809
|
-
placeholderData:
|
|
8034
|
+
placeholderData: import_react_query34.keepPreviousData
|
|
7810
8035
|
});
|
|
7811
8036
|
return {
|
|
7812
8037
|
data: (_a = query.data) != null ? _a : null,
|
|
@@ -7817,12 +8042,12 @@ function useOrderbookQuote(options) {
|
|
|
7817
8042
|
}
|
|
7818
8043
|
|
|
7819
8044
|
// src/use-orders.ts
|
|
7820
|
-
var
|
|
8045
|
+
var import_react_query35 = require("@tanstack/react-query");
|
|
7821
8046
|
function useOrders(options = {}) {
|
|
7822
8047
|
var _a, _b, _c, _d;
|
|
7823
8048
|
const client = useAggClient();
|
|
7824
8049
|
const { userId, status, limit = 50, offset = 0, enabled = true } = options;
|
|
7825
|
-
const query = (0,
|
|
8050
|
+
const query = (0, import_react_query35.useQuery)({
|
|
7826
8051
|
queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
|
|
7827
8052
|
queryFn: () => client.getOrders({
|
|
7828
8053
|
userId,
|
|
@@ -7839,16 +8064,16 @@ function useOrders(options = {}) {
|
|
|
7839
8064
|
}
|
|
7840
8065
|
|
|
7841
8066
|
// src/use-search.ts
|
|
7842
|
-
var
|
|
7843
|
-
var
|
|
8067
|
+
var import_react_query36 = require("@tanstack/react-query");
|
|
8068
|
+
var import_react34 = require("react");
|
|
7844
8069
|
function useSearch(options) {
|
|
7845
8070
|
var _a, _b, _c, _d;
|
|
7846
|
-
const client = (0,
|
|
7847
|
-
const queryClient = (0,
|
|
7848
|
-
const [fallbackQueryClient] = (0,
|
|
8071
|
+
const client = (0, import_react34.useContext)(AggClientContext);
|
|
8072
|
+
const queryClient = (0, import_react34.useContext)(import_react_query36.QueryClientContext);
|
|
8073
|
+
const [fallbackQueryClient] = (0, import_react34.useState)(() => new import_react_query36.QueryClient());
|
|
7849
8074
|
const { q, type, categoryIds, status, limit = 20, enabled = true, deep = false } = options;
|
|
7850
8075
|
const isEnabled = enabled && q.length > 0;
|
|
7851
|
-
(0,
|
|
8076
|
+
(0, import_react34.useEffect)(() => {
|
|
7852
8077
|
if (queryClient) return void 0;
|
|
7853
8078
|
fallbackQueryClient.mount();
|
|
7854
8079
|
return () => {
|
|
@@ -7858,7 +8083,7 @@ function useSearch(options) {
|
|
|
7858
8083
|
if (isEnabled && !client) {
|
|
7859
8084
|
throw new Error("useSearch must be used within an <AggProvider>");
|
|
7860
8085
|
}
|
|
7861
|
-
const query = (0,
|
|
8086
|
+
const query = (0, import_react_query36.useInfiniteQuery)(
|
|
7862
8087
|
{
|
|
7863
8088
|
// deep is part of the key — TanStack treats deep vs light as
|
|
7864
8089
|
// independent queries so users can have both modes cached side-by-side.
|
|
@@ -7892,7 +8117,7 @@ function useSearch(options) {
|
|
|
7892
8117
|
if (!lastPage.hasMore) return void 0;
|
|
7893
8118
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
7894
8119
|
},
|
|
7895
|
-
placeholderData:
|
|
8120
|
+
placeholderData: import_react_query36.keepPreviousData,
|
|
7896
8121
|
enabled: isEnabled && !!client
|
|
7897
8122
|
},
|
|
7898
8123
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
@@ -7911,7 +8136,7 @@ function useSearch(options) {
|
|
|
7911
8136
|
}
|
|
7912
8137
|
|
|
7913
8138
|
// src/use-market-search.ts
|
|
7914
|
-
var
|
|
8139
|
+
var import_react35 = require("react");
|
|
7915
8140
|
function useMarketSearch(options) {
|
|
7916
8141
|
var _a;
|
|
7917
8142
|
const {
|
|
@@ -7923,8 +8148,8 @@ function useMarketSearch(options) {
|
|
|
7923
8148
|
enableSuggestions = true,
|
|
7924
8149
|
minLength = 1
|
|
7925
8150
|
} = options;
|
|
7926
|
-
const [query, setQueryState] = (0,
|
|
7927
|
-
const [submittedQuery, setSubmittedQuery] = (0,
|
|
8151
|
+
const [query, setQueryState] = (0, import_react35.useState)("");
|
|
8152
|
+
const [submittedQuery, setSubmittedQuery] = (0, import_react35.useState)(null);
|
|
7928
8153
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
7929
8154
|
const trimmedDebounced = debouncedQuery.trim();
|
|
7930
8155
|
const suggestionsEnabled = enableSuggestions && trimmedDebounced.length >= minLength;
|
|
@@ -7947,10 +8172,10 @@ function useMarketSearch(options) {
|
|
|
7947
8172
|
enabled: submittedQ.length > 0,
|
|
7948
8173
|
deep: true
|
|
7949
8174
|
});
|
|
7950
|
-
const setQuery = (0,
|
|
8175
|
+
const setQuery = (0, import_react35.useCallback)((value) => {
|
|
7951
8176
|
setQueryState(value);
|
|
7952
8177
|
}, []);
|
|
7953
|
-
const submit = (0,
|
|
8178
|
+
const submit = (0, import_react35.useCallback)(
|
|
7954
8179
|
(q) => {
|
|
7955
8180
|
const target = (q != null ? q : query).trim();
|
|
7956
8181
|
if (target.length === 0) return;
|
|
@@ -7958,7 +8183,7 @@ function useMarketSearch(options) {
|
|
|
7958
8183
|
},
|
|
7959
8184
|
[query]
|
|
7960
8185
|
);
|
|
7961
|
-
const clear = (0,
|
|
8186
|
+
const clear = (0, import_react35.useCallback)(() => {
|
|
7962
8187
|
setQueryState("");
|
|
7963
8188
|
setSubmittedQuery(null);
|
|
7964
8189
|
}, []);
|
|
@@ -8000,7 +8225,7 @@ function useMarketSearch(options) {
|
|
|
8000
8225
|
}
|
|
8001
8226
|
|
|
8002
8227
|
// src/use-smart-route.ts
|
|
8003
|
-
var
|
|
8228
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
8004
8229
|
|
|
8005
8230
|
// src/smart-route-refresh-policy.ts
|
|
8006
8231
|
var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
|
|
@@ -8087,8 +8312,10 @@ var assessThinSmartRouteLiquidity = (quote, nowMs = Date.now()) => {
|
|
|
8087
8312
|
};
|
|
8088
8313
|
};
|
|
8089
8314
|
var resolveSmartRouteRefetchInterval = (args, nowMs = Date.now()) => {
|
|
8315
|
+
var _a, _b;
|
|
8090
8316
|
const {
|
|
8091
8317
|
aggressiveIntervalMs = THIN_SMART_ROUTE_REFETCH_INTERVAL_MS,
|
|
8318
|
+
adaptive = true,
|
|
8092
8319
|
data,
|
|
8093
8320
|
defaultIntervalMs,
|
|
8094
8321
|
isDocumentVisible,
|
|
@@ -8104,6 +8331,18 @@ var resolveSmartRouteRefetchInterval = (args, nowMs = Date.now()) => {
|
|
|
8104
8331
|
if (!queryEnabled || !isInputValid || !isActivelyViewingQuote || !isMarketOpen || isSubmitting || !isDocumentVisible) {
|
|
8105
8332
|
return false;
|
|
8106
8333
|
}
|
|
8334
|
+
const primaryUsesProphetx = ((_a = data == null ? void 0 : data.fills) == null ? void 0 : _a.some((fill) => fill.venue === "prophetx")) || (data == null ? void 0 : data.status) !== "ok";
|
|
8335
|
+
const deadlines = [
|
|
8336
|
+
data == null ? void 0 : data.quoteRefreshNotBefore,
|
|
8337
|
+
...primaryUsesProphetx ? [(_b = data == null ? void 0 : data.quoteFailure) == null ? void 0 : _b.retryAt] : []
|
|
8338
|
+
].filter((value) => !!value).map(Date.parse).filter((value) => Number.isFinite(value) && value > nowMs);
|
|
8339
|
+
if (deadlines.length) return Math.max(...deadlines) - nowMs;
|
|
8340
|
+
if (!adaptive)
|
|
8341
|
+
return clampIntervalToRefreshDeadline({
|
|
8342
|
+
intervalMs: defaultIntervalMs,
|
|
8343
|
+
refreshAt: void 0,
|
|
8344
|
+
nowMs
|
|
8345
|
+
});
|
|
8107
8346
|
const defaultInterval = clampIntervalToRefreshDeadline({
|
|
8108
8347
|
intervalMs: defaultIntervalMs,
|
|
8109
8348
|
refreshAt: data == null ? void 0 : data.refreshAt,
|
|
@@ -8150,7 +8389,7 @@ function useSmartRoute(options) {
|
|
|
8150
8389
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
8151
8390
|
const hasValidInput = (maxSpend != null ? maxSpend : 0) > 0 || (sellShares != null ? sellShares : 0) > 0;
|
|
8152
8391
|
const queryEnabled = enabled && !!resolvedVenueMarketOutcomeId && hasValidInput;
|
|
8153
|
-
const query = (0,
|
|
8392
|
+
const query = (0, import_react_query37.useQuery)({
|
|
8154
8393
|
queryKey: [
|
|
8155
8394
|
"smart-route",
|
|
8156
8395
|
resolvedVenueMarketOutcomeId,
|
|
@@ -8190,7 +8429,8 @@ function useSmartRoute(options) {
|
|
|
8190
8429
|
return resolveSmartRouteRefetchInterval({
|
|
8191
8430
|
// SELL already fans out into one quote per venue. Keep that group on a
|
|
8192
8431
|
// stable cadence instead of multiplying the adaptive 5s/refreshAt poll.
|
|
8193
|
-
data:
|
|
8432
|
+
data: queryState.state.data,
|
|
8433
|
+
adaptive: tradeSide !== "sell",
|
|
8194
8434
|
defaultIntervalMs: staleTimeMs,
|
|
8195
8435
|
isDocumentVisible: getIsDocumentVisible(),
|
|
8196
8436
|
isEditing: (_a2 = refreshContext == null ? void 0 : refreshContext.isEditing) != null ? _a2 : false,
|
|
@@ -8209,7 +8449,7 @@ function useSmartRoute(options) {
|
|
|
8209
8449
|
// a different amount or position snapshot. Never expose it under a new
|
|
8210
8450
|
// sell key while the replacement request is in flight. BUY retains the
|
|
8211
8451
|
// existing no-flicker behavior.
|
|
8212
|
-
placeholderData: tradeSide === "sell" ? void 0 :
|
|
8452
|
+
placeholderData: tradeSide === "sell" ? void 0 : import_react_query37.keepPreviousData
|
|
8213
8453
|
});
|
|
8214
8454
|
const error = query.error;
|
|
8215
8455
|
let loadingReason = null;
|
|
@@ -8231,7 +8471,7 @@ function useSmartRoute(options) {
|
|
|
8231
8471
|
}
|
|
8232
8472
|
|
|
8233
8473
|
// src/use-limit-order-venue-quotes.ts
|
|
8234
|
-
var
|
|
8474
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
8235
8475
|
var getIsDocumentVisible2 = () => {
|
|
8236
8476
|
if (typeof document === "undefined") return true;
|
|
8237
8477
|
return document.visibilityState !== "hidden";
|
|
@@ -8286,7 +8526,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8286
8526
|
const hasRequiredAccount = tradeSide === "buy" || Boolean(accountId);
|
|
8287
8527
|
const queryEnabled = enabled && hasValidInput && hasRequiredAccount;
|
|
8288
8528
|
const serializedChainBalances = chainBalances ? JSON.stringify(chainBalances) : null;
|
|
8289
|
-
const tickMetadataQuery = (0,
|
|
8529
|
+
const tickMetadataQuery = (0, import_react_query38.useQuery)({
|
|
8290
8530
|
queryKey: ["orderbooks", marketId != null ? marketId : "__disabled__", "limit-order-ticks"],
|
|
8291
8531
|
queryFn: ({ signal }) => client.getOrderbooks({ venueMarketIds: [marketId] }, { signal }),
|
|
8292
8532
|
enabled: enabled && Boolean(marketId),
|
|
@@ -8295,7 +8535,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8295
8535
|
refetchOnWindowFocus: false,
|
|
8296
8536
|
retry: 1
|
|
8297
8537
|
});
|
|
8298
|
-
const queries = (0,
|
|
8538
|
+
const queries = (0, import_react_query38.useQueries)({
|
|
8299
8539
|
queries: uniqueRequests.map((request) => ({
|
|
8300
8540
|
queryKey: [
|
|
8301
8541
|
"smart-route",
|
|
@@ -8327,7 +8567,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8327
8567
|
);
|
|
8328
8568
|
}),
|
|
8329
8569
|
enabled: queryEnabled,
|
|
8330
|
-
placeholderData:
|
|
8570
|
+
placeholderData: import_react_query38.keepPreviousData,
|
|
8331
8571
|
staleTime: staleTimeMs,
|
|
8332
8572
|
refetchInterval: (queryState) => {
|
|
8333
8573
|
var _a2, _b2, _c, _d;
|
|
@@ -8377,7 +8617,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
8377
8617
|
};
|
|
8378
8618
|
|
|
8379
8619
|
// src/use-venue-sell-quotes.ts
|
|
8380
|
-
var
|
|
8620
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
8381
8621
|
var getIsDocumentVisible3 = () => {
|
|
8382
8622
|
if (typeof document === "undefined") return true;
|
|
8383
8623
|
return document.visibilityState !== "hidden";
|
|
@@ -8408,7 +8648,7 @@ var useVenueSellQuotes = (options) => {
|
|
|
8408
8648
|
refreshContext
|
|
8409
8649
|
} = options;
|
|
8410
8650
|
const uniqueRequests = getUniqueVenueRequests2(requests);
|
|
8411
|
-
const queries = (0,
|
|
8651
|
+
const queries = (0, import_react_query39.useQueries)({
|
|
8412
8652
|
queries: uniqueRequests.map((request) => {
|
|
8413
8653
|
const hasValidInput = request.requestedSellShares > 0 && request.sellShares > 0 && request.availableShares > 0;
|
|
8414
8654
|
const queryEnabled = enabled && !!venueMarketOutcomeId && !!accountId && hasValidInput;
|
|
@@ -8445,13 +8685,14 @@ var useVenueSellQuotes = (options) => {
|
|
|
8445
8685
|
}),
|
|
8446
8686
|
enabled: queryEnabled,
|
|
8447
8687
|
staleTime: staleTimeMs,
|
|
8448
|
-
refetchInterval: (
|
|
8688
|
+
refetchInterval: (queryState) => {
|
|
8449
8689
|
var _a2, _b2, _c, _d;
|
|
8450
8690
|
return resolveSmartRouteRefetchInterval({
|
|
8451
8691
|
// Venue quotes are display companions to the aggregate SELL quote.
|
|
8452
8692
|
// Poll them at the normal cadence rather than independently
|
|
8453
8693
|
// accelerating every venue to the thin-liquidity interval.
|
|
8454
|
-
data:
|
|
8694
|
+
data: queryState.state.data,
|
|
8695
|
+
adaptive: false,
|
|
8455
8696
|
defaultIntervalMs: staleTimeMs,
|
|
8456
8697
|
isDocumentVisible: getIsDocumentVisible3(),
|
|
8457
8698
|
isEditing: (_a2 = refreshContext == null ? void 0 : refreshContext.isEditing) != null ? _a2 : false,
|
|
@@ -8491,12 +8732,12 @@ var useVenueSellQuotes = (options) => {
|
|
|
8491
8732
|
};
|
|
8492
8733
|
|
|
8493
8734
|
// src/use-user-holdings.ts
|
|
8494
|
-
var
|
|
8735
|
+
var import_react_query40 = require("@tanstack/react-query");
|
|
8495
8736
|
function useUserHoldings(options) {
|
|
8496
8737
|
var _a, _b;
|
|
8497
8738
|
const client = useAggClient();
|
|
8498
8739
|
const { venue, venueMarketId, venueEventId, enabled = true } = options;
|
|
8499
|
-
const query = (0,
|
|
8740
|
+
const query = (0, import_react_query40.useInfiniteQuery)({
|
|
8500
8741
|
queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
|
|
8501
8742
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
8502
8743
|
return client.getUserHoldings({
|
|
@@ -8522,13 +8763,13 @@ function useUserHoldings(options) {
|
|
|
8522
8763
|
}
|
|
8523
8764
|
|
|
8524
8765
|
// src/use-enriched-venue-event.ts
|
|
8525
|
-
var
|
|
8766
|
+
var import_react37 = require("react");
|
|
8526
8767
|
|
|
8527
8768
|
// src/use-venue-event.ts
|
|
8528
|
-
var
|
|
8769
|
+
var import_react_query42 = require("@tanstack/react-query");
|
|
8529
8770
|
|
|
8530
8771
|
// src/use-recurring-crypto-markets.ts
|
|
8531
|
-
var
|
|
8772
|
+
var import_react_query41 = require("@tanstack/react-query");
|
|
8532
8773
|
var RESOLVING_POLL_INTERVAL_MS = 15e3;
|
|
8533
8774
|
var FALLBACK_VENUE_EVENT_PAGE_LIMIT = 100;
|
|
8534
8775
|
var FALLBACK_VENUE_EVENT_MAX_PAGES = 5;
|
|
@@ -9022,7 +9263,7 @@ var useRecurringCryptoMarkets = ({
|
|
|
9022
9263
|
const client = useAggClient();
|
|
9023
9264
|
const identity = event ? resolveRecurringCryptoIdentity(event) : null;
|
|
9024
9265
|
const isEnabled = enabled && event != null && identity != null;
|
|
9025
|
-
const query = (0,
|
|
9266
|
+
const query = (0, import_react_query41.useQuery)({
|
|
9026
9267
|
queryKey: [
|
|
9027
9268
|
"recurring-crypto-markets",
|
|
9028
9269
|
event == null ? void 0 : event.id,
|
|
@@ -9084,7 +9325,7 @@ function useVenueEvent(options) {
|
|
|
9084
9325
|
var _a;
|
|
9085
9326
|
const client = useAggClient();
|
|
9086
9327
|
const { eventId, enabled = true, cluster } = options;
|
|
9087
|
-
const query = (0,
|
|
9328
|
+
const query = (0, import_react_query42.useQuery)({
|
|
9088
9329
|
queryKey: ["venue-event", eventId, cluster === false ? "no-cluster" : ""],
|
|
9089
9330
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
9090
9331
|
return client.getVenueEventById(eventId, { signal, cluster });
|
|
@@ -9104,13 +9345,13 @@ function useVenueEvent(options) {
|
|
|
9104
9345
|
}
|
|
9105
9346
|
|
|
9106
9347
|
// src/use-venue-markets.ts
|
|
9107
|
-
var
|
|
9108
|
-
var
|
|
9348
|
+
var import_react_query43 = require("@tanstack/react-query");
|
|
9349
|
+
var import_react36 = require("react");
|
|
9109
9350
|
function useVenueMarkets(options) {
|
|
9110
9351
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9111
|
-
const client = (0,
|
|
9112
|
-
const queryClient = (0,
|
|
9113
|
-
const [fallbackQueryClient] = (0,
|
|
9352
|
+
const client = (0, import_react36.useContext)(AggClientContext);
|
|
9353
|
+
const queryClient = (0, import_react36.useContext)(import_react_query43.QueryClientContext);
|
|
9354
|
+
const [fallbackQueryClient] = (0, import_react36.useState)(() => new import_react_query43.QueryClient());
|
|
9114
9355
|
const venue = options == null ? void 0 : options.venue;
|
|
9115
9356
|
const venueEventId = options == null ? void 0 : options.venueEventId;
|
|
9116
9357
|
const cluster = options == null ? void 0 : options.cluster;
|
|
@@ -9128,7 +9369,7 @@ function useVenueMarkets(options) {
|
|
|
9128
9369
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
9129
9370
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
9130
9371
|
const context = options == null ? void 0 : options.context;
|
|
9131
|
-
(0,
|
|
9372
|
+
(0, import_react36.useEffect)(() => {
|
|
9132
9373
|
if (queryClient) return void 0;
|
|
9133
9374
|
fallbackQueryClient.mount();
|
|
9134
9375
|
return () => {
|
|
@@ -9138,7 +9379,7 @@ function useVenueMarkets(options) {
|
|
|
9138
9379
|
if (enabled && !client) {
|
|
9139
9380
|
throw new Error("useVenueMarkets must be used within an <AggProvider>");
|
|
9140
9381
|
}
|
|
9141
|
-
const query = (0,
|
|
9382
|
+
const query = (0, import_react_query43.useInfiniteQuery)(
|
|
9142
9383
|
{
|
|
9143
9384
|
queryKey: [
|
|
9144
9385
|
"venue-markets",
|
|
@@ -9198,7 +9439,7 @@ function useVenueMarkets(options) {
|
|
|
9198
9439
|
const hasNextPage = !!query.hasNextPage;
|
|
9199
9440
|
const { fetchNextPage, isFetchingNextPage } = query;
|
|
9200
9441
|
const fetchAll = (_k = options == null ? void 0 : options.fetchAll) != null ? _k : false;
|
|
9201
|
-
(0,
|
|
9442
|
+
(0, import_react36.useEffect)(() => {
|
|
9202
9443
|
if (!fetchAll || !hasNextPage || isFetchingNextPage) return;
|
|
9203
9444
|
void fetchNextPage();
|
|
9204
9445
|
}, [fetchAll, hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
@@ -9249,7 +9490,7 @@ function useEnrichedVenueEvent(options) {
|
|
|
9249
9490
|
});
|
|
9250
9491
|
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
9251
9492
|
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
|
9252
|
-
const enrichedEvent = (0,
|
|
9493
|
+
const enrichedEvent = (0, import_react37.useMemo)(() => {
|
|
9253
9494
|
if (!event) return void 0;
|
|
9254
9495
|
if (markets.length === 0) return event;
|
|
9255
9496
|
return mergeEventWithFullMarkets(event, markets);
|
|
@@ -9263,13 +9504,13 @@ function useEnrichedVenueEvent(options) {
|
|
|
9263
9504
|
}
|
|
9264
9505
|
|
|
9265
9506
|
// src/use-venue-events.ts
|
|
9266
|
-
var
|
|
9267
|
-
var
|
|
9507
|
+
var import_react_query44 = require("@tanstack/react-query");
|
|
9508
|
+
var import_react38 = require("react");
|
|
9268
9509
|
function useVenueEvents(options) {
|
|
9269
9510
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9270
|
-
const client = (0,
|
|
9271
|
-
const queryClient = (0,
|
|
9272
|
-
const [fallbackQueryClient] = (0,
|
|
9511
|
+
const client = (0, import_react38.useContext)(AggClientContext);
|
|
9512
|
+
const queryClient = (0, import_react38.useContext)(import_react_query44.QueryClientContext);
|
|
9513
|
+
const [fallbackQueryClient] = (0, import_react38.useState)(() => new import_react_query44.QueryClient());
|
|
9273
9514
|
const venues = options == null ? void 0 : options.venues;
|
|
9274
9515
|
const search = options == null ? void 0 : options.search;
|
|
9275
9516
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
@@ -9286,7 +9527,7 @@ function useVenueEvents(options) {
|
|
|
9286
9527
|
const endDateFrom = options == null ? void 0 : options.endDateFrom;
|
|
9287
9528
|
const grouped = options == null ? void 0 : options.grouped;
|
|
9288
9529
|
const initialPages = options == null ? void 0 : options.initialPages;
|
|
9289
|
-
(0,
|
|
9530
|
+
(0, import_react38.useEffect)(() => {
|
|
9290
9531
|
if (queryClient) return void 0;
|
|
9291
9532
|
fallbackQueryClient.mount();
|
|
9292
9533
|
return () => {
|
|
@@ -9296,7 +9537,7 @@ function useVenueEvents(options) {
|
|
|
9296
9537
|
if (enabled && !client) {
|
|
9297
9538
|
throw new Error("useVenueEvents must be used within an <AggProvider>");
|
|
9298
9539
|
}
|
|
9299
|
-
const query = (0,
|
|
9540
|
+
const query = (0, import_react_query44.useInfiniteQuery)(
|
|
9300
9541
|
{
|
|
9301
9542
|
queryKey: [
|
|
9302
9543
|
queryKeyScope,
|
|
@@ -9343,13 +9584,13 @@ function useVenueEvents(options) {
|
|
|
9343
9584
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
9344
9585
|
},
|
|
9345
9586
|
// TODO: RMIK - Comment out to show skeletons on category switch
|
|
9346
|
-
placeholderData:
|
|
9587
|
+
placeholderData: import_react_query44.keepPreviousData,
|
|
9347
9588
|
enabled: enabled && !!client
|
|
9348
9589
|
},
|
|
9349
9590
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
9350
9591
|
);
|
|
9351
|
-
const prefetchedRef = (0,
|
|
9352
|
-
(0,
|
|
9592
|
+
const prefetchedRef = (0, import_react38.useRef)(false);
|
|
9593
|
+
(0, import_react38.useEffect)(() => {
|
|
9353
9594
|
var _a2, _b2;
|
|
9354
9595
|
if (prefetchedRef.current) return;
|
|
9355
9596
|
if (!initialPages || initialPages <= 1) return;
|
|
@@ -9367,7 +9608,7 @@ function useVenueEvents(options) {
|
|
|
9367
9608
|
query.hasNextPage,
|
|
9368
9609
|
query.fetchNextPage
|
|
9369
9610
|
]);
|
|
9370
|
-
const events = (0,
|
|
9611
|
+
const events = (0, import_react38.useMemo)(
|
|
9371
9612
|
() => {
|
|
9372
9613
|
var _a2, _b2;
|
|
9373
9614
|
return (_b2 = (_a2 = query.data) == null ? void 0 : _a2.pages.flatMap((page) => page.data)) != null ? _b2 : [];
|
|
@@ -9385,7 +9626,7 @@ function useVenueEvents(options) {
|
|
|
9385
9626
|
}
|
|
9386
9627
|
|
|
9387
9628
|
// src/use-sports-live.ts
|
|
9388
|
-
var
|
|
9629
|
+
var import_react_query45 = require("@tanstack/react-query");
|
|
9389
9630
|
var SPORTS_LIVE_POLL_INTERVAL_MS = 5e3;
|
|
9390
9631
|
var SPORTS_SCHEDULED_POLL_INTERVAL_MS = 3e4;
|
|
9391
9632
|
var sportsLiveQueryKey = (sortedEventIds) => ["sports-live", ...sortedEventIds];
|
|
@@ -9405,7 +9646,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
9405
9646
|
const sortedEventIds = [
|
|
9406
9647
|
...new Set(eventIds.map((eventId) => eventId.trim()).filter(Boolean))
|
|
9407
9648
|
].sort();
|
|
9408
|
-
const query = (0,
|
|
9649
|
+
const query = (0, import_react_query45.useQuery)({
|
|
9409
9650
|
queryKey: sportsLiveQueryKey(sortedEventIds),
|
|
9410
9651
|
queryFn: ({ signal }) => client.getSportsLive(sortedEventIds, { signal }),
|
|
9411
9652
|
enabled: enabled && sortedEventIds.length > 0,
|
|
@@ -9425,7 +9666,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
9425
9666
|
};
|
|
9426
9667
|
|
|
9427
9668
|
// src/use-venue-market-midpoints.ts
|
|
9428
|
-
var
|
|
9669
|
+
var import_react_query46 = require("@tanstack/react-query");
|
|
9429
9670
|
var normalizeVenueMarketIds2 = (venueMarketIds) => {
|
|
9430
9671
|
return [
|
|
9431
9672
|
...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
|
|
@@ -9464,7 +9705,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
9464
9705
|
const enabled = (_a = options.enabled) != null ? _a : true;
|
|
9465
9706
|
const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
|
|
9466
9707
|
const maxMidpointIdsPerRequest = (_b = options.maxMidpointIdsPerRequest) != null ? _b : configuredMaxMidpointIdsPerRequest;
|
|
9467
|
-
const query = (0,
|
|
9708
|
+
const query = (0, import_react_query46.useQuery)({
|
|
9468
9709
|
queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds, maxMidpointIdsPerRequest] : ["venue-market-midpoints", "__disabled__"],
|
|
9469
9710
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
9470
9711
|
if (requestedVenueMarketIds.length === 0) {
|
|
@@ -9480,7 +9721,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
9480
9721
|
gcTime: 5 * 6e4,
|
|
9481
9722
|
refetchOnWindowFocus: false,
|
|
9482
9723
|
retry: 1,
|
|
9483
|
-
placeholderData:
|
|
9724
|
+
placeholderData: import_react_query46.keepPreviousData
|
|
9484
9725
|
});
|
|
9485
9726
|
const midpointRows = (_d = (_c = query.data) == null ? void 0 : _c.data) != null ? _d : [];
|
|
9486
9727
|
const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
|
|
@@ -9540,7 +9781,7 @@ var computePriceGaps = ({
|
|
|
9540
9781
|
};
|
|
9541
9782
|
|
|
9542
9783
|
// src/use-viewport-midpoints.ts
|
|
9543
|
-
var
|
|
9784
|
+
var import_react39 = require("react");
|
|
9544
9785
|
var buildOutcomeMidpointMap = (outcomes) => {
|
|
9545
9786
|
const m = /* @__PURE__ */ new Map();
|
|
9546
9787
|
if (!outcomes) return m;
|
|
@@ -9593,15 +9834,15 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9593
9834
|
market: { maxMidpointIdsPerRequest: configuredMaxMidpointIdsPerRequest }
|
|
9594
9835
|
} = useAggUiConfig();
|
|
9595
9836
|
const maxMidpointIdsPerRequest = (_a = options == null ? void 0 : options.maxMidpointIdsPerRequest) != null ? _a : configuredMaxMidpointIdsPerRequest;
|
|
9596
|
-
const [cache, setCache] = (0,
|
|
9597
|
-
const inFlightRef = (0,
|
|
9598
|
-
const visibleRef = (0,
|
|
9837
|
+
const [cache, setCache] = (0, import_react39.useState)(() => /* @__PURE__ */ new Map());
|
|
9838
|
+
const inFlightRef = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
|
|
9839
|
+
const visibleRef = (0, import_react39.useRef)(visibleMarkets);
|
|
9599
9840
|
visibleRef.current = visibleMarkets;
|
|
9600
|
-
const visibleFp = (0,
|
|
9841
|
+
const visibleFp = (0, import_react39.useMemo)(
|
|
9601
9842
|
() => [...new Set(visibleMarkets.map((m) => m.id))].sort().join("|"),
|
|
9602
9843
|
[visibleMarkets]
|
|
9603
9844
|
);
|
|
9604
|
-
(0,
|
|
9845
|
+
(0, import_react39.useEffect)(() => {
|
|
9605
9846
|
const toFetch = resolveUncachedVisibleMarketIds(visibleRef.current, cache, inFlightRef.current);
|
|
9606
9847
|
if (!toFetch.length) return;
|
|
9607
9848
|
let cancelled = false;
|
|
@@ -9625,7 +9866,7 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9625
9866
|
cancelled = true;
|
|
9626
9867
|
};
|
|
9627
9868
|
}, [visibleFp, cache, maxMidpointIdsPerRequest]);
|
|
9628
|
-
const { prices, venueByOutcomeId } = (0,
|
|
9869
|
+
const { prices, venueByOutcomeId } = (0, import_react39.useMemo)(() => {
|
|
9629
9870
|
var _a2, _b, _c, _d;
|
|
9630
9871
|
const map = /* @__PURE__ */ new Map();
|
|
9631
9872
|
const venueMap = /* @__PURE__ */ new Map();
|
|
@@ -9658,15 +9899,15 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
9658
9899
|
}
|
|
9659
9900
|
|
|
9660
9901
|
// src/use-visible-ids.ts
|
|
9661
|
-
var
|
|
9902
|
+
var import_react40 = require("react");
|
|
9662
9903
|
function useVisibleIds(options = {}) {
|
|
9663
9904
|
const { rootMargin = "0px", threshold = 0 } = options;
|
|
9664
|
-
const [visibleIds, setVisibleIds] = (0,
|
|
9665
|
-
const observerRef = (0,
|
|
9666
|
-
const elementsRef = (0,
|
|
9667
|
-
const elementIdRef = (0,
|
|
9668
|
-
const callbackRefsRef = (0,
|
|
9669
|
-
(0,
|
|
9905
|
+
const [visibleIds, setVisibleIds] = (0, import_react40.useState)(() => /* @__PURE__ */ new Set());
|
|
9906
|
+
const observerRef = (0, import_react40.useRef)(null);
|
|
9907
|
+
const elementsRef = (0, import_react40.useRef)(/* @__PURE__ */ new Map());
|
|
9908
|
+
const elementIdRef = (0, import_react40.useRef)(/* @__PURE__ */ new WeakMap());
|
|
9909
|
+
const callbackRefsRef = (0, import_react40.useRef)(/* @__PURE__ */ new Map());
|
|
9910
|
+
(0, import_react40.useEffect)(() => {
|
|
9670
9911
|
if (typeof IntersectionObserver === "undefined") return;
|
|
9671
9912
|
const observer = new IntersectionObserver(
|
|
9672
9913
|
(entries) => {
|
|
@@ -9698,7 +9939,7 @@ function useVisibleIds(options = {}) {
|
|
|
9698
9939
|
observerRef.current = null;
|
|
9699
9940
|
};
|
|
9700
9941
|
}, [rootMargin, threshold]);
|
|
9701
|
-
const register = (0,
|
|
9942
|
+
const register = (0, import_react40.useCallback)((id) => {
|
|
9702
9943
|
const existing = callbackRefsRef.current.get(id);
|
|
9703
9944
|
if (existing) return existing;
|
|
9704
9945
|
const callback = (el) => {
|
|
@@ -9730,48 +9971,49 @@ function useVisibleIds(options = {}) {
|
|
|
9730
9971
|
return { visibleIds, register };
|
|
9731
9972
|
}
|
|
9732
9973
|
|
|
9733
|
-
// src/use-
|
|
9734
|
-
var
|
|
9735
|
-
var
|
|
9736
|
-
var
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
const query = (0, import_react_query45.useQuery)({
|
|
9753
|
-
queryKey: APP_CONFIG_QUERY_KEY,
|
|
9754
|
-
enabled: false,
|
|
9755
|
-
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
9756
|
-
staleTime: FIVE_MINUTES
|
|
9757
|
-
});
|
|
9758
|
-
return toAppConfigResult({
|
|
9759
|
-
data: query.data,
|
|
9760
|
-
isLoading: query.isLoading,
|
|
9761
|
-
error: query.error
|
|
9762
|
-
});
|
|
9763
|
-
}
|
|
9764
|
-
var toAppConfigResult = (query) => {
|
|
9765
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9766
|
-
return {
|
|
9767
|
-
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
9768
|
-
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
9769
|
-
earlyAccessEnabled: (_f = (_e = query.data) == null ? void 0 : _e.earlyAccessEnabled) != null ? _f : false,
|
|
9770
|
-
authOptions: (_h = (_g = query.data) == null ? void 0 : _g.authOptions) != null ? _h : [],
|
|
9771
|
-
isLoading: query.isLoading,
|
|
9772
|
-
error: query.error
|
|
9773
|
-
};
|
|
9974
|
+
// src/use-paper-onboarding.ts
|
|
9975
|
+
var import_react41 = require("react");
|
|
9976
|
+
var STORAGE_KEY2 = "agg_paper_onboarding_seen";
|
|
9977
|
+
var isBrowser2 = () => typeof window !== "undefined" && "localStorage" in window;
|
|
9978
|
+
var seenKey = (userId) => `${STORAGE_KEY2}:${userId}`;
|
|
9979
|
+
var hasSeen = (userId) => {
|
|
9980
|
+
if (!isBrowser2()) return false;
|
|
9981
|
+
try {
|
|
9982
|
+
return window.localStorage.getItem(seenKey(userId)) === "1";
|
|
9983
|
+
} catch (e) {
|
|
9984
|
+
return true;
|
|
9985
|
+
}
|
|
9986
|
+
};
|
|
9987
|
+
var markSeen = (userId) => {
|
|
9988
|
+
if (!isBrowser2()) return;
|
|
9989
|
+
try {
|
|
9990
|
+
window.localStorage.setItem(seenKey(userId), "1");
|
|
9991
|
+
} catch (e) {
|
|
9992
|
+
}
|
|
9774
9993
|
};
|
|
9994
|
+
function usePaperOnboarding() {
|
|
9995
|
+
const { isPaperMode, isResolving } = useResolvedExecutionMode();
|
|
9996
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
9997
|
+
const userId = user == null ? void 0 : user.id;
|
|
9998
|
+
const [dismissed, setDismissed] = (0, import_react41.useState)(false);
|
|
9999
|
+
const [seen, setSeen] = (0, import_react41.useState)(null);
|
|
10000
|
+
(0, import_react41.useEffect)(() => {
|
|
10001
|
+
if (!userId) {
|
|
10002
|
+
setSeen(null);
|
|
10003
|
+
return;
|
|
10004
|
+
}
|
|
10005
|
+
setSeen(hasSeen(userId));
|
|
10006
|
+
}, [userId]);
|
|
10007
|
+
(0, import_react41.useEffect)(() => {
|
|
10008
|
+
setDismissed(false);
|
|
10009
|
+
}, [userId]);
|
|
10010
|
+
const dismiss = (0, import_react41.useCallback)(() => {
|
|
10011
|
+
setDismissed(true);
|
|
10012
|
+
if (userId) markSeen(userId);
|
|
10013
|
+
}, [userId]);
|
|
10014
|
+
const isOpen = isPaperMode && !isResolving && isAuthenticated && Boolean(userId) && seen === false && !dismissed;
|
|
10015
|
+
return { isOpen, dismiss };
|
|
10016
|
+
}
|
|
9775
10017
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9776
10018
|
0 && (module.exports = {
|
|
9777
10019
|
AUTH_CHOOSER_OPEN_EVENT,
|
|
@@ -9796,6 +10038,7 @@ var toAppConfigResult = (query) => {
|
|
|
9796
10038
|
TradeSide,
|
|
9797
10039
|
TurnstileChallengeError,
|
|
9798
10040
|
Venue,
|
|
10041
|
+
appConfigQueryKey,
|
|
9799
10042
|
buildLiveBestPriceCandidates,
|
|
9800
10043
|
computeClosedPositionTotals,
|
|
9801
10044
|
computePriceGaps,
|
|
@@ -9837,6 +10080,7 @@ var toAppConfigResult = (query) => {
|
|
|
9837
10080
|
resolveRecurringCryptoTimeline,
|
|
9838
10081
|
resolveRollingWindow,
|
|
9839
10082
|
resolveTradingStateKind,
|
|
10083
|
+
sharedKycQueryKeys,
|
|
9840
10084
|
sortVenues,
|
|
9841
10085
|
sportsLiveQueryKey,
|
|
9842
10086
|
sportsLiveRefetchInterval,
|
|
@@ -9897,6 +10141,7 @@ var toAppConfigResult = (query) => {
|
|
|
9897
10141
|
useOrderBook,
|
|
9898
10142
|
useOrderbookQuote,
|
|
9899
10143
|
useOrders,
|
|
10144
|
+
usePaperOnboarding,
|
|
9900
10145
|
usePlaceLimitOrder,
|
|
9901
10146
|
usePositions,
|
|
9902
10147
|
useQueryClient,
|
|
@@ -9907,10 +10152,12 @@ var toAppConfigResult = (query) => {
|
|
|
9907
10152
|
useRedeemEligibleCount,
|
|
9908
10153
|
useRedeemLifecycle,
|
|
9909
10154
|
useRedeemLifecycles,
|
|
10155
|
+
useResolvedExecutionMode,
|
|
9910
10156
|
useRollingChartWindow,
|
|
9911
10157
|
useSdkLabels,
|
|
9912
10158
|
useSdkUiConfig,
|
|
9913
10159
|
useSearch,
|
|
10160
|
+
useSharedKyc,
|
|
9914
10161
|
useSmartRoute,
|
|
9915
10162
|
useSportsLive,
|
|
9916
10163
|
useSyncBalances,
|