@agg-build/hooks 4.18.2 → 4.19.1

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/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  useRampQuotes,
3
3
  useRampSession
4
- } from "./chunk-SBGLJDPJ.mjs";
4
+ } from "./chunk-3PDK5FZ4.mjs";
5
5
  import {
6
6
  useWithdrawEstimate,
7
7
  useWithdrawFlow,
8
8
  useWithdrawPreview,
9
9
  useWithdrawalLifecycle
10
- } from "./chunk-5B2F3GMC.mjs";
10
+ } from "./chunk-YLIXR2QM.mjs";
11
11
  import {
12
12
  AggAuthContext,
13
13
  AggBalanceProvider,
@@ -98,7 +98,7 @@ import {
98
98
  useSyncBalances,
99
99
  useWithdrawManaged,
100
100
  userActivityQueryKeys
101
- } from "./chunk-ESDA4NZI.mjs";
101
+ } from "./chunk-ZERDRL6N.mjs";
102
102
 
103
103
  // src/index.ts
104
104
  import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
@@ -656,6 +656,56 @@ function useUserActivity(options = {}) {
656
656
  });
657
657
  }
658
658
 
659
+ // src/use-leaderboard.ts
660
+ import { keepPreviousData as keepPreviousData2, useInfiniteQuery as useInfiniteQuery4 } from "@tanstack/react-query";
661
+ var LEADERBOARD_PERIODS = ["1d", "7d", "30d", "all"];
662
+ var utcDayKey = (d) => d.toISOString().slice(0, 10);
663
+ function leaderboardRange(period, now = /* @__PURE__ */ new Date()) {
664
+ if (period === "all") return {};
665
+ const spanDays = period === "1d" ? 0 : period === "7d" ? 6 : 29;
666
+ const from = new Date(
667
+ Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - spanDays)
668
+ );
669
+ return { from: utcDayKey(from), to: utcDayKey(now) };
670
+ }
671
+ var leaderboardQueryKeys = {
672
+ all: () => ["leaderboard"],
673
+ list: (period, metric, limit) => ["leaderboard", period, metric, limit]
674
+ };
675
+ var LEADERBOARD_STALE_TIME_MS = 6e4;
676
+ function useLeaderboard(options = {}) {
677
+ var _a, _b;
678
+ const client = useAggClient();
679
+ const { period = "30d", metric = "realizedPnl", limit = 50, enabled = true } = options;
680
+ const query = useInfiniteQuery4({
681
+ queryKey: leaderboardQueryKeys.list(period, metric, limit),
682
+ queryFn: ({ pageParam }) => client.getLeaderboard(__spreadProps(__spreadValues({}, leaderboardRange(period)), {
683
+ metric,
684
+ limit,
685
+ cursor: pageParam
686
+ })),
687
+ initialPageParam: void 0,
688
+ getNextPageParam: (lastPage) => {
689
+ var _a2;
690
+ return lastPage.hasMore ? (_a2 = lastPage.nextCursor) != null ? _a2 : void 0 : void 0;
691
+ },
692
+ enabled,
693
+ // Keep the previous list on screen while a period/metric switch loads.
694
+ placeholderData: keepPreviousData2,
695
+ staleTime: LEADERBOARD_STALE_TIME_MS
696
+ });
697
+ const seen = /* @__PURE__ */ new Set();
698
+ const rows = ((_b = (_a = query.data) == null ? void 0 : _a.pages.flatMap((page) => page.data)) != null ? _b : []).filter((row) => {
699
+ if (seen.has(row.userId)) return false;
700
+ seen.add(row.userId);
701
+ return true;
702
+ });
703
+ return __spreadProps(__spreadValues({}, query), {
704
+ rows,
705
+ hasNextPage: !!query.hasNextPage
706
+ });
707
+ }
708
+
659
709
  // src/use-external-id.ts
660
710
  import { useCallback as useCallback4, useState as useState3 } from "react";
