@berachain/berajs 0.2.10 → 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 (144) hide show
  1. package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
  2. package/dist/actions/clients/exports.mjs +1 -1
  3. package/dist/actions/exports.d.ts +67 -17
  4. package/dist/actions/exports.mjs +60 -19
  5. package/dist/actions/governance/exports.d.ts +3 -11
  6. package/dist/{chunk-P5WXXULM.mjs → chunk-MRQGHXAN.mjs} +1 -1
  7. package/dist/{chunk-WNBWX23Q.mjs → chunk-SXUNCX5E.mjs} +5 -4
  8. package/dist/chunk-UD5IUNCW.mjs +34 -0
  9. package/dist/{chunk-QBBOWFMH.mjs → chunk-VAA2FVPP.mjs} +58 -12
  10. package/dist/contexts/exports.d.ts +2 -2
  11. package/dist/contexts/exports.mjs +4 -2
  12. package/dist/enum/exports.d.ts +8 -2
  13. package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
  14. package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts} +2 -2
  15. package/dist/{global.d-BuGDKh4k.d.ts → global.d-q_LQWQqs.d.ts} +2 -4
  16. package/dist/hooks/exports.d.ts +100 -149
  17. package/dist/hooks/exports.mjs +468 -484
  18. package/dist/hooks/governance/exports.d.ts +20 -15
  19. package/dist/hooks/governance/exports.mjs +39 -37
  20. package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
  21. package/dist/types/exports.d.ts +5 -5
  22. package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
  23. package/dist/utils/exports.d.ts +2 -2
  24. package/dist/utils/exports.mjs +4 -0
  25. package/package.json +8 -7
  26. package/src/actions/bend/getMaxDeposit.ts +28 -2
  27. package/src/actions/clients/fetchOpenApi.ts +6 -2
  28. package/src/actions/clients/fetchOpenApi.unit.test.ts +24 -2
  29. package/src/actions/exports.ts +1 -0
  30. package/src/actions/honey/getChartData.ts +53 -12
  31. package/src/actions/honey/getHoney24hVolume.ts +34 -6
  32. package/src/actions/honey/getHoneyTxns.ts +93 -0
  33. package/src/actions/validators/getValidatorIncentiveDistribution.ts +64 -12
  34. package/src/contexts/SwrFallback.tsx +2 -1
  35. package/src/data/contracts.ts +4 -0
  36. package/src/errors/getRevertReason.integration.test.ts +5 -1
  37. package/src/hooks/bend/useGetConvertToAssets.ts +2 -3
  38. package/src/hooks/dex/useAggregatorsQuotes.ts +10 -10
  39. package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -1
  40. package/src/hooks/dex/useAllUserPools.ts +7 -5
  41. package/src/hooks/dex/useApiPool.ts +1 -1
  42. package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -1
  43. package/src/hooks/dex/useOnChainPoolData.ts +1 -1
  44. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +2 -2
  45. package/src/hooks/dex/usePoolEvents.ts +1 -2
  46. package/src/hooks/dex/usePoolHistoricalData.ts +2 -3
  47. package/src/hooks/dex/usePools.ts +4 -2
  48. package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
  49. package/src/hooks/enso/useBendDemultiply.ts +3 -4
  50. package/src/hooks/enso/useBendMultiply.ts +3 -4
  51. package/src/hooks/enso/useBendZapSupply.ts +3 -4
  52. package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
  53. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +3 -5
  54. package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
  55. package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
  56. package/src/hooks/enso/useZapStakeBera.ts +2 -2
  57. package/src/hooks/exports.ts +1 -0
  58. package/src/hooks/governance/useGetPastVotes.ts +1 -1
  59. package/src/hooks/governance/useHasVoted.ts +1 -1
  60. package/src/hooks/governance/useIsCanceller.ts +1 -1
  61. package/src/hooks/governance/usePollAllProposals.ts +13 -12
  62. package/src/hooks/governance/usePollProposal.ts +3 -3
  63. package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
  64. package/src/hooks/governance/usePollProposalVotes.ts +23 -5
  65. package/src/hooks/governance/usePollUserDelegates.ts +3 -3
  66. package/src/hooks/governance/useProposalFromTx.ts +2 -1
  67. package/src/hooks/governance/useProposalSnapshot.ts +2 -3
  68. package/src/hooks/governance/useProposalState.ts +2 -2
  69. package/src/hooks/governance/useProposalTimelockState.ts +2 -1
  70. package/src/hooks/governance/useQuorum.ts +1 -2
  71. package/src/hooks/honey/useCappedGlobally.ts +3 -6
  72. package/src/hooks/honey/useCappedRelatively.ts +2 -2
  73. package/src/hooks/honey/useCollateralWeights.ts +3 -3
  74. package/src/hooks/honey/useHoney24hVolume.ts +1 -1
  75. package/src/hooks/honey/useHoneyBalances.ts +1 -1
  76. package/src/hooks/honey/useHoneyChartData.ts +1 -1
  77. package/src/hooks/honey/useHoneyVaultsBalance.ts +2 -3
  78. package/src/hooks/honey/useIsBadCollateralAsset.ts +4 -7
  79. package/src/hooks/honey/useIsBasketModeEnabled.ts +4 -7
  80. package/src/hooks/honey/usePythLatestPrices.ts +13 -9
  81. package/src/hooks/perps/usePythUpdateFee.ts +13 -11
  82. package/src/hooks/pol/useAutoclaimedIncentives.ts +1 -2
  83. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +1 -2
  84. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +39 -0
  85. package/src/hooks/pol/useBgtUnstakedBalance.ts +2 -2
  86. package/src/hooks/pol/useClaimableFees.ts +1 -1
  87. package/src/hooks/pol/useHighestVaultsAPR.ts +4 -6
  88. package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
  89. package/src/hooks/pol/usePollGlobalData.ts +2 -3
  90. package/src/hooks/pol/usePollMarkets.ts +2 -2
  91. package/src/hooks/pol/useQueuedBeraUnlock.ts +2 -2
  92. package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
  93. package/src/hooks/pol/useRewardVault.ts +7 -6
  94. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +4 -4
  95. package/src/hooks/pol/useRewardVaultFromToken.ts +1 -1
  96. package/src/hooks/pol/useRewardVaultIncentives.ts +1 -1
  97. package/src/hooks/pol/useRewardVaultRewards.ts +2 -2
  98. package/src/hooks/pol/useRewardVaults.ts +3 -6
  99. package/src/hooks/pol/useStakedAPR.ts +1 -2
  100. package/src/hooks/pol/useStakedData.ts +90 -41
  101. package/src/hooks/pol/useStakedSnapshots.ts +1 -1
  102. package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
  103. package/src/hooks/pol/useTotalStakedAmount.ts +1 -2
  104. package/src/hooks/pol/useUserVaultInfo.ts +2 -2
  105. package/src/hooks/pol/useUserVaults.ts +2 -3
  106. package/src/hooks/pol/useVaultAddress.ts +1 -1
  107. package/src/hooks/pol/useVaultHistory.ts +1 -2
  108. package/src/hooks/pol/useVaultValidators.ts +2 -2
  109. package/src/hooks/tokens/useMultipleTokenInformation.ts +2 -2
  110. package/src/hooks/tokens/usePollAllowances.ts +3 -4
  111. package/src/hooks/tokens/usePollBalance.ts +2 -2
  112. package/src/hooks/tokens/usePollWalletBalances.ts +2 -2
  113. package/src/hooks/tokens/useStakingTokenInformation.ts +2 -2
  114. package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
  115. package/src/hooks/tokens/useTokenInformation.ts +2 -2
  116. package/src/hooks/tokens/useTokenPrice.ts +2 -1
  117. package/src/hooks/tokens/useTokenPrices.ts +3 -4
  118. package/src/hooks/tokens/useTotalSupply.ts +1 -1
  119. package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
  120. package/src/hooks/useBlockToTimestamp.ts +1 -2
  121. package/src/hooks/useGetVerifiedAbi.ts +2 -1
  122. package/src/hooks/validators/useAllValidators.ts +2 -3
  123. package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
  124. package/src/hooks/validators/useApiValidator.ts +3 -6
  125. package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
  126. package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
  127. package/src/hooks/validators/useDefaultRewardAllocation.ts +2 -3
  128. package/src/hooks/validators/useManagedValidatorRole.ts +2 -2
  129. package/src/hooks/validators/useOnChainValidator.ts +3 -3
  130. package/src/hooks/validators/useStakingPoolBatch.ts +3 -4
  131. package/src/hooks/validators/useUserActiveValidators.ts +2 -3
  132. package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
  133. package/src/hooks/validators/useUserClaimableIncentives.ts +1 -1
  134. package/src/hooks/validators/useUserStakingPositions.ts +2 -1
  135. package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
  136. package/src/hooks/validators/useValidatorCommission.ts +2 -2
  137. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +3 -3
  138. package/src/hooks/validators/useValidatorQueuedCommission.ts +2 -2
  139. package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +2 -2
  140. package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +2 -2
  141. package/src/hooks/validators/useValidatorRewardAllocation.ts +2 -2
  142. package/src/types/global.d.ts +3 -4
  143. package/src/types/pol.d.ts +17 -3
  144. package/dist/polling-BKnyavLI.d.ts +0 -8
