@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
package/dist/hooks/exports.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getAutoclaimedIncentives,
|
|
16
16
|
getAutoclaimedIncentivesTxHash,
|
|
17
17
|
getBgtAprSimulation,
|
|
18
|
+
getBgtIncentiveDistributorPaused,
|
|
18
19
|
getBlockTimestamp,
|
|
19
20
|
getChartData,
|
|
20
21
|
getCollateralWeights,
|
|
@@ -70,11 +71,11 @@ import {
|
|
|
70
71
|
getVaultValidators,
|
|
71
72
|
isBadCollateralAsset,
|
|
72
73
|
isBasketModeEnabled
|
|
73
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-VAA2FVPP.mjs";
|
|
74
75
|
import {
|
|
75
76
|
fetchBeep,
|
|
76
77
|
fetchRailwayBackend
|
|
77
|
-
} from "../chunk-
|
|
78
|
+
} from "../chunk-MRQGHXAN.mjs";
|
|
78
79
|
import "../chunk-3JJLQ2JX.mjs";
|
|
79
80
|
import "../chunk-CDK4YV3D.mjs";
|
|
80
81
|
import {
|
|
@@ -84,7 +85,12 @@ import {
|
|
|
84
85
|
useBlockTime,
|
|
85
86
|
useEnsoUserTokensWithBalances,
|
|
86
87
|
useHoneyConfig
|
|
87
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-SXUNCX5E.mjs";
|
|
89
|
+
import {
|
|
90
|
+
swr_default,
|
|
91
|
+
useSWR,
|
|
92
|
+
useSWRImmutable
|
|
93
|
+
} from "../chunk-UD5IUNCW.mjs";
|
|
88
94
|
import {
|
|
89
95
|
getEnsoClient,
|
|
90
96
|
getWalletBalances
|
|
@@ -113,6 +119,7 @@ import {
|
|
|
113
119
|
import {
|
|
114
120
|
DEFAULT_METAMASK_GAS_LIMIT,
|
|
115
121
|
bignumber_js_default,
|
|
122
|
+
calculateTimestampFromDays,
|
|
116
123
|
getPythDefaultUpdateFee,
|
|
117
124
|
msToSeconds,
|
|
118
125
|
seconds
|
|
@@ -139,7 +146,6 @@ import {
|
|
|
139
146
|
} from "../chunk-KHXJDYA4.mjs";
|
|
140
147
|
|
|
141
148
|
// src/hooks/bend/useGetConvertToAssets.ts
|
|
142
|
-
import useSWR from "swr";
|
|
143
149
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
144
150
|
var useGetConvertToAssets = ({
|
|
145
151
|
sharesAmount,
|
|
@@ -158,7 +164,7 @@ var useGetConvertToAssets = ({
|
|
|
158
164
|
});
|
|
159
165
|
},
|
|
160
166
|
{
|
|
161
|
-
...options
|
|
167
|
+
...options
|
|
162
168
|
}
|
|
163
169
|
);
|
|
164
170
|
return {
|
|
@@ -1386,7 +1392,6 @@ var WBeraAggregator = class extends BaseAggregator {
|
|
|
1386
1392
|
var wberaSwap = new WBeraAggregator();
|
|
1387
1393
|
|
|
1388
1394
|
// src/hooks/tokens/useUnderlyingAsset.ts
|
|
1389
|
-
import useSWRImmutable from "swr/immutable";
|
|
1390
1395
|
import { useConfig } from "@berachain/wagmi/hooks";
|
|
1391
1396
|
|
|
1392
1397
|
// src/actions/tokens/getUnderlyingToken.ts
|
|
@@ -1433,7 +1438,6 @@ function useUnderlyingAsset({ token }) {
|
|
|
1433
1438
|
}
|
|
1434
1439
|
|
|
1435
1440
|
// src/hooks/dex/useAggregatorsRouterFeeBps.ts
|
|
1436
|
-
import useSWRImmutable2 from "swr/immutable";
|
|
1437
1441
|
import { zeroAddress as zeroAddress8 } from "viem";
|
|
1438
1442
|
import aggregatorsRouterAbi7 from "@berachain/abis/meta-aggregator/metaAggregatorV2";
|
|
1439
1443
|
import { usePublicClient as usePublicClient2 } from "@berachain/wagmi/hooks";
|
|
@@ -1442,7 +1446,7 @@ var useAggregatorsRouterFeeBps = () => {
|
|
|
1442
1446
|
const { config } = parseBaseArgs({
|
|
1443
1447
|
chainId: publicClient.chain?.id
|
|
1444
1448
|
});
|
|
1445
|
-
const swrResponse =
|
|
1449
|
+
const swrResponse = useSWRImmutable(
|
|
1446
1450
|
publicClient && config.bex.aggregatorsRouter && config.bex.aggregatorsRouter !== zeroAddress8 ? ["useAggregatorsRouterFeeBps", config.bex.aggregatorsRouter] : null,
|
|
1447
1451
|
async ([, aggregatorsRouter]) => {
|
|
1448
1452
|
const fee = await publicClient.readContract({
|
|
@@ -1460,7 +1464,6 @@ var useAggregatorsRouterFeeBps = () => {
|
|
|
1460
1464
|
};
|
|
1461
1465
|
|
|
1462
1466
|
// src/hooks/dex/useSingleAggregatorQuote.ts
|
|
1463
|
-
import useSWR2 from "swr";
|
|
1464
1467
|
import { parseUnits as parseUnits2, zeroAddress as zeroAddress9 } from "viem";
|
|
1465
1468
|
import { useBeraWallet, usePublicClient as usePublicClient3 } from "@berachain/wagmi/hooks";
|
|
1466
1469
|
var USE_AGGREGATORS_QUOTES_QUERY_KEY = "useAggregatorsQuotes";
|
|
@@ -1469,13 +1472,9 @@ function getQueryKey({
|
|
|
1469
1472
|
account,
|
|
1470
1473
|
args,
|
|
1471
1474
|
feeBps,
|
|
1472
|
-
options,
|
|
1473
1475
|
activeAggregators,
|
|
1474
1476
|
isMAEnabled
|
|
1475
1477
|
}) {
|
|
1476
|
-
if (options?.opts?.isEnabled !== void 0 && !options?.opts?.isEnabled) {
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
1478
|
if (!Number(args.amount)) {
|
|
1480
1479
|
return null;
|
|
1481
1480
|
}
|
|
@@ -1573,13 +1572,12 @@ function raw_useSingleAggregatorQuote({
|
|
|
1573
1572
|
isMAEnabled,
|
|
1574
1573
|
...args
|
|
1575
1574
|
}, options) {
|
|
1576
|
-
return
|
|
1575
|
+
return useSWR(
|
|
1577
1576
|
getQueryKey({
|
|
1578
1577
|
aggregator: args.aggregator,
|
|
1579
1578
|
account,
|
|
1580
1579
|
args,
|
|
1581
1580
|
feeBps,
|
|
1582
|
-
options,
|
|
1583
1581
|
activeAggregators,
|
|
1584
1582
|
isMAEnabled
|
|
1585
1583
|
}),
|
|
@@ -1588,7 +1586,7 @@ function raw_useSingleAggregatorQuote({
|
|
|
1588
1586
|
proxyAggregatorsThroughVercel,
|
|
1589
1587
|
publicClient
|
|
1590
1588
|
}),
|
|
1591
|
-
options
|
|
1589
|
+
options
|
|
1592
1590
|
);
|
|
1593
1591
|
}
|
|
1594
1592
|
function getAggregatorsSWROptions(options) {
|
|
@@ -1596,16 +1594,10 @@ function getAggregatorsSWROptions(options) {
|
|
|
1596
1594
|
refreshInterval: 1e4 /* FAST */,
|
|
1597
1595
|
// every 10s
|
|
1598
1596
|
errorRetryCount: 3,
|
|
1599
|
-
...options
|
|
1597
|
+
...options,
|
|
1600
1598
|
// biome-ignore lint/nursery/useMaxParams: the function is defined in the SWRConfiguration type
|
|
1601
1599
|
onErrorRetry(err, key, config, revalidate, revalidateOpts) {
|
|
1602
|
-
options?.
|
|
1603
|
-
err,
|
|
1604
|
-
key,
|
|
1605
|
-
config,
|
|
1606
|
-
revalidate,
|
|
1607
|
-
revalidateOpts
|
|
1608
|
-
);
|
|
1600
|
+
options?.onErrorRetry?.(err, key, config, revalidate, revalidateOpts);
|
|
1609
1601
|
if (err instanceof BeraError) {
|
|
1610
1602
|
if (err.reason === BaseAggregator.PATH_NOT_FOUND_REASON) {
|
|
1611
1603
|
return;
|
|
@@ -1651,7 +1643,7 @@ function useSingleAggregatorQuote(args, options) {
|
|
|
1651
1643
|
publicClient,
|
|
1652
1644
|
proxyAggregatorsThroughVercel
|
|
1653
1645
|
},
|
|
1654
|
-
|
|
1646
|
+
getAggregatorsSWROptions(options)
|
|
1655
1647
|
);
|
|
1656
1648
|
}
|
|
1657
1649
|
|
|
@@ -1702,7 +1694,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1702
1694
|
...args,
|
|
1703
1695
|
aggregator: oogabooga
|
|
1704
1696
|
},
|
|
1705
|
-
|
|
1697
|
+
swrOptions
|
|
1706
1698
|
);
|
|
1707
1699
|
const flyResult = raw_useSingleAggregatorQuote(
|
|
1708
1700
|
{
|
|
@@ -1710,7 +1702,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1710
1702
|
...args,
|
|
1711
1703
|
aggregator: fly
|
|
1712
1704
|
},
|
|
1713
|
-
|
|
1705
|
+
swrOptions
|
|
1714
1706
|
);
|
|
1715
1707
|
const erc4626Result = raw_useSingleAggregatorQuote(
|
|
1716
1708
|
{
|
|
@@ -1718,7 +1710,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1718
1710
|
...args,
|
|
1719
1711
|
aggregator: erc4626Deposit
|
|
1720
1712
|
},
|
|
1721
|
-
|
|
1713
|
+
swrOptions
|
|
1722
1714
|
);
|
|
1723
1715
|
const kyberswapResult = raw_useSingleAggregatorQuote(
|
|
1724
1716
|
{
|
|
@@ -1726,7 +1718,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1726
1718
|
...args,
|
|
1727
1719
|
aggregator: kyberswap
|
|
1728
1720
|
},
|
|
1729
|
-
|
|
1721
|
+
swrOptions
|
|
1730
1722
|
);
|
|
1731
1723
|
const openOceanResult = raw_useSingleAggregatorQuote(
|
|
1732
1724
|
{
|
|
@@ -1734,7 +1726,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1734
1726
|
...args,
|
|
1735
1727
|
aggregator: openOcean
|
|
1736
1728
|
},
|
|
1737
|
-
|
|
1729
|
+
swrOptions
|
|
1738
1730
|
);
|
|
1739
1731
|
const haikuResult = raw_useSingleAggregatorQuote(
|
|
1740
1732
|
{
|
|
@@ -1742,7 +1734,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1742
1734
|
...args,
|
|
1743
1735
|
aggregator: haiku
|
|
1744
1736
|
},
|
|
1745
|
-
|
|
1737
|
+
swrOptions
|
|
1746
1738
|
);
|
|
1747
1739
|
const ensoResult = raw_useSingleAggregatorQuote(
|
|
1748
1740
|
{
|
|
@@ -1750,7 +1742,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1750
1742
|
...args,
|
|
1751
1743
|
aggregator: enso
|
|
1752
1744
|
},
|
|
1753
|
-
|
|
1745
|
+
swrOptions
|
|
1754
1746
|
);
|
|
1755
1747
|
const { protocol: bexProtocol } = useBexStatus();
|
|
1756
1748
|
const bexResult = raw_useSingleAggregatorQuote(
|
|
@@ -1759,7 +1751,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1759
1751
|
...args,
|
|
1760
1752
|
aggregator: bex
|
|
1761
1753
|
},
|
|
1762
|
-
{
|
|
1754
|
+
{ ...swrOptions, isEnabled: bexProtocol.isPaused === false }
|
|
1763
1755
|
);
|
|
1764
1756
|
const wberaSwapResult = raw_useSingleAggregatorQuote({
|
|
1765
1757
|
...sharedArgs,
|
|
@@ -1772,7 +1764,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1772
1764
|
...args,
|
|
1773
1765
|
aggregator: bgtRedeem
|
|
1774
1766
|
},
|
|
1775
|
-
|
|
1767
|
+
swrOptions
|
|
1776
1768
|
);
|
|
1777
1769
|
const honeyResult = raw_useSingleAggregatorQuote(
|
|
1778
1770
|
{
|
|
@@ -1780,7 +1772,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1780
1772
|
...args,
|
|
1781
1773
|
aggregator: honeyNative
|
|
1782
1774
|
},
|
|
1783
|
-
|
|
1775
|
+
swrOptions
|
|
1784
1776
|
);
|
|
1785
1777
|
const results = isWrapOrUnwrap ? [wberaSwapResult] : isBgtRedeem ? [bgtRedeemResult] : [
|
|
1786
1778
|
oogaBogaResult,
|
|
@@ -1814,21 +1806,23 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1814
1806
|
}
|
|
1815
1807
|
|
|
1816
1808
|
// src/hooks/dex/useAllUserPools.ts
|
|
1817
|
-
import useSWR3 from "swr";
|
|
1818
1809
|
var useAllUserPoolsQueryKey = ({
|
|
1819
1810
|
query
|
|
1820
1811
|
} = {}) => {
|
|
1821
1812
|
return ["useAllUserPools", query];
|
|
1822
1813
|
};
|
|
1823
1814
|
var useAllUserPools = (query, options) => {
|
|
1824
|
-
const swrResponse =
|
|
1815
|
+
const swrResponse = useSWR(
|
|
1825
1816
|
useAllUserPoolsQueryKey({ query }),
|
|
1826
1817
|
async ([_, params]) => {
|
|
1827
|
-
return getAllPools({
|
|
1818
|
+
return getAllPools({
|
|
1819
|
+
...params,
|
|
1820
|
+
fetchPolicy: "no-cache"
|
|
1821
|
+
});
|
|
1828
1822
|
},
|
|
1829
1823
|
{
|
|
1830
1824
|
refreshInterval: 18e4 /* SLOW */,
|
|
1831
|
-
...options
|
|
1825
|
+
...options
|
|
1832
1826
|
}
|
|
1833
1827
|
);
|
|
1834
1828
|
return {
|
|
@@ -1840,7 +1834,6 @@ var useAllUserPools = (query, options) => {
|
|
|
1840
1834
|
};
|
|
1841
1835
|
|
|
1842
1836
|
// src/hooks/dex/useApiPool.ts
|
|
1843
|
-
import useSWR4 from "swr";
|
|
1844
1837
|
import { isAddress } from "viem";
|
|
1845
1838
|
var useApiPoolQueryKey = ({
|
|
1846
1839
|
poolId,
|
|
@@ -1852,7 +1845,7 @@ function useApiPool({
|
|
|
1852
1845
|
poolId,
|
|
1853
1846
|
account
|
|
1854
1847
|
}) {
|
|
1855
|
-
const res =
|
|
1848
|
+
const res = useSWR(
|
|
1856
1849
|
useApiPoolQueryKey({ poolId, account }),
|
|
1857
1850
|
async ([, poolId2, account2]) => {
|
|
1858
1851
|
if (account2 && !isAddress(account2)) {
|
|
@@ -2157,9 +2150,8 @@ var useCreatePool = ({
|
|
|
2157
2150
|
};
|
|
2158
2151
|
|
|
2159
2152
|
// src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts
|
|
2160
|
-
import useSWR5 from "swr";
|
|
2161
2153
|
var useGlobalLiquidityAndSwapVolume = () => {
|
|
2162
|
-
const response =
|
|
2154
|
+
const response = useSWR(
|
|
2163
2155
|
"useGlobalLiquidityAndSwapVolume",
|
|
2164
2156
|
async () => getGlobalLiquidityAndSwapVolume()
|
|
2165
2157
|
);
|
|
@@ -2287,13 +2279,11 @@ var useLiquidityMismatch = ({
|
|
|
2287
2279
|
import { formatEther as formatEther3, isAddressEqual } from "viem";
|
|
2288
2280
|
|
|
2289
2281
|
// src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts
|
|
2290
|
-
import useSWR6 from "swr";
|
|
2291
2282
|
import { isAddress as isAddress3, zeroAddress as zeroAddress13 } from "viem";
|
|
2292
2283
|
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
2293
2284
|
import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
|
|
2294
2285
|
|
|
2295
2286
|
// src/hooks/pol/useRewardVaultFromToken.ts
|
|
2296
|
-
import useSWRImmutable3 from "swr/immutable";
|
|
2297
2287
|
import { isAddress as isAddress2, zeroAddress as zeroAddress12 } from "viem";
|
|
2298
2288
|
import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
|
|
2299
2289
|
import { usePublicClient as usePublicClient5 } from "@berachain/wagmi/hooks";
|
|
@@ -2304,7 +2294,7 @@ var useRewardVaultFromToken = ({
|
|
|
2304
2294
|
} = {}) => {
|
|
2305
2295
|
const publicClient = usePublicClient5();
|
|
2306
2296
|
const QUERY_KEY = publicClient && tokenAddress && isAddress2(tokenAddress) && isEnabled ? ["useRewardVaultFromToken", tokenAddress] : null;
|
|
2307
|
-
const swrResponse =
|
|
2297
|
+
const swrResponse = useSWRImmutable(QUERY_KEY, async ([, tokenAddress2]) => {
|
|
2308
2298
|
if (!tokenAddress2) {
|
|
2309
2299
|
throw new Error("useRewardVaultFromToken needs a valid token address");
|
|
2310
2300
|
}
|
|
@@ -2333,7 +2323,7 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2333
2323
|
}, options) => {
|
|
2334
2324
|
const { address: account } = useBeraWallet3();
|
|
2335
2325
|
const publicClient = usePublicClient6();
|
|
2336
|
-
const isEnabled = options?.
|
|
2326
|
+
const isEnabled = options?.isEnabled ?? true;
|
|
2337
2327
|
const {
|
|
2338
2328
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
2339
2329
|
error,
|
|
@@ -2347,8 +2337,8 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2347
2337
|
isEnabled: !_rewardVaultAddress && isEnabled
|
|
2348
2338
|
}
|
|
2349
2339
|
);
|
|
2350
|
-
const swrResponse =
|
|
2351
|
-
rewardVaultAddress && account && publicClient && isAddress3(rewardVaultAddress) && isAddress3(account)
|
|
2340
|
+
const swrResponse = useSWR(
|
|
2341
|
+
rewardVaultAddress && account && publicClient && isAddress3(rewardVaultAddress) && isAddress3(account) ? ["useVaultBalanceFromStakingToken", rewardVaultAddress, account] : null,
|
|
2352
2342
|
async ([, rewardVaultAddress2, account2]) => {
|
|
2353
2343
|
assertPublicClient(publicClient);
|
|
2354
2344
|
if (rewardVaultAddress2 === zeroAddress13) {
|
|
@@ -2367,7 +2357,8 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2367
2357
|
address: rewardVaultAddress2,
|
|
2368
2358
|
balance
|
|
2369
2359
|
};
|
|
2370
|
-
}
|
|
2360
|
+
},
|
|
2361
|
+
options
|
|
2371
2362
|
);
|
|
2372
2363
|
return {
|
|
2373
2364
|
...swrResponse,
|
|
@@ -2380,7 +2371,6 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2380
2371
|
};
|
|
2381
2372
|
|
|
2382
2373
|
// src/hooks/tokens/usePollBalance.ts
|
|
2383
|
-
import useSWR7 from "swr";
|
|
2384
2374
|
import {
|
|
2385
2375
|
erc20Abi,
|
|
2386
2376
|
formatEther as formatEther2,
|
|
@@ -2392,7 +2382,6 @@ import { defaultChainId as defaultChainId3 } from "@berachain/config/internal";
|
|
|
2392
2382
|
import { useBeraWallet as useBeraWallet4, usePublicClient as usePublicClient8 } from "@berachain/wagmi/hooks";
|
|
2393
2383
|
|
|
2394
2384
|
// src/hooks/tokens/useTokenInformation.ts
|
|
2395
|
-
import useSWRImmutable4 from "swr/immutable";
|
|
2396
2385
|
import { isAddress as isAddress4, zeroAddress as zeroAddress14 } from "viem";
|
|
2397
2386
|
import { defaultChainId as defaultChainId2 } from "@berachain/config/internal";
|
|
2398
2387
|
import { usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
@@ -2401,7 +2390,7 @@ function useTokenInformation(args, options) {
|
|
|
2401
2390
|
chainId: args.chainId
|
|
2402
2391
|
});
|
|
2403
2392
|
const QUERY_KEY = args?.address && publicClient && isAddress4(args.address) ? ["useTokenInformation", args.address, args.chainId] : null;
|
|
2404
|
-
const swrResponse =
|
|
2393
|
+
const swrResponse = useSWRImmutable(
|
|
2405
2394
|
QUERY_KEY,
|
|
2406
2395
|
async ([_, address, chainId2 = defaultChainId2]) => {
|
|
2407
2396
|
if (isToken(address, "BERA")) {
|
|
@@ -2420,7 +2409,7 @@ function useTokenInformation(args, options) {
|
|
|
2420
2409
|
chainId: chainId2
|
|
2421
2410
|
});
|
|
2422
2411
|
},
|
|
2423
|
-
{ ...options
|
|
2412
|
+
{ ...options }
|
|
2424
2413
|
);
|
|
2425
2414
|
return {
|
|
2426
2415
|
...swrResponse,
|
|
@@ -2441,10 +2430,10 @@ function usePollBalance({
|
|
|
2441
2430
|
const publicClient = usePublicClient8({ chainId: chainId2 });
|
|
2442
2431
|
const { address: account } = useBeraWallet4();
|
|
2443
2432
|
const assetOwner = owner ?? account;
|
|
2444
|
-
const QUERY_KEY =
|
|
2433
|
+
const QUERY_KEY = publicClient && assetOwner && isAddress5(assetOwner) && address && isAddress5(address) ? ["usePollBalance", assetOwner, address, chainId2] : null;
|
|
2445
2434
|
const { data: tokenInformation, isLoading: isLoadingTokenInformation } = useTokenInformation({ address, chainId: chainId2 });
|
|
2446
2435
|
const isNativeToken = isToken(address, "BERA");
|
|
2447
|
-
const { isLoading, data, error, ...rest } =
|
|
2436
|
+
const { isLoading, data, error, ...rest } = useSWR(
|
|
2448
2437
|
QUERY_KEY,
|
|
2449
2438
|
async ([, assetOwner2, address2]) => {
|
|
2450
2439
|
assertPublicClient(publicClient);
|
|
@@ -2461,7 +2450,8 @@ function usePollBalance({
|
|
|
2461
2450
|
});
|
|
2462
2451
|
},
|
|
2463
2452
|
{
|
|
2464
|
-
refreshInterval: 1e4 /* FAST
|
|
2453
|
+
refreshInterval: 1e4 /* FAST */,
|
|
2454
|
+
...options
|
|
2465
2455
|
}
|
|
2466
2456
|
);
|
|
2467
2457
|
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ? formatUnits5(data, tokenInformation.decimals) : void 0 : void 0;
|
|
@@ -2554,13 +2544,12 @@ import { useMemo as useMemo3 } from "react";
|
|
|
2554
2544
|
import { parseUnits as parseUnits4, zeroAddress as zeroAddress16 } from "viem";
|
|
2555
2545
|
|
|
2556
2546
|
// src/hooks/tokens/usePollAllowances.ts
|
|
2557
|
-
import useSWR8 from "swr";
|
|
2558
2547
|
import { useBeraWallet as useBeraWallet5, useConfig as useConfig2 } from "@berachain/wagmi/hooks";
|
|
2559
2548
|
function usePollAllowances(args, options) {
|
|
2560
2549
|
const config = useConfig2();
|
|
2561
2550
|
const { address: account } = useBeraWallet5();
|
|
2562
2551
|
const QUERY_KEY = config && account && args?.items ? ["usePollAllowances", account, args?.items] : null;
|
|
2563
|
-
const swrResponse =
|
|
2552
|
+
const swrResponse = useSWR(
|
|
2564
2553
|
QUERY_KEY,
|
|
2565
2554
|
async ([, account2, items]) => {
|
|
2566
2555
|
return getAllowances({
|
|
@@ -2570,8 +2559,8 @@ function usePollAllowances(args, options) {
|
|
|
2570
2559
|
});
|
|
2571
2560
|
},
|
|
2572
2561
|
{
|
|
2573
|
-
...options
|
|
2574
|
-
refreshInterval: options?.
|
|
2562
|
+
...options,
|
|
2563
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
2575
2564
|
}
|
|
2576
2565
|
);
|
|
2577
2566
|
return {
|
|
@@ -2645,12 +2634,10 @@ function useMultipleTokenApprovalsWithSlippage(tokenInput, options) {
|
|
|
2645
2634
|
|
|
2646
2635
|
// src/hooks/dex/useOnChainPoolData.ts
|
|
2647
2636
|
import { useMemo as useMemo5 } from "react";
|
|
2648
|
-
import useSWRImmutable6 from "swr/immutable";
|
|
2649
2637
|
import { formatUnits as formatUnits6, isAddress as isAddress8 } from "viem";
|
|
2650
2638
|
import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
|
|
2651
2639
|
|
|
2652
2640
|
// src/hooks/tokens/useMultipleTokenInformation.ts
|
|
2653
|
-
import useSWRImmutable5 from "swr/immutable";
|
|
2654
2641
|
import { isAddress as isAddress6 } from "viem";
|
|
2655
2642
|
import { defaultChainId as defaultChainId4 } from "@berachain/config/internal";
|
|
2656
2643
|
import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
|
|
@@ -2661,7 +2648,7 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2661
2648
|
args.addresses,
|
|
2662
2649
|
args.chainId ?? defaultChainId4
|
|
2663
2650
|
] : null;
|
|
2664
|
-
const swrResponse =
|
|
2651
|
+
const swrResponse = useSWRImmutable(
|
|
2665
2652
|
QUERY_KEY,
|
|
2666
2653
|
async ([, addresses, chainId2]) => {
|
|
2667
2654
|
assertPublicClient(publicClient);
|
|
@@ -2682,7 +2669,7 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2682
2669
|
})
|
|
2683
2670
|
);
|
|
2684
2671
|
},
|
|
2685
|
-
{ ...options
|
|
2672
|
+
{ ...options }
|
|
2686
2673
|
);
|
|
2687
2674
|
return {
|
|
2688
2675
|
...swrResponse,
|
|
@@ -2692,7 +2679,6 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2692
2679
|
|
|
2693
2680
|
// src/hooks/tokens/useTokenCurrentPrices.ts
|
|
2694
2681
|
import { useMemo as useMemo4 } from "react";
|
|
2695
|
-
import useSWR9 from "swr";
|
|
2696
2682
|
import { isAddress as isAddress7, zeroAddress as zeroAddress17 } from "viem";
|
|
2697
2683
|
import { defaultChainId as defaultChainId5 } from "@berachain/config/internal";
|
|
2698
2684
|
|
|
@@ -2723,10 +2709,8 @@ function useTokens() {
|
|
|
2723
2709
|
function useTokenCurrentPrices({
|
|
2724
2710
|
addressIn
|
|
2725
2711
|
} = {}, options = {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
revalidateOnFocus: true
|
|
2729
|
-
}
|
|
2712
|
+
refreshInterval: 1e5 /* NORMAL */,
|
|
2713
|
+
revalidateOnFocus: true
|
|
2730
2714
|
}) {
|
|
2731
2715
|
const { tokenList, ensoTokens } = useTokens();
|
|
2732
2716
|
const beraAddresses = useMemo4(() => {
|
|
@@ -2748,16 +2732,16 @@ function useTokenCurrentPrices({
|
|
|
2748
2732
|
return beraAddresses?.some((a) => !tokenSet.has(a));
|
|
2749
2733
|
}, [beraAddresses, tokenList]);
|
|
2750
2734
|
const addresses = hasAddressesNotInTokenList ? beraAddresses : tokenList.map((token) => token.address);
|
|
2751
|
-
const QUERY_KEY = addresses
|
|
2735
|
+
const QUERY_KEY = addresses ? [
|
|
2752
2736
|
"useTokenCurrentPrices",
|
|
2753
2737
|
addresses.map((a) => a.toLowerCase())
|
|
2754
2738
|
] : null;
|
|
2755
|
-
const apiResponse =
|
|
2739
|
+
const apiResponse = useSWR(
|
|
2756
2740
|
QUERY_KEY,
|
|
2757
2741
|
async ([, addresses2]) => {
|
|
2758
2742
|
return getTokenCurrentPrices({ addressIn: addresses2 });
|
|
2759
2743
|
},
|
|
2760
|
-
options
|
|
2744
|
+
options
|
|
2761
2745
|
);
|
|
2762
2746
|
const ensoMatchingPrices = useMemo4(() => {
|
|
2763
2747
|
if (!ensoTokens) return {};
|
|
@@ -2818,7 +2802,7 @@ function useOnChainPoolData(poolId) {
|
|
|
2818
2802
|
error,
|
|
2819
2803
|
isLoading,
|
|
2820
2804
|
mutate
|
|
2821
|
-
} =
|
|
2805
|
+
} = useSWRImmutable(
|
|
2822
2806
|
// FIXME: why are we using useSWRImmutable when we fetch tokenSupply and swapFee?
|
|
2823
2807
|
publicClient ? QUERY_KEY : null,
|
|
2824
2808
|
async ([, poolId2]) => {
|
|
@@ -2892,7 +2876,6 @@ function useOnChainPoolData(poolId) {
|
|
|
2892
2876
|
}
|
|
2893
2877
|
|
|
2894
2878
|
// src/hooks/dex/usePollPoolCreationRelayerApproval.ts
|
|
2895
|
-
import useSWR10 from "swr";
|
|
2896
2879
|
import { vaultAbi as balancerVaultAbi2 } from "@berachain/abis/bex/vault";
|
|
2897
2880
|
import { useBeraWallet as useBeraWallet6, usePublicClient as usePublicClient11 } from "@berachain/wagmi/hooks";
|
|
2898
2881
|
var usePollPoolCreationRelayerApproval = (options) => {
|
|
@@ -2903,7 +2886,7 @@ var usePollPoolCreationRelayerApproval = (options) => {
|
|
|
2903
2886
|
account,
|
|
2904
2887
|
publicClient.chain.id
|
|
2905
2888
|
] : null;
|
|
2906
|
-
const swrResponse =
|
|
2889
|
+
const swrResponse = useSWR(
|
|
2907
2890
|
QUERY_KEY,
|
|
2908
2891
|
async ([, account2]) => {
|
|
2909
2892
|
assertPublicClient(publicClient);
|
|
@@ -2916,7 +2899,7 @@ var usePollPoolCreationRelayerApproval = (options) => {
|
|
|
2916
2899
|
});
|
|
2917
2900
|
return approved;
|
|
2918
2901
|
},
|
|
2919
|
-
{ ...options
|
|
2902
|
+
{ ...options }
|
|
2920
2903
|
);
|
|
2921
2904
|
const refreshPoolCreationApproval = () => {
|
|
2922
2905
|
swrResponse.mutate();
|
|
@@ -2945,12 +2928,11 @@ function usePool({ poolId }) {
|
|
|
2945
2928
|
}
|
|
2946
2929
|
|
|
2947
2930
|
// src/hooks/dex/usePoolEvents.ts
|
|
2948
|
-
import useSWRImmutable7 from "swr/immutable";
|
|
2949
2931
|
var usePoolEvents = ({
|
|
2950
2932
|
poolId,
|
|
2951
2933
|
typeInArray
|
|
2952
2934
|
}) => {
|
|
2953
|
-
return
|
|
2935
|
+
return useSWRImmutable(
|
|
2954
2936
|
poolId ? ["usePoolEvents", poolId, typeInArray] : null,
|
|
2955
2937
|
async ([, poolId2, typeInArray2]) => getPoolEvents({ poolId: poolId2, typeInArray: typeInArray2 }),
|
|
2956
2938
|
{
|
|
@@ -2960,11 +2942,10 @@ var usePoolEvents = ({
|
|
|
2960
2942
|
};
|
|
2961
2943
|
|
|
2962
2944
|
// src/hooks/dex/usePoolHistoricalData.ts
|
|
2963
|
-
import useSWR11 from "swr";
|
|
2964
2945
|
var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
2965
2946
|
const { config } = parseBaseArgs(baseArgs);
|
|
2966
2947
|
const QUERY_KEY = poolId ? ["usePoolHistoricalData", poolId] : null;
|
|
2967
|
-
const swrResponse =
|
|
2948
|
+
const swrResponse = useSWR(
|
|
2968
2949
|
QUERY_KEY,
|
|
2969
2950
|
async ([, poolId2]) => {
|
|
2970
2951
|
return getPoolHistoricalData({
|
|
@@ -2972,7 +2953,7 @@ var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
|
2972
2953
|
chain: config.bex.chainName
|
|
2973
2954
|
});
|
|
2974
2955
|
},
|
|
2975
|
-
options
|
|
2956
|
+
options
|
|
2976
2957
|
);
|
|
2977
2958
|
return {
|
|
2978
2959
|
...swrResponse,
|
|
@@ -2982,7 +2963,6 @@ var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
|
2982
2963
|
|
|
2983
2964
|
// src/hooks/dex/usePools.ts
|
|
2984
2965
|
import { useMemo as useMemo6 } from "react";
|
|
2985
|
-
import useSWR12 from "swr";
|
|
2986
2966
|
import { useBeraWallet as useBeraWallet7 } from "@berachain/wagmi/hooks";
|
|
2987
2967
|
var usePoolsQueryKey = ({
|
|
2988
2968
|
query
|
|
@@ -3002,15 +2982,16 @@ var usePools = (query, options) => {
|
|
|
3002
2982
|
const {
|
|
3003
2983
|
data: pools,
|
|
3004
2984
|
isLoading: isPoolsLoading,
|
|
3005
|
-
mutate: mutatePools
|
|
3006
|
-
|
|
2985
|
+
mutate: mutatePools,
|
|
2986
|
+
error: poolsError
|
|
2987
|
+
} = useSWR(
|
|
3007
2988
|
usePoolsQueryKey({ query }),
|
|
3008
2989
|
async ([_, query2]) => {
|
|
3009
2990
|
return getAllPools(query2);
|
|
3010
2991
|
},
|
|
3011
2992
|
{
|
|
3012
2993
|
refreshInterval: 18e4 /* SLOW */,
|
|
3013
|
-
...options
|
|
2994
|
+
...options
|
|
3014
2995
|
}
|
|
3015
2996
|
);
|
|
3016
2997
|
const mergedPools = useMemo6(() => {
|
|
@@ -3034,6 +3015,7 @@ var usePools = (query, options) => {
|
|
|
3034
3015
|
pools: mergedPools ?? [],
|
|
3035
3016
|
walletPools: pools?.pools ?? [],
|
|
3036
3017
|
isLoading: isPoolsLoading || isUserPoolsLoading,
|
|
3018
|
+
error: poolsError,
|
|
3037
3019
|
refresh: () => {
|
|
3038
3020
|
mutatePools();
|
|
3039
3021
|
mutateUserPools();
|
|
@@ -3051,10 +3033,8 @@ import { defaultChainId as defaultChainId6 } from "@berachain/config/internal";
|
|
|
3051
3033
|
function useTokenPrices({
|
|
3052
3034
|
tokens
|
|
3053
3035
|
} = {}, options = {
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
revalidateOnFocus: true
|
|
3057
|
-
}
|
|
3036
|
+
refreshInterval: 1e5 /* NORMAL */,
|
|
3037
|
+
revalidateOnFocus: true
|
|
3058
3038
|
}) {
|
|
3059
3039
|
const { ensoTokens } = useTokens();
|
|
3060
3040
|
const apiResponse = useTokenCurrentPrices(
|
|
@@ -3125,6 +3105,7 @@ function useTokenPrices({
|
|
|
3125
3105
|
);
|
|
3126
3106
|
return {
|
|
3127
3107
|
isLoading: apiResponse.isLoading,
|
|
3108
|
+
error: apiResponse.error,
|
|
3128
3109
|
data,
|
|
3129
3110
|
priceMap,
|
|
3130
3111
|
getTokenPrice
|
|
@@ -3168,7 +3149,6 @@ function usePriceImpact({
|
|
|
3168
3149
|
}
|
|
3169
3150
|
|
|
3170
3151
|
// src/hooks/enso/useBendDemultiply.ts
|
|
3171
|
-
import useSWR15 from "swr";
|
|
3172
3152
|
import { parseUnits as parseUnits5 } from "viem";
|
|
3173
3153
|
import { defaultChainId as defaultChainId7 } from "@berachain/config/internal";
|
|
3174
3154
|
import {
|
|
@@ -3605,7 +3585,6 @@ async function getBendDemultiplyBundle({
|
|
|
3605
3585
|
}
|
|
3606
3586
|
|
|
3607
3587
|
// src/hooks/enso/useEnsoWalletV2Address.ts
|
|
3608
|
-
import useSWR13 from "swr";
|
|
3609
3588
|
import { getAddress as getAddress3 } from "viem";
|
|
3610
3589
|
import { useBeraWallet as useBeraWallet8, usePublicClient as usePublicClient12 } from "@berachain/wagmi/hooks";
|
|
3611
3590
|
function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
@@ -3614,7 +3593,7 @@ function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
|
3614
3593
|
const { config } = parseBaseArgs({});
|
|
3615
3594
|
const ensoWalletV2Factory = config.enso.walletV2Factory;
|
|
3616
3595
|
const QUERY_KEY = fromAddress && ensoWalletV2Factory ? ["useEnsoWalletV2Address", fromAddress, ensoWalletV2Factory] : null;
|
|
3617
|
-
return
|
|
3596
|
+
return useSWR(
|
|
3618
3597
|
QUERY_KEY,
|
|
3619
3598
|
async ([_, accountAddress, factory]) => {
|
|
3620
3599
|
assertPublicClient(publicClient);
|
|
@@ -3629,7 +3608,6 @@ function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
|
3629
3608
|
}
|
|
3630
3609
|
|
|
3631
3610
|
// src/hooks/enso/useIsBendAuthorized.ts
|
|
3632
|
-
import useSWR14 from "swr";
|
|
3633
3611
|
import { useBeraWallet as useBeraWallet9, usePublicClient as usePublicClient13 } from "@berachain/wagmi/hooks";
|
|
3634
3612
|
function useIsBendAuthorized({
|
|
3635
3613
|
chainId: chainId2,
|
|
@@ -3644,7 +3622,7 @@ function useIsBendAuthorized({
|
|
|
3644
3622
|
primaryAddress,
|
|
3645
3623
|
ensoWalletV2Address
|
|
3646
3624
|
] : null;
|
|
3647
|
-
return
|
|
3625
|
+
return useSWR(
|
|
3648
3626
|
QUERY_KEY,
|
|
3649
3627
|
async ([_, accountAddress, primaryAddress2, ensoWalletV2Address2]) => {
|
|
3650
3628
|
assertPublicClient(publicClient);
|
|
@@ -3687,7 +3665,7 @@ function useBendDemultiply({
|
|
|
3687
3665
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
3688
3666
|
"proxyAggregatorsThroughVercel"
|
|
3689
3667
|
);
|
|
3690
|
-
const QUERY_KEY = collateralToken && loanToken && marketId && primaryAddress && repayAmount && ensoWalletV2Address && isAuthorized !== void 0 && collateralToken.address !== loanToken.address && Number(repayAmount) > 0 && slippage !== void 0 && collateralPriceInLoanAsset !== void 0 && currentCollateral && currentDebt && Number(currentDebt) > 0 && fromAddress
|
|
3668
|
+
const QUERY_KEY = collateralToken && loanToken && marketId && primaryAddress && repayAmount && ensoWalletV2Address && isAuthorized !== void 0 && collateralToken.address !== loanToken.address && Number(repayAmount) > 0 && slippage !== void 0 && collateralPriceInLoanAsset !== void 0 && currentCollateral && currentDebt && Number(currentDebt) > 0 && fromAddress ? [
|
|
3691
3669
|
"useBendDemultiply",
|
|
3692
3670
|
fromAddress,
|
|
3693
3671
|
collateralToken,
|
|
@@ -3704,7 +3682,7 @@ function useBendDemultiply({
|
|
|
3704
3682
|
isAuthorized,
|
|
3705
3683
|
proxyAggregatorsThroughVercel ?? false
|
|
3706
3684
|
] : null;
|
|
3707
|
-
return
|
|
3685
|
+
return useSWR(
|
|
3708
3686
|
QUERY_KEY,
|
|
3709
3687
|
async ([
|
|
3710
3688
|
_,
|
|
@@ -3757,14 +3735,13 @@ function useBendDemultiply({
|
|
|
3757
3735
|
});
|
|
3758
3736
|
},
|
|
3759
3737
|
{
|
|
3760
|
-
...options
|
|
3738
|
+
...options,
|
|
3761
3739
|
refreshInterval: 1e5 /* NORMAL */
|
|
3762
3740
|
}
|
|
3763
3741
|
);
|
|
3764
3742
|
}
|
|
3765
3743
|
|
|
3766
3744
|
// src/hooks/enso/useBendMultiply.ts
|
|
3767
|
-
import useSWR16 from "swr";
|
|
3768
3745
|
import { parseUnits as parseUnits6 } from "viem";
|
|
3769
3746
|
import { defaultChainId as defaultChainId8 } from "@berachain/config/internal";
|
|
3770
3747
|
import {
|
|
@@ -4034,7 +4011,7 @@ function useBendMultiply({
|
|
|
4034
4011
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4035
4012
|
"proxyAggregatorsThroughVercel"
|
|
4036
4013
|
);
|
|
4037
|
-
const QUERY_KEY = collateralToken && loanToken && marketId && primaryAddress && ensoWalletV2Address && isAuthorized !== void 0 && collateralToken.address !== loanToken.address && slippage !== void 0 && leverageMultiplier !== void 0 && formattedCollateralPriceInLoanAsset !== void 0 && (Number(formattedSupplyCollateralAmount ?? 0) > 0 || leverageMultiplier > 1 && (Number(formattedCurrentCollateralAmount ?? 0) > 0 || Number(formattedSupplyCollateralAmount ?? 0) > 0)) && fromAddress
|
|
4014
|
+
const QUERY_KEY = collateralToken && loanToken && marketId && primaryAddress && ensoWalletV2Address && isAuthorized !== void 0 && collateralToken.address !== loanToken.address && slippage !== void 0 && leverageMultiplier !== void 0 && formattedCollateralPriceInLoanAsset !== void 0 && (Number(formattedSupplyCollateralAmount ?? 0) > 0 || leverageMultiplier > 1 && (Number(formattedCurrentCollateralAmount ?? 0) > 0 || Number(formattedSupplyCollateralAmount ?? 0) > 0)) && fromAddress ? [
|
|
4038
4015
|
"useBendMultiply",
|
|
4039
4016
|
fromAddress,
|
|
4040
4017
|
collateralToken,
|
|
@@ -4052,7 +4029,7 @@ function useBendMultiply({
|
|
|
4052
4029
|
isAuthorized,
|
|
4053
4030
|
proxyAggregatorsThroughVercel ?? false
|
|
4054
4031
|
] : null;
|
|
4055
|
-
return
|
|
4032
|
+
return useSWR(
|
|
4056
4033
|
QUERY_KEY,
|
|
4057
4034
|
async ([
|
|
4058
4035
|
_,
|
|
@@ -4107,14 +4084,13 @@ function useBendMultiply({
|
|
|
4107
4084
|
});
|
|
4108
4085
|
},
|
|
4109
4086
|
{
|
|
4110
|
-
...options
|
|
4087
|
+
...options,
|
|
4111
4088
|
refreshInterval: 1e5 /* NORMAL */
|
|
4112
4089
|
}
|
|
4113
4090
|
);
|
|
4114
4091
|
}
|
|
4115
4092
|
|
|
4116
4093
|
// src/hooks/enso/useBendZapSupply.ts
|
|
4117
|
-
import useSWR17 from "swr";
|
|
4118
4094
|
import { formatEther as formatEther4, parseUnits as parseUnits7, zeroAddress as zeroAddress20 } from "viem";
|
|
4119
4095
|
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
4120
4096
|
import { useBeraWallet as useBeraWallet12, usePublicClient as usePublicClient16 } from "@berachain/wagmi/hooks";
|
|
@@ -4306,7 +4282,7 @@ function useBendZapSupply({
|
|
|
4306
4282
|
address: zeroAddress20,
|
|
4307
4283
|
chainId: isCrossChain ? tokenIn?.chainId : void 0
|
|
4308
4284
|
},
|
|
4309
|
-
{
|
|
4285
|
+
{ isEnabled: !!isCrossChain }
|
|
4310
4286
|
);
|
|
4311
4287
|
const transactionValue = swrResponse.data?.getCalldata?.({ account: zeroAddress20 })?.value ?? 0n;
|
|
4312
4288
|
const nativeBalance = nativeBalanceData?.balance ?? {
|
|
@@ -4342,7 +4318,7 @@ function useBendZapSupplyHelper({
|
|
|
4342
4318
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4343
4319
|
"proxyAggregatorsThroughVercel"
|
|
4344
4320
|
);
|
|
4345
|
-
const isEnabled =
|
|
4321
|
+
const isEnabled = !!tokenIn && !!loanToken && !!bendVault && !!amount && !!fromAddress && !isToken(loanToken.address, tokenIn.address) && tokenIn.chainId && Number(amount) > 0 && !!slippage;
|
|
4346
4322
|
const publicClientBeraChain = usePublicClient16();
|
|
4347
4323
|
const QUERY_KEY = isEnabled ? [
|
|
4348
4324
|
"useBendZapSupply",
|
|
@@ -4355,7 +4331,7 @@ function useBendZapSupplyHelper({
|
|
|
4355
4331
|
slippage,
|
|
4356
4332
|
proxyAggregatorsThroughVercel ?? false
|
|
4357
4333
|
] : null;
|
|
4358
|
-
return
|
|
4334
|
+
return useSWR(
|
|
4359
4335
|
QUERY_KEY,
|
|
4360
4336
|
async ([
|
|
4361
4337
|
,
|
|
@@ -4383,7 +4359,7 @@ function useBendZapSupplyHelper({
|
|
|
4383
4359
|
});
|
|
4384
4360
|
},
|
|
4385
4361
|
{
|
|
4386
|
-
...options
|
|
4362
|
+
...options,
|
|
4387
4363
|
refreshInterval: 1e5 /* NORMAL */
|
|
4388
4364
|
}
|
|
4389
4365
|
);
|
|
@@ -4391,7 +4367,6 @@ function useBendZapSupplyHelper({
|
|
|
4391
4367
|
|
|
4392
4368
|
// src/hooks/enso/useEnsoSwapBundle.ts
|
|
4393
4369
|
import { getPublicClient as getPublicClient2 } from "@wagmi/core";
|
|
4394
|
-
import useSWR19 from "swr";
|
|
4395
4370
|
import { parseUnits as parseUnits8 } from "viem";
|
|
4396
4371
|
import { defaultChainId as berachainChainId2 } from "@berachain/config/internal";
|
|
4397
4372
|
import { useBeraWallet as useBeraWallet14, useConfig as useConfig4 } from "@berachain/wagmi/hooks";
|
|
@@ -4462,7 +4437,6 @@ async function getEnsoSwapBundle({
|
|
|
4462
4437
|
|
|
4463
4438
|
// src/hooks/tokens/usePollWalletBalances.ts
|
|
4464
4439
|
import { useMemo as useMemo9 } from "react";
|
|
4465
|
-
import useSWR18 from "swr";
|
|
4466
4440
|
import {
|
|
4467
4441
|
useBeraWallet as useBeraWallet13,
|
|
4468
4442
|
useConfig as useConfig3,
|
|
@@ -4485,7 +4459,7 @@ function usePollWalletBalances(args, options) {
|
|
|
4485
4459
|
// TODO: adding the whole list to the query is very inefficient, we should only add the tokens addresses
|
|
4486
4460
|
Array.from(tokens.values())
|
|
4487
4461
|
] : null;
|
|
4488
|
-
const swrResponse =
|
|
4462
|
+
const swrResponse = useSWR(
|
|
4489
4463
|
QUERY_KEY,
|
|
4490
4464
|
async ([, wallet2, tokenList2]) => {
|
|
4491
4465
|
return getWalletBalances({
|
|
@@ -4496,7 +4470,7 @@ function usePollWalletBalances(args, options) {
|
|
|
4496
4470
|
},
|
|
4497
4471
|
{
|
|
4498
4472
|
refreshInterval: 1e5 /* NORMAL */,
|
|
4499
|
-
...options
|
|
4473
|
+
...options
|
|
4500
4474
|
}
|
|
4501
4475
|
);
|
|
4502
4476
|
return {
|
|
@@ -4534,7 +4508,7 @@ function useEnsoSwapBundle({
|
|
|
4534
4508
|
slippage,
|
|
4535
4509
|
proxyAggregatorsThroughVercel ?? false
|
|
4536
4510
|
] : null;
|
|
4537
|
-
const swrResponse =
|
|
4511
|
+
const swrResponse = useSWR(
|
|
4538
4512
|
QUERY_KEY,
|
|
4539
4513
|
async ([, fromAddress2, tokenIn2, tokenOut2, amount2, slippage2]) => {
|
|
4540
4514
|
assertAddress(fromAddress2, "fromAddress");
|
|
@@ -4575,7 +4549,6 @@ function useEnsoSwapBundle({
|
|
|
4575
4549
|
}
|
|
4576
4550
|
|
|
4577
4551
|
// src/hooks/enso/useZapStakeBera.ts
|
|
4578
|
-
import useSWR20 from "swr";
|
|
4579
4552
|
import { formatUnits as formatUnits9, parseUnits as parseUnits9 } from "viem";
|
|
4580
4553
|
import { chainConfigs, defaultChainId as defaultChainId9 } from "@berachain/config/internal";
|
|
4581
4554
|
import { useBeraWallet as useBeraWallet15 } from "@berachain/wagmi/hooks";
|
|
@@ -4598,7 +4571,7 @@ function useZapStakeBera({
|
|
|
4598
4571
|
underlyingToken,
|
|
4599
4572
|
tokenOut
|
|
4600
4573
|
] : null;
|
|
4601
|
-
const swrResponse =
|
|
4574
|
+
const swrResponse = useSWR(
|
|
4602
4575
|
QUERY_KEY,
|
|
4603
4576
|
async ([
|
|
4604
4577
|
,
|
|
@@ -4620,7 +4593,7 @@ function useZapStakeBera({
|
|
|
4620
4593
|
});
|
|
4621
4594
|
},
|
|
4622
4595
|
{
|
|
4623
|
-
...options
|
|
4596
|
+
...options,
|
|
4624
4597
|
refreshInterval: 1e5 /* NORMAL */
|
|
4625
4598
|
}
|
|
4626
4599
|
);
|
|
@@ -4647,20 +4620,22 @@ function useZapStakeBera({
|
|
|
4647
4620
|
}
|
|
4648
4621
|
|
|
4649
4622
|
// src/hooks/honey/useCappedGlobally.ts
|
|
4650
|
-
import useSWR22 from "swr";
|
|
4651
4623
|
import { usePublicClient as usePublicClient18 } from "@berachain/wagmi/hooks";
|
|
4652
4624
|
|
|
4653
4625
|
// src/hooks/honey/usePythLatestPrices.ts
|
|
4654
|
-
import useSWR21 from "swr";
|
|
4655
4626
|
function usePythLatestPrices({
|
|
4656
4627
|
priceFeedMap
|
|
4657
4628
|
}, options) {
|
|
4658
4629
|
const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
|
|
4659
|
-
const QUERY_KEY =
|
|
4660
|
-
const swrResponse =
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4630
|
+
const QUERY_KEY = priceFeedIds ? ["usePythLatestPrices", priceFeedIds] : null;
|
|
4631
|
+
const swrResponse = useSWR(
|
|
4632
|
+
QUERY_KEY,
|
|
4633
|
+
async ([_, priceFeeds]) => {
|
|
4634
|
+
const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
|
|
4635
|
+
return data;
|
|
4636
|
+
},
|
|
4637
|
+
options
|
|
4638
|
+
);
|
|
4664
4639
|
return swrResponse;
|
|
4665
4640
|
}
|
|
4666
4641
|
|
|
@@ -4678,9 +4653,7 @@ var useCappedGlobally = ({
|
|
|
4678
4653
|
priceFeedMap: asset?.address && priceFeedMap ? { [asset.address]: priceFeedMap[asset.address] } : void 0
|
|
4679
4654
|
},
|
|
4680
4655
|
{
|
|
4681
|
-
|
|
4682
|
-
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
4683
|
-
}
|
|
4656
|
+
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
4684
4657
|
}
|
|
4685
4658
|
);
|
|
4686
4659
|
const QUERY_KEY = amount && asset && (flags.isPythWrapperEnabled && !!latestPrices?.prices.length || !flags.isPythWrapperEnabled) ? [
|
|
@@ -4691,7 +4664,7 @@ var useCappedGlobally = ({
|
|
|
4691
4664
|
flags.isPythWrapperEnabled,
|
|
4692
4665
|
isBasketModeEnabled2
|
|
4693
4666
|
] : null;
|
|
4694
|
-
const swrResponse =
|
|
4667
|
+
const swrResponse = useSWR(
|
|
4695
4668
|
QUERY_KEY,
|
|
4696
4669
|
async ([
|
|
4697
4670
|
_,
|
|
@@ -4715,7 +4688,7 @@ var useCappedGlobally = ({
|
|
|
4715
4688
|
});
|
|
4716
4689
|
},
|
|
4717
4690
|
{
|
|
4718
|
-
...options
|
|
4691
|
+
...options,
|
|
4719
4692
|
refreshInterval: 0
|
|
4720
4693
|
}
|
|
4721
4694
|
);
|
|
@@ -4726,7 +4699,6 @@ var useCappedGlobally = ({
|
|
|
4726
4699
|
};
|
|
4727
4700
|
|
|
4728
4701
|
// src/hooks/honey/useCappedRelatively.ts
|
|
4729
|
-
import useSWR23 from "swr";
|
|
4730
4702
|
import { usePublicClient as usePublicClient19 } from "@berachain/wagmi/hooks";
|
|
4731
4703
|
var useCappedRelatively = ({
|
|
4732
4704
|
asset,
|
|
@@ -4743,7 +4715,7 @@ var useCappedRelatively = ({
|
|
|
4743
4715
|
collateralList,
|
|
4744
4716
|
referenceCollateral
|
|
4745
4717
|
] : null;
|
|
4746
|
-
const swrResponse =
|
|
4718
|
+
const swrResponse = useSWR(
|
|
4747
4719
|
QUERY_KEY,
|
|
4748
4720
|
async ([_, asset2, amount2, collaterals, referenceCollateral2]) => {
|
|
4749
4721
|
if (isBasketModeEnabled2) {
|
|
@@ -4778,7 +4750,7 @@ var useCappedRelatively = ({
|
|
|
4778
4750
|
},
|
|
4779
4751
|
{
|
|
4780
4752
|
refreshInterval: 0,
|
|
4781
|
-
...options
|
|
4753
|
+
...options
|
|
4782
4754
|
}
|
|
4783
4755
|
);
|
|
4784
4756
|
return {
|
|
@@ -4788,14 +4760,13 @@ var useCappedRelatively = ({
|
|
|
4788
4760
|
};
|
|
4789
4761
|
|
|
4790
4762
|
// src/hooks/honey/useCollateralWeights.ts
|
|
4791
|
-
import useSWR24 from "swr";
|
|
4792
4763
|
import { usePublicClient as usePublicClient20 } from "@berachain/wagmi/hooks";
|
|
4793
4764
|
var useCollateralWeights = ({
|
|
4794
4765
|
collateralList
|
|
4795
4766
|
}, options) => {
|
|
4796
4767
|
const publicClient = usePublicClient20();
|
|
4797
4768
|
const QUERY_KEY = publicClient && collateralList ? ["useCollateralWeights", collateralList] : void 0;
|
|
4798
|
-
const swrResponse =
|
|
4769
|
+
const swrResponse = useSWR(
|
|
4799
4770
|
QUERY_KEY,
|
|
4800
4771
|
async ([_, collateralList2]) => {
|
|
4801
4772
|
assertPublicClient(publicClient);
|
|
@@ -4805,8 +4776,8 @@ var useCollateralWeights = ({
|
|
|
4805
4776
|
});
|
|
4806
4777
|
},
|
|
4807
4778
|
{
|
|
4808
|
-
...options
|
|
4809
|
-
refreshInterval: options?.
|
|
4779
|
+
...options,
|
|
4780
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
4810
4781
|
}
|
|
4811
4782
|
);
|
|
4812
4783
|
return {
|
|
@@ -4816,9 +4787,8 @@ var useCollateralWeights = ({
|
|
|
4816
4787
|
};
|
|
4817
4788
|
|
|
4818
4789
|
// src/hooks/honey/useHoney24hVolume.ts
|
|
4819
|
-
import useSWR25 from "swr";
|
|
4820
4790
|
function useHoney24hVolume() {
|
|
4821
|
-
const response =
|
|
4791
|
+
const response = useSWR(["useHoney24hVolume"], () => getHoney24hVolume(), {
|
|
4822
4792
|
refreshInterval: 18e4 /* SLOW */
|
|
4823
4793
|
});
|
|
4824
4794
|
return {
|
|
@@ -4831,7 +4801,6 @@ function useHoney24hVolume() {
|
|
|
4831
4801
|
import { useMemo as useMemo10 } from "react";
|
|
4832
4802
|
|
|
4833
4803
|
// src/hooks/honey/useHoneyBalances.ts
|
|
4834
|
-
import useSWR26 from "swr";
|
|
4835
4804
|
import {
|
|
4836
4805
|
useBeraWallet as useBeraWallet16,
|
|
4837
4806
|
useConfig as useConfig5,
|
|
@@ -4843,7 +4812,7 @@ var useHoneyBalances = () => {
|
|
|
4843
4812
|
const { collateralList } = useHoneyConfig();
|
|
4844
4813
|
const wagmiConfig = useConfig5();
|
|
4845
4814
|
const QUERY_KEY = account && collateralList && publicClient ? ["useHoneyBalances", account, collateralList] : null;
|
|
4846
|
-
const swrResponse =
|
|
4815
|
+
const swrResponse = useSWR(
|
|
4847
4816
|
QUERY_KEY,
|
|
4848
4817
|
async ([_, account2, collateralList2]) => {
|
|
4849
4818
|
assertPublicClient(publicClient);
|
|
@@ -4873,13 +4842,12 @@ var useHoneyBalances = () => {
|
|
|
4873
4842
|
};
|
|
4874
4843
|
|
|
4875
4844
|
// src/hooks/honey/useHoneyVaultsBalance.ts
|
|
4876
|
-
import useSWR27 from "swr";
|
|
4877
4845
|
import { usePublicClient as usePublicClient22 } from "@berachain/wagmi/hooks";
|
|
4878
4846
|
var useHoneyVaultsBalance = (options) => {
|
|
4879
4847
|
const publicClient = usePublicClient22();
|
|
4880
4848
|
const { collateralList } = useHoneyConfig();
|
|
4881
4849
|
const QUERY_KEY = collateralList && publicClient ? ["useHoneyVaultsBalance", collateralList] : null;
|
|
4882
|
-
const swrResponse =
|
|
4850
|
+
const swrResponse = useSWR(
|
|
4883
4851
|
QUERY_KEY,
|
|
4884
4852
|
async ([_, collateralList2]) => {
|
|
4885
4853
|
assertPublicClient(publicClient);
|
|
@@ -4888,7 +4856,7 @@ var useHoneyVaultsBalance = (options) => {
|
|
|
4888
4856
|
collateralList: collateralList2
|
|
4889
4857
|
});
|
|
4890
4858
|
},
|
|
4891
|
-
{ ...options
|
|
4859
|
+
{ ...options, refreshInterval: 1e5 /* NORMAL */ }
|
|
4892
4860
|
);
|
|
4893
4861
|
return {
|
|
4894
4862
|
...swrResponse,
|
|
@@ -4897,7 +4865,6 @@ var useHoneyVaultsBalance = (options) => {
|
|
|
4897
4865
|
};
|
|
4898
4866
|
|
|
4899
4867
|
// src/hooks/honey/useIsBadCollateralAsset.ts
|
|
4900
|
-
import useSWR28 from "swr";
|
|
4901
4868
|
import { usePublicClient as usePublicClient23 } from "@berachain/wagmi/hooks";
|
|
4902
4869
|
var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
4903
4870
|
const publicClient = usePublicClient23();
|
|
@@ -4909,9 +4876,7 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4909
4876
|
} : void 0
|
|
4910
4877
|
},
|
|
4911
4878
|
{
|
|
4912
|
-
|
|
4913
|
-
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address
|
|
4914
|
-
}
|
|
4879
|
+
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address
|
|
4915
4880
|
}
|
|
4916
4881
|
);
|
|
4917
4882
|
const QUERY_KEY = publicClient && collateral && (flags.isPythWrapperEnabled && !!latestPrices?.prices.length || !flags.isPythWrapperEnabled) ? [
|
|
@@ -4920,7 +4885,7 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4920
4885
|
latestPrices,
|
|
4921
4886
|
flags.isPythWrapperEnabled
|
|
4922
4887
|
] : null;
|
|
4923
|
-
const swrResponse =
|
|
4888
|
+
const swrResponse = useSWR(
|
|
4924
4889
|
QUERY_KEY,
|
|
4925
4890
|
async ([_, collateral2, latestPrices2, isPythWrapperEnabled]) => {
|
|
4926
4891
|
assertPublicClient(publicClient);
|
|
@@ -4932,8 +4897,8 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4932
4897
|
});
|
|
4933
4898
|
},
|
|
4934
4899
|
{
|
|
4935
|
-
...options
|
|
4936
|
-
refreshInterval: options?.
|
|
4900
|
+
...options,
|
|
4901
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
4937
4902
|
}
|
|
4938
4903
|
);
|
|
4939
4904
|
return {
|
|
@@ -5120,9 +5085,8 @@ var useHoneyAlerts = ({
|
|
|
5120
5085
|
};
|
|
5121
5086
|
|
|
5122
5087
|
// src/hooks/honey/useHoneyChartData.ts
|
|
5123
|
-
import useSWR29 from "swr";
|
|
5124
5088
|
function useHoneyChartData({ days }) {
|
|
5125
|
-
const swrResponse =
|
|
5089
|
+
const swrResponse = useSWR(
|
|
5126
5090
|
["useHoneyChartData", days],
|
|
5127
5091
|
async ([_, days2]) => {
|
|
5128
5092
|
return await getChartData({ days: days2 });
|
|
@@ -5140,7 +5104,6 @@ import { formatUnits as formatUnits10 } from "viem";
|
|
|
5140
5104
|
import { defaultChainId as defaultChainId10 } from "@berachain/config/internal";
|
|
5141
5105
|
|
|
5142
5106
|
// src/hooks/honey/useIsBasketModeEnabled.ts
|
|
5143
|
-
import useSWR30 from "swr";
|
|
5144
5107
|
import { usePublicClient as usePublicClient24 } from "@berachain/wagmi/hooks";
|
|
5145
5108
|
function useIsBasketModeEnabled({ state }, options) {
|
|
5146
5109
|
const publicClient = usePublicClient24();
|
|
@@ -5150,9 +5113,7 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5150
5113
|
priceFeedMap
|
|
5151
5114
|
},
|
|
5152
5115
|
{
|
|
5153
|
-
|
|
5154
|
-
isEnabled: flags.isPythWrapperEnabled && !!collateralList.length
|
|
5155
|
-
}
|
|
5116
|
+
isEnabled: flags.isPythWrapperEnabled && !!collateralList.length
|
|
5156
5117
|
}
|
|
5157
5118
|
);
|
|
5158
5119
|
const isMint = state.actionType === "mint";
|
|
@@ -5163,7 +5124,7 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5163
5124
|
flags.isPythWrapperEnabled,
|
|
5164
5125
|
collateralList
|
|
5165
5126
|
] : null;
|
|
5166
|
-
const swrResponse =
|
|
5127
|
+
const swrResponse = useSWR(
|
|
5167
5128
|
QUERY_KEY,
|
|
5168
5129
|
async ([_, isMint2, latestPrices2, isPythWrapperEnabled, collateralList2]) => {
|
|
5169
5130
|
assertPublicClient(publicClient);
|
|
@@ -5177,8 +5138,8 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5177
5138
|
return isActive;
|
|
5178
5139
|
},
|
|
5179
5140
|
{
|
|
5180
|
-
...options
|
|
5181
|
-
refreshInterval: options?.
|
|
5141
|
+
...options,
|
|
5142
|
+
refreshInterval: options?.refreshInterval ?? 1e4 /* FAST */
|
|
5182
5143
|
}
|
|
5183
5144
|
);
|
|
5184
5145
|
return {
|
|
@@ -5324,21 +5285,24 @@ var useHoneySwapState = () => {
|
|
|
5324
5285
|
};
|
|
5325
5286
|
|
|
5326
5287
|
// src/hooks/perps/usePythUpdateFee.ts
|
|
5327
|
-
import useSWRImmutable8 from "swr/immutable";
|
|
5328
5288
|
import { usePublicClient as usePublicClient25 } from "@berachain/wagmi/hooks";
|
|
5329
5289
|
var usePythUpdateFee = ({
|
|
5330
5290
|
pythPriceFeedCalldata,
|
|
5331
5291
|
tokenListLength
|
|
5332
5292
|
}, options) => {
|
|
5333
5293
|
const publicClient = usePublicClient25();
|
|
5334
|
-
const QUERY_KEY =
|
|
5335
|
-
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } =
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5294
|
+
const QUERY_KEY = pythPriceFeedCalldata && pythPriceFeedCalldata.length > 0 ? ["usePythUpdateFee", pythPriceFeedCalldata] : null;
|
|
5295
|
+
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } = useSWRImmutable(
|
|
5296
|
+
QUERY_KEY,
|
|
5297
|
+
async ([_, pythPriceFeedCalldata2]) => {
|
|
5298
|
+
assertPublicClient(publicClient);
|
|
5299
|
+
return getPythUpdateFee({
|
|
5300
|
+
client: publicClient,
|
|
5301
|
+
priceFeedId: pythPriceFeedCalldata2
|
|
5302
|
+
});
|
|
5303
|
+
},
|
|
5304
|
+
options
|
|
5305
|
+
);
|
|
5342
5306
|
return {
|
|
5343
5307
|
QUERY_KEY,
|
|
5344
5308
|
data,
|
|
@@ -5347,14 +5311,13 @@ var usePythUpdateFee = ({
|
|
|
5347
5311
|
};
|
|
5348
5312
|
|
|
5349
5313
|
// src/hooks/pol/useAutoclaimedIncentives.ts
|
|
5350
|
-
import useSWR31 from "swr";
|
|
5351
5314
|
import { useBeraWallet as useBeraWallet17 } from "@berachain/wagmi/hooks";
|
|
5352
5315
|
function useAutoclaimedIncentives({
|
|
5353
5316
|
enabled
|
|
5354
5317
|
}) {
|
|
5355
5318
|
const { address: account } = useBeraWallet17();
|
|
5356
5319
|
const QUERY_KEY = enabled && account ? ["useAutoclaimedIncentives", account] : null;
|
|
5357
|
-
const swrResponse =
|
|
5320
|
+
const swrResponse = useSWR(
|
|
5358
5321
|
QUERY_KEY,
|
|
5359
5322
|
async ([, account2]) => getAutoclaimedIncentives({ account: account2 }),
|
|
5360
5323
|
{
|
|
@@ -5370,14 +5333,13 @@ function useAutoclaimedIncentives({
|
|
|
5370
5333
|
}
|
|
5371
5334
|
|
|
5372
5335
|
// src/hooks/pol/useAutoclaimedIncentivesTxHash.ts
|
|
5373
|
-
import useSWR32 from "swr";
|
|
5374
5336
|
import { useBeraWallet as useBeraWallet18 } from "@berachain/wagmi/hooks";
|
|
5375
5337
|
function useAutoclaimedIncentivesTxHash({
|
|
5376
5338
|
enabled
|
|
5377
5339
|
}) {
|
|
5378
5340
|
const { address: account } = useBeraWallet18();
|
|
5379
5341
|
const QUERY_KEY = enabled && account ? ["useAutoclaimedIncentivesTxHash", account] : null;
|
|
5380
|
-
const swrResponse =
|
|
5342
|
+
const swrResponse = useSWR(
|
|
5381
5343
|
QUERY_KEY,
|
|
5382
5344
|
async ([, account2]) => getAutoclaimedIncentivesTxHash({ account: account2 }),
|
|
5383
5345
|
{
|
|
@@ -5408,16 +5370,35 @@ function useBgtAprSimulation(args) {
|
|
|
5408
5370
|
}, [args]);
|
|
5409
5371
|
}
|
|
5410
5372
|
|
|
5373
|
+
// src/hooks/pol/useBgtIncentiveDistributorPaused.ts
|
|
5374
|
+
import { usePublicClient as usePublicClient26 } from "@berachain/wagmi/hooks";
|
|
5375
|
+
function useBgtIncentiveDistributorPaused(options) {
|
|
5376
|
+
const publicClient = usePublicClient26();
|
|
5377
|
+
const QUERY_KEY = publicClient ? ["useBgtIncentiveDistributorPaused", publicClient.chain?.id] : null;
|
|
5378
|
+
const swrResponse = swr_default(
|
|
5379
|
+
QUERY_KEY,
|
|
5380
|
+
async () => getBgtIncentiveDistributorPaused({ publicClient }).catch(() => false),
|
|
5381
|
+
{
|
|
5382
|
+
revalidateOnFocus: false,
|
|
5383
|
+
revalidateOnReconnect: false,
|
|
5384
|
+
...options
|
|
5385
|
+
}
|
|
5386
|
+
);
|
|
5387
|
+
return {
|
|
5388
|
+
...swrResponse,
|
|
5389
|
+
refresh: () => swrResponse?.mutate?.()
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
|
|
5411
5393
|
// src/hooks/pol/useBgtUnstakedBalance.ts
|
|
5412
|
-
import useSWR33 from "swr";
|
|
5413
5394
|
import { formatEther as formatEther5 } from "viem";
|
|
5414
5395
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5415
|
-
import { useBeraWallet as useBeraWallet19, usePublicClient as
|
|
5396
|
+
import { useBeraWallet as useBeraWallet19, usePublicClient as usePublicClient27 } from "@berachain/wagmi/hooks";
|
|
5416
5397
|
var useBgtUnstakedBalance = (options) => {
|
|
5417
5398
|
const { address: account } = useBeraWallet19();
|
|
5418
|
-
const publicClient =
|
|
5399
|
+
const publicClient = usePublicClient27();
|
|
5419
5400
|
const QUERY_KEY = account && publicClient ? ["useBgtUnstakedBalance", account] : null;
|
|
5420
|
-
const swrResponse =
|
|
5401
|
+
const swrResponse = useSWR(
|
|
5421
5402
|
QUERY_KEY,
|
|
5422
5403
|
async ([, account2]) => {
|
|
5423
5404
|
assertPublicClient(publicClient);
|
|
@@ -5434,7 +5415,7 @@ var useBgtUnstakedBalance = (options) => {
|
|
|
5434
5415
|
},
|
|
5435
5416
|
{
|
|
5436
5417
|
...options,
|
|
5437
|
-
refreshInterval: options?.
|
|
5418
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
5438
5419
|
}
|
|
5439
5420
|
);
|
|
5440
5421
|
return {
|
|
@@ -5444,14 +5425,13 @@ var useBgtUnstakedBalance = (options) => {
|
|
|
5444
5425
|
};
|
|
5445
5426
|
|
|
5446
5427
|
// src/hooks/pol/useClaimableFees.ts
|
|
5447
|
-
import useSWR34 from "swr";
|
|
5448
5428
|
import { formatUnits as formatUnits11 } from "viem";
|
|
5449
|
-
import { useBeraWallet as useBeraWallet20, usePublicClient as
|
|
5429
|
+
import { useBeraWallet as useBeraWallet20, usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5450
5430
|
var useClaimableFees = () => {
|
|
5451
5431
|
const { address: account } = useBeraWallet20();
|
|
5452
|
-
const publicClient =
|
|
5432
|
+
const publicClient = usePublicClient28();
|
|
5453
5433
|
const QUERY_KEY = account && publicClient ? ["useClaimableFees", account] : null;
|
|
5454
|
-
const swrResponse =
|
|
5434
|
+
const swrResponse = useSWR(
|
|
5455
5435
|
QUERY_KEY,
|
|
5456
5436
|
async ([, account2]) => {
|
|
5457
5437
|
assertPublicClient(publicClient);
|
|
@@ -5482,8 +5462,7 @@ import {
|
|
|
5482
5462
|
} from "@berachain/graphql/pol/api";
|
|
5483
5463
|
|
|
5484
5464
|
// src/hooks/pol/useRewardVaults.ts
|
|
5485
|
-
import
|
|
5486
|
-
import { usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5465
|
+
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5487
5466
|
var useRewardVaultsQueryKey = (filter, onChainIncentives = false) => {
|
|
5488
5467
|
return ["useRewardVaults", filter, onChainIncentives];
|
|
5489
5468
|
};
|
|
@@ -5492,18 +5471,16 @@ var useRewardVaults = (args, options) => {
|
|
|
5492
5471
|
args.filter,
|
|
5493
5472
|
args.onChainIncentives
|
|
5494
5473
|
);
|
|
5495
|
-
const publicClient =
|
|
5496
|
-
const swrResponse =
|
|
5497
|
-
|
|
5474
|
+
const publicClient = usePublicClient29();
|
|
5475
|
+
const swrResponse = useSWR(
|
|
5476
|
+
QUERY_KEY,
|
|
5498
5477
|
async ([, filter, onChainIncentives]) => {
|
|
5499
5478
|
return await getRewardVaults({
|
|
5500
5479
|
filter,
|
|
5501
5480
|
publicClient: onChainIncentives ? publicClient : void 0
|
|
5502
5481
|
});
|
|
5503
5482
|
},
|
|
5504
|
-
|
|
5505
|
-
...options?.opts
|
|
5506
|
-
}
|
|
5483
|
+
options
|
|
5507
5484
|
);
|
|
5508
5485
|
return {
|
|
5509
5486
|
...swrResponse,
|
|
@@ -5523,12 +5500,10 @@ var useHighestVaultsAPR = (where = {}, { isEnabled = true } = {}) => {
|
|
|
5523
5500
|
}
|
|
5524
5501
|
},
|
|
5525
5502
|
{
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
isEnabled
|
|
5531
|
-
}
|
|
5503
|
+
refreshInterval: 0,
|
|
5504
|
+
revalidateOnFocus: false,
|
|
5505
|
+
refreshWhenOffline: false,
|
|
5506
|
+
isEnabled
|
|
5532
5507
|
}
|
|
5533
5508
|
);
|
|
5534
5509
|
return {
|
|
@@ -5539,11 +5514,10 @@ var useHighestVaultsAPR = (where = {}, { isEnabled = true } = {}) => {
|
|
|
5539
5514
|
};
|
|
5540
5515
|
|
|
5541
5516
|
// src/hooks/pol/usePollGlobalData.ts
|
|
5542
|
-
import
|
|
5543
|
-
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5517
|
+
import { usePublicClient as usePublicClient30 } from "@berachain/wagmi/hooks";
|
|
5544
5518
|
var usePollGlobalData = (options) => {
|
|
5545
|
-
const publicClient =
|
|
5546
|
-
const swrResponse =
|
|
5519
|
+
const publicClient = usePublicClient30();
|
|
5520
|
+
const swrResponse = useSWR(
|
|
5547
5521
|
publicClient ? "usePollGlobalData" : null,
|
|
5548
5522
|
async () => {
|
|
5549
5523
|
assertPublicClient(publicClient);
|
|
@@ -5551,7 +5525,7 @@ var usePollGlobalData = (options) => {
|
|
|
5551
5525
|
},
|
|
5552
5526
|
{
|
|
5553
5527
|
revalidateOnFocus: false,
|
|
5554
|
-
...options
|
|
5528
|
+
...options
|
|
5555
5529
|
}
|
|
5556
5530
|
);
|
|
5557
5531
|
return {
|
|
@@ -5561,20 +5535,19 @@ var usePollGlobalData = (options) => {
|
|
|
5561
5535
|
};
|
|
5562
5536
|
|
|
5563
5537
|
// src/hooks/pol/usePollMarkets.ts
|
|
5564
|
-
import useSWRImmutable9 from "swr/immutable";
|
|
5565
5538
|
var usePollMarketsQueryKey = () => {
|
|
5566
5539
|
return "usePollMarkets";
|
|
5567
5540
|
};
|
|
5568
5541
|
var usePollMarkets = (options) => {
|
|
5569
5542
|
const QUERY_KEY = usePollMarketsQueryKey();
|
|
5570
|
-
const swrResponse =
|
|
5543
|
+
const swrResponse = useSWRImmutable(
|
|
5571
5544
|
QUERY_KEY,
|
|
5572
5545
|
async () => {
|
|
5573
5546
|
const res = await getMarkets();
|
|
5574
5547
|
return res;
|
|
5575
5548
|
},
|
|
5576
5549
|
{
|
|
5577
|
-
...options
|
|
5550
|
+
...options
|
|
5578
5551
|
}
|
|
5579
5552
|
);
|
|
5580
5553
|
return {
|
|
@@ -5584,22 +5557,21 @@ var usePollMarkets = (options) => {
|
|
|
5584
5557
|
};
|
|
5585
5558
|
|
|
5586
5559
|
// src/hooks/pol/useQueuedBeraUnlock.ts
|
|
5587
|
-
import useSWRImmutable10 from "swr/immutable";
|
|
5588
5560
|
import { isAddress as isAddress9 } from "viem";
|
|
5589
|
-
import { usePublicClient as
|
|
5561
|
+
import { usePublicClient as usePublicClient31 } from "@berachain/wagmi/hooks";
|
|
5590
5562
|
function useQueuedBeraUnlock({
|
|
5591
5563
|
receiptTokenAddresses,
|
|
5592
5564
|
account,
|
|
5593
5565
|
version
|
|
5594
5566
|
}, options) {
|
|
5595
|
-
const publicClient =
|
|
5567
|
+
const publicClient = usePublicClient31();
|
|
5596
5568
|
const QUERY_KEY = receiptTokenAddresses && account && publicClient && isAddress9(account) && version ? [
|
|
5597
5569
|
"useQueuedBeraUnlock",
|
|
5598
5570
|
receiptTokenAddresses,
|
|
5599
5571
|
account,
|
|
5600
5572
|
version
|
|
5601
5573
|
] : null;
|
|
5602
|
-
const swrResponse =
|
|
5574
|
+
const swrResponse = useSWRImmutable(
|
|
5603
5575
|
QUERY_KEY,
|
|
5604
5576
|
async ([, receiptTokenAddresses2, account2, version2]) => {
|
|
5605
5577
|
assertPublicClient(publicClient);
|
|
@@ -5616,7 +5588,7 @@ function useQueuedBeraUnlock({
|
|
|
5616
5588
|
},
|
|
5617
5589
|
{
|
|
5618
5590
|
refreshInterval: 1e4 /* FAST */,
|
|
5619
|
-
...options
|
|
5591
|
+
...options
|
|
5620
5592
|
}
|
|
5621
5593
|
);
|
|
5622
5594
|
return {
|
|
@@ -5626,16 +5598,15 @@ function useQueuedBeraUnlock({
|
|
|
5626
5598
|
}
|
|
5627
5599
|
|
|
5628
5600
|
// src/hooks/pol/useRewardTokenToBeraRate.ts
|
|
5629
|
-
import useSWR37 from "swr";
|
|
5630
5601
|
import { isAddress as isAddress10 } from "viem";
|
|
5631
5602
|
import { defaultChainId as defaultChainId11 } from "@berachain/config/internal";
|
|
5632
|
-
import { usePublicClient as
|
|
5603
|
+
import { usePublicClient as usePublicClient32 } from "@berachain/wagmi/hooks";
|
|
5633
5604
|
var useRewardTokenToBeraRate = ({
|
|
5634
5605
|
address
|
|
5635
5606
|
}, opt) => {
|
|
5636
5607
|
const QUERY_KEY = address ? ["useRewardTokenToBeraRate", address] : null;
|
|
5637
|
-
const publicClient =
|
|
5638
|
-
return
|
|
5608
|
+
const publicClient = usePublicClient32({ chainId: defaultChainId11 });
|
|
5609
|
+
return useSWR(
|
|
5639
5610
|
QUERY_KEY,
|
|
5640
5611
|
async ([_, address2]) => {
|
|
5641
5612
|
if (!address2 || !isAddress10(address2)) {
|
|
@@ -5652,19 +5623,15 @@ var useRewardTokenToBeraRate = ({
|
|
|
5652
5623
|
});
|
|
5653
5624
|
},
|
|
5654
5625
|
{
|
|
5655
|
-
...opt
|
|
5626
|
+
...opt
|
|
5656
5627
|
}
|
|
5657
5628
|
);
|
|
5658
5629
|
};
|
|
5659
5630
|
|
|
5660
|
-
// src/hooks/pol/useRewardVault.ts
|
|
5661
|
-
import useSWR39 from "swr";
|
|
5662
|
-
|
|
5663
5631
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
5664
|
-
import useSWR38 from "swr";
|
|
5665
5632
|
import { erc20Abi as erc20Abi4, formatUnits as formatUnits13, isAddress as isAddress11 } from "viem";
|
|
5666
5633
|
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
5667
|
-
import { usePublicClient as
|
|
5634
|
+
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
5668
5635
|
|
|
5669
5636
|
// src/actions/pol/getStakingTokenInformation.ts
|
|
5670
5637
|
import { erc20Abi as erc20Abi3, formatUnits as formatUnits12 } from "viem";
|
|
@@ -5713,98 +5680,102 @@ var useOnChainRewardVaultQueryKey = (address) => address && isAddress11(address)
|
|
|
5713
5680
|
var useOnChainRewardVault = ({
|
|
5714
5681
|
address
|
|
5715
5682
|
}, opt) => {
|
|
5716
|
-
const publicClient =
|
|
5717
|
-
const isEnabled = opt.opts?.isEnabled ?? true;
|
|
5683
|
+
const publicClient = usePublicClient33();
|
|
5718
5684
|
const QUERY_KEY = useOnChainRewardVaultQueryKey(address);
|
|
5719
|
-
return
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
});
|
|
5728
|
-
const [incentives, isWhitelisted, stakingTokenAmount] = await Promise.all([
|
|
5729
|
-
getRewardVaultIncentives({
|
|
5685
|
+
return useSWR(
|
|
5686
|
+
publicClient ? QUERY_KEY : null,
|
|
5687
|
+
async ([, address2]) => {
|
|
5688
|
+
assertPublicClient(publicClient);
|
|
5689
|
+
const { config } = parseBaseArgs({
|
|
5690
|
+
chainId: publicClient.chain.id
|
|
5691
|
+
});
|
|
5692
|
+
const stakingTokenAddress = await getRewardVaultStakingToken({
|
|
5730
5693
|
address: address2,
|
|
5731
|
-
stakingToken: stakingTokenAddress,
|
|
5732
5694
|
publicClient
|
|
5733
|
-
})
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
}),
|
|
5740
|
-
publicClient.readContract({
|
|
5741
|
-
address: stakingTokenAddress,
|
|
5742
|
-
abi: erc20Abi4,
|
|
5743
|
-
functionName: "balanceOf",
|
|
5744
|
-
args: [address2]
|
|
5745
|
-
})
|
|
5746
|
-
]);
|
|
5747
|
-
const [stakingToken, incentiveTokens] = await Promise.all([
|
|
5748
|
-
getStakingTokenInformation({
|
|
5749
|
-
address: stakingTokenAddress,
|
|
5750
|
-
publicClient
|
|
5751
|
-
}),
|
|
5752
|
-
Promise.all(
|
|
5753
|
-
incentives.map(
|
|
5754
|
-
(add) => getTokenInformation({
|
|
5755
|
-
address: add.token,
|
|
5756
|
-
chainId: publicClient.chain.id,
|
|
5695
|
+
});
|
|
5696
|
+
const [incentives, isWhitelisted, stakingTokenAmount] = await Promise.all(
|
|
5697
|
+
[
|
|
5698
|
+
getRewardVaultIncentives({
|
|
5699
|
+
address: address2,
|
|
5700
|
+
stakingToken: stakingTokenAddress,
|
|
5757
5701
|
publicClient
|
|
5702
|
+
}),
|
|
5703
|
+
publicClient.readContract({
|
|
5704
|
+
address: config.pol.beraChef,
|
|
5705
|
+
abi: beraChefAbi,
|
|
5706
|
+
functionName: "isWhitelistedVault",
|
|
5707
|
+
args: [address2]
|
|
5708
|
+
}),
|
|
5709
|
+
publicClient.readContract({
|
|
5710
|
+
address: stakingTokenAddress,
|
|
5711
|
+
abi: erc20Abi4,
|
|
5712
|
+
functionName: "balanceOf",
|
|
5713
|
+
args: [address2]
|
|
5758
5714
|
})
|
|
5715
|
+
]
|
|
5716
|
+
);
|
|
5717
|
+
const [stakingToken, incentiveTokens] = await Promise.all([
|
|
5718
|
+
getStakingTokenInformation({
|
|
5719
|
+
address: stakingTokenAddress,
|
|
5720
|
+
publicClient
|
|
5721
|
+
}),
|
|
5722
|
+
Promise.all(
|
|
5723
|
+
incentives.map(
|
|
5724
|
+
(add) => getTokenInformation({
|
|
5725
|
+
address: add.token,
|
|
5726
|
+
chainId: publicClient.chain.id,
|
|
5727
|
+
publicClient
|
|
5728
|
+
})
|
|
5729
|
+
)
|
|
5759
5730
|
)
|
|
5760
|
-
)
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
}
|
|
5789
|
-
}
|
|
5790
|
-
|
|
5731
|
+
]);
|
|
5732
|
+
if (!stakingToken) {
|
|
5733
|
+
throw new Error("Staking token not found");
|
|
5734
|
+
}
|
|
5735
|
+
return {
|
|
5736
|
+
id: address2,
|
|
5737
|
+
address: address2,
|
|
5738
|
+
vaultAddress: address2,
|
|
5739
|
+
stakingToken: {
|
|
5740
|
+
address: stakingTokenAddress,
|
|
5741
|
+
name: stakingToken.name ?? "",
|
|
5742
|
+
symbol: stakingToken.symbol ?? "",
|
|
5743
|
+
decimals: stakingToken.decimals ?? 0
|
|
5744
|
+
},
|
|
5745
|
+
stakingTokenAmount: formatUnits13(
|
|
5746
|
+
stakingTokenAmount,
|
|
5747
|
+
stakingToken.decimals ?? 18
|
|
5748
|
+
),
|
|
5749
|
+
isVaultWhitelisted: isWhitelisted,
|
|
5750
|
+
activeIncentives: incentives.map((incentive, idx) => ({
|
|
5751
|
+
active: !!incentive.remainingAmount,
|
|
5752
|
+
remainingAmount: incentive.remainingAmount,
|
|
5753
|
+
remainingAmountUsd: "0",
|
|
5754
|
+
incentiveRate: incentive.incentiveRate,
|
|
5755
|
+
incentiveRateUsd: "0",
|
|
5756
|
+
tokenAddress: incentive.token,
|
|
5757
|
+
token: incentiveTokens[idx]
|
|
5758
|
+
}))
|
|
5759
|
+
};
|
|
5760
|
+
},
|
|
5761
|
+
opt
|
|
5762
|
+
);
|
|
5791
5763
|
};
|
|
5792
5764
|
|
|
5793
5765
|
// src/hooks/pol/useRewardVault.ts
|
|
5794
5766
|
var useRewardVaultQueryKey = (address) => address ? ["useRewardVault", address.toLowerCase()] : null;
|
|
5795
5767
|
var useRewardVault = (id, options) => {
|
|
5796
5768
|
const QUERY_KEY = useRewardVaultQueryKey(id);
|
|
5797
|
-
const
|
|
5769
|
+
const { isEnabled: _isEnabled, ...swrOptions } = options ?? {};
|
|
5770
|
+
const swrResponse = useSWR(
|
|
5798
5771
|
QUERY_KEY,
|
|
5799
5772
|
async ([_, id2]) => getRewardVault({ address: id2 }),
|
|
5800
|
-
|
|
5801
|
-
...options?.opts
|
|
5802
|
-
}
|
|
5773
|
+
swrOptions
|
|
5803
5774
|
);
|
|
5804
|
-
const isOnChainEnabled = options?.
|
|
5775
|
+
const isOnChainEnabled = options?.isEnabled ?? ((!!swrResponse.error || !swrResponse.isLoading) && !swrResponse.data);
|
|
5805
5776
|
const onChainRewardVault = useOnChainRewardVault(
|
|
5806
5777
|
{ address: id },
|
|
5807
|
-
{
|
|
5778
|
+
{ ...options, isEnabled: isOnChainEnabled }
|
|
5808
5779
|
);
|
|
5809
5780
|
return {
|
|
5810
5781
|
data: onChainRewardVault.data ?? swrResponse.data,
|
|
@@ -5819,15 +5790,14 @@ var useRewardVault = (id, options) => {
|
|
|
5819
5790
|
};
|
|
5820
5791
|
|
|
5821
5792
|
// src/hooks/pol/useRewardVaultIncentives.ts
|
|
5822
|
-
import
|
|
5823
|
-
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
5793
|
+
import { usePublicClient as usePublicClient34 } from "@berachain/wagmi/hooks";
|
|
5824
5794
|
function useRewardVaultIncentives({
|
|
5825
5795
|
address,
|
|
5826
5796
|
stakingToken
|
|
5827
5797
|
}) {
|
|
5828
|
-
const publicClient =
|
|
5798
|
+
const publicClient = usePublicClient34();
|
|
5829
5799
|
const QUERY_KEY = publicClient && address && stakingToken ? ["useRewardVaultIncentives", address, stakingToken] : null;
|
|
5830
|
-
const swrResponse =
|
|
5800
|
+
const swrResponse = useSWR(QUERY_KEY, async ([, address2, stakingToken2]) => {
|
|
5831
5801
|
assertPublicClient(publicClient);
|
|
5832
5802
|
return await getRewardVaultIncentives({
|
|
5833
5803
|
address: address2,
|
|
@@ -5842,19 +5812,18 @@ function useRewardVaultIncentives({
|
|
|
5842
5812
|
}
|
|
5843
5813
|
|
|
5844
5814
|
// src/hooks/pol/useRewardVaultRewards.ts
|
|
5845
|
-
import
|
|
5846
|
-
import { usePublicClient as usePublicClient34 } from "@berachain/wagmi/hooks";
|
|
5815
|
+
import { usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
5847
5816
|
var useRewardVaultRewards = (address, options) => {
|
|
5848
|
-
const publicClient =
|
|
5817
|
+
const publicClient = usePublicClient35();
|
|
5849
5818
|
const QUERY_KEY = publicClient && address ? ["useRewardVaultRewards", address] : null;
|
|
5850
|
-
const swrResponse =
|
|
5819
|
+
const swrResponse = useSWR(
|
|
5851
5820
|
QUERY_KEY,
|
|
5852
5821
|
async ([, address2]) => {
|
|
5853
5822
|
assertPublicClient(publicClient);
|
|
5854
5823
|
return await getRewardVaultRewards(address2, publicClient);
|
|
5855
5824
|
},
|
|
5856
5825
|
{
|
|
5857
|
-
...options
|
|
5826
|
+
...options
|
|
5858
5827
|
}
|
|
5859
5828
|
);
|
|
5860
5829
|
return {
|
|
@@ -5863,9 +5832,6 @@ var useRewardVaultRewards = (address, options) => {
|
|
|
5863
5832
|
};
|
|
5864
5833
|
};
|
|
5865
5834
|
|
|
5866
|
-
// src/hooks/pol/useStakedAPR.ts
|
|
5867
|
-
import useSWR42 from "swr";
|
|
5868
|
-
|
|
5869
5835
|
// src/utils/filter.ts
|
|
5870
5836
|
var dailyResolution = (data) => {
|
|
5871
5837
|
const dailyData = [];
|
|
@@ -5893,7 +5859,7 @@ function useStakedAPR({
|
|
|
5893
5859
|
range
|
|
5894
5860
|
}) {
|
|
5895
5861
|
const QUERY_KEY = range ? ["useStakedAPR", range] : null;
|
|
5896
|
-
const swrResponse =
|
|
5862
|
+
const swrResponse = useSWR(QUERY_KEY, async ([, range2]) => {
|
|
5897
5863
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
5898
5864
|
range: range2
|
|
5899
5865
|
});
|
|
@@ -5913,11 +5879,10 @@ function useStakedAPR({
|
|
|
5913
5879
|
|
|
5914
5880
|
// src/hooks/pol/useStakedData.ts
|
|
5915
5881
|
import { useMemo as useMemo12 } from "react";
|
|
5916
|
-
import
|
|
5917
|
-
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
5882
|
+
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
5918
5883
|
var useStakedData = (stakingConfigs) => {
|
|
5919
5884
|
const window2 = useBeraFlag("swberaAprWindow");
|
|
5920
|
-
const publicClient =
|
|
5885
|
+
const publicClient = usePublicClient36();
|
|
5921
5886
|
const { address: account } = useBeraWallet21();
|
|
5922
5887
|
const receiptTokens = useMemo12(
|
|
5923
5888
|
() => stakingConfigs.map((config) => config.receiptToken),
|
|
@@ -5928,15 +5893,21 @@ var useStakedData = (stakingConfigs) => {
|
|
|
5928
5893
|
[stakingConfigs]
|
|
5929
5894
|
);
|
|
5930
5895
|
const aprKey = window2 ? ["useStakedData:apr", window2] : null;
|
|
5931
|
-
const { data: apr } =
|
|
5896
|
+
const { data: apr } = useSWR(
|
|
5932
5897
|
aprKey,
|
|
5933
5898
|
async ([, window3]) => getStakedBeraAPR({ window: window3 }),
|
|
5934
5899
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
5935
5900
|
);
|
|
5936
|
-
const {
|
|
5937
|
-
|
|
5901
|
+
const {
|
|
5902
|
+
data: walletBalances,
|
|
5903
|
+
isLoading: isLoadingBalances,
|
|
5904
|
+
error: walletBalancesError
|
|
5905
|
+
} = usePollWalletBalances({ tokens: receiptTokens });
|
|
5906
|
+
const { getTokenPrice } = useTokenPrices({
|
|
5907
|
+
tokens: inputTokens
|
|
5908
|
+
});
|
|
5938
5909
|
const exchangeRatesKey = publicClient && receiptTokens.length > 0 ? ["useStakedData:exchangeRates", receiptTokens] : null;
|
|
5939
|
-
const { data: exchangeRates } =
|
|
5910
|
+
const { data: exchangeRates, error: exchangeRatesError } = useSWR(
|
|
5940
5911
|
exchangeRatesKey,
|
|
5941
5912
|
async ([, receiptTokens2]) => {
|
|
5942
5913
|
assertPublicClient(publicClient);
|
|
@@ -5951,33 +5922,13 @@ var useStakedData = (stakingConfigs) => {
|
|
|
5951
5922
|
},
|
|
5952
5923
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
5953
5924
|
);
|
|
5954
|
-
const balances = useMemo12(() => {
|
|
5955
|
-
if (!walletBalances || !exchangeRates) return void 0;
|
|
5956
|
-
return stakingConfigs.map((config, i) => {
|
|
5957
|
-
const inputToken = config.inputTokens[0];
|
|
5958
|
-
const stakedBalance = walletBalances.find((b) => b.address === config.receiptToken.address)?.balance.raw ?? "0";
|
|
5959
|
-
const exchangeRate = exchangeRates[i] ?? 0;
|
|
5960
|
-
const inputTokenPrice = getTokenPrice(inputToken) ?? 0;
|
|
5961
|
-
const total = new bignumber_js_default(stakedBalance).multipliedBy(exchangeRate);
|
|
5962
|
-
const stakedAmount = total.dividedBy(10 ** inputToken.decimals);
|
|
5963
|
-
const stakedAmountUsd = stakedAmount.multipliedBy(inputTokenPrice);
|
|
5964
|
-
return {
|
|
5965
|
-
token: inputToken,
|
|
5966
|
-
apr: apr ?? 0,
|
|
5967
|
-
stakedAmount: stakedAmount.toNumber(),
|
|
5968
|
-
stakedAmountUsd: stakedAmountUsd.toNumber(),
|
|
5969
|
-
earnedAmount: 0,
|
|
5970
|
-
earnedAmountUsd: 0,
|
|
5971
|
-
isLoadingEarnings: true
|
|
5972
|
-
};
|
|
5973
|
-
});
|
|
5974
|
-
}, [walletBalances, exchangeRates, stakingConfigs, apr, getTokenPrice]);
|
|
5975
5925
|
const positionsKey = account && publicClient && stakingConfigs.length > 0 ? ["useStakedData:positions", account, stakingConfigs] : null;
|
|
5976
5926
|
const {
|
|
5977
5927
|
data: positionsRaw,
|
|
5928
|
+
error: positionsError,
|
|
5978
5929
|
isLoading: isLoadingPositions,
|
|
5979
5930
|
isValidating: isValidatingPositions
|
|
5980
|
-
} =
|
|
5931
|
+
} = useSWR(
|
|
5981
5932
|
positionsKey,
|
|
5982
5933
|
async ([, account2, stakingConfigs2]) => {
|
|
5983
5934
|
assertPublicClient(publicClient);
|
|
@@ -6000,13 +5951,42 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6000
5951
|
},
|
|
6001
5952
|
{ refreshInterval: 1e4 /* FAST */ }
|
|
6002
5953
|
);
|
|
5954
|
+
const earningsSettled = !!positionsRaw || !!positionsError;
|
|
5955
|
+
const balances = useMemo12(() => {
|
|
5956
|
+
if (!walletBalances || !exchangeRates) return void 0;
|
|
5957
|
+
return stakingConfigs.map((config, i) => {
|
|
5958
|
+
const inputToken = config.inputTokens[0];
|
|
5959
|
+
const stakedBalance = walletBalances.find((b) => b.address === config.receiptToken.address)?.balance.raw ?? "0";
|
|
5960
|
+
const exchangeRate = exchangeRates[i] ?? 0;
|
|
5961
|
+
const inputTokenPrice = getTokenPrice(inputToken);
|
|
5962
|
+
const total = new bignumber_js_default(stakedBalance).multipliedBy(exchangeRate);
|
|
5963
|
+
const stakedAmount = total.dividedBy(10 ** inputToken.decimals);
|
|
5964
|
+
const stakedAmountUsd = inputTokenPrice === void 0 ? void 0 : stakedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
5965
|
+
return {
|
|
5966
|
+
token: inputToken,
|
|
5967
|
+
apr,
|
|
5968
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
5969
|
+
stakedAmountUsd,
|
|
5970
|
+
earnedAmount: 0,
|
|
5971
|
+
earnedAmountUsd: earningsSettled ? void 0 : 0,
|
|
5972
|
+
isLoadingEarnings: !earningsSettled
|
|
5973
|
+
};
|
|
5974
|
+
});
|
|
5975
|
+
}, [
|
|
5976
|
+
walletBalances,
|
|
5977
|
+
exchangeRates,
|
|
5978
|
+
stakingConfigs,
|
|
5979
|
+
apr,
|
|
5980
|
+
getTokenPrice,
|
|
5981
|
+
earningsSettled
|
|
5982
|
+
]);
|
|
6003
5983
|
const data = useMemo12(() => {
|
|
6004
5984
|
if (!positionsRaw || !walletBalances) return void 0;
|
|
6005
5985
|
return stakingConfigs.map((config, i) => {
|
|
6006
5986
|
const inputToken = config.inputTokens[0];
|
|
6007
5987
|
const stakingToken = config.receiptToken;
|
|
6008
5988
|
const { earnings, exchangeRate: exchangeRateRaw } = positionsRaw[i];
|
|
6009
|
-
const inputTokenPrice = getTokenPrice(inputToken)
|
|
5989
|
+
const inputTokenPrice = getTokenPrice(inputToken);
|
|
6010
5990
|
const stakedBalance = walletBalances.find((b) => b.address === stakingToken.address)?.balance.raw ?? "0";
|
|
6011
5991
|
const exchangeRate = exchangeRateRaw ?? 0;
|
|
6012
5992
|
const unrealisedGains = new bignumber_js_default(earnings.earningsTotal).minus(
|
|
@@ -6016,15 +5996,15 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6016
5996
|
const deposited = total.minus(unrealisedGains);
|
|
6017
5997
|
const stakedAmount = deposited.dividedBy(10 ** inputToken.decimals);
|
|
6018
5998
|
const earnedAmount = unrealisedGains.dividedBy(10 ** inputToken.decimals);
|
|
6019
|
-
const stakedAmountUsd = stakedAmount.multipliedBy(inputTokenPrice);
|
|
6020
|
-
const earnedAmountUsd = earnedAmount.multipliedBy(inputTokenPrice);
|
|
5999
|
+
const stakedAmountUsd = inputTokenPrice === void 0 ? void 0 : stakedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
6000
|
+
const earnedAmountUsd = inputTokenPrice === void 0 ? void 0 : earnedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
6021
6001
|
return {
|
|
6022
6002
|
token: inputToken,
|
|
6023
|
-
apr
|
|
6003
|
+
apr,
|
|
6024
6004
|
stakedAmount: stakedAmount.toNumber(),
|
|
6025
6005
|
earnedAmount: earnedAmount.toNumber(),
|
|
6026
|
-
stakedAmountUsd
|
|
6027
|
-
earnedAmountUsd
|
|
6006
|
+
stakedAmountUsd,
|
|
6007
|
+
earnedAmountUsd
|
|
6028
6008
|
};
|
|
6029
6009
|
});
|
|
6030
6010
|
}, [positionsRaw, walletBalances, stakingConfigs, apr, getTokenPrice]);
|
|
@@ -6037,13 +6017,25 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6037
6017
|
isLoading: isLoadingBalances && isLoadingPositions,
|
|
6038
6018
|
isLoadingBalances,
|
|
6039
6019
|
isLoadingPositions,
|
|
6040
|
-
isValidatingPositions
|
|
6020
|
+
isValidatingPositions,
|
|
6021
|
+
/**
|
|
6022
|
+
* Hard error: the RPC fast-path could not produce staked balances (wallet
|
|
6023
|
+
* balances or exchange-rate reads failed). Price and earnings backend
|
|
6024
|
+
* failures are intentionally excluded — those degrade gracefully (USD/APR
|
|
6025
|
+
* render as "—", earnings stop loading) so RPC-derived amounts still show.
|
|
6026
|
+
*/
|
|
6027
|
+
error: walletBalancesError ?? exchangeRatesError,
|
|
6028
|
+
/** Set when the earnings (slow path) request failed. */
|
|
6029
|
+
positionsError,
|
|
6030
|
+
/**
|
|
6031
|
+
* True once the earnings (slow path) request has settled — resolved or
|
|
6032
|
+
* errored. Consumers should stop showing an earnings loading state once
|
|
6033
|
+
* this is true, even if `data` never arrives (backend outage).
|
|
6034
|
+
*/
|
|
6035
|
+
earningsSettled
|
|
6041
6036
|
};
|
|
6042
6037
|
};
|
|
6043
6038
|
|
|
6044
|
-
// src/hooks/pol/useStakedSnapshots.ts
|
|
6045
|
-
import useSWR44 from "swr";
|
|
6046
|
-
|
|
6047
6039
|
// src/actions/pol/getStakingDailyAssets.ts
|
|
6048
6040
|
async function getStakingDailyAssets({
|
|
6049
6041
|
address,
|
|
@@ -6068,7 +6060,7 @@ function useStakedSnapshots({
|
|
|
6068
6060
|
addresses
|
|
6069
6061
|
}) {
|
|
6070
6062
|
const QUERY_KEY = range ? ["useStakedSnapshots", range, addresses] : null;
|
|
6071
|
-
const swrResponse =
|
|
6063
|
+
const swrResponse = useSWR(QUERY_KEY, async ([, range2, addresses2]) => {
|
|
6072
6064
|
const [...sortedStakingDailyAssetsArray] = await Promise.all([
|
|
6073
6065
|
...addresses2.map(async (address) => {
|
|
6074
6066
|
const unstakingDailyAssets = await getStakingDailyAssets({
|
|
@@ -6095,13 +6087,12 @@ function useStakedSnapshots({
|
|
|
6095
6087
|
}
|
|
6096
6088
|
|
|
6097
6089
|
// src/hooks/pol/useStakingVaultsMetadata.ts
|
|
6098
|
-
import
|
|
6099
|
-
import { usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
6090
|
+
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
6100
6091
|
var useStakingVaultsMetadata = (vaults = []) => {
|
|
6101
|
-
const publicClient =
|
|
6092
|
+
const publicClient = usePublicClient37();
|
|
6102
6093
|
const blockTime = useBlockTime();
|
|
6103
6094
|
const QUERY_KEY = vaults.length > 0 && publicClient && blockTime ? ["useStakingVaultMetadata", vaults, publicClient, blockTime] : null;
|
|
6104
|
-
return
|
|
6095
|
+
return useSWR(
|
|
6105
6096
|
QUERY_KEY,
|
|
6106
6097
|
async ([, vaults2, publicClient2, blockTime2]) => {
|
|
6107
6098
|
assertPublicClient(publicClient2);
|
|
@@ -6121,13 +6112,12 @@ var useStakingVaultsMetadata = (vaults = []) => {
|
|
|
6121
6112
|
};
|
|
6122
6113
|
|
|
6123
6114
|
// src/hooks/pol/useTotalStakedAmount.ts
|
|
6124
|
-
import
|
|
6125
|
-
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
6115
|
+
import { usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
6126
6116
|
function useTotalStakedAmount({
|
|
6127
6117
|
vaultAddresses
|
|
6128
6118
|
}) {
|
|
6129
|
-
const publicClient =
|
|
6130
|
-
const swrResponse =
|
|
6119
|
+
const publicClient = usePublicClient38();
|
|
6120
|
+
const swrResponse = useSWR(
|
|
6131
6121
|
vaultAddresses && publicClient ? ["useTotalStakedAmount", vaultAddresses] : null,
|
|
6132
6122
|
([, vaultAddresses2]) => {
|
|
6133
6123
|
return getTotalStakedAmount({ vaultAddresses: vaultAddresses2, publicClient });
|
|
@@ -6140,13 +6130,12 @@ function useTotalStakedAmount({
|
|
|
6140
6130
|
}
|
|
6141
6131
|
|
|
6142
6132
|
// src/hooks/pol/useUserVaultInfo.ts
|
|
6143
|
-
import
|
|
6144
|
-
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
6133
|
+
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
6145
6134
|
var useUserVaultInfo = (args, options) => {
|
|
6146
6135
|
const { address: account } = useBeraWallet22();
|
|
6147
|
-
const publicClient =
|
|
6136
|
+
const publicClient = usePublicClient39();
|
|
6148
6137
|
const QUERY_KEY = account && publicClient && args.vaultAddress ? ["useUserVaultInfo", account, args.vaultAddress] : null;
|
|
6149
|
-
const swrResponse =
|
|
6138
|
+
const swrResponse = useSWR(
|
|
6150
6139
|
QUERY_KEY,
|
|
6151
6140
|
async ([, account2, vaultAddress]) => {
|
|
6152
6141
|
assertPublicClient(publicClient);
|
|
@@ -6158,7 +6147,7 @@ var useUserVaultInfo = (args, options) => {
|
|
|
6158
6147
|
},
|
|
6159
6148
|
{
|
|
6160
6149
|
...options,
|
|
6161
|
-
refreshInterval: options?.
|
|
6150
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
6162
6151
|
}
|
|
6163
6152
|
);
|
|
6164
6153
|
return {
|
|
@@ -6168,13 +6157,12 @@ var useUserVaultInfo = (args, options) => {
|
|
|
6168
6157
|
};
|
|
6169
6158
|
|
|
6170
6159
|
// src/hooks/pol/useUserVaults.ts
|
|
6171
|
-
import
|
|
6172
|
-
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
6160
|
+
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
6173
6161
|
var useUserVaults = (options) => {
|
|
6174
6162
|
const { address: account } = useBeraWallet23();
|
|
6175
|
-
const publicClient =
|
|
6163
|
+
const publicClient = usePublicClient40();
|
|
6176
6164
|
const QUERY_KEY = account && publicClient ? ["useUserVaults", account] : null;
|
|
6177
|
-
const swrResponse =
|
|
6165
|
+
const swrResponse = useSWR(
|
|
6178
6166
|
QUERY_KEY,
|
|
6179
6167
|
async ([, account2]) => {
|
|
6180
6168
|
assertPublicClient(publicClient);
|
|
@@ -6185,7 +6173,7 @@ var useUserVaults = (options) => {
|
|
|
6185
6173
|
},
|
|
6186
6174
|
{
|
|
6187
6175
|
...options,
|
|
6188
|
-
refreshInterval: options?.
|
|
6176
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */,
|
|
6189
6177
|
keepPreviousData: true
|
|
6190
6178
|
}
|
|
6191
6179
|
);
|
|
@@ -6196,12 +6184,11 @@ var useUserVaults = (options) => {
|
|
|
6196
6184
|
};
|
|
6197
6185
|
|
|
6198
6186
|
// src/hooks/pol/useVaultAddress.ts
|
|
6199
|
-
import
|
|
6200
|
-
import { usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
6187
|
+
import { usePublicClient as usePublicClient41 } from "@berachain/wagmi/hooks";
|
|
6201
6188
|
var useVaultAddress = (vaultAddress) => {
|
|
6202
|
-
const publicClient =
|
|
6189
|
+
const publicClient = usePublicClient41();
|
|
6203
6190
|
const QUERY_KEY = vaultAddress && publicClient ? ["useVaultAddress", vaultAddress] : null;
|
|
6204
|
-
return
|
|
6191
|
+
return useSWR(QUERY_KEY, async ([, vaultAddress2]) => {
|
|
6205
6192
|
assertPublicClient(publicClient);
|
|
6206
6193
|
const [stakeToken] = await Promise.all([
|
|
6207
6194
|
getRewardVaultStakingToken({
|
|
@@ -6214,14 +6201,13 @@ var useVaultAddress = (vaultAddress) => {
|
|
|
6214
6201
|
};
|
|
6215
6202
|
|
|
6216
6203
|
// src/hooks/pol/useVaultHistory.ts
|
|
6217
|
-
import useSWR50 from "swr";
|
|
6218
6204
|
var useVaultHistory = ({
|
|
6219
6205
|
vault,
|
|
6220
6206
|
range,
|
|
6221
6207
|
resolution
|
|
6222
6208
|
}) => {
|
|
6223
6209
|
const QUERY_KEY = vault ? ["useVaultHistory", vault, range, resolution] : null;
|
|
6224
|
-
const swrResponse =
|
|
6210
|
+
const swrResponse = useSWR(
|
|
6225
6211
|
QUERY_KEY,
|
|
6226
6212
|
([, vault2, range2, resolution2]) => getVaultHistory({ vault: vault2, range: range2, resolution: resolution2 })
|
|
6227
6213
|
);
|
|
@@ -6232,10 +6218,9 @@ var useVaultHistory = ({
|
|
|
6232
6218
|
};
|
|
6233
6219
|
|
|
6234
6220
|
// src/hooks/pol/useVaultValidators.ts
|
|
6235
|
-
import useSWR51 from "swr";
|
|
6236
6221
|
var useVaultValidators = (id, options) => {
|
|
6237
6222
|
const QUERY_KEY = id ? ["useVaultValidators", id] : null;
|
|
6238
|
-
const swrResponse =
|
|
6223
|
+
const swrResponse = useSWR(
|
|
6239
6224
|
QUERY_KEY,
|
|
6240
6225
|
async ([, address]) => {
|
|
6241
6226
|
return await getVaultValidators({
|
|
@@ -6243,7 +6228,7 @@ var useVaultValidators = (id, options) => {
|
|
|
6243
6228
|
});
|
|
6244
6229
|
},
|
|
6245
6230
|
{
|
|
6246
|
-
...options
|
|
6231
|
+
...options
|
|
6247
6232
|
}
|
|
6248
6233
|
);
|
|
6249
6234
|
return {
|
|
@@ -6275,13 +6260,12 @@ function useBeraCurrentPrice(opts) {
|
|
|
6275
6260
|
}
|
|
6276
6261
|
|
|
6277
6262
|
// src/hooks/tokens/useStakingTokenInformation.ts
|
|
6278
|
-
import useSWRImmutable11 from "swr/immutable";
|
|
6279
6263
|
import { isAddress as isAddress12, zeroAddress as zeroAddress23 } from "viem";
|
|
6280
|
-
import { usePublicClient as
|
|
6264
|
+
import { usePublicClient as usePublicClient42 } from "@berachain/wagmi/hooks";
|
|
6281
6265
|
var useStakingTokenInformation = (args, options) => {
|
|
6282
|
-
const publicClient =
|
|
6266
|
+
const publicClient = usePublicClient42();
|
|
6283
6267
|
const QUERY_KEY = args?.address && publicClient && isAddress12(args.address) ? ["useStakingTokenInformation", args.address] : null;
|
|
6284
|
-
const swrResponse =
|
|
6268
|
+
const swrResponse = useSWRImmutable(
|
|
6285
6269
|
QUERY_KEY,
|
|
6286
6270
|
async ([_, address]) => {
|
|
6287
6271
|
if (isToken(address, "BERA")) {
|
|
@@ -6297,7 +6281,7 @@ var useStakingTokenInformation = (args, options) => {
|
|
|
6297
6281
|
publicClient
|
|
6298
6282
|
});
|
|
6299
6283
|
},
|
|
6300
|
-
{ ...options
|
|
6284
|
+
{ ...options }
|
|
6301
6285
|
);
|
|
6302
6286
|
return {
|
|
6303
6287
|
...swrResponse,
|
|
@@ -6307,23 +6291,23 @@ var useStakingTokenInformation = (args, options) => {
|
|
|
6307
6291
|
|
|
6308
6292
|
// src/hooks/tokens/useTokenPrice.ts
|
|
6309
6293
|
function useTokenPrice({ token }, options) {
|
|
6310
|
-
const { isLoading, priceMap } = useTokenPrices(
|
|
6294
|
+
const { isLoading, error, priceMap } = useTokenPrices(
|
|
6311
6295
|
{ tokens: token ? [token] : void 0 },
|
|
6312
6296
|
options
|
|
6313
6297
|
);
|
|
6314
6298
|
return {
|
|
6315
6299
|
data: token ? priceMap[token.chainId]?.[token.address.toLowerCase()] : void 0,
|
|
6316
|
-
isLoading
|
|
6300
|
+
isLoading,
|
|
6301
|
+
error
|
|
6317
6302
|
};
|
|
6318
6303
|
}
|
|
6319
6304
|
|
|
6320
6305
|
// src/hooks/tokens/useTotalSupply.ts
|
|
6321
|
-
import useSWR52 from "swr";
|
|
6322
6306
|
import { erc20Abi as erc20Abi5 } from "viem";
|
|
6323
|
-
import { usePublicClient as
|
|
6307
|
+
import { usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
6324
6308
|
function useTotalSupply({ address }) {
|
|
6325
|
-
const publicClient =
|
|
6326
|
-
return
|
|
6309
|
+
const publicClient = usePublicClient43();
|
|
6310
|
+
return useSWR(
|
|
6327
6311
|
address && publicClient ? ["useTotalSupply", address] : null,
|
|
6328
6312
|
([, address2]) => {
|
|
6329
6313
|
assertPublicClient(publicClient);
|
|
@@ -6338,15 +6322,14 @@ function useTotalSupply({ address }) {
|
|
|
6338
6322
|
}
|
|
6339
6323
|
|
|
6340
6324
|
// src/hooks/useBlockToTimestamp.ts
|
|
6341
|
-
import
|
|
6342
|
-
import { useBlockNumber, usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
6325
|
+
import { useBlockNumber, usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
6343
6326
|
function useBlockToTimestamp(inputBlock) {
|
|
6344
|
-
const publicClient =
|
|
6327
|
+
const publicClient = usePublicClient44();
|
|
6345
6328
|
const { config } = parseBaseArgs({ chainId: publicClient?.chain.id });
|
|
6346
6329
|
const { data: currentBlock, isLoading } = useBlockNumber({
|
|
6347
6330
|
cacheTime: seconds(config.averageBlockTime)
|
|
6348
6331
|
});
|
|
6349
|
-
const { data: block } =
|
|
6332
|
+
const { data: block } = useSWRImmutable(
|
|
6350
6333
|
currentBlock && publicClient && Number(inputBlock) > 0 ? ["useBlockToTimestamp", inputBlock, currentBlock] : null,
|
|
6351
6334
|
async ([, inputBlock2, currentBlock2]) => {
|
|
6352
6335
|
assertPublicClient(publicClient);
|
|
@@ -6497,7 +6480,6 @@ function useBeraContractWrite({
|
|
|
6497
6480
|
var useBeraContractWrite_default = useBeraContractWrite;
|
|
6498
6481
|
|
|
6499
6482
|
// src/hooks/useGetVerifiedAbi.ts
|
|
6500
|
-
import useSWRImmutable13 from "swr/immutable";
|
|
6501
6483
|
import { isAddress as isAddress13, zeroAddress as zeroAddress24 } from "viem";
|
|
6502
6484
|
import { chainId } from "@berachain/config/internal";
|
|
6503
6485
|
async function fetchVerifiedAbi(address) {
|
|
@@ -6512,7 +6494,7 @@ async function fetchVerifiedAbi(address) {
|
|
|
6512
6494
|
return data.result;
|
|
6513
6495
|
}
|
|
6514
6496
|
var useGetVerifiedAbi = (address) => {
|
|
6515
|
-
return
|
|
6497
|
+
return useSWRImmutable(
|
|
6516
6498
|
address && isAddress13(address) && // Address zero can't be a contract for sure
|
|
6517
6499
|
address !== zeroAddress24 ? ["useGetVerifiedAbi", address] : null,
|
|
6518
6500
|
() => address ? fetchVerifiedAbi(address) : Promise.resolve(""),
|
|
@@ -6568,7 +6550,6 @@ function usePrevious(value) {
|
|
|
6568
6550
|
}
|
|
6569
6551
|
|
|
6570
6552
|
// src/hooks/validators/useAllValidators.ts
|
|
6571
|
-
import useSWR53 from "swr";
|
|
6572
6553
|
var useAllValidatorsQueryKey = ({
|
|
6573
6554
|
variables
|
|
6574
6555
|
} = {}) => {
|
|
@@ -6576,7 +6557,7 @@ var useAllValidatorsQueryKey = ({
|
|
|
6576
6557
|
};
|
|
6577
6558
|
var useAllValidators = (variables, options) => {
|
|
6578
6559
|
const { config } = parseBaseArgs(variables);
|
|
6579
|
-
const swrResponse =
|
|
6560
|
+
const swrResponse = useSWR(
|
|
6580
6561
|
useAllValidatorsQueryKey({ variables }),
|
|
6581
6562
|
async ([, variables2]) => {
|
|
6582
6563
|
const result = await getAllValidators({
|
|
@@ -6589,7 +6570,7 @@ var useAllValidators = (variables, options) => {
|
|
|
6589
6570
|
},
|
|
6590
6571
|
{
|
|
6591
6572
|
refreshInterval: 18e4 /* SLOW */,
|
|
6592
|
-
...options
|
|
6573
|
+
...options
|
|
6593
6574
|
}
|
|
6594
6575
|
);
|
|
6595
6576
|
return {
|
|
@@ -6599,11 +6580,10 @@ var useAllValidators = (variables, options) => {
|
|
|
6599
6580
|
};
|
|
6600
6581
|
|
|
6601
6582
|
// src/hooks/validators/useApiEnrichedAllocation.ts
|
|
6602
|
-
import useSWR54 from "swr";
|
|
6603
6583
|
function useApiEnrichedAllocation({
|
|
6604
6584
|
allocation
|
|
6605
6585
|
}) {
|
|
6606
|
-
return
|
|
6586
|
+
return useSWR(
|
|
6607
6587
|
allocation ? ["useApiEnrichedAllocation", allocation] : null,
|
|
6608
6588
|
([, allocation2]) => {
|
|
6609
6589
|
return getApiEnrichedAllocation({ allocation: allocation2 });
|
|
@@ -6612,21 +6592,17 @@ function useApiEnrichedAllocation({
|
|
|
6612
6592
|
}
|
|
6613
6593
|
|
|
6614
6594
|
// src/hooks/validators/useApiValidator.ts
|
|
6615
|
-
import useSWR55 from "swr";
|
|
6616
6595
|
import { isHex } from "viem";
|
|
6617
6596
|
var useApiValidatorQueryKey = (id) => id ? ["useApiValidator", id] : null;
|
|
6618
6597
|
var useApiValidator = (id, options) => {
|
|
6619
6598
|
const QUERY_KEY = useApiValidatorQueryKey(id);
|
|
6620
|
-
const
|
|
6621
|
-
|
|
6622
|
-
isEnabled && id ? QUERY_KEY : null,
|
|
6599
|
+
const swrResponse = useSWR(
|
|
6600
|
+
id ? QUERY_KEY : null,
|
|
6623
6601
|
async ([, id2]) => {
|
|
6624
6602
|
if (!id2 || !isHex(id2)) throw new Error(`Invalid validator ID: ${id2}`);
|
|
6625
6603
|
return getApiValidator({ id: id2 });
|
|
6626
6604
|
},
|
|
6627
|
-
|
|
6628
|
-
...options?.opts
|
|
6629
|
-
}
|
|
6605
|
+
options
|
|
6630
6606
|
);
|
|
6631
6607
|
return {
|
|
6632
6608
|
...swrResponse,
|
|
@@ -6635,8 +6611,7 @@ var useApiValidator = (id, options) => {
|
|
|
6635
6611
|
};
|
|
6636
6612
|
|
|
6637
6613
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6638
|
-
import
|
|
6639
|
-
import { usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
6614
|
+
import { usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
6640
6615
|
|
|
6641
6616
|
// src/actions/validators/getBaselineRewardAllocation.ts
|
|
6642
6617
|
import { rewardAllocatorFactoryAbi as rewardAllocationFactoryAbi } from "@berachain/abis/pol/rewards/rewardAllocatorFactory";
|
|
@@ -6658,8 +6633,8 @@ async function getBaselineRewardAllocation({
|
|
|
6658
6633
|
|
|
6659
6634
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6660
6635
|
function useBaselineRewardAllocation() {
|
|
6661
|
-
const publicClient =
|
|
6662
|
-
return
|
|
6636
|
+
const publicClient = usePublicClient45();
|
|
6637
|
+
return useSWR(publicClient ? ["baselineRewardAllocation"] : null, () => {
|
|
6663
6638
|
assertPublicClient(publicClient);
|
|
6664
6639
|
return getBaselineRewardAllocation({
|
|
6665
6640
|
publicClient
|
|
@@ -6668,13 +6643,12 @@ function useBaselineRewardAllocation() {
|
|
|
6668
6643
|
}
|
|
6669
6644
|
|
|
6670
6645
|
// src/hooks/validators/useDailyValidatorBlockStats.ts
|
|
6671
|
-
import useSWR57 from "swr";
|
|
6672
6646
|
var useDailyValidatorBlockStats = ({
|
|
6673
6647
|
pubKey,
|
|
6674
6648
|
first = 1
|
|
6675
6649
|
}) => {
|
|
6676
6650
|
const QUERY_KEY = pubKey ? ["useDailyValidatorBlockStats", pubKey, first] : null;
|
|
6677
|
-
const swrResponse =
|
|
6651
|
+
const swrResponse = useSWR(
|
|
6678
6652
|
QUERY_KEY,
|
|
6679
6653
|
async ([, pubKey2, first2]) => {
|
|
6680
6654
|
return await getDailyValidatorBlockStats({
|
|
@@ -6690,12 +6664,11 @@ var useDailyValidatorBlockStats = ({
|
|
|
6690
6664
|
};
|
|
6691
6665
|
|
|
6692
6666
|
// src/hooks/validators/useDefaultRewardAllocation.ts
|
|
6693
|
-
import
|
|
6694
|
-
import { usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
6667
|
+
import { usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
6695
6668
|
function useDefaultRewardAllocation(options) {
|
|
6696
|
-
const publicClient =
|
|
6669
|
+
const publicClient = usePublicClient46();
|
|
6697
6670
|
const QUERY_KEY = publicClient ? ["useDefaultRewardAllocation"] : null;
|
|
6698
|
-
const swrResponse =
|
|
6671
|
+
const swrResponse = useSWR(
|
|
6699
6672
|
QUERY_KEY,
|
|
6700
6673
|
async () => {
|
|
6701
6674
|
assertPublicClient(publicClient);
|
|
@@ -6704,7 +6677,7 @@ function useDefaultRewardAllocation(options) {
|
|
|
6704
6677
|
});
|
|
6705
6678
|
},
|
|
6706
6679
|
{
|
|
6707
|
-
...options
|
|
6680
|
+
...options
|
|
6708
6681
|
}
|
|
6709
6682
|
);
|
|
6710
6683
|
return {
|
|
@@ -6715,8 +6688,7 @@ function useDefaultRewardAllocation(options) {
|
|
|
6715
6688
|
|
|
6716
6689
|
// src/hooks/validators/useManagedValidatorRole.ts
|
|
6717
6690
|
import { useMemo as useMemo13 } from "react";
|
|
6718
|
-
import
|
|
6719
|
-
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
6691
|
+
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient47 } from "@berachain/wagmi/hooks";
|
|
6720
6692
|
|
|
6721
6693
|
// src/actions/validators/getValidatorRewardAllocatorAddress.ts
|
|
6722
6694
|
import { zeroAddress as zeroAddress25 } from "viem";
|
|
@@ -6763,7 +6735,7 @@ function useManagedValidatorRole({
|
|
|
6763
6735
|
pubKey,
|
|
6764
6736
|
account: accountAddress
|
|
6765
6737
|
}, options) {
|
|
6766
|
-
const publicClient =
|
|
6738
|
+
const publicClient = usePublicClient47();
|
|
6767
6739
|
const mockValidatorOperator = useBeraFlag("mockValidatorOperator");
|
|
6768
6740
|
const mockValidatorRewardAllocator = useBeraFlag(
|
|
6769
6741
|
"mockValidatorRewardAllocator"
|
|
@@ -6771,7 +6743,7 @@ function useManagedValidatorRole({
|
|
|
6771
6743
|
const QUERY_KEY = publicClient && pubKey ? ["useManagedValidatorRole", pubKey] : null;
|
|
6772
6744
|
const { address: connectedAccount } = useBeraWallet24();
|
|
6773
6745
|
const account = accountAddress ?? connectedAccount;
|
|
6774
|
-
const swrResponse =
|
|
6746
|
+
const swrResponse = useSWR(
|
|
6775
6747
|
QUERY_KEY,
|
|
6776
6748
|
async ([, pubKey2]) => {
|
|
6777
6749
|
assertPublicClient(publicClient);
|
|
@@ -6791,7 +6763,7 @@ function useManagedValidatorRole({
|
|
|
6791
6763
|
};
|
|
6792
6764
|
},
|
|
6793
6765
|
{
|
|
6794
|
-
...options
|
|
6766
|
+
...options
|
|
6795
6767
|
}
|
|
6796
6768
|
);
|
|
6797
6769
|
const hasOperatorRole = useMemo13(() => {
|
|
@@ -6812,18 +6784,16 @@ function useManagedValidatorRole({
|
|
|
6812
6784
|
}
|
|
6813
6785
|
|
|
6814
6786
|
// src/hooks/validators/useOnChainValidator.ts
|
|
6815
|
-
import useSWR60 from "swr";
|
|
6816
6787
|
import { keccak256 as keccak2562 } from "viem";
|
|
6817
6788
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
6818
6789
|
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
6819
6790
|
import { beraChefAbi as beraChefAbi3 } from "@berachain/abis/pol/rewards/beraChef";
|
|
6820
|
-
import { usePublicClient as
|
|
6791
|
+
import { usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
6821
6792
|
var useOnChainValidator = ({ pubkey }, options) => {
|
|
6822
|
-
const publicClient =
|
|
6793
|
+
const publicClient = usePublicClient48();
|
|
6823
6794
|
const QUERY_KEY = pubkey ? ["useOnChainValidator", pubkey] : null;
|
|
6824
|
-
const
|
|
6825
|
-
|
|
6826
|
-
isEnabled && publicClient ? QUERY_KEY : null,
|
|
6795
|
+
const swrResponse = useSWR(
|
|
6796
|
+
publicClient ? QUERY_KEY : null,
|
|
6827
6797
|
async ([, pubkey2]) => {
|
|
6828
6798
|
assertPublicClient(publicClient);
|
|
6829
6799
|
const { config } = parseBaseArgs({
|
|
@@ -6855,7 +6825,8 @@ var useOnChainValidator = ({ pubkey }, options) => {
|
|
|
6855
6825
|
operator,
|
|
6856
6826
|
votingPower: Number(boostees)
|
|
6857
6827
|
};
|
|
6858
|
-
}
|
|
6828
|
+
},
|
|
6829
|
+
options
|
|
6859
6830
|
);
|
|
6860
6831
|
return {
|
|
6861
6832
|
...swrResponse,
|
|
@@ -6866,16 +6837,14 @@ var useOnChainValidator = ({ pubkey }, options) => {
|
|
|
6866
6837
|
};
|
|
6867
6838
|
|
|
6868
6839
|
// src/hooks/validators/useStakingPoolBatch.ts
|
|
6869
|
-
import
|
|
6870
|
-
import { usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
6840
|
+
import { usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
6871
6841
|
var useStakingPoolBatch = ({
|
|
6872
6842
|
valPubKey,
|
|
6873
6843
|
options
|
|
6874
6844
|
}) => {
|
|
6875
|
-
const publicClient =
|
|
6876
|
-
const
|
|
6877
|
-
const
|
|
6878
|
-
const swrResponse = useSWR61(
|
|
6845
|
+
const publicClient = usePublicClient49();
|
|
6846
|
+
const QUERY_KEY = publicClient && valPubKey ? ["useStakingPoolBatch", valPubKey] : null;
|
|
6847
|
+
const swrResponse = useSWR(
|
|
6879
6848
|
QUERY_KEY,
|
|
6880
6849
|
async ([, valPubKey2]) => {
|
|
6881
6850
|
assertPublicClient(publicClient);
|
|
@@ -6886,7 +6855,7 @@ var useStakingPoolBatch = ({
|
|
|
6886
6855
|
},
|
|
6887
6856
|
{
|
|
6888
6857
|
refreshInterval: 1e4 /* FAST */,
|
|
6889
|
-
...options
|
|
6858
|
+
...options
|
|
6890
6859
|
}
|
|
6891
6860
|
);
|
|
6892
6861
|
return {
|
|
@@ -6896,13 +6865,12 @@ var useStakingPoolBatch = ({
|
|
|
6896
6865
|
};
|
|
6897
6866
|
|
|
6898
6867
|
// src/hooks/validators/useUserActiveValidators.ts
|
|
6899
|
-
import
|
|
6900
|
-
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
6868
|
+
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
6901
6869
|
var useUserActiveValidators = (options) => {
|
|
6902
6870
|
const { address: account } = useBeraWallet25();
|
|
6903
|
-
const publicClient =
|
|
6871
|
+
const publicClient = usePublicClient50();
|
|
6904
6872
|
const QUERY_KEY = publicClient && account ? ["useUserActiveValidators", account] : null;
|
|
6905
|
-
const swrResponse =
|
|
6873
|
+
const swrResponse = useSWR(
|
|
6906
6874
|
QUERY_KEY,
|
|
6907
6875
|
async ([, account2]) => {
|
|
6908
6876
|
return await getUserActiveValidators({
|
|
@@ -6912,7 +6880,7 @@ var useUserActiveValidators = (options) => {
|
|
|
6912
6880
|
},
|
|
6913
6881
|
{
|
|
6914
6882
|
...options,
|
|
6915
|
-
refreshInterval: options?.
|
|
6883
|
+
refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */,
|
|
6916
6884
|
keepPreviousData: true
|
|
6917
6885
|
}
|
|
6918
6886
|
);
|
|
@@ -6923,17 +6891,16 @@ var useUserActiveValidators = (options) => {
|
|
|
6923
6891
|
};
|
|
6924
6892
|
|
|
6925
6893
|
// src/hooks/validators/useUserBoostsOnValidator.ts
|
|
6926
|
-
import
|
|
6927
|
-
import { useBeraWallet as useBeraWallet26, usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
6894
|
+
import { useBeraWallet as useBeraWallet26, usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
6928
6895
|
var useUserBoostsOnValidator = ({
|
|
6929
6896
|
pubkey,
|
|
6930
6897
|
...args
|
|
6931
6898
|
}) => {
|
|
6932
6899
|
const { address: connectedAccount } = useBeraWallet26();
|
|
6933
|
-
const publicClient =
|
|
6900
|
+
const publicClient = usePublicClient51();
|
|
6934
6901
|
const account = args.account ?? connectedAccount;
|
|
6935
6902
|
const QUERY_KEY = account && pubkey ? ["useUserBoostsOnValidator", pubkey, account] : null;
|
|
6936
|
-
const swrResponse =
|
|
6903
|
+
const swrResponse = useSWR(
|
|
6937
6904
|
QUERY_KEY,
|
|
6938
6905
|
async ([, pubkey2, account2]) => {
|
|
6939
6906
|
return await getUserBoostsOnValidator({
|
|
@@ -6951,7 +6918,6 @@ var useUserBoostsOnValidator = ({
|
|
|
6951
6918
|
|
|
6952
6919
|
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
6953
6920
|
import { useCallback as useCallback4, useMemo as useMemo14 } from "react";
|
|
6954
|
-
import useSWR64 from "swr";
|
|
6955
6921
|
import { useBeraWallet as useBeraWallet27 } from "@berachain/wagmi/hooks";
|
|
6956
6922
|
|
|
6957
6923
|
// src/utils/formatIncentivesTokenMap.ts
|
|
@@ -6973,7 +6939,7 @@ var formatIncentivesTokenMap = (allRewards) => {
|
|
|
6973
6939
|
var useUserClaimableIncentives = () => {
|
|
6974
6940
|
const { address: account } = useBeraWallet27();
|
|
6975
6941
|
const REWARDS_QUERY_KEY = account ? ["useUserClaimableIncentives", account] : null;
|
|
6976
|
-
const allRewardsResponse =
|
|
6942
|
+
const allRewardsResponse = useSWR(
|
|
6977
6943
|
REWARDS_QUERY_KEY,
|
|
6978
6944
|
async ([, account2]) => {
|
|
6979
6945
|
if (!account2) {
|
|
@@ -7014,7 +6980,7 @@ var useUserClaimableIncentives = () => {
|
|
|
7014
6980
|
return formatIncentivesTokenMap(allRewards);
|
|
7015
6981
|
}, [allRewards, account]);
|
|
7016
6982
|
const QUERY_KEY = account && allRewards ? ["useUserClaimableIncentives", account, allRewards] : null;
|
|
7017
|
-
const swrResponse =
|
|
6983
|
+
const swrResponse = useSWR(
|
|
7018
6984
|
QUERY_KEY,
|
|
7019
6985
|
async ([, account2, allRewards2]) => {
|
|
7020
6986
|
if (!account2) {
|
|
@@ -7073,13 +7039,12 @@ var useUserClaimableIncentives = () => {
|
|
|
7073
7039
|
};
|
|
7074
7040
|
|
|
7075
7041
|
// src/hooks/validators/useUserStakingPositions.ts
|
|
7076
|
-
import useSWRImmutable14 from "swr/immutable";
|
|
7077
7042
|
var useUserStakingPositions = ({
|
|
7078
7043
|
account,
|
|
7079
7044
|
validatorAddress
|
|
7080
7045
|
}) => {
|
|
7081
7046
|
const queryClient = account ? ["useUserStakingPositions", account, validatorAddress] : null;
|
|
7082
|
-
const swrResponse =
|
|
7047
|
+
const swrResponse = useSWRImmutable(
|
|
7083
7048
|
queryClient,
|
|
7084
7049
|
async ([_, account2, validatorAddress2]) => {
|
|
7085
7050
|
const userStakingPolls = await getUserStakingPositions(account2);
|
|
@@ -7144,13 +7109,12 @@ function useValidator({ pubkey }, options) {
|
|
|
7144
7109
|
}
|
|
7145
7110
|
|
|
7146
7111
|
// src/hooks/validators/useValidatorAnalytics.ts
|
|
7147
|
-
import useSWR65 from "swr";
|
|
7148
7112
|
function useValidatorAnalytics({
|
|
7149
7113
|
pubkey,
|
|
7150
7114
|
dayRange
|
|
7151
7115
|
}) {
|
|
7152
7116
|
const QUERY_KEY = pubkey && dayRange ? ["useValidatorAnalytics", pubkey, dayRange] : null;
|
|
7153
|
-
const swrResponse =
|
|
7117
|
+
const swrResponse = useSWR(
|
|
7154
7118
|
QUERY_KEY,
|
|
7155
7119
|
async ([, pubkey2, dayRange2]) => {
|
|
7156
7120
|
return await getValidatorAnalytics({
|
|
@@ -7166,12 +7130,11 @@ function useValidatorAnalytics({
|
|
|
7166
7130
|
}
|
|
7167
7131
|
|
|
7168
7132
|
// src/hooks/validators/useValidatorCommission.ts
|
|
7169
|
-
import
|
|
7170
|
-
import { usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
7133
|
+
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
7171
7134
|
var useValidatorCommission = (pubKey, options) => {
|
|
7172
|
-
const publicClient =
|
|
7135
|
+
const publicClient = usePublicClient52();
|
|
7173
7136
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorCommission", pubKey] : null;
|
|
7174
|
-
const swrResponse =
|
|
7137
|
+
const swrResponse = swr_default(
|
|
7175
7138
|
QUERY_KEY,
|
|
7176
7139
|
async ([, pubKey2]) => {
|
|
7177
7140
|
return await getValidatorCommission({
|
|
@@ -7180,7 +7143,7 @@ var useValidatorCommission = (pubKey, options) => {
|
|
|
7180
7143
|
});
|
|
7181
7144
|
},
|
|
7182
7145
|
{
|
|
7183
|
-
...options
|
|
7146
|
+
...options
|
|
7184
7147
|
}
|
|
7185
7148
|
);
|
|
7186
7149
|
return {
|
|
@@ -7203,9 +7166,6 @@ var useValidatorEstimatedBgtPerYear = (validator) => {
|
|
|
7203
7166
|
};
|
|
7204
7167
|
};
|
|
7205
7168
|
|
|
7206
|
-
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
7207
|
-
import useSWR67 from "swr";
|
|
7208
|
-
|
|
7209
7169
|
// src/actions/validators/getValidatorIncentiveDistribution.ts
|
|
7210
7170
|
async function getValidatorIncentiveDistribution({
|
|
7211
7171
|
pubkey,
|
|
@@ -7217,15 +7177,42 @@ async function getValidatorIncentiveDistribution({
|
|
|
7217
7177
|
level: "error"
|
|
7218
7178
|
});
|
|
7219
7179
|
}
|
|
7220
|
-
const
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7180
|
+
const { config } = parseBaseArgs({});
|
|
7181
|
+
if (!config.beep) {
|
|
7182
|
+
const params = new URLSearchParams({
|
|
7183
|
+
pubkey,
|
|
7184
|
+
dayRange: String(dayRange)
|
|
7185
|
+
});
|
|
7186
|
+
return beraFetchJson({
|
|
7187
|
+
url: `/api/pol/validator-incentive-distribution?${params}`,
|
|
7188
|
+
name: "pol-validator-incentive-distribution",
|
|
7189
|
+
type: "rest"
|
|
7190
|
+
});
|
|
7191
|
+
}
|
|
7192
|
+
const SECONDS_PER_DAY = 86400;
|
|
7193
|
+
const after = String(
|
|
7194
|
+
Math.floor(
|
|
7195
|
+
calculateTimestampFromDays(dayRange) / 1e6 / SECONDS_PER_DAY
|
|
7196
|
+
) * SECONDS_PER_DAY
|
|
7197
|
+
);
|
|
7198
|
+
const PER_PAGE = 1e3;
|
|
7199
|
+
const rows = [];
|
|
7200
|
+
let page = 1;
|
|
7201
|
+
while (true) {
|
|
7202
|
+
const pageRows = await fetchBeep("/v0/validators/{pubkey}/incentives", {
|
|
7203
|
+
path: { pubkey },
|
|
7204
|
+
query: {
|
|
7205
|
+
interval: "day",
|
|
7206
|
+
after,
|
|
7207
|
+
page: String(page),
|
|
7208
|
+
perPage: String(PER_PAGE)
|
|
7209
|
+
}
|
|
7210
|
+
});
|
|
7211
|
+
rows.push(...pageRows);
|
|
7212
|
+
if (pageRows.length < PER_PAGE) break;
|
|
7213
|
+
page++;
|
|
7214
|
+
}
|
|
7215
|
+
return rows;
|
|
7229
7216
|
}
|
|
7230
7217
|
|
|
7231
7218
|
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
@@ -7234,7 +7221,7 @@ function useValidatorIncentiveDistribution({
|
|
|
7234
7221
|
dayRange
|
|
7235
7222
|
}) {
|
|
7236
7223
|
const QUERY_KEY = pubkey && dayRange ? ["useValidatorIncentiveDistribution", pubkey, dayRange] : null;
|
|
7237
|
-
const swrResponse =
|
|
7224
|
+
const swrResponse = useSWR(
|
|
7238
7225
|
QUERY_KEY,
|
|
7239
7226
|
async ([, pubkey2, dayRange2]) => {
|
|
7240
7227
|
return await getValidatorIncentiveDistribution({ pubkey: pubkey2, dayRange: dayRange2 });
|
|
@@ -7247,12 +7234,11 @@ function useValidatorIncentiveDistribution({
|
|
|
7247
7234
|
}
|
|
7248
7235
|
|
|
7249
7236
|
// src/hooks/validators/useValidatorQueuedCommission.ts
|
|
7250
|
-
import
|
|
7251
|
-
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
7237
|
+
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
7252
7238
|
function useValidatorQueuedCommission(pubKey, options) {
|
|
7253
|
-
const publicClient =
|
|
7239
|
+
const publicClient = usePublicClient53();
|
|
7254
7240
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedCommission", pubKey] : null;
|
|
7255
|
-
const swrResponse =
|
|
7241
|
+
const swrResponse = useSWR(
|
|
7256
7242
|
QUERY_KEY,
|
|
7257
7243
|
async ([, pubKey2]) => {
|
|
7258
7244
|
assertPublicClient(publicClient);
|
|
@@ -7262,7 +7248,7 @@ function useValidatorQueuedCommission(pubKey, options) {
|
|
|
7262
7248
|
});
|
|
7263
7249
|
},
|
|
7264
7250
|
{
|
|
7265
|
-
...options
|
|
7251
|
+
...options
|
|
7266
7252
|
}
|
|
7267
7253
|
);
|
|
7268
7254
|
return {
|
|
@@ -7272,12 +7258,11 @@ function useValidatorQueuedCommission(pubKey, options) {
|
|
|
7272
7258
|
}
|
|
7273
7259
|
|
|
7274
7260
|
// src/hooks/validators/useValidatorQueuedOperatorAddress.ts
|
|
7275
|
-
import
|
|
7276
|
-
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
7261
|
+
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
7277
7262
|
var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
7278
|
-
const publicClient =
|
|
7263
|
+
const publicClient = usePublicClient54();
|
|
7279
7264
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedOperatorAddress", pubKey] : null;
|
|
7280
|
-
const swrResponse =
|
|
7265
|
+
const swrResponse = useSWR(
|
|
7281
7266
|
QUERY_KEY,
|
|
7282
7267
|
async ([, pubKey2]) => {
|
|
7283
7268
|
return await getValidatorQueuedOperatorAddress({
|
|
@@ -7286,7 +7271,7 @@ var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
|
7286
7271
|
});
|
|
7287
7272
|
},
|
|
7288
7273
|
{
|
|
7289
|
-
...options
|
|
7274
|
+
...options
|
|
7290
7275
|
}
|
|
7291
7276
|
);
|
|
7292
7277
|
return {
|
|
@@ -7296,12 +7281,11 @@ var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
|
7296
7281
|
};
|
|
7297
7282
|
|
|
7298
7283
|
// src/hooks/validators/useValidatorQueuedRewardAllocation.ts
|
|
7299
|
-
import
|
|
7300
|
-
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
7284
|
+
import { usePublicClient as usePublicClient55 } from "@berachain/wagmi/hooks";
|
|
7301
7285
|
var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
7302
|
-
const publicClient =
|
|
7286
|
+
const publicClient = usePublicClient55();
|
|
7303
7287
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedRewardAllocation", pubKey] : null;
|
|
7304
|
-
const swrResponse =
|
|
7288
|
+
const swrResponse = useSWR(
|
|
7305
7289
|
QUERY_KEY,
|
|
7306
7290
|
async ([, pubKey2]) => {
|
|
7307
7291
|
return await getValidatorQueuedRewardAllocation({
|
|
@@ -7310,7 +7294,7 @@ var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
|
7310
7294
|
});
|
|
7311
7295
|
},
|
|
7312
7296
|
{
|
|
7313
|
-
...options
|
|
7297
|
+
...options
|
|
7314
7298
|
}
|
|
7315
7299
|
);
|
|
7316
7300
|
return {
|
|
@@ -7320,12 +7304,11 @@ var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
|
7320
7304
|
};
|
|
7321
7305
|
|
|
7322
7306
|
// src/hooks/validators/useValidatorRewardAllocation.ts
|
|
7323
|
-
import
|
|
7324
|
-
import { usePublicClient as usePublicClient55 } from "@berachain/wagmi/hooks";
|
|
7307
|
+
import { usePublicClient as usePublicClient56 } from "@berachain/wagmi/hooks";
|
|
7325
7308
|
function useValidatorRewardAllocation(pubKey, options) {
|
|
7326
|
-
const publicClient =
|
|
7309
|
+
const publicClient = usePublicClient56();
|
|
7327
7310
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorRewardAllocation", pubKey] : null;
|
|
7328
|
-
const swrResponse =
|
|
7311
|
+
const swrResponse = useSWR(
|
|
7329
7312
|
QUERY_KEY,
|
|
7330
7313
|
async ([, pubKey2]) => {
|
|
7331
7314
|
return getValidatorRewardAllocation({
|
|
@@ -7334,7 +7317,7 @@ function useValidatorRewardAllocation(pubKey, options) {
|
|
|
7334
7317
|
});
|
|
7335
7318
|
},
|
|
7336
7319
|
{
|
|
7337
|
-
...options
|
|
7320
|
+
...options
|
|
7338
7321
|
}
|
|
7339
7322
|
);
|
|
7340
7323
|
return {
|
|
@@ -7368,6 +7351,7 @@ export {
|
|
|
7368
7351
|
useBeraCurrentPrice,
|
|
7369
7352
|
useBexStatus,
|
|
7370
7353
|
useBgtAprSimulation,
|
|
7354
|
+
useBgtIncentiveDistributorPaused,
|
|
7371
7355
|
useBgtUnstakedBalance,
|
|
7372
7356
|
useBlockToTimestamp,
|
|
7373
7357
|
useCappedGlobally,
|