@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,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getAllowances } from "../../actions/tokens/getAllowances";
|
|
6
5
|
import { POLLING } from "../../enum/polling";
|
|
@@ -36,7 +35,7 @@ export function usePollAllowances(
|
|
|
36
35
|
? (["usePollAllowances", account, args?.items] as const)
|
|
37
36
|
: null;
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
return useSWR(
|
|
40
39
|
QUERY_KEY,
|
|
41
40
|
async ([, account, items]) => {
|
|
42
41
|
return getAllowances({
|
|
@@ -46,14 +45,8 @@ export function usePollAllowances(
|
|
|
46
45
|
});
|
|
47
46
|
},
|
|
48
47
|
{
|
|
49
|
-
...options
|
|
50
|
-
refreshInterval: options?.
|
|
48
|
+
...options,
|
|
49
|
+
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
51
50
|
},
|
|
52
51
|
);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...swrResponse,
|
|
56
|
-
|
|
57
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
58
|
-
};
|
|
59
52
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import {
|
|
3
2
|
type Address,
|
|
4
3
|
erc20Abi,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
import { defaultChainId } from "@berachain/config/internal";
|
|
12
11
|
|
|
13
12
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
13
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
14
14
|
|
|
15
15
|
import { POLLING } from "../../enum/polling";
|
|
16
16
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -47,7 +47,6 @@ export function usePollBalance(
|
|
|
47
47
|
const assetOwner = owner ?? account;
|
|
48
48
|
|
|
49
49
|
const QUERY_KEY =
|
|
50
|
-
(options?.opts?.isEnabled ?? true) &&
|
|
51
50
|
publicClient &&
|
|
52
51
|
assetOwner &&
|
|
53
52
|
isAddress(assetOwner) &&
|
|
@@ -80,6 +79,7 @@ export function usePollBalance(
|
|
|
80
79
|
},
|
|
81
80
|
{
|
|
82
81
|
refreshInterval: POLLING.FAST,
|
|
82
|
+
...options,
|
|
83
83
|
},
|
|
84
84
|
);
|
|
85
85
|
|
|
@@ -110,9 +110,6 @@ export function usePollBalance(
|
|
|
110
110
|
|
|
111
111
|
return {
|
|
112
112
|
...rest,
|
|
113
|
-
refresh: () => {
|
|
114
|
-
rest.mutate();
|
|
115
|
-
},
|
|
116
113
|
isLoading: isLoading || isNativeToken ? isLoadingTokenInformation : false,
|
|
117
114
|
error: error || !isNativeToken ? error : undefined,
|
|
118
115
|
data: tokenBalance,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
import type { Address } from "viem";
|
|
4
3
|
|
|
5
4
|
import {
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
useConfig,
|
|
8
7
|
usePublicClient,
|
|
9
8
|
} from "@berachain/wagmi/hooks";
|
|
9
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
10
10
|
|
|
11
11
|
import { getWalletBalances } from "../../actions/tokens/getWalletBalances";
|
|
12
12
|
import { POLLING } from "../../enum/polling";
|
|
@@ -67,14 +67,14 @@ export function usePollWalletBalances(
|
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
refreshInterval: POLLING.NORMAL,
|
|
70
|
-
...options
|
|
70
|
+
...options,
|
|
71
71
|
},
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
return {
|
|
75
75
|
...swrResponse,
|
|
76
76
|
refresh: () => {
|
|
77
|
-
swrResponse?.
|
|
77
|
+
swrResponse?.refresh();
|
|
78
78
|
refresh();
|
|
79
79
|
},
|
|
80
80
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { isAddress, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getStakingTokenInformation } from "../../actions/pol/getStakingTokenInformation";
|
|
7
7
|
import type { Token } from "../../types/dex";
|
|
@@ -27,11 +27,7 @@ export const useStakingTokenInformation = (
|
|
|
27
27
|
args?.address && publicClient && isAddress(args.address)
|
|
28
28
|
? (["useStakingTokenInformation", args.address] as const)
|
|
29
29
|
: null;
|
|
30
|
-
|
|
31
|
-
Partial<Token> | undefined,
|
|
32
|
-
any,
|
|
33
|
-
typeof QUERY_KEY
|
|
34
|
-
>(
|
|
30
|
+
return useSWRImmutable<Partial<Token> | undefined, any, typeof QUERY_KEY>(
|
|
35
31
|
QUERY_KEY,
|
|
36
32
|
async ([_, address]) => {
|
|
37
33
|
if (isToken(address, "BERA")) {
|
|
@@ -48,11 +44,6 @@ export const useStakingTokenInformation = (
|
|
|
48
44
|
publicClient,
|
|
49
45
|
});
|
|
50
46
|
},
|
|
51
|
-
{ ...options
|
|
47
|
+
{ ...options },
|
|
52
48
|
);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...swrResponse,
|
|
56
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
57
|
-
};
|
|
58
49
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
import { type Address, isAddress, zeroAddress } from "viem";
|
|
4
3
|
|
|
5
4
|
import { defaultChainId } from "@berachain/config/internal";
|
|
6
5
|
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
|
+
|
|
7
8
|
import { getTokenCurrentPrices } from "../../actions/prices/getTokenCurrentPrices";
|
|
8
9
|
import { POLLING } from "../../enum/polling";
|
|
9
10
|
import type { TokenCurrentPriceMap, TokenWithPrice } from "../../types/dex";
|
|
@@ -21,10 +22,8 @@ export function useTokenCurrentPrices(
|
|
|
21
22
|
addressIn?: string[] | readonly string[];
|
|
22
23
|
} = {},
|
|
23
24
|
options: DefaultHookOptions = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
revalidateOnFocus: true,
|
|
27
|
-
},
|
|
25
|
+
refreshInterval: POLLING.NORMAL,
|
|
26
|
+
revalidateOnFocus: true,
|
|
28
27
|
},
|
|
29
28
|
) {
|
|
30
29
|
const { tokenList, ensoTokens } = useTokens();
|
|
@@ -65,13 +64,12 @@ export function useTokenCurrentPrices(
|
|
|
65
64
|
? beraAddresses
|
|
66
65
|
: tokenList.map((token) => token.address);
|
|
67
66
|
|
|
68
|
-
const QUERY_KEY =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
: null;
|
|
67
|
+
const QUERY_KEY = addresses
|
|
68
|
+
? ([
|
|
69
|
+
"useTokenCurrentPrices",
|
|
70
|
+
addresses.map((a) => a.toLowerCase() as Address),
|
|
71
|
+
] as const)
|
|
72
|
+
: null;
|
|
75
73
|
|
|
76
74
|
const apiResponse = useSWR(
|
|
77
75
|
QUERY_KEY,
|
|
@@ -79,7 +77,7 @@ export function useTokenCurrentPrices(
|
|
|
79
77
|
// this only works for Berachain tokens
|
|
80
78
|
return getTokenCurrentPrices({ addressIn: addresses });
|
|
81
79
|
},
|
|
82
|
-
options
|
|
80
|
+
options,
|
|
83
81
|
);
|
|
84
82
|
|
|
85
83
|
const ensoMatchingPrices = useMemo<TokenCurrentPriceMap>(() => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { isAddress, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { defaultChainId } from "@berachain/config/internal";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { getTokenInformation } from "../../actions/tokens/getTokenInformation";
|
|
9
9
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -33,7 +33,7 @@ export function useTokenInformation(
|
|
|
33
33
|
args?.address && publicClient && isAddress(args.address)
|
|
34
34
|
? (["useTokenInformation", args.address, args.chainId] as const)
|
|
35
35
|
: null;
|
|
36
|
-
|
|
36
|
+
return useSWRImmutable<Token | undefined, any, typeof QUERY_KEY>(
|
|
37
37
|
QUERY_KEY,
|
|
38
38
|
async ([_, address, chainId = defaultChainId]) => {
|
|
39
39
|
if (isToken(address, "BERA")) {
|
|
@@ -57,11 +57,6 @@ export function useTokenInformation(
|
|
|
57
57
|
chainId,
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
|
-
{ ...options
|
|
60
|
+
{ ...options },
|
|
61
61
|
);
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
...swrResponse,
|
|
65
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
66
|
-
};
|
|
67
62
|
}
|
|
@@ -7,7 +7,7 @@ export function useTokenPrice(
|
|
|
7
7
|
{ token }: { token: TokenPriceInput | undefined },
|
|
8
8
|
options?: DefaultHookOptions,
|
|
9
9
|
) {
|
|
10
|
-
const { isLoading, priceMap } = useTokenPrices(
|
|
10
|
+
const { isLoading, error, priceMap } = useTokenPrices(
|
|
11
11
|
{ tokens: token ? [token] : undefined },
|
|
12
12
|
options,
|
|
13
13
|
);
|
|
@@ -17,5 +17,6 @@ export function useTokenPrice(
|
|
|
17
17
|
? priceMap[token.chainId]?.[token.address.toLowerCase() as Address]
|
|
18
18
|
: undefined,
|
|
19
19
|
isLoading,
|
|
20
|
+
error,
|
|
20
21
|
};
|
|
21
22
|
}
|
|
@@ -23,10 +23,8 @@ export function useTokenPrices(
|
|
|
23
23
|
tokens?: TokenPriceInput[];
|
|
24
24
|
} = {},
|
|
25
25
|
options: DefaultHookOptions = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
revalidateOnFocus: true,
|
|
29
|
-
},
|
|
26
|
+
refreshInterval: POLLING.NORMAL,
|
|
27
|
+
revalidateOnFocus: true,
|
|
30
28
|
},
|
|
31
29
|
) {
|
|
32
30
|
const { ensoTokens } = useTokens();
|
|
@@ -126,6 +124,7 @@ export function useTokenPrices(
|
|
|
126
124
|
|
|
127
125
|
return {
|
|
128
126
|
isLoading: apiResponse.isLoading,
|
|
127
|
+
error: apiResponse.error,
|
|
129
128
|
data,
|
|
130
129
|
priceMap,
|
|
131
130
|
getTokenPrice,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
|
-
|
|
3
1
|
import { useConfig } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getUnderlyingToken } from "../../actions/tokens/getUnderlyingToken";
|
|
6
5
|
import type { MinimalERC20 } from "../../types/dex";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
|
-
|
|
3
1
|
import { useBlockNumber, usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getBlockTimestamp } from "../actions/misc/getBlockTimestamp";
|
|
6
5
|
import { useBlockTime } from "../contexts/block-time-provider";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { isAddress, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { chainId } from "@berachain/config/internal";
|
|
5
4
|
|
|
5
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
6
|
+
|
|
6
7
|
import { beraFetchJson } from "../utils/beraFetch";
|
|
7
8
|
|
|
8
9
|
interface SuccessResponse {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
GetValidatorsQuery,
|
|
5
3
|
GetValidatorsQueryVariables,
|
|
6
4
|
GqlChain,
|
|
7
5
|
} from "@berachain/graphql/pol/api";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
8
7
|
|
|
9
8
|
import { getAllValidators } from "../../actions/validators/getAllValidators";
|
|
10
9
|
import { POLLING } from "../../enum/polling";
|
|
@@ -27,7 +26,7 @@ export const useAllValidators = (
|
|
|
27
26
|
options?: DefaultHookOptions,
|
|
28
27
|
): DefaultHookReturnType<GetValidatorsQuery | undefined> => {
|
|
29
28
|
const { config } = parseBaseArgs(variables);
|
|
30
|
-
|
|
29
|
+
return useSWR<GetValidatorsQuery | undefined>(
|
|
31
30
|
useAllValidatorsQueryKey({ variables }),
|
|
32
31
|
async ([, variables]) => {
|
|
33
32
|
const result = await getAllValidators({
|
|
@@ -40,12 +39,7 @@ export const useAllValidators = (
|
|
|
40
39
|
},
|
|
41
40
|
{
|
|
42
41
|
refreshInterval: POLLING.SLOW,
|
|
43
|
-
...options
|
|
42
|
+
...options,
|
|
44
43
|
},
|
|
45
44
|
);
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...swrResponse,
|
|
49
|
-
refresh: () => swrResponse.mutate(),
|
|
50
|
-
};
|
|
51
45
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
1
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
2
2
|
|
|
3
3
|
import { getApiEnrichedAllocation } from "../../actions/validators/getApiEnrichedAllocation";
|
|
4
4
|
import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, isHex } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { GetValidatorQuery } from "@berachain/graphql/pol/api";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getApiValidator } from "../../actions/validators/getApiValidator";
|
|
7
7
|
import type {
|
|
@@ -20,21 +20,13 @@ export const useApiValidator = (
|
|
|
20
20
|
options?: DefaultHookOptions,
|
|
21
21
|
): UsePollValidatorInfoResponse => {
|
|
22
22
|
const QUERY_KEY = useApiValidatorQueryKey(id);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isEnabled && id ? QUERY_KEY : null,
|
|
23
|
+
return useSWR(
|
|
24
|
+
id ? QUERY_KEY : null,
|
|
26
25
|
async ([, id]) => {
|
|
27
26
|
if (!id || !isHex(id)) throw new Error(`Invalid validator ID: ${id}`);
|
|
28
27
|
|
|
29
28
|
return getApiValidator({ id });
|
|
30
29
|
},
|
|
31
|
-
|
|
32
|
-
...options?.opts,
|
|
33
|
-
},
|
|
30
|
+
options,
|
|
34
31
|
);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
...swrResponse,
|
|
38
|
-
refresh: () => swrResponse.mutate(),
|
|
39
|
-
};
|
|
40
32
|
};
|
|
@@ -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 { getBaselineRewardAllocation } from "../../actions/validators/getBaselineRewardAllocation";
|
|
6
5
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { GetValidatorBlockStatsQuery } from "@berachain/graphql/pol/subgraph";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getDailyValidatorBlockStats } from "../../actions/validators/getDailyValidatorBlockStats";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -18,7 +18,7 @@ export const useDailyValidatorBlockStats = ({
|
|
|
18
18
|
? (["useDailyValidatorBlockStats", pubKey, first] as const)
|
|
19
19
|
: null;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return useSWR(
|
|
22
22
|
QUERY_KEY,
|
|
23
23
|
async ([, pubKey, first]) => {
|
|
24
24
|
return await getDailyValidatorBlockStats({
|
|
@@ -30,6 +30,4 @@ export const useDailyValidatorBlockStats = ({
|
|
|
30
30
|
refreshInterval: POLLING.SLOW,
|
|
31
31
|
},
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
35
33
|
};
|
|
@@ -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 { getDefaultRewardAllocation } from "../../actions/validators/getDefaultRewardAllocation";
|
|
6
5
|
import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
|
|
@@ -11,7 +10,7 @@ export function useDefaultRewardAllocation(options?: DefaultHookOptions) {
|
|
|
11
10
|
const publicClient = usePublicClient();
|
|
12
11
|
const QUERY_KEY = publicClient ? ["useDefaultRewardAllocation"] : null;
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
return useSWR<ValidatorRewardAllocation | undefined>(
|
|
15
14
|
QUERY_KEY,
|
|
16
15
|
async () => {
|
|
17
16
|
assertPublicClient(publicClient);
|
|
@@ -21,12 +20,7 @@ export function useDefaultRewardAllocation(options?: DefaultHookOptions) {
|
|
|
21
20
|
});
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
|
-
...options
|
|
23
|
+
...options,
|
|
25
24
|
},
|
|
26
25
|
);
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
...swrResponse,
|
|
30
|
-
refresh: () => swrResponse.mutate(),
|
|
31
|
-
};
|
|
32
26
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
import type { Address, PublicClient } from "viem";
|
|
4
3
|
|
|
5
4
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
6
6
|
|
|
7
7
|
import { getValidatorOperatorAddress } from "../../actions/validators/getValidatorOperatorAddress";
|
|
8
8
|
import { getValidatorRewardAllocatorAddress } from "../../actions/validators/getValidatorRewardAllocatorAddress";
|
|
@@ -93,7 +93,7 @@ export function useManagedValidatorRole(
|
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
...options
|
|
96
|
+
...options,
|
|
97
97
|
},
|
|
98
98
|
);
|
|
99
99
|
|
|
@@ -117,6 +117,5 @@ export function useManagedValidatorRole(
|
|
|
117
117
|
hasRewardAllocatorRole,
|
|
118
118
|
}
|
|
119
119
|
: undefined,
|
|
120
|
-
refresh: () => swrResponse.mutate(),
|
|
121
120
|
};
|
|
122
121
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, keccak256 } from "viem";
|
|
3
2
|
|
|
4
3
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
@@ -7,6 +6,7 @@ import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
|
7
6
|
|
|
8
7
|
import type { ApiValidatorFragment } from "@berachain/graphql/pol/api";
|
|
9
8
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
9
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
10
10
|
|
|
11
11
|
import { assertPublicClient } from "../../errors/assert";
|
|
12
12
|
import type {
|
|
@@ -21,9 +21,8 @@ export const useOnChainValidator = (
|
|
|
21
21
|
): DefaultHookReturnType<Partial<ApiValidatorFragment>> => {
|
|
22
22
|
const publicClient = usePublicClient();
|
|
23
23
|
const QUERY_KEY = pubkey ? (["useOnChainValidator", pubkey] as const) : null;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
isEnabled && publicClient ? QUERY_KEY : null,
|
|
24
|
+
return useSWR(
|
|
25
|
+
publicClient ? QUERY_KEY : null,
|
|
27
26
|
async ([, pubkey]) => {
|
|
28
27
|
assertPublicClient(publicClient);
|
|
29
28
|
|
|
@@ -59,12 +58,6 @@ export const useOnChainValidator = (
|
|
|
59
58
|
votingPower: Number(boostees),
|
|
60
59
|
} as Partial<ApiValidatorFragment>;
|
|
61
60
|
},
|
|
61
|
+
options,
|
|
62
62
|
);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
...swrResponse,
|
|
66
|
-
refresh: () => {
|
|
67
|
-
swrResponse.mutate();
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
63
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getStakingPoolBatch } from "../../actions/validators/getStakingPoolBatch";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -19,13 +19,12 @@ export const useStakingPoolBatch = ({
|
|
|
19
19
|
options?: DefaultHookOptions;
|
|
20
20
|
}): DefaultHookReturnType<number | undefined> => {
|
|
21
21
|
const publicClient = usePublicClient();
|
|
22
|
-
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
23
22
|
const QUERY_KEY =
|
|
24
|
-
|
|
23
|
+
publicClient && valPubKey
|
|
25
24
|
? (["useStakingPoolBatch", valPubKey] as const)
|
|
26
25
|
: null;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
return useSWR(
|
|
29
28
|
QUERY_KEY,
|
|
30
29
|
async ([, valPubKey]) => {
|
|
31
30
|
assertPublicClient(publicClient);
|
|
@@ -37,12 +36,7 @@ export const useStakingPoolBatch = ({
|
|
|
37
36
|
},
|
|
38
37
|
{
|
|
39
38
|
refreshInterval: POLLING.FAST,
|
|
40
|
-
...options
|
|
39
|
+
...options,
|
|
41
40
|
},
|
|
42
41
|
);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
...swrResponse,
|
|
46
|
-
refresh: () => swrResponse.mutate(),
|
|
47
|
-
};
|
|
48
42
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
getUserActiveValidators,
|
|
@@ -25,7 +24,7 @@ export const useUserActiveValidators = (
|
|
|
25
24
|
? (["useUserActiveValidators", account] as const)
|
|
26
25
|
: null;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
return useSWR(
|
|
29
28
|
QUERY_KEY,
|
|
30
29
|
async ([, account]) => {
|
|
31
30
|
return await getUserActiveValidators({
|
|
@@ -35,13 +34,8 @@ export const useUserActiveValidators = (
|
|
|
35
34
|
},
|
|
36
35
|
{
|
|
37
36
|
...options,
|
|
38
|
-
refreshInterval: options?.
|
|
37
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
39
38
|
keepPreviousData: true,
|
|
40
39
|
},
|
|
41
40
|
);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...swrResponse,
|
|
45
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
46
|
-
};
|
|
47
41
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
getUserBoostsOnValidator,
|
|
@@ -27,7 +27,7 @@ export const useUserBoostsOnValidator = ({
|
|
|
27
27
|
? (["useUserBoostsOnValidator", pubkey, account] as const)
|
|
28
28
|
: null;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
return useSWR(
|
|
31
31
|
QUERY_KEY,
|
|
32
32
|
async ([, pubkey, account]) => {
|
|
33
33
|
return await getUserBoostsOnValidator({
|
|
@@ -40,6 +40,4 @@ export const useUserBoostsOnValidator = ({
|
|
|
40
40
|
refreshInterval: POLLING.NORMAL,
|
|
41
41
|
},
|
|
42
42
|
);
|
|
43
|
-
|
|
44
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
45
43
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
|
|
4
3
|
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getRewardProofsByValidator } from "../../actions/pol/getRewardProofsByValidator";
|
|
7
7
|
import { getUserClaimableIncentives } from "../../actions/pol/getUserClaimableIncentives";
|
|
@@ -136,8 +136,8 @@ export const useUserClaimableIncentives =
|
|
|
136
136
|
);
|
|
137
137
|
|
|
138
138
|
const refresh = useCallback(() => {
|
|
139
|
-
allRewardsResponse?.
|
|
140
|
-
swrResponse?.
|
|
139
|
+
allRewardsResponse?.refresh();
|
|
140
|
+
swrResponse?.refresh();
|
|
141
141
|
}, [allRewardsResponse, swrResponse]);
|
|
142
142
|
|
|
143
143
|
return {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
3
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
4
|
+
|
|
4
5
|
import { getUserStakingPositions } from "../../actions/validators/getUserStakingPositions";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -38,7 +39,7 @@ export const useUserStakingPositions = ({
|
|
|
38
39
|
const queryClient = account
|
|
39
40
|
? (["useUserStakingPositions", account, validatorAddress] as const)
|
|
40
41
|
: null;
|
|
41
|
-
|
|
42
|
+
return useSWRImmutable(
|
|
42
43
|
queryClient,
|
|
43
44
|
async ([_, account, validatorAddress]) => {
|
|
44
45
|
const userStakingPolls = await getUserStakingPositions(account);
|
|
@@ -52,11 +53,4 @@ export const useUserStakingPositions = ({
|
|
|
52
53
|
return userStakingPolls;
|
|
53
54
|
},
|
|
54
55
|
);
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
...swrResponse,
|
|
58
|
-
refresh: () => {
|
|
59
|
-
swrResponse.mutate();
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
56
|
};
|