@berachain/berajs 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
- package/dist/actions/clients/exports.d.ts +5 -21
- package/dist/actions/clients/exports.mjs +5 -7
- package/dist/actions/exports.d.ts +117 -31
- package/dist/actions/exports.mjs +36 -25
- package/dist/actions/governance/exports.d.ts +3 -11
- package/dist/actions/server/exports.mjs +2 -2
- package/dist/chunk-4ML4Y6UN.mjs +46 -0
- package/dist/{chunk-7YVNSDXG.mjs → chunk-FGION6F6.mjs} +1 -1
- package/dist/{chunk-3JJLQ2JX.mjs → chunk-MKSFQIKC.mjs} +1 -4
- package/dist/{chunk-ZLTMIFCZ.mjs → chunk-RFJGL4MF.mjs} +3 -3
- package/dist/{chunk-Y6THHG77.mjs → chunk-T43JPYQS.mjs} +1 -1
- package/dist/{chunk-WNBWX23Q.mjs → chunk-W2VODV76.mjs} +7 -10
- package/dist/{chunk-QBBOWFMH.mjs → chunk-XDG26EG6.mjs} +115 -162
- package/dist/{chunk-P5WXXULM.mjs → chunk-YLTWPFCJ.mjs} +3 -18
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +6 -4
- package/dist/enum/exports.d.ts +8 -2
- package/dist/errors/exports.mjs +2 -2
- package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
- package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
- package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +8 -59
- package/dist/{global.d-BuGDKh4k.d.ts → global.d-CR3zicga.d.ts} +3 -10
- package/dist/hooks/exports.d.ts +145 -403
- package/dist/hooks/exports.mjs +496 -755
- package/dist/hooks/governance/exports.d.ts +24 -19
- package/dist/hooks/governance/exports.mjs +43 -53
- package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
- package/dist/types/exports.d.ts +5 -5
- package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
- package/dist/utils/exports.d.ts +2 -2
- package/dist/utils/exports.mjs +6 -2
- package/package.json +8 -7
- package/src/actions/bend/getMaxDeposit.ts +28 -2
- package/src/actions/clients/exports.ts +0 -1
- package/src/actions/clients/fetchBeep.ts +0 -7
- package/src/actions/clients/fetchOpenApi.ts +10 -6
- package/src/actions/clients/fetchOpenApi.unit.test.ts +20 -14
- package/src/actions/clients/getApolloClient.ts +4 -9
- package/src/actions/exports.ts +1 -1
- package/src/actions/honey/getChartData.ts +14 -14
- package/src/actions/honey/getHoney24hVolume.ts +17 -8
- package/src/actions/honey/getHoneyTxns.ts +45 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +3 -3
- package/src/actions/pol/getEarnedStakedBeraVault.ts +0 -15
- package/src/actions/pol/getGlobalData.ts +10 -29
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getSWBeraVaultMetadata.ts +0 -7
- package/src/actions/pol/getStakingDailyAssets.ts +0 -14
- package/src/actions/validators/getApiEnrichedAllocation.ts +1 -1
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +43 -13
- package/src/contexts/SwrFallback.tsx +2 -1
- package/src/data/contracts.ts +4 -0
- package/src/errors/RequestError.ts +3 -3
- package/src/errors/getRevertReason.integration.test.ts +5 -1
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -11
- package/src/hooks/dex/useAggregatorsQuotes.ts +13 -11
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -7
- package/src/hooks/dex/useAllUserPools.ts +8 -13
- package/src/hooks/dex/useApiPool.ts +2 -9
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -2
- package/src/hooks/dex/useOnChainPoolData.ts +3 -4
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +3 -9
- package/src/hooks/dex/usePoolEvents.ts +1 -2
- package/src/hooks/dex/usePoolHistoricalData.ts +3 -9
- package/src/hooks/dex/usePools.ts +6 -4
- package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
- package/src/hooks/enso/useBendDemultiply.ts +3 -4
- package/src/hooks/enso/useBendMultiply.ts +3 -4
- package/src/hooks/enso/useBendZapSupply.ts +4 -5
- package/src/hooks/enso/useEnsoSwapBundle.ts +2 -2
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +4 -10
- package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
- package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
- package/src/hooks/enso/useZapStakeBera.ts +2 -5
- package/src/hooks/exports.ts +1 -0
- package/src/hooks/governance/useGetPastVotes.ts +1 -1
- package/src/hooks/governance/useHasVoted.ts +1 -1
- package/src/hooks/governance/useIsCanceller.ts +1 -1
- package/src/hooks/governance/usePollAllProposals.ts +13 -12
- package/src/hooks/governance/usePollProposal.ts +7 -10
- package/src/hooks/governance/usePollProposalThreshold.ts +2 -7
- package/src/hooks/governance/usePollProposalVotes.ts +23 -5
- package/src/hooks/governance/usePollUserDelegates.ts +4 -9
- package/src/hooks/governance/useProposalFromTx.ts +4 -5
- package/src/hooks/governance/useProposalSnapshot.ts +3 -4
- package/src/hooks/governance/useProposalState.ts +3 -3
- package/src/hooks/governance/useProposalTimelockState.ts +3 -2
- package/src/hooks/governance/useQuorum.ts +1 -2
- package/src/hooks/honey/useCappedGlobally.ts +4 -12
- package/src/hooks/honey/useCappedRelatively.ts +3 -8
- package/src/hooks/honey/useCollateralWeights.ts +4 -9
- package/src/hooks/honey/useHoney24hVolume.ts +2 -6
- package/src/hooks/honey/useHoneyBalances.ts +2 -7
- package/src/hooks/honey/useHoneyChartData.ts +4 -12
- package/src/hooks/honey/useHoneyVaultsBalance.ts +3 -9
- package/src/hooks/honey/useIsBadCollateralAsset.ts +5 -13
- package/src/hooks/honey/useIsBasketModeEnabled.ts +5 -13
- package/src/hooks/honey/usePythLatestPrices.ts +15 -13
- package/src/hooks/perps/usePythUpdateFee.ts +13 -11
- package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -8
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +2 -8
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +34 -0
- package/src/hooks/pol/useBgtUnstakedBalance.ts +3 -8
- package/src/hooks/pol/useClaimableFees.ts +2 -6
- package/src/hooks/pol/useHighestVaultsAPR.ts +6 -11
- package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
- package/src/hooks/pol/usePollGlobalData.ts +3 -9
- package/src/hooks/pol/usePollMarkets.ts +3 -8
- package/src/hooks/pol/useQueuedBeraUnlock.ts +3 -12
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
- package/src/hooks/pol/useRewardVault.ts +9 -8
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +6 -6
- package/src/hooks/pol/useRewardVaultFromToken.ts +24 -30
- package/src/hooks/pol/useRewardVaultIncentives.ts +2 -7
- package/src/hooks/pol/useRewardVaultRewards.ts +3 -8
- package/src/hooks/pol/useRewardVaults.ts +4 -12
- package/src/hooks/pol/useStakedAPR.ts +2 -8
- package/src/hooks/pol/useStakedData.ts +90 -41
- package/src/hooks/pol/useStakedSnapshots.ts +4 -9
- package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
- package/src/hooks/pol/useTotalStakedAmount.ts +2 -8
- package/src/hooks/pol/useUserVaultInfo.ts +3 -8
- package/src/hooks/pol/useUserVaults.ts +3 -8
- package/src/hooks/pol/useVaultAddress.ts +1 -1
- package/src/hooks/pol/useVaultHistory.ts +2 -8
- package/src/hooks/pol/useVaultValidators.ts +3 -8
- package/src/hooks/tokens/useMultipleTokenInformation.ts +3 -8
- package/src/hooks/tokens/usePollAllowances.ts +4 -11
- package/src/hooks/tokens/usePollBalance.ts +2 -5
- package/src/hooks/tokens/usePollWalletBalances.ts +3 -3
- package/src/hooks/tokens/useStakingTokenInformation.ts +3 -12
- package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
- package/src/hooks/tokens/useTokenInformation.ts +3 -8
- package/src/hooks/tokens/useTokenPrice.ts +2 -1
- package/src/hooks/tokens/useTokenPrices.ts +3 -4
- package/src/hooks/tokens/useTotalSupply.ts +1 -1
- package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
- package/src/hooks/useBlockToTimestamp.ts +1 -2
- package/src/hooks/useGetVerifiedAbi.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +3 -9
- package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +4 -12
- package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +2 -4
- package/src/hooks/validators/useDefaultRewardAllocation.ts +3 -9
- package/src/hooks/validators/useManagedValidatorRole.ts +2 -3
- package/src/hooks/validators/useOnChainValidator.ts +4 -11
- package/src/hooks/validators/useStakingPoolBatch.ts +4 -10
- package/src/hooks/validators/useUserActiveValidators.ts +3 -9
- package/src/hooks/validators/useUserBoostsOnValidator.ts +2 -4
- package/src/hooks/validators/useUserClaimableIncentives.ts +3 -3
- package/src/hooks/validators/useUserStakingPositions.ts +3 -9
- package/src/hooks/validators/useValidatorAnalytics.ts +2 -4
- package/src/hooks/validators/useValidatorCommission.ts +3 -8
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -6
- package/src/hooks/validators/useValidatorQueuedCommission.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +3 -8
- package/src/hooks/validators/useValidatorRewardAllocation.ts +3 -8
- package/src/types/global.d.ts +7 -10
- package/src/types/pol.d.ts +17 -3
- package/dist/polling-BKnyavLI.d.ts +0 -8
- package/src/actions/clients/fetchRailwayBackend.ts +0 -34
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
1
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
2
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
4
3
|
|
|
5
4
|
import type { GetConvertToAssetsProps } from "../../actions/bend/getConvertToAssets";
|
|
6
5
|
import { getConvertToAssets } from "../../actions/bend/getConvertToAssets";
|
|
@@ -16,7 +15,7 @@ export const useGetConvertToAssets = (
|
|
|
16
15
|
options?: DefaultHookOptions,
|
|
17
16
|
) => {
|
|
18
17
|
const publicClient = usePublicClient({ chainId: vaultChainId });
|
|
19
|
-
|
|
18
|
+
return useSWR(
|
|
20
19
|
publicClient && sharesAmount && vaultAddress
|
|
21
20
|
? ["useGetConvertToAssets", sharesAmount, vaultAddress, vaultChainId]
|
|
22
21
|
: null,
|
|
@@ -30,14 +29,7 @@ export const useGetConvertToAssets = (
|
|
|
30
29
|
});
|
|
31
30
|
},
|
|
32
31
|
{
|
|
33
|
-
...options
|
|
32
|
+
...options,
|
|
34
33
|
},
|
|
35
34
|
);
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...swrResponse,
|
|
39
|
-
refresh: () => {
|
|
40
|
-
swrResponse.mutate();
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
35
|
};
|
|
@@ -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
|
|
@@ -258,6 +258,8 @@ export function useAggregatorsQuotes(
|
|
|
258
258
|
|
|
259
259
|
return {
|
|
260
260
|
...data,
|
|
261
|
-
refresh: () =>
|
|
261
|
+
refresh: () => {
|
|
262
|
+
results.map((r) => r.refresh());
|
|
263
|
+
},
|
|
262
264
|
};
|
|
263
265
|
}
|
|
@@ -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
|
|
|
@@ -12,7 +12,7 @@ export const useAggregatorsRouterFeeBps = () => {
|
|
|
12
12
|
const { config } = parseBaseArgs({
|
|
13
13
|
chainId: publicClient.chain?.id,
|
|
14
14
|
});
|
|
15
|
-
|
|
15
|
+
return useSWRImmutable(
|
|
16
16
|
publicClient &&
|
|
17
17
|
config.bex.aggregatorsRouter &&
|
|
18
18
|
config.bex.aggregatorsRouter !== zeroAddress
|
|
@@ -27,9 +27,4 @@ export const useAggregatorsRouterFeeBps = () => {
|
|
|
27
27
|
return Number(fee);
|
|
28
28
|
},
|
|
29
29
|
);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...swrResponse,
|
|
33
|
-
refresh: swrResponse.mutate,
|
|
34
|
-
};
|
|
35
30
|
};
|
|
@@ -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";
|
|
@@ -18,21 +17,17 @@ export const useAllUserPools = (
|
|
|
18
17
|
query: GetPoolsQueryVariables,
|
|
19
18
|
options?: DefaultHookOptions,
|
|
20
19
|
) => {
|
|
21
|
-
|
|
20
|
+
return 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
|
-
|
|
32
|
-
return {
|
|
33
|
-
...swrResponse,
|
|
34
|
-
refresh: () => {
|
|
35
|
-
swrResponse.mutate();
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
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";
|
|
@@ -24,7 +24,7 @@ export function useApiPool({
|
|
|
24
24
|
poolId: Hex;
|
|
25
25
|
account?: Address;
|
|
26
26
|
}) {
|
|
27
|
-
|
|
27
|
+
return useSWR(
|
|
28
28
|
useApiPoolQueryKey({ poolId, account }),
|
|
29
29
|
async ([, poolId, account]): Promise<MinimalPoolFragment> => {
|
|
30
30
|
if (account && !isAddress(account)) {
|
|
@@ -43,11 +43,4 @@ export function useApiPool({
|
|
|
43
43
|
refreshInterval: POLLING.NORMAL,
|
|
44
44
|
},
|
|
45
45
|
);
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...res,
|
|
49
|
-
refresh: () => {
|
|
50
|
-
res.mutate();
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
1
|
+
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
2
2
|
|
|
3
3
|
import { getGlobalLiquidityAndSwapVolume } from "../../actions/dex/getGlobalLiquidityAndSwapVolume";
|
|
4
4
|
|
|
@@ -17,6 +17,5 @@ export const useGlobalLiquidityAndSwapVolume = () => {
|
|
|
17
17
|
response.data?.protocolMetricsAggregated.swapVolume24h,
|
|
18
18
|
),
|
|
19
19
|
},
|
|
20
|
-
refresh: () => response.mutate(),
|
|
21
20
|
};
|
|
22
21
|
};
|
|
@@ -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";
|
|
@@ -65,7 +65,7 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
65
65
|
data: poolData,
|
|
66
66
|
error,
|
|
67
67
|
isLoading,
|
|
68
|
-
mutate,
|
|
68
|
+
refresh: mutate,
|
|
69
69
|
} = useSWRImmutable(
|
|
70
70
|
// FIXME: why are we using useSWRImmutable when we fetch tokenSupply and swapFee?
|
|
71
71
|
publicClient ? QUERY_KEY : null,
|
|
@@ -145,7 +145,6 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
145
145
|
data: pool,
|
|
146
146
|
error,
|
|
147
147
|
isLoading: isLoading || isTokenInformationLoading || isTokenPricesLoading,
|
|
148
|
-
mutate,
|
|
149
|
-
refresh: () => mutate(),
|
|
148
|
+
refresh: mutate,
|
|
150
149
|
};
|
|
151
150
|
}
|
|
@@ -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";
|
|
@@ -29,7 +29,7 @@ export const usePollPoolCreationRelayerApproval = (
|
|
|
29
29
|
] as const)
|
|
30
30
|
: null;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return useSWR<boolean>(
|
|
33
33
|
QUERY_KEY,
|
|
34
34
|
async ([, account]) => {
|
|
35
35
|
assertPublicClient(publicClient);
|
|
@@ -44,12 +44,6 @@ export const usePollPoolCreationRelayerApproval = (
|
|
|
44
44
|
|
|
45
45
|
return approved;
|
|
46
46
|
},
|
|
47
|
-
{ ...options
|
|
47
|
+
{ ...options },
|
|
48
48
|
);
|
|
49
|
-
|
|
50
|
-
const refreshPoolCreationApproval = () => {
|
|
51
|
-
swrResponse.mutate();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return { ...swrResponse, refreshPoolCreationApproval };
|
|
55
49
|
};
|
|
@@ -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 {
|
|
@@ -25,7 +24,7 @@ export const usePoolHistoricalData = (
|
|
|
25
24
|
? (["usePoolHistoricalData", poolId] as const)
|
|
26
25
|
: null;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
return useSWR<
|
|
29
28
|
PoolHistoricalDataFragment[] | undefined,
|
|
30
29
|
any,
|
|
31
30
|
typeof QUERY_KEY
|
|
@@ -37,11 +36,6 @@ export const usePoolHistoricalData = (
|
|
|
37
36
|
chain: config.bex.chainName as GqlChain,
|
|
38
37
|
});
|
|
39
38
|
},
|
|
40
|
-
options
|
|
39
|
+
options,
|
|
41
40
|
);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...swrResponse,
|
|
45
|
-
refresh: () => void swrResponse.mutate(),
|
|
46
|
-
};
|
|
47
41
|
};
|
|
@@ -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";
|
|
@@ -28,7 +28,7 @@ export const usePools = (
|
|
|
28
28
|
const {
|
|
29
29
|
data: userPools,
|
|
30
30
|
isLoading: isUserPoolsLoading,
|
|
31
|
-
|
|
31
|
+
refresh: mutateUserPools,
|
|
32
32
|
} = useAllUserPools({
|
|
33
33
|
userAddress: account,
|
|
34
34
|
chain: query.chain,
|
|
@@ -37,7 +37,8 @@ export const usePools = (
|
|
|
37
37
|
const {
|
|
38
38
|
data: pools,
|
|
39
39
|
isLoading: isPoolsLoading,
|
|
40
|
-
|
|
40
|
+
refresh: 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
|
|
@@ -151,7 +151,7 @@ export function useBendZapSupply(
|
|
|
151
151
|
isCrossChain,
|
|
152
152
|
nativeFee,
|
|
153
153
|
refresh: () => {
|
|
154
|
-
swrResponse.
|
|
154
|
+
swrResponse.refresh();
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
}
|
|
@@ -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";
|
|
@@ -114,7 +114,7 @@ export function useEnsoSwapBundle({
|
|
|
114
114
|
return {
|
|
115
115
|
...swrResponse,
|
|
116
116
|
refresh: () => {
|
|
117
|
-
swrResponse.
|
|
117
|
+
swrResponse.refresh();
|
|
118
118
|
refreshBalances();
|
|
119
119
|
},
|
|
120
120
|
};
|
|
@@ -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
|
|
@@ -30,7 +29,7 @@ export function useEnsoUserTokensWithBalances(
|
|
|
30
29
|
] as const)
|
|
31
30
|
: null;
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
return useSWR(
|
|
34
33
|
QUERY_KEY,
|
|
35
34
|
async ([, fromAddress, chainId]): Promise<BalanceToken[]> =>
|
|
36
35
|
getEnsoUserTokensWithBalances({
|
|
@@ -43,12 +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
|
-
return {
|
|
51
|
-
...swrResponse,
|
|
52
|
-
refresh: () => swrResponse.mutate(),
|
|
53
|
-
};
|
|
54
48
|
}
|
|
@@ -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";
|