@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,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
  /**
@@ -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
 
@@ -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 { getValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
7
7
  import type { DefaultHookOptions } from "../../types/global";
@@ -25,7 +25,7 @@ export function useValidatorRewardAllocation(
25
25
  });
26
26
  },
27
27
  {
28
- ...options?.opts,
28
+ ...options,
29
29
  },
30
30
  );
31
31
 
@@ -1,5 +1,4 @@
1
1
  import type { Config, GetWalletClientReturnType } from "@wagmi/core";
2
- import type { SWRConfiguration, SWRResponse } from "swr";
3
2
  import type {
4
3
  Abi,
5
4
  Account,
@@ -13,6 +12,8 @@ import type {
13
12
 
14
13
  import type { BeraConfig, ChainId } from "@berachain/config";
15
14
 
15
+ import type { SWRConfiguration, SWRResponse } from "@berachain/utils/pkg/swr";
16
+
16
17
  import type { ContractName } from "../enum/contracts";
17
18
  import type { TransactionActionType } from "../enum/txnEnum";
18
19
  import type {
@@ -20,9 +21,7 @@ import type {
20
21
  TxnEventKeys,
21
22
  } from "../hooks/useContractWrite/types";
22
23
 
23
- export type DefaultHookOptions = {
24
- opts?: SWRConfiguration & { isEnabled?: boolean };
25
- };
24
+ export type DefaultHookOptions = SWRConfiguration & { isEnabled?: boolean };
26
25
 
27
26
  export type DefaultHookReturnType<T = any> = Omit<
28
27
  SWRResponse<T, any, any>,
@@ -55,10 +55,24 @@ export interface UserVaultInfo {
55
55
 
56
56
  export type StakedBeraAsset = {
57
57
  token: TokenWithMetadata;
58
- apr: number;
58
+ /**
59
+ * Staking APR, or `undefined` when unavailable (e.g. the APR backend is
60
+ * down). `undefined` lets the UI render a "—" placeholder instead of a
61
+ * misleading "0%".
62
+ */
63
+ apr: number | undefined;
59
64
  stakedAmount: number;
60
- stakedAmountUsd: number;
65
+ /**
66
+ * USD value of the staked amount, or `undefined` when the token price is
67
+ * unavailable (e.g. the price backend is down). `undefined` lets the UI
68
+ * render a "—" placeholder instead of a misleading "$0.00".
69
+ */
70
+ stakedAmountUsd: number | undefined;
61
71
  earnedAmount: number;
62
- earnedAmountUsd: number;
72
+ /**
73
+ * USD value of the earned amount, or `undefined` when the token price is
74
+ * unavailable. See {@link stakedAmountUsd}.
75
+ */
76
+ earnedAmountUsd: number | undefined;
63
77
  isLoadingEarnings?: boolean;
64
78
  };
@@ -1,8 +0,0 @@
1
- declare enum POLLING {
2
- FAST = 10000,// 10 sec
3
- NORMAL = 100000,// 100 sec
4
- SLOW = 180000,// 3 min
5
- REFRESH_BLOCK_INTERVAL = 10000
6
- }
7
-
8
- export { POLLING as P };