@berachain/berajs 0.2.8-beta.8 → 0.2.9
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/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
- package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
- package/dist/RequestError-DBOIV65x.d.ts +144 -0
- package/dist/abi/exports.mjs +3 -4
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +108 -187
- package/dist/actions/exports.mjs +97 -158
- package/dist/actions/governance/exports.d.ts +140 -0
- package/dist/actions/governance/exports.mjs +226 -0
- package/dist/actions/server/exports.d.ts +13 -0
- package/dist/actions/server/exports.mjs +27 -0
- package/dist/{chunk-VA3BQ34H.mjs → chunk-3EARVV7K.mjs} +20 -9
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/{chunk-7TFV6UKF.mjs → chunk-BGMRHTBQ.mjs} +0 -1
- package/dist/{chunk-3M47ZRXT.mjs → chunk-CDFWPU2R.mjs} +73 -17
- package/dist/{chunk-GWSTVITN.mjs → chunk-CDK4YV3D.mjs} +0 -1
- package/dist/{chunk-KL6YZ5VR.mjs → chunk-DKMAIU74.mjs} +0 -1
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/{chunk-VA5L5FDG.mjs → chunk-FFB5LFDW.mjs} +2 -3
- package/dist/{chunk-ZCEFC2TK.mjs → chunk-HQCOU6GY.mjs} +0 -1
- package/dist/{chunk-SGZP4O6R.mjs → chunk-HSSJKHZ4.mjs} +11 -11
- package/dist/{chunk-7QKRRIHI.mjs → chunk-J5I45WGQ.mjs} +77 -152
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/{chunk-JA4DHMTG.mjs → chunk-NBYLMO2L.mjs} +0 -1
- package/dist/{chunk-4GFN4LEP.mjs → chunk-NPBQLVL3.mjs} +4 -21
- package/dist/{chunk-I3FTWD6I.mjs → chunk-O2NQFKJK.mjs} +1 -1
- package/dist/{chunk-2R73G2PO.mjs → chunk-QJIXTYTZ.mjs} +121 -765
- package/dist/{chunk-GLWPRM33.mjs → chunk-SGIJVHZO.mjs} +0 -1
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/{chunk-5NMATIH4.mjs → chunk-WXXOISTU.mjs} +1 -35
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +11 -9
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +3 -16
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +5 -90
- package/dist/errors/exports.mjs +19 -10
- package/dist/exports-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
- package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
- package/dist/hooks/exports.d.ts +80 -236
- package/dist/hooks/exports.mjs +609 -1508
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-CqPA9K6m.d.ts +142 -0
- package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
- package/dist/types/exports.d.ts +9 -9
- package/dist/types/exports.mjs +0 -1
- package/dist/types/governance/exports.d.ts +109 -0
- package/dist/types/governance/exports.mjs +0 -0
- package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
- package/dist/utils/exports.d.ts +24 -7
- package/dist/utils/exports.mjs +49 -11
- package/package.json +60 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/BeraApolloClient.ts +9 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +70 -25
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/base.ts +1 -1
- package/src/actions/dex/aggregators/enso/enso.ts +27 -17
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
- package/src/actions/dex/aggregators/kyberswap.ts +18 -23
- package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
- package/src/actions/exports.ts +5 -10
- package/src/actions/governance/exports.ts +9 -0
- package/src/actions/governance/getAllProposals.ts +10 -65
- package/src/actions/governance/getProposalDetails.ts +6 -33
- package/src/actions/governance/getProposalVotes.ts +8 -15
- package/src/actions/honey/getChartData.ts +27 -21
- package/src/actions/honey/getHoney24hVolume.ts +27 -0
- package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +15 -9
- package/src/actions/pol/getGlobalData.ts +1 -0
- package/src/actions/pol/getHeroEarnVaults.ts +62 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
- package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +11 -8
- package/src/actions/server/exports.ts +1 -0
- package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
- package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
- package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
- package/src/actions/validators/getValidatorAnalytics.ts +20 -21
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
- package/src/data/contracts.ts +5 -0
- package/src/enum/contracts.ts +1 -0
- package/src/enum/exports.ts +0 -1
- package/src/enum/governance/exports.ts +1 -0
- package/src/errors/BeraError.ts +47 -7
- package/src/errors/BeraTracing.unit.test.ts +65 -0
- package/src/errors/RequestError.ts +15 -2
- package/src/errors/exports.ts +5 -0
- package/src/errors/getRevertReason.integration.test.ts +3 -3
- package/src/errors/spanStatus.ts +78 -0
- package/src/errors/spanStatus.unit.test.ts +62 -0
- package/src/hooks/dex/useCreatePool.ts +1 -88
- package/src/hooks/dex/useOnChainPoolData.ts +27 -2
- package/src/hooks/dex/usePriceImpact.ts +12 -5
- package/src/hooks/enso/useBendDemultiply.ts +9 -1
- package/src/hooks/enso/useBendMultiply.ts +9 -1
- package/src/hooks/enso/useBendZapSupply.ts +26 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
- package/src/hooks/exports.ts +3 -16
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/honey/useHoney24hVolume.ts +16 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +2 -0
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +8 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +76 -15
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- package/src/utils/sanitizeRpcUrl.ts +22 -0
- package/src/utils/tracedTransport.ts +35 -0
- package/dist/BeraError-_mQdkanr.d.ts +0 -94
- package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
- package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
- package/dist/RequestError-A8XJ6QR9.d.cts +0 -57
- package/dist/RequestError-Dk97z8rm.d.ts +0 -57
- package/dist/abi/exports.cjs +0 -4453
- package/dist/abi/exports.cjs.map +0 -1
- package/dist/abi/exports.d.cts +0 -6574
- package/dist/abi/exports.mjs.map +0 -1
- package/dist/actions/exports.cjs +0 -914
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1644
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-2R73G2PO.mjs.map +0 -1
- package/dist/chunk-3M47ZRXT.mjs.map +0 -1
- package/dist/chunk-4GFN4LEP.mjs.map +0 -1
- package/dist/chunk-5N7QQS55.cjs +0 -130
- package/dist/chunk-5N7QQS55.cjs.map +0 -1
- package/dist/chunk-5NMATIH4.mjs.map +0 -1
- package/dist/chunk-7QKRRIHI.mjs.map +0 -1
- package/dist/chunk-7TFV6UKF.mjs.map +0 -1
- package/dist/chunk-A4FPM7U3.cjs +0 -63
- package/dist/chunk-A4FPM7U3.cjs.map +0 -1
- package/dist/chunk-BDHINMWQ.cjs +0 -417
- package/dist/chunk-BDHINMWQ.cjs.map +0 -1
- package/dist/chunk-BEHP54S3.cjs +0 -24
- package/dist/chunk-BEHP54S3.cjs.map +0 -1
- package/dist/chunk-EGDXV2PT.cjs +0 -36
- package/dist/chunk-EGDXV2PT.cjs.map +0 -1
- package/dist/chunk-EWBKSMPG.cjs +0 -13
- package/dist/chunk-EWBKSMPG.cjs.map +0 -1
- package/dist/chunk-F6ZW7ZDD.cjs +0 -403
- package/dist/chunk-F6ZW7ZDD.cjs.map +0 -1
- package/dist/chunk-FTXTRUYT.cjs +0 -170
- package/dist/chunk-FTXTRUYT.cjs.map +0 -1
- package/dist/chunk-GLWPRM33.mjs.map +0 -1
- package/dist/chunk-GWSTVITN.mjs.map +0 -1
- package/dist/chunk-H3Z37RYU.cjs +0 -15
- package/dist/chunk-H3Z37RYU.cjs.map +0 -1
- package/dist/chunk-I3FTWD6I.mjs.map +0 -1
- package/dist/chunk-JA4DHMTG.mjs.map +0 -1
- package/dist/chunk-KL6YZ5VR.mjs.map +0 -1
- package/dist/chunk-MXWPP6MS.cjs +0 -572
- package/dist/chunk-MXWPP6MS.cjs.map +0 -1
- package/dist/chunk-SGZP4O6R.mjs.map +0 -1
- package/dist/chunk-TDW5SPXR.cjs +0 -244
- package/dist/chunk-TDW5SPXR.cjs.map +0 -1
- package/dist/chunk-TGK3IXDN.cjs +0 -169
- package/dist/chunk-TGK3IXDN.cjs.map +0 -1
- package/dist/chunk-TJEW6YCJ.cjs +0 -97
- package/dist/chunk-TJEW6YCJ.cjs.map +0 -1
- package/dist/chunk-VA3BQ34H.mjs.map +0 -1
- package/dist/chunk-VA5L5FDG.mjs.map +0 -1
- package/dist/chunk-XSGCRLSD.cjs +0 -1844
- package/dist/chunk-XSGCRLSD.cjs.map +0 -1
- package/dist/chunk-XV3GG3HC.cjs +0 -135
- package/dist/chunk-XV3GG3HC.cjs.map +0 -1
- package/dist/chunk-Y5B224UX.cjs +0 -4698
- package/dist/chunk-Y5B224UX.cjs.map +0 -1
- package/dist/chunk-ZBTRKBSI.mjs +0 -169
- package/dist/chunk-ZBTRKBSI.mjs.map +0 -1
- package/dist/chunk-ZCEFC2TK.mjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -83
- package/dist/contexts/exports.cjs.map +0 -1
- package/dist/contexts/exports.d.cts +0 -66
- package/dist/contexts/exports.mjs.map +0 -1
- package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
- package/dist/dex-C_BB0b0O.d.cts +0 -37
- package/dist/enum/exports.cjs +0 -59
- package/dist/enum/exports.cjs.map +0 -1
- package/dist/enum/exports.d.cts +0 -23
- package/dist/enum/exports.mjs.map +0 -1
- package/dist/errors/exports.cjs +0 -39
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -413
- package/dist/errors/exports.mjs.map +0 -1
- package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
- package/dist/global.d-B7IeayVX.d.cts +0 -474
- package/dist/honey-CYm0RWf4.d.cts +0 -14
- package/dist/hooks/exports.cjs +0 -8333
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1748
- package/dist/hooks/exports.mjs.map +0 -1
- package/dist/polling-BKnyavLI.d.cts +0 -8
- package/dist/txnEnum-7_o92X3N.d.ts +0 -164
- package/dist/types/exports.cjs +0 -1
- package/dist/types/exports.cjs.map +0 -1
- package/dist/types/exports.d.cts +0 -90
- package/dist/types/exports.mjs.map +0 -1
- package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
- package/dist/utils/exports.cjs +0 -787
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -412
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/actions/honey/getHoneyGlobalData.ts +0 -21
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
- package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
package/dist/hooks/exports.mjs
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensoWalletV2FactoryAbi
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NBYLMO2L.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BalancerApi,
|
|
6
6
|
BaseAggregator,
|
|
7
7
|
beraWriteContract,
|
|
8
|
-
checkProposalField,
|
|
9
8
|
formatValidatorRewardAllocation,
|
|
10
9
|
getAllPools,
|
|
11
|
-
getAllProposals,
|
|
12
10
|
getAllValidators,
|
|
13
11
|
getAllowances,
|
|
14
12
|
getApiEnrichedAllocation,
|
|
15
13
|
getApiPool,
|
|
16
14
|
getApiValidator,
|
|
17
|
-
|
|
15
|
+
getAutoclaimedIncentives,
|
|
18
16
|
getBgtAprSimulation,
|
|
19
17
|
getBlockTimestamp,
|
|
20
|
-
getBodyErrors,
|
|
21
18
|
getChartData,
|
|
22
19
|
getCollateralWeights,
|
|
23
20
|
getConvertToAssets,
|
|
@@ -27,16 +24,13 @@ import {
|
|
|
27
24
|
getGlobalCapLimit,
|
|
28
25
|
getGlobalData,
|
|
29
26
|
getGlobalLiquidityAndSwapVolume,
|
|
30
|
-
|
|
27
|
+
getHoney24hVolume,
|
|
31
28
|
getHoneyPreview,
|
|
32
29
|
getHoneyVaultsBalance,
|
|
33
30
|
getMarkets,
|
|
34
31
|
getOnChainPool,
|
|
35
32
|
getPoolEvents,
|
|
36
33
|
getPoolHistoricalData,
|
|
37
|
-
getProposalDetails,
|
|
38
|
-
getProposalFromTx,
|
|
39
|
-
getProposalVotes,
|
|
40
34
|
getPythLatestPrices,
|
|
41
35
|
getPythUpdateFee,
|
|
42
36
|
getRelativeCapLimit,
|
|
@@ -75,8 +69,9 @@ import {
|
|
|
75
69
|
getVaultValidators,
|
|
76
70
|
isBadCollateralAsset,
|
|
77
71
|
isBasketModeEnabled
|
|
78
|
-
} from "../chunk-
|
|
79
|
-
import "../chunk-
|
|
72
|
+
} from "../chunk-QJIXTYTZ.mjs";
|
|
73
|
+
import "../chunk-4Z4AK6SH.mjs";
|
|
74
|
+
import "../chunk-CDK4YV3D.mjs";
|
|
80
75
|
import {
|
|
81
76
|
TokenContext,
|
|
82
77
|
useBeraFlag,
|
|
@@ -84,31 +79,32 @@ import {
|
|
|
84
79
|
useBlockTime,
|
|
85
80
|
useEnsoUserTokensWithBalances,
|
|
86
81
|
useHoneyConfig
|
|
87
|
-
} from "../chunk-
|
|
82
|
+
} from "../chunk-3EARVV7K.mjs";
|
|
88
83
|
import {
|
|
89
84
|
getEnsoClient,
|
|
90
85
|
getWalletBalances
|
|
91
|
-
} from "../chunk-
|
|
92
|
-
import "../chunk-
|
|
93
|
-
import "../chunk-
|
|
94
|
-
import "../chunk-
|
|
95
|
-
import "../chunk-GLWPRM33.mjs";
|
|
86
|
+
} from "../chunk-HSSJKHZ4.mjs";
|
|
87
|
+
import "../chunk-HQCOU6GY.mjs";
|
|
88
|
+
import "../chunk-O2NQFKJK.mjs";
|
|
89
|
+
import "../chunk-SGIJVHZO.mjs";
|
|
96
90
|
import {
|
|
97
91
|
TransactionFailedError
|
|
98
|
-
} from "../chunk-
|
|
92
|
+
} from "../chunk-WXXOISTU.mjs";
|
|
99
93
|
import {
|
|
100
94
|
BeraMonitoring,
|
|
95
|
+
initBeraError
|
|
96
|
+
} from "../chunk-EXIUPSFN.mjs";
|
|
97
|
+
import {
|
|
101
98
|
assertAddress,
|
|
102
99
|
assertAmount,
|
|
103
100
|
assertDefined,
|
|
104
101
|
assertPositive,
|
|
105
|
-
assertPublicClient
|
|
106
|
-
|
|
107
|
-
} from "../chunk-ZBTRKBSI.mjs";
|
|
102
|
+
assertPublicClient
|
|
103
|
+
} from "../chunk-KQUMKB66.mjs";
|
|
108
104
|
import {
|
|
109
105
|
computePriceImpact,
|
|
110
106
|
wrapNativeTokens
|
|
111
|
-
} from "../chunk-
|
|
107
|
+
} from "../chunk-FFB5LFDW.mjs";
|
|
112
108
|
import {
|
|
113
109
|
DEFAULT_METAMASK_GAS_LIMIT,
|
|
114
110
|
beraFetchJson,
|
|
@@ -116,19 +112,24 @@ import {
|
|
|
116
112
|
getPythDefaultUpdateFee,
|
|
117
113
|
msToSeconds,
|
|
118
114
|
seconds
|
|
119
|
-
} from "../chunk-
|
|
120
|
-
import "../chunk-
|
|
115
|
+
} from "../chunk-CDFWPU2R.mjs";
|
|
116
|
+
import "../chunk-BGMRHTBQ.mjs";
|
|
121
117
|
import {
|
|
122
118
|
beraToken,
|
|
123
119
|
getHoneyToken,
|
|
124
|
-
isToken
|
|
120
|
+
isToken
|
|
121
|
+
} from "../chunk-NPBQLVL3.mjs";
|
|
122
|
+
import {
|
|
125
123
|
parseBaseArgs
|
|
126
|
-
} from "../chunk-
|
|
124
|
+
} from "../chunk-75M6TF7M.mjs";
|
|
125
|
+
import "../chunk-SZ5C44L5.mjs";
|
|
127
126
|
import {
|
|
128
|
-
BeraError,
|
|
129
|
-
InvalidArgumentError,
|
|
130
127
|
RequestError
|
|
131
|
-
} from "../chunk-
|
|
128
|
+
} from "../chunk-XIYN6AL6.mjs";
|
|
129
|
+
import {
|
|
130
|
+
BeraError,
|
|
131
|
+
InvalidArgumentError
|
|
132
|
+
} from "../chunk-J5I45WGQ.mjs";
|
|
132
133
|
|
|
133
134
|
// src/hooks/bend/useGetConvertToAssets.ts
|
|
134
135
|
import useSWR from "swr";
|
|
@@ -438,21 +439,20 @@ var EnsoAggregator = class extends BaseAggregator {
|
|
|
438
439
|
amount,
|
|
439
440
|
aggregatorsFeeBps
|
|
440
441
|
);
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
this.config.bex.aggregatorsRouterExecutor
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
url.
|
|
454
|
-
|
|
455
|
-
const response = await this.fetch(url);
|
|
442
|
+
const refundReceiver = account === zeroAddress2 ? this.config.bex.aggregatorsRouterExecutor : account;
|
|
443
|
+
const params = new URLSearchParams({
|
|
444
|
+
fromAddress: this.config.bex.aggregatorsRouterExecutor,
|
|
445
|
+
receiver: this.config.bex.aggregatorsRouterExecutor,
|
|
446
|
+
spender: this.config.bex.aggregatorsRouterExecutor,
|
|
447
|
+
amountIn: inputAmountAfterFees,
|
|
448
|
+
tokenIn: tokenInAddress,
|
|
449
|
+
tokenOut: tokenOutAddress,
|
|
450
|
+
chainId: ChainId3.MAINNET.toString(),
|
|
451
|
+
slippage: (Number(slippage) * 100).toString(),
|
|
452
|
+
refundReceiver
|
|
453
|
+
});
|
|
454
|
+
this.url = proxyAggregatorsThroughVercel ? `/api/aggregators?aggregator=enso&${params.toString()}` : `${this.config.bex.aggregatorsProxyUrl}/enso/api/v1/shortcuts/route?${params.toString()}`;
|
|
455
|
+
const response = await this.fetch(this.url);
|
|
456
456
|
const quote = await response.json();
|
|
457
457
|
const inputData = this.getInputData({
|
|
458
458
|
tokenIn: tokenInAddress,
|
|
@@ -1027,15 +1027,16 @@ var KyberSwapAggregator = class extends BaseAggregator {
|
|
|
1027
1027
|
amount,
|
|
1028
1028
|
aggregatorsFeeBps
|
|
1029
1029
|
);
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1030
|
+
const params = new URLSearchParams({
|
|
1031
|
+
tokenIn: tokenInAddress,
|
|
1032
|
+
tokenOut: tokenOutAddress,
|
|
1033
|
+
amountIn: inputAmountAfterFees,
|
|
1034
|
+
slippageTolerance: (slippage / 100).toString(),
|
|
1035
|
+
to: this.config.bex.aggregatorsRouterExecutor,
|
|
1036
|
+
clientData: JSON.stringify({ source: "berachain" })
|
|
1037
|
+
});
|
|
1038
|
+
this.url = proxyAggregatorsThroughVercel ? `/api/aggregators?aggregator=kyberswapRoutes&${params.toString()}` : `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/routes?${params.toString()}`;
|
|
1039
|
+
const routeResponse = await this.fetch(this.url);
|
|
1039
1040
|
const routeData = await routeResponse.json();
|
|
1040
1041
|
const formattedQuote = {
|
|
1041
1042
|
amountOut: routeData.data.routeSummary.amountOut,
|
|
@@ -1058,13 +1059,7 @@ var KyberSwapAggregator = class extends BaseAggregator {
|
|
|
1058
1059
|
// 5 minutes from now
|
|
1059
1060
|
source: "berachain"
|
|
1060
1061
|
};
|
|
1061
|
-
const
|
|
1062
|
-
const buildUrl = new URL(
|
|
1063
|
-
proxyAggregatorsThroughVercel ? `/api/aggregators?aggregator=kyberswapBuild` : `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/route/build`
|
|
1064
|
-
);
|
|
1065
|
-
for (const [key, value] of params) {
|
|
1066
|
-
buildUrl.searchParams.set(key, value);
|
|
1067
|
-
}
|
|
1062
|
+
const buildUrl = proxyAggregatorsThroughVercel ? `/api/aggregators?aggregator=kyberswapBuild&${params.toString()}` : `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/route/build?${params.toString()}`;
|
|
1068
1063
|
const buildRouteResponse = await this.fetch(buildUrl, {
|
|
1069
1064
|
method: "POST",
|
|
1070
1065
|
body: JSON.stringify(buildRouteBody)
|
|
@@ -1880,17 +1875,8 @@ function useApiPool({
|
|
|
1880
1875
|
// src/hooks/dex/useCreatePool.ts
|
|
1881
1876
|
import { useMemo as useMemo2 } from "react";
|
|
1882
1877
|
import { PoolType as PoolType2 } from "@berachain-foundation/berancer-sdk";
|
|
1883
|
-
import
|
|
1884
|
-
import {
|
|
1885
|
-
formatUnits as formatUnits5,
|
|
1886
|
-
keccak256,
|
|
1887
|
-
parseUnits as parseUnits3,
|
|
1888
|
-
zeroAddress as zeroAddress11
|
|
1889
|
-
} from "viem";
|
|
1878
|
+
import { keccak256, parseUnits as parseUnits3, zeroAddress as zeroAddress11 } from "viem";
|
|
1890
1879
|
import { poolCreationHelperAbi as balancerPoolCreationHelperAbi } from "@berachain/abis/bex/poolCreationHelper";
|
|
1891
|
-
import {
|
|
1892
|
-
GetDedupedSubgraphPools
|
|
1893
|
-
} from "@berachain/graphql/dex/subgraph";
|
|
1894
1880
|
|
|
1895
1881
|
// src/utils/poolNamings.ts
|
|
1896
1882
|
import { PoolType } from "@berachain-foundation/berancer-sdk";
|
|
@@ -1930,7 +1916,6 @@ var generatePoolSymbol = (tokens, weights, poolType) => {
|
|
|
1930
1916
|
};
|
|
1931
1917
|
|
|
1932
1918
|
// src/hooks/dex/useCreatePool.ts
|
|
1933
|
-
var DEFAULT_WEIGHTS_DUPLICATION_THRESHOLD = 5e-3;
|
|
1934
1919
|
var OracleMode = /* @__PURE__ */ ((OracleMode2) => {
|
|
1935
1920
|
OracleMode2["None"] = "None";
|
|
1936
1921
|
OracleMode2["Custom"] = "Custom";
|
|
@@ -2086,60 +2071,8 @@ var useCreatePool = ({
|
|
|
2086
2071
|
owner,
|
|
2087
2072
|
amplification,
|
|
2088
2073
|
oracles,
|
|
2089
|
-
weightsDuplicationThreshold = DEFAULT_WEIGHTS_DUPLICATION_THRESHOLD,
|
|
2090
2074
|
...baseArgs
|
|
2091
2075
|
}) => {
|
|
2092
|
-
const {
|
|
2093
|
-
data: dupePool,
|
|
2094
|
-
error: errorLoadingPools,
|
|
2095
|
-
isLoading: isLoadingPools
|
|
2096
|
-
} = useSWRImmutable3(
|
|
2097
|
-
[
|
|
2098
|
-
"useCreatePool__deduped_pool",
|
|
2099
|
-
poolCreateTokens,
|
|
2100
|
-
poolType,
|
|
2101
|
-
normalizedWeights
|
|
2102
|
-
],
|
|
2103
|
-
async () => {
|
|
2104
|
-
if (poolCreateTokens.length === 0 || !poolType) {
|
|
2105
|
-
return null;
|
|
2106
|
-
}
|
|
2107
|
-
const bexSubgraphClient = getApolloClient("bex.subgraph", {});
|
|
2108
|
-
try {
|
|
2109
|
-
const tokensSorted = wrapNativeTokens(poolCreateTokens).map((token) => token.address.toLowerCase()).sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1);
|
|
2110
|
-
const res = await bexSubgraphClient.query(
|
|
2111
|
-
{
|
|
2112
|
-
query: GetDedupedSubgraphPools,
|
|
2113
|
-
variables: {
|
|
2114
|
-
tokens: tokensSorted,
|
|
2115
|
-
type: poolType
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
);
|
|
2119
|
-
const matchingPools = res.data.pools.filter((pool) => {
|
|
2120
|
-
return pool.tokens?.every(
|
|
2121
|
-
(token) => poolType === PoolType2.Weighted ? (
|
|
2122
|
-
// in weighted pools, a dupe is if tokens and weights match within tolerance FIXME: we aren't getting weighted pools returned here
|
|
2123
|
-
tokensSorted.includes(token.address) && Math.abs(
|
|
2124
|
-
Number(token.weight) - Number(
|
|
2125
|
-
formatUnits5(
|
|
2126
|
-
normalizedWeights[tokensSorted.indexOf(token.address)],
|
|
2127
|
-
18
|
|
2128
|
-
)
|
|
2129
|
-
)
|
|
2130
|
-
) < weightsDuplicationThreshold
|
|
2131
|
-
) : (
|
|
2132
|
-
// in composable pools a dupe is if the tokens match, handling that the LP token is in the tokens list
|
|
2133
|
-
tokensSorted.includes(token.address) || token.address === pool.address
|
|
2134
|
-
)
|
|
2135
|
-
);
|
|
2136
|
-
});
|
|
2137
|
-
return matchingPools?.at(0) ?? null;
|
|
2138
|
-
} catch {
|
|
2139
|
-
return null;
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
);
|
|
2143
2076
|
const { generatedPoolName, generatedPoolSymbol } = useMemo2(() => {
|
|
2144
2077
|
if (!poolCreateTokens) {
|
|
2145
2078
|
return {
|
|
@@ -2212,94 +2145,14 @@ var useCreatePool = ({
|
|
|
2212
2145
|
return {
|
|
2213
2146
|
generatedPoolName,
|
|
2214
2147
|
generatedPoolSymbol,
|
|
2215
|
-
|
|
2216
|
-
dupePool,
|
|
2217
|
-
createPoolArgs,
|
|
2218
|
-
isLoadingPools,
|
|
2219
|
-
errorLoadingPools
|
|
2148
|
+
createPoolArgs
|
|
2220
2149
|
};
|
|
2221
2150
|
};
|
|
2222
2151
|
|
|
2223
|
-
// src/hooks/dex/useExploitedTokens.ts
|
|
2224
|
-
import useSWR5 from "swr";
|
|
2225
|
-
import { usePublicClient as usePublicClient5 } from "@berachain/wagmi/hooks";
|
|
2226
|
-
|
|
2227
|
-
// src/actions/dex/getIsTokenExploited.ts
|
|
2228
|
-
import { erc20Abi, formatUnits as formatUnits6 } from "viem";
|
|
2229
|
-
import {
|
|
2230
|
-
GetExploitedTokens
|
|
2231
|
-
} from "@berachain/graphql/dex/subgraph";
|
|
2232
|
-
var BEX_EXPLOITED_TOKEN_THRESHOLD = 1e-4;
|
|
2233
|
-
async function getIsTokenExploited({
|
|
2234
|
-
token,
|
|
2235
|
-
publicClient,
|
|
2236
|
-
...args
|
|
2237
|
-
}) {
|
|
2238
|
-
const bexSubgraphClient = getApolloClient("bex.subgraph", args);
|
|
2239
|
-
const totalSupply = await publicClient.readContract({
|
|
2240
|
-
address: token.address,
|
|
2241
|
-
abi: erc20Abi,
|
|
2242
|
-
functionName: "totalSupply"
|
|
2243
|
-
});
|
|
2244
|
-
const balanceThreshold = bignumber_js_default(
|
|
2245
|
-
formatUnits6(totalSupply, token.decimals)
|
|
2246
|
-
).multipliedBy(BEX_EXPLOITED_TOKEN_THRESHOLD);
|
|
2247
|
-
const { data } = await bexSubgraphClient.query({
|
|
2248
|
-
query: GetExploitedTokens,
|
|
2249
|
-
variables: {
|
|
2250
|
-
token: token.address,
|
|
2251
|
-
balance: balanceThreshold.toFixed()
|
|
2252
|
-
}
|
|
2253
|
-
});
|
|
2254
|
-
if (data.userInternalBalances.length > 0) {
|
|
2255
|
-
return true;
|
|
2256
|
-
}
|
|
2257
|
-
return false;
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// src/hooks/dex/useExploitedTokens.ts
|
|
2261
|
-
var useExploitedTokensQueryKey = (tokens) => {
|
|
2262
|
-
const filteredTokens = tokens?.filter((token) => token.address);
|
|
2263
|
-
if (!filteredTokens || filteredTokens.length === 0) {
|
|
2264
|
-
return null;
|
|
2265
|
-
}
|
|
2266
|
-
return ["useExploitedTokens", filteredTokens];
|
|
2267
|
-
};
|
|
2268
|
-
var useExploitedTokens = ({
|
|
2269
|
-
tokens
|
|
2270
|
-
}) => {
|
|
2271
|
-
const QUERY_KEY = useExploitedTokensQueryKey(tokens);
|
|
2272
|
-
const publicClient = usePublicClient5();
|
|
2273
|
-
const swrResponse = useSWR5(
|
|
2274
|
-
publicClient ? QUERY_KEY : null,
|
|
2275
|
-
async ([, tokens2]) => {
|
|
2276
|
-
assertPublicClient(publicClient);
|
|
2277
|
-
const exploitedTokens = await Promise.all(
|
|
2278
|
-
tokens2.map(
|
|
2279
|
-
(token) => getIsTokenExploited({
|
|
2280
|
-
token,
|
|
2281
|
-
publicClient
|
|
2282
|
-
})
|
|
2283
|
-
)
|
|
2284
|
-
);
|
|
2285
|
-
return exploitedTokens.reduce(
|
|
2286
|
-
(acc, curr, idx) => {
|
|
2287
|
-
if (curr !== void 0) {
|
|
2288
|
-
acc[tokens2[idx].address] = curr;
|
|
2289
|
-
}
|
|
2290
|
-
return acc;
|
|
2291
|
-
},
|
|
2292
|
-
{}
|
|
2293
|
-
);
|
|
2294
|
-
}
|
|
2295
|
-
);
|
|
2296
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
2297
|
-
};
|
|
2298
|
-
|
|
2299
2152
|
// src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts
|
|
2300
|
-
import
|
|
2153
|
+
import useSWR5 from "swr";
|
|
2301
2154
|
var useGlobalLiquidityAndSwapVolume = () => {
|
|
2302
|
-
const response =
|
|
2155
|
+
const response = useSWR5(
|
|
2303
2156
|
"useGlobalLiquidityAndSwapVolume",
|
|
2304
2157
|
async () => getGlobalLiquidityAndSwapVolume()
|
|
2305
2158
|
);
|
|
@@ -2427,24 +2280,24 @@ var useLiquidityMismatch = ({
|
|
|
2427
2280
|
import { formatEther as formatEther3, isAddressEqual } from "viem";
|
|
2428
2281
|
|
|
2429
2282
|
// src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts
|
|
2430
|
-
import
|
|
2283
|
+
import useSWR6 from "swr";
|
|
2431
2284
|
import { isAddress as isAddress3, zeroAddress as zeroAddress13 } from "viem";
|
|
2432
2285
|
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
2433
|
-
import { useBeraWallet as useBeraWallet3, usePublicClient as
|
|
2286
|
+
import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
|
|
2434
2287
|
|
|
2435
2288
|
// src/hooks/pol/useRewardVaultFromToken.ts
|
|
2436
|
-
import
|
|
2289
|
+
import useSWRImmutable3 from "swr/immutable";
|
|
2437
2290
|
import { isAddress as isAddress2, zeroAddress as zeroAddress12 } from "viem";
|
|
2438
2291
|
import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
|
|
2439
|
-
import { usePublicClient as
|
|
2292
|
+
import { usePublicClient as usePublicClient5 } from "@berachain/wagmi/hooks";
|
|
2440
2293
|
var useRewardVaultFromToken = ({
|
|
2441
2294
|
tokenAddress
|
|
2442
2295
|
}, {
|
|
2443
2296
|
isEnabled = true
|
|
2444
2297
|
} = {}) => {
|
|
2445
|
-
const publicClient =
|
|
2298
|
+
const publicClient = usePublicClient5();
|
|
2446
2299
|
const QUERY_KEY = publicClient && tokenAddress && isAddress2(tokenAddress) && isEnabled ? ["useRewardVaultFromToken", tokenAddress] : null;
|
|
2447
|
-
const swrResponse =
|
|
2300
|
+
const swrResponse = useSWRImmutable3(QUERY_KEY, async ([, tokenAddress2]) => {
|
|
2448
2301
|
if (!tokenAddress2) {
|
|
2449
2302
|
throw new Error("useRewardVaultFromToken needs a valid token address");
|
|
2450
2303
|
}
|
|
@@ -2472,7 +2325,7 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2472
2325
|
rewardVaultAddress: _rewardVaultAddress
|
|
2473
2326
|
}, options) => {
|
|
2474
2327
|
const { address: account } = useBeraWallet3();
|
|
2475
|
-
const publicClient =
|
|
2328
|
+
const publicClient = usePublicClient6();
|
|
2476
2329
|
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
2477
2330
|
const {
|
|
2478
2331
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
@@ -2487,7 +2340,7 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2487
2340
|
isEnabled: !_rewardVaultAddress && isEnabled
|
|
2488
2341
|
}
|
|
2489
2342
|
);
|
|
2490
|
-
const swrResponse =
|
|
2343
|
+
const swrResponse = useSWR6(
|
|
2491
2344
|
rewardVaultAddress && account && publicClient && isAddress3(rewardVaultAddress) && isAddress3(account) && isEnabled ? ["useVaultBalanceFromStakingToken", rewardVaultAddress, account] : null,
|
|
2492
2345
|
async ([, rewardVaultAddress2, account2]) => {
|
|
2493
2346
|
assertPublicClient(publicClient);
|
|
@@ -2520,28 +2373,28 @@ var useRewardVaultBalanceFromStakingToken = ({
|
|
|
2520
2373
|
};
|
|
2521
2374
|
|
|
2522
2375
|
// src/hooks/tokens/usePollBalance.ts
|
|
2523
|
-
import
|
|
2376
|
+
import useSWR7 from "swr";
|
|
2524
2377
|
import {
|
|
2525
|
-
erc20Abi
|
|
2378
|
+
erc20Abi,
|
|
2526
2379
|
formatEther as formatEther2,
|
|
2527
|
-
formatUnits as
|
|
2380
|
+
formatUnits as formatUnits5,
|
|
2528
2381
|
isAddress as isAddress5,
|
|
2529
2382
|
zeroAddress as zeroAddress15
|
|
2530
2383
|
} from "viem";
|
|
2531
2384
|
import { defaultChainId as defaultChainId3 } from "@berachain/config/internal";
|
|
2532
|
-
import { useBeraWallet as useBeraWallet4, usePublicClient as
|
|
2385
|
+
import { useBeraWallet as useBeraWallet4, usePublicClient as usePublicClient8 } from "@berachain/wagmi/hooks";
|
|
2533
2386
|
|
|
2534
2387
|
// src/hooks/tokens/useTokenInformation.ts
|
|
2535
|
-
import
|
|
2388
|
+
import useSWRImmutable4 from "swr/immutable";
|
|
2536
2389
|
import { isAddress as isAddress4, zeroAddress as zeroAddress14 } from "viem";
|
|
2537
2390
|
import { defaultChainId as defaultChainId2 } from "@berachain/config/internal";
|
|
2538
|
-
import { usePublicClient as
|
|
2391
|
+
import { usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
2539
2392
|
function useTokenInformation(args, options) {
|
|
2540
|
-
const publicClient =
|
|
2393
|
+
const publicClient = usePublicClient7({
|
|
2541
2394
|
chainId: args.chainId
|
|
2542
2395
|
});
|
|
2543
2396
|
const QUERY_KEY = args?.address && publicClient && isAddress4(args.address) ? ["useTokenInformation", args.address, args.chainId] : null;
|
|
2544
|
-
const swrResponse =
|
|
2397
|
+
const swrResponse = useSWRImmutable4(
|
|
2545
2398
|
QUERY_KEY,
|
|
2546
2399
|
async ([_, address, chainId2 = defaultChainId2]) => {
|
|
2547
2400
|
if (isToken(address, "BERA")) {
|
|
@@ -2578,20 +2431,20 @@ function usePollBalance({
|
|
|
2578
2431
|
if (isToken(address, "ETH")) {
|
|
2579
2432
|
address = zeroAddress15;
|
|
2580
2433
|
}
|
|
2581
|
-
const publicClient =
|
|
2434
|
+
const publicClient = usePublicClient8({ chainId: chainId2 });
|
|
2582
2435
|
const { address: account } = useBeraWallet4();
|
|
2583
2436
|
const assetOwner = owner ?? account;
|
|
2584
2437
|
const QUERY_KEY = (options?.opts?.isEnabled ?? true) && publicClient && assetOwner && isAddress5(assetOwner) && address && isAddress5(address) ? ["usePollBalance", assetOwner, address, chainId2] : null;
|
|
2585
2438
|
const { data: tokenInformation, isLoading: isLoadingTokenInformation } = useTokenInformation({ address, chainId: chainId2 });
|
|
2586
2439
|
const isNativeToken = isToken(address, "BERA");
|
|
2587
|
-
const { isLoading, data, error, ...rest } =
|
|
2440
|
+
const { isLoading, data, error, ...rest } = useSWR7(
|
|
2588
2441
|
QUERY_KEY,
|
|
2589
2442
|
async ([, assetOwner2, address2]) => {
|
|
2590
2443
|
assertPublicClient(publicClient);
|
|
2591
2444
|
if (!isToken(address2, "BERA")) {
|
|
2592
2445
|
return await publicClient.readContract({
|
|
2593
2446
|
address: address2,
|
|
2594
|
-
abi:
|
|
2447
|
+
abi: erc20Abi,
|
|
2595
2448
|
functionName: "balanceOf",
|
|
2596
2449
|
args: [assetOwner2]
|
|
2597
2450
|
});
|
|
@@ -2604,7 +2457,7 @@ function usePollBalance({
|
|
|
2604
2457
|
refreshInterval: 1e4 /* FAST */
|
|
2605
2458
|
}
|
|
2606
2459
|
);
|
|
2607
|
-
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ?
|
|
2460
|
+
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ? formatUnits5(data, tokenInformation.decimals) : void 0 : void 0;
|
|
2608
2461
|
const tokenBalance = {
|
|
2609
2462
|
chainId: chainId2,
|
|
2610
2463
|
balance: data ? {
|
|
@@ -2694,13 +2547,13 @@ import { useMemo as useMemo3 } from "react";
|
|
|
2694
2547
|
import { parseUnits as parseUnits4, zeroAddress as zeroAddress16 } from "viem";
|
|
2695
2548
|
|
|
2696
2549
|
// src/hooks/tokens/usePollAllowances.ts
|
|
2697
|
-
import
|
|
2550
|
+
import useSWR8 from "swr";
|
|
2698
2551
|
import { useBeraWallet as useBeraWallet5, useConfig as useConfig2 } from "@berachain/wagmi/hooks";
|
|
2699
2552
|
function usePollAllowances(args, options) {
|
|
2700
2553
|
const config = useConfig2();
|
|
2701
2554
|
const { address: account } = useBeraWallet5();
|
|
2702
2555
|
const QUERY_KEY = config && account && args?.items ? ["usePollAllowances", account, args?.items] : null;
|
|
2703
|
-
const swrResponse =
|
|
2556
|
+
const swrResponse = useSWR8(
|
|
2704
2557
|
QUERY_KEY,
|
|
2705
2558
|
async ([, account2, items]) => {
|
|
2706
2559
|
return getAllowances({
|
|
@@ -2785,23 +2638,23 @@ function useMultipleTokenApprovalsWithSlippage(tokenInput, options) {
|
|
|
2785
2638
|
|
|
2786
2639
|
// src/hooks/dex/useOnChainPoolData.ts
|
|
2787
2640
|
import { useMemo as useMemo5 } from "react";
|
|
2788
|
-
import
|
|
2789
|
-
import { formatUnits as
|
|
2790
|
-
import { usePublicClient as
|
|
2641
|
+
import useSWRImmutable6 from "swr/immutable";
|
|
2642
|
+
import { formatUnits as formatUnits6, isAddress as isAddress8 } from "viem";
|
|
2643
|
+
import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
|
|
2791
2644
|
|
|
2792
2645
|
// src/hooks/tokens/useMultipleTokenInformation.ts
|
|
2793
|
-
import
|
|
2646
|
+
import useSWRImmutable5 from "swr/immutable";
|
|
2794
2647
|
import { isAddress as isAddress6 } from "viem";
|
|
2795
2648
|
import { defaultChainId as defaultChainId4 } from "@berachain/config/internal";
|
|
2796
|
-
import { usePublicClient as
|
|
2649
|
+
import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
|
|
2797
2650
|
function useMultipleTokenInformation(args, options) {
|
|
2798
|
-
const publicClient =
|
|
2651
|
+
const publicClient = usePublicClient9();
|
|
2799
2652
|
const QUERY_KEY = publicClient && args.addresses ? [
|
|
2800
2653
|
"useMultipleTokenInformation",
|
|
2801
2654
|
args.addresses,
|
|
2802
2655
|
args.chainId ?? defaultChainId4
|
|
2803
2656
|
] : null;
|
|
2804
|
-
const swrResponse =
|
|
2657
|
+
const swrResponse = useSWRImmutable5(
|
|
2805
2658
|
QUERY_KEY,
|
|
2806
2659
|
async ([, addresses, chainId2]) => {
|
|
2807
2660
|
assertPublicClient(publicClient);
|
|
@@ -2832,7 +2685,7 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2832
2685
|
|
|
2833
2686
|
// src/hooks/tokens/useTokenCurrentPrices.ts
|
|
2834
2687
|
import { useMemo as useMemo4 } from "react";
|
|
2835
|
-
import
|
|
2688
|
+
import useSWR9 from "swr";
|
|
2836
2689
|
import { isAddress as isAddress7, zeroAddress as zeroAddress17 } from "viem";
|
|
2837
2690
|
import { defaultChainId as defaultChainId5 } from "@berachain/config/internal";
|
|
2838
2691
|
|
|
@@ -2892,7 +2745,7 @@ function useTokenCurrentPrices({
|
|
|
2892
2745
|
"useTokenCurrentPrices",
|
|
2893
2746
|
addresses.map((a) => a.toLowerCase())
|
|
2894
2747
|
] : null;
|
|
2895
|
-
const apiResponse =
|
|
2748
|
+
const apiResponse = useSWR9(
|
|
2896
2749
|
QUERY_KEY,
|
|
2897
2750
|
async ([, addresses2]) => {
|
|
2898
2751
|
return getTokenCurrentPrices({ addressIn: addresses2 });
|
|
@@ -2950,7 +2803,7 @@ function useOnChainPoolDataQueryKey(args) {
|
|
|
2950
2803
|
return isValid && address ? ["useOnChainPoolData", address] : null;
|
|
2951
2804
|
}
|
|
2952
2805
|
function useOnChainPoolData(poolId) {
|
|
2953
|
-
const publicClient =
|
|
2806
|
+
const publicClient = usePublicClient10();
|
|
2954
2807
|
const address = poolId?.slice(0, 42);
|
|
2955
2808
|
const QUERY_KEY = useOnChainPoolDataQueryKey({ poolId });
|
|
2956
2809
|
const {
|
|
@@ -2958,7 +2811,7 @@ function useOnChainPoolData(poolId) {
|
|
|
2958
2811
|
error,
|
|
2959
2812
|
isLoading,
|
|
2960
2813
|
mutate
|
|
2961
|
-
} =
|
|
2814
|
+
} = useSWRImmutable6(
|
|
2962
2815
|
// FIXME: why are we using useSWRImmutable when we fetch tokenSupply and swapFee?
|
|
2963
2816
|
publicClient ? QUERY_KEY : null,
|
|
2964
2817
|
async ([, poolId2]) => {
|
|
@@ -2997,7 +2850,7 @@ function useOnChainPoolData(poolId) {
|
|
|
2997
2850
|
symbol: token.symbol,
|
|
2998
2851
|
index: idx,
|
|
2999
2852
|
weight: poolData.weights?.[idx] ?? void 0,
|
|
3000
|
-
balance:
|
|
2853
|
+
balance: formatUnits6(
|
|
3001
2854
|
BigInt(poolData.poolTokens[1][idx]),
|
|
3002
2855
|
token.decimals
|
|
3003
2856
|
),
|
|
@@ -3032,18 +2885,18 @@ function useOnChainPoolData(poolId) {
|
|
|
3032
2885
|
}
|
|
3033
2886
|
|
|
3034
2887
|
// src/hooks/dex/usePollPoolCreationRelayerApproval.ts
|
|
3035
|
-
import
|
|
2888
|
+
import useSWR10 from "swr";
|
|
3036
2889
|
import { vaultAbi as balancerVaultAbi2 } from "@berachain/abis/bex/vault";
|
|
3037
|
-
import { useBeraWallet as useBeraWallet6, usePublicClient as
|
|
2890
|
+
import { useBeraWallet as useBeraWallet6, usePublicClient as usePublicClient11 } from "@berachain/wagmi/hooks";
|
|
3038
2891
|
var usePollPoolCreationRelayerApproval = (options) => {
|
|
3039
2892
|
const { address: account } = useBeraWallet6();
|
|
3040
|
-
const publicClient =
|
|
2893
|
+
const publicClient = usePublicClient11();
|
|
3041
2894
|
const QUERY_KEY = account && publicClient ? [
|
|
3042
2895
|
"usePollPoolCreationRelayerApproval",
|
|
3043
2896
|
account,
|
|
3044
2897
|
publicClient.chain.id
|
|
3045
2898
|
] : null;
|
|
3046
|
-
const swrResponse =
|
|
2899
|
+
const swrResponse = useSWR10(
|
|
3047
2900
|
QUERY_KEY,
|
|
3048
2901
|
async ([, account2]) => {
|
|
3049
2902
|
assertPublicClient(publicClient);
|
|
@@ -3085,12 +2938,12 @@ function usePool({ poolId }) {
|
|
|
3085
2938
|
}
|
|
3086
2939
|
|
|
3087
2940
|
// src/hooks/dex/usePoolEvents.ts
|
|
3088
|
-
import
|
|
2941
|
+
import useSWRImmutable7 from "swr/immutable";
|
|
3089
2942
|
var usePoolEvents = ({
|
|
3090
2943
|
poolId,
|
|
3091
2944
|
typeInArray
|
|
3092
2945
|
}) => {
|
|
3093
|
-
return
|
|
2946
|
+
return useSWRImmutable7(
|
|
3094
2947
|
poolId ? ["usePoolEvents", poolId, typeInArray] : null,
|
|
3095
2948
|
async ([, poolId2, typeInArray2]) => getPoolEvents({ poolId: poolId2, typeInArray: typeInArray2 }),
|
|
3096
2949
|
{
|
|
@@ -3100,11 +2953,11 @@ var usePoolEvents = ({
|
|
|
3100
2953
|
};
|
|
3101
2954
|
|
|
3102
2955
|
// src/hooks/dex/usePoolHistoricalData.ts
|
|
3103
|
-
import
|
|
2956
|
+
import useSWR11 from "swr";
|
|
3104
2957
|
var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
3105
2958
|
const { config } = parseBaseArgs(baseArgs);
|
|
3106
2959
|
const QUERY_KEY = poolId ? ["usePoolHistoricalData", poolId] : null;
|
|
3107
|
-
const swrResponse =
|
|
2960
|
+
const swrResponse = useSWR11(
|
|
3108
2961
|
QUERY_KEY,
|
|
3109
2962
|
async ([, poolId2]) => {
|
|
3110
2963
|
return getPoolHistoricalData({
|
|
@@ -3122,7 +2975,7 @@ var usePoolHistoricalData = ({ poolId, ...baseArgs }, options) => {
|
|
|
3122
2975
|
|
|
3123
2976
|
// src/hooks/dex/usePools.ts
|
|
3124
2977
|
import { useMemo as useMemo6 } from "react";
|
|
3125
|
-
import
|
|
2978
|
+
import useSWR12 from "swr";
|
|
3126
2979
|
import { useBeraWallet as useBeraWallet7 } from "@berachain/wagmi/hooks";
|
|
3127
2980
|
var usePoolsQueryKey = ({
|
|
3128
2981
|
query
|
|
@@ -3143,7 +2996,7 @@ var usePools = (query, options) => {
|
|
|
3143
2996
|
data: pools,
|
|
3144
2997
|
isLoading: isPoolsLoading,
|
|
3145
2998
|
mutate: mutatePools
|
|
3146
|
-
} =
|
|
2999
|
+
} = useSWR12(
|
|
3147
3000
|
usePoolsQueryKey({ query }),
|
|
3148
3001
|
async ([_, query2]) => {
|
|
3149
3002
|
return getAllPools(query2);
|
|
@@ -3281,19 +3134,26 @@ function usePriceImpact({
|
|
|
3281
3134
|
const { getTokenPrice, isLoading } = useTokenPrices({
|
|
3282
3135
|
tokens: tokenIn && tokenOut ? [tokenIn, tokenOut] : void 0
|
|
3283
3136
|
});
|
|
3137
|
+
const tokenInPrice = getTokenPrice(tokenIn);
|
|
3138
|
+
const tokenOutPrice = getTokenPrice(tokenOut);
|
|
3284
3139
|
const priceImpact = useMemo8(() => {
|
|
3285
3140
|
if (!tokenIn || !tokenOut || !formattedAmountIn || !formattedAmountOut)
|
|
3286
3141
|
return void 0;
|
|
3287
|
-
|
|
3288
|
-
const tokenOutPrice = getTokenPrice(tokenOut);
|
|
3289
|
-
if (!tokenInPrice || !tokenOutPrice) return null;
|
|
3142
|
+
if (tokenInPrice == null || tokenOutPrice == null) return null;
|
|
3290
3143
|
return computePriceImpact(
|
|
3291
3144
|
tokenInPrice.toString(),
|
|
3292
3145
|
tokenOutPrice.toString(),
|
|
3293
3146
|
formattedAmountIn,
|
|
3294
3147
|
formattedAmountOut
|
|
3295
3148
|
);
|
|
3296
|
-
}, [
|
|
3149
|
+
}, [
|
|
3150
|
+
tokenIn,
|
|
3151
|
+
tokenOut,
|
|
3152
|
+
formattedAmountIn,
|
|
3153
|
+
formattedAmountOut,
|
|
3154
|
+
tokenInPrice,
|
|
3155
|
+
tokenOutPrice
|
|
3156
|
+
]);
|
|
3297
3157
|
return {
|
|
3298
3158
|
data: priceImpact,
|
|
3299
3159
|
isLoading
|
|
@@ -3301,17 +3161,17 @@ function usePriceImpact({
|
|
|
3301
3161
|
}
|
|
3302
3162
|
|
|
3303
3163
|
// src/hooks/enso/useBendDemultiply.ts
|
|
3304
|
-
import
|
|
3164
|
+
import useSWR15 from "swr";
|
|
3305
3165
|
import { parseUnits as parseUnits5 } from "viem";
|
|
3306
3166
|
import { defaultChainId as defaultChainId7 } from "@berachain/config/internal";
|
|
3307
3167
|
import {
|
|
3308
3168
|
useBeraWagmi,
|
|
3309
3169
|
useBeraWallet as useBeraWallet10,
|
|
3310
|
-
usePublicClient as
|
|
3170
|
+
usePublicClient as usePublicClient14
|
|
3311
3171
|
} from "@berachain/wagmi/hooks";
|
|
3312
3172
|
|
|
3313
3173
|
// src/actions/enso/getBendDemultiplyBundle.ts
|
|
3314
|
-
import { formatUnits as
|
|
3174
|
+
import { formatUnits as formatUnits8 } from "viem";
|
|
3315
3175
|
|
|
3316
3176
|
// src/actions/enso/flashloan.ts
|
|
3317
3177
|
import {
|
|
@@ -3323,9 +3183,9 @@ import { morphoAbi } from "@berachain/abis/bend/morpho";
|
|
|
3323
3183
|
// src/actions/enso/util.ts
|
|
3324
3184
|
import {
|
|
3325
3185
|
encodeFunctionData,
|
|
3326
|
-
erc20Abi as
|
|
3186
|
+
erc20Abi as erc20Abi2,
|
|
3327
3187
|
ethAddress,
|
|
3328
|
-
formatUnits as
|
|
3188
|
+
formatUnits as formatUnits7,
|
|
3329
3189
|
getAddress,
|
|
3330
3190
|
zeroAddress as zeroAddress18
|
|
3331
3191
|
} from "viem";
|
|
@@ -3359,7 +3219,7 @@ async function getTransactionsFromBundle({
|
|
|
3359
3219
|
if (publicClient) {
|
|
3360
3220
|
const currentAllowance = await publicClient.readContract({
|
|
3361
3221
|
address: tokenIn,
|
|
3362
|
-
abi:
|
|
3222
|
+
abi: erc20Abi2,
|
|
3363
3223
|
functionName: "allowance",
|
|
3364
3224
|
args: [fromAddress, approvalRequest.spender]
|
|
3365
3225
|
});
|
|
@@ -3398,7 +3258,7 @@ async function getEnsoWalletTransactionsWithApproval({
|
|
|
3398
3258
|
if (tokenInAddress !== ethAddress) {
|
|
3399
3259
|
const currentAllowance = await publicClient.readContract({
|
|
3400
3260
|
address: tokenIn.address,
|
|
3401
|
-
abi:
|
|
3261
|
+
abi: erc20Abi2,
|
|
3402
3262
|
functionName: "allowance",
|
|
3403
3263
|
args: [fromAddress, spender]
|
|
3404
3264
|
});
|
|
@@ -3410,12 +3270,12 @@ async function getEnsoWalletTransactionsWithApproval({
|
|
|
3410
3270
|
token: tokenIn,
|
|
3411
3271
|
amount: {
|
|
3412
3272
|
raw,
|
|
3413
|
-
formatted:
|
|
3273
|
+
formatted: formatUnits7(amountInBigInt, tokenIn.decimals)
|
|
3414
3274
|
},
|
|
3415
3275
|
spender
|
|
3416
3276
|
};
|
|
3417
3277
|
const approvalData = encodeFunctionData({
|
|
3418
|
-
abi:
|
|
3278
|
+
abi: erc20Abi2,
|
|
3419
3279
|
functionName: "approve",
|
|
3420
3280
|
args: [spender, amountInBigInt]
|
|
3421
3281
|
});
|
|
@@ -3561,11 +3421,11 @@ function getPositionEstimate({
|
|
|
3561
3421
|
loanToken
|
|
3562
3422
|
}) {
|
|
3563
3423
|
return {
|
|
3564
|
-
finalCollateral:
|
|
3424
|
+
finalCollateral: formatUnits8(
|
|
3565
3425
|
BigInt(collateralToWithdraw),
|
|
3566
3426
|
collateralToken.decimals
|
|
3567
3427
|
),
|
|
3568
|
-
totalBorrow:
|
|
3428
|
+
totalBorrow: formatUnits8(BigInt(repayAmount), loanToken.decimals)
|
|
3569
3429
|
};
|
|
3570
3430
|
}
|
|
3571
3431
|
async function getBendDemultiplyBundle({
|
|
@@ -3738,16 +3598,16 @@ async function getBendDemultiplyBundle({
|
|
|
3738
3598
|
}
|
|
3739
3599
|
|
|
3740
3600
|
// src/hooks/enso/useEnsoWalletV2Address.ts
|
|
3741
|
-
import
|
|
3601
|
+
import useSWR13 from "swr";
|
|
3742
3602
|
import { getAddress as getAddress3 } from "viem";
|
|
3743
|
-
import { useBeraWallet as useBeraWallet8, usePublicClient as
|
|
3603
|
+
import { useBeraWallet as useBeraWallet8, usePublicClient as usePublicClient12 } from "@berachain/wagmi/hooks";
|
|
3744
3604
|
function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
3745
3605
|
const { address: fromAddress } = useBeraWallet8();
|
|
3746
|
-
const publicClient =
|
|
3606
|
+
const publicClient = usePublicClient12({ chainId: chainId2 });
|
|
3747
3607
|
const { config } = parseBaseArgs({});
|
|
3748
3608
|
const ensoWalletV2Factory = config.enso.walletV2Factory;
|
|
3749
3609
|
const QUERY_KEY = fromAddress && ensoWalletV2Factory ? ["useEnsoWalletV2Address", fromAddress, ensoWalletV2Factory] : null;
|
|
3750
|
-
return
|
|
3610
|
+
return useSWR13(
|
|
3751
3611
|
QUERY_KEY,
|
|
3752
3612
|
async ([_, accountAddress, factory]) => {
|
|
3753
3613
|
assertPublicClient(publicClient);
|
|
@@ -3762,22 +3622,22 @@ function useEnsoWalletV2Address({ chainId: chainId2 }) {
|
|
|
3762
3622
|
}
|
|
3763
3623
|
|
|
3764
3624
|
// src/hooks/enso/useIsBendAuthorized.ts
|
|
3765
|
-
import
|
|
3766
|
-
import { useBeraWallet as useBeraWallet9, usePublicClient as
|
|
3625
|
+
import useSWR14 from "swr";
|
|
3626
|
+
import { useBeraWallet as useBeraWallet9, usePublicClient as usePublicClient13 } from "@berachain/wagmi/hooks";
|
|
3767
3627
|
function useIsBendAuthorized({
|
|
3768
3628
|
chainId: chainId2,
|
|
3769
3629
|
primaryAddress,
|
|
3770
3630
|
ensoWalletV2Address
|
|
3771
3631
|
}) {
|
|
3772
3632
|
const { address: fromAddress } = useBeraWallet9();
|
|
3773
|
-
const publicClient =
|
|
3633
|
+
const publicClient = usePublicClient13({ chainId: chainId2 });
|
|
3774
3634
|
const QUERY_KEY = fromAddress && primaryAddress && ensoWalletV2Address ? [
|
|
3775
3635
|
"useIsBendAuthorized",
|
|
3776
3636
|
fromAddress,
|
|
3777
3637
|
primaryAddress,
|
|
3778
3638
|
ensoWalletV2Address
|
|
3779
3639
|
] : null;
|
|
3780
|
-
return
|
|
3640
|
+
return useSWR14(
|
|
3781
3641
|
QUERY_KEY,
|
|
3782
3642
|
async ([_, accountAddress, primaryAddress2, ensoWalletV2Address2]) => {
|
|
3783
3643
|
assertPublicClient(publicClient);
|
|
@@ -3808,7 +3668,7 @@ function useBendDemultiply({
|
|
|
3808
3668
|
const { address: fromAddress } = useBeraWallet10();
|
|
3809
3669
|
const { account: { chainId: accountChainId } = {} } = useBeraWagmi();
|
|
3810
3670
|
const chainIdToUse = chainId2 ?? accountChainId ?? defaultChainId7;
|
|
3811
|
-
const publicClient =
|
|
3671
|
+
const publicClient = usePublicClient14({ chainId: chainIdToUse });
|
|
3812
3672
|
const { data: ensoWalletV2Address } = useEnsoWalletV2Address({
|
|
3813
3673
|
chainId: chainIdToUse
|
|
3814
3674
|
});
|
|
@@ -3817,6 +3677,9 @@ function useBendDemultiply({
|
|
|
3817
3677
|
primaryAddress,
|
|
3818
3678
|
ensoWalletV2Address
|
|
3819
3679
|
});
|
|
3680
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
3681
|
+
"proxyAggregatorsThroughVercel"
|
|
3682
|
+
);
|
|
3820
3683
|
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 && (options?.opts?.isEnabled ?? true) ? [
|
|
3821
3684
|
"useBendDemultiply",
|
|
3822
3685
|
fromAddress,
|
|
@@ -3831,9 +3694,10 @@ function useBendDemultiply({
|
|
|
3831
3694
|
currentCollateral,
|
|
3832
3695
|
currentDebt,
|
|
3833
3696
|
ensoWalletV2Address,
|
|
3834
|
-
isAuthorized
|
|
3697
|
+
isAuthorized,
|
|
3698
|
+
proxyAggregatorsThroughVercel ?? false
|
|
3835
3699
|
] : null;
|
|
3836
|
-
return
|
|
3700
|
+
return useSWR15(
|
|
3837
3701
|
QUERY_KEY,
|
|
3838
3702
|
async ([
|
|
3839
3703
|
_,
|
|
@@ -3849,7 +3713,8 @@ function useBendDemultiply({
|
|
|
3849
3713
|
currentCollateral2,
|
|
3850
3714
|
currentDebt2,
|
|
3851
3715
|
ensoWalletV2Address2,
|
|
3852
|
-
isAuthorized2
|
|
3716
|
+
isAuthorized2,
|
|
3717
|
+
proxyAggregatorsThroughVercel2
|
|
3853
3718
|
]) => {
|
|
3854
3719
|
assertPublicClient(publicClient);
|
|
3855
3720
|
const rawRepayAmount = parseUnits5(
|
|
@@ -3872,7 +3737,9 @@ function useBendDemultiply({
|
|
|
3872
3737
|
marketId: marketId2,
|
|
3873
3738
|
primaryAddress: primaryAddress2,
|
|
3874
3739
|
chainId: chainId3,
|
|
3875
|
-
ensoClient: getEnsoClient(
|
|
3740
|
+
ensoClient: getEnsoClient({
|
|
3741
|
+
baseURL: proxyAggregatorsThroughVercel2 ? "/api/enso" : void 0
|
|
3742
|
+
}),
|
|
3876
3743
|
slippage: slippage2,
|
|
3877
3744
|
publicClient,
|
|
3878
3745
|
collateralPriceInLoanAsset: collateralPriceInLoanAsset2,
|
|
@@ -3890,13 +3757,13 @@ function useBendDemultiply({
|
|
|
3890
3757
|
}
|
|
3891
3758
|
|
|
3892
3759
|
// src/hooks/enso/useBendMultiply.ts
|
|
3893
|
-
import
|
|
3760
|
+
import useSWR16 from "swr";
|
|
3894
3761
|
import { parseUnits as parseUnits6 } from "viem";
|
|
3895
3762
|
import { defaultChainId as defaultChainId8 } from "@berachain/config/internal";
|
|
3896
3763
|
import {
|
|
3897
3764
|
useBeraWagmi as useBeraWagmi2,
|
|
3898
3765
|
useBeraWallet as useBeraWallet11,
|
|
3899
|
-
usePublicClient as
|
|
3766
|
+
usePublicClient as usePublicClient15
|
|
3900
3767
|
} from "@berachain/wagmi/hooks";
|
|
3901
3768
|
|
|
3902
3769
|
// src/actions/enso/getBendMultiplyBundle.ts
|
|
@@ -4148,7 +4015,7 @@ function useBendMultiply({
|
|
|
4148
4015
|
const { address: fromAddress } = useBeraWallet11();
|
|
4149
4016
|
const { account: { chainId: accountChainId } = {} } = useBeraWagmi2();
|
|
4150
4017
|
const chainIdToUse = chainId2 ?? accountChainId ?? defaultChainId8;
|
|
4151
|
-
const publicClient =
|
|
4018
|
+
const publicClient = usePublicClient15({ chainId: chainIdToUse });
|
|
4152
4019
|
const { data: ensoWalletV2Address } = useEnsoWalletV2Address({
|
|
4153
4020
|
chainId: chainIdToUse
|
|
4154
4021
|
});
|
|
@@ -4157,6 +4024,9 @@ function useBendMultiply({
|
|
|
4157
4024
|
primaryAddress,
|
|
4158
4025
|
ensoWalletV2Address
|
|
4159
4026
|
});
|
|
4027
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4028
|
+
"proxyAggregatorsThroughVercel"
|
|
4029
|
+
);
|
|
4160
4030
|
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 && (options?.opts?.isEnabled ?? true) ? [
|
|
4161
4031
|
"useBendMultiply",
|
|
4162
4032
|
fromAddress,
|
|
@@ -4172,9 +4042,10 @@ function useBendMultiply({
|
|
|
4172
4042
|
slippage,
|
|
4173
4043
|
formattedCollateralPriceInLoanAsset,
|
|
4174
4044
|
ensoWalletV2Address,
|
|
4175
|
-
isAuthorized
|
|
4045
|
+
isAuthorized,
|
|
4046
|
+
proxyAggregatorsThroughVercel ?? false
|
|
4176
4047
|
] : null;
|
|
4177
|
-
return
|
|
4048
|
+
return useSWR16(
|
|
4178
4049
|
QUERY_KEY,
|
|
4179
4050
|
async ([
|
|
4180
4051
|
_,
|
|
@@ -4191,7 +4062,8 @@ function useBendMultiply({
|
|
|
4191
4062
|
slippage2,
|
|
4192
4063
|
formattedCollateralPriceInLoanAsset2,
|
|
4193
4064
|
ensoWalletV2Address2,
|
|
4194
|
-
isAuthorized2
|
|
4065
|
+
isAuthorized2,
|
|
4066
|
+
proxyAggregatorsThroughVercel2
|
|
4195
4067
|
]) => {
|
|
4196
4068
|
assertPublicClient(publicClient);
|
|
4197
4069
|
const rawSupplyCollateralAmount = parseUnits6(
|
|
@@ -4216,7 +4088,9 @@ function useBendMultiply({
|
|
|
4216
4088
|
marketId: marketId2,
|
|
4217
4089
|
primaryAddress: primaryAddress2,
|
|
4218
4090
|
chainId: chainId3,
|
|
4219
|
-
ensoClient: getEnsoClient(
|
|
4091
|
+
ensoClient: getEnsoClient({
|
|
4092
|
+
baseURL: proxyAggregatorsThroughVercel2 ? "/api/enso" : void 0
|
|
4093
|
+
}),
|
|
4220
4094
|
slippage: slippage2,
|
|
4221
4095
|
leverageMultiplier: leverageMultiplier2,
|
|
4222
4096
|
publicClient,
|
|
@@ -4233,10 +4107,10 @@ function useBendMultiply({
|
|
|
4233
4107
|
}
|
|
4234
4108
|
|
|
4235
4109
|
// src/hooks/enso/useBendZapSupply.ts
|
|
4236
|
-
import
|
|
4110
|
+
import useSWR17 from "swr";
|
|
4237
4111
|
import { formatEther as formatEther4, parseUnits as parseUnits7, zeroAddress as zeroAddress20 } from "viem";
|
|
4238
4112
|
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
4239
|
-
import { useBeraWallet as useBeraWallet12, usePublicClient as
|
|
4113
|
+
import { useBeraWallet as useBeraWallet12, usePublicClient as usePublicClient16 } from "@berachain/wagmi/hooks";
|
|
4240
4114
|
|
|
4241
4115
|
// src/actions/dex/aggregators/enso/ensoErc4626.ts
|
|
4242
4116
|
import { ethAddress as ethAddress2, zeroAddress as zeroAddress19 } from "viem";
|
|
@@ -4265,7 +4139,7 @@ var EnsoErc4626Aggregator = class extends BaseAggregator {
|
|
|
4265
4139
|
this.assertChainSupport({ tokenIn, tokenOut });
|
|
4266
4140
|
assertAddress(account, "account");
|
|
4267
4141
|
const ensoClient = getEnsoClient({
|
|
4268
|
-
|
|
4142
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : void 0
|
|
4269
4143
|
});
|
|
4270
4144
|
if (tokenIn.address === zeroAddress19) tokenIn.address = ethAddress2;
|
|
4271
4145
|
if (tokenOut.address === zeroAddress19) tokenOut.address = ethAddress2;
|
|
@@ -4354,7 +4228,7 @@ var EnsoErc4626Aggregator = class extends BaseAggregator {
|
|
|
4354
4228
|
const tokenOutAddress = rewardVault?.toLowerCase() ?? tokenOut.address.toLowerCase();
|
|
4355
4229
|
const amountOut = (
|
|
4356
4230
|
// @ts-expect-error enso has not typed this but is returned sometimes from API.
|
|
4357
|
-
bundle.minAmountsOut[tokenOutAddress] ?? bundle.amountsOut[tokenOutAddress] ?? "0"
|
|
4231
|
+
bundle.minAmountsOut?.[tokenOutAddress] ?? bundle.amountsOut[tokenOutAddress] ?? "0"
|
|
4358
4232
|
);
|
|
4359
4233
|
return {
|
|
4360
4234
|
amountOut,
|
|
@@ -4402,16 +4276,23 @@ function useBendZapSupply({
|
|
|
4402
4276
|
},
|
|
4403
4277
|
options
|
|
4404
4278
|
);
|
|
4405
|
-
const {
|
|
4279
|
+
const {
|
|
4280
|
+
data: zapSupplyAmount,
|
|
4281
|
+
isLoading: isZapSupplyAmountLoading,
|
|
4282
|
+
error: zapSupplyAmountError
|
|
4283
|
+
} = useGetConvertToAssets({
|
|
4406
4284
|
sharesAmount: BigInt(swrResponse.data?.amountOut ?? 0),
|
|
4407
|
-
vaultAddress: bendVault.address
|
|
4408
|
-
|
|
4409
|
-
const { data: priceImpact } = usePriceImpact({
|
|
4410
|
-
tokenIn,
|
|
4411
|
-
tokenOut: loanToken,
|
|
4412
|
-
formattedAmountIn: amount,
|
|
4413
|
-
formattedAmountOut: zapSupplyAmount?.formatted ?? "0"
|
|
4285
|
+
vaultAddress: bendVault.address,
|
|
4286
|
+
vaultChainId: bendVault.chainId
|
|
4414
4287
|
});
|
|
4288
|
+
const { data: priceImpact, isLoading: isPriceImpactLoading } = usePriceImpact(
|
|
4289
|
+
{
|
|
4290
|
+
tokenIn,
|
|
4291
|
+
tokenOut: loanToken,
|
|
4292
|
+
formattedAmountIn: amount,
|
|
4293
|
+
formattedAmountOut: zapSupplyAmount?.formatted ?? "0"
|
|
4294
|
+
}
|
|
4295
|
+
);
|
|
4415
4296
|
const isCrossChain = tokenIn?.chainId && tokenIn.chainId !== berachainChainId;
|
|
4416
4297
|
const { data: nativeBalanceData, isLoading: isNativeBalanceLoading } = usePollBalance(
|
|
4417
4298
|
{
|
|
@@ -4430,7 +4311,10 @@ function useBendZapSupply({
|
|
|
4430
4311
|
return {
|
|
4431
4312
|
...swrResponse,
|
|
4432
4313
|
zapSupplyAmount,
|
|
4314
|
+
zapSupplyAmountError,
|
|
4315
|
+
isZapSupplyAmountLoading,
|
|
4433
4316
|
priceImpact,
|
|
4317
|
+
isPriceImpactLoading,
|
|
4434
4318
|
hasInsufficientNativeBalance,
|
|
4435
4319
|
isCrossChain,
|
|
4436
4320
|
nativeFee,
|
|
@@ -4448,21 +4332,27 @@ function useBendZapSupplyHelper({
|
|
|
4448
4332
|
slippage
|
|
4449
4333
|
}, options) {
|
|
4450
4334
|
const { address: fromAddress } = useBeraWallet12();
|
|
4451
|
-
const
|
|
4452
|
-
|
|
4335
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4336
|
+
"proxyAggregatorsThroughVercel"
|
|
4337
|
+
);
|
|
4338
|
+
const isEnabled = (options?.opts?.isEnabled ?? true) && !!tokenIn && !!loanToken && !!bendVault && !!amount && !!fromAddress && !isToken(loanToken.address, tokenIn.address) && tokenIn.chainId && Number(amount) > 0 && !!slippage;
|
|
4339
|
+
const publicClientBeraChain = usePublicClient16();
|
|
4453
4340
|
const QUERY_KEY = isEnabled ? [
|
|
4454
4341
|
"useBendZapSupply",
|
|
4342
|
+
fromAddress,
|
|
4455
4343
|
tokenIn,
|
|
4456
4344
|
loanToken,
|
|
4457
4345
|
bendVault,
|
|
4458
4346
|
rewardVault,
|
|
4459
4347
|
amount,
|
|
4460
|
-
slippage
|
|
4348
|
+
slippage,
|
|
4349
|
+
proxyAggregatorsThroughVercel ?? false
|
|
4461
4350
|
] : null;
|
|
4462
|
-
return
|
|
4351
|
+
return useSWR17(
|
|
4463
4352
|
QUERY_KEY,
|
|
4464
4353
|
async ([
|
|
4465
4354
|
,
|
|
4355
|
+
fromAddress2,
|
|
4466
4356
|
tokenIn2,
|
|
4467
4357
|
loanToken2,
|
|
4468
4358
|
bendVault2,
|
|
@@ -4471,7 +4361,7 @@ function useBendZapSupplyHelper({
|
|
|
4471
4361
|
slippage2
|
|
4472
4362
|
]) => {
|
|
4473
4363
|
assertPublicClient(publicClientBeraChain);
|
|
4474
|
-
assertAddress(
|
|
4364
|
+
assertAddress(fromAddress2, "fromAddress");
|
|
4475
4365
|
assertAddress(tokenIn2?.address, "tokenInAddress");
|
|
4476
4366
|
assertDefined(tokenIn2?.chainId, "tokenInChainId");
|
|
4477
4367
|
return ensoErc4626.getQuote({
|
|
@@ -4480,8 +4370,9 @@ function useBendZapSupplyHelper({
|
|
|
4480
4370
|
underlyingToken: loanToken2,
|
|
4481
4371
|
amount: amount2,
|
|
4482
4372
|
slippage: slippage2,
|
|
4483
|
-
account:
|
|
4484
|
-
rewardVault: rewardVault2
|
|
4373
|
+
account: fromAddress2,
|
|
4374
|
+
rewardVault: rewardVault2,
|
|
4375
|
+
proxyAggregatorsThroughVercel
|
|
4485
4376
|
});
|
|
4486
4377
|
},
|
|
4487
4378
|
{
|
|
@@ -4493,7 +4384,7 @@ function useBendZapSupplyHelper({
|
|
|
4493
4384
|
|
|
4494
4385
|
// src/hooks/enso/useEnsoSwapBundle.ts
|
|
4495
4386
|
import { getPublicClient as getPublicClient2 } from "@wagmi/core";
|
|
4496
|
-
import
|
|
4387
|
+
import useSWR19 from "swr";
|
|
4497
4388
|
import { parseUnits as parseUnits8 } from "viem";
|
|
4498
4389
|
import { defaultChainId as berachainChainId2 } from "@berachain/config/internal";
|
|
4499
4390
|
import { useBeraWallet as useBeraWallet14, useConfig as useConfig4 } from "@berachain/wagmi/hooks";
|
|
@@ -4564,14 +4455,14 @@ async function getEnsoSwapBundle({
|
|
|
4564
4455
|
|
|
4565
4456
|
// src/hooks/tokens/usePollWalletBalances.ts
|
|
4566
4457
|
import { useMemo as useMemo9 } from "react";
|
|
4567
|
-
import
|
|
4458
|
+
import useSWR18 from "swr";
|
|
4568
4459
|
import {
|
|
4569
4460
|
useBeraWallet as useBeraWallet13,
|
|
4570
4461
|
useConfig as useConfig3,
|
|
4571
|
-
usePublicClient as
|
|
4462
|
+
usePublicClient as usePublicClient17
|
|
4572
4463
|
} from "@berachain/wagmi/hooks";
|
|
4573
4464
|
function usePollWalletBalances(args, options) {
|
|
4574
|
-
const publicClient =
|
|
4465
|
+
const publicClient = usePublicClient17();
|
|
4575
4466
|
const wagmiConfig = useConfig3();
|
|
4576
4467
|
const { address: connectedAccount } = useBeraWallet13();
|
|
4577
4468
|
const { tokenList, refresh } = useTokens();
|
|
@@ -4587,7 +4478,7 @@ function usePollWalletBalances(args, options) {
|
|
|
4587
4478
|
// TODO: adding the whole list to the query is very inefficient, we should only add the tokens addresses
|
|
4588
4479
|
Array.from(tokens.values())
|
|
4589
4480
|
] : null;
|
|
4590
|
-
const swrResponse =
|
|
4481
|
+
const swrResponse = useSWR18(
|
|
4591
4482
|
QUERY_KEY,
|
|
4592
4483
|
async ([, wallet2, tokenList2]) => {
|
|
4593
4484
|
return getWalletBalances({
|
|
@@ -4619,14 +4510,27 @@ function useEnsoSwapBundle({
|
|
|
4619
4510
|
}) {
|
|
4620
4511
|
const { address: fromAddress } = useBeraWallet14();
|
|
4621
4512
|
const wagmiConfig = useConfig4();
|
|
4622
|
-
const
|
|
4513
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4514
|
+
"proxyAggregatorsThroughVercel"
|
|
4515
|
+
);
|
|
4516
|
+
const ensoClient = getEnsoClient({
|
|
4517
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : void 0
|
|
4518
|
+
});
|
|
4623
4519
|
const { refresh: refreshBalances } = usePollWalletBalances();
|
|
4624
4520
|
const isEnabled = !!tokenIn && !!tokenOut && !!amount && Number(amount) > 0 && !!slippage && !!fromAddress && !!tokenIn.chainId;
|
|
4625
|
-
const QUERY_KEY = isEnabled ? [
|
|
4626
|
-
|
|
4521
|
+
const QUERY_KEY = isEnabled ? [
|
|
4522
|
+
"useEnsoSwapBundle",
|
|
4523
|
+
fromAddress,
|
|
4524
|
+
tokenIn,
|
|
4525
|
+
tokenOut,
|
|
4526
|
+
amount,
|
|
4527
|
+
slippage,
|
|
4528
|
+
proxyAggregatorsThroughVercel ?? false
|
|
4529
|
+
] : null;
|
|
4530
|
+
const swrResponse = useSWR19(
|
|
4627
4531
|
QUERY_KEY,
|
|
4628
|
-
async ([, tokenIn2, tokenOut2, amount2, slippage2]) => {
|
|
4629
|
-
assertAddress(
|
|
4532
|
+
async ([, fromAddress2, tokenIn2, tokenOut2, amount2, slippage2]) => {
|
|
4533
|
+
assertAddress(fromAddress2, "fromAddress");
|
|
4630
4534
|
assertAddress(tokenIn2?.address, "tokenInAddress");
|
|
4631
4535
|
assertDefined(tokenIn2?.chainId, "tokenInChainId");
|
|
4632
4536
|
assertAddress(tokenOut2?.address, "tokenOutAddress");
|
|
@@ -4638,7 +4542,7 @@ function useEnsoSwapBundle({
|
|
|
4638
4542
|
assertPublicClient(publicClient);
|
|
4639
4543
|
const rawAmount = parseUnits8(amount2, tokenIn2.decimals).toString();
|
|
4640
4544
|
return getEnsoSwapBundle({
|
|
4641
|
-
fromAddress,
|
|
4545
|
+
fromAddress: fromAddress2,
|
|
4642
4546
|
amountIn: rawAmount,
|
|
4643
4547
|
tokenIn: tokenIn2.address,
|
|
4644
4548
|
tokenOut: tokenOut2.address,
|
|
@@ -4664,8 +4568,8 @@ function useEnsoSwapBundle({
|
|
|
4664
4568
|
}
|
|
4665
4569
|
|
|
4666
4570
|
// src/hooks/enso/useZapStakeBera.ts
|
|
4667
|
-
import
|
|
4668
|
-
import { formatUnits as
|
|
4571
|
+
import useSWR20 from "swr";
|
|
4572
|
+
import { formatUnits as formatUnits9, parseUnits as parseUnits9 } from "viem";
|
|
4669
4573
|
import { chainConfigs, defaultChainId as defaultChainId9 } from "@berachain/config/internal";
|
|
4670
4574
|
import { useBeraWallet as useBeraWallet15 } from "@berachain/wagmi/hooks";
|
|
4671
4575
|
function useZapStakeBera({
|
|
@@ -4687,7 +4591,7 @@ function useZapStakeBera({
|
|
|
4687
4591
|
underlyingToken,
|
|
4688
4592
|
tokenOut
|
|
4689
4593
|
] : null;
|
|
4690
|
-
const swrResponse =
|
|
4594
|
+
const swrResponse = useSWR20(
|
|
4691
4595
|
QUERY_KEY,
|
|
4692
4596
|
async ([
|
|
4693
4597
|
,
|
|
@@ -4717,7 +4621,7 @@ function useZapStakeBera({
|
|
|
4717
4621
|
tokenIn: inputToken,
|
|
4718
4622
|
tokenOut,
|
|
4719
4623
|
formattedAmountIn: amount,
|
|
4720
|
-
formattedAmountOut:
|
|
4624
|
+
formattedAmountOut: formatUnits9(
|
|
4721
4625
|
BigInt(swrResponse.data?.amountOut ?? "0"),
|
|
4722
4626
|
tokenOut.decimals
|
|
4723
4627
|
)
|
|
@@ -4735,893 +4639,40 @@ function useZapStakeBera({
|
|
|
4735
4639
|
};
|
|
4736
4640
|
}
|
|
4737
4641
|
|
|
4738
|
-
// src/hooks/
|
|
4739
|
-
import
|
|
4642
|
+
// src/hooks/honey/useCappedGlobally.ts
|
|
4643
|
+
import useSWR22 from "swr";
|
|
4644
|
+
import { usePublicClient as usePublicClient18 } from "@berachain/wagmi/hooks";
|
|
4740
4645
|
|
|
4741
|
-
// src/
|
|
4742
|
-
import
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
// src/utils/hasAnyTruthyValues.ts
|
|
4753
|
-
function hasAnyTruthyValues(obj) {
|
|
4754
|
-
return Object.values(obj).some((value) => {
|
|
4755
|
-
if (Array.isArray(value)) {
|
|
4756
|
-
return value.some(
|
|
4757
|
-
(item) => typeof item === "object" && item !== null ? hasAnyTruthyValues(item) : !!item
|
|
4758
|
-
);
|
|
4759
|
-
}
|
|
4760
|
-
if (typeof value === "object" && value !== null) {
|
|
4761
|
-
return hasAnyTruthyValues(value);
|
|
4762
|
-
}
|
|
4763
|
-
return !!value;
|
|
4646
|
+
// src/hooks/honey/usePythLatestPrices.ts
|
|
4647
|
+
import useSWR21 from "swr";
|
|
4648
|
+
function usePythLatestPrices({
|
|
4649
|
+
priceFeedMap
|
|
4650
|
+
}, options) {
|
|
4651
|
+
const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
|
|
4652
|
+
const QUERY_KEY = (options?.opts?.isEnabled ?? true) && priceFeedIds ? ["usePythLatestPrices", priceFeedIds] : null;
|
|
4653
|
+
const swrResponse = useSWR21(QUERY_KEY, async ([_, priceFeeds]) => {
|
|
4654
|
+
const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
|
|
4655
|
+
return data;
|
|
4764
4656
|
});
|
|
4657
|
+
return swrResponse;
|
|
4765
4658
|
}
|
|
4766
4659
|
|
|
4767
|
-
// src/
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
const
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
errors.ABI = checkProposalField({
|
|
4784
|
-
fieldOrType: "abi",
|
|
4785
|
-
value: action.ABI
|
|
4786
|
-
});
|
|
4787
|
-
if (!action.functionSignature) {
|
|
4788
|
-
errors.functionSignature = "Required" /* REQUIRED */;
|
|
4789
|
-
} else {
|
|
4790
|
-
try {
|
|
4791
|
-
const parsedSignatureAbi = parseAbiItem(action.functionSignature);
|
|
4792
|
-
if (parsedSignatureAbi.type !== "function") {
|
|
4793
|
-
console.error(
|
|
4794
|
-
"parsedSignatureAbi is not a function",
|
|
4795
|
-
parsedSignatureAbi
|
|
4796
|
-
);
|
|
4797
|
-
errors.functionSignature = "Invalid ABI" /* INVALID_ABI */;
|
|
4798
|
-
} else {
|
|
4799
|
-
errors.args = parsedSignatureAbi.inputs.map((input, index) => {
|
|
4800
|
-
try {
|
|
4801
|
-
if ("components" in input) {
|
|
4802
|
-
return checkProposalField({
|
|
4803
|
-
// @ts-expect-error this is not typed, will throw if not valid
|
|
4804
|
-
fieldOrType: input.type,
|
|
4805
|
-
value: action.args?.[index],
|
|
4806
|
-
components: input.components
|
|
4807
|
-
});
|
|
4808
|
-
}
|
|
4809
|
-
return checkProposalField({
|
|
4810
|
-
// @ts-expect-error this is not typed, will throw if not valid
|
|
4811
|
-
fieldOrType: input.type,
|
|
4812
|
-
value: action.args?.[index]
|
|
4813
|
-
});
|
|
4814
|
-
} catch {
|
|
4815
|
-
return null;
|
|
4816
|
-
}
|
|
4817
|
-
});
|
|
4818
|
-
if (!errors.args.some((v) => v)) {
|
|
4819
|
-
actions[idx] = encodeFunctionData3({
|
|
4820
|
-
abi: [parsedSignatureAbi],
|
|
4821
|
-
args: action.args
|
|
4822
|
-
});
|
|
4823
|
-
}
|
|
4824
|
-
}
|
|
4825
|
-
} catch {
|
|
4826
|
-
errors.functionSignature = "Invalid ABI" /* INVALID_ABI */;
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
} else if (action.input === "rawCalldata") {
|
|
4830
|
-
errors.rawCalldata = checkProposalField({
|
|
4831
|
-
fieldOrType: "hex",
|
|
4832
|
-
value: action.rawCalldata
|
|
4833
|
-
});
|
|
4834
|
-
actions[idx] = action.rawCalldata;
|
|
4835
|
-
} else if (action.input === "message") {
|
|
4836
|
-
errors.message = checkProposalField({
|
|
4837
|
-
fieldOrType: "string",
|
|
4838
|
-
value: action.message
|
|
4839
|
-
});
|
|
4840
|
-
actions[idx] = toHex(action.message);
|
|
4841
|
-
} else {
|
|
4842
|
-
throw new Error("Invalid input type");
|
|
4843
|
-
}
|
|
4844
|
-
} else if (action.type === "whitelist-reward-vault" /* WHITELIST_REWARD_VAULT */ || action.type === "blacklist-reward-vault" /* BLACKLIST_REWARD_VAULT */) {
|
|
4845
|
-
errors.vault = checkProposalField({
|
|
4846
|
-
fieldOrType: "address",
|
|
4847
|
-
value: action.vault
|
|
4848
|
-
});
|
|
4849
|
-
if (!errors.vault) {
|
|
4850
|
-
const whiteList = action.type === "whitelist-reward-vault" /* WHITELIST_REWARD_VAULT */;
|
|
4851
|
-
actions[idx] = encodeFunctionData3({
|
|
4852
|
-
abi: beraChefAbi,
|
|
4853
|
-
functionName: "setVaultWhitelistedStatus",
|
|
4854
|
-
args: [action.vault, whiteList, ""]
|
|
4855
|
-
});
|
|
4856
|
-
}
|
|
4857
|
-
} else if (action.type === "whitelist-reward-vault-incentive" /* WHITELIST_REWARD_VAULT_INCENTIVE */) {
|
|
4858
|
-
errors.token = checkProposalField({
|
|
4859
|
-
fieldOrType: "address",
|
|
4860
|
-
value: action.token
|
|
4861
|
-
});
|
|
4862
|
-
errors.minIncentiveRate = checkProposalField({
|
|
4863
|
-
fieldOrType: "uint256",
|
|
4864
|
-
value: action.minIncentiveRate
|
|
4865
|
-
});
|
|
4866
|
-
errors.managerAddress = checkProposalField({
|
|
4867
|
-
fieldOrType: "address",
|
|
4868
|
-
value: action.managerAddress
|
|
4869
|
-
});
|
|
4870
|
-
if (!errors.token && !errors.minIncentiveRate && !errors.managerAddress) {
|
|
4871
|
-
actions[idx] = encodeFunctionData3({
|
|
4872
|
-
abi: rewardVaultAbi2,
|
|
4873
|
-
functionName: "whitelistIncentiveToken",
|
|
4874
|
-
args: [
|
|
4875
|
-
action.token,
|
|
4876
|
-
BigInt(action.minIncentiveRate),
|
|
4877
|
-
action.managerAddress
|
|
4878
|
-
]
|
|
4879
|
-
});
|
|
4880
|
-
}
|
|
4881
|
-
} else if (action.type === "erc20-transfer" /* ERC20_TRANSFER */) {
|
|
4882
|
-
errors.amount = checkProposalField({
|
|
4883
|
-
fieldOrType: "uint256",
|
|
4884
|
-
value: action.amount
|
|
4885
|
-
});
|
|
4886
|
-
errors.to = checkProposalField({
|
|
4887
|
-
fieldOrType: "address",
|
|
4888
|
-
value: action.to
|
|
4889
|
-
});
|
|
4890
|
-
if (!errors.amount && !errors.to) {
|
|
4891
|
-
actions[idx] = encodeFunctionData3({
|
|
4892
|
-
abi: erc20Abi4,
|
|
4893
|
-
functionName: "transfer",
|
|
4894
|
-
args: [action.to, BigInt(action.amount)]
|
|
4895
|
-
});
|
|
4896
|
-
}
|
|
4897
|
-
}
|
|
4898
|
-
const hasErrors = hasAnyTruthyValues(errors);
|
|
4899
|
-
if (!hasErrors) {
|
|
4900
|
-
return null;
|
|
4901
|
-
}
|
|
4902
|
-
return errors;
|
|
4903
|
-
});
|
|
4904
|
-
onError?.(e);
|
|
4905
|
-
if (Object.getOwnPropertyNames(e).map((name) => e[name]).some((v) => {
|
|
4906
|
-
if (Array.isArray(v)) {
|
|
4907
|
-
return v.filter((v2) => v2).length > 0;
|
|
4908
|
-
}
|
|
4909
|
-
if (v === null) {
|
|
4910
|
-
return false;
|
|
4911
|
-
}
|
|
4912
|
-
return !!v;
|
|
4913
|
-
})) {
|
|
4914
|
-
console.warn("Proposal has errors", e);
|
|
4915
|
-
return;
|
|
4916
|
-
}
|
|
4917
|
-
if (actions.length === 0) {
|
|
4918
|
-
throw new Error("No actions submitted in proposal");
|
|
4919
|
-
}
|
|
4920
|
-
const link = new URL(proposal.forumLink);
|
|
4921
|
-
const description = matter.stringify(proposal.description, {
|
|
4922
|
-
title: proposal.title,
|
|
4923
|
-
topics: Array.from(proposal.topic.values()),
|
|
4924
|
-
forumLink: link.toString(),
|
|
4925
|
-
version: "1.0.0",
|
|
4926
|
-
"content-encoding": "utf-8",
|
|
4927
|
-
"content-type": "text/markdown",
|
|
4928
|
-
actions: proposal.actions.map((action) => {
|
|
4929
|
-
const actionMetadata = {
|
|
4930
|
-
type: action.type
|
|
4931
|
-
};
|
|
4932
|
-
if (action.type === "custom-action" /* CUSTOM_PROPOSAL */) {
|
|
4933
|
-
actionMetadata.inputType = action.input;
|
|
4934
|
-
}
|
|
4935
|
-
return actionMetadata;
|
|
4936
|
-
})
|
|
4937
|
-
});
|
|
4938
|
-
return [
|
|
4939
|
-
proposal.actions.map((action) => action.target),
|
|
4940
|
-
proposal.actions.map((action) => action.value ?? 0n),
|
|
4941
|
-
actions,
|
|
4942
|
-
description
|
|
4943
|
-
];
|
|
4944
|
-
}
|
|
4945
|
-
|
|
4946
|
-
// src/hooks/governance/useCreateProposal.ts
|
|
4947
|
-
var defaultAction = {
|
|
4948
|
-
type: "custom-action" /* CUSTOM_PROPOSAL */,
|
|
4949
|
-
target: "",
|
|
4950
|
-
ABI: "",
|
|
4951
|
-
value: 0n,
|
|
4952
|
-
functionSignature: "",
|
|
4953
|
-
args: [],
|
|
4954
|
-
input: "ABI",
|
|
4955
|
-
rawCalldata: "0x",
|
|
4956
|
-
message: ""
|
|
4957
|
-
};
|
|
4958
|
-
var useCreateProposal = ({
|
|
4959
|
-
initialData = {},
|
|
4960
|
-
currentTopic,
|
|
4961
|
-
onError
|
|
4962
|
-
}) => {
|
|
4963
|
-
const [proposal, setProposal] = useState2({
|
|
4964
|
-
title: "",
|
|
4965
|
-
description: "",
|
|
4966
|
-
forumLink: "",
|
|
4967
|
-
actions: [defaultAction],
|
|
4968
|
-
...initialData,
|
|
4969
|
-
topic: /* @__PURE__ */ new Set()
|
|
4970
|
-
});
|
|
4971
|
-
useEffect2(() => {
|
|
4972
|
-
setProposal((p) => ({
|
|
4973
|
-
...p,
|
|
4974
|
-
topic: /* @__PURE__ */ new Set([currentTopic.id])
|
|
4975
|
-
}));
|
|
4976
|
-
}, [currentTopic]);
|
|
4977
|
-
const addProposalAction = useCallback2(() => {
|
|
4978
|
-
setProposal((p) => ({ ...p, actions: [...p.actions, defaultAction] }));
|
|
4979
|
-
}, []);
|
|
4980
|
-
const removeProposalAction = useCallback2(
|
|
4981
|
-
(idx) => {
|
|
4982
|
-
setProposal((p) => {
|
|
4983
|
-
const actions = [...p.actions];
|
|
4984
|
-
actions.splice(idx, 1);
|
|
4985
|
-
return { ...p, actions };
|
|
4986
|
-
});
|
|
4987
|
-
},
|
|
4988
|
-
[setProposal]
|
|
4989
|
-
);
|
|
4990
|
-
const computeParamsAndErrors = useCallback2(() => {
|
|
4991
|
-
if (!proposal) {
|
|
4992
|
-
return;
|
|
4993
|
-
}
|
|
4994
|
-
const computedParams = getProposalParams({
|
|
4995
|
-
proposal,
|
|
4996
|
-
currentTopic,
|
|
4997
|
-
onError
|
|
4998
|
-
});
|
|
4999
|
-
return computedParams;
|
|
5000
|
-
}, [proposal, currentTopic]);
|
|
5001
|
-
return {
|
|
5002
|
-
proposal,
|
|
5003
|
-
setProposal,
|
|
5004
|
-
addProposalAction,
|
|
5005
|
-
removeProposalAction,
|
|
5006
|
-
computeParamsAndErrors
|
|
5007
|
-
};
|
|
5008
|
-
};
|
|
5009
|
-
|
|
5010
|
-
// src/hooks/governance/useGetPastVotes.ts
|
|
5011
|
-
import useSWRImmutable10 from "swr/immutable";
|
|
5012
|
-
import { formatUnits as formatUnits12 } from "viem";
|
|
5013
|
-
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5014
|
-
import { useBeraWallet as useBeraWallet16, usePublicClient as usePublicClient20 } from "@berachain/wagmi/hooks";
|
|
5015
|
-
|
|
5016
|
-
// src/hooks/governance/useProposalSnapshot.ts
|
|
5017
|
-
import useSWRImmutable9 from "swr/immutable";
|
|
5018
|
-
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
5019
|
-
import { usePublicClient as usePublicClient19 } from "@berachain/wagmi/hooks";
|
|
5020
|
-
var useProposalSnapshot = ({
|
|
5021
|
-
proposalId
|
|
5022
|
-
}) => {
|
|
5023
|
-
const publicClient = usePublicClient19();
|
|
5024
|
-
const QUERY_KEY = publicClient && proposalId ? ["useProposalSnapshot", proposalId] : null;
|
|
5025
|
-
return useSWRImmutable9(QUERY_KEY, async ([, proposalId2]) => {
|
|
5026
|
-
assertPublicClient(publicClient);
|
|
5027
|
-
const { config } = parseBaseArgs({
|
|
5028
|
-
chainId: publicClient.chain.id
|
|
5029
|
-
});
|
|
5030
|
-
const snapshot = await publicClient.readContract({
|
|
5031
|
-
abi: governanceAbi,
|
|
5032
|
-
address: config.governance.governor,
|
|
5033
|
-
functionName: "proposalSnapshot",
|
|
5034
|
-
args: [BigInt(proposalId2)]
|
|
5035
|
-
});
|
|
5036
|
-
return snapshot.toString();
|
|
5037
|
-
});
|
|
5038
|
-
};
|
|
5039
|
-
|
|
5040
|
-
// src/hooks/governance/useGetPastVotes.ts
|
|
5041
|
-
var useGetPastVotes = (args) => {
|
|
5042
|
-
const { address: account } = useBeraWallet16();
|
|
5043
|
-
const publicClient = usePublicClient20();
|
|
5044
|
-
const wallet = args.wallet || account;
|
|
5045
|
-
const { data: snapshot } = useProposalSnapshot({
|
|
5046
|
-
proposalId: args.proposalId
|
|
5047
|
-
});
|
|
5048
|
-
const ts = args.timepoint || snapshot;
|
|
5049
|
-
const QUERY_KEY = ts && publicClient && wallet ? ["useGetPastVotes", ts, wallet] : null;
|
|
5050
|
-
return useSWRImmutable10(QUERY_KEY, async ([, ts2, wallet2]) => {
|
|
5051
|
-
assertPublicClient(publicClient);
|
|
5052
|
-
const { config } = parseBaseArgs({
|
|
5053
|
-
chainId: publicClient.chain.id
|
|
5054
|
-
});
|
|
5055
|
-
if (Number(ts2) > Date.now() / 1e3) {
|
|
5056
|
-
throw new Error("timepoint is in the future");
|
|
5057
|
-
}
|
|
5058
|
-
const votes = await publicClient.readContract({
|
|
5059
|
-
abi: bgtAbi,
|
|
5060
|
-
address: config.tokens.bgt,
|
|
5061
|
-
functionName: "getPastVotes",
|
|
5062
|
-
args: [wallet2, BigInt(ts2)]
|
|
5063
|
-
});
|
|
5064
|
-
return formatUnits12(votes, 18);
|
|
5065
|
-
});
|
|
5066
|
-
};
|
|
5067
|
-
|
|
5068
|
-
// src/hooks/governance/useHasVoted.ts
|
|
5069
|
-
import useSWR22 from "swr";
|
|
5070
|
-
import { isAddress as isAddress9 } from "viem";
|
|
5071
|
-
import { berachainGovernanceAbi as governanceAbi2 } from "@berachain/abis/gov/berachainGovernance";
|
|
5072
|
-
import { useBeraWallet as useBeraWallet17, usePublicClient as usePublicClient21 } from "@berachain/wagmi/hooks";
|
|
5073
|
-
var useHasVoted = ({
|
|
5074
|
-
proposalId,
|
|
5075
|
-
wallet
|
|
5076
|
-
}) => {
|
|
5077
|
-
const { address: account } = useBeraWallet17();
|
|
5078
|
-
const publicClient = usePublicClient21();
|
|
5079
|
-
const address = wallet || account;
|
|
5080
|
-
return useSWR22(
|
|
5081
|
-
publicClient && address && isAddress9(address) ? ["useHasVoted", proposalId, address] : null,
|
|
5082
|
-
([, proposalId2, address2]) => {
|
|
5083
|
-
assertPublicClient(publicClient);
|
|
5084
|
-
const { config } = parseBaseArgs({
|
|
5085
|
-
chainId: publicClient.chain.id
|
|
5086
|
-
});
|
|
5087
|
-
return publicClient.readContract({
|
|
5088
|
-
address: config.governance.governor,
|
|
5089
|
-
abi: governanceAbi2,
|
|
5090
|
-
functionName: "hasVoted",
|
|
5091
|
-
args: [BigInt(proposalId2), address2]
|
|
5092
|
-
});
|
|
5093
|
-
}
|
|
5094
|
-
);
|
|
5095
|
-
};
|
|
5096
|
-
|
|
5097
|
-
// src/hooks/governance/useIsCanceller.ts
|
|
5098
|
-
import useSWR23 from "swr";
|
|
5099
|
-
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
5100
|
-
import { usePublicClient as usePublicClient22 } from "@berachain/wagmi/hooks";
|
|
5101
|
-
|
|
5102
|
-
// src/actions/governance/constants.ts
|
|
5103
|
-
var CANCELLER_ROLE = "0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783";
|
|
5104
|
-
|
|
5105
|
-
// src/hooks/governance/useIsCanceller.ts
|
|
5106
|
-
var useIsCanceller = ({
|
|
5107
|
-
account,
|
|
5108
|
-
...baseArgs
|
|
5109
|
-
}) => {
|
|
5110
|
-
const publicClient = usePublicClient22();
|
|
5111
|
-
const { config: chainConfig } = parseBaseArgs(baseArgs);
|
|
5112
|
-
const QUERY_KEY = account && publicClient ? ["useCancellerRole", account] : null;
|
|
5113
|
-
return useSWR23(
|
|
5114
|
-
QUERY_KEY,
|
|
5115
|
-
async ([, account2]) => {
|
|
5116
|
-
assertPublicClient(publicClient);
|
|
5117
|
-
const canceller = await publicClient.readContract({
|
|
5118
|
-
abi: governanceTimelockAbi,
|
|
5119
|
-
address: chainConfig.governance.timelock,
|
|
5120
|
-
functionName: "hasRole",
|
|
5121
|
-
args: [CANCELLER_ROLE, account2]
|
|
5122
|
-
});
|
|
5123
|
-
return canceller;
|
|
5124
|
-
},
|
|
5125
|
-
{
|
|
5126
|
-
refreshInterval: 18e4 /* SLOW */,
|
|
5127
|
-
revalidateOnFocus: false
|
|
5128
|
-
}
|
|
5129
|
-
);
|
|
5130
|
-
};
|
|
5131
|
-
|
|
5132
|
-
// src/hooks/governance/usePollAllProposals.ts
|
|
5133
|
-
import { useEffect as useEffect3, useMemo as useMemo10, useState as useState3 } from "react";
|
|
5134
|
-
import useSWRInfinite from "swr/infinite";
|
|
5135
|
-
import {
|
|
5136
|
-
Proposal_OrderBy,
|
|
5137
|
-
ProposalStatus
|
|
5138
|
-
} from "@berachain/graphql/governance";
|
|
5139
|
-
var DEFAULT_PER_PAGE = 10;
|
|
5140
|
-
var fromUiStatusToSubgraphStatuses = (status) => {
|
|
5141
|
-
switch (status) {
|
|
5142
|
-
case ProposalStatus.QuorumNotReached:
|
|
5143
|
-
return [ProposalStatus.Active, ProposalStatus.Pending];
|
|
5144
|
-
case ProposalStatus.PendingQueue:
|
|
5145
|
-
case ProposalStatus.Defeated:
|
|
5146
|
-
return [ProposalStatus.Active];
|
|
5147
|
-
case ProposalStatus.PendingExecution:
|
|
5148
|
-
return [ProposalStatus.InQueue];
|
|
5149
|
-
default:
|
|
5150
|
-
return [status];
|
|
5151
|
-
}
|
|
5152
|
-
};
|
|
5153
|
-
function usePollAllProposalsQueryKey(topic, args = {}) {
|
|
5154
|
-
const subgraphPageSize = 2 * (args.perPage ?? DEFAULT_PER_PAGE);
|
|
5155
|
-
return (pageIndex, previousPageData) => {
|
|
5156
|
-
if (pageIndex !== 0 && previousPageData && previousPageData.length < subgraphPageSize) {
|
|
5157
|
-
return null;
|
|
5158
|
-
}
|
|
5159
|
-
const statuses = args.status_in?.flatMap(fromUiStatusToSubgraphStatuses).filter((s, i, arr) => arr.indexOf(s) === i);
|
|
5160
|
-
return [
|
|
5161
|
-
"usePollAllProposals",
|
|
5162
|
-
pageIndex,
|
|
5163
|
-
topic,
|
|
5164
|
-
args.where,
|
|
5165
|
-
statuses,
|
|
5166
|
-
args.orderBy,
|
|
5167
|
-
args.orderDirection,
|
|
5168
|
-
subgraphPageSize,
|
|
5169
|
-
args.text
|
|
5170
|
-
];
|
|
5171
|
-
};
|
|
5172
|
-
}
|
|
5173
|
-
function usePollAllProposals(args, options) {
|
|
5174
|
-
const autoRefreshProposals = options?.autoRefresh ?? false;
|
|
5175
|
-
const perPage = args.perPage ?? DEFAULT_PER_PAGE;
|
|
5176
|
-
const subgraphPageSize = 2 * perPage;
|
|
5177
|
-
const getKey = usePollAllProposalsQueryKey(args.topic, args);
|
|
5178
|
-
async function fetcher(key) {
|
|
5179
|
-
if (!key) return [];
|
|
5180
|
-
const [
|
|
5181
|
-
,
|
|
5182
|
-
pageIndex,
|
|
5183
|
-
topic,
|
|
5184
|
-
where,
|
|
5185
|
-
statuses,
|
|
5186
|
-
orderBy,
|
|
5187
|
-
orderDirection,
|
|
5188
|
-
pageSize,
|
|
5189
|
-
text
|
|
5190
|
-
] = key;
|
|
5191
|
-
const proposals = await getAllProposals({
|
|
5192
|
-
where: {
|
|
5193
|
-
topics_contains: [topic],
|
|
5194
|
-
status_in: statuses?.length ? statuses : void 0,
|
|
5195
|
-
...where
|
|
5196
|
-
},
|
|
5197
|
-
orderBy,
|
|
5198
|
-
orderDirection,
|
|
5199
|
-
text,
|
|
5200
|
-
perPage: pageSize,
|
|
5201
|
-
offset: pageIndex * pageSize
|
|
5202
|
-
});
|
|
5203
|
-
return (proposals ?? []).filter(Boolean);
|
|
5204
|
-
}
|
|
5205
|
-
const swr = useSWRInfinite(
|
|
5206
|
-
getKey,
|
|
5207
|
-
fetcher,
|
|
5208
|
-
{
|
|
5209
|
-
// Increase initialSize in order to prefetch more proposals at a time.
|
|
5210
|
-
initialSize: 1,
|
|
5211
|
-
refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */,
|
|
5212
|
-
...options?.opts
|
|
5213
|
-
}
|
|
5214
|
-
);
|
|
5215
|
-
const data = useMemo10(() => {
|
|
5216
|
-
if (!swr.data) return [];
|
|
5217
|
-
const flattened = swr.data.flat().filter((p) => {
|
|
5218
|
-
if (!p) return false;
|
|
5219
|
-
if (!args.status_in?.length) return true;
|
|
5220
|
-
return args.status_in.includes(p.status);
|
|
5221
|
-
}).sort((a, b) => {
|
|
5222
|
-
if (!args.text) return 0;
|
|
5223
|
-
if (args.orderBy === Proposal_OrderBy.CreatedAt) {
|
|
5224
|
-
const result = Number(b.createdAt) - Number(a.createdAt);
|
|
5225
|
-
return args.orderDirection === "asc" ? result : -result;
|
|
5226
|
-
}
|
|
5227
|
-
return 0;
|
|
5228
|
-
});
|
|
5229
|
-
const chunked = [];
|
|
5230
|
-
for (let i = 0; i < flattened.length; i += perPage) {
|
|
5231
|
-
chunked.push(flattened.slice(i, i + perPage));
|
|
5232
|
-
}
|
|
5233
|
-
return chunked;
|
|
5234
|
-
}, [swr.data, args, perPage]);
|
|
5235
|
-
const lastPage = swr.data?.[swr.data.length - 1];
|
|
5236
|
-
const hasMore = !!lastPage && lastPage.length === subgraphPageSize;
|
|
5237
|
-
const [timestamp, setTimestamp] = useState3(Date.now() / 1e3);
|
|
5238
|
-
useEffect3(() => {
|
|
5239
|
-
if (!autoRefreshProposals) return;
|
|
5240
|
-
const interval = setInterval(() => {
|
|
5241
|
-
setTimestamp(Date.now() / 1e3);
|
|
5242
|
-
}, 1e4 /* FAST */);
|
|
5243
|
-
return () => clearInterval(interval);
|
|
5244
|
-
}, [autoRefreshProposals]);
|
|
5245
|
-
useEffect3(() => {
|
|
5246
|
-
if (!swr.data) return;
|
|
5247
|
-
let shouldMutate = false;
|
|
5248
|
-
for (const proposal of swr.data.flat()) {
|
|
5249
|
-
switch (proposal.status) {
|
|
5250
|
-
case ProposalStatus.Pending:
|
|
5251
|
-
if (timestamp >= Number(proposal.voteStartAt)) {
|
|
5252
|
-
shouldMutate = true;
|
|
5253
|
-
}
|
|
5254
|
-
break;
|
|
5255
|
-
case ProposalStatus.Active:
|
|
5256
|
-
if (timestamp >= Number(proposal.voteEndAt)) {
|
|
5257
|
-
shouldMutate = true;
|
|
5258
|
-
}
|
|
5259
|
-
break;
|
|
5260
|
-
case ProposalStatus.InQueue:
|
|
5261
|
-
if (Date.now() / 1e3 + 1 >= Number(proposal.queueEnd)) {
|
|
5262
|
-
shouldMutate = true;
|
|
5263
|
-
}
|
|
5264
|
-
break;
|
|
5265
|
-
default:
|
|
5266
|
-
break;
|
|
5267
|
-
}
|
|
5268
|
-
if (shouldMutate) break;
|
|
5269
|
-
}
|
|
5270
|
-
if (shouldMutate) {
|
|
5271
|
-
swr.mutate();
|
|
5272
|
-
}
|
|
5273
|
-
}, [swr.data, timestamp]);
|
|
5274
|
-
return {
|
|
5275
|
-
...swr,
|
|
5276
|
-
data,
|
|
5277
|
-
hasMore
|
|
5278
|
-
};
|
|
5279
|
-
}
|
|
5280
|
-
|
|
5281
|
-
// src/hooks/governance/usePollProposal.ts
|
|
5282
|
-
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
5283
|
-
import useSWR24 from "swr";
|
|
5284
|
-
import {
|
|
5285
|
-
ProposalStatus as ProposalStatus2
|
|
5286
|
-
} from "@berachain/graphql/governance";
|
|
5287
|
-
import { usePublicClient as usePublicClient23 } from "@berachain/wagmi/hooks";
|
|
5288
|
-
var usePollProposal = (proposalId, options) => {
|
|
5289
|
-
const autoRefreshProposal = options?.autoRefresh ?? false;
|
|
5290
|
-
const publicClient = usePublicClient23();
|
|
5291
|
-
const QUERY_KEY = proposalId && publicClient ? ["usePollProposal", proposalId] : null;
|
|
5292
|
-
const swrResponse = useSWR24(
|
|
5293
|
-
QUERY_KEY,
|
|
5294
|
-
([, proposalId2]) => {
|
|
5295
|
-
assertPublicClient(publicClient);
|
|
5296
|
-
return getProposalDetails({ proposalId: proposalId2, client: publicClient });
|
|
5297
|
-
},
|
|
5298
|
-
{
|
|
5299
|
-
...options?.opts,
|
|
5300
|
-
refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */
|
|
5301
|
-
}
|
|
5302
|
-
);
|
|
5303
|
-
const [timestamp, setTimestamp] = useState4(Date.now());
|
|
5304
|
-
useEffect4(() => {
|
|
5305
|
-
if (!autoRefreshProposal) return;
|
|
5306
|
-
const interval = setInterval(() => {
|
|
5307
|
-
setTimestamp(Date.now() / 1e3);
|
|
5308
|
-
}, 1e4 /* FAST */);
|
|
5309
|
-
return () => clearInterval(interval);
|
|
5310
|
-
}, []);
|
|
5311
|
-
useEffect4(() => {
|
|
5312
|
-
if (swrResponse.data === void 0) return;
|
|
5313
|
-
switch (swrResponse.data.status) {
|
|
5314
|
-
case ProposalStatus2.Pending:
|
|
5315
|
-
if (timestamp >= Number(swrResponse.data.voteStartAt)) {
|
|
5316
|
-
swrResponse.mutate();
|
|
5317
|
-
}
|
|
5318
|
-
break;
|
|
5319
|
-
case ProposalStatus2.Active:
|
|
5320
|
-
if (timestamp >= Number(swrResponse.data.voteEndAt)) {
|
|
5321
|
-
swrResponse.mutate();
|
|
5322
|
-
}
|
|
5323
|
-
break;
|
|
5324
|
-
case ProposalStatus2.InQueue:
|
|
5325
|
-
if (Date.now() / 1e3 + 1 >= Number(swrResponse.data.queueEnd)) {
|
|
5326
|
-
swrResponse.mutate();
|
|
5327
|
-
}
|
|
5328
|
-
break;
|
|
5329
|
-
}
|
|
5330
|
-
}, [swrResponse.data?.status, timestamp]);
|
|
5331
|
-
return {
|
|
5332
|
-
...swrResponse,
|
|
5333
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5334
|
-
};
|
|
5335
|
-
};
|
|
5336
|
-
|
|
5337
|
-
// src/hooks/governance/usePollProposalThreshold.ts
|
|
5338
|
-
import useSWR25 from "swr";
|
|
5339
|
-
import { formatEther as formatEther5 } from "viem";
|
|
5340
|
-
import { berachainGovernanceAbi as governanceAbi3 } from "@berachain/abis/gov/berachainGovernance";
|
|
5341
|
-
import { usePublicClient as usePublicClient24 } from "@berachain/wagmi/hooks";
|
|
5342
|
-
var usePollProposalThreshold = (governorAddress) => {
|
|
5343
|
-
const publicClient = usePublicClient24();
|
|
5344
|
-
const QUERY_KEY = publicClient ? ["usePollProposalThreshold", governorAddress] : null;
|
|
5345
|
-
const swrResponse = useSWR25(
|
|
5346
|
-
QUERY_KEY,
|
|
5347
|
-
async ([, governorAddress2]) => {
|
|
5348
|
-
assertPublicClient(publicClient);
|
|
5349
|
-
const votesThreshold = await publicClient.readContract({
|
|
5350
|
-
address: governorAddress2,
|
|
5351
|
-
abi: governanceAbi3,
|
|
5352
|
-
functionName: "proposalThreshold"
|
|
5353
|
-
});
|
|
5354
|
-
return { votesThreshold: formatEther5(votesThreshold) };
|
|
5355
|
-
},
|
|
5356
|
-
{
|
|
5357
|
-
refreshInterval: 18e4 /* SLOW */
|
|
5358
|
-
}
|
|
5359
|
-
);
|
|
5360
|
-
return {
|
|
5361
|
-
...swrResponse,
|
|
5362
|
-
refresh: swrResponse.mutate
|
|
5363
|
-
};
|
|
5364
|
-
};
|
|
5365
|
-
|
|
5366
|
-
// src/hooks/governance/usePollProposalVotes.ts
|
|
5367
|
-
import useSWRInfinite2 from "swr/infinite";
|
|
5368
|
-
var DEFAULT_LIMIT = 1e3;
|
|
5369
|
-
var usePollProposalVotes = (args, total) => {
|
|
5370
|
-
return useSWRInfinite2(
|
|
5371
|
-
usePollProposalVotesQueryKey(args, total),
|
|
5372
|
-
async ([_key, page]) => {
|
|
5373
|
-
return getProposalVotes({
|
|
5374
|
-
variables: {
|
|
5375
|
-
...args,
|
|
5376
|
-
limit: DEFAULT_LIMIT,
|
|
5377
|
-
offset: DEFAULT_LIMIT * page
|
|
5378
|
-
}
|
|
5379
|
-
});
|
|
5380
|
-
},
|
|
5381
|
-
{
|
|
5382
|
-
parallel: true,
|
|
5383
|
-
// Fetches all the data at once, we limit the number of pages by providing a total
|
|
5384
|
-
initialSize: Number.POSITIVE_INFINITY
|
|
5385
|
-
}
|
|
5386
|
-
);
|
|
5387
|
-
};
|
|
5388
|
-
var usePollProposalVotesQueryKey = ({ ...args }, total) => (pageIndex) => {
|
|
5389
|
-
if (pageIndex > Math.floor(total / DEFAULT_LIMIT)) {
|
|
5390
|
-
return null;
|
|
5391
|
-
}
|
|
5392
|
-
return [
|
|
5393
|
-
"usePollProposalVotes",
|
|
5394
|
-
pageIndex,
|
|
5395
|
-
DEFAULT_LIMIT,
|
|
5396
|
-
args.proposalId,
|
|
5397
|
-
args.orderBy,
|
|
5398
|
-
args.orderDirection
|
|
5399
|
-
];
|
|
5400
|
-
};
|
|
5401
|
-
|
|
5402
|
-
// src/hooks/governance/usePollUserDelegates.ts
|
|
5403
|
-
import useSWR26 from "swr";
|
|
5404
|
-
import { formatEther as formatEther6 } from "viem";
|
|
5405
|
-
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
5406
|
-
import { useBeraWallet as useBeraWallet18, usePublicClient as usePublicClient25 } from "@berachain/wagmi/hooks";
|
|
5407
|
-
var usePollUserDelegates = (options) => {
|
|
5408
|
-
const { address: account } = useBeraWallet18();
|
|
5409
|
-
const publicClient = usePublicClient25();
|
|
5410
|
-
const QUERY_KEY = account ? ["usePollUserDelegates", account] : null;
|
|
5411
|
-
const swrResponse = useSWR26(
|
|
5412
|
-
QUERY_KEY,
|
|
5413
|
-
async ([, account2]) => {
|
|
5414
|
-
assertPublicClient(publicClient);
|
|
5415
|
-
const { config } = parseBaseArgs({
|
|
5416
|
-
chainId: publicClient.chain.id
|
|
5417
|
-
});
|
|
5418
|
-
if (!publicClient || !account2) {
|
|
5419
|
-
throw new Error("usePollUserDelegates needs publicClient and account");
|
|
5420
|
-
}
|
|
5421
|
-
const [delegate, currentVotes] = await Promise.all([
|
|
5422
|
-
publicClient.readContract({
|
|
5423
|
-
address: config.tokens.bgt,
|
|
5424
|
-
abi: bgtAbi2,
|
|
5425
|
-
functionName: "delegates",
|
|
5426
|
-
args: [account2]
|
|
5427
|
-
}),
|
|
5428
|
-
publicClient.readContract({
|
|
5429
|
-
address: config.tokens.bgt,
|
|
5430
|
-
abi: bgtAbi2,
|
|
5431
|
-
functionName: "getVotes",
|
|
5432
|
-
args: [account2]
|
|
5433
|
-
})
|
|
5434
|
-
]);
|
|
5435
|
-
return {
|
|
5436
|
-
delegate,
|
|
5437
|
-
currentVotes: formatEther6(currentVotes)
|
|
5438
|
-
};
|
|
5439
|
-
},
|
|
5440
|
-
{
|
|
5441
|
-
...options?.opts,
|
|
5442
|
-
refreshInterval: options?.opts?.refreshInterval ?? 18e4 /* SLOW */
|
|
5443
|
-
}
|
|
5444
|
-
);
|
|
5445
|
-
return {
|
|
5446
|
-
...swrResponse,
|
|
5447
|
-
refresh: () => swrResponse?.mutate?.()
|
|
5448
|
-
};
|
|
5449
|
-
};
|
|
5450
|
-
|
|
5451
|
-
// src/hooks/governance/useProposalFromTx.ts
|
|
5452
|
-
import useSWR27 from "swr";
|
|
5453
|
-
import { usePublicClient as usePublicClient26, useTransactionReceipt } from "@berachain/wagmi/hooks";
|
|
5454
|
-
var useProposalFromTx = (txHash) => {
|
|
5455
|
-
const { data: tx } = useTransactionReceipt({
|
|
5456
|
-
hash: txHash
|
|
5457
|
-
});
|
|
5458
|
-
const publicClient = usePublicClient26();
|
|
5459
|
-
const QUERY_KEY = tx && publicClient ? ["useProposalFromTx", txHash] : null;
|
|
5460
|
-
const swrResponse = useSWR27(QUERY_KEY, async ([, txHash2]) => {
|
|
5461
|
-
if (!tx) {
|
|
5462
|
-
throw new Error("Transaction not found");
|
|
5463
|
-
}
|
|
5464
|
-
if (tx.transactionHash !== txHash2) {
|
|
5465
|
-
throw new Error("Transaction hash mismatch");
|
|
5466
|
-
}
|
|
5467
|
-
return getProposalFromTx({ tx, publicClient });
|
|
5468
|
-
});
|
|
5469
|
-
return swrResponse;
|
|
5470
|
-
};
|
|
5471
|
-
|
|
5472
|
-
// src/hooks/governance/useProposalState.ts
|
|
5473
|
-
import useSWRImmutable11 from "swr/immutable";
|
|
5474
|
-
import { berachainGovernanceAbi as governanceAbi4 } from "@berachain/abis/gov/berachainGovernance";
|
|
5475
|
-
import { usePublicClient as usePublicClient27 } from "@berachain/wagmi/hooks";
|
|
5476
|
-
var ProposalStateMap = {
|
|
5477
|
-
[0 /* Pending */]: "pending",
|
|
5478
|
-
[1 /* Active */]: "active",
|
|
5479
|
-
[2 /* Canceled */]: "canceled",
|
|
5480
|
-
[3 /* Defeated */]: "defeated",
|
|
5481
|
-
[4 /* Succeeded */]: "succeeded",
|
|
5482
|
-
[5 /* Queued */]: "queued",
|
|
5483
|
-
[6 /* Expired */]: "expired",
|
|
5484
|
-
[7 /* Executed */]: "executed"
|
|
5485
|
-
};
|
|
5486
|
-
var useProposalState = ({
|
|
5487
|
-
proposalId,
|
|
5488
|
-
governorAddress
|
|
5489
|
-
}) => {
|
|
5490
|
-
const publicClient = usePublicClient27();
|
|
5491
|
-
const QUERY_KEY = governorAddress && publicClient && proposalId ? ["useProposalState", proposalId] : null;
|
|
5492
|
-
return useSWRImmutable11(QUERY_KEY, async ([, proposalId2]) => {
|
|
5493
|
-
assertPublicClient(publicClient);
|
|
5494
|
-
const snapshot = await publicClient.readContract({
|
|
5495
|
-
abi: governanceAbi4,
|
|
5496
|
-
address: governorAddress,
|
|
5497
|
-
functionName: "state",
|
|
5498
|
-
args: [BigInt(proposalId2)]
|
|
5499
|
-
});
|
|
5500
|
-
return ProposalStateMap[snapshot];
|
|
5501
|
-
});
|
|
5502
|
-
};
|
|
5503
|
-
|
|
5504
|
-
// src/hooks/governance/useProposalTimelockState.ts
|
|
5505
|
-
import useSWR28 from "swr";
|
|
5506
|
-
import { timeLockAbi as governanceTimelockAbi2 } from "@berachain/abis/gov/timeLock";
|
|
5507
|
-
import { usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5508
|
-
var TimelockOperationState = {
|
|
5509
|
-
0: "unset",
|
|
5510
|
-
1: "waiting",
|
|
5511
|
-
2: "ready",
|
|
5512
|
-
3: "done"
|
|
5513
|
-
};
|
|
5514
|
-
function useProposalTimelockState({
|
|
5515
|
-
proposalTimelockId,
|
|
5516
|
-
timelockAddress
|
|
5517
|
-
}) {
|
|
5518
|
-
const publicClient = usePublicClient28();
|
|
5519
|
-
const QUERY_KEY = timelockAddress && publicClient && proposalTimelockId ? [
|
|
5520
|
-
"useProposalTimelockState",
|
|
5521
|
-
proposalTimelockId,
|
|
5522
|
-
timelockAddress
|
|
5523
|
-
] : null;
|
|
5524
|
-
return useSWR28(
|
|
5525
|
-
QUERY_KEY,
|
|
5526
|
-
async ([, proposalTimelockId2, timelockAddress2]) => {
|
|
5527
|
-
assertPublicClient(publicClient);
|
|
5528
|
-
const snapshot = await publicClient.readContract({
|
|
5529
|
-
abi: governanceTimelockAbi2,
|
|
5530
|
-
address: timelockAddress2,
|
|
5531
|
-
functionName: "getOperationState",
|
|
5532
|
-
args: [proposalTimelockId2]
|
|
5533
|
-
});
|
|
5534
|
-
return TimelockOperationState[snapshot];
|
|
5535
|
-
},
|
|
5536
|
-
{
|
|
5537
|
-
refreshInterval: 18e4 /* SLOW */
|
|
5538
|
-
}
|
|
5539
|
-
);
|
|
5540
|
-
}
|
|
5541
|
-
|
|
5542
|
-
// src/hooks/governance/useQuorum.ts
|
|
5543
|
-
import useSWR29 from "swr";
|
|
5544
|
-
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5545
|
-
|
|
5546
|
-
// src/actions/governance/getQuorum.ts
|
|
5547
|
-
import { formatEther as formatEther7 } from "viem";
|
|
5548
|
-
import { berachainGovernanceAbi as governanceAbi5 } from "@berachain/abis/gov/berachainGovernance";
|
|
5549
|
-
async function getQuorum({
|
|
5550
|
-
at,
|
|
5551
|
-
publicClient,
|
|
5552
|
-
...args
|
|
5553
|
-
}) {
|
|
5554
|
-
const { config } = parseBaseArgs(args);
|
|
5555
|
-
assertPublicClient(publicClient);
|
|
5556
|
-
const quorum = await publicClient.readContract({
|
|
5557
|
-
address: config.governance.governor,
|
|
5558
|
-
abi: governanceAbi5,
|
|
5559
|
-
functionName: "quorum",
|
|
5560
|
-
// Needs to be pending or you'll get a ERC5805FutureLookup error when reading current quorum
|
|
5561
|
-
// this is because now will always be in the future compared to the latest block
|
|
5562
|
-
blockTag: "pending",
|
|
5563
|
-
args: [BigInt(at ?? Math.floor(Date.now() / 1e3))]
|
|
5564
|
-
});
|
|
5565
|
-
return formatEther7(quorum);
|
|
5566
|
-
}
|
|
5567
|
-
|
|
5568
|
-
// src/hooks/governance/useQuorum.ts
|
|
5569
|
-
function useQuorum({ at }, {
|
|
5570
|
-
isEnabled = true
|
|
5571
|
-
}) {
|
|
5572
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
5573
|
-
const publicClient = usePublicClient29();
|
|
5574
|
-
const QUERY_KEY = isEnabled && publicClient ? [
|
|
5575
|
-
"useQuorum",
|
|
5576
|
-
// Using Now because we cannot query quorum in the future, so no need to have different query keys.
|
|
5577
|
-
Number(at) > now ? "now" : at
|
|
5578
|
-
] : null;
|
|
5579
|
-
const response = useSWR29(QUERY_KEY, async ([, at2]) => {
|
|
5580
|
-
if (at2 === "now") {
|
|
5581
|
-
return getQuorum({ publicClient });
|
|
5582
|
-
}
|
|
5583
|
-
return getQuorum({ at: at2, publicClient });
|
|
5584
|
-
});
|
|
5585
|
-
return {
|
|
5586
|
-
...response,
|
|
5587
|
-
data: response.data ? Number(response.data) : void 0
|
|
5588
|
-
};
|
|
5589
|
-
}
|
|
5590
|
-
|
|
5591
|
-
// src/hooks/honey/useCappedGlobally.ts
|
|
5592
|
-
import useSWR31 from "swr";
|
|
5593
|
-
import { usePublicClient as usePublicClient30 } from "@berachain/wagmi/hooks";
|
|
5594
|
-
|
|
5595
|
-
// src/hooks/honey/usePythLatestPrices.ts
|
|
5596
|
-
import useSWR30 from "swr";
|
|
5597
|
-
function usePythLatestPrices({
|
|
5598
|
-
priceFeedMap
|
|
5599
|
-
}, options) {
|
|
5600
|
-
const priceFeedIds = priceFeedMap ? Object.values(priceFeedMap) : null;
|
|
5601
|
-
const QUERY_KEY = (options?.opts?.isEnabled ?? true) && priceFeedIds ? ["usePythLatestPrices", priceFeedIds] : null;
|
|
5602
|
-
const swrResponse = useSWR30(QUERY_KEY, async ([_, priceFeeds]) => {
|
|
5603
|
-
const data = await getPythLatestPrices({ priceFeedId: priceFeeds });
|
|
5604
|
-
return data;
|
|
5605
|
-
});
|
|
5606
|
-
return swrResponse;
|
|
5607
|
-
}
|
|
5608
|
-
|
|
5609
|
-
// src/hooks/honey/useCappedGlobally.ts
|
|
5610
|
-
var useCappedGlobally = ({
|
|
5611
|
-
asset,
|
|
5612
|
-
amount,
|
|
5613
|
-
isMint,
|
|
5614
|
-
isBasketModeEnabled: isBasketModeEnabled2
|
|
5615
|
-
}, options) => {
|
|
5616
|
-
const publicClient = usePublicClient30();
|
|
5617
|
-
const { priceFeedMap, flags } = useHoneyConfig();
|
|
5618
|
-
const { data: latestPrices } = usePythLatestPrices(
|
|
5619
|
-
{
|
|
5620
|
-
priceFeedMap: asset?.address && priceFeedMap ? { [asset.address]: priceFeedMap[asset.address] } : void 0
|
|
5621
|
-
},
|
|
5622
|
-
{
|
|
5623
|
-
opts: {
|
|
5624
|
-
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
4660
|
+
// src/hooks/honey/useCappedGlobally.ts
|
|
4661
|
+
var useCappedGlobally = ({
|
|
4662
|
+
asset,
|
|
4663
|
+
amount,
|
|
4664
|
+
isMint,
|
|
4665
|
+
isBasketModeEnabled: isBasketModeEnabled2
|
|
4666
|
+
}, options) => {
|
|
4667
|
+
const publicClient = usePublicClient18();
|
|
4668
|
+
const { priceFeedMap, flags } = useHoneyConfig();
|
|
4669
|
+
const { data: latestPrices } = usePythLatestPrices(
|
|
4670
|
+
{
|
|
4671
|
+
priceFeedMap: asset?.address && priceFeedMap ? { [asset.address]: priceFeedMap[asset.address] } : void 0
|
|
4672
|
+
},
|
|
4673
|
+
{
|
|
4674
|
+
opts: {
|
|
4675
|
+
isEnabled: flags.isPythWrapperEnabled && !!asset?.address
|
|
5625
4676
|
}
|
|
5626
4677
|
}
|
|
5627
4678
|
);
|
|
@@ -5633,7 +4684,7 @@ var useCappedGlobally = ({
|
|
|
5633
4684
|
flags.isPythWrapperEnabled,
|
|
5634
4685
|
isBasketModeEnabled2
|
|
5635
4686
|
] : null;
|
|
5636
|
-
const swrResponse =
|
|
4687
|
+
const swrResponse = useSWR22(
|
|
5637
4688
|
QUERY_KEY,
|
|
5638
4689
|
async ([
|
|
5639
4690
|
_,
|
|
@@ -5668,15 +4719,15 @@ var useCappedGlobally = ({
|
|
|
5668
4719
|
};
|
|
5669
4720
|
|
|
5670
4721
|
// src/hooks/honey/useCappedRelatively.ts
|
|
5671
|
-
import
|
|
5672
|
-
import { usePublicClient as
|
|
4722
|
+
import useSWR23 from "swr";
|
|
4723
|
+
import { usePublicClient as usePublicClient19 } from "@berachain/wagmi/hooks";
|
|
5673
4724
|
var useCappedRelatively = ({
|
|
5674
4725
|
asset,
|
|
5675
4726
|
amount,
|
|
5676
4727
|
isMint,
|
|
5677
4728
|
isBasketModeEnabled: isBasketModeEnabled2
|
|
5678
4729
|
}, options) => {
|
|
5679
|
-
const publicClient =
|
|
4730
|
+
const publicClient = usePublicClient19();
|
|
5680
4731
|
const { collateralList, referenceCollateral } = useHoneyConfig();
|
|
5681
4732
|
const QUERY_KEY = asset && amount ? [
|
|
5682
4733
|
"useCappedRelatively",
|
|
@@ -5685,7 +4736,7 @@ var useCappedRelatively = ({
|
|
|
5685
4736
|
collateralList,
|
|
5686
4737
|
referenceCollateral
|
|
5687
4738
|
] : null;
|
|
5688
|
-
const swrResponse =
|
|
4739
|
+
const swrResponse = useSWR23(
|
|
5689
4740
|
QUERY_KEY,
|
|
5690
4741
|
async ([_, asset2, amount2, collaterals, referenceCollateral2]) => {
|
|
5691
4742
|
if (isBasketModeEnabled2) {
|
|
@@ -5730,14 +4781,14 @@ var useCappedRelatively = ({
|
|
|
5730
4781
|
};
|
|
5731
4782
|
|
|
5732
4783
|
// src/hooks/honey/useCollateralWeights.ts
|
|
5733
|
-
import
|
|
5734
|
-
import { usePublicClient as
|
|
4784
|
+
import useSWR24 from "swr";
|
|
4785
|
+
import { usePublicClient as usePublicClient20 } from "@berachain/wagmi/hooks";
|
|
5735
4786
|
var useCollateralWeights = ({
|
|
5736
4787
|
collateralList
|
|
5737
4788
|
}, options) => {
|
|
5738
|
-
const publicClient =
|
|
4789
|
+
const publicClient = usePublicClient20();
|
|
5739
4790
|
const QUERY_KEY = publicClient && collateralList ? ["useCollateralWeights", collateralList] : void 0;
|
|
5740
|
-
const swrResponse =
|
|
4791
|
+
const swrResponse = useSWR24(
|
|
5741
4792
|
QUERY_KEY,
|
|
5742
4793
|
async ([_, collateralList2]) => {
|
|
5743
4794
|
assertPublicClient(publicClient);
|
|
@@ -5757,23 +4808,35 @@ var useCollateralWeights = ({
|
|
|
5757
4808
|
};
|
|
5758
4809
|
};
|
|
5759
4810
|
|
|
4811
|
+
// src/hooks/honey/useHoney24hVolume.ts
|
|
4812
|
+
import useSWR25 from "swr";
|
|
4813
|
+
function useHoney24hVolume() {
|
|
4814
|
+
const response = useSWR25(["useHoney24hVolume"], () => getHoney24hVolume(), {
|
|
4815
|
+
refreshInterval: 18e4 /* SLOW */
|
|
4816
|
+
});
|
|
4817
|
+
return {
|
|
4818
|
+
...response,
|
|
4819
|
+
refresh: () => response.mutate()
|
|
4820
|
+
};
|
|
4821
|
+
}
|
|
4822
|
+
|
|
5760
4823
|
// src/hooks/honey/useHoneyAlerts.ts
|
|
5761
|
-
import { useMemo as
|
|
4824
|
+
import { useMemo as useMemo10 } from "react";
|
|
5762
4825
|
|
|
5763
4826
|
// src/hooks/honey/useHoneyBalances.ts
|
|
5764
|
-
import
|
|
4827
|
+
import useSWR26 from "swr";
|
|
5765
4828
|
import {
|
|
5766
|
-
useBeraWallet as
|
|
4829
|
+
useBeraWallet as useBeraWallet16,
|
|
5767
4830
|
useConfig as useConfig5,
|
|
5768
|
-
usePublicClient as
|
|
4831
|
+
usePublicClient as usePublicClient21
|
|
5769
4832
|
} from "@berachain/wagmi/hooks";
|
|
5770
4833
|
var useHoneyBalances = () => {
|
|
5771
|
-
const publicClient =
|
|
5772
|
-
const { address: account } =
|
|
4834
|
+
const publicClient = usePublicClient21();
|
|
4835
|
+
const { address: account } = useBeraWallet16();
|
|
5773
4836
|
const { collateralList } = useHoneyConfig();
|
|
5774
4837
|
const wagmiConfig = useConfig5();
|
|
5775
4838
|
const QUERY_KEY = account && collateralList && publicClient ? ["useHoneyBalances", account, collateralList] : null;
|
|
5776
|
-
const swrResponse =
|
|
4839
|
+
const swrResponse = useSWR26(
|
|
5777
4840
|
QUERY_KEY,
|
|
5778
4841
|
async ([_, account2, collateralList2]) => {
|
|
5779
4842
|
assertPublicClient(publicClient);
|
|
@@ -5803,13 +4866,13 @@ var useHoneyBalances = () => {
|
|
|
5803
4866
|
};
|
|
5804
4867
|
|
|
5805
4868
|
// src/hooks/honey/useHoneyVaultsBalance.ts
|
|
5806
|
-
import
|
|
5807
|
-
import { usePublicClient as
|
|
4869
|
+
import useSWR27 from "swr";
|
|
4870
|
+
import { usePublicClient as usePublicClient22 } from "@berachain/wagmi/hooks";
|
|
5808
4871
|
var useHoneyVaultsBalance = (options) => {
|
|
5809
|
-
const publicClient =
|
|
4872
|
+
const publicClient = usePublicClient22();
|
|
5810
4873
|
const { collateralList } = useHoneyConfig();
|
|
5811
4874
|
const QUERY_KEY = collateralList && publicClient ? ["useHoneyVaultsBalance", collateralList] : null;
|
|
5812
|
-
const swrResponse =
|
|
4875
|
+
const swrResponse = useSWR27(
|
|
5813
4876
|
QUERY_KEY,
|
|
5814
4877
|
async ([_, collateralList2]) => {
|
|
5815
4878
|
assertPublicClient(publicClient);
|
|
@@ -5827,10 +4890,10 @@ var useHoneyVaultsBalance = (options) => {
|
|
|
5827
4890
|
};
|
|
5828
4891
|
|
|
5829
4892
|
// src/hooks/honey/useIsBadCollateralAsset.ts
|
|
5830
|
-
import
|
|
5831
|
-
import { usePublicClient as
|
|
4893
|
+
import useSWR28 from "swr";
|
|
4894
|
+
import { usePublicClient as usePublicClient23 } from "@berachain/wagmi/hooks";
|
|
5832
4895
|
var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
5833
|
-
const publicClient =
|
|
4896
|
+
const publicClient = usePublicClient23();
|
|
5834
4897
|
const { priceFeedMap, flags } = useHoneyConfig();
|
|
5835
4898
|
const { data: latestPrices } = usePythLatestPrices(
|
|
5836
4899
|
{
|
|
@@ -5850,7 +4913,7 @@ var useIsBadCollateralAsset = ({ collateral }, options) => {
|
|
|
5850
4913
|
latestPrices,
|
|
5851
4914
|
flags.isPythWrapperEnabled
|
|
5852
4915
|
] : null;
|
|
5853
|
-
const swrResponse =
|
|
4916
|
+
const swrResponse = useSWR28(
|
|
5854
4917
|
QUERY_KEY,
|
|
5855
4918
|
async ([_, collateral2, latestPrices2, isPythWrapperEnabled]) => {
|
|
5856
4919
|
assertPublicClient(publicClient);
|
|
@@ -6001,7 +5064,7 @@ var useHoneyAlerts = ({
|
|
|
6001
5064
|
const redeemedVaultBalance = vaultsBalances?.find(
|
|
6002
5065
|
(vault) => vault.address.toLowerCase() === redeemedCollateral.toLowerCase()
|
|
6003
5066
|
);
|
|
6004
|
-
const [isLiquidityDepleted, isLowLiquidity] =
|
|
5067
|
+
const [isLiquidityDepleted, isLowLiquidity] = useMemo10(() => {
|
|
6005
5068
|
const isDepleted = getIsLiquidityLowerThan({
|
|
6006
5069
|
lowerThan: 1,
|
|
6007
5070
|
vaultsBalances,
|
|
@@ -6019,7 +5082,7 @@ var useHoneyAlerts = ({
|
|
|
6019
5082
|
const {
|
|
6020
5083
|
isMore: isRedeemMoreThanLiquidity,
|
|
6021
5084
|
isRedeemMoreThanLiquidityCollaterals
|
|
6022
|
-
} =
|
|
5085
|
+
} = useMemo10(() => {
|
|
6023
5086
|
return getRedeemMoreThanLiquidity({
|
|
6024
5087
|
vaultsBalances,
|
|
6025
5088
|
redeemedVaultBalance,
|
|
@@ -6027,7 +5090,7 @@ var useHoneyAlerts = ({
|
|
|
6027
5090
|
collateralList
|
|
6028
5091
|
});
|
|
6029
5092
|
}, [vaultsBalances, redeemedVaultBalance, state, collateralList]);
|
|
6030
|
-
const isExceedingBalance =
|
|
5093
|
+
const isExceedingBalance = useMemo10(
|
|
6031
5094
|
() => getExceedingBalance({
|
|
6032
5095
|
state,
|
|
6033
5096
|
honeyBalances
|
|
@@ -6050,9 +5113,9 @@ var useHoneyAlerts = ({
|
|
|
6050
5113
|
};
|
|
6051
5114
|
|
|
6052
5115
|
// src/hooks/honey/useHoneyChartData.ts
|
|
6053
|
-
import
|
|
5116
|
+
import useSWR29 from "swr";
|
|
6054
5117
|
function useHoneyChartData({ days }) {
|
|
6055
|
-
const swrResponse =
|
|
5118
|
+
const swrResponse = useSWR29(
|
|
6056
5119
|
["useHoneyChartData", days],
|
|
6057
5120
|
async ([_, days2]) => {
|
|
6058
5121
|
return await getChartData({ days: days2 });
|
|
@@ -6064,34 +5127,16 @@ function useHoneyChartData({ days }) {
|
|
|
6064
5127
|
};
|
|
6065
5128
|
}
|
|
6066
5129
|
|
|
6067
|
-
// src/hooks/honey/useHoneyGlobalData.ts
|
|
6068
|
-
import useSWR38 from "swr";
|
|
6069
|
-
function useHoneyGlobalData() {
|
|
6070
|
-
const response = useSWR38(["useHoneyGlobalData"], () => getHoneyGlobalData());
|
|
6071
|
-
const dailyVolume = response.data?.honeySnapshots.reduce(
|
|
6072
|
-
(acc, curr) => new bignumber_js_default(curr.totalVolume).plus(acc),
|
|
6073
|
-
new bignumber_js_default(0)
|
|
6074
|
-
);
|
|
6075
|
-
return {
|
|
6076
|
-
...response,
|
|
6077
|
-
data: {
|
|
6078
|
-
...response.data,
|
|
6079
|
-
dailyVolume
|
|
6080
|
-
},
|
|
6081
|
-
refresh: () => response.mutate()
|
|
6082
|
-
};
|
|
6083
|
-
}
|
|
6084
|
-
|
|
6085
5130
|
// src/hooks/honey/useHoneySwapState.ts
|
|
6086
|
-
import { useEffect as
|
|
6087
|
-
import { formatUnits as
|
|
5131
|
+
import { useEffect as useEffect2, useReducer } from "react";
|
|
5132
|
+
import { formatUnits as formatUnits10 } from "viem";
|
|
6088
5133
|
import { defaultChainId as defaultChainId10 } from "@berachain/config/internal";
|
|
6089
5134
|
|
|
6090
5135
|
// src/hooks/honey/useIsBasketModeEnabled.ts
|
|
6091
|
-
import
|
|
6092
|
-
import { usePublicClient as
|
|
5136
|
+
import useSWR30 from "swr";
|
|
5137
|
+
import { usePublicClient as usePublicClient24 } from "@berachain/wagmi/hooks";
|
|
6093
5138
|
function useIsBasketModeEnabled({ state }, options) {
|
|
6094
|
-
const publicClient =
|
|
5139
|
+
const publicClient = usePublicClient24();
|
|
6095
5140
|
const { priceFeedMap, flags, collateralList } = useHoneyConfig();
|
|
6096
5141
|
const { data: latestPrices } = usePythLatestPrices(
|
|
6097
5142
|
{
|
|
@@ -6111,7 +5156,7 @@ function useIsBasketModeEnabled({ state }, options) {
|
|
|
6111
5156
|
flags.isPythWrapperEnabled,
|
|
6112
5157
|
collateralList
|
|
6113
5158
|
] : null;
|
|
6114
|
-
const swrResponse =
|
|
5159
|
+
const swrResponse = useSWR30(
|
|
6115
5160
|
QUERY_KEY,
|
|
6116
5161
|
async ([_, isMint2, latestPrices2, isPythWrapperEnabled, collateralList2]) => {
|
|
6117
5162
|
assertPublicClient(publicClient);
|
|
@@ -6197,13 +5242,13 @@ function reducer(state, action) {
|
|
|
6197
5242
|
return state.toAmount[idx];
|
|
6198
5243
|
}
|
|
6199
5244
|
if (preview.collaterals[coll.address]) {
|
|
6200
|
-
return
|
|
5245
|
+
return formatUnits10(preview.collaterals[coll.address], coll.decimals);
|
|
6201
5246
|
}
|
|
6202
5247
|
return state.isBasketModeEnabled ? "0" : "";
|
|
6203
5248
|
});
|
|
6204
5249
|
const honey = isToken(action.changedAsset, "HONEY", {
|
|
6205
5250
|
chainId: defaultChainId10
|
|
6206
|
-
}) ? isMint ? state.toAmount[0] : state.fromAmount[0] : !preview.honey ? state.isBasketModeEnabled ? "0" : "" :
|
|
5251
|
+
}) ? isMint ? state.toAmount[0] : state.fromAmount[0] : !preview.honey ? state.isBasketModeEnabled ? "0" : "" : formatUnits10(preview.honey, 18);
|
|
6207
5252
|
return {
|
|
6208
5253
|
...state,
|
|
6209
5254
|
fromAmount: isMint ? collateralsAmount : [honey],
|
|
@@ -6252,7 +5297,7 @@ var useHoneySwapState = () => {
|
|
|
6252
5297
|
const { data: isBasketModeEnabled2 } = useIsBasketModeEnabled({
|
|
6253
5298
|
state
|
|
6254
5299
|
});
|
|
6255
|
-
|
|
5300
|
+
useEffect2(() => {
|
|
6256
5301
|
if (isBasketModeEnabled2 !== void 0 && state.isBasketModeEnabled !== isBasketModeEnabled2) {
|
|
6257
5302
|
dispatch({
|
|
6258
5303
|
type: "IS_LOADING_CHANGE" /* IS_LOADING_CHANGE */,
|
|
@@ -6272,15 +5317,15 @@ var useHoneySwapState = () => {
|
|
|
6272
5317
|
};
|
|
6273
5318
|
|
|
6274
5319
|
// src/hooks/perps/usePythUpdateFee.ts
|
|
6275
|
-
import
|
|
6276
|
-
import { usePublicClient as
|
|
5320
|
+
import useSWRImmutable8 from "swr/immutable";
|
|
5321
|
+
import { usePublicClient as usePublicClient25 } from "@berachain/wagmi/hooks";
|
|
6277
5322
|
var usePythUpdateFee = ({
|
|
6278
5323
|
pythPriceFeedCalldata,
|
|
6279
5324
|
tokenListLength
|
|
6280
5325
|
}, options) => {
|
|
6281
|
-
const publicClient =
|
|
5326
|
+
const publicClient = usePublicClient25();
|
|
6282
5327
|
const QUERY_KEY = (options?.opts?.isEnabled ?? true) && pythPriceFeedCalldata && pythPriceFeedCalldata.length > 0 ? ["usePythUpdateFee", pythPriceFeedCalldata] : null;
|
|
6283
|
-
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } =
|
|
5328
|
+
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } = useSWRImmutable8(QUERY_KEY, async ([_, pythPriceFeedCalldata2]) => {
|
|
6284
5329
|
assertPublicClient(publicClient);
|
|
6285
5330
|
return getPythUpdateFee({
|
|
6286
5331
|
client: publicClient,
|
|
@@ -6292,12 +5337,43 @@ var usePythUpdateFee = ({
|
|
|
6292
5337
|
data,
|
|
6293
5338
|
isLoading
|
|
6294
5339
|
};
|
|
6295
|
-
};
|
|
5340
|
+
};
|
|
5341
|
+
|
|
5342
|
+
// src/hooks/pol/useAutoclaimedIncentives.ts
|
|
5343
|
+
import useSWR31 from "swr";
|
|
5344
|
+
import { useBeraWallet as useBeraWallet17 } from "@berachain/wagmi/hooks";
|
|
5345
|
+
function useAutoclaimedIncentives({
|
|
5346
|
+
enabled
|
|
5347
|
+
}) {
|
|
5348
|
+
const { address: account } = useBeraWallet17();
|
|
5349
|
+
const QUERY_KEY = enabled && account ? ["useAutoclaimedIncentives", account] : null;
|
|
5350
|
+
const swrResponse = useSWR31(
|
|
5351
|
+
QUERY_KEY,
|
|
5352
|
+
async ([, account2]) => {
|
|
5353
|
+
if (!account2) {
|
|
5354
|
+
throw new BeraError({
|
|
5355
|
+
message: "useAutoclaimedIncentives needs a logged in account",
|
|
5356
|
+
level: "error"
|
|
5357
|
+
});
|
|
5358
|
+
}
|
|
5359
|
+
return await getAutoclaimedIncentives({ account: account2 });
|
|
5360
|
+
},
|
|
5361
|
+
{
|
|
5362
|
+
revalidateOnFocus: false,
|
|
5363
|
+
revalidateOnReconnect: false,
|
|
5364
|
+
revalidateIfStale: false
|
|
5365
|
+
}
|
|
5366
|
+
);
|
|
5367
|
+
return {
|
|
5368
|
+
...swrResponse,
|
|
5369
|
+
refresh: () => swrResponse?.mutate?.()
|
|
5370
|
+
};
|
|
5371
|
+
}
|
|
6296
5372
|
|
|
6297
5373
|
// src/hooks/pol/useBgtAprSimulation.ts
|
|
6298
|
-
import { useMemo as
|
|
5374
|
+
import { useMemo as useMemo11 } from "react";
|
|
6299
5375
|
function useBgtAprSimulation(args) {
|
|
6300
|
-
return
|
|
5376
|
+
return useMemo11(() => {
|
|
6301
5377
|
if (!args) {
|
|
6302
5378
|
return void 0;
|
|
6303
5379
|
}
|
|
@@ -6306,15 +5382,15 @@ function useBgtAprSimulation(args) {
|
|
|
6306
5382
|
}
|
|
6307
5383
|
|
|
6308
5384
|
// src/hooks/pol/useBgtUnstakedBalance.ts
|
|
6309
|
-
import
|
|
6310
|
-
import { formatEther as
|
|
6311
|
-
import { bgtAbi
|
|
6312
|
-
import { useBeraWallet as
|
|
5385
|
+
import useSWR32 from "swr";
|
|
5386
|
+
import { formatEther as formatEther5 } from "viem";
|
|
5387
|
+
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5388
|
+
import { useBeraWallet as useBeraWallet18, usePublicClient as usePublicClient26 } from "@berachain/wagmi/hooks";
|
|
6313
5389
|
var useBgtUnstakedBalance = (options) => {
|
|
6314
|
-
const { address: account } =
|
|
6315
|
-
const publicClient =
|
|
5390
|
+
const { address: account } = useBeraWallet18();
|
|
5391
|
+
const publicClient = usePublicClient26();
|
|
6316
5392
|
const QUERY_KEY = account && publicClient ? ["useBgtUnstakedBalance", account] : null;
|
|
6317
|
-
const swrResponse =
|
|
5393
|
+
const swrResponse = useSWR32(
|
|
6318
5394
|
QUERY_KEY,
|
|
6319
5395
|
async ([, account2]) => {
|
|
6320
5396
|
assertPublicClient(publicClient);
|
|
@@ -6323,11 +5399,11 @@ var useBgtUnstakedBalance = (options) => {
|
|
|
6323
5399
|
});
|
|
6324
5400
|
const bgtBalance = await publicClient.readContract({
|
|
6325
5401
|
address: config.tokens.bgt,
|
|
6326
|
-
abi:
|
|
5402
|
+
abi: bgtAbi,
|
|
6327
5403
|
functionName: "unboostedBalanceOf",
|
|
6328
5404
|
args: [account2]
|
|
6329
5405
|
});
|
|
6330
|
-
return
|
|
5406
|
+
return formatEther5(bgtBalance);
|
|
6331
5407
|
},
|
|
6332
5408
|
{
|
|
6333
5409
|
...options,
|
|
@@ -6341,14 +5417,14 @@ var useBgtUnstakedBalance = (options) => {
|
|
|
6341
5417
|
};
|
|
6342
5418
|
|
|
6343
5419
|
// src/hooks/pol/useClaimableFees.ts
|
|
6344
|
-
import
|
|
6345
|
-
import { formatUnits as
|
|
6346
|
-
import { useBeraWallet as
|
|
5420
|
+
import useSWR33 from "swr";
|
|
5421
|
+
import { formatUnits as formatUnits11 } from "viem";
|
|
5422
|
+
import { useBeraWallet as useBeraWallet19, usePublicClient as usePublicClient27 } from "@berachain/wagmi/hooks";
|
|
6347
5423
|
var useClaimableFees = () => {
|
|
6348
|
-
const { address: account } =
|
|
6349
|
-
const publicClient =
|
|
5424
|
+
const { address: account } = useBeraWallet19();
|
|
5425
|
+
const publicClient = usePublicClient27();
|
|
6350
5426
|
const QUERY_KEY = account && publicClient ? ["useClaimableFees", account] : null;
|
|
6351
|
-
const swrResponse =
|
|
5427
|
+
const swrResponse = useSWR33(
|
|
6352
5428
|
QUERY_KEY,
|
|
6353
5429
|
async ([, account2]) => {
|
|
6354
5430
|
assertPublicClient(publicClient);
|
|
@@ -6360,7 +5436,7 @@ var useClaimableFees = () => {
|
|
|
6360
5436
|
vaultAddress: config.pol.staker,
|
|
6361
5437
|
publicClient
|
|
6362
5438
|
});
|
|
6363
|
-
return
|
|
5439
|
+
return formatUnits11(vaultReward, 18);
|
|
6364
5440
|
},
|
|
6365
5441
|
{
|
|
6366
5442
|
refreshInterval: 18e4 /* SLOW */ * 2
|
|
@@ -6379,8 +5455,8 @@ import {
|
|
|
6379
5455
|
} from "@berachain/graphql/pol/api";
|
|
6380
5456
|
|
|
6381
5457
|
// src/hooks/pol/useRewardVaults.ts
|
|
6382
|
-
import
|
|
6383
|
-
import { usePublicClient as
|
|
5458
|
+
import useSWR34 from "swr";
|
|
5459
|
+
import { usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
6384
5460
|
var useRewardVaultsQueryKey = (filter, onChainIncentives = false) => {
|
|
6385
5461
|
return ["useRewardVaults", filter, onChainIncentives];
|
|
6386
5462
|
};
|
|
@@ -6389,8 +5465,8 @@ var useRewardVaults = (args, options) => {
|
|
|
6389
5465
|
args.filter,
|
|
6390
5466
|
args.onChainIncentives
|
|
6391
5467
|
);
|
|
6392
|
-
const publicClient =
|
|
6393
|
-
const swrResponse =
|
|
5468
|
+
const publicClient = usePublicClient28();
|
|
5469
|
+
const swrResponse = useSWR34(
|
|
6394
5470
|
options?.opts?.isEnabled ?? true ? QUERY_KEY : null,
|
|
6395
5471
|
async ([, filter, onChainIncentives]) => {
|
|
6396
5472
|
return await getRewardVaults({
|
|
@@ -6436,11 +5512,11 @@ var useHighestVaultsAPR = (where = {}, { isEnabled = true } = {}) => {
|
|
|
6436
5512
|
};
|
|
6437
5513
|
|
|
6438
5514
|
// src/hooks/pol/usePollGlobalData.ts
|
|
6439
|
-
import
|
|
6440
|
-
import { usePublicClient as
|
|
5515
|
+
import useSWR35 from "swr";
|
|
5516
|
+
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
6441
5517
|
var usePollGlobalData = (options) => {
|
|
6442
|
-
const publicClient =
|
|
6443
|
-
const swrResponse =
|
|
5518
|
+
const publicClient = usePublicClient29();
|
|
5519
|
+
const swrResponse = useSWR35(
|
|
6444
5520
|
publicClient ? "usePollGlobalData" : null,
|
|
6445
5521
|
async () => {
|
|
6446
5522
|
assertPublicClient(publicClient);
|
|
@@ -6458,13 +5534,13 @@ var usePollGlobalData = (options) => {
|
|
|
6458
5534
|
};
|
|
6459
5535
|
|
|
6460
5536
|
// src/hooks/pol/usePollMarkets.ts
|
|
6461
|
-
import
|
|
5537
|
+
import useSWRImmutable9 from "swr/immutable";
|
|
6462
5538
|
var usePollMarketsQueryKey = () => {
|
|
6463
5539
|
return "usePollMarkets";
|
|
6464
5540
|
};
|
|
6465
5541
|
var usePollMarkets = (options) => {
|
|
6466
5542
|
const QUERY_KEY = usePollMarketsQueryKey();
|
|
6467
|
-
const swrResponse =
|
|
5543
|
+
const swrResponse = useSWRImmutable9(
|
|
6468
5544
|
QUERY_KEY,
|
|
6469
5545
|
async () => {
|
|
6470
5546
|
const res = await getMarkets();
|
|
@@ -6481,22 +5557,22 @@ var usePollMarkets = (options) => {
|
|
|
6481
5557
|
};
|
|
6482
5558
|
|
|
6483
5559
|
// src/hooks/pol/useQueuedBeraUnlock.ts
|
|
6484
|
-
import
|
|
6485
|
-
import { isAddress as
|
|
6486
|
-
import { usePublicClient as
|
|
5560
|
+
import useSWRImmutable10 from "swr/immutable";
|
|
5561
|
+
import { isAddress as isAddress9 } from "viem";
|
|
5562
|
+
import { usePublicClient as usePublicClient30 } from "@berachain/wagmi/hooks";
|
|
6487
5563
|
function useQueuedBeraUnlock({
|
|
6488
5564
|
receiptTokenAddresses,
|
|
6489
5565
|
account,
|
|
6490
5566
|
version
|
|
6491
5567
|
}, options) {
|
|
6492
|
-
const publicClient =
|
|
6493
|
-
const QUERY_KEY = receiptTokenAddresses && account && publicClient &&
|
|
5568
|
+
const publicClient = usePublicClient30();
|
|
5569
|
+
const QUERY_KEY = receiptTokenAddresses && account && publicClient && isAddress9(account) && version ? [
|
|
6494
5570
|
"useQueuedBeraUnlock",
|
|
6495
5571
|
receiptTokenAddresses,
|
|
6496
5572
|
account,
|
|
6497
5573
|
version
|
|
6498
5574
|
] : null;
|
|
6499
|
-
const swrResponse =
|
|
5575
|
+
const swrResponse = useSWRImmutable10(
|
|
6500
5576
|
QUERY_KEY,
|
|
6501
5577
|
async ([, receiptTokenAddresses2, account2, version2]) => {
|
|
6502
5578
|
assertPublicClient(publicClient);
|
|
@@ -6523,19 +5599,19 @@ function useQueuedBeraUnlock({
|
|
|
6523
5599
|
}
|
|
6524
5600
|
|
|
6525
5601
|
// src/hooks/pol/useRewardTokenToBeraRate.ts
|
|
6526
|
-
import
|
|
6527
|
-
import { isAddress as
|
|
5602
|
+
import useSWR36 from "swr";
|
|
5603
|
+
import { isAddress as isAddress10 } from "viem";
|
|
6528
5604
|
import { defaultChainId as defaultChainId11 } from "@berachain/config/internal";
|
|
6529
|
-
import { usePublicClient as
|
|
5605
|
+
import { usePublicClient as usePublicClient31 } from "@berachain/wagmi/hooks";
|
|
6530
5606
|
var useRewardTokenToBeraRate = ({
|
|
6531
5607
|
address
|
|
6532
5608
|
}, opt) => {
|
|
6533
5609
|
const QUERY_KEY = address ? ["useRewardTokenToBeraRate", address] : null;
|
|
6534
|
-
const publicClient =
|
|
6535
|
-
return
|
|
5610
|
+
const publicClient = usePublicClient31({ chainId: defaultChainId11 });
|
|
5611
|
+
return useSWR36(
|
|
6536
5612
|
QUERY_KEY,
|
|
6537
5613
|
async ([_, address2]) => {
|
|
6538
|
-
if (!address2 || !
|
|
5614
|
+
if (!address2 || !isAddress10(address2)) {
|
|
6539
5615
|
throw new InvalidArgumentError({
|
|
6540
5616
|
property: "address",
|
|
6541
5617
|
value: address2,
|
|
@@ -6555,16 +5631,16 @@ var useRewardTokenToBeraRate = ({
|
|
|
6555
5631
|
};
|
|
6556
5632
|
|
|
6557
5633
|
// src/hooks/pol/useRewardVault.ts
|
|
6558
|
-
import
|
|
5634
|
+
import useSWR38 from "swr";
|
|
6559
5635
|
|
|
6560
5636
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
6561
|
-
import
|
|
6562
|
-
import { erc20Abi as
|
|
6563
|
-
import { beraChefAbi
|
|
6564
|
-
import { usePublicClient as
|
|
5637
|
+
import useSWR37 from "swr";
|
|
5638
|
+
import { erc20Abi as erc20Abi4, formatUnits as formatUnits13, isAddress as isAddress11 } from "viem";
|
|
5639
|
+
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
5640
|
+
import { usePublicClient as usePublicClient32 } from "@berachain/wagmi/hooks";
|
|
6565
5641
|
|
|
6566
5642
|
// src/actions/pol/getStakingTokenInformation.ts
|
|
6567
|
-
import { erc20Abi as
|
|
5643
|
+
import { erc20Abi as erc20Abi3, formatUnits as formatUnits12 } from "viem";
|
|
6568
5644
|
async function getStakingTokenInformation({
|
|
6569
5645
|
address,
|
|
6570
5646
|
publicClient
|
|
@@ -6574,22 +5650,22 @@ async function getStakingTokenInformation({
|
|
|
6574
5650
|
contracts: [
|
|
6575
5651
|
{
|
|
6576
5652
|
address,
|
|
6577
|
-
abi:
|
|
5653
|
+
abi: erc20Abi3,
|
|
6578
5654
|
functionName: "decimals"
|
|
6579
5655
|
},
|
|
6580
5656
|
{
|
|
6581
5657
|
address,
|
|
6582
|
-
abi:
|
|
5658
|
+
abi: erc20Abi3,
|
|
6583
5659
|
functionName: "name"
|
|
6584
5660
|
},
|
|
6585
5661
|
{
|
|
6586
5662
|
address,
|
|
6587
|
-
abi:
|
|
5663
|
+
abi: erc20Abi3,
|
|
6588
5664
|
functionName: "symbol"
|
|
6589
5665
|
},
|
|
6590
5666
|
{
|
|
6591
5667
|
address,
|
|
6592
|
-
abi:
|
|
5668
|
+
abi: erc20Abi3,
|
|
6593
5669
|
functionName: "totalSupply"
|
|
6594
5670
|
}
|
|
6595
5671
|
],
|
|
@@ -6600,20 +5676,20 @@ async function getStakingTokenInformation({
|
|
|
6600
5676
|
decimals: decimals.result,
|
|
6601
5677
|
name: name.result,
|
|
6602
5678
|
symbol: symbol.result,
|
|
6603
|
-
totalSupply: totalSupply.result !== void 0 ? decimals.status === "success" ?
|
|
5679
|
+
totalSupply: totalSupply.result !== void 0 ? decimals.status === "success" ? formatUnits12(totalSupply.result, decimals.result) : totalSupply.result.toString() : void 0
|
|
6604
5680
|
};
|
|
6605
5681
|
return token;
|
|
6606
5682
|
}
|
|
6607
5683
|
|
|
6608
5684
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
6609
|
-
var useOnChainRewardVaultQueryKey = (address) => address &&
|
|
5685
|
+
var useOnChainRewardVaultQueryKey = (address) => address && isAddress11(address) ? ["onChainRewardVault", address.toLowerCase()] : null;
|
|
6610
5686
|
var useOnChainRewardVault = ({
|
|
6611
5687
|
address
|
|
6612
5688
|
}, opt) => {
|
|
6613
|
-
const publicClient =
|
|
5689
|
+
const publicClient = usePublicClient32();
|
|
6614
5690
|
const isEnabled = opt.opts?.isEnabled ?? true;
|
|
6615
5691
|
const QUERY_KEY = useOnChainRewardVaultQueryKey(address);
|
|
6616
|
-
return
|
|
5692
|
+
return useSWR37(isEnabled && publicClient ? QUERY_KEY : null, async ([, address2]) => {
|
|
6617
5693
|
assertPublicClient(publicClient);
|
|
6618
5694
|
const { config } = parseBaseArgs({
|
|
6619
5695
|
chainId: publicClient.chain.id
|
|
@@ -6630,13 +5706,13 @@ var useOnChainRewardVault = ({
|
|
|
6630
5706
|
}),
|
|
6631
5707
|
publicClient.readContract({
|
|
6632
5708
|
address: config.pol.beraChef,
|
|
6633
|
-
abi:
|
|
5709
|
+
abi: beraChefAbi,
|
|
6634
5710
|
functionName: "isWhitelistedVault",
|
|
6635
5711
|
args: [address2]
|
|
6636
5712
|
}),
|
|
6637
5713
|
publicClient.readContract({
|
|
6638
5714
|
address: stakingTokenAddress,
|
|
6639
|
-
abi:
|
|
5715
|
+
abi: erc20Abi4,
|
|
6640
5716
|
functionName: "balanceOf",
|
|
6641
5717
|
args: [address2]
|
|
6642
5718
|
})
|
|
@@ -6669,7 +5745,7 @@ var useOnChainRewardVault = ({
|
|
|
6669
5745
|
symbol: stakingToken.symbol ?? "",
|
|
6670
5746
|
decimals: stakingToken.decimals ?? 0
|
|
6671
5747
|
},
|
|
6672
|
-
stakingTokenAmount:
|
|
5748
|
+
stakingTokenAmount: formatUnits13(
|
|
6673
5749
|
stakingTokenAmount,
|
|
6674
5750
|
stakingToken.decimals ?? 18
|
|
6675
5751
|
),
|
|
@@ -6691,7 +5767,7 @@ var useOnChainRewardVault = ({
|
|
|
6691
5767
|
var useRewardVaultQueryKey = (address) => address ? ["useRewardVault", address.toLowerCase()] : null;
|
|
6692
5768
|
var useRewardVault = (id, options) => {
|
|
6693
5769
|
const QUERY_KEY = useRewardVaultQueryKey(id);
|
|
6694
|
-
const swrResponse =
|
|
5770
|
+
const swrResponse = useSWR38(
|
|
6695
5771
|
QUERY_KEY,
|
|
6696
5772
|
async ([_, id2]) => getRewardVault({ address: id2 }),
|
|
6697
5773
|
{
|
|
@@ -6716,15 +5792,15 @@ var useRewardVault = (id, options) => {
|
|
|
6716
5792
|
};
|
|
6717
5793
|
|
|
6718
5794
|
// src/hooks/pol/useRewardVaultIncentives.ts
|
|
6719
|
-
import
|
|
6720
|
-
import { usePublicClient as
|
|
5795
|
+
import useSWR39 from "swr";
|
|
5796
|
+
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
6721
5797
|
function useRewardVaultIncentives({
|
|
6722
5798
|
address,
|
|
6723
5799
|
stakingToken
|
|
6724
5800
|
}) {
|
|
6725
|
-
const publicClient =
|
|
5801
|
+
const publicClient = usePublicClient33();
|
|
6726
5802
|
const QUERY_KEY = publicClient && address && stakingToken ? ["useRewardVaultIncentives", address, stakingToken] : null;
|
|
6727
|
-
const swrResponse =
|
|
5803
|
+
const swrResponse = useSWR39(QUERY_KEY, async ([, address2, stakingToken2]) => {
|
|
6728
5804
|
assertPublicClient(publicClient);
|
|
6729
5805
|
return await getRewardVaultIncentives({
|
|
6730
5806
|
address: address2,
|
|
@@ -6739,12 +5815,12 @@ function useRewardVaultIncentives({
|
|
|
6739
5815
|
}
|
|
6740
5816
|
|
|
6741
5817
|
// src/hooks/pol/useRewardVaultRewards.ts
|
|
6742
|
-
import
|
|
6743
|
-
import { usePublicClient as
|
|
5818
|
+
import useSWR40 from "swr";
|
|
5819
|
+
import { usePublicClient as usePublicClient34 } from "@berachain/wagmi/hooks";
|
|
6744
5820
|
var useRewardVaultRewards = (address, options) => {
|
|
6745
|
-
const publicClient =
|
|
5821
|
+
const publicClient = usePublicClient34();
|
|
6746
5822
|
const QUERY_KEY = publicClient && address ? ["useRewardVaultRewards", address] : null;
|
|
6747
|
-
const swrResponse =
|
|
5823
|
+
const swrResponse = useSWR40(
|
|
6748
5824
|
QUERY_KEY,
|
|
6749
5825
|
async ([, address2]) => {
|
|
6750
5826
|
assertPublicClient(publicClient);
|
|
@@ -6761,7 +5837,7 @@ var useRewardVaultRewards = (address, options) => {
|
|
|
6761
5837
|
};
|
|
6762
5838
|
|
|
6763
5839
|
// src/hooks/pol/useStakedAPR.ts
|
|
6764
|
-
import
|
|
5840
|
+
import useSWR41 from "swr";
|
|
6765
5841
|
|
|
6766
5842
|
// src/utils/filter.ts
|
|
6767
5843
|
var dailyResolution = (data) => {
|
|
@@ -6790,7 +5866,7 @@ function useStakedAPR({
|
|
|
6790
5866
|
range
|
|
6791
5867
|
}) {
|
|
6792
5868
|
const QUERY_KEY = range ? ["useStakedAPR", range] : null;
|
|
6793
|
-
const swrResponse =
|
|
5869
|
+
const swrResponse = useSWR41(QUERY_KEY, async ([, range2]) => {
|
|
6794
5870
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
6795
5871
|
range: range2
|
|
6796
5872
|
});
|
|
@@ -6798,7 +5874,7 @@ function useStakedAPR({
|
|
|
6798
5874
|
unsortedStakedBeraSnapshots.sort((a, b) => a.timestamp - b.timestamp)
|
|
6799
5875
|
);
|
|
6800
5876
|
return sortedStakedBeraSnapshots.map((item) => ({
|
|
6801
|
-
|
|
5877
|
+
timestamp: item.timestamp,
|
|
6802
5878
|
apr: item.apr
|
|
6803
5879
|
}));
|
|
6804
5880
|
});
|
|
@@ -6809,23 +5885,23 @@ function useStakedAPR({
|
|
|
6809
5885
|
}
|
|
6810
5886
|
|
|
6811
5887
|
// src/hooks/pol/useStakedData.ts
|
|
6812
|
-
import { useMemo as
|
|
6813
|
-
import
|
|
6814
|
-
import { useBeraWallet as
|
|
5888
|
+
import { useMemo as useMemo12 } from "react";
|
|
5889
|
+
import useSWR42 from "swr";
|
|
5890
|
+
import { useBeraWallet as useBeraWallet20, usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
6815
5891
|
var useStakedData = (stakingConfigs) => {
|
|
6816
5892
|
const window2 = useBeraFlag("swberaAprWindow");
|
|
6817
|
-
const publicClient =
|
|
6818
|
-
const { address: account } =
|
|
6819
|
-
const receiptTokens =
|
|
5893
|
+
const publicClient = usePublicClient35();
|
|
5894
|
+
const { address: account } = useBeraWallet20();
|
|
5895
|
+
const receiptTokens = useMemo12(
|
|
6820
5896
|
() => stakingConfigs.map((config) => config.receiptToken),
|
|
6821
5897
|
[stakingConfigs]
|
|
6822
5898
|
);
|
|
6823
|
-
const inputTokens =
|
|
5899
|
+
const inputTokens = useMemo12(
|
|
6824
5900
|
() => stakingConfigs.map((config) => config.inputTokens[0]),
|
|
6825
5901
|
[stakingConfigs]
|
|
6826
5902
|
);
|
|
6827
5903
|
const aprKey = window2 ? ["useStakedData:apr", window2] : null;
|
|
6828
|
-
const { data: apr } =
|
|
5904
|
+
const { data: apr } = useSWR42(
|
|
6829
5905
|
aprKey,
|
|
6830
5906
|
async ([, window3]) => getStakedBeraAPR({ window: window3 }),
|
|
6831
5907
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
@@ -6833,7 +5909,7 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6833
5909
|
const { data: walletBalances, isLoading: isLoadingBalances } = usePollWalletBalances({ tokens: receiptTokens });
|
|
6834
5910
|
const { getTokenPrice } = useTokenPrices({ tokens: inputTokens });
|
|
6835
5911
|
const exchangeRatesKey = publicClient && receiptTokens.length > 0 ? ["useStakedData:exchangeRates", receiptTokens] : null;
|
|
6836
|
-
const { data: exchangeRates } =
|
|
5912
|
+
const { data: exchangeRates } = useSWR42(
|
|
6837
5913
|
exchangeRatesKey,
|
|
6838
5914
|
async ([, receiptTokens2]) => {
|
|
6839
5915
|
assertPublicClient(publicClient);
|
|
@@ -6848,7 +5924,7 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6848
5924
|
},
|
|
6849
5925
|
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
6850
5926
|
);
|
|
6851
|
-
const balances =
|
|
5927
|
+
const balances = useMemo12(() => {
|
|
6852
5928
|
if (!walletBalances || !exchangeRates) return void 0;
|
|
6853
5929
|
return stakingConfigs.map((config, i) => {
|
|
6854
5930
|
const inputToken = config.inputTokens[0];
|
|
@@ -6874,7 +5950,7 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6874
5950
|
data: positionsRaw,
|
|
6875
5951
|
isLoading: isLoadingPositions,
|
|
6876
5952
|
isValidating: isValidatingPositions
|
|
6877
|
-
} =
|
|
5953
|
+
} = useSWR42(
|
|
6878
5954
|
positionsKey,
|
|
6879
5955
|
async ([, account2, stakingConfigs2]) => {
|
|
6880
5956
|
assertPublicClient(publicClient);
|
|
@@ -6897,7 +5973,7 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6897
5973
|
},
|
|
6898
5974
|
{ refreshInterval: 1e4 /* FAST */ }
|
|
6899
5975
|
);
|
|
6900
|
-
const data =
|
|
5976
|
+
const data = useMemo12(() => {
|
|
6901
5977
|
if (!positionsRaw || !walletBalances) return void 0;
|
|
6902
5978
|
return stakingConfigs.map((config, i) => {
|
|
6903
5979
|
const inputToken = config.inputTokens[0];
|
|
@@ -6939,21 +6015,19 @@ var useStakedData = (stakingConfigs) => {
|
|
|
6939
6015
|
};
|
|
6940
6016
|
|
|
6941
6017
|
// src/hooks/pol/useStakedSnapshots.ts
|
|
6942
|
-
import
|
|
6018
|
+
import useSWR43 from "swr";
|
|
6943
6019
|
|
|
6944
6020
|
// src/actions/pol/getStakingDailyAssets.ts
|
|
6021
|
+
import { getUriFromLink as getUriFromLink2 } from "@berachain/config";
|
|
6945
6022
|
async function getStakingDailyAssets({
|
|
6946
6023
|
address,
|
|
6947
6024
|
range
|
|
6948
6025
|
}) {
|
|
6949
|
-
const now = /* @__PURE__ */ new Date();
|
|
6950
|
-
const startDayDate = new Date(
|
|
6951
|
-
now.getTime() - Number(range) * 24 * 60 * 60 * 1e3
|
|
6952
|
-
);
|
|
6953
6026
|
const { config } = parseBaseArgs({});
|
|
6954
|
-
const url = `${config.
|
|
6027
|
+
const url = `${getUriFromLink2(config.backend)}/vaults/${address}/stats-by-day?days=${range}`;
|
|
6955
6028
|
return beraFetchJson({
|
|
6956
6029
|
url,
|
|
6030
|
+
name: typeof config.backend === "string" ? "backend-railway" : config.backend.name,
|
|
6957
6031
|
type: "rest"
|
|
6958
6032
|
});
|
|
6959
6033
|
}
|
|
@@ -6964,7 +6038,7 @@ function useStakedSnapshots({
|
|
|
6964
6038
|
addresses
|
|
6965
6039
|
}) {
|
|
6966
6040
|
const QUERY_KEY = range ? ["useStakedSnapshots", range, addresses] : null;
|
|
6967
|
-
const swrResponse =
|
|
6041
|
+
const swrResponse = useSWR43(QUERY_KEY, async ([, range2, addresses2]) => {
|
|
6968
6042
|
const [...sortedStakingDailyAssetsArray] = await Promise.all([
|
|
6969
6043
|
...addresses2.map(async (address) => {
|
|
6970
6044
|
const unstakingDailyAssets = await getStakingDailyAssets({
|
|
@@ -6972,7 +6046,7 @@ function useStakedSnapshots({
|
|
|
6972
6046
|
range: range2
|
|
6973
6047
|
});
|
|
6974
6048
|
const sortedStakingDailyAssets = dailyResolution(
|
|
6975
|
-
unstakingDailyAssets.sort((a, b) => a.
|
|
6049
|
+
unstakingDailyAssets.sort((a, b) => a.timestamp - b.timestamp)
|
|
6976
6050
|
);
|
|
6977
6051
|
return {
|
|
6978
6052
|
[address]: sortedStakingDailyAssets
|
|
@@ -6991,13 +6065,13 @@ function useStakedSnapshots({
|
|
|
6991
6065
|
}
|
|
6992
6066
|
|
|
6993
6067
|
// src/hooks/pol/useStakingVaultsMetadata.ts
|
|
6994
|
-
import
|
|
6995
|
-
import { usePublicClient as
|
|
6068
|
+
import useSWR44 from "swr";
|
|
6069
|
+
import { usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
6996
6070
|
var useStakingVaultsMetadata = (vaults = []) => {
|
|
6997
|
-
const publicClient =
|
|
6071
|
+
const publicClient = usePublicClient36();
|
|
6998
6072
|
const blockTime = useBlockTime();
|
|
6999
6073
|
const QUERY_KEY = vaults.length > 0 && publicClient && blockTime ? ["useStakingVaultMetadata", vaults, publicClient, blockTime] : null;
|
|
7000
|
-
return
|
|
6074
|
+
return useSWR44(
|
|
7001
6075
|
QUERY_KEY,
|
|
7002
6076
|
async ([, vaults2, publicClient2, blockTime2]) => {
|
|
7003
6077
|
assertPublicClient(publicClient2);
|
|
@@ -7017,13 +6091,13 @@ var useStakingVaultsMetadata = (vaults = []) => {
|
|
|
7017
6091
|
};
|
|
7018
6092
|
|
|
7019
6093
|
// src/hooks/pol/useTotalStakedAmount.ts
|
|
7020
|
-
import
|
|
7021
|
-
import { usePublicClient as
|
|
6094
|
+
import useSWR45 from "swr";
|
|
6095
|
+
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
7022
6096
|
function useTotalStakedAmount({
|
|
7023
6097
|
vaultAddresses
|
|
7024
6098
|
}) {
|
|
7025
|
-
const publicClient =
|
|
7026
|
-
const swrResponse =
|
|
6099
|
+
const publicClient = usePublicClient37();
|
|
6100
|
+
const swrResponse = useSWR45(
|
|
7027
6101
|
vaultAddresses && publicClient ? ["useTotalStakedAmount", vaultAddresses] : null,
|
|
7028
6102
|
([, vaultAddresses2]) => {
|
|
7029
6103
|
return getTotalStakedAmount({ vaultAddresses: vaultAddresses2, publicClient });
|
|
@@ -7036,13 +6110,13 @@ function useTotalStakedAmount({
|
|
|
7036
6110
|
}
|
|
7037
6111
|
|
|
7038
6112
|
// src/hooks/pol/useUserVaultInfo.ts
|
|
7039
|
-
import
|
|
7040
|
-
import { useBeraWallet as
|
|
6113
|
+
import useSWR46 from "swr";
|
|
6114
|
+
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
7041
6115
|
var useUserVaultInfo = (args, options) => {
|
|
7042
|
-
const { address: account } =
|
|
7043
|
-
const publicClient =
|
|
6116
|
+
const { address: account } = useBeraWallet21();
|
|
6117
|
+
const publicClient = usePublicClient38();
|
|
7044
6118
|
const QUERY_KEY = account && publicClient && args.vaultAddress ? ["useUserVaultInfo", account, args.vaultAddress] : null;
|
|
7045
|
-
const swrResponse =
|
|
6119
|
+
const swrResponse = useSWR46(
|
|
7046
6120
|
QUERY_KEY,
|
|
7047
6121
|
async ([, account2, vaultAddress]) => {
|
|
7048
6122
|
assertPublicClient(publicClient);
|
|
@@ -7064,13 +6138,13 @@ var useUserVaultInfo = (args, options) => {
|
|
|
7064
6138
|
};
|
|
7065
6139
|
|
|
7066
6140
|
// src/hooks/pol/useUserVaults.ts
|
|
7067
|
-
import
|
|
7068
|
-
import { useBeraWallet as
|
|
6141
|
+
import useSWR47 from "swr";
|
|
6142
|
+
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
7069
6143
|
var useUserVaults = (options) => {
|
|
7070
|
-
const { address: account } =
|
|
7071
|
-
const publicClient =
|
|
6144
|
+
const { address: account } = useBeraWallet22();
|
|
6145
|
+
const publicClient = usePublicClient39();
|
|
7072
6146
|
const QUERY_KEY = account && publicClient ? ["useUserVaults", account] : null;
|
|
7073
|
-
const swrResponse =
|
|
6147
|
+
const swrResponse = useSWR47(
|
|
7074
6148
|
QUERY_KEY,
|
|
7075
6149
|
async ([, account2]) => {
|
|
7076
6150
|
assertPublicClient(publicClient);
|
|
@@ -7092,12 +6166,12 @@ var useUserVaults = (options) => {
|
|
|
7092
6166
|
};
|
|
7093
6167
|
|
|
7094
6168
|
// src/hooks/pol/useVaultAddress.ts
|
|
7095
|
-
import
|
|
7096
|
-
import { usePublicClient as
|
|
6169
|
+
import useSWR48 from "swr";
|
|
6170
|
+
import { usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
7097
6171
|
var useVaultAddress = (vaultAddress) => {
|
|
7098
|
-
const publicClient =
|
|
6172
|
+
const publicClient = usePublicClient40();
|
|
7099
6173
|
const QUERY_KEY = vaultAddress && publicClient ? ["useVaultAddress", vaultAddress] : null;
|
|
7100
|
-
return
|
|
6174
|
+
return useSWR48(QUERY_KEY, async ([, vaultAddress2]) => {
|
|
7101
6175
|
assertPublicClient(publicClient);
|
|
7102
6176
|
const [stakeToken] = await Promise.all([
|
|
7103
6177
|
getRewardVaultStakingToken({
|
|
@@ -7110,14 +6184,14 @@ var useVaultAddress = (vaultAddress) => {
|
|
|
7110
6184
|
};
|
|
7111
6185
|
|
|
7112
6186
|
// src/hooks/pol/useVaultHistory.ts
|
|
7113
|
-
import
|
|
6187
|
+
import useSWR49 from "swr";
|
|
7114
6188
|
var useVaultHistory = ({
|
|
7115
6189
|
vault,
|
|
7116
6190
|
range,
|
|
7117
6191
|
resolution
|
|
7118
6192
|
}) => {
|
|
7119
6193
|
const QUERY_KEY = vault ? ["useVaultHistory", vault, range, resolution] : null;
|
|
7120
|
-
const swrResponse =
|
|
6194
|
+
const swrResponse = useSWR49(
|
|
7121
6195
|
QUERY_KEY,
|
|
7122
6196
|
([, vault2, range2, resolution2]) => getVaultHistory({ vault: vault2, range: range2, resolution: resolution2 })
|
|
7123
6197
|
);
|
|
@@ -7128,10 +6202,10 @@ var useVaultHistory = ({
|
|
|
7128
6202
|
};
|
|
7129
6203
|
|
|
7130
6204
|
// src/hooks/pol/useVaultValidators.ts
|
|
7131
|
-
import
|
|
6205
|
+
import useSWR50 from "swr";
|
|
7132
6206
|
var useVaultValidators = (id, options) => {
|
|
7133
6207
|
const QUERY_KEY = id ? ["useVaultValidators", id] : null;
|
|
7134
|
-
const swrResponse =
|
|
6208
|
+
const swrResponse = useSWR50(
|
|
7135
6209
|
QUERY_KEY,
|
|
7136
6210
|
async ([, address]) => {
|
|
7137
6211
|
return await getVaultValidators({
|
|
@@ -7171,13 +6245,13 @@ function useBeraCurrentPrice(opts) {
|
|
|
7171
6245
|
}
|
|
7172
6246
|
|
|
7173
6247
|
// src/hooks/tokens/useStakingTokenInformation.ts
|
|
7174
|
-
import
|
|
7175
|
-
import { isAddress as
|
|
7176
|
-
import { usePublicClient as
|
|
6248
|
+
import useSWRImmutable11 from "swr/immutable";
|
|
6249
|
+
import { isAddress as isAddress12, zeroAddress as zeroAddress23 } from "viem";
|
|
6250
|
+
import { usePublicClient as usePublicClient41 } from "@berachain/wagmi/hooks";
|
|
7177
6251
|
var useStakingTokenInformation = (args, options) => {
|
|
7178
|
-
const publicClient =
|
|
7179
|
-
const QUERY_KEY = args?.address && publicClient &&
|
|
7180
|
-
const swrResponse =
|
|
6252
|
+
const publicClient = usePublicClient41();
|
|
6253
|
+
const QUERY_KEY = args?.address && publicClient && isAddress12(args.address) ? ["useStakingTokenInformation", args.address] : null;
|
|
6254
|
+
const swrResponse = useSWRImmutable11(
|
|
7181
6255
|
QUERY_KEY,
|
|
7182
6256
|
async ([_, address]) => {
|
|
7183
6257
|
if (isToken(address, "BERA")) {
|
|
@@ -7214,18 +6288,18 @@ function useTokenPrice({ token }, options) {
|
|
|
7214
6288
|
}
|
|
7215
6289
|
|
|
7216
6290
|
// src/hooks/tokens/useTotalSupply.ts
|
|
7217
|
-
import
|
|
7218
|
-
import { erc20Abi as
|
|
7219
|
-
import { usePublicClient as
|
|
6291
|
+
import useSWR51 from "swr";
|
|
6292
|
+
import { erc20Abi as erc20Abi5 } from "viem";
|
|
6293
|
+
import { usePublicClient as usePublicClient42 } from "@berachain/wagmi/hooks";
|
|
7220
6294
|
function useTotalSupply({ address }) {
|
|
7221
|
-
const publicClient =
|
|
7222
|
-
return
|
|
6295
|
+
const publicClient = usePublicClient42();
|
|
6296
|
+
return useSWR51(
|
|
7223
6297
|
address && publicClient ? ["useTotalSupply", address] : null,
|
|
7224
6298
|
([, address2]) => {
|
|
7225
6299
|
assertPublicClient(publicClient);
|
|
7226
6300
|
return publicClient.readContract({
|
|
7227
6301
|
address: address2,
|
|
7228
|
-
abi:
|
|
6302
|
+
abi: erc20Abi5,
|
|
7229
6303
|
functionName: "totalSupply",
|
|
7230
6304
|
args: []
|
|
7231
6305
|
});
|
|
@@ -7234,15 +6308,15 @@ function useTotalSupply({ address }) {
|
|
|
7234
6308
|
}
|
|
7235
6309
|
|
|
7236
6310
|
// src/hooks/useBlockToTimestamp.ts
|
|
7237
|
-
import
|
|
7238
|
-
import { useBlockNumber, usePublicClient as
|
|
6311
|
+
import useSWRImmutable12 from "swr/immutable";
|
|
6312
|
+
import { useBlockNumber, usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
7239
6313
|
function useBlockToTimestamp(inputBlock) {
|
|
7240
|
-
const publicClient =
|
|
6314
|
+
const publicClient = usePublicClient43();
|
|
7241
6315
|
const { config } = parseBaseArgs({ chainId: publicClient?.chain.id });
|
|
7242
6316
|
const { data: currentBlock, isLoading } = useBlockNumber({
|
|
7243
6317
|
cacheTime: seconds(config.averageBlockTime)
|
|
7244
6318
|
});
|
|
7245
|
-
const { data: block } =
|
|
6319
|
+
const { data: block } = useSWRImmutable12(
|
|
7246
6320
|
currentBlock && publicClient && Number(inputBlock) > 0 ? ["useBlockToTimestamp", inputBlock, currentBlock] : null,
|
|
7247
6321
|
async ([, inputBlock2, currentBlock2]) => {
|
|
7248
6322
|
assertPublicClient(publicClient);
|
|
@@ -7265,7 +6339,7 @@ function useBlockToTimestamp(inputBlock) {
|
|
|
7265
6339
|
}
|
|
7266
6340
|
|
|
7267
6341
|
// src/hooks/useContractWrite/useBeraContractWrite.ts
|
|
7268
|
-
import { useCallback as
|
|
6342
|
+
import { useCallback as useCallback2, useReducer as useReducer2 } from "react";
|
|
7269
6343
|
import { useBeraWagmi as useBeraWagmi3, useConfig as useConfig6 } from "@berachain/wagmi/hooks";
|
|
7270
6344
|
|
|
7271
6345
|
// src/hooks/useContractWrite/stateReducer.ts
|
|
@@ -7319,11 +6393,11 @@ function useBeraContractWrite({
|
|
|
7319
6393
|
const { account, onSmartAccountRejection } = useBeraWagmi3();
|
|
7320
6394
|
const wagmiConfig = useConfig6();
|
|
7321
6395
|
const txConfirmationTimeout = account?.wallet?.isContract ? 6e4 * 10 : 12e4;
|
|
7322
|
-
const reset =
|
|
6396
|
+
const reset = useCallback2(() => {
|
|
7323
6397
|
dispatch({ type: "confirm_reset" /* RESET */ });
|
|
7324
6398
|
}, []);
|
|
7325
6399
|
const enableSimulateCalls = useBeraFlag("enableSimulateCalls");
|
|
7326
|
-
const write =
|
|
6400
|
+
const write = useCallback2(
|
|
7327
6401
|
(writeArgs) => {
|
|
7328
6402
|
if (onlyPermissionless && !writeArgs.permissionless) {
|
|
7329
6403
|
const er = new TransactionFailedError({
|
|
@@ -7393,8 +6467,8 @@ function useBeraContractWrite({
|
|
|
7393
6467
|
var useBeraContractWrite_default = useBeraContractWrite;
|
|
7394
6468
|
|
|
7395
6469
|
// src/hooks/useGetVerifiedAbi.ts
|
|
7396
|
-
import
|
|
7397
|
-
import { isAddress as
|
|
6470
|
+
import useSWRImmutable13 from "swr/immutable";
|
|
6471
|
+
import { isAddress as isAddress13, zeroAddress as zeroAddress24 } from "viem";
|
|
7398
6472
|
import { chainId } from "@berachain/config/internal";
|
|
7399
6473
|
async function fetchVerifiedAbi(address) {
|
|
7400
6474
|
const data = await beraFetchJson({
|
|
@@ -7408,8 +6482,8 @@ async function fetchVerifiedAbi(address) {
|
|
|
7408
6482
|
return data.result;
|
|
7409
6483
|
}
|
|
7410
6484
|
var useGetVerifiedAbi = (address) => {
|
|
7411
|
-
return
|
|
7412
|
-
address &&
|
|
6485
|
+
return useSWRImmutable13(
|
|
6486
|
+
address && isAddress13(address) && // Address zero can't be a contract for sure
|
|
7413
6487
|
address !== zeroAddress24 ? ["useGetVerifiedAbi", address] : null,
|
|
7414
6488
|
() => address ? fetchVerifiedAbi(address) : Promise.resolve(""),
|
|
7415
6489
|
{}
|
|
@@ -7417,12 +6491,12 @@ var useGetVerifiedAbi = (address) => {
|
|
|
7417
6491
|
};
|
|
7418
6492
|
|
|
7419
6493
|
// src/hooks/useHistoryState.ts
|
|
7420
|
-
import { useCallback as
|
|
6494
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState2 } from "react";
|
|
7421
6495
|
function useHistoryState({
|
|
7422
6496
|
key,
|
|
7423
6497
|
defaultValue
|
|
7424
6498
|
}) {
|
|
7425
|
-
const getCurrentState =
|
|
6499
|
+
const getCurrentState = useCallback3(() => {
|
|
7426
6500
|
if (typeof window === "undefined") {
|
|
7427
6501
|
return defaultValue;
|
|
7428
6502
|
}
|
|
@@ -7430,8 +6504,8 @@ function useHistoryState({
|
|
|
7430
6504
|
const state2 = existing !== void 0 ? existing : defaultValue;
|
|
7431
6505
|
return state2;
|
|
7432
6506
|
}, [key, defaultValue]);
|
|
7433
|
-
const [state, setState] =
|
|
7434
|
-
const setHistoryState =
|
|
6507
|
+
const [state, setState] = useState2(getCurrentState());
|
|
6508
|
+
const setHistoryState = useCallback3(
|
|
7435
6509
|
(value) => {
|
|
7436
6510
|
const currentState = getCurrentState();
|
|
7437
6511
|
const newValue = value instanceof Function ? value(currentState) : value;
|
|
@@ -7442,7 +6516,7 @@ function useHistoryState({
|
|
|
7442
6516
|
},
|
|
7443
6517
|
[key, getCurrentState]
|
|
7444
6518
|
);
|
|
7445
|
-
|
|
6519
|
+
useEffect3(() => {
|
|
7446
6520
|
const existing = window.history.state?.[key];
|
|
7447
6521
|
if (existing === void 0) {
|
|
7448
6522
|
const currentState = window.history.state || {};
|
|
@@ -7454,17 +6528,17 @@ function useHistoryState({
|
|
|
7454
6528
|
}
|
|
7455
6529
|
|
|
7456
6530
|
// src/hooks/usePrevious.ts
|
|
7457
|
-
import { useEffect as
|
|
6531
|
+
import { useEffect as useEffect4, useRef } from "react";
|
|
7458
6532
|
function usePrevious(value) {
|
|
7459
6533
|
const ref = useRef(void 0);
|
|
7460
|
-
|
|
6534
|
+
useEffect4(() => {
|
|
7461
6535
|
ref.current = value;
|
|
7462
6536
|
});
|
|
7463
6537
|
return ref.current;
|
|
7464
6538
|
}
|
|
7465
6539
|
|
|
7466
6540
|
// src/hooks/validators/useAllValidators.ts
|
|
7467
|
-
import
|
|
6541
|
+
import useSWR52 from "swr";
|
|
7468
6542
|
var useAllValidatorsQueryKey = ({
|
|
7469
6543
|
variables
|
|
7470
6544
|
} = {}) => {
|
|
@@ -7472,7 +6546,7 @@ var useAllValidatorsQueryKey = ({
|
|
|
7472
6546
|
};
|
|
7473
6547
|
var useAllValidators = (variables, options) => {
|
|
7474
6548
|
const { config } = parseBaseArgs(variables);
|
|
7475
|
-
const swrResponse =
|
|
6549
|
+
const swrResponse = useSWR52(
|
|
7476
6550
|
useAllValidatorsQueryKey({ variables }),
|
|
7477
6551
|
async ([, variables2]) => {
|
|
7478
6552
|
const result = await getAllValidators({
|
|
@@ -7495,11 +6569,11 @@ var useAllValidators = (variables, options) => {
|
|
|
7495
6569
|
};
|
|
7496
6570
|
|
|
7497
6571
|
// src/hooks/validators/useApiEnrichedAllocation.ts
|
|
7498
|
-
import
|
|
6572
|
+
import useSWR53 from "swr";
|
|
7499
6573
|
function useApiEnrichedAllocation({
|
|
7500
6574
|
allocation
|
|
7501
6575
|
}) {
|
|
7502
|
-
return
|
|
6576
|
+
return useSWR53(
|
|
7503
6577
|
allocation ? ["useApiEnrichedAllocation", allocation] : null,
|
|
7504
6578
|
([, allocation2]) => {
|
|
7505
6579
|
return getApiEnrichedAllocation({ allocation: allocation2 });
|
|
@@ -7508,13 +6582,13 @@ function useApiEnrichedAllocation({
|
|
|
7508
6582
|
}
|
|
7509
6583
|
|
|
7510
6584
|
// src/hooks/validators/useApiValidator.ts
|
|
7511
|
-
import
|
|
6585
|
+
import useSWR54 from "swr";
|
|
7512
6586
|
import { isHex } from "viem";
|
|
7513
6587
|
var useApiValidatorQueryKey = (id) => id ? ["useApiValidator", id] : null;
|
|
7514
6588
|
var useApiValidator = (id, options) => {
|
|
7515
6589
|
const QUERY_KEY = useApiValidatorQueryKey(id);
|
|
7516
6590
|
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
7517
|
-
const swrResponse =
|
|
6591
|
+
const swrResponse = useSWR54(
|
|
7518
6592
|
isEnabled && id ? QUERY_KEY : null,
|
|
7519
6593
|
async ([, id2]) => {
|
|
7520
6594
|
if (!id2 || !isHex(id2)) throw new Error(`Invalid validator ID: ${id2}`);
|
|
@@ -7531,8 +6605,8 @@ var useApiValidator = (id, options) => {
|
|
|
7531
6605
|
};
|
|
7532
6606
|
|
|
7533
6607
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
7534
|
-
import
|
|
7535
|
-
import { usePublicClient as
|
|
6608
|
+
import useSWR55 from "swr";
|
|
6609
|
+
import { usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
7536
6610
|
|
|
7537
6611
|
// src/actions/validators/getBaselineRewardAllocation.ts
|
|
7538
6612
|
import { rewardAllocatorFactoryAbi as rewardAllocationFactoryAbi } from "@berachain/abis/pol/rewards/rewardAllocatorFactory";
|
|
@@ -7554,8 +6628,8 @@ async function getBaselineRewardAllocation({
|
|
|
7554
6628
|
|
|
7555
6629
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
7556
6630
|
function useBaselineRewardAllocation() {
|
|
7557
|
-
const publicClient =
|
|
7558
|
-
return
|
|
6631
|
+
const publicClient = usePublicClient44();
|
|
6632
|
+
return useSWR55(publicClient ? ["baselineRewardAllocation"] : null, () => {
|
|
7559
6633
|
assertPublicClient(publicClient);
|
|
7560
6634
|
return getBaselineRewardAllocation({
|
|
7561
6635
|
publicClient
|
|
@@ -7564,13 +6638,13 @@ function useBaselineRewardAllocation() {
|
|
|
7564
6638
|
}
|
|
7565
6639
|
|
|
7566
6640
|
// src/hooks/validators/useDailyValidatorBlockStats.ts
|
|
7567
|
-
import
|
|
6641
|
+
import useSWR56 from "swr";
|
|
7568
6642
|
var useDailyValidatorBlockStats = ({
|
|
7569
6643
|
pubKey,
|
|
7570
6644
|
first = 1
|
|
7571
6645
|
}) => {
|
|
7572
6646
|
const QUERY_KEY = pubKey ? ["useDailyValidatorBlockStats", pubKey, first] : null;
|
|
7573
|
-
const swrResponse =
|
|
6647
|
+
const swrResponse = useSWR56(
|
|
7574
6648
|
QUERY_KEY,
|
|
7575
6649
|
async ([, pubKey2, first2]) => {
|
|
7576
6650
|
return await getDailyValidatorBlockStats({
|
|
@@ -7586,12 +6660,12 @@ var useDailyValidatorBlockStats = ({
|
|
|
7586
6660
|
};
|
|
7587
6661
|
|
|
7588
6662
|
// src/hooks/validators/useDefaultRewardAllocation.ts
|
|
7589
|
-
import
|
|
7590
|
-
import { usePublicClient as
|
|
6663
|
+
import useSWR57 from "swr";
|
|
6664
|
+
import { usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
7591
6665
|
function useDefaultRewardAllocation(options) {
|
|
7592
|
-
const publicClient =
|
|
6666
|
+
const publicClient = usePublicClient45();
|
|
7593
6667
|
const QUERY_KEY = publicClient ? ["useDefaultRewardAllocation"] : null;
|
|
7594
|
-
const swrResponse =
|
|
6668
|
+
const swrResponse = useSWR57(
|
|
7595
6669
|
QUERY_KEY,
|
|
7596
6670
|
async () => {
|
|
7597
6671
|
assertPublicClient(publicClient);
|
|
@@ -7610,13 +6684,13 @@ function useDefaultRewardAllocation(options) {
|
|
|
7610
6684
|
}
|
|
7611
6685
|
|
|
7612
6686
|
// src/hooks/validators/useManagedValidatorRole.ts
|
|
7613
|
-
import { useMemo as
|
|
7614
|
-
import
|
|
7615
|
-
import { useBeraWallet as
|
|
6687
|
+
import { useMemo as useMemo13 } from "react";
|
|
6688
|
+
import useSWR58 from "swr";
|
|
6689
|
+
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
7616
6690
|
|
|
7617
6691
|
// src/actions/validators/getValidatorRewardAllocatorAddress.ts
|
|
7618
6692
|
import { zeroAddress as zeroAddress25 } from "viem";
|
|
7619
|
-
import { beraChefAbi as
|
|
6693
|
+
import { beraChefAbi as beraChefAbi2 } from "@berachain/abis/pol/rewards/beraChef";
|
|
7620
6694
|
async function getValidatorRewardAllocatorAddress({
|
|
7621
6695
|
client,
|
|
7622
6696
|
pubKey,
|
|
@@ -7626,7 +6700,7 @@ async function getValidatorRewardAllocatorAddress({
|
|
|
7626
6700
|
try {
|
|
7627
6701
|
const result = await client.readContract({
|
|
7628
6702
|
address: config.pol.beraChef,
|
|
7629
|
-
abi:
|
|
6703
|
+
abi: beraChefAbi2,
|
|
7630
6704
|
functionName: "valRewardAllocator",
|
|
7631
6705
|
args: [pubKey]
|
|
7632
6706
|
});
|
|
@@ -7659,15 +6733,15 @@ function useManagedValidatorRole({
|
|
|
7659
6733
|
pubKey,
|
|
7660
6734
|
account: accountAddress
|
|
7661
6735
|
}, options) {
|
|
7662
|
-
const publicClient =
|
|
6736
|
+
const publicClient = usePublicClient46();
|
|
7663
6737
|
const mockValidatorOperator = useBeraFlag("mockValidatorOperator");
|
|
7664
6738
|
const mockValidatorRewardAllocator = useBeraFlag(
|
|
7665
6739
|
"mockValidatorRewardAllocator"
|
|
7666
6740
|
);
|
|
7667
6741
|
const QUERY_KEY = publicClient && pubKey ? ["useManagedValidatorRole", pubKey] : null;
|
|
7668
|
-
const { address: connectedAccount } =
|
|
6742
|
+
const { address: connectedAccount } = useBeraWallet23();
|
|
7669
6743
|
const account = accountAddress ?? connectedAccount;
|
|
7670
|
-
const swrResponse =
|
|
6744
|
+
const swrResponse = useSWR58(
|
|
7671
6745
|
QUERY_KEY,
|
|
7672
6746
|
async ([, pubKey2]) => {
|
|
7673
6747
|
assertPublicClient(publicClient);
|
|
@@ -7690,10 +6764,10 @@ function useManagedValidatorRole({
|
|
|
7690
6764
|
...options?.opts
|
|
7691
6765
|
}
|
|
7692
6766
|
);
|
|
7693
|
-
const hasOperatorRole =
|
|
6767
|
+
const hasOperatorRole = useMemo13(() => {
|
|
7694
6768
|
return mockValidatorOperator || isOperator(account, swrResponse.data);
|
|
7695
6769
|
}, [account, mockValidatorOperator, swrResponse.data]);
|
|
7696
|
-
const hasRewardAllocatorRole =
|
|
6770
|
+
const hasRewardAllocatorRole = useMemo13(() => {
|
|
7697
6771
|
return mockValidatorRewardAllocator || isRewardAllocator(account, swrResponse.data);
|
|
7698
6772
|
}, [account, mockValidatorRewardAllocator, swrResponse.data]);
|
|
7699
6773
|
return {
|
|
@@ -7708,17 +6782,17 @@ function useManagedValidatorRole({
|
|
|
7708
6782
|
}
|
|
7709
6783
|
|
|
7710
6784
|
// src/hooks/validators/useOnChainValidator.ts
|
|
7711
|
-
import
|
|
6785
|
+
import useSWR59 from "swr";
|
|
7712
6786
|
import { keccak256 as keccak2562 } from "viem";
|
|
7713
6787
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
7714
|
-
import { bgtAbi as
|
|
7715
|
-
import { beraChefAbi as
|
|
7716
|
-
import { usePublicClient as
|
|
6788
|
+
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
6789
|
+
import { beraChefAbi as beraChefAbi3 } from "@berachain/abis/pol/rewards/beraChef";
|
|
6790
|
+
import { usePublicClient as usePublicClient47 } from "@berachain/wagmi/hooks";
|
|
7717
6791
|
var useOnChainValidator = ({ pubkey }, options) => {
|
|
7718
|
-
const publicClient =
|
|
6792
|
+
const publicClient = usePublicClient47();
|
|
7719
6793
|
const QUERY_KEY = pubkey ? ["useOnChainValidator", pubkey] : null;
|
|
7720
6794
|
const isEnabled = options.opts?.isEnabled ?? true;
|
|
7721
|
-
const swrResponse =
|
|
6795
|
+
const swrResponse = useSWR59(
|
|
7722
6796
|
isEnabled && publicClient ? QUERY_KEY : null,
|
|
7723
6797
|
async ([, pubkey2]) => {
|
|
7724
6798
|
assertPublicClient(publicClient);
|
|
@@ -7734,13 +6808,13 @@ var useOnChainValidator = ({ pubkey }, options) => {
|
|
|
7734
6808
|
}),
|
|
7735
6809
|
publicClient?.readContract({
|
|
7736
6810
|
address: config.tokens.bgt,
|
|
7737
|
-
abi:
|
|
6811
|
+
abi: bgtAbi2,
|
|
7738
6812
|
functionName: "boostees",
|
|
7739
6813
|
args: [pubkey2]
|
|
7740
6814
|
}),
|
|
7741
6815
|
publicClient.readContract({
|
|
7742
6816
|
address: config.pol.beraChef,
|
|
7743
|
-
abi:
|
|
6817
|
+
abi: beraChefAbi3,
|
|
7744
6818
|
functionName: "getActiveRewardAllocation",
|
|
7745
6819
|
args: [pubkey2]
|
|
7746
6820
|
})
|
|
@@ -7762,16 +6836,16 @@ var useOnChainValidator = ({ pubkey }, options) => {
|
|
|
7762
6836
|
};
|
|
7763
6837
|
|
|
7764
6838
|
// src/hooks/validators/useStakingPoolBatch.ts
|
|
7765
|
-
import
|
|
7766
|
-
import { usePublicClient as
|
|
6839
|
+
import useSWR60 from "swr";
|
|
6840
|
+
import { usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
7767
6841
|
var useStakingPoolBatch = ({
|
|
7768
6842
|
valPubKey,
|
|
7769
6843
|
options
|
|
7770
6844
|
}) => {
|
|
7771
|
-
const publicClient =
|
|
6845
|
+
const publicClient = usePublicClient48();
|
|
7772
6846
|
const isEnabled = options?.opts?.isEnabled ?? true;
|
|
7773
6847
|
const QUERY_KEY = isEnabled && publicClient && valPubKey ? ["useStakingPoolBatch", valPubKey] : null;
|
|
7774
|
-
const swrResponse =
|
|
6848
|
+
const swrResponse = useSWR60(
|
|
7775
6849
|
QUERY_KEY,
|
|
7776
6850
|
async ([, valPubKey2]) => {
|
|
7777
6851
|
assertPublicClient(publicClient);
|
|
@@ -7792,13 +6866,13 @@ var useStakingPoolBatch = ({
|
|
|
7792
6866
|
};
|
|
7793
6867
|
|
|
7794
6868
|
// src/hooks/validators/useUserActiveValidators.ts
|
|
7795
|
-
import
|
|
7796
|
-
import { useBeraWallet as
|
|
6869
|
+
import useSWR61 from "swr";
|
|
6870
|
+
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
7797
6871
|
var useUserActiveValidators = (options) => {
|
|
7798
|
-
const { address: account } =
|
|
7799
|
-
const publicClient =
|
|
6872
|
+
const { address: account } = useBeraWallet24();
|
|
6873
|
+
const publicClient = usePublicClient49();
|
|
7800
6874
|
const QUERY_KEY = publicClient && account ? ["useUserActiveValidators", account] : null;
|
|
7801
|
-
const swrResponse =
|
|
6875
|
+
const swrResponse = useSWR61(
|
|
7802
6876
|
QUERY_KEY,
|
|
7803
6877
|
async ([, account2]) => {
|
|
7804
6878
|
return await getUserActiveValidators({
|
|
@@ -7819,17 +6893,17 @@ var useUserActiveValidators = (options) => {
|
|
|
7819
6893
|
};
|
|
7820
6894
|
|
|
7821
6895
|
// src/hooks/validators/useUserBoostsOnValidator.ts
|
|
7822
|
-
import
|
|
7823
|
-
import { useBeraWallet as
|
|
6896
|
+
import useSWR62 from "swr";
|
|
6897
|
+
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
7824
6898
|
var useUserBoostsOnValidator = ({
|
|
7825
6899
|
pubkey,
|
|
7826
6900
|
...args
|
|
7827
6901
|
}) => {
|
|
7828
|
-
const { address: connectedAccount } =
|
|
7829
|
-
const publicClient =
|
|
6902
|
+
const { address: connectedAccount } = useBeraWallet25();
|
|
6903
|
+
const publicClient = usePublicClient50();
|
|
7830
6904
|
const account = args.account ?? connectedAccount;
|
|
7831
6905
|
const QUERY_KEY = account && pubkey ? ["useUserBoostsOnValidator", pubkey, account] : null;
|
|
7832
|
-
const swrResponse =
|
|
6906
|
+
const swrResponse = useSWR62(
|
|
7833
6907
|
QUERY_KEY,
|
|
7834
6908
|
async ([, pubkey2, account2]) => {
|
|
7835
6909
|
return await getUserBoostsOnValidator({
|
|
@@ -7846,9 +6920,9 @@ var useUserBoostsOnValidator = ({
|
|
|
7846
6920
|
};
|
|
7847
6921
|
|
|
7848
6922
|
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
7849
|
-
import { useCallback as
|
|
7850
|
-
import
|
|
7851
|
-
import { useBeraWallet as
|
|
6923
|
+
import { useCallback as useCallback4, useMemo as useMemo14 } from "react";
|
|
6924
|
+
import useSWR63 from "swr";
|
|
6925
|
+
import { useBeraWallet as useBeraWallet26 } from "@berachain/wagmi/hooks";
|
|
7852
6926
|
|
|
7853
6927
|
// src/utils/formatIncentivesTokenMap.ts
|
|
7854
6928
|
var formatIncentivesTokenMap = (allRewards) => {
|
|
@@ -7867,9 +6941,9 @@ var formatIncentivesTokenMap = (allRewards) => {
|
|
|
7867
6941
|
|
|
7868
6942
|
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
7869
6943
|
var useUserClaimableIncentives = () => {
|
|
7870
|
-
const { address: account } =
|
|
6944
|
+
const { address: account } = useBeraWallet26();
|
|
7871
6945
|
const REWARDS_QUERY_KEY = account ? ["useUserClaimableIncentives", account] : null;
|
|
7872
|
-
const allRewardsResponse =
|
|
6946
|
+
const allRewardsResponse = useSWR63(
|
|
7873
6947
|
REWARDS_QUERY_KEY,
|
|
7874
6948
|
async ([, account2]) => {
|
|
7875
6949
|
if (!account2) {
|
|
@@ -7890,7 +6964,7 @@ var useUserClaimableIncentives = () => {
|
|
|
7890
6964
|
}
|
|
7891
6965
|
);
|
|
7892
6966
|
const allRewards = allRewardsResponse?.data;
|
|
7893
|
-
const tokenMap =
|
|
6967
|
+
const tokenMap = useMemo14(() => {
|
|
7894
6968
|
if (!allRewards) {
|
|
7895
6969
|
return void 0;
|
|
7896
6970
|
}
|
|
@@ -7910,7 +6984,7 @@ var useUserClaimableIncentives = () => {
|
|
|
7910
6984
|
return formatIncentivesTokenMap(allRewards);
|
|
7911
6985
|
}, [allRewards, account]);
|
|
7912
6986
|
const QUERY_KEY = account && allRewards ? ["useUserClaimableIncentives", account, allRewards] : null;
|
|
7913
|
-
const swrResponse =
|
|
6987
|
+
const swrResponse = useSWR63(
|
|
7914
6988
|
QUERY_KEY,
|
|
7915
6989
|
async ([, account2, allRewards2]) => {
|
|
7916
6990
|
if (!account2) {
|
|
@@ -7956,7 +7030,7 @@ var useUserClaimableIncentives = () => {
|
|
|
7956
7030
|
refreshInterval: 18e4 /* SLOW */
|
|
7957
7031
|
}
|
|
7958
7032
|
);
|
|
7959
|
-
const refresh =
|
|
7033
|
+
const refresh = useCallback4(() => {
|
|
7960
7034
|
allRewardsResponse?.mutate();
|
|
7961
7035
|
swrResponse?.mutate();
|
|
7962
7036
|
}, [allRewardsResponse, swrResponse]);
|
|
@@ -7969,13 +7043,13 @@ var useUserClaimableIncentives = () => {
|
|
|
7969
7043
|
};
|
|
7970
7044
|
|
|
7971
7045
|
// src/hooks/validators/useUserStakingPositions.ts
|
|
7972
|
-
import
|
|
7046
|
+
import useSWRImmutable14 from "swr/immutable";
|
|
7973
7047
|
var useUserStakingPositions = ({
|
|
7974
7048
|
account,
|
|
7975
7049
|
validatorAddress
|
|
7976
7050
|
}) => {
|
|
7977
7051
|
const queryClient = account ? ["useUserStakingPositions", account, validatorAddress] : null;
|
|
7978
|
-
const swrResponse =
|
|
7052
|
+
const swrResponse = useSWRImmutable14(
|
|
7979
7053
|
queryClient,
|
|
7980
7054
|
async ([_, account2, validatorAddress2]) => {
|
|
7981
7055
|
const userStakingPolls = await getUserStakingPositions(account2);
|
|
@@ -8024,6 +7098,7 @@ function useValidator({ pubkey }, options) {
|
|
|
8024
7098
|
rewardRate: onChainValidator?.dynamicData?.rewardRate ?? indexerValidator?.dynamicData?.rewardRate ?? "",
|
|
8025
7099
|
stakedBeraAmount: indexerValidator?.dynamicData?.stakedBeraAmount ?? "",
|
|
8026
7100
|
lastDayDistributedBGTAmount: indexerValidator?.dynamicData?.lastDayDistributedBGTAmount ?? "",
|
|
7101
|
+
lastDayProposedBlockCount: indexerValidator?.dynamicData?.lastDayProposedBlockCount ?? 0,
|
|
8027
7102
|
activeBoostAmountRank: indexerValidator?.dynamicData?.activeBoostAmountRank ?? 0,
|
|
8028
7103
|
boostApr: indexerValidator?.dynamicData?.boostApr ?? // todo: remove 'as' once BE has migrated types
|
|
8029
7104
|
0,
|
|
@@ -8041,13 +7116,13 @@ function useValidator({ pubkey }, options) {
|
|
|
8041
7116
|
}
|
|
8042
7117
|
|
|
8043
7118
|
// src/hooks/validators/useValidatorAnalytics.ts
|
|
8044
|
-
import
|
|
7119
|
+
import useSWR64 from "swr";
|
|
8045
7120
|
function useValidatorAnalytics({
|
|
8046
7121
|
pubkey,
|
|
8047
7122
|
dayRange
|
|
8048
7123
|
}) {
|
|
8049
7124
|
const QUERY_KEY = pubkey && dayRange ? ["useValidatorAnalytics", pubkey, dayRange] : null;
|
|
8050
|
-
const swrResponse =
|
|
7125
|
+
const swrResponse = useSWR64(
|
|
8051
7126
|
QUERY_KEY,
|
|
8052
7127
|
async ([, pubkey2, dayRange2]) => {
|
|
8053
7128
|
return await getValidatorAnalytics({
|
|
@@ -8063,12 +7138,12 @@ function useValidatorAnalytics({
|
|
|
8063
7138
|
}
|
|
8064
7139
|
|
|
8065
7140
|
// src/hooks/validators/useValidatorCommission.ts
|
|
8066
|
-
import
|
|
8067
|
-
import { usePublicClient as
|
|
7141
|
+
import useSWR65 from "swr";
|
|
7142
|
+
import { usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
8068
7143
|
var useValidatorCommission = (pubKey, options) => {
|
|
8069
|
-
const publicClient =
|
|
7144
|
+
const publicClient = usePublicClient51();
|
|
8070
7145
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorCommission", pubKey] : null;
|
|
8071
|
-
const swrResponse =
|
|
7146
|
+
const swrResponse = useSWR65(
|
|
8072
7147
|
QUERY_KEY,
|
|
8073
7148
|
async ([, pubKey2]) => {
|
|
8074
7149
|
return await getValidatorCommission({
|
|
@@ -8100,13 +7175,56 @@ var useValidatorEstimatedBgtPerYear = (validator) => {
|
|
|
8100
7175
|
};
|
|
8101
7176
|
};
|
|
8102
7177
|
|
|
7178
|
+
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
7179
|
+
import useSWR66 from "swr";
|
|
7180
|
+
|
|
7181
|
+
// src/actions/validators/getValidatorIncentiveDistribution.ts
|
|
7182
|
+
async function getValidatorIncentiveDistribution({
|
|
7183
|
+
pubkey,
|
|
7184
|
+
dayRange
|
|
7185
|
+
}) {
|
|
7186
|
+
if (typeof window === "undefined") {
|
|
7187
|
+
throw new BeraError({
|
|
7188
|
+
message: "getValidatorIncentiveDistribution is browser-only; call from a Client Component / SWR hook",
|
|
7189
|
+
level: "error"
|
|
7190
|
+
});
|
|
7191
|
+
}
|
|
7192
|
+
const params = new URLSearchParams({
|
|
7193
|
+
pubkey,
|
|
7194
|
+
dayRange: String(dayRange)
|
|
7195
|
+
});
|
|
7196
|
+
return beraFetchJson({
|
|
7197
|
+
url: `/api/pol/validator-incentive-distribution?${params}`,
|
|
7198
|
+
name: "pol-validator-incentive-distribution",
|
|
7199
|
+
type: "rest"
|
|
7200
|
+
});
|
|
7201
|
+
}
|
|
7202
|
+
|
|
7203
|
+
// src/hooks/validators/useValidatorIncentiveDistribution.ts
|
|
7204
|
+
function useValidatorIncentiveDistribution({
|
|
7205
|
+
pubkey,
|
|
7206
|
+
dayRange
|
|
7207
|
+
}) {
|
|
7208
|
+
const QUERY_KEY = pubkey && dayRange ? ["useValidatorIncentiveDistribution", pubkey, dayRange] : null;
|
|
7209
|
+
const swrResponse = useSWR66(
|
|
7210
|
+
QUERY_KEY,
|
|
7211
|
+
async ([, pubkey2, dayRange2]) => {
|
|
7212
|
+
return await getValidatorIncentiveDistribution({ pubkey: pubkey2, dayRange: dayRange2 });
|
|
7213
|
+
},
|
|
7214
|
+
{
|
|
7215
|
+
refreshInterval: 18e4 /* SLOW */
|
|
7216
|
+
}
|
|
7217
|
+
);
|
|
7218
|
+
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
7219
|
+
}
|
|
7220
|
+
|
|
8103
7221
|
// src/hooks/validators/useValidatorQueuedCommission.ts
|
|
8104
|
-
import
|
|
8105
|
-
import { usePublicClient as
|
|
7222
|
+
import useSWR67 from "swr";
|
|
7223
|
+
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
8106
7224
|
function useValidatorQueuedCommission(pubKey, options) {
|
|
8107
|
-
const publicClient =
|
|
7225
|
+
const publicClient = usePublicClient52();
|
|
8108
7226
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedCommission", pubKey] : null;
|
|
8109
|
-
const swrResponse =
|
|
7227
|
+
const swrResponse = useSWR67(
|
|
8110
7228
|
QUERY_KEY,
|
|
8111
7229
|
async ([, pubKey2]) => {
|
|
8112
7230
|
assertPublicClient(publicClient);
|
|
@@ -8126,12 +7244,12 @@ function useValidatorQueuedCommission(pubKey, options) {
|
|
|
8126
7244
|
}
|
|
8127
7245
|
|
|
8128
7246
|
// src/hooks/validators/useValidatorQueuedOperatorAddress.ts
|
|
8129
|
-
import
|
|
8130
|
-
import { usePublicClient as
|
|
7247
|
+
import useSWR68 from "swr";
|
|
7248
|
+
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
8131
7249
|
var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
8132
|
-
const publicClient =
|
|
7250
|
+
const publicClient = usePublicClient53();
|
|
8133
7251
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedOperatorAddress", pubKey] : null;
|
|
8134
|
-
const swrResponse =
|
|
7252
|
+
const swrResponse = useSWR68(
|
|
8135
7253
|
QUERY_KEY,
|
|
8136
7254
|
async ([, pubKey2]) => {
|
|
8137
7255
|
return await getValidatorQueuedOperatorAddress({
|
|
@@ -8150,12 +7268,12 @@ var useValidatorQueuedOperatorAddress = (pubKey, options) => {
|
|
|
8150
7268
|
};
|
|
8151
7269
|
|
|
8152
7270
|
// src/hooks/validators/useValidatorQueuedRewardAllocation.ts
|
|
8153
|
-
import
|
|
8154
|
-
import { usePublicClient as
|
|
7271
|
+
import useSWR69 from "swr";
|
|
7272
|
+
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
8155
7273
|
var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
8156
|
-
const publicClient =
|
|
7274
|
+
const publicClient = usePublicClient54();
|
|
8157
7275
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedRewardAllocation", pubKey] : null;
|
|
8158
|
-
const swrResponse =
|
|
7276
|
+
const swrResponse = useSWR69(
|
|
8159
7277
|
QUERY_KEY,
|
|
8160
7278
|
async ([, pubKey2]) => {
|
|
8161
7279
|
return await getValidatorQueuedRewardAllocation({
|
|
@@ -8174,12 +7292,12 @@ var useValidatorQueuedRewardAllocation = (pubKey, options) => {
|
|
|
8174
7292
|
};
|
|
8175
7293
|
|
|
8176
7294
|
// src/hooks/validators/useValidatorRewardAllocation.ts
|
|
8177
|
-
import
|
|
8178
|
-
import { usePublicClient as
|
|
7295
|
+
import useSWR70 from "swr";
|
|
7296
|
+
import { usePublicClient as usePublicClient55 } from "@berachain/wagmi/hooks";
|
|
8179
7297
|
function useValidatorRewardAllocation(pubKey, options) {
|
|
8180
|
-
const publicClient =
|
|
7298
|
+
const publicClient = usePublicClient55();
|
|
8181
7299
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorRewardAllocation", pubKey] : null;
|
|
8182
|
-
const swrResponse =
|
|
7300
|
+
const swrResponse = useSWR70(
|
|
8183
7301
|
QUERY_KEY,
|
|
8184
7302
|
async ([, pubKey2]) => {
|
|
8185
7303
|
return getValidatorRewardAllocation({
|
|
@@ -8211,6 +7329,7 @@ export {
|
|
|
8211
7329
|
useApiPoolQueryKey,
|
|
8212
7330
|
useApiValidator,
|
|
8213
7331
|
useApiValidatorQueryKey,
|
|
7332
|
+
useAutoclaimedIncentives,
|
|
8214
7333
|
useBaselineRewardAllocation,
|
|
8215
7334
|
useBendDemultiply,
|
|
8216
7335
|
useBendMultiply,
|
|
@@ -8227,29 +7346,23 @@ export {
|
|
|
8227
7346
|
useClaimableFees,
|
|
8228
7347
|
useCollateralWeights,
|
|
8229
7348
|
useCreatePool,
|
|
8230
|
-
useCreateProposal,
|
|
8231
7349
|
useDailyValidatorBlockStats,
|
|
8232
7350
|
useDefaultRewardAllocation,
|
|
8233
7351
|
useEnsoSwapBundle,
|
|
8234
7352
|
useEnsoUserTokensWithBalances,
|
|
8235
|
-
useExploitedTokens,
|
|
8236
|
-
useExploitedTokensQueryKey,
|
|
8237
7353
|
useGetConvertToAssets,
|
|
8238
|
-
useGetPastVotes,
|
|
8239
7354
|
useGetVerifiedAbi,
|
|
8240
7355
|
useGlobalLiquidityAndSwapVolume,
|
|
8241
|
-
useHasVoted,
|
|
8242
7356
|
useHighestVaultsAPR,
|
|
8243
7357
|
useHistoryState,
|
|
7358
|
+
useHoney24hVolume,
|
|
8244
7359
|
useHoneyAlerts,
|
|
8245
7360
|
useHoneyBalances,
|
|
8246
7361
|
useHoneyChartData,
|
|
8247
|
-
useHoneyGlobalData,
|
|
8248
7362
|
useHoneySwapState,
|
|
8249
7363
|
useHoneyVaultsBalance,
|
|
8250
7364
|
useIsBadCollateralAsset,
|
|
8251
7365
|
useIsBasketModeEnabled,
|
|
8252
|
-
useIsCanceller,
|
|
8253
7366
|
useLiquidityMismatch,
|
|
8254
7367
|
useLpPosition,
|
|
8255
7368
|
useManagedValidatorRole,
|
|
@@ -8258,19 +7371,12 @@ export {
|
|
|
8258
7371
|
useOnChainPoolData,
|
|
8259
7372
|
useOnChainPoolDataQueryKey,
|
|
8260
7373
|
useOnChainValidator,
|
|
8261
|
-
usePollAllProposals,
|
|
8262
|
-
usePollAllProposalsQueryKey,
|
|
8263
7374
|
usePollAllowances,
|
|
8264
7375
|
usePollBalance,
|
|
8265
7376
|
usePollGlobalData,
|
|
8266
7377
|
usePollMarkets,
|
|
8267
7378
|
usePollMarketsQueryKey,
|
|
8268
7379
|
usePollPoolCreationRelayerApproval,
|
|
8269
|
-
usePollProposal,
|
|
8270
|
-
usePollProposalThreshold,
|
|
8271
|
-
usePollProposalVotes,
|
|
8272
|
-
usePollProposalVotesQueryKey,
|
|
8273
|
-
usePollUserDelegates,
|
|
8274
7380
|
usePollWalletBalances,
|
|
8275
7381
|
usePool,
|
|
8276
7382
|
usePoolEvents,
|
|
@@ -8279,14 +7385,9 @@ export {
|
|
|
8279
7385
|
usePoolsQueryKey,
|
|
8280
7386
|
usePrevious,
|
|
8281
7387
|
usePriceImpact,
|
|
8282
|
-
useProposalFromTx,
|
|
8283
|
-
useProposalSnapshot,
|
|
8284
|
-
useProposalState,
|
|
8285
|
-
useProposalTimelockState,
|
|
8286
7388
|
usePythLatestPrices,
|
|
8287
7389
|
usePythUpdateFee,
|
|
8288
7390
|
useQueuedBeraUnlock,
|
|
8289
|
-
useQuorum,
|
|
8290
7391
|
useRewardTokenToBeraRate,
|
|
8291
7392
|
useRewardVault,
|
|
8292
7393
|
useRewardVaultBalanceFromStakingToken,
|
|
@@ -8321,6 +7422,7 @@ export {
|
|
|
8321
7422
|
useValidatorAnalytics,
|
|
8322
7423
|
useValidatorCommission,
|
|
8323
7424
|
useValidatorEstimatedBgtPerYear,
|
|
7425
|
+
useValidatorIncentiveDistribution,
|
|
8324
7426
|
useValidatorQueuedCommission,
|
|
8325
7427
|
useValidatorQueuedOperatorAddress,
|
|
8326
7428
|
useValidatorQueuedRewardAllocation,
|
|
@@ -8330,4 +7432,3 @@ export {
|
|
|
8330
7432
|
useVaultValidators,
|
|
8331
7433
|
useZapStakeBera
|
|
8332
7434
|
};
|
|
8333
|
-
//# sourceMappingURL=exports.mjs.map
|