@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,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import { formatUnits, parseUnits } from "viem";
|
|
5
4
|
|
|
6
5
|
import { chainConfigs, defaultChainId } from "@berachain/config/internal";
|
|
7
6
|
|
|
8
7
|
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
|
|
11
11
|
import { POLLING } from "../../enum/polling";
|
|
@@ -85,7 +85,7 @@ export function useZapStakeBera(
|
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
|
-
...options
|
|
88
|
+
...options,
|
|
89
89
|
refreshInterval: POLLING.NORMAL,
|
|
90
90
|
},
|
|
91
91
|
);
|
|
@@ -106,8 +106,5 @@ export function useZapStakeBera(
|
|
|
106
106
|
priceImpactPercentage,
|
|
107
107
|
isCrossChain: inputToken && tokenOut.chainId !== inputToken?.chainId,
|
|
108
108
|
},
|
|
109
|
-
refresh: () => {
|
|
110
|
-
swrResponse.mutate();
|
|
111
|
-
},
|
|
112
109
|
};
|
|
113
110
|
}
|
package/src/hooks/exports.ts
CHANGED
|
@@ -51,6 +51,7 @@ export * from "./perps/usePythUpdateFee";
|
|
|
51
51
|
export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
|
|
52
52
|
export { useAutoclaimedIncentivesTxHash } from "./pol/useAutoclaimedIncentivesTxHash";
|
|
53
53
|
export * from "./pol/useBgtAprSimulation";
|
|
54
|
+
export { useBgtIncentiveDistributorPaused } from "./pol/useBgtIncentiveDistributorPaused";
|
|
54
55
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
55
56
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
56
57
|
export * from "./pol/useHighestVaultsAPR";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { type Address, formatUnits } from "viem";
|
|
3
2
|
|
|
4
3
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
9
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, isAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
9
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { CANCELLER_ROLE } from "../../actions/governance/constants";
|
|
9
9
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import useSWRInfinite, { type SWRInfiniteResponse } from "swr/infinite";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
type OrderDirection,
|
|
@@ -8,6 +7,8 @@ import {
|
|
|
8
7
|
type ProposalSelectionFragment,
|
|
9
8
|
ProposalStatus,
|
|
10
9
|
} from "@berachain/graphql/governance";
|
|
10
|
+
import type { SWRInfiniteResponse } from "@berachain/utils/pkg/swr/infinite";
|
|
11
|
+
import useSWRInfinite from "@berachain/utils/pkg/swr/infinite";
|
|
11
12
|
|
|
12
13
|
import { getAllProposals } from "../../actions/governance/getAllProposals";
|
|
13
14
|
import { POLLING } from "../../enum/polling";
|
|
@@ -66,7 +67,7 @@ export function usePollAllProposalsQueryKey(
|
|
|
66
67
|
args: Partial<UsePollAllProposalsArgs> = {},
|
|
67
68
|
): (
|
|
68
69
|
pageIndex: number,
|
|
69
|
-
previousPageData?: ProposalSelectionFragment[],
|
|
70
|
+
previousPageData?: ProposalSelectionFragment[] | null,
|
|
70
71
|
) => PollAllProposalsKey {
|
|
71
72
|
const subgraphPageSize = 2 * (args.perPage ?? DEFAULT_PER_PAGE);
|
|
72
73
|
|
|
@@ -141,16 +142,16 @@ export function usePollAllProposals(
|
|
|
141
142
|
return (proposals ?? []).filter(Boolean) as ProposalSelectionFragment[];
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
const swr = useSWRInfinite<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
145
|
+
const swr = useSWRInfinite<
|
|
146
|
+
ProposalSelectionFragment[],
|
|
147
|
+
any,
|
|
148
|
+
PollAllProposalsKey
|
|
149
|
+
>(getKey, fetcher, {
|
|
150
|
+
// Increase initialSize in order to prefetch more proposals at a time.
|
|
151
|
+
initialSize: 1,
|
|
152
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
153
|
+
...options,
|
|
154
|
+
});
|
|
154
155
|
|
|
155
156
|
const data = useMemo(() => {
|
|
156
157
|
if (!swr.data) return [];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
ProposalStatus,
|
|
6
5
|
type ProposalWithVotesFragment,
|
|
7
6
|
} from "@berachain/graphql/governance";
|
|
8
7
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { getProposalDetails } from "../../actions/governance/getProposalDetails";
|
|
11
11
|
import { POLLING } from "../../enum/polling";
|
|
@@ -53,8 +53,8 @@ export const usePollProposal = (
|
|
|
53
53
|
return getProposalDetails({ proposalId, client: publicClient });
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
...options
|
|
57
|
-
refreshInterval: options?.
|
|
56
|
+
...options,
|
|
57
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
58
58
|
},
|
|
59
59
|
);
|
|
60
60
|
|
|
@@ -75,25 +75,22 @@ export const usePollProposal = (
|
|
|
75
75
|
switch (swrResponse.data.status) {
|
|
76
76
|
case ProposalStatus.Pending:
|
|
77
77
|
if (timestamp >= Number(swrResponse.data.voteStartAt)) {
|
|
78
|
-
swrResponse.
|
|
78
|
+
swrResponse.refresh();
|
|
79
79
|
}
|
|
80
80
|
break;
|
|
81
81
|
case ProposalStatus.Active:
|
|
82
82
|
if (timestamp >= Number(swrResponse.data.voteEndAt)) {
|
|
83
|
-
swrResponse.
|
|
83
|
+
swrResponse.refresh();
|
|
84
84
|
}
|
|
85
85
|
break;
|
|
86
86
|
case ProposalStatus.InQueue:
|
|
87
87
|
if (Date.now() / 1000 + 1 >= Number(swrResponse.data.queueEnd)) {
|
|
88
|
-
swrResponse.
|
|
88
|
+
swrResponse.refresh();
|
|
89
89
|
}
|
|
90
90
|
break;
|
|
91
91
|
}
|
|
92
92
|
}, [swrResponse.data?.status, timestamp]);
|
|
93
93
|
|
|
94
94
|
// const votes = swrResponse.data?.votes.nodes ?? [];
|
|
95
|
-
return
|
|
96
|
-
...swrResponse,
|
|
97
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
98
|
-
};
|
|
95
|
+
return swrResponse;
|
|
99
96
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, formatEther } from "viem";
|
|
3
2
|
|
|
4
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { POLLING } from "../../enum/polling";
|
|
9
9
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -18,7 +18,7 @@ export const usePollProposalThreshold = (
|
|
|
18
18
|
? (["usePollProposalThreshold", governorAddress] as const)
|
|
19
19
|
: null;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return useSWR<{ votesThreshold: string }, any, typeof QUERY_KEY>(
|
|
22
22
|
QUERY_KEY,
|
|
23
23
|
async ([, governorAddress]) => {
|
|
24
24
|
assertPublicClient(publicClient);
|
|
@@ -34,9 +34,4 @@ export const usePollProposalThreshold = (
|
|
|
34
34
|
refreshInterval: POLLING.SLOW,
|
|
35
35
|
},
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...swrResponse,
|
|
40
|
-
refresh: swrResponse.mutate,
|
|
41
|
-
};
|
|
42
37
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import useSWRInfinite, { type SWRInfiniteKeyLoader } from "swr/infinite";
|
|
2
|
-
|
|
3
1
|
import type { GetProposalVotesQueryVariables } from "@berachain/graphql/governance";
|
|
2
|
+
import type { SWRInfiniteKeyLoader } from "@berachain/utils/pkg/swr/infinite";
|
|
3
|
+
import { useSWRInfinite } from "@berachain/utils/pkg/swr/infinite";
|
|
4
4
|
|
|
5
5
|
import { getProposalVotes } from "../../actions/governance/getProposalVotes";
|
|
6
6
|
|
|
@@ -12,6 +12,17 @@ type UsePollProposalVotesArgs = Omit<
|
|
|
12
12
|
// const ACTUAL_PER_PAGE = 500;
|
|
13
13
|
|
|
14
14
|
const DEFAULT_LIMIT = 1000;
|
|
15
|
+
|
|
16
|
+
type ProposalVotesKey =
|
|
17
|
+
| [
|
|
18
|
+
string,
|
|
19
|
+
number,
|
|
20
|
+
number,
|
|
21
|
+
UsePollProposalVotesArgs["proposalId"],
|
|
22
|
+
UsePollProposalVotesArgs["orderBy"],
|
|
23
|
+
UsePollProposalVotesArgs["orderDirection"],
|
|
24
|
+
]
|
|
25
|
+
| null;
|
|
15
26
|
/**
|
|
16
27
|
* Fetches all the votes for a proposal from the Subgraph
|
|
17
28
|
* @param args - The arguments to pass to the query
|
|
@@ -21,9 +32,13 @@ export const usePollProposalVotes = (
|
|
|
21
32
|
args: UsePollProposalVotesArgs,
|
|
22
33
|
total: number,
|
|
23
34
|
) => {
|
|
24
|
-
return useSWRInfinite
|
|
35
|
+
return useSWRInfinite<
|
|
36
|
+
Awaited<ReturnType<typeof getProposalVotes>>,
|
|
37
|
+
any,
|
|
38
|
+
ProposalVotesKey
|
|
39
|
+
>(
|
|
25
40
|
usePollProposalVotesQueryKey(args, total),
|
|
26
|
-
async ([_key, page]
|
|
41
|
+
async ([_key, page]) => {
|
|
27
42
|
return getProposalVotes({
|
|
28
43
|
variables: {
|
|
29
44
|
...args,
|
|
@@ -44,7 +59,10 @@ export const usePollProposalVotesQueryKey =
|
|
|
44
59
|
(
|
|
45
60
|
{ ...args }: UsePollProposalVotesArgs,
|
|
46
61
|
total: number,
|
|
47
|
-
): SWRInfiniteKeyLoader
|
|
62
|
+
): SWRInfiniteKeyLoader<
|
|
63
|
+
Awaited<ReturnType<typeof getProposalVotes>>,
|
|
64
|
+
ProposalVotesKey
|
|
65
|
+
> =>
|
|
48
66
|
(
|
|
49
67
|
pageIndex: number,
|
|
50
68
|
// previousPageData: Awaited<ReturnType<typeof getProposalVotes>>,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, formatEther } from "viem";
|
|
3
2
|
|
|
4
3
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { POLLING } from "../../enum/polling";
|
|
9
9
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -25,7 +25,7 @@ export const usePollUserDelegates = (
|
|
|
25
25
|
? (["usePollUserDelegates", account] as const)
|
|
26
26
|
: null;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
return useSWR<
|
|
29
29
|
{ delegate: Address; currentVotes: string | undefined },
|
|
30
30
|
any,
|
|
31
31
|
typeof QUERY_KEY
|
|
@@ -62,13 +62,8 @@ export const usePollUserDelegates = (
|
|
|
62
62
|
};
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
...options
|
|
66
|
-
refreshInterval: options?.
|
|
65
|
+
...options,
|
|
66
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
67
67
|
},
|
|
68
68
|
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...swrResponse,
|
|
72
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
73
|
-
};
|
|
74
69
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { ProposalWithVotesFragment } from "@berachain/graphql/governance";
|
|
5
4
|
import { usePublicClient, useTransactionReceipt } from "@berachain/wagmi/hooks";
|
|
5
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
6
7
|
|
|
7
8
|
import { getProposalFromTx } from "../../actions/governance/getProposalFromTx";
|
|
8
9
|
|
|
9
10
|
export const useProposalFromTx = (
|
|
10
11
|
txHash?: Address,
|
|
11
|
-
):
|
|
12
|
+
): BeraSwrResponse<ProposalWithVotesFragment | null> => {
|
|
12
13
|
const { data: tx } = useTransactionReceipt({
|
|
13
14
|
hash: txHash,
|
|
14
15
|
});
|
|
@@ -18,7 +19,7 @@ export const useProposalFromTx = (
|
|
|
18
19
|
const QUERY_KEY =
|
|
19
20
|
tx && publicClient ? (["useProposalFromTx", txHash] as const) : null;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
return useSWR(QUERY_KEY, async ([, txHash]) => {
|
|
22
23
|
if (!tx) {
|
|
23
24
|
throw new Error("Transaction not found");
|
|
24
25
|
}
|
|
@@ -32,6 +33,4 @@ export const useProposalFromTx = (
|
|
|
32
33
|
|
|
33
34
|
return getProposalFromTx({ tx, publicClient });
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
-
return swrResponse;
|
|
37
36
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { SWRResponse } from "swr";
|
|
2
|
-
import useSWRImmutable from "swr/immutable";
|
|
3
|
-
|
|
4
1
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
2
|
|
|
6
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
5
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
6
|
|
|
8
7
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
8
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -19,7 +18,7 @@ export const useProposalSnapshot = ({
|
|
|
19
18
|
proposalId,
|
|
20
19
|
}: {
|
|
21
20
|
proposalId: number | bigint | string | undefined;
|
|
22
|
-
}):
|
|
21
|
+
}): BeraSwrResponse<string> => {
|
|
23
22
|
const publicClient = usePublicClient();
|
|
24
23
|
|
|
25
24
|
const QUERY_KEY =
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { SWRResponse } from "swr";
|
|
2
|
-
import useSWRImmutable from "swr/immutable";
|
|
3
1
|
import type { Address } from "viem";
|
|
4
2
|
|
|
5
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
6
4
|
|
|
7
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
7
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
8
8
|
|
|
9
9
|
import { ProposalState } from "../../enum/governance";
|
|
10
10
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -26,7 +26,7 @@ export const useProposalState = ({
|
|
|
26
26
|
}: {
|
|
27
27
|
proposalId: number | bigint | string | undefined;
|
|
28
28
|
governorAddress: Address;
|
|
29
|
-
}):
|
|
29
|
+
}): BeraSwrResponse<string> => {
|
|
30
30
|
const publicClient = usePublicClient();
|
|
31
31
|
|
|
32
32
|
const QUERY_KEY =
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
7
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
8
|
|
|
8
9
|
import { POLLING } from "../../enum/polling";
|
|
9
10
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -25,7 +26,7 @@ export function useProposalTimelockState({
|
|
|
25
26
|
}: {
|
|
26
27
|
proposalTimelockId: Address | undefined;
|
|
27
28
|
timelockAddress: Address;
|
|
28
|
-
}):
|
|
29
|
+
}): BeraSwrResponse<
|
|
29
30
|
(typeof TimelockOperationState)[keyof typeof TimelockOperationState]
|
|
30
31
|
> {
|
|
31
32
|
const publicClient = usePublicClient();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getGlobalCapLimit } from "../../actions/honey/getGlobalCapLimit";
|
|
6
5
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -39,9 +38,7 @@ export const useCappedGlobally = (
|
|
|
39
38
|
: undefined,
|
|
40
39
|
},
|
|
41
40
|
{
|
|
42
|
-
|
|
43
|
-
isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
|
|
44
|
-
},
|
|
41
|
+
isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
|
|
45
42
|
},
|
|
46
43
|
);
|
|
47
44
|
const QUERY_KEY =
|
|
@@ -59,7 +56,7 @@ export const useCappedGlobally = (
|
|
|
59
56
|
] as const)
|
|
60
57
|
: null;
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
return useSWR(
|
|
63
60
|
QUERY_KEY,
|
|
64
61
|
async ([
|
|
65
62
|
_,
|
|
@@ -84,13 +81,8 @@ export const useCappedGlobally = (
|
|
|
84
81
|
});
|
|
85
82
|
},
|
|
86
83
|
{
|
|
87
|
-
...options
|
|
84
|
+
...options,
|
|
88
85
|
refreshInterval: 0,
|
|
89
86
|
},
|
|
90
87
|
);
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
...swrResponse,
|
|
94
|
-
refresh: () => void swrResponse.mutate(),
|
|
95
|
-
};
|
|
96
88
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getRelativeCapLimit } from "../../actions/honey/getRelativeCapLimit";
|
|
7
7
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -41,7 +41,7 @@ export const useCappedRelatively = (
|
|
|
41
41
|
] as const)
|
|
42
42
|
: null;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return useSWR(
|
|
45
45
|
QUERY_KEY,
|
|
46
46
|
async ([_, asset, amount, collaterals, referenceCollateral]) => {
|
|
47
47
|
if (isBasketModeEnabled) {
|
|
@@ -80,12 +80,7 @@ export const useCappedRelatively = (
|
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
refreshInterval: 0,
|
|
83
|
-
...options
|
|
83
|
+
...options,
|
|
84
84
|
},
|
|
85
85
|
);
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
...swrResponse,
|
|
89
|
-
refresh: () => void swrResponse.mutate(),
|
|
90
|
-
};
|
|
91
86
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getCollateralWeights } from "../../actions/honey/getCollateralWeights";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -29,7 +29,7 @@ export const useCollateralWeights = (
|
|
|
29
29
|
? (["useCollateralWeights", collateralList] as const)
|
|
30
30
|
: undefined;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return useSWR(
|
|
33
33
|
QUERY_KEY,
|
|
34
34
|
async ([_, collateralList]) => {
|
|
35
35
|
assertPublicClient(publicClient);
|
|
@@ -40,13 +40,8 @@ export const useCollateralWeights = (
|
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
...options
|
|
44
|
-
refreshInterval: options?.
|
|
43
|
+
...options,
|
|
44
|
+
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
45
45
|
},
|
|
46
46
|
);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
...swrResponse,
|
|
50
|
-
refresh: () => void swrResponse.mutate(),
|
|
51
|
-
};
|
|
52
47
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
1
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
2
2
|
|
|
3
3
|
import { getHoney24hVolume } from "../../actions/honey/getHoney24hVolume";
|
|
4
4
|
import { POLLING } from "../../enum/polling";
|
|
@@ -8,9 +8,5 @@ export function useHoney24hVolume() {
|
|
|
8
8
|
refreshInterval: POLLING.SLOW,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
return
|
|
12
|
-
...response,
|
|
13
|
-
|
|
14
|
-
refresh: () => response.mutate(),
|
|
15
|
-
};
|
|
11
|
+
return response;
|
|
16
12
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
useConfig,
|
|
7
6
|
usePublicClient,
|
|
8
7
|
} from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { getWalletBalances } from "../../actions/tokens/getWalletBalances";
|
|
11
11
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -48,7 +48,7 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
48
48
|
? (["useHoneyBalances", account, collateralList] as const)
|
|
49
49
|
: null;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
return useSWR(
|
|
52
52
|
QUERY_KEY,
|
|
53
53
|
async ([_, account, collateralList]) => {
|
|
54
54
|
assertPublicClient(publicClient);
|
|
@@ -75,9 +75,4 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
75
75
|
refreshInterval: POLLING.FAST,
|
|
76
76
|
},
|
|
77
77
|
);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
...swrResponse,
|
|
81
|
-
refresh: () => swrResponse.mutate(),
|
|
82
|
-
};
|
|
83
78
|
};
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
1
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
2
2
|
|
|
3
3
|
import { getChartData } from "../../actions/honey/getChartData";
|
|
4
4
|
|
|
5
5
|
export function useHoneyChartData({ days }: { days: number }) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return await getChartData({ days });
|
|
10
|
-
},
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
...swrResponse,
|
|
15
|
-
refresh: () => swrResponse.mutate(),
|
|
16
|
-
};
|
|
6
|
+
return useSWR(["useHoneyChartData", days] as const, async ([_, days]) => {
|
|
7
|
+
return await getChartData({ days });
|
|
8
|
+
});
|
|
17
9
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
type GetHoneyVaultsBalanceResponse,
|
|
@@ -24,7 +23,7 @@ export const useHoneyVaultsBalance = (
|
|
|
24
23
|
? (["useHoneyVaultsBalance", collateralList] as const)
|
|
25
24
|
: null;
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
return useSWR(
|
|
28
27
|
QUERY_KEY,
|
|
29
28
|
async ([_, collateralList]) => {
|
|
30
29
|
assertPublicClient(publicClient);
|
|
@@ -34,11 +33,6 @@ export const useHoneyVaultsBalance = (
|
|
|
34
33
|
collateralList,
|
|
35
34
|
});
|
|
36
35
|
},
|
|
37
|
-
{ ...options
|
|
36
|
+
{ ...options, refreshInterval: POLLING.NORMAL },
|
|
38
37
|
);
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...swrResponse,
|
|
42
|
-
refresh: () => void swrResponse.mutate(),
|
|
43
|
-
};
|
|
44
38
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
type IsBadCollateralResponse,
|
|
@@ -34,9 +33,7 @@ export const useIsBadCollateralAsset = (
|
|
|
34
33
|
: undefined,
|
|
35
34
|
},
|
|
36
35
|
{
|
|
37
|
-
|
|
38
|
-
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address,
|
|
39
|
-
},
|
|
36
|
+
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address,
|
|
40
37
|
},
|
|
41
38
|
);
|
|
42
39
|
const QUERY_KEY =
|
|
@@ -52,7 +49,7 @@ export const useIsBadCollateralAsset = (
|
|
|
52
49
|
] as const)
|
|
53
50
|
: null;
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
return useSWR(
|
|
56
53
|
QUERY_KEY,
|
|
57
54
|
async ([_, collateral, latestPrices, isPythWrapperEnabled]) => {
|
|
58
55
|
assertPublicClient(publicClient);
|
|
@@ -65,13 +62,8 @@ export const useIsBadCollateralAsset = (
|
|
|
65
62
|
});
|
|
66
63
|
},
|
|
67
64
|
{
|
|
68
|
-
...options
|
|
69
|
-
refreshInterval: options?.
|
|
65
|
+
...options,
|
|
66
|
+
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
70
67
|
},
|
|
71
68
|
);
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
...swrResponse,
|
|
75
|
-
refresh: () => void swrResponse.mutate(),
|
|
76
|
-
};
|
|
77
69
|
};
|