@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.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useRampQuotes,
|
|
3
3
|
useRampSession
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MIWXPZNP.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useWithdrawEstimate,
|
|
7
7
|
useWithdrawFlow,
|
|
8
8
|
useWithdrawPreview,
|
|
9
9
|
useWithdrawalLifecycle
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7DCOWPUQ.mjs";
|
|
11
11
|
import {
|
|
12
12
|
AggAuthContext,
|
|
13
13
|
AggBalanceProvider,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
__objRest,
|
|
29
29
|
__spreadProps,
|
|
30
30
|
__spreadValues,
|
|
31
|
+
appConfigQueryKey,
|
|
31
32
|
applyOrderbookDepth,
|
|
32
33
|
computeClosedPositionTotals,
|
|
33
34
|
createMarketChartData,
|
|
@@ -71,7 +72,9 @@ import {
|
|
|
71
72
|
useAggUiConfig,
|
|
72
73
|
useAggWebSocket,
|
|
73
74
|
useAggWebSocketConnectionState,
|
|
75
|
+
useAppConfig,
|
|
74
76
|
useBalanceRefillPolicies,
|
|
77
|
+
useCachedAppConfig,
|
|
75
78
|
useCancelManagedOrder,
|
|
76
79
|
useDepositAddresses,
|
|
77
80
|
useEventListState,
|
|
@@ -92,15 +95,16 @@ import {
|
|
|
92
95
|
useRedeemEligibleCount,
|
|
93
96
|
useRedeemLifecycle,
|
|
94
97
|
useRedeemLifecycles,
|
|
98
|
+
useResolvedExecutionMode,
|
|
95
99
|
useSdkLabels,
|
|
96
100
|
useSdkUiConfig,
|
|
97
101
|
useSyncBalances,
|
|
98
102
|
useWithdrawManaged,
|
|
99
103
|
userActivityQueryKeys
|
|
100
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-SFSGE25P.mjs";
|
|
101
105
|
|
|
102
106
|
// src/index.ts
|
|
103
|
-
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as
|
|
107
|
+
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
104
108
|
import { TurnstileChallengeError } from "@agg-build/sdk";
|
|
105
109
|
|
|
106
110
|
// src/use-geo-block.ts
|
|
@@ -166,8 +170,42 @@ var useVenueKeyStatus = (venue, enabled = true) => {
|
|
|
166
170
|
});
|
|
167
171
|
};
|
|
168
172
|
|
|
169
|
-
// src/use-
|
|
173
|
+
// src/use-shared-kyc.ts
|
|
170
174
|
import { useCallback } from "react";
|
|
175
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
176
|
+
var sharedKycQueryKeys = {
|
|
177
|
+
status: (userId) => ["agg", "shared-kyc", userId]
|
|
178
|
+
};
|
|
179
|
+
var useSharedKyc = () => {
|
|
180
|
+
var _a, _b;
|
|
181
|
+
const client = useAggClient();
|
|
182
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
183
|
+
const userId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
|
|
184
|
+
const query = useQuery2({
|
|
185
|
+
queryKey: sharedKycQueryKeys.status(userId),
|
|
186
|
+
queryFn: () => client.getSharedKycStatus(),
|
|
187
|
+
enabled: isAuthenticated && userId !== null,
|
|
188
|
+
staleTime: 15e3,
|
|
189
|
+
retry: false
|
|
190
|
+
});
|
|
191
|
+
const { refetch } = query;
|
|
192
|
+
const refreshStatus = useCallback(() => __async(null, null, function* () {
|
|
193
|
+
var _a2;
|
|
194
|
+
if (!isAuthenticated || !userId) return "unverified";
|
|
195
|
+
const result = yield refetch({ cancelRefetch: false });
|
|
196
|
+
if (result.error) throw result.error;
|
|
197
|
+
return ((_a2 = result.data) == null ? void 0 : _a2.verified) === true ? "verified" : "unverified";
|
|
198
|
+
}), [isAuthenticated, userId, refetch]);
|
|
199
|
+
const initiateVerification = useCallback(
|
|
200
|
+
({ venue, redirectUri }) => client.initiateKyc(venue, redirectUri),
|
|
201
|
+
[client]
|
|
202
|
+
);
|
|
203
|
+
const status = !isAuthenticated ? "unverified" : !userId || query.isPending ? "loading" : ((_b = query.data) == null ? void 0 : _b.verified) === true ? "verified" : "unverified";
|
|
204
|
+
return { status, refreshStatus, initiateVerification };
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/use-agg-auth.ts
|
|
208
|
+
import { useCallback as useCallback2 } from "react";
|
|
171
209
|
function useAggAuth(options = {}) {
|
|
172
210
|
const {
|
|
173
211
|
isAuthenticated,
|
|
@@ -177,7 +215,7 @@ function useAggAuth(options = {}) {
|
|
|
177
215
|
signIn: signInWithProvider,
|
|
178
216
|
signOut
|
|
179
217
|
} = useAggAuthContext();
|
|
180
|
-
const signIn =
|
|
218
|
+
const signIn = useCallback2(
|
|
181
219
|
(statement) => __async(null, null, function* () {
|
|
182
220
|
if (!options.signMessage) {
|
|
183
221
|
throw new Error(
|
|
@@ -201,7 +239,7 @@ function useAggAuth(options = {}) {
|
|
|
201
239
|
}
|
|
202
240
|
|
|
203
241
|
// src/use-link-account.ts
|
|
204
|
-
import { useCallback as
|
|
242
|
+
import { useCallback as useCallback3, useState } from "react";
|
|
205
243
|
function useLinkAccount() {
|
|
206
244
|
const client = useAggClient();
|
|
207
245
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -215,11 +253,11 @@ function useLinkAccount() {
|
|
|
215
253
|
throw err;
|
|
216
254
|
}).finally(() => setIsLoading(false));
|
|
217
255
|
};
|
|
218
|
-
const startLink =
|
|
256
|
+
const startLink = useCallback3(
|
|
219
257
|
(body) => run(() => client.linkAccount(body)),
|
|
220
258
|
[client]
|
|
221
259
|
);
|
|
222
|
-
const confirmLink =
|
|
260
|
+
const confirmLink = useCallback3(
|
|
223
261
|
(input) => run(() => client.linkAccountConfirm(input)),
|
|
224
262
|
[client]
|
|
225
263
|
);
|
|
@@ -436,13 +474,13 @@ function useUserActivity(options = {}) {
|
|
|
436
474
|
}
|
|
437
475
|
|
|
438
476
|
// src/use-external-id.ts
|
|
439
|
-
import { useCallback as
|
|
477
|
+
import { useCallback as useCallback4, useState as useState3 } from "react";
|
|
440
478
|
function useExternalId(options = {}) {
|
|
441
479
|
const client = useAggClient();
|
|
442
480
|
const { onSuccess, onError: onErrorCb } = options;
|
|
443
481
|
const [isLoading, setIsLoading] = useState3(false);
|
|
444
482
|
const [error, setError] = useState3(null);
|
|
445
|
-
const linkExternalId =
|
|
483
|
+
const linkExternalId = useCallback4(
|
|
446
484
|
(assertion) => __async(null, null, function* () {
|
|
447
485
|
setIsLoading(true);
|
|
448
486
|
setError(null);
|
|
@@ -494,7 +532,7 @@ function useExecutionPositions(options = {}) {
|
|
|
494
532
|
}
|
|
495
533
|
|
|
496
534
|
// src/use-live-candle-overlay.ts
|
|
497
|
-
import { useCallback as
|
|
535
|
+
import { useCallback as useCallback5, useMemo as useMemo4 } from "react";
|
|
498
536
|
|
|
499
537
|
// src/use-live-candles.ts
|
|
500
538
|
import { useMemo as useMemo3 } from "react";
|
|
@@ -801,7 +839,7 @@ function useLiveCandleOverlay(options) {
|
|
|
801
839
|
startTs,
|
|
802
840
|
endTs
|
|
803
841
|
});
|
|
804
|
-
const scaleCandle =
|
|
842
|
+
const scaleCandle = useCallback5(
|
|
805
843
|
(candle) => ({
|
|
806
844
|
time: candle.time,
|
|
807
845
|
open: candle.o * scale,
|
|
@@ -864,7 +902,7 @@ function useEventOrderbookData(venueMarkets, selectedMarketId) {
|
|
|
864
902
|
}
|
|
865
903
|
|
|
866
904
|
// src/use-live-market.ts
|
|
867
|
-
import { useQuery as
|
|
905
|
+
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
868
906
|
function outcomeOrderbookToState(response, marketId) {
|
|
869
907
|
var _a, _b, _c, _d;
|
|
870
908
|
const { venue, orderbook, midpoint, spread, seq, checksum, timestamp, venueMarketOutcomeId } = response;
|
|
@@ -914,7 +952,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
914
952
|
enabled: isLiveSubscriptionEnabled,
|
|
915
953
|
orderbook: true
|
|
916
954
|
});
|
|
917
|
-
const query =
|
|
955
|
+
const query = useQuery3({
|
|
918
956
|
queryKey: marketDataKeys.live(canonicalMarketId != null ? canonicalMarketId : "__disabled__"),
|
|
919
957
|
queryFn: () => __async(null, null, function* () {
|
|
920
958
|
return createMarketLiveState(canonicalMarketId != null ? canonicalMarketId : "__disabled__");
|
|
@@ -926,7 +964,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
926
964
|
isConnected: Boolean(isLiveSubscriptionEnabled && isConnected)
|
|
927
965
|
})
|
|
928
966
|
});
|
|
929
|
-
const seedQuery =
|
|
967
|
+
const seedQuery = useQuery3({
|
|
930
968
|
queryKey: ["live-market-seed", canonicalMarketId],
|
|
931
969
|
queryFn: ({ signal }) => canonicalMarketId ? client.getOutcomeOrderbook(canonicalMarketId, { signal }) : Promise.resolve(null),
|
|
932
970
|
enabled: Boolean(canonicalMarketId),
|
|
@@ -1325,7 +1363,7 @@ function useLiveTrades(canonicalMarketId) {
|
|
|
1325
1363
|
}
|
|
1326
1364
|
|
|
1327
1365
|
// src/use-midpoints.ts
|
|
1328
|
-
import { useQuery as
|
|
1366
|
+
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
1329
1367
|
import { useMemo as useMemo8 } from "react";
|
|
1330
1368
|
var normalizeVenueMarketIds = (venueMarkets) => {
|
|
1331
1369
|
var _a;
|
|
@@ -1504,7 +1542,7 @@ function useMidpoints(venueMarkets, options) {
|
|
|
1504
1542
|
() => resolveBestMidpointCandidateOutcomeIds(venueMarkets),
|
|
1505
1543
|
[venueMarkets]
|
|
1506
1544
|
);
|
|
1507
|
-
const { data, isLoading } =
|
|
1545
|
+
const { data, isLoading } = useQuery4({
|
|
1508
1546
|
queryKey: ["midpoints", ids, maxMidpointIdsPerRequest],
|
|
1509
1547
|
queryFn: () => client.getMidpoints(ids, { bestPrice: true, maxMidpointIdsPerRequest }),
|
|
1510
1548
|
enabled: ids.length > 0,
|
|
@@ -1655,8 +1693,9 @@ var useRollingChartWindow = (options) => {
|
|
|
1655
1693
|
// src/use-market-orderbook.ts
|
|
1656
1694
|
import { useQueries as useQueries5, useQueryClient } from "@tanstack/react-query";
|
|
1657
1695
|
function useMarketOrderbook(options) {
|
|
1658
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
1696
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1659
1697
|
const queryClient = useQueryClient();
|
|
1698
|
+
const client = useAggClient();
|
|
1660
1699
|
const ws = useAggWebSocket();
|
|
1661
1700
|
const isConnected = useAggWebSocketConnectionState();
|
|
1662
1701
|
const {
|
|
@@ -1685,12 +1724,30 @@ function useMarketOrderbook(options) {
|
|
|
1685
1724
|
refetchOnReconnect: false
|
|
1686
1725
|
}))
|
|
1687
1726
|
});
|
|
1727
|
+
const seedQueries = useQueries5({
|
|
1728
|
+
queries: subscriptionIds.map((subscriptionId) => ({
|
|
1729
|
+
queryKey: ["market-orderbook-seed", subscriptionId],
|
|
1730
|
+
queryFn: ({ signal }) => client.getOutcomeOrderbook(subscriptionId, { signal }),
|
|
1731
|
+
enabled: enabled && !!subscriptionId,
|
|
1732
|
+
staleTime: 5e3,
|
|
1733
|
+
gcTime: 6e4,
|
|
1734
|
+
refetchOnWindowFocus: false,
|
|
1735
|
+
retry: 1
|
|
1736
|
+
}))
|
|
1737
|
+
});
|
|
1688
1738
|
const liveStates = subscriptionIds.map((subscriptionId, index) => {
|
|
1689
1739
|
var _a2, _b2;
|
|
1690
1740
|
return (_b2 = (_a2 = liveQueries[index]) == null ? void 0 : _a2.data) != null ? _b2 : createMarketLiveState(subscriptionId);
|
|
1691
1741
|
});
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1742
|
+
const seededOrderbooks = subscriptionIds.map((subscriptionId, index) => {
|
|
1743
|
+
var _a2, _b2, _c2, _d2;
|
|
1744
|
+
const liveBook = (_b2 = (_a2 = liveStates[index]) == null ? void 0 : _a2.orderbook) != null ? _b2 : null;
|
|
1745
|
+
if (liveBook) return liveBook;
|
|
1746
|
+
const seed = (_c2 = seedQueries[index]) == null ? void 0 : _c2.data;
|
|
1747
|
+
return ((_d2 = seed == null ? void 0 : seed.orderbook) == null ? void 0 : _d2.bids) && seed.orderbook.asks ? outcomeOrderbookToState(seed, subscriptionId) : null;
|
|
1748
|
+
});
|
|
1749
|
+
const primaryOrderbook = (_c = seededOrderbooks[0]) != null ? _c : null;
|
|
1750
|
+
const primarySnapshotVersion = (_e = (_d = liveStates[0]) == null ? void 0 : _d.orderbookSnapshotVersion) != null ? _e : 0;
|
|
1694
1751
|
const data = primaryOrderbook ? applyOrderbookDepth(
|
|
1695
1752
|
createMarketOrderbookDataFromState(primaryOrderbook, {
|
|
1696
1753
|
snapshotVersion: primarySnapshotVersion
|
|
@@ -1698,14 +1755,15 @@ function useMarketOrderbook(options) {
|
|
|
1698
1755
|
depth
|
|
1699
1756
|
) : null;
|
|
1700
1757
|
const dataById = Object.fromEntries(
|
|
1701
|
-
|
|
1702
|
-
|
|
1758
|
+
seededOrderbooks.flatMap((orderbook, index) => {
|
|
1759
|
+
var _a2;
|
|
1760
|
+
if (!orderbook) return [];
|
|
1703
1761
|
return [
|
|
1704
1762
|
[
|
|
1705
1763
|
subscriptionIds[index],
|
|
1706
1764
|
applyOrderbookDepth(
|
|
1707
|
-
createMarketOrderbookDataFromState(
|
|
1708
|
-
snapshotVersion:
|
|
1765
|
+
createMarketOrderbookDataFromState(orderbook, {
|
|
1766
|
+
snapshotVersion: (_a2 = liveStates[index]) == null ? void 0 : _a2.orderbookSnapshotVersion
|
|
1709
1767
|
}),
|
|
1710
1768
|
depth
|
|
1711
1769
|
)
|
|
@@ -1713,14 +1771,15 @@ function useMarketOrderbook(options) {
|
|
|
1713
1771
|
];
|
|
1714
1772
|
})
|
|
1715
1773
|
);
|
|
1716
|
-
const hasAnyOrderbook =
|
|
1717
|
-
const
|
|
1774
|
+
const hasAnyOrderbook = seededOrderbooks.some((orderbook) => orderbook != null);
|
|
1775
|
+
const seedLoading = seedQueries.some((query) => query.isLoading);
|
|
1776
|
+
const liveOrderbookErrorMessage = enabled && liveEnabled && !hasAnyOrderbook ? (_g = (_f = liveStates.find(
|
|
1718
1777
|
(liveState) => typeof liveState.orderbookError === "string" && liveState.orderbookError.length > 0
|
|
1719
|
-
)) == null ? void 0 :
|
|
1778
|
+
)) == null ? void 0 : _f.orderbookError) != null ? _g : null : null;
|
|
1720
1779
|
return {
|
|
1721
1780
|
data,
|
|
1722
1781
|
dataById,
|
|
1723
|
-
isLoading: enabled &&
|
|
1782
|
+
isLoading: enabled && !hasAnyOrderbook && liveOrderbookErrorMessage == null && (isConnected || seedLoading),
|
|
1724
1783
|
error: liveOrderbookErrorMessage ? new Error(liveOrderbookErrorMessage) : null,
|
|
1725
1784
|
isLive: Boolean(liveEnabled && selectedOutcomeId && isConnected),
|
|
1726
1785
|
refetch: () => __async(null, null, function* () {
|
|
@@ -1798,7 +1857,7 @@ function useArbFeed() {
|
|
|
1798
1857
|
}
|
|
1799
1858
|
|
|
1800
1859
|
// src/use-order-book.ts
|
|
1801
|
-
import { keepPreviousData as keepPreviousData3, useQuery as
|
|
1860
|
+
import { keepPreviousData as keepPreviousData3, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
1802
1861
|
function useOrderBook(options) {
|
|
1803
1862
|
const client = useAggClient();
|
|
1804
1863
|
const { orderbooks, enabled = true, canonicalMarketId } = options;
|
|
@@ -1811,7 +1870,7 @@ function useOrderBook(options) {
|
|
|
1811
1870
|
venueMarketOutcomeId: outcome.id
|
|
1812
1871
|
})) : void 0
|
|
1813
1872
|
});
|
|
1814
|
-
const batchedResult =
|
|
1873
|
+
const batchedResult = useQuery5({
|
|
1815
1874
|
queryKey: requestedVenueMarketIds.length ? ["orderbooks", requestedVenueMarketIds, null] : ["orderbooks", "__disabled__", null],
|
|
1816
1875
|
queryFn: ({ signal }) => client.getOrderbooks(
|
|
1817
1876
|
{
|
|
@@ -1879,7 +1938,7 @@ function useOrderBook(options) {
|
|
|
1879
1938
|
}
|
|
1880
1939
|
|
|
1881
1940
|
// src/use-orderbook-quote.ts
|
|
1882
|
-
import { keepPreviousData as keepPreviousData4, useQuery as
|
|
1941
|
+
import { keepPreviousData as keepPreviousData4, useQuery as useQuery6 } from "@tanstack/react-query";
|
|
1883
1942
|
var QUOTE_DEBOUNCE_MS = 300;
|
|
1884
1943
|
var createUnavailableOrderbookError = (message, code, retryable) => {
|
|
1885
1944
|
const error = new Error(message);
|
|
@@ -1941,7 +2000,7 @@ function useOrderbookQuote(options) {
|
|
|
1941
2000
|
const { marketId, side, size, enabled = true } = options;
|
|
1942
2001
|
const debouncedSize = useDebouncedValue(size, QUOTE_DEBOUNCE_MS);
|
|
1943
2002
|
const shouldFetch = enabled && !!marketId && debouncedSize > 0;
|
|
1944
|
-
const query =
|
|
2003
|
+
const query = useQuery6({
|
|
1945
2004
|
queryKey: marketId ? marketDataKeys.orderbookQuote(marketId, side, debouncedSize) : ["market-data", "orderbook-quote", "__disabled__"],
|
|
1946
2005
|
queryFn: () => __async(null, null, function* () {
|
|
1947
2006
|
var _a2, _b, _c, _d;
|
|
@@ -1983,12 +2042,12 @@ function useOrderbookQuote(options) {
|
|
|
1983
2042
|
}
|
|
1984
2043
|
|
|
1985
2044
|
// src/use-orders.ts
|
|
1986
|
-
import { useQuery as
|
|
2045
|
+
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
1987
2046
|
function useOrders(options = {}) {
|
|
1988
2047
|
var _a, _b, _c, _d;
|
|
1989
2048
|
const client = useAggClient();
|
|
1990
2049
|
const { userId, status, limit = 50, offset = 0, enabled = true } = options;
|
|
1991
|
-
const query =
|
|
2050
|
+
const query = useQuery7({
|
|
1992
2051
|
queryKey: ["orders", userId != null ? userId : "me", status != null ? status : "all", limit, offset],
|
|
1993
2052
|
queryFn: () => client.getOrders({
|
|
1994
2053
|
userId,
|
|
@@ -2082,7 +2141,7 @@ function useSearch(options) {
|
|
|
2082
2141
|
}
|
|
2083
2142
|
|
|
2084
2143
|
// src/use-market-search.ts
|
|
2085
|
-
import { useCallback as
|
|
2144
|
+
import { useCallback as useCallback6, useState as useState7 } from "react";
|
|
2086
2145
|
function useMarketSearch(options) {
|
|
2087
2146
|
var _a;
|
|
2088
2147
|
const {
|
|
@@ -2118,10 +2177,10 @@ function useMarketSearch(options) {
|
|
|
2118
2177
|
enabled: submittedQ.length > 0,
|
|
2119
2178
|
deep: true
|
|
2120
2179
|
});
|
|
2121
|
-
const setQuery =
|
|
2180
|
+
const setQuery = useCallback6((value) => {
|
|
2122
2181
|
setQueryState(value);
|
|
2123
2182
|
}, []);
|
|
2124
|
-
const submit =
|
|
2183
|
+
const submit = useCallback6(
|
|
2125
2184
|
(q) => {
|
|
2126
2185
|
const target = (q != null ? q : query).trim();
|
|
2127
2186
|
if (target.length === 0) return;
|
|
@@ -2129,7 +2188,7 @@ function useMarketSearch(options) {
|
|
|
2129
2188
|
},
|
|
2130
2189
|
[query]
|
|
2131
2190
|
);
|
|
2132
|
-
const clear =
|
|
2191
|
+
const clear = useCallback6(() => {
|
|
2133
2192
|
setQueryState("");
|
|
2134
2193
|
setSubmittedQuery(null);
|
|
2135
2194
|
}, []);
|
|
@@ -2171,7 +2230,7 @@ function useMarketSearch(options) {
|
|
|
2171
2230
|
}
|
|
2172
2231
|
|
|
2173
2232
|
// src/use-smart-route.ts
|
|
2174
|
-
import { keepPreviousData as keepPreviousData6, useQuery as
|
|
2233
|
+
import { keepPreviousData as keepPreviousData6, useQuery as useQuery8 } from "@tanstack/react-query";
|
|
2175
2234
|
|
|
2176
2235
|
// src/smart-route-refresh-policy.ts
|
|
2177
2236
|
var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
|
|
@@ -2258,8 +2317,10 @@ var assessThinSmartRouteLiquidity = (quote, nowMs = Date.now()) => {
|
|
|
2258
2317
|
};
|
|
2259
2318
|
};
|
|
2260
2319
|
var resolveSmartRouteRefetchInterval = (args, nowMs = Date.now()) => {
|
|
2320
|
+
var _a, _b;
|
|
2261
2321
|
const {
|
|
2262
2322
|
aggressiveIntervalMs = THIN_SMART_ROUTE_REFETCH_INTERVAL_MS,
|
|
2323
|
+
adaptive = true,
|
|
2263
2324
|
data,
|
|
2264
2325
|
defaultIntervalMs,
|
|
2265
2326
|
isDocumentVisible,
|
|
@@ -2275,6 +2336,18 @@ var resolveSmartRouteRefetchInterval = (args, nowMs = Date.now()) => {
|
|
|
2275
2336
|
if (!queryEnabled || !isInputValid || !isActivelyViewingQuote || !isMarketOpen || isSubmitting || !isDocumentVisible) {
|
|
2276
2337
|
return false;
|
|
2277
2338
|
}
|
|
2339
|
+
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";
|
|
2340
|
+
const deadlines = [
|
|
2341
|
+
data == null ? void 0 : data.quoteRefreshNotBefore,
|
|
2342
|
+
...primaryUsesProphetx ? [(_b = data == null ? void 0 : data.quoteFailure) == null ? void 0 : _b.retryAt] : []
|
|
2343
|
+
].filter((value) => !!value).map(Date.parse).filter((value) => Number.isFinite(value) && value > nowMs);
|
|
2344
|
+
if (deadlines.length) return Math.max(...deadlines) - nowMs;
|
|
2345
|
+
if (!adaptive)
|
|
2346
|
+
return clampIntervalToRefreshDeadline({
|
|
2347
|
+
intervalMs: defaultIntervalMs,
|
|
2348
|
+
refreshAt: void 0,
|
|
2349
|
+
nowMs
|
|
2350
|
+
});
|
|
2278
2351
|
const defaultInterval = clampIntervalToRefreshDeadline({
|
|
2279
2352
|
intervalMs: defaultIntervalMs,
|
|
2280
2353
|
refreshAt: data == null ? void 0 : data.refreshAt,
|
|
@@ -2321,7 +2394,7 @@ function useSmartRoute(options) {
|
|
|
2321
2394
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
2322
2395
|
const hasValidInput = (maxSpend != null ? maxSpend : 0) > 0 || (sellShares != null ? sellShares : 0) > 0;
|
|
2323
2396
|
const queryEnabled = enabled && !!resolvedVenueMarketOutcomeId && hasValidInput;
|
|
2324
|
-
const query =
|
|
2397
|
+
const query = useQuery8({
|
|
2325
2398
|
queryKey: [
|
|
2326
2399
|
"smart-route",
|
|
2327
2400
|
resolvedVenueMarketOutcomeId,
|
|
@@ -2361,7 +2434,8 @@ function useSmartRoute(options) {
|
|
|
2361
2434
|
return resolveSmartRouteRefetchInterval({
|
|
2362
2435
|
// SELL already fans out into one quote per venue. Keep that group on a
|
|
2363
2436
|
// stable cadence instead of multiplying the adaptive 5s/refreshAt poll.
|
|
2364
|
-
data:
|
|
2437
|
+
data: queryState.state.data,
|
|
2438
|
+
adaptive: tradeSide !== "sell",
|
|
2365
2439
|
defaultIntervalMs: staleTimeMs,
|
|
2366
2440
|
isDocumentVisible: getIsDocumentVisible(),
|
|
2367
2441
|
isEditing: (_a2 = refreshContext == null ? void 0 : refreshContext.isEditing) != null ? _a2 : false,
|
|
@@ -2402,7 +2476,7 @@ function useSmartRoute(options) {
|
|
|
2402
2476
|
}
|
|
2403
2477
|
|
|
2404
2478
|
// src/use-limit-order-venue-quotes.ts
|
|
2405
|
-
import { keepPreviousData as keepPreviousData7, useQueries as useQueries6, useQuery as
|
|
2479
|
+
import { keepPreviousData as keepPreviousData7, useQueries as useQueries6, useQuery as useQuery9 } from "@tanstack/react-query";
|
|
2406
2480
|
var getIsDocumentVisible2 = () => {
|
|
2407
2481
|
if (typeof document === "undefined") return true;
|
|
2408
2482
|
return document.visibilityState !== "hidden";
|
|
@@ -2457,7 +2531,7 @@ var useLimitOrderVenueQuotes = (options) => {
|
|
|
2457
2531
|
const hasRequiredAccount = tradeSide === "buy" || Boolean(accountId);
|
|
2458
2532
|
const queryEnabled = enabled && hasValidInput && hasRequiredAccount;
|
|
2459
2533
|
const serializedChainBalances = chainBalances ? JSON.stringify(chainBalances) : null;
|
|
2460
|
-
const tickMetadataQuery =
|
|
2534
|
+
const tickMetadataQuery = useQuery9({
|
|
2461
2535
|
queryKey: ["orderbooks", marketId != null ? marketId : "__disabled__", "limit-order-ticks"],
|
|
2462
2536
|
queryFn: ({ signal }) => client.getOrderbooks({ venueMarketIds: [marketId] }, { signal }),
|
|
2463
2537
|
enabled: enabled && Boolean(marketId),
|
|
@@ -2616,13 +2690,14 @@ var useVenueSellQuotes = (options) => {
|
|
|
2616
2690
|
}),
|
|
2617
2691
|
enabled: queryEnabled,
|
|
2618
2692
|
staleTime: staleTimeMs,
|
|
2619
|
-
refetchInterval: (
|
|
2693
|
+
refetchInterval: (queryState) => {
|
|
2620
2694
|
var _a2, _b2, _c, _d;
|
|
2621
2695
|
return resolveSmartRouteRefetchInterval({
|
|
2622
2696
|
// Venue quotes are display companions to the aggregate SELL quote.
|
|
2623
2697
|
// Poll them at the normal cadence rather than independently
|
|
2624
2698
|
// accelerating every venue to the thin-liquidity interval.
|
|
2625
|
-
data:
|
|
2699
|
+
data: queryState.state.data,
|
|
2700
|
+
adaptive: false,
|
|
2626
2701
|
defaultIntervalMs: staleTimeMs,
|
|
2627
2702
|
isDocumentVisible: getIsDocumentVisible3(),
|
|
2628
2703
|
isEditing: (_a2 = refreshContext == null ? void 0 : refreshContext.isEditing) != null ? _a2 : false,
|
|
@@ -2696,10 +2771,10 @@ function useUserHoldings(options) {
|
|
|
2696
2771
|
import { useMemo as useMemo10 } from "react";
|
|
2697
2772
|
|
|
2698
2773
|
// src/use-venue-event.ts
|
|
2699
|
-
import { useQuery as
|
|
2774
|
+
import { useQuery as useQuery11 } from "@tanstack/react-query";
|
|
2700
2775
|
|
|
2701
2776
|
// src/use-recurring-crypto-markets.ts
|
|
2702
|
-
import { useQuery as
|
|
2777
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
2703
2778
|
var RESOLVING_POLL_INTERVAL_MS = 15e3;
|
|
2704
2779
|
var FALLBACK_VENUE_EVENT_PAGE_LIMIT = 100;
|
|
2705
2780
|
var FALLBACK_VENUE_EVENT_MAX_PAGES = 5;
|
|
@@ -3193,7 +3268,7 @@ var useRecurringCryptoMarkets = ({
|
|
|
3193
3268
|
const client = useAggClient();
|
|
3194
3269
|
const identity = event ? resolveRecurringCryptoIdentity(event) : null;
|
|
3195
3270
|
const isEnabled = enabled && event != null && identity != null;
|
|
3196
|
-
const query =
|
|
3271
|
+
const query = useQuery10({
|
|
3197
3272
|
queryKey: [
|
|
3198
3273
|
"recurring-crypto-markets",
|
|
3199
3274
|
event == null ? void 0 : event.id,
|
|
@@ -3255,7 +3330,7 @@ function useVenueEvent(options) {
|
|
|
3255
3330
|
var _a;
|
|
3256
3331
|
const client = useAggClient();
|
|
3257
3332
|
const { eventId, enabled = true, cluster } = options;
|
|
3258
|
-
const query =
|
|
3333
|
+
const query = useQuery11({
|
|
3259
3334
|
queryKey: ["venue-event", eventId, cluster === false ? "no-cluster" : ""],
|
|
3260
3335
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
3261
3336
|
return client.getVenueEventById(eventId, { signal, cluster });
|
|
@@ -3561,7 +3636,7 @@ function useVenueEvents(options) {
|
|
|
3561
3636
|
}
|
|
3562
3637
|
|
|
3563
3638
|
// src/use-sports-live.ts
|
|
3564
|
-
import { useQuery as
|
|
3639
|
+
import { useQuery as useQuery12 } from "@tanstack/react-query";
|
|
3565
3640
|
var SPORTS_LIVE_POLL_INTERVAL_MS = 5e3;
|
|
3566
3641
|
var SPORTS_SCHEDULED_POLL_INTERVAL_MS = 3e4;
|
|
3567
3642
|
var sportsLiveQueryKey = (sortedEventIds) => ["sports-live", ...sortedEventIds];
|
|
@@ -3581,7 +3656,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
3581
3656
|
const sortedEventIds = [
|
|
3582
3657
|
...new Set(eventIds.map((eventId) => eventId.trim()).filter(Boolean))
|
|
3583
3658
|
].sort();
|
|
3584
|
-
const query =
|
|
3659
|
+
const query = useQuery12({
|
|
3585
3660
|
queryKey: sportsLiveQueryKey(sortedEventIds),
|
|
3586
3661
|
queryFn: ({ signal }) => client.getSportsLive(sortedEventIds, { signal }),
|
|
3587
3662
|
enabled: enabled && sortedEventIds.length > 0,
|
|
@@ -3601,7 +3676,7 @@ var useSportsLive = (eventIds, enabled = true) => {
|
|
|
3601
3676
|
};
|
|
3602
3677
|
|
|
3603
3678
|
// src/use-venue-market-midpoints.ts
|
|
3604
|
-
import { keepPreviousData as keepPreviousData9, useQuery as
|
|
3679
|
+
import { keepPreviousData as keepPreviousData9, useQuery as useQuery13 } from "@tanstack/react-query";
|
|
3605
3680
|
var normalizeVenueMarketIds2 = (venueMarketIds) => {
|
|
3606
3681
|
return [
|
|
3607
3682
|
...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
|
|
@@ -3640,7 +3715,7 @@ function useVenueMarketMidpoints(options) {
|
|
|
3640
3715
|
const enabled = (_a = options.enabled) != null ? _a : true;
|
|
3641
3716
|
const requestedVenueMarketIds = normalizeVenueMarketIds2(options.venueMarketIds);
|
|
3642
3717
|
const maxMidpointIdsPerRequest = (_b = options.maxMidpointIdsPerRequest) != null ? _b : configuredMaxMidpointIdsPerRequest;
|
|
3643
|
-
const query =
|
|
3718
|
+
const query = useQuery13({
|
|
3644
3719
|
queryKey: requestedVenueMarketIds.length ? ["venue-market-midpoints", requestedVenueMarketIds, maxMidpointIdsPerRequest] : ["venue-market-midpoints", "__disabled__"],
|
|
3645
3720
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
3646
3721
|
if (requestedVenueMarketIds.length === 0) {
|
|
@@ -3834,7 +3909,7 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
3834
3909
|
}
|
|
3835
3910
|
|
|
3836
3911
|
// src/use-visible-ids.ts
|
|
3837
|
-
import { useCallback as
|
|
3912
|
+
import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef7, useState as useState11 } from "react";
|
|
3838
3913
|
function useVisibleIds(options = {}) {
|
|
3839
3914
|
const { rootMargin = "0px", threshold = 0 } = options;
|
|
3840
3915
|
const [visibleIds, setVisibleIds] = useState11(() => /* @__PURE__ */ new Set());
|
|
@@ -3874,7 +3949,7 @@ function useVisibleIds(options = {}) {
|
|
|
3874
3949
|
observerRef.current = null;
|
|
3875
3950
|
};
|
|
3876
3951
|
}, [rootMargin, threshold]);
|
|
3877
|
-
const register =
|
|
3952
|
+
const register = useCallback7((id) => {
|
|
3878
3953
|
const existing = callbackRefsRef.current.get(id);
|
|
3879
3954
|
if (existing) return existing;
|
|
3880
3955
|
const callback = (el) => {
|
|
@@ -3906,48 +3981,49 @@ function useVisibleIds(options = {}) {
|
|
|
3906
3981
|
return { visibleIds, register };
|
|
3907
3982
|
}
|
|
3908
3983
|
|
|
3909
|
-
// src/use-
|
|
3910
|
-
import {
|
|
3911
|
-
var
|
|
3912
|
-
var
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
const query = useQuery13({
|
|
3929
|
-
queryKey: APP_CONFIG_QUERY_KEY,
|
|
3930
|
-
enabled: false,
|
|
3931
|
-
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
3932
|
-
staleTime: FIVE_MINUTES
|
|
3933
|
-
});
|
|
3934
|
-
return toAppConfigResult({
|
|
3935
|
-
data: query.data,
|
|
3936
|
-
isLoading: query.isLoading,
|
|
3937
|
-
error: query.error
|
|
3938
|
-
});
|
|
3939
|
-
}
|
|
3940
|
-
var toAppConfigResult = (query) => {
|
|
3941
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3942
|
-
return {
|
|
3943
|
-
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
3944
|
-
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
3945
|
-
earlyAccessEnabled: (_f = (_e = query.data) == null ? void 0 : _e.earlyAccessEnabled) != null ? _f : false,
|
|
3946
|
-
authOptions: (_h = (_g = query.data) == null ? void 0 : _g.authOptions) != null ? _h : [],
|
|
3947
|
-
isLoading: query.isLoading,
|
|
3948
|
-
error: query.error
|
|
3949
|
-
};
|
|
3984
|
+
// src/use-paper-onboarding.ts
|
|
3985
|
+
import { useCallback as useCallback8, useEffect as useEffect12, useState as useState12 } from "react";
|
|
3986
|
+
var STORAGE_KEY = "agg_paper_onboarding_seen";
|
|
3987
|
+
var isBrowser = () => typeof window !== "undefined" && "localStorage" in window;
|
|
3988
|
+
var seenKey = (userId) => `${STORAGE_KEY}:${userId}`;
|
|
3989
|
+
var hasSeen = (userId) => {
|
|
3990
|
+
if (!isBrowser()) return false;
|
|
3991
|
+
try {
|
|
3992
|
+
return window.localStorage.getItem(seenKey(userId)) === "1";
|
|
3993
|
+
} catch (e) {
|
|
3994
|
+
return true;
|
|
3995
|
+
}
|
|
3996
|
+
};
|
|
3997
|
+
var markSeen = (userId) => {
|
|
3998
|
+
if (!isBrowser()) return;
|
|
3999
|
+
try {
|
|
4000
|
+
window.localStorage.setItem(seenKey(userId), "1");
|
|
4001
|
+
} catch (e) {
|
|
4002
|
+
}
|
|
3950
4003
|
};
|
|
4004
|
+
function usePaperOnboarding() {
|
|
4005
|
+
const { isPaperMode, isResolving } = useResolvedExecutionMode();
|
|
4006
|
+
const { isAuthenticated, user } = useAggAuthContext();
|
|
4007
|
+
const userId = user == null ? void 0 : user.id;
|
|
4008
|
+
const [dismissed, setDismissed] = useState12(false);
|
|
4009
|
+
const [seen, setSeen] = useState12(null);
|
|
4010
|
+
useEffect12(() => {
|
|
4011
|
+
if (!userId) {
|
|
4012
|
+
setSeen(null);
|
|
4013
|
+
return;
|
|
4014
|
+
}
|
|
4015
|
+
setSeen(hasSeen(userId));
|
|
4016
|
+
}, [userId]);
|
|
4017
|
+
useEffect12(() => {
|
|
4018
|
+
setDismissed(false);
|
|
4019
|
+
}, [userId]);
|
|
4020
|
+
const dismiss = useCallback8(() => {
|
|
4021
|
+
setDismissed(true);
|
|
4022
|
+
if (userId) markSeen(userId);
|
|
4023
|
+
}, [userId]);
|
|
4024
|
+
const isOpen = isPaperMode && !isResolving && isAuthenticated && Boolean(userId) && seen === false && !dismissed;
|
|
4025
|
+
return { isOpen, dismiss };
|
|
4026
|
+
}
|
|
3951
4027
|
export {
|
|
3952
4028
|
AUTH_CHOOSER_OPEN_EVENT,
|
|
3953
4029
|
AggBalanceProvider,
|
|
@@ -3971,6 +4047,7 @@ export {
|
|
|
3971
4047
|
TradeSide,
|
|
3972
4048
|
TurnstileChallengeError,
|
|
3973
4049
|
Venue,
|
|
4050
|
+
appConfigQueryKey,
|
|
3974
4051
|
buildLiveBestPriceCandidates,
|
|
3975
4052
|
computeClosedPositionTotals,
|
|
3976
4053
|
computePriceGaps,
|
|
@@ -4012,6 +4089,7 @@ export {
|
|
|
4012
4089
|
resolveRecurringCryptoTimeline,
|
|
4013
4090
|
resolveRollingWindow,
|
|
4014
4091
|
resolveTradingStateKind,
|
|
4092
|
+
sharedKycQueryKeys,
|
|
4015
4093
|
sortVenues,
|
|
4016
4094
|
sportsLiveQueryKey,
|
|
4017
4095
|
sportsLiveRefetchInterval,
|
|
@@ -4072,9 +4150,10 @@ export {
|
|
|
4072
4150
|
useOrderBook,
|
|
4073
4151
|
useOrderbookQuote,
|
|
4074
4152
|
useOrders,
|
|
4153
|
+
usePaperOnboarding,
|
|
4075
4154
|
usePlaceLimitOrder,
|
|
4076
4155
|
usePositions,
|
|
4077
|
-
|
|
4156
|
+
useQueryClient2 as useQueryClient,
|
|
4078
4157
|
useRampQuotes,
|
|
4079
4158
|
useRampSession,
|
|
4080
4159
|
useRecurringCryptoMarkets,
|
|
@@ -4082,10 +4161,12 @@ export {
|
|
|
4082
4161
|
useRedeemEligibleCount,
|
|
4083
4162
|
useRedeemLifecycle,
|
|
4084
4163
|
useRedeemLifecycles,
|
|
4164
|
+
useResolvedExecutionMode,
|
|
4085
4165
|
useRollingChartWindow,
|
|
4086
4166
|
useSdkLabels,
|
|
4087
4167
|
useSdkUiConfig,
|
|
4088
4168
|
useSearch,
|
|
4169
|
+
useSharedKyc,
|
|
4089
4170
|
useSmartRoute,
|
|
4090
4171
|
useSportsLive,
|
|
4091
4172
|
useSyncBalances,
|