@berachain/berajs 0.2.9 → 0.2.11

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.
Files changed (182) hide show
  1. package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
  2. package/dist/actions/clients/exports.d.ts +77 -1
  3. package/dist/actions/clients/exports.mjs +13 -4
  4. package/dist/actions/exports.d.ts +121 -39
  5. package/dist/actions/exports.mjs +75 -34
  6. package/dist/actions/governance/exports.d.ts +3 -11
  7. package/dist/actions/governance/exports.mjs +3 -3
  8. package/dist/actions/server/exports.mjs +4 -4
  9. package/dist/{chunk-4Z4AK6SH.mjs → chunk-3JJLQ2JX.mjs} +3 -3
  10. package/dist/{chunk-EXIUPSFN.mjs → chunk-7YVNSDXG.mjs} +2 -2
  11. package/dist/{chunk-WXXOISTU.mjs → chunk-AUOPN6NK.mjs} +1 -1
  12. package/dist/{chunk-75M6TF7M.mjs → chunk-DQRH5VE3.mjs} +1 -1
  13. package/dist/{chunk-CDFWPU2R.mjs → chunk-E7YFXBBQ.mjs} +0 -124
  14. package/dist/{chunk-AFN4CVD3.mjs → chunk-GUURQAME.mjs} +1 -1
  15. package/dist/{chunk-KQUMKB66.mjs → chunk-GY6B3PD5.mjs} +1 -1
  16. package/dist/{chunk-HSSJKHZ4.mjs → chunk-HYDP32P6.mjs} +3 -3
  17. package/dist/{chunk-NPBQLVL3.mjs → chunk-IXIBY5FP.mjs} +2 -2
  18. package/dist/{chunk-J5I45WGQ.mjs → chunk-KHXJDYA4.mjs} +7 -0
  19. package/dist/chunk-MRQGHXAN.mjs +54 -0
  20. package/dist/{chunk-FFB5LFDW.mjs → chunk-QVHEM4BG.mjs} +2 -2
  21. package/dist/{chunk-3EARVV7K.mjs → chunk-SXUNCX5E.mjs} +22 -9
  22. package/dist/chunk-UD5IUNCW.mjs +34 -0
  23. package/dist/{chunk-QJIXTYTZ.mjs → chunk-VAA2FVPP.mjs} +162 -41
  24. package/dist/chunk-Y6THHG77.mjs +126 -0
  25. package/dist/{chunk-XIYN6AL6.mjs → chunk-ZLTMIFCZ.mjs} +10 -5
  26. package/dist/contexts/exports.d.ts +2 -2
  27. package/dist/contexts/exports.mjs +11 -9
  28. package/dist/enum/exports.d.ts +8 -2
  29. package/dist/errors/exports.mjs +5 -5
  30. package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
  31. package/dist/{getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts → getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts} +2 -2
  32. package/dist/{global.d-BuGDKh4k.d.ts → global.d-q_LQWQqs.d.ts} +2 -4
  33. package/dist/hooks/exports.d.ts +114 -164
  34. package/dist/hooks/exports.mjs +535 -522
  35. package/dist/hooks/governance/exports.d.ts +20 -15
  36. package/dist/hooks/governance/exports.mjs +43 -41
  37. package/dist/{pol.d-CqPA9K6m.d.ts → pol.d-CeRgXBL8.d.ts} +33 -8
  38. package/dist/types/exports.d.ts +5 -5
  39. package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
  40. package/dist/utils/exports.d.ts +2 -2
  41. package/dist/utils/exports.mjs +15 -9
  42. package/package.json +9 -8
  43. package/src/actions/bend/getMaxDeposit.ts +28 -2
  44. package/src/actions/clients/exports.ts +3 -0
  45. package/src/actions/clients/fetchBeep.ts +34 -0
  46. package/src/actions/clients/fetchOpenApi.ts +97 -0
  47. package/src/actions/clients/fetchOpenApi.unit.test.ts +245 -0
  48. package/src/actions/clients/fetchRailwayBackend.ts +34 -0
  49. package/src/actions/enso/getEnsoUserTokensWithBalances.ts +18 -0
  50. package/src/actions/exports.ts +2 -0
  51. package/src/actions/honey/getChartData.ts +53 -12
  52. package/src/actions/honey/getHoney24hVolume.ts +34 -6
  53. package/src/actions/honey/getHoneyTxns.ts +93 -0
  54. package/src/actions/honey/getPythLatestPrices.ts +7 -0
  55. package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +1 -1
  56. package/src/actions/pol/getAutoclaimedIncentives.ts +21 -10
  57. package/src/actions/pol/getAutoclaimedIncentivesTxHash.ts +41 -0
  58. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +5 -12
  59. package/src/actions/pol/getEarnedStakedBeraVault.ts +20 -16
  60. package/src/actions/pol/getRewardVaults.ts +4 -4
  61. package/src/actions/pol/getStakingDailyAssets.ts +18 -14
  62. package/src/actions/validators/getValidatorIncentiveDistribution.ts +64 -12
  63. package/src/actions/validators/utils/getValidatorBoostApy.ts +1 -1
  64. package/src/contexts/SwrFallback.tsx +2 -1
  65. package/src/data/contracts.ts +4 -0
  66. package/src/errors/RequestError.ts +12 -3
  67. package/src/errors/RequestError.unit.test.ts +55 -0
  68. package/src/errors/errorMap.ts +8 -0
  69. package/src/errors/getRevertReason.integration.test.ts +5 -1
  70. package/src/hooks/bend/useGetConvertToAssets.ts +2 -3
  71. package/src/hooks/dex/useAggregatorsQuotes.ts +10 -10
  72. package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -1
  73. package/src/hooks/dex/useAllUserPools.ts +7 -5
  74. package/src/hooks/dex/useApiPool.ts +1 -1
  75. package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -1
  76. package/src/hooks/dex/useOnChainPoolData.ts +1 -1
  77. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +2 -2
  78. package/src/hooks/dex/usePoolEvents.ts +1 -2
  79. package/src/hooks/dex/usePoolHistoricalData.ts +2 -3
  80. package/src/hooks/dex/usePools.ts +4 -2
  81. package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
  82. package/src/hooks/enso/useBendDemultiply.ts +3 -4
  83. package/src/hooks/enso/useBendMultiply.ts +3 -4
  84. package/src/hooks/enso/useBendZapSupply.ts +3 -4
  85. package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
  86. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +3 -5
  87. package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
  88. package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
  89. package/src/hooks/enso/useZapStakeBera.ts +2 -2
  90. package/src/hooks/exports.ts +2 -0
  91. package/src/hooks/governance/useGetPastVotes.ts +1 -1
  92. package/src/hooks/governance/useHasVoted.ts +1 -1
  93. package/src/hooks/governance/useIsCanceller.ts +1 -1
  94. package/src/hooks/governance/usePollAllProposals.ts +13 -12
  95. package/src/hooks/governance/usePollProposal.ts +3 -3
  96. package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
  97. package/src/hooks/governance/usePollProposalVotes.ts +23 -5
  98. package/src/hooks/governance/usePollUserDelegates.ts +3 -3
  99. package/src/hooks/governance/useProposalFromTx.ts +2 -1
  100. package/src/hooks/governance/useProposalSnapshot.ts +2 -3
  101. package/src/hooks/governance/useProposalState.ts +2 -2
  102. package/src/hooks/governance/useProposalTimelockState.ts +2 -1
  103. package/src/hooks/governance/useQuorum.ts +1 -2
  104. package/src/hooks/honey/useCappedGlobally.ts +3 -6
  105. package/src/hooks/honey/useCappedRelatively.ts +2 -2
  106. package/src/hooks/honey/useCollateralWeights.ts +3 -3
  107. package/src/hooks/honey/useHoney24hVolume.ts +1 -1
  108. package/src/hooks/honey/useHoneyBalances.ts +1 -1
  109. package/src/hooks/honey/useHoneyChartData.ts +1 -1
  110. package/src/hooks/honey/useHoneyVaultsBalance.ts +2 -3
  111. package/src/hooks/honey/useIsBadCollateralAsset.ts +4 -7
  112. package/src/hooks/honey/useIsBasketModeEnabled.ts +4 -7
  113. package/src/hooks/honey/usePythLatestPrices.ts +13 -9
  114. package/src/hooks/perps/usePythUpdateFee.ts +13 -11
  115. package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -12
  116. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +44 -0
  117. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +39 -0
  118. package/src/hooks/pol/useBgtUnstakedBalance.ts +2 -2
  119. package/src/hooks/pol/useClaimableFees.ts +1 -1
  120. package/src/hooks/pol/useHighestVaultsAPR.ts +4 -6
  121. package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
  122. package/src/hooks/pol/usePollGlobalData.ts +2 -3
  123. package/src/hooks/pol/usePollMarkets.ts +2 -2
  124. package/src/hooks/pol/useQueuedBeraUnlock.ts +2 -2
  125. package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
  126. package/src/hooks/pol/useRewardVault.ts +7 -6
  127. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +4 -4
  128. package/src/hooks/pol/useRewardVaultFromToken.ts +1 -1
  129. package/src/hooks/pol/useRewardVaultIncentives.ts +1 -1
  130. package/src/hooks/pol/useRewardVaultRewards.ts +2 -2
  131. package/src/hooks/pol/useRewardVaults.ts +3 -6
  132. package/src/hooks/pol/useStakedAPR.ts +1 -2
  133. package/src/hooks/pol/useStakedData.ts +90 -41
  134. package/src/hooks/pol/useStakedSnapshots.ts +1 -1
  135. package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
  136. package/src/hooks/pol/useTotalStakedAmount.ts +1 -2
  137. package/src/hooks/pol/useUserVaultInfo.ts +2 -2
  138. package/src/hooks/pol/useUserVaults.ts +2 -3
  139. package/src/hooks/pol/useVaultAddress.ts +1 -1
  140. package/src/hooks/pol/useVaultHistory.ts +1 -2
  141. package/src/hooks/pol/useVaultValidators.ts +2 -2
  142. package/src/hooks/tokens/useMultipleTokenInformation.ts +2 -2
  143. package/src/hooks/tokens/usePollAllowances.ts +3 -4
  144. package/src/hooks/tokens/usePollBalance.ts +2 -2
  145. package/src/hooks/tokens/usePollWalletBalances.ts +2 -2
  146. package/src/hooks/tokens/useStakingTokenInformation.ts +2 -2
  147. package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
  148. package/src/hooks/tokens/useTokenInformation.ts +2 -2
  149. package/src/hooks/tokens/useTokenPrice.ts +2 -1
  150. package/src/hooks/tokens/useTokenPrices.ts +3 -4
  151. package/src/hooks/tokens/useTotalSupply.ts +1 -1
  152. package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
  153. package/src/hooks/useBlockToTimestamp.ts +1 -2
  154. package/src/hooks/useGetVerifiedAbi.ts +2 -1
  155. package/src/hooks/validators/useAllValidators.ts +2 -3
  156. package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
  157. package/src/hooks/validators/useApiValidator.ts +3 -6
  158. package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
  159. package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
  160. package/src/hooks/validators/useDefaultRewardAllocation.ts +2 -3
  161. package/src/hooks/validators/useManagedValidatorRole.ts +2 -2
  162. package/src/hooks/validators/useOnChainValidator.ts +3 -3
  163. package/src/hooks/validators/useStakingPoolBatch.ts +3 -4
  164. package/src/hooks/validators/useUserActiveValidators.ts +2 -3
  165. package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
  166. package/src/hooks/validators/useUserClaimableIncentives.ts +1 -1
  167. package/src/hooks/validators/useUserStakingPositions.ts +2 -1
  168. package/src/hooks/validators/useValidator.ts +4 -8
  169. package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
  170. package/src/hooks/validators/useValidatorCommission.ts +2 -2
  171. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +3 -3
  172. package/src/hooks/validators/useValidatorQueuedCommission.ts +2 -2
  173. package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +2 -2
  174. package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +2 -2
  175. package/src/hooks/validators/useValidatorRewardAllocation.ts +2 -2
  176. package/src/types/bribe-boost.d.ts +14 -3
  177. package/src/types/global.d.ts +3 -4
  178. package/src/types/pol.d.ts +17 -3
  179. package/src/utils/polyfillAbortSignalAny.ts +53 -0
  180. package/src/utils/polyfillAbortSignalAny.unit.test.ts +81 -0
  181. package/dist/polling-BKnyavLI.d.ts +0 -8
  182. /package/dist/{exports-BcUTGFUb.d.ts → getApolloClient-BcUTGFUb.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getRewardVaultStakingToken } from "../../actions/pol/getRewardVaultStakingToken";
