@berachain/berajs 0.2.8-beta.9 → 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.
Files changed (237) hide show
  1. package/dist/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
  2. package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
  3. package/dist/{RequestError-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
  4. package/dist/abi/exports.mjs +4452 -2
  5. package/dist/actions/clients/exports.d.ts +2 -0
  6. package/dist/actions/clients/exports.mjs +12 -0
  7. package/dist/actions/exports.d.ts +104 -189
  8. package/dist/actions/exports.mjs +853 -2
  9. package/dist/actions/governance/exports.d.ts +140 -0
  10. package/dist/actions/governance/exports.mjs +226 -0
  11. package/dist/actions/server/exports.d.ts +13 -0
  12. package/dist/actions/server/exports.mjs +27 -0
  13. package/dist/chunk-3EARVV7K.mjs +414 -0
  14. package/dist/chunk-4Z4AK6SH.mjs +211 -0
  15. package/dist/chunk-75M6TF7M.mjs +25 -0
  16. package/dist/chunk-AFN4CVD3.mjs +326 -0
  17. package/dist/chunk-BGMRHTBQ.mjs +23 -0
  18. package/dist/chunk-CDFWPU2R.mjs +473 -0
  19. package/dist/chunk-CDK4YV3D.mjs +571 -0
  20. package/dist/chunk-DKMAIU74.mjs +62 -0
  21. package/dist/chunk-EXIUPSFN.mjs +86 -0
  22. package/dist/chunk-FFB5LFDW.mjs +35 -0
  23. package/dist/chunk-HQCOU6GY.mjs +243 -0
  24. package/dist/chunk-HSSJKHZ4.mjs +135 -0
  25. package/dist/chunk-J5I45WGQ.mjs +1769 -0
  26. package/dist/chunk-KQUMKB66.mjs +89 -0
  27. package/dist/chunk-NBYLMO2L.mjs +14 -0
  28. package/dist/chunk-NPBQLVL3.mjs +80 -0
  29. package/dist/chunk-O2NQFKJK.mjs +170 -0
  30. package/dist/chunk-QJIXTYTZ.mjs +4054 -0
  31. package/dist/chunk-SGIJVHZO.mjs +12 -0
  32. package/dist/chunk-SZ5C44L5.mjs +35 -0
  33. package/dist/chunk-WXXOISTU.mjs +96 -0
  34. package/dist/chunk-XIYN6AL6.mjs +160 -0
  35. package/dist/contexts/exports.d.ts +2 -2
  36. package/dist/contexts/exports.mjs +85 -2
  37. package/dist/enum/exports.d.ts +1 -1
  38. package/dist/enum/exports.mjs +46 -2
  39. package/dist/enum/governance/exports.d.ts +60 -0
  40. package/dist/enum/governance/exports.mjs +14 -0
  41. package/dist/errors/exports.d.ts +4 -3
  42. package/dist/errors/exports.mjs +48 -2
  43. package/dist/exports-BcUTGFUb.d.ts +40 -0
  44. package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
  45. package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
  46. package/dist/hooks/exports.d.ts +69 -211
  47. package/dist/hooks/exports.mjs +7434 -4
  48. package/dist/hooks/governance/exports.d.ts +181 -0
  49. package/dist/hooks/governance/exports.mjs +888 -0
  50. package/dist/pol.d-CqPA9K6m.d.ts +142 -0
  51. package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
  52. package/dist/types/exports.d.ts +9 -9
  53. package/dist/types/exports.mjs +0 -1
  54. package/dist/types/governance/exports.d.ts +109 -0
  55. package/dist/types/governance/exports.mjs +0 -0
  56. package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
  57. package/dist/utils/exports.d.ts +15 -6
  58. package/dist/utils/exports.mjs +825 -2
  59. package/package.json +49 -13
  60. package/src/actions/__test/transports.ts +61 -0
  61. package/src/actions/clients/exports.ts +4 -0
  62. package/src/actions/clients/getApolloClient.ts +58 -23
  63. package/src/actions/clients/getEnsoClient.ts +20 -9
  64. package/src/actions/dex/aggregators/enso/enso.ts +27 -17
  65. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
  66. package/src/actions/dex/aggregators/kyberswap.ts +18 -23
  67. package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
  68. package/src/actions/exports.ts +4 -9
  69. package/src/actions/governance/exports.ts +9 -0
  70. package/src/actions/governance/getAllProposals.ts +10 -65
  71. package/src/actions/governance/getProposalDetails.ts +6 -33
  72. package/src/actions/governance/getProposalVotes.ts +8 -15
  73. package/src/actions/honey/getChartData.ts +27 -21
  74. package/src/actions/honey/getHoney24hVolume.ts +19 -22
  75. package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
  76. package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
  77. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
  78. package/src/actions/pol/getEarnedStakedBeraVault.ts +7 -11
  79. package/src/actions/pol/getGlobalData.ts +1 -0
  80. package/src/actions/pol/getHeroEarnVaults.ts +62 -0
  81. package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
  82. package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
  83. package/src/actions/pol/getStakingDailyAssets.ts +7 -10
  84. package/src/actions/server/exports.ts +1 -0
  85. package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
  86. package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
  87. package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
  88. package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
  89. package/src/actions/validators/getValidatorAnalytics.ts +20 -21
  90. package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
  91. package/src/enum/contracts.ts +1 -0
  92. package/src/enum/exports.ts +0 -1
  93. package/src/enum/governance/exports.ts +1 -0
  94. package/src/errors/BeraError.ts +47 -7
  95. package/src/errors/BeraTracing.unit.test.ts +65 -0
  96. package/src/errors/RequestError.ts +13 -1
  97. package/src/errors/exports.ts +5 -0
  98. package/src/errors/getRevertReason.integration.test.ts +3 -3
  99. package/src/errors/spanStatus.ts +78 -0
  100. package/src/errors/spanStatus.unit.test.ts +62 -0
  101. package/src/hooks/dex/useCreatePool.ts +1 -88
  102. package/src/hooks/dex/useOnChainPoolData.ts +27 -2
  103. package/src/hooks/dex/usePriceImpact.ts +12 -5
  104. package/src/hooks/enso/useBendDemultiply.ts +9 -1
  105. package/src/hooks/enso/useBendMultiply.ts +9 -1
  106. package/src/hooks/enso/useBendZapSupply.ts +26 -7
  107. package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
  108. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
  109. package/src/hooks/exports.ts +2 -15
  110. package/src/hooks/governance/exports.ts +14 -0
  111. package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
  112. package/src/hooks/pol/useStakedAPR.ts +2 -2
  113. package/src/hooks/pol/useStakedSnapshots.ts +5 -9
  114. package/src/hooks/validators/useValidator.ts +2 -0
  115. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
  116. package/src/types/bribe-boost.d.ts +8 -0
  117. package/src/types/exports.ts +0 -1
  118. package/src/types/governance/exports.ts +1 -0
  119. package/src/utils/beraFetch.ts +9 -3
  120. package/src/utils/exports.ts +1 -0
  121. package/src/utils/getServerSideClient.ts +4 -2
  122. package/src/utils/sanitizeRpcUrl.ts +22 -0
  123. package/src/utils/tracedTransport.ts +35 -0
  124. package/dist/BeraError-_mQdkanr.d.ts +0 -94
  125. package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
  126. package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
  127. package/dist/RequestError-DSUzJ1Iy.d.cts +0 -144
  128. package/dist/abi/exports.cjs +0 -2
  129. package/dist/abi/exports.cjs.map +0 -1
  130. package/dist/abi/exports.d.cts +0 -6574
  131. package/dist/abi/exports.mjs.map +0 -1
  132. package/dist/actions/exports.cjs +0 -2
  133. package/dist/actions/exports.cjs.map +0 -1
  134. package/dist/actions/exports.d.cts +0 -1650
  135. package/dist/actions/exports.mjs.map +0 -1
  136. package/dist/chunk-45HIEVNI.cjs +0 -4
  137. package/dist/chunk-45HIEVNI.cjs.map +0 -1
  138. package/dist/chunk-47ILYVHC.mjs +0 -2
  139. package/dist/chunk-47ILYVHC.mjs.map +0 -1
  140. package/dist/chunk-575OK77P.mjs +0 -2
  141. package/dist/chunk-575OK77P.mjs.map +0 -1
  142. package/dist/chunk-5NVZG5N6.mjs +0 -2
  143. package/dist/chunk-5NVZG5N6.mjs.map +0 -1
  144. package/dist/chunk-6DIA6PXV.cjs +0 -2
  145. package/dist/chunk-6DIA6PXV.cjs.map +0 -1
  146. package/dist/chunk-6JJIZCVY.cjs +0 -2
  147. package/dist/chunk-6JJIZCVY.cjs.map +0 -1
  148. package/dist/chunk-7F72ZH4Q.mjs +0 -2
  149. package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
  150. package/dist/chunk-AUA42YIG.mjs +0 -4
  151. package/dist/chunk-AUA42YIG.mjs.map +0 -1
  152. package/dist/chunk-BC2WX6O6.cjs +0 -2
  153. package/dist/chunk-BC2WX6O6.cjs.map +0 -1
  154. package/dist/chunk-CJOZC5Z2.cjs +0 -2
  155. package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
  156. package/dist/chunk-D6L7LTA2.cjs +0 -2
  157. package/dist/chunk-D6L7LTA2.cjs.map +0 -1
  158. package/dist/chunk-DDEQFR3M.cjs +0 -2
  159. package/dist/chunk-DDEQFR3M.cjs.map +0 -1
  160. package/dist/chunk-GXV2JA36.mjs +0 -2
  161. package/dist/chunk-GXV2JA36.mjs.map +0 -1
  162. package/dist/chunk-ISYNEDET.mjs +0 -2
  163. package/dist/chunk-ISYNEDET.mjs.map +0 -1
  164. package/dist/chunk-JDDRTHFG.mjs +0 -2
  165. package/dist/chunk-JDDRTHFG.mjs.map +0 -1
  166. package/dist/chunk-JDZGYU5T.mjs +0 -2
  167. package/dist/chunk-JDZGYU5T.mjs.map +0 -1
  168. package/dist/chunk-LVOXBZMA.cjs +0 -2
  169. package/dist/chunk-LVOXBZMA.cjs.map +0 -1
  170. package/dist/chunk-MK5NS5B5.mjs +0 -2
  171. package/dist/chunk-MK5NS5B5.mjs.map +0 -1
  172. package/dist/chunk-NAXAZJJY.mjs +0 -2
  173. package/dist/chunk-NAXAZJJY.mjs.map +0 -1
  174. package/dist/chunk-NLVWRMGD.mjs +0 -2
  175. package/dist/chunk-NLVWRMGD.mjs.map +0 -1
  176. package/dist/chunk-OGBD5YOG.mjs +0 -2
  177. package/dist/chunk-OGBD5YOG.mjs.map +0 -1
  178. package/dist/chunk-OGJMSGB2.mjs +0 -2
  179. package/dist/chunk-OGJMSGB2.mjs.map +0 -1
  180. package/dist/chunk-OIYXOKTT.cjs +0 -2
  181. package/dist/chunk-OIYXOKTT.cjs.map +0 -1
  182. package/dist/chunk-OUD27MU7.cjs +0 -2
  183. package/dist/chunk-OUD27MU7.cjs.map +0 -1
  184. package/dist/chunk-PRLVZIKD.mjs +0 -2
  185. package/dist/chunk-PRLVZIKD.mjs.map +0 -1
  186. package/dist/chunk-Q2SNRLW3.cjs +0 -2
  187. package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
  188. package/dist/chunk-REWME3FY.cjs +0 -2
  189. package/dist/chunk-REWME3FY.cjs.map +0 -1
  190. package/dist/chunk-RJN36GBU.mjs +0 -2
  191. package/dist/chunk-RJN36GBU.mjs.map +0 -1
  192. package/dist/chunk-RWOICHRW.cjs +0 -2
  193. package/dist/chunk-RWOICHRW.cjs.map +0 -1
  194. package/dist/chunk-S4CDSVLK.cjs +0 -2
  195. package/dist/chunk-S4CDSVLK.cjs.map +0 -1
  196. package/dist/chunk-SFEULGSX.cjs +0 -2
  197. package/dist/chunk-SFEULGSX.cjs.map +0 -1
  198. package/dist/chunk-WBTS6KFG.mjs +0 -2
  199. package/dist/chunk-WBTS6KFG.mjs.map +0 -1
  200. package/dist/chunk-WRFDB3QJ.cjs +0 -2
  201. package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
  202. package/dist/chunk-XNJLSA6P.cjs +0 -2
  203. package/dist/chunk-XNJLSA6P.cjs.map +0 -1
  204. package/dist/contexts/exports.cjs +0 -2
  205. package/dist/contexts/exports.cjs.map +0 -1
  206. package/dist/contexts/exports.d.cts +0 -66
  207. package/dist/contexts/exports.mjs.map +0 -1
  208. package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
  209. package/dist/dex-C_BB0b0O.d.cts +0 -37
  210. package/dist/enum/exports.cjs +0 -2
  211. package/dist/enum/exports.cjs.map +0 -1
  212. package/dist/enum/exports.d.cts +0 -23
  213. package/dist/enum/exports.mjs.map +0 -1
  214. package/dist/errors/exports.cjs +0 -2
  215. package/dist/errors/exports.cjs.map +0 -1
  216. package/dist/errors/exports.d.cts +0 -327
  217. package/dist/errors/exports.mjs.map +0 -1
  218. package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
  219. package/dist/global.d-B7IeayVX.d.cts +0 -474
  220. package/dist/honey-CYm0RWf4.d.cts +0 -14
  221. package/dist/hooks/exports.cjs +0 -4
  222. package/dist/hooks/exports.cjs.map +0 -1
  223. package/dist/hooks/exports.d.cts +0 -1734
  224. package/dist/hooks/exports.mjs.map +0 -1
  225. package/dist/polling-BKnyavLI.d.cts +0 -8
  226. package/dist/txnEnum-7_o92X3N.d.ts +0 -164
  227. package/dist/types/exports.cjs +0 -1
  228. package/dist/types/exports.cjs.map +0 -1
  229. package/dist/types/exports.d.cts +0 -90
  230. package/dist/types/exports.mjs.map +0 -1
  231. package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
  232. package/dist/utils/exports.cjs +0 -2
  233. package/dist/utils/exports.cjs.map +0 -1
  234. package/dist/utils/exports.d.cts +0 -420
  235. package/dist/utils/exports.mjs.map +0 -1
  236. package/src/actions/dex/getIsTokenExploited.ts +0 -63
  237. package/src/hooks/dex/useExploitedTokens.ts +0 -57
@@ -18,21 +18,28 @@ export function usePriceImpact({
18
18
  const { getTokenPrice, isLoading } = useTokenPrices({
19
19
  tokens: tokenIn && tokenOut ? [tokenIn, tokenOut] : undefined,
20
20
  });
21
+ const tokenInPrice = getTokenPrice(tokenIn);
22
+ const tokenOutPrice = getTokenPrice(tokenOut);
23
+
21
24
  const priceImpact = useMemo(() => {
22
25
  if (!tokenIn || !tokenOut || !formattedAmountIn || !formattedAmountOut)
23
26
  return undefined;
24
27
 
25
- const tokenInPrice = getTokenPrice(tokenIn);
26
- const tokenOutPrice = getTokenPrice(tokenOut);
27
-
28
- if (!tokenInPrice || !tokenOutPrice) return null;
28
+ if (tokenInPrice == null || tokenOutPrice == null) return null;
29
29
  return computePriceImpact(
30
30
  tokenInPrice.toString(),
31
31
  tokenOutPrice.toString(),
32
32
  formattedAmountIn,
33
33
  formattedAmountOut,
34
34
  );
35
- }, [tokenIn, tokenOut, formattedAmountIn, formattedAmountOut]);
35
+ }, [
36
+ tokenIn,
37
+ tokenOut,
38
+ formattedAmountIn,
39
+ formattedAmountOut,
40
+ tokenInPrice,
41
+ tokenOutPrice,
42
+ ]);
36
43
  return {
37
44
  data: priceImpact,
38
45
  isLoading,
@@ -14,6 +14,7 @@ import {
14
14
 
15
15
  import { getEnsoClient } from "../../actions/clients/getEnsoClient";
16
16
  import { getBendDemultiplyBundle } from "../../actions/enso/getBendDemultiplyBundle";
17
+ import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
17
18
  import { POLLING } from "../../enum/polling";
18
19
  import { assertPublicClient } from "../../errors/assert";
19
20
  import type { Token } from "../../types/dex";
@@ -63,6 +64,9 @@ export function useBendDemultiply(
63
64
  primaryAddress,
64
65
  ensoWalletV2Address,
65
66
  });
67
+ const proxyAggregatorsThroughVercel = useBeraFlag(
68
+ "proxyAggregatorsThroughVercel",
69
+ );
66
70
 
67
71
  const QUERY_KEY =
68
72
  collateralToken &&
@@ -96,6 +100,7 @@ export function useBendDemultiply(
96
100
  currentDebt,
97
101
  ensoWalletV2Address,
98
102
  isAuthorized,
103
+ proxyAggregatorsThroughVercel ?? false,
99
104
  ] as const)
100
105
  : null;
101
106
 
@@ -116,6 +121,7 @@ export function useBendDemultiply(
116
121
  currentDebt,
117
122
  ensoWalletV2Address,
118
123
  isAuthorized,
124
+ proxyAggregatorsThroughVercel,
119
125
  ]) => {
120
126
  assertPublicClient(publicClient);
121
127
 
@@ -140,7 +146,9 @@ export function useBendDemultiply(
140
146
  marketId,
141
147
  primaryAddress,
142
148
  chainId,
143
- ensoClient: getEnsoClient(),
149
+ ensoClient: getEnsoClient({
150
+ baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
151
+ }),
144
152
  slippage,
145
153
  publicClient,
146
154
  collateralPriceInLoanAsset,
@@ -14,6 +14,7 @@ import {
14
14
 
15
15
  import { getEnsoClient } from "../../actions/clients/getEnsoClient";
16
16
  import { getBendMultiplyBundle } from "../../actions/enso/getBendMultiplyBundle";
17
+ import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
17
18
  import { POLLING } from "../../enum/polling";
18
19
  import { assertPublicClient } from "../../errors/assert";
19
20
  import type { Token } from "../../types/dex";
@@ -65,6 +66,9 @@ export function useBendMultiply(
65
66
  primaryAddress,
66
67
  ensoWalletV2Address,
67
68
  });
69
+ const proxyAggregatorsThroughVercel = useBeraFlag(
70
+ "proxyAggregatorsThroughVercel",
71
+ );
68
72
 
69
73
  const QUERY_KEY =
70
74
  collateralToken &&
@@ -99,6 +103,7 @@ export function useBendMultiply(
99
103
  formattedCollateralPriceInLoanAsset,
100
104
  ensoWalletV2Address,
101
105
  isAuthorized,
106
+ proxyAggregatorsThroughVercel ?? false,
102
107
  ] as const)
103
108
  : null;
104
109
 
@@ -120,6 +125,7 @@ export function useBendMultiply(
120
125
  formattedCollateralPriceInLoanAsset,
121
126
  ensoWalletV2Address,
122
127
  isAuthorized,
128
+ proxyAggregatorsThroughVercel,
123
129
  ]) => {
124
130
  assertPublicClient(publicClient);
125
131
 
@@ -146,7 +152,9 @@ export function useBendMultiply(
146
152
  marketId,
147
153
  primaryAddress,
148
154
  chainId,
149
- ensoClient: getEnsoClient(),
155
+ ensoClient: getEnsoClient({
156
+ baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
157
+ }),
150
158
  slippage,
151
159
  leverageMultiplier,
152
160
  publicClient,
@@ -8,6 +8,7 @@ import { defaultChainId as berachainChainId } from "@berachain/config/internal";
8
8
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
9
9
 
10
10
  import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
11
+ import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
11
12
  import { POLLING } from "../../enum/polling";
12
13
  import {
13
14
  assertAddress,
@@ -86,17 +87,24 @@ export function useBendZapSupply(
86
87
  options,
87
88
  );
88
89
 
89
- const { data: zapSupplyAmount } = useGetConvertToAssets({
90
+ const {
91
+ data: zapSupplyAmount,
92
+ isLoading: isZapSupplyAmountLoading,
93
+ error: zapSupplyAmountError,
94
+ } = useGetConvertToAssets({
90
95
  sharesAmount: BigInt(swrResponse.data?.amountOut ?? 0),
91
96
  vaultAddress: bendVault.address,
97
+ vaultChainId: bendVault.chainId,
92
98
  });
93
99
 
94
- const { data: priceImpact } = usePriceImpact({
95
- tokenIn: tokenIn,
96
- tokenOut: loanToken,
97
- formattedAmountIn: amount,
98
- formattedAmountOut: zapSupplyAmount?.formatted ?? "0",
99
- });
100
+ const { data: priceImpact, isLoading: isPriceImpactLoading } = usePriceImpact(
101
+ {
102
+ tokenIn: tokenIn,
103
+ tokenOut: loanToken,
104
+ formattedAmountIn: amount,
105
+ formattedAmountOut: zapSupplyAmount?.formatted ?? "0",
106
+ },
107
+ );
100
108
 
101
109
  const isCrossChain = tokenIn?.chainId && tokenIn.chainId !== berachainChainId;
102
110
 
@@ -135,7 +143,10 @@ export function useBendZapSupply(
135
143
  return {
136
144
  ...swrResponse,
137
145
  zapSupplyAmount,
146
+ zapSupplyAmountError,
147
+ isZapSupplyAmountLoading,
138
148
  priceImpact,
149
+ isPriceImpactLoading,
139
150
  hasInsufficientNativeBalance,
140
151
  isCrossChain,
141
152
  nativeFee,
@@ -157,8 +168,12 @@ export function useBendZapSupplyHelper(
157
168
  options?: DefaultHookOptions,
158
169
  ) {
159
170
  const { address: fromAddress } = useBeraWallet();
171
+ const proxyAggregatorsThroughVercel = useBeraFlag(
172
+ "proxyAggregatorsThroughVercel",
173
+ );
160
174
 
161
175
  const isEnabled =
176
+ (options?.opts?.isEnabled ?? true) &&
162
177
  !!tokenIn &&
163
178
  !!loanToken &&
164
179
  !!bendVault &&
@@ -173,12 +188,14 @@ export function useBendZapSupplyHelper(
173
188
  const QUERY_KEY = isEnabled
174
189
  ? ([
175
190
  "useBendZapSupply",
191
+ fromAddress,
176
192
  tokenIn,
177
193
  loanToken,
178
194
  bendVault,
179
195
  rewardVault,
180
196
  amount,
181
197
  slippage,
198
+ proxyAggregatorsThroughVercel ?? false,
182
199
  ] as const)
183
200
  : null;
184
201
 
@@ -186,6 +203,7 @@ export function useBendZapSupplyHelper(
186
203
  QUERY_KEY,
187
204
  async ([
188
205
  ,
206
+ fromAddress,
189
207
  tokenIn,
190
208
  loanToken,
191
209
  bendVault,
@@ -206,6 +224,7 @@ export function useBendZapSupplyHelper(
206
224
  slippage,
207
225
  account: fromAddress,
208
226
  rewardVault,
227
+ proxyAggregatorsThroughVercel,
209
228
  });
210
229
  },
211
230
  {
@@ -10,6 +10,7 @@ import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
10
10
 
11
11
  import { getEnsoClient } from "../../actions/clients/getEnsoClient";
12
12
  import { getEnsoSwapBundle } from "../../actions/enso/getEnsoSwapBundle";
13
+ import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
13
14
  import { POLLING } from "../../enum/polling";
14
15
  import {
15
16
  assertAddress,
@@ -45,7 +46,12 @@ export function useEnsoSwapBundle({
45
46
  }) {
46
47
  const { address: fromAddress } = useBeraWallet();
47
48
  const wagmiConfig = useConfig();
48
- const ensoClient = getEnsoClient();
49
+ const proxyAggregatorsThroughVercel = useBeraFlag(
50
+ "proxyAggregatorsThroughVercel",
51
+ );
52
+ const ensoClient = getEnsoClient({
53
+ baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
54
+ });
49
55
 
50
56
  const { refresh: refreshBalances } = usePollWalletBalances();
51
57
 
@@ -59,12 +65,20 @@ export function useEnsoSwapBundle({
59
65
  !!tokenIn.chainId;
60
66
 
61
67
  const QUERY_KEY = isEnabled
62
- ? (["useEnsoSwapBundle", tokenIn, tokenOut, amount, slippage] as const)
68
+ ? ([
69
+ "useEnsoSwapBundle",
70
+ fromAddress,
71
+ tokenIn,
72
+ tokenOut,
73
+ amount,
74
+ slippage,
75
+ proxyAggregatorsThroughVercel ?? false,
76
+ ] as const)
63
77
  : null;
64
78
 
65
79
  const swrResponse = useSWR(
66
80
  QUERY_KEY,
67
- async ([, tokenIn, tokenOut, amount, slippage]) => {
81
+ async ([, fromAddress, tokenIn, tokenOut, amount, slippage]) => {
68
82
  assertAddress(fromAddress, "fromAddress");
69
83
  assertAddress(tokenIn?.address, "tokenInAddress");
70
84
  assertDefined(tokenIn?.chainId, "tokenInChainId");
@@ -4,6 +4,7 @@ import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
4
4
 
5
5
  import { getEnsoClient } from "../../actions/clients/getEnsoClient";
6
6
  import { getEnsoUserTokensWithBalances } from "../../actions/enso/getEnsoUserTokensWithBalances";
7
+ import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
7
8
  import { POLLING } from "../../enum/polling";
8
9
  import type { BalanceToken } from "../../types/dex";
9
10
  import type { DefaultHookOptions } from "../../types/global";
@@ -14,11 +15,19 @@ export function useEnsoUserTokensWithBalances(
14
15
  ) {
15
16
  const { address: fromAddress } = useBeraWallet();
16
17
  const wagmiConfig = useConfig();
18
+ const proxyAggregatorsThroughVercel = useBeraFlag(
19
+ "proxyAggregatorsThroughVercel",
20
+ );
17
21
  const isEnabled = !!fromAddress && (options?.opts?.isEnabled ?? true);
18
22
 
19
23
  const QUERY_KEY =
20
24
  isEnabled && wagmiConfig
21
- ? (["useEnsoUserTokensWithBalances", fromAddress, chainId] as const)
25
+ ? ([
26
+ "useEnsoUserTokensWithBalances",
27
+ fromAddress,
28
+ chainId,
29
+ proxyAggregatorsThroughVercel ?? false,
30
+ ] as const)
22
31
  : null;
23
32
 
24
33
  const swrResponse = useSWR(
@@ -28,7 +37,9 @@ export function useEnsoUserTokensWithBalances(
28
37
  account: fromAddress,
29
38
  wagmiConfig,
30
39
  chainId: chainId ?? "all",
31
- ensoClient: getEnsoClient(),
40
+ ensoClient: getEnsoClient({
41
+ baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
42
+ }),
32
43
  }),
33
44
  {
34
45
  refreshInterval: POLLING.NORMAL,
@@ -13,7 +13,6 @@ export * from "./dex/useAllUserPools";
13
13
  export * from "./dex/useApiPool";
14
14
  export * from "./dex/useBexStatus";
15
15
  export * from "./dex/useCreatePool";
16
- export * from "./dex/useExploitedTokens";
17
16
  export { useGlobalLiquidityAndSwapVolume } from "./dex/useGlobalLiquidityAndSwapVolume";
18
17
  export * from "./dex/useLiquidityMismatch";
19
18
  export * from "./dex/useLpPosition";
@@ -36,20 +35,6 @@ export * from "./enso/useBendZapSupply";
36
35
  export * from "./enso/useEnsoSwapBundle";
37
36
  export * from "./enso/useEnsoUserTokensWithBalances";
38
37
  export * from "./enso/useZapStakeBera";
39
- export { useCreateProposal } from "./governance/useCreateProposal";
40
- export * from "./governance/useGetPastVotes";
41
- export * from "./governance/useHasVoted";
42
- export * from "./governance/useIsCanceller";
43
- export * from "./governance/usePollAllProposals";
44
- export * from "./governance/usePollProposal";
45
- export * from "./governance/usePollProposalThreshold";
46
- export * from "./governance/usePollProposalVotes";
47
- export * from "./governance/usePollUserDelegates";
48
- export * from "./governance/useProposalFromTx";
49
- export * from "./governance/useProposalSnapshot";
50
- export * from "./governance/useProposalState";
51
- export * from "./governance/useProposalTimelockState";
52
- export * from "./governance/useQuorum";
53
38
  export * from "./honey/useCappedGlobally";
54
39
  export * from "./honey/useCappedRelatively";
55
40
  export * from "./honey/useCollateralWeights";
@@ -63,6 +48,7 @@ export * from "./honey/useIsBadCollateralAsset";
63
48
  export * from "./honey/useIsBasketModeEnabled";
64
49
  export * from "./honey/usePythLatestPrices";
65
50
  export * from "./perps/usePythUpdateFee";
51
+ export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
66
52
  export * from "./pol/useBgtAprSimulation";
67
53
  export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
68
54
  export { useClaimableFees } from "./pol/useClaimableFees";
@@ -126,6 +112,7 @@ export * from "./validators/useValidator";
126
112
  export { useValidatorAnalytics } from "./validators/useValidatorAnalytics";
127
113
  export { useValidatorCommission } from "./validators/useValidatorCommission";
128
114
  export { useValidatorEstimatedBgtPerYear } from "./validators/useValidatorEstimatedBgtPerYear";
115
+ export { useValidatorIncentiveDistribution } from "./validators/useValidatorIncentiveDistribution";
129
116
  export { useValidatorQueuedCommission } from "./validators/useValidatorQueuedCommission";
130
117
  export { useValidatorQueuedOperatorAddress } from "./validators/useValidatorQueuedOperatorAddress";
131
118
  export { useValidatorQueuedRewardAllocation } from "./validators/useValidatorQueuedRewardAllocation";
@@ -0,0 +1,14 @@
1
+ export { useCreateProposal } from "./useCreateProposal";
2
+ export * from "./useGetPastVotes";
3
+ export * from "./useHasVoted";
4
+ export * from "./useIsCanceller";
5
+ export * from "./usePollAllProposals";
6
+ export * from "./usePollProposal";
7
+ export * from "./usePollProposalThreshold";
8
+ export * from "./usePollProposalVotes";
9
+ export * from "./usePollUserDelegates";
10
+ export * from "./useProposalFromTx";
11
+ export * from "./useProposalSnapshot";
12
+ export * from "./useProposalState";
13
+ export * from "./useProposalTimelockState";
14
+ export * from "./useQuorum";
@@ -0,0 +1,49 @@
1
+ import useSWR from "swr";
2
+
3
+ import { useBeraWallet } from "@berachain/wagmi/hooks";
4
+
5
+ import { getAutoclaimedIncentives } from "../../actions/pol/getAutoclaimedIncentives";
6
+ import { BeraError } from "../../errors/BeraError";
7
+ import type { AutoclaimedIncentivesResponse } from "../../types/bribe-boost";
8
+ import type { DefaultHookReturnType } from "../../types/global";
9
+
10
+ interface UseAutoclaimedIncentivesArgs {
11
+ // Hard gate: when false the SWR key is null, so the API is never called.
12
+ // The banner consumer flips this to true only after both `!isBgtPolRewardToken`
13
+ // and `bgtIncentiveDistributor.paused() === true` have been verified.
14
+ enabled: boolean;
15
+ }
16
+
17
+ export function useAutoclaimedIncentives({
18
+ enabled,
19
+ }: UseAutoclaimedIncentivesArgs): DefaultHookReturnType<AutoclaimedIncentivesResponse | null> {
20
+ const { address: account } = useBeraWallet();
21
+
22
+ const QUERY_KEY =
23
+ enabled && account
24
+ ? (["useAutoclaimedIncentives", account] as const)
25
+ : null;
26
+
27
+ const swrResponse = useSWR(
28
+ QUERY_KEY,
29
+ async ([, account]) => {
30
+ if (!account) {
31
+ throw new BeraError({
32
+ message: "useAutoclaimedIncentives needs a logged in account",
33
+ level: "error",
34
+ });
35
+ }
36
+ return await getAutoclaimedIncentives({ account });
37
+ },
38
+ {
39
+ revalidateOnFocus: false,
40
+ revalidateOnReconnect: false,
41
+ revalidateIfStale: false,
42
+ },
43
+ );
44
+
45
+ return {
46
+ ...swrResponse,
47
+ refresh: () => swrResponse?.mutate?.(),
48
+ };
49
+ }
@@ -7,7 +7,7 @@ import type { DefaultHookReturnType } from "../../types/global";
7
7
  import { dailyResolution } from "../../utils/filter";
8
8
 
9
9
  type UseStakedAPR = {
10
- _timestamp: number;
10
+ timestamp: number;
11
11
  apr: string;
12
12
  }[];
13
13
  export function useStakedAPR({
@@ -26,7 +26,7 @@ export function useStakedAPR({
26
26
  );
27
27
 
28
28
  return sortedStakedBeraSnapshots.map((item) => ({
29
- _timestamp: item.timestamp,
29
+ timestamp: item.timestamp,
30
30
  apr: item.apr,
31
31
  }));
32
32
  });
@@ -1,17 +1,13 @@
1
1
  import useSWR from "swr";
2
2
  import type { Address } from "viem";
3
3
 
4
+ import type { VaultStatsByDayResponse } from "@berachain/graphql/api";
5
+
4
6
  import { getStakingDailyAssets } from "../../actions/pol/getStakingDailyAssets";
5
7
  import type { DefaultHookReturnType } from "../../types/global";
6
8
  import { dailyResolution } from "../../utils/filter";
7
9
 
8
- type UseStakedBeraSnapshot = Record<
9
- Address,
10
- {
11
- _timestamp: number;
12
- total_assets: string;
13
- }[]
14
- >;
10
+ type UseStakedBeraSnapshot = Record<Address, VaultStatsByDayResponse>;
15
11
  export function useStakedSnapshots({
16
12
  range,
17
13
  addresses,
@@ -30,7 +26,7 @@ export function useStakedSnapshots({
30
26
  range,
31
27
  });
32
28
  const sortedStakingDailyAssets = dailyResolution(
33
- unstakingDailyAssets.sort((a, b) => a._timestamp - b._timestamp),
29
+ unstakingDailyAssets.sort((a, b) => a.timestamp - b.timestamp),
34
30
  );
35
31
  return {
36
32
  [address]: sortedStakingDailyAssets,
@@ -41,7 +37,7 @@ export function useStakedSnapshots({
41
37
  // Merge all address data into a single object
42
38
  return sortedStakingDailyAssetsArray.reduce(
43
39
  (acc, addressData) => ({ ...acc, ...addressData }),
44
- {} as Record<Address, { _timestamp: number; total_assets: string }[]>,
40
+ {} as UseStakedBeraSnapshot,
45
41
  );
46
42
  });
47
43
 
@@ -56,6 +56,8 @@ export function useValidator(
56
56
  lastDayDistributedBGTAmount:
57
57
  indexerValidator?.dynamicData?.lastDayDistributedBGTAmount ??
58
58
  "",
59
+ lastDayProposedBlockCount:
60
+ indexerValidator?.dynamicData?.lastDayProposedBlockCount ?? 0,
59
61
  activeBoostAmountRank:
60
62
  indexerValidator?.dynamicData?.activeBoostAmountRank ?? 0,
61
63
 
@@ -0,0 +1,39 @@
1
+ import useSWR from "swr";
2
+ import type { Address } from "viem";
3
+
4
+ import type { GetValidatorIncentiveDistributionQuery } from "@berachain/graphql/pol/subgraph";
5
+
6
+ import { getValidatorIncentiveDistribution } from "../../actions/validators/getValidatorIncentiveDistribution";
7
+ import { POLLING } from "../../enum/polling";
8
+ import type { DefaultHookReturnType } from "../../types/global";
9
+
10
+ /**
11
+ * Historical per-validator incentive distribution. Split from
12
+ * `useValidatorAnalytics` so the IncentivesEarned chart can switch data
13
+ * sources independently of the other charts that still consume the umbrella
14
+ * `GetValidatorAnalytics` query.
15
+ */
16
+ export function useValidatorIncentiveDistribution({
17
+ pubkey,
18
+ dayRange,
19
+ }: {
20
+ pubkey: Address | undefined;
21
+ dayRange: number;
22
+ }): DefaultHookReturnType<GetValidatorIncentiveDistributionQuery> {
23
+ const QUERY_KEY =
24
+ pubkey && dayRange
25
+ ? (["useValidatorIncentiveDistribution", pubkey, dayRange] as const)
26
+ : null;
27
+
28
+ const swrResponse = useSWR(
29
+ QUERY_KEY,
30
+ async ([, pubkey, dayRange]) => {
31
+ return await getValidatorIncentiveDistribution({ pubkey, dayRange });
32
+ },
33
+ {
34
+ refreshInterval: POLLING.SLOW,
35
+ },
36
+ );
37
+
38
+ return { ...swrResponse, refresh: () => swrResponse.mutate() };
39
+ }
@@ -32,6 +32,14 @@ export interface BribeBoostRewardProof {
32
32
  | null;
33
33
  }
34
34
 
35
+ // Response shape of GET /api/v1/wallets/:wallet/autoclaimed:
36
+ // { [wallet]: { [validatorPubkey]: { [tokenAddress]: rawAmount (stringified bigint) } } }
37
+ // Top-level wallet key is the lowercase wallet address that was queried.
38
+ export type AutoclaimedIncentivesResponse = Record<
39
+ Address,
40
+ Record<Address, Record<Address, string>>
41
+ >;
42
+
35
43
  export interface BribeBoostValidatorApr {
36
44
  id: string;
37
45
  boost_total_bgt: string;
@@ -2,7 +2,6 @@ export * from "./bribe-boost.d";
2
2
  export * from "./dex.d";
3
3
  export * from "./enso.d";
4
4
  export * from "./global.d";
5
- export * from "./governance.d";
6
5
  export * from "./honeySwap.d";
7
6
  export * from "./pol.d";
8
7
  export * from "./staking.d";
@@ -0,0 +1 @@
1
+ export * from "../governance.d";
@@ -1,6 +1,7 @@
1
1
  import { BeraTracing, type SpanContext } from "../errors/BeraTracing";
2
2
  import { RequestError } from "../errors/RequestError";
3
3
  import { getErrorResponse } from "./getErrorResponse";
4
+ import { sanitizeRpcUrl } from "./sanitizeRpcUrl";
4
5
 
5
6
  type RequestOptions = RequestInit;
6
7
 
@@ -18,10 +19,10 @@ export async function beraFetch(
18
19
  },
19
20
  ) {
20
21
  try {
21
- let spanUrl = (
22
+ let spanUrl = sanitizeRpcUrl(
22
23
  typeof endpoint === "string" || endpoint instanceof URL
23
24
  ? endpoint.toString()
24
- : endpoint.url.toString()
25
+ : endpoint.url.toString(),
25
26
  ).replace(/0x[a-fA-F0-9]{40}/g, ":address");
26
27
 
27
28
  if (spanContext?.keepQueryParams !== true && URL.canParse(spanUrl)) {
@@ -43,10 +44,15 @@ export async function beraFetch(
43
44
  }
44
45
  }
45
46
 
47
+ const endpointName =
48
+ typeof endpoint === "string" || endpoint instanceof URL
49
+ ? undefined
50
+ : endpoint.name;
51
+
46
52
  return await BeraTracing.startSpan(
47
53
  {
48
54
  op: "beraFetch",
49
- name: "beraFetch",
55
+ name: endpointName ? `beraFetch ${endpointName}` : "beraFetch",
50
56
  attributes:
51
57
  typeof endpoint === "string" || endpoint instanceof URL
52
58
  ? {
@@ -24,5 +24,6 @@ export {
24
24
  wBeraToken as internal_wBeraToken,
25
25
  } from "./tokens";
26
26
  export * from "./tokenWrapping";
27
+ export { tracedTransport } from "./tracedTransport";
27
28
  export * from "./truncateHash";
28
29
  export * from "./validatorUptimeStatus";
@@ -7,6 +7,8 @@ import {
7
7
  getRpcUrls,
8
8
  } from "@berachain/config/internal";
9
9
 
10
+ import { tracedTransport } from "./tracedTransport";
11
+
10
12
  /**
11
13
  * This is a singleton to avoid creating a new client for each request.
12
14
  *
@@ -31,10 +33,10 @@ export const getServerSidePublicClient = (
31
33
  rpcs.publicJsonRpcUrl,
32
34
  ]
33
35
  .filter((i) => i)
34
- .map((url) => http(url));
36
+ .map((url) => tracedTransport(http(url)));
35
37
 
36
38
  if (fallbackTransports.length === 0) {
37
- fallbackTransports.push(http());
39
+ fallbackTransports.push(tracedTransport(http()));
38
40
  }
39
41
  const chain = chainId === ChainId.MAINNET ? berachain : berachainBepolia;
40
42
  const client = createPublicClient({
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Strips secret tokens from RPC URLs for safe use in span attributes and logs.
3
+ *
4
+ * QuickNode URLs embed API keys as path segments, e.g.:
5
+ * https://polished-morning-sun.bera-mainnet.quiknode.pro/abc123def/
6
+ * This function trims the subpath, producing:
7
+ * https://polished-morning-sun.bera-mainnet.quiknode.pro/
8
+ */
9
+ export function sanitizeRpcUrl(url: string | undefined): string {
10
+ if (!url) return "";
11
+ try {
12
+ const parsed = new URL(url);
13
+ if (parsed.hostname.endsWith(".quiknode.pro")) {
14
+ parsed.pathname = "/";
15
+ parsed.search = "";
16
+ return parsed.toString();
17
+ }
18
+ return url;
19
+ } catch {
20
+ return url;
21
+ }
22
+ }
@@ -0,0 +1,35 @@
1
+ import type { Transport } from "viem";
2
+
3
+ import { BeraTracing } from "../errors/BeraTracing";
4
+ import { sanitizeRpcUrl } from "./sanitizeRpcUrl";
5
+
6
+ /**
7
+ * Wraps a viem Transport to trace each RPC request via BeraTracing.
8
+ *
9
+ * Each `request()` call is wrapped in a span with the JSON-RPC method name,
10
+ * transport type, and URL as attributes. Works with `http()`, `fallback()`,
11
+ * and any other viem transport.
12
+ */
13
+ export function tracedTransport<T extends Transport>(transport: T): T {
14
+ return ((opts: Parameters<Transport>[0]) => {
15
+ const result = transport(opts);
16
+ const originalRequest = result.request;
17
+
18
+ result.request = async (args, options) => {
19
+ return BeraTracing.startSpan(
20
+ {
21
+ name: `RPC ${args.method}`,
22
+ op: "rpc.request",
23
+ attributes: {
24
+ "rpc.method": args.method,
25
+ "rpc.transport": result.config.type,
26
+ "rpc.url": sanitizeRpcUrl(result.value?.url),
27
+ },
28
+ },
29
+ () => originalRequest(args, options),
30
+ );
31
+ };
32
+
33
+ return result;
34
+ }) as T;
35
+ }