@berachain/berajs 0.2.11 → 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/actions/clients/exports.d.ts +5 -21
- package/dist/actions/clients/exports.mjs +5 -7
- package/dist/actions/exports.d.ts +65 -29
- package/dist/actions/exports.mjs +6 -36
- package/dist/actions/server/exports.mjs +2 -2
- package/dist/{chunk-UD5IUNCW.mjs → chunk-4ML4Y6UN.mjs} +14 -2
- 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-SXUNCX5E.mjs → chunk-W2VODV76.mjs} +3 -7
- package/dist/{chunk-VAA2FVPP.mjs → chunk-XDG26EG6.mjs} +90 -183
- package/dist/{chunk-MRQGHXAN.mjs → chunk-YLTWPFCJ.mjs} +2 -17
- package/dist/contexts/exports.mjs +4 -4
- package/dist/errors/exports.mjs +2 -2
- package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
- package/dist/{getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +6 -57
- package/dist/{global.d-q_LQWQqs.d.ts → global.d-CR3zicga.d.ts} +2 -7
- package/dist/hooks/exports.d.ts +109 -318
- package/dist/hooks/exports.mjs +102 -345
- package/dist/hooks/governance/exports.d.ts +10 -10
- package/dist/hooks/governance/exports.mjs +8 -20
- package/dist/types/exports.d.ts +1 -1
- package/dist/utils/exports.mjs +2 -2
- package/package.json +3 -3
- package/src/actions/clients/exports.ts +0 -1
- package/src/actions/clients/fetchBeep.ts +0 -7
- package/src/actions/clients/fetchOpenApi.ts +4 -4
- package/src/actions/clients/fetchOpenApi.unit.test.ts +3 -19
- package/src/actions/clients/getApolloClient.ts +4 -9
- package/src/actions/exports.ts +0 -1
- package/src/actions/honey/getChartData.ts +3 -44
- package/src/actions/honey/getHoney24hVolume.ts +2 -21
- package/src/actions/honey/getHoneyTxns.ts +1 -49
- 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 +2 -24
- package/src/errors/RequestError.ts +3 -3
- package/src/hooks/bend/useGetConvertToAssets.ts +1 -8
- package/src/hooks/dex/useAggregatorsQuotes.ts +3 -1
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -6
- package/src/hooks/dex/useAllUserPools.ts +1 -8
- package/src/hooks/dex/useApiPool.ts +1 -8
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +0 -1
- package/src/hooks/dex/useOnChainPoolData.ts +2 -3
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -7
- package/src/hooks/dex/usePoolHistoricalData.ts +1 -6
- package/src/hooks/dex/usePools.ts +2 -2
- package/src/hooks/enso/useBendZapSupply.ts +1 -1
- package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +1 -5
- package/src/hooks/enso/useZapStakeBera.ts +0 -3
- package/src/hooks/governance/usePollProposal.ts +4 -7
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -6
- package/src/hooks/governance/usePollUserDelegates.ts +1 -6
- package/src/hooks/governance/useProposalFromTx.ts +3 -5
- package/src/hooks/governance/useProposalSnapshot.ts +2 -2
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/governance/useProposalTimelockState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +1 -6
- package/src/hooks/honey/useCappedRelatively.ts +1 -6
- package/src/hooks/honey/useCollateralWeights.ts +1 -6
- package/src/hooks/honey/useHoney24hVolume.ts +1 -5
- package/src/hooks/honey/useHoneyBalances.ts +1 -6
- package/src/hooks/honey/useHoneyChartData.ts +3 -11
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -6
- package/src/hooks/honey/useIsBadCollateralAsset.ts +1 -6
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -6
- package/src/hooks/honey/usePythLatestPrices.ts +4 -6
- package/src/hooks/pol/useAutoclaimedIncentives.ts +1 -6
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +1 -6
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +1 -6
- package/src/hooks/pol/useBgtUnstakedBalance.ts +1 -6
- package/src/hooks/pol/useClaimableFees.ts +1 -5
- package/src/hooks/pol/useHighestVaultsAPR.ts +2 -5
- package/src/hooks/pol/usePollGlobalData.ts +1 -6
- package/src/hooks/pol/usePollMarkets.ts +1 -6
- package/src/hooks/pol/useQueuedBeraUnlock.ts +1 -10
- package/src/hooks/pol/useRewardVault.ts +2 -2
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +2 -2
- package/src/hooks/pol/useRewardVaultFromToken.ts +23 -29
- package/src/hooks/pol/useRewardVaultIncentives.ts +1 -6
- package/src/hooks/pol/useRewardVaultRewards.ts +1 -6
- package/src/hooks/pol/useRewardVaults.ts +1 -6
- package/src/hooks/pol/useStakedAPR.ts +1 -6
- package/src/hooks/pol/useStakedSnapshots.ts +3 -8
- package/src/hooks/pol/useTotalStakedAmount.ts +1 -6
- package/src/hooks/pol/useUserVaultInfo.ts +1 -6
- package/src/hooks/pol/useUserVaults.ts +1 -5
- package/src/hooks/pol/useVaultHistory.ts +1 -6
- package/src/hooks/pol/useVaultValidators.ts +1 -6
- package/src/hooks/tokens/useMultipleTokenInformation.ts +1 -6
- package/src/hooks/tokens/usePollAllowances.ts +1 -7
- package/src/hooks/tokens/usePollBalance.ts +0 -3
- package/src/hooks/tokens/usePollWalletBalances.ts +1 -1
- package/src/hooks/tokens/useStakingTokenInformation.ts +1 -10
- package/src/hooks/tokens/useTokenInformation.ts +1 -6
- package/src/hooks/validators/useAllValidators.ts +1 -6
- package/src/hooks/validators/useApiValidator.ts +1 -6
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -3
- package/src/hooks/validators/useDefaultRewardAllocation.ts +1 -6
- package/src/hooks/validators/useManagedValidatorRole.ts +0 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -8
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -6
- package/src/hooks/validators/useUserActiveValidators.ts +1 -6
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -3
- package/src/hooks/validators/useUserClaimableIncentives.ts +2 -2
- package/src/hooks/validators/useUserStakingPositions.ts +1 -8
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -3
- package/src/hooks/validators/useValidatorCommission.ts +1 -6
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +1 -3
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -6
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -6
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -6
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -6
- package/src/types/global.d.ts +5 -7
- package/src/actions/clients/fetchRailwayBackend.ts +0 -34
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
|
@@ -23,7 +23,7 @@ export const useHoneyVaultsBalance = (
|
|
|
23
23
|
? (["useHoneyVaultsBalance", collateralList] as const)
|
|
24
24
|
: null;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
return useSWR(
|
|
27
27
|
QUERY_KEY,
|
|
28
28
|
async ([_, collateralList]) => {
|
|
29
29
|
assertPublicClient(publicClient);
|
|
@@ -35,9 +35,4 @@ export const useHoneyVaultsBalance = (
|
|
|
35
35
|
},
|
|
36
36
|
{ ...options, refreshInterval: POLLING.NORMAL },
|
|
37
37
|
);
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
...swrResponse,
|
|
41
|
-
refresh: () => void swrResponse.mutate(),
|
|
42
|
-
};
|
|
43
38
|
};
|
|
@@ -49,7 +49,7 @@ export const useIsBadCollateralAsset = (
|
|
|
49
49
|
] as const)
|
|
50
50
|
: null;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
return useSWR(
|
|
53
53
|
QUERY_KEY,
|
|
54
54
|
async ([_, collateral, latestPrices, isPythWrapperEnabled]) => {
|
|
55
55
|
assertPublicClient(publicClient);
|
|
@@ -66,9 +66,4 @@ export const useIsBadCollateralAsset = (
|
|
|
66
66
|
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
67
67
|
},
|
|
68
68
|
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...swrResponse,
|
|
72
|
-
refresh: () => void swrResponse.mutate(),
|
|
73
|
-
};
|
|
74
69
|
};
|
|
@@ -42,7 +42,7 @@ export function useIsBasketModeEnabled(
|
|
|
42
42
|
] as const)
|
|
43
43
|
: null;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return useSWR(
|
|
46
46
|
QUERY_KEY,
|
|
47
47
|
async ([_, isMint, latestPrices, isPythWrapperEnabled, collateralList]) => {
|
|
48
48
|
assertPublicClient(publicClient);
|
|
@@ -62,9 +62,4 @@ export function useIsBasketModeEnabled(
|
|
|
62
62
|
refreshInterval: options?.refreshInterval ?? POLLING.FAST,
|
|
63
63
|
},
|
|
64
64
|
);
|
|
65
|
-
return {
|
|
66
|
-
...swrResponse,
|
|
67
|
-
data: swrResponse.data,
|
|
68
|
-
refresh: () => void swrResponse.mutate(),
|
|
69
|
-
};
|
|
70
65
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
2
2
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
3
3
|
|
|
4
4
|
import type { PythLatestUpdates } from "../../actions/honey/getPythLatestPrices";
|
|
@@ -10,7 +10,7 @@ import type { PythPriceFeedMap } from "../../types/honeySwap";
|
|
|
10
10
|
* Hook to fetch the latest Pyth price updates for specified pair addresses
|
|
11
11
|
* @param {Object} params - The parameters object
|
|
12
12
|
* @param {Address[] | undefined} params.pairMainAddress - Array of pair addresses to fetch price updates for
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {BeraSwrResponse<PythLatestUpdates>} SWR response containing the latest Pyth price updates
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
16
|
* const { data, error } = usePythLatestPrices({
|
|
@@ -25,14 +25,14 @@ export function usePythLatestPrices(
|
|
|
25
25
|
priceFeedMap: PythPriceFeedMap | undefined;
|
|
26
26
|
},
|
|
27
27
|
options?: DefaultHookOptions,
|
|
28
|
-
):
|
|
28
|
+
): BeraSwrResponse<PythLatestUpdates> {
|
|
29
29
|
const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
|
|
30
30
|
|
|
31
31
|
const QUERY_KEY = priceFeedIds
|
|
32
32
|
? (["usePythLatestPrices", priceFeedIds] as const)
|
|
33
33
|
: null;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
return useSWR(
|
|
36
36
|
QUERY_KEY,
|
|
37
37
|
async ([_, priceFeeds]) => {
|
|
38
38
|
const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
|
|
@@ -40,6 +40,4 @@ export function usePythLatestPrices(
|
|
|
40
40
|
},
|
|
41
41
|
options,
|
|
42
42
|
);
|
|
43
|
-
|
|
44
|
-
return swrResponse;
|
|
45
43
|
}
|
|
@@ -22,7 +22,7 @@ export function useAutoclaimedIncentives({
|
|
|
22
22
|
? (["useAutoclaimedIncentives", account] as const)
|
|
23
23
|
: null;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
return useSWR(
|
|
26
26
|
QUERY_KEY,
|
|
27
27
|
async ([, account]) => getAutoclaimedIncentives({ account }),
|
|
28
28
|
{
|
|
@@ -31,9 +31,4 @@ export function useAutoclaimedIncentives({
|
|
|
31
31
|
revalidateIfStale: false,
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...swrResponse,
|
|
37
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
38
|
-
};
|
|
39
34
|
}
|
|
@@ -22,7 +22,7 @@ export function useAutoclaimedIncentivesTxHash({
|
|
|
22
22
|
? (["useAutoclaimedIncentivesTxHash", account] as const)
|
|
23
23
|
: null;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
return useSWR(
|
|
26
26
|
QUERY_KEY,
|
|
27
27
|
async ([, account]) => getAutoclaimedIncentivesTxHash({ account }),
|
|
28
28
|
{
|
|
@@ -36,9 +36,4 @@ export function useAutoclaimedIncentivesTxHash({
|
|
|
36
36
|
revalidateIfStale: false,
|
|
37
37
|
},
|
|
38
38
|
);
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...swrResponse,
|
|
42
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
43
|
-
};
|
|
44
39
|
}
|
|
@@ -21,7 +21,7 @@ export function useBgtIncentiveDistributorPaused(
|
|
|
21
21
|
? (["useBgtIncentiveDistributorPaused", publicClient.chain?.id] as const)
|
|
22
22
|
: null;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
return useSWR(
|
|
25
25
|
QUERY_KEY,
|
|
26
26
|
async () =>
|
|
27
27
|
getBgtIncentiveDistributorPaused({ publicClient }).catch(() => false),
|
|
@@ -31,9 +31,4 @@ export function useBgtIncentiveDistributorPaused(
|
|
|
31
31
|
...options,
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...swrResponse,
|
|
37
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
38
|
-
};
|
|
39
34
|
}
|
|
@@ -24,7 +24,7 @@ export const useBgtUnstakedBalance = (
|
|
|
24
24
|
? (["useBgtUnstakedBalance", account] as const)
|
|
25
25
|
: null;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
return useSWR(
|
|
28
28
|
QUERY_KEY,
|
|
29
29
|
async ([, account]) => {
|
|
30
30
|
assertPublicClient(publicClient);
|
|
@@ -46,9 +46,4 @@ export const useBgtUnstakedBalance = (
|
|
|
46
46
|
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
47
47
|
},
|
|
48
48
|
);
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
...swrResponse,
|
|
52
|
-
refresh: () => swrResponse.mutate(),
|
|
53
|
-
};
|
|
54
49
|
};
|
|
@@ -13,7 +13,7 @@ export const useClaimableFees = () => {
|
|
|
13
13
|
const publicClient = usePublicClient();
|
|
14
14
|
const QUERY_KEY =
|
|
15
15
|
account && publicClient ? (["useClaimableFees", account] as const) : null;
|
|
16
|
-
|
|
16
|
+
return useSWR(
|
|
17
17
|
QUERY_KEY,
|
|
18
18
|
async ([, account]) => {
|
|
19
19
|
assertPublicClient(publicClient);
|
|
@@ -31,8 +31,4 @@ export const useClaimableFees = () => {
|
|
|
31
31
|
refreshInterval: POLLING.SLOW * 2,
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
|
-
return {
|
|
35
|
-
...swrResponse,
|
|
36
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
37
|
-
};
|
|
38
34
|
};
|
|
@@ -14,8 +14,7 @@ import { useRewardVaults } from "./useRewardVaults";
|
|
|
14
14
|
*
|
|
15
15
|
* @returns {Object} An object containing:
|
|
16
16
|
* - highestApr: The highest APR value from the reward vaults
|
|
17
|
-
* -
|
|
18
|
-
* - ...swrResponse: All properties from the underlying SWR response
|
|
17
|
+
* - isLoading: Loading state
|
|
19
18
|
*
|
|
20
19
|
* @example
|
|
21
20
|
* const { highestApr } = useHighestVaultsAPR({
|
|
@@ -28,7 +27,6 @@ export const useHighestVaultsAPR = (
|
|
|
28
27
|
): {
|
|
29
28
|
highestApr: GqlRewardVaultDynamicData["apr"] | undefined;
|
|
30
29
|
isLoading: boolean;
|
|
31
|
-
refresh: () => void;
|
|
32
30
|
} => {
|
|
33
31
|
const swrResponse = useRewardVaults(
|
|
34
32
|
{
|
|
@@ -49,7 +47,6 @@ export const useHighestVaultsAPR = (
|
|
|
49
47
|
|
|
50
48
|
return {
|
|
51
49
|
isLoading: swrResponse.isLoading,
|
|
52
|
-
highestApr: swrResponse.data?.
|
|
53
|
-
refresh: swrResponse.mutate,
|
|
50
|
+
highestApr: swrResponse.data?.rewardVaultList[0].dynamicData?.apr,
|
|
54
51
|
};
|
|
55
52
|
};
|
|
@@ -16,7 +16,7 @@ export const usePollGlobalData = (
|
|
|
16
16
|
): DefaultHookReturnType<GlobalData> => {
|
|
17
17
|
const publicClient = usePublicClient();
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
return useSWR<GlobalData>(
|
|
20
20
|
publicClient ? "usePollGlobalData" : null,
|
|
21
21
|
async () => {
|
|
22
22
|
assertPublicClient(publicClient);
|
|
@@ -28,9 +28,4 @@ export const usePollGlobalData = (
|
|
|
28
28
|
...options,
|
|
29
29
|
},
|
|
30
30
|
);
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
...swrResponse,
|
|
34
|
-
refresh: swrResponse.mutate,
|
|
35
|
-
};
|
|
36
31
|
};
|
|
@@ -17,7 +17,7 @@ export const usePollMarkets = (
|
|
|
17
17
|
options?: DefaultHookOptions,
|
|
18
18
|
): UsePollMarketsResponse => {
|
|
19
19
|
const QUERY_KEY = usePollMarketsQueryKey();
|
|
20
|
-
|
|
20
|
+
return useSWRImmutable<GetMarkets, any, typeof QUERY_KEY>(
|
|
21
21
|
QUERY_KEY,
|
|
22
22
|
async () => {
|
|
23
23
|
const res = await getMarkets();
|
|
@@ -27,9 +27,4 @@ export const usePollMarkets = (
|
|
|
27
27
|
...options,
|
|
28
28
|
},
|
|
29
29
|
);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...swrResponse,
|
|
33
|
-
refresh: () => swrResponse.mutate(),
|
|
34
|
-
};
|
|
35
30
|
};
|
|
@@ -39,11 +39,7 @@ export function useQueuedBeraUnlock(
|
|
|
39
39
|
] as const)
|
|
40
40
|
: null;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
StakedBeraWithdrawal[],
|
|
44
|
-
any,
|
|
45
|
-
typeof QUERY_KEY
|
|
46
|
-
>(
|
|
42
|
+
return useSWRImmutable<StakedBeraWithdrawal[], any, typeof QUERY_KEY>(
|
|
47
43
|
QUERY_KEY,
|
|
48
44
|
async ([, receiptTokenAddresses, account, version]) => {
|
|
49
45
|
assertPublicClient(publicClient);
|
|
@@ -64,9 +60,4 @@ export function useQueuedBeraUnlock(
|
|
|
64
60
|
...options,
|
|
65
61
|
},
|
|
66
62
|
);
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...swrResponse,
|
|
70
|
-
refresh: () => swrResponse.mutate(),
|
|
71
|
-
};
|
|
72
63
|
}
|
|
@@ -48,8 +48,8 @@ export const useRewardVault = (
|
|
|
48
48
|
isLoading: onChainRewardVault.isLoading || swrResponse.isLoading,
|
|
49
49
|
isValidating: onChainRewardVault.isValidating ?? swrResponse.isValidating,
|
|
50
50
|
refresh: () => {
|
|
51
|
-
swrResponse.
|
|
52
|
-
onChainRewardVault.
|
|
51
|
+
swrResponse.refresh();
|
|
52
|
+
onChainRewardVault.refresh();
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
};
|
|
@@ -27,7 +27,7 @@ export const useRewardVaultBalanceFromStakingToken = (
|
|
|
27
27
|
const {
|
|
28
28
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
29
29
|
error,
|
|
30
|
-
|
|
30
|
+
refresh: mutateRewardVaultAddress,
|
|
31
31
|
isLoading: isLoadingRewardVaultAddress,
|
|
32
32
|
} = useRewardVaultFromToken(
|
|
33
33
|
{
|
|
@@ -76,7 +76,7 @@ export const useRewardVaultBalanceFromStakingToken = (
|
|
|
76
76
|
...swrResponse,
|
|
77
77
|
refresh: () => {
|
|
78
78
|
mutateRewardVaultAddress();
|
|
79
|
-
swrResponse.
|
|
79
|
+
swrResponse.refresh();
|
|
80
80
|
},
|
|
81
81
|
isLoading: swrResponse.isLoading || isLoadingRewardVaultAddress,
|
|
82
82
|
};
|
|
@@ -27,33 +27,27 @@ export const useRewardVaultFromToken = (
|
|
|
27
27
|
? ["useRewardVaultFromToken", tokenAddress]
|
|
28
28
|
: null;
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
...swrResponse,
|
|
57
|
-
refresh: () => swrResponse.mutate(),
|
|
58
|
-
};
|
|
30
|
+
return useSWRImmutable<Address | undefined, any, typeof QUERY_KEY>(
|
|
31
|
+
QUERY_KEY,
|
|
32
|
+
async ([, tokenAddress]) => {
|
|
33
|
+
if (!tokenAddress) {
|
|
34
|
+
throw new Error("useRewardVaultFromToken needs a valid token address");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
assertPublicClient(publicClient);
|
|
38
|
+
|
|
39
|
+
const { config } = parseBaseArgs({
|
|
40
|
+
chainId: publicClient.chain.id,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const res = await publicClient.readContract({
|
|
44
|
+
address: config.pol.factory,
|
|
45
|
+
abi: rewardVaultFactoryAbi,
|
|
46
|
+
functionName: "getVault",
|
|
47
|
+
args: [tokenAddress],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return res === zeroAddress ? undefined : res;
|
|
51
|
+
},
|
|
52
|
+
);
|
|
59
53
|
};
|
|
@@ -20,7 +20,7 @@ export function useRewardVaultIncentives({
|
|
|
20
20
|
? (["useRewardVaultIncentives", address, stakingToken] as const)
|
|
21
21
|
: null;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
return useSWR(QUERY_KEY, async ([, address, stakingToken]) => {
|
|
24
24
|
assertPublicClient(publicClient);
|
|
25
25
|
|
|
26
26
|
return await getRewardVaultIncentives({
|
|
@@ -29,9 +29,4 @@ export function useRewardVaultIncentives({
|
|
|
29
29
|
publicClient,
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
...swrResponse,
|
|
35
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
36
|
-
};
|
|
37
32
|
}
|
|
@@ -18,7 +18,7 @@ export const useRewardVaultRewards = (
|
|
|
18
18
|
? (["useRewardVaultRewards", address] as const)
|
|
19
19
|
: null;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return useSWR(
|
|
22
22
|
QUERY_KEY,
|
|
23
23
|
async ([, address]) => {
|
|
24
24
|
assertPublicClient(publicClient);
|
|
@@ -29,9 +29,4 @@ export const useRewardVaultRewards = (
|
|
|
29
29
|
...options,
|
|
30
30
|
},
|
|
31
31
|
);
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
...swrResponse,
|
|
35
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
36
|
-
};
|
|
37
32
|
};
|
|
@@ -24,7 +24,7 @@ export const useRewardVaults = (
|
|
|
24
24
|
args.onChainIncentives,
|
|
25
25
|
);
|
|
26
26
|
const publicClient = usePublicClient();
|
|
27
|
-
|
|
27
|
+
return useSWR(
|
|
28
28
|
QUERY_KEY,
|
|
29
29
|
async ([, filter, onChainIncentives]) => {
|
|
30
30
|
return await getRewardVaults({
|
|
@@ -34,9 +34,4 @@ export const useRewardVaults = (
|
|
|
34
34
|
},
|
|
35
35
|
options,
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...swrResponse,
|
|
40
|
-
refresh: swrResponse.mutate,
|
|
41
|
-
};
|
|
42
37
|
};
|
|
@@ -15,7 +15,7 @@ export function useStakedAPR({
|
|
|
15
15
|
range: GqlVaultSnapshotDataRange;
|
|
16
16
|
}): DefaultHookReturnType<UseStakedAPR> {
|
|
17
17
|
const QUERY_KEY = range ? (["useStakedAPR", range] as const) : null;
|
|
18
|
-
|
|
18
|
+
return useSWR(QUERY_KEY, async ([, range]) => {
|
|
19
19
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
20
20
|
range,
|
|
21
21
|
});
|
|
@@ -29,9 +29,4 @@ export function useStakedAPR({
|
|
|
29
29
|
apr: item.apr,
|
|
30
30
|
}));
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
...swrResponse,
|
|
35
|
-
refresh: () => swrResponse.mutate(),
|
|
36
|
-
};
|
|
37
32
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { StakeStatsByDayResponse } from "@berachain/graphql/beep";
|
|
4
4
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getStakingDailyAssets } from "../../actions/pol/getStakingDailyAssets";
|
|
7
7
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
8
8
|
import { dailyResolution } from "../../utils/filter";
|
|
9
9
|
|
|
10
|
-
type UseStakedBeraSnapshot = Record<Address,
|
|
10
|
+
type UseStakedBeraSnapshot = Record<Address, StakeStatsByDayResponse>;
|
|
11
11
|
export function useStakedSnapshots({
|
|
12
12
|
range,
|
|
13
13
|
addresses,
|
|
@@ -18,7 +18,7 @@ export function useStakedSnapshots({
|
|
|
18
18
|
const QUERY_KEY = range
|
|
19
19
|
? (["useStakedSnapshots", range, addresses] as const)
|
|
20
20
|
: null;
|
|
21
|
-
|
|
21
|
+
return useSWR(QUERY_KEY, async ([, range, addresses]) => {
|
|
22
22
|
const [...sortedStakingDailyAssetsArray] = await Promise.all([
|
|
23
23
|
...addresses.map(async (address) => {
|
|
24
24
|
const unstakingDailyAssets = await getStakingDailyAssets({
|
|
@@ -40,9 +40,4 @@ export function useStakedSnapshots({
|
|
|
40
40
|
{} as UseStakedBeraSnapshot,
|
|
41
41
|
);
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
...swrResponse,
|
|
46
|
-
refresh: () => swrResponse.mutate(),
|
|
47
|
-
};
|
|
48
43
|
}
|
|
@@ -13,7 +13,7 @@ export function useTotalStakedAmount({
|
|
|
13
13
|
}): DefaultHookReturnType<Record<Address, bigint>> {
|
|
14
14
|
const publicClient = usePublicClient();
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return useSWR(
|
|
17
17
|
vaultAddresses && publicClient
|
|
18
18
|
? ["useTotalStakedAmount", vaultAddresses]
|
|
19
19
|
: null,
|
|
@@ -21,9 +21,4 @@ export function useTotalStakedAmount({
|
|
|
21
21
|
return getTotalStakedAmount({ vaultAddresses, publicClient });
|
|
22
22
|
},
|
|
23
23
|
);
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
...swrResponse,
|
|
27
|
-
refresh: () => swrResponse.mutate(),
|
|
28
|
-
};
|
|
29
24
|
}
|
|
@@ -25,7 +25,7 @@ export const useUserVaultInfo = (
|
|
|
25
25
|
? (["useUserVaultInfo", account, args.vaultAddress] as const)
|
|
26
26
|
: null;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
return useSWR(
|
|
29
29
|
QUERY_KEY,
|
|
30
30
|
async ([, account, vaultAddress]) => {
|
|
31
31
|
assertPublicClient(publicClient);
|
|
@@ -41,9 +41,4 @@ export const useUserVaultInfo = (
|
|
|
41
41
|
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
42
42
|
},
|
|
43
43
|
);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...swrResponse,
|
|
47
|
-
refresh: () => swrResponse.mutate(),
|
|
48
|
-
};
|
|
49
44
|
};
|
|
@@ -19,7 +19,7 @@ export const useUserVaults = (
|
|
|
19
19
|
const publicClient = usePublicClient();
|
|
20
20
|
const QUERY_KEY =
|
|
21
21
|
account && publicClient ? (["useUserVaults", account] as const) : null;
|
|
22
|
-
|
|
22
|
+
return useSWR<GetUserVaultsResponse, unknown, typeof QUERY_KEY>(
|
|
23
23
|
QUERY_KEY,
|
|
24
24
|
async ([, account]) => {
|
|
25
25
|
assertPublicClient(publicClient);
|
|
@@ -35,8 +35,4 @@ export const useUserVaults = (
|
|
|
35
35
|
keepPreviousData: true,
|
|
36
36
|
},
|
|
37
37
|
);
|
|
38
|
-
return {
|
|
39
|
-
...swrResponse,
|
|
40
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
41
|
-
};
|
|
42
38
|
};
|
|
@@ -17,12 +17,7 @@ export const useVaultHistory = ({
|
|
|
17
17
|
const QUERY_KEY = vault
|
|
18
18
|
? (["useVaultHistory", vault, range, resolution] as const)
|
|
19
19
|
: null;
|
|
20
|
-
|
|
20
|
+
return useSWR(QUERY_KEY, ([, vault, range, resolution]) =>
|
|
21
21
|
getVaultHistory({ vault, range, resolution }),
|
|
22
22
|
);
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...swrResponse,
|
|
26
|
-
refresh: () => swrResponse.mutate(),
|
|
27
|
-
};
|
|
28
23
|
};
|
|
@@ -17,7 +17,7 @@ export const useVaultValidators = (
|
|
|
17
17
|
options?: DefaultHookOptions,
|
|
18
18
|
): UsePollValidatorInfoResponse => {
|
|
19
19
|
const QUERY_KEY = id ? (["useVaultValidators", id] as const) : null;
|
|
20
|
-
|
|
20
|
+
return useSWR(
|
|
21
21
|
QUERY_KEY,
|
|
22
22
|
async ([, address]) => {
|
|
23
23
|
return await getVaultValidators({
|
|
@@ -28,9 +28,4 @@ export const useVaultValidators = (
|
|
|
28
28
|
...options,
|
|
29
29
|
},
|
|
30
30
|
);
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
...swrResponse,
|
|
34
|
-
refresh: () => swrResponse.mutate(),
|
|
35
|
-
};
|
|
36
31
|
};
|
|
@@ -36,7 +36,7 @@ export function useMultipleTokenInformation(
|
|
|
36
36
|
] as const)
|
|
37
37
|
: null;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
return useSWRImmutable<Token[], unknown, typeof QUERY_KEY>(
|
|
40
40
|
QUERY_KEY,
|
|
41
41
|
async ([, addresses, chainId]) => {
|
|
42
42
|
// We already checked for publicClient in the QUERY_KEY
|
|
@@ -66,9 +66,4 @@ export function useMultipleTokenInformation(
|
|
|
66
66
|
},
|
|
67
67
|
{ ...options },
|
|
68
68
|
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...swrResponse,
|
|
72
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
73
|
-
};
|
|
74
69
|
}
|
|
@@ -35,7 +35,7 @@ export function usePollAllowances(
|
|
|
35
35
|
? (["usePollAllowances", account, args?.items] as const)
|
|
36
36
|
: null;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
return useSWR(
|
|
39
39
|
QUERY_KEY,
|
|
40
40
|
async ([, account, items]) => {
|
|
41
41
|
return getAllowances({
|
|
@@ -49,10 +49,4 @@ export function usePollAllowances(
|
|
|
49
49
|
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
50
50
|
},
|
|
51
51
|
);
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
...swrResponse,
|
|
55
|
-
|
|
56
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
57
|
-
};
|
|
58
52
|
}
|
|
@@ -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,
|
|
@@ -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")) {
|
|
@@ -50,9 +46,4 @@ export const useStakingTokenInformation = (
|
|
|
50
46
|
},
|
|
51
47
|
{ ...options },
|
|
52
48
|
);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...swrResponse,
|
|
56
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
57
|
-
};
|
|
58
49
|
};
|