@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/actions/exports.mjs
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BalancerApi,
|
|
3
3
|
BaseAggregator,
|
|
4
|
-
BeraApolloClient,
|
|
5
4
|
HoneyPreviewMethod,
|
|
6
|
-
MOCKED_PROPOSAL_STATUSES,
|
|
7
5
|
RewardVaultDistributionMode,
|
|
8
6
|
beraWriteContract,
|
|
9
|
-
checkProposalField,
|
|
10
|
-
computeActualStatus,
|
|
11
7
|
formatValidatorRewardAllocation,
|
|
12
8
|
getAllPools,
|
|
13
|
-
getAllProposals,
|
|
14
9
|
getAllValidators,
|
|
15
10
|
getAllowances,
|
|
16
11
|
getApiEnrichedAllocation,
|
|
17
12
|
getApiPool,
|
|
18
13
|
getApiValidator,
|
|
19
|
-
|
|
14
|
+
getAutoclaimedIncentives,
|
|
20
15
|
getBgtAprSimulation,
|
|
21
16
|
getBlockTimestamp,
|
|
22
|
-
getBodyErrors,
|
|
23
17
|
getChartData,
|
|
24
18
|
getCollateralWeights,
|
|
25
19
|
getConvertToAssets,
|
|
@@ -29,8 +23,8 @@ import {
|
|
|
29
23
|
getGlobalCapLimit,
|
|
30
24
|
getGlobalData,
|
|
31
25
|
getGlobalLiquidityAndSwapVolume,
|
|
26
|
+
getHoney24hVolume,
|
|
32
27
|
getHoneyCollaterals,
|
|
33
|
-
getHoneyGlobalData,
|
|
34
28
|
getHoneyPreview,
|
|
35
29
|
getHoneyVaultsBalance,
|
|
36
30
|
getIncentiveFeeClaimStats,
|
|
@@ -39,9 +33,6 @@ import {
|
|
|
39
33
|
getPoolEvents,
|
|
40
34
|
getPoolHistoricalData,
|
|
41
35
|
getPoolPausedState,
|
|
42
|
-
getProposalDetails,
|
|
43
|
-
getProposalFromTx,
|
|
44
|
-
getProposalVotes,
|
|
45
36
|
getPythLatestPrices,
|
|
46
37
|
getPythUpdateFee,
|
|
47
38
|
getRelativeCapLimit,
|
|
@@ -79,39 +70,46 @@ import {
|
|
|
79
70
|
getValidatorRewardAllocation,
|
|
80
71
|
getVaultHistory,
|
|
81
72
|
getVaultValidators,
|
|
82
|
-
gql,
|
|
83
73
|
isBadCollateralAsset,
|
|
84
74
|
isBasketModeEnabled,
|
|
85
75
|
isDefaultRewardAllocation,
|
|
86
76
|
isImpersonateAccount,
|
|
87
|
-
isSameRewardAllocation
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
isSameRewardAllocation
|
|
78
|
+
} from "../chunk-QJIXTYTZ.mjs";
|
|
79
|
+
import {
|
|
80
|
+
BeraApolloClient,
|
|
81
|
+
getApolloClient,
|
|
82
|
+
gql
|
|
83
|
+
} from "../chunk-4Z4AK6SH.mjs";
|
|
84
|
+
import "../chunk-CDK4YV3D.mjs";
|
|
91
85
|
import {
|
|
92
86
|
getBalanceCall,
|
|
93
87
|
getEnsoClient,
|
|
94
88
|
getWalletBalances
|
|
95
|
-
} from "../chunk-
|
|
96
|
-
import "../chunk-
|
|
97
|
-
import "../chunk-
|
|
98
|
-
import "../chunk-
|
|
89
|
+
} from "../chunk-HSSJKHZ4.mjs";
|
|
90
|
+
import "../chunk-HQCOU6GY.mjs";
|
|
91
|
+
import "../chunk-WXXOISTU.mjs";
|
|
92
|
+
import "../chunk-EXIUPSFN.mjs";
|
|
99
93
|
import {
|
|
100
94
|
assertAddress,
|
|
101
95
|
assertDefined,
|
|
102
96
|
assertPublicClient
|
|
103
|
-
} from "../chunk-
|
|
97
|
+
} from "../chunk-KQUMKB66.mjs";
|
|
104
98
|
import {
|
|
105
99
|
beraFetchJson,
|
|
106
100
|
bignumber_js_default,
|
|
107
101
|
hoursInSeconds,
|
|
108
102
|
msToSeconds
|
|
109
|
-
} from "../chunk-
|
|
103
|
+
} from "../chunk-CDFWPU2R.mjs";
|
|
104
|
+
import {
|
|
105
|
+
isToken
|
|
106
|
+
} from "../chunk-NPBQLVL3.mjs";
|
|
110
107
|
import {
|
|
111
|
-
isToken,
|
|
112
108
|
parseBaseArgs
|
|
113
|
-
} from "../chunk-
|
|
114
|
-
import "../chunk-
|
|
109
|
+
} from "../chunk-75M6TF7M.mjs";
|
|
110
|
+
import "../chunk-SZ5C44L5.mjs";
|
|
111
|
+
import "../chunk-XIYN6AL6.mjs";
|
|
112
|
+
import "../chunk-J5I45WGQ.mjs";
|
|
115
113
|
|
|
116
114
|
// src/actions/bend/getMaxDeposit.ts
|
|
117
115
|
import { formatEther } from "viem";
|
|
@@ -163,116 +161,6 @@ async function getVaultPausedState({
|
|
|
163
161
|
return vaultPausedState[0];
|
|
164
162
|
}
|
|
165
163
|
|
|
166
|
-
// src/actions/governance/getDecodedFunctionData.ts
|
|
167
|
-
import {
|
|
168
|
-
decodeFunctionData,
|
|
169
|
-
erc20Abi,
|
|
170
|
-
pad,
|
|
171
|
-
toFunctionSignature,
|
|
172
|
-
trim
|
|
173
|
-
} from "viem";
|
|
174
|
-
import { appConfig, defaultChainId } from "@berachain/config/internal";
|
|
175
|
-
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
176
|
-
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
177
|
-
function isProxyABI(abi) {
|
|
178
|
-
return abi.some((item) => {
|
|
179
|
-
const i = item;
|
|
180
|
-
return i.name === "implementation" || i.name === "proxyType" || i.type === "constructor" && i.inputs?.[0]?.name === "implementation";
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
async function _getAbi({
|
|
184
|
-
contractAddress,
|
|
185
|
-
chainId,
|
|
186
|
-
publicClient
|
|
187
|
-
}) {
|
|
188
|
-
const url = `https://api.etherscan.io/v2/api?module=contract&action=getabi&address=${contractAddress}&apikey=${appConfig.apiKeys.private.etherscan}&chainId=${chainId}`;
|
|
189
|
-
const response = await fetch(url);
|
|
190
|
-
if (!response.ok) {
|
|
191
|
-
throw new Error(`Failed to fetch ABI: ${response.statusText}`);
|
|
192
|
-
}
|
|
193
|
-
const data = await response.json();
|
|
194
|
-
if (data.status === "0") throw new Error(data.result);
|
|
195
|
-
const abi = JSON.parse(data.result);
|
|
196
|
-
if (!isProxyABI(abi)) return abi;
|
|
197
|
-
const implementationResult = await publicClient.getStorageAt({
|
|
198
|
-
address: contractAddress,
|
|
199
|
-
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)).
|
|
200
|
-
slot: "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
|
|
201
|
-
});
|
|
202
|
-
if (!implementationResult || trim(implementationResult) === "0x00")
|
|
203
|
-
return abi;
|
|
204
|
-
const implementationAddress = pad(trim(implementationResult), { size: 20 });
|
|
205
|
-
return _getAbi({
|
|
206
|
-
contractAddress: implementationAddress,
|
|
207
|
-
chainId,
|
|
208
|
-
publicClient
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
async function _getAbiForCallData({
|
|
212
|
-
address,
|
|
213
|
-
callData,
|
|
214
|
-
knownAbi,
|
|
215
|
-
chainId,
|
|
216
|
-
publicClient
|
|
217
|
-
}) {
|
|
218
|
-
try {
|
|
219
|
-
if (decodeFunctionData({ data: callData, abi: knownAbi })) {
|
|
220
|
-
return knownAbi;
|
|
221
|
-
}
|
|
222
|
-
} catch {
|
|
223
|
-
}
|
|
224
|
-
return _getAbi({ contractAddress: address, chainId, publicClient }).catch(
|
|
225
|
-
() => void 0
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
function _decodeCallData(callData, abi) {
|
|
229
|
-
try {
|
|
230
|
-
return decodeFunctionData({ data: callData, abi });
|
|
231
|
-
} catch {
|
|
232
|
-
return void 0;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function _findAbiItem(abi, functionName) {
|
|
236
|
-
return abi.find(
|
|
237
|
-
(a) => a.type === "function" && a.name === functionName
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
function _getFunctionSignature(abiItem) {
|
|
241
|
-
if (!abiItem) return;
|
|
242
|
-
try {
|
|
243
|
-
return toFunctionSignature(abiItem);
|
|
244
|
-
} catch (error) {
|
|
245
|
-
console.error(error);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async function getDecodedFunctionData({
|
|
249
|
-
address,
|
|
250
|
-
callData,
|
|
251
|
-
chainId = defaultChainId,
|
|
252
|
-
publicClient
|
|
253
|
-
}) {
|
|
254
|
-
const knownAbi = [...beraChefAbi, ...rewardVaultAbi, ...erc20Abi];
|
|
255
|
-
const abi = await _getAbiForCallData({
|
|
256
|
-
address,
|
|
257
|
-
callData,
|
|
258
|
-
knownAbi,
|
|
259
|
-
chainId,
|
|
260
|
-
publicClient
|
|
261
|
-
});
|
|
262
|
-
const decodedData = _decodeCallData(callData, abi);
|
|
263
|
-
if (!abi || !decodedData) {
|
|
264
|
-
return { args: [] };
|
|
265
|
-
}
|
|
266
|
-
const abiItem = _findAbiItem(abi, decodedData.functionName);
|
|
267
|
-
const functionSignature = _getFunctionSignature(abiItem);
|
|
268
|
-
return {
|
|
269
|
-
abiItem,
|
|
270
|
-
functionSignature,
|
|
271
|
-
functionName: decodedData.functionName,
|
|
272
|
-
args: decodedData.args
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
164
|
// src/actions/honey/getHoneyFees.ts
|
|
277
165
|
import { formatUnits } from "viem";
|
|
278
166
|
import { honeyFactoryAbi } from "@berachain/abis/honey/honeyFactory";
|
|
@@ -381,6 +269,44 @@ async function getHoneyRootPriceOracle({
|
|
|
381
269
|
});
|
|
382
270
|
}
|
|
383
271
|
|
|
272
|
+
// src/actions/pol/getBeraTokenTotalSupply.ts
|
|
273
|
+
import { ChainId } from "@berachain/config";
|
|
274
|
+
async function getBeraTokenTotalSupply(args = {}) {
|
|
275
|
+
const { config } = parseBaseArgs(args);
|
|
276
|
+
const network = config.chainId === ChainId.MAINNET ? "mainnet" : "bepolia";
|
|
277
|
+
const supplyMonitor = config.pol.supplyMonitor;
|
|
278
|
+
const baseUrl = typeof supplyMonitor === "string" ? supplyMonitor : supplyMonitor.uri;
|
|
279
|
+
const data = await beraFetchJson(
|
|
280
|
+
{
|
|
281
|
+
url: `${baseUrl}/api/stats/bera?network=${network}`,
|
|
282
|
+
name: typeof supplyMonitor === "string" ? "supply-monitor-bera" : supplyMonitor.name,
|
|
283
|
+
type: "rest"
|
|
284
|
+
},
|
|
285
|
+
{ cache: "no-store" }
|
|
286
|
+
);
|
|
287
|
+
return data.totalSupply.toString();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/actions/pol/getBgtIncentiveDistributorPaused.ts
|
|
291
|
+
import { bgtIncentiveDistributorAbi } from "@berachain/abis/pol/rewards/bgtIncentiveDistributor";
|
|
292
|
+
async function getBgtIncentiveDistributorPaused({
|
|
293
|
+
publicClient,
|
|
294
|
+
...args
|
|
295
|
+
}) {
|
|
296
|
+
assertPublicClient(publicClient);
|
|
297
|
+
const { config } = parseBaseArgs(args);
|
|
298
|
+
try {
|
|
299
|
+
const paused = await publicClient.readContract({
|
|
300
|
+
address: config.pol.bgtIncentiveDistributor,
|
|
301
|
+
abi: bgtIncentiveDistributorAbi,
|
|
302
|
+
functionName: "paused"
|
|
303
|
+
});
|
|
304
|
+
return paused;
|
|
305
|
+
} catch {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
384
310
|
// src/actions/pol/getBlockTime.ts
|
|
385
311
|
async function getBlockTime({
|
|
386
312
|
defaultBlockTime,
|
|
@@ -402,6 +328,26 @@ async function getBlockTime({
|
|
|
402
328
|
);
|
|
403
329
|
}
|
|
404
330
|
|
|
331
|
+
// src/actions/pol/getHeroEarnVaults.ts
|
|
332
|
+
import {
|
|
333
|
+
GetHeroEarnVaults
|
|
334
|
+
} from "@berachain/graphql/pol/api";
|
|
335
|
+
async function getHeroEarnVaults({
|
|
336
|
+
bestAprExcludedAddresses = [],
|
|
337
|
+
...args
|
|
338
|
+
} = {}) {
|
|
339
|
+
const bexApiGraphqlClient = getApolloClient("api", args);
|
|
340
|
+
const res = await bexApiGraphqlClient.query({
|
|
341
|
+
query: GetHeroEarnVaults,
|
|
342
|
+
variables: { bestAprExcludedAddresses }
|
|
343
|
+
});
|
|
344
|
+
return {
|
|
345
|
+
bestApr: res.data.bestApr.vaults,
|
|
346
|
+
bendRewardVault: res.data.bendRewardVault.vaults,
|
|
347
|
+
bendVaults: res.data.bendVaults
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
405
351
|
// src/actions/pol/getLSTStakeConfig.ts
|
|
406
352
|
import { lstStakerVaultAbi } from "@berachain/abis/pol/lst/lstStakerVault";
|
|
407
353
|
async function getLSTStakeConfig({
|
|
@@ -449,7 +395,7 @@ async function getLSTStakeConfig({
|
|
|
449
395
|
}
|
|
450
396
|
|
|
451
397
|
// src/actions/pol/getRewardVaultDurationConstants.ts
|
|
452
|
-
import { rewardVaultAbi
|
|
398
|
+
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
453
399
|
|
|
454
400
|
// src/actions/pol/getRewardVaultBeaconImplementation.ts
|
|
455
401
|
import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
|
|
@@ -576,12 +522,12 @@ async function getRewardVaultDurationConstants({
|
|
|
576
522
|
const [minRewardDuration, maxRewardDuration] = await Promise.all([
|
|
577
523
|
publicClient.readContract({
|
|
578
524
|
address: beaconImplementation,
|
|
579
|
-
abi:
|
|
525
|
+
abi: rewardVaultAbi,
|
|
580
526
|
functionName: "MIN_REWARD_DURATION"
|
|
581
527
|
}),
|
|
582
528
|
publicClient.readContract({
|
|
583
529
|
address: beaconImplementation,
|
|
584
|
-
abi:
|
|
530
|
+
abi: rewardVaultAbi,
|
|
585
531
|
functionName: "MAX_REWARD_DURATION"
|
|
586
532
|
})
|
|
587
533
|
]);
|
|
@@ -661,7 +607,7 @@ async function getTokens({
|
|
|
661
607
|
|
|
662
608
|
// src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts
|
|
663
609
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
664
|
-
import { beraChefAbi
|
|
610
|
+
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
665
611
|
async function getActiveBoostAndCommissionChangeDelay({
|
|
666
612
|
publicClient,
|
|
667
613
|
ui,
|
|
@@ -680,27 +626,27 @@ async function getActiveBoostAndCommissionChangeDelay({
|
|
|
680
626
|
] = await Promise.all([
|
|
681
627
|
publicClient.readContract({
|
|
682
628
|
address: config.pol.beraChef,
|
|
683
|
-
abi:
|
|
629
|
+
abi: beraChefAbi,
|
|
684
630
|
functionName: "MAX_COMMISSION_RATE"
|
|
685
631
|
}),
|
|
686
632
|
publicClient.readContract({
|
|
687
633
|
address: config.pol.beraChef,
|
|
688
|
-
abi:
|
|
634
|
+
abi: beraChefAbi,
|
|
689
635
|
functionName: "commissionChangeDelay"
|
|
690
636
|
}),
|
|
691
637
|
publicClient.readContract({
|
|
692
638
|
address: config.pol.beraChef,
|
|
693
|
-
abi:
|
|
639
|
+
abi: beraChefAbi,
|
|
694
640
|
functionName: "rewardAllocationBlockDelay"
|
|
695
641
|
}),
|
|
696
642
|
publicClient.readContract({
|
|
697
643
|
address: config.pol.beraChef,
|
|
698
|
-
abi:
|
|
644
|
+
abi: beraChefAbi,
|
|
699
645
|
functionName: "maxWeightPerVault"
|
|
700
646
|
}),
|
|
701
647
|
publicClient.readContract({
|
|
702
648
|
address: config.pol.beraChef,
|
|
703
|
-
abi:
|
|
649
|
+
abi: beraChefAbi,
|
|
704
650
|
functionName: "maxNumWeightsPerRewardAllocation"
|
|
705
651
|
}),
|
|
706
652
|
publicClient.readContract({
|
|
@@ -715,7 +661,7 @@ async function getActiveBoostAndCommissionChangeDelay({
|
|
|
715
661
|
}),
|
|
716
662
|
publicClient.readContract({
|
|
717
663
|
address: config.pol.beraChef,
|
|
718
|
-
abi:
|
|
664
|
+
abi: beraChefAbi,
|
|
719
665
|
functionName: "rewardAllocationInactivityBlockSpan"
|
|
720
666
|
})
|
|
721
667
|
]);
|
|
@@ -806,41 +752,39 @@ export {
|
|
|
806
752
|
BaseAggregator,
|
|
807
753
|
BeraApolloClient,
|
|
808
754
|
HoneyPreviewMethod,
|
|
809
|
-
MOCKED_PROPOSAL_STATUSES,
|
|
810
755
|
RewardVaultDistributionMode,
|
|
811
756
|
aggregateValidatorIncentives,
|
|
812
757
|
beraWriteContract,
|
|
813
|
-
checkProposalField,
|
|
814
|
-
computeActualStatus,
|
|
815
758
|
formatValidatorRewardAllocation,
|
|
816
759
|
getActiveBoostAndCommissionChangeDelay,
|
|
817
760
|
getAllPools,
|
|
818
|
-
getAllProposals,
|
|
819
761
|
getAllValidators,
|
|
820
762
|
getAllowances,
|
|
821
763
|
getApiEnrichedAllocation,
|
|
822
764
|
getApiPool,
|
|
823
765
|
getApiValidator,
|
|
824
766
|
getApolloClient,
|
|
767
|
+
getAutoclaimedIncentives,
|
|
825
768
|
getBalanceCall,
|
|
769
|
+
getBeraTokenTotalSupply,
|
|
826
770
|
getBgtAprSimulation,
|
|
771
|
+
getBgtIncentiveDistributorPaused,
|
|
827
772
|
getBlockTime,
|
|
828
773
|
getBlockTimestamp,
|
|
829
|
-
getBodyErrors,
|
|
830
774
|
getChartData,
|
|
831
775
|
getCollateralWeights,
|
|
832
776
|
getConvertToAssets,
|
|
833
777
|
getDailyValidatorBlockStats,
|
|
834
|
-
getDecodedFunctionData,
|
|
835
778
|
getDefaultRewardAllocation,
|
|
836
779
|
getEarnedStakedBeraVault,
|
|
837
780
|
getEnsoClient,
|
|
838
781
|
getGlobalCapLimit,
|
|
839
782
|
getGlobalData,
|
|
840
783
|
getGlobalLiquidityAndSwapVolume,
|
|
784
|
+
getHeroEarnVaults,
|
|
785
|
+
getHoney24hVolume,
|
|
841
786
|
getHoneyCollaterals,
|
|
842
787
|
getHoneyFees,
|
|
843
|
-
getHoneyGlobalData,
|
|
844
788
|
getHoneyPausedState,
|
|
845
789
|
getHoneyPreview,
|
|
846
790
|
getHoneyPythFeeds,
|
|
@@ -856,9 +800,6 @@ export {
|
|
|
856
800
|
getPoolHistoricalData,
|
|
857
801
|
getPoolPausedState,
|
|
858
802
|
getPoolState,
|
|
859
|
-
getProposalDetails,
|
|
860
|
-
getProposalFromTx,
|
|
861
|
-
getProposalVotes,
|
|
862
803
|
getPythLatestPrices,
|
|
863
804
|
getPythUpdateFee,
|
|
864
805
|
getRelativeCapLimit,
|
|
@@ -908,7 +849,5 @@ export {
|
|
|
908
849
|
isBasketModeEnabled,
|
|
909
850
|
isDefaultRewardAllocation,
|
|
910
851
|
isImpersonateAccount,
|
|
911
|
-
isSameRewardAllocation
|
|
912
|
-
parseProposalBody
|
|
852
|
+
isSameRewardAllocation
|
|
913
853
|
};
|
|
914
|
-
//# sourceMappingURL=exports.mjs.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AbiParameter, Address, PublicClient, AbiFunction, TransactionReceipt } from 'viem';
|
|
2
|
+
import { ProposalErrorCodes, ProposalState } from '../../enum/governance/exports.js';
|
|
3
|
+
import { ProposalStatus, ProposalSelectionFragment, Proposal_Filter, Proposal_OrderBy, OrderDirection, ProposalWithVotesFragment, GetProposalVotesQueryVariables, GetProposalVotesQuery } from '@berachain/graphql/governance';
|
|
4
|
+
import { CustomProposal, GovernanceTopic, CustomProposalErrors } from '../../types/governance/exports.js';
|
|
5
|
+
import graymatter from 'gray-matter';
|
|
6
|
+
|
|
7
|
+
type CheckProposalFieldResultMinimal = ProposalErrorCodes | null;
|
|
8
|
+
type CheckProposalFieldResult = ProposalErrorCodes | null | CheckProposalFieldResultMinimal[] | Record<string, CheckProposalFieldResultMinimal>;
|
|
9
|
+
/**
|
|
10
|
+
* Validates a single proposal field or ABI-typed value.
|
|
11
|
+
* Returns `null` if valid, or a `ProposalErrorCodes` value describing the problem.
|
|
12
|
+
*/
|
|
13
|
+
declare function checkProposalField(arg: {
|
|
14
|
+
fieldOrType: "address" | "hex" | "abi" | "string" | "bool" | `uint${string}` | `int${string}` | "action" | "title" | "forumLink" | "description" | "logoURI" | "url";
|
|
15
|
+
value: unknown;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
components?: readonly (AbiParameter | readonly AbiParameter[])[];
|
|
19
|
+
}): CheckProposalFieldResultMinimal;
|
|
20
|
+
/**
|
|
21
|
+
* For tuple/tuple[] types, may return nested error structures.
|
|
22
|
+
*/
|
|
23
|
+
declare function checkProposalField(arg: {
|
|
24
|
+
fieldOrType: "tuple[]" | "tuple";
|
|
25
|
+
value: unknown;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
components?: readonly (AbiParameter | readonly AbiParameter[])[];
|
|
29
|
+
}): CheckProposalFieldResult;
|
|
30
|
+
|
|
31
|
+
declare const MOCKED_PROPOSAL_STATUSES: readonly ProposalStatus[];
|
|
32
|
+
/**
|
|
33
|
+
* Derives the effective `ProposalStatus` by reconciling subgraph data with the
|
|
34
|
+
* on-chain contract state. Falls back to subgraph timestamps when the on-chain
|
|
35
|
+
* state is unavailable.
|
|
36
|
+
*/
|
|
37
|
+
declare function computeActualStatus(
|
|
38
|
+
/** Subgraph proposal data */
|
|
39
|
+
proposal: ProposalSelectionFragment,
|
|
40
|
+
/** Value returned by the `state` function of the governance contract */
|
|
41
|
+
proposalOnChainState?: ProposalState): ProposalStatus;
|
|
42
|
+
|
|
43
|
+
type GetAllProposalsArgs = BeraJS.BaseFunctionArgs & {
|
|
44
|
+
/** Subgraph filter applied to the proposals query */
|
|
45
|
+
where: Proposal_Filter;
|
|
46
|
+
/** Number of proposals to skip (for pagination) */
|
|
47
|
+
offset?: number;
|
|
48
|
+
/** Maximum proposals per page; must be ≤ 1000 */
|
|
49
|
+
perPage?: number;
|
|
50
|
+
orderBy?: Proposal_OrderBy;
|
|
51
|
+
orderDirection?: OrderDirection;
|
|
52
|
+
/** Full-text search query; switches to the search endpoint when provided */
|
|
53
|
+
text?: string;
|
|
54
|
+
};
|
|
55
|
+
/** Fetches a paginated list of governance proposals from the subgraph */
|
|
56
|
+
declare function getAllProposals(_args: GetAllProposalsArgs): Promise<ProposalSelectionFragment[] | undefined>;
|
|
57
|
+
|
|
58
|
+
interface GetBodyErrorsArgs {
|
|
59
|
+
/** The proposal to validate */
|
|
60
|
+
proposal: CustomProposal;
|
|
61
|
+
/** The current governance topic, used for forum link base URL validation */
|
|
62
|
+
currentTopic: GovernanceTopic;
|
|
63
|
+
}
|
|
64
|
+
/** Validates the body fields (title, description, forum link) of a proposal */
|
|
65
|
+
declare function getBodyErrors({ proposal, currentTopic, }: GetBodyErrorsArgs): CustomProposalErrors;
|
|
66
|
+
|
|
67
|
+
interface GetDecodedFunctionDataArgs {
|
|
68
|
+
/** Contract address that emitted the calldata */
|
|
69
|
+
address: Address;
|
|
70
|
+
/** Raw calldata to decode */
|
|
71
|
+
callData: `0x${string}`;
|
|
72
|
+
/** @default defaultChainId */
|
|
73
|
+
chainId?: number;
|
|
74
|
+
publicClient: PublicClient;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Decodes the function data from a given contract address and calldata.
|
|
78
|
+
*
|
|
79
|
+
* Attempts to decode using a known set of ABIs first, then falls back to
|
|
80
|
+
* fetching the ABI from the block-explorer API.
|
|
81
|
+
*
|
|
82
|
+
* @returns An object with the decoded ABI item, function signature, function name, and arguments.
|
|
83
|
+
*/
|
|
84
|
+
declare function getDecodedFunctionData({ address, callData, chainId, publicClient, }: GetDecodedFunctionDataArgs): Promise<{
|
|
85
|
+
args: never[];
|
|
86
|
+
abiItem?: undefined;
|
|
87
|
+
functionSignature?: undefined;
|
|
88
|
+
functionName?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
abiItem: AbiFunction | undefined;
|
|
91
|
+
functionSignature: string | undefined;
|
|
92
|
+
functionName: string;
|
|
93
|
+
args: unknown[];
|
|
94
|
+
}>;
|
|
95
|
+
|
|
96
|
+
type GetProposalDetailsArgs = BeraJS.BaseFunctionArgs & {
|
|
97
|
+
/** On-chain proposal ID */
|
|
98
|
+
proposalId: string;
|
|
99
|
+
client?: PublicClient;
|
|
100
|
+
};
|
|
101
|
+
/** Fetches a single proposal with its vote data from the subgraph */
|
|
102
|
+
declare function getProposalDetails(_args: GetProposalDetailsArgs): Promise<ProposalWithVotesFragment | undefined>;
|
|
103
|
+
|
|
104
|
+
type GetProposalFromTxArgs = {
|
|
105
|
+
/** Viem public client used to fetch block and receipt data */
|
|
106
|
+
publicClient: PublicClient | undefined;
|
|
107
|
+
} & ({
|
|
108
|
+
/** Pre-fetched transaction receipt */
|
|
109
|
+
tx: TransactionReceipt;
|
|
110
|
+
} | {
|
|
111
|
+
/** Transaction hash to look up */
|
|
112
|
+
txHash: Address;
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* Reconstructs a `ProposalWithVotesFragment` from the `ProposalCreated` event
|
|
116
|
+
* emitted in a given transaction. Returns `null` if the event is not found.
|
|
117
|
+
*/
|
|
118
|
+
declare function getProposalFromTx(args: GetProposalFromTxArgs): Promise<ProposalWithVotesFragment | null>;
|
|
119
|
+
|
|
120
|
+
type GetProposalVotesArgs = BeraJS.BaseFunctionArgs & {
|
|
121
|
+
/** GraphQL variables forwarded to the GetProposalVotes query */
|
|
122
|
+
variables: GetProposalVotesQueryVariables;
|
|
123
|
+
};
|
|
124
|
+
/** Fetches the votes for a proposal from the subgraph */
|
|
125
|
+
declare function getProposalVotes(_args: GetProposalVotesArgs): Promise<{
|
|
126
|
+
data: GetProposalVotesQuery;
|
|
127
|
+
}>;
|
|
128
|
+
|
|
129
|
+
type ParseProposalBodyResult = graymatter.GrayMatterFile<string> & {
|
|
130
|
+
/** Whether the body uses YAML front-matter (true) or legacy heading format (false) */
|
|
131
|
+
isFrontMatter: boolean;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Parses the body of a governance proposal into structured front-matter and content.
|
|
135
|
+
* Supports YAML front-matter format and a legacy heading-based format.
|
|
136
|
+
* Falls back to raw description on parse failure.
|
|
137
|
+
*/
|
|
138
|
+
declare function parseProposalBody(proposal?: Pick<ProposalSelectionFragment, "description">): ParseProposalBodyResult;
|
|
139
|
+
|
|
140
|
+
export { type GetAllProposalsArgs, type GetBodyErrorsArgs, type GetDecodedFunctionDataArgs, type GetProposalDetailsArgs, type GetProposalFromTxArgs, type GetProposalVotesArgs, MOCKED_PROPOSAL_STATUSES, type ParseProposalBodyResult, checkProposalField, computeActualStatus, getAllProposals, getBodyErrors, getDecodedFunctionData, getProposalDetails, getProposalFromTx, getProposalVotes, parseProposalBody };
|