@berachain/berajs 0.2.8-beta.9 → 0.2.10

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 (254) 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 +78 -0
  6. package/dist/actions/clients/exports.mjs +21 -0
  7. package/dist/actions/exports.d.ts +154 -207
  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-3JJLQ2JX.mjs +211 -0
  14. package/dist/chunk-7YVNSDXG.mjs +86 -0
  15. package/dist/chunk-AUOPN6NK.mjs +96 -0
  16. package/dist/chunk-BGMRHTBQ.mjs +23 -0
  17. package/dist/chunk-CDK4YV3D.mjs +571 -0
  18. package/dist/chunk-DKMAIU74.mjs +62 -0
  19. package/dist/chunk-DQRH5VE3.mjs +25 -0
  20. package/dist/chunk-E7YFXBBQ.mjs +349 -0
  21. package/dist/chunk-GUURQAME.mjs +326 -0
  22. package/dist/chunk-GY6B3PD5.mjs +89 -0
  23. package/dist/chunk-HQCOU6GY.mjs +243 -0
  24. package/dist/chunk-HYDP32P6.mjs +135 -0
  25. package/dist/chunk-IXIBY5FP.mjs +80 -0
  26. package/dist/chunk-KHXJDYA4.mjs +1776 -0
  27. package/dist/chunk-NBYLMO2L.mjs +14 -0
  28. package/dist/chunk-O2NQFKJK.mjs +170 -0
  29. package/dist/chunk-P5WXXULM.mjs +54 -0
  30. package/dist/chunk-QBBOWFMH.mjs +4129 -0
  31. package/dist/chunk-QVHEM4BG.mjs +35 -0
  32. package/dist/chunk-SGIJVHZO.mjs +12 -0
  33. package/dist/chunk-SZ5C44L5.mjs +35 -0
  34. package/dist/chunk-WNBWX23Q.mjs +426 -0
  35. package/dist/chunk-Y6THHG77.mjs +126 -0
  36. package/dist/chunk-ZLTMIFCZ.mjs +165 -0
  37. package/dist/contexts/exports.d.ts +2 -2
  38. package/dist/contexts/exports.mjs +85 -2
  39. package/dist/enum/exports.d.ts +1 -1
  40. package/dist/enum/exports.mjs +46 -2
  41. package/dist/enum/governance/exports.d.ts +60 -0
  42. package/dist/enum/governance/exports.mjs +14 -0
  43. package/dist/errors/exports.d.ts +4 -3
  44. package/dist/errors/exports.mjs +48 -2
  45. package/dist/getApolloClient-BcUTGFUb.d.ts +40 -0
  46. package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-DphU3qhE.d.ts} +2 -2
  47. package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
  48. package/dist/hooks/exports.d.ts +83 -226
  49. package/dist/hooks/exports.mjs +7463 -4
  50. package/dist/hooks/governance/exports.d.ts +181 -0
  51. package/dist/hooks/governance/exports.mjs +888 -0
  52. package/dist/pol.d-Dw5SQcRX.d.ts +153 -0
  53. package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
  54. package/dist/types/exports.d.ts +9 -9
  55. package/dist/types/exports.mjs +0 -1
  56. package/dist/types/governance/exports.d.ts +109 -0
  57. package/dist/types/governance/exports.mjs +0 -0
  58. package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
  59. package/dist/utils/exports.d.ts +15 -6
  60. package/dist/utils/exports.mjs +827 -2
  61. package/package.json +49 -13
  62. package/src/actions/__test/transports.ts +61 -0
  63. package/src/actions/clients/exports.ts +7 -0
  64. package/src/actions/clients/fetchBeep.ts +34 -0
  65. package/src/actions/clients/fetchOpenApi.ts +93 -0
  66. package/src/actions/clients/fetchOpenApi.unit.test.ts +223 -0
  67. package/src/actions/clients/fetchRailwayBackend.ts +34 -0
  68. package/src/actions/clients/getApolloClient.ts +58 -23
  69. package/src/actions/clients/getEnsoClient.ts +20 -9
  70. package/src/actions/dex/aggregators/enso/enso.ts +27 -17
  71. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
  72. package/src/actions/dex/aggregators/kyberswap.ts +18 -23
  73. package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
  74. package/src/actions/enso/getEnsoUserTokensWithBalances.ts +18 -0
  75. package/src/actions/exports.ts +5 -9
  76. package/src/actions/governance/exports.ts +9 -0
  77. package/src/actions/governance/getAllProposals.ts +10 -65
  78. package/src/actions/governance/getProposalDetails.ts +6 -33
  79. package/src/actions/governance/getProposalVotes.ts +8 -15
  80. package/src/actions/honey/getChartData.ts +27 -21
  81. package/src/actions/honey/getHoney24hVolume.ts +19 -22
  82. package/src/actions/honey/getPythLatestPrices.ts +7 -0
  83. package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +1 -1
  84. package/src/actions/pol/getAutoclaimedIncentives.ts +41 -0
  85. package/src/actions/pol/getAutoclaimedIncentivesTxHash.ts +41 -0
  86. package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
  87. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +28 -0
  88. package/src/actions/pol/getEarnedStakedBeraVault.ts +20 -20
  89. package/src/actions/pol/getGlobalData.ts +1 -0
  90. package/src/actions/pol/getHeroEarnVaults.ts +62 -0
  91. package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
  92. package/src/actions/pol/getRewardVaults.ts +4 -4
  93. package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
  94. package/src/actions/pol/getStakingDailyAssets.ts +18 -17
  95. package/src/actions/server/exports.ts +1 -0
  96. package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
  97. package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
  98. package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
  99. package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
  100. package/src/actions/validators/getValidatorAnalytics.ts +20 -21
  101. package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
  102. package/src/actions/validators/utils/getValidatorBoostApy.ts +1 -1
  103. package/src/enum/contracts.ts +1 -0
  104. package/src/enum/exports.ts +0 -1
  105. package/src/enum/governance/exports.ts +1 -0
  106. package/src/errors/BeraError.ts +47 -7
  107. package/src/errors/BeraTracing.unit.test.ts +65 -0
  108. package/src/errors/RequestError.ts +25 -4
  109. package/src/errors/RequestError.unit.test.ts +55 -0
  110. package/src/errors/errorMap.ts +8 -0
  111. package/src/errors/exports.ts +5 -0
  112. package/src/errors/getRevertReason.integration.test.ts +3 -3
  113. package/src/errors/spanStatus.ts +78 -0
  114. package/src/errors/spanStatus.unit.test.ts +62 -0
  115. package/src/hooks/dex/useCreatePool.ts +1 -88
  116. package/src/hooks/dex/useOnChainPoolData.ts +27 -2
  117. package/src/hooks/dex/usePriceImpact.ts +12 -5
  118. package/src/hooks/enso/useBendDemultiply.ts +9 -1
  119. package/src/hooks/enso/useBendMultiply.ts +9 -1
  120. package/src/hooks/enso/useBendZapSupply.ts +26 -7
  121. package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
  122. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
  123. package/src/hooks/exports.ts +3 -15
  124. package/src/hooks/governance/exports.ts +14 -0
  125. package/src/hooks/pol/useAutoclaimedIncentives.ts +40 -0
  126. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +45 -0
  127. package/src/hooks/pol/useStakedAPR.ts +2 -2
  128. package/src/hooks/pol/useStakedSnapshots.ts +5 -9
  129. package/src/hooks/validators/useValidator.ts +6 -8
  130. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
  131. package/src/types/bribe-boost.d.ts +19 -0
  132. package/src/types/exports.ts +0 -1
  133. package/src/types/governance/exports.ts +1 -0
  134. package/src/utils/beraFetch.ts +9 -3
  135. package/src/utils/exports.ts +1 -0
  136. package/src/utils/getServerSideClient.ts +4 -2
  137. package/src/utils/polyfillAbortSignalAny.ts +53 -0
  138. package/src/utils/polyfillAbortSignalAny.unit.test.ts +81 -0
  139. package/src/utils/sanitizeRpcUrl.ts +22 -0
  140. package/src/utils/tracedTransport.ts +35 -0
  141. package/dist/BeraError-_mQdkanr.d.ts +0 -94
  142. package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
  143. package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
  144. package/dist/RequestError-DSUzJ1Iy.d.cts +0 -144
  145. package/dist/abi/exports.cjs +0 -2
  146. package/dist/abi/exports.cjs.map +0 -1
  147. package/dist/abi/exports.d.cts +0 -6574
  148. package/dist/abi/exports.mjs.map +0 -1
  149. package/dist/actions/exports.cjs +0 -2
  150. package/dist/actions/exports.cjs.map +0 -1
  151. package/dist/actions/exports.d.cts +0 -1650
  152. package/dist/actions/exports.mjs.map +0 -1
  153. package/dist/chunk-45HIEVNI.cjs +0 -4
  154. package/dist/chunk-45HIEVNI.cjs.map +0 -1
  155. package/dist/chunk-47ILYVHC.mjs +0 -2
  156. package/dist/chunk-47ILYVHC.mjs.map +0 -1
  157. package/dist/chunk-575OK77P.mjs +0 -2
  158. package/dist/chunk-575OK77P.mjs.map +0 -1
  159. package/dist/chunk-5NVZG5N6.mjs +0 -2
  160. package/dist/chunk-5NVZG5N6.mjs.map +0 -1
  161. package/dist/chunk-6DIA6PXV.cjs +0 -2
  162. package/dist/chunk-6DIA6PXV.cjs.map +0 -1
  163. package/dist/chunk-6JJIZCVY.cjs +0 -2
  164. package/dist/chunk-6JJIZCVY.cjs.map +0 -1
  165. package/dist/chunk-7F72ZH4Q.mjs +0 -2
  166. package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
  167. package/dist/chunk-AUA42YIG.mjs +0 -4
  168. package/dist/chunk-AUA42YIG.mjs.map +0 -1
  169. package/dist/chunk-BC2WX6O6.cjs +0 -2
  170. package/dist/chunk-BC2WX6O6.cjs.map +0 -1
  171. package/dist/chunk-CJOZC5Z2.cjs +0 -2
  172. package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
  173. package/dist/chunk-D6L7LTA2.cjs +0 -2
  174. package/dist/chunk-D6L7LTA2.cjs.map +0 -1
  175. package/dist/chunk-DDEQFR3M.cjs +0 -2
  176. package/dist/chunk-DDEQFR3M.cjs.map +0 -1
  177. package/dist/chunk-GXV2JA36.mjs +0 -2
  178. package/dist/chunk-GXV2JA36.mjs.map +0 -1
  179. package/dist/chunk-ISYNEDET.mjs +0 -2
  180. package/dist/chunk-ISYNEDET.mjs.map +0 -1
  181. package/dist/chunk-JDDRTHFG.mjs +0 -2
  182. package/dist/chunk-JDDRTHFG.mjs.map +0 -1
  183. package/dist/chunk-JDZGYU5T.mjs +0 -2
  184. package/dist/chunk-JDZGYU5T.mjs.map +0 -1
  185. package/dist/chunk-LVOXBZMA.cjs +0 -2
  186. package/dist/chunk-LVOXBZMA.cjs.map +0 -1
  187. package/dist/chunk-MK5NS5B5.mjs +0 -2
  188. package/dist/chunk-MK5NS5B5.mjs.map +0 -1
  189. package/dist/chunk-NAXAZJJY.mjs +0 -2
  190. package/dist/chunk-NAXAZJJY.mjs.map +0 -1
  191. package/dist/chunk-NLVWRMGD.mjs +0 -2
  192. package/dist/chunk-NLVWRMGD.mjs.map +0 -1
  193. package/dist/chunk-OGBD5YOG.mjs +0 -2
  194. package/dist/chunk-OGBD5YOG.mjs.map +0 -1
  195. package/dist/chunk-OGJMSGB2.mjs +0 -2
  196. package/dist/chunk-OGJMSGB2.mjs.map +0 -1
  197. package/dist/chunk-OIYXOKTT.cjs +0 -2
  198. package/dist/chunk-OIYXOKTT.cjs.map +0 -1
  199. package/dist/chunk-OUD27MU7.cjs +0 -2
  200. package/dist/chunk-OUD27MU7.cjs.map +0 -1
  201. package/dist/chunk-PRLVZIKD.mjs +0 -2
  202. package/dist/chunk-PRLVZIKD.mjs.map +0 -1
  203. package/dist/chunk-Q2SNRLW3.cjs +0 -2
  204. package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
  205. package/dist/chunk-REWME3FY.cjs +0 -2
  206. package/dist/chunk-REWME3FY.cjs.map +0 -1
  207. package/dist/chunk-RJN36GBU.mjs +0 -2
  208. package/dist/chunk-RJN36GBU.mjs.map +0 -1
  209. package/dist/chunk-RWOICHRW.cjs +0 -2
  210. package/dist/chunk-RWOICHRW.cjs.map +0 -1
  211. package/dist/chunk-S4CDSVLK.cjs +0 -2
  212. package/dist/chunk-S4CDSVLK.cjs.map +0 -1
  213. package/dist/chunk-SFEULGSX.cjs +0 -2
  214. package/dist/chunk-SFEULGSX.cjs.map +0 -1
  215. package/dist/chunk-WBTS6KFG.mjs +0 -2
  216. package/dist/chunk-WBTS6KFG.mjs.map +0 -1
  217. package/dist/chunk-WRFDB3QJ.cjs +0 -2
  218. package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
  219. package/dist/chunk-XNJLSA6P.cjs +0 -2
  220. package/dist/chunk-XNJLSA6P.cjs.map +0 -1
  221. package/dist/contexts/exports.cjs +0 -2
  222. package/dist/contexts/exports.cjs.map +0 -1
  223. package/dist/contexts/exports.d.cts +0 -66
  224. package/dist/contexts/exports.mjs.map +0 -1
  225. package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
  226. package/dist/dex-C_BB0b0O.d.cts +0 -37
  227. package/dist/enum/exports.cjs +0 -2
  228. package/dist/enum/exports.cjs.map +0 -1
  229. package/dist/enum/exports.d.cts +0 -23
  230. package/dist/enum/exports.mjs.map +0 -1
  231. package/dist/errors/exports.cjs +0 -2
  232. package/dist/errors/exports.cjs.map +0 -1
  233. package/dist/errors/exports.d.cts +0 -327
  234. package/dist/errors/exports.mjs.map +0 -1
  235. package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
  236. package/dist/global.d-B7IeayVX.d.cts +0 -474
  237. package/dist/honey-CYm0RWf4.d.cts +0 -14
  238. package/dist/hooks/exports.cjs +0 -4
  239. package/dist/hooks/exports.cjs.map +0 -1
  240. package/dist/hooks/exports.d.cts +0 -1734
  241. package/dist/hooks/exports.mjs.map +0 -1
  242. package/dist/polling-BKnyavLI.d.cts +0 -8
  243. package/dist/txnEnum-7_o92X3N.d.ts +0 -164
  244. package/dist/types/exports.cjs +0 -1
  245. package/dist/types/exports.cjs.map +0 -1
  246. package/dist/types/exports.d.cts +0 -90
  247. package/dist/types/exports.mjs.map +0 -1
  248. package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
  249. package/dist/utils/exports.cjs +0 -2
  250. package/dist/utils/exports.cjs.map +0 -1
  251. package/dist/utils/exports.d.cts +0 -420
  252. package/dist/utils/exports.mjs.map +0 -1
  253. package/src/actions/dex/getIsTokenExploited.ts +0 -63
  254. package/src/hooks/dex/useExploitedTokens.ts +0 -57