7
7
  import { assertPublicClient } from "../../errors/assert";
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import type { GetVaultHistoryQuery } from "@berachain/graphql/pol/api";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import {
6
5
  type GetVaultHistoryArgs,
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import type { ApiValidatorFragment } from "@berachain/graphql/pol/api";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getVaultValidators } from "../../actions/pol/getVaultValidators";
7
7
  import type {
@@ -25,7 +25,7 @@ export const useVaultValidators = (
25
25
  });
26
26
  },
27
27
  {
28
- ...options?.opts,
28
+ ...options,
29
29
  },
30
30
  );
31
31
 
@@ -1,9 +1,9 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { isAddress } from "viem";
3
2
 
4
3
  import { defaultChainId } from "@berachain/config/internal";
5
4
 
6
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { getTokenInformation } from "../../actions/tokens/getTokenInformation";
9
9
  import { assertPublicClient } from "../../errors/assert";
@@ -64,7 +64,7 @@ export function useMultipleTokenInformation(
64
64
  }),
65
65
  );
66
66
  },
67
- { ...options?.opts },
67
+ { ...options },
68
68
  );
69
69
 
70
70
  return {
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getAllowances } from "../../actions/tokens/getAllowances";
6
5
  import { POLLING } from "../../enum/polling";
@@ -46,8 +45,8 @@ export function usePollAllowances(
46
45
  });