661
711
  function useExternalId(options = {}) {
@@ -686,12 +736,12 @@ function useExternalId(options = {}) {
686
736
  }
687
737
 
688
738
  // src/use-execution-positions.ts
689
- import { useInfiniteQuery as useInfiniteQuery4 } from "@tanstack/react-query";
739
+ import { useInfiniteQuery as useInfiniteQuery5 } from "@tanstack/react-query";
690
740
  function useExecutionPositions(options = {}) {
691
741
  var _a, _b;
692
742
  const client = useAggClient();
693
743
  const { limit = 50, status, mode, enabled = true } = options;
694
- const query = useInfiniteQuery4({
744
+ const query = useInfiniteQuery5({
695
745
  queryKey: executionKeys.positions(null, limit, status != null ? status : null, mode != null ? mode : null),
696
746
  queryFn: ({ pageParam }) => client.getExecutionPositions(__spreadProps(__spreadValues({
697
747
  limit,
@@ -722,7 +772,7 @@ import { useMemo as useMemo4 } from "react";
722
772
  import { mergeCandles, mergeClosedCandles } from "@agg-build/sdk";
723
773
 
724
774
  // src/use-market-chart.ts
725
- import { keepPreviousData as keepPreviousData2, useQueries as useQueries3, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
775
+ import { keepPreviousData as keepPreviousData3, useQueries as useQueries3, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
726
776
 
727
777
  // src/read-retry.ts
728
778
  import { isAggApiError } from "@agg-build/sdk";
@@ -1246,7 +1296,7 @@ function useMarketChartQueries(options) {
1246
1296
  },
1247
1297
  retryDelay: (_attempt, error) => error instanceof ChartDeliveryError && error.retryAfterMs != null ? Math.min(error.state === "warming" ? 1e3 : 5e3, Math.max(0, error.retryAfterMs)) : 1e3
1248
1298
  })), {
1249
- placeholderData: keepPreviousData2,
1299
+ placeholderData: keepPreviousData3,
1250
1300
  refetchInterval: (query) => chartRefetchInterval(
1251
1301
  query,
1252
1302
  refetchIntervalMs != null && refetchIntervalMs > 0 ? refetchIntervalMs : false
@@ -2713,7 +2763,7 @@ function useArbFeed() {
2713
2763
  }
2714
2764
 
2715
2765
  // src/use-order-book.ts
2716
- import { keepPreviousData as keepPreviousData3, useQuery as useQuery7 } from "@tanstack/react-query";
2766
+ import { keepPreviousData as keepPreviousData4, useQuery as useQuery7 } from "@tanstack/react-query";
2717
2767
  var fetchBatchBookQuery = (client, venueMarketIds, { signal }) => client.getOrderbooks({ venueMarketIds }, { signal });
2718
2768
  var createBatchBookQuery = (client, venueMarketIds) => fetchBatchBookQuery.bind(null, client, venueMarketIds);
2719
2769
  function useOrderBook(options) {
@@ -2736,7 +2786,7 @@ function useOrderBook(options) {
2736
2786
  gcTime: 5 * 6e4,
2737
2787
  refetchOnWindowFocus: false,
2738
2788
  retry: 1,
2739
- placeholderData: keepPreviousData3
2789
+ placeholderData: keepPreviousData4
2740
2790
  });
2741
2791
  const data = (() => {
2742
2792
  var _a, _b;
@@ -2791,7 +2841,7 @@ function useOrderBook(options) {
2791
2841
  }
2792
2842
 
2793
2843
  // src/use-orderbook-quote.ts
2794
- import { keepPreviousData as keepPreviousData4, useQuery as useQuery8 } from "@tanstack/react-query";
2844
+ import { keepPreviousData as keepPreviousData5, useQuery as useQuery8 } from "@tanstack/react-query";
2795
2845
  var QUOTE_DEBOUNCE_MS = 300;
2796
2846
  var createUnavailableOrderbookError = (message, code, retryable) => {
2797
2847
  const error = new Error(message);
@@ -2884,7 +2934,7 @@ function useOrderbookQuote(options) {
2884
2934
  staleTime: 1e4,
2885
2935
  gcTime: 5 * 6e4,
2886
2936
  retry: 1,
2887
- placeholderData: keepPreviousData4
2937
+ placeholderData: keepPreviousData5
2888
2938
  });
2889
2939
  return {
2890
2940
  data: (_a = query.data) != null ? _a : null,
@@ -2920,8 +2970,8 @@ function useOrders(options = {}) {
2920
2970
  import {
2921
2971
  QueryClient,
2922
2972
  QueryClientContext,
2923
- keepPreviousData as keepPreviousData5,
2924
- useInfiniteQuery as useInfiniteQuery5
2973
+ keepPreviousData as keepPreviousData6,
2974
+ useInfiniteQuery as useInfiniteQuery6
2925
2975
  } from "@tanstack/react-query";
2926
2976
  import { useContext as useContext2, useEffect as useEffect9, useState as useState6 } from "react";
2927
2977
  function useSearch(options) {
@@ -2962,7 +3012,7 @@ function useSearch(options) {
2962
3012
  ];
2963
3013
  const effectiveQueryClient = queryClient != null ? queryClient : fallbackQueryClient;
2964
3014
  const retryOptions = withReadRetry(effectiveQueryClient.defaultQueryOptions({ queryKey }));
2965
- const query = useInfiniteQuery5(
3015
+ const query = useInfiniteQuery6(
2966
3016
  __spreadProps(__spreadValues({
2967
3017
  // deep is part of the key — TanStack treats deep vs light as
2968
3018
  // independent queries so users can have both modes cached side-by-side.
@@ -2992,7 +3042,7 @@ function useSearch(options) {
2992
3042
  if (!lastPage.hasMore) return void 0;
2993
3043
  return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
2994
3044
  },
2995
- placeholderData: keepPreviousData5
3045
+ placeholderData: keepPreviousData6
2996
3046
  }, retryOptions), {
2997
3047
  enabled: isEnabled && !!client
2998
3048
  }),
@@ -3102,7 +3152,7 @@ function useMarketSearch(options) {
3102
3152
  }
3103
3153
 
3104
3154
  // src/use-smart-route.ts
3105
- import { keepPreviousData as keepPreviousData6, useQuery as useQuery10 } from "@tanstack/react-query";
3155
+ import { keepPreviousData as keepPreviousData7, useQuery as useQuery10 } from "@tanstack/react-query";
3106
3156
 
3107
3157
  // src/smart-route-refresh-policy.ts
3108
3158
  var THIN_SMART_ROUTE_REFETCH_INTERVAL_MS = 5e3;
@@ -3329,7 +3379,7 @@ function useSmartRoute(options) {
3329
3379
  // a different amount or position snapshot. Never expose it under a new
3330
3380
  // sell key while the replacement request is in flight. BUY retains the
3331
3381
  // existing no-flicker behavior.
3332
- placeholderData: tradeSide === "sell" ? void 0 : keepPreviousData6
3382
+ placeholderData: tradeSide === "sell" ? void 0 : keepPreviousData7
3333
3383
  });
3334
3384
  const error = query.error;
3335
3385
  let loadingReason = null;
@@ -3351,7 +3401,7 @@ function useSmartRoute(options) {
3351
3401
  }
3352
3402
 
3353
3403
  // src/use-limit-order-venue-quotes.ts
3354
- import { keepPreviousData as keepPreviousData7, useQueries as useQueries4, useQuery as useQuery11 } from "@tanstack/react-query";
3404
+ import { keepPreviousData as keepPreviousData8, useQueries as useQueries4, useQuery as useQuery11 } from "@tanstack/react-query";
3355
3405
  var getIsDocumentVisible2 = () => {
3356
3406
  if (typeof document === "undefined") return true;
3357
3407
  return document.visibilityState !== "hidden";
@@ -3447,7 +3497,7 @@ var useLimitOrderVenueQuotes = (options) => {
3447
3497
  );
3448
3498
  }),
3449
3499
  enabled: queryEnabled,
3450
- placeholderData: keepPreviousData7,
3500
+ placeholderData: keepPreviousData8,
3451
3501
  staleTime: staleTimeMs,
3452
3502
  refetchInterval: (queryState) => {
3453
3503
  var _a2, _b2, _c, _d;
@@ -3612,12 +3662,12 @@ var useVenueSellQuotes = (options) => {
3612
3662
  };
3613
3663
 
3614
3664
  // src/use-user-holdings.ts
3615
- import { useInfiniteQuery as useInfiniteQuery6 } from "@tanstack/react-query";
3665
+ import { useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
3616
3666
  function useUserHoldings(options) {
3617
3667
  var _a, _b;
3618
3668
  const client = useAggClient();
3619
3669
  const { venue, venueMarketId, venueEventId, enabled = true } = options;
3620
- const query = useInfiniteQuery6({
3670
+ const query = useInfiniteQuery7({
3621
3671
  queryKey: ["user-holdings", venue, venueMarketId, venueEventId],
3622
3672
  queryFn: (_0) => __async(null, [_0], function* ({ pageParam }) {
3623
3673
  return client.getUserHoldings({
@@ -4231,7 +4281,7 @@ function useVenueEvent(options) {
4231
4281
  }
4232
4282
 
4233
4283
  // src/use-venue-markets.ts
4234
- import { QueryClient as QueryClient2, QueryClientContext as QueryClientContext2, useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
4284
+ import { QueryClient as QueryClient2, QueryClientContext as QueryClientContext2, useInfiniteQuery as useInfiniteQuery8 } from "@tanstack/react-query";
4235
4285
  import { useContext as useContext3, useEffect as useEffect10, useState as useState8 } from "react";
4236
4286
  function useVenueMarkets(options) {
4237
4287
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
@@ -4264,7 +4314,7 @@ function useVenueMarkets(options) {
4264
4314
  if (enabled && !client) {
4265
4315
  throw new Error("useVenueMarkets must be used within an <AggProvider>");
4266
4316
  }
4267
- const query = useInfiniteQuery7(
4317
+ const query = useInfiniteQuery8(
4268
4318
  {
4269
4319
  queryKey: [
4270
4320
  "venue-markets",
@@ -4399,8 +4449,8 @@ function useEnrichedVenueEvent(options) {
4399
4449
  import {
4400
4450
  QueryClient as QueryClient3,
4401
4451
  QueryClientContext as QueryClientContext3,
4402
- keepPreviousData as keepPreviousData8,
4403
- useInfiniteQuery as useInfiniteQuery8
4452
+ keepPreviousData as keepPreviousData9,
4453
+ useInfiniteQuery as useInfiniteQuery9
4404
4454
  } from "@tanstack/react-query";
4405
4455
  import { useContext as useContext4, useEffect as useEffect11, useMemo as useMemo12, useRef as useRef7, useState as useState9 } from "react";
4406
4456
  function useVenueEvents(options) {
@@ -4434,7 +4484,7 @@ function useVenueEvents(options) {
4434
4484
  if (enabled && !client) {
4435
4485
  throw new Error("useVenueEvents must be used within an <AggProvider>");
4436
4486
  }
4437
- const query = useInfiniteQuery8(
4487
+ const query = useInfiniteQuery9(
4438
4488
  {
4439
4489
  queryKey: [
4440
4490
  queryKeyScope,
@@ -4482,7 +4532,7 @@ function useVenueEvents(options) {
4482
4532
  return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
4483
4533
  },
4484
4534
  // TODO: RMIK - Comment out to show skeletons on category switch
4485
- placeholderData: keepPreviousData8,
4535
+ placeholderData: keepPreviousData9,
4486
4536
  enabled: enabled && !!client
4487
4537
  },
4488
4538
  queryClient != null ? queryClient : fallbackQueryClient
@@ -4570,7 +4620,7 @@ var useSportsLive = (eventIds, enabled = true) => {
4570
4620
  };
4571
4621
 
4572
4622
  // src/use-venue-market-midpoints.ts
4573
- import { keepPreviousData as keepPreviousData9, useQuery as useQuery15 } from "@tanstack/react-query";
4623
+ import { keepPreviousData as keepPreviousData10, useQuery as useQuery15 } from "@tanstack/react-query";
4574
4624
  var normalizeVenueMarketIds2 = (venueMarketIds) => {
4575
4625
  return [
4576
4626
  ...new Set(venueMarketIds.map((venueMarketId) => venueMarketId.trim()).filter(Boolean))
@@ -4625,7 +4675,7 @@ function useVenueMarketMidpoints(options) {
4625
4675
  gcTime: 5 * 6e4,
4626
4676
  refetchOnWindowFocus: false,
4627
4677
  retry: 1,
4628
- placeholderData: keepPreviousData9
4678
+ placeholderData: keepPreviousData10
4629
4679
  });
4630
4680
  const midpointRows = (_d = (_c = query.data) == null ? void 0 : _c.data) != null ? _d : [];
4631
4681
  const midpointsByVenueMarketId = mapMidpointsByVenueMarketId(midpointRows);
@@ -5128,6 +5178,7 @@ export {
5128
5178
  CONFIRMED_MATCH_STATUSES,
5129
5179
  DEFAULT_AGG_ROOT_CLASS_NAME,
5130
5180
  EventListStateProvider,
5181
+ LEADERBOARD_PERIODS,
5131
5182
  MAX_ORDER_VENUE_MARKET_IDS_PER_REQUEST,
5132
5183
  MAX_PRICE_GAP_PCT,
5133
5184
  MIN_PRICE_GAP_PCT,
@@ -5166,6 +5217,8 @@ export {
5166
5217
  invalidateUserClaimState,
5167
5218
  invalidateUserMoneyState,
5168
5219
  isVenueDisabledByConfig,
5220
+ leaderboardQueryKeys,
5221
+ leaderboardRange,
5169
5222
  mergeBestPricesPreferringLive,
5170
5223
  mergeRecurringCryptoWindows,
5171
5224
  normalizeVenueId,
@@ -5226,6 +5279,7 @@ export {
5226
5279
  useHostedVenueActivity,
5227
5280
  useHostedVenueTransfers,
5228
5281
  useLabels,
5282
+ useLeaderboard,
5229
5283
  useLimitOrderVenueQuotes,
5230
5284
  useLinkAccount,
5231
5285
  useLiveBestPriceCandidates,
package/dist/withdraw.js CHANGED
@@ -408,6 +408,10 @@ var enUsLabels = {
408
408
  networkTooltipDescription: "Funds are stored across networks. We handle routing automatically, but keeping funds on the right network enables faster trades and lower fees. When depositing, you can choose your preferred network."
409
409
  },
410
410
  hostedBetdex: {
411
+ manageFunds: "Manage funds",
412
+ fromWallet: "Transfer from AGG wallet",
413
+ toWallet: "Use my AGG wallet",
414
+ transferToBetdex: "Transfer to BETDEX",
411
415
  deposit: "Deposit USDC",
412
416
  depositInstructions: {
413
417
  production: "Send USDC on Solana to this BETDEX account address.",
@@ -670,6 +674,31 @@ var enUsLabels = {
670
674
  readFullDetails: "Read full details",
671
675
  showLess: "Show less"
672
676
  },
677
+ leaderboard: {
678
+ title: "Leaderboard",
679
+ subtitle: (appName, periodLabel) => `Top traders${appName ? ` on ${appName}` : ""} \xB7 ${periodLabel} \xB7 updates every 5 minutes`,
680
+ periodLabel: "Period",
681
+ rankByLabel: "Rank by",
682
+ periods: { "1d": "24h", "7d": "7d", "30d": "30d", all: "All time" },
683
+ metrics: { realizedPnl: "Profit & loss", volume: "Volume" },
684
+ columns: {
685
+ rank: "#",
686
+ trader: "Trader",
687
+ orders: "Trades",
688
+ volume: "Volume",
689
+ realizedPnl: "P&L"
690
+ },
691
+ tradesCount: (count) => `${count} ${count === 1 ? "trade" : "trades"}`,
692
+ anonymousTrader: "Anonymous trader",
693
+ you: "You",
694
+ showMore: "Show more traders",
695
+ loadingAria: "Loading leaderboard",
696
+ emptyTitle: "No trades in this period yet",
697
+ emptyDescription: "Rankings appear once traders place orders. Try a longer period or check back later.",
698
+ errorTitle: "Couldn't load the leaderboard",
699
+ errorDescription: "Something went wrong on our side. Try again in a moment.",
700
+ pnlFootnote: "P&L is realized only: sells and settled markets, before fees. Volume counts both buys and sells. Trades are filled orders. Figures refresh every 5 minutes."
701
+ },
673
702
  marketDetails: {
674
703
  loading: "Loading market details",
675
704
  unavailableAria: "Market details unavailable",
@@ -888,6 +917,7 @@ var enUsLabels = {
888
917
  tradingAccessVenues: "Venues",
889
918
  tradingAccessAvailable: "Available",
890
919
  tradingAccessAddKalshiAccount: "Add Kalshi Account",
920
+ configureBetdexAccount: "Configure account",
891
921
  outcome: (label) => `Outcome: ${label}`,
892
922
  smartRouting: "Smart Routing",
893
923
  limitRoutingCurrentPrice: (priceLabel, feeLabel) => feeLabel ? `Current ${priceLabel} \xB7 Fee ${feeLabel}` : `Current ${priceLabel}`,
package/dist/withdraw.mjs CHANGED
@@ -3,12 +3,12 @@ import {
3
3
  useWithdrawFlow,
4
4
  useWithdrawPreview,
5
5
  useWithdrawalLifecycle
6
- } from "./chunk-5B2F3GMC.mjs";
6
+ } from "./chunk-YLIXR2QM.mjs";
7
7
  import {
8
8
  useDepositAddresses,
9
9
  useManagedBalances,
10
10
  useWithdrawManaged
11
- } from "./chunk-ESDA4NZI.mjs";
11
+ } from "./chunk-ZERDRL6N.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": "4.18.2",
3
+ "version": "4.19.1",
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": "^4.18.0"
86
+ "@agg-build/sdk": "^4.19.1"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@solana/wallet-adapter-react": {