@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.
Files changed (225) 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-DBOIV65x.d.ts +144 -0
  4. package/dist/abi/exports.mjs +3 -4
  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 +108 -187
  8. package/dist/actions/exports.mjs +97 -158
  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-VA3BQ34H.mjs → chunk-3EARVV7K.mjs} +20 -9
  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-7TFV6UKF.mjs → chunk-BGMRHTBQ.mjs} +0 -1
  18. package/dist/{chunk-3M47ZRXT.mjs → chunk-CDFWPU2R.mjs} +73 -17
  19. package/dist/{chunk-GWSTVITN.mjs → chunk-CDK4YV3D.mjs} +0 -1
  20. package/dist/{chunk-KL6YZ5VR.mjs → chunk-DKMAIU74.mjs} +0 -1
  21. package/dist/chunk-EXIUPSFN.mjs +86 -0
  22. package/dist/{chunk-VA5L5FDG.mjs → chunk-FFB5LFDW.mjs} +2 -3
  23. package/dist/{chunk-ZCEFC2TK.mjs → chunk-HQCOU6GY.mjs} +0 -1
  24. package/dist/{chunk-SGZP4O6R.mjs → chunk-HSSJKHZ4.mjs} +11 -11
  25. package/dist/{chunk-7QKRRIHI.mjs → chunk-J5I45WGQ.mjs} +77 -152
  26. package/dist/chunk-KQUMKB66.mjs +89 -0
  27. package/dist/{chunk-JA4DHMTG.mjs → chunk-NBYLMO2L.mjs} +0 -1
  28. package/dist/{chunk-4GFN4LEP.mjs → chunk-NPBQLVL3.mjs} +4 -21
  29. package/dist/{chunk-I3FTWD6I.mjs → chunk-O2NQFKJK.mjs} +1 -1
  30. package/dist/{chunk-2R73G2PO.mjs → chunk-QJIXTYTZ.mjs} +121 -765
  31. package/dist/{chunk-GLWPRM33.mjs → chunk-SGIJVHZO.mjs} +0 -1
  32. package/dist/chunk-SZ5C44L5.mjs +35 -0
  33. package/dist/{chunk-5NMATIH4.mjs → chunk-WXXOISTU.mjs} +1 -35
  34. package/dist/chunk-XIYN6AL6.mjs +160 -0
  35. package/dist/contexts/exports.d.ts +2 -2
  36. package/dist/contexts/exports.mjs +11 -9
  37. package/dist/enum/exports.d.ts +1 -1
  38. package/dist/enum/exports.mjs +3 -16
  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 +5 -90
  42. package/dist/errors/exports.mjs +19 -10
  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 +80 -236
  47. package/dist/hooks/exports.mjs +609 -1508
  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 +24 -7
  58. package/dist/utils/exports.mjs +49 -11
  59. package/package.json +60 -13
  60. package/src/actions/__test/transports.ts +61 -0
  61. package/src/actions/clients/BeraApolloClient.ts +9 -0
  62. package/src/actions/clients/exports.ts +4 -0
  63. package/src/actions/clients/getApolloClient.ts +70 -25
  64. package/src/actions/clients/getEnsoClient.ts +20 -9
  65. package/src/actions/dex/aggregators/base.ts +1 -1
  66. package/src/actions/dex/aggregators/enso/enso.ts +27 -17
  67. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
  68. package/src/actions/dex/aggregators/kyberswap.ts +18 -23
  69. package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
  70. package/src/actions/exports.ts +5 -10
  71. package/src/actions/governance/exports.ts +9 -0
  72. package/src/actions/governance/getAllProposals.ts +10 -65
  73. package/src/actions/governance/getProposalDetails.ts +6 -33
  74. package/src/actions/governance/getProposalVotes.ts +8 -15
  75. package/src/actions/honey/getChartData.ts +27 -21
  76. package/src/actions/honey/getHoney24hVolume.ts +27 -0
  77. package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
  78. package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
  79. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
  80. package/src/actions/pol/getEarnedStakedBeraVault.ts +15 -9
  81. package/src/actions/pol/getGlobalData.ts +1 -0
  82. package/src/actions/pol/getHeroEarnVaults.ts +62 -0
  83. package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
  84. package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
  85. package/src/actions/pol/getStakingDailyAssets.ts +11 -8
  86. package/src/actions/server/exports.ts +1 -0
  87. package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
  88. package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
  89. package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
  90. package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
  91. package/src/actions/validators/getValidatorAnalytics.ts +20 -21
  92. package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
  93. package/src/data/contracts.ts +5 -0
  94. package/src/enum/contracts.ts +1 -0
  95. package/src/enum/exports.ts +0 -1
  96. package/src/enum/governance/exports.ts +1 -0
  97. package/src/errors/BeraError.ts +47 -7
  98. package/src/errors/BeraTracing.unit.test.ts +65 -0
  99. package/src/errors/RequestError.ts +15 -2
  100. package/src/errors/exports.ts +5 -0
  101. package/src/errors/getRevertReason.integration.test.ts +3 -3
  102. package/src/errors/spanStatus.ts +78 -0
  103. package/src/errors/spanStatus.unit.test.ts +62 -0
  104. package/src/hooks/dex/useCreatePool.ts +1 -88
  105. package/src/hooks/dex/useOnChainPoolData.ts +27 -2
  106. package/src/hooks/dex/usePriceImpact.ts +12 -5
  107. package/src/hooks/enso/useBendDemultiply.ts +9 -1
  108. package/src/hooks/enso/useBendMultiply.ts +9 -1
  109. package/src/hooks/enso/useBendZapSupply.ts +26 -7
  110. package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
  111. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
  112. package/src/hooks/exports.ts +3 -16
  113. package/src/hooks/governance/exports.ts +14 -0
  114. package/src/hooks/honey/useHoney24hVolume.ts +16 -0
  115. package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
  116. package/src/hooks/pol/useStakedAPR.ts +2 -2
  117. package/src/hooks/pol/useStakedSnapshots.ts +5 -9
  118. package/src/hooks/validators/useValidator.ts +2 -0
  119. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
  120. package/src/types/bribe-boost.d.ts +8 -0
  121. package/src/types/exports.ts +0 -1
  122. package/src/types/governance/exports.ts +1 -0
  123. package/src/utils/beraFetch.ts +76 -15
  124. package/src/utils/exports.ts +1 -0
  125. package/src/utils/getServerSideClient.ts +4 -2
  126. package/src/utils/sanitizeRpcUrl.ts +22 -0
  127. package/src/utils/tracedTransport.ts +35 -0
  128. package/dist/BeraError-_mQdkanr.d.ts +0 -94
  129. package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
  130. package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
  131. package/dist/RequestError-A8XJ6QR9.d.cts +0 -57
  132. package/dist/RequestError-Dk97z8rm.d.ts +0 -57
  133. package/dist/abi/exports.cjs +0 -4453
  134. package/dist/abi/exports.cjs.map +0 -1
  135. package/dist/abi/exports.d.cts +0 -6574
  136. package/dist/abi/exports.mjs.map +0 -1
  137. package/dist/actions/exports.cjs +0 -914
  138. package/dist/actions/exports.cjs.map +0 -1
  139. package/dist/actions/exports.d.cts +0 -1644
  140. package/dist/actions/exports.mjs.map +0 -1
  141. package/dist/chunk-2R73G2PO.mjs.map +0 -1
  142. package/dist/chunk-3M47ZRXT.mjs.map +0 -1
  143. package/dist/chunk-4GFN4LEP.mjs.map +0 -1
  144. package/dist/chunk-5N7QQS55.cjs +0 -130
  145. package/dist/chunk-5N7QQS55.cjs.map +0 -1
  146. package/dist/chunk-5NMATIH4.mjs.map +0 -1
  147. package/dist/chunk-7QKRRIHI.mjs.map +0 -1
  148. package/dist/chunk-7TFV6UKF.mjs.map +0 -1
  149. package/dist/chunk-A4FPM7U3.cjs +0 -63
  150. package/dist/chunk-A4FPM7U3.cjs.map +0 -1
  151. package/dist/chunk-BDHINMWQ.cjs +0 -417
  152. package/dist/chunk-BDHINMWQ.cjs.map +0 -1
  153. package/dist/chunk-BEHP54S3.cjs +0 -24
  154. package/dist/chunk-BEHP54S3.cjs.map +0 -1
  155. package/dist/chunk-EGDXV2PT.cjs +0 -36
  156. package/dist/chunk-EGDXV2PT.cjs.map +0 -1
  157. package/dist/chunk-EWBKSMPG.cjs +0 -13
  158. package/dist/chunk-EWBKSMPG.cjs.map +0 -1
  159. package/dist/chunk-F6ZW7ZDD.cjs +0 -403
  160. package/dist/chunk-F6ZW7ZDD.cjs.map +0 -1
  161. package/dist/chunk-FTXTRUYT.cjs +0 -170
  162. package/dist/chunk-FTXTRUYT.cjs.map +0 -1
  163. package/dist/chunk-GLWPRM33.mjs.map +0 -1
  164. package/dist/chunk-GWSTVITN.mjs.map +0 -1
  165. package/dist/chunk-H3Z37RYU.cjs +0 -15
  166. package/dist/chunk-H3Z37RYU.cjs.map +0 -1
  167. package/dist/chunk-I3FTWD6I.mjs.map +0 -1
  168. package/dist/chunk-JA4DHMTG.mjs.map +0 -1
  169. package/dist/chunk-KL6YZ5VR.mjs.map +0 -1
  170. package/dist/chunk-MXWPP6MS.cjs +0 -572
  171. package/dist/chunk-MXWPP6MS.cjs.map +0 -1
  172. package/dist/chunk-SGZP4O6R.mjs.map +0 -1
  173. package/dist/chunk-TDW5SPXR.cjs +0 -244
  174. package/dist/chunk-TDW5SPXR.cjs.map +0 -1
  175. package/dist/chunk-TGK3IXDN.cjs +0 -169
  176. package/dist/chunk-TGK3IXDN.cjs.map +0 -1
  177. package/dist/chunk-TJEW6YCJ.cjs +0 -97
  178. package/dist/chunk-TJEW6YCJ.cjs.map +0 -1
  179. package/dist/chunk-VA3BQ34H.mjs.map +0 -1
  180. package/dist/chunk-VA5L5FDG.mjs.map +0 -1
  181. package/dist/chunk-XSGCRLSD.cjs +0 -1844
  182. package/dist/chunk-XSGCRLSD.cjs.map +0 -1
  183. package/dist/chunk-XV3GG3HC.cjs +0 -135
  184. package/dist/chunk-XV3GG3HC.cjs.map +0 -1
  185. package/dist/chunk-Y5B224UX.cjs +0 -4698
  186. package/dist/chunk-Y5B224UX.cjs.map +0 -1
  187. package/dist/chunk-ZBTRKBSI.mjs +0 -169
  188. package/dist/chunk-ZBTRKBSI.mjs.map +0 -1
  189. package/dist/chunk-ZCEFC2TK.mjs.map +0 -1
  190. package/dist/contexts/exports.cjs +0 -83
  191. package/dist/contexts/exports.cjs.map +0 -1
  192. package/dist/contexts/exports.d.cts +0 -66
  193. package/dist/contexts/exports.mjs.map +0 -1
  194. package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
  195. package/dist/dex-C_BB0b0O.d.cts +0 -37
  196. package/dist/enum/exports.cjs +0 -59
  197. package/dist/enum/exports.cjs.map +0 -1
  198. package/dist/enum/exports.d.cts +0 -23
  199. package/dist/enum/exports.mjs.map +0 -1
  200. package/dist/errors/exports.cjs +0 -39
  201. package/dist/errors/exports.cjs.map +0 -1
  202. package/dist/errors/exports.d.cts +0 -413
  203. package/dist/errors/exports.mjs.map +0 -1
  204. package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
  205. package/dist/global.d-B7IeayVX.d.cts +0 -474
  206. package/dist/honey-CYm0RWf4.d.cts +0 -14
  207. package/dist/hooks/exports.cjs +0 -8333
  208. package/dist/hooks/exports.cjs.map +0 -1
  209. package/dist/hooks/exports.d.cts +0 -1748
  210. package/dist/hooks/exports.mjs.map +0 -1
  211. package/dist/polling-BKnyavLI.d.cts +0 -8
  212. package/dist/txnEnum-7_o92X3N.d.ts +0 -164
  213. package/dist/types/exports.cjs +0 -1
  214. package/dist/types/exports.cjs.map +0 -1
  215. package/dist/types/exports.d.cts +0 -90
  216. package/dist/types/exports.mjs.map +0 -1
  217. package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
  218. package/dist/utils/exports.cjs +0 -787
  219. package/dist/utils/exports.cjs.map +0 -1
  220. package/dist/utils/exports.d.cts +0 -412
  221. package/dist/utils/exports.mjs.map +0 -1
  222. package/src/actions/dex/getIsTokenExploited.ts +0 -63
  223. package/src/actions/honey/getHoneyGlobalData.ts +0 -21
  224. package/src/hooks/dex/useExploitedTokens.ts +0 -57
  225. package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
