@berachain/berajs 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
- package/dist/actions/clients/exports.d.ts +5 -21
- package/dist/actions/clients/exports.mjs +5 -7
- package/dist/actions/exports.d.ts +117 -31
- package/dist/actions/exports.mjs +36 -25
- package/dist/actions/governance/exports.d.ts +3 -11
- package/dist/actions/server/exports.mjs +2 -2
- package/dist/chunk-4ML4Y6UN.mjs +46 -0
- package/dist/{chunk-7YVNSDXG.mjs → chunk-FGION6F6.mjs} +1 -1
- package/dist/{chunk-3JJLQ2JX.mjs → chunk-MKSFQIKC.mjs} +1 -4
- package/dist/{chunk-ZLTMIFCZ.mjs → chunk-RFJGL4MF.mjs} +3 -3
- package/dist/{chunk-Y6THHG77.mjs → chunk-T43JPYQS.mjs} +1 -1
- package/dist/{chunk-WNBWX23Q.mjs → chunk-W2VODV76.mjs} +7 -10
- package/dist/{chunk-QBBOWFMH.mjs → chunk-XDG26EG6.mjs} +115 -162
- package/dist/{chunk-P5WXXULM.mjs → chunk-YLTWPFCJ.mjs} +3 -18
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +6 -4
- package/dist/enum/exports.d.ts +8 -2
- package/dist/errors/exports.mjs +2 -2
- package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
- package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
- package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +8 -59
- package/dist/{global.d-BuGDKh4k.d.ts → global.d-CR3zicga.d.ts} +3 -10
- package/dist/hooks/exports.d.ts +145 -403
- package/dist/hooks/exports.mjs +496 -755
- package/dist/hooks/governance/exports.d.ts +24 -19
- package/dist/hooks/governance/exports.mjs +43 -53
- package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
- package/dist/types/exports.d.ts +5 -5
- package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
- package/dist/utils/exports.d.ts +2 -2
- package/dist/utils/exports.mjs +6 -2
- package/package.json +8 -7
- package/src/actions/bend/getMaxDeposit.ts +28 -2
- package/src/actions/clients/exports.ts +0 -1
- package/src/actions/clients/fetchBeep.ts +0 -7
- package/src/actions/clients/fetchOpenApi.ts +10 -6
- package/src/actions/clients/fetchOpenApi.unit.test.ts +20 -14
- package/src/actions/clients/getApolloClient.ts +4 -9
- package/src/actions/exports.ts +1 -1
- package/src/actions/honey/getChartData.ts +14 -14
- package/src/actions/honey/getHoney24hVolume.ts +17 -8
- package/src/actions/honey/getHoneyTxns.ts +45 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +3 -3
- package/src/actions/pol/getEarnedStakedBeraVault.ts +0 -15
- package/src/actions/pol/getGlobalData.ts +10 -29
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getSWBeraVaultMetadata.ts +0 -7
- package/src/actions/pol/getStakingDailyAssets.ts +0 -14
- package/src/actions/validators/getApiEnrichedAllocation.ts +1 -1
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +43 -13
- package/src/contexts/SwrFallback.tsx +2 -1
- package/src/data/contracts.ts +4 -0
- package/src/errors/RequestError.ts +3 -3
- package/src/errors/getRevertReason.integration.test.ts +5 -1
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -11
- package/src/hooks/dex/useAggregatorsQuotes.ts +13 -11
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -7
- package/src/hooks/dex/useAllUserPools.ts +8 -13
- package/src/hooks/dex/useApiPool.ts +2 -9
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -2
- package/src/hooks/dex/useOnChainPoolData.ts +3 -4
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +3 -9
- package/src/hooks/dex/usePoolEvents.ts +1 -2
- package/src/hooks/dex/usePoolHistoricalData.ts +3 -9
- package/src/hooks/dex/usePools.ts +6 -4
- package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
- package/src/hooks/enso/useBendDemultiply.ts +3 -4
- package/src/hooks/enso/useBendMultiply.ts +3 -4
- package/src/hooks/enso/useBendZapSupply.ts +4 -5
- package/src/hooks/enso/useEnsoSwapBundle.ts +2 -2
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +4 -10
- package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
- package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
- package/src/hooks/enso/useZapStakeBera.ts +2 -5
- package/src/hooks/exports.ts +1 -0
- package/src/hooks/governance/useGetPastVotes.ts +1 -1
- package/src/hooks/governance/useHasVoted.ts +1 -1
- package/src/hooks/governance/useIsCanceller.ts +1 -1
- package/src/hooks/governance/usePollAllProposals.ts +13 -12
- package/src/hooks/governance/usePollProposal.ts +7 -10
- package/src/hooks/governance/usePollProposalThreshold.ts +2 -7
- package/src/hooks/governance/usePollProposalVotes.ts +23 -5
- package/src/hooks/governance/usePollUserDelegates.ts +4 -9
- package/src/hooks/governance/useProposalFromTx.ts +4 -5
- package/src/hooks/governance/useProposalSnapshot.ts +3 -4
- package/src/hooks/governance/useProposalState.ts +3 -3
- package/src/hooks/governance/useProposalTimelockState.ts +3 -2
- package/src/hooks/governance/useQuorum.ts +1 -2
- package/src/hooks/honey/useCappedGlobally.ts +4 -12
- package/src/hooks/honey/useCappedRelatively.ts +3 -8
- package/src/hooks/honey/useCollateralWeights.ts +4 -9
- package/src/hooks/honey/useHoney24hVolume.ts +2 -6
- package/src/hooks/honey/useHoneyBalances.ts +2 -7
- package/src/hooks/honey/useHoneyChartData.ts +4 -12
- package/src/hooks/honey/useHoneyVaultsBalance.ts +3 -9
- package/src/hooks/honey/useIsBadCollateralAsset.ts +5 -13
- package/src/hooks/honey/useIsBasketModeEnabled.ts +5 -13
- package/src/hooks/honey/usePythLatestPrices.ts +15 -13
- package/src/hooks/perps/usePythUpdateFee.ts +13 -11
- package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -8
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +2 -8
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +34 -0
- package/src/hooks/pol/useBgtUnstakedBalance.ts +3 -8
- package/src/hooks/pol/useClaimableFees.ts +2 -6
- package/src/hooks/pol/useHighestVaultsAPR.ts +6 -11
- package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
- package/src/hooks/pol/usePollGlobalData.ts +3 -9
- package/src/hooks/pol/usePollMarkets.ts +3 -8
- package/src/hooks/pol/useQueuedBeraUnlock.ts +3 -12
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
- package/src/hooks/pol/useRewardVault.ts +9 -8
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +6 -6
- package/src/hooks/pol/useRewardVaultFromToken.ts +24 -30
- package/src/hooks/pol/useRewardVaultIncentives.ts +2 -7
- package/src/hooks/pol/useRewardVaultRewards.ts +3 -8
- package/src/hooks/pol/useRewardVaults.ts +4 -12
- package/src/hooks/pol/useStakedAPR.ts +2 -8
- package/src/hooks/pol/useStakedData.ts +90 -41
- package/src/hooks/pol/useStakedSnapshots.ts +4 -9
- package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
- package/src/hooks/pol/useTotalStakedAmount.ts +2 -8
- package/src/hooks/pol/useUserVaultInfo.ts +3 -8
- package/src/hooks/pol/useUserVaults.ts +3 -8
- package/src/hooks/pol/useVaultAddress.ts +1 -1
- package/src/hooks/pol/useVaultHistory.ts +2 -8
- package/src/hooks/pol/useVaultValidators.ts +3 -8
- package/src/hooks/tokens/useMultipleTokenInformation.ts +3 -8
- package/src/hooks/tokens/usePollAllowances.ts +4 -11
- package/src/hooks/tokens/usePollBalance.ts +2 -5
- package/src/hooks/tokens/usePollWalletBalances.ts +3 -3
- package/src/hooks/tokens/useStakingTokenInformation.ts +3 -12
- package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
- package/src/hooks/tokens/useTokenInformation.ts +3 -8
- package/src/hooks/tokens/useTokenPrice.ts +2 -1
- package/src/hooks/tokens/useTokenPrices.ts +3 -4
- package/src/hooks/tokens/useTotalSupply.ts +1 -1
- package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
- package/src/hooks/useBlockToTimestamp.ts +1 -2
- package/src/hooks/useGetVerifiedAbi.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +3 -9
- package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +4 -12
- package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +2 -4
- package/src/hooks/validators/useDefaultRewardAllocation.ts +3 -9
- package/src/hooks/validators/useManagedValidatorRole.ts +2 -3
- package/src/hooks/validators/useOnChainValidator.ts +4 -11
- package/src/hooks/validators/useStakingPoolBatch.ts +4 -10
- package/src/hooks/validators/useUserActiveValidators.ts +3 -9
- package/src/hooks/validators/useUserBoostsOnValidator.ts +2 -4
- package/src/hooks/validators/useUserClaimableIncentives.ts +3 -3
- package/src/hooks/validators/useUserStakingPositions.ts +3 -9
- package/src/hooks/validators/useValidatorAnalytics.ts +2 -4
- package/src/hooks/validators/useValidatorCommission.ts +3 -8
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -6
- package/src/hooks/validators/useValidatorQueuedCommission.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +3 -8
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +3 -8
- package/src/hooks/validators/useValidatorRewardAllocation.ts +3 -8
- package/src/types/global.d.ts +7 -10
- package/src/types/pol.d.ts +17 -3
- package/dist/polling-BKnyavLI.d.ts +0 -8
- package/src/actions/clients/fetchRailwayBackend.ts +0 -34
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
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,12 +71,11 @@ import {
|
|
|
70
71
|
getVaultValidators,
|
|
71
72
|
isBadCollateralAsset,
|
|
72
73
|
isBasketModeEnabled
|
|
73
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-XDG26EG6.mjs";
|
|
74
75
|
import {
|
|
75
|
-
fetchBeep
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
import "../chunk-3JJLQ2JX.mjs";
|
|
76
|
+
fetchBeep
|
|
77
|
+
} from "../chunk-YLTWPFCJ.mjs";
|
|
78
|
+
import "../chunk-MKSFQIKC.mjs";
|
|
79
79
|
import "../chunk-CDK4YV3D.mjs";
|
|
80
80
|
import {
|
|
81
81
|
TokenContext,
|
|
@@ -84,7 +84,12 @@ import {
|
|
|
84
84
|
useBlockTime,
|
|
85
85
|
useEnsoUserTokensWithBalances,
|
|
86
86
|
useHoneyConfig
|
|
87
|
-
} from "../chunk-
|
|
87
|
+
} from "../chunk-W2VODV76.mjs";
|
|
88
|
+
import {
|
|
89
|
+
swr_default,
|
|
90
|
+
useSWR,
|
|
91
|
+
useSWRImmutable
|
|
92
|
+
} from "../chunk-4ML4Y6UN.mjs";
|
|
88
93
|
import {
|
|
89
94
|
getEnsoClient,
|
|
90
95
|
getWalletBalances
|
|
@@ -98,7 +103,7 @@ import {
|
|
|
98
103
|
import {
|
|
99
104
|
BeraMonitoring,
|
|
100
105
|
initBeraError
|
|
101
|
-
} from "../chunk-
|
|
106
|
+
} from "../chunk-FGION6F6.mjs";
|
|
102
107
|
import {
|
|
103
108
|
assertAddress,
|
|
104
109
|
assertAmount,
|
|
@@ -113,13 +118,14 @@ import {
|
|
|
113
118
|
import {
|
|
114
119
|
DEFAULT_METAMASK_GAS_LIMIT,
|
|
115
120
|
bignumber_js_default,
|
|
121
|
+
calculateTimestampFromDays,
|
|
116
122
|
getPythDefaultUpdateFee,
|
|
117
123
|
msToSeconds,
|
|
118
124
|
seconds
|
|
119
125
|
} from "../chunk-E7YFXBBQ.mjs";
|
|
120
126
|
import {
|
|
121
127
|
beraFetchJson
|
|
122
|
-
} from "../chunk-
|
|
128
|
+
} from "../chunk-T43JPYQS.mjs";
|
|
123
129
|
import "../chunk-BGMRHTBQ.mjs";
|
|
124
130
|
import {
|
|
125
131
|
beraToken,
|
|
@@ -132,14 +138,13 @@ import {
|
|
|
132
138
|
import "../chunk-SZ5C44L5.mjs";
|
|
133
139
|
import {
|
|
134
140
|
RequestError
|
|
135
|
-
} from "../chunk-
|
|
141
|
+
} from "../chunk-RFJGL4MF.mjs";
|
|
136
142
|
import {
|
|
137
143
|
BeraError,
|
|
138
144
|
InvalidArgumentError
|
|
139
145
|
} from "../chunk-KHXJDYA4.mjs";
|
|
140
146
|
|
|
141
147
|
// src/hooks/bend/useGetConvertToAssets.ts
|
|
142
|
-
import useSWR from "swr";
|
|
143
148
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
144
149
|
var useGetConvertToAssets = ({
|
|
145
150
|
sharesAmount,
|
|
@@ -147,7 +152,7 @@ var useGetConvertToAssets = ({
|
|
|
147
152
|
vaultChainId
|
|
148
153
|
}, options) => {
|
|
149
154
|
const publicClient = usePublicClient({ chainId: vaultChainId });
|
|
150
|
-
|
|
155
|
+
return useSWR(
|
|
151
156
|
publicClient && sharesAmount && vaultAddress ? ["useGetConvertToAssets", sharesAmount, vaultAddress, vaultChainId] : null,
|
|
152
157
|
async ([_, sharesAmount2, vaultAddress2]) => {
|
|
153
158
|
assertPublicClient(publicClient);
|
|
@@ -158,15 +163,9 @@ var useGetConvertToAssets = ({
|
|
|
158
163
|
});
|
|
159
164
|
},
|
|
160
165
|
{
|
|
161
|
-
...options
|
|
166
|
+
...options
|
|
162
167
|
}
|
|
163
168
|
);
|
|
164
|
-
return {
|
|
165
|
-
...swrResponse,
|
|
166
|
-
refresh: () => {
|
|
167
|
-
swrResponse.mutate();
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
// src/hooks/dex/useAggregatorsQuotes.ts
|
|
@@ -1386,7 +1385,6 @@ var WBeraAggregator = class extends BaseAggregator {
|
|
|
1386
1385
|
var wberaSwap = new WBeraAggregator();
|
|
1387
1386
|
|
|
1388
1387
|
// src/hooks/tokens/useUnderlyingAsset.ts
|
|
1389
|
-
import useSWRImmutable from "swr/immutable";
|
|
1390
1388
|
import { useConfig } from "@berachain/wagmi/hooks";
|
|
1391
1389
|
|
|
1392
1390
|
// src/actions/tokens/getUnderlyingToken.ts
|
|
@@ -1433,7 +1431,6 @@ function useUnderlyingAsset({ token }) {
|
|
|
1433
1431
|
}
|
|
1434
1432
|
|
|
1435
1433
|
// src/hooks/dex/useAggregatorsRouterFeeBps.ts
|
|
1436
|
-
import useSWRImmutable2 from "swr/immutable";
|
|
1437
1434
|
import { zeroAddress as zeroAddress8 } from "viem";
|
|
1438
1435
|
import aggregatorsRouterAbi7 from "@berachain/abis/meta-aggregator/metaAggregatorV2";
|
|
1439
1436
|
import { usePublicClient as usePublicClient2 } from "@berachain/wagmi/hooks";
|
|
@@ -1442,7 +1439,7 @@ var useAggregatorsRouterFeeBps = () => {
|
|
|
1442
1439
|
const { config } = parseBaseArgs({
|
|
1443
1440
|
chainId: publicClient.chain?.id
|
|
1444
1441
|
});
|
|
1445
|
-
|
|
1442
|
+
return useSWRImmutable(
|
|
1446
1443
|
publicClient && config.bex.aggregatorsRouter && config.bex.aggregatorsRouter !== zeroAddress8 ? ["useAggregatorsRouterFeeBps", config.bex.aggregatorsRouter] : null,
|
|
1447
1444
|
async ([, aggregatorsRouter]) => {
|
|
1448
1445
|
const fee = await publicClient.readContract({
|
|
@@ -1453,14 +1450,9 @@ var useAggregatorsRouterFeeBps = () => {
|
|
|
1453
1450
|
return Number(fee);
|
|
1454
1451
|
}
|
|
1455
1452
|
);
|
|
1456
|
-
return {
|
|
1457
|
-
...swrResponse,
|
|
1458
|
-
refresh: swrResponse.mutate
|
|
1459
|
-
};
|
|
1460
1453
|
};
|
|
1461
1454
|
|
|
1462
1455
|
// src/hooks/dex/useSingleAggregatorQuote.ts
|
|
1463
|
-
import useSWR2 from "swr";
|
|
1464
1456
|
import { parseUnits as parseUnits2, zeroAddress as zeroAddress9 } from "viem";
|
|
1465
1457
|
import { useBeraWallet, usePublicClient as usePublicClient3 } from "@berachain/wagmi/hooks";
|
|
1466
1458
|
var USE_AGGREGATORS_QUOTES_QUERY_KEY = "useAggregatorsQuotes";
|
|
@@ -1469,13 +1461,9 @@ function getQueryKey({
|
|
|
1469
1461
|
account,
|
|
1470
1462
|
args,
|
|
1471
1463
|
feeBps,
|
|
1472
|
-
options,
|
|
1473
1464
|
activeAggregators,
|
|
1474
1465
|
isMAEnabled
|
|
1475
1466
|
}) {
|
|
1476
|
-
if (options?.opts?.isEnabled !== void 0 && !options?.opts?.isEnabled) {
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
1467
|
if (!Number(args.amount)) {
|
|
1480
1468
|
return null;
|
|
1481
1469
|
}
|
|
@@ -1573,13 +1561,12 @@ function raw_useSingleAggregatorQuote({
|
|
|
1573
1561
|
isMAEnabled,
|
|
1574
1562
|
...args
|
|
1575
1563
|
}, options) {
|
|
1576
|
-
return
|
|
1564
|
+
return useSWR(
|
|
1577
1565
|
getQueryKey({
|
|
1578
1566
|
aggregator: args.aggregator,
|
|
1579
1567
|
account,
|
|
1580
1568
|
args,
|
|
1581
1569
|
feeBps,
|
|
1582
|
-
options,
|
|
1583
1570
|
activeAggregators,
|
|
1584
1571
|
isMAEnabled
|
|
1585
1572
|
}),
|
|
@@ -1588,7 +1575,7 @@ function raw_useSingleAggregatorQuote({
|
|
|
1588
1575
|
proxyAggregatorsThroughVercel,
|
|
1589
1576
|
publicClient
|
|
1590
1577
|
}),
|
|
1591
|
-
options
|
|
1578
|
+
options
|
|
1592
1579
|
);
|
|
1593
1580
|
}
|
|
1594
1581
|
function getAggregatorsSWROptions(options) {
|
|
@@ -1596,16 +1583,10 @@ function getAggregatorsSWROptions(options) {
|
|
|
1596
1583
|
refreshInterval: 1e4 /* FAST */,
|
|
1597
1584
|
// every 10s
|
|
1598
1585
|
errorRetryCount: 3,
|
|
1599
|
-
...options
|
|
1586
|
+
...options,
|
|
1600
1587
|
// biome-ignore lint/nursery/useMaxParams: the function is defined in the SWRConfiguration type
|
|
1601
1588
|
onErrorRetry(err, key, config, revalidate, revalidateOpts) {
|
|
1602
|
-
options?.
|
|
1603
|
-
err,
|
|
1604
|
-
key,
|
|
1605
|
-
config,
|
|
1606
|
-
revalidate,
|
|
1607
|
-
revalidateOpts
|
|
1608
|
-
);
|
|
1589
|
+
options?.onErrorRetry?.(err, key, config, revalidate, revalidateOpts);
|
|
1609
1590
|
if (err instanceof BeraError) {
|
|
1610
1591
|
if (err.reason === BaseAggregator.PATH_NOT_FOUND_REASON) {
|
|
1611
1592
|
return;
|
|
@@ -1651,7 +1632,7 @@ function useSingleAggregatorQuote(args, options) {
|
|
|
1651
1632
|
publicClient,
|
|
1652
1633
|
proxyAggregatorsThroughVercel
|
|
1653
1634
|
},
|
|
1654
|
-
|
|
1635
|
+
getAggregatorsSWROptions(options)
|
|
1655
1636
|
);
|
|
1656
1637
|
}
|
|
1657
1638
|
|
|
@@ -1702,7 +1683,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1702
1683
|
...args,
|
|
1703
1684
|
aggregator: oogabooga
|
|
1704
1685
|
},
|
|
1705
|
-
|
|
1686
|
+
swrOptions
|
|
1706
1687
|
);
|
|
1707
1688
|
const flyResult = raw_useSingleAggregatorQuote(
|
|
1708
1689
|
{
|
|
@@ -1710,7 +1691,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1710
1691
|
...args,
|
|
1711
1692
|
aggregator: fly
|
|
1712
1693
|
},
|
|
1713
|
-
|
|
1694
|
+
swrOptions
|
|
1714
1695
|
);
|
|
1715
1696
|
const erc4626Result = raw_useSingleAggregatorQuote(
|
|
1716
1697
|
{
|
|
@@ -1718,7 +1699,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1718
1699
|
...args,
|
|
1719
1700
|
aggregator: erc4626Deposit
|
|
1720
1701
|
},
|
|
1721
|
-
|
|
1702
|
+
swrOptions
|
|
1722
1703
|
);
|
|
1723
1704
|
const kyberswapResult = raw_useSingleAggregatorQuote(
|
|
1724
1705
|
{
|
|
@@ -1726,7 +1707,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1726
1707
|
...args,
|
|
1727
1708
|
aggregator: kyberswap
|
|
1728
1709
|
},
|
|
1729
|
-
|
|
1710
|
+
swrOptions
|
|
1730
1711
|
);
|
|
1731
1712
|
const openOceanResult = raw_useSingleAggregatorQuote(
|
|
1732
1713
|
{
|
|
@@ -1734,7 +1715,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1734
1715
|
...args,
|
|
1735
1716
|
aggregator: openOcean
|
|
1736
1717
|
},
|
|
1737
|
-
|
|
1718
|
+
swrOptions
|
|
1738
1719
|
);
|
|
1739
1720
|
const haikuResult = raw_useSingleAggregatorQuote(
|
|
1740
1721
|
{
|
|
@@ -1742,7 +1723,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1742
1723
|
...args,
|
|
1743
1724
|
aggregator: haiku
|
|
1744
1725
|
},
|
|
1745
|
-
|
|
1726
|
+
swrOptions
|
|
1746
1727
|
);
|
|
1747
1728
|
const ensoResult = raw_useSingleAggregatorQuote(
|
|
1748
1729
|
{
|
|
@@ -1750,7 +1731,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1750
1731
|
...args,
|
|
1751
1732
|
aggregator: enso
|
|
1752
1733
|
},
|
|
1753
|
-
|
|
1734
|
+
swrOptions
|
|
1754
1735
|
);
|
|
1755
1736
|
const { protocol: bexProtocol } = useBexStatus();
|
|
1756
1737
|
const bexResult = raw_useSingleAggregatorQuote(
|
|
@@ -1759,7 +1740,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1759
1740
|
...args,
|
|
1760
1741
|
aggregator: bex
|
|
1761
1742
|
},
|
|
1762
|
-
{
|
|
1743
|
+
{ ...swrOptions, isEnabled: bexProtocol.isPaused === false }
|
|
1763
1744
|
);
|
|
1764
1745
|
const wberaSwapResult = raw_useSingleAggregatorQuote({
|
|
1765
1746
|
...sharedArgs,
|
|
@@ -1772,7 +1753,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1772
1753
|
...args,
|
|
1773
1754
|
aggregator: bgtRedeem
|
|
1774
1755
|
},
|
|
1775
|
-
|
|
1756
|
+
swrOptions
|
|
1776
1757
|
);
|
|
1777
1758
|
const honeyResult = raw_useSingleAggregatorQuote(
|
|
1778
1759
|
{
|
|
@@ -1780,7 +1761,7 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1780
1761
|
...args,
|
|
1781
1762
|
aggregator: honeyNative
|
|
1782
1763
|
},
|
|
1783
|
-
|
|
1764
|
+
swrOptions
|
|
1784
1765
|
);
|
|
1785
1766
|
const results = isWrapOrUnwrap ? [wberaSwapResult] : isBgtRedeem ? [bgtRedeemResult] : [
|
|
1786
1767
|
oogaBogaResult,
|
|
@@ -1809,38 +1790,35 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1809
1790
|
}, [results]);
|
|
1810
1791
|
return {
|
|
1811
1792
|
...data,
|
|
1812
|
-
refresh: () =>
|
|
1793
|
+
refresh: () => {
|
|
1794
|
+
results.map((r) => r.refresh());
|
|
1795
|
+
}
|
|
1813
1796
|
};
|
|
1814
1797
|
}
|
|
1815
1798
|
|
|
1816
1799
|
// src/hooks/dex/useAllUserPools.ts
|
|
1817
|
-
import useSWR3 from "swr";
|
|
1818
1800
|
var useAllUserPoolsQueryKey = ({
|
|
1819
1801
|
query
|
|
1820
1802
|
} = {}) => {
|
|
1821
1803
|
return ["useAllUserPools", query];
|
|
1822
1804
|
};
|
|
1823
1805
|
var useAllUserPools = (query, options) => {
|
|
1824
|
-
|
|
1806
|
+
return useSWR(
|
|
1825
1807
|
useAllUserPoolsQueryKey({ query }),
|
|
1826
1808
|
async ([_, params]) => {
|
|
1827
|
-
return getAllPools({
|
|
1809
|
+
return getAllPools({
|
|
1810
|
+
...params,
|
|
1811
|
+
fetchPolicy: "no-cache"
|
|
1812
|
+
});
|
|
1828
1813
|
},
|
|
1829
1814
|
{
|
|
1830
1815
|
refreshInterval: 18e4 /* SLOW */,
|
|
1831
|
-
...options
|
|
1816
|
+
...options
|
|
1832
1817
|
}
|
|
1833
1818
|
);
|
|
1834
|
-
return {
|
|
1835
|
-
...swrResponse,
|
|
1836
|
-
refresh: () => {
|
|
1837
|
-
swrResponse.mutate();
|
|
1838
|
-
}
|
|
1839
|
-
};
|
|
1840
1819
|
};
|
|
1841
1820
|
|
|
1842
1821
|
// src/hooks/dex/useApiPool.ts
|
|
1843
|
-
import useSWR4 from "swr";
|
|
1844
1822
|
import { isAddress } from "viem";
|
|
1845
1823
|
var useApiPoolQueryKey = ({
|
|
1846
1824
|
poolId,
|
|
@@ -1852,7 +1830,7 @@ function useApiPool({
|
|
|
1852
1830
|
poolId,
|
|
1853
1831
|
account
|
|
1854
1832
|
}) {
|
|
1855
|
-
|
|
1833
|
+
return useSWR(
|
|
1856
1834
|
useApiPoolQueryKey({ poolId, account }),
|
|
1857
1835
|
async ([, poolId2, account2]) => {
|
|
1858
1836
|
if (account2 && !isAddress(account2)) {
|
|
@@ -1871,12 +1849,6 @@ function useApiPool({
|
|
|
1871
1849
|
refreshInterval: 1e5 /* NORMAL */
|
|
1872
1850
|
}
|
|
1873
1851
|
);
|
|
1874
|
-
return {
|
|
1875
|
-
...res,
|
|
1876
|
-
refresh: () => {
|
|
1877
|
-
res.mutate();
|
|
1878
|
-
}
|
|
1879
|
-
};
|
|
1880
1852
|
}
|
|
1881
1853
|
|
|
1882
1854
|
// src/hooks/dex/useCreatePool.ts
|
|
@@ -2157,9 +2129,8 @@ var useCreatePool = ({
|
|
|
2157
2129
|
};
|
|
2158
2130
|
|
|
2159
2131
|
// src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts
|
|
2160
|
-
import useSWR5 from "swr";
|
|
2161
2132
|
var useGlobalLiquidityAndSwapVolume = () => {
|
|
2162
|
-
const response =
|
|
2133
|
+
const response = useSWR(
|
|
2163
2134
|
"useGlobalLiquidityAndSwapVolume",
|
|
2164
2135
|
async () => getGlobalLiquidityAndSwapVolume()
|
|
2165
2136
|
);
|
|
@@ -2172,8 +2143,7 @@ var useGlobalLiquidityAndSwapVolume = () => {
|
|
|
2172
2143
|
swapVolume24h: Number(
|
|
2173
2144
|
response.data?.protocolMetricsAggregated.swapVolume24h
|
|
2174
2145
|
)
|
|
2175
|
-
}
|
|
2176
|
-
refresh: () => response.mutate()
|
|
2146
|
+
}
|
|
2177
2147
|
};
|
|
2178
2148
|
};
|
|
2179
2149
|
|
|
@@ -2287,13 +2257,11 @@ var useLiquidityMismatch = ({
|
|
|
2287
2257
|
import { formatEther as formatEther3, isAddressEqual } from "viem";
|
|
2288
2258
|
|
|
2289
2259
|
// src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts
|
|
2290
|
-
import useSWR6 from "swr";
|
|
2291
2260
|
import { isAddress as isAddress3, zeroAddress as zeroAddress13 } from "viem";
|
|
2292
2261
|
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
2293
2262
|
import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
|
|
2294
2263
|
|
|
2295
2264
|
// src/hooks/pol/useRewardVaultFromToken.ts
|
|
2296
|
-
import useSWRImmutable3 from "swr/immutable";
|
|
2297
2265
|
import { isAddress as isAddress2, zeroAddress as zeroAddress12 } from "viem";
|
|
2298
2266
|
import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
|
|
2299
2267
|
import { usePublicClient as usePublicClient5 } from "@berachain/wagmi/hooks";
|
|
@@ -2304,26 +2272,25 @@ var useRewardVaultFromToken = ({
|
|
|
2304
2272
|
} = {}) => {
|
|
2305
2273
|
const publicClient = usePublicClient5();
|
|
2306
2274
|
const QUERY_KEY = publicClient && tokenAddress && isAddress2(tokenAddress) && isEnabled ? ["useRewardVaultFromToken", tokenAddress] : null;
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2275
|
+
return useSWRImmutable(
|
|
2276
|
+
QUERY_KEY,
|
|
2277
|
+
async ([, tokenAddress2]) => {
|
|
2278
|
+
if (!tokenAddress2) {
|
|
2279
|
+
throw new Error("useRewardVaultFromToken needs a valid token address");
|
|
2280
|
+
}
|
|
2281
|
+
assertPublicClient(publicClient);
|
|
2282
|
+
const { config } = parseBaseArgs({
|
|
2283
|
+
chainId: publicClient.chain.id
|
|
2284
|
+
});
|
|
2285
|
+
const res = await publicClient.readContract({
|
|
2286
|
+
address: config.pol.factory,
|
|
2287
|
+
abi: rewardVaultFactoryAbi,
|
|
2288
|
+
functionName: "getVault",
|
|
2289
|
+
args: [tokenAddress2]
|
|
2290
|
+
});
|
|
2291
|
+
return res === zeroAddress12 ? void 0 : res;
|
|
2310
2292
|
}
|
|
2311
|
-
|
|
2312
|
-
const { config } = parseBaseArgs({
|
|
2313
|
-
chainId: publicClient.chain.id
|
|
2314
|
-
});
|
|
2315
|
-
const res = await publicClient.readContract({
|
|
2316
|
-
address: config.pol.factory,
|
|
2317
|
-
abi: rewardVaultFactoryAbi,
|
|
2318
|
-
functionName: "getVault",
|
|
2319
|
-
args: [tokenAddress2]
|
|
2320
|
-
});
|
|
2321
|
-
return res === zeroAddress12 ? void 0 : res;
|
|
2322
|
-
});
|
|
2323
|
-
return {
|
|
2324
|
-
...swrResponse,
|
|
2325
|
-
refresh: () => swrResponse.mutate()
|
|
2326
|
-
};
|
|
2293
|
+
);
|
|
2327
2294
|
};
|
|
2328
2295
|
|
|
2329
2296
|
// src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts
|
|
@@ -2333,11 +2300,11 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2333
2300
|
}, options) => {
|
|
2334
2301
|
const { address: account } = useBeraWallet3();
|
|
2335
2302
|
const publicClient = usePublicClient6();
|
|
2336
|
-
const isEnabled = options?.
|
|
2303
|
+
const isEnabled = options?.isEnabled ?? true;
|
|
2337
2304
|
const {
|
|
2338
2305
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
2339
2306
|
error,
|
|
2340
|
-
|
|
2307
|
+
refresh: mutateRewardVaultAddress,
|
|
2341
2308
|
isLoading: isLoadingRewardVaultAddress
|
|
2342
2309
|
} = useRewardVaultFromToken(
|
|
2343
2310
|
{
|
|
@@ -2347,8 +2314,8 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2347
2314
|
isEnabled: !_rewardVaultAddress && isEnabled
|
|
2348
2315
|
}
|
|
2349
2316
|
);
|
|
2350
|
-
const swrResponse =
|
|
2351
|
-
rewardVaultAddress && account && publicClient && isAddress3(rewardVaultAddress) && isAddress3(account)
|
|
2317
|
+
const swrResponse = useSWR(
|
|
2318
|
+
rewardVaultAddress && account && publicClient && isAddress3(rewardVaultAddress) && isAddress3(account) ? ["useVaultBalanceFromStakingToken", rewardVaultAddress, account] : null,
|
|
2352
2319
|
async ([, rewardVaultAddress2, account2]) => {
|
|
2353
2320
|
assertPublicClient(publicClient);
|
|
2354
2321
|
if (rewardVaultAddress2 === zeroAddress13) {
|
|
@@ -2367,20 +2334,20 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2367
2334
|
address: rewardVaultAddress2,
|
|
2368
2335
|
balance
|
|
2369
2336
|
};
|
|
2370
|
-
}
|
|
2337
|
+
},
|
|
2338
|
+
options
|
|
2371
2339
|
);
|
|
2372
2340
|
return {
|
|
2373
2341
|
...swrResponse,
|
|
2374
2342
|
refresh: () => {
|
|
2375
2343
|
mutateRewardVaultAddress();
|
|
2376
|
-
swrResponse.
|
|
2344
|
+
swrResponse.refresh();
|
|
2377
2345
|
},
|
|
2378
2346
|
isLoading: swrResponse.isLoading || isLoadingRewardVaultAddress
|
|
2379
2347
|
};
|
|
2380
2348
|
};
|
|
2381
2349
|
|
|
2382
2350
|
// src/hooks/tokens/usePollBalance.ts
|
|
2383
|
-
import useSWR7 from "swr";
|
|
2384
2351
|
import {
|
|
2385
2352
|
erc20Abi,
|
|
2386
2353
|
formatEther as formatEther2,
|
|
@@ -2392,7 +2359,6 @@ import { defaultChainId as defaultChainId3 } from "@berachain/config/internal";
|
|
|
2392
2359
|
import { useBeraWallet as useBeraWallet4, usePublicClient as usePublicClient8 } from "@berachain/wagmi/hooks";
|
|
2393
2360
|
|
|
2394
2361
|
// src/hooks/tokens/useTokenInformation.ts
|
|
2395
|
-
import useSWRImmutable4 from "swr/immutable";
|
|
2396
2362
|
import { isAddress as isAddress4, zeroAddress as zeroAddress14 } from "viem";
|
|
2397
2363
|
import { defaultChainId as defaultChainId2 } from "@berachain/config/internal";
|
|
2398
2364
|
import { usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
@@ -2401,7 +2367,7 @@ function useTokenInformation(args, options) {
|
|
|
2401
2367
|
chainId: args.chainId
|
|
2402
2368
|
});
|
|
2403
2369
|
const QUERY_KEY = args?.address && publicClient && isAddress4(args.address) ? ["useTokenInformation", args.address, args.chainId] : null;
|
|
2404
|
-
|
|
2370
|
+
return useSWRImmutable(
|
|
2405
2371
|
QUERY_KEY,
|
|
2406
2372
|
async ([_, address, chainId2 = defaultChainId2]) => {
|
|
2407
2373
|
if (isToken(address, "BERA")) {
|
|
@@ -2420,12 +2386,8 @@ function useTokenInformation(args, options) {
|
|
|
2420
2386
|
chainId: chainId2
|
|
2421
2387
|
});
|
|
2422
2388
|
},
|
|
2423
|
-
{ ...options
|
|
2389
|
+
{ ...options }
|
|
2424
2390
|
);
|
|
2425
|
-
return {
|
|
2426
|
-
...swrResponse,
|
|
2427
|
-
refresh: () => swrResponse?.mutate?.()
|
|
2428
|
-
};
|
|
2429
2391
|
}
|
|
2430
2392
|
|
|
2431
2393
|
// src/hooks/tokens/usePollBalance.ts
|
|
@@ -2441,10 +2403,10 @@ function usePollBalance({
|
|
|
2441
2403
|
const publicClient = usePublicClient8({ chainId: chainId2 });
|
|
2442
2404
|
const { address: account } = useBeraWallet4();
|
|
2443
2405
|
const assetOwner = owner ?? account;
|
|
2444
|
-
const QUERY_KEY =
|
|
2406
|
+
const QUERY_KEY = publicClient && assetOwner && isAddress5(assetOwner) && address && isAddress5(address) ? ["usePollBalance", assetOwner, address, chainId2] : null;
|
|
2445
2407
|
const { data: tokenInformation, isLoading: isLoadingTokenInformation } = useTokenInformation({ address, chainId: chainId2 });
|
|
2446
2408
|
const isNativeToken = isToken(address, "BERA");
|
|
2447
|
-
const { isLoading, data, error, ...rest } =
|
|
2409
|
+
const { isLoading, data, error, ...rest } = useSWR(
|
|
2448
2410
|
QUERY_KEY,
|
|
2449
2411
|
async ([, assetOwner2, address2]) => {
|
|
2450
2412
|
assertPublicClient(publicClient);
|
|
@@ -2461,7 +2423,8 @@ function usePollBalance({
|
|
|
2461
2423
|
});
|
|
2462
2424
|
},
|
|
2463
2425
|
{
|
|
2464
|
-
refreshInterval: 1e4 /* FAST
|
|
2426
|
+
refreshInterval: 1e4 /* FAST */,
|
|
2427
|
+
...options
|
|
2465
2428
|
}
|
|
2466
2429
|
);
|
|
2467
2430
|
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ? formatUnits5(data, tokenInformation.decimals) : void 0 : void 0;
|
|
@@ -2478,9 +2441,6 @@ function usePollBalance({
|
|
|
2478
2441
|
};
|
|
2479
2442
|
return {
|
|
2480
2443
|
...rest,
|
|
2481
|
-
refresh: () => {
|
|
2482
|
-
rest.mutate();
|
|
2483
|
-
},
|
|
2484
2444
|
isLoading: isLoading || isNativeToken ? isLoadingTokenInformation : false,
|
|
2485
2445
|
error: error || !isNativeToken ? error : void 0,
|
|
2486
2446
|
data: tokenBalance
|
|
@@ -2554,13 +2514,12 @@ import { useMemo as useMemo3 } from "react";
|
|
|
2554
2514
|
import { parseUnits as parseUnits4, zeroAddress as zeroAddress16 } from "viem";
|
|
2555
2515
|
|
|
2556
2516
|
// src/hooks/tokens/usePollAllowances.ts
|
|
2557
|
-
import useSWR8 from "swr";
|
|
2558
2517
|
import { useBeraWallet as useBeraWallet5, useConfig as useConfig2 } from "@berachain/wagmi/hooks";
|
|
2559
2518
|
function usePollAllowances(args, options) {
|
|
2560
2519
|
const config = useConfig2();
|
|
2561
2520
|
const { address: account } = useBeraWallet5();
|
|
2562
2521
|
const QUERY_KEY = config && account && args?.items ? ["usePollAllowances", account, args?.items] : null;
|
|
2563
|
-
|
|
2522
|
+
return useSWR(
|
|
2564
2523
|
QUERY_KEY,
|
|
2565
2524
|
async ([, account2, items]) => {
|
|
2566
2525
|
return getAllowances({
|
|
@@ -2570,14 +2529,10 @@ function usePollAllowances(args, options) {
|
|
|
2570
2529
|
});
|
|
2571
2530
|
},
|
|
2572
2531
|
{
|
|
2573
|
-
...options
|
|
2574
|
-
refreshInterval: options?.
|
|
2532
|
+
...options,
|
|
2533
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
2575
2534
|
}
|
|
2576
2535
|
);
|
|
2577
|
-
return {
|
|
2578
|
-
...swrResponse,
|
|
2579
|
-
refresh: () => swrResponse?.mutate?.()
|
|
2580
|
-
};
|
|
2581
2536
|
}
|
|
2582
2537
|
|
|
2583
2538
|
// src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts
|
|
@@ -2645,12 +2600,10 @@ function useMultipleTokenApprovalsWithSlippage(tokenInput, options) {
|
|
|
2645
2600
|
|
|
2646
2601
|
// src/hooks/dex/useOnChainPoolData.ts
|
|
2647
2602
|
import { useMemo as useMemo5 } from "react";
|
|
2648
|
-
import useSWRImmutable6 from "swr/immutable";
|
|
2649
2603
|
import { formatUnits as formatUnits6, isAddress as isAddress8 } from "viem";
|
|
2650
2604
|
import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
|
|
2651
2605
|
|
|
2652
2606
|
// src/hooks/tokens/useMultipleTokenInformation.ts
|
|
2653
|
-
import useSWRImmutable5 from "swr/immutable";
|
|
2654
2607
|
import { isAddress as isAddress6 } from "viem";
|
|
2655
2608
|
import { defaultChainId as defaultChainId4 } from "@berachain/config/internal";
|
|
2656
2609
|
import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
|
|
@@ -2661,7 +2614,7 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2661
2614
|
args.addresses,
|
|
2662
2615
|
args.chainId ?? defaultChainId4
|
|
2663
2616
|
] : null;
|
|
2664
|
-
|
|
2617
|
+
return useSWRImmutable(
|
|
2665
2618
|
QUERY_KEY,
|
|
2666
2619
|
async ([, addresses, chainId2]) => {
|
|
2667
2620
|
assertPublicClient(publicClient);
|
|
@@ -2682,17 +2635,12 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2682
2635
|
})
|
|
2683
2636
|
);
|
|
2684
2637
|
},
|
|
2685
|
-
{ ...options
|
|
2638
|
+
{ ...options }
|
|
2686
2639
|
);
|
|
2687
|
-
return {
|
|
2688
|
-
...swrResponse,
|
|
2689
|
-
refresh: () => swrResponse?.mutate?.()
|
|
2690
|
-
};
|
|
2691
2640
|
}
|
|
2692
2641
|
|
|
2693
2642
|
// src/hooks/tokens/useTokenCurrentPrices.ts
|
|
2694
2643
|
import { useMemo as useMemo4 } from "react";
|
|
2695
|
-
import useSWR9 from "swr";
|
|
2696
2644
|
import { isAddress as isAddress7, zeroAddress as zeroAddress17 } from "viem";
|
|
2697
2645
|
import { defaultChainId as defaultChainId5 } from "@berachain/config/internal";
|
|
2698
2646
|
|
|
@@ -2723,10 +2671,8 @@ function useTokens() {
|
|
|
2723
2671
|
function useTokenCurrentPrices({
|
|
2724
2672
|
addressIn
|
|
2725
2673
|
} = {}, options = {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
revalidateOnFocus: true
|
|
2729
|
-
}
|
|
2674
|
+
refreshInterval: 1e5 /* NORMAL */,
|
|
2675
|
+
revalidateOnFocus: true
|
|
2730
2676
|
}) {
|
|
2731
2677
|
const { tokenList, ensoTokens } = useTokens();
|
|
2732
2678
|
const beraAddresses = useMemo4(() => {
|
|
@@ -2748,16 +2694,16 @@ function useTokenCurrentPrices({
|
|
|
2748
2694
|
return beraAddresses?.some((a) => !tokenSet.has(a));
|
|
2749
2695
|
}, [beraAddresses, tokenList]);
|
|
2750
2696
|
const addresses = hasAddressesNotInTokenList ? beraAddresses : tokenList.map((token) => token.address);
|
|
2751
|
-
const QUERY_KEY = addresses
|
|
2697
|
+
const QUERY_KEY = addresses ? [
|
|
2752
2698
|
"useTokenCurrentPrices",
|
|
2753
2699
|
addresses.map((a) => a.toLowerCase())
|
|
2754
2700
|
] : null;
|
|
2755
|
-
const apiResponse =
|
|
2701
|
+
const apiResponse = useSWR(
|
|
2756
2702
|
QUERY_KEY,
|
|
2757
2703
|
async ([, addresses2]) => {
|
|
2758
2704
|
return getTokenCurrentPrices({ addressIn: addresses2 });
|
|
2759
2705
|
},
|
|
2760
|
-
options
|
|
2706
|
+
options
|
|
2761
2707
|
);
|
|
2762
2708
|
const ensoMatchingPrices = useMemo4(() => {
|
|
2763
2709
|
if (!ensoTokens) return {};
|
|
@@ -2817,8 +2763,8 @@ function useOnChainPoolData(poolId) {
|
|
|
2817
2763
|
data: poolData,
|
|
2818
2764
|
error,
|
|
2819
2765
|
isLoading,
|
|
2820
|
-
mutate
|
|
2821
|
-
} =
|
|
2766
|
+
refresh: mutate
|
|
2767
|
+
} = useSWRImmutable(
|
|
2822
2768
|
// FIXME: why are we using useSWRImmutable when we fetch tokenSupply and swapFee?
|
|
2823
2769
|
publicClient ? QUERY_KEY : null,
|
|
2824
2770
|
async ([, poolId2]) => {
|
|
@@ -2886,13 +2832,11 @@ function useOnChainPoolData(poolId) {
|
|
|
2886
2832
|
data: pool,
|
|
2887
2833
|
error,
|
|
2888
2834
|
isLoading: isLoading || isTokenInformationLoading || isTokenPricesLoading,
|
|
2889
|
-
mutate
|
|
2890
|
-
refresh: () => mutate()
|
|
2835
|
+
refresh: mutate
|
|
2891
2836
|
};
|
|
2892
2837
|
}
|
|
2893
2838
|
|
|
2894
2839
|
// src/hooks/dex/usePollPoolCreationRelayerApproval.ts
|
|
2895
|
-
import useSWR10 from "swr";
|
|
2896
2840
|
import { vaultAbi as balancerVaultAbi2 } from "@berachain/abis/bex/vault";
|
|
2897
2841
|
import { useBeraWallet as useBeraWallet6, usePublicClient as usePublicClient11 } from "@berachain/wagmi/hooks";
|
|
2898
2842
|
var usePollPoolCreationRelayerApproval = (options) => {
|
|
@@ -2903,7 +2847,7 @@ var usePollPoolCreationRelayerApproval = (options) => {
|
|
|
2903
2847
|
account,
|
|
2904
2848
|
publicClient.chain.id
|
|
2905
2849
|
] : null;
|
|
2906
|
-
|
|
2850
|
+
return useSWR(
|
|
2907
2851
|
QUERY_KEY,
|
|
2908
2852
|
async ([, account2]) => {
|
|
2909
2853
|
assertPublicClient(publicClient);
|
|
@@ -2916,12 +2860,8 @@ var usePollPoolCreationRelayerApproval = (options) => {
|
|
|
2916
2860
|
});
|
|
2917
2861
|
return approved;
|
|
2918
2862
|
},
|
|
2919
|
-
{ ...options
|
|
2863
|
+
{ ...options }
|
|
2920
2864
|
);
|
|
2921
|
-
const refreshPoolCreationApproval = () => {
|
|
2922
|
-
swrResponse.mutate();
|
|
2923
|
-
};
|
|
2924
|
-
return { ...swrResponse, refreshPoolCreationApproval };
|
|
2925
2865
|
};
|
|
2926
2866
|
|
|
2927
2867
|
// src/hooks/dex/usePool.ts
|
|
@@ -2945,12 +2885,11 @@ function usePool({ poolId }) {
|
|
|
2945
2885
|
}
|
|
2946
2886
|
|
|
2947
2887
|
// src/hooks/dex/usePoolEvents.ts
|
|
2948
|
-
import useSWRImmutable7 from "swr/immutable";
|
|
2949
2888
|
var usePoolEvents = ({
|
|
2950
2889
|
poolId,
|
|
2951
2890
|
typeInArray
|
|
2952
2891
|
}) => {
|
|
2953
|
-
return
|
|
2892
|
+
return useSWRImmutable(
|
|
2954
2893
|
poolId ? ["usePoolEvents", poolId, typeInArray] : null,
|
|
2955
2894
|
async ([, poolId2, typeInArray2]) => getPoolEvents({ poolId: poolId2, typeInArray: typeInArray2 }),
|
|
2956
2895
|
{
|
|
@@ -2960,11 +2899,10 @@ var usePoolEvents = ({
|
|
|
2960
2899
|
};
|
|
2961
2900
|
|
|
2962
2901
|
// src/hooks/dex/usePoolHistoricalData.ts
|
|
2963
|
-
import useSWR11 from "swr";
|
|
2964
2902
|
var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
2965
2903
|
const { config } = parseBaseArgs(baseArgs);
|
|
2966
2904
|
const QUERY_KEY = poolId ? ["usePoolHistoricalData", poolId] : null;
|
|
2967
|
-
|
|
2905
|
+
return useSWR(
|
|
2968
2906
|
QUERY_KEY,
|
|
2969
2907
|
async ([, poolId2]) => {
|
|
2970
2908
|
return getPoolHistoricalData({
|
|
@@ -2972,17 +2910,12 @@ var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
|
2972
2910
|
chain: config.bex.chainName
|
|
2973
2911
|
});
|
|
2974
2912
|
},
|
|
2975
|
-
options
|
|
2913
|
+
options
|
|
2976
2914
|
);
|
|
2977
|
-
return {
|
|
2978
|
-
...swrResponse,
|
|
2979
|
-
refresh: () => void swrResponse.mutate()
|
|
2980
|
-
};
|
|
2981
2915
|
};
|
|
2982
2916
|
|
|
2983
2917
|
// src/hooks/dex/usePools.ts
|
|
2984
2918
|
import { useMemo as useMemo6 } from "react";
|
|
2985
|
-
import useSWR12 from "swr";
|
|
2986
2919
|
import { useBeraWallet as useBeraWallet7 } from "@berachain/wagmi/hooks";
|
|
2987
2920
|
var usePoolsQueryKey = ({
|
|
2988
2921
|
query
|
|
@@ -2994,7 +2927,7 @@ var usePools = (query, options) => {
|
|
|
2994
2927
|
const {
|
|
2995
2928
|
data: userPools,
|
|
2996
2929
|
isLoading: isUserPoolsLoading,
|
|
2997
|
-
|
|
2930
|
+
refresh: mutateUserPools
|
|
2998
2931
|
} = useAllUserPools({
|
|
2999
2932
|
userAddress: account,
|
|
3000
2933
|
chain: query.chain
|
|
@@ -3002,15 +2935,16 @@ var usePools = (query, options) => {
|
|
|
3002
2935
|
const {
|
|
3003
2936
|
data: pools,
|
|
3004
2937
|
isLoading: isPoolsLoading,
|
|
3005
|
-
|
|
3006
|
-
|
|
2938
|
+
refresh: mutatePools,
|
|
2939
|
+
error: poolsError
|
|
2940
|
+
} = useSWR(
|
|
3007
2941
|
usePoolsQueryKey({ query }),
|
|
3008
2942
|
async ([_, query2]) => {
|
|
3009
2943
|
return getAllPools(query2);
|
|
3010
2944
|
},
|
|
3011
2945
|
{
|
|
3012
2946
|
refreshInterval: 18e4 /* SLOW */,
|
|
3013
|
-
...options
|
|
2947
|
+
...options
|
|
3014
2948
|
}
|
|
3015
2949
|
);
|
|
3016
2950
|
const mergedPools = useMemo6(() => {
|
|
@@ -3034,6 +2968,7 @@ var usePools = (query, options) => {
|
|
|
3034
2968
|
pools: mergedPools ?? [],
|
|
3035
2969
|
walletPools: pools?.pools ?? [],
|
|
3036
2970
|
isLoading: isPoolsLoading || isUserPoolsLoading,
|
|
2971
|
+
error: poolsError,
|
|
3037
2972
|
refresh: () => {
|
|
3038
2973
|
mutatePools();
|
|
3039
2974
|
mutateUserPools();
|
|
@@ -3051,10 +2986,8 @@ import { defaultChainId as defaultChainId6 } from "@berachain/config/internal";
|
|
|
3051
2986
|
function useTokenPrices({
|
|
3052
2987
|
tokens
|
|
3053
2988
|
} = {}, options = {
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
revalidateOnFocus: true
|
|
3057
|
-
}
|
|
2989
|
+
refreshInterval: 1e5 /* NORMAL */,
|
|
2990
|
+
revalidateOnFocus: true
|
|
3058
2991
|
}) {
|
|
3059
2992
|
const { ensoTokens } = useTokens();
|
|
3060
2993
|
const apiResponse = useTokenCurrentPrices(
|
|
@@ -3125,6 +3058,7 @@ function useTokenPrices({
|
|
|
3125
3058
|
);
|
|
3126
3059
|
return {
|
|
3127
3060
|
isLoading: apiResponse.isLoading,
|
|
3061
|
+
error: apiResponse.error,
|
|
3128
3062
|
data,
|
|
3129
3063
|
priceMap,
|
|
3130
3064
|
getTokenPrice
|
|
@@ -3168,7 +3102,6 @@ function usePriceImpact({
|
|
|
3168
3102
|
}
|
|
3169
3103
|
|
|
3170
3104
|
// src/hooks/enso/useBendDemultiply.ts
|
|
3171
|
-
import useSWR15 from "swr";
|
|
3172
3105
|
import { parseUnits as parseUnits5 } from "viem";
|
|
3173
3106
|
import { defaultChainId as defaultChainId7 } from "@berachain/config/internal";
|
|
3174
3107
|
import {
|
|
@@ -3605,7 +3538,6 @@ async function getBendDemultiplyBundle({
|
|
|
3605
3538
|
}
|
|
3606
3539
|
|
|
3607
3540
|
// src/hooks/enso/useEnsoWalletV2Address.ts
|
|
3608
|
-
import useSWR13 from "swr";
|
|
3609
3541
|
import { getAddress as getAddress3 } from "viem";
|
|
3610
3542
|
import { useBeraWallet as useBeraWallet8, usePublicClient as usePublicClient12 } from "@berachain/wagmi/hooks";
|
|
3611
3543
|
function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
@@ -3614,7 +3546,7 @@ function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
|
3614
3546
|
const { config } = parseBaseArgs({});
|
|
3615
3547
|
const ensoWalletV2Factory = config.enso.walletV2Factory;
|
|
3616
3548
|
const QUERY_KEY = fromAddress && ensoWalletV2Factory ? ["useEnsoWalletV2Address", fromAddress, ensoWalletV2Factory] : null;
|
|
3617
|
-
return
|
|
3549
|
+
return useSWR(
|
|
3618
3550
|
QUERY_KEY,
|
|
3619
3551
|
async ([_, accountAddress, factory]) => {
|
|
3620
3552
|
assertPublicClient(publicClient);
|
|
@@ -3629,7 +3561,6 @@ function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
|
3629
3561
|
}
|
|
3630
3562
|
|
|
3631
3563
|
// src/hooks/enso/useIsBendAuthorized.ts
|
|
3632
|
-
import useSWR14 from "swr";
|
|
3633
3564
|
import { useBeraWallet as useBeraWallet9, usePublicClient as usePublicClient13 } from "@berachain/wagmi/hooks";
|
|
3634
3565
|
function useIsBendAuthorized({
|
|
3635
3566
|
chainId: chainId2,
|
|
@@ -3644,7 +3575,7 @@ function useIsBendAuthorized({
|
|
|
3644
3575
|
primaryAddress,
|
|
3645
3576
|
ensoWalletV2Address
|
|
3646
3577
|
] : null;
|
|
3647
|
-
return
|
|
3578
|
+
return useSWR(
|
|
3648
3579
|
QUERY_KEY,
|
|
3649
3580
|
async ([_, accountAddress, primaryAddress2, ensoWalletV2Address2]) => {
|
|
3650
3581
|
assertPublicClient(publicClient);
|
|
@@ -3687,7 +3618,7 @@ function useBendDemultiply({
|
|
|
3687
3618
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
3688
3619
|
"proxyAggregatorsThroughVercel"
|
|
3689
3620
|
);
|
|
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
|
|
3621
|
+
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
3622
|
"useBendDemultiply",
|
|
3692
3623
|
fromAddress,
|
|
3693
3624
|
collateralToken,
|
|
@@ -3704,7 +3635,7 @@ function useBendDemultiply({
|
|
|
3704
3635
|
isAuthorized,
|
|
3705
3636
|
proxyAggregatorsThroughVercel ?? false
|
|
3706
3637
|
] : null;
|
|
3707
|
-
return
|
|
3638
|
+
return useSWR(
|
|
3708
3639
|
QUERY_KEY,
|
|
3709
3640
|
async ([
|
|
3710
3641
|
_,
|
|
@@ -3757,14 +3688,13 @@ function useBendDemultiply({
|
|
|
3757
3688
|
});
|
|
3758
3689
|
},
|
|
3759
3690
|
{
|
|
3760
|
-
...options
|
|
3691
|
+
...options,
|
|
3761
3692
|
refreshInterval: 1e5 /* NORMAL */
|
|
3762
3693
|
}
|
|
3763
3694
|
);
|
|
3764
3695
|
}
|
|
3765
3696
|
|
|
3766
3697
|
// src/hooks/enso/useBendMultiply.ts
|
|
3767
|
-
import useSWR16 from "swr";
|
|
3768
3698
|
import { parseUnits as parseUnits6 } from "viem";
|
|
3769
3699
|
import { defaultChainId as defaultChainId8 } from "@berachain/config/internal";
|
|
3770
3700
|
import {
|
|
@@ -4034,7 +3964,7 @@ function useBendMultiply({
|
|
|
4034
3964
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4035
3965
|
"proxyAggregatorsThroughVercel"
|
|
4036
3966
|
);
|
|
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
|
|
3967
|
+
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
3968
|
"useBendMultiply",
|
|
4039
3969
|
fromAddress,
|
|
4040
3970
|
collateralToken,
|
|
@@ -4052,7 +3982,7 @@ function useBendMultiply({
|
|
|
4052
3982
|
isAuthorized,
|
|
4053
3983
|
proxyAggregatorsThroughVercel ?? false
|
|
4054
3984
|
] : null;
|
|
4055
|
-
return
|
|
3985
|
+
return useSWR(
|
|
4056
3986
|
QUERY_KEY,
|
|
4057
3987
|
async ([
|
|
4058
3988
|
_,
|
|
@@ -4107,14 +4037,13 @@ function useBendMultiply({
|
|
|
4107
4037
|
});
|
|
4108
4038
|
},
|
|
4109
4039
|
{
|
|
4110
|
-
...options
|
|
4040
|
+
...options,
|
|
4111
4041
|
refreshInterval: 1e5 /* NORMAL */
|
|
4112
4042
|
}
|
|
4113
4043
|
);
|
|
4114
4044
|
}
|
|
4115
4045
|
|
|
4116
4046
|
// src/hooks/enso/useBendZapSupply.ts
|
|
4117
|
-
import useSWR17 from "swr";
|
|
4118
4047
|
import { formatEther as formatEther4, parseUnits as parseUnits7, zeroAddress as zeroAddress20 } from "viem";
|
|
4119
4048
|
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
4120
4049
|
import { useBeraWallet as useBeraWallet12, usePublicClient as usePublicClient16 } from "@berachain/wagmi/hooks";
|
|
@@ -4306,7 +4235,7 @@ function useBendZapSupply({
|
|
|
4306
4235
|
address: zeroAddress20,
|
|
4307
4236
|
chainId: isCrossChain ? tokenIn?.chainId : void 0
|
|
4308
4237
|
},
|
|
4309
|
-
{
|
|
4238
|
+
{ isEnabled: !!isCrossChain }
|
|
4310
4239
|
);
|
|
4311
4240
|
const transactionValue = swrResponse.data?.getCalldata?.({ account: zeroAddress20 })?.value ?? 0n;
|
|
4312
4241
|
const nativeBalance = nativeBalanceData?.balance ?? {
|
|
@@ -4326,7 +4255,7 @@ function useBendZapSupply({
|
|
|
4326
4255
|
isCrossChain,
|
|
4327
4256
|
nativeFee,
|
|
4328
4257
|
refresh: () => {
|
|
4329
|
-
swrResponse.
|
|
4258
|
+
swrResponse.refresh();
|
|
4330
4259
|
}
|
|
4331
4260
|
};
|
|
4332
4261
|
}
|
|
@@ -4342,7 +4271,7 @@ function useBendZapSupplyHelper({
|
|
|
4342
4271
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4343
4272
|
"proxyAggregatorsThroughVercel"
|
|
4344
4273
|
);
|
|
4345
|
-
const isEnabled =
|
|
4274
|
+
const isEnabled = !!tokenIn && !!loanToken && !!bendVault && !!amount && !!fromAddress && !isToken(loanToken.address, tokenIn.address) && tokenIn.chainId && Number(amount) > 0 && !!slippage;
|
|
4346
4275
|
const publicClientBeraChain = usePublicClient16();
|
|
4347
4276
|
const QUERY_KEY = isEnabled ? [
|
|
4348
4277
|
"useBendZapSupply",
|
|
@@ -4355,7 +4284,7 @@ function useBendZapSupplyHelper({
|
|
|
4355
4284
|
slippage,
|
|
4356
4285
|
proxyAggregatorsThroughVercel ?? false
|
|
4357
4286
|
] : null;
|
|
4358
|
-
return
|
|
4287
|
+
return useSWR(
|
|
4359
4288
|
QUERY_KEY,
|
|
4360
4289
|
async ([
|
|
4361
4290
|
,
|
|
@@ -4383,7 +4312,7 @@ function useBendZapSupplyHelper({
|
|
|
4383
4312
|
});
|
|
4384
4313
|
},
|
|
4385
4314
|
{
|
|
4386
|
-
...options
|
|
4315
|
+
...options,
|
|
4387
4316
|
refreshInterval: 1e5 /* NORMAL */
|
|
4388
4317
|
}
|
|
4389
4318
|
);
|
|
@@ -4391,7 +4320,6 @@ function useBendZapSupplyHelper({
|
|
|
4391
4320
|
|
|
4392
4321
|
// src/hooks/enso/useEnsoSwapBundle.ts
|
|
4393
4322
|
import { getPublicClient as getPublicClient2 } from "@wagmi/core";
|
|
4394
|
-
import useSWR19 from "swr";
|
|
4395
4323
|
import { parseUnits as parseUnits8 } from "viem";
|
|
4396
4324
|
import { defaultChainId as berachainChainId2 } from "@berachain/config/internal";
|
|
4397
4325
|
import { useBeraWallet as useBeraWallet14, useConfig as useConfig4 } from "@berachain/wagmi/hooks";
|
|
@@ -4462,7 +4390,6 @@ async function getEnsoSwapBundle({
|
|
|
4462
4390
|
|
|
4463
4391
|
// src/hooks/tokens/usePollWalletBalances.ts
|
|
4464
4392
|
import { useMemo as useMemo9 } from "react";
|
|
4465
|
-
import useSWR18 from "swr";
|
|
4466
4393
|
import {
|
|
4467
4394
|
useBeraWallet as useBeraWallet13,
|
|
4468
4395
|
useConfig as useConfig3,
|
|
@@ -4485,7 +4412,7 @@ function usePollWalletBalances(args, options) {
|
|
|
4485
4412
|
// TODO: adding the whole list to the query is very inefficient, we should only add the tokens addresses
|
|
4486
4413
|
Array.from(tokens.values())
|
|
4487
4414
|
] : null;
|
|
4488
|
-
const swrResponse =
|
|
4415
|
+
const swrResponse = useSWR(
|
|
4489
4416
|
QUERY_KEY,
|
|
4490
4417
|
async ([, wallet2, tokenList2]) => {
|
|
4491
4418
|
return getWalletBalances({
|
|
@@ -4496,13 +4423,13 @@ function usePollWalletBalances(args, options) {
|
|
|
4496
4423
|
},
|
|
4497
4424
|
{
|
|
4498
4425
|
refreshInterval: 1e5 /* NORMAL */,
|
|
4499
|
-
...options
|
|
4426
|
+
...options
|
|
4500
4427
|
}
|
|
4501
4428
|
);
|
|
4502
4429
|
return {
|
|
4503
4430
|
...swrResponse,
|
|
4504
4431
|
refresh: () => {
|
|
4505
|
-
swrResponse?.
|
|
4432
|
+
swrResponse?.refresh();
|
|
4506
4433
|
refresh();
|
|
4507
4434
|
}
|
|
4508
4435
|
};
|
|
@@ -4534,7 +4461,7 @@ function useEnsoSwapBundle({
|
|
|
4534
4461
|
slippage,
|
|
4535
4462
|
proxyAggregatorsThroughVercel ?? false
|
|
4536
4463
|
] : null;
|
|
4537
|
-
const swrResponse =
|
|
4464
|
+
const swrResponse = useSWR(
|
|
4538
4465
|
QUERY_KEY,
|
|
4539
4466
|
async ([, fromAddress2, tokenIn2, tokenOut2, amount2, slippage2]) => {
|
|
4540
4467
|
assertAddress(fromAddress2, "fromAddress");
|
|
@@ -4568,14 +4495,13 @@ function useEnsoSwapBundle({
|
|
|
4568
4495
|
return {
|
|
4569
4496
|
...swrResponse,
|
|
4570
4497
|
refresh: () => {
|
|
4571
|
-
swrResponse.
|
|
4498
|
+
swrResponse.refresh();
|
|
4572
4499
|
refreshBalances();
|
|
4573
4500
|
}
|
|
4574
4501
|
};
|
|
4575
4502
|
}
|
|
4576
4503
|
|
|
4577
4504
|
// src/hooks/enso/useZapStakeBera.ts
|
|
4578
|
-
import useSWR20 from "swr";
|
|
4579
4505
|
import { formatUnits as formatUnits9, parseUnits as parseUnits9 } from "viem";
|
|
4580
4506
|
import { chainConfigs, defaultChainId as defaultChainId9 } from "@berachain/config/internal";
|
|
4581
4507
|
import { useBeraWallet as useBeraWallet15 } from "@berachain/wagmi/hooks";
|
|
@@ -4598,7 +4524,7 @@ function useZapStakeBera({
|
|
|
4598
4524
|
underlyingToken,
|
|
4599
4525
|
tokenOut
|
|
4600
4526
|
] : null;
|
|
4601
|
-
const swrResponse =
|
|
4527
|
+
const swrResponse = useSWR(
|
|
4602
4528
|
QUERY_KEY,
|
|
4603
4529
|
async ([
|
|
4604
4530
|
,
|
|
@@ -4620,7 +4546,7 @@ function useZapStakeBera({
|
|
|
4620
4546
|
});
|
|
4621
4547
|
},
|
|
4622
4548
|
{
|
|
4623
|
-
...options
|
|
4549
|
+
...options,
|
|
4624
4550
|
refreshInterval: 1e5 /* NORMAL */
|
|
4625
4551
|
}
|
|
4626
4552
|
);
|
|
@@ -4639,29 +4565,27 @@ function useZapStakeBera({
|
|
|
4639
4565
|
...swrResponse.data,
|
|
4640
4566
|
priceImpactPercentage,
|
|
4641
4567
|
isCrossChain: inputToken && tokenOut.chainId !== inputToken?.chainId
|
|
4642
|
-
},
|
|
4643
|
-
refresh: () => {
|
|
4644
|
-
swrResponse.mutate();
|
|
4645
4568
|
}
|
|
4646
4569
|
};
|
|
4647
4570
|
}
|
|
4648
4571
|
|
|
4649
4572
|
// src/hooks/honey/useCappedGlobally.ts
|
|
4650
|
-
import useSWR22 from "swr";
|
|
4651
4573
|
import { usePublicClient as usePublicClient18 } from "@berachain/wagmi/hooks";
|
|
4652
4574
|
|
|
4653
4575
|
// src/hooks/honey/usePythLatestPrices.ts
|
|
4654
|
-
import useSWR21 from "swr";
|
|
4655
4576
|
function usePythLatestPrices({
|
|
4656
4577
|
priceFeedMap
|
|
4657
4578
|
}, options) {
|
|
4658
4579
|
const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
|
|
4659
|
-
const QUERY_KEY =
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4580
|
+
const QUERY_KEY = priceFeedIds ? ["usePythLatestPrices", priceFeedIds] : null;
|
|
4581
|
+
return useSWR(
|
|
4582
|
+
QUERY_KEY,
|
|
4583
|
+
async ([_, priceFeeds]) => {
|
|
4584
|
+
const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
|
|
4585
|
+
return data;
|
|
4586
|
+
},
|
|
4587
|
+
options
|
|
4588
|
+
);
|
|
4665
4589
|
}
|
|
4666
4590
|
|
|
4667
4591
|
// src/hooks/honey/useCappedGlobally.ts
|
|
@@ -4678,9 +4602,7 @@ var useCappedGlobally = ({
|
|
|
4678
4602
|
priceFeedMap: asset?.address && priceFeedMap ? { [asset.address]: priceFeedMap[asset.address] } : void 0
|
|
4679
4603
|
},
|
|
4680
4604
|
{
|
|
4681
|
-
|
|
4682
|
-
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
4683
|
-
}
|
|
4605
|
+
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
4684
4606
|
}
|
|
4685
4607
|
);
|
|
4686
4608
|
const QUERY_KEY = amount && asset && (flags.isPythWrapperEnabled && !!latestPrices?.prices.length || !flags.isPythWrapperEnabled) ? [
|
|
@@ -4691,7 +4613,7 @@ var useCappedGlobally = ({
|
|
|
4691
4613
|
flags.isPythWrapperEnabled,
|
|
4692
4614
|
isBasketModeEnabled2
|
|
4693
4615
|
] : null;
|
|
4694
|
-
|
|
4616
|
+
return useSWR(
|
|
4695
4617
|
QUERY_KEY,
|
|
4696
4618
|
async ([
|
|
4697
4619
|
_,
|
|
@@ -4715,18 +4637,13 @@ var useCappedGlobally = ({
|
|
|
4715
4637
|
});
|
|
4716
4638
|
},
|
|
4717
4639
|
{
|
|
4718
|
-
...options
|
|
4640
|
+
...options,
|
|
4719
4641
|
refreshInterval: 0
|
|
4720
4642
|
}
|
|
4721
4643
|
);
|
|
4722
|
-
return {
|
|
4723
|
-
...swrResponse,
|
|
4724
|
-
refresh: () => void swrResponse.mutate()
|
|
4725
|
-
};
|
|
4726
4644
|
};
|
|
4727
4645
|
|
|
4728
4646
|
// src/hooks/honey/useCappedRelatively.ts
|
|
4729
|
-
import useSWR23 from "swr";
|
|
4730
4647
|
import { usePublicClient as usePublicClient19 } from "@berachain/wagmi/hooks";
|
|
4731
4648
|
var useCappedRelatively = ({
|
|
4732
4649
|
asset,
|
|
@@ -4743,7 +4660,7 @@ var useCappedRelatively = ({
|
|
|
4743
4660
|
collateralList,
|
|
4744
4661
|
referenceCollateral
|
|
4745
4662
|
] : null;
|
|
4746
|
-
|
|
4663
|
+
return useSWR(
|
|
4747
4664
|
QUERY_KEY,
|
|
4748
4665
|
async ([_, asset2, amount2, collaterals, referenceCollateral2]) => {
|
|
4749
4666
|
if (isBasketModeEnabled2) {
|
|
@@ -4778,24 +4695,19 @@ var useCappedRelatively = ({
|
|
|
4778
4695
|
},
|
|
4779
4696
|
{
|
|
4780
4697
|
refreshInterval: 0,
|
|
4781
|
-
...options
|
|
4698
|
+
...options
|
|
4782
4699
|
}
|
|
4783
4700
|
);
|
|
4784
|
-
return {
|
|
4785
|
-
...swrResponse,
|
|
4786
|
-
refresh: () => void swrResponse.mutate()
|
|
4787
|
-
};
|
|
4788
4701
|
};
|
|
4789
4702
|
|
|
4790
4703
|
// src/hooks/honey/useCollateralWeights.ts
|
|
4791
|
-
import useSWR24 from "swr";
|
|
4792
4704
|
import { usePublicClient as usePublicClient20 } from "@berachain/wagmi/hooks";
|
|
4793
4705
|
var useCollateralWeights = ({
|
|
4794
4706
|
collateralList
|
|
4795
4707
|
}, options) => {
|
|
4796
4708
|
const publicClient = usePublicClient20();
|
|
4797
4709
|
const QUERY_KEY = publicClient && collateralList ? ["useCollateralWeights", collateralList] : void 0;
|
|
4798
|
-
|
|
4710
|
+
return useSWR(
|
|
4799
4711
|
QUERY_KEY,
|
|
4800
4712
|
async ([_, collateralList2]) => {
|
|
4801
4713
|
assertPublicClient(publicClient);
|
|
@@ -4805,33 +4717,24 @@ var useCollateralWeights = ({
|
|
|
4805
4717
|
});
|
|
4806
4718
|
},
|
|
4807
4719
|
{
|
|
4808
|
-
...options
|
|
4809
|
-
refreshInterval: options?.
|
|
4720
|
+
...options,
|
|
4721
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
4810
4722
|
}
|
|
4811
4723
|
);
|
|
4812
|
-
return {
|
|
4813
|
-
...swrResponse,
|
|
4814
|
-
refresh: () => void swrResponse.mutate()
|
|
4815
|
-
};
|
|
4816
4724
|
};
|
|
4817
4725
|
|
|
4818
4726
|
// src/hooks/honey/useHoney24hVolume.ts
|
|
4819
|
-
import useSWR25 from "swr";
|
|
4820
4727
|
function useHoney24hVolume() {
|
|
4821
|
-
const response =
|
|
4728
|
+
const response = useSWR(["useHoney24hVolume"], () => getHoney24hVolume(), {
|
|
4822
4729
|
refreshInterval: 18e4 /* SLOW */
|
|
4823
4730
|
});
|
|
4824
|
-
return
|
|
4825
|
-
...response,
|
|
4826
|
-
refresh: () => response.mutate()
|
|
4827
|
-
};
|
|
4731
|
+
return response;
|
|
4828
4732
|
}
|
|
4829
4733
|
|
|
4830
4734
|
// src/hooks/honey/useHoneyAlerts.ts
|
|
4831
4735
|
import { useMemo as useMemo10 } from "react";
|
|
4832
4736
|
|
|
4833
4737
|
// src/hooks/honey/useHoneyBalances.ts
|
|
4834
|
-
import useSWR26 from "swr";
|
|
4835
4738
|
import {
|
|
4836
4739
|
useBeraWallet as useBeraWallet16,
|
|
4837
4740
|
useConfig as useConfig5,
|
|
@@ -4843,7 +4746,7 @@ var useHoneyBalances = () => {
|
|
|
4843
4746
|
const { collateralList } = useHoneyConfig();
|
|
4844
4747
|
const wagmiConfig = useConfig5();
|
|
4845
4748
|
const QUERY_KEY = account && collateralList && publicClient ? ["useHoneyBalances", account, collateralList] : null;
|
|
4846
|
-
|
|
4749
|
+
return useSWR(
|
|
4847
4750
|
QUERY_KEY,
|
|
4848
4751
|
async ([_, account2, collateralList2]) => {
|
|
4849
4752
|
assertPublicClient(publicClient);
|
|
@@ -4866,20 +4769,15 @@ var useHoneyBalances = () => {
|
|
|
4866
4769
|
refreshInterval: 1e4 /* FAST */
|
|
4867
4770
|
}
|
|
4868
4771
|
);
|
|
4869
|
-
return {
|
|
4870
|
-
...swrResponse,
|
|
4871
|
-
refresh: () => swrResponse.mutate()
|
|
4872
|
-
};
|
|
4873
4772
|
};
|
|
4874
4773
|
|
|
4875
4774
|
// src/hooks/honey/useHoneyVaultsBalance.ts
|
|
4876
|
-
import useSWR27 from "swr";
|
|
4877
4775
|
import { usePublicClient as usePublicClient22 } from "@berachain/wagmi/hooks";
|
|
4878
4776
|
var useHoneyVaultsBalance = (options) => {
|
|
4879
4777
|
const publicClient = usePublicClient22();
|
|
4880
4778
|
const { collateralList } = useHoneyConfig();
|
|
4881
4779
|
const QUERY_KEY = collateralList && publicClient ? ["useHoneyVaultsBalance", collateralList] : null;
|
|
4882
|
-
|
|
4780
|
+
return useSWR(
|
|
4883
4781
|
QUERY_KEY,
|
|
4884
4782
|
async ([_, collateralList2]) => {
|
|
4885
4783
|
assertPublicClient(publicClient);
|
|
@@ -4888,16 +4786,11 @@ var useHoneyVaultsBalance = (options) => {
|
|
|
4888
4786
|
collateralList: collateralList2
|
|
4889
4787
|
});
|
|
4890
4788
|
},
|
|
4891
|
-
{ ...options
|
|
4789
|
+
{ ...options, refreshInterval: 1e5 /* NORMAL */ }
|
|
4892
4790
|
);
|
|
4893
|
-
return {
|
|
4894
|
-
...swrResponse,
|
|
4895
|
-
refresh: () => void swrResponse.mutate()
|
|
4896
|
-
};
|
|
4897
4791
|
};
|
|
4898
4792
|
|
|
4899
4793
|
// src/hooks/honey/useIsBadCollateralAsset.ts
|
|
4900
|
-
import useSWR28 from "swr";
|
|
4901
4794
|
import { usePublicClient as usePublicClient23 } from "@berachain/wagmi/hooks";
|
|
4902
4795
|
var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
4903
4796
|
const publicClient = usePublicClient23();
|
|
@@ -4909,9 +4802,7 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4909
4802
|
} : void 0
|
|
4910
4803
|
},
|
|
4911
4804
|
{
|
|
4912
|
-
|
|
4913
|
-
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address
|
|
4914
|
-
}
|
|
4805
|
+
isEnabled: flags.isPythWrapperEnabled && !!collateral?.address
|
|
4915
4806
|
}
|
|
4916
4807
|
);
|
|
4917
4808
|
const QUERY_KEY = publicClient && collateral && (flags.isPythWrapperEnabled && !!latestPrices?.prices.length || !flags.isPythWrapperEnabled) ? [
|
|
@@ -4920,7 +4811,7 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4920
4811
|
latestPrices,
|
|
4921
4812
|
flags.isPythWrapperEnabled
|
|
4922
4813
|
] : null;
|
|
4923
|
-
|
|
4814
|
+
return useSWR(
|
|
4924
4815
|
QUERY_KEY,
|
|
4925
4816
|
async ([_, collateral2, latestPrices2, isPythWrapperEnabled]) => {
|
|
4926
4817
|
assertPublicClient(publicClient);
|
|
@@ -4932,14 +4823,10 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
4932
4823
|
});
|
|
4933
4824
|
},
|
|
4934
4825
|
{
|
|
4935
|
-
...options
|
|
4936
|
-
refreshInterval: options?.
|
|
4826
|
+
...options,
|
|
4827
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
4937
4828
|
}
|
|
4938
4829
|
);
|
|
4939
|
-
return {
|
|
4940
|
-
...swrResponse,
|
|
4941
|
-
refresh: () => void swrResponse.mutate()
|
|
4942
|
-
};
|
|
4943
4830
|
};
|
|
4944
4831
|
|
|
4945
4832
|
// src/hooks/honey/useHoneyAlerts.ts
|
|
@@ -5120,18 +5007,10 @@ var useHoneyAlerts = ({
|
|
|
5120
5007
|
};
|
|
5121
5008
|
|
|
5122
5009
|
// src/hooks/honey/useHoneyChartData.ts
|
|
5123
|
-
import useSWR29 from "swr";
|
|
5124
5010
|
function useHoneyChartData({ days }) {
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
return await getChartData({ days: days2 });
|
|
5129
|
-
}
|
|
5130
|
-
);
|
|
5131
|
-
return {
|
|
5132
|
-
...swrResponse,
|
|
5133
|
-
refresh: () => swrResponse.mutate()
|
|
5134
|
-
};
|
|
5011
|
+
return useSWR(["useHoneyChartData", days], async ([_, days2]) => {
|
|
5012
|
+
return await getChartData({ days: days2 });
|
|
5013
|
+
});
|
|
5135
5014
|
}
|
|
5136
5015
|
|
|
5137
5016
|
// src/hooks/honey/useHoneySwapState.ts
|
|
@@ -5140,7 +5019,6 @@ import { formatUnits as formatUnits10 } from "viem";
|
|
|
5140
5019
|
import { defaultChainId as defaultChainId10 } from "@berachain/config/internal";
|
|
5141
5020
|
|
|
5142
5021
|
// src/hooks/honey/useIsBasketModeEnabled.ts
|
|
5143
|
-
import useSWR30 from "swr";
|
|
5144
5022
|
import { usePublicClient as usePublicClient24 } from "@berachain/wagmi/hooks";
|
|
5145
5023
|
function useIsBasketModeEnabled({ state }, options) {
|
|
5146
5024
|
const publicClient = usePublicClient24();
|
|
@@ -5150,9 +5028,7 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5150
5028
|
priceFeedMap
|
|
5151
5029
|
},
|
|
5152
5030
|
{
|
|
5153
|
-
|
|
5154
|
-
isEnabled: flags.isPythWrapperEnabled && !!collateralList.length
|
|
5155
|
-
}
|
|
5031
|
+
isEnabled: flags.isPythWrapperEnabled && !!collateralList.length
|
|
5156
5032
|
}
|
|
5157
5033
|
);
|
|
5158
5034
|
const isMint = state.actionType === "mint";
|
|
@@ -5163,7 +5039,7 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5163
5039
|
flags.isPythWrapperEnabled,
|
|
5164
5040
|
collateralList
|
|
5165
5041
|
] : null;
|
|
5166
|
-
|
|
5042
|
+
return useSWR(
|
|
5167
5043
|
QUERY_KEY,
|
|
5168
5044
|
async ([_, isMint2, latestPrices2, isPythWrapperEnabled, collateralList2]) => {
|
|
5169
5045
|
assertPublicClient(publicClient);
|
|
@@ -5177,15 +5053,10 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
5177
5053
|
return isActive;
|
|
5178
5054
|
},
|
|
5179
5055
|
{
|
|
5180
|
-
...options
|
|
5181
|
-
refreshInterval: options?.
|
|
5056
|
+
...options,
|
|
5057
|
+
refreshInterval: options?.refreshInterval ?? 1e4 /* FAST */
|
|
5182
5058
|
}
|
|
5183
5059
|
);
|
|
5184
|
-
return {
|
|
5185
|
-
...swrResponse,
|
|
5186
|
-
data: swrResponse.data,
|
|
5187
|
-
refresh: () => void swrResponse.mutate()
|
|
5188
|
-
};
|
|
5189
5060
|
}
|
|
5190
5061
|
|
|
5191
5062
|
// src/hooks/honey/useHoneySwapState.ts
|
|
@@ -5324,21 +5195,24 @@ var useHoneySwapState = () => {
|
|
|
5324
5195
|
};
|
|
5325
5196
|
|
|
5326
5197
|
// src/hooks/perps/usePythUpdateFee.ts
|
|
5327
|
-
import useSWRImmutable8 from "swr/immutable";
|
|
5328
5198
|
import { usePublicClient as usePublicClient25 } from "@berachain/wagmi/hooks";
|
|
5329
5199
|
var usePythUpdateFee = ({
|
|
5330
5200
|
pythPriceFeedCalldata,
|
|
5331
5201
|
tokenListLength
|
|
5332
5202
|
}, options) => {
|
|
5333
5203
|
const publicClient = usePublicClient25();
|
|
5334
|
-
const QUERY_KEY =
|
|
5335
|
-
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } =
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5204
|
+
const QUERY_KEY = pythPriceFeedCalldata && pythPriceFeedCalldata.length > 0 ? ["usePythUpdateFee", pythPriceFeedCalldata] : null;
|
|
5205
|
+
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } = useSWRImmutable(
|
|
5206
|
+
QUERY_KEY,
|
|
5207
|
+
async ([_, pythPriceFeedCalldata2]) => {
|
|
5208
|
+
assertPublicClient(publicClient);
|
|
5209
|
+
return getPythUpdateFee({
|
|
5210
|
+
client: publicClient,
|
|
5211
|
+
priceFeedId: pythPriceFeedCalldata2
|
|
5212
|
+
});
|
|
5213
|
+
},
|
|
5214
|
+
options
|
|
5215
|
+
);
|
|
5342
5216
|
return {
|
|
5343
5217
|
QUERY_KEY,
|
|
5344
5218
|
data,
|
|
@@ -5347,14 +5221,13 @@ var usePythUpdateFee = ({
|
|
|
5347
5221
|
};
|
|
5348
5222
|
|
|
5349
5223
|
// src/hooks/pol/useAutoclaimedIncentives.ts
|
|
5350
|
-
import useSWR31 from "swr";
|
|
5351
5224
|
import { useBeraWallet as useBeraWallet17 } from "@berachain/wagmi/hooks";
|
|
5352
5225
|
function useAutoclaimedIncentives({
|
|
5353
5226
|
enabled
|
|
5354
5227
|
}) {
|
|
5355
5228
|
const { address: account } = useBeraWallet17();
|
|
5356
5229
|
const QUERY_KEY = enabled && account ? ["useAutoclaimedIncentives", account] : null;
|
|
5357
|
-
|
|
5230
|
+
return useSWR(
|
|
5358
5231
|
QUERY_KEY,
|
|
5359
5232
|
async ([, account2]) => getAutoclaimedIncentives({ account: account2 }),
|
|
5360
5233
|
{
|
|
@@ -5363,21 +5236,16 @@ function useAutoclaimedIncentives({
|
|
|
5363
5236
|
revalidateIfStale: false
|
|
5364
5237
|
}
|
|
5365
5238
|
);
|
|
5366
|
-
return {
|
|
5367
|
-
...swrResponse,
|
|
5368
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5369
|
-
};
|
|
5370
5239
|
}
|
|
5371
5240
|
|
|
5372
5241
|
// src/hooks/pol/useAutoclaimedIncentivesTxHash.ts
|
|
5373
|
-
import useSWR32 from "swr";
|
|
5374
5242
|
import { useBeraWallet as useBeraWallet18 } from "@berachain/wagmi/hooks";
|
|
5375
5243
|
function useAutoclaimedIncentivesTxHash({
|
|
5376
5244
|
enabled
|
|
5377
5245
|
}) {
|
|
5378
5246
|
const { address: account } = useBeraWallet18();
|
|
5379
5247
|
const QUERY_KEY = enabled && account ? ["useAutoclaimedIncentivesTxHash", account] : null;
|
|
5380
|
-
|
|
5248
|
+
return useSWR(
|
|
5381
5249
|
QUERY_KEY,
|
|
5382
5250
|
async ([, account2]) => getAutoclaimedIncentivesTxHash({ account: account2 }),
|
|
5383
5251
|
{
|
|
@@ -5391,10 +5259,6 @@ function useAutoclaimedIncentivesTxHash({
|
|
|
5391
5259
|
revalidateIfStale: false
|
|
5392
5260
|
}
|
|
5393
5261
|
);
|
|
5394
|
-
return {
|
|
5395
|
-
...swrResponse,
|
|
5396
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5397
|
-
};
|
|
5398
5262
|
}
|
|
5399
5263
|
|
|
5400
5264
|
// src/hooks/pol/useBgtAprSimulation.ts
|
|
@@ -5408,16 +5272,31 @@ function useBgtAprSimulation(args) {
|
|
|
5408
5272
|
}, [args]);
|
|
5409
5273
|
}
|
|
5410
5274
|
|
|
5275
|
+
// src/hooks/pol/useBgtIncentiveDistributorPaused.ts
|
|
5276
|
+
import { usePublicClient as usePublicClient26 } from "@berachain/wagmi/hooks";
|
|
5277
|
+
function useBgtIncentiveDistributorPaused(options) {
|
|
5278
|
+
const publicClient = usePublicClient26();
|
|
5279
|
+
const QUERY_KEY = publicClient ? ["useBgtIncentiveDistributorPaused", publicClient.chain?.id] : null;
|
|
5280
|
+
return swr_default(
|
|
5281
|
+
QUERY_KEY,
|
|
5282
|
+
async () => getBgtIncentiveDistributorPaused({ publicClient }).catch(() => false),
|
|
5283
|
+
{
|
|
5284
|
+
revalidateOnFocus: false,
|
|
5285
|
+
revalidateOnReconnect: false,
|
|
5286
|
+
...options
|
|
5287
|
+
}
|
|
5288
|
+
);
|
|
5289
|
+
}
|
|
5290
|
+
|
|
5411
5291
|
// src/hooks/pol/useBgtUnstakedBalance.ts
|
|
5412
|
-
import useSWR33 from "swr";
|
|
5413
5292
|
import { formatEther as formatEther5 } from "viem";
|
|
5414
5293
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5415
|
-
import { useBeraWallet as useBeraWallet19, usePublicClient as
|
|
5294
|
+
import { useBeraWallet as useBeraWallet19, usePublicClient as usePublicClient27 } from "@berachain/wagmi/hooks";
|
|
5416
5295
|
var useBgtUnstakedBalance = (options) => {
|
|
5417
5296
|
const { address: account } = useBeraWallet19();
|
|
5418
|
-
const publicClient =
|
|
5297
|
+
const publicClient = usePublicClient27();
|
|
5419
5298
|
const QUERY_KEY = account && publicClient ? ["useBgtUnstakedBalance", account] : null;
|
|
5420
|
-
|
|
5299
|
+
return useSWR(
|
|
5421
5300
|
QUERY_KEY,
|
|
5422
5301
|
async ([, account2]) => {
|
|
5423
5302
|
assertPublicClient(publicClient);
|
|
@@ -5434,24 +5313,19 @@ var useBgtUnstakedBalance = (options) => {
|
|
|
5434
5313
|
},
|
|
5435
5314
|
{
|
|
5436
5315
|
...options,
|
|
5437
|
-
refreshInterval: options?.
|
|
5316
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
5438
5317
|
}
|
|
5439
5318
|
);
|
|
5440
|
-
return {
|
|
5441
|
-
...swrResponse,
|
|
5442
|
-
refresh: () => swrResponse.mutate()
|
|
5443
|
-
};
|
|
5444
5319
|
};
|
|
5445
5320
|
|
|
5446
5321
|
// src/hooks/pol/useClaimableFees.ts
|
|
5447
|
-
import useSWR34 from "swr";
|
|
5448
5322
|
import { formatUnits as formatUnits11 } from "viem";
|
|
5449
|
-
import { useBeraWallet as useBeraWallet20, usePublicClient as
|
|
5323
|
+
import { useBeraWallet as useBeraWallet20, usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5450
5324
|
var useClaimableFees = () => {
|
|
5451
5325
|
const { address: account } = useBeraWallet20();
|
|
5452
|
-
const publicClient =
|
|
5326
|
+
const publicClient = usePublicClient28();
|
|
5453
5327
|
const QUERY_KEY = account && publicClient ? ["useClaimableFees", account] : null;
|
|
5454
|
-
|
|
5328
|
+
return useSWR(
|
|
5455
5329
|
QUERY_KEY,
|
|
5456
5330
|
async ([, account2]) => {
|
|
5457
5331
|
assertPublicClient(publicClient);
|
|
@@ -5469,10 +5343,6 @@ var useClaimableFees = () => {
|
|
|
5469
5343
|
refreshInterval: 18e4 /* SLOW */ * 2
|
|
5470
5344
|
}
|
|
5471
5345
|
);
|
|
5472
|
-
return {
|
|
5473
|
-
...swrResponse,
|
|
5474
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5475
|
-
};
|
|
5476
5346
|
};
|
|
5477
5347
|
|
|
5478
5348
|
// src/hooks/pol/useHighestVaultsAPR.ts
|
|
@@ -5482,8 +5352,7 @@ import {
|
|
|
5482
5352
|
} from "@berachain/graphql/pol/api";
|
|
5483
5353
|
|
|
5484
5354
|
// src/hooks/pol/useRewardVaults.ts
|
|
5485
|
-
import
|
|
5486
|
-
import { usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5355
|
+
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5487
5356
|
var useRewardVaultsQueryKey = (filter, onChainIncentives = false) => {
|
|
5488
5357
|
return ["useRewardVaults", filter, onChainIncentives];
|
|
5489
5358
|
};
|
|
@@ -5492,23 +5361,17 @@ var useRewardVaults = (args, options) => {
|
|
|
5492
5361
|
args.filter,
|
|
5493
5362
|
args.onChainIncentives
|
|
5494
5363
|
);
|
|
5495
|
-
const publicClient =
|
|
5496
|
-
|
|
5497
|
-
|
|
5364
|
+
const publicClient = usePublicClient29();
|
|
5365
|
+
return useSWR(
|
|
5366
|
+
QUERY_KEY,
|
|
5498
5367
|
async ([, filter, onChainIncentives]) => {
|
|
5499
5368
|
return await getRewardVaults({
|
|
5500
5369
|
filter,
|
|
5501
5370
|
publicClient: onChainIncentives ? publicClient : void 0
|
|
5502
5371
|
});
|
|
5503
5372
|
},
|
|
5504
|
-
|
|
5505
|
-
...options?.opts
|
|
5506
|
-
}
|
|
5373
|
+
options
|
|
5507
5374
|
);
|
|
5508
|
-
return {
|
|
5509
|
-
...swrResponse,
|
|
5510
|
-
refresh: swrResponse.mutate
|
|
5511
|
-
};
|
|
5512
5375
|
};
|
|
5513
5376
|
|
|
5514
5377
|
// src/hooks/pol/useHighestVaultsAPR.ts
|
|
@@ -5523,27 +5386,23 @@ var useHighestVaultsAPR = (where = {}, { isEnabled = true } = {}) => {
|
|
|
5523
5386
|
}
|
|
5524
5387
|
},
|
|
5525
5388
|
{
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
isEnabled
|
|
5531
|
-
}
|
|
5389
|
+
refreshInterval: 0,
|
|
5390
|
+
revalidateOnFocus: false,
|
|
5391
|
+
refreshWhenOffline: false,
|
|
5392
|
+
isEnabled
|
|
5532
5393
|
}
|
|
5533
5394
|
);
|
|
5534
5395
|
return {
|
|
5535
5396
|
isLoading: swrResponse.isLoading,
|
|
5536
|
-
highestApr: swrResponse.data?.
|
|
5537
|
-
refresh: swrResponse.mutate
|
|
5397
|
+
highestApr: swrResponse.data?.rewardVaultList[0].dynamicData?.apr
|
|
5538
5398
|
};
|
|
5539
5399
|
};
|
|
5540
5400
|
|
|
5541
5401
|
// src/hooks/pol/usePollGlobalData.ts
|
|
5542
|
-
import
|
|
5543
|
-
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5402
|
+
import { usePublicClient as usePublicClient30 } from "@berachain/wagmi/hooks";
|
|
5544
5403
|
var usePollGlobalData = (options) => {
|
|
5545
|
-
const publicClient =
|
|
5546
|
-
|
|
5404
|
+
const publicClient = usePublicClient30();
|
|
5405
|
+
return useSWR(
|
|
5547
5406
|
publicClient ? "usePollGlobalData" : null,
|
|
5548
5407
|
async () => {
|
|
5549
5408
|
assertPublicClient(publicClient);
|
|
@@ -5551,55 +5410,45 @@ var usePollGlobalData = (options) => {
|
|
|
5551
5410
|
},
|
|
5552
5411
|
{
|
|
5553
5412
|
revalidateOnFocus: false,
|
|
5554
|
-
...options
|
|
5413
|
+
...options
|
|
5555
5414
|
}
|
|
5556
5415
|
);
|
|
5557
|
-
return {
|
|
5558
|
-
...swrResponse,
|
|
5559
|
-
refresh: swrResponse.mutate
|
|
5560
|
-
};
|
|
5561
5416
|
};
|
|
5562
5417
|
|
|
5563
5418
|
// src/hooks/pol/usePollMarkets.ts
|
|
5564
|
-
import useSWRImmutable9 from "swr/immutable";
|
|
5565
5419
|
var usePollMarketsQueryKey = () => {
|
|
5566
5420
|
return "usePollMarkets";
|
|
5567
5421
|
};
|
|
5568
5422
|
var usePollMarkets = (options) => {
|
|
5569
5423
|
const QUERY_KEY = usePollMarketsQueryKey();
|
|
5570
|
-
|
|
5424
|
+
return useSWRImmutable(
|
|
5571
5425
|
QUERY_KEY,
|
|
5572
5426
|
async () => {
|
|
5573
5427
|
const res = await getMarkets();
|
|
5574
5428
|
return res;
|
|
5575
5429
|
},
|
|
5576
5430
|
{
|
|
5577
|
-
...options
|
|
5431
|
+
...options
|
|
5578
5432
|
}
|
|
5579
5433
|
);
|
|
5580
|
-
return {
|
|
5581
|
-
...swrResponse,
|
|
5582
|
-
refresh: () => swrResponse.mutate()
|
|
5583
|
-
};
|
|
5584
5434
|
};
|
|
5585
5435
|
|
|
5586
5436
|
// src/hooks/pol/useQueuedBeraUnlock.ts
|
|
5587
|
-
import useSWRImmutable10 from "swr/immutable";
|
|
5588
5437
|
import { isAddress as isAddress9 } from "viem";
|
|
5589
|
-
import { usePublicClient as
|
|
5438
|
+
import { usePublicClient as usePublicClient31 } from "@berachain/wagmi/hooks";
|
|
5590
5439
|
function useQueuedBeraUnlock({
|
|
5591
5440
|
receiptTokenAddresses,
|
|
5592
5441
|
account,
|
|
5593
5442
|
version
|
|
5594
5443
|
}, options) {
|
|
5595
|
-
const publicClient =
|
|
5444
|
+
const publicClient = usePublicClient31();
|
|
5596
5445
|
const QUERY_KEY = receiptTokenAddresses && account && publicClient && isAddress9(account) && version ? [
|
|
5597
5446
|
"useQueuedBeraUnlock",
|
|
5598
5447
|
receiptTokenAddresses,
|
|
5599
5448
|
account,
|
|
5600
5449
|
version
|
|
5601
5450
|
] : null;
|
|
5602
|
-
|
|
5451
|
+
return useSWRImmutable(
|
|
5603
5452
|
QUERY_KEY,
|
|
5604
5453
|
async ([, receiptTokenAddresses2, account2, version2]) => {
|
|
5605
5454
|
assertPublicClient(publicClient);
|
|
@@ -5616,26 +5465,21 @@ function useQueuedBeraUnlock({
|
|
|
5616
5465
|
},
|
|
5617
5466
|
{
|
|
5618
5467
|
refreshInterval: 1e4 /* FAST */,
|
|
5619
|
-
...options
|
|
5468
|
+
...options
|
|
5620
5469
|
}
|
|
5621
5470
|
);
|
|
5622
|
-
return {
|
|
5623
|
-
...swrResponse,
|
|
5624
|
-
refresh: () => swrResponse.mutate()
|
|
5625
|
-
};
|
|
5626
5471
|
}
|
|
5627
5472
|
|
|
5628
5473
|
// src/hooks/pol/useRewardTokenToBeraRate.ts
|
|
5629
|
-
import useSWR37 from "swr";
|
|
5630
5474
|
import { isAddress as isAddress10 } from "viem";
|
|
5631
5475
|
import { defaultChainId as defaultChainId11 } from "@berachain/config/internal";
|
|
5632
|
-
import { usePublicClient as
|
|
5476
|
+
import { usePublicClient as usePublicClient32 } from "@berachain/wagmi/hooks";
|
|
5633
5477
|
var useRewardTokenToBeraRate = ({
|
|
5634
5478
|
address
|
|
5635
5479
|
}, opt) => {
|
|
5636
5480
|
const QUERY_KEY = address ? ["useRewardTokenToBeraRate", address] : null;
|
|
5637
|
-
const publicClient =
|
|
5638
|
-
return
|
|
5481
|
+
const publicClient = usePublicClient32({ chainId: defaultChainId11 });
|
|
5482
|
+
return useSWR(
|
|
5639
5483
|
QUERY_KEY,
|
|
5640
5484
|
async ([_, address2]) => {
|
|
5641
5485
|
if (!address2 || !isAddress10(address2)) {
|
|
@@ -5652,19 +5496,15 @@ var useRewardTokenToBeraRate = ({
|
|
|
5652
5496
|
});
|
|
5653
5497
|
},
|
|
5654
5498
|
{
|
|
5655
|
-
...opt
|
|
5499
|
+
...opt
|
|
5656
5500
|
}
|
|
5657
5501
|
);
|
|
5658
5502
|
};
|
|
5659
5503
|
|
|
5660
|
-
// src/hooks/pol/useRewardVault.ts
|
|
5661
|
-
import useSWR39 from "swr";
|
|
5662
|
-
|
|
5663
5504
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
5664
|
-
import useSWR38 from "swr";
|
|
5665
5505
|
import { erc20Abi as erc20Abi4, formatUnits as formatUnits13, isAddress as isAddress11 } from "viem";
|
|
5666
5506
|
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
5667
|
-
import { usePublicClient as
|
|
5507
|
+
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
5668
5508
|
|
|
5669
5509
|
// src/actions/pol/getStakingTokenInformation.ts
|
|
5670
5510
|
import { erc20Abi as erc20Abi3, formatUnits as formatUnits12 } from "viem";
|
|
@@ -5713,98 +5553,102 @@ var useOnChainRewardVaultQueryKey = (address) => address && isAddress11(address)
|
|
|
5713
5553
|
var useOnChainRewardVault = ({
|
|
5714
5554
|
address
|
|
5715
5555
|
}, opt) => {
|
|
5716
|
-
const publicClient =
|
|
5717
|
-
const isEnabled = opt.opts?.isEnabled ?? true;
|
|
5556
|
+
const publicClient = usePublicClient33();
|
|
5718
5557
|
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({
|
|
5558
|
+
return useSWR(
|
|
5559
|
+
publicClient ? QUERY_KEY : null,
|
|
5560
|
+
async ([, address2]) => {
|
|
5561
|
+
assertPublicClient(publicClient);
|
|
5562
|
+
const { config } = parseBaseArgs({
|
|
5563
|
+
chainId: publicClient.chain.id
|
|
5564
|
+
});
|
|
5565
|
+
const stakingTokenAddress = await getRewardVaultStakingToken({
|
|
5730
5566
|
address: address2,
|
|
5731
|
-
stakingToken: stakingTokenAddress,
|
|
5732
|
-
publicClient
|
|
5733
|
-
}),
|
|
5734
|
-
publicClient.readContract({
|
|
5735
|
-
address: config.pol.beraChef,
|
|
5736
|
-
abi: beraChefAbi,
|
|
5737
|
-
functionName: "isWhitelistedVault",
|
|
5738
|
-
args: [address2]
|
|
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
5567
|
publicClient
|
|
5751
|
-
})
|
|
5752
|
-
Promise.all(
|
|
5753
|
-
|
|
5754
|
-
(
|
|
5755
|
-
address:
|
|
5756
|
-
|
|
5568
|
+
});
|
|
5569
|
+
const [incentives, isWhitelisted, stakingTokenAmount] = await Promise.all(
|
|
5570
|
+
[
|
|
5571
|
+
getRewardVaultIncentives({
|
|
5572
|
+
address: address2,
|
|
5573
|
+
stakingToken: stakingTokenAddress,
|
|
5757
5574
|
publicClient
|
|
5575
|
+
}),
|
|
5576
|
+
publicClient.readContract({
|
|
5577
|
+
address: config.pol.beraChef,
|
|
5578
|
+
abi: beraChefAbi,
|
|
5579
|
+
functionName: "isWhitelistedVault",
|
|
5580
|
+
args: [address2]
|
|
5581
|
+
}),
|
|
5582
|
+
publicClient.readContract({
|
|
5583
|
+
address: stakingTokenAddress,
|
|
5584
|
+
abi: erc20Abi4,
|
|
5585
|
+
functionName: "balanceOf",
|
|
5586
|
+
args: [address2]
|
|
5758
5587
|
})
|
|
5588
|
+
]
|
|
5589
|
+
);
|
|
5590
|
+
const [stakingToken, incentiveTokens] = await Promise.all([
|
|
5591
|
+
getStakingTokenInformation({
|
|
5592
|
+
address: stakingTokenAddress,
|
|
5593
|
+
publicClient
|
|
5594
|
+
}),
|
|
5595
|
+
Promise.all(
|
|
5596
|
+
incentives.map(
|
|
5597
|
+
(add) => getTokenInformation({
|
|
5598
|
+
address: add.token,
|
|
5599
|
+
chainId: publicClient.chain.id,
|
|
5600
|
+
publicClient
|
|
5601
|
+
})
|
|
5602
|
+
)
|
|
5759
5603
|
)
|
|
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
|
-
|
|
5604
|
+
]);
|
|
5605
|
+
if (!stakingToken) {
|
|
5606
|
+
throw new Error("Staking token not found");
|
|
5607
|
+
}
|
|
5608
|
+
return {
|
|
5609
|
+
id: address2,
|
|
5610
|
+
address: address2,
|
|
5611
|
+
vaultAddress: address2,
|
|
5612
|
+
stakingToken: {
|
|
5613
|
+
address: stakingTokenAddress,
|
|
5614
|
+
name: stakingToken.name ?? "",
|
|
5615
|
+
symbol: stakingToken.symbol ?? "",
|
|
5616
|
+
decimals: stakingToken.decimals ?? 0
|
|
5617
|
+
},
|
|
5618
|
+
stakingTokenAmount: formatUnits13(
|
|
5619
|
+
stakingTokenAmount,
|
|
5620
|
+
stakingToken.decimals ?? 18
|
|
5621
|
+
),
|
|
5622
|
+
isVaultWhitelisted: isWhitelisted,
|
|
5623
|
+
activeIncentives: incentives.map((incentive, idx) => ({
|
|
5624
|
+
active: !!incentive.remainingAmount,
|
|
5625
|
+
remainingAmount: incentive.remainingAmount,
|
|
5626
|
+
remainingAmountUsd: "0",
|
|
5627
|
+
incentiveRate: incentive.incentiveRate,
|
|
5628
|
+
incentiveRateUsd: "0",
|
|
5629
|
+
tokenAddress: incentive.token,
|
|
5630
|
+
token: incentiveTokens[idx]
|
|
5631
|
+
}))
|
|
5632
|
+
};
|
|
5633
|
+
},
|
|
5634
|
+
opt
|
|
5635
|
+
);
|
|
5791
5636
|
};
|
|
5792
5637
|
|
|
5793
5638
|
// src/hooks/pol/useRewardVault.ts
|
|
5794
5639
|
var useRewardVaultQueryKey = (address) => address ? ["useRewardVault", address.toLowerCase()] : null;
|
|
5795
5640
|
var useRewardVault = (id, options) => {
|
|
5796
5641
|
const QUERY_KEY = useRewardVaultQueryKey(id);
|
|
5797
|
-
const
|
|
5642
|
+
const { isEnabled: _isEnabled, ...swrOptions } = options ?? {};
|
|
5643
|
+
const swrResponse = useSWR(
|
|
5798
5644
|
QUERY_KEY,
|
|
5799
5645
|
async ([_, id2]) => getRewardVault({ address: id2 }),
|
|
5800
|
-
|
|
5801
|
-
...options?.opts
|
|
5802
|
-
}
|
|
5646
|
+
swrOptions
|
|
5803
5647
|
);
|
|
5804
|
-
const isOnChainEnabled = options?.
|
|
5648
|
+
const isOnChainEnabled = options?.isEnabled ?? ((!!swrResponse.error || !swrResponse.isLoading) && !swrResponse.data);
|
|
5805
5649
|
const onChainRewardVault = useOnChainRewardVault(
|
|
5806
5650
|
{ address: id },
|
|
5807
|
-
{
|
|
5651
|
+
{ ...options, isEnabled: isOnChainEnabled }
|
|
5808
5652
|
);
|
|
5809
5653
|
return {
|
|
5810
5654
|
data: onChainRewardVault.data ?? swrResponse.data,
|
|
@@ -5812,22 +5656,21 @@ var useRewardVault = (id, options) => {
|
|
|
5812
5656
|
isLoading: onChainRewardVault.isLoading || swrResponse.isLoading,
|
|
5813
5657
|
isValidating: onChainRewardVault.isValidating ?? swrResponse.isValidating,
|
|
5814
5658
|
refresh: () => {
|
|
5815
|
-
swrResponse.
|
|
5816
|
-
onChainRewardVault.
|
|
5659
|
+
swrResponse.refresh();
|
|
5660
|
+
onChainRewardVault.refresh();
|
|
5817
5661
|
}
|
|
5818
5662
|
};
|
|
5819
5663
|
};
|
|
5820
5664
|
|
|
5821
5665
|
// src/hooks/pol/useRewardVaultIncentives.ts
|
|
5822
|
-
import
|
|
5823
|
-
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
5666
|
+
import { usePublicClient as usePublicClient34 } from "@berachain/wagmi/hooks";
|
|
5824
5667
|
function useRewardVaultIncentives({
|
|
5825
5668
|
address,
|
|
5826
5669
|
stakingToken
|
|
5827
5670
|
}) {
|
|
5828
|
-
const publicClient =
|
|
5671
|
+
const publicClient = usePublicClient34();
|
|
5829
5672
|
const QUERY_KEY = publicClient && address && stakingToken ? ["useRewardVaultIncentives", address, stakingToken] : null;
|
|
5830
|
-
|
|
5673
|
+
return useSWR(QUERY_KEY, async ([, address2, stakingToken2]) => {
|
|
5831
5674
|
assertPublicClient(publicClient);
|
|
5832
5675
|
return await getRewardVaultIncentives({
|
|
5833
5676
|
address: address2,
|
|
@@ -5835,37 +5678,25 @@ function useRewardVaultIncentives({
|
|
|
5835
5678
|
publicClient
|
|
5836
5679
|
});
|
|
5837
5680
|
});
|
|
5838
|
-
return {
|
|
5839
|
-
...swrResponse,
|
|
5840
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5841
|
-
};
|
|
5842
5681
|
}
|
|
5843
5682
|
|
|
5844
5683
|
// src/hooks/pol/useRewardVaultRewards.ts
|
|
5845
|
-
import
|
|
5846
|
-
import { usePublicClient as usePublicClient34 } from "@berachain/wagmi/hooks";
|
|
5684
|
+
import { usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
5847
5685
|
var useRewardVaultRewards = (address, options) => {
|
|
5848
|
-
const publicClient =
|
|
5686
|
+
const publicClient = usePublicClient35();
|
|
5849
5687
|
const QUERY_KEY = publicClient && address ? ["useRewardVaultRewards", address] : null;
|
|
5850
|
-
|
|
5688
|
+
return useSWR(
|
|
5851
5689
|
QUERY_KEY,
|
|
5852
5690
|
async ([, address2]) => {
|
|
5853
5691
|
assertPublicClient(publicClient);
|
|
5854
5692
|
return await getRewardVaultRewards(address2, publicClient);
|
|
5855
5693
|
},
|
|
5856
5694
|
{
|
|
5857
|
-
...options
|
|
5695
|
+
...options
|
|
5858
5696
|
}
|
|
5859
5697
|
);
|
|
5860
|
-
return {
|
|
5861
|
-
...swrResponse,
|
|
5862
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5863
|
-
};
|
|
5864
5698
|
};
|
|
5865
5699
|
|
|
5866
|
-
// src/hooks/pol/useStakedAPR.ts
|
|
5867
|
-
import useSWR42 from "swr";
|
|
5868
|
-
|
|
5869
5700
|
// src/utils/filter.ts
|
|
5870
5701
|
var dailyResolution = (data) => {
|
|
5871
5702
|
const dailyData = [];
|
|
@@ -5893,7 +5724,7 @@ function useStakedAPR({
|
|
|
5893
5724
|
range
|
|
5894
5725
|
}) {
|
|
5895
5726
|
const QUERY_KEY = range ? ["useStakedAPR", range] : null;
|
|
5896
|
-
|
|
5727
|
+
return useSWR(QUERY_KEY, async ([, range2]) => {
|
|
5897
5728
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
5898
5729
|
range: range2
|
|
5899
5730
|
});
|
|
@@ -5905,19 +5736,14 @@ function useStakedAPR({
|
|
|
5905
5736
|
apr: item.apr
|
|
5906
5737
|
}));
|
|
5907
5738
|
});
|
|
5908
|
-
return {
|
|
5909
|
-
...swrResponse,
|
|
5910
|
-
refresh: () => swrResponse.mutate()
|
|
5911
|
-
};
|
|
5912
5739
|
}
|
|
5913
5740
|
|
|
5914
5741
|
// src/hooks/pol/useStakedData.ts
|
|
5915
5742
|
import { useMemo as useMemo12 } from "react";
|
|
5916
|
-
import
|
|
5917
|
-
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
5743
|
+
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
5918
5744
|
var useStakedData = (stakingConfigs) => {
|
|
5919
5745
|
const window2 = useBeraFlag("swberaAprWindow");
|
|
5920
|
-
const publicClient =
|
|
5746
|
+
const publicClient = usePublicClient36();
|
|
5921
5747
|
const { address: account } = useBeraWallet21();
|
|
5922
5748
|
const receiptTokens = useMemo12(
|
|
5923
5749
|
() => stakingConfigs.map((config) => config.receiptToken),
|
|
@@ -5928,15 +5754,21 @@ var useStakedData = (stakingConfigs) => {
|
|
|
5928
5754
|
[stakingConfigs]
|
|
5929
5755
|
);
|
|
5930
5756
|
const aprKey = window2 ? ["useStakedData:apr", window2] : null;
|
|
5931
|
-
const { data: apr } =
|
|
5757
|
+
const { data: apr } = useSWR(
|
|
5932
5758
|
aprKey,
|
|
5933
5759
|
async ([, window3]) => getStakedBeraAPR({ window: window3 }),
|
|
5934
5760
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
5935
5761
|
);
|
|
5936
|
-
const {
|
|
5937
|
-
|
|
5762
|
+
const {
|
|
5763
|
+
data: walletBalances,
|
|
5764
|
+
isLoading: isLoadingBalances,
|
|
5765
|
+
error: walletBalancesError
|
|
5766
|
+
} = usePollWalletBalances({ tokens: receiptTokens });
|
|
5767
|
+
const { getTokenPrice } = useTokenPrices({
|
|
5768
|
+
tokens: inputTokens
|
|
5769
|
+
});
|
|
5938
5770
|
const exchangeRatesKey = publicClient && receiptTokens.length > 0 ? ["useStakedData:exchangeRates", receiptTokens] : null;
|
|
5939
|
-
const { data: exchangeRates } =
|
|
5771
|
+
const { data: exchangeRates, error: exchangeRatesError } = useSWR(
|
|
5940
5772
|
exchangeRatesKey,
|
|
5941
5773
|
async ([, receiptTokens2]) => {
|
|
5942
5774
|
assertPublicClient(publicClient);
|
|
@@ -5951,33 +5783,13 @@ var useStakedData = (stakingConfigs) => {
|
|
|
5951
5783
|
},
|
|
5952
5784
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
5953
5785
|
);
|
|
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
5786
|
const positionsKey = account && publicClient && stakingConfigs.length > 0 ? ["useStakedData:positions", account, stakingConfigs] : null;
|
|
5976
5787
|
const {
|
|
5977
5788
|
data: positionsRaw,
|
|
5789
|
+
error: positionsError,
|
|
5978
5790
|
isLoading: isLoadingPositions,
|
|
5979
5791
|
isValidating: isValidatingPositions
|
|
5980
|
-
} =
|
|
5792
|
+
} = useSWR(
|
|
5981
5793
|
positionsKey,
|
|
5982
5794
|
async ([, account2, stakingConfigs2]) => {
|
|
5983
5795
|
assertPublicClient(publicClient);
|
|
@@ -6000,13 +5812,42 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6000
5812
|
},
|
|
6001
5813
|
{ refreshInterval: 1e4 /* FAST */ }
|
|
6002
5814
|
);
|
|
5815
|
+
const earningsSettled = !!positionsRaw || !!positionsError;
|
|
5816
|
+
const balances = useMemo12(() => {
|
|
5817
|
+
if (!walletBalances || !exchangeRates) return void 0;
|
|
5818
|
+
return stakingConfigs.map((config, i) => {
|
|
5819
|
+
const inputToken = config.inputTokens[0];
|
|
5820
|
+
const stakedBalance = walletBalances.find((b) => b.address === config.receiptToken.address)?.balance.raw ?? "0";
|
|
5821
|
+
const exchangeRate = exchangeRates[i] ?? 0;
|
|
5822
|
+
const inputTokenPrice = getTokenPrice(inputToken);
|
|
5823
|
+
const total = new bignumber_js_default(stakedBalance).multipliedBy(exchangeRate);
|
|
5824
|
+
const stakedAmount = total.dividedBy(10 ** inputToken.decimals);
|
|
5825
|
+
const stakedAmountUsd = inputTokenPrice === void 0 ? void 0 : stakedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
5826
|
+
return {
|
|
5827
|
+
token: inputToken,
|
|
5828
|
+
apr,
|
|
5829
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
5830
|
+
stakedAmountUsd,
|
|
5831
|
+
earnedAmount: 0,
|
|
5832
|
+
earnedAmountUsd: earningsSettled ? void 0 : 0,
|
|
5833
|
+
isLoadingEarnings: !earningsSettled
|
|
5834
|
+
};
|
|
5835
|
+
});
|
|
5836
|
+
}, [
|
|
5837
|
+
walletBalances,
|
|
5838
|
+
exchangeRates,
|
|
5839
|
+
stakingConfigs,
|
|
5840
|
+
apr,
|
|
5841
|
+
getTokenPrice,
|
|
5842
|
+
earningsSettled
|
|
5843
|
+
]);
|
|
6003
5844
|
const data = useMemo12(() => {
|
|
6004
5845
|
if (!positionsRaw || !walletBalances) return void 0;
|
|
6005
5846
|
return stakingConfigs.map((config, i) => {
|
|
6006
5847
|
const inputToken = config.inputTokens[0];
|
|
6007
5848
|
const stakingToken = config.receiptToken;
|
|
6008
5849
|
const { earnings, exchangeRate: exchangeRateRaw } = positionsRaw[i];
|
|
6009
|
-
const inputTokenPrice = getTokenPrice(inputToken)
|
|
5850
|
+
const inputTokenPrice = getTokenPrice(inputToken);
|
|
6010
5851
|
const stakedBalance = walletBalances.find((b) => b.address === stakingToken.address)?.balance.raw ?? "0";
|
|
6011
5852
|
const exchangeRate = exchangeRateRaw ?? 0;
|
|
6012
5853
|
const unrealisedGains = new bignumber_js_default(earnings.earningsTotal).minus(
|
|
@@ -6016,15 +5857,15 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6016
5857
|
const deposited = total.minus(unrealisedGains);
|
|
6017
5858
|
const stakedAmount = deposited.dividedBy(10 ** inputToken.decimals);
|
|
6018
5859
|
const earnedAmount = unrealisedGains.dividedBy(10 ** inputToken.decimals);
|
|
6019
|
-
const stakedAmountUsd = stakedAmount.multipliedBy(inputTokenPrice);
|
|
6020
|
-
const earnedAmountUsd = earnedAmount.multipliedBy(inputTokenPrice);
|
|
5860
|
+
const stakedAmountUsd = inputTokenPrice === void 0 ? void 0 : stakedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
5861
|
+
const earnedAmountUsd = inputTokenPrice === void 0 ? void 0 : earnedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
6021
5862
|
return {
|
|
6022
5863
|
token: inputToken,
|
|
6023
|
-
apr
|
|
5864
|
+
apr,
|
|
6024
5865
|
stakedAmount: stakedAmount.toNumber(),
|
|
6025
5866
|
earnedAmount: earnedAmount.toNumber(),
|
|
6026
|
-
stakedAmountUsd
|
|
6027
|
-
earnedAmountUsd
|
|
5867
|
+
stakedAmountUsd,
|
|
5868
|
+
earnedAmountUsd
|
|
6028
5869
|
};
|
|
6029
5870
|
});
|
|
6030
5871
|
}, [positionsRaw, walletBalances, stakingConfigs, apr, getTokenPrice]);
|
|
@@ -6037,25 +5878,30 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6037
5878
|
isLoading: isLoadingBalances && isLoadingPositions,
|
|
6038
5879
|
isLoadingBalances,
|
|
6039
5880
|
isLoadingPositions,
|
|
6040
|
-
isValidatingPositions
|
|
5881
|
+
isValidatingPositions,
|
|
5882
|
+
/**
|
|
5883
|
+
* Hard error: the RPC fast-path could not produce staked balances (wallet
|
|
5884
|
+
* balances or exchange-rate reads failed). Price and earnings backend
|
|
5885
|
+
* failures are intentionally excluded — those degrade gracefully (USD/APR
|
|
5886
|
+
* render as "—", earnings stop loading) so RPC-derived amounts still show.
|
|
5887
|
+
*/
|
|
5888
|
+
error: walletBalancesError ?? exchangeRatesError,
|
|
5889
|
+
/** Set when the earnings (slow path) request failed. */
|
|
5890
|
+
positionsError,
|
|
5891
|
+
/**
|
|
5892
|
+
* True once the earnings (slow path) request has settled — resolved or
|
|
5893
|
+
* errored. Consumers should stop showing an earnings loading state once
|
|
5894
|
+
* this is true, even if `data` never arrives (backend outage).
|
|
5895
|
+
*/
|
|
5896
|
+
earningsSettled
|
|
6041
5897
|
};
|
|
6042
5898
|
};
|
|
6043
5899
|
|
|
6044
|
-
// src/hooks/pol/useStakedSnapshots.ts
|
|
6045
|
-
import useSWR44 from "swr";
|
|
6046
|
-
|
|
6047
5900
|
// src/actions/pol/getStakingDailyAssets.ts
|
|
6048
5901
|
async function getStakingDailyAssets({
|
|
6049
5902
|
address,
|
|
6050
5903
|
range
|
|
6051
5904
|
}) {
|
|
6052
|
-
const { config } = parseBaseArgs({});
|
|
6053
|
-
if (!config.beep) {
|
|
6054
|
-
return fetchRailwayBackend("/vaults/{vault}/stats-by-day", {
|
|
6055
|
-
path: { vault: address },
|
|
6056
|
-
query: { days: `${range}` }
|
|
6057
|
-
});
|
|
6058
|
-
}
|
|
6059
5905
|
return fetchBeep("/v0/stake/{vault}/stats-by-day", {
|
|
6060
5906
|
path: { vault: address },
|
|
6061
5907
|
query: { days: `${range}` }
|
|
@@ -6068,7 +5914,7 @@ function useStakedSnapshots({
|
|
|
6068
5914
|
addresses
|
|
6069
5915
|
}) {
|
|
6070
5916
|
const QUERY_KEY = range ? ["useStakedSnapshots", range, addresses] : null;
|
|
6071
|
-
|
|
5917
|
+
return useSWR(QUERY_KEY, async ([, range2, addresses2]) => {
|
|
6072
5918
|
const [...sortedStakingDailyAssetsArray] = await Promise.all([
|
|
6073
5919
|
...addresses2.map(async (address) => {
|
|
6074
5920
|
const unstakingDailyAssets = await getStakingDailyAssets({
|
|
@@ -6088,20 +5934,15 @@ function useStakedSnapshots({
|
|
|
6088
5934
|
{}
|
|
6089
5935
|
);
|
|
6090
5936
|
});
|
|
6091
|
-
return {
|
|
6092
|
-
...swrResponse,
|
|
6093
|
-
refresh: () => swrResponse.mutate()
|
|
6094
|
-
};
|
|
6095
5937
|
}
|
|
6096
5938
|
|
|
6097
5939
|
// src/hooks/pol/useStakingVaultsMetadata.ts
|
|
6098
|
-
import
|
|
6099
|
-
import { usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
5940
|
+
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
6100
5941
|
var useStakingVaultsMetadata = (vaults = []) => {
|
|
6101
|
-
const publicClient =
|
|
5942
|
+
const publicClient = usePublicClient37();
|
|
6102
5943
|
const blockTime = useBlockTime();
|
|
6103
5944
|
const QUERY_KEY = vaults.length > 0 && publicClient && blockTime ? ["useStakingVaultMetadata", vaults, publicClient, blockTime] : null;
|
|
6104
|
-
return
|
|
5945
|
+
return useSWR(
|
|
6105
5946
|
QUERY_KEY,
|
|
6106
5947
|
async ([, vaults2, publicClient2, blockTime2]) => {
|
|
6107
5948
|
assertPublicClient(publicClient2);
|
|
@@ -6121,32 +5962,26 @@ var useStakingVaultsMetadata = (vaults = []) => {
|
|
|
6121
5962
|
};
|
|
6122
5963
|
|
|
6123
5964
|
// src/hooks/pol/useTotalStakedAmount.ts
|
|
6124
|
-
import
|
|
6125
|
-
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
5965
|
+
import { usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
6126
5966
|
function useTotalStakedAmount({
|
|
6127
5967
|
vaultAddresses
|
|
6128
5968
|
}) {
|
|
6129
|
-
const publicClient =
|
|
6130
|
-
|
|
5969
|
+
const publicClient = usePublicClient38();
|
|
5970
|
+
return useSWR(
|
|
6131
5971
|
vaultAddresses && publicClient ? ["useTotalStakedAmount", vaultAddresses] : null,
|
|
6132
5972
|
([, vaultAddresses2]) => {
|
|
6133
5973
|
return getTotalStakedAmount({ vaultAddresses: vaultAddresses2, publicClient });
|
|
6134
5974
|
}
|
|
6135
5975
|
);
|
|
6136
|
-
return {
|
|
6137
|
-
...swrResponse,
|
|
6138
|
-
refresh: () => swrResponse.mutate()
|
|
6139
|
-
};
|
|
6140
5976
|
}
|
|
6141
5977
|
|
|
6142
5978
|
// src/hooks/pol/useUserVaultInfo.ts
|
|
6143
|
-
import
|
|
6144
|
-
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
5979
|
+
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
6145
5980
|
var useUserVaultInfo = (args, options) => {
|
|
6146
5981
|
const { address: account } = useBeraWallet22();
|
|
6147
|
-
const publicClient =
|
|
5982
|
+
const publicClient = usePublicClient39();
|
|
6148
5983
|
const QUERY_KEY = account && publicClient && args.vaultAddress ? ["useUserVaultInfo", account, args.vaultAddress] : null;
|
|
6149
|
-
|
|
5984
|
+
return useSWR(
|
|
6150
5985
|
QUERY_KEY,
|
|
6151
5986
|
async ([, account2, vaultAddress]) => {
|
|
6152
5987
|
assertPublicClient(publicClient);
|
|
@@ -6158,23 +5993,18 @@ var useUserVaultInfo = (args, options) => {
|
|
|
6158
5993
|
},
|
|
6159
5994
|
{
|
|
6160
5995
|
...options,
|
|
6161
|
-
refreshInterval: options?.
|
|
5996
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */
|
|
6162
5997
|
}
|
|
6163
5998
|
);
|
|
6164
|
-
return {
|
|
6165
|
-
...swrResponse,
|
|
6166
|
-
refresh: () => swrResponse.mutate()
|
|
6167
|
-
};
|
|
6168
5999
|
};
|
|
6169
6000
|
|
|
6170
6001
|
// src/hooks/pol/useUserVaults.ts
|
|
6171
|
-
import
|
|
6172
|
-
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
6002
|
+
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
6173
6003
|
var useUserVaults = (options) => {
|
|
6174
6004
|
const { address: account } = useBeraWallet23();
|
|
6175
|
-
const publicClient =
|
|
6005
|
+
const publicClient = usePublicClient40();
|
|
6176
6006
|
const QUERY_KEY = account && publicClient ? ["useUserVaults", account] : null;
|
|
6177
|
-
|
|
6007
|
+
return useSWR(
|
|
6178
6008
|
QUERY_KEY,
|
|
6179
6009
|
async ([, account2]) => {
|
|
6180
6010
|
assertPublicClient(publicClient);
|
|
@@ -6185,23 +6015,18 @@ var useUserVaults = (options) => {
|
|
|
6185
6015
|
},
|
|
6186
6016
|
{
|
|
6187
6017
|
...options,
|
|
6188
|
-
refreshInterval: options?.
|
|
6018
|
+
refreshInterval: options?.refreshInterval ?? 1e5 /* NORMAL */,
|
|
6189
6019
|
keepPreviousData: true
|
|
6190
6020
|
}
|
|
6191
6021
|
);
|
|
6192
|
-
return {
|
|
6193
|
-
...swrResponse,
|
|
6194
|
-
refresh: () => swrResponse?.mutate?.()
|
|
6195
|
-
};
|
|
6196
6022
|
};
|
|
6197
6023
|
|
|
6198
6024
|
// src/hooks/pol/useVaultAddress.ts
|
|
6199
|
-
import
|
|
6200
|
-
import { usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
6025
|
+
import { usePublicClient as usePublicClient41 } from "@berachain/wagmi/hooks";
|
|
6201
6026
|
var useVaultAddress = (vaultAddress) => {
|
|
6202
|
-
const publicClient =
|
|
6027
|
+
const publicClient = usePublicClient41();
|
|
6203
6028
|
const QUERY_KEY = vaultAddress && publicClient ? ["useVaultAddress", vaultAddress] : null;
|
|
6204
|
-
return
|
|
6029
|
+
return useSWR(QUERY_KEY, async ([, vaultAddress2]) => {
|
|
6205
6030
|
assertPublicClient(publicClient);
|
|
6206
6031
|
const [stakeToken] = await Promise.all([
|
|
6207
6032
|
getRewardVaultStakingToken({
|
|
@@ -6214,28 +6039,22 @@ var useVaultAddress = (vaultAddress) => {
|
|
|
6214
6039
|
};
|
|
6215
6040
|
|
|
6216
6041
|
// src/hooks/pol/useVaultHistory.ts
|
|
6217
|
-
import useSWR50 from "swr";
|
|
6218
6042
|
var useVaultHistory = ({
|
|
6219
6043
|
vault,
|
|
6220
6044
|
range,
|
|
6221
6045
|
resolution
|
|
6222
6046
|
}) => {
|
|
6223
6047
|
const QUERY_KEY = vault ? ["useVaultHistory", vault, range, resolution] : null;
|
|
6224
|
-
|
|
6048
|
+
return useSWR(
|
|
6225
6049
|
QUERY_KEY,
|
|
6226
6050
|
([, vault2, range2, resolution2]) => getVaultHistory({ vault: vault2, range: range2, resolution: resolution2 })
|
|
6227
6051
|
);
|
|
6228
|
-
return {
|
|
6229
|
-
...swrResponse,
|
|
6230
|
-
refresh: () => swrResponse.mutate()
|
|
6231
|
-
};
|
|
6232
6052
|
};
|
|
6233
6053
|
|
|
6234
6054
|
// src/hooks/pol/useVaultValidators.ts
|
|
6235
|
-
import useSWR51 from "swr";
|
|
6236
6055
|
var useVaultValidators = (id, options) => {
|
|
6237
6056
|
const QUERY_KEY = id ? ["useVaultValidators", id] : null;
|
|
6238
|
-
|
|
6057
|
+
return useSWR(
|
|
6239
6058
|
QUERY_KEY,
|
|
6240
6059
|
async ([, address]) => {
|
|
6241
6060
|
return await getVaultValidators({
|
|
@@ -6243,13 +6062,9 @@ var useVaultValidators = (id, options) => {
|
|
|
6243
6062
|
});
|
|
6244
6063
|
},
|
|
6245
6064
|
{
|
|
6246
|
-
...options
|
|
6065
|
+
...options
|
|
6247
6066
|
}
|
|
6248
6067
|
);
|
|
6249
|
-
return {
|
|
6250
|
-
...swrResponse,
|
|
6251
|
-
refresh: () => swrResponse.mutate()
|
|
6252
|
-
};
|
|
6253
6068
|
};
|
|
6254
6069
|
|
|
6255
6070
|
// src/hooks/tokens/useBeraCurrentPrice.ts
|
|
@@ -6275,13 +6090,12 @@ function useBeraCurrentPrice(opts) {
|
|
|
6275
6090
|
}
|
|
6276
6091
|
|
|
6277
6092
|
// src/hooks/tokens/useStakingTokenInformation.ts
|
|
6278
|
-
import useSWRImmutable11 from "swr/immutable";
|
|
6279
6093
|
import { isAddress as isAddress12, zeroAddress as zeroAddress23 } from "viem";
|
|
6280
|
-
import { usePublicClient as
|
|
6094
|
+
import { usePublicClient as usePublicClient42 } from "@berachain/wagmi/hooks";
|
|
6281
6095
|
var useStakingTokenInformation = (args, options) => {
|
|
6282
|
-
const publicClient =
|
|
6096
|
+
const publicClient = usePublicClient42();
|
|
6283
6097
|
const QUERY_KEY = args?.address && publicClient && isAddress12(args.address) ? ["useStakingTokenInformation", args.address] : null;
|
|
6284
|
-
|
|
6098
|
+
return useSWRImmutable(
|
|
6285
6099
|
QUERY_KEY,
|
|
6286
6100
|
async ([_, address]) => {
|
|
6287
6101
|
if (isToken(address, "BERA")) {
|
|
@@ -6297,33 +6111,29 @@ var useStakingTokenInformation = (args, options) => {
|
|
|
6297
6111
|
publicClient
|
|
6298
6112
|
});
|
|
6299
6113
|
},
|
|
6300
|
-
{ ...options
|
|
6114
|
+
{ ...options }
|
|
6301
6115
|
);
|
|
6302
|
-
return {
|
|
6303
|
-
...swrResponse,
|
|
6304
|
-
refresh: () => swrResponse?.mutate?.()
|
|
6305
|
-
};
|
|
6306
6116
|
};
|
|
6307
6117
|
|
|
6308
6118
|
// src/hooks/tokens/useTokenPrice.ts
|
|
6309
6119
|
function useTokenPrice({ token }, options) {
|
|
6310
|
-
const { isLoading, priceMap } = useTokenPrices(
|
|
6120
|
+
const { isLoading, error, priceMap } = useTokenPrices(
|
|
6311
6121
|
{ tokens: token ? [token] : void 0 },
|
|
6312
6122
|
options
|
|
6313
6123
|
);
|
|
6314
6124
|
return {
|
|
6315
6125
|
data: token ? priceMap[token.chainId]?.[token.address.toLowerCase()] : void 0,
|
|
6316
|
-
isLoading
|
|
6126
|
+
isLoading,
|
|
6127
|
+
error
|
|
6317
6128
|
};
|
|
6318
6129
|
}
|
|
6319
6130
|
|
|
6320
6131
|
// src/hooks/tokens/useTotalSupply.ts
|
|
6321
|
-
import useSWR52 from "swr";
|
|
6322
6132
|
import { erc20Abi as erc20Abi5 } from "viem";
|
|
6323
|
-
import { usePublicClient as
|
|
6133
|
+
import { usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
6324
6134
|
function useTotalSupply({ address }) {
|
|
6325
|
-
const publicClient =
|
|
6326
|
-
return
|
|
6135
|
+
const publicClient = usePublicClient43();
|
|
6136
|
+
return useSWR(
|
|
6327
6137
|
address && publicClient ? ["useTotalSupply", address] : null,
|
|
6328
6138
|
([, address2]) => {
|
|
6329
6139
|
assertPublicClient(publicClient);
|
|
@@ -6338,15 +6148,14 @@ function useTotalSupply({ address }) {
|
|
|
6338
6148
|
}
|
|
6339
6149
|
|
|
6340
6150
|
// src/hooks/useBlockToTimestamp.ts
|
|
6341
|
-
import
|
|
6342
|
-
import { useBlockNumber, usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
6151
|
+
import { useBlockNumber, usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
6343
6152
|
function useBlockToTimestamp(inputBlock) {
|
|
6344
|
-
const publicClient =
|
|
6153
|
+
const publicClient = usePublicClient44();
|
|
6345
6154
|
const { config } = parseBaseArgs({ chainId: publicClient?.chain.id });
|
|
6346
6155
|
const { data: currentBlock, isLoading } = useBlockNumber({
|
|
6347
6156
|
cacheTime: seconds(config.averageBlockTime)
|
|
6348
6157
|
});
|
|
6349
|
-
const { data: block } =
|
|
6158
|
+
const { data: block } = useSWRImmutable(
|
|
6350
6159
|
currentBlock && publicClient && Number(inputBlock) > 0 ? ["useBlockToTimestamp", inputBlock, currentBlock] : null,
|
|
6351
6160
|
async ([, inputBlock2, currentBlock2]) => {
|
|
6352
6161
|
assertPublicClient(publicClient);
|
|
@@ -6497,7 +6306,6 @@ function useBeraContractWrite({
|
|
|
6497
6306
|
var useBeraContractWrite_default = useBeraContractWrite;
|
|
6498
6307
|
|
|
6499
6308
|
// src/hooks/useGetVerifiedAbi.ts
|
|
6500
|
-
import useSWRImmutable13 from "swr/immutable";
|
|
6501
6309
|
import { isAddress as isAddress13, zeroAddress as zeroAddress24 } from "viem";
|
|
6502
6310
|
import { chainId } from "@berachain/config/internal";
|
|
6503
6311
|
async function fetchVerifiedAbi(address) {
|
|
@@ -6512,7 +6320,7 @@ async function fetchVerifiedAbi(address) {
|
|
|
6512
6320
|
return data.result;
|
|
6513
6321
|
}
|
|
6514
6322
|
var useGetVerifiedAbi = (address) => {
|
|
6515
|
-
return
|
|
6323
|
+
return useSWRImmutable(
|
|
6516
6324
|
address && isAddress13(address) && // Address zero can't be a contract for sure
|
|
6517
6325
|
address !== zeroAddress24 ? ["useGetVerifiedAbi", address] : null,
|
|
6518
6326
|
() => address ? fetchVerifiedAbi(address) : Promise.resolve(""),
|
|
@@ -6568,7 +6376,6 @@ function usePrevious(value) {
|
|
|
6568
6376
|
}
|
|
6569
6377
|
|
|
6570
6378
|
// src/hooks/validators/useAllValidators.ts
|
|
6571
|
-
import useSWR53 from "swr";
|
|
6572
6379
|
var useAllValidatorsQueryKey = ({
|
|
6573
6380
|
variables
|
|
6574
6381
|
} = {}) => {
|
|
@@ -6576,7 +6383,7 @@ var useAllValidatorsQueryKey = ({
|
|
|
6576
6383
|
};
|
|
6577
6384
|
var useAllValidators = (variables, options) => {
|
|
6578
6385
|
const { config } = parseBaseArgs(variables);
|
|
6579
|
-
|
|
6386
|
+
return useSWR(
|
|
6580
6387
|
useAllValidatorsQueryKey({ variables }),
|
|
6581
6388
|
async ([, variables2]) => {
|
|
6582
6389
|
const result = await getAllValidators({
|
|
@@ -6589,21 +6396,16 @@ var useAllValidators = (variables, options) => {
|
|
|
6589
6396
|
},
|
|
6590
6397
|
{
|
|
6591
6398
|
refreshInterval: 18e4 /* SLOW */,
|
|
6592
|
-
...options
|
|
6399
|
+
...options
|
|
6593
6400
|
}
|
|
6594
6401
|
);
|
|
6595
|
-
return {
|
|
6596
|
-
...swrResponse,
|
|
6597
|
-
refresh: () => swrResponse.mutate()
|
|
6598
|
-
};
|
|
6599
6402
|
};
|
|
6600
6403
|
|
|
6601
6404
|
// src/hooks/validators/useApiEnrichedAllocation.ts
|
|
6602
|
-
import useSWR54 from "swr";
|
|
6603
6405
|
function useApiEnrichedAllocation({
|
|
6604
6406
|
allocation
|
|
6605
6407
|
}) {
|
|
6606
|
-
return
|
|
6408
|
+
return useSWR(
|
|
6607
6409
|
allocation ? ["useApiEnrichedAllocation", allocation] : null,
|
|
6608
6410
|
([, allocation2]) => {
|
|
6609
6411
|
return getApiEnrichedAllocation({ allocation: allocation2 });
|
|
@@ -6612,31 +6414,22 @@ function useApiEnrichedAllocation({
|
|
|
6612
6414
|
}
|
|
6613
6415
|
|
|
6614
6416
|
// src/hooks/validators/useApiValidator.ts
|
|
6615
|
-
import useSWR55 from "swr";
|
|
6616
6417
|
import { isHex } from "viem";
|
|
6617
6418
|
var useApiValidatorQueryKey = (id) => id ? ["useApiValidator", id] : null;
|
|
6618
6419
|
var useApiValidator = (id, options) => {
|
|
6619
6420
|
const QUERY_KEY = useApiValidatorQueryKey(id);
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
isEnabled && id ? QUERY_KEY : null,
|
|
6421
|
+
return useSWR(
|
|
6422
|
+
id ? QUERY_KEY : null,
|
|
6623
6423
|
async ([, id2]) => {
|
|
6624
6424
|
if (!id2 || !isHex(id2)) throw new Error(`Invalid validator ID: ${id2}`);
|
|
6625
6425
|
return getApiValidator({ id: id2 });
|
|
6626
6426
|
},
|
|
6627
|
-
|
|
6628
|
-
...options?.opts
|
|
6629
|
-
}
|
|
6427
|
+
options
|
|
6630
6428
|
);
|
|
6631
|
-
return {
|
|
6632
|
-
...swrResponse,
|
|
6633
|
-
refresh: () => swrResponse.mutate()
|
|
6634
|
-
};
|
|
6635
6429
|
};
|
|
6636
6430
|
|
|
6637
6431
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6638
|
-
import
|
|
6639
|
-
import { usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
6432
|
+
import { usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
6640
6433
|
|
|
6641
6434
|
// src/actions/validators/getBaselineRewardAllocation.ts
|
|
6642
6435
|
import { rewardAllocatorFactoryAbi as rewardAllocationFactoryAbi } from "@berachain/abis/pol/rewards/rewardAllocatorFactory";
|
|
@@ -6658,8 +6451,8 @@ async function getBaselineRewardAllocation({
|
|
|
6658
6451
|
|
|
6659
6452
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6660
6453
|
function useBaselineRewardAllocation() {
|
|
6661
|
-
const publicClient =
|
|
6662
|
-
return
|
|
6454
|
+
const publicClient = usePublicClient45();
|
|
6455
|
+
return useSWR(publicClient ? ["baselineRewardAllocation"] : null, () => {
|
|
6663
6456
|
assertPublicClient(publicClient);
|
|
6664
6457
|
return getBaselineRewardAllocation({
|
|
6665
6458
|
publicClient
|
|
@@ -6668,13 +6461,12 @@ function useBaselineRewardAllocation() {
|
|
|
6668
6461
|
}
|
|
6669
6462
|
|
|
6670
6463
|
// src/hooks/validators/useDailyValidatorBlockStats.ts
|
|
6671
|
-
import useSWR57 from "swr";
|
|
6672
6464
|
var useDailyValidatorBlockStats = ({
|
|
6673
6465
|
pubKey,
|
|
6674
6466
|
first = 1
|
|
6675
6467
|
}) => {
|
|
6676
6468
|
const QUERY_KEY = pubKey ? ["useDailyValidatorBlockStats", pubKey, first] : null;
|
|
6677
|
-
|
|
6469
|
+
return useSWR(
|
|
6678
6470
|
QUERY_KEY,
|
|
6679
6471
|
async ([, pubKey2, first2]) => {
|
|
6680
6472
|
return await getDailyValidatorBlockStats({
|
|
@@ -6686,16 +6478,14 @@ var useDailyValidatorBlockStats = ({
|
|
|
6686
6478
|
refreshInterval: 18e4 /* SLOW */
|
|
6687
6479
|
}
|
|
6688
6480
|
);
|
|
6689
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
6690
6481
|
};
|
|
6691
6482
|
|
|
6692
6483
|
// src/hooks/validators/useDefaultRewardAllocation.ts
|
|
6693
|
-
import
|
|
6694
|
-
import { usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
6484
|
+
import { usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
6695
6485
|
function useDefaultRewardAllocation(options) {
|
|
6696
|
-
const publicClient =
|
|
6486
|
+
const publicClient = usePublicClient46();
|
|
6697
6487
|
const QUERY_KEY = publicClient ? ["useDefaultRewardAllocation"] : null;
|
|
6698
|
-
|
|
6488
|
+
return useSWR(
|
|
6699
6489
|
QUERY_KEY,
|
|
6700
6490
|
async () => {
|
|
6701
6491
|
assertPublicClient(publicClient);
|
|
@@ -6704,19 +6494,14 @@ function useDefaultRewardAllocation(options) {
|
|
|
6704
6494
|
});
|
|
6705
6495
|
},
|
|
6706
6496
|
{
|
|
6707
|
-
...options
|
|
6497
|
+
...options
|
|
6708
6498
|
}
|
|
6709
6499
|
);
|
|
6710
|
-
return {
|
|
6711
|
-
...swrResponse,
|
|
6712
|
-
refresh: () => swrResponse.mutate()
|
|
6713
|
-
};
|
|
6714
6500
|
}
|
|
6715
6501
|
|
|
6716
6502
|
// src/hooks/validators/useManagedValidatorRole.ts
|
|
6717
6503
|
import { useMemo as useMemo13 } from "react";
|
|
6718
|
-
import
|
|
6719
|
-
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
6504
|
+
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient47 } from "@berachain/wagmi/hooks";
|
|
6720
6505
|
|
|
6721
6506
|
// src/actions/validators/getValidatorRewardAllocatorAddress.ts
|
|
6722
6507
|
import { zeroAddress as zeroAddress25 } from "viem";
|
|
@@ -6763,7 +6548,7 @@ function useManagedValidatorRole({
|
|
|
6763
6548
|
pubKey,
|
|
6764
6549
|
account: accountAddress
|
|
6765
6550
|
}, options) {
|
|
6766
|
-
const publicClient =
|
|
6551
|
+
const publicClient = usePublicClient47();
|
|
6767
6552
|
const mockValidatorOperator = useBeraFlag("mockValidatorOperator");
|
|
6768
6553
|
const mockValidatorRewardAllocator = useBeraFlag(
|
|
6769
6554
|
"mockValidatorRewardAllocator"
|
|
@@ -6771,7 +6556,7 @@ function useManagedValidatorRole({
|
|
|
6771
6556
|
const QUERY_KEY = publicClient && pubKey ? ["useManagedValidatorRole", pubKey] : null;
|
|
6772
6557
|
const { address: connectedAccount } = useBeraWallet24();
|
|
6773
6558
|
const account = accountAddress ?? connectedAccount;
|
|
6774
|
-
const swrResponse =
|
|
6559
|
+
const swrResponse = useSWR(
|
|
6775
6560
|
QUERY_KEY,
|
|
6776
6561
|
async ([, pubKey2]) => {
|
|
6777
6562
|
assertPublicClient(publicClient);
|
|
@@ -6791,7 +6576,7 @@ function useManagedValidatorRole({
|
|
|
6791
6576
|
};
|
|
6792
6577
|
},
|
|
6793
6578
|
{
|
|
6794
|
-
...options
|
|
6579
|
+
...options
|
|
6795
6580
|
}
|
|
6796
6581
|
);
|
|
6797
6582
|
const hasOperatorRole = useMemo13(() => {
|
|
@@ -6806,24 +6591,21 @@ function useManagedValidatorRole({
|
|
|
6806
6591
|
...swrResponse.data,
|
|
6807
6592
|
hasOperatorRole,
|
|
6808
6593
|
hasRewardAllocatorRole
|
|
6809
|
-
} : void 0
|
|
6810
|
-
refresh: () => swrResponse.mutate()
|
|
6594
|
+
} : void 0
|
|
6811
6595
|
};
|
|
6812
6596
|
}
|
|
6813
6597
|
|
|
6814
6598
|
// src/hooks/validators/useOnChainValidator.ts
|
|
6815
|
-
import useSWR60 from "swr";
|
|
6816
6599
|
import { keccak256 as keccak2562 } from "viem";
|
|
6817
6600
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
6818
6601
|
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
6819
6602
|
import { beraChefAbi as beraChefAbi3 } from "@berachain/abis/pol/rewards/beraChef";
|
|
6820
|
-
import { usePublicClient as
|
|
6603
|
+
import { usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
6821
6604
|
var useOnChainValidator = ({ pubkey }, options) => {
|
|
6822
|
-
const publicClient =
|
|
6605
|
+
const publicClient = usePublicClient48();
|
|
6823
6606
|
const QUERY_KEY = pubkey ? ["useOnChainValidator", pubkey] : null;
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
isEnabled && publicClient ? QUERY_KEY : null,
|
|
6607
|
+
return useSWR(
|
|
6608
|
+
publicClient ? QUERY_KEY : null,
|
|
6827
6609
|
async ([, pubkey2]) => {
|
|
6828
6610
|
assertPublicClient(publicClient);
|
|
6829
6611
|
const { config } = parseBaseArgs({
|
|
@@ -6855,27 +6637,20 @@ var useOnChainValidator = ({ pubkey }, options) => {
|
|
|
6855
6637
|
operator,
|
|
6856
6638
|
votingPower: Number(boostees)
|
|
6857
6639
|
};
|
|
6858
|
-
}
|
|
6640
|
+
},
|
|
6641
|
+
options
|
|
6859
6642
|
);
|
|
6860
|
-
return {
|
|
6861
|
-
...swrResponse,
|
|
6862
|
-
refresh: () => {
|
|
6863
|
-
swrResponse.mutate();
|
|
6864
|
-
}
|
|
6865
|
-
};
|
|
6866
6643
|
};
|
|
6867
6644
|
|
|
6868
6645
|
// src/hooks/validators/useStakingPoolBatch.ts
|
|
6869
|
-
import
|
|
6870
|
-
import { usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
6646
|
+
import { usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
6871
6647
|
var useStakingPoolBatch = ({
|
|
6872
6648
|
valPubKey,
|
|
6873
6649
|
options
|
|
6874
6650
|
}) => {
|
|
6875
|
-
const publicClient =
|
|
6876
|
-
const
|
|
6877
|
-
|
|
6878
|
-
const swrResponse = useSWR61(
|
|
6651
|
+
const publicClient = usePublicClient49();
|
|
6652
|
+
const QUERY_KEY = publicClient && valPubKey ? ["useStakingPoolBatch", valPubKey] : null;
|
|
6653
|
+
return useSWR(
|
|
6879
6654
|
QUERY_KEY,
|
|
6880
6655
|
async ([, valPubKey2]) => {
|
|
6881
6656
|
assertPublicClient(publicClient);
|
|
@@ -6886,23 +6661,18 @@ var useStakingPoolBatch = ({
|
|
|
6886
6661
|
},
|
|
6887
6662
|
{
|
|
6888
6663
|
refreshInterval: 1e4 /* FAST */,
|
|
6889
|
-
...options
|
|
6664
|
+
...options
|
|
6890
6665
|
}
|
|
6891
6666
|
);
|
|
6892
|
-
return {
|
|
6893
|
-
...swrResponse,
|
|
6894
|
-
refresh: () => swrResponse.mutate()
|
|
6895
|
-
};
|
|
6896
6667
|
};
|
|
6897
6668
|
|
|
6898
6669
|
// src/hooks/validators/useUserActiveValidators.ts
|
|
6899
|
-
import
|
|
6900
|
-
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
6670
|
+
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
6901
6671
|
var useUserActiveValidators = (options) => {
|
|
6902
6672
|
const { address: account } = useBeraWallet25();
|
|
6903
|
-
const publicClient =
|
|
6673
|
+
const publicClient = usePublicClient50();
|
|
6904
6674
|
const QUERY_KEY = publicClient && account ? ["useUserActiveValidators", account] : null;
|
|
6905
|
-
|
|
6675
|
+
return useSWR(
|
|
6906
6676
|
QUERY_KEY,
|
|
6907
6677
|
async ([, account2]) => {
|
|
6908
6678
|
return await getUserActiveValidators({
|
|
@@ -6912,28 +6682,23 @@ var useUserActiveValidators = (options) => {
|
|
|
6912
6682
|
},
|
|
6913
6683
|
{
|
|
6914
6684
|
...options,
|
|
6915
|
-
refreshInterval: options?.
|
|
6685
|
+
refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */,
|
|
6916
6686
|
keepPreviousData: true
|
|
6917
6687
|
}
|
|
6918
6688
|
);
|
|
6919
|
-
return {
|
|
6920
|
-
...swrResponse,
|
|
6921
|
-
refresh: () => swrResponse?.mutate?.()
|
|
6922
|
-
};
|
|
6923
6689
|
};
|
|
6924
6690
|
|
|
6925
6691
|
// src/hooks/validators/useUserBoostsOnValidator.ts
|
|
6926
|
-
import
|
|
6927
|
-
import { useBeraWallet as useBeraWallet26, usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
6692
|
+
import { useBeraWallet as useBeraWallet26, usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
6928
6693
|
var useUserBoostsOnValidator = ({
|
|
6929
6694
|
pubkey,
|
|
6930
6695
|
...args
|
|
6931
6696
|
}) => {
|
|
6932
6697
|
const { address: connectedAccount } = useBeraWallet26();
|
|
6933
|
-
const publicClient =
|
|
6698
|
+
const publicClient = usePublicClient51();
|
|
6934
6699
|
const account = args.account ?? connectedAccount;
|
|
6935
6700
|
const QUERY_KEY = account && pubkey ? ["useUserBoostsOnValidator", pubkey, account] : null;
|
|
6936
|
-
|
|
6701
|
+
return useSWR(
|
|
6937
6702
|
QUERY_KEY,
|
|
6938
6703
|
async ([, pubkey2, account2]) => {
|
|
6939
6704
|
return await getUserBoostsOnValidator({
|
|
@@ -6946,12 +6711,10 @@ var useUserBoostsOnValidator = ({
|
|
|
6946
6711
|
refreshInterval: 1e5 /* NORMAL */
|
|
6947
6712
|
}
|
|
6948
6713
|
);
|
|
6949
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
6950
6714
|
};
|
|
6951
6715
|
|
|
6952
6716
|
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
6953
6717
|
import { useCallback as useCallback4, useMemo as useMemo14 } from "react";
|
|
6954
|
-
import useSWR64 from "swr";
|
|
6955
6718
|
import { useBeraWallet as useBeraWallet27 } from "@berachain/wagmi/hooks";
|
|
6956
6719
|
|
|
6957
6720
|
// src/utils/formatIncentivesTokenMap.ts
|
|
@@ -6973,7 +6736,7 @@ var formatIncentivesTokenMap = (allRewards) => {
|
|
|
6973
6736
|
var useUserClaimableIncentives = () => {
|
|
6974
6737
|
const { address: account } = useBeraWallet27();
|
|
6975
6738
|
const REWARDS_QUERY_KEY = account ? ["useUserClaimableIncentives", account] : null;
|
|
6976
|
-
const allRewardsResponse =
|
|
6739
|
+
const allRewardsResponse = useSWR(
|
|
6977
6740
|
REWARDS_QUERY_KEY,
|
|
6978
6741
|
async ([, account2]) => {
|
|
6979
6742
|
if (!account2) {
|
|
@@ -7014,7 +6777,7 @@ var useUserClaimableIncentives = () => {
|
|
|
7014
6777
|
return formatIncentivesTokenMap(allRewards);
|
|
7015
6778
|
}, [allRewards, account]);
|
|
7016
6779
|
const QUERY_KEY = account && allRewards ? ["useUserClaimableIncentives", account, allRewards] : null;
|
|
7017
|
-
const swrResponse =
|
|
6780
|
+
const swrResponse = useSWR(
|
|
7018
6781
|
QUERY_KEY,
|
|
7019
6782
|
async ([, account2, allRewards2]) => {
|
|
7020
6783
|
if (!account2) {
|
|
@@ -7061,8 +6824,8 @@ var useUserClaimableIncentives = () => {
|
|
|
7061
6824
|
}
|
|
7062
6825
|
);
|
|
7063
6826
|
const refresh = useCallback4(() => {
|
|
7064
|
-
allRewardsResponse?.
|
|
7065
|
-
swrResponse?.
|
|
6827
|
+
allRewardsResponse?.refresh();
|
|
6828
|
+
swrResponse?.refresh();
|
|
7066
6829
|
}, [allRewardsResponse, swrResponse]);
|
|
7067
6830
|
return {
|
|
7068
6831
|
...swrResponse,
|
|
@@ -7073,13 +6836,12 @@ var useUserClaimableIncentives = () => {
|
|
|
7073
6836
|
};
|
|
7074
6837
|
|
|
7075
6838
|
// src/hooks/validators/useUserStakingPositions.ts
|
|
7076
|
-
import useSWRImmutable14 from "swr/immutable";
|
|
7077
6839
|
var useUserStakingPositions = ({
|
|
7078
6840
|
account,
|
|
7079
6841
|
validatorAddress
|
|
7080
6842
|
}) => {
|
|
7081
6843
|
const queryClient = account ? ["useUserStakingPositions", account, validatorAddress] : null;
|
|
7082
|
-
|
|
6844
|
+
return useSWRImmutable(
|
|
7083
6845
|
queryClient,
|
|
7084
6846
|
async ([_, account2, validatorAddress2]) => {
|
|
7085
6847
|
const userStakingPolls = await getUserStakingPositions(account2);
|
|
@@ -7091,12 +6853,6 @@ var useUserStakingPositions = ({
|
|
|
7091
6853
|
return userStakingPolls;
|
|
7092
6854
|
}
|
|
7093
6855
|
);
|
|
7094
|
-
return {
|
|
7095
|
-
...swrResponse,
|
|
7096
|
-
refresh: () => {
|
|
7097
|
-
swrResponse.mutate();
|
|
7098
|
-
}
|
|
7099
|
-
};
|
|
7100
6856
|
};
|
|
7101
6857
|
|
|
7102
6858
|
// src/hooks/validators/useValidator.ts
|
|
@@ -7144,13 +6900,12 @@ function useValidator({ pubkey }, options) {
|
|
|
7144
6900
|
}
|
|
7145
6901
|
|
|
7146
6902
|
// src/hooks/validators/useValidatorAnalytics.ts
|
|
7147
|
-
import useSWR65 from "swr";
|
|
7148
6903
|
function useValidatorAnalytics({
|
|
7149
6904
|
pubkey,
|
|
7150
6905
|
dayRange
|
|
7151
6906
|
}) {
|
|
7152
6907
|
const QUERY_KEY = pubkey && dayRange ? ["useValidatorAnalytics", pubkey, dayRange] : null;
|
|
7153
|
-
|
|
6908
|
+
return useSWR(
|
|
7154
6909
|
QUERY_KEY,
|
|
7155
6910
|
async ([, pubkey2, dayRange2]) => {
|
|
7156
6911
|
return await getValidatorAnalytics({
|
|
@@ -7162,16 +6917,14 @@ function useValidatorAnalytics({
|
|
|
7162
6917
|
refreshInterval: 18e4 /* SLOW */
|
|
7163
6918
|
}
|
|
7164
6919
|
);
|
|
7165
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
7166
6920
|
}
|
|
7167
6921
|
|
|
7168
6922
|
// src/hooks/validators/useValidatorCommission.ts
|
|
7169
|
-
import
|
|
7170
|
-
import { usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
6923
|
+
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
7171
6924
|
var useValidatorCommission = (pubKey, options) => {
|
|
7172
|
-
const publicClient =
|
|
6925
|
+
const publicClient = usePublicClient52();
|
|
7173
6926
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorCommission", pubKey] : null;
|
|
7174
|
-
|
|
6927
|
+
return swr_default(
|
|
7175
6928
|
QUERY_KEY,
|
|
7176
6929
|
async ([, pubKey2]) => {
|
|
7177
6930
|
return await getValidatorCommission({
|
|
@@ -7180,13 +6933,9 @@ var useValidatorCommission = (pubKey, options) => {
|
|
|
7180
6933
|
});
|
|
7181
6934
|
},
|
|
7182
6935
|
{
|
|
7183
|
-
...options
|
|
6936
|
+
...options
|
|
7184
6937
|
}
|
|
7185
6938
|
);
|
|
7186
|
-
return {
|
|
7187
|
-
...swrResponse,
|
|
7188
|
-
refresh: () => swrResponse.mutate()
|
|
7189
|
-
};
|
|
7190
6939
|
};
|
|
7191
6940
|
|
|
7192
6941
|
// src/hooks/validators/useValidatorEstimatedBgtPerYear.ts
|
|
@@ -7203,9 +6952,6 @@ var useValidatorEstimatedBgtPerYear = (validator) => {
|
|
|
7203
6952
|
};
|
|
7204
6953
|
};
|
|
7205
6954
|
|
|
7206
|
-
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
7207
|
-
import useSWR67 from "swr";
|
|
7208
|
-
|
|
7209
6955
|
// src/actions/validators/getValidatorIncentiveDistribution.ts
|
|
7210
6956
|
async function getValidatorIncentiveDistribution({
|
|
7211
6957
|
pubkey,
|
|
@@ -7217,15 +6963,30 @@ async function getValidatorIncentiveDistribution({
|
|
|
7217
6963
|
level: "error"
|
|
7218
6964
|
});
|
|
7219
6965
|
}
|
|
7220
|
-
const
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
6966
|
+
const SECONDS_PER_DAY = 86400;
|
|
6967
|
+
const after = String(
|
|
6968
|
+
Math.floor(
|
|
6969
|
+
calculateTimestampFromDays(dayRange) / 1e6 / SECONDS_PER_DAY
|
|
6970
|
+
) * SECONDS_PER_DAY
|
|
6971
|
+
);
|
|
6972
|
+
const PER_PAGE = 1e3;
|
|
6973
|
+
const rows = [];
|
|
6974
|
+
let page = 1;
|
|
6975
|
+
while (true) {
|
|
6976
|
+
const pageRows = await fetchBeep("/v0/validators/{pubkey}/incentives", {
|
|
6977
|
+
path: { pubkey },
|
|
6978
|
+
query: {
|
|
6979
|
+
interval: "day",
|
|
6980
|
+
after,
|
|
6981
|
+
page: String(page),
|
|
6982
|
+
perPage: String(PER_PAGE)
|
|
6983
|
+
}
|
|
6984
|
+
});
|
|
6985
|
+
rows.push(...pageRows);
|
|
6986
|
+
if (pageRows.length < PER_PAGE) break;
|
|
6987
|
+
page++;
|
|
6988
|
+
}
|
|
6989
|
+
return rows;
|
|
7229
6990
|
}
|
|
7230
6991
|
|
|
7231
6992
|
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
@@ -7234,7 +6995,7 @@ function useValidatorIncentiveDistribution({
|
|
|
7234
6995
|
dayRange
|
|
7235
6996
|
}) {
|
|
7236
6997
|
const QUERY_KEY = pubkey && dayRange ? ["useValidatorIncentiveDistribution", pubkey, dayRange] : null;
|
|
7237
|
-
|
|
6998
|
+
return useSWR(
|
|
7238
6999
|
QUERY_KEY,
|
|
7239
7000
|
async ([, pubkey2, dayRange2]) => {
|
|
7240
7001
|
return await getValidatorIncentiveDistribution({ pubkey: pubkey2, dayRange: dayRange2 });
|
|
@@ -7243,16 +7004,14 @@ function useValidatorIncentiveDistribution({
|
|
|
7243
7004
|
refreshInterval: 18e4 /* SLOW */
|
|
7244
7005
|
}
|
|
7245
7006
|
);
|
|
7246
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
7247
7007
|
}
|
|
7248
7008
|
|
|
7249
7009
|
// src/hooks/validators/useValidatorQueuedCommission.ts
|
|
7250
|
-
import
|
|
7251
|
-
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
7010
|
+
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
7252
7011
|
function useValidatorQueuedCommission(pubKey, options) {
|
|
7253
|
-
const publicClient =
|
|
7012
|
+
const publicClient = usePublicClient53();
|
|
7254
7013
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedCommission", pubKey] : null;
|
|
7255
|
-
|
|
7014
|
+
return useSWR(
|
|
7256
7015
|
QUERY_KEY,
|
|
7257
7016
|
async ([, pubKey2]) => {
|
|
7258
7017
|
assertPublicClient(publicClient);
|
|
@@ -7262,22 +7021,17 @@ function useValidatorQueuedCommission(pubKey, options) {
|
|
|
7262
7021
|
});
|
|
7263
7022
|
},
|
|
7264
7023
|
{
|
|
7265
|
-
...options
|
|
7024
|
+
...options
|
|
7266
7025
|
}
|
|
7267
7026
|
);
|
|
7268
|
-
return {
|
|
7269
|
-
...swrResponse,
|
|
7270
|
-
refresh: () => swrResponse.mutate()
|
|
7271
|
-
};
|
|
7272
7027
|
}
|
|
7273
7028
|
|
|
7274
7029
|
// src/hooks/validators/useValidatorQueuedOperatorAddress.ts
|
|
7275
|
-
import
|
|
7276
|
-
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
7030
|
+
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
7277
7031
|
var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
7278
|
-
const publicClient =
|
|
7032
|
+
const publicClient = usePublicClient54();
|
|
7279
7033
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedOperatorAddress", pubKey] : null;
|
|
7280
|
-
|
|
7034
|
+
return useSWR(
|
|
7281
7035
|
QUERY_KEY,
|
|
7282
7036
|
async ([, pubKey2]) => {
|
|
7283
7037
|
return await getValidatorQueuedOperatorAddress({
|
|
@@ -7286,22 +7040,17 @@ var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
|
7286
7040
|
});
|
|
7287
7041
|
},
|
|
7288
7042
|
{
|
|
7289
|
-
...options
|
|
7043
|
+
...options
|
|
7290
7044
|
}
|
|
7291
7045
|
);
|
|
7292
|
-
return {
|
|
7293
|
-
...swrResponse,
|
|
7294
|
-
refresh: () => swrResponse.mutate()
|
|
7295
|
-
};
|
|
7296
7046
|
};
|
|
7297
7047
|
|
|
7298
7048
|
// src/hooks/validators/useValidatorQueuedRewardAllocation.ts
|
|
7299
|
-
import
|
|
7300
|
-
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
7049
|
+
import { usePublicClient as usePublicClient55 } from "@berachain/wagmi/hooks";
|
|
7301
7050
|
var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
7302
|
-
const publicClient =
|
|
7051
|
+
const publicClient = usePublicClient55();
|
|
7303
7052
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedRewardAllocation", pubKey] : null;
|
|
7304
|
-
|
|
7053
|
+
return useSWR(
|
|
7305
7054
|
QUERY_KEY,
|
|
7306
7055
|
async ([, pubKey2]) => {
|
|
7307
7056
|
return await getValidatorQueuedRewardAllocation({
|
|
@@ -7310,22 +7059,17 @@ var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
|
7310
7059
|
});
|
|
7311
7060
|
},
|
|
7312
7061
|
{
|
|
7313
|
-
...options
|
|
7062
|
+
...options
|
|
7314
7063
|
}
|
|
7315
7064
|
);
|
|
7316
|
-
return {
|
|
7317
|
-
...swrResponse,
|
|
7318
|
-
refresh: () => swrResponse.mutate()
|
|
7319
|
-
};
|
|
7320
7065
|
};
|
|
7321
7066
|
|
|
7322
7067
|
// src/hooks/validators/useValidatorRewardAllocation.ts
|
|
7323
|
-
import
|
|
7324
|
-
import { usePublicClient as usePublicClient55 } from "@berachain/wagmi/hooks";
|
|
7068
|
+
import { usePublicClient as usePublicClient56 } from "@berachain/wagmi/hooks";
|
|
7325
7069
|
function useValidatorRewardAllocation(pubKey, options) {
|
|
7326
|
-
const publicClient =
|
|
7070
|
+
const publicClient = usePublicClient56();
|
|
7327
7071
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorRewardAllocation", pubKey] : null;
|
|
7328
|
-
|
|
7072
|
+
return useSWR(
|
|
7329
7073
|
QUERY_KEY,
|
|
7330
7074
|
async ([, pubKey2]) => {
|
|
7331
7075
|
return getValidatorRewardAllocation({
|
|
@@ -7334,13 +7078,9 @@ function useValidatorRewardAllocation(pubKey, options) {
|
|
|
7334
7078
|
});
|
|
7335
7079
|
},
|
|
7336
7080
|
{
|
|
7337
|
-
...options
|
|
7081
|
+
...options
|
|
7338
7082
|
}
|
|
7339
7083
|
);
|
|
7340
|
-
return {
|
|
7341
|
-
...swrResponse,
|
|
7342
|
-
refresh: () => swrResponse.mutate()
|
|
7343
|
-
};
|
|
7344
7084
|
}
|
|
7345
7085
|
export {
|
|
7346
7086
|
OracleMode,
|
|
@@ -7368,6 +7108,7 @@ export {
|
|
|
7368
7108
|
useBeraCurrentPrice,
|
|
7369
7109
|
useBexStatus,
|
|
7370
7110
|
useBgtAprSimulation,
|
|
7111
|
+
useBgtIncentiveDistributorPaused,
|
|
7371
7112
|
useBgtUnstakedBalance,
|
|
7372
7113
|
useBlockToTimestamp,
|
|
7373
7114
|
useCappedGlobally,
|