@@ -0,0 +1,62 @@
1
+ // src/enum/governance.ts
2
+ var ProposalState = /* @__PURE__ */ ((ProposalState2) => {
3
+ ProposalState2[ProposalState2["Pending"] = 0] = "Pending";
4
+ ProposalState2[ProposalState2["Active"] = 1] = "Active";
5
+ ProposalState2[ProposalState2["Canceled"] = 2] = "Canceled";
6
+ ProposalState2[ProposalState2["Defeated"] = 3] = "Defeated";
7
+ ProposalState2[ProposalState2["Succeeded"] = 4] = "Succeeded";
8
+ ProposalState2[ProposalState2["Queued"] = 5] = "Queued";
9
+ ProposalState2[ProposalState2["Expired"] = 6] = "Expired";
10
+ ProposalState2[ProposalState2["Executed"] = 7] = "Executed";
11
+ return ProposalState2;
12
+ })(ProposalState || {});
13
+ var VoteEnum = /* @__PURE__ */ ((VoteEnum2) => {
14
+ VoteEnum2["AGAINST"] = "no";
15
+ VoteEnum2["FOR"] = "yes";
16
+ VoteEnum2["ABSTAIN"] = "abstain";
17
+ return VoteEnum2;
18
+ })(VoteEnum || {});
19
+ var ProposalErrorCodes = /* @__PURE__ */ ((ProposalErrorCodes2) => {
20
+ ProposalErrorCodes2["REQUIRED"] = "Required";
21
+ ProposalErrorCodes2["INVALID_AMOUNT"] = "Invalid amount";
22
+ ProposalErrorCodes2["NEGATIVE_AMOUNT"] = "Negative amount";
23
+ ProposalErrorCodes2["INVALID_ADDRESS"] = "Invalid address";
24
+ ProposalErrorCodes2["INVALID_ACTION"] = "Invalid action";
25
+ ProposalErrorCodes2["INVALID_ABI"] = "Invalid ABI";
26
+ ProposalErrorCodes2["MUST_BE_HTTPS"] = "Must be HTTPS";
27
+ ProposalErrorCodes2["MUST_BE_HTTPS_OR_IPFS"] = "Must be HTTPS or IPFS";
28
+ ProposalErrorCodes2["INVALID_BASEPATH"] = "Must be a berachain forum link";
29
+ ProposalErrorCodes2["INVALID_CONTRACT"] = "This is not a valid contract";
30
+ return ProposalErrorCodes2;
31
+ })(ProposalErrorCodes || {});
32
+ var ProposalTypeEnum = /* @__PURE__ */ ((ProposalTypeEnum2) => {
33
+ ProposalTypeEnum2["CUSTOM_PROPOSAL"] = "custom-action";
34
+ ProposalTypeEnum2["WHITELIST_REWARD_VAULT"] = "whitelist-reward-vault";
35
+ ProposalTypeEnum2["BLACKLIST_REWARD_VAULT"] = "blacklist-reward-vault";
36
+ ProposalTypeEnum2["ERC20_TRANSFER"] = "erc20-transfer";
37
+ ProposalTypeEnum2["WHITELIST_REWARD_VAULT_INCENTIVE"] = "whitelist-reward-vault-incentive";
38
+ return ProposalTypeEnum2;
39
+ })(ProposalTypeEnum || {});
40
+ var VoteColorMap = {
41
+ yes: "#059669",
42
+ 1: "#059669",
43
+ no: "#DC2629",
44
+ 2: "#DC2629",
45
+ veto: "#0284C7",
46
+ 4: "#0284C7",
47
+ abstain: "#78716c",
48
+ 3: "#78716c",
49
+ yes_secondary: "#ECFDF5",
50
+ no_secondary: "#FEF2F2",
51
+ veto_secondary: "#F0F9FF",
52
+ abstain_secondary: "#E7E5E4",
53
+ default: "#57534e"
54
+ };
55
+
56
+ export {
57
+ ProposalState,
58
+ VoteEnum,
59
+ ProposalErrorCodes,
60
+ ProposalTypeEnum,
61
+ VoteColorMap
62
+ };
@@ -0,0 +1,25 @@
1
+ import {
2
+ InvalidArgumentError
3
+ } from "./chunk-KHXJDYA4.mjs";
4
+
5
+ // src/utils/parseBaseArgs.ts
6
+ import {
7
+ chainConfigs,
8
+ defaultChainId
9
+ } from "@berachain/config/internal";
10
+ function parseBaseArgs(args) {
11
+ const chainId = args.chainId ?? defaultChainId;
12
+ const config = args.config ?? chainConfigs[chainId];
13
+ if (args.chainId && args.chainId !== config.chainId) {
14
+ throw new InvalidArgumentError({
15
+ property: "chainId",
16
+ value: chainId,
17
+ expected: `config.chainId: ${config.chainId}`
18
+ });
19
+ }
20
+ return { config, chainId: config.chainId };
21
+ }
22
+
23
+ export {
24
+ parseBaseArgs
25
+ };
@@ -0,0 +1,349 @@
1
+ // src/utils/constants.ts
2
+ import { parseEther } from "viem";
3
+ var CAP_LIMIT_BUFFER = parseEther("0.005");
4
+ var MAX_CUSTOM_DEADLINE = 1e5;
5
+ var MIN_CUSTOM_DEADLINE = 1;
6
+ var MIN_CUSTOM_SLIPPAGE = 0.1;
7
+ var MAX_CUSTOM_SLIPPAGE = 50;
8
+ var DEFAULT_METAMASK_GAS_LIMIT = 7920027n;
9
+
10
+ // src/utils/pythHoneyUtils.ts
11
+ var getPythDefaultUpdateFee = (tokenListLength) => {
12
+ return 2n * BigInt(tokenListLength);
13
+ };
14
+
15
+ // src/utils/time.ts
16
+ function msToSeconds(ms) {
17
+ return Math.floor(ms / 1e3);
18
+ }
19
+ function seconds(seconds2) {
20
+ return seconds2 * 1e3;
21
+ }
22
+ function minutes(minutes2) {
23
+ return minutes2 * seconds(60);
24
+ }
25
+ function minutesInSeconds(minutes2) {
26
+ return minutes2 * 60;
27
+ }
28
+ function hours(hours2) {
29
+ return hours2 * minutes(60);
30
+ }
31
+ function hoursInSeconds(hours2) {
32
+ return hours2 * minutesInSeconds(60);
33
+ }
34
+ function days(days2) {
35
+ return days2 * hours(24);
36
+ }
37
+ function daysInSeconds(days2) {
38
+ return days2 * hoursInSeconds(24);
39
+ }
40
+ function weeks(weeks2) {
41
+ return weeks2 * days(7);
42
+ }
43
+ function weeksInSeconds(weeks2) {
44
+ return weeks2 * daysInSeconds(7);
45
+ }
46
+ function months(months2) {
47
+ return months2 * days(30);
48
+ }
49
+ function monthsInSeconds(months2) {
50
+ return months2 * daysInSeconds(30);
51
+ }
52
+ function years(years2) {
53
+ return years2 * days(365);
54
+ }
55
+ function yearsInSeconds(years2) {
56
+ return years2 * daysInSeconds(365);
57
+ }
58
+
59
+ // src/utils/formatTimestamps.ts
60
+ function calculateTimestampFromDays(daysRange) {
61
+ const currentDate = /* @__PURE__ */ new Date();
62
+ return currentDate.setDate(currentDate.getDate() - daysRange) * 1e3;
63
+ }
64
+ var monthNames = [
65
+ "January",
66
+ "February",
67
+ "March",
68
+ "April",
69
+ "May",
70
+ "June",
71
+ "July",
72
+ "August",
73
+ "September",
74
+ "October",
75
+ "November",
76
+ "December"
77
+ ];
78
+ var shortMonthNames = [
79
+ "Jan",
80
+ "Feb",
81
+ "Mar",
82
+ "Apr",
83
+ "May",
84
+ "Jun",
85
+ "Jul",
86
+ "Aug",
87
+ "Sep",
88
+ "Oct",
89
+ "Nov",
90
+ "Dec"
91
+ ];
92
+ function formatUnixTimestamp(unixTimestamp, isShort) {
93
+ const date = new Date(unixTimestamp * 1e3);
94
+ const day = date.getDate();
95
+ let daySuffix = "th";
96
+ if (day === 1 || day === 21 || day === 31) {
97
+ daySuffix = "st";
98
+ } else if (day === 2 || day === 22) {
99
+ daySuffix = "nd";
100
+ } else if (day === 3 || day === 23) {
101
+ daySuffix = "rd";
102
+ }
103
+ if (isShort) {
104
+ return `${shortMonthNames[date.getMonth()]} ${day}`;
105
+ }
106
+ return `${monthNames[date.getMonth()]} ${day}${daySuffix}, ${date.getFullYear()}`;
107
+ }
108
+ function formatTimeLeft(...args) {
109
+ const timeLeftInSeconds = args[0];
110
+ let condensed;
111
+ let showDays;
112
+ let showMinutes;
113
+ let showSeconds;
114
+ if (typeof args[1] !== "object") {
115
+ condensed = args[1] ?? false;
116
+ showDays = args[2] ?? false;
117
+ showSeconds = args[3] ?? false;
118
+ showMinutes = true;
119
+ } else {
120
+ const opts = args[1];
121
+ condensed = opts.condensed ?? false;
122
+ const greaterUnit = opts.greaterUnit ?? "hours";
123
+ if (greaterUnit === "days") {
124
+ showDays = true;
125
+ showMinutes = true;
126
+ } else if (greaterUnit === "hours") {
127
+ showDays = false;
128
+ showMinutes = true;
129
+ showSeconds = false;
130
+ } else {
131
+ showDays = false;
132
+ showMinutes = true;
133
+ }
134
+ showSeconds = opts.showSeconds ?? false;
135
+ }
136
+ let days2 = Math.floor(timeLeftInSeconds / (3600 * 24));
137
+ let hours2 = Math.floor(timeLeftInSeconds % (3600 * 24) / 3600);
138
+ const minutes2 = Math.floor(timeLeftInSeconds % 3600 / 60);
139
+ const seconds2 = timeLeftInSeconds % 60;
140
+ if (!showDays) {
141
+ hours2 += days2 * 24;
142
+ days2 = 0;
143
+ }
144
+ if (days2 === 0 && hours2 === 0 && minutes2 === 0) {
145
+ return condensed ? "< 1 M" : "less than a minute";
146
+ }
147
+ const daysDisplay = days2 > 0 ? `${days2}${condensed ? "D" : " day"}${!condensed && days2 !== 1 ? "s" : ""}` : "";
148
+ const hoursDisplay = hours2 > 0 ? `${hours2}${condensed ? "H" : " hour"}${!condensed && hours2 !== 1 ? "s" : ""}` : "";
149
+ const minutesDisplay = minutes2 > 0 && showMinutes || !days2 && !hours2 ? `${minutes2}${condensed ? "M" : " minute"}${!condensed && minutes2 !== 1 ? "s" : ""}` : "";
150
+ const secondsDisplay = seconds2 > 0 && showSeconds ? `${seconds2}${condensed ? "S" : " second"}${!condensed && seconds2 !== 1 ? "s" : ""}` : "";
151
+ return [daysDisplay, hoursDisplay, minutesDisplay, secondsDisplay].filter(Boolean).join(condensed ? " " : ", ");
152
+ }
153
+
154
+ // ../utils/src/pkg/bignumber.js.ts
155
+ import BigNumber from "bignumber.js";
156
+ BigNumber.set({
157
+ // The EXPONENTIAL_AT option defines the exponent value(s) at which toString returns exponential notation.
158
+ // - Single number: the exponent magnitude at and above which exponential notation is used (e.g., `1e9` here disables it for almost all values).
159
+ // - 1e9 is the maximum value supported by BigNumber.js.
160
+ // See: https://mikemcl.github.io/bignumber.js/#exponential-at
161
+ EXPONENTIAL_AT: 1e9
162
+ });
163
+ var bignumber_js_default = BigNumber;
164
+
165
+ // src/utils/formatNumber.ts
166
+ var POSTFIXES = ["", "K", "M", "B", "T", "P", "E", "Z", "Y"];
167
+ function valueToBigNumber(amount) {
168
+ if (amount instanceof bignumber_js_default) return amount;
169
+ return new bignumber_js_default(amount);
170
+ }
171
+ function normalizeBN(n, decimals) {
172
+ return valueToBigNumber(n).shiftedBy(decimals * -1);
173
+ }
174
+ function formatNumber(value, options = {}) {
175
+ if (typeof options === "number") {
176
+ const decimals2 = options;
177
+ if (value === void 0 || value === null) {
178
+ return "";
179
+ }
180
+ if (typeof value === "object") {
181
+ throw new Error("Value must be a number if using deprecated version");
182
+ }
183
+ let formatted = Number(value).toFixed(decimals2);
184
+ formatted = formatted.replace(/(\.\d*?[1-9])0+$|\.0*$/, "$1");
185
+ return formatted;
186
+ }
187
+ const {
188
+ visibleDecimals,
189
+ compact = true,
190
+ percent = false,
191
+ roundDown = false,
192
+ roundUp = false,
193
+ compactThreshold,
194
+ maxValue,
195
+ symbol,
196
+ prefixText = "",
197
+ suffixText = "",
198
+ showIsSmallerThanMin = true,
199
+ ifNullish = ""
200
+ } = options || {};
201
+ if (value === void 0 || value === null) {
202
+ return ifNullish;
203
+ }
204
+ const number = percent ? Number(value) * 100 : Number(value);
205
+ if (Number.isNaN(number)) {
206
+ return "NaN";
207
+ }
208
+ if (number === Number.POSITIVE_INFINITY) {
209
+ return "Infinity";
210
+ }
211
+ if (number === Number.NEGATIVE_INFINITY) {
212
+ return "-Infinity";
213
+ }
214
+ let decimals = visibleDecimals ?? 0;
215
+ if (number === 0) {
216
+ decimals = 0;
217
+ } else if (visibleDecimals === void 0) {
218
+ if (Math.abs(number) > 1 || percent || symbol === "USD") {
219
+ decimals = 2;
220
+ } else {
221
+ decimals = 7;
222
+ }
223
+ }
224
+ const minValue = 10 ** -decimals;
225
+ const isSmallerThanMin = number !== 0 && Math.abs(number) < Math.abs(minValue);
226
+ const isNegative = number < 0;
227
+ const isBiggerThanMax = maxValue ? Math.abs(number) > maxValue : false;
228
+ let formattedNumber = isSmallerThanMin ? minValue : number;
229
+ const forceCompact = compact && (!compactThreshold || Math.abs(number) > compactThreshold);
230
+ if (roundDown && !forceCompact) {
231
+ formattedNumber = Math.trunc(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
232
+ } else if (roundUp && !forceCompact) {
233
+ formattedNumber = Math.ceil(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
234
+ }
235
+ let formattedValue;
236
+ if (isBiggerThanMax) {
237
+ formattedValue = number > maxValue ? "\u221E" : "-\u221E";
238
+ } else if (!forceCompact) {
239
+ const absFormatted = new Intl.NumberFormat("en-US", {
240
+ maximumFractionDigits: decimals,
241
+ minimumFractionDigits: decimals
242
+ }).format(Math.abs(formattedNumber));
243
+ formattedValue = `${isNegative ? "-" : ""}${absFormatted}`;
244
+ } else {
245
+ const bnValue = valueToBigNumber(formattedNumber);
246
+ let integerPlaces = bnValue.abs().toFixed(0).length;
247
+ if (compactThreshold && Math.abs(number) <= compactThreshold) {
248
+ integerPlaces = 0;
249
+ }
250
+ const significantDigitsGroup = Math.min(
251
+ Math.floor(integerPlaces ? (integerPlaces - 1) / 3 : 0),
252
+ POSTFIXES.length - 1
253
+ );
254
+ const postfix = POSTFIXES[significantDigitsGroup];
255
+ let compactValue = normalizeBN(
256
+ bnValue,
257
+ 3 * significantDigitsGroup
258
+ ).toNumber();
259
+ if (roundDown) {
260
+ compactValue = Math.trunc(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
261
+ } else if (roundUp) {
262
+ compactValue = Math.ceil(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
263
+ }
264
+ const prefix = new Intl.NumberFormat("en-US", {
265
+ maximumFractionDigits: decimals,
266
+ minimumFractionDigits: decimals
267
+ }).format(compactValue);
268
+ formattedValue = `${prefix}${postfix}`;
269
+ }
270
+ const parts = [];
271
+ if (prefixText) {
272
+ parts.push(prefixText);
273
+ }
274
+ if (isSmallerThanMin && showIsSmallerThanMin) {
275
+ parts.push(number < 0 ? ">" : "<");
276
+ }
277
+ if (symbol?.toLowerCase() === "usd" && !percent) {
278
+ parts.push("$");
279
+ }
280
+ parts.push(formattedValue);
281
+ if (percent) {
282
+ parts.push("%");
283
+ }
284
+ if (symbol?.toLowerCase() !== "usd" && typeof symbol !== "undefined") {
285
+ parts.push(" ", symbol);
286
+ }
287
+ if (suffixText) {
288
+ parts.push(suffixText);
289
+ }
290
+ return parts.join("");
291
+ }
292
+ var getSafeNumber = (value) => {
293
+ if (!value) return 0;
294
+ return Number(value) > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Number(value) ?? 0;
295
+ };
296
+ var truncateDecimal = (value, maxDecimal) => {
297
+ if (!value) return "0";
298
+ const [integerPart = "0", decimalPart = "0"] = `${value}`.split(".");
299
+ return `${integerPart}.${decimalPart.substring(0, maxDecimal)}`;
300
+ };
301
+
302
+ // src/utils/getTestClient.ts
303
+ import { createTestClient, http } from "viem";
304
+ import {
305
+ defaultChainId,
306
+ getRpcUrls
307
+ } from "@berachain/config/internal";
308
+ function getTestClient(chainId = defaultChainId) {
309
+ const rpc = getRpcUrls(chainId);
310
+ if (!rpc.isAnvil) {
311
+ throw new Error("No anvil RPC URL found");
312
+ }
313
+ return createTestClient({
314
+ mode: "anvil",
315
+ transport: http(rpc.jsonRpcUrl)
316
+ });
317
+ }
318
+
319
+ export {
320
+ bignumber_js_default,
321
+ CAP_LIMIT_BUFFER,
322
+ MAX_CUSTOM_DEADLINE,
323
+ MIN_CUSTOM_DEADLINE,
324
+ MIN_CUSTOM_SLIPPAGE,
325
+ MAX_CUSTOM_SLIPPAGE,
326
+ DEFAULT_METAMASK_GAS_LIMIT,
327
+ getPythDefaultUpdateFee,
328
+ msToSeconds,
329
+ seconds,
330
+ minutes,
331
+ minutesInSeconds,
332
+ hours,
333
+ hoursInSeconds,
334
+ days,
335
+ daysInSeconds,
336
+ weeks,
337
+ weeksInSeconds,
338
+ months,
339
+ monthsInSeconds,
340
+ years,
341
+ yearsInSeconds,
342
+ calculateTimestampFromDays,
343
+ formatUnixTimestamp,
344
+ formatTimeLeft,
345
+ formatNumber,
346
+ getSafeNumber,
347
+ truncateDecimal,
348
+ getTestClient
349
+ };