@agg-build/hooks 1.2.11 → 1.3.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-JWPZNCGY.mjs → chunk-KXO3JOXF.mjs} +1 -1
- package/dist/{chunk-CWEJLBYY.mjs → chunk-OBHXWQ6L.mjs} +1 -1
- package/dist/{chunk-553OI6M2.mjs → chunk-VLYLQSDD.mjs} +211 -59
- package/dist/deposit.js +125 -20
- package/dist/deposit.mjs +2 -2
- package/dist/index.d.mts +311 -58
- package/dist/index.d.ts +311 -58
- package/dist/index.js +592 -230
- package/dist/index.mjs +283 -81
- package/dist/withdraw.d.mts +3 -3
- package/dist/withdraw.d.ts +3 -3
- package/dist/withdraw.js +128 -23
- package/dist/withdraw.mjs +2 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useRampQuotes,
|
|
3
3
|
useRampSession
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KXO3JOXF.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useWithdrawEstimate,
|
|
7
7
|
useWithdrawFlow,
|
|
8
8
|
useWithdrawalLifecycle
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OBHXWQ6L.mjs";
|
|
10
10
|
import {
|
|
11
11
|
AggAuthContext,
|
|
12
12
|
AggBalanceProvider,
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
invalidateBalanceQueries,
|
|
44
44
|
invalidatePositionQueries,
|
|
45
45
|
invalidateUserActivityQueries,
|
|
46
|
+
invalidateUserClaimState,
|
|
46
47
|
invalidateUserMoneyState,
|
|
47
48
|
marketDataKeys,
|
|
48
49
|
marketOrderbookDataToResponse,
|
|
@@ -77,9 +78,11 @@ import {
|
|
|
77
78
|
useLabels,
|
|
78
79
|
useManagedBalances,
|
|
79
80
|
useOnBalanceUpdate,
|
|
81
|
+
useOnOrderEvent,
|
|
80
82
|
useOnOrderSubmitted,
|
|
81
83
|
useOnRedeemEvent,
|
|
82
84
|
useOnWithdrawalLifecycle,
|
|
85
|
+
useOptionalAggClient,
|
|
83
86
|
usePositions,
|
|
84
87
|
useQuoteManaged,
|
|
85
88
|
useRedeem,
|
|
@@ -91,10 +94,10 @@ import {
|
|
|
91
94
|
useSyncBalances,
|
|
92
95
|
useWithdrawManaged,
|
|
93
96
|
userActivityQueryKeys
|
|
94
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-VLYLQSDD.mjs";
|
|
95
98
|
|
|
96
99
|
// src/index.ts
|
|
97
|
-
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as
|
|
100
|
+
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
98
101
|
import { TurnstileChallengeError } from "@agg-build/sdk";
|
|
99
102
|
|
|
100
103
|
// src/use-geo-block.ts
|
|
@@ -117,6 +120,32 @@ function useGeoBlock() {
|
|
|
117
120
|
};
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
// src/venue-availability.ts
|
|
124
|
+
var normalizeVenueId = (venueId) => venueId.trim().toLowerCase();
|
|
125
|
+
var getDisabledVenueSet = (disabledVenues) => {
|
|
126
|
+
return new Set((disabledVenues != null ? disabledVenues : []).map(normalizeVenueId));
|
|
127
|
+
};
|
|
128
|
+
var isVenueDisabledByConfig = (venueId, disabledVenues) => {
|
|
129
|
+
return getDisabledVenueSet(disabledVenues).has(normalizeVenueId(venueId));
|
|
130
|
+
};
|
|
131
|
+
var getVisibleVenuesByConfig = (venues, disabledVenues) => {
|
|
132
|
+
const disabledVenueSet = getDisabledVenueSet(disabledVenues);
|
|
133
|
+
return venues.filter((venue) => !disabledVenueSet.has(normalizeVenueId(venue.id)));
|
|
134
|
+
};
|
|
135
|
+
var getVisibleVenueIdsByConfig = (venueIds, disabledVenues) => {
|
|
136
|
+
const disabledVenueSet = getDisabledVenueSet(disabledVenues);
|
|
137
|
+
return venueIds.filter((venueId) => !disabledVenueSet.has(normalizeVenueId(venueId)));
|
|
138
|
+
};
|
|
139
|
+
var getVenueAvailabilityState = ({
|
|
140
|
+
venueId,
|
|
141
|
+
disabledVenues,
|
|
142
|
+
isLocationBlocked
|
|
143
|
+
}) => {
|
|
144
|
+
if (isVenueDisabledByConfig(venueId, disabledVenues)) return "hidden";
|
|
145
|
+
if (isLocationBlocked) return "geoblocked";
|
|
146
|
+
return "available";
|
|
147
|
+
};
|
|
148
|
+
|
|
120
149
|
// src/use-agg-auth.ts
|
|
121
150
|
import { useCallback } from "react";
|
|
122
151
|
function useAggAuth(options = {}) {
|
|
@@ -185,19 +214,21 @@ var requestAggAuthChooserOpen = () => {
|
|
|
185
214
|
};
|
|
186
215
|
|
|
187
216
|
// src/use-categories.ts
|
|
188
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
217
|
+
import { useInfiniteQuery, useQueries } from "@tanstack/react-query";
|
|
189
218
|
function useCategories(options) {
|
|
190
|
-
var _a, _b, _c, _d;
|
|
219
|
+
var _a, _b, _c, _d, _e, _f;
|
|
191
220
|
const client = useAggClient();
|
|
192
|
-
const
|
|
193
|
-
const
|
|
221
|
+
const queryKeyScope = (_a = options == null ? void 0 : options.queryKeyScope) != null ? _a : "categories";
|
|
222
|
+
const parentId = (_b = options == null ? void 0 : options.parentId) != null ? _b : null;
|
|
223
|
+
const enabled = (_c = options == null ? void 0 : options.enabled) != null ? _c : true;
|
|
224
|
+
const limit = (_d = options == null ? void 0 : options.limit) != null ? _d : 20;
|
|
194
225
|
const query = useInfiniteQuery({
|
|
195
|
-
queryKey: ["
|
|
226
|
+
queryKey: [queryKeyScope, "parent", parentId != null ? parentId : "__root__", limit],
|
|
196
227
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
197
|
-
const res = yield client.getCategories({
|
|
228
|
+
const res = yield client.getCategories(__spreadValues({
|
|
198
229
|
limit,
|
|
199
230
|
cursor: pageParam
|
|
200
|
-
});
|
|
231
|
+
}, parentId != null ? { parentId } : {}));
|
|
201
232
|
return res;
|
|
202
233
|
}),
|
|
203
234
|
initialPageParam: void 0,
|
|
@@ -207,13 +238,48 @@ function useCategories(options) {
|
|
|
207
238
|
},
|
|
208
239
|
enabled
|
|
209
240
|
});
|
|
210
|
-
const categories = (
|
|
241
|
+
const categories = (_f = (_e = query.data) == null ? void 0 : _e.pages.flatMap((p) => p.data)) != null ? _f : [];
|
|
211
242
|
const hasNextPage = !!query.hasNextPage;
|
|
212
243
|
return __spreadProps(__spreadValues({}, query), {
|
|
213
244
|
categories,
|
|
214
245
|
hasNextPage
|
|
215
246
|
});
|
|
216
247
|
}
|
|
248
|
+
function useCategoryChildren(options) {
|
|
249
|
+
var _a, _b, _c, _d;
|
|
250
|
+
const client = useAggClient();
|
|
251
|
+
const queryKeyScope = (_a = options == null ? void 0 : options.queryKeyScope) != null ? _a : "category-children";
|
|
252
|
+
const enabled = (_b = options == null ? void 0 : options.enabled) != null ? _b : true;
|
|
253
|
+
const limit = (_c = options == null ? void 0 : options.limit) != null ? _c : 20;
|
|
254
|
+
const parentIds = Array.from(
|
|
255
|
+
new Set(((_d = options == null ? void 0 : options.parentIds) != null ? _d : []).filter((parentId) => Boolean(parentId)))
|
|
256
|
+
);
|
|
257
|
+
const queries = useQueries({
|
|
258
|
+
queries: parentIds.map((parentId) => ({
|
|
259
|
+
queryKey: [queryKeyScope, "parent", parentId, limit],
|
|
260
|
+
queryFn: () => __async(null, null, function* () {
|
|
261
|
+
return client.getCategories({
|
|
262
|
+
limit,
|
|
263
|
+
cursor: void 0,
|
|
264
|
+
parentId
|
|
265
|
+
});
|
|
266
|
+
}),
|
|
267
|
+
enabled
|
|
268
|
+
}))
|
|
269
|
+
});
|
|
270
|
+
const childrenByParentId = /* @__PURE__ */ new Map();
|
|
271
|
+
queries.forEach((query, index) => {
|
|
272
|
+
var _a2, _b2;
|
|
273
|
+
const parentId = parentIds[index];
|
|
274
|
+
if (!parentId) return;
|
|
275
|
+
childrenByParentId.set(parentId, (_b2 = (_a2 = query.data) == null ? void 0 : _a2.data) != null ? _b2 : []);
|
|
276
|
+
});
|
|
277
|
+
return {
|
|
278
|
+
queries,
|
|
279
|
+
childrenByParentId,
|
|
280
|
+
isLoading: queries.some((query) => query.isLoading)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
217
283
|
|
|
218
284
|
// src/use-debounced-value.ts
|
|
219
285
|
import { useEffect, useState as useState2 } from "react";
|
|
@@ -239,6 +305,7 @@ function useExecutionOrders(options = {}) {
|
|
|
239
305
|
status,
|
|
240
306
|
orderId,
|
|
241
307
|
quoteId,
|
|
308
|
+
mode,
|
|
242
309
|
limit = 50,
|
|
243
310
|
enabled = true,
|
|
244
311
|
refetchIntervalMs = false
|
|
@@ -246,14 +313,22 @@ function useExecutionOrders(options = {}) {
|
|
|
246
313
|
const query = useInfiniteQuery2({
|
|
247
314
|
// quoteId + orderId are part of the cache key — different filters
|
|
248
315
|
// produce different result sets, so they have to vary the key.
|
|
249
|
-
queryKey: [
|
|
250
|
-
|
|
316
|
+
queryKey: [
|
|
317
|
+
"execution-orders",
|
|
318
|
+
status != null ? status : "all",
|
|
319
|
+
quoteId != null ? quoteId : null,
|
|
320
|
+
orderId != null ? orderId : null,
|
|
321
|
+
...mode ? [mode] : [],
|
|
322
|
+
limit
|
|
323
|
+
],
|
|
324
|
+
queryFn: ({ pageParam }) => client.getExecutionOrders(__spreadProps(__spreadValues({
|
|
251
325
|
status,
|
|
252
326
|
orderId,
|
|
253
|
-
quoteId
|
|
327
|
+
quoteId
|
|
328
|
+
}, mode ? { mode } : {}), {
|
|
254
329
|
limit,
|
|
255
330
|
cursor: pageParam
|
|
256
|
-
}),
|
|
331
|
+
})),
|
|
257
332
|
initialPageParam: void 0,
|
|
258
333
|
getNextPageParam: (lastPage) => {
|
|
259
334
|
var _a2;
|
|
@@ -288,6 +363,9 @@ var hasPendingActivity = (pages) => {
|
|
|
288
363
|
if (!pages) return false;
|
|
289
364
|
for (const page of pages) {
|
|
290
365
|
for (const item of page.data) {
|
|
366
|
+
if (item.type === "redeem" && item.legs.length > 0 && item.legs.every((leg) => leg.status.toLowerCase() === "confirmed")) {
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
291
369
|
if (PENDING_ACTIVITY_STATUSES.has(item.status.toLowerCase())) return true;
|
|
292
370
|
}
|
|
293
371
|
}
|
|
@@ -303,7 +381,7 @@ function useUserActivity(options = {}) {
|
|
|
303
381
|
pendingRefetchIntervalMs = DEFAULT_PENDING_REFETCH_INTERVAL_MS
|
|
304
382
|
} = options;
|
|
305
383
|
const query = useInfiniteQuery3({
|
|
306
|
-
queryKey:
|
|
384
|
+
queryKey: userActivityQueryKeys.feed(type, limit),
|
|
307
385
|
queryFn: ({ pageParam }) => client.getUserActivity({
|
|
308
386
|
type,
|
|
309
387
|
limit,
|
|
@@ -368,14 +446,15 @@ import { useInfiniteQuery as useInfiniteQuery4 } from "@tanstack/react-query";
|
|
|
368
446
|
function useExecutionPositions(options = {}) {
|
|
369
447
|
var _a, _b;
|
|
370
448
|
const client = useAggClient();
|
|
371
|
-
const { limit = 50, status, enabled = true } = options;
|
|
449
|
+
const { limit = 50, status, mode, enabled = true } = options;
|
|
372
450
|
const query = useInfiniteQuery4({
|
|
373
|
-
queryKey: executionKeys.positions(null, limit, status != null ? status : null),
|
|
374
|
-
queryFn: ({ pageParam }) => client.getExecutionPositions({
|
|
451
|
+
queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
|
|
452
|
+
queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
|
|
375
453
|
limit,
|
|
376
|
-
status
|
|
454
|
+
status
|
|
455
|
+
}, mode ? { mode } : {}), {
|
|
377
456
|
cursor: pageParam
|
|
378
|
-
}),
|
|
457
|
+
})),
|
|
379
458
|
initialPageParam: void 0,
|
|
380
459
|
getNextPageParam: (lastPage) => {
|
|
381
460
|
var _a2;
|
|
@@ -399,7 +478,7 @@ import { useMemo as useMemo3 } from "react";
|
|
|
399
478
|
import { mergeCandles, mergeClosedCandles } from "@agg-build/sdk";
|
|
400
479
|
|
|
401
480
|
// src/use-market-chart.ts
|
|
402
|
-
import { keepPreviousData as keepPreviousData2, useQueries } from "@tanstack/react-query";
|
|
481
|
+
import { keepPreviousData as keepPreviousData2, useQueries as useQueries2 } from "@tanstack/react-query";
|
|
403
482
|
|
|
404
483
|
// src/market-data/subscription.ts
|
|
405
484
|
import { useEffect as useEffect2, useMemo } from "react";
|
|
@@ -484,7 +563,7 @@ function useMarketChart(options) {
|
|
|
484
563
|
orderbook: true,
|
|
485
564
|
trades: true
|
|
486
565
|
});
|
|
487
|
-
const queries =
|
|
566
|
+
const queries = useQueries2({
|
|
488
567
|
queries: outcomeIds.map((outcomeId) => ({
|
|
489
568
|
// Cache key is intentionally time-free. The rolling window's
|
|
490
569
|
// startTs/endTs advance on every bucket but the user expects the same
|
|
@@ -845,7 +924,7 @@ function useLiveMarket(canonicalMarketId) {
|
|
|
845
924
|
|
|
846
925
|
// src/use-live-outcome-prices.ts
|
|
847
926
|
import { useMemo as useMemo6, useRef as useRef2 } from "react";
|
|
848
|
-
import { useQueries as
|
|
927
|
+
import { useQueries as useQueries3 } from "@tanstack/react-query";
|
|
849
928
|
var EMPTY_PRICES = /* @__PURE__ */ new Map();
|
|
850
929
|
var buildMidpointFingerprint = (outcomeIds, queries) => {
|
|
851
930
|
var _a, _b, _c;
|
|
@@ -871,7 +950,7 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
871
950
|
}
|
|
872
951
|
return [...ids].sort();
|
|
873
952
|
}, [venueMarkets]);
|
|
874
|
-
const queries =
|
|
953
|
+
const queries = useQueries3({
|
|
875
954
|
queries: outcomeIds.map((id) => ({
|
|
876
955
|
queryKey: marketDataKeys.live(id),
|
|
877
956
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -921,7 +1000,7 @@ function findLivePriceById(livePrices, id) {
|
|
|
921
1000
|
|
|
922
1001
|
// src/use-live-best-prices.ts
|
|
923
1002
|
import { useMemo as useMemo7, useRef as useRef3 } from "react";
|
|
924
|
-
import { useQueries as
|
|
1003
|
+
import { useQueries as useQueries4 } from "@tanstack/react-query";
|
|
925
1004
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
926
1005
|
var extractOutcomeBestPrices = (state) => {
|
|
927
1006
|
var _a, _b;
|
|
@@ -963,7 +1042,7 @@ function useLiveBestPrices(venueMarkets) {
|
|
|
963
1042
|
}
|
|
964
1043
|
return [...ids].sort();
|
|
965
1044
|
}, [venueMarkets]);
|
|
966
|
-
const queries =
|
|
1045
|
+
const queries = useQueries4({
|
|
967
1046
|
queries: outcomeIds.map((id) => ({
|
|
968
1047
|
queryKey: marketDataKeys.live(id),
|
|
969
1048
|
queryFn: () => createMarketLiveState(id),
|
|
@@ -1350,7 +1429,7 @@ var useRollingChartWindow = (options) => {
|
|
|
1350
1429
|
};
|
|
1351
1430
|
|
|
1352
1431
|
// src/use-market-orderbook.ts
|
|
1353
|
-
import { useQueries as
|
|
1432
|
+
import { useQueries as useQueries5, useQueryClient } from "@tanstack/react-query";
|
|
1354
1433
|
function useMarketOrderbook(options) {
|
|
1355
1434
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1356
1435
|
const queryClient = useQueryClient();
|
|
@@ -1370,7 +1449,7 @@ function useMarketOrderbook(options) {
|
|
|
1370
1449
|
enabled: enabled && !!selectedOutcomeId,
|
|
1371
1450
|
orderbook: true
|
|
1372
1451
|
});
|
|
1373
|
-
const liveQueries =
|
|
1452
|
+
const liveQueries = useQueries5({
|
|
1374
1453
|
queries: subscriptionIds.map((subscriptionId) => ({
|
|
1375
1454
|
queryKey: marketDataKeys.live(subscriptionId),
|
|
1376
1455
|
queryFn: () => createMarketLiveState(subscriptionId),
|
|
@@ -1435,6 +1514,64 @@ function useMarketOrderbook(options) {
|
|
|
1435
1514
|
};
|
|
1436
1515
|
}
|
|
1437
1516
|
|
|
1517
|
+
// src/use-arb.ts
|
|
1518
|
+
import { useEffect as useEffect6, useRef as useRef4, useState as useState5 } from "react";
|
|
1519
|
+
function useMarketArb(marketId) {
|
|
1520
|
+
const ws = useAggWebSocket();
|
|
1521
|
+
const [state, setState] = useState5({ arbReturn: null, isLive: false });
|
|
1522
|
+
useEffect6(() => {
|
|
1523
|
+
if (!ws || !marketId) return;
|
|
1524
|
+
const cached = ws.getArb(marketId);
|
|
1525
|
+
if (cached != null) {
|
|
1526
|
+
setState({ arbReturn: cached.arbReturn, isLive: true });
|
|
1527
|
+
}
|
|
1528
|
+
const off = ws.subscribeArb(marketId, (msg) => {
|
|
1529
|
+
setState({ arbReturn: msg.arbReturn, isLive: true });
|
|
1530
|
+
});
|
|
1531
|
+
return off;
|
|
1532
|
+
}, [ws, marketId]);
|
|
1533
|
+
return state;
|
|
1534
|
+
}
|
|
1535
|
+
var EMPTY_ARB_FEED = {
|
|
1536
|
+
byMarket: /* @__PURE__ */ new Map(),
|
|
1537
|
+
byEvent: /* @__PURE__ */ new Map()
|
|
1538
|
+
};
|
|
1539
|
+
function useArbFeed() {
|
|
1540
|
+
const ws = useAggWebSocket();
|
|
1541
|
+
const [state, setState] = useState5(EMPTY_ARB_FEED);
|
|
1542
|
+
const stateRef = useRef4(state);
|
|
1543
|
+
stateRef.current = state;
|
|
1544
|
+
useEffect6(() => {
|
|
1545
|
+
if (!ws) return;
|
|
1546
|
+
const off = ws.subscribeArbFeed((batch) => {
|
|
1547
|
+
setState((prev) => {
|
|
1548
|
+
const nextByMarket = new Map(prev.byMarket);
|
|
1549
|
+
for (const entry of batch.entries) {
|
|
1550
|
+
nextByMarket.set(entry.marketId, {
|
|
1551
|
+
arb: entry.arbReturn,
|
|
1552
|
+
eventId: entry.venueEventId
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
const nextByEvent = /* @__PURE__ */ new Map();
|
|
1556
|
+
for (const { arb, eventId } of nextByMarket.values()) {
|
|
1557
|
+
if (eventId == null) continue;
|
|
1558
|
+
const current = nextByEvent.get(eventId);
|
|
1559
|
+
if (current == null || arb > current) {
|
|
1560
|
+
nextByEvent.set(eventId, arb);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return { byMarket: nextByMarket, byEvent: nextByEvent };
|
|
1564
|
+
});
|
|
1565
|
+
});
|
|
1566
|
+
return off;
|
|
1567
|
+
}, [ws]);
|
|
1568
|
+
const publicByMarket = /* @__PURE__ */ new Map();
|
|
1569
|
+
for (const [marketId, { arb }] of state.byMarket) {
|
|
1570
|
+
publicByMarket.set(marketId, arb);
|
|
1571
|
+
}
|
|
1572
|
+
return { byMarket: publicByMarket, byEvent: state.byEvent };
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1438
1575
|
// src/use-order-book.ts
|
|
1439
1576
|
import { keepPreviousData as keepPreviousData3, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
1440
1577
|
function useOrderBook(options) {
|
|
@@ -1649,15 +1786,15 @@ import {
|
|
|
1649
1786
|
keepPreviousData as keepPreviousData5,
|
|
1650
1787
|
useInfiniteQuery as useInfiniteQuery5
|
|
1651
1788
|
} from "@tanstack/react-query";
|
|
1652
|
-
import { useContext as useContext2, useEffect as
|
|
1789
|
+
import { useContext as useContext2, useEffect as useEffect7, useState as useState6 } from "react";
|
|
1653
1790
|
function useSearch(options) {
|
|
1654
1791
|
var _a, _b, _c;
|
|
1655
1792
|
const client = useContext2(AggClientContext);
|
|
1656
1793
|
const queryClient = useContext2(QueryClientContext);
|
|
1657
|
-
const [fallbackQueryClient] =
|
|
1794
|
+
const [fallbackQueryClient] = useState6(() => new QueryClient());
|
|
1658
1795
|
const { q, type, categoryIds, limit = 20, enabled = true, deep = false } = options;
|
|
1659
1796
|
const isEnabled = enabled && q.length > 0;
|
|
1660
|
-
|
|
1797
|
+
useEffect7(() => {
|
|
1661
1798
|
if (queryClient) return void 0;
|
|
1662
1799
|
fallbackQueryClient.mount();
|
|
1663
1800
|
return () => {
|
|
@@ -1711,7 +1848,7 @@ function useSearch(options) {
|
|
|
1711
1848
|
}
|
|
1712
1849
|
|
|
1713
1850
|
// src/use-market-search.ts
|
|
1714
|
-
import { useCallback as useCallback5, useState as
|
|
1851
|
+
import { useCallback as useCallback5, useState as useState7 } from "react";
|
|
1715
1852
|
function useMarketSearch(options) {
|
|
1716
1853
|
var _a;
|
|
1717
1854
|
const {
|
|
@@ -1722,8 +1859,8 @@ function useMarketSearch(options) {
|
|
|
1722
1859
|
enableSuggestions = true,
|
|
1723
1860
|
minLength = 1
|
|
1724
1861
|
} = options;
|
|
1725
|
-
const [query, setQueryState] =
|
|
1726
|
-
const [submittedQuery, setSubmittedQuery] =
|
|
1862
|
+
const [query, setQueryState] = useState7("");
|
|
1863
|
+
const [submittedQuery, setSubmittedQuery] = useState7(null);
|
|
1727
1864
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
1728
1865
|
const trimmedDebounced = debouncedQuery.trim();
|
|
1729
1866
|
const suggestionsEnabled = enableSuggestions && trimmedDebounced.length >= minLength;
|
|
@@ -1808,6 +1945,7 @@ function useSmartRoute(options) {
|
|
|
1808
1945
|
outcomeId,
|
|
1809
1946
|
side,
|
|
1810
1947
|
tradeSide,
|
|
1948
|
+
mode,
|
|
1811
1949
|
maxSpend,
|
|
1812
1950
|
sellShares,
|
|
1813
1951
|
chainBalances,
|
|
@@ -1824,6 +1962,7 @@ function useSmartRoute(options) {
|
|
|
1824
1962
|
resolvedVenueMarketOutcomeId,
|
|
1825
1963
|
side != null ? side : null,
|
|
1826
1964
|
tradeSide != null ? tradeSide : null,
|
|
1965
|
+
...mode ? [mode] : [],
|
|
1827
1966
|
maxSpend != null ? maxSpend : null,
|
|
1828
1967
|
sellShares != null ? sellShares : null,
|
|
1829
1968
|
chainBalances ? JSON.stringify(chainBalances) : null,
|
|
@@ -1833,17 +1972,18 @@ function useSmartRoute(options) {
|
|
|
1833
1972
|
],
|
|
1834
1973
|
queryFn: (_0) => __async(null, [_0], function* ({ signal }) {
|
|
1835
1974
|
return client.getSmartRoute(
|
|
1836
|
-
{
|
|
1975
|
+
__spreadProps(__spreadValues({
|
|
1837
1976
|
venueMarketOutcomeId: resolvedVenueMarketOutcomeId,
|
|
1838
1977
|
side: side != null ? side : void 0,
|
|
1839
|
-
tradeSide: tradeSide != null ? tradeSide : void 0
|
|
1978
|
+
tradeSide: tradeSide != null ? tradeSide : void 0
|
|
1979
|
+
}, mode ? { mode } : {}), {
|
|
1840
1980
|
maxSpend,
|
|
1841
1981
|
sellShares,
|
|
1842
1982
|
chainBalances,
|
|
1843
1983
|
slipCapBps,
|
|
1844
1984
|
compareVenues,
|
|
1845
1985
|
deepEstimate
|
|
1846
|
-
},
|
|
1986
|
+
}),
|
|
1847
1987
|
{ signal }
|
|
1848
1988
|
);
|
|
1849
1989
|
}),
|
|
@@ -1925,12 +2065,12 @@ function useVenueEvent(options) {
|
|
|
1925
2065
|
|
|
1926
2066
|
// src/use-venue-markets.ts
|
|
1927
2067
|
import { QueryClient as QueryClient2, QueryClientContext as QueryClientContext2, useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
|
|
1928
|
-
import { useContext as useContext3, useEffect as
|
|
2068
|
+
import { useContext as useContext3, useEffect as useEffect8, useState as useState8 } from "react";
|
|
1929
2069
|
function useVenueMarkets(options) {
|
|
1930
2070
|
var _a, _b, _c, _d, _e;
|
|
1931
2071
|
const client = useContext3(AggClientContext);
|
|
1932
2072
|
const queryClient = useContext3(QueryClientContext2);
|
|
1933
|
-
const [fallbackQueryClient] =
|
|
2073
|
+
const [fallbackQueryClient] = useState8(() => new QueryClient2());
|
|
1934
2074
|
const venue = options == null ? void 0 : options.venue;
|
|
1935
2075
|
const venueEventId = options == null ? void 0 : options.venueEventId;
|
|
1936
2076
|
const search = options == null ? void 0 : options.search;
|
|
@@ -1941,7 +2081,7 @@ function useVenueMarkets(options) {
|
|
|
1941
2081
|
const limit = (_b = options == null ? void 0 : options.limit) != null ? _b : 20;
|
|
1942
2082
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
1943
2083
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
1944
|
-
|
|
2084
|
+
useEffect8(() => {
|
|
1945
2085
|
if (queryClient) return void 0;
|
|
1946
2086
|
fallbackQueryClient.mount();
|
|
1947
2087
|
return () => {
|
|
@@ -2041,12 +2181,12 @@ import {
|
|
|
2041
2181
|
keepPreviousData as keepPreviousData7,
|
|
2042
2182
|
useInfiniteQuery as useInfiniteQuery8
|
|
2043
2183
|
} from "@tanstack/react-query";
|
|
2044
|
-
import { useContext as useContext4, useEffect as
|
|
2184
|
+
import { useContext as useContext4, useEffect as useEffect9, useMemo as useMemo12, useRef as useRef5, useState as useState9 } from "react";
|
|
2045
2185
|
function useVenueEvents(options) {
|
|
2046
2186
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2047
2187
|
const client = useContext4(AggClientContext);
|
|
2048
2188
|
const queryClient = useContext4(QueryClientContext3);
|
|
2049
|
-
const [fallbackQueryClient] =
|
|
2189
|
+
const [fallbackQueryClient] = useState9(() => new QueryClient3());
|
|
2050
2190
|
const venues = options == null ? void 0 : options.venues;
|
|
2051
2191
|
const search = options == null ? void 0 : options.search;
|
|
2052
2192
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
@@ -2056,12 +2196,13 @@ function useVenueEvents(options) {
|
|
|
2056
2196
|
const status = options == null ? void 0 : options.status;
|
|
2057
2197
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
2058
2198
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
2199
|
+
const recurrence = options == null ? void 0 : options.recurrence;
|
|
2059
2200
|
const queryKeyScope = (_d = options == null ? void 0 : options.queryKeyScope) != null ? _d : "events";
|
|
2060
2201
|
const minYesPrice = options == null ? void 0 : options.minYesPrice;
|
|
2061
2202
|
const maxYesPrice = options == null ? void 0 : options.maxYesPrice;
|
|
2062
2203
|
const endDateFrom = options == null ? void 0 : options.endDateFrom;
|
|
2063
2204
|
const initialPages = options == null ? void 0 : options.initialPages;
|
|
2064
|
-
|
|
2205
|
+
useEffect9(() => {
|
|
2065
2206
|
if (queryClient) return void 0;
|
|
2066
2207
|
fallbackQueryClient.mount();
|
|
2067
2208
|
return () => {
|
|
@@ -2082,6 +2223,7 @@ function useVenueEvents(options) {
|
|
|
2082
2223
|
(_g = status == null ? void 0 : status.join(",")) != null ? _g : "",
|
|
2083
2224
|
sortBy != null ? sortBy : "",
|
|
2084
2225
|
sortDir != null ? sortDir : "",
|
|
2226
|
+
recurrence != null ? recurrence : "",
|
|
2085
2227
|
minYesPrice != null ? minYesPrice : "",
|
|
2086
2228
|
maxYesPrice != null ? maxYesPrice : "",
|
|
2087
2229
|
endDateFrom != null ? endDateFrom : "",
|
|
@@ -2099,6 +2241,7 @@ function useVenueEvents(options) {
|
|
|
2099
2241
|
status,
|
|
2100
2242
|
sortBy,
|
|
2101
2243
|
sortDir,
|
|
2244
|
+
recurrence,
|
|
2102
2245
|
limit,
|
|
2103
2246
|
minYesPrice,
|
|
2104
2247
|
maxYesPrice,
|
|
@@ -2119,8 +2262,8 @@ function useVenueEvents(options) {
|
|
|
2119
2262
|
},
|
|
2120
2263
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
2121
2264
|
);
|
|
2122
|
-
const prefetchedRef =
|
|
2123
|
-
|
|
2265
|
+
const prefetchedRef = useRef5(false);
|
|
2266
|
+
useEffect9(() => {
|
|
2124
2267
|
var _a2, _b2;
|
|
2125
2268
|
if (prefetchedRef.current) return;
|
|
2126
2269
|
if (!initialPages || initialPages <= 1) return;
|
|
@@ -2224,29 +2367,52 @@ function useVenueMarketMidpoints(options) {
|
|
|
2224
2367
|
|
|
2225
2368
|
// src/utils/compute-price-gaps.ts
|
|
2226
2369
|
var MIN_PRICE_GAP_PCT = 3;
|
|
2227
|
-
|
|
2370
|
+
var MAX_PRICE_GAP_PCT = 50;
|
|
2371
|
+
var normalizeMidpoint = (value) => {
|
|
2372
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
2373
|
+
if (value <= 0) return void 0;
|
|
2374
|
+
if (value > 1) return void 0;
|
|
2375
|
+
return value;
|
|
2376
|
+
};
|
|
2377
|
+
var collectMarketMidpoints = (market, midpointsByVenueMarketId) => {
|
|
2228
2378
|
var _a;
|
|
2229
|
-
const
|
|
2230
|
-
const
|
|
2379
|
+
const midpoints = [];
|
|
2380
|
+
const marketMidpoint = normalizeMidpoint(midpointsByVenueMarketId.get(market.id));
|
|
2381
|
+
if (marketMidpoint != null) {
|
|
2382
|
+
midpoints.push(marketMidpoint);
|
|
2383
|
+
}
|
|
2384
|
+
for (const matchedMarket of (_a = market.matchedVenueMarkets) != null ? _a : []) {
|
|
2385
|
+
const matchedMidpoint = normalizeMidpoint(midpointsByVenueMarketId.get(matchedMarket.id));
|
|
2386
|
+
if (matchedMidpoint == null) continue;
|
|
2387
|
+
midpoints.push(matchedMidpoint);
|
|
2388
|
+
}
|
|
2389
|
+
return midpoints;
|
|
2390
|
+
};
|
|
2391
|
+
var computePriceGapPct = (midpoints) => {
|
|
2392
|
+
if (midpoints.length < 2) return void 0;
|
|
2393
|
+
const minMidpoint = Math.min(...midpoints);
|
|
2394
|
+
const maxMidpoint = Math.max(...midpoints);
|
|
2395
|
+
if (minMidpoint <= 0 || maxMidpoint <= minMidpoint) return void 0;
|
|
2396
|
+
const gapPct = (maxMidpoint - minMidpoint) * 100;
|
|
2397
|
+
if (gapPct < MIN_PRICE_GAP_PCT) return void 0;
|
|
2398
|
+
if (gapPct > MAX_PRICE_GAP_PCT) return void 0;
|
|
2399
|
+
return gapPct;
|
|
2400
|
+
};
|
|
2401
|
+
var computePriceGaps = ({
|
|
2402
|
+
markets,
|
|
2403
|
+
midpointsByVenueMarketId
|
|
2404
|
+
}) => {
|
|
2405
|
+
const gapsByVenueMarketId = /* @__PURE__ */ new Map();
|
|
2231
2406
|
for (const market of markets) {
|
|
2232
|
-
const
|
|
2233
|
-
if (
|
|
2234
|
-
|
|
2235
|
-
if (siblings.length === 0) continue;
|
|
2236
|
-
let maxGap = 0;
|
|
2237
|
-
for (const sibling of siblings) {
|
|
2238
|
-
const siblingMidpoint = midpointsByVenueMarketId.get(sibling.id);
|
|
2239
|
-
if (siblingMidpoint == null || siblingMidpoint <= 0) continue;
|
|
2240
|
-
const gap = Math.abs(ownMidpoint - siblingMidpoint) / ownMidpoint * 100;
|
|
2241
|
-
if (gap > maxGap) maxGap = gap;
|
|
2242
|
-
}
|
|
2243
|
-
if (maxGap >= MIN_PRICE_GAP_PCT) result.set(market.id, maxGap);
|
|
2407
|
+
const gapPct = computePriceGapPct(collectMarketMidpoints(market, midpointsByVenueMarketId));
|
|
2408
|
+
if (gapPct == null) continue;
|
|
2409
|
+
gapsByVenueMarketId.set(market.id, gapPct);
|
|
2244
2410
|
}
|
|
2245
|
-
return
|
|
2246
|
-
}
|
|
2411
|
+
return gapsByVenueMarketId;
|
|
2412
|
+
};
|
|
2247
2413
|
|
|
2248
2414
|
// src/use-viewport-midpoints.ts
|
|
2249
|
-
import { useEffect as
|
|
2415
|
+
import { useEffect as useEffect10, useMemo as useMemo13, useRef as useRef6, useState as useState10 } from "react";
|
|
2250
2416
|
var buildOutcomeMidpointMap = (outcomes) => {
|
|
2251
2417
|
const m = /* @__PURE__ */ new Map();
|
|
2252
2418
|
if (!outcomes) return m;
|
|
@@ -2294,15 +2460,15 @@ var buildCachedMidpointEntries = (requestedVenueMarketIds, rows) => {
|
|
|
2294
2460
|
};
|
|
2295
2461
|
function useViewportMidpoints(visibleMarkets) {
|
|
2296
2462
|
const client = useAggClient();
|
|
2297
|
-
const [cache, setCache] =
|
|
2298
|
-
const inFlightRef =
|
|
2299
|
-
const visibleRef =
|
|
2463
|
+
const [cache, setCache] = useState10(() => /* @__PURE__ */ new Map());
|
|
2464
|
+
const inFlightRef = useRef6(/* @__PURE__ */ new Set());
|
|
2465
|
+
const visibleRef = useRef6(visibleMarkets);
|
|
2300
2466
|
visibleRef.current = visibleMarkets;
|
|
2301
2467
|
const visibleFp = useMemo13(
|
|
2302
2468
|
() => [...new Set(visibleMarkets.map((m) => m.id))].sort().join("|"),
|
|
2303
2469
|
[visibleMarkets]
|
|
2304
2470
|
);
|
|
2305
|
-
|
|
2471
|
+
useEffect10(() => {
|
|
2306
2472
|
const toFetch = resolveUncachedVisibleMarketIds(visibleRef.current, cache, inFlightRef.current);
|
|
2307
2473
|
if (!toFetch.length) return;
|
|
2308
2474
|
let cancelled = false;
|
|
@@ -2359,15 +2525,15 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
2359
2525
|
}
|
|
2360
2526
|
|
|
2361
2527
|
// src/use-visible-ids.ts
|
|
2362
|
-
import { useCallback as useCallback6, useEffect as
|
|
2528
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useRef as useRef7, useState as useState11 } from "react";
|
|
2363
2529
|
function useVisibleIds(options = {}) {
|
|
2364
2530
|
const { rootMargin = "0px", threshold = 0 } = options;
|
|
2365
|
-
const [visibleIds, setVisibleIds] =
|
|
2366
|
-
const observerRef =
|
|
2367
|
-
const elementsRef =
|
|
2368
|
-
const elementIdRef =
|
|
2369
|
-
const callbackRefsRef =
|
|
2370
|
-
|
|
2531
|
+
const [visibleIds, setVisibleIds] = useState11(() => /* @__PURE__ */ new Set());
|
|
2532
|
+
const observerRef = useRef7(null);
|
|
2533
|
+
const elementsRef = useRef7(/* @__PURE__ */ new Map());
|
|
2534
|
+
const elementIdRef = useRef7(/* @__PURE__ */ new WeakMap());
|
|
2535
|
+
const callbackRefsRef = useRef7(/* @__PURE__ */ new Map());
|
|
2536
|
+
useEffect11(() => {
|
|
2371
2537
|
if (typeof IntersectionObserver === "undefined") return;
|
|
2372
2538
|
const observer = new IntersectionObserver(
|
|
2373
2539
|
(entries) => {
|
|
@@ -2432,16 +2598,38 @@ function useVisibleIds(options = {}) {
|
|
|
2432
2598
|
}
|
|
2433
2599
|
|
|
2434
2600
|
// src/use-app-config.ts
|
|
2435
|
-
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
2601
|
+
import { useQuery as useQuery9, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
2436
2602
|
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
2603
|
+
var APP_CONFIG_QUERY_KEY = ["agg", "app-config"];
|
|
2437
2604
|
function useAppConfig() {
|
|
2438
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2439
2605
|
const client = useAggClient();
|
|
2440
2606
|
const query = useQuery9({
|
|
2441
|
-
queryKey:
|
|
2607
|
+
queryKey: APP_CONFIG_QUERY_KEY,
|
|
2442
2608
|
queryFn: () => client.getAppConfig(),
|
|
2443
2609
|
staleTime: FIVE_MINUTES
|
|
2444
2610
|
});
|
|
2611
|
+
return toAppConfigResult({
|
|
2612
|
+
data: query.data,
|
|
2613
|
+
isLoading: query.isLoading,
|
|
2614
|
+
error: query.error
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
function useCachedAppConfig() {
|
|
2618
|
+
const queryClient = useQueryClient2();
|
|
2619
|
+
const query = useQuery9({
|
|
2620
|
+
queryKey: APP_CONFIG_QUERY_KEY,
|
|
2621
|
+
enabled: false,
|
|
2622
|
+
initialData: () => queryClient.getQueryData(APP_CONFIG_QUERY_KEY),
|
|
2623
|
+
staleTime: FIVE_MINUTES
|
|
2624
|
+
});
|
|
2625
|
+
return toAppConfigResult({
|
|
2626
|
+
data: query.data,
|
|
2627
|
+
isLoading: query.isLoading,
|
|
2628
|
+
error: query.error
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
var toAppConfigResult = (query) => {
|
|
2632
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2445
2633
|
return {
|
|
2446
2634
|
disabledVenues: (_b = (_a = query.data) == null ? void 0 : _a.disabledVenues) != null ? _b : [],
|
|
2447
2635
|
disabledCategoryPresets: (_d = (_c = query.data) == null ? void 0 : _c.disabledCategoryPresets) != null ? _d : [],
|
|
@@ -2450,7 +2638,7 @@ function useAppConfig() {
|
|
|
2450
2638
|
isLoading: query.isLoading,
|
|
2451
2639
|
error: query.error
|
|
2452
2640
|
};
|
|
2453
|
-
}
|
|
2641
|
+
};
|
|
2454
2642
|
export {
|
|
2455
2643
|
AUTH_CHOOSER_OPEN_EVENT,
|
|
2456
2644
|
AggBalanceProvider,
|
|
@@ -2461,6 +2649,8 @@ export {
|
|
|
2461
2649
|
CONFIRMED_MATCH_STATUSES,
|
|
2462
2650
|
DEFAULT_AGG_ROOT_CLASS_NAME,
|
|
2463
2651
|
EventListStateProvider,
|
|
2652
|
+
MAX_PRICE_GAP_PCT,
|
|
2653
|
+
MIN_PRICE_GAP_PCT,
|
|
2464
2654
|
MarketStatus,
|
|
2465
2655
|
MatchStatus,
|
|
2466
2656
|
MatchType,
|
|
@@ -2479,12 +2669,18 @@ export {
|
|
|
2479
2669
|
getBuilder,
|
|
2480
2670
|
getDepositAddress,
|
|
2481
2671
|
getOrCreateBuilder,
|
|
2672
|
+
getVenueAvailabilityState,
|
|
2673
|
+
getVisibleVenueIdsByConfig,
|
|
2674
|
+
getVisibleVenuesByConfig,
|
|
2482
2675
|
getWalletAddressFromUserProfile,
|
|
2483
2676
|
invalidateBalanceQueries,
|
|
2484
2677
|
invalidatePositionQueries,
|
|
2485
2678
|
invalidateUserActivityQueries,
|
|
2679
|
+
invalidateUserClaimState,
|
|
2486
2680
|
invalidateUserMoneyState,
|
|
2681
|
+
isVenueDisabledByConfig,
|
|
2487
2682
|
mergeBestPricesPreferringLive,
|
|
2683
|
+
normalizeVenueId,
|
|
2488
2684
|
optimizedImageUrl,
|
|
2489
2685
|
parseEmail,
|
|
2490
2686
|
parseEmailStrict,
|
|
@@ -2512,7 +2708,10 @@ export {
|
|
|
2512
2708
|
useAggUiConfig,
|
|
2513
2709
|
useAggWebSocket,
|
|
2514
2710
|
useAppConfig,
|
|
2711
|
+
useArbFeed,
|
|
2712
|
+
useCachedAppConfig,
|
|
2515
2713
|
useCategories,
|
|
2714
|
+
useCategoryChildren,
|
|
2516
2715
|
useDebouncedValue,
|
|
2517
2716
|
useDepositAddresses,
|
|
2518
2717
|
useEnrichedVenueEvent,
|
|
@@ -2535,19 +2734,22 @@ export {
|
|
|
2535
2734
|
useLiveOutcomePrices,
|
|
2536
2735
|
useLiveTrades,
|
|
2537
2736
|
useManagedBalances,
|
|
2737
|
+
useMarketArb,
|
|
2538
2738
|
useMarketChart,
|
|
2539
2739
|
useMarketOrderbook,
|
|
2540
2740
|
useMarketSearch,
|
|
2541
2741
|
useMidpoints,
|
|
2542
2742
|
useOnBalanceUpdate,
|
|
2743
|
+
useOnOrderEvent,
|
|
2543
2744
|
useOnOrderSubmitted,
|
|
2544
2745
|
useOnRedeemEvent,
|
|
2545
2746
|
useOnWithdrawalLifecycle,
|
|
2747
|
+
useOptionalAggClient,
|
|
2546
2748
|
useOrderBook,
|
|
2547
2749
|
useOrderbookQuote,
|
|
2548
2750
|
useOrders,
|
|
2549
2751
|
usePositions,
|
|
2550
|
-
|
|
2752
|
+
useQueryClient3 as useQueryClient,
|
|
2551
2753
|
useQuoteManaged,
|
|
2552
2754
|
useRampQuotes,
|
|
2553
2755
|
useRampSession,
|