47
46
  },
48
47
  {
49
- ...options?.opts,
50
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.NORMAL,
48
+ ...options,
49
+ refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
51
50
  },
52
51
  );
53
52
 
@@ -1,4 +1,3 @@
1
- import useSWR from "swr";
2
1
  import {
3
2
  type Address,
4
3
  erc20Abi,
@@ -11,6 +10,7 @@ import {
11
10
  import { defaultChainId } from "@berachain/config/internal";
12
11
 
13
12
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
13
+ import { useSWR } from "@berachain/utils/pkg/swr";
14
14
 
15
15
  import { POLLING } from "../../enum/polling";
16
16
  import { assertPublicClient } from "../../errors/assert";
@@ -47,7 +47,6 @@ export function usePollBalance(
47
47
  const assetOwner = owner ?? account;
48
48
 
49
49
  const QUERY_KEY =
50
- (options?.opts?.isEnabled ?? true) &&
51
50
  publicClient &&
52
51
  assetOwner &&
53
52
  isAddress(assetOwner) &&
@@ -80,6 +79,7 @@ export function usePollBalance(
80
79
  },
81
80
  {
82
81
  refreshInterval: POLLING.FAST,
82
+ ...options,
83
83
  },
84
84
  );
85
85
 
@@ -1,5 +1,4 @@
1
1
  import { useMemo } from "react";
2
- import useSWR from "swr";
3
2
  import type { Address } from "viem";
4
3
 
5
4
  import {
@@ -7,6 +6,7 @@ import {
7
6
  useConfig,
8
7
  usePublicClient,
9
8
  } from "@berachain/wagmi/hooks";
9
+ import { useSWR } from "@berachain/utils/pkg/swr";
10
10
 
11
11
  import { getWalletBalances } from "../../actions/tokens/getWalletBalances";
12
12
  import { POLLING } from "../../enum/polling";
@@ -67,7 +67,7 @@ export function usePollWalletBalances(
67
67
  },
68
68
  {
69
69
  refreshInterval: POLLING.NORMAL,
70
- ...options?.opts,
70
+ ...options,
71
71
  },
72
72
  );
73
73
 
@@ -1,7 +1,7 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { isAddress, zeroAddress } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getStakingTokenInformation } from "../../actions/pol/getStakingTokenInformation";
7
7
  import type { Token } from "../../types/dex";
@@ -48,7 +48,7 @@ export const useStakingTokenInformation = (
48
48
  publicClient,
49
49
  });