@@ -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 {
6
5
  type IsBadCollateralResponse,
@@ -34,9 +33,7 @@ export const useIsBadCollateralAsset = (
34
33
  : undefined,
35
34
  },
36
35
  {
37
- opts: {
38
- isEnabled: flags.isPythWrapperEnabled && !!collateral?.address,
39
- },
36
+ isEnabled: flags.isPythWrapperEnabled && !!collateral?.address,
40
37
  },
41
38
  );
42
39
  const QUERY_KEY =
@@ -65,8 +62,8 @@ export const useIsBadCollateralAsset = (
65
62
  });
66
63
  },
67
64
  {
68
- ...options?.opts,
69
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.NORMAL,
65
+ ...options,
66
+ refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
70
67
  },
71
68
  );
72
69
 
@@ -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 { isBasketModeEnabled } from "../../actions/honey/isBasketModeEnabled";
6
5
  import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
@@ -24,9 +23,7 @@ export function useIsBasketModeEnabled(
24
23
  priceFeedMap,
25
24
  },
26
25
  {
27
- opts: {
28
- isEnabled: flags.isPythWrapperEnabled && !!collateralList.length,
29
- },
26
+ isEnabled: flags.isPythWrapperEnabled && !!collateralList.length,
30
27
  },
31
28
  );
