@berachain/berajs 0.2.10 → 0.2.12
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.
- package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
- package/dist/actions/clients/exports.d.ts +5 -21
- package/dist/actions/clients/exports.mjs +5 -7
- package/dist/actions/exports.d.ts +117 -31
- package/dist/actions/exports.mjs +36 -25
- package/dist/actions/governance/exports.d.ts +3 -11
- package/dist/actions/server/exports.mjs +2 -2
- package/dist/chunk-4ML4Y6UN.mjs +46 -0
- package/dist/{chunk-7YVNSDXG.mjs → chunk-FGION6F6.mjs} +1 -1
- package/dist/{chunk-3JJLQ2JX.mjs → chunk-MKSFQIKC.mjs} +1 -4
- package/dist/{chunk-ZLTMIFCZ.mjs → chunk-RFJGL4MF.mjs} +3 -3
- package/dist/{chunk-Y6THHG77.mjs → chunk-T43JPYQS.mjs} +1 -1
- package/dist/{chunk-WNBWX23Q.mjs → chunk-W2VODV76.mjs} +7 -10
- package/dist/{chunk-QBBOWFMH.mjs → chunk-XDG26EG6.mjs} +115 -162
- package/dist/{chunk-P5WXXULM.mjs → chunk-YLTWPFCJ.mjs} +3 -18
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +6 -4
- package/dist/enum/exports.d.ts +8 -2
- package/dist/errors/exports.mjs +2 -2
- package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
- package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
- package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +8 -59
- package/dist/{global.d-BuGDKh4k.d.ts → global.d-CR3zicga.d.ts} +3 -10
- package/dist/hooks/exports.d.ts +145 -403
- package/dist/hooks/exports.mjs +496 -755
- package/dist/hooks/governance/exports.d.ts +24 -19
- package/dist/hooks/governance/exports.mjs +43 -53
- package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
- package/dist/types/exports.d.ts +5 -5
- package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
- package/dist/utils/exports.d.ts +2 -2
- package/dist/utils/exports.mjs +6 -2
- package/package.json +8 -7
- package/src/actions/bend/getMaxDeposit.ts +28 -2
- package/src/actions/clients/exports.ts +0 -1
- package/src/actions/clients/fetchBeep.ts +0 -7
- package/src/actions/clients/fetchOpenApi.ts +10 -6
- package/src/actions/clients/fetchOpenApi.unit.test.ts +20 -14
- package/src/actions/clients/getApolloClient.ts +4 -9
- package/src/actions/exports.ts +1 -1
- package/src/actions/honey/getChartData.ts +14 -14
- package/src/actions/honey/getHoney24hVolume.ts +17 -8
- package/src/actions/honey/getHoneyTxns.ts +45 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +3 -3
- package/src/actions/pol/getEarnedStakedBeraVault.ts +0 -15
- package/src/actions/pol/getGlobalData.ts +10 -29
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getSWBeraVaultMetadata.ts +0 -7
- package/src/actions/pol/getStakingDailyAssets.ts +0 -14
- package/src/actions/validators/getApiEnrichedAllocation.ts +1 -1
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +43 -13
- package/src/contexts/SwrFallback.tsx +2 -1
- package/src/data/contracts.ts +4 -0
- package/src/errors/RequestError.ts +3 -3
- package/src/errors/getRevertReason.integration.test.ts +5 -1
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -11
- package/src/hooks/dex/useAggregatorsQuotes.ts +13 -11
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -7
- package/src/hooks/dex/useAllUserPools.ts +8 -13
- package/src/hooks/dex/useApiPool.ts +2 -9
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -2
- package/src/hooks/dex/useOnChainPoolData.ts +3 -4
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +3 -9
- package/src/hooks/dex/usePoolEvents.ts +1 -2
- package/src/hooks/dex/usePoolHistoricalData.ts +3 -9
- package/src/hooks/dex/usePools.ts +6 -4
- package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
- package/src/hooks/enso/useBendDemultiply.ts +3 -4
- package/src/hooks/enso/useBendMultiply.ts +3 -4
- package/src/hooks/enso/useBendZapSupply.ts +4 -5
- package/src/hooks/enso/useEnsoSwapBundle.ts +2 -2
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +4 -10
- package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
- package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
- package/src/hooks/enso/useZapStakeBera.ts +2 -5
- package/src/hooks/exports.ts +1 -0
- package/src/hooks/governance/useGetPastVotes.ts +1 -1
- package/src/hooks/governance/useHasVoted.ts +1 -1
- package/src/hooks/governance/useIsCanceller.ts +1 -1
- package/src/hooks/governance/usePollAllProposals.ts +13 -12
- package/src/hooks/governance/usePollProposal.ts +7 -10
- package/src/hooks/governance/usePollProposalThreshold.ts +2 -7
- package/src/hooks/governance/usePollProposalVotes.ts +23 -5
- package/src/hooks/governance/usePollUserDelegates.ts +4 -9
- package/src/hooks/governance/useProposalFromTx.ts +4 -5
- package/src/hooks/governance/useProposalSnapshot.ts +3 -4
- package/src/hooks/governance/useProposalState.ts +3 -3
- package/src/hooks/governance/useProposalTimelockState.ts +3 -2
- package/src/hooks/governance/useQuorum.ts +1 -2
- package/src/hooks/honey/useCappedGlobally.ts +4 -12
- package/src/hooks/honey/useCappedRelatively.ts +3 -8
- package/src/hooks/honey/useCollateralWeights.ts +4 -9
- package/src/hooks/honey/useHoney24hVolume.ts +2 -6
- package/src/hooks/honey/useHoneyBalances.ts +2 -7
- package/src/hooks/honey/useHoneyChartData.ts +4 -12
- package/src/hooks/honey/useHoneyVaultsBalance.ts +3 -9
- package/src/hooks/honey/useIsBadCollateralAsset.ts +5 -13
- package/src/hooks/honey/useIsBasketModeEnabled.ts +5 -13
- package/src/hooks/honey/usePythLatestPrices.ts +15 -13
- package/src/hooks/perps/usePythUpdateFee.ts +13 -11
- package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -8
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +2 -8
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +34 -0
- package/src/hooks/pol/useBgtUnstakedBalance.ts +3 -8
- package/src/hooks/pol/useClaimableFees.ts +2 -6
- package/src/hooks/pol/useHighestVaultsAPR.ts +6 -11
- package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
- package/src/hooks/pol/usePollGlobalData.ts +3 -9
- package/src/hooks/pol/usePollMarkets.ts +3 -8
- package/src/hooks/pol/useQueuedBeraUnlock.ts +3 -12
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
- package/src/hooks/pol/useRewardVault.ts +9 -8
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +6 -6
- package/src/hooks/pol/useRewardVaultFromToken.ts +24 -30
- package/src/hooks/pol/useRewardVaultIncentives.ts +2 -7
- package/src/hooks/pol/useRewardVaultRewards.ts +3 -8
- package/src/hooks/pol/useRewardVaults.ts +4 -12
- package/src/hooks/pol/useStakedAPR.ts +2 -8
- package/src/hooks/pol/useStakedData.ts +90 -41
- package/src/hooks/pol/useStakedSnapshots.ts +4 -9
- package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
- package/src/hooks/pol/useTotalStakedAmount.ts +2 -8
- package/src/hooks/pol/useUserVaultInfo.ts +3 -8
- package/src/hooks/pol/useUserVaults.ts +3 -8
- package/src/hooks/pol/useVaultAddress.ts +1 -1
- package/src/hooks/pol/useVaultHistory.ts +2 -8
- package/src/hooks/pol/useVaultValidators.ts +3 -8
- package/src/hooks/tokens/useMultipleTokenInformation.ts +3 -8
- package/src/hooks/tokens/usePollAllowances.ts +4 -11
- package/src/hooks/tokens/usePollBalance.ts +2 -5
- package/src/hooks/tokens/usePollWalletBalances.ts +3 -3
- package/src/hooks/tokens/useStakingTokenInformation.ts +3 -12
- package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
- package/src/hooks/tokens/useTokenInformation.ts +3 -8
- package/src/hooks/tokens/useTokenPrice.ts +2 -1
- package/src/hooks/tokens/useTokenPrices.ts +3 -4
- package/src/hooks/tokens/useTotalSupply.ts +1 -1
- package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
- package/src/hooks/useBlockToTimestamp.ts +1 -2
- package/src/hooks/useGetVerifiedAbi.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +3 -9
- package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +4 -12
- package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +2 -4
- package/src/hooks/validators/useDefaultRewardAllocation.ts +3 -9
- package/src/hooks/validators/useManagedValidatorRole.ts +2 -3
- package/src/hooks/validators/useOnChainValidator.ts +4 -11
- package/src/hooks/validators/useStakingPoolBatch.ts +4 -10
- package/src/hooks/validators/useUserActiveValidators.ts +3 -9
- package/src/hooks/validators/useUserBoostsOnValidator.ts +2 -4
- package/src/hooks/validators/useUserClaimableIncentives.ts +3 -3
- package/src/hooks/validators/useUserStakingPositions.ts +3 -9
- package/src/hooks/validators/useValidatorAnalytics.ts +2 -4
- package/src/hooks/validators/useValidatorCommission.ts +3 -8
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -6
- package/src/hooks/validators/useValidatorQueuedCommission.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +3 -8
- package/src/hooks/validators/useValidatorRewardAllocation.ts +3 -8
- package/src/types/global.d.ts +7 -10
- package/src/types/pol.d.ts +17 -3
- package/dist/polling-BKnyavLI.d.ts +0 -8
- package/src/actions/clients/fetchRailwayBackend.ts +0 -34
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
|
@@ -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
|
|
4
|
-
import {
|
|
3
|
+
import * as _berachain_utils_pkg_swr from '@berachain/utils/pkg/swr';
|
|
4
|
+
import { BeraSwrResponse } 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 {
|
|
8
|
+
import { SWRInfiniteResponse, SWRInfiniteKeyLoader } from '@berachain/utils/pkg/swr/infinite';
|
|
9
|
+
import { D as DefaultHookOptions, a as DefaultHookReturnType } from '../../global.d-CR3zicga.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
|
-
})) =>
|
|
43
|
+
})) => _berachain_utils_pkg_swr.BeraSwrResponse<string, any>;
|
|
44
44
|
|
|
45
45
|
declare const useHasVoted: ({ proposalId, wallet, }: {
|
|
46
46
|
proposalId: string;
|
|
47
47
|
wallet?: Address;
|
|
48
|
-
}) =>
|
|
48
|
+
}) => _berachain_utils_pkg_swr.BeraSwrResponse<boolean, any>;
|
|
49
49
|
|
|
50
50
|
declare const useIsCanceller: ({ account, ...baseArgs }: {
|
|
51
51
|
account: Address | undefined;
|
|
52
|
-
} & BeraJS.BaseFunctionArgs) =>
|
|
53
|
-
refreshInterval: POLLING;
|
|
54
|
-
revalidateOnFocus: false;
|
|
55
|
-
}>;
|
|
52
|
+
} & BeraJS.BaseFunctionArgs) => _berachain_utils_pkg_swr.BeraSwrResponse<boolean, 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,14 +126,14 @@ 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;
|
|
128
133
|
currentVotes: string | undefined;
|
|
129
134
|
}>;
|
|
130
135
|
|
|
131
|
-
declare const useProposalFromTx: (txHash?: Address) =>
|
|
136
|
+
declare const useProposalFromTx: (txHash?: Address) => BeraSwrResponse<ProposalWithVotesFragment | null>;
|
|
132
137
|
|
|
133
138
|
/**
|
|
134
139
|
* Timepoint used to retrieve user’s votes and quorum. If using block
|
|
@@ -139,12 +144,12 @@ declare const useProposalFromTx: (txHash?: Address) => SWRResponse<ProposalWithV
|
|
|
139
144
|
*/
|
|
140
145
|
declare const useProposalSnapshot: ({ proposalId, }: {
|
|
141
146
|
proposalId: number | bigint | string | undefined;
|
|
142
|
-
}) =>
|
|
147
|
+
}) => BeraSwrResponse<string>;
|
|
143
148
|
|
|
144
149
|
declare const useProposalState: ({ proposalId, governorAddress, }: {
|
|
145
150
|
proposalId: number | bigint | string | undefined;
|
|
146
151
|
governorAddress: Address;
|
|
147
|
-
}) =>
|
|
152
|
+
}) => BeraSwrResponse<string>;
|
|
148
153
|
|
|
149
154
|
declare const TimelockOperationState: {
|
|
150
155
|
readonly 0: "unset";
|
|
@@ -159,7 +164,7 @@ declare const TimelockOperationState: {
|
|
|
159
164
|
declare function useProposalTimelockState({ proposalTimelockId, timelockAddress, }: {
|
|
160
165
|
proposalTimelockId: Address | undefined;
|
|
161
166
|
timelockAddress: Address;
|
|
162
|
-
}):
|
|
167
|
+
}): BeraSwrResponse<(typeof TimelockOperationState)[keyof typeof TimelockOperationState]>;
|
|
163
168
|
|
|
164
169
|
/**
|
|
165
170
|
* Queries the quorum for a given timestamp.
|
|
@@ -173,9 +178,9 @@ declare function useQuorum({ at }: {
|
|
|
173
178
|
}): {
|
|
174
179
|
data: number | undefined;
|
|
175
180
|
error: any;
|
|
176
|
-
mutate: swr.KeyedMutator<string>;
|
|
177
181
|
isValidating: boolean;
|
|
178
182
|
isLoading: swr__internal.IsLoadingResponse<Data, Config>;
|
|
183
|
+
refresh: () => void;
|
|
179
184
|
};
|
|
180
185
|
|
|
181
186
|
export { type UsePollProposalResponse, useCreateProposal, useGetPastVotes, useHasVoted, useIsCanceller, usePollAllProposals, usePollAllProposalsQueryKey, usePollProposal, usePollProposalThreshold, usePollProposalVotes, usePollProposalVotesQueryKey, usePollUserDelegates, useProposalFromTx, useProposalSnapshot, useProposalState, useProposalTimelockState, useQuorum };
|
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
getProposalVotes
|
|
8
8
|
} from "../../chunk-GUURQAME.mjs";
|
|
9
9
|
import "../../chunk-DKMAIU74.mjs";
|
|
10
|
+
import {
|
|
11
|
+
useSWR,
|
|
12
|
+
useSWRImmutable
|
|
13
|
+
} from "../../chunk-4ML4Y6UN.mjs";
|
|
10
14
|
import "../../chunk-SGIJVHZO.mjs";
|
|
11
15
|
import {
|
|
12
16
|
assertPublicClient
|
|
@@ -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
|
|
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
|
|
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 =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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 =
|
|
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
|
|
581
|
-
refreshInterval: options?.
|
|
589
|
+
...options,
|
|
590
|
+
refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */
|
|
582
591
|
}
|
|
583
592
|
);
|
|
584
593
|
const [timestamp, setTimestamp] = useState3(Date.now());
|
|
@@ -594,36 +603,32 @@ var usePollProposal = (proposalId, options) => {
|
|
|
594
603
|
switch (swrResponse.data.status) {
|
|
595
604
|
case ProposalStatus2.Pending:
|
|
596
605
|
if (timestamp >= Number(swrResponse.data.voteStartAt)) {
|
|
597
|
-
swrResponse.
|
|
606
|
+
swrResponse.refresh();
|
|
598
607
|
}
|
|
599
608
|
break;
|
|
600
609
|
case ProposalStatus2.Active:
|
|
601
610
|
if (timestamp >= Number(swrResponse.data.voteEndAt)) {
|
|
602
|
-
swrResponse.
|
|
611
|
+
swrResponse.refresh();
|
|
603
612
|
}
|
|
604
613
|
break;
|
|
605
614
|
case ProposalStatus2.InQueue:
|
|
606
615
|
if (Date.now() / 1e3 + 1 >= Number(swrResponse.data.queueEnd)) {
|
|
607
|
-
swrResponse.
|
|
616
|
+
swrResponse.refresh();
|
|
608
617
|
}
|
|
609
618
|
break;
|
|
610
619
|
}
|
|
611
620
|
}, [swrResponse.data?.status, timestamp]);
|
|
612
|
-
return
|
|
613
|
-
...swrResponse,
|
|
614
|
-
refresh: () => swrResponse?.mutate?.()
|
|
615
|
-
};
|
|
621
|
+
return swrResponse;
|
|
616
622
|
};
|
|
617
623
|
|
|
618
624
|
// src/hooks/governance/usePollProposalThreshold.ts
|
|
619
|
-
import useSWR4 from "swr";
|
|
620
625
|
import { formatEther } from "viem";
|
|
621
626
|
import { berachainGovernanceAbi as governanceAbi3 } from "@berachain/abis/gov/berachainGovernance";
|
|
622
627
|
import { usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
|
|
623
628
|
var usePollProposalThreshold = (governorAddress) => {
|
|
624
629
|
const publicClient = usePublicClient6();
|
|
625
630
|
const QUERY_KEY = publicClient ? ["usePollProposalThreshold", governorAddress] : null;
|
|
626
|
-
|
|
631
|
+
return useSWR(
|
|
627
632
|
QUERY_KEY,
|
|
628
633
|
async ([, governorAddress2]) => {
|
|
629
634
|
assertPublicClient(publicClient);
|
|
@@ -638,17 +643,12 @@ var usePollProposalThreshold = (governorAddress) => {
|
|
|
638
643
|
refreshInterval: 18e4 /* SLOW */
|
|
639
644
|
}
|
|
640
645
|
);
|
|
641
|
-
return {
|
|
642
|
-
...swrResponse,
|
|
643
|
-
refresh: swrResponse.mutate
|
|
644
|
-
};
|
|
645
646
|
};
|
|
646
647
|
|
|
647
648
|
// src/hooks/governance/usePollProposalVotes.ts
|
|
648
|
-
import useSWRInfinite2 from "swr/infinite";
|
|
649
649
|
var DEFAULT_LIMIT = 1e3;
|
|
650
650
|
var usePollProposalVotes = (args, total) => {
|
|
651
|
-
return
|
|
651
|
+
return useSWRInfinite(
|
|
652
652
|
usePollProposalVotesQueryKey(args, total),
|
|
653
653
|
async ([_key, page]) => {
|
|
654
654
|
return getProposalVotes({
|
|
@@ -681,7 +681,6 @@ var usePollProposalVotesQueryKey = ({ ...args }, total) => (pageIndex) => {
|
|
|
681
681
|
};
|
|
682
682
|
|
|
683
683
|
// src/hooks/governance/usePollUserDelegates.ts
|
|
684
|
-
import useSWR5 from "swr";
|
|
685
684
|
import { formatEther as formatEther2 } from "viem";
|
|
686
685
|
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
687
686
|
import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
@@ -689,7 +688,7 @@ var usePollUserDelegates = (options) => {
|
|
|
689
688
|
const { address: account } = useBeraWallet3();
|
|
690
689
|
const publicClient = usePublicClient7();
|
|
691
690
|
const QUERY_KEY = account ? ["usePollUserDelegates", account] : null;
|
|
692
|
-
|
|
691
|
+
return useSWR(
|
|
693
692
|
QUERY_KEY,
|
|
694
693
|
async ([, account2]) => {
|
|
695
694
|
assertPublicClient(publicClient);
|
|
@@ -719,18 +718,13 @@ var usePollUserDelegates = (options) => {
|
|
|
719
718
|
};
|
|
720
719
|
},
|
|
721
720
|
{
|
|
722
|
-
...options
|
|
723
|
-
refreshInterval: options?.
|
|
721
|
+
...options,
|
|
722
|
+
refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */
|
|
724
723
|
}
|
|
725
724
|
);
|
|
726
|
-
return {
|
|
727
|
-
...swrResponse,
|
|
728
|
-
refresh: () => swrResponse?.mutate?.()
|
|
729
|
-
};
|
|
730
725
|
};
|
|
731
726
|
|
|
732
727
|
// src/hooks/governance/useProposalFromTx.ts
|
|
733
|
-
import useSWR6 from "swr";
|
|
734
728
|
import { usePublicClient as usePublicClient8, useTransactionReceipt } from "@berachain/wagmi/hooks";
|
|
735
729
|
var useProposalFromTx = (txHash) => {
|
|
736
730
|
const { data: tx } = useTransactionReceipt({
|
|
@@ -738,7 +732,7 @@ var useProposalFromTx = (txHash) => {
|
|
|
738
732
|
});
|
|
739
733
|
const publicClient = usePublicClient8();
|
|
740
734
|
const QUERY_KEY = tx && publicClient ? ["useProposalFromTx", txHash] : null;
|
|
741
|
-
|
|
735
|
+
return useSWR(QUERY_KEY, async ([, txHash2]) => {
|
|
742
736
|
if (!tx) {
|
|
743
737
|
throw new Error("Transaction not found");
|
|
744
738
|
}
|
|
@@ -747,11 +741,9 @@ var useProposalFromTx = (txHash) => {
|
|
|
747
741
|
}
|
|
748
742
|
return getProposalFromTx({ tx, publicClient });
|
|
749
743
|
});
|
|
750
|
-
return swrResponse;
|
|
751
744
|
};
|
|
752
745
|
|
|
753
746
|
// src/hooks/governance/useProposalState.ts
|
|
754
|
-
import useSWRImmutable3 from "swr/immutable";
|
|
755
747
|
import { berachainGovernanceAbi as governanceAbi4 } from "@berachain/abis/gov/berachainGovernance";
|
|
756
748
|
import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
|
|
757
749
|
var ProposalStateMap = {
|
|
@@ -770,7 +762,7 @@ var useProposalState = ({
|
|
|
770
762
|
}) => {
|
|
771
763
|
const publicClient = usePublicClient9();
|
|
772
764
|
const QUERY_KEY = governorAddress && publicClient && proposalId ? ["useProposalState", proposalId] : null;
|
|
773
|
-
return
|
|
765
|
+
return useSWRImmutable(QUERY_KEY, async ([, proposalId2]) => {
|
|
774
766
|
assertPublicClient(publicClient);
|
|
775
767
|
const snapshot = await publicClient.readContract({
|
|
776
768
|
abi: governanceAbi4,
|
|
@@ -783,7 +775,6 @@ var useProposalState = ({
|
|
|
783
775
|
};
|
|
784
776
|
|
|
785
777
|
// src/hooks/governance/useProposalTimelockState.ts
|
|
786
|
-
import useSWR7 from "swr";
|
|
787
778
|
import { timeLockAbi as governanceTimelockAbi2 } from "@berachain/abis/gov/timeLock";
|
|
788
779
|
import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
|
|
789
780
|
var TimelockOperationState = {
|
|
@@ -802,7 +793,7 @@ function useProposalTimelockState({
|
|
|
802
793
|
proposalTimelockId,
|
|
803
794
|
timelockAddress
|
|
804
795
|
] : null;
|
|
805
|
-
return
|
|
796
|
+
return useSWR(
|
|
806
797
|
QUERY_KEY,
|
|
807
798
|
async ([, proposalTimelockId2, timelockAddress2]) => {
|
|
808
799
|
assertPublicClient(publicClient);
|
|
@@ -821,7 +812,6 @@ function useProposalTimelockState({
|
|
|
821
812
|
}
|
|
822
813
|
|
|
823
814
|
// src/hooks/governance/useQuorum.ts
|
|
824
|
-
import useSWR8 from "swr";
|
|
825
815
|
import { usePublicClient as usePublicClient11 } from "@berachain/wagmi/hooks";
|
|
826
816
|
|
|
827
817
|
// src/actions/governance/getQuorum.ts
|
|
@@ -857,7 +847,7 @@ function useQuorum({ at }, {
|
|
|
857
847
|
// Using Now because we cannot query quorum in the future, so no need to have different query keys.
|
|
858
848
|
Number(at) > now ? "now" : at
|
|
859
849
|
] : null;
|
|
860
|
-
const response =
|
|
850
|
+
const response = useSWR(QUERY_KEY, async ([, at2]) => {
|
|
861
851
|
if (at2 === "now") {
|
|
862
852
|
return getQuorum({ publicClient });
|
|
863
853
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
|
-
import { a as TokenWithMetadata, b as Token } from './HoneyConfigProvider-
|
|
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 {
|
|
@@ -142,11 +142,25 @@ interface UserVaultInfo {
|
|
|
142
142
|
|
|
143
143
|
type StakedBeraAsset = {
|
|
144
144
|
token: TokenWithMetadata;
|
|
145
|
-
|
|
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;
|
|
146
151
|
stakedAmount: number;
|
|
147
|
-
|
|
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;
|
|
148
158
|
earnedAmount: number;
|
|
149
|
-
|
|
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;
|
|
150
164
|
isLoadingEarnings?: boolean;
|
|
151
165
|
};
|
|
152
166
|
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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-
|
|
2
|
-
import { M as MinimalERC20 } from '../HoneyConfigProvider-
|
|
3
|
-
export { A as AllowanceQueryItem, j as AllowanceToken, B as BalanceToken,
|
|
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-
|
|
6
|
+
export { D as DefaultHookOptions, a as DefaultHookReturnType, I as IContractWrite, c as IContractWriteFn } from '../global.d-CR3zicga.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-
|
|
2
|
+
import { T as TokenWithOrder, H as HoneySwapActions } from './HoneyConfigProvider-COOuDNra.js';
|
|
3
3
|
|
|
4
4
|
interface IHoneySwapState {
|
|
5
5
|
actionType: "mint" | "redeem";
|
package/dist/utils/exports.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
17
|
+
import '../HoneyConfigProvider-COOuDNra.js';
|
|
18
18
|
import 'react/jsx-runtime';
|
|
19
19
|
import '@berachain-foundation/berancer-sdk';
|
|
20
20
|
import '../honey-CYm0RWf4.js';
|
package/dist/utils/exports.mjs
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
beraFetch,
|
|
39
39
|
beraFetchJson,
|
|
40
40
|
sanitizeRpcUrl
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-T43JPYQS.mjs";
|
|
42
42
|
import {
|
|
43
43
|
defaultFlags
|
|
44
44
|
} from "../chunk-BGMRHTBQ.mjs";
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
} from "../chunk-SZ5C44L5.mjs";
|
|
57
57
|
import {
|
|
58
58
|
RequestError
|
|
59
|
-
} from "../chunk-
|
|
59
|
+
} from "../chunk-RFJGL4MF.mjs";
|
|
60
60
|
import {
|
|
61
61
|
BeraError,
|
|
62
62
|
InvalidArgumentError
|
|
@@ -484,6 +484,10 @@ var contracts = [
|
|
|
484
484
|
"80094": "0x2880aB155794e7179c9eE2e38200202908C17B43",
|
|
485
485
|
name: "external.pyth"
|
|
486
486
|
},
|
|
487
|
+
{
|
|
488
|
+
"80094": "0xB5f473c4b7F402d8f7bED42b6D516f5ff3306B01",
|
|
489
|
+
name: "bend.production.supportedVaults.1"
|
|
490
|
+
},
|
|
487
491
|
{
|
|
488
492
|
"80069": null,
|
|
489
493
|
"80094": "0xC5FabF3a7E98a2ed89f5d5057Ab010634Ca7e71f",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berachain/berajs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
"@apollo/client": "4.1.6",
|
|
14
14
|
"@berachain-foundation/berancer-sdk": "1.1.7",
|
|
15
15
|
"@berachain/abis": "0.1.3-beta.0",
|
|
16
|
-
"@berachain/config": "0.1.
|
|
17
|
-
"@berachain/graphql": "0.5.
|
|
16
|
+
"@berachain/config": "0.1.21",
|
|
17
|
+
"@berachain/graphql": "0.5.2",
|
|
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.
|
|
31
|
-
"vitest": "3.2.
|
|
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<
|
|
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
|
|
43
|
+
return {
|
|
44
|
+
formatted: formatEther(maxDeposit),
|
|
45
|
+
isUncapped: maxDeposit >= UNCAPPED_THRESHOLD,
|
|
46
|
+
};
|
|
21
47
|
}
|
|
@@ -15,9 +15,6 @@ import {
|
|
|
15
15
|
* against the beep schema (`@berachain/graphql/beep`), so route shapes (e.g.
|
|
16
16
|
* the `/v0/stake/*` namespace) can never drift out of sync with the backend.
|
|
17
17
|
* The base URL is resolved from `config.beep`.
|
|
18
|
-
*
|
|
19
|
-
* @throws if `config.beep` is not set for the active chain. Callers should only
|
|
20
|
-
* reach for beep when `config.beep` is non-null.
|
|
21
18
|
*/
|
|
22
19
|
export function fetchBeep<P extends GetPath<paths>>(
|
|
23
20
|
path: P,
|
|
@@ -26,9 +23,5 @@ export function fetchBeep<P extends GetPath<paths>>(
|
|
|
26
23
|
): Promise<GetResponse<paths, P>> {
|
|
27
24
|
const { config } = parseBaseArgs(args);
|
|
28
25
|
|
|
29
|
-
if (!config.beep) {
|
|
30
|
-
throw new Error("fetchBeep: `beep` backend is not configured.");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
26
|
return fetchOpenApi<paths, P>(config.beep, path, params, "beep");
|
|
34
27
|
}
|