@berachain/berajs 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
- package/dist/actions/clients/exports.d.ts +77 -1
- package/dist/actions/clients/exports.mjs +13 -4
- package/dist/actions/exports.d.ts +121 -39
- package/dist/actions/exports.mjs +75 -34
- package/dist/actions/governance/exports.d.ts +3 -11
- package/dist/actions/governance/exports.mjs +3 -3
- package/dist/actions/server/exports.mjs +4 -4
- package/dist/{chunk-4Z4AK6SH.mjs → chunk-3JJLQ2JX.mjs} +3 -3
- package/dist/{chunk-EXIUPSFN.mjs → chunk-7YVNSDXG.mjs} +2 -2
- package/dist/{chunk-WXXOISTU.mjs → chunk-AUOPN6NK.mjs} +1 -1
- package/dist/{chunk-75M6TF7M.mjs → chunk-DQRH5VE3.mjs} +1 -1
- package/dist/{chunk-CDFWPU2R.mjs → chunk-E7YFXBBQ.mjs} +0 -124
- package/dist/{chunk-AFN4CVD3.mjs → chunk-GUURQAME.mjs} +1 -1
- package/dist/{chunk-KQUMKB66.mjs → chunk-GY6B3PD5.mjs} +1 -1
- package/dist/{chunk-HSSJKHZ4.mjs → chunk-HYDP32P6.mjs} +3 -3
- package/dist/{chunk-NPBQLVL3.mjs → chunk-IXIBY5FP.mjs} +2 -2
- package/dist/{chunk-J5I45WGQ.mjs → chunk-KHXJDYA4.mjs} +7 -0
- package/dist/chunk-MRQGHXAN.mjs +54 -0
- package/dist/{chunk-FFB5LFDW.mjs → chunk-QVHEM4BG.mjs} +2 -2
- package/dist/{chunk-3EARVV7K.mjs → chunk-SXUNCX5E.mjs} +22 -9
- package/dist/chunk-UD5IUNCW.mjs +34 -0
- package/dist/{chunk-QJIXTYTZ.mjs → chunk-VAA2FVPP.mjs} +162 -41
- package/dist/chunk-Y6THHG77.mjs +126 -0
- package/dist/{chunk-XIYN6AL6.mjs → chunk-ZLTMIFCZ.mjs} +10 -5
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +11 -9
- package/dist/enum/exports.d.ts +8 -2
- package/dist/errors/exports.mjs +5 -5
- package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
- package/dist/{getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts → getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts} +2 -2
- package/dist/{global.d-BuGDKh4k.d.ts → global.d-q_LQWQqs.d.ts} +2 -4
- package/dist/hooks/exports.d.ts +114 -164
- package/dist/hooks/exports.mjs +535 -522
- package/dist/hooks/governance/exports.d.ts +20 -15
- package/dist/hooks/governance/exports.mjs +43 -41
- package/dist/{pol.d-CqPA9K6m.d.ts → pol.d-CeRgXBL8.d.ts} +33 -8
- 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 +15 -9
- package/package.json +9 -8
- package/src/actions/bend/getMaxDeposit.ts +28 -2
- package/src/actions/clients/exports.ts +3 -0
- package/src/actions/clients/fetchBeep.ts +34 -0
- package/src/actions/clients/fetchOpenApi.ts +97 -0
- package/src/actions/clients/fetchOpenApi.unit.test.ts +245 -0
- package/src/actions/clients/fetchRailwayBackend.ts +34 -0
- package/src/actions/enso/getEnsoUserTokensWithBalances.ts +18 -0
- package/src/actions/exports.ts +2 -0
- package/src/actions/honey/getChartData.ts +53 -12
- package/src/actions/honey/getHoney24hVolume.ts +34 -6
- package/src/actions/honey/getHoneyTxns.ts +93 -0
- package/src/actions/honey/getPythLatestPrices.ts +7 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +1 -1
- package/src/actions/pol/getAutoclaimedIncentives.ts +21 -10
- package/src/actions/pol/getAutoclaimedIncentivesTxHash.ts +41 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +5 -12
- package/src/actions/pol/getEarnedStakedBeraVault.ts +20 -16
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getStakingDailyAssets.ts +18 -14
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +64 -12
- package/src/actions/validators/utils/getValidatorBoostApy.ts +1 -1
- package/src/contexts/SwrFallback.tsx +2 -1
- package/src/data/contracts.ts +4 -0
- package/src/errors/RequestError.ts +12 -3
- package/src/errors/RequestError.unit.test.ts +55 -0
- package/src/errors/errorMap.ts +8 -0
- package/src/errors/getRevertReason.integration.test.ts +5 -1
- package/src/hooks/bend/useGetConvertToAssets.ts +2 -3
- package/src/hooks/dex/useAggregatorsQuotes.ts +10 -10
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -1
- package/src/hooks/dex/useAllUserPools.ts +7 -5
- package/src/hooks/dex/useApiPool.ts +1 -1
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -1
- package/src/hooks/dex/useOnChainPoolData.ts +1 -1
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +2 -2
- package/src/hooks/dex/usePoolEvents.ts +1 -2
- package/src/hooks/dex/usePoolHistoricalData.ts +2 -3
- package/src/hooks/dex/usePools.ts +4 -2
- 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 +3 -4
- package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +3 -5
- package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
- package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
- package/src/hooks/enso/useZapStakeBera.ts +2 -2
- package/src/hooks/exports.ts +2 -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 +3 -3
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
- package/src/hooks/governance/usePollProposalVotes.ts +23 -5
- package/src/hooks/governance/usePollUserDelegates.ts +3 -3
- package/src/hooks/governance/useProposalFromTx.ts +2 -1
- package/src/hooks/governance/useProposalSnapshot.ts +2 -3
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/governance/useProposalTimelockState.ts +2 -1
- package/src/hooks/governance/useQuorum.ts +1 -2
- package/src/hooks/honey/useCappedGlobally.ts +3 -6
- package/src/hooks/honey/useCappedRelatively.ts +2 -2
- package/src/hooks/honey/useCollateralWeights.ts +3 -3
- package/src/hooks/honey/useHoney24hVolume.ts +1 -1
- package/src/hooks/honey/useHoneyBalances.ts +1 -1
- package/src/hooks/honey/useHoneyChartData.ts +1 -1
- package/src/hooks/honey/useHoneyVaultsBalance.ts +2 -3
- package/src/hooks/honey/useIsBadCollateralAsset.ts +4 -7
- package/src/hooks/honey/useIsBasketModeEnabled.ts +4 -7
- package/src/hooks/honey/usePythLatestPrices.ts +13 -9
- package/src/hooks/perps/usePythUpdateFee.ts +13 -11
- package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -12
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +44 -0
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +39 -0
- package/src/hooks/pol/useBgtUnstakedBalance.ts +2 -2
- package/src/hooks/pol/useClaimableFees.ts +1 -1
- package/src/hooks/pol/useHighestVaultsAPR.ts +4 -6
- package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
- package/src/hooks/pol/usePollGlobalData.ts +2 -3
- package/src/hooks/pol/usePollMarkets.ts +2 -2
- package/src/hooks/pol/useQueuedBeraUnlock.ts +2 -2
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
- package/src/hooks/pol/useRewardVault.ts +7 -6
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +4 -4
- package/src/hooks/pol/useRewardVaultFromToken.ts +1 -1
- package/src/hooks/pol/useRewardVaultIncentives.ts +1 -1
- package/src/hooks/pol/useRewardVaultRewards.ts +2 -2
- package/src/hooks/pol/useRewardVaults.ts +3 -6
- package/src/hooks/pol/useStakedAPR.ts +1 -2
- package/src/hooks/pol/useStakedData.ts +90 -41
- package/src/hooks/pol/useStakedSnapshots.ts +1 -1
- package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
- package/src/hooks/pol/useTotalStakedAmount.ts +1 -2
- package/src/hooks/pol/useUserVaultInfo.ts +2 -2
- package/src/hooks/pol/useUserVaults.ts +2 -3
- package/src/hooks/pol/useVaultAddress.ts +1 -1
- package/src/hooks/pol/useVaultHistory.ts +1 -2
- package/src/hooks/pol/useVaultValidators.ts +2 -2
- package/src/hooks/tokens/useMultipleTokenInformation.ts +2 -2
- package/src/hooks/tokens/usePollAllowances.ts +3 -4
- package/src/hooks/tokens/usePollBalance.ts +2 -2
- package/src/hooks/tokens/usePollWalletBalances.ts +2 -2
- package/src/hooks/tokens/useStakingTokenInformation.ts +2 -2
- package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
- package/src/hooks/tokens/useTokenInformation.ts +2 -2
- 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 +2 -3
- package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +3 -6
- package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
- package/src/hooks/validators/useDefaultRewardAllocation.ts +2 -3
- package/src/hooks/validators/useManagedValidatorRole.ts +2 -2
- package/src/hooks/validators/useOnChainValidator.ts +3 -3
- package/src/hooks/validators/useStakingPoolBatch.ts +3 -4
- package/src/hooks/validators/useUserActiveValidators.ts +2 -3
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
- package/src/hooks/validators/useUserClaimableIncentives.ts +1 -1
- package/src/hooks/validators/useUserStakingPositions.ts +2 -1
- package/src/hooks/validators/useValidator.ts +4 -8
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
- package/src/hooks/validators/useValidatorCommission.ts +2 -2
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +3 -3
- package/src/hooks/validators/useValidatorQueuedCommission.ts +2 -2
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +2 -2
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +2 -2
- package/src/hooks/validators/useValidatorRewardAllocation.ts +2 -2
- package/src/types/bribe-boost.d.ts +14 -3
- package/src/types/global.d.ts +3 -4
- package/src/types/pol.d.ts +17 -3
- package/src/utils/polyfillAbortSignalAny.ts +53 -0
- package/src/utils/polyfillAbortSignalAny.unit.test.ts +81 -0
- package/dist/polling-BKnyavLI.d.ts +0 -8
- /package/dist/{exports-BcUTGFUb.d.ts → getApolloClient-BcUTGFUb.d.ts} +0 -0
|
@@ -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 { getRewardVaultStakingToken } from "../../actions/pol/getRewardVaultStakingToken";
|
|
7
7
|
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 { ApiValidatorFragment } from "@berachain/graphql/pol/api";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getVaultValidators } from "../../actions/pol/getVaultValidators";
|
|
7
7
|
import type {
|
|
@@ -25,7 +25,7 @@ export const useVaultValidators = (
|
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
...options
|
|
28
|
+
...options,
|
|
29
29
|
},
|
|
30
30
|
);
|
|
31
31
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { isAddress } 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";
|
|
@@ -64,7 +64,7 @@ export function useMultipleTokenInformation(
|
|
|
64
64
|
}),
|
|
65
65
|
);
|
|
66
66
|
},
|
|
67
|
-
{ ...options
|
|
67
|
+
{ ...options },
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
return {
|
|
@@ -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";
|
|
@@ -46,8 +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
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
|
|
|
@@ -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,7 +67,7 @@ export function usePollWalletBalances(
|
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
refreshInterval: POLLING.NORMAL,
|
|
70
|
-
...options
|
|
70
|
+
...options,
|
|
71
71
|
},
|
|
72
72
|
);
|
|
73
73
|
|
|
@@ -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";
|
|
@@ -48,7 +48,7 @@ export const useStakingTokenInformation = (
|
|
|
48
48
|
publicClient,
|
|
49
49
|
});
|
|
50
50
|
},
|
|
51
|
-
{ ...options
|
|
51
|
+
{ ...options },
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
return {
|
|
@@ -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";
|
|
@@ -57,7 +57,7 @@ export function useTokenInformation(
|
|
|
57
57
|
chainId,
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
|
-
{ ...options
|
|
60
|
+
{ ...options },
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
return {
|
|
@@ -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";
|
|
@@ -40,7 +39,7 @@ export const useAllValidators = (
|
|
|
40
39
|
},
|
|
41
40
|
{
|
|
42
41
|
refreshInterval: POLLING.SLOW,
|
|
43
|
-
...options
|
|
42
|
+
...options,
|
|
44
43
|
},
|
|
45
44
|
);
|
|
46
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,17 +20,14 @@ export const useApiValidator = (
|
|
|
20
20
|
options?: DefaultHookOptions,
|
|
21
21
|
): UsePollValidatorInfoResponse => {
|
|
22
22
|
const QUERY_KEY = useApiValidatorQueryKey(id);
|
|
23
|
-
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
24
23
|
const swrResponse = useSWR(
|
|
25
|
-
|
|
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
32
|
|
|
36
33
|
return {
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -21,7 +20,7 @@ export function useDefaultRewardAllocation(options?: DefaultHookOptions) {
|
|
|
21
20
|
});
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
|
-
...options
|
|
23
|
+
...options,
|
|
25
24
|
},
|
|
26
25
|
);
|
|
27
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
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, keccak256 } from "viem";
|
|
3
2
|
|
|
4
3
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
@@ -7,6 +6,7 @@ import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
|
7
6
|
|
|
8
7
|
import type { ApiValidatorFragment } from "@berachain/graphql/pol/api";
|
|
9
8
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
9
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
10
10
|
|
|
11
11
|
import { assertPublicClient } from "../../errors/assert";
|
|
12
12
|
import type {
|
|
@@ -21,9 +21,8 @@ export const useOnChainValidator = (
|
|
|
21
21
|
): DefaultHookReturnType<Partial<ApiValidatorFragment>> => {
|
|
22
22
|
const publicClient = usePublicClient();
|
|
23
23
|
const QUERY_KEY = pubkey ? (["useOnChainValidator", pubkey] as const) : null;
|
|
24
|
-
const isEnabled = options.opts?.isEnabled ?? true;
|
|
25
24
|
const swrResponse = useSWR(
|
|
26
|
-
|
|
25
|
+
publicClient ? QUERY_KEY : null,
|
|
27
26
|
async ([, pubkey]) => {
|
|
28
27
|
assertPublicClient(publicClient);
|
|
29
28
|
|
|
@@ -59,6 +58,7 @@ export const useOnChainValidator = (
|
|
|
59
58
|
votingPower: Number(boostees),
|
|
60
59
|
} as Partial<ApiValidatorFragment>;
|
|
61
60
|
},
|
|
61
|
+
options,
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getStakingPoolBatch } from "../../actions/validators/getStakingPoolBatch";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -19,9 +19,8 @@ export const useStakingPoolBatch = ({
|
|
|
19
19
|
options?: DefaultHookOptions;
|
|
20
20
|
}): DefaultHookReturnType<number | undefined> => {
|
|
21
21
|
const publicClient = usePublicClient();
|
|
22
|
-
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
23
22
|
const QUERY_KEY =
|
|
24
|
-
|
|
23
|
+
publicClient && valPubKey
|
|
25
24
|
? (["useStakingPoolBatch", valPubKey] as const)
|
|
26
25
|
: null;
|
|
27
26
|
|
|
@@ -37,7 +36,7 @@ export const useStakingPoolBatch = ({
|
|
|
37
36
|
},
|
|
38
37
|
{
|
|
39
38
|
refreshInterval: POLLING.FAST,
|
|
40
|
-
...options
|
|
39
|
+
...options,
|
|
41
40
|
},
|
|
42
41
|
);
|
|
43
42
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
getUserActiveValidators,
|
|
@@ -35,7 +34,7 @@ export const useUserActiveValidators = (
|
|
|
35
34
|
},
|
|
36
35
|
{
|
|
37
36
|
...options,
|
|
38
|
-
refreshInterval: options?.
|
|
37
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
39
38
|
keepPreviousData: true,
|
|
40
39
|
},
|
|
41
40
|
);
|
|
@@ -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";
|
|
@@ -40,12 +40,8 @@ export function useValidator(
|
|
|
40
40
|
"",
|
|
41
41
|
queuedBoostAmount:
|
|
42
42
|
indexerValidator?.dynamicData?.queuedBoostAmount ?? "",
|
|
43
|
-
|
|
44
|
-
indexerValidator?.dynamicData?.
|
|
45
|
-
usersQueuedBoostCount:
|
|
46
|
-
indexerValidator?.dynamicData?.usersQueuedBoostCount ?? 0,
|
|
47
|
-
allTimeDistributedBGTAmount:
|
|
48
|
-
indexerValidator?.dynamicData?.allTimeDistributedBGTAmount ??
|
|
43
|
+
allTimeDistributedRewards:
|
|
44
|
+
indexerValidator?.dynamicData?.allTimeDistributedRewards ??
|
|
49
45
|
"0",
|
|
50
46
|
rewardRate:
|
|
51
47
|
onChainValidator?.dynamicData?.rewardRate ??
|
|
@@ -53,8 +49,8 @@ export function useValidator(
|
|
|
53
49
|
"",
|
|
54
50
|
stakedBeraAmount:
|
|
55
51
|
indexerValidator?.dynamicData?.stakedBeraAmount ?? "",
|
|
56
|
-
|
|
57
|
-
indexerValidator?.dynamicData?.
|
|
52
|
+
lastDayDistributedRewards:
|
|
53
|
+
indexerValidator?.dynamicData?.lastDayDistributedRewards ??
|
|
58
54
|
"",
|
|
59
55
|
lastDayProposedBlockCount:
|
|
60
56
|
indexerValidator?.dynamicData?.lastDayProposedBlockCount ?? 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { GetValidatorAnalyticsQuery } from "@berachain/graphql/pol/subgraph";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getValidatorAnalytics } from "../../actions/validators/getValidatorAnalytics";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address, PublicClient } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import useSWR from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getValidatorCommission } from "../../actions/validators/getValidatorCommission";
|
|
7
7
|
import type {
|
|
@@ -28,7 +28,7 @@ export const useValidatorCommission = (
|
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
...options
|
|
31
|
+
...options,
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
|
-
import type {
|
|
3
|
+
import type { ValidatorIncentivesResponse } from "@berachain/graphql/beep";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getValidatorIncentiveDistribution } from "../../actions/validators/getValidatorIncentiveDistribution";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -19,7 +19,7 @@ export function useValidatorIncentiveDistribution({
|
|
|
19
19
|
}: {
|
|
20
20
|
pubkey: Address | undefined;
|
|
21
21
|
dayRange: number;
|
|
22
|
-
}): DefaultHookReturnType<
|
|
22
|
+
}): DefaultHookReturnType<ValidatorIncentivesResponse> {
|
|
23
23
|
const QUERY_KEY =
|
|
24
24
|
pubkey && dayRange
|
|
25
25
|
? (["useValidatorIncentiveDistribution", pubkey, dayRange] as const)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
getValidatorQueuedCommission,
|
|
@@ -33,7 +33,7 @@ export function useValidatorQueuedCommission(
|
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
...options
|
|
36
|
+
...options,
|
|
37
37
|
},
|
|
38
38
|
);
|
|
39
39
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address, PublicClient } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
getValidatorQueuedOperatorAddress,
|
|
@@ -31,7 +31,7 @@ export const useValidatorQueuedOperatorAddress = (
|
|
|
31
31
|
});
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
...options
|
|
34
|
+
...options,
|
|
35
35
|
},
|
|
36
36
|
);
|
|
37
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address, PublicClient } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getValidatorQueuedRewardAllocation } from "../../actions/validators/getValidatorQueuedRewardAllocation";
|
|
7
7
|
import type { ValidatorRewardAllocation } from "../../actions/validators/getValidatorRewardAllocation";
|
|
@@ -29,7 +29,7 @@ export const useValidatorQueuedRewardAllocation = (
|
|
|
29
29
|
});
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
...options
|
|
32
|
+
...options,
|
|
33
33
|
},
|
|
34
34
|
);
|
|
35
35
|
|