50
50
  },
51
- { ...options?.opts },
51
+ { ...options },
52
52
  );
53
53
 
54
54
  return {
@@ -1,9 +1,10 @@
1
1
  import { useMemo } from "react";
2
- import useSWR from "swr";
3
2
  import { type Address, isAddress, zeroAddress } from "viem";
4
3
 
5
4
  import { defaultChainId } from "@berachain/config/internal";
6
5
 
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
+
7
8
  import { getTokenCurrentPrices } from "../../actions/prices/getTokenCurrentPrices";
8
9
  import { POLLING } from "../../enum/polling";
9
10
  import type { TokenCurrentPriceMap, TokenWithPrice } from "../../types/dex";
@@ -21,10 +22,8 @@ export function useTokenCurrentPrices(
21
22
  addressIn?: string[] | readonly string[];
22
23
  } = {},
23
24
  options: DefaultHookOptions = {
24
- opts: {
25
- refreshInterval: POLLING.NORMAL,
26
- revalidateOnFocus: true,
27
- },
25
+ refreshInterval: POLLING.NORMAL,
26
+ revalidateOnFocus: true,
28
27
  },
29
28
  ) {
30
29
  const { tokenList, ensoTokens } = useTokens();
@@ -65,13 +64,12 @@ export function useTokenCurrentPrices(
65
64
  ? beraAddresses
66
65
  : tokenList.map((token) => token.address);
67
66
 
68
- const QUERY_KEY =
69
- addresses && (options.opts?.isEnabled ?? true)
70
- ? ([
71
- "useTokenCurrentPrices",
72
- addresses.map((a) => a.toLowerCase() as Address),
73
- ] as const)
74
- : null;
67
+ const QUERY_KEY = addresses
68
+ ? ([
69
+ "useTokenCurrentPrices",
70
+ addresses.map((a) => a.toLowerCase() as Address),
71
+ ] as const)
72
+ : null;
75
73
 
76
74
  const apiResponse = useSWR(
77
75
  QUERY_KEY,
@@ -79,7 +77,7 @@ export function useTokenCurrentPrices(
79
77
  // this only works for Berachain tokens
80
78
  return getTokenCurrentPrices({ addressIn: addresses });
81
79
  },
82
- options.opts,
80
+ options,
83
81
  );
84
82
 
85
83
  const ensoMatchingPrices = useMemo<TokenCurrentPriceMap>(() => {
@@ -1,9 +1,9 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { isAddress, zeroAddress } from "viem";
3
2
 
4
3
  import { defaultChainId } from "@berachain/config/internal";
5
4
 
6
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { getTokenInformation } from "../../actions/tokens/getTokenInformation";
9
9
  import { assertPublicClient } from "../../errors/assert";
@@ -57,7 +57,7 @@ export function useTokenInformation(
57
57
  chainId,
58
58
  });
59
59
  },
60
- { ...options?.opts },
60
+ { ...options },
61
61
  );
62
62
 
63
63
  return {
@@ -7,7 +7,7 @@ export function useTokenPrice(
7
7
  { token }: { token: TokenPriceInput | undefined },
8
8
  options?: DefaultHookOptions,
9
9
  ) {
10
- const { isLoading, priceMap } = useTokenPrices(
10
+ const { isLoading, error, priceMap } = useTokenPrices(
11
11
  { tokens: token ? [token] : undefined },
12
12
  options,
13
13
  );
@@ -17,5 +17,6 @@ export function useTokenPrice(
17
17
  ? priceMap[token.chainId]?.[token.address.toLowerCase() as Address]
18
18
  : undefined,
19
19
  isLoading,
20
+ error,
20
21
  };
21
22
  }
@@ -23,10 +23,8 @@ export function useTokenPrices(
23
23
  tokens?: TokenPriceInput[];
24
24
  } = {},
25
25
  options: DefaultHookOptions = {
26
- opts: {
27
- refreshInterval: POLLING.NORMAL,
28
- revalidateOnFocus: true,
29
- },
26
+ refreshInterval: POLLING.NORMAL,
27
+ revalidateOnFocus: true,
30
28
  },
31
29
  ) {
32
30
  const { ensoTokens } = useTokens();
@@ -126,6 +124,7 @@ export function useTokenPrices(
126
124
 
127
125
  return {
128
126
  isLoading: apiResponse.isLoading,
127
+ error: apiResponse.error,
129
128
  data,
130
129
  priceMap,
131
130
  getTokenPrice,
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import { type Address, erc20Abi } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { assertPublicClient } from "../../errors/assert";
7
7
 
@@ -1,6 +1,5 @@
1
- import useSWRImmutable from "swr/immutable";
2
-
3
1
  import { useConfig } from "@berachain/wagmi/hooks";
2
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getUnderlyingToken } from "../../actions/tokens/getUnderlyingToken";
6
5
  import type { MinimalERC20 } from "../../types/dex";
@@ -1,6 +1,5 @@
1
- import useSWRImmutable from "swr/immutable";
2
-
3
1
  import { useBlockNumber, usePublicClient } from "@berachain/wagmi/hooks";
2
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getBlockTimestamp } from "../actions/misc/getBlockTimestamp";
6
5
  import { useBlockTime } from "../contexts/block-time-provider";
@@ -1,8 +1,9 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { isAddress, zeroAddress } from "viem";
3
2
 
4
3
  import { chainId } from "@berachain/config/internal";
5
4
 
5
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
6
+
6
7
  import { beraFetchJson } from "../utils/beraFetch";
7
8
 
8
9
  interface SuccessResponse {
@@ -1,10 +1,9 @@
1
- import useSWR from "swr";
2
-
3
1
  import type {
4
2
  GetValidatorsQuery,
5
3
  GetValidatorsQueryVariables,
6
4
  GqlChain,
7
5
  } from "@berachain/graphql/pol/api";
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
8
7
 
9
8
  import { getAllValidators } from "../../actions/validators/getAllValidators";
10
9
  import { POLLING } from "../../enum/polling";
@@ -40,7 +39,7 @@ export const useAllValidators = (
40
39
  },
41
40
  {
42
41
  refreshInterval: POLLING.SLOW,
43
- ...options?.opts,
42
+ ...options,
44
43
  },
45
44
  );
46
45
 
@@ -1,4 +1,4 @@
1
- import useSWR from "swr";
1
+ import { useSWR } from "@berachain/utils/pkg/swr";
2
2
 
3
3
  import { getApiEnrichedAllocation } from "../../actions/validators/getApiEnrichedAllocation";
4
4
  import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import { type Address, isHex } from "viem";
3
2
 
4
3
  import type { GetValidatorQuery } from "@berachain/graphql/pol/api";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getApiValidator } from "../../actions/validators/getApiValidator";
7
7
  import type {
@@ -20,17 +20,14 @@ export const useApiValidator = (
20
20
  options?: DefaultHookOptions,
21
21
  ): UsePollValidatorInfoResponse => {
22
22
  const QUERY_KEY = useApiValidatorQueryKey(id);
23
- const isEnabled = options?.opts?.isEnabled ?? true;
24
23
  const swrResponse = useSWR(
25
- isEnabled && id ? QUERY_KEY : null,
24
+ id ? QUERY_KEY : null,
26
25
  async ([, id]) => {
27
26
  if (!id || !isHex(id)) throw new Error(`Invalid validator ID: ${id}`);
28
27
 
29
28
  return getApiValidator({ id });
30
29
  },
31
- {
32
- ...options?.opts,
33
- },
30
+ options,
34
31
  );
35
32
 
36
33
  return {
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { usePublicClient } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getBaselineRewardAllocation } from "../../actions/validators/getBaselineRewardAllocation";
6
5
  import { assertPublicClient } from "../../errors/assert";
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import type { GetValidatorBlockStatsQuery } from "@berachain/graphql/pol/subgraph";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getDailyValidatorBlockStats } from "../../actions/validators/getDailyValidatorBlockStats";
7
7
  import { POLLING } from "../../enum/polling";
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { usePublicClient } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getDefaultRewardAllocation } from "../../actions/validators/getDefaultRewardAllocation";
6
5
  import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
@@ -21,7 +20,7 @@ export function useDefaultRewardAllocation(options?: DefaultHookOptions) {
21
20
  });
22
21
  },
