@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,14 +1,14 @@
1
1
  import * as react from 'react';
2
2
  import { GovernanceTopic, CustomProposalErrors, CustomProposal } from '../../types/governance/exports.js';
3
- import * as swr from 'swr';
4
- import { SWRResponse } from 'swr';
3
+ import * as _berachain_utils_pkg_swr from '@berachain/utils/pkg/swr';
4
+ import { SWRResponse } from '@berachain/utils/pkg/swr';
5
5
  import { Address } from 'viem';
6
- import { P as POLLING } from '../../polling-BKnyavLI.js';
7
- import * as swr_infinite from 'swr/infinite';
8
- import { SWRInfiniteResponse, SWRInfiniteKeyLoader } from 'swr/infinite';
9
6
  import * as _berachain_graphql_governance from '@berachain/graphql/governance';
10
7
  import { Proposal_Filter, Proposal_OrderBy, OrderDirection, ProposalStatus, ProposalSelectionFragment, ProposalWithVotesFragment, GetProposalVotesQueryVariables } from '@berachain/graphql/governance';
11
- import { D as DefaultHookOptions, a as DefaultHookReturnType } from '../../global.d-BuGDKh4k.js';
8
+ import { SWRInfiniteResponse, SWRInfiniteKeyLoader } from '@berachain/utils/pkg/swr/infinite';
9
+ import { D as DefaultHookOptions, a as DefaultHookReturnType } from '../../global.d-q_LQWQqs.js';
10
+ import * as swr_infinite from 'swr/infinite';
11
+ import { g as getProposalVotes } from '../../getProposalVotes-DAUrdX2n.js';
12
12
  import * as swr__internal from 'swr/_internal';
13
13
  import '../../enum/governance/exports.js';
14
14
  import '@wagmi/core';
@@ -40,19 +40,16 @@ declare const useGetPastVotes: (args: {
40
40
  } | {
41
41
  proposalId: bigint;
42
42
  timepoint?: number | bigint;
43
- })) => swr.SWRResponse<string, any, any>;
43
+ })) => _berachain_utils_pkg_swr.SWRResponse<string, any, any>;
44
44
 
45
45
  declare const useHasVoted: ({ proposalId, wallet, }: {
46
46
  proposalId: string;
47
47
  wallet?: Address;
48
- }) => swr.SWRResponse<boolean, any, any>;
48
+ }) => _berachain_utils_pkg_swr.SWRResponse<boolean, any, any>;
49
49
 
50
50
  declare const useIsCanceller: ({ account, ...baseArgs }: {
51
51
  account: Address | undefined;
52
- } & BeraJS.BaseFunctionArgs) => swr.SWRResponse<boolean, any, {
53
- refreshInterval: POLLING;
54
- revalidateOnFocus: false;
55
- }>;
52
+ } & BeraJS.BaseFunctionArgs) => _berachain_utils_pkg_swr.SWRResponse<boolean, any, any>;
56
53
 
57
54
  type UsePollAllProposalsArgs = {
58
55
  topic: string;
@@ -79,7 +76,7 @@ type PollAllProposalsKey = [
79
76
  number,
80
77
  string | undefined
81
78
  ] | null;
82
- declare function usePollAllProposalsQueryKey(topic: string, args?: Partial<UsePollAllProposalsArgs>): (pageIndex: number, previousPageData?: ProposalSelectionFragment[]) => PollAllProposalsKey;
79
+ declare function usePollAllProposalsQueryKey(topic: string, args?: Partial<UsePollAllProposalsArgs>): (pageIndex: number, previousPageData?: ProposalSelectionFragment[] | null) => PollAllProposalsKey;
83
80
  /**
84
81
  * Fetch all proposals for a given topic
85
82
  */
@@ -113,6 +110,14 @@ declare const usePollProposalThreshold: (governorAddress: Address) => DefaultHoo
113
110
  }>;
114
111
 
115
112
  type UsePollProposalVotesArgs = Omit<GetProposalVotesQueryVariables, "offset" | "limit">;
