@berachain/berajs 0.2.10 → 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.mjs +1 -1
- package/dist/actions/exports.d.ts +67 -17
- package/dist/actions/exports.mjs +60 -19
- package/dist/actions/governance/exports.d.ts +3 -11
- package/dist/{chunk-P5WXXULM.mjs → chunk-MRQGHXAN.mjs} +1 -1
- package/dist/{chunk-WNBWX23Q.mjs → chunk-SXUNCX5E.mjs} +5 -4
- package/dist/chunk-UD5IUNCW.mjs +34 -0
- package/dist/{chunk-QBBOWFMH.mjs → chunk-VAA2FVPP.mjs} +58 -12
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +4 -2
- package/dist/enum/exports.d.ts +8 -2
- package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
- package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.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 +100 -149
- package/dist/hooks/exports.mjs +468 -484
- package/dist/hooks/governance/exports.d.ts +20 -15
- package/dist/hooks/governance/exports.mjs +39 -37
- 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 +4 -0
- package/package.json +8 -7
- package/src/actions/bend/getMaxDeposit.ts +28 -2
- package/src/actions/clients/fetchOpenApi.ts +6 -2
- package/src/actions/clients/fetchOpenApi.unit.test.ts +24 -2
- package/src/actions/exports.ts +1 -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/validators/getValidatorIncentiveDistribution.ts +64 -12
- package/src/contexts/SwrFallback.tsx +2 -1
- package/src/data/contracts.ts +4 -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 +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 +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 +1 -2
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +1 -2
- 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/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/global.d.ts +3 -4
- package/src/types/pol.d.ts +17 -3
- package/dist/polling-BKnyavLI.d.ts +0 -8
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import useSWR, { type SWRConfiguration } from "swr";
|
|
2
1
|
import { type Address, type PublicClient, parseUnits, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import type { SWRConfiguration } from "@berachain/utils/pkg/swr";
|
|
5
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
6
|
|
|
6
7
|
import { BaseAggregator } from "../../actions/dex/aggregators/base";
|
|
7
8
|
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
@@ -67,7 +68,6 @@ function getQueryKey({
|
|
|
67
68
|
account,
|
|
68
69
|
args,
|
|
69
70
|
feeBps,
|
|
70
|
-
options,
|
|
71
71
|
activeAggregators,
|
|
72
72
|
isMAEnabled,
|
|
73
73
|
}: {
|
|
@@ -75,7 +75,6 @@ function getQueryKey({
|
|
|
75
75
|
account: Address | undefined;
|
|
76
76
|
args: IUseAggregatorsQuotesArgs;
|
|
77
77
|
feeBps: number | undefined;
|
|
78
|
-
options?: DefaultHookOptions;
|
|
79
78
|
/**
|
|
80
79
|
* List of active aggregators fetched from edge config flags.
|
|
81
80
|
*
|
|
@@ -84,10 +83,6 @@ function getQueryKey({
|
|
|
84
83
|
activeAggregators: string[] | undefined;
|
|
85
84
|
isMAEnabled: boolean;
|
|
86
85
|
}): IQueryKey | null {
|
|
87
|
-
if (options?.opts?.isEnabled !== undefined && !options?.opts?.isEnabled) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
86
|
if (!Number(args.amount)) {
|
|
92
87
|
return null;
|
|
93
88
|
}
|
|
@@ -243,7 +238,6 @@ export function raw_useSingleAggregatorQuote(
|
|
|
243
238
|
account,
|
|
244
239
|
args,
|
|
245
240
|
feeBps,
|
|
246
|
-
options,
|
|
247
241
|
activeAggregators,
|
|
248
242
|
isMAEnabled,
|
|
249
243
|
}),
|
|
@@ -252,7 +246,7 @@ export function raw_useSingleAggregatorQuote(
|
|
|
252
246
|
proxyAggregatorsThroughVercel,
|
|
253
247
|
publicClient,
|
|
254
248
|
}),
|
|
255
|
-
options
|
|
249
|
+
options,
|
|
256
250
|
);
|
|
257
251
|
}
|
|
258
252
|
|
|
@@ -266,16 +260,10 @@ export function getAggregatorsSWROptions(
|
|
|
266
260
|
return {
|
|
267
261
|
refreshInterval: POLLING.FAST, // every 10s
|
|
268
262
|
errorRetryCount: 3,
|
|
269
|
-
...options
|
|
263
|
+
...options,
|
|
270
264
|
// biome-ignore lint/nursery/useMaxParams: the function is defined in the SWRConfiguration type
|
|
271
265
|
onErrorRetry(err, key, config, revalidate, revalidateOpts) {
|
|
272
|
-
options?.
|
|
273
|
-
err,
|
|
274
|
-
key,
|
|
275
|
-
config,
|
|
276
|
-
revalidate,
|
|
277
|
-
revalidateOpts,
|
|
278
|
-
);
|
|
266
|
+
options?.onErrorRetry?.(err, key, config, revalidate, revalidateOpts);
|
|
279
267
|
if (err instanceof BeraError) {
|
|
280
268
|
if (err.reason === BaseAggregator.PATH_NOT_FOUND_REASON) {
|
|
281
269
|
return;
|
|
@@ -345,6 +333,6 @@ export function useSingleAggregatorQuote(
|
|
|
345
333
|
publicClient,
|
|
346
334
|
proxyAggregatorsThroughVercel,
|
|
347
335
|
},
|
|
348
|
-
|
|
336
|
+
getAggregatorsSWROptions(options),
|
|
349
337
|
);
|
|
350
338
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import type { Address, Hex } from "viem";
|
|
5
4
|
import { parseUnits } from "viem";
|
|
6
5
|
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
useBeraWallet,
|
|
12
11
|
usePublicClient,
|
|
13
12
|
} from "@berachain/wagmi/hooks";
|
|
13
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
14
14
|
|
|
15
15
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
16
16
|
import { getBendDemultiplyBundle } from "../../actions/enso/getBendDemultiplyBundle";
|
|
@@ -83,8 +83,7 @@ export function useBendDemultiply(
|
|
|
83
83
|
currentCollateral &&
|
|
84
84
|
currentDebt &&
|
|
85
85
|
Number(currentDebt) > 0 &&
|
|
86
|
-
fromAddress
|
|
87
|
-
(options?.opts?.isEnabled ?? true)
|
|
86
|
+
fromAddress
|
|
88
87
|
? ([
|
|
89
88
|
"useBendDemultiply",
|
|
90
89
|
fromAddress,
|
|
@@ -159,7 +158,7 @@ export function useBendDemultiply(
|
|
|
159
158
|
});
|
|
160
159
|
},
|
|
161
160
|
{
|
|
162
|
-
...options
|
|
161
|
+
...options,
|
|
163
162
|
refreshInterval: POLLING.NORMAL,
|
|
164
163
|
},
|
|
165
164
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import type { Address, Hex } from "viem";
|
|
5
4
|
import { parseUnits } from "viem";
|
|
6
5
|
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
useBeraWallet,
|
|
12
11
|
usePublicClient,
|
|
13
12
|
} from "@berachain/wagmi/hooks";
|
|
13
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
14
14
|
|
|
15
15
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
16
16
|
import { getBendMultiplyBundle } from "../../actions/enso/getBendMultiplyBundle";
|
|
@@ -85,8 +85,7 @@ export function useBendMultiply(
|
|
|
85
85
|
(leverageMultiplier > 1 &&
|
|
86
86
|
(Number(formattedCurrentCollateralAmount ?? 0) > 0 ||
|
|
87
87
|
Number(formattedSupplyCollateralAmount ?? 0) > 0))) &&
|
|
88
|
-
fromAddress
|
|
89
|
-
(options?.opts?.isEnabled ?? true)
|
|
88
|
+
fromAddress
|
|
90
89
|
? ([
|
|
91
90
|
"useBendMultiply",
|
|
92
91
|
fromAddress,
|
|
@@ -164,7 +163,7 @@ export function useBendMultiply(
|
|
|
164
163
|
});
|
|
165
164
|
},
|
|
166
165
|
{
|
|
167
|
-
...options
|
|
166
|
+
...options,
|
|
168
167
|
refreshInterval: POLLING.NORMAL,
|
|
169
168
|
},
|
|
170
169
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import { type Address, formatEther, parseUnits, zeroAddress } from "viem";
|
|
5
4
|
|
|
6
5
|
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
7
6
|
|
|
8
7
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
|
|
11
11
|
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
@@ -115,7 +115,7 @@ export function useBendZapSupply(
|
|
|
115
115
|
address: zeroAddress,
|
|
116
116
|
chainId: isCrossChain ? tokenIn?.chainId : undefined,
|
|
117
117
|
},
|
|
118
|
-
{
|
|
118
|
+
{ isEnabled: !!isCrossChain },
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
// for cross-chain zaps, check if transaction value exceeds native token balance
|
|
@@ -173,7 +173,6 @@ export function useBendZapSupplyHelper(
|
|
|
173
173
|
);
|
|
174
174
|
|
|
175
175
|
const isEnabled =
|
|
176
|
-
(options?.opts?.isEnabled ?? true) &&
|
|
177
176
|
!!tokenIn &&
|
|
178
177
|
!!loanToken &&
|
|
179
178
|
!!bendVault &&
|
|
@@ -228,7 +227,7 @@ export function useBendZapSupplyHelper(
|
|
|
228
227
|
});
|
|
229
228
|
},
|
|
230
229
|
{
|
|
231
|
-
...options
|
|
230
|
+
...options,
|
|
232
231
|
refreshInterval: POLLING.NORMAL,
|
|
233
232
|
},
|
|
234
233
|
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { getPublicClient } from "@wagmi/core";
|
|
4
|
-
import useSWR from "swr";
|
|
5
4
|
import { parseUnits } from "viem";
|
|
6
5
|
|
|
7
6
|
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
8
7
|
|
|
9
8
|
import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
9
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
10
10
|
|
|
11
11
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
12
12
|
import { getEnsoSwapBundle } from "../../actions/enso/getEnsoSwapBundle";
|
|
@@ -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 { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
6
5
|
import { getEnsoUserTokensWithBalances } from "../../actions/enso/getEnsoUserTokensWithBalances";
|
|
@@ -18,7 +17,7 @@ export function useEnsoUserTokensWithBalances(
|
|
|
18
17
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
19
18
|
"proxyAggregatorsThroughVercel",
|
|
20
19
|
);
|
|
21
|
-
const isEnabled = !!fromAddress
|
|
20
|
+
const isEnabled = !!fromAddress;
|
|
22
21
|
|
|
23
22
|
const QUERY_KEY =
|
|
24
23
|
isEnabled && wagmiConfig
|
|
@@ -43,8 +42,7 @@ export function useEnsoUserTokensWithBalances(
|
|
|
43
42
|
}),
|
|
44
43
|
{
|
|
45
44
|
refreshInterval: POLLING.NORMAL,
|
|
46
|
-
|
|
47
|
-
...options?.opts,
|
|
45
|
+
...options,
|
|
48
46
|
},
|
|
49
47
|
);
|
|
50
48
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import type { Address } from "viem";
|
|
5
4
|
import { getAddress } from "viem";
|
|
6
5
|
|
|
7
6
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
7
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
8
8
|
|
|
9
9
|
import { getEnsoWalletV2Address } from "../../actions/enso/flashloan";
|
|
10
10
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import type { Address } from "viem";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { getIsBendAuthorized } from "../../actions/enso/flashloan";
|
|
9
9
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import useSWR from "swr";
|
|
4
3
|
import { formatUnits, parseUnits } from "viem";
|
|
5
4
|
|
|
6
5
|
import { chainConfigs, defaultChainId } from "@berachain/config/internal";
|
|
7
6
|
|
|
8
7
|
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
|
|
11
11
|
import { POLLING } from "../../enum/polling";
|
|
@@ -85,7 +85,7 @@ export function useZapStakeBera(
|
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
|
-
...options
|
|
88
|
+
...options,
|
|
89
89
|
refreshInterval: POLLING.NORMAL,
|
|
90
90
|
},
|
|
91
91
|
);
|
package/src/hooks/exports.ts
CHANGED
|
@@ -51,6 +51,7 @@ export * from "./perps/usePythUpdateFee";
|
|
|
51
51
|
export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
|
|
52
52
|
export { useAutoclaimedIncentivesTxHash } from "./pol/useAutoclaimedIncentivesTxHash";
|
|
53
53
|
export * from "./pol/useBgtAprSimulation";
|
|
54
|
+
export { useBgtIncentiveDistributorPaused } from "./pol/useBgtIncentiveDistributorPaused";
|
|
54
55
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
55
56
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
56
57
|
export * from "./pol/useHighestVaultsAPR";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { type Address, formatUnits } from "viem";
|
|
3
2
|
|
|
4
3
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
9
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, isAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
9
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { CANCELLER_ROLE } from "../../actions/governance/constants";
|
|
9
9
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import useSWRInfinite, { type SWRInfiniteResponse } from "swr/infinite";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
type OrderDirection,
|
|
@@ -8,6 +7,8 @@ import {
|
|
|
8
7
|
type ProposalSelectionFragment,
|
|
9
8
|
ProposalStatus,
|
|
10
9
|
} from "@berachain/graphql/governance";
|
|
10
|
+
import type { SWRInfiniteResponse } from "@berachain/utils/pkg/swr/infinite";
|
|
11
|
+
import useSWRInfinite from "@berachain/utils/pkg/swr/infinite";
|
|
11
12
|
|
|
12
13
|
import { getAllProposals } from "../../actions/governance/getAllProposals";
|
|
13
14
|
import { POLLING } from "../../enum/polling";
|
|
@@ -66,7 +67,7 @@ export function usePollAllProposalsQueryKey(
|
|
|
66
67
|
args: Partial<UsePollAllProposalsArgs> = {},
|
|
67
68
|
): (
|
|
68
69
|
pageIndex: number,
|
|
69
|
-
previousPageData?: ProposalSelectionFragment[],
|
|
70
|
+
previousPageData?: ProposalSelectionFragment[] | null,
|
|
70
71
|
) => PollAllProposalsKey {
|
|
71
72
|
const subgraphPageSize = 2 * (args.perPage ?? DEFAULT_PER_PAGE);
|
|
72
73
|
|
|
@@ -141,16 +142,16 @@ export function usePollAllProposals(
|
|
|
141
142
|
return (proposals ?? []).filter(Boolean) as ProposalSelectionFragment[];
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
const swr = useSWRInfinite<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
145
|
+
const swr = useSWRInfinite<
|
|
146
|
+
ProposalSelectionFragment[],
|
|
147
|
+
any,
|
|
148
|
+
PollAllProposalsKey
|
|
149
|
+
>(getKey, fetcher, {
|
|
150
|
+
// Increase initialSize in order to prefetch more proposals at a time.
|
|
151
|
+
initialSize: 1,
|
|
152
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
153
|
+
...options,
|
|
154
|
+
});
|
|
154
155
|
|
|
155
156
|
const data = useMemo(() => {
|
|
156
157
|
if (!swr.data) return [];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
ProposalStatus,
|
|
6
5
|
type ProposalWithVotesFragment,
|
|
7
6
|
} from "@berachain/graphql/governance";
|
|
8
7
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { getProposalDetails } from "../../actions/governance/getProposalDetails";
|
|
11
11
|
import { POLLING } from "../../enum/polling";
|
|
@@ -53,8 +53,8 @@ export const usePollProposal = (
|
|
|
53
53
|
return getProposalDetails({ proposalId, client: publicClient });
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
...options
|
|
57
|
-
refreshInterval: options?.
|
|
56
|
+
...options,
|
|
57
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
58
58
|
},
|
|
59
59
|
);
|
|
60
60
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, formatEther } from "viem";
|
|
3
2
|
|
|
4
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { POLLING } from "../../enum/polling";
|
|
9
9
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import useSWRInfinite, { type SWRInfiniteKeyLoader } from "swr/infinite";
|
|
2
|
-
|
|
3
1
|
import type { GetProposalVotesQueryVariables } from "@berachain/graphql/governance";
|
|
2
|
+
import type { SWRInfiniteKeyLoader } from "@berachain/utils/pkg/swr/infinite";
|
|
3
|
+
import { useSWRInfinite } from "@berachain/utils/pkg/swr/infinite";
|
|
4
4
|
|
|
5
5
|
import { getProposalVotes } from "../../actions/governance/getProposalVotes";
|
|
6
6
|
|
|
@@ -12,6 +12,17 @@ type UsePollProposalVotesArgs = Omit<
|
|
|
12
12
|
// const ACTUAL_PER_PAGE = 500;
|
|
13
13
|
|
|
14
14
|
const DEFAULT_LIMIT = 1000;
|
|
15
|
+
|
|
16
|
+
type ProposalVotesKey =
|
|
17
|
+
| [
|
|
18
|
+
string,
|
|
19
|
+
number,
|
|
20
|
+
number,
|
|
21
|
+
UsePollProposalVotesArgs["proposalId"],
|
|
22
|
+
UsePollProposalVotesArgs["orderBy"],
|
|
23
|
+
UsePollProposalVotesArgs["orderDirection"],
|
|
24
|
+
]
|
|
25
|
+
| null;
|
|
15
26
|
/**
|
|
16
27
|
* Fetches all the votes for a proposal from the Subgraph
|
|
17
28
|
* @param args - The arguments to pass to the query
|
|
@@ -21,9 +32,13 @@ export const usePollProposalVotes = (
|
|
|
21
32
|
args: UsePollProposalVotesArgs,
|
|
22
33
|
total: number,
|
|
23
34
|
) => {
|
|
24
|
-
return useSWRInfinite
|
|
35
|
+
return useSWRInfinite<
|
|
36
|
+
Awaited<ReturnType<typeof getProposalVotes>>,
|
|
37
|
+
any,
|
|
38
|
+
ProposalVotesKey
|
|
39
|
+
>(
|
|
25
40
|
usePollProposalVotesQueryKey(args, total),
|
|
26
|
-
async ([_key, page]
|
|
41
|
+
async ([_key, page]) => {
|
|
27
42
|
return getProposalVotes({
|
|
28
43
|
variables: {
|
|
29
44
|
...args,
|
|
@@ -44,7 +59,10 @@ export const usePollProposalVotesQueryKey =
|
|
|
44
59
|
(
|
|
45
60
|
{ ...args }: UsePollProposalVotesArgs,
|
|
46
61
|
total: number,
|
|
47
|
-
): SWRInfiniteKeyLoader
|
|
62
|
+
): SWRInfiniteKeyLoader<
|
|
63
|
+
Awaited<ReturnType<typeof getProposalVotes>>,
|
|
64
|
+
ProposalVotesKey
|
|
65
|
+
> =>
|
|
48
66
|
(
|
|
49
67
|
pageIndex: number,
|
|
50
68
|
// previousPageData: Awaited<ReturnType<typeof getProposalVotes>>,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, formatEther } from "viem";
|
|
3
2
|
|
|
4
3
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5
4
|
|
|
6
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { POLLING } from "../../enum/polling";
|
|
9
9
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -62,8 +62,8 @@ export const usePollUserDelegates = (
|
|
|
62
62
|
};
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
...options
|
|
66
|
-
refreshInterval: options?.
|
|
65
|
+
...options,
|
|
66
|
+
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
67
67
|
},
|
|
68
68
|
);
|
|
69
69
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { ProposalWithVotesFragment } from "@berachain/graphql/governance";
|
|
5
4
|
import { usePublicClient, useTransactionReceipt } from "@berachain/wagmi/hooks";
|
|
5
|
+
import type { SWRResponse } from "@berachain/utils/pkg/swr";
|
|
6
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
6
7
|
|
|
7
8
|
import { getProposalFromTx } from "../../actions/governance/getProposalFromTx";
|
|
8
9
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { SWRResponse } from "swr";
|
|
2
|
-
import useSWRImmutable from "swr/immutable";
|
|
3
|
-
|
|
4
1
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5
2
|
|
|
6
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import type { SWRResponse } from "@berachain/utils/pkg/swr";
|
|
5
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
6
|
|
|
8
7
|
import { assertPublicClient } from "../../errors/assert";
|
|
9
8
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { SWRResponse } from "swr";
|
|
2
|
-
import useSWRImmutable from "swr/immutable";
|
|
3
1
|
import type { Address } from "viem";
|
|
4
2
|
|
|
5
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
6
4
|
|
|
7
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import type { SWRResponse } from "@berachain/utils/pkg/swr";
|
|
7
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
8
8
|
|
|
9
9
|
import { ProposalState } from "../../enum/governance";
|
|
10
10
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import type { SWRResponse } from "@berachain/utils/pkg/swr";
|
|
7
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
8
|
|
|
8
9
|
import { POLLING } from "../../enum/polling";
|
|
9
10
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getGlobalCapLimit } from "../../actions/honey/getGlobalCapLimit";
|
|
6
5
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -39,9 +38,7 @@ export const useCappedGlobally = (
|
|
|
39
38
|
: undefined,
|
|
40
39
|
},
|
|
41
40
|
{
|
|
42
|
-
|
|
43
|
-
isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
|
|
44
|
-
},
|
|
41
|
+
isEnabled: flags.isPythWrapperEnabled && !!asset?.address,
|
|
45
42
|
},
|
|
46
43
|
);
|
|
47
44
|
const QUERY_KEY =
|
|
@@ -84,7 +81,7 @@ export const useCappedGlobally = (
|
|
|
84
81
|
});
|
|
85
82
|
},
|
|
86
83
|
{
|
|
87
|
-
...options
|
|
84
|
+
...options,
|
|
88
85
|
refreshInterval: 0,
|
|
89
86
|
},
|
|
90
87
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getRelativeCapLimit } from "../../actions/honey/getRelativeCapLimit";
|
|
7
7
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -80,7 +80,7 @@ export const useCappedRelatively = (
|
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
refreshInterval: 0,
|
|
83
|
-
...options
|
|
83
|
+
...options,
|
|
84
84
|
},
|
|
85
85
|
);
|
|
86
86
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getCollateralWeights } from "../../actions/honey/getCollateralWeights";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -40,8 +40,8 @@ export const useCollateralWeights = (
|
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
...options
|
|
44
|
-
refreshInterval: options?.
|
|
43
|
+
...options,
|
|
44
|
+
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
45
45
|
},
|
|
46
46
|
);
|
|
47
47
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
useConfig,
|
|
7
6
|
usePublicClient,
|
|
8
7
|
} from "@berachain/wagmi/hooks";
|
|
8
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { getWalletBalances } from "../../actions/tokens/getWalletBalances";
|
|
11
11
|
import { useHoneyConfig } from "../../contexts/HoneyConfigProvider";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
type GetHoneyVaultsBalanceResponse,
|
|
@@ -34,7 +33,7 @@ export const useHoneyVaultsBalance = (
|
|
|
34
33
|
collateralList,
|
|
35
34
|
});
|
|
36
35
|
},
|
|
37
|
-
{ ...options
|
|
36
|
+
{ ...options, refreshInterval: POLLING.NORMAL },
|
|
38
37
|
);
|
|
39
38
|
|
|
40
39
|
return {
|