@@ -1,26 +1,28 @@
1
+ import {
2
+ getApolloClient
3
+ } from "./chunk-4Z4AK6SH.mjs";
1
4
  import {
2
5
  pythAbi
3
- } from "./chunk-GWSTVITN.mjs";
6
+ } from "./chunk-CDK4YV3D.mjs";
4
7
  import {
5
- BeraTracing,
6
8
  NotFoundError,
7
9
  TransactionFailedError
8
- } from "./chunk-5NMATIH4.mjs";
10
+ } from "./chunk-WXXOISTU.mjs";
9
11
  import {
10
12
  BeraMonitoring,
13
+ initBeraError
14
+ } from "./chunk-EXIUPSFN.mjs";
15
+ import {
11
16
  assertAddress,
12
17
  assertDefined,
13
- assertPublicClient,
14
- initBeraError
15
- } from "./chunk-ZBTRKBSI.mjs";
18
+ assertPublicClient
19
+ } from "./chunk-KQUMKB66.mjs";
16
20
  import {
17
21
  CAP_LIMIT_BUFFER,
18
22
  DEFAULT_METAMASK_GAS_LIMIT,
19
23
  beraFetch,
20
24
  beraFetchJson,
21
25
  bignumber_js_default,
22
- calculateTimestampFromDays,
23
- days,
24
26
  formatTimeLeft,
25
27
  getErrorResponse,
26
28
  getPythDefaultUpdateFee,
@@ -29,21 +31,25 @@ import {
29
31
  msToSeconds,
30
32
  seconds,
31
33
  yearsInSeconds
32
- } from "./chunk-3M47ZRXT.mjs";
34
+ } from "./chunk-CDFWPU2R.mjs";
33
35
  import {
34
36
  beraToken,
35
37
  getHoneyToken,
36
- isToken,
38
+ isToken
39
+ } from "./chunk-NPBQLVL3.mjs";
40
+ import {
37
41
  parseBaseArgs
38
- } from "./chunk-4GFN4LEP.mjs";
42
+ } from "./chunk-75M6TF7M.mjs";
43
+ import {
44
+ RequestError
45
+ } from "./chunk-XIYN6AL6.mjs";
39
46
  import {
40
47
  BeraError,
41
48
  InvalidArgumentError,
42
- RequestError,
43
49
  commonAbiErrors,
44
50
  parseDecodedError,
45
51
  parseViemError
46
- } from "./chunk-7QKRRIHI.mjs";
52
+ } from "./chunk-J5I45WGQ.mjs";
47
53
 