113
+ type ProposalVotesKey = [
114
+ string,
115
+ number,
116
+ number,
117
+ UsePollProposalVotesArgs["proposalId"],
118
+ UsePollProposalVotesArgs["orderBy"],
119
+ UsePollProposalVotesArgs["orderDirection"]
120
+ ] | null;
116
121
  /**
117
122
  * Fetches all the votes for a proposal from the Subgraph
118
123
  * @param args - The arguments to pass to the query
@@ -121,7 +126,7 @@ type UsePollProposalVotesArgs = Omit<GetProposalVotesQueryVariables, "offset" |
121
126
  declare const usePollProposalVotes: (args: UsePollProposalVotesArgs, total: number) => swr_infinite.SWRInfiniteResponse<{
122
127
  data: _berachain_graphql_governance.GetProposalVotesQuery;
123
128
  }, any>;
124
- declare const usePollProposalVotesQueryKey: ({ ...args }: UsePollProposalVotesArgs, total: number) => SWRInfiniteKeyLoader;
129
+ declare const usePollProposalVotesQueryKey: ({ ...args }: UsePollProposalVotesArgs, total: number) => SWRInfiniteKeyLoader<Awaited<ReturnType<typeof getProposalVotes>>, ProposalVotesKey>;
125
130
 
126
131
  declare const usePollUserDelegates: (options?: DefaultHookOptions) => DefaultHookReturnType<{
127
132
  delegate: Address;
@@ -173,7 +178,7 @@ declare function useQuorum({ at }: {
173
178
  }): {
174
179
  data: number | undefined;
175
180
  error: any;
176
- mutate: swr.KeyedMutator<string>;
181
+ mutate: _berachain_utils_pkg_swr.KeyedMutator<string>;
177
182
  isValidating: boolean;
178
183
  isLoading: swr__internal.IsLoadingResponse<Data, Config>;
179
184
  };
@@ -5,16 +5,20 @@ import {
5
5
  getProposalDetails,
6
6
  getProposalFromTx,
7
7
  getProposalVotes
8
- } from "../../chunk-AFN4CVD3.mjs";
8
+ } from "../../chunk-GUURQAME.mjs";
9
9
  import "../../chunk-DKMAIU74.mjs";
10
+ import {
11
+ useSWR,
12
+ useSWRImmutable
13
+ } from "../../chunk-UD5IUNCW.mjs";
10
14
  import "../../chunk-SGIJVHZO.mjs";
11
15
  import {
12
16
  assertPublicClient
13
- } from "../../chunk-KQUMKB66.mjs";
17
+ } from "../../chunk-GY6B3PD5.mjs";
14
18
  import {
15
19
  parseBaseArgs
16
- } from "../../chunk-75M6TF7M.mjs";
17
- import "../../chunk-J5I45WGQ.mjs";
20
+ } from "../../chunk-DQRH5VE3.mjs";
21
+ import "../../chunk-KHXJDYA4.mjs";
18
22
 
19
23
  // src/hooks/governance/useCreateProposal.ts
20
24
  import { useCallback, useEffect, useState } from "react";
@@ -289,13 +293,11 @@ var useCreateProposal = ({
289
293
  };
290
294
 
291
295
  // src/hooks/governance/useGetPastVotes.ts
292
- import useSWRImmutable2 from "swr/immutable";
293
296
  import { formatUnits } from "viem";
294
297
  import { bgtAbi } from "@berachain/abis/pol/bgt";
295
298
  import { useBeraWallet, usePublicClient as usePublicClient2 } from "@berachain/wagmi/hooks";
296
299
 
297
300
  // src/hooks/governance/useProposalSnapshot.ts
298
- import useSWRImmutable from "swr/immutable";
299
301
  import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
300
302
  import { usePublicClient } from "@berachain/wagmi/hooks";
301
303
  var useProposalSnapshot = ({
@@ -328,7 +330,7 @@ var useGetPastVotes = (args) => {
328
330
  });
329
331
  const ts = args.timepoint || snapshot;
330
332
  const QUERY_KEY = ts && publicClient && wallet ? ["useGetPastVotes", ts, wallet] : null;
331
- return useSWRImmutable2(QUERY_KEY, async ([, ts2, wallet2]) => {
333
+ return useSWRImmutable(QUERY_KEY, async ([, ts2, wallet2]) => {
332
334
  assertPublicClient(publicClient);
333
335
  const { config } = parseBaseArgs({
334
336
  chainId: publicClient.chain.id
@@ -347,7 +349,6 @@ var useGetPastVotes = (args) => {
347
349
  };
348
350
 
349
351
  // src/hooks/governance/useHasVoted.ts
350
- import useSWR from "swr";
351
352
  import { isAddress } from "viem";
352
353
  import { berachainGovernanceAbi as governanceAbi2 } from "@berachain/abis/gov/berachainGovernance";
353
354
  import { useBeraWallet as useBeraWallet2, usePublicClient as usePublicClient3 } from "@berachain/wagmi/hooks";
@@ -376,7 +377,6 @@ var useHasVoted = ({
376
377
  };
377
378
 
378
379
  // src/hooks/governance/useIsCanceller.ts
379
- import useSWR2 from "swr";
380
380
  import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
381
381
  import { usePublicClient as usePublicClient4 } from "@berachain/wagmi/hooks";
382
382
 
@@ -391,7 +391,7 @@ var useIsCanceller = ({
391
391
  const publicClient = usePublicClient4();
392
392
  const { config: chainConfig } = parseBaseArgs(baseArgs);
393
393
  const QUERY_KEY = account && publicClient ? ["useCancellerRole", account] : null;
394
- return useSWR2(
394
+ return useSWR(
395
395
  QUERY_KEY,
396
396
  async ([, account2]) => {
397
397
  assertPublicClient(publicClient);
@@ -412,11 +412,25 @@ var useIsCanceller = ({
412
412
 
413
413
  // src/hooks/governance/usePollAllProposals.ts
414
414
  import { useEffect as useEffect2, useMemo, useState as useState2 } from "react";
415
- import useSWRInfinite from "swr/infinite";
416
415
  import {
417
416
  Proposal_OrderBy,
418
417
  ProposalStatus
419
418
  } from "@berachain/graphql/governance";
419
+
420
+ // ../utils/src/pkg/swr/infinite.ts
421
+ import { unstable_serialize } from "swr/infinite";
422
+ import useOriginalSWRInfinite from "swr/infinite";
423
+ function useSWRInfinite(getKey, fetcher, options) {
424
+ const { isEnabled = true, ...swrConfig } = options ?? {};
425
+ return useOriginalSWRInfinite(
426
+ isEnabled ? getKey : () => null,
427
+ fetcher,
428
+ swrConfig
429
+ );
430
+ }
431
+ var infinite_default = useSWRInfinite;
432
+
433
+ // src/hooks/governance/usePollAllProposals.ts
420
434
  var DEFAULT_PER_PAGE = 10;
421
435
  var fromUiStatusToSubgraphStatuses = (status) => {
422
436
  switch (status) {
@@ -483,16 +497,12 @@ function usePollAllProposals(args, options) {
483
497
  });
484
498
  return (proposals ?? []).filter(Boolean);
485
499
  }
486
- const swr = useSWRInfinite(
487
- getKey,
488
- fetcher,
489
- {
490
- // Increase initialSize in order to prefetch more proposals at a time.
491
- initialSize: 1,
492
- refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */,
493
- ...options?.opts
494
- }
495
- );
500
+ const swr = infinite_default(getKey, fetcher, {
501
+ // Increase initialSize in order to prefetch more proposals at a time.
502
+ initialSize: 1,
503
+ refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */,
504
+ ...options
505
+ });
496
506
  const data = useMemo(() => {
497
507
  if (!swr.data) return [];
498
508
  const flattened = swr.data.flat().filter((p) => {
@@ -561,7 +571,6 @@ function usePollAllProposals(args, options) {
561
571
 
562
572
  // src/hooks/governance/usePollProposal.ts
563
573
  import { useEffect as useEffect3, useState as useState3 } from "react";
564
- import useSWR3 from "swr";
565
574
  import {
566
575
  ProposalStatus as ProposalStatus2
567
576
  } from "@berachain/graphql/governance";
@@ -570,15 +579,15 @@ var usePollProposal = (proposalId, options) => {
570
579
  const autoRefreshProposal = options?.autoRefresh ?? false;
571
580
  const publicClient = usePublicClient5();
572
581
  const QUERY_KEY = proposalId && publicClient ? ["usePollProposal", proposalId] : null;
573
- const swrResponse = useSWR3(
582
+ const swrResponse = useSWR(
574
583
  QUERY_KEY,
575
584
  ([, proposalId2]) => {
576
585
  assertPublicClient(publicClient);
577
586
  return getProposalDetails({ proposalId: proposalId2, client: publicClient });
578
587
  },
579
588
  {
580
- ...options?.opts,
581
- refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */
589
+ ...options,
590
+ refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */
582
591
  }
583
592
  );
584
593
  const [timestamp, setTimestamp] = useState3(Date.now());
@@ -616,14 +625,13 @@ var usePollProposal = (proposalId, options) => {
616
625
  };
617
626
 
618
627
  // src/hooks/governance/usePollProposalThreshold.ts
619
- import useSWR4 from "swr";
620
628
  import { formatEther } from "viem";
621
629
  import { berachainGovernanceAbi as governanceAbi3 } from "@berachain/abis/gov/berachainGovernance";
622
630
  import { usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
623
631
  var usePollProposalThreshold = (governorAddress) => {
624
632
  const publicClient = usePublicClient6();
625
633
  const QUERY_KEY = publicClient ? ["usePollProposalThreshold", governorAddress] : null;
626
- const swrResponse = useSWR4(
634
+ const swrResponse = useSWR(
627
635
  QUERY_KEY,
628
636
  async ([, governorAddress2]) => {
629
637
  assertPublicClient(publicClient);
@@ -645,10 +653,9 @@ var usePollProposalThreshold = (governorAddress) => {
645
653
  };
646
654
 
647
655
  // src/hooks/governance/usePollProposalVotes.ts
648
- import useSWRInfinite2 from "swr/infinite";
649
656
  var DEFAULT_LIMIT = 1e3;
650
657
  var usePollProposalVotes = (args, total) => {
651
- return useSWRInfinite2(
658
+ return useSWRInfinite(
652
659
  usePollProposalVotesQueryKey(args, total),
653
660
  async ([_key, page]) => {
654
661
  return getProposalVotes({
@@ -681,7 +688,6 @@ var usePollProposalVotesQueryKey = ({ ...args }, total) => (pageIndex) => {
681
688
  };
682
689
 
683
690
  // src/hooks/governance/usePollUserDelegates.ts
684
- import useSWR5 from "swr";
685
691
  import { formatEther as formatEther2 } from "viem";
686
692
  import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
687
693
  import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
@@ -689,7 +695,7 @@ var usePollUserDelegates = (options) => {
689
695
  const { address: account } = useBeraWallet3();
690
696
  const publicClient = usePublicClient7();
691
697
  const QUERY_KEY = account ? ["usePollUserDelegates", account] : null;
692
- const swrResponse = useSWR5(
698
+ const swrResponse = useSWR(
693
699
  QUERY_KEY,
694
700
  async ([, account2]) => {
695
701
  assertPublicClient(publicClient);
@@ -719,8 +725,8 @@ var usePollUserDelegates = (options) => {
719
725
  };
720
726
  },
721
727
  {
722
- ...options?.opts,
723
- refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */
728
+ ...options,
729
+ refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */
724
730
  }
725
731
  );
726
732
  return {
@@ -730,7 +736,6 @@ var usePollUserDelegates = (options) => {
730
736
  };
731
737
 
732
738
  // src/hooks/governance/useProposalFromTx.ts
733
- import useSWR6 from "swr";
734
739
  import { usePublicClient as usePublicClient8, useTransactionReceipt } from "@berachain/wagmi/hooks";
735
740
  var useProposalFromTx = (txHash) => {
736
741
  const { data: tx } = useTransactionReceipt({
@@ -738,7 +743,7 @@ var useProposalFromTx = (txHash) => {
738
743
  });
739
744
  const publicClient = usePublicClient8();
740
745
  const QUERY_KEY = tx && publicClient ? ["useProposalFromTx", txHash] : null;
741
- const swrResponse = useSWR6(QUERY_KEY, async ([, txHash2]) => {
746
+ const swrResponse = useSWR(QUERY_KEY, async ([, txHash2]) => {
742
747
  if (!tx) {
743
748
  throw new Error("Transaction not found");
744
749
  }
@@ -751,7 +756,6 @@ var useProposalFromTx = (txHash) => {
751
756
  };
752
757
 
753
758
  // src/hooks/governance/useProposalState.ts
754
- import useSWRImmutable3 from "swr/immutable";
755
759
  import { berachainGovernanceAbi as governanceAbi4 } from "@berachain/abis/gov/berachainGovernance";
756
760
  import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
757
761
  var ProposalStateMap = {
@@ -770,7 +774,7 @@ var useProposalState = ({
770
774
  }) => {
771
775
  const publicClient = usePublicClient9();
772
776
  const QUERY_KEY = governorAddress && publicClient && proposalId ? ["useProposalState", proposalId] : null;
773
- return useSWRImmutable3(QUERY_KEY, async ([, proposalId2]) => {
777
+ return useSWRImmutable(QUERY_KEY, async ([, proposalId2]) => {
774
778
  assertPublicClient(publicClient);
775
779
  const snapshot = await publicClient.readContract({
776
780
  abi: governanceAbi4,
@@ -783,7 +787,6 @@ var useProposalState = ({
783
787
  };
784
788
 
785
789
  // src/hooks/governance/useProposalTimelockState.ts
786
- import useSWR7 from "swr";
787
790
  import { timeLockAbi as governanceTimelockAbi2 } from "@berachain/abis/gov/timeLock";
788
791
  import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
789
792
  var TimelockOperationState = {
@@ -802,7 +805,7 @@ function useProposalTimelockState({
802
805
  proposalTimelockId,
803
806
  timelockAddress
804
807
  ] : null;
805
- return useSWR7(
808
+ return useSWR(
806
809
  QUERY_KEY,
807
810
  async ([, proposalTimelockId2, timelockAddress2]) => {
808
811
  assertPublicClient(publicClient);
@@ -821,7 +824,6 @@ function useProposalTimelockState({
821
824
  }
822
825
 
823
826
  // src/hooks/governance/useQuorum.ts
824
- import useSWR8 from "swr";
825
827
  import { usePublicClient as usePublicClient11 } from "@berachain/wagmi/hooks";
826
828
 
827
829
  // src/actions/governance/getQuorum.ts
@@ -857,7 +859,7 @@ function useQuorum({ at }, {
857
859
  // Using Now because we cannot query quorum in the future, so no need to have different query keys.
858
860
  Number(at) > now ? "now" : at
859
861
  ] : null;
860
- const response = useSWR8(QUERY_KEY, async ([, at2]) => {
862
+ const response = useSWR(QUERY_KEY, async ([, at2]) => {
861
863
  if (at2 === "now") {
862
864
  return getQuorum({ publicClient });
863
865
  }
@@ -1,5 +1,5 @@
1
1
  import { Address } from 'viem';
2
- import { a as TokenWithMetadata, b as Token } from './HoneyConfigProvider-Dkj-_a5x.js';
2
+ import { a as TokenWithMetadata, b as Token } from './HoneyConfigProvider-COOuDNra.js';
3
3
  import { ApiValidatorFragment } from '@berachain/graphql/pol/api';
4
4
 
5
5
  interface BribeBoostReward {
@@ -35,11 +35,22 @@ interface BribeBoostRewardProof {
35
35
  }
36
36
 
37
37
  // Response shape of GET /api/v1/wallets/:wallet/autoclaimed:
38
- // { [wallet]: { [validatorPubkey]: { [tokenAddress]: rawAmount (stringified bigint) } } }
39
- // Top-level wallet key is the lowercase wallet address that was queried.
38
+ // { [wallet]: { [validatorPubkey]: { [tokenAddress]: { amount } } } }
39
+ // `amount` is a stringified bigint in token base units. The backend now
40
+ // aggregates across validators under a single fake pubkey (`0x000…000`),
41
+ // so consumers can collapse the validator dimension blindly.
40
42
  type AutoclaimedIncentivesResponse = Record<
41
43
  Address,
42
- Record<Address, Record<Address, string>>
44
+ Record<Address, Record<Address, { amount: string }>>
45
+ >;
46
+
47
+ // Response shape of GET /api/v1/wallets/:wallet/autoclaimed/txhash: same
48
+ // nesting, but each token leaf is `{ txhash }`. Tokens still pending are
49
+ // simply absent — when a token from `/autoclaimed` has no entry here, the
50
+ // bot hasn't distributed it yet.
51
+ type AutoclaimedIncentivesTxHashResponse = Record<
52
+ Address,
53
+ Record<Address, Record<Address, { txhash: string }>>
43
54
  >;
44
55
 
45
56
  interface BribeBoostValidatorApr {
@@ -131,12 +142,26 @@ interface UserVaultInfo {
131
142
 
132
143
  type StakedBeraAsset = {
133
144
  token: TokenWithMetadata;
134
- apr: number;
145
+ /**
146
+ * Staking APR, or `undefined` when unavailable (e.g. the APR backend is
147
+ * down). `undefined` lets the UI render a "—" placeholder instead of a
148
+ * misleading "0%".
149
+ */
150
+ apr: number | undefined;
135
151
  stakedAmount: number;
136
- stakedAmountUsd: number;
152
+ /**
153
+ * USD value of the staked amount, or `undefined` when the token price is
154
+ * unavailable (e.g. the price backend is down). `undefined` lets the UI
155
+ * render a "—" placeholder instead of a misleading "$0.00".
156
+ */
157
+ stakedAmountUsd: number | undefined;
137
158
  earnedAmount: number;
138
- earnedAmountUsd: number;
159
+ /**
160
+ * USD value of the earned amount, or `undefined` when the token price is
161
+ * unavailable. See {@link stakedAmountUsd}.
162
+ */
163
+ earnedAmountUsd: number | undefined;
139
164
  isLoadingEarnings?: boolean;
140
165
  };
141
166
 
142
- export type { AutoclaimedIncentivesResponse as A, BribeBoostRewardProof as B, ClaimedIncentives as C, IncentiveReward as I, ProtocolMetadata as P, StakingConfig as S, UserVaultInfo as U, BribeBoostRewardItem as a, StakedBeraAsset as b, AggregatedTokenTotals as c, BribeBoostReward as d, BribeBoostValidatorApr as e, ClaimedIncentivesLocalState as f, IncentiveRewardChunksWithValidatorData as g };
167
+ export type { AutoclaimedIncentivesResponse as A, BribeBoostRewardProof as B, ClaimedIncentives as C, IncentiveReward as I, ProtocolMetadata as P, StakingConfig as S, UserVaultInfo as U, AutoclaimedIncentivesTxHashResponse as a, BribeBoostRewardItem as b, StakedBeraAsset as c, AggregatedTokenTotals as d, BribeBoostReward as e, BribeBoostValidatorApr as f, ClaimedIncentivesLocalState as g, IncentiveRewardChunksWithValidatorData as h };
@@ -1,17 +1,17 @@
1
- export { c as AggregatedTokenTotals, A as AutoclaimedIncentivesResponse, d as BribeBoostReward, a as BribeBoostRewardItem, B as BribeBoostRewardProof, e as BribeBoostValidatorApr, C as ClaimedIncentives, f as ClaimedIncentivesLocalState, I as IncentiveReward, g as IncentiveRewardChunksWithValidatorData, P as ProtocolMetadata, b as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo } from '../pol.d-CqPA9K6m.js';
2
- import { M as MinimalERC20 } from '../HoneyConfigProvider-Dkj-_a5x.js';
3
- export { A as AllowanceQueryItem, j as AllowanceToken, B as BalanceToken, y as BexStatus, x as Calldata, H as HoneySwapActions, I as IAggregatorArgs, z as IAggregatorQuote, g as IRawAggregatorQuote, v as IUserPosition, h as PythPriceFeedMap, S as SwapRequest, b as Token, i as TokenCurrentPriceMap, w as TokenPriceInfo, t as TokenWithAmount, a as TokenWithMetadata, D as TokenWithPrice } from '../HoneyConfigProvider-Dkj-_a5x.js';
1
+ export { d as AggregatedTokenTotals, A as AutoclaimedIncentivesResponse, a as AutoclaimedIncentivesTxHashResponse, e as BribeBoostReward, b as BribeBoostRewardItem, B as BribeBoostRewardProof, f as BribeBoostValidatorApr, C as ClaimedIncentives, g as ClaimedIncentivesLocalState, I as IncentiveReward, h as IncentiveRewardChunksWithValidatorData, P as ProtocolMetadata, c as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo } from '../pol.d-CeRgXBL8.js';
2
+ import { M as MinimalERC20 } from '../HoneyConfigProvider-COOuDNra.js';
3
+ export { A as AllowanceQueryItem, j as AllowanceToken, B as BalanceToken, x as BexStatus, y as Calldata, H as HoneySwapActions, I as IAggregatorArgs, z as IAggregatorQuote, g as IRawAggregatorQuote, v as IUserPosition, h as PythPriceFeedMap, S as SwapRequest, b as Token, i as TokenCurrentPriceMap, w as TokenPriceInfo, t as TokenWithAmount, a as TokenWithMetadata, D as TokenWithPrice } from '../HoneyConfigProvider-COOuDNra.js';
4
4
  import { BundleData, EnsoClient } from '@ensofinance/sdk';
5
5
  import { TransactionRequest, Address, Hex, PublicClient } from 'viem';
6
- export { D as DefaultHookOptions, a as DefaultHookReturnType, I as IContractWrite, c as IContractWriteFn } from '../global.d-BuGDKh4k.js';
6
+ export { D as DefaultHookOptions, a as DefaultHookReturnType, I as IContractWrite, c as IContractWriteFn } from '../global.d-q_LQWQqs.js';
7
7
  import '@berachain/graphql/pol/api';
8
8
  import 'react/jsx-runtime';
9
9
  import 'react';
10
10
  import '@berachain-foundation/berancer-sdk';
11
11
  import '../honey-CYm0RWf4.js';
12
12
  import '@wagmi/core';
13
- import 'swr';
14
13
  import '@berachain/config';
14
+ import '@berachain/utils/pkg/swr';
15
15
  import '../txnEnum-ByI5dtDi.js';
16
16
  import '../BeraError-7-A5JYy_.js';
17
17
 
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { T as TokenWithOrder, H as HoneySwapActions } from './HoneyConfigProvider-Dkj-_a5x.js';
2
+ import { T as TokenWithOrder, H as HoneySwapActions } from './HoneyConfigProvider-COOuDNra.js';
3
3
 
4
4
  interface IHoneySwapState {
5
5
  actionType: "mint" | "redeem";
@@ -5,7 +5,7 @@ import * as viem from 'viem';
5
5
  import { Address, PublicClient, Transport } from 'viem';
6
6
  import * as _berachain_config_internal from '@berachain/config/internal';
7
7
  import { ChainId, BeraConfig } from '@berachain/config/internal';
8
- import { I as IHoneySwapState } from '../useHoneySwapState-vFmuFF0g.js';
8
+ import { I as IHoneySwapState } from '../useHoneySwapState-twi7NTaO.js';
9
9
  import * as _berachain_graphql_bend_whisk from '@berachain/graphql/bend/whisk';
10
10
  import { TokenInfoFragmentFragment } from '@berachain/graphql/bend/whisk';
11
11
  import * as _berachain_config from '@berachain/config';
@@ -14,7 +14,7 @@ import '@berachain/config/internal/flags';
14
14
  import '@apollo/client';
15
15
  import '../BeraError-7-A5JYy_.js';
16
16
  import 'react';
17
- import '../HoneyConfigProvider-Dkj-_a5x.js';
17
+ import '../HoneyConfigProvider-COOuDNra.js';
18
18
  import 'react/jsx-runtime';
19
19
  import '@berachain-foundation/berancer-sdk';
20
20
  import '../honey-CYm0RWf4.js';
@@ -2,7 +2,7 @@ import {
2
2
  computePriceImpact,
3
3
  wrapNativeToken,
4
4
  wrapNativeTokens
5
- } from "../chunk-FFB5LFDW.mjs";
5
+ } from "../chunk-QVHEM4BG.mjs";
6
6
  import {
7
7
  CAP_LIMIT_BUFFER,
8
8
  DEFAULT_METAMASK_GAS_LIMIT,
@@ -10,8 +10,6 @@ import {
10
10
  MAX_CUSTOM_SLIPPAGE,
11
11
  MIN_CUSTOM_DEADLINE,
12
12
  MIN_CUSTOM_SLIPPAGE,
13
- beraFetch,
14
- beraFetchJson,
15
13
  bignumber_js_default,
16
14
  calculateTimestampFromDays,
17
15
  days,
@@ -29,14 +27,18 @@ import {
29
27
  months,
30
28
  monthsInSeconds,
31
29
  msToSeconds,
32
- sanitizeRpcUrl,
33
30
  seconds,
34
31
  truncateDecimal,
35
32
  weeks,
36
33
  weeksInSeconds,
37
34
  years,
38
35
  yearsInSeconds
39
- } from "../chunk-CDFWPU2R.mjs";
36
+ } from "../chunk-E7YFXBBQ.mjs";
37
+ import {
38
+ beraFetch,
39
+ beraFetchJson,
40
+ sanitizeRpcUrl
41
+ } from "../chunk-Y6THHG77.mjs";
40
42
  import {
41
43
  defaultFlags
42
44
  } from "../chunk-BGMRHTBQ.mjs";
@@ -45,20 +47,20 @@ import {
45
47
  getHoneyToken,
46
48
  isToken,
47
49
  wBeraToken
48
- } from "../chunk-NPBQLVL3.mjs";
50
+ } from "../chunk-IXIBY5FP.mjs";
49
51
  import {
50
52
  parseBaseArgs
51
- } from "../chunk-75M6TF7M.mjs";
53
+ } from "../chunk-DQRH5VE3.mjs";
52
54
  import {
53
55
  BeraTracing
54
56
  } from "../chunk-SZ5C44L5.mjs";
55
57
  import {
56
58
  RequestError
57
- } from "../chunk-XIYN6AL6.mjs";
59
+ } from "../chunk-ZLTMIFCZ.mjs";
58
60
  import {
59
61
  BeraError,
60
62
  InvalidArgumentError
61
- } from "../chunk-J5I45WGQ.mjs";
63
+ } from "../chunk-KHXJDYA4.mjs";
62
64
 
63
65
  // src/utils/formatInputTokenValue.ts
64
66
  var formatInputTokenValue = (inputValue) => {
@@ -482,6 +484,10 @@ var contracts = [
482
484
  "80094": "0x2880aB155794e7179c9eE2e38200202908C17B43",
483
485
  name: "external.pyth"
484
486
  },
487
+ {
488
+ "80094": "0xB5f473c4b7F402d8f7bED42b6D516f5ff3306B01",
489
+ name: "bend.production.supportedVaults.1"
490
+ },
485
491
  {
486
492
  "80069": null,
487
493
  "80094": "0xC5FabF3a7E98a2ed89f5d5057Ab010634Ca7e71f",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berachain/berajs",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "sideEffects": false,
5
5
  "files": [
6
6
  "dist",
@@ -12,23 +12,23 @@
12
12
  "dependencies": {
13
13
  "@apollo/client": "4.1.6",
14
14
  "@berachain-foundation/berancer-sdk": "1.1.7",
15
- "@berachain/abis": "0.1.2",
16
- "@berachain/config": "0.1.16",
17
- "@berachain/graphql": "0.4.17",
15
+ "@berachain/abis": "0.1.3-beta.0",
16
+ "@berachain/config": "0.1.20",
17
+ "@berachain/graphql": "0.5.1",
18
18
  "@ensofinance/sdk": "2.3.1",
19
19
  "@pythnetwork/hermes-client": "2.0.0",
20
20
  "@wagmi/core": "2.22.1",
21
- "gray-matter": "4.0.3",
22
- "swr": "2.4.1"
21
+ "gray-matter": "4.0.3"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@types/react-dom": "19.2.3",
26
25
  "@types/react": "19.2.14",
27
26
  "@typescript/analyze-trace": "0.10.1",
27
+ "swr": "2.4.1",
28
28
  "tsup": "8.5.1",
29
29
  "typescript": "5.5.4",
30
- "viem": "2.45.0",
31
- "vitest": "3.2.4",
30
+ "viem": "2.52.0",
31
+ "vitest": "3.2.6",
32
32
  "@berachain/utils": "0.1.0",
33
33
  "@berachain/wagmi": "0.4.2-beta.6"
34
34
  },
@@ -86,6 +86,7 @@
86
86
  "peerDependencies": {
87
87
  "react": "^19.1",
88
88
  "react-dom": "^19.1",
89
+ "swr": "^2.4.1",
89
90
  "viem": "^2.41.2",
90
91
  "@berachain/wagmi": "0.4.2-beta.6"
91
92
  },
@@ -7,15 +7,41 @@ interface GetMaxDepositProps {
7
7
  publicClient: PublicClient;
8
8
  }
9
9
 
10
+ export interface MaxDeposit {
11
+ /** `maxDeposit` formatted as an ether-denominated decimal string. */
12
+ formatted: string;
13
+ /**
14
+ * True when the vault has no real deposit cap. MetaMorpho's `maxDeposit` sums
15
+ * each enabled market's remaining capacity (its supply cap minus current
16
+ * supply); an uncapped market stores `type(uint184).max` as its cap, so the
17
+ * sum lands at ~uint184.max (≈2.45e55) — not uint256.max. `formatted` turns
18
+ * that into an astronomical number, so callers must key off this flag, not
19
+ * the formatted value, to detect "unlimited".
20
+ *
21
+ * A genuine cap is many orders of magnitude smaller (e.g. Re7 HONEY's ~92M =
22
+ * ~9.2e25), so the uint184-based threshold cleanly separates the two. The sum
23
+ * can exceed uint184.max when several markets are uncapped, so we compare with
24
+ * `>=` rather than testing for the exact sentinel.
25
+ */
26
+ isUncapped: boolean;
27
+ }
28
+
29
+ const UINT_184_MAX = (1n << 184n) - 1n;
30
+ // 1% below uint184.max — any maxDeposit at/above this is effectively unlimited.
31
+ const UNCAPPED_THRESHOLD = (UINT_184_MAX * 99n) / 100n;
32
+
10
33
  export async function getMaxDeposit({
11
34
  vaultAddress,
12
35
  publicClient,
13
- }: GetMaxDepositProps): Promise<string> {
36
+ }: GetMaxDepositProps): Promise<MaxDeposit> {
14
37
  const maxDeposit = await publicClient.readContract({
15
38
  address: vaultAddress,
16
39
  abi: metaMorphoAbi,
17
40
  functionName: "maxDeposit",
18
41
  args: [vaultAddress],
19
42
  });
20
- return formatEther(maxDeposit);
43
+ return {
44
+ formatted: formatEther(maxDeposit),
45
+ isUncapped: maxDeposit >= UNCAPPED_THRESHOLD,
46
+ };
21
47
  }
@@ -1,3 +1,6 @@
1
+ export { fetchBeep } from "./fetchBeep";
2
+ export { fetchOpenApi } from "./fetchOpenApi";
3
+ export { fetchRailwayBackend } from "./fetchRailwayBackend";
1
4
  export {
2
5
  getApolloClient,
3
6
  gql,