@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
|
@@ -118,7 +118,7 @@ export function useAggregatorsQuotes(
|
|
|
118
118
|
...args,
|
|
119
119
|
aggregator: oogabooga,
|
|
120
120
|
},
|
|
121
|
-
|
|
121
|
+
swrOptions,
|
|
122
122
|
);
|
|
123
123
|
|
|
124
124
|
const flyResult = raw_useSingleAggregatorQuote(
|
|
@@ -127,7 +127,7 @@ export function useAggregatorsQuotes(
|
|
|
127
127
|
...args,
|
|
128
128
|
aggregator: fly,
|
|
129
129
|
},
|
|
130
|
-
|
|
130
|
+
swrOptions,
|
|
131
131
|
);
|
|
132
132
|
|
|
133
133
|
const erc4626Result = raw_useSingleAggregatorQuote(
|
|
@@ -136,7 +136,7 @@ export function useAggregatorsQuotes(
|
|
|
136
136
|
...args,
|
|
137
137
|
aggregator: erc4626Deposit,
|
|
138
138
|
},
|
|
139
|
-
|
|
139
|
+
swrOptions,
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
const kyberswapResult = raw_useSingleAggregatorQuote(
|
|
@@ -145,7 +145,7 @@ export function useAggregatorsQuotes(
|
|
|
145
145
|
...args,
|
|
146
146
|
aggregator: kyberswap,
|
|
147
147
|
},
|
|
148
|
-
|
|
148
|
+
swrOptions,
|
|
149
149
|
);
|
|
150
150
|
|
|
151
151
|
const openOceanResult = raw_useSingleAggregatorQuote(
|
|
@@ -154,7 +154,7 @@ export function useAggregatorsQuotes(
|
|
|
154
154
|
...args,
|
|
155
155
|
aggregator: openOcean,
|
|
156
156
|
},
|
|
157
|
-
|
|
157
|
+
swrOptions,
|
|
158
158
|
);
|
|
159
159
|
|
|
160
160
|
const haikuResult = raw_useSingleAggregatorQuote(
|
|
@@ -163,7 +163,7 @@ export function useAggregatorsQuotes(
|
|
|
163
163
|
...args,
|
|
164
164
|
aggregator: haiku,
|
|
165
165
|
},
|
|
166
|
-
|
|
166
|
+
swrOptions,
|
|
167
167
|
);
|
|
168
168
|
|
|
169
169
|
const ensoResult = raw_useSingleAggregatorQuote(
|
|
@@ -172,7 +172,7 @@ export function useAggregatorsQuotes(
|
|
|
172
172
|
...args,
|
|
173
173
|
aggregator: enso,
|
|
174
174
|
},
|
|
175
|
-
|
|
175
|
+
swrOptions,
|
|
176
176
|
);
|
|
177
177
|
|
|
178
178
|
const { protocol: bexProtocol } = useBexStatus();
|
|
@@ -183,7 +183,7 @@ export function useAggregatorsQuotes(
|
|
|
183
183
|
...args,
|
|
184
184
|
aggregator: bex,
|
|
185
185
|
},
|
|
186
|
-
{
|
|
186
|
+
{ ...swrOptions, isEnabled: bexProtocol.isPaused === false },
|
|
187
187
|
);
|
|
188
188
|
|
|
189
189
|
const wberaSwapResult = raw_useSingleAggregatorQuote({
|
|
@@ -198,7 +198,7 @@ export function useAggregatorsQuotes(
|
|
|
198
198
|
...args,
|
|
199
199
|
aggregator: bgtRedeem,
|
|
200
200
|
},
|
|
201
|
-
|
|
201
|
+
swrOptions,
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
const honeyResult = raw_useSingleAggregatorQuote(
|
|
@@ -207,7 +207,7 @@ export function useAggregatorsQuotes(
|
|
|
207
207
|
...args,
|
|
208
208
|
aggregator: honeyNative,
|
|
209
209
|
},
|
|
210
|
-
|
|
210
|
+
swrOptions,
|
|
211
211
|
);
|
|
212
212
|
|
|
213
213
|
const results = isWrapOrUnwrap
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
1
|
import { type PublicClient, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import aggregatorsRouterAbi from "@berachain/abis/meta-aggregator/metaAggregatorV2";
|
|
5
4
|
|
|
6
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
9
9
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import type { GetPoolsQueryVariables } from "@berachain/graphql/dex/api";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getAllPools } from "../../actions/dex/getAllPools";
|
|
6
5
|
import { POLLING } from "../../enum/polling";
|
|
@@ -20,12 +19,15 @@ export const useAllUserPools = (
|
|
|
20
19
|
) => {
|
|
21
20
|
const swrResponse = useSWR(
|
|
22
21
|
useAllUserPoolsQueryKey({ query }),
|
|
23
|
-
async ([_, params]
|
|
24
|
-
return getAllPools({
|
|
22
|
+
async ([_, params]) => {
|
|
23
|
+
return getAllPools({
|
|
24
|
+
...(params as GetPoolsQueryVariables),
|
|
25
|
+
fetchPolicy: "no-cache",
|
|
26
|
+
});
|
|
25
27
|
},
|
|
26
28
|
{
|
|
27
29
|
refreshInterval: POLLING.SLOW,
|
|
28
|
-
...options
|
|
30
|
+
...options,
|
|
29
31
|
},
|
|
30
32
|
);
|
|
31
33
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import { type Address, type Hex, isAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { MinimalPoolFragment } from "@berachain/graphql/dex/api";
|
|
4
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getApiPool } from "../../actions/dex/getApiPool";
|
|
7
7
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import useSWRImmutable from "swr/immutable";
|
|
3
2
|
import { type Address, formatUnits, isAddress } from "viem";
|
|
4
3
|
|
|
5
4
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
6
6
|
|
|
7
7
|
import { getOnChainPool } from "../../actions/dex/getOnChainPool";
|
|
8
8
|
import type { TokenPriceInfo } from "../../types/dex";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
2
|
|
|
4
3
|
import { vaultAbi as balancerVaultAbi } from "@berachain/abis/bex/vault";
|
|
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 type { DefaultHookOptions } from "../../types/global";
|
|
@@ -44,7 +44,7 @@ export const usePollPoolCreationRelayerApproval = (
|
|
|
44
44
|
|
|
45
45
|
return approved;
|
|
46
46
|
},
|
|
47
|
-
{ ...options
|
|
47
|
+
{ ...options },
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
const refreshPoolCreationApproval = () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWRImmutable from "swr/immutable";
|
|
2
|
-
|
|
3
1
|
import type { GqlPoolEventType } from "@berachain/graphql/dex/api";
|
|
2
|
+
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import { getPoolEvents } from "../../actions/dex/getPoolEvents";
|
|
6
5
|
import { POLLING } from "../../enum/polling";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
GqlChain,
|
|
5
3
|
PoolHistoricalDataFragment,
|
|
6
4
|
} from "@berachain/graphql/dex/api";
|
|
5
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
6
|
|
|
8
7
|
import { getPoolHistoricalData } from "../../actions/dex/getPoolHistoricalData";
|
|
9
8
|
import type {
|
|
@@ -37,7 +36,7 @@ export const usePoolHistoricalData = (
|
|
|
37
36
|
chain: config.bex.chainName as GqlChain,
|
|
38
37
|
});
|
|
39
38
|
},
|
|
40
|
-
options
|
|
39
|
+
options,
|
|
41
40
|
);
|
|
42
41
|
|
|
43
42
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
2
|
|
|
4
3
|
import type { GetPoolsQueryVariables } from "@berachain/graphql/dex/api";
|
|
5
4
|
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
5
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
6
6
|
|
|
7
7
|
import { getAllPools } from "../../actions/dex/getAllPools";
|
|
8
8
|
import { POLLING } from "../../enum/polling";
|
|
@@ -38,6 +38,7 @@ export const usePools = (
|
|
|
38
38
|
data: pools,
|
|
39
39
|
isLoading: isPoolsLoading,
|
|
40
40
|
mutate: mutatePools,
|
|
41
|
+
error: poolsError,
|
|
41
42
|
} = useSWR(
|
|
42
43
|
usePoolsQueryKey({ query }),
|
|
43
44
|
async ([_, query]) => {
|
|
@@ -45,7 +46,7 @@ export const usePools = (
|
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
48
|
refreshInterval: POLLING.SLOW,
|
|
48
|
-
...options
|
|
49
|
+
...options,
|
|
49
50
|
},
|
|
50
51
|
);
|
|
51
52
|
|
|
@@ -74,6 +75,7 @@ export const usePools = (
|
|
|
74
75
|
pools: mergedPools ?? [],
|
|
75
76
|
walletPools: pools?.pools ?? [],
|
|
76
77
|
isLoading: isPoolsLoading || isUserPoolsLoading,
|
|
78
|
+
error: poolsError,
|
|
77
79
|
refresh: () => {
|
|
78
80
|
mutatePools();
|
|
79
81
|
mutateUserPools();
|
|
@@ -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
|
@@ -49,7 +49,9 @@ export * from "./honey/useIsBasketModeEnabled";
|
|
|
49
49
|
export * from "./honey/usePythLatestPrices";
|
|
50
50
|
export * from "./perps/usePythUpdateFee";
|
|
51
51
|
export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
|
|
52
|
+
export { useAutoclaimedIncentivesTxHash } from "./pol/useAutoclaimedIncentivesTxHash";
|
|
52
53
|
export * from "./pol/useBgtAprSimulation";
|
|
54
|
+
export { useBgtIncentiveDistributorPaused } from "./pol/useBgtIncentiveDistributorPaused";
|
|
53
55
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
54
56
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
55
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";
|