48
54
  // src/actions/bend/getConvertToAssets.ts
49
55
  import { formatEther } from "viem";
@@ -62,167 +68,6 @@ async function getConvertToAssets({
62
68
  return { raw: convertToAssets, formatted: formatEther(convertToAssets) };
63
69
  }
64
70
 
65
- // src/actions/clients/BeraApolloClient.ts
66
- import {
67
- ApolloClient,
68
- ServerError
69
- } from "@apollo/client";
70
- import { appConfig } from "@berachain/config/internal";
71
- var BeraApolloClient = class extends ApolloClient {
72
- /**
73
- * The URL of the endpoint. Used for error reporting only.
74
- */
75
- url;
76
- constructor(options) {
77
- super(options);
78
- this.url = options.url;
79
- }
80
- async query(options) {
81
- const queryName = getQueryName(options.query);
82
- const endpoint = {
83
- url: this.url,
84
- type: "graphql"
85
- };
86
- const tags = {
87
- "operation.type": "query",
88
- "operation.source.url": endpoint.url,
89
- "operation.source.type": endpoint.type,
90
- "operation.source.queryName": queryName
91
- };
92
- try {
93
- const executeQuery = () => super.query(
94
- options
95
- );
96
- const res = await BeraTracing.startSpan(
97
- {
98
- name: `GraphQL ${queryName}`,
99
- op: "BeraApolloClient.query",
100
- attributes: tags
101
- },
102
- executeQuery
103
- );
104
- if (res.error || res.data === void 0) {
105
- throw new BeraError({
106
- level: "fatal",
107
- tags,
108
- message: "Bera Apollo Client: No data returned from query, but error should be thrown since errorPolicy is none"
109
- });
110
- }
111
- return { data: res.data };
112
- } catch (error) {
113
- !appConfig.env.isProduction && console.error("BeraApolloClient error", error);
114
- if (ServerError.is(error)) {
115
- throw new RequestError({
116
- // reason: error,
117
- response: error.response,
118
- cause: error,
119
- statusCode: error.statusCode,
120
- endpoint,
121
- tags
122
- });
123
- }
124
- if (error instanceof TypeError) {
125
- throw new RequestError({
126
- level: "fatal",
127
- reason: "TypeError",
128
- response: error,
129
- cause: error,
130
- endpoint,
131
- tags
132
- });
133
- }
134
- throw new RequestError({
135
- response: error,
136
- tags,
137
- cause: error,
138
- endpoint
139
- });
140
- }
141
- }
142
- };
143
- function getQueryName(queryDefinition) {
144
- const likelyNode = queryDefinition.definitions.find(
145
- (def) => def.kind === "OperationDefinition"
146
- );
147
- return likelyNode?.name?.value;
148
- }
149
-
150
- // src/actions/clients/getApolloClient.ts
151
- import { InMemoryCache } from "@apollo/client";
152
- import { HttpLink } from "@apollo/client/link/http";
153
- import { getUriFromLink } from "@berachain/config";
154
- import { currentDapp } from "@berachain/config/internal";
155
- import apiResults from "@berachain/graphql/dex/api";
156
- import { gql } from "@apollo/client";
157
- function applyStellateClientName(url) {
158
- const headers = typeof url === "string" ? void 0 : url.headers;
159
- const isDapp = !!currentDapp;
160
- const isTest = process.env.VERCEL_ENV === "test";
161
- return {
162
- uri: getUriFromLink(url),
163
- headers: {
164
- ...headers,
165
- "x-graphql-client-name": `berachain.${isDapp ? "dapps" : isTest ? "test" : (
166
- // this tracks usage of the berajs package in other packages
167
- "berajs"
168
- )}`,
169
- "x-graphql-client-version": `${process.env.VERCEL_TARGET_ENV}.${process.env.VERCEL_GIT_COMMIT_SHA}`
170
- }
171
- };
172
- }
173
- function getClient(endpoint, {
174
- ssrMode,
175
- inMemoryCacheOptions
176
- } = {}) {
177
- const url = getUriFromLink(endpoint);
178
- const headers = typeof endpoint === "string" ? void 0 : endpoint.headers;
179
- return new BeraApolloClient({
180
- url,
181
- link: new HttpLink({
182
- uri: url,
183
- headers
184
- }),
185
- defaultOptions: {
186
- query: {
187
- // With the default none error policy, an error causes the promise to reject.
188
- errorPolicy: "none",
189
- fetchPolicy: "no-cache"
190
- }
191
- },
192
- cache: new InMemoryCache(inMemoryCacheOptions),
193
- ssrMode
194
- });
195
- }
196
- function getApolloClient(clientName, { ...args }) {
197
- const { config } = parseBaseArgs(args);
198
- switch (clientName) {
199
- case "api":
200
- return getClient(applyStellateClientName(config.api), {
201
- inMemoryCacheOptions: {
202
- possibleTypes: apiResults.possibleTypes
203
- }
204
- });
205
- case "bend.whisk":
206
- if (!config.bend.whiskApi) {
207
- throw new BeraError({
208
- message: "Bend whisk API is not configured on this chain",
209
- level: "error"
210
- });
211
- }
212
- return getClient(config.bend.whiskApi);
213
- case "honey.subgraph":
214
- return getClient(config.honey.subgraph);
215
- case "pol.subgraph":
216
- return getClient(config.pol.subgraph);
217
- case "pol.fees":
218
- return getClient(config.pol.feesSubgraph);
219
- case "governance.subgraph":
220
- return getClient(config.governance.subgraph);
221
- case "bex.subgraph":
222
- return getClient(config.bex.subgraph);
223
- }
224
- }
225
-
226
71
  // src/actions/dex/aggregators/base.ts
227
72
  import { formatUnits, isAddress, zeroAddress } from "viem";
228
73
  var BaseAggregator = class _BaseAggregator {
@@ -349,7 +194,7 @@ var BaseAggregator = class _BaseAggregator {
349
194
  }
350
195
  async fetch(url, options) {
351
196
  try {
352
- return beraFetch(
197
+ return await beraFetch(
353
198
  { url, name: this.name, type: this.type },
354
199
  {
355
200
  method: "GET",
@@ -726,506 +571,23 @@ async function getPoolHistoricalData({
726
571
  return data.poolGetSnapshots;
727
572
  }
728
573
 
729
- // src/actions/governance/checkProposalField.ts
730
- import { isAddress as isAddress3, isHex as isHex3 } from "viem";
731
- function checkProposalField({
732
- fieldOrType,
733
- value,
734
- required = true,
735
- baseUrl,
736
- components
737
- }) {
738
- const notRequiredAbiTypes = ["bool", "string"];
739
- if (!notRequiredAbiTypes.includes(fieldOrType) && required && (value === void 0 || value === null || value === "")) {
740
- return "Required" /* REQUIRED */;
741
- }
742
- if (fieldOrType.startsWith("uint") || fieldOrType.startsWith("int")) {
743
- if (typeof value !== "string") {
744
- return "Invalid amount" /* INVALID_AMOUNT */;
745
- }
746
- try {
747
- const valueBN = BigInt(value);
748
- if (fieldOrType.startsWith("uint")) {
749
- if (valueBN < 0n) {
750
- return "Negative amount" /* NEGATIVE_AMOUNT */;
751
- }
752
- }
753
- } catch {
754
- return "Invalid amount" /* INVALID_AMOUNT */;
755
- }
756
- return null;
757
- }
758
- switch (fieldOrType) {
759
- case "string":
760
- if (value !== void 0 && typeof value !== "string") {
761
- return "Invalid amount" /* INVALID_AMOUNT */;
762
- }
763
- return null;
764
- case "bool":
765
- if (typeof value !== "boolean") {
766
- return "Invalid amount" /* INVALID_AMOUNT */;
767
- }
768
- return null;
769
- case "title":
770
- if (typeof value !== "string" || value.length === 0) {
771
- return "Required" /* REQUIRED */;
772
- }
773
- return null;
774
- case "description":
775
- if (typeof value !== "string" || value.length === 0) {
776
- return "Required" /* REQUIRED */;
777
- }
778
- return null;
779
- case "forumLink": {
780
- if (typeof value !== "string" || value.length === 0) {
781
- return "Required" /* REQUIRED */;
782
- }
783
- if (!URL.canParse(value)) {
784
- return "Invalid address" /* INVALID_ADDRESS */;
785
- }
786
- const base = new URL(baseUrl);
787
- if (!value.startsWith(base.toString())) {
788
- return "Must be a berachain forum link" /* INVALID_BASEPATH */;
789
- }
790
- return null;
791
- }
792
- case "address":
793
- if (typeof value !== "string" || !isAddress3(value, { strict: true })) {
794
- return "Invalid address" /* INVALID_ADDRESS */;
795
- }
796
- return null;
797
- case "hex":
798
- if (typeof value !== "string" || !isHex3(value, { strict: true })) {
799
- return "Invalid address" /* INVALID_ADDRESS */;
800
- }
801
- return null;
802
- case "abi":
803
- if (typeof value !== "string") {
804
- return "Invalid ABI" /* INVALID_ABI */;
805
- }
806
- try {
807
- JSON.parse(value);
808
- } catch {
809
- return "Invalid ABI" /* INVALID_ABI */;
810
- }
811
- return null;
812
- case "action":
813
- if (typeof value !== "string" || !isAddress3(value, { strict: true })) {
814
- return "Invalid address" /* INVALID_ADDRESS */;
815
- }
816
- return null;
817
- case "tuple":
818
- if (typeof value === "object" && Array.isArray(components)) {
819
- const errors = {};
820
- for (const component of components) {
821
- const abiParam = component;
822
- const name = abiParam.name;
823
- errors[name] = checkProposalField({
824
- fieldOrType: abiParam.type,
825
- value: value[name],
826
- components: abiParam.components
827
- });
828
- }
829
- if (Object.values(errors).every((v) => v === null)) {
830
- return null;
831
- }
832
- return errors;
833
- }
834
- return null;
835
- case "tuple[]":
836
- if (Array.isArray(value)) {
837
- const errors = value.map(
838
- (v) => checkProposalField({
839
- fieldOrType: "tuple",
840
- value: v,
841
- components
842
- })
843
- );
844
- if (errors.every((v) => v === null)) {
845
- return null;
846
- }
847
- return errors;
848
- }
849
- return null;
850
- case "logoURI": {
851
- if (value === void 0 || value === "") {
852
- return null;
853
- }
854
- if (typeof value !== "string" || !URL.canParse(value) || new URL(value).protocol !== "https:") {
855
- return "Must be HTTPS or IPFS" /* MUST_BE_HTTPS_OR_IPFS */;
856
- }
857
- return null;
858
- }
859
- case "url": {
860
- if (value === void 0 || value === "") {
861
- return null;
862
- }
863
- if (typeof value !== "string" || !URL.canParse(value) || new URL(value).protocol !== "https:") {
864
- return "Must be HTTPS" /* MUST_BE_HTTPS */;
865
- }
866
- return null;
867
- }
868
- default:
869
- console.error(`Invalid field or type: ${fieldOrType}`);
870
- return null;
871
- }
872
- }
873
-
874
- // src/actions/governance/computeActualStatus.ts
875
- import {
876
- ProposalStatus
877
- } from "@berachain/graphql/governance";
878
- var GOVERNANCE_ACCELERATE_PROPOSAL = false;
879
- var MOCKED_PROPOSAL_STATUSES = [
880
- ProposalStatus.Active,
881
- ProposalStatus.PendingQueue,
882
- ProposalStatus.PendingExecution,
883
- ProposalStatus.Defeated,
884
- ProposalStatus.QuorumNotReached
885
- ];
886
- function computeActualStatus(proposal, proposalOnChainState) {
887
- const timestampInSeconds = Date.now() / 1e3;
888
- if (proposalOnChainState !== void 0) {
889
- if (proposal.status === ProposalStatus.CanceledByGuardian) {
890
- return ProposalStatus.CanceledByGuardian;
891
- }
892
- if (proposalOnChainState === 2 /* Canceled */) {
893
- if (Number(proposal.voteStartAt) < timestampInSeconds)
894
- return ProposalStatus.CanceledByUser;
895
- return ProposalStatus.CanceledByGuardian;
896
- }
897
- if (proposalOnChainState === 3 /* Defeated */) {
898
- if (!proposal.pollResult) {
899
- return ProposalStatus.QuorumNotReached;
900
- }
901
- if (
902
- // Quorum might be null if no votes were cast.
903
- !proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)
904
- ) {
905
- return ProposalStatus.QuorumNotReached;
906
- }
907
- return ProposalStatus.Defeated;
908
- }
909
- if (proposalOnChainState === 4 /* Succeeded */) {
910
- return ProposalStatus.PendingQueue;
911
- }
912
- if (proposalOnChainState === 5 /* Queued */) {
913
- if (Number(proposal.queueEnd) < Date.now() / 1e3) {
914
- return ProposalStatus.PendingExecution;
915
- }
916
- return ProposalStatus.InQueue;
917
- }
918
- if (proposalOnChainState === 6 /* Expired */) {
919
- console.warn("Unexpected expired state on proposal id: ", proposal.id);
920
- return ProposalStatus.Defeated;
921
- }
922
- }
923
- if (proposal.status === ProposalStatus.InQueue) {
924
- if (Number(proposal.queueEnd) < Date.now() / 1e3) {
925
- return ProposalStatus.PendingExecution;
926
- }
927
- }
928
- if (GOVERNANCE_ACCELERATE_PROPOSAL && proposalOnChainState === 1 /* Active */ && proposal.quorum && BigInt(proposal.quorum) < BigInt(proposal.pollResult.totalTowardsQuorum) && Number(proposal.pollResult.forPercentage) > Number(proposal.pollResult.againstPercentage)) {
929
- return ProposalStatus.PendingQueue;
930
- }
931
- if (proposal.status === ProposalStatus.Pending) {
932
- if (Number(proposal.voteStartAt) < timestampInSeconds && Number(proposal.voteEndAt) > timestampInSeconds) {
933
- return ProposalStatus.Active;
934
- }
935
- if (Number(proposal.voteEndAt) < timestampInSeconds) {
936
- if (!proposal.pollResult) {
937
- return ProposalStatus.QuorumNotReached;
938
- }
939
- if (!proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)) {
940
- return ProposalStatus.QuorumNotReached;
941
- }
942
- if (proposal.pollResult?.against > proposal.pollResult?.for) {
943
- return ProposalStatus.Defeated;
944
- }
945
- return ProposalStatus.PendingQueue;
946
- }
947
- return ProposalStatus.Pending;
948
- }
949
- if (proposal.status === ProposalStatus.Active && Number(proposal.voteEndAt) < timestampInSeconds) {
950
- if (!proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)) {
951
- return ProposalStatus.QuorumNotReached;
952
- }
953
- if (BigInt(proposal.pollResult?.against ?? 0n) > BigInt(proposal.pollResult?.for ?? 0n)) {
954
- return ProposalStatus.Defeated;
955
- }
956
- return ProposalStatus.PendingQueue;
957
- }
958
- if (proposal.status === ProposalStatus.InQueue) {
959
- if (Number(proposal.queueEnd) < Date.now() / 1e3) {
960
- return ProposalStatus.PendingExecution;
961
- }
962
- }
963
- return proposal.status;
964
- }
965
-
966
- // src/actions/governance/getAllProposals.ts
967
- import {
968
- GetProposals,
969
- SearchProposals
970
- } from "@berachain/graphql/governance";
971
- async function getAllProposals({
972
- where,
973
- orderBy,
974
- orderDirection,
975
- offset = 0,
976
- perPage = 20,
977
- text,
978
- ...args
979
- }) {
980
- try {
981
- if (perPage > 1e3) {
982
- throw new Error("perPage must be less than 1000");
983
- }
984
- const governanceClient = getApolloClient("governance.subgraph", args);
985
- const [response] = await Promise.all([
986
- text ? governanceClient.query({
987
- query: SearchProposals,
988
- variables: {
989
- offset,
990
- limit: perPage,
991
- where,
992
- text
993
- }
994
- }) : governanceClient.query(
995
- {
996
- query: GetProposals,
997
- variables: {
998
- offset,
999
- limit: perPage,
1000
- where,
1001
- orderBy,
1002
- orderDirection
1003
- }
1004
- }
1005
- )
1006
- ]);
1007
- return response.data.proposals.map((p) => ({
1008
- ...p,
1009
- status: computeActualStatus(p)
1010
- }));
1011
- } catch (e) {
1012
- console.error("getAllProposals:", e);
1013
- throw e;
1014
- }
1015
- }
1016
-
1017
- // src/actions/governance/getBodyErrors.ts
1018
- function getBodyErrors({
1019
- proposal,
1020
- currentTopic
1021
- }) {
1022
- const e = {};
1023
- e.title = checkProposalField({
1024
- fieldOrType: "title",
1025
- value: proposal.title
1026
- });
1027
- e.description = checkProposalField({
1028
- fieldOrType: "description",
1029
- value: proposal.description
1030
- });
1031
- e.forumLink = checkProposalField({
1032
- fieldOrType: "forumLink",
1033
- value: proposal.forumLink,
1034
- baseUrl: currentTopic.forumLink
1035
- });
1036
- return e;
1037
- }
1038
-
1039
- // src/actions/governance/getProposalDetails.ts
1040
- import {
1041
- GetProposal
1042
- } from "@berachain/graphql/governance";
1043
- async function getProposalDetails({
1044
- proposalId,
1045
- ...args
1046
- }) {
1047
- const governanceClient = getApolloClient("governance.subgraph", args);
1048
- const res = await governanceClient.query({
1049
- query: GetProposal,
1050
- variables: {
1051
- id: proposalId
1052
- }
1053
- });
1054
- if (!res.data.proposal) {
1055
- return void 0;
1056
- }
1057
- return {
1058
- ...res.data.proposal,
1059
- status: computeActualStatus(res.data.proposal)
1060
- };
1061
- }
1062
-
1063
- // src/actions/governance/parseProposalBody.ts
1064
- import graymatter from "gray-matter";
1065
- function parseLegacyBody(s) {
1066
- const pattern = /#(?:([\w-]+)# )?(.+)\n([\s\S]*)/;
1067
- const match = s.match(pattern);
1068
- if (match) {
1069
- const type = match[1] || null;
1070
- const title = match[2];
1071
- const content = match[3].replace("\n", "<br />");
1072
- return {
1073
- type,
1074
- title,
1075
- content
1076
- };
1077
- }
1078
- throw new Error("Invalid proposal body");
1079
- }
1080
- function parseProposalBody(proposal) {
1081
- if (!proposal) {
1082
- return {
1083
- isFrontMatter: false,
1084
- data: { title: "Loading..." },
1085
- content: "",
1086
- matter: "",
1087
- language: "",
1088
- orig: "",
1089
- stringify: () => ""
1090
- };
1091
- }
1092
- const body = proposal?.description ?? "";
1093
- if (graymatter.test(body)) {
1094
- return { ...graymatter(body), isFrontMatter: true };
1095
- }
1096
- try {
1097
- const legacyBody = parseLegacyBody(body);
1098
- return {
1099
- isFrontMatter: false,
1100
- data: { title: legacyBody.title },
1101
- content: legacyBody.content,
1102
- matter: "",
1103
- language: "",
1104
- orig: body,
1105
- stringify: () => body
1106
- };
1107
- } catch {
1108
- return {
1109
- isFrontMatter: false,
1110
- data: {
1111
- title: proposal?.description?.split("\n")[0].slice(0, 100)
1112
- },
1113
- content: body,
1114
- matter: "",
1115
- language: "",
1116
- orig: body,
1117
- stringify: () => body
1118
- };
1119
- }
1120
- }
1121
-
1122
- // src/actions/governance/getProposalFromTx.ts
1123
- import {
1124
- parseEventLogs
1125
- } from "viem";
1126
- import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
1127
- import {
1128
- ProposalStatus as ProposalStatus2
1129
- } from "@berachain/graphql/governance";
1130
- async function getProposalFromTx(args) {
1131
- assertPublicClient(args.publicClient);
1132
- let tx;
1133
- if ("tx" in args) {
1134
- tx = args.tx;
1135
- } else {
1136
- tx = await args.publicClient.getTransactionReceipt({ hash: args.txHash });
1137
- }
1138
- const creationEvent = tx?.logs ? parseEventLogs({
1139
- abi: governanceAbi,
1140
- logs: tx.logs,
1141
- eventName: "ProposalCreated"
1142
- })?.at(0) : void 0;
1143
- if (!tx || !creationEvent) {
1144
- return null;
1145
- }
1146
- const block = await args.publicClient.getBlock({
1147
- blockNumber: tx.blockNumber
1148
- });
1149
- const fm = parseProposalBody({
1150
- description: creationEvent?.args.description
1151
- });
1152
- return {
1153
- id: String(creationEvent.args.proposalId),
1154
- proposalId: String(creationEvent?.args.proposalId),
1155
- createdAt: block.timestamp.toString(),
1156
- title: fm.data.title,
1157
- createdAtBlock: block.timestamp.toString(),
1158
- voteStartAt: String(creationEvent?.args.voteStart),
1159
- voteEndAt: String(creationEvent?.args.voteEnd),
1160
- proposer: creationEvent?.args.proposer,
1161
- description: fm.content,
1162
- unverifiedForumLink: fm.data.forumLink,
1163
- pollResult: {
1164
- for: "0",
1165
- forVotersCount: 0,
1166
- forPercentage: "0",
1167
- against: "0",
1168
- againstVotersCount: 0,
1169
- againstPercentage: "0",
1170
- abstain: "0",
1171
- abstainVotersCount: 0,
1172
- abstainPercentage: "0",
1173
- total: "0",
1174
- totalVotersCount: 0,
1175
- totalTowardsQuorum: "0"
1176
- },
1177
- status: ProposalStatus2.Pending,
1178
- quorum: null,
1179
- topics: fm.data.topics,
1180
- votes: [],
1181
- executableCalls: creationEvent?.args.targets.map(
1182
- (target, index) => ({
1183
- __typename: "ExecutableCall",
1184
- id: `${tx.transactionHash}-${index}`,
1185
- target,
1186
- value: String(creationEvent?.args.values[index]),
1187
- calldata: creationEvent?.args.calldatas[index]
1188
- })
1189
- ),
1190
- timelock: void 0
1191
- };
1192
- }
1193
-
1194
- // src/actions/governance/getProposalVotes.ts
1195
- import {
1196
- GetProposalVotes
1197
- } from "@berachain/graphql/governance";
1198
- async function getProposalVotes({
1199
- variables,
1200
- ...args
1201
- }) {
1202
- const governanceClient = getApolloClient("governance.subgraph", args);
1203
- return governanceClient.query({
1204
- query: GetProposalVotes,
1205
- variables
1206
- });
1207
- }
1208
-
1209
574
  // src/actions/honey/getChartData.ts
1210
- import {
1211
- Aggregation_Interval,
1212
- GetChartData
1213
- } from "@berachain/graphql/honey";
1214
575
  async function getChartData({
1215
- days: days2,
1216
- ...args
576
+ days
1217
577
  }) {
1218
- const client = getApolloClient("honey.subgraph", args);
1219
- const res = await client.query(
1220
- {
1221
- query: GetChartData,
1222
- variables: {
1223
- interval: Aggregation_Interval.Day,
1224
- first: days2
1225
- }
1226
- }
1227
- );
1228
- return res.data;
578
+ if (typeof window === "undefined") {
579
+ throw new BeraError({
580
+ message: "getChartData is browser-only; call from a Client Component / SWR hook",
581
+ level: "error"
582
+ });
583
+ }
584
+ const params = new URLSearchParams({ interval: "day", first: String(days) });
585
+ const honeySnapshots = await beraFetchJson({
586
+ url: `/api/honey/snapshots?${params}`,
587
+ name: "honey-snapshots",
588
+ type: "rest"
589
+ });
590
+ return { honeySnapshots };
1229
591
  }
1230
592
 
1231
593
  // src/actions/honey/getCollateralWeights.ts
@@ -1552,18 +914,24 @@ async function getWeights({
1552
914
  return weights;
1553
915
  }
1554
916
 
1555
- // src/actions/honey/getHoneyGlobalData.ts
1556
- import {
1557
- GetGlobalData
1558
- } from "@berachain/graphql/honey";
1559
- async function getHoneyGlobalData({
1560
- ...args
1561
- } = {}) {
1562
- const client = getApolloClient("honey.subgraph", args);
1563
- const result = await client.query({
1564
- query: GetGlobalData
917
+ // src/actions/honey/getHoney24hVolume.ts
918
+ async function getHoney24hVolume() {
919
+ if (typeof window === "undefined") {
920
+ throw new BeraError({
921
+ message: "getHoney24hVolume is browser-only; call from a Client Component / SWR hook",
922
+ level: "error"
923
+ });
924
+ }
925
+ const params = new URLSearchParams({ interval: "hour", first: "24" });
926
+ const snapshots = await beraFetchJson({
927
+ url: `/api/honey/snapshots?${params}`,
928
+ name: "honey-snapshots",
929
+ type: "rest"
1565
930
  });
1566
- return result.data;
931
+ return snapshots.reduce(
932
+ (acc, curr) => new bignumber_js_default(curr.totalVolume).plus(acc),
933
+ new bignumber_js_default(0)
934
+ );
1567
935
  }
1568
936
 
1569
937
  // src/actions/honey/getHoneyPreview.ts
@@ -1943,6 +1311,22 @@ async function getBlockTimestamp({
1943
1311
  };
1944
1312
  }
1945
1313
 
1314
+ // src/actions/pol/getAutoclaimedIncentives.ts
1315
+ async function getAutoclaimedIncentives({
1316
+ account,
1317
+ ...args
1318
+ }) {
1319
+ const { config } = parseBaseArgs(args);
1320
+ return beraFetchJson(
1321
+ {
1322
+ url: `${config.pol.bribeBoostApi}/api/v1/wallets/${account.toLowerCase()}/autoclaimed`,
1323
+ name: "pol-autoclaimed-incentives",
1324
+ type: "rest"
1325
+ },
1326
+ { cache: "no-store" }
1327
+ );
1328
+ }
1329
+
1946
1330
  // src/actions/pol/getRewardVaultRewards.ts
1947
1331
  import { formatUnits as formatUnits5 } from "viem";
1948
1332
  import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
@@ -2099,14 +1483,19 @@ function getBgtAprSimulation({
2099
1483
  }
2100
1484
 
2101
1485
  // src/actions/pol/getEarnedStakedBeraVault.ts
1486
+ import { getUriFromLink } from "@berachain/config";
2102
1487
  async function getEarnedStakedBeraVault({
2103
1488
  address,
2104
1489
  account,
2105
1490
  ...args
2106
1491
  }) {
2107
1492
  const { config } = parseBaseArgs(args);
2108
- const url = `${config.staking}/vaults/${address}/earnings/${account}`;
2109
- return beraFetchJson({ url, type: "rest" });
1493
+ const url = `${getUriFromLink(config.backend)}/vaults/${address}/earnings/${account}`;
1494
+ return beraFetchJson({
1495
+ url,
1496
+ name: typeof config.backend === "string" ? "backend-railway" : config.backend.name,
1497
+ type: "rest"
1498
+ });
2110
1499
  }
2111
1500
 
2112
1501
  // src/actions/pol/getRewardVaults.ts
@@ -2305,38 +1694,18 @@ async function getGlobalData(publicClient) {
2305
1694
  }
2306
1695
 
2307
1696
  // src/actions/pol/getIncentiveFeeClaimStats.ts
2308
- import {
2309
- GetIncentiveFeeClaimStats
2310
- } from "@berachain/graphql/pol/fees";
2311
- async function getIncentiveFeeClaimStats({
2312
- ...args
2313
- }) {
2314
- const bgtClient = getApolloClient("pol.fees", args);
2315
- const { data } = await bgtClient.query({
2316
- query: GetIncentiveFeeClaimStats
2317
- });
2318
- if (data.incentiveFeeClaims.length > 0) {
2319
- const sumAllClaims = data?.incentiveFeeClaims.reduce(
2320
- (acc, curr) => acc + Number(curr.payoutAmount),
2321
- 3e4
2322
- // this is due to a bug in the subgraph, where the first claim of 50_000 was counted as 20_000, once hunter pushed the fix we can upgrade it.
2323
- );
2324
- const claimsInLast24Hours = data?.incentiveFeeClaims.filter(
2325
- (claim) => Number(claim.timestamp) / 1e3 > Date.now() - days(1)
2326
- );
2327
- const sumClaimsInLast24Hours = claimsInLast24Hours.reduce(
2328
- (acc, curr) => acc + Number(curr.payoutAmount),
2329
- 0
2330
- );
2331
- return {
2332
- sumAllClaims,
2333
- sumClaimsInLast24Hours
2334
- };
1697
+ async function getIncentiveFeeClaimStats() {
1698
+ if (typeof window === "undefined") {
1699
+ throw new BeraError({
1700
+ message: "getIncentiveFeeClaimStats is browser-only; call from a Client Component / SWR hook",
1701
+ level: "error"
1702
+ });
2335
1703
  }
2336
- return {
2337
- sumAllClaims: 0,
2338
- sumClaimsInLast24Hours: 0
2339
- };
1704
+ return beraFetchJson({
1705
+ url: "/api/pol/incentive-fee-claims",
1706
+ name: "pol-incentive-fee-claims",
1707
+ type: "rest"
1708
+ });
2340
1709
  }
2341
1710
 
2342
1711
  // src/actions/pol/getMarkets.ts
@@ -2573,14 +1942,14 @@ import {
2573
1942
  GetSWberaVaultMetadata,
2574
1943
  GqlSWberaVaultMetadataResolution
2575
1944
  } from "@berachain/graphql/pol/api";
2576
- function getResolution(window) {
2577
- if (window === "DAY") {
1945
+ function getResolution(window2) {
1946
+ if (window2 === "DAY") {
2578
1947
  return GqlSWberaVaultMetadataResolution.OneDay;
2579
1948
  }
2580
1949
  return GqlSWberaVaultMetadataResolution.SevenDays;
2581
1950
  }
2582
1951
  async function getStakedBeraAPR({
2583
- window,
1952
+ window: window2,
2584
1953
  ...args
2585
1954
  }) {
2586
1955
  const { config } = parseBaseArgs(args);
@@ -2590,7 +1959,7 @@ async function getStakedBeraAPR({
2590
1959
  query: GetSWberaVaultMetadata,
2591
1960
  variables: {
2592
1961
  chain: config.bex.chainName,
2593
- resolution: getResolution(window ?? "DAY")
1962
+ resolution: getResolution(window2 ?? "DAY")
2594
1963
  }
2595
1964
  });
2596
1965
  const { apr } = data.data.polGetSWberaVaultMetadata;
@@ -2727,7 +2096,7 @@ async function getSWBeraVaultMetadata({
2727
2096
  publicClient,
2728
2097
  address
2729
2098
  }),
2730
- getIncentiveFeeClaimStats({})
2099
+ getIncentiveFeeClaimStats()
2731
2100
  ]);
2732
2101
  const exchangeRateWindowAgo = new bignumber_js_default(
2733
2102
  oneShareWorthWindowAgo.toString()
@@ -4009,28 +3378,25 @@ async function getApiValidator({
4009
3378
  }
4010
3379
 
4011
3380
  // src/actions/validators/getDailyValidatorBlockStats.ts
4012
- import {
4013
- GetValidatorBlockStats
4014
- } from "@berachain/graphql/pol/subgraph";
4015
3381
  async function getDailyValidatorBlockStats({
4016
3382
  pubKey,
4017
- first = 1,
4018
- ...args
3383
+ first = 1
4019
3384
  }) {
4020
- const bgtClient = getApolloClient("pol.subgraph", args);
4021
- try {
4022
- const result = await bgtClient.query({
4023
- query: GetValidatorBlockStats,
4024
- variables: {
4025
- pubKey,
4026
- first
4027
- }
3385
+ if (typeof window === "undefined") {
3386
+ throw new BeraError({
3387
+ message: "getDailyValidatorBlockStats is browser-only; for RSC use @berachain/berajs/actions/server",
3388
+ level: "error"
4028
3389
  });
4029
- return result.data;
4030
- } catch (e) {
4031
- console.error("GetValidatorBlockStats:", e);
4032
- throw e;
4033
3390
  }
3391
+ const params = new URLSearchParams({
3392
+ pubkey: pubKey,
3393
+ first: String(first)
3394
+ });
3395
+ return beraFetchJson({
3396
+ url: `/api/pol/validator-block-stats?${params}`,
3397
+ name: "pol-validator-block-stats",
3398
+ type: "rest"
3399
+ });
4034
3400
  }
4035
3401
 
4036
3402
  // src/actions/validators/getValidatorRewardAllocation.ts
@@ -4476,23 +3842,25 @@ async function getUserStakingPositions(account) {
4476
3842
  }
4477
3843
 
4478
3844
  // src/actions/validators/getValidatorAnalytics.ts
4479
- import {
4480
- GetValidatorAnalytics
4481
- } from "@berachain/graphql/pol/subgraph";
4482
3845
  async function getValidatorAnalytics({
4483
3846
  pubkey,
4484
- dayRange,
4485
- ...args
3847
+ dayRange
4486
3848
  }) {
4487
- const bgtClient = getApolloClient("pol.subgraph", args);
4488
- const result = await bgtClient.query({
4489
- query: GetValidatorAnalytics,
4490
- variables: {
4491
- pubKey: pubkey,
4492
- timestamp: calculateTimestampFromDays(dayRange).toString()
4493
- }
3849
+ if (typeof window === "undefined") {
3850
+ throw new BeraError({
3851
+ message: "getValidatorAnalytics is browser-only; call from a Client Component / SWR hook",
3852
+ level: "error"
3853
+ });
3854
+ }
3855
+ const params = new URLSearchParams({
3856
+ pubkey,
3857
+ dayRange: String(dayRange)
3858
+ });
3859
+ return beraFetchJson({
3860
+ url: `/api/pol/validator-analytics?${params}`,
3861
+ name: "pol-validator-analytics",
3862
+ type: "rest"
4494
3863
  });
4495
- return result.data;
4496
3864
  }
4497
3865
 
4498
3866
  // src/actions/validators/getValidatorCommission.ts
@@ -4608,9 +3976,6 @@ async function getValidatorQueuedRewardAllocation({
4608
3976
 
4609
3977
  export {
4610
3978
  getConvertToAssets,
4611
- BeraApolloClient,
4612
- getApolloClient,
4613
- gql,
4614
3979
  BaseAggregator,
4615
3980
  BalancerApi,
4616
3981
  getAllPools,
@@ -4620,22 +3985,13 @@ export {
4620
3985
  getOnChainPool,
4621
3986
  getPoolEvents,
4622
3987
  getPoolHistoricalData,
4623
- checkProposalField,
4624
- MOCKED_PROPOSAL_STATUSES,
4625
- computeActualStatus,
4626
- getAllProposals,
4627
- getBodyErrors,
4628
- getProposalDetails,
4629
- parseProposalBody,
4630
- getProposalFromTx,
4631
- getProposalVotes,
4632
3988
  getChartData,
4633
3989
  getCollateralWeights,
4634
3990
  getTokenInformation,
4635
3991
  getHoneyCollaterals,
4636
3992
  isBadCollateralAsset,
4637
3993
  getGlobalCapLimit,
4638
- getHoneyGlobalData,
3994
+ getHoney24hVolume,
4639
3995
  HoneyPreviewMethod,
4640
3996
  getHoneyPreview,
4641
3997
  getHoneyVaultsBalance,
@@ -4645,6 +4001,7 @@ export {
4645
4001
  getSwapPayload,
4646
4002
  isBasketModeEnabled,
4647
4003
  getBlockTimestamp,
4004
+ getAutoclaimedIncentives,
4648
4005
  RewardVaultDistributionMode,
4649
4006
  getRewardVaultRewards,
4650
4007
  getBgtAprSimulation,
@@ -4695,4 +4052,3 @@ export {
4695
4052
  getValidatorQueuedOperatorAddress,
4696
4053
  getValidatorQueuedRewardAllocation
4697
4054
  };
4698
- //# sourceMappingURL=chunk-2R73G2PO.mjs.map