@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,6 +1,6 @@
1
- import useSWRInfinite, { type SWRInfiniteKeyLoader } from "swr/infinite";
2
-
3
1
  import type { GetProposalVotesQueryVariables } from "@berachain/graphql/governance";
2
+ import type { SWRInfiniteKeyLoader } from "@berachain/utils/pkg/swr/infinite";
3
+ import { useSWRInfinite } from "@berachain/utils/pkg/swr/infinite";
4
4
 
5
5
  import { getProposalVotes } from "../../actions/governance/getProposalVotes";
6
6
 
@@ -12,6 +12,17 @@ type UsePollProposalVotesArgs = Omit<
12
12
  // const ACTUAL_PER_PAGE = 500;
13
13
 
14
14
  const DEFAULT_LIMIT = 1000;
15
+
16
+ type ProposalVotesKey =
17
+ | [
18
+ string,
19
+ number,
20
+ number,
21
+ UsePollProposalVotesArgs["proposalId"],
22
+ UsePollProposalVotesArgs["orderBy"],
23
+ UsePollProposalVotesArgs["orderDirection"],
24
+ ]
25
+ | null;
15
26
  /**
16
27
  * Fetches all the votes for a proposal from the Subgraph
17
28
  * @param args - The arguments to pass to the query
@@ -21,9 +32,13 @@ export const usePollProposalVotes = (
21
32
  args: UsePollProposalVotesArgs,
22
33
  total: number,
23
34
  ) => {
24
- return useSWRInfinite(
35
+ return useSWRInfinite<
36
+ Awaited<ReturnType<typeof getProposalVotes>>,
37
+ any,
38
+ ProposalVotesKey
39
+ >(
25
40
  usePollProposalVotesQueryKey(args, total),
26
- async ([_key, page]: [string, number]) => {
41
+ async ([_key, page]) => {
27
42
  return getProposalVotes({
28
43
  variables: {
29
44
  ...args,
@@ -44,7 +59,10 @@ export const usePollProposalVotesQueryKey =
44
59
  (
45
60
  { ...args }: UsePollProposalVotesArgs,
46
61
  total: number,
47
- ): SWRInfiniteKeyLoader =>
62
+ ): SWRInfiniteKeyLoader<
63
+ Awaited<ReturnType<typeof getProposalVotes>>,
64
+ ProposalVotesKey
65
+ > =>
48
66
  (
49
67
  pageIndex: number,
50
68
  // previousPageData: Awaited<ReturnType<typeof getProposalVotes>>,
@@ -1,9 +1,9 @@
1
- import useSWR from "swr";
2
1
  import { type Address, 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";
@@ -62,8 +62,8 @@ export const usePollUserDelegates = (
62
62
  };
63
63
  },
64
64
  {
65
- ...options?.opts,
66
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.SLOW,
65
+ ...options,
66
+ refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
67
67
  },
68
68
  );
69
69
 
@@ -1,8 +1,9 @@
1
- import useSWR, { type SWRResponse } from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import type { ProposalWithVotesFragment } from "@berachain/graphql/governance";
5
4
  import { usePublicClient, useTransactionReceipt } from "@berachain/wagmi/hooks";
5
+ import type { SWRResponse } from "@berachain/utils/pkg/swr";
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
6
7
 
7
8
  import { getProposalFromTx } from "../../actions/governance/getProposalFromTx";
8
9
 
@@ -1,9 +1,8 @@
1
- import type { SWRResponse } from "swr";
2
- import useSWRImmutable from "swr/immutable";
3
-
4
1
  import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
5
2
 
6
3
  import { usePublicClient } from "@berachain/wagmi/hooks";
4
+ import type { SWRResponse } from "@berachain/utils/pkg/swr";
5
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
7
6
 
8
7
  import { assertPublicClient } from "../../errors/assert";
9
8
  import { parseBaseArgs } from "../../utils/parseBaseArgs";
@@ -1,10 +1,10 @@
1
- import type { SWRResponse } from "swr";
2
- import useSWRImmutable from "swr/immutable";
3
1
  import type { Address } from "viem";
4
2
 
5
3
  import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
6
4
 
7
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import type { SWRResponse } from "@berachain/utils/pkg/swr";
7
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
8
8
 
9
9
  import { ProposalState } from "../../enum/governance";
10
10
  import { assertPublicClient } from "../../errors/assert";
@@ -1,9 +1,10 @@
1
- import useSWR, { type SWRResponse } from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
5
4
 
6
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import type { SWRResponse } from "@berachain/utils/pkg/swr";
7
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
8
 
8
9
  import { POLLING } from "../../enum/polling";
9
10
  import { assertPublicClient } from "../../errors/assert";
@@ -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 { getQuorum } from "../../actions/governance/getQuorum";
6
5
 
@@ -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 { getGlobalCapLimit } from "../../actions/honey/getGlobalCapLimit";
6
5
  import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
@@ -39,9 +38,7 @@ export const useCappedGlobally = (
39
38
  : undefined,
40
39
  },
41
40
  {
42
- opts: {
43
- isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
44
- },
41
+ isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
45
42
  },
46
43
  );
47
44
  const QUERY_KEY =
@@ -84,7 +81,7 @@ export const useCappedGlobally = (
84
81
  });
85
82
  },
86
83
  {
87
- ...options?.opts,
84
+ ...options,
88
85
  refreshInterval: 0,
89
86
  },
90
87
  );
@@ -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 { getRelativeCapLimit } from "../../actions/honey/getRelativeCapLimit";
7
7
  import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
@@ -80,7 +80,7 @@ export const useCappedRelatively = (
80
80
  },
81
81
  {
82
82
  refreshInterval: 0,
83
- ...options?.opts,
83
+ ...options,
84
84
  },
85
85
  );
86
86
 
@@ -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 { getCollateralWeights } from "../../actions/honey/getCollateralWeights";
7
7
  import { POLLING } from "../../enum/polling";
@@ -40,8 +40,8 @@ export const useCollateralWeights = (
40
40
  });
41
41
  },
42
42
  {
43
- ...options?.opts,
44
- refreshInterval: options?.opts?.refreshInterval ?? POLLING.NORMAL,
43
+ ...options,
44
+ refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
45
45
  },
46
46
  );
47
47
 
@@ -1,4 +1,4 @@
1
- import useSWR from "swr";
1
+ import { useSWR } from "@berachain/utils/pkg/swr";
2
2
 
3
3
  import { getHoney24hVolume } from "../../actions/honey/getHoney24hVolume";
4
4
  import { POLLING } from "../../enum/polling";
@@ -1,4 +1,3 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import {
@@ -6,6 +5,7 @@ import {
6
5
  useConfig,
7
6
  usePublicClient,
8
7
  } from "@berachain/wagmi/hooks";
8
+ import { useSWR } from "@berachain/utils/pkg/swr";
9
9
 
10
10
  import { getWalletBalances } from "../../actions/tokens/getWalletBalances";
11
11
  import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
@@ -1,4 +1,4 @@
1
- import useSWR from "swr";
1
+ import { useSWR } from "@berachain/utils/pkg/swr";
2
2
 
3
3
  import { getChartData } from "../../actions/honey/getChartData";
4
4
 
@@ -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 GetHoneyVaultsBalanceResponse,
@@ -34,7 +33,7 @@ export const useHoneyVaultsBalance = (
34
33
  collateralList,
35
34
  });
36
35
  },
37
- { ...options?.opts, refreshInterval: POLLING.NORMAL },
36
+ { ...options, refreshInterval: POLLING.NORMAL },
38
37
  );
39
38
 
40
39
  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 {
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,9 +1,7 @@
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
- import { BeraError } from "../../errors/BeraError";
7
5
  import type { AutoclaimedIncentivesResponse } from "../../types/bribe-boost";
8
6
  import type { DefaultHookReturnType } from "../../types/global";
9
7
 
@@ -26,15 +24,7 @@ export function useAutoclaimedIncentives({
26
24
 
27
25
  const swrResponse = useSWR(
28
26
  QUERY_KEY,
29
- async ([, account]) => {
30
- if (!account) {
31
- throw new BeraError({
32
- message: "useAutoclaimedIncentives needs a logged in account",
33
- level: "error",
34
- });
35
- }
36
- return await getAutoclaimedIncentives({ account });
37
- },
27
+ async ([, account]) => getAutoclaimedIncentives({ account }),
38
28
  {
39
29
  revalidateOnFocus: false,
40
30
  revalidateOnReconnect: false,
@@ -0,0 +1,44 @@
1
+ import { useBeraWallet } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
3
+
4
+ import { getAutoclaimedIncentivesTxHash } from "../../actions/pol/getAutoclaimedIncentivesTxHash";
5
+ import { POLLING } from "../../enum/polling";
6
+ import type { AutoclaimedIncentivesTxHashResponse } from "../../types/bribe-boost";
7
+ import type { DefaultHookReturnType } from "../../types/global";
8
+
9
+ interface UseAutoclaimedIncentivesTxHashArgs {
10
+ // Hard gate, identical to `useAutoclaimedIncentives` — only flip true once
11
+ // both `!isBgtPolRewardToken` and `bgtIncentiveDistributor.paused()` hold.
12
+ enabled: boolean;
13
+ }
14
+
15
+ export function useAutoclaimedIncentivesTxHash({
16
+ enabled,
17
+ }: UseAutoclaimedIncentivesTxHashArgs): DefaultHookReturnType<AutoclaimedIncentivesTxHashResponse | null> {
18
+ const { address: account } = useBeraWallet();
19
+
20
+ const QUERY_KEY =
21
+ enabled && account
22
+ ? (["useAutoclaimedIncentivesTxHash", account] as const)
23
+ : null;
24
+
25
+ const swrResponse = useSWR(
26
+ QUERY_KEY,
27
+ async ([, account]) => getAutoclaimedIncentivesTxHash({ account }),
28
+ {
29
+ // txhashes flip from absent → present as the bot processes each token,
30
+ // so we need to actually poll. Cadence matches the bot's tx cadence
31
+ // (minutes, not seconds) and lets the user watch pending → claimed
32
+ // transitions without reloading the page.
33
+ refreshInterval: POLLING.NORMAL,
34
+ revalidateOnFocus: true,
35
+ revalidateOnReconnect: true,
36
+ revalidateIfStale: false,
37
+ },
38
+ );
39
+
40
+ return {
41
+ ...swrResponse,
42
+ refresh: () => swrResponse?.mutate?.(),
43
+ };
44
+ }
@@ -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