32
29
  const isMint = state.actionType === "mint";
@@ -61,8 +58,8 @@ export function useIsBasketModeEnabled(
61
58
  return isActive;
62
59
  },
63
60
  {
64
- ...options?.opts,
65
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.FAST,
61
+ ...options,
62
+ refreshInterval: options?.refreshInterval ?? POLLING.FAST,
66
63
  },
67
64
  );
68
65
  return {
@@ -1,4 +1,5 @@
1
- import useSWR, { type SWRResponse } from "swr";
1
+ import type { SWRResponse } from "@berachain/utils/pkg/swr";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
2
3
 
3
4
  import type { PythLatestUpdates } from "../../actions/honey/getPythLatestPrices";
4
5
  import { getPythLatestPrices } from "../../actions/honey/getPythLatestPrices";
@@ -27,15 +28,18 @@ export function usePythLatestPrices(
27
28
  ): SWRResponse<PythLatestUpdates> {
28
29
  const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
29
30
 
30
- const QUERY_KEY =
31
- (options?.opts?.isEnabled ?? true) && priceFeedIds
32
- ? (["usePythLatestPrices", priceFeedIds] as const)
33
- : null;
31
+ const QUERY_KEY = priceFeedIds
32
+ ? (["usePythLatestPrices", priceFeedIds] as const)
33
+ : null;
34
34
 
35
- const swrResponse = useSWR(QUERY_KEY, async ([_, priceFeeds]) => {
36
- const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
37
- return data;
38
- });
35
+ const swrResponse = useSWR(
36
+ QUERY_KEY,
37
+ async ([_, priceFeeds]) => {
38
+ const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
39
+ return data;
40
+ },
41
+ options,
42
+ );
39
43
 
40
44
  return swrResponse;
41
45
  }
@@ -1,7 +1,7 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import type { Address } 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 { getPythUpdateFee } from "../../actions/pyth/getUpdateFee";
7
7
  import { assertPublicClient } from "../../errors/assert";
@@ -20,20 +20,22 @@ export const usePythUpdateFee = (
20
20
  ) => {
21
21
  const publicClient = usePublicClient();
22
22
  const QUERY_KEY =
23
- (options?.opts?.isEnabled ?? true) &&
24
- pythPriceFeedCalldata &&
25
- pythPriceFeedCalldata.length > 0
23
+ pythPriceFeedCalldata && pythPriceFeedCalldata.length > 0
26
24
  ? (["usePythUpdateFee", pythPriceFeedCalldata] as const)
27
25
  : null;
28
26
  const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } =
29
- useSWRImmutable(QUERY_KEY, async ([_, pythPriceFeedCalldata]) => {
30
- assertPublicClient(publicClient);
27
+ useSWRImmutable(
28
+ QUERY_KEY,
29
+ async ([_, pythPriceFeedCalldata]) => {
30
+ assertPublicClient(publicClient);
31
31
 
32
- return getPythUpdateFee({
33
- client: publicClient,
34
- priceFeedId: pythPriceFeedCalldata,
35
- });
36
- });
32
+ return getPythUpdateFee({
33
+ client: publicClient,
34
+ priceFeedId: pythPriceFeedCalldata,
35
+ });
36
+ },
37
+ options,
38
+ );
37
39
 
38
40
  return {
39
41
  QUERY_KEY,
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { useBeraWallet } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getAutoclaimedIncentives } from "../../actions/pol/getAutoclaimedIncentives";
6
5
  import type { AutoclaimedIncentivesResponse } from "../../types/bribe-boost";
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { useBeraWallet } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getAutoclaimedIncentivesTxHash } from "../../actions/pol/getAutoclaimedIncentivesTxHash";
6
5
  import { POLLING } from "../../enum/polling";