23
22
  {
24
- ...options?.opts,
23
+ ...options,
25
24
  },
26
25
  );
27
26
 
@@ -1,8 +1,8 @@
1
1
  import { useMemo } from "react";
2
- import useSWR from "swr";
3
2
  import type { Address, PublicClient } from "viem";
4
3
 
5
4
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
5
+ import { useSWR } from "@berachain/utils/pkg/swr";
6
6
 
7
7
  import { getValidatorOperatorAddress } from "../../actions/validators/getValidatorOperatorAddress";
8
8
  import { getValidatorRewardAllocatorAddress } from "../../actions/validators/getValidatorRewardAllocatorAddress";
@@ -93,7 +93,7 @@ export function useManagedValidatorRole(
93
93
  };
94
94
  },
95
95
  {
96
- ...options?.opts,
96
+ ...options,
97
97
  },
98
98
  );
99
99
 
@@ -1,4 +1,3 @@
1
- import useSWR from "swr";
2
1
  import { type Address, keccak256 } from "viem";
3
2
 
4
3
  import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
@@ -7,6 +6,7 @@ import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
7
6
 
8
7
  import type { ApiValidatorFragment } from "@berachain/graphql/pol/api";
9
8
  import { usePublicClient } from "@berachain/wagmi/hooks";
