@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
@@ -0,0 +1,473 @@
1
+ import {
2
+ BeraTracing
3
+ } from "./chunk-SZ5C44L5.mjs";
4
+ import {
5
+ RequestError
6
+ } from "./chunk-XIYN6AL6.mjs";
7
+
8
+ // src/utils/getErrorResponse.ts
9
+ async function getErrorResponse(response) {
10
+ const contentType = response.headers.get("content-type");
11
+ if (contentType?.includes("application/json")) {
12
+ return response.json();
13
+ } else {
14
+ const text = await response.text();
15
+ try {
16
+ return JSON.parse(text);
17
+ } catch {
18
+ return {
19
+ message: "Unknown error, can't decode response into JSON",
20
+ cause: text
21
+ };
22
+ }
23
+ }
24
+ }
25
+
26
+ // src/utils/sanitizeRpcUrl.ts
27
+ function sanitizeRpcUrl(url) {
28
+ if (!url) return "";
29
+ try {
30
+ const parsed = new URL(url);
31
+ if (parsed.hostname.endsWith(".quiknode.pro")) {
32
+ parsed.pathname = "/";
33
+ parsed.search = "";
34
+ return parsed.toString();
35
+ }
36
+ return url;
37
+ } catch {
38
+ return url;
39
+ }
40
+ }
41
+
42
+ // src/utils/beraFetch.ts
43
+ async function beraFetch(endpoint, options, spanContext) {
44
+ try {
45
+ let spanUrl = sanitizeRpcUrl(
46
+ typeof endpoint === "string" || endpoint instanceof URL ? endpoint.toString() : endpoint.url.toString()
47
+ ).replace(/0x[a-fA-F0-9]{40}/g, ":address");
48
+ if (spanContext?.keepQueryParams !== true && URL.canParse(spanUrl)) {
49
+ const queryParams = new URL(spanUrl).searchParams;
50
+ if (Array.isArray(spanContext?.keepQueryParams)) {
51
+ const searchParams = new URLSearchParams();
52
+ for (const param of spanContext.keepQueryParams) {
53
+ searchParams.set(param, queryParams.get(param) ?? "");
54
+ }
55
+ const newUrl = new URL(spanUrl);
56
+ newUrl.search = searchParams.toString();
57
+ spanUrl = newUrl.toString();
58
+ } else {
59
+ const newUrl = new URL(spanUrl);
60
+ newUrl.search = "";
61
+ spanUrl = newUrl.toString();
62
+ }
63
+ }
64
+ const endpointName = typeof endpoint === "string" || endpoint instanceof URL ? void 0 : endpoint.name;
65
+ return await BeraTracing.startSpan(
66
+ {
67
+ op: "beraFetch",
68
+ name: endpointName ? `beraFetch ${endpointName}` : "beraFetch",
69
+ attributes: typeof endpoint === "string" || endpoint instanceof URL ? {
70
+ "operation.source.url": spanUrl,
71
+ ...spanContext?.attributes
72
+ } : {
73
+ "operation.source.url": spanUrl,
74
+ "operation.source.type": endpoint.type,
75
+ "operation.source.name": endpoint.name,
76
+ ...spanContext?.attributes
77
+ }
78
+ },
79
+ async () => {
80
+ const response = await fetch(
81
+ typeof endpoint === "string" || endpoint instanceof URL ? endpoint : endpoint.url,
82
+ {
83
+ ...options
84
+ }
85
+ );
86
+ if (!response.ok) {
87
+ const error = await getErrorResponse(response);
88
+ throw new RequestError({
89
+ cause: error,
90
+ // @to-do import getErrorResponse logic in this function
91
+ // when it's removed from other places
92
+ response,
93
+ endpoint
94
+ });
95
+ }
96
+ return response;
97
+ }
98
+ );
99
+ } catch (error) {
100
+ if (error instanceof RequestError) {
101
+ throw error;
102
+ }
103
+ throw new RequestError({
104
+ cause: error,
105
+ endpoint,
106
+ response: void 0
107
+ });
108
+ }
109
+ }
110
+ async function beraFetchJson(endpoint, options) {
111
+ const response = await beraFetch(endpoint, {
112
+ ...options,
113
+ headers: {
114
+ Accept: "application/json",
115
+ ...options?.headers
116
+ }
117
+ });
118
+ return response.json();
119
+ }
120
+
121
+ // src/utils/constants.ts
122
+ import { parseEther } from "viem";
123
+ var CAP_LIMIT_BUFFER = parseEther("0.005");
124
+ var MAX_CUSTOM_DEADLINE = 1e5;
125
+ var MIN_CUSTOM_DEADLINE = 1;
126
+ var MIN_CUSTOM_SLIPPAGE = 0.1;
127
+ var MAX_CUSTOM_SLIPPAGE = 50;
128
+ var DEFAULT_METAMASK_GAS_LIMIT = 7920027n;
129
+
130
+ // src/utils/pythHoneyUtils.ts
131
+ var getPythDefaultUpdateFee = (tokenListLength) => {
132
+ return 2n * BigInt(tokenListLength);
133
+ };
134
+
135
+ // src/utils/time.ts
136
+ function msToSeconds(ms) {
137
+ return Math.floor(ms / 1e3);
138
+ }
139
+ function seconds(seconds2) {
140
+ return seconds2 * 1e3;
141
+ }
142
+ function minutes(minutes2) {
143
+ return minutes2 * seconds(60);
144
+ }
145
+ function minutesInSeconds(minutes2) {
146
+ return minutes2 * 60;
147
+ }
148
+ function hours(hours2) {
149
+ return hours2 * minutes(60);
150
+ }
151
+ function hoursInSeconds(hours2) {
152
+ return hours2 * minutesInSeconds(60);
153
+ }
154
+ function days(days2) {
155
+ return days2 * hours(24);
156
+ }
157
+ function daysInSeconds(days2) {
158
+ return days2 * hoursInSeconds(24);
159
+ }
160
+ function weeks(weeks2) {
161
+ return weeks2 * days(7);
162
+ }
163
+ function weeksInSeconds(weeks2) {
164
+ return weeks2 * daysInSeconds(7);
165
+ }
166
+ function months(months2) {
167
+ return months2 * days(30);
168
+ }
169
+ function monthsInSeconds(months2) {
170
+ return months2 * daysInSeconds(30);
171
+ }
172
+ function years(years2) {
173
+ return years2 * days(365);
174
+ }
175
+ function yearsInSeconds(years2) {
176
+ return years2 * daysInSeconds(365);
177
+ }
178
+
179
+ // src/utils/formatTimestamps.ts
180
+ function calculateTimestampFromDays(daysRange) {
181
+ const currentDate = /* @__PURE__ */ new Date();
182
+ return currentDate.setDate(currentDate.getDate() - daysRange) * 1e3;
183
+ }
184
+ var monthNames = [
185
+ "January",
186
+ "February",
187
+ "March",
188
+ "April",
189
+ "May",
190
+ "June",
191
+ "July",
192
+ "August",
193
+ "September",
194
+ "October",
195
+ "November",
196
+ "December"
197
+ ];
198
+ var shortMonthNames = [
199
+ "Jan",
200
+ "Feb",
201
+ "Mar",
202
+ "Apr",
203
+ "May",
204
+ "Jun",
205
+ "Jul",
206
+ "Aug",
207
+ "Sep",
208
+ "Oct",
209
+ "Nov",
210
+ "Dec"
211
+ ];
212
+ function formatUnixTimestamp(unixTimestamp, isShort) {
213
+ const date = new Date(unixTimestamp * 1e3);
214
+ const day = date.getDate();
215
+ let daySuffix = "th";
216
+ if (day === 1 || day === 21 || day === 31) {
217
+ daySuffix = "st";
218
+ } else if (day === 2 || day === 22) {
219
+ daySuffix = "nd";
220
+ } else if (day === 3 || day === 23) {
221
+ daySuffix = "rd";
222
+ }
223
+ if (isShort) {
224
+ return `${shortMonthNames[date.getMonth()]} ${day}`;
225
+ }
226
+ return `${monthNames[date.getMonth()]} ${day}${daySuffix}, ${date.getFullYear()}`;
227
+ }
228
+ function formatTimeLeft(...args) {
229
+ const timeLeftInSeconds = args[0];
230
+ let condensed;
231
+ let showDays;
232
+ let showMinutes;
233
+ let showSeconds;
234
+ if (typeof args[1] !== "object") {
235
+ condensed = args[1] ?? false;
236
+ showDays = args[2] ?? false;
237
+ showSeconds = args[3] ?? false;
238
+ showMinutes = true;
239
+ } else {
240
+ const opts = args[1];
241
+ condensed = opts.condensed ?? false;
242
+ const greaterUnit = opts.greaterUnit ?? "hours";
243
+ if (greaterUnit === "days") {
244
+ showDays = true;
245
+ showMinutes = true;
246
+ } else if (greaterUnit === "hours") {
247
+ showDays = false;
248
+ showMinutes = true;
249
+ showSeconds = false;
250
+ } else {
251
+ showDays = false;
252
+ showMinutes = true;
253
+ }
254
+ showSeconds = opts.showSeconds ?? false;
255
+ }
256
+ let days2 = Math.floor(timeLeftInSeconds / (3600 * 24));
257
+ let hours2 = Math.floor(timeLeftInSeconds % (3600 * 24) / 3600);
258
+ const minutes2 = Math.floor(timeLeftInSeconds % 3600 / 60);
259
+ const seconds2 = timeLeftInSeconds % 60;
260
+ if (!showDays) {
261
+ hours2 += days2 * 24;
262
+ days2 = 0;
263
+ }
264
+ if (days2 === 0 && hours2 === 0 && minutes2 === 0) {
265
+ return condensed ? "< 1 M" : "less than a minute";
266
+ }
267
+ const daysDisplay = days2 > 0 ? `${days2}${condensed ? "D" : " day"}${!condensed && days2 !== 1 ? "s" : ""}` : "";
268
+ const hoursDisplay = hours2 > 0 ? `${hours2}${condensed ? "H" : " hour"}${!condensed && hours2 !== 1 ? "s" : ""}` : "";
269
+ const minutesDisplay = minutes2 > 0 && showMinutes || !days2 && !hours2 ? `${minutes2}${condensed ? "M" : " minute"}${!condensed && minutes2 !== 1 ? "s" : ""}` : "";
270
+ const secondsDisplay = seconds2 > 0 && showSeconds ? `${seconds2}${condensed ? "S" : " second"}${!condensed && seconds2 !== 1 ? "s" : ""}` : "";
271
+ return [daysDisplay, hoursDisplay, minutesDisplay, secondsDisplay].filter(Boolean).join(condensed ? " " : ", ");
272
+ }
273
+
274
+ // ../utils/src/pkg/bignumber.js.ts
275
+ import BigNumber from "bignumber.js";
276
+ BigNumber.set({
277
+ // The EXPONENTIAL_AT option defines the exponent value(s) at which toString returns exponential notation.
278
+ // - Single number: the exponent magnitude at and above which exponential notation is used (e.g., `1e9` here disables it for almost all values).
279
+ // - 1e9 is the maximum value supported by BigNumber.js.
280
+ // See: https://mikemcl.github.io/bignumber.js/#exponential-at
281
+ EXPONENTIAL_AT: 1e9
282
+ });
283
+ var bignumber_js_default = BigNumber;
284
+
285
+ // src/utils/formatNumber.ts
286
+ var POSTFIXES = ["", "K", "M", "B", "T", "P", "E", "Z", "Y"];
287
+ function valueToBigNumber(amount) {
288
+ if (amount instanceof bignumber_js_default) return amount;
289
+ return new bignumber_js_default(amount);
290
+ }
291
+ function normalizeBN(n, decimals) {
292
+ return valueToBigNumber(n).shiftedBy(decimals * -1);
293
+ }
294
+ function formatNumber(value, options = {}) {
295
+ if (typeof options === "number") {
296
+ const decimals2 = options;
297
+ if (value === void 0 || value === null) {
298
+ return "";
299
+ }
300
+ if (typeof value === "object") {
301
+ throw new Error("Value must be a number if using deprecated version");
302
+ }
303
+ let formatted = Number(value).toFixed(decimals2);
304
+ formatted = formatted.replace(/(\.\d*?[1-9])0+$|\.0*$/, "$1");
305
+ return formatted;
306
+ }
307
+ const {
308
+ visibleDecimals,
309
+ compact = true,
310
+ percent = false,
311
+ roundDown = false,
312
+ roundUp = false,
313
+ compactThreshold,
314
+ maxValue,
315
+ symbol,
316
+ prefixText = "",
317
+ suffixText = "",
318
+ showIsSmallerThanMin = true,
319
+ ifNullish = ""
320
+ } = options || {};
321
+ if (value === void 0 || value === null) {
322
+ return ifNullish;
323
+ }
324
+ const number = percent ? Number(value) * 100 : Number(value);
325
+ if (Number.isNaN(number)) {
326
+ return "NaN";
327
+ }
328
+ if (number === Number.POSITIVE_INFINITY) {
329
+ return "Infinity";
330
+ }
331
+ if (number === Number.NEGATIVE_INFINITY) {
332
+ return "-Infinity";
333
+ }
334
+ let decimals = visibleDecimals ?? 0;
335
+ if (number === 0) {
336
+ decimals = 0;
337
+ } else if (visibleDecimals === void 0) {
338
+ if (Math.abs(number) > 1 || percent || symbol === "USD") {
339
+ decimals = 2;
340
+ } else {
341
+ decimals = 7;
342
+ }
343
+ }
344
+ const minValue = 10 ** -decimals;
345
+ const isSmallerThanMin = number !== 0 && Math.abs(number) < Math.abs(minValue);
346
+ const isNegative = number < 0;
347
+ const isBiggerThanMax = maxValue ? Math.abs(number) > maxValue : false;
348
+ let formattedNumber = isSmallerThanMin ? minValue : number;
349
+ const forceCompact = compact && (!compactThreshold || Math.abs(number) > compactThreshold);
350
+ if (roundDown && !forceCompact) {
351
+ formattedNumber = Math.trunc(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
352
+ } else if (roundUp && !forceCompact) {
353
+ formattedNumber = Math.ceil(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
354
+ }
355
+ let formattedValue;
356
+ if (isBiggerThanMax) {
357
+ formattedValue = number > maxValue ? "\u221E" : "-\u221E";
358
+ } else if (!forceCompact) {
359
+ const absFormatted = new Intl.NumberFormat("en-US", {
360
+ maximumFractionDigits: decimals,
361
+ minimumFractionDigits: decimals
362
+ }).format(Math.abs(formattedNumber));
363
+ formattedValue = `${isNegative ? "-" : ""}${absFormatted}`;
364
+ } else {
365
+ const bnValue = valueToBigNumber(formattedNumber);
366
+ let integerPlaces = bnValue.abs().toFixed(0).length;
367
+ if (compactThreshold && Math.abs(number) <= compactThreshold) {
368
+ integerPlaces = 0;
369
+ }
370
+ const significantDigitsGroup = Math.min(
371
+ Math.floor(integerPlaces ? (integerPlaces - 1) / 3 : 0),
372
+ POSTFIXES.length - 1
373
+ );
374
+ const postfix = POSTFIXES[significantDigitsGroup];
375
+ let compactValue = normalizeBN(
376
+ bnValue,
377
+ 3 * significantDigitsGroup
378
+ ).toNumber();
379
+ if (roundDown) {
380
+ compactValue = Math.trunc(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
381
+ } else if (roundUp) {
382
+ compactValue = Math.ceil(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
383
+ }
384
+ const prefix = new Intl.NumberFormat("en-US", {
385
+ maximumFractionDigits: decimals,
386
+ minimumFractionDigits: decimals
387
+ }).format(compactValue);
388
+ formattedValue = `${prefix}${postfix}`;
389
+ }
390
+ const parts = [];
391
+ if (prefixText) {
392
+ parts.push(prefixText);
393
+ }
394
+ if (isSmallerThanMin && showIsSmallerThanMin) {
395
+ parts.push(number < 0 ? ">" : "<");
396
+ }
397
+ if (symbol?.toLowerCase() === "usd" && !percent) {
398
+ parts.push("$");
399
+ }
400
+ parts.push(formattedValue);
401
+ if (percent) {
402
+ parts.push("%");
403
+ }
404
+ if (symbol?.toLowerCase() !== "usd" && typeof symbol !== "undefined") {
405
+ parts.push(" ", symbol);
406
+ }
407
+ if (suffixText) {
408
+ parts.push(suffixText);
409
+ }
410
+ return parts.join("");
411
+ }
412
+ var getSafeNumber = (value) => {
413
+ if (!value) return 0;
414
+ return Number(value) > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Number(value) ?? 0;
415
+ };
416
+ var truncateDecimal = (value, maxDecimal) => {
417
+ if (!value) return "0";
418
+ const [integerPart = "0", decimalPart = "0"] = `${value}`.split(".");
419
+ return `${integerPart}.${decimalPart.substring(0, maxDecimal)}`;
420
+ };
421
+
422
+ // src/utils/getTestClient.ts
423
+ import { createTestClient, http } from "viem";
424
+ import {
425
+ defaultChainId,
426
+ getRpcUrls
427
+ } from "@berachain/config/internal";
428
+ function getTestClient(chainId = defaultChainId) {
429
+ const rpc = getRpcUrls(chainId);
430
+ if (!rpc.isAnvil) {
431
+ throw new Error("No anvil RPC URL found");
432
+ }
433
+ return createTestClient({
434
+ mode: "anvil",
435
+ transport: http(rpc.jsonRpcUrl)
436
+ });
437
+ }
438
+
439
+ export {
440
+ bignumber_js_default,
441
+ getErrorResponse,
442
+ sanitizeRpcUrl,
443
+ beraFetch,
444
+ beraFetchJson,
445
+ CAP_LIMIT_BUFFER,
446
+ MAX_CUSTOM_DEADLINE,
447
+ MIN_CUSTOM_DEADLINE,
448
+ MIN_CUSTOM_SLIPPAGE,
449
+ MAX_CUSTOM_SLIPPAGE,
450
+ DEFAULT_METAMASK_GAS_LIMIT,
451
+ getPythDefaultUpdateFee,
452
+ msToSeconds,
453
+ seconds,
454
+ minutes,
455
+ minutesInSeconds,
456
+ hours,
457
+ hoursInSeconds,
458
+ days,
459
+ daysInSeconds,
460
+ weeks,
461
+ weeksInSeconds,
462
+ months,
463
+ monthsInSeconds,
464
+ years,
465
+ yearsInSeconds,
466
+ calculateTimestampFromDays,
467
+ formatUnixTimestamp,
468
+ formatTimeLeft,
469
+ formatNumber,
470
+ getSafeNumber,
471
+ truncateDecimal,
472
+ getTestClient
473
+ };