@agg-build/hooks 2.1.2 → 2.2.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-7UDYSDKQ.mjs → chunk-56RISN73.mjs} +250 -16
- package/dist/{chunk-FBYQBFFR.mjs → chunk-NZEXGOFC.mjs} +1 -1
- package/dist/{chunk-5VDUIUJB.mjs → chunk-SN4AO5D7.mjs} +1 -1
- package/dist/deposit.d.mts +1 -1
- package/dist/deposit.d.ts +1 -1
- package/dist/deposit.js +88 -18
- package/dist/deposit.mjs +30 -9
- package/dist/index.d.mts +109 -43
- package/dist/index.d.ts +109 -43
- package/dist/index.js +491 -107
- package/dist/index.mjs +202 -51
- package/dist/withdraw.js +49 -2
- 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-SN4AO5D7.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useWithdrawEstimate,
|
|
7
7
|
useWithdrawFlow,
|
|
8
8
|
useWithdrawPreview,
|
|
9
9
|
useWithdrawalLifecycle
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NZEXGOFC.mjs";
|
|
11
11
|
import {
|
|
12
12
|
AggAuthContext,
|
|
13
13
|
AggBalanceProvider,
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
useSyncBalances,
|
|
96
96
|
useWithdrawManaged,
|
|
97
97
|
userActivityQueryKeys
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-56RISN73.mjs";
|
|
99
99
|
|
|
100
100
|
// src/index.ts
|
|
101
101
|
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
@@ -981,7 +981,6 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
981
981
|
for (const vm of venueMarkets) {
|
|
982
982
|
for (const outcome of (_d = vm.venueMarketOutcomes) != null ? _d : []) {
|
|
983
983
|
if (!enableLiveUpdates) {
|
|
984
|
-
prices.set(outcome.id, outcome.price);
|
|
985
984
|
continue;
|
|
986
985
|
}
|
|
987
986
|
const liveMidpoint = liveByOutcomeId.get(outcome.id);
|
|
@@ -1534,31 +1533,8 @@ function useMidpoints(venueMarkets, options) {
|
|
|
1534
1533
|
};
|
|
1535
1534
|
}
|
|
1536
1535
|
|
|
1537
|
-
// src/use-tradable-venues.ts
|
|
1538
|
-
import { useMemo as useMemo9 } from "react";
|
|
1539
|
-
function useTradableVenues(venueMarkets) {
|
|
1540
|
-
const { prices, isLoading } = useMidpoints(venueMarkets);
|
|
1541
|
-
const tradableVenues = useMemo9(() => {
|
|
1542
|
-
var _a;
|
|
1543
|
-
if (isLoading) return null;
|
|
1544
|
-
if (!venueMarkets || venueMarkets.length === 0) return /* @__PURE__ */ new Set();
|
|
1545
|
-
const set = /* @__PURE__ */ new Set();
|
|
1546
|
-
for (const market of venueMarkets) {
|
|
1547
|
-
const outcomes = (_a = market.venueMarketOutcomes) != null ? _a : [];
|
|
1548
|
-
for (const outcome of outcomes) {
|
|
1549
|
-
if (prices.has(outcome.id)) {
|
|
1550
|
-
set.add(market.venue);
|
|
1551
|
-
break;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
return set;
|
|
1556
|
-
}, [venueMarkets, prices, isLoading]);
|
|
1557
|
-
return { tradableVenues, isLoading };
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
1536
|
// src/use-rolling-chart-window.ts
|
|
1561
|
-
import { useEffect as useEffect5, useMemo as
|
|
1537
|
+
import { useEffect as useEffect5, useMemo as useMemo9, useState as useState4 } from "react";
|
|
1562
1538
|
var RANGE_SECONDS_BY_RANGE = {
|
|
1563
1539
|
"1H": 60 * 60,
|
|
1564
1540
|
"6H": 6 * 60 * 60,
|
|
@@ -1589,7 +1565,7 @@ var useRollingChartWindow = (options) => {
|
|
|
1589
1565
|
var _a;
|
|
1590
1566
|
const tickMs = (_a = options.tickMs) != null ? _a : 1e3;
|
|
1591
1567
|
const optionsNowMs = options.nowMs;
|
|
1592
|
-
const nowMs =
|
|
1568
|
+
const nowMs = useMemo9(() => optionsNowMs != null ? optionsNowMs : (() => Date.now()), [optionsNowMs]);
|
|
1593
1569
|
const [nowSec, setNowSec] = useState4(() => Math.floor(nowMs() / 1e3));
|
|
1594
1570
|
useEffect5(() => {
|
|
1595
1571
|
setNowSec(Math.floor(nowMs() / 1e3));
|
|
@@ -1598,7 +1574,7 @@ var useRollingChartWindow = (options) => {
|
|
|
1598
1574
|
}, tickMs);
|
|
1599
1575
|
return () => clearInterval(handle);
|
|
1600
1576
|
}, [tickMs, nowMs]);
|
|
1601
|
-
return
|
|
1577
|
+
return useMemo9(
|
|
1602
1578
|
() => resolveRollingWindow({ range: options.range, nowSec, interval: options.interval }),
|
|
1603
1579
|
[options.range, options.interval, nowSec]
|
|
1604
1580
|
);
|
|
@@ -2111,7 +2087,130 @@ function useMarketSearch(options) {
|
|
|
2111
2087
|
|
|
2112
2088
|
// src/use-smart-route.ts
|
|
2113
2089
|
import { keepPreviousData as keepPreviousData6, useQuery as useQuery6 } from "@tanstack/react-query";
|
|
2090
|
+
|
|
2091
|
+
// src/smart-route-refresh-policy.ts
|
|
2092
|
+
var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
|
|
2093
|
+
var SMART_ROUTE_REFRESH_DEADLINE_BUFFER_MS = 4e3;
|
|
2094
|
+
var SMART_ROUTE_MIN_REFETCH_INTERVAL_MS = 5e3;
|
|
2095
|
+
var SMART_ROUTE_MAX_REFETCH_INTERVAL_MS = 2e4;
|
|
2096
|
+
var SMART_ROUTE_HIGH_SLIPPAGE_BPS = 75;
|
|
2097
|
+
var SMART_ROUTE_SHALLOW_TOP_LEVEL_RATIO = 0.7;
|
|
2098
|
+
var SMART_ROUTE_DEEP_FILL_LEVEL_COUNT = 3;
|
|
2099
|
+
var LIQUIDITY_CONSTRAINED_STATUSES = /* @__PURE__ */ new Set([
|
|
2100
|
+
"infeasible",
|
|
2101
|
+
"no_orderbooks",
|
|
2102
|
+
"insufficient_depth",
|
|
2103
|
+
"no_bids_above_min_price"
|
|
2104
|
+
]);
|
|
2105
|
+
var THIN_LIQUIDITY_WARNING_PATTERN = /partial(?:[_\s-]?fill)?|insufficient(?:[_\s-]?liquidity|[_\s-]?depth)|shallow|price moved|no active quote path|couldn'?t fill|unable to fill|quote stale|stale/i;
|
|
2106
|
+
var resolveMsUntilIsoTimestamp = (value, nowMs) => {
|
|
2107
|
+
if (!value) return null;
|
|
2108
|
+
const parsedValue = Date.parse(value);
|
|
2109
|
+
if (!Number.isFinite(parsedValue)) return null;
|
|
2110
|
+
return parsedValue - nowMs;
|
|
2111
|
+
};
|
|
2112
|
+
var clampIntervalToRefreshDeadline = ({
|
|
2113
|
+
intervalMs,
|
|
2114
|
+
refreshAt,
|
|
2115
|
+
nowMs
|
|
2116
|
+
}) => {
|
|
2117
|
+
const msUntilRefresh = resolveMsUntilIsoTimestamp(refreshAt, nowMs);
|
|
2118
|
+
if (msUntilRefresh == null || msUntilRefresh <= 0) {
|
|
2119
|
+
return Math.min(
|
|
2120
|
+
SMART_ROUTE_MAX_REFETCH_INTERVAL_MS,
|
|
2121
|
+
Math.max(SMART_ROUTE_MIN_REFETCH_INTERVAL_MS, intervalMs)
|
|
2122
|
+
);
|
|
2123
|
+
}
|
|
2124
|
+
return Math.max(
|
|
2125
|
+
SMART_ROUTE_MIN_REFETCH_INTERVAL_MS,
|
|
2126
|
+
Math.min(SMART_ROUTE_MAX_REFETCH_INTERVAL_MS, intervalMs, Math.floor(msUntilRefresh))
|
|
2127
|
+
);
|
|
2128
|
+
};
|
|
2129
|
+
var assessThinSmartRouteLiquidity = (quote, nowMs = Date.now()) => {
|
|
2130
|
+
var _a, _b;
|
|
2131
|
+
if (!quote) {
|
|
2132
|
+
return {
|
|
2133
|
+
isThin: false,
|
|
2134
|
+
reasons: []
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
const reasons = /* @__PURE__ */ new Set();
|
|
2138
|
+
if (LIQUIDITY_CONSTRAINED_STATUSES.has(quote.status)) {
|
|
2139
|
+
reasons.add("liquidity_status");
|
|
2140
|
+
}
|
|
2141
|
+
if (typeof ((_a = quote.slippage) == null ? void 0 : _a.slippageBps) === "number" && Number.isFinite(quote.slippage.slippageBps) && quote.slippage.slippageBps >= SMART_ROUTE_HIGH_SLIPPAGE_BPS) {
|
|
2142
|
+
reasons.add("high_slippage");
|
|
2143
|
+
}
|
|
2144
|
+
const msUntilRefresh = resolveMsUntilIsoTimestamp(quote.refreshAt, nowMs);
|
|
2145
|
+
if (msUntilRefresh != null && msUntilRefresh <= SMART_ROUTE_REFRESH_DEADLINE_BUFFER_MS) {
|
|
2146
|
+
reasons.add("refresh_due_soon");
|
|
2147
|
+
}
|
|
2148
|
+
const hasShallowTopLevel = quote.fills.some((fill) => {
|
|
2149
|
+
var _a2, _b2;
|
|
2150
|
+
if (fill.fills.length <= 1 || fill.venueQty <= 0) return false;
|
|
2151
|
+
const topLevelSize = (_b2 = (_a2 = fill.fills[0]) == null ? void 0 : _a2.size) != null ? _b2 : 0;
|
|
2152
|
+
if (!Number.isFinite(topLevelSize) || topLevelSize <= 0) return false;
|
|
2153
|
+
return topLevelSize / fill.venueQty < SMART_ROUTE_SHALLOW_TOP_LEVEL_RATIO;
|
|
2154
|
+
});
|
|
2155
|
+
if (hasShallowTopLevel) {
|
|
2156
|
+
reasons.add("shallow_top_level");
|
|
2157
|
+
}
|
|
2158
|
+
const hasDeepFillLevels = quote.fills.some(
|
|
2159
|
+
(fill) => fill.fills.length >= SMART_ROUTE_DEEP_FILL_LEVEL_COUNT
|
|
2160
|
+
);
|
|
2161
|
+
if (hasDeepFillLevels) {
|
|
2162
|
+
reasons.add("deep_fill_levels");
|
|
2163
|
+
}
|
|
2164
|
+
const hasThinWarning = ((_b = quote.warnings) != null ? _b : []).some(
|
|
2165
|
+
(warning) => THIN_LIQUIDITY_WARNING_PATTERN.test(warning.reason)
|
|
2166
|
+
);
|
|
2167
|
+
if (hasThinWarning) {
|
|
2168
|
+
reasons.add("warning_signal");
|
|
2169
|
+
}
|
|
2170
|
+
return {
|
|
2171
|
+
isThin: reasons.size > 0,
|
|
2172
|
+
reasons: [...reasons]
|
|
2173
|
+
};
|
|
2174
|
+
};
|
|
2175
|
+
var resolveSmartRouteRefetchInterval = (args, nowMs = Date.now()) => {
|
|
2176
|
+
const {
|
|
2177
|
+
aggressiveIntervalMs = THIN_SMART_ROUTE_REFETCH_INTERVAL_MS,
|
|
2178
|
+
data,
|
|
2179
|
+
defaultIntervalMs,
|
|
2180
|
+
isDocumentVisible,
|
|
2181
|
+
isEditing = false,
|
|
2182
|
+
isInputValid,
|
|
2183
|
+
isMarketOpen,
|
|
2184
|
+
isPanelActive,
|
|
2185
|
+
isSubmitting,
|
|
2186
|
+
queryEnabled
|
|
2187
|
+
} = args;
|
|
2188
|
+
if (defaultIntervalMs <= 0) return false;
|
|
2189
|
+
const isActivelyViewingQuote = isPanelActive || isEditing;
|
|
2190
|
+
if (!queryEnabled || !isInputValid || !isActivelyViewingQuote || !isMarketOpen || isSubmitting || !isDocumentVisible) {
|
|
2191
|
+
return false;
|
|
2192
|
+
}
|
|
2193
|
+
const defaultInterval = clampIntervalToRefreshDeadline({
|
|
2194
|
+
intervalMs: defaultIntervalMs,
|
|
2195
|
+
refreshAt: data == null ? void 0 : data.refreshAt,
|
|
2196
|
+
nowMs
|
|
2197
|
+
});
|
|
2198
|
+
if (!data) return defaultInterval;
|
|
2199
|
+
const thinLiquidity = assessThinSmartRouteLiquidity(data, nowMs);
|
|
2200
|
+
if (!thinLiquidity.isThin) return defaultInterval;
|
|
2201
|
+
return clampIntervalToRefreshDeadline({
|
|
2202
|
+
intervalMs: aggressiveIntervalMs,
|
|
2203
|
+
refreshAt: data.refreshAt,
|
|
2204
|
+
nowMs
|
|
2205
|
+
});
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2208
|
+
// src/use-smart-route.ts
|
|
2114
2209
|
var SMART_ROUTE_STALE_TIME_MS = 2e4;
|
|
2210
|
+
var getIsDocumentVisible = () => {
|
|
2211
|
+
if (typeof document === "undefined") return true;
|
|
2212
|
+
return document.visibilityState !== "hidden";
|
|
2213
|
+
};
|
|
2115
2214
|
function useSmartRoute(options) {
|
|
2116
2215
|
var _a, _b;
|
|
2117
2216
|
const client = useAggClient();
|
|
@@ -2129,9 +2228,12 @@ function useSmartRoute(options) {
|
|
|
2129
2228
|
compareVenues,
|
|
2130
2229
|
deepEstimate,
|
|
2131
2230
|
enabled = true,
|
|
2132
|
-
staleTimeMs = SMART_ROUTE_STALE_TIME_MS
|
|
2231
|
+
staleTimeMs = SMART_ROUTE_STALE_TIME_MS,
|
|
2232
|
+
refreshContext
|
|
2133
2233
|
} = options;
|
|
2134
2234
|
const resolvedVenueMarketOutcomeId = (_a = venueMarketOutcomeId != null ? venueMarketOutcomeId : venueMarketId) != null ? _a : outcomeId;
|
|
2235
|
+
const hasValidInput = (maxSpend != null ? maxSpend : 0) > 0 || (sellShares != null ? sellShares : 0) > 0;
|
|
2236
|
+
const queryEnabled = enabled && !!resolvedVenueMarketOutcomeId && hasValidInput;
|
|
2135
2237
|
const query = useQuery6({
|
|
2136
2238
|
queryKey: [
|
|
2137
2239
|
"smart-route",
|
|
@@ -2163,11 +2265,25 @@ function useSmartRoute(options) {
|
|
|
2163
2265
|
{ signal }
|
|
2164
2266
|
);
|
|
2165
2267
|
}),
|
|
2166
|
-
enabled:
|
|
2268
|
+
enabled: queryEnabled,
|
|
2167
2269
|
staleTime: staleTimeMs,
|
|
2168
|
-
refetchInterval:
|
|
2270
|
+
refetchInterval: (queryState) => {
|
|
2271
|
+
var _a2, _b2, _c, _d;
|
|
2272
|
+
return resolveSmartRouteRefetchInterval({
|
|
2273
|
+
data: queryState.state.data,
|
|
2274
|
+
defaultIntervalMs: staleTimeMs,
|
|
2275
|
+
isDocumentVisible: getIsDocumentVisible(),
|
|
2276
|
+
isEditing: (_a2 = refreshContext == null ? void 0 : refreshContext.isEditing) != null ? _a2 : false,
|
|
2277
|
+
isInputValid: hasValidInput,
|
|
2278
|
+
isMarketOpen: (_b2 = refreshContext == null ? void 0 : refreshContext.isMarketOpen) != null ? _b2 : true,
|
|
2279
|
+
isPanelActive: (_c = refreshContext == null ? void 0 : refreshContext.isPanelActive) != null ? _c : true,
|
|
2280
|
+
isSubmitting: (_d = refreshContext == null ? void 0 : refreshContext.isSubmitting) != null ? _d : false,
|
|
2281
|
+
queryEnabled
|
|
2282
|
+
});
|
|
2283
|
+
},
|
|
2169
2284
|
gcTime: 6e4,
|
|
2170
2285
|
refetchOnWindowFocus: false,
|
|
2286
|
+
refetchIntervalInBackground: false,
|
|
2171
2287
|
retry: 1,
|
|
2172
2288
|
placeholderData: keepPreviousData6
|
|
2173
2289
|
});
|
|
@@ -2222,7 +2338,7 @@ function useUserHoldings(options) {
|
|
|
2222
2338
|
}
|
|
2223
2339
|
|
|
2224
2340
|
// src/use-enriched-venue-event.ts
|
|
2225
|
-
import { useMemo as
|
|
2341
|
+
import { useMemo as useMemo10 } from "react";
|
|
2226
2342
|
|
|
2227
2343
|
// src/use-venue-event.ts
|
|
2228
2344
|
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
@@ -2252,7 +2368,7 @@ function useVenueEvent(options) {
|
|
|
2252
2368
|
import { QueryClient as QueryClient2, QueryClientContext as QueryClientContext2, useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
|
|
2253
2369
|
import { useContext as useContext3, useEffect as useEffect8, useState as useState8 } from "react";
|
|
2254
2370
|
function useVenueMarkets(options) {
|
|
2255
|
-
var _a, _b, _c, _d, _e;
|
|
2371
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2256
2372
|
const client = useContext3(AggClientContext);
|
|
2257
2373
|
const queryClient = useContext3(QueryClientContext2);
|
|
2258
2374
|
const [fallbackQueryClient] = useState8(() => new QueryClient2());
|
|
@@ -2262,10 +2378,16 @@ function useVenueMarkets(options) {
|
|
|
2262
2378
|
const matchStatus = options == null ? void 0 : options.matchStatus;
|
|
2263
2379
|
const status = options == null ? void 0 : options.status;
|
|
2264
2380
|
const categoryIds = options == null ? void 0 : options.categoryIds;
|
|
2381
|
+
const aggKey = options == null ? void 0 : options.aggKey;
|
|
2382
|
+
const sportsMarketType = options == null ? void 0 : options.sportsMarketType;
|
|
2383
|
+
const period = options == null ? void 0 : options.period;
|
|
2384
|
+
const marketCategory = options == null ? void 0 : options.marketCategory;
|
|
2385
|
+
const marketGroup = options == null ? void 0 : options.marketGroup;
|
|
2265
2386
|
const enabled = (_a = options == null ? void 0 : options.enabled) != null ? _a : true;
|
|
2266
2387
|
const limit = (_b = options == null ? void 0 : options.limit) != null ? _b : 20;
|
|
2267
2388
|
const sortBy = options == null ? void 0 : options.sortBy;
|
|
2268
2389
|
const sortDir = options == null ? void 0 : options.sortDir;
|
|
2390
|
+
const context = options == null ? void 0 : options.context;
|
|
2269
2391
|
useEffect8(() => {
|
|
2270
2392
|
if (queryClient) return void 0;
|
|
2271
2393
|
fallbackQueryClient.mount();
|
|
@@ -2286,9 +2408,15 @@ function useVenueMarkets(options) {
|
|
|
2286
2408
|
matchStatus != null ? matchStatus : "",
|
|
2287
2409
|
status != null ? status : "",
|
|
2288
2410
|
(_c = categoryIds == null ? void 0 : categoryIds.join(",")) != null ? _c : "",
|
|
2411
|
+
(_d = aggKey == null ? void 0 : aggKey.join(",")) != null ? _d : "",
|
|
2412
|
+
(_e = sportsMarketType == null ? void 0 : sportsMarketType.join(",")) != null ? _e : "",
|
|
2413
|
+
(_f = period == null ? void 0 : period.join(",")) != null ? _f : "",
|
|
2414
|
+
(_g = marketCategory == null ? void 0 : marketCategory.join(",")) != null ? _g : "",
|
|
2415
|
+
(_h = marketGroup == null ? void 0 : marketGroup.join(",")) != null ? _h : "",
|
|
2289
2416
|
limit,
|
|
2290
2417
|
sortBy != null ? sortBy : "",
|
|
2291
|
-
sortDir != null ? sortDir : ""
|
|
2418
|
+
sortDir != null ? sortDir : "",
|
|
2419
|
+
context != null ? context : ""
|
|
2292
2420
|
],
|
|
2293
2421
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
2294
2422
|
if (!client) {
|
|
@@ -2301,10 +2429,16 @@ function useVenueMarkets(options) {
|
|
|
2301
2429
|
matchStatus,
|
|
2302
2430
|
status,
|
|
2303
2431
|
categoryIds,
|
|
2432
|
+
aggKey,
|
|
2433
|
+
sportsMarketType,
|
|
2434
|
+
period,
|
|
2435
|
+
marketCategory,
|
|
2436
|
+
marketGroup,
|
|
2304
2437
|
limit,
|
|
2305
2438
|
cursor: pageParam,
|
|
2306
2439
|
sortBy,
|
|
2307
|
-
sortDir
|
|
2440
|
+
sortDir,
|
|
2441
|
+
context
|
|
2308
2442
|
});
|
|
2309
2443
|
return res;
|
|
2310
2444
|
}),
|
|
@@ -2318,7 +2452,7 @@ function useVenueMarkets(options) {
|
|
|
2318
2452
|
},
|
|
2319
2453
|
queryClient != null ? queryClient : fallbackQueryClient
|
|
2320
2454
|
);
|
|
2321
|
-
const markets = (
|
|
2455
|
+
const markets = (_j = (_i = query.data) == null ? void 0 : _i.pages.flatMap((page) => page.data)) != null ? _j : [];
|
|
2322
2456
|
const hasNextPage = !!query.hasNextPage;
|
|
2323
2457
|
return __spreadProps(__spreadValues({}, query), {
|
|
2324
2458
|
markets,
|
|
@@ -2330,23 +2464,38 @@ function useVenueMarkets(options) {
|
|
|
2330
2464
|
function mergeEventWithFullMarkets(event, fullMarkets) {
|
|
2331
2465
|
if (fullMarkets.length === 0) return event;
|
|
2332
2466
|
const fullById = new Map(fullMarkets.map((m) => [m.id, m]));
|
|
2333
|
-
const
|
|
2467
|
+
const ordering = event.venueMarkets.length > 0 ? event.venueMarkets : fullMarkets;
|
|
2468
|
+
const mergedMarkets = ordering.map((minimal) => {
|
|
2334
2469
|
var _a;
|
|
2335
2470
|
return (_a = fullById.get(minimal.id)) != null ? _a : minimal;
|
|
2336
2471
|
});
|
|
2337
2472
|
return __spreadProps(__spreadValues({}, event), { venueMarkets: mergedMarkets });
|
|
2338
2473
|
}
|
|
2339
2474
|
function useEnrichedVenueEvent(options) {
|
|
2340
|
-
var _b;
|
|
2475
|
+
var _b, _c;
|
|
2341
2476
|
const _a = useVenueEvent(options), { event, isLoading, error } = _a, rest = __objRest(_a, ["event", "isLoading", "error"]);
|
|
2342
|
-
const
|
|
2477
|
+
const eventEndedAt = (event == null ? void 0 : event.endDate) && Number.isFinite(Date.parse(event.endDate)) ? Date.parse(event.endDate) : null;
|
|
2478
|
+
const shouldFetchOnlyOpenMarkets = eventEndedAt == null || eventEndedAt >= Date.now();
|
|
2479
|
+
const { markets: openMarkets, isLoading: isEnrichingOpenMarkets } = useVenueMarkets({
|
|
2343
2480
|
venueEventId: options.eventId,
|
|
2344
2481
|
enabled: ((_b = options.enabled) != null ? _b : true) && !!event,
|
|
2345
|
-
status: "open" /* open
|
|
2346
|
-
sortBy:
|
|
2347
|
-
|
|
2482
|
+
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0
|
|
2483
|
+
// No explicit sortBy: event-scoped /venue-markets sorts by the event's
|
|
2484
|
+
// type-aware order (structureOrderBy). Keeping this in lockstep with
|
|
2485
|
+
// MarketDetailsList preserves the shared React Query cache key and the
|
|
2486
|
+
// event-type ordering.
|
|
2487
|
+
});
|
|
2488
|
+
const shouldFetchAllMarketsFallback = ((_c = options.enabled) != null ? _c : true) && !!event && shouldFetchOnlyOpenMarkets && !isEnrichingOpenMarkets && openMarkets.length === 0;
|
|
2489
|
+
const { markets: fallbackMarkets, isLoading: isEnrichingFallbackMarkets } = useVenueMarkets({
|
|
2490
|
+
venueEventId: options.eventId,
|
|
2491
|
+
enabled: shouldFetchAllMarketsFallback
|
|
2492
|
+
// No status filter on fallback: if an active event temporarily has only
|
|
2493
|
+
// closed/resolved markets, still render the event page instead of the
|
|
2494
|
+
// unavailable state.
|
|
2348
2495
|
});
|
|
2349
|
-
const
|
|
2496
|
+
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
2497
|
+
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
|
2498
|
+
const enrichedEvent = useMemo10(() => {
|
|
2350
2499
|
if (!event) return void 0;
|
|
2351
2500
|
if (markets.length === 0) return event;
|
|
2352
2501
|
return mergeEventWithFullMarkets(event, markets);
|
|
@@ -2366,7 +2515,7 @@ import {
|
|
|
2366
2515
|
keepPreviousData as keepPreviousData7,
|
|
2367
2516
|
useInfiniteQuery as useInfiniteQuery8
|
|
2368
2517
|
} from "@tanstack/react-query";
|
|
2369
|
-
import { useContext as useContext4, useEffect as useEffect9, useMemo as
|
|
2518
|
+
import { useContext as useContext4, useEffect as useEffect9, useMemo as useMemo11, useRef as useRef5, useState as useState9 } from "react";
|
|
2370
2519
|
function useVenueEvents(options) {
|
|
2371
2520
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2372
2521
|
const client = useContext4(AggClientContext);
|
|
@@ -2386,6 +2535,7 @@ function useVenueEvents(options) {
|
|
|
2386
2535
|
const minYesPrice = options == null ? void 0 : options.minYesPrice;
|
|
2387
2536
|
const maxYesPrice = options == null ? void 0 : options.maxYesPrice;
|
|
2388
2537
|
const endDateFrom = options == null ? void 0 : options.endDateFrom;
|
|
2538
|
+
const grouped = options == null ? void 0 : options.grouped;
|
|
2389
2539
|
const initialPages = options == null ? void 0 : options.initialPages;
|
|
2390
2540
|
useEffect9(() => {
|
|
2391
2541
|
if (queryClient) return void 0;
|
|
@@ -2412,6 +2562,7 @@ function useVenueEvents(options) {
|
|
|
2412
2562
|
minYesPrice != null ? minYesPrice : "",
|
|
2413
2563
|
maxYesPrice != null ? maxYesPrice : "",
|
|
2414
2564
|
endDateFrom != null ? endDateFrom : "",
|
|
2565
|
+
grouped != null ? grouped : false,
|
|
2415
2566
|
limit
|
|
2416
2567
|
],
|
|
2417
2568
|
queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
|
|
@@ -2431,6 +2582,7 @@ function useVenueEvents(options) {
|
|
|
2431
2582
|
minYesPrice,
|
|
2432
2583
|
maxYesPrice,
|
|
2433
2584
|
endDateFrom,
|
|
2585
|
+
grouped,
|
|
2434
2586
|
cursor: pageParam
|
|
2435
2587
|
});
|
|
2436
2588
|
return res;
|
|
@@ -2466,7 +2618,7 @@ function useVenueEvents(options) {
|
|
|
2466
2618
|
query.hasNextPage,
|
|
2467
2619
|
query.fetchNextPage
|
|
2468
2620
|
]);
|
|
2469
|
-
const events =
|
|
2621
|
+
const events = useMemo11(
|
|
2470
2622
|
() => {
|
|
2471
2623
|
var _a2, _b2;
|
|
2472
2624
|
return (_b2 = (_a2 = query.data) == null ? void 0 : _a2.pages.flatMap((page) => page.data)) != null ? _b2 : [];
|
|
@@ -2584,7 +2736,7 @@ var computePriceGaps = ({
|
|
|
2584
2736
|
};
|
|
2585
2737
|
|
|
2586
2738
|
// src/use-viewport-midpoints.ts
|
|
2587
|
-
import { useEffect as useEffect10, useMemo as
|
|
2739
|
+
import { useEffect as useEffect10, useMemo as useMemo12, useRef as useRef6, useState as useState10 } from "react";
|
|
2588
2740
|
var buildOutcomeMidpointMap = (outcomes) => {
|
|
2589
2741
|
const m = /* @__PURE__ */ new Map();
|
|
2590
2742
|
if (!outcomes) return m;
|
|
@@ -2641,7 +2793,7 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
2641
2793
|
const inFlightRef = useRef6(/* @__PURE__ */ new Set());
|
|
2642
2794
|
const visibleRef = useRef6(visibleMarkets);
|
|
2643
2795
|
visibleRef.current = visibleMarkets;
|
|
2644
|
-
const visibleFp =
|
|
2796
|
+
const visibleFp = useMemo12(
|
|
2645
2797
|
() => [...new Set(visibleMarkets.map((m) => m.id))].sort().join("|"),
|
|
2646
2798
|
[visibleMarkets]
|
|
2647
2799
|
);
|
|
@@ -2669,7 +2821,7 @@ function useViewportMidpoints(visibleMarkets, options) {
|
|
|
2669
2821
|
cancelled = true;
|
|
2670
2822
|
};
|
|
2671
2823
|
}, [visibleFp, cache, maxMidpointIdsPerRequest]);
|
|
2672
|
-
const { prices, venueByOutcomeId } =
|
|
2824
|
+
const { prices, venueByOutcomeId } = useMemo12(() => {
|
|
2673
2825
|
var _a2, _b, _c, _d;
|
|
2674
2826
|
const map = /* @__PURE__ */ new Map();
|
|
2675
2827
|
const venueMap = /* @__PURE__ */ new Map();
|
|
@@ -2943,7 +3095,6 @@ export {
|
|
|
2943
3095
|
useSearch,
|
|
2944
3096
|
useSmartRoute,
|
|
2945
3097
|
useSyncBalances,
|
|
2946
|
-
useTradableVenues,
|
|
2947
3098
|
useUserActivity,
|
|
2948
3099
|
useUserHoldings,
|
|
2949
3100
|
useVenueEvent,
|
package/dist/withdraw.js
CHANGED
|
@@ -529,6 +529,8 @@ var enUsLabels = {
|
|
|
529
529
|
showOutcomeAria: (label) => `Show ${label} outcome`,
|
|
530
530
|
viewResolved: "View resolved",
|
|
531
531
|
hideResolved: "Hide resolved",
|
|
532
|
+
resolvingTitle: "Resolving market\u2026",
|
|
533
|
+
resolvingDescription: "This market has closed. We're waiting for final settlement data and will update the result once it's confirmed on-chain.",
|
|
532
534
|
volumeUnavailable: "Volume unavailable",
|
|
533
535
|
tabs: {
|
|
534
536
|
orderBook: "Order Book",
|
|
@@ -847,7 +849,51 @@ var enUsLabels = {
|
|
|
847
849
|
winningOutcome: (label) => `Winning outcome: ${label}`,
|
|
848
850
|
resolvedOutcome: (label) => `Resolved: ${label}`,
|
|
849
851
|
marketDetailsAriaByDate: (dateLabel) => `Market details for ${dateLabel}`,
|
|
850
|
-
marketDetailsAriaByQuestion: (question) => `Market details for ${question}
|
|
852
|
+
marketDetailsAriaByQuestion: (question) => `Market details for ${question}`,
|
|
853
|
+
sports: {
|
|
854
|
+
summaryAria: "Sports event summary",
|
|
855
|
+
sectionTabsAria: "Sports market sections",
|
|
856
|
+
lineSelectorAria: (marketTitle) => `Select line for ${marketTitle}`,
|
|
857
|
+
previousLineAria: (marketTitle) => `Show previous lines for ${marketTitle}`,
|
|
858
|
+
nextLineAria: (marketTitle) => `Show next lines for ${marketTitle}`,
|
|
859
|
+
comparisonToggleAria: (marketTitle, expanded) => `${expanded ? "Hide" : "Show"} venue comparison for ${marketTitle}`,
|
|
860
|
+
comparisonTitle: "Venue alternatives",
|
|
861
|
+
compareVenues: (count) => `Compare ${count} venues`,
|
|
862
|
+
marketCount: (count) => `${count} markets`,
|
|
863
|
+
venueCount: (count) => `${count} venues`,
|
|
864
|
+
volumeShort: "Vol.",
|
|
865
|
+
totalVolumeShort: "Total Vol.",
|
|
866
|
+
gameStarts: "Game starts",
|
|
867
|
+
moreMarketsTitle: "More markets",
|
|
868
|
+
gameLinesTab: "Game Lines",
|
|
869
|
+
halvesTab: "Halves",
|
|
870
|
+
exactScoreTab: "Exact Score",
|
|
871
|
+
cornersTab: "Corners",
|
|
872
|
+
goalsTab: "Goals",
|
|
873
|
+
assistsTab: "Assists",
|
|
874
|
+
shotsTab: "Shots",
|
|
875
|
+
otherTab: "Other",
|
|
876
|
+
moneylineTitle: "Moneyline",
|
|
877
|
+
spreadTitle: "Spreads",
|
|
878
|
+
totalTitle: "Totals",
|
|
879
|
+
fullPeriod: "Regular time",
|
|
880
|
+
firstHalfPeriod: "1st half",
|
|
881
|
+
secondHalfPeriod: "2nd half",
|
|
882
|
+
quarterOnePeriod: "1st quarter",
|
|
883
|
+
quarterTwoPeriod: "2nd quarter",
|
|
884
|
+
quarterThreePeriod: "3rd quarter",
|
|
885
|
+
quarterFourPeriod: "4th quarter",
|
|
886
|
+
overtimePeriod: "Overtime",
|
|
887
|
+
otherPeriod: "Other",
|
|
888
|
+
loadingTitle: "Loading section",
|
|
889
|
+
loadingDescription: "Fetching the latest markets for this game.",
|
|
890
|
+
emptyTitle: "No markets available",
|
|
891
|
+
emptyDescription: (sectionLabel) => `There are no ${sectionLabel} markets yet.`,
|
|
892
|
+
loadMore: "Load more",
|
|
893
|
+
loadingMore: "Loading more",
|
|
894
|
+
bestPriceBadge: "Best price",
|
|
895
|
+
selectOutcomeAria: (marketTitle, outcomeLabel, priceLabel) => `Select ${outcomeLabel} in ${marketTitle} at ${priceLabel}`
|
|
896
|
+
}
|
|
851
897
|
},
|
|
852
898
|
header: {
|
|
853
899
|
bannerAria: "Site header",
|
|
@@ -989,7 +1035,8 @@ var defaultAggUiConfig = {
|
|
|
989
1035
|
showFeesBreakdown: false,
|
|
990
1036
|
enableGradients: false,
|
|
991
1037
|
enableVenueEventDiscoveryFilters: false,
|
|
992
|
-
enableNotifications: true
|
|
1038
|
+
enableNotifications: true,
|
|
1039
|
+
showSportsMarkets: false
|
|
993
1040
|
},
|
|
994
1041
|
market: {
|
|
995
1042
|
arbitrageThreshold: 0,
|
package/dist/withdraw.mjs
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
useWithdrawFlow,
|
|
4
4
|
useWithdrawPreview,
|
|
5
5
|
useWithdrawalLifecycle
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NZEXGOFC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useDepositAddresses,
|
|
9
9
|
useManagedBalances,
|
|
10
10
|
useWithdrawManaged
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-56RISN73.mjs";
|
|
12
12
|
export {
|
|
13
13
|
useDepositAddresses,
|
|
14
14
|
useManagedBalances,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/hooks",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "React hooks and providers for the AGG prediction market aggregator. Wraps @agg-build/sdk with TanStack Query, shared session state, and live WebSocket data.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react": "^18.0.0 || ^19.0.0",
|
|
84
84
|
"viem": "^2.0.0",
|
|
85
85
|
"wagmi": "^3.0.0 || ^2.0.0",
|
|
86
|
-
"@agg-build/sdk": "^2.
|
|
86
|
+
"@agg-build/sdk": "^2.2.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@solana/wallet-adapter-react": {
|