9
+ import { useSWR } from "@berachain/utils/pkg/swr";
10
10
 
11
11
  import { assertPublicClient } from "../../errors/assert";
12
12
  import type {
@@ -21,9 +21,8 @@ export const useOnChainValidator = (
21
21
  ): DefaultHookReturnType<Partial<ApiValidatorFragment>> => {
22
22
  const publicClient = usePublicClient();
23
23
  const QUERY_KEY = pubkey ? (["useOnChainValidator", pubkey] as const) : null;
24
- const isEnabled = options.opts?.isEnabled ?? true;
25
24
  const swrResponse = useSWR(
26
- isEnabled && publicClient ? QUERY_KEY : null,
25
+ publicClient ? QUERY_KEY : null,
27
26
  async ([, pubkey]) => {
28
27
  assertPublicClient(publicClient);
29
28
 
@@ -59,6 +58,7 @@ export const useOnChainValidator = (
59
58
  votingPower: Number(boostees),
60
59
  } as Partial<ApiValidatorFragment>;
61
60
  },
61
+ options,
62
62
  );
63
63
 
64
64
  return {
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getStakingPoolBatch } from "../../actions/validators/getStakingPoolBatch";
7
7
  import { POLLING } from "../../enum/polling";
@@ -19,9 +19,8 @@ export const useStakingPoolBatch = ({
19
19
  options?: DefaultHookOptions;
20
20
  }): DefaultHookReturnType<number | undefined> => {
21
21
  const publicClient = usePublicClient();
22
- const isEnabled = options?.opts?.isEnabled ?? true;
23
22
  const QUERY_KEY =
24
- isEnabled && publicClient && valPubKey
23
+ publicClient && valPubKey
25
24
  ? (["useStakingPoolBatch", valPubKey] as const)
26
25
  : null;
27
26
 
@@ -37,7 +36,7 @@ export const useStakingPoolBatch = ({
37
36
  },
38
37
  {
39
38
  refreshInterval: POLLING.FAST,
40
- ...options?.opts,
39
+ ...options,
41
40
  },
42
41
  );
43
42
 
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import {
6
5
  getUserActiveValidators,
@@ -35,7 +34,7 @@ export const useUserActiveValidators = (
35
34
  },
36
35
  {
37
36
  ...options,
38
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.SLOW,
37
+ refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
39
38
  keepPreviousData: true,
40
39
  },
41
40
  );
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import {
7
7
  getUserBoostsOnValidator,
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useMemo } from "react";
2
- import useSWR from "swr";
3
2
 
4
3
  import { useBeraWallet } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getRewardProofsByValidator } from "../../actions/pol/getRewardProofsByValidator";
7
7
  import { getUserClaimableIncentives } from "../../actions/pol/getUserClaimableIncentives";
@@ -1,6 +1,7 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import type { Address } from "viem";
3
2
 
3
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
4
+
4
5
  import { getUserStakingPositions } from "../../actions/validators/getUserStakingPositions";
5
6
 
6
7
  /**
@@ -40,12 +40,8 @@ export function useValidator(
40
40
  "",
41
41
  queuedBoostAmount:
42
42
  indexerValidator?.dynamicData?.queuedBoostAmount ?? "",
43
- usersActiveBoostCount:
44
- indexerValidator?.dynamicData?.usersActiveBoostCount ?? 0,
45
- usersQueuedBoostCount:
46
- indexerValidator?.dynamicData?.usersQueuedBoostCount ?? 0,
47
- allTimeDistributedBGTAmount:
48
- indexerValidator?.dynamicData?.allTimeDistributedBGTAmount ??
43
+ allTimeDistributedRewards:
44
+ indexerValidator?.dynamicData?.allTimeDistributedRewards ??
49
45
  "0",
50
46
  rewardRate:
51
47
  onChainValidator?.dynamicData?.rewardRate ??
@@ -53,8 +49,8 @@ export function useValidator(
53
49
  "",
54
50
  stakedBeraAmount:
55
51
  indexerValidator?.dynamicData?.stakedBeraAmount ?? "",
56
- lastDayDistributedBGTAmount:
57
- indexerValidator?.dynamicData?.lastDayDistributedBGTAmount ??
52
+ lastDayDistributedRewards:
53
+ indexerValidator?.dynamicData?.lastDayDistributedRewards ??
58
54
  "",
59
55
  lastDayProposedBlockCount:
60
56
  indexerValidator?.dynamicData?.lastDayProposedBlockCount ?? 0,
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import type { GetValidatorAnalyticsQuery } from "@berachain/graphql/pol/subgraph";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getValidatorAnalytics } from "../../actions/validators/getValidatorAnalytics";
7
7
  import { POLLING } from "../../enum/polling";
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address, PublicClient } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import useSWR from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getValidatorCommission } from "../../actions/validators/getValidatorCommission";
7
7
  import type {
@@ -28,7 +28,7 @@ export const useValidatorCommission = (
28
28
  });
29
29
  },
30
30
  {
31
- ...options?.opts,
31
+ ...options,
32
32
  },
33
33
  );
34
34
 
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
- import type { GetValidatorIncentiveDistributionQuery } from "@berachain/graphql/pol/subgraph";
3
+ import type { ValidatorIncentivesResponse } from "@berachain/graphql/beep";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getValidatorIncentiveDistribution } from "../../actions/validators/getValidatorIncentiveDistribution";
7
7
  import { POLLING } from "../../enum/polling";
@@ -19,7 +19,7 @@ export function useValidatorIncentiveDistribution({
19
19
  }: {
20
20
  pubkey: Address | undefined;
21
21
  dayRange: number;
22
- }): DefaultHookReturnType<GetValidatorIncentiveDistributionQuery> {
22
+ }): DefaultHookReturnType<ValidatorIncentivesResponse> {
23
23
  const QUERY_KEY =
24
24
  pubkey && dayRange
25
25
  ? (["useValidatorIncentiveDistribution", pubkey, dayRange] as const)
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import {
7
7
  getValidatorQueuedCommission,
@@ -33,7 +33,7 @@ export function useValidatorQueuedCommission(
33
33
  });
34
34
  },
35
35
  {
36
- ...options?.opts,
36
+ ...options,
37
37
  },
38
38
  );
39
39
 
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address, PublicClient } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import {
7
7
  getValidatorQueuedOperatorAddress,
@@ -31,7 +31,7 @@ export const useValidatorQueuedOperatorAddress = (
31
31
  });
32
32
  },
33
33
  {
34
- ...options?.opts,
34
+ ...options,
35
35
  },
36
36
  );
37
37
 
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address, PublicClient } from "viem";
3
2
 
4
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getValidatorQueuedRewardAllocation } from "../../actions/validators/getValidatorQueuedRewardAllocation";
7
7
  import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
@@ -29,7 +29,7 @@ export const useValidatorQueuedRewardAllocation = (
29
29
  });
30
30
  },
31
31
  {
32
- ...options?.opts,
32
+ ...options,
33
33
  },
34
34
  );
35
35