@@ -0,0 +1,39 @@
1
+ import { usePublicClient } from "@berachain/wagmi/hooks";
2
+ import useSWR from "@berachain/utils/pkg/swr";
3
+
4
+ import { getBgtIncentiveDistributorPaused } from "../../actions/pol/getBgtIncentiveDistributorPaused";
5
+ import type {
6
+ DefaultHookOptions,
7
+ DefaultHookReturnType,
8
+ } from "../../types/global";
9
+
10
+ /**
11
+ * Client hook around `getBgtIncentiveDistributorPaused`. When `paused()` is
12
+ * true, users can no longer self-claim incentives and the bot distributes them
13
+ * on their behalf. Fails closed (`false`) so a read error never blocks the UI.
14
+ */
15
+ export function useBgtIncentiveDistributorPaused(
16
+ options?: DefaultHookOptions,
17
+ ): DefaultHookReturnType<boolean> {
18
+ const publicClient = usePublicClient();
19
+
20
+ const QUERY_KEY = publicClient
21
+ ? (["useBgtIncentiveDistributorPaused", publicClient.chain?.id] as const)
22
+ : null;
23
+
24
+ const swrResponse = useSWR(
25
+ QUERY_KEY,
26
+ async () =>
27
+ getBgtIncentiveDistributorPaused({ publicClient }).catch(() => false),
28
+ {
29
+ revalidateOnFocus: false,
30
+ revalidateOnReconnect: false,
31
+ ...options,
32
+ },
33
+ );
34
+
35
+ return {
36
+ ...swrResponse,
37
+ refresh: () => swrResponse?.mutate?.(),
38
+ };
39
+ }
@@ -1,9 +1,9 @@
1
- import useSWR from "swr";
2
1
  import { formatEther } from "viem";
3
2
 
4
3
  import { bgtAbi } from "@berachain/abis/pol/bgt";
5
4
 
6
5
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { POLLING } from "../../enum/polling";
9
9
  import { assertPublicClient } from "../../errors/assert";
@@ -43,7 +43,7 @@ export const useBgtUnstakedBalance = (
43
43
  },
44
44
  {
45
45
  ...options,
46
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.NORMAL,
46
+ refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
47
47
  },
48
48
  );
49
49
 
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import { formatUnits } 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 { getUserVaultsReward } from "../../actions/pol/getUserVaultsReward";
7
7
  import { POLLING } from "../../enum/polling";
@@ -40,12 +40,10 @@ export const useHighestVaultsAPR = (
40
40
  },
41
41
  },
42
42
  {
43
- opts: {
44
- refreshInterval: 0,
45
- revalidateOnFocus: false,
46
- refreshWhenOffline: false,
47
- isEnabled,
48
- },
43
+ refreshInterval: 0,
44
+ revalidateOnFocus: false,
45
+ refreshWhenOffline: false,
46
+ isEnabled,
49
47
  },
50
48
  );
51
49
 
@@ -1,10 +1,10 @@
1
- import useSWR from "swr";
2
1
  import { type Address, erc20Abi, formatUnits, isAddress } from "viem";
3
2
 
4
3
  import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
5
4
 
6
5
  import type { ApiVaultFragment } from "@berachain/graphql/pol/api";
