@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
@@ -0,0 +1,35 @@
1
+ import type { Transport } from "viem";
2
+
3
+ import { BeraTracing } from "../errors/BeraTracing";
4
+ import { sanitizeRpcUrl } from "./sanitizeRpcUrl";
5
+
6
+ /**
7
+ * Wraps a viem Transport to trace each RPC request via BeraTracing.
8
+ *
9
+ * Each `request()` call is wrapped in a span with the JSON-RPC method name,
10
+ * transport type, and URL as attributes. Works with `http()`, `fallback()`,
11
+ * and any other viem transport.
12
+ */
13
+ export function tracedTransport<T extends Transport>(transport: T): T {
14
+ return ((opts: Parameters<Transport>[0]) => {
15
+ const result = transport(opts);
16
+ const originalRequest = result.request;
17
+
18
+ result.request = async (args, options) => {
19
+ return BeraTracing.startSpan(
20
+ {
21
+ name: `RPC ${args.method}`,
22
+ op: "rpc.request",
23
+ attributes: {
24
+ "rpc.method": args.method,
25
+ "rpc.transport": result.config.type,
26
+ "rpc.url": sanitizeRpcUrl(result.value?.url),
27
+ },
28
+ },
29
+ () => originalRequest(args, options),
30
+ );
31
+ };
32
+
33
+ return result;
34
+ }) as T;
35
+ }
@@ -1,94 +0,0 @@
1
- import { Abi } from 'viem';
2
-
3
- /**
4
- * Severity levels for error reporting.
5
- * Mirrors Sentry's SeverityLevel for compatibility, but owned by berajs
6
- * so we don't depend on @sentry/nextjs.
7
- */
8
- type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
9
-
10
- interface IBeraErrorArgs {
11
- message?: string;
12
- displayMessage?: string;
13
- cause?: unknown;
14
- reason?: string;
15
- chainId?: number;
16
- fingerprint?: string[];
17
- /**
18
- * The level of the error to be used for error reporting.
19
- */
20
- level?: SeverityLevel;
21
- tags?: {
22
- [key in TagsKey]?: Primitive;
23
- };
24
- extra?: Record<string, unknown>;
25
- /**
26
- * Optional ABI to be used to parse the error.
27
- */
28
- abi?: Abi;
29
- }
30
- type Primitive = number | string | boolean | bigint | symbol | null | undefined;
31
- /**
32
- * An helper type to make sure we only use the allowed tags. Sync this with docs/errors.md
33
- */
34
- type TagsKey = "wallet.chain" | "wallet.connector" | "wallet.address" | "error.reason" | "operation.type" | "operation.key" | "operation.txn.functionName" | "operation.txn.to" | "operation.txn.status" | "operation.source.url" | "operation.source.name" | "operation.source.queryName" | "operation.source.type";
35
- /**
36
- * Base error class for the entire berajs SDK.
37
- *
38
- * All errors should be a BeraError or one of its subclasses. Unknown errors should be
39
- * normalized via `initBeraError({ cause })`.
40
- *
41
- * Key design: the constructor runs an **automatic reason detection pipeline** when `reason`
42
- * is not explicitly provided. It calls `parseViemError` on the `cause` to extract a
43
- * machine-readable reason code (e.g. "NotEnoughBalance", "BAL#508", "UserRejectedRequestError").
44
- * That reason is then matched against `errorMap.ts` to resolve a user-friendly `displayMessage`.
45
- *
46
- * This means: for most viem errors, you only need to pass `cause` and everything else
47
- * (reason, displayMessage, level) is derived automatically.
48
- *
49
- * @see parseViemError — the reason extraction engine
50
- * @see errorMap.ts — reason → displayMessage mapping
51
- * @see initBeraError — normalizes any error into a BeraError (preferred entry point)
52
- */
53
- declare class BeraError extends Error {
54
- /**
55
- * A human-readable message that can be displayed to end user.
56
- *
57
- * In berachain dapps, this is shown in the error pop-up.
58
- */
59
- displayMessage: string;
60
- /**
61
- * The cause of the error.
62
- *
63
- * This is typically the error that was thrown.
64
- */
65
- cause: unknown;
66
- /**
67
- * The chain id of the error.
68
- */
69
- chainId?: number;
70
- /**
71
- * The code for the reason for the error.
72
- *
73
- * This is typically the error code can be found in the errorMap.ts file. I.e. NotEnoughBalance or BAL#508
74
- */
75
- reason: string | null;
76
- /**
77
- * The fingerprint for the error.
78
- *
79
- * This is typically used to group errors in Sentry.
80
- */
81
- fingerprint: string[] | undefined;
82
- private _tags;
83
- set tags(tags: {
84
- [key: string | TagsKey]: Primitive;
85
- });
86
- get tags(): {
87
- [key: string | TagsKey]: Primitive;
88
- };
89
- level: SeverityLevel;
90
- extra: Record<string, unknown>;
91
- constructor({ message: m, displayMessage: dm, cause, reason, level, abi, tags, chainId, fingerprint, }: IBeraErrorArgs);
92
- }
93
-
94
- export { BeraError as B, type IBeraErrorArgs as I, type SeverityLevel as S };
@@ -1,70 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { Dispatch, SetStateAction, PropsWithChildren } from 'react';
4
- import { Hex } from 'viem';
5
- import { EdgeConfigSchema } from '@berachain/config/internal/edge-config';
6
-
7
- type FactoryStatus = {
8
- /**
9
- * If the composable stable factory is enabled
10
- */
11
- composableStable: "paused" | "enabled";
12
- /**
13
- * If the weighted factory is enabled
14
- */
15
- weighted: "paused" | "enabled";
16
- };
17
- interface BexStatusProviderProps {
18
- isVaultPaused: boolean;
19
- pool?: {
20
- id: Hex;
21
- isInRecoveryMode: boolean;
22
- isPaused: boolean;
23
- };
24
- factories: FactoryStatus;
25
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
26
- }
27
- declare const BexStateContext: react.Context<{
28
- protocol: {
29
- isPaused: boolean;
30
- factories: FactoryStatus & {
31
- allPaused: boolean;
32
- };
33
- };
34
- onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
35
- pool?: {
36
- id: Hex;
37
- isInRecoveryMode: boolean;
38
- isPaused: boolean;
39
- disablePoolWithdrawals: boolean;
40
- disablePoolDeposits: boolean;
41
- };
42
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
43
- }>;
44
- /**
45
- * @description Determines the status of a pool or vault and returns the appropriate messages and flags to disable functionality.
46
- * More information here https://www.notion.so/berachain/BEX-RecoveryMode-and-Pause-explained-17c6120abced80e0985dd589b57ff018
47
- *
48
- * @returns status flags to enable/disable/notify users across the BEX
49
- *
50
- **/
51
- declare function useBexStatus(): {
52
- protocol: {
53
- isPaused: boolean;
54
- factories: FactoryStatus & {
55
- allPaused: boolean;
56
- };
57
- };
58
- onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
59
- pool?: {
60
- id: Hex;
61
- isInRecoveryMode: boolean;
62
- isPaused: boolean;
63
- disablePoolWithdrawals: boolean;
64
- disablePoolDeposits: boolean;
65
- };
66
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
67
- };
68
- declare function BexStatusProvider({ children, isVaultPaused, labels, factories, }: PropsWithChildren<BexStatusProviderProps>): react_jsx_runtime.JSX.Element;
69
-
70
- export { BexStateContext as B, BexStatusProvider as a, type BexStatusProviderProps as b, useBexStatus as u };
@@ -1,390 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { Address, PublicClient, Abi, Hex } from 'viem';
4
- import { Token as Token$1 } from '@berachain/graphql/pol/api';
5
- import { SwapKind } from '@berachain-foundation/berancer-sdk';
6
- import { H as HoneySwapAction } from './honey-CYm0RWf4.cjs';
7
-
8
- interface CollateralRates {
9
- mintFee: number;
10
- redeemFee: number;
11
- }
12
- interface HoneyFeeMap {
13
- single: Record<Address, CollateralRates>;
14
- basket: CollateralRates;
15
- }
16
- interface CollateralRatesArgs extends BeraJS.BaseFunctionArgs {
17
- client: PublicClient;
18
- collateralList: Token$1[];
19
- }
20
- /**
21
- * Fetches the mint and redeem rates for all collateral tokens and calculates the weighted basket rates
22
- * @param {Object} params - The parameters object
23
- * @param {PublicClient} params.client - The Viem public client instance
24
- * @param {Address[]} params.collateralList - Array of collateral token addresses
25
- * @returns {Promise<HoneyFeeMap | undefined>} Object containing individual collateral rates and weighted basket rates,
26
- * or undefined if the operation fails
27
- */
28
- declare function getHoneyFees({ client, collateralList, ...args }: CollateralRatesArgs): Promise<HoneyFeeMap>;
29
-
30
- type MinimalERC20 = {
31
- address: Address;
32
- decimals: number;
33
- symbol: string;
34
- name: string;
35
- chainId: number;
36
- };
37
-
38
- type TokenWithMetadata = MinimalERC20 & {
39
- tags?: string[];
40
- base64?: string;
41
- logoURI?: string;
42
- };
43
-
44
- type Token = TokenWithMetadata & {
45
- totalSupply?: string;
46
- weight?: number | string | null;
47
- };
48
-
49
- interface TokenPriceInfo {
50
- price: number;
51
- updatedAt: number;
52
- chainId: number;
53
- }
54
-
55
- type TokenCurrentPriceMap = Record<
56
- Lowercase<Address> | string,
57
- TokenPriceInfo | undefined
58
- >;
59
-
60
- interface TokenWithAmount extends Token {
61
- amount: string;
62
- exceeding?: boolean;
63
- }
64
-
65
- interface TokenWithPrice extends Token {
66
- price: number;
67
- }
68
-
69
- interface BalanceToken extends Token {
70
- balance: {
71
- /**
72
- * This is the string representation of the balance in wei.
73
- *
74
- * It can be safely parsed to a bigint, but we're returning it as a string to avoid serialization issues.
75
- *
76
- * @example "1200000000000000000"
77
- */
78
- raw: string;
79
- /**
80
- * This is the formatted representation of the balance in the token's decimals.
81
- *
82
- * @example "1.2"
83
- */
84
- formatted: string;
85
- };
86
- /**
87
- * Price of the token in USD.
88
- */
89
- price?: number;
90
- /**
91
- * Balance value in USD.
92
- * Calculated as balance * price.
93
- */
94
- usdValue?: number;
95
- }
96
-
97
- interface SwapRequest {
98
- tokenIn: Address;
99
- tokenOut: Address;
100
- tokenInDecimals: number;
101
- tokenOutDecimals: number;
102
- amount: string;
103
- wberaIsBera: boolean;
104
- swapKind: SwapKind;
105
- }
106
-
107
- /**
108
- * Object with properties to check the allowance of a token.
109
- */
110
- interface AllowanceQueryItem {
111
- token: MinimalERC20;
112
- /**
113
- * The amount of the token to approve.
114
- */
115
- amount: {
116
- raw: string;
117
- formatted: string;
118
- };
119
- /**
120
- * The address to approve the tokens to.
121
- */
122
- spender: Address;
123
- }
124
-
125
- interface AllowanceToken extends AllowanceQueryItem {
126
- /**
127
- * The current allowance of the token.
128
- */
129
- allowance: {
130
- raw: string;
131
- formatted: string;
132
- };
133
- /**
134
- * Whether the allowance is needed to perform the transaction.
135
- */
136
- needsApproval: boolean;
137
- }
138
-
139
- interface IUserPosition {
140
- lpBalance?: BalanceToken;
141
- tokenBalances?: Omit<BalanceToken, "chainId">[];
142
- userSharePercentage?: number;
143
- stakedBalance?: Pick<BalanceToken, "address" | "balance" | "usdValue">;
144
- /**
145
- * Just a utility to detect if there is a price for the LP token.
146
- */
147
- lpTokenPrice?: number;
148
- }
149
- type BexStatus = {
150
- protocol: {
151
- /**
152
- * If the whole protocol is paused (i.e. ~the~ vault contract) disable any functionality except withdrawing proportional
153
- * liquidity (provided that pool's recovery mode is enabled). Specifically we disable swaps and pool creation.
154
- */
155
- isPaused: boolean;
156
- };
157
- /**
158
- * Pool is undefined if pool status is still loading if no pool address was provided.
159
- */
160
- pool?: {
161
- /**
162
- * Pool should be put into recovery mode if tx are reverting on-chain to do with fee computation or pool exits.
163
- * It reduces the computation needed to withdraw liquidity and does not charge protocol fees on exits while enabled.
164
- *
165
- * NOTE: that you can potentially still do regular exits/joins/etc in recovery mode, but if the flag is true will only
166
- * present the safe exit option to the user in FE.
167
- */
168
- isInRecoveryMode: boolean;
169
- /**
170
- * If the pool is paused you cannot do anything unless you also enable recovery mode (then you can withdraw safely).
171
- */
172
- isPaused: boolean;
173
- /**
174
- * Disable withdrawals for a pool due to a combination of pool and vault statuses.
175
- */
176
- disablePoolWithdrawals: boolean;
177
- /**
178
- * Disable deposits for a pool due to a combination of pool and vault statuses.
179
- */
180
- disablePoolDeposits: boolean;
181
- };
182
- };
183
-
184
- type IAggregatorArgs = {
185
- tokenIn: MinimalERC20;
186
- tokenOut: MinimalERC20;
187
- /**
188
- * Amount of tokenIn to swap in wei.
189
- */
190
- amount: string;
191
- slippage: number;
192
- account?: Address;
193
- publicClient?: PublicClient;
194
- aggregatorsFeeBps?: number;
195
- proxyAggregatorsThroughVercel?: boolean;
196
- referrer?: SwapReferrer;
197
- /**
198
- * If provided, the aggregator will swap to the underlying token and deposit it into the vault (tokenOut).
199
- *
200
- * The aggregator won't check if the tokenOut is an ERC4626 vault, so this needs to be asserted by the caller.
201
- * This is used for Staked BERA/iBera and Bend Vaults.
202
- */
203
- underlyingToken?: MinimalERC20 | null;
204
- /**
205
- * If provided, the aggregator will stake into the reward vault after the swap.
206
- */
207
- rewardVault?: Address;
208
- /**
209
- * Only needed by the honey mint/redeem aggregator.
210
- */
211
- honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
212
- };
213
-
214
- type Calldata = {
215
- params?: readonly unknown[] | undefined;
216
- functionName?: string;
217
- abi?: Abi;
218
- address: Address;
219
- data?: Hex;
220
- value: bigint;
221
- gasLimit?: bigint;
222
- };
223
-
224
- type IRawAggregatorQuote = {
225
- amountOut: string;
226
- amountIn: string;
227
- name: Aggregators;
228
- allowanceRequirements: AllowanceQueryItem[];
229
- /**
230
- * True if it's bera wrap/unwrap or bgt redeem.
231
- */
232
- isNativeSwap?: boolean;
233
- priceImpactPercentage?: number | null;
234
- swapFeeBps: number;
235
- getCalldata?: ({ account }: { account: Address }) => Calldata;
236
- };
237
-
238
- type IAggregatorQuote =
239
- // no need to force to swapAndStake as type check is done on each getQuote
240
- IRawAggregatorQuote & {
241
- amountOut: string;
242
- amountOutUsd: string;
243
- amountIn: string;
244
- amountInUsd: string;
245
- priceImpactPercentage: number;
246
- exchangeRate: number;
247
- relativeLossPercentage: number;
248
- isBest?: boolean;
249
- };
250
-
251
- /**
252
- * Interface representing the latest Pyth price updates
253
- * @interface PythLatestUpdates
254
- * @property {`0x${string}`[]} calldata - Array of hex-encoded calldata for price updates
255
- * @property {string[]} prices - Array of formatted price strings
256
- */
257
- interface PythLatestUpdates {
258
- calldata: `0x${string}`[];
259
- prices: string[];
260
- }
261
- /**
262
- * Fetches the latest price updates from Pyth Network's Hermes service
263
- * @param {Object} params - The parameters object
264
- * @param {string[]} params.priceFeedId - Array of Pyth price feed IDs to fetch updates for
265
- * @returns {Promise<PythLatestUpdates>} Promise resolving to the latest price updates
266
- * @example
267
- * ```ts
268
- * const updates = await getPythLatestPrices({
269
- * priceFeedId: ["0x123...", "0x456..."]
270
- * });
271
- * ```
272
- */
273
- declare function getPythLatestPrices({ priceFeedId, }: {
274
- priceFeedId: string[];
275
- }): Promise<PythLatestUpdates>;
276
-
277
- declare enum HoneyPreviewMethod {
278
- Mint = "previewMintHoney",
279
- MintWithPrice = "previewMintHoneyWithPrices",
280
- RequiredCollateral = "previewMintCollaterals",
281
- RequiredCollateralWithPrice = "previewMintCollateralsWithPrices",
282
- Redeem = "previewRedeemCollaterals",
283
- RedeemWithPrice = "previewRedeemCollateralsWithPrices",
284
- HoneyToRedeem = "previewRedeemHoney",
285
- HoneyToRedeemWithPrice = "previewRedeemHoneyWithPrices"
286
- }
287
- interface HoneyPreviewArgs extends BeraJS.BaseFunctionArgs {
288
- client: PublicClient;
289
- collateral: Token;
290
- collateralList: TokenWithOrder[];
291
- amount: string;
292
- method: HoneyPreviewMethod;
293
- latestPrices?: PythLatestUpdates;
294
- isPythWrapperEnabled: boolean;
295
- }
296
- interface HoneyPreviewResult {
297
- collaterals: Record<Address, bigint>;
298
- honey: bigint;
299
- }
300
- interface HoneyPreviewReadResult {
301
- collaterals: bigint[];
302
- honey: bigint;
303
- }
304
- /**
305
- * Calculates preview amounts for Honey protocol operations including minting and redeeming.
306
- * This function handles different preview methods to calculate either the amount of Honey tokens
307
- * that can be minted with given collateral or the amount of collateral needed to mint/redeem Honey tokens.
308
- *
309
- * @param {Object} params - The parameters for the preview calculation
310
- * @param {PublicClient} params.client - The Viem public client for blockchain interaction
311
- * @param {Token} params.collateral - The primary collateral token being used
312
- * @param {Address[]} params.collateralList - List of all supported collateral tokens
313
- * @param {string} params.amount - The amount to calculate preview for (in token units)
314
- * @param {HoneyPreviewMethod} params.method - The type of preview calculation to perform
315
- * @param {PythLatestUpdates | undefined} params.latestPrices - Optional latest price updates from Pyth oracle
316
- *
317
- * @returns {Promise<HoneyPreviewResult | undefined>} An object containing:
318
- * - collaterals: Record mapping collateral token addresses to their respective amounts
319
- * - honey: The amount of Honey tokens involved in the operation
320
- *
321
- * @throws {Error} If there's an error during the contract interaction or calculation
322
- */
323
- declare function getHoneyPreview({ client, collateral, collateralList, amount, method, latestPrices, isPythWrapperEnabled, ...baseArgs }: HoneyPreviewArgs): Promise<HoneyPreviewResult | undefined>;
324
-
325
- type PythPriceFeedMap = Record<Address, Hex>;
326
-
327
- type HoneySwapActions =
328
- | { type: HoneySwapAction.RESET_AMOUNTS }
329
- | { type: HoneySwapAction.ACTION_TYPE_CHANGE; value: "mint" | "redeem" }
330
- | { type: HoneySwapAction.COLLATERALS_CHANGE; value: TokenWithOrder[] }
331
- | { type: HoneySwapAction.FROM_AMOUNT_CHANGE; index: number; value: string }
332
- | { type: HoneySwapAction.TO_AMOUNT_CHANGE; index: number; value: string }
333
- | {
334
- type: HoneySwapAction.PREVIEW_CHANGE;
335
- value: HoneyPreviewResult;
336
- changedAsset: Address;
337
- }
338
- | { type: HoneySwapAction.IS_BASKET_MODE_ENABLED_CHANGE; value: boolean }
339
- | { type: HoneySwapAction.IS_TYPING_CHANGE; value: boolean }
340
- | { type: HoneySwapAction.IS_SUBMITTING_CHANGE; value: boolean }
341
- | { type: HoneySwapAction.IS_LOADING_CHANGE; value: boolean };
342
-
343
- declare const HoneyConfigContext: react.Context<HoneyConfigContextReturn | undefined>;
344
- type TokenWithOrder = TokenWithMetadata & {
345
- order: number;
346
- };
347
- interface HoneyConfigContextReturn {
348
- /**
349
- * Map of the Pyth price feed ids for each collateral
350
- */
351
- priceFeedMap: PythPriceFeedMap;
352
- /**
353
- * This is the list of all the collaterals that are supported by the Honey protocol
354
- */
355
- collateralList: TokenWithOrder[];
356
- /**
357
- * This is the main collateral that is used to calculate the relative cap limit
358
- */
359
- referenceCollateral: TokenWithOrder;
360
- /**
361
- * An object that maps the redeem/mint rate for each collateral and the weighted rates for the basket mode
362
- */
363
- feeMap: HoneyFeeMap;
364
- flags: {
365
- /**
366
- * If true, mint/redeem will also update pyth prices
367
- */
368
- isPythWrapperEnabled: boolean;
369
- };
370
- /**
371
- * Honey protocol configs
372
- */
373
- protocol: {
374
- /**
375
- * Honey protocol paused state
376
- */
377
- isPaused: boolean;
378
- /**
379
- * The label for the Honey protocol paused message
380
- */
381
- pausedBannerLabel?: string;
382
- };
383
- }
384
- interface HoneyConfigProviderProps extends HoneyConfigContextReturn {
385
- children: React.ReactNode;
386
- }
387
- declare function HoneyConfigProvider({ children, ...props }: HoneyConfigProviderProps): react_jsx_runtime.JSX.Element;
388
- declare function useHoneyConfig(): HoneyConfigContextReturn;
389
-
390
- export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type TokenWithPrice as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, HoneyConfigProvider as e, type HoneyConfigProviderProps as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type CollateralRatesArgs as k, type HoneyFeeMap as l, type HoneyPreviewArgs as m, HoneyPreviewMethod as n, type HoneyPreviewReadResult as o, type HoneyPreviewResult as p, getHoneyFees as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type BexStatus as y, type IAggregatorQuote as z };
@@ -1,57 +0,0 @@
1
- import { ErrorLike } from '@apollo/client';
2
- import { B as BeraError, I as IBeraErrorArgs } from './BeraError-_mQdkanr.cjs';
3
-
4
- /**
5
- * This is an error class that should be used to handle errors from fetch requests.
6
- */
7
- declare class RequestError extends BeraError {
8
- /**
9
- * The error response from the request.
10
- */
11
- response: Response | ErrorLike | undefined;
12
- static isCorsError(error: Error): boolean;
13
- /**
14
- * The endpoint that was requested.
15
- */
16
- endpoint: {
17
- name?: string;
18
- url: string;
19
- type?: "rest" | "graphql" | "rpc";
20
- };
21
- /**
22
- * A list of domains that should have their query params removed.
23
- */
24
- private queryRichfulDomains;
25
- statusCode: number | undefined;
26
- payload?: object;
27
- static readonly REASON_MAP: {
28
- readonly 429: "RATE_LIMITED_429";
29
- readonly NETWORK_ERROR: "NETWORK_ERROR";
30
- readonly CORS_ERROR: "CORS";
31
- };
32
- constructor(args: IBeraErrorArgs & {
33
- response: Response | ErrorLike | undefined;
34
- /**
35
- * The payload sent to the request.
36
- */
37
- payload?: object;
38
- endpoint: string | URL | {
39
- name?: string;
40
- url: string | URL;
41
- type: "rest" | "graphql" | "rpc";
42
- };
43
- statusCode?: number;
44
- });
45
- setEndpoint(endpoint: string | URL | {
46
- name?: string;
47
- url: string | URL;
48
- type?: "rest" | "graphql" | "rpc";
49
- }): {
50
- name?: string;
51
- url: string;
52
- type?: "rest" | "graphql" | "rpc";
53
- };
54
- private tryMatchNetworkError;
55
- }
56
-
57
- export { RequestError as R };
@@ -1,57 +0,0 @@
1
- import { ErrorLike } from '@apollo/client';
2
- import { B as BeraError, I as IBeraErrorArgs } from './BeraError-_mQdkanr.js';
3
-
4
- /**
5
- * This is an error class that should be used to handle errors from fetch requests.
6
- */
7
- declare class RequestError extends BeraError {
8
- /**
9
- * The error response from the request.
10
- */
11
- response: Response | ErrorLike | undefined;
12
- static isCorsError(error: Error): boolean;
13
- /**
14
- * The endpoint that was requested.
15
- */
16
- endpoint: {
17
- name?: string;
18
- url: string;
19
- type?: "rest" | "graphql" | "rpc";
20
- };
21
- /**
22
- * A list of domains that should have their query params removed.
23
- */
24
- private queryRichfulDomains;
25
- statusCode: number | undefined;
26
- payload?: object;
27
- static readonly REASON_MAP: {
28
- readonly 429: "RATE_LIMITED_429";
29
- readonly NETWORK_ERROR: "NETWORK_ERROR";
30
- readonly CORS_ERROR: "CORS";
31
- };
32
- constructor(args: IBeraErrorArgs & {
33
- response: Response | ErrorLike | undefined;
34
- /**
35
- * The payload sent to the request.
36
- */
37
- payload?: object;
38
- endpoint: string | URL | {
39
- name?: string;
40
- url: string | URL;
41
- type: "rest" | "graphql" | "rpc";
42
- };
43
- statusCode?: number;
44
- });
45
- setEndpoint(endpoint: string | URL | {
46
- name?: string;
47
- url: string | URL;
48
- type?: "rest" | "graphql" | "rpc";
49
- }): {
50
- name?: string;
51
- url: string;
52
- type?: "rest" | "graphql" | "rpc";
53
- };
54
- private tryMatchNetworkError;
55
- }
56
-
57
- export { RequestError as R };