7
6
  import { usePublicClient } from "@berachain/wagmi/hooks";
7
+ import { useSWR } from "@berachain/utils/pkg/swr";
8
8
 
9
9
  import { getRewardVaultIncentives } from "../../actions/pol/getRewardVaultIncentives";
10
10
  import { getRewardVaultStakingToken } from "../../actions/pol/getRewardVaultStakingToken";
@@ -28,7 +28,6 @@ export const useOnChainRewardVault = (
28
28
  opt: DefaultHookOptions,
29
29
  ) => {
30
30
  const publicClient = usePublicClient();
31
- const isEnabled = opt.opts?.isEnabled ?? true;
32
31
 
33
32
  const QUERY_KEY = useOnChainRewardVaultQueryKey(address);
34
33
 
@@ -36,81 +35,87 @@ export const useOnChainRewardVault = (
36
35
  ApiVaultFragment,
37
36
  unknown,
38
37
  ReturnType<typeof useOnChainRewardVaultQueryKey>
39
- >(isEnabled && publicClient ? QUERY_KEY : null, async ([, address]) => {
40
- assertPublicClient(publicClient);
41
- const { config } = parseBaseArgs({
42
- chainId: publicClient.chain.id,
43
- });
38
+ >(
39
+ publicClient ? QUERY_KEY : null,
40
+ async ([, address]) => {
41
+ assertPublicClient(publicClient);
42
+ const { config } = parseBaseArgs({
43
+ chainId: publicClient.chain.id,
44
+ });
44
45
 
45
- const stakingTokenAddress = await getRewardVaultStakingToken({
46
- address,
47
- publicClient: publicClient,
48
- });
49
-
50
- const [incentives, isWhitelisted, stakingTokenAmount] = await Promise.all([
51
- getRewardVaultIncentives({
46
+ const stakingTokenAddress = await getRewardVaultStakingToken({
52
47
  address,
53
- stakingToken: stakingTokenAddress,
54
- publicClient,
55
- }),
56
- publicClient.readContract({
57
- address: config.pol.beraChef,
58
- abi: beraChefAbi,
59
- functionName: "isWhitelistedVault",
60
- args: [address],
61
- }),
62
- publicClient.readContract({
63
- address: stakingTokenAddress,
64
- abi: erc20Abi,
65
- functionName: "balanceOf",
66
- args: [address],
67
- }),
68
- ]);
69
-
70
- const [stakingToken, incentiveTokens] = await Promise.all([
71
- getStakingTokenInformation({
72
- address: stakingTokenAddress,
73
48
  publicClient: publicClient,
74
- }),
75
- Promise.all(
76
- incentives.map((add) =>
77
- getTokenInformation({
78
- address: add.token,
79
- chainId: publicClient.chain.id,
80
- publicClient: publicClient,
49
+ });
50
+
51
+ const [incentives, isWhitelisted, stakingTokenAmount] = await Promise.all(
52
+ [
53
+ getRewardVaultIncentives({
54
+ address,
55
+ stakingToken: stakingTokenAddress,
56
+ publicClient,
57
+ }),
58
+ publicClient.readContract({
59
+ address: config.pol.beraChef,
60
+ abi: beraChefAbi,
61
+ functionName: "isWhitelistedVault",
62
+ args: [address],
81
63
  }),
64
+ publicClient.readContract({
65
+ address: stakingTokenAddress,
66
+ abi: erc20Abi,
67
+ functionName: "balanceOf",
68
+ args: [address],
69
+ }),
70
+ ],
71
+ );
72
+
73
+ const [stakingToken, incentiveTokens] = await Promise.all([
74
+ getStakingTokenInformation({
75
+ address: stakingTokenAddress,
76
+ publicClient: publicClient,
77
+ }),
78
+ Promise.all(
79
+ incentives.map((add) =>
80
+ getTokenInformation({
81
+ address: add.token,
82
+ chainId: publicClient.chain.id,
83
+ publicClient: publicClient,
84
+ }),
85
+ ),
82
86
  ),
83
- ),
84
- ]);
87
+ ]);
85
88
 
86
- if (!stakingToken) {
87
- throw new Error("Staking token not found");
88
- }
89
+ if (!stakingToken) {
90
+ throw new Error("Staking token not found");
91
+ }
89
92
 
90
- return {
91
- id: address,
92
- address,
93
- vaultAddress: address,
94
- stakingToken: {
95
- address: stakingTokenAddress,
96
- name: stakingToken.name ?? "",
97
- symbol: stakingToken.symbol ?? "",
98
- decimals: stakingToken.decimals ?? 0,
99
- },
100
- stakingTokenAmount: formatUnits(
101
- stakingTokenAmount,
102
- stakingToken.decimals ?? 18,
103
- ),
104
- isVaultWhitelisted: isWhitelisted,
105
- activeIncentives: incentives.map((incentive, idx) => ({
106
- active: !!incentive.remainingAmount,
107
- remainingAmount: incentive.remainingAmount,
108
- remainingAmountUsd: "0",
109
- incentiveRate: incentive.incentiveRate,
110
- incentiveRateUsd: "0",
111
- tokenAddress: incentive.token,
112
- token: incentiveTokens[idx]!,
113
- })),
114
- } satisfies ApiVaultFragment;
115
- });
93
+ return {
94
+ id: address,
95
+ address,
96
+ vaultAddress: address,
97
+ stakingToken: {
98
+ address: stakingTokenAddress,
99
+ name: stakingToken.name ?? "",
100
+ symbol: stakingToken.symbol ?? "",
101
+ decimals: stakingToken.decimals ?? 0,
102
+ },
103
+ stakingTokenAmount: formatUnits(
104
+ stakingTokenAmount,
105
+ stakingToken.decimals ?? 18,
106
+ ),
107
+ isVaultWhitelisted: isWhitelisted,
108
+ activeIncentives: incentives.map((incentive, idx) => ({
109
+ active: !!incentive.remainingAmount,
110
+ remainingAmount: incentive.remainingAmount,
111
+ remainingAmountUsd: "0",
112
+ incentiveRate: incentive.incentiveRate,
113
+ incentiveRateUsd: "0",
114
+ tokenAddress: incentive.token,
115
+ token: incentiveTokens[idx]!,
116
+ })),
117
+ } satisfies ApiVaultFragment;
118
+ },
119
+ opt,
120
+ );
116
121
  };
@@ -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 {
6
5
  type GlobalData,
@@ -26,7 +25,7 @@ export const usePollGlobalData = (
26
25
  },
27
26
  {
28
27
  revalidateOnFocus: false,
29
- ...options?.opts,
28
+ ...options,
30
29
  },
31
30
  );
32
31
 
@@ -1,4 +1,4 @@
1
- import useSWRImmutable from "swr/immutable";
1
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
2
2
 
3
3
  import { type GetMarkets, getMarkets } from "../../actions/pol/getMarkets";
4
4
  import type {
@@ -24,7 +24,7 @@ export const usePollMarkets = (
24
24
  return res;
25
25
  },
26
26
  {
27
- ...options?.opts,
27
+ ...options,
28
28
  },
29
29
  );
30
30
 
@@ -1,7 +1,7 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { type Address, isAddress } 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 {
7
7
  getSWBeraWithdrawal,
@@ -61,7 +61,7 @@ export function useQueuedBeraUnlock(
61
61
  },
62
62
  {
63
63
  refreshInterval: POLLING.FAST,
64
- ...options?.opts,
64
+ ...options,
65
65
  },
66
66
  );
67
67
 
@@ -1,9 +1,9 @@
1
- import useSWR from "swr";
2
1
  import { type Address, 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 { useSWR } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { getRewardTokenToBeraRate } from "../../actions/pol/getRewardTokenToBeraRate";
9
9
  import { assertPublicClient } from "../../errors/assert";
@@ -42,7 +42,7 @@ export const useRewardTokenToBeraRate = (
42
42
  });
43
43
  },
44
44
  {
45
- ...opt?.opts,
45
+ ...opt,
46
46
  },
47
47
  );
48
48
  };
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import type { ApiVaultFragment } from "@berachain/graphql/pol/api";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getRewardVault } from "../../actions/pol/getRewardVault";
7
7
  import type {
@@ -24,21 +24,22 @@ export const useRewardVault = (
24
24
  ): UseRewardVaultResponse => {
25
25
  const QUERY_KEY = useRewardVaultQueryKey(id);
26
26
 
27
+ // The off-chain fetch is intentionally always enabled; `isEnabled` only gates
28
+ // the on-chain fallback below, so it is stripped from this call's options.
29
+ const { isEnabled: _isEnabled, ...swrOptions } = options ?? {};
27
30
  const swrResponse = useSWR(
28
31
  QUERY_KEY,
29
32
  async ([_, id]) => getRewardVault({ address: id }),
30
- {
31
- ...options?.opts,
32
- },
33
+ swrOptions,
33
34
  );
34
35
 
35
36
  const isOnChainEnabled =
36
- options?.opts?.isEnabled ??
37
+ options?.isEnabled ??
37
38
  ((!!swrResponse.error || !swrResponse.isLoading) && !swrResponse.data);
38
39
 
39
40
  const onChainRewardVault = useOnChainRewardVault(
40
41
  { address: id },
41
- { opts: { ...options?.opts, isEnabled: isOnChainEnabled } },
42
+ { ...options, isEnabled: isOnChainEnabled },
42
43
  );
43
44
 
44
45
  return {
@@ -1,9 +1,9 @@
1
- import useSWR from "swr";
2
1
  import { type Address, isAddress, zeroAddress } from "viem";
3
2
 
4
3
  import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
5
4
 
6
5
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { assertPublicClient } from "../../errors/assert";
9
9
  import type { DefaultHookOptions } from "../../types/global";
@@ -23,7 +23,7 @@ export const useRewardVaultBalanceFromStakingToken = (
23
23
  const { address: account } = useBeraWallet();
24
24
  const publicClient = usePublicClient();
25
25
 
26
- const isEnabled = options?.opts?.isEnabled ?? true;
26
+ const isEnabled = options?.isEnabled ?? true;
27
27
  const {
28
28
  data: rewardVaultAddress = _rewardVaultAddress,
29
29
  error,
@@ -43,8 +43,7 @@ export const useRewardVaultBalanceFromStakingToken = (
43
43
  account &&
44
44
  publicClient &&
45
45
  isAddress(rewardVaultAddress) &&
46
- isAddress(account) &&
47
- isEnabled
46
+ isAddress(account)
48
47
  ? ["useVaultBalanceFromStakingToken", rewardVaultAddress, account]
49
48
  : null,
50
49
 
@@ -70,6 +69,7 @@ export const useRewardVaultBalanceFromStakingToken = (
70
69
  balance: balance,
71
70
  };
72
71
  },
72
+ options,
73
73
  );
74
74
 
75
75
  return {
@@ -1,9 +1,9 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { type Address, isAddress, zeroAddress } from "viem";
3
2
 
4
3
  import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
5
4
 
6
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { assertPublicClient } from "../../errors/assert";
9
9
  import { parseBaseArgs } from "../../utils/parseBaseArgs";
@@ -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 { getRewardVaultIncentives } from "../../actions/pol/getRewardVaultIncentives";
7
7
  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 { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getRewardVaultRewards } from "../../actions/pol/getRewardVaultRewards";
7
7
  import { assertPublicClient } from "../../errors/assert";
@@ -26,7 +26,7 @@ export const useRewardVaultRewards = (
26
26
  return await getRewardVaultRewards(address, publicClient);
27
27
  },
28
28
  {
29
- ...options?.opts,
29
+ ...options,
30
30
  },
31
31
  );
32
32
 
@@ -1,7 +1,6 @@
1
- import useSWR from "swr";
2
-
3
1
  import type { GetVaultsQueryVariables } from "@berachain/graphql/pol/api";
4
2
  import { usePublicClient } from "@berachain/wagmi/hooks";
3
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
4
 
6
5
  import { getRewardVaults } from "../../actions/pol/getRewardVaults";
7
6
  import type { DefaultHookOptions } from "../../types/global";
@@ -26,16 +25,14 @@ export const useRewardVaults = (
26
25
  );
27
26
  const publicClient = usePublicClient();
28
27
  const swrResponse = useSWR(
29
- (options?.opts?.isEnabled ?? true) ? QUERY_KEY : null,
28
+ QUERY_KEY,
30
29
  async ([, filter, onChainIncentives]) => {
31
30
  return await getRewardVaults({
32
31
  filter: filter,
33
32
  publicClient: onChainIncentives ? publicClient : undefined,
34
33
  });
35
34
  },
36
- {
37
- ...options?.opts,
38
- },
35
+ options,
39
36
  );
40
37
 
41
38
  return {
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import type { GqlVaultSnapshotDataRange } from "@berachain/graphql/dex/api";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getStakedBeraSnapshots } from "../../actions/pol/getStakedBeraSnapshots";
6
5
  import type { DefaultHookReturnType } from "../../types/global";