@berachain/berajs 0.1.2 → 0.2.1

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 (448) hide show
  1. package/dist/{BeraError-D1HS_rbb.d.cts → BeraError-_mQdkanr.d.cts} +35 -10
  2. package/dist/{BeraError-D1HS_rbb.d.ts → BeraError-_mQdkanr.d.ts} +35 -10
  3. package/dist/HoneyConfigProvider-CK6mOKFH.d.ts +390 -0
  4. package/dist/HoneyConfigProvider-Ca3ouozs.d.cts +390 -0
  5. package/dist/{RequestError-D8AE6xnI.d.cts → RequestError-A8XJ6QR9.d.cts} +1 -1
  6. package/dist/{RequestError-m4jxyM7D.d.ts → RequestError-Dk97z8rm.d.ts} +1 -1
  7. package/dist/abi/exports.cjs +2 -0
  8. package/dist/abi/exports.cjs.map +1 -0
  9. package/dist/abi/{index.d.cts → exports.d.cts} +12369 -9122
  10. package/dist/abi/{index.d.ts → exports.d.ts} +12369 -9122
  11. package/dist/abi/exports.mjs +2 -0
  12. package/dist/abi/exports.mjs.map +1 -0
  13. package/dist/actions/exports.cjs +2 -0
  14. package/dist/actions/exports.cjs.map +1 -0
  15. package/dist/actions/{index.d.cts → exports.d.cts} +79 -107
  16. package/dist/actions/{index.d.ts → exports.d.ts} +79 -107
  17. package/dist/actions/exports.mjs +2 -0
  18. package/dist/actions/exports.mjs.map +1 -0
  19. package/dist/chunk-22J3YJDN.cjs +2 -0
  20. package/dist/chunk-22J3YJDN.cjs.map +1 -0
  21. package/dist/chunk-2LL3P5PN.mjs +2 -0
  22. package/dist/chunk-2LL3P5PN.mjs.map +1 -0
  23. package/dist/chunk-3YXSUBA5.mjs +2 -0
  24. package/dist/chunk-3YXSUBA5.mjs.map +1 -0
  25. package/dist/chunk-55L7STYD.mjs +2 -0
  26. package/dist/chunk-55L7STYD.mjs.map +1 -0
  27. package/dist/chunk-575OK77P.mjs +2 -0
  28. package/dist/chunk-575OK77P.mjs.map +1 -0
  29. package/dist/chunk-6LDOG5RL.cjs +2 -0
  30. package/dist/chunk-6LDOG5RL.cjs.map +1 -0
  31. package/dist/chunk-7LNBSOVV.cjs +2 -0
  32. package/dist/chunk-7LNBSOVV.cjs.map +1 -0
  33. package/dist/chunk-7SMWQ6SN.mjs +2 -0
  34. package/dist/chunk-7SMWQ6SN.mjs.map +1 -0
  35. package/dist/chunk-7WRTK7RJ.mjs +2 -0
  36. package/dist/chunk-7WRTK7RJ.mjs.map +1 -0
  37. package/dist/chunk-A4UDYSB6.mjs +4 -0
  38. package/dist/chunk-A4UDYSB6.mjs.map +1 -0
  39. package/dist/chunk-AX2YQQFQ.mjs +2 -0
  40. package/dist/chunk-AX2YQQFQ.mjs.map +1 -0
  41. package/dist/chunk-C3FHGFLK.mjs +2 -0
  42. package/dist/chunk-C3FHGFLK.mjs.map +1 -0
  43. package/dist/chunk-C6ZGUO4H.cjs +2 -0
  44. package/dist/chunk-C6ZGUO4H.cjs.map +1 -0
  45. package/dist/chunk-CYKCYPFR.cjs +2 -0
  46. package/dist/chunk-CYKCYPFR.cjs.map +1 -0
  47. package/dist/chunk-ECRMUMTA.mjs +2 -0
  48. package/dist/chunk-ECRMUMTA.mjs.map +1 -0
  49. package/dist/chunk-F4BKSBEM.mjs +2 -0
  50. package/dist/chunk-F4BKSBEM.mjs.map +1 -0
  51. package/dist/chunk-FCWDGE62.cjs +2 -0
  52. package/dist/chunk-FCWDGE62.cjs.map +1 -0
  53. package/dist/chunk-FL2N3XHK.cjs +2 -0
  54. package/dist/chunk-FL2N3XHK.cjs.map +1 -0
  55. package/dist/chunk-MUCEYO3E.cjs +4 -0
  56. package/dist/chunk-MUCEYO3E.cjs.map +1 -0
  57. package/dist/chunk-NAXAZJJY.mjs +2 -0
  58. package/dist/chunk-NAXAZJJY.mjs.map +1 -0
  59. package/dist/chunk-OGJMSGB2.mjs +2 -0
  60. package/dist/chunk-OGJMSGB2.mjs.map +1 -0
  61. package/dist/chunk-OIYXOKTT.cjs +2 -0
  62. package/dist/chunk-OIYXOKTT.cjs.map +1 -0
  63. package/dist/chunk-P2Q7CMUD.cjs +2 -0
  64. package/dist/chunk-P2Q7CMUD.cjs.map +1 -0
  65. package/dist/chunk-PKXAW6MO.cjs +2 -0
  66. package/dist/chunk-PKXAW6MO.cjs.map +1 -0
  67. package/dist/chunk-Q3SCM6WL.mjs +2 -0
  68. package/dist/chunk-Q3SCM6WL.mjs.map +1 -0
  69. package/dist/chunk-SWMJQOH6.cjs +2 -0
  70. package/dist/chunk-SWMJQOH6.cjs.map +1 -0
  71. package/dist/chunk-TEBJWAVU.mjs +2 -0
  72. package/dist/chunk-TEBJWAVU.mjs.map +1 -0
  73. package/dist/chunk-THATXCJK.mjs +2 -0
  74. package/dist/chunk-THATXCJK.mjs.map +1 -0
  75. package/dist/chunk-VP7XUOSI.cjs +2 -0
  76. package/dist/chunk-VP7XUOSI.cjs.map +1 -0
  77. package/dist/chunk-VXL2ZZ4X.cjs +2 -0
  78. package/dist/chunk-VXL2ZZ4X.cjs.map +1 -0
  79. package/dist/chunk-WRFDB3QJ.cjs +2 -0
  80. package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
  81. package/dist/chunk-XNJLSA6P.cjs +2 -0
  82. package/dist/chunk-XNJLSA6P.cjs.map +1 -0
  83. package/dist/chunk-YXLFOEZN.mjs +2 -0
  84. package/dist/chunk-YXLFOEZN.mjs.map +1 -0
  85. package/dist/chunk-YZV5LKIP.cjs +2 -0
  86. package/dist/chunk-YZV5LKIP.cjs.map +1 -0
  87. package/dist/contexts/exports.cjs +2 -0
  88. package/dist/contexts/exports.cjs.map +1 -0
  89. package/dist/contexts/{index.d.cts → exports.d.cts} +10 -27
  90. package/dist/contexts/{index.d.ts → exports.d.ts} +10 -27
  91. package/dist/contexts/exports.mjs +2 -0
  92. package/dist/contexts/exports.mjs.map +1 -0
  93. package/dist/{defaultFlags-V-tJs2K8.d.cts → defaultFlags-d0kPbT0i.d.cts} +1 -1
  94. package/dist/{defaultFlags-V-tJs2K8.d.ts → defaultFlags-d0kPbT0i.d.ts} +1 -1
  95. package/dist/dex-C_BB0b0O.d.cts +37 -0
  96. package/dist/dex-C_BB0b0O.d.ts +37 -0
  97. package/dist/enum/exports.cjs +2 -0
  98. package/dist/enum/exports.cjs.map +1 -0
  99. package/dist/enum/exports.d.cts +23 -0
  100. package/dist/enum/exports.d.ts +23 -0
  101. package/dist/enum/exports.mjs +2 -0
  102. package/dist/enum/exports.mjs.map +1 -0
  103. package/dist/errors/exports.cjs +2 -0
  104. package/dist/errors/exports.cjs.map +1 -0
  105. package/dist/errors/exports.d.cts +408 -0
  106. package/dist/errors/exports.d.ts +408 -0
  107. package/dist/errors/exports.mjs +2 -0
  108. package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-Dstyaomr.d.cts} +125 -15
  109. package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-RW4OMcD1.d.ts} +125 -15
  110. package/dist/global.d-CN6l2b9E.d.cts +473 -0
  111. package/dist/global.d-wYu8G8IQ.d.ts +473 -0
  112. package/dist/honey-CYm0RWf4.d.cts +14 -0
  113. package/dist/honey-CYm0RWf4.d.ts +14 -0
  114. package/dist/hooks/exports.cjs +4 -0
  115. package/dist/hooks/exports.cjs.map +1 -0
  116. package/dist/hooks/{index.d.cts → exports.d.cts} +218 -176
  117. package/dist/hooks/{index.d.ts → exports.d.ts} +218 -176
  118. package/dist/hooks/exports.mjs +4 -0
  119. package/dist/hooks/exports.mjs.map +1 -0
  120. package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BlBYhNRl.d.cts} +75 -1
  121. package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BlBYhNRl.d.ts} +75 -1
  122. package/dist/types/exports.cjs +1 -0
  123. package/dist/types/exports.cjs.map +1 -0
  124. package/dist/types/exports.d.cts +57 -0
  125. package/dist/types/exports.d.ts +57 -0
  126. package/dist/types/exports.mjs +1 -0
  127. package/dist/{useHoneySwapState-C-9BV4VB.d.cts → useHoneySwapState-B-vmIP1b.d.cts} +1 -1
  128. package/dist/{useHoneySwapState-CUY5Sm1b.d.ts → useHoneySwapState-D1DKG_Of.d.ts} +1 -1
  129. package/dist/utils/exports.cjs +2 -0
  130. package/dist/utils/exports.cjs.map +1 -0
  131. package/dist/utils/{index.d.cts → exports.d.cts} +83 -20
  132. package/dist/utils/{index.d.ts → exports.d.ts} +83 -20
  133. package/dist/utils/exports.mjs +2 -0
  134. package/dist/utils/exports.mjs.map +1 -0
  135. package/package.json +19 -20
  136. package/src/abi/{index.ts → exports.ts} +3 -0
  137. package/src/abi/pol/LSTStakerVault.ts +2032 -0
  138. package/src/abi/utils/openChainErrors.ts +71 -30
  139. package/src/abi/utils/thirdwebMinimalAccount.ts +616 -0
  140. package/src/actions/clients/BeraApolloClient.ts +8 -6
  141. package/src/actions/dex/__tests__/aggregators.unit.test.ts +2 -5
  142. package/src/actions/dex/aggregators/base.ts +74 -16
  143. package/src/actions/dex/aggregators/bex.ts +54 -74
  144. package/src/actions/dex/aggregators/bgt.ts +31 -8
  145. package/src/actions/dex/aggregators/{enso.ts → enso/enso.ts} +18 -14
  146. package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +37 -0
  147. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +176 -0
  148. package/src/actions/dex/aggregators/erc4626.ts +122 -0
  149. package/src/actions/dex/aggregators/fly.ts +59 -53
  150. package/src/actions/dex/aggregators/haiku.ts +52 -54
  151. package/src/actions/dex/aggregators/honey.ts +54 -45
  152. package/src/actions/dex/aggregators/kyberswap.ts +41 -39
  153. package/src/actions/dex/aggregators/oogabooga.ts +47 -46
  154. package/src/actions/dex/aggregators/openOcean.ts +51 -46
  155. package/src/actions/dex/aggregators/wbera.ts +54 -42
  156. package/src/actions/dex/b-sdk.ts +5 -2
  157. package/src/actions/dex/getIsTokenExploited.ts +2 -2
  158. package/src/actions/enso/{zap.ts → getEnsoSwapBundle.ts} +4 -5
  159. package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +73 -0
  160. package/src/actions/enso/{getEnsoUserToken.ts → getEnsoUserTokensWithBalances.ts} +42 -30
  161. package/src/actions/enso/util.ts +1 -1
  162. package/src/actions/{index.ts → exports.ts} +5 -0
  163. package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +1 -1
  164. package/src/actions/governance/__tests__/getQuorum.integration.test.ts +1 -1
  165. package/src/actions/governance/checkProposalField.ts +1 -1
  166. package/src/actions/governance/computeActualStatus.ts +1 -1
  167. package/src/actions/governance/getBodyErrors.ts +1 -1
  168. package/src/actions/governance/getDecodedFunctionData.ts +1 -4
  169. package/src/actions/governance/getProposalDetails.ts +2 -2
  170. package/src/actions/governance/getProposalFromTx.ts +1 -2
  171. package/src/actions/governance/getProposalParams.ts +7 -8
  172. package/src/actions/governance/getQuorum.ts +1 -2
  173. package/src/actions/honey/getCollateralWeights.ts +1 -1
  174. package/src/actions/honey/getHoneyCollaterals.ts +1 -0
  175. package/src/actions/honey/getHoneyVaultsBalance.ts +51 -55
  176. package/src/actions/honey/getSwapPayload.ts +37 -35
  177. package/src/actions/honey/tests/pyth.integration.test.ts +0 -1
  178. package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +1 -1
  179. package/src/actions/pol/getEarnedStakedBeraVault.ts +31 -0
  180. package/src/actions/pol/getGlobalData.ts +14 -13
  181. package/src/actions/pol/getLSTStakeConfig.ts +67 -0
  182. package/src/actions/pol/getMarkets.ts +1 -1
  183. package/src/actions/pol/getRewardProofsByValidator.ts +1 -1
  184. package/src/actions/pol/getRewardVaultIncentives.ts +3 -5
  185. package/src/actions/pol/getRewardVaults.ts +2 -3
  186. package/src/actions/pol/getSWBeraVaultMetadata.ts +7 -5
  187. package/src/actions/pol/getSWBeraWithdrawal.ts +41 -27
  188. package/src/actions/pol/getStakeWithdrawalCooldown.ts +5 -7
  189. package/src/actions/pol/getStakingDailyAssets.ts +24 -0
  190. package/src/actions/pol/getStakingTokenInformation.ts +3 -4
  191. package/src/actions/pol/getTotalStakedAmount.ts +47 -0
  192. package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
  193. package/src/actions/pol/getUserVaults.ts +8 -6
  194. package/src/actions/pol/getUserVaultsBalance.ts +4 -16
  195. package/src/actions/prices/getTokenCurrentPrices.ts +8 -3
  196. package/src/actions/tokens/getAllowances.ts +68 -41
  197. package/src/actions/tokens/getTokenInformation.ts +4 -1
  198. package/src/actions/tokens/getTokens.ts +1 -1
  199. package/src/actions/tokens/getUnderlyingToken.ts +53 -0
  200. package/src/actions/tokens/getWalletBalances.integration.test.ts +53 -14
  201. package/src/actions/tokens/getWalletBalances.ts +69 -43
  202. package/src/actions/transactions/beraWriteContract.integration.test.ts +18 -6
  203. package/src/actions/transactions/beraWriteContract.ts +3 -3
  204. package/src/actions/validators/getUserActiveValidators.ts +2 -3
  205. package/src/actions/validators/getUserBoostsOnValidator.ts +2 -3
  206. package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
  207. package/src/contexts/SwrFallback.tsx +13 -3
  208. package/src/contexts/TokensProvider.tsx +35 -8
  209. package/src/contexts/block-time-provider.tsx +1 -1
  210. package/src/contexts/{index.ts → exports.ts} +0 -1
  211. package/src/data/contracts.ts +17 -2
  212. package/src/enum/contracts.ts +13 -0
  213. package/src/enum/dex.ts +29 -0
  214. package/src/enum/{index.ts → exports.ts} +3 -0
  215. package/src/enum/governance.ts +61 -0
  216. package/src/enum/honey.ts +12 -0
  217. package/src/enum/txnEnum.ts +1 -0
  218. package/src/errors/BeraError.ts +61 -13
  219. package/src/errors/BeraMonitoring.ts +66 -0
  220. package/src/errors/BeraTracing.ts +79 -0
  221. package/src/errors/BeraTracing.unit.test.ts +198 -0
  222. package/src/errors/RequestError.ts +29 -3
  223. package/src/errors/assert.ts +4 -2
  224. package/src/errors/assert.unit.test.ts +6 -2
  225. package/src/errors/errorMap.ts +19 -8
  226. package/src/errors/{index.ts → exports.ts} +7 -0
  227. package/src/errors/getErrorMessage.ts +67 -9
  228. package/src/errors/getRevertReason.integration.test.ts +18 -6
  229. package/src/errors/getRevertReason.ts +41 -2
  230. package/src/errors/initBeraError.ts +52 -7
  231. package/src/errors/parseViemError.ts +114 -27
  232. package/src/errors/severity.ts +12 -0
  233. package/src/hooks/bend/useGetConvertToAssets.ts +3 -2
  234. package/src/hooks/dex/useAggregatorsQuotes.ts +126 -365
  235. package/src/hooks/dex/useAllUserPools.ts +1 -1
  236. package/src/hooks/dex/useApiPool.ts +1 -1
  237. package/src/hooks/dex/useCreatePool.ts +6 -5
  238. package/src/hooks/dex/useExploitedTokens.ts +1 -1
  239. package/src/hooks/dex/useLiquidityMismatch.ts +2 -5
  240. package/src/hooks/dex/useLpPosition.ts +21 -20
  241. package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +40 -29
  242. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -1
  243. package/src/hooks/dex/usePoolEvents.ts +1 -1
  244. package/src/hooks/dex/usePools.ts +1 -1
  245. package/src/hooks/dex/usePriceImpact.ts +40 -0
  246. package/src/hooks/dex/useSingleAggregatorQuote.ts +350 -0
  247. package/src/hooks/enso/useBendZapSupply.ts +216 -0
  248. package/src/hooks/enso/useEnsoSwapBundle.ts +107 -0
  249. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +43 -0
  250. package/src/hooks/enso/useZapStakeBera.ts +113 -0
  251. package/src/hooks/{index.ts → exports.ts} +17 -10
  252. package/src/hooks/governance/useCreateProposal.ts +8 -8
  253. package/src/hooks/governance/usePollAllProposals.ts +1 -1
  254. package/src/hooks/governance/usePollProposal.ts +1 -1
  255. package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
  256. package/src/hooks/governance/usePollUserDelegates.ts +1 -1
  257. package/src/hooks/governance/useProposalState.ts +2 -2
  258. package/src/hooks/honey/useCappedGlobally.ts +2 -1
  259. package/src/hooks/honey/useCappedRelatively.ts +1 -1
  260. package/src/hooks/honey/useCollateralWeights.ts +2 -1
  261. package/src/hooks/honey/useHoneyAlerts.ts +11 -11
  262. package/src/hooks/honey/useHoneyBalances.ts +7 -3
  263. package/src/hooks/honey/useHoneyGlobalData.ts +2 -1
  264. package/src/hooks/honey/useHoneySwapState.ts +2 -1
  265. package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -1
  266. package/src/hooks/honey/useIsBadCollateralAsset.ts +2 -1
  267. package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -1
  268. package/src/hooks/honey/usePythLatestPrices.ts +1 -1
  269. package/src/hooks/pol/useOnChainRewardVault.ts +3 -2
  270. package/src/hooks/pol/usePollGlobalData.ts +1 -1
  271. package/src/hooks/pol/usePollMarkets.ts +1 -1
  272. package/src/hooks/pol/useQueuedBeraUnlock.ts +17 -15
  273. package/src/hooks/pol/useRewardTokenToBeraRate.ts +6 -3
  274. package/src/hooks/pol/useRewardVault.ts +1 -1
  275. package/src/hooks/pol/useRewardVaults.ts +1 -1
  276. package/src/hooks/pol/useSWBeraVaultMetadata.ts +35 -0
  277. package/src/hooks/pol/useStakedAPR.ts +38 -0
  278. package/src/hooks/pol/useStakedData.ts +117 -0
  279. package/src/hooks/pol/useStakedSnapshots.ts +52 -0
  280. package/src/hooks/pol/useTotalStakedAmount.ts +30 -0
  281. package/src/hooks/pol/useUserVaultInfo.ts +1 -1
  282. package/src/hooks/pol/useVaultValidators.ts +1 -1
  283. package/src/hooks/tokens/useMultipleTokenInformation.ts +15 -6
  284. package/src/hooks/tokens/usePollAllowances.ts +15 -19
  285. package/src/hooks/tokens/usePollBalance.ts +8 -4
  286. package/src/hooks/tokens/usePollWalletBalances.ts +14 -11
  287. package/src/hooks/tokens/useStakingTokenInformation.ts +2 -1
  288. package/src/hooks/tokens/useTokenCurrentPrice.ts +4 -2
  289. package/src/hooks/tokens/useTokenCurrentPrices.ts +92 -13
  290. package/src/hooks/tokens/useTokenInformation.ts +11 -6
  291. package/src/hooks/tokens/useTokenPrice.ts +21 -0
  292. package/src/hooks/tokens/useTokenPrices.ts +133 -0
  293. package/src/hooks/tokens/useTokens.ts +1 -0
  294. package/src/hooks/tokens/useUnderlyingAsset.ts +23 -0
  295. package/src/hooks/useContractWrite/useBeraContractWrite.ts +2 -1
  296. package/src/hooks/validators/useAllValidators.ts +1 -1
  297. package/src/hooks/validators/useApiValidator.ts +1 -1
  298. package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
  299. package/src/hooks/validators/useManagedValidatorByAccount.ts +1 -1
  300. package/src/hooks/validators/useManagedValidatorRole.ts +1 -1
  301. package/src/hooks/validators/useOnChainValidator.ts +1 -1
  302. package/src/hooks/validators/useStakingPoolBatch.ts +1 -1
  303. package/src/hooks/validators/useUserActiveValidators.ts +1 -1
  304. package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
  305. package/src/hooks/validators/useUserClaimableIncentives.ts +8 -8
  306. package/src/hooks/validators/useValidator.ts +1 -1
  307. package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
  308. package/src/hooks/validators/useValidatorCommission.ts +1 -1
  309. package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -1
  310. package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -1
  311. package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -1
  312. package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
  313. package/src/types/{dex.ts → dex.d.ts} +96 -67
  314. package/src/types/{enso.ts → enso.d.ts} +1 -1
  315. package/src/types/exports.ts +8 -0
  316. package/src/types/{global.ts → global.d.ts} +1 -30
  317. package/src/types/{governance.ts → governance.d.ts} +2 -64
  318. package/src/types/{honeySwap.ts → honeySwap.d.ts} +1 -13
  319. package/src/types/{pol.ts → pol.d.ts} +12 -1
  320. package/src/types/staking.d.ts +22 -0
  321. package/src/utils/createEmitter.ts +122 -0
  322. package/src/utils/createEmitter.unit.test.ts +149 -0
  323. package/src/utils/{index.ts → exports.ts} +3 -2
  324. package/src/utils/filter.ts +34 -0
  325. package/src/utils/formatNumber.ts +1 -1
  326. package/src/utils/formatNumber.unit.test.ts +2 -1
  327. package/src/utils/formatTokenList.ts +4 -10
  328. package/src/utils/getHoneySwapMessage.test.ts +1 -2
  329. package/src/utils/getServerSideClient.ts +4 -5
  330. package/src/utils/isDifferenceExceedingThreshold.ts +1 -1
  331. package/src/utils/layerZeroScan.ts +122 -0
  332. package/src/utils/math.ts +1 -1
  333. package/src/utils/parseWhiskToken.ts +15 -0
  334. package/src/utils/poolNamings.ts +1 -1
  335. package/src/utils/tokens.ts +23 -7
  336. package/dist/HoneyConfigProvider-6PXZJMSU.d.cts +0 -562
  337. package/dist/HoneyConfigProvider-CwDFrt02.d.ts +0 -562
  338. package/dist/abi/index.cjs +0 -2
  339. package/dist/abi/index.cjs.map +0 -1
  340. package/dist/abi/index.mjs +0 -2
  341. package/dist/actions/index.cjs +0 -2
  342. package/dist/actions/index.cjs.map +0 -1
  343. package/dist/actions/index.mjs +0 -2
  344. package/dist/aggregatorsRouter-Cny4B_MB.d.cts +0 -593
  345. package/dist/aggregatorsRouter-Cny4B_MB.d.ts +0 -593
  346. package/dist/chunk-22MQVFHP.cjs +0 -2
  347. package/dist/chunk-22MQVFHP.cjs.map +0 -1
  348. package/dist/chunk-3TKSVFZ3.mjs +0 -2
  349. package/dist/chunk-3TKSVFZ3.mjs.map +0 -1
  350. package/dist/chunk-6VF3RF53.cjs +0 -3
  351. package/dist/chunk-6VF3RF53.cjs.map +0 -1
  352. package/dist/chunk-6W22TFYA.mjs +0 -2
  353. package/dist/chunk-6W22TFYA.mjs.map +0 -1
  354. package/dist/chunk-AMRJ4B36.mjs +0 -2
  355. package/dist/chunk-AMRJ4B36.mjs.map +0 -1
  356. package/dist/chunk-DS2ZDVKU.mjs +0 -2
  357. package/dist/chunk-DS2ZDVKU.mjs.map +0 -1
  358. package/dist/chunk-ED43NYSE.cjs +0 -2
  359. package/dist/chunk-ED43NYSE.cjs.map +0 -1
  360. package/dist/chunk-EU4WFADK.cjs +0 -2
  361. package/dist/chunk-EU4WFADK.cjs.map +0 -1
  362. package/dist/chunk-HCTFDGXL.mjs +0 -2
  363. package/dist/chunk-HCTFDGXL.mjs.map +0 -1
  364. package/dist/chunk-IOSYBHKU.mjs +0 -2
  365. package/dist/chunk-IOSYBHKU.mjs.map +0 -1
  366. package/dist/chunk-JMKLDDKY.cjs +0 -2
  367. package/dist/chunk-JMKLDDKY.cjs.map +0 -1
  368. package/dist/chunk-KMKUXP2S.mjs +0 -3
  369. package/dist/chunk-KMKUXP2S.mjs.map +0 -1
  370. package/dist/chunk-OJXJ6CZ4.mjs +0 -4
  371. package/dist/chunk-OJXJ6CZ4.mjs.map +0 -1
  372. package/dist/chunk-PHIOKO3A.mjs +0 -2
  373. package/dist/chunk-PHIOKO3A.mjs.map +0 -1
  374. package/dist/chunk-QCK474XD.cjs +0 -2
  375. package/dist/chunk-QCK474XD.cjs.map +0 -1
  376. package/dist/chunk-REDXXUK7.cjs +0 -2
  377. package/dist/chunk-REDXXUK7.cjs.map +0 -1
  378. package/dist/chunk-S74ZMG2G.cjs +0 -2
  379. package/dist/chunk-S74ZMG2G.cjs.map +0 -1
  380. package/dist/chunk-TOAXF4YW.cjs +0 -2
  381. package/dist/chunk-TOAXF4YW.cjs.map +0 -1
  382. package/dist/chunk-UZ5CB33M.cjs +0 -2
  383. package/dist/chunk-UZ5CB33M.cjs.map +0 -1
  384. package/dist/chunk-VYWYJR63.mjs +0 -2
  385. package/dist/chunk-VYWYJR63.mjs.map +0 -1
  386. package/dist/chunk-XFPTQMAK.cjs +0 -4
  387. package/dist/chunk-XFPTQMAK.cjs.map +0 -1
  388. package/dist/chunk-YK4NINF5.mjs +0 -2
  389. package/dist/chunk-YK4NINF5.mjs.map +0 -1
  390. package/dist/contexts/index.cjs +0 -2
  391. package/dist/contexts/index.cjs.map +0 -1
  392. package/dist/contexts/index.mjs +0 -2
  393. package/dist/contexts/index.mjs.map +0 -1
  394. package/dist/enum/index.cjs +0 -2
  395. package/dist/enum/index.cjs.map +0 -1
  396. package/dist/enum/index.d.cts +0 -31
  397. package/dist/enum/index.d.ts +0 -31
  398. package/dist/enum/index.mjs +0 -2
  399. package/dist/enum/index.mjs.map +0 -1
  400. package/dist/errors/index.cjs +0 -2
  401. package/dist/errors/index.cjs.map +0 -1
  402. package/dist/errors/index.d.cts +0 -204
  403. package/dist/errors/index.d.ts +0 -204
  404. package/dist/errors/index.mjs +0 -2
  405. package/dist/errors/index.mjs.map +0 -1
  406. package/dist/hooks/index.cjs +0 -4
  407. package/dist/hooks/index.cjs.map +0 -1
  408. package/dist/hooks/index.mjs +0 -4
  409. package/dist/hooks/index.mjs.map +0 -1
  410. package/dist/staking-F9Nx9TKD.d.ts +0 -246
  411. package/dist/staking-f4BpYH7l.d.cts +0 -246
  412. package/dist/types/index.cjs +0 -2
  413. package/dist/types/index.cjs.map +0 -1
  414. package/dist/types/index.d.cts +0 -56
  415. package/dist/types/index.d.ts +0 -56
  416. package/dist/types/index.mjs +0 -2
  417. package/dist/types/index.mjs.map +0 -1
  418. package/dist/utils/index.cjs +0 -2
  419. package/dist/utils/index.cjs.map +0 -1
  420. package/dist/utils/index.mjs +0 -2
  421. package/dist/utils/index.mjs.map +0 -1
  422. package/src/actions/dex/getTransactionCount.ts +0 -29
  423. package/src/actions/enso/bend.ts +0 -143
  424. package/src/actions/enso/getEnsoUserToken.debug.test.ts +0 -57
  425. package/src/contexts/berajsProvider/context.tsx +0 -49
  426. package/src/contexts/berajsProvider/index.ts +0 -2
  427. package/src/contexts/berajsProvider/useBeraJs.ts +0 -18
  428. package/src/hooks/dex/usePollVaultIsPaused.ts +0 -30
  429. package/src/hooks/enso/useBendTransactionRequests.ts +0 -247
  430. package/src/hooks/enso/useEnsoZap.ts +0 -166
  431. package/src/hooks/enso/useZapTransactionRequests.ts +0 -81
  432. package/src/hooks/pol/useEarnedStakedBeraVault.ts +0 -59
  433. package/src/hooks/pol/useStakedBeraSnapshots.ts +0 -27
  434. package/src/hooks/transactions/TransactionStoreContext.tsx +0 -59
  435. package/src/hooks/transactions/transactionStore.ts +0 -275
  436. package/src/hooks/transactions/transactionStore.unit.test.ts +0 -508
  437. package/src/hooks/transactions/useAddRecentTransaction.ts +0 -29
  438. package/src/hooks/transactions/useRecentTransactions.ts +0 -27
  439. package/src/hooks/validators/validatorRoleManager.ts +0 -0
  440. package/src/types/index.ts +0 -8
  441. package/src/types/staking.ts +0 -7
  442. package/src/utils/formatAggregatorsQuotes.ts +0 -57
  443. package/src/utils/formatAggregatorsQuotes.unit.test.ts +0 -191
  444. package/src/utils/sentryBeforeSend.ts +0 -52
  445. /package/dist/{abi/index.mjs.map → errors/exports.mjs.map} +0 -0
  446. /package/dist/{actions/index.mjs.map → types/exports.mjs.map} +0 -0
  447. /package/src/actions/dex/{__tests__ → aggregators}/haiku.integration.test.ts +0 -0
  448. /package/src/types/{bribe-boost.ts → bribe-boost.d.ts} +0 -0
@@ -10,9 +10,14 @@ import {
10
10
  import { mnemonicToAccount } from "viem/accounts";
11
11
  import { assert, describe, expect, it } from "vitest";
12
12
 
13
- import { ChainId, getRpcUrls } from "@berachain/config/internal";
13
+ import { appConfig, ChainId, getRpcUrls } from "@berachain/config/internal";
14
+ import {
15
+ defaultChain,
16
+ externalChains,
17
+ transports,
18
+ } from "@berachain/config/internal/wagmi";
14
19
 
15
- import { defaultBeraNetworkConfig, wagmiConfig } from "@berachain/wagmi/config";
20
+ import { getConfig } from "@berachain/wagmi/config";
16
21
 
17
22
  import { bgtAbi } from "~/abi/pol/bgt";
18
23
  import { TransactionActionType } from "~/enum/txnEnum";
@@ -30,7 +35,14 @@ const testFn: IContractWriteFn = async (_args) => {
30
35
  };
31
36
 
32
37
  describe("beraWriteContract", () => {
33
- const { config, chainId } = parseBaseArgs({});
38
+ const { config } = parseBaseArgs({ chainId: defaultChain.id });
39
+ const beraWagmiConfig = getConfig({
40
+ transports,
41
+ defaultChain,
42
+ chains: externalChains,
43
+ thirdweb: { clientId: appConfig.apiKeys.public.thirdweb },
44
+ });
45
+ const wagmiConfig = beraWagmiConfig.wagmi;
34
46
  const anvilMockAccount = mnemonicToAccount(anvilMnemonic);
35
47
 
36
48
  /**
@@ -41,13 +53,13 @@ describe("beraWriteContract", () => {
41
53
  [ChainId.BEPOLIA]: "0x0d283A8AFf77f4fb7B7A9EC78B09b26E083dA304",
42
54
  };
43
55
 
44
- const wallet = valMap[chainId];
56
+ const wallet = valMap[defaultChain.id as ChainId];
45
57
 
46
- const publicClient = getServerSidePublicClient();
58
+ const publicClient = getServerSidePublicClient({ chainId: defaultChain.id });
47
59
  const walletClient = createWalletClient({
48
60
  transport: http(getRpcUrls().publicJsonRpcUrl),
49
61
  account: anvilMockAccount,
50
- chain: defaultBeraNetworkConfig.chain,
62
+ chain: defaultChain,
51
63
  });
52
64
 
53
65
  it("should have proper types", async () => {
@@ -3,6 +3,7 @@ import {
3
3
  getWalletClient,
4
4
  type SwitchChainErrorType,
5
5
  switchChain,
6
+ type WriteContractParameters,
6
7
  } from "@wagmi/core";
7
8
  import {
8
9
  type Abi,
@@ -29,7 +30,7 @@ import { InvalidArgumentError } from "~/errors/InvalidArgumentError";
29
30
  import { parseDecodedError, parseViemError } from "~/errors/parseViemError";
30
31
  import { RequestError } from "~/errors/RequestError";
31
32
  import { TransactionFailedError } from "~/errors/TransactionFailedError";
32
- import type { IContractWrite } from "~/types";
33
+ import type { IContractWrite } from "~/types/global";
33
34
  import { DEFAULT_METAMASK_GAS_LIMIT } from "~/utils/constants";
34
35
  import { getTestClient } from "~/utils/getTestClient";
35
36
  import { seconds } from "~/utils/time";
@@ -570,7 +571,6 @@ export async function beraWriteContract<
570
571
  ? increaseByPercentage(gasEstimateResult.value, 10)
571
572
  : DEFAULT_METAMASK_GAS_LIMIT);
572
573
 
573
- // @ts-expect-error nested type issues. Be careful when changing this.
574
574
  txHash = await walletClient.writeContract({
575
575
  ...simulationResult.value.request,
576
576
  chainId,
@@ -581,7 +581,7 @@ export async function beraWriteContract<
581
581
  onWarning?.(e, args);
582
582
  },
583
583
  }),
584
- });
584
+ } as WriteContractParameters);
585
585
  onSubmission?.({ txHash }, args);
586
586
  } else {
587
587
  const [nonceResult] = await Promise.allSettled([noncePromise]);
@@ -1,5 +1,4 @@
1
- import type { GetPublicClientReturnType } from "@wagmi/core";
2
- import type { Address } from "viem";
1
+ import type { Address, PublicClient } from "viem";
3
2
 
4
3
  import type {
5
4
  ApiValidatorFragment,
@@ -26,7 +25,7 @@ export async function getUserActiveValidators({
26
25
  ...args
27
26
  }: {
28
27
  account: string;
29
- publicClient?: GetPublicClientReturnType;
28
+ publicClient?: PublicClient | undefined;
30
29
  chain?: GqlChain;
31
30
  } & BeraJS.BaseFunctionArgs): Promise<ValidatorWithUserBoost[] | undefined> {
32
31
  const { config } = parseBaseArgs(args);
@@ -1,5 +1,4 @@
1
- import type { GetPublicClientReturnType } from "@wagmi/core";
2
- import { type Address, formatEther } from "viem";
1
+ import { type Address, formatEther, type PublicClient } from "viem";
3
2
 
4
3
  import { bgtAbi } from "~/abi/pol/bgt";
5
4
  import { parseBaseArgs } from "~/utils/parseBaseArgs";
@@ -23,7 +22,7 @@ export async function getUserBoostsOnValidator({
23
22
  }: {
24
23
  account: Address;
25
24
  pubkey: Address;
26
- publicClient: GetPublicClientReturnType;
25
+ publicClient: PublicClient | undefined;
27
26
  } & BeraJS.BaseFunctionArgs): Promise<UserBoostsOnValidator> {
28
27
  const { config } = parseBaseArgs(args);
29
28
 
@@ -11,9 +11,11 @@ export type BeraFlags = Record<
11
11
  | "enableEip5792"
12
12
  | "proxyAggregatorsThroughVercel"
13
13
  | "isEmbeddedWalletsEnabled"
14
+ | "sponsorGas"
14
15
  | "enableSimulateCalls"
15
16
  | "isBendVaultDataHourly"
16
17
  | "isMultiChainZapBendEnabled"
18
+ | "isZapStakeBeraEnabled"
17
19
  | "mockValidatorOperator"
18
20
  | "mockValidatorRewardAllocator"
19
21
  | "mockRewardDurationManager"
@@ -31,9 +33,11 @@ export const defaultFlags: BeraFlags = {
31
33
  enableEip5792: false,
32
34
  proxyAggregatorsThroughVercel: false,
33
35
  isEmbeddedWalletsEnabled: true,
36
+ sponsorGas: false,
34
37
  enableSimulateCalls: false,
35
38
  isBendVaultDataHourly: true,
36
39
  isMultiChainZapBendEnabled: false,
40
+ isZapStakeBeraEnabled: false,
37
41
  mockValidatorOperator: false,
38
42
  mockValidatorRewardAllocator: false,
39
43
  mockRewardDurationManager: false,
@@ -1,8 +1,10 @@
1
1
  import type React from "react";
2
2
  import { useEffect } from "react";
3
- import * as Sentry from "@sentry/nextjs";
4
3
  import { SWRConfig } from "swr";
5
4
 
5
+ import { BeraError } from "~/errors/BeraError";
6
+ import { BeraMonitoring } from "~/errors/BeraMonitoring";
7
+
6
8
  export function SWRFallback({
7
9
  fallback,
8
10
  children,
@@ -14,8 +16,16 @@ export function SWRFallback({
14
16
  Object.entries(fallback).some(([key, value]) => {
15
17
  if (!key) {
16
18
  console.warn("SWRFallback", key, value);
17
- Sentry.captureException(
18
- "Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",
19
+ BeraMonitoring.captureException(
20
+ new BeraError({
21
+ message:
22
+ "Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",
23
+ level: "warning",
24
+ extra: {
25
+ key,
26
+ value,
27
+ },
28
+ }),
19
29
  );
20
30
  return true;
21
31
  } else return false;
@@ -1,8 +1,12 @@
1
1
  import { createContext, type PropsWithChildren, useMemo } from "react";
2
2
 
3
- import { defaultChainId } from "@berachain/config/internal";
3
+ import {
4
+ type EdgeConfigSchema,
5
+ isFlagEnabled,
6
+ } from "@berachain/config/internal/edge-config";
4
7
 
5
- import type { Token, TokenWithMetadata } from "~/types/dex";
8
+ import { useEnsoUserTokensWithBalances } from "~/hooks/enso/useEnsoUserTokensWithBalances";
9
+ import type { BalanceToken, Token, TokenWithMetadata } from "~/types/dex";
6
10
  import { formatTokenList } from "~/utils/formatTokenList";
7
11
 
8
12
  export interface TokensProviderContext {
@@ -11,7 +15,10 @@ export interface TokensProviderContext {
11
15
  featuredTokens: TokenWithMetadata[];
12
16
  onRemoveToken: (token: Token) => void;
13
17
  onAddToken: (token: Token) => void;
18
+ refresh: () => void;
19
+ ensoTokens: BalanceToken[] | undefined;
14
20
  }
21
+
15
22
  export const TokenContext = createContext<TokensProviderContext | undefined>(
16
23
  undefined,
17
24
  );
@@ -19,7 +26,7 @@ export const TokenContext = createContext<TokensProviderContext | undefined>(
19
26
  export interface TokensProviderProps
20
27
  extends Omit<
21
28
  TokensProviderContext,
22
- "tokenList" | "onAddToken" | "featuredTokens"
29
+ "tokenList" | "onAddToken" | "featuredTokens" | "ensoTokens"
23
30
  > {
24
31
  onAddToken: (
25
32
  token: Token,
@@ -30,34 +37,54 @@ export interface TokensProviderProps
30
37
  },
31
38
  ) => void;
32
39
  defaultTokens: TokenWithMetadata[];
40
+ edgeConfigTokenList: EdgeConfigSchema["tokens"];
33
41
  }
34
42
 
35
43
  export function TokensProvider({
36
44
  children,
37
45
  defaultTokens,
46
+ edgeConfigTokenList,
38
47
  userTokens,
39
48
  onAddToken,
40
49
  onRemoveToken,
41
- }: PropsWithChildren<TokensProviderProps>) {
50
+ }: PropsWithChildren<Omit<TokensProviderProps, "refresh">>) {
51
+ const { data: ensoTokens, refresh } = useEnsoUserTokensWithBalances();
52
+
42
53
  const { tokenList = [], featuredTokenList = [] } = useMemo(
43
54
  () =>
44
55
  formatTokenList({
45
- defaultTokenList: defaultTokens,
46
- externalList: userTokens,
47
- chainId: defaultChainId,
56
+ defaultTokenList: [
57
+ ...defaultTokens,
58
+ ...(edgeConfigTokenList?.filter((token) =>
59
+ isFlagEnabled(token.enabled),
60
+ ) as TokenWithMetadata[]),
61
+ ],
62
+ externalList: [
63
+ ...userTokens,
64
+ ...(ensoTokens ?? []).map((t) => ({
65
+ ...t,
66
+ balance: undefined,
67
+ price: undefined,
68
+ })),
69
+ ],
48
70
  }),
49
- [defaultTokens, userTokens],
71
+ [defaultTokens, userTokens, edgeConfigTokenList, ensoTokens],
50
72
  );
73
+
51
74
  return (
52
75
  <TokenContext.Provider
53
76
  value={{
54
77
  tokenList,
55
78
  userTokens,
56
79
  featuredTokens: featuredTokenList,
80
+ ensoTokens,
57
81
  onAddToken(tk) {
58
82
  onAddToken(tk, { defaultTokens, userTokens, tokenList });
59
83
  },
60
84
  onRemoveToken,
85
+ refresh: () => {
86
+ refresh();
87
+ },
61
88
  }}
62
89
  >
63
90
  {children}
@@ -1,6 +1,6 @@
1
1
  import { createContext, type PropsWithChildren, useContext } from "react";
2
2
 
3
- import mainnet from "@berachain/config/mainnet";
3
+ import { mainnet } from "@berachain/config/mainnet";
4
4
 
5
5
  import { parseBaseArgs } from "~/utils/parseBaseArgs";
6
6
 
@@ -7,7 +7,6 @@ export {
7
7
  useBeraFlags,
8
8
  } from "./BeraFlags/BeraFlags";
9
9
  export * from "./BexStatusProvider";
10
- export * from "./berajsProvider";
11
10
  export * from "./block-time-provider";
12
11
  export * from "./HoneyConfigProvider";
13
12
  export * from "./SwrFallback";
@@ -142,6 +142,21 @@ export const contracts = [
142
142
  "80094": "0xb5f2000b5744f207c931526cAE2134cAa8b6862a",
143
143
  name: "pol.timelock",
144
144
  },
145
+ {
146
+ "80069": "0x176c081E95C82CA68DEa20CA419C7506Aa063C24",
147
+ "80094": "0xb79b43dBA821Cb67751276Ce050fF4111445fB99",
148
+ name: "stakingPools.stakingPoolContractsFactory",
149
+ },
150
+ {
151
+ "80069": "0x8b472791aC2f9e9Bd85f8919401b8Ce3bdFd464c",
152
+ "80094": "0xAd17932a5B1aaeEa73D277a6AE670623F176E0D0",
153
+ name: "stakingPools.delegationHandlerFactory",
154
+ },
155
+ {
156
+ "80069": "0xAFAc2f11Cb39F0521b22494F6101002ce653D2f4",
157
+ "80094": "0xE858802Ed532C6DAD2D196AB5B1F2C15F9cb52b4",
158
+ name: "stakingPools.withdrawalVault",
159
+ },
145
160
  {
146
161
  "80069": "0x656b95E550C07a9ffe548bd4085c72418Ceb1dba",
147
162
  "80094": "0x656b95E550C07a9ffe548bd4085c72418Ceb1dba",
@@ -348,8 +363,8 @@ export const contracts = [
348
363
  name: "honey.pythOracle",
349
364
  },
350
365
  {
351
- "80069": "0x4b7cb1c197f8EE4d309866B16C2c12E3B4E7E606",
352
- "80094": "0x4b7cb1c197f8EE4d309866B16C2c12E3B4E7E606",
366
+ "80069": "0xE5Ad9BA751714ec8cdd554b5a9f12BFcA13980cB",
367
+ "80094": "0xF5686e448BE103beA465105bEb9d284a34ae7e95",
353
368
  name: "honey.pythWrapper",
354
369
  },
355
370
  {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A list of contract names that are not mapped in the devrel's contract mapping or that are generated by factories (e.g. RewardVault).
3
+ */
4
+ export enum ContractName {
5
+ ENSO_ROUTER = "enso.router",
6
+ POL_REWARD_VAULT = "pol.rewardVault",
7
+ BEX_POOL = "bex.pool",
8
+ ERC20 = "others.erc20",
9
+ ERC4626 = "others.erc4626",
10
+ POL_STAKE_VAULT = "pol.stakeVault",
11
+ BEX_EXPLOITED_FUND_DISTRIBUTOR = "bex.exploitedFundDistributor",
12
+ TW_MINIMAL_ACCOUNT = "thirdweb.minimalAccount",
13
+ }
package/src/enum/dex.ts CHANGED
@@ -8,3 +8,32 @@ export enum ParameterPreset {
8
8
  USDBACKED = "USD-Backed Stablecoin",
9
9
  ALGORITHMIC = "Algorithmic Stablecoin",
10
10
  }
11
+
12
+ export enum PoolCreationStep {
13
+ POOL_TYPE = "Pool Type",
14
+ SELECT_TOKENS = "Select Tokens",
15
+ DEPOSIT_LIQUIDITY = "Deposit Liquidity",
16
+ SET_PARAMETERS = "Set Parameters",
17
+ SET_INFO = "Set Info",
18
+ }
19
+
20
+ export enum Aggregators {
21
+ ERC4626 = "Mint",
22
+ Oogabooga = "Oogabooga",
23
+ Fly = "Fly",
24
+ HubPools = "Hub Pools",
25
+ Wrap = "Wrap",
26
+ Unwrap = "Unwrap",
27
+ KyberSwap = "KyberSwap",
28
+ OpenOcean = "OpenOcean",
29
+ Haiku = "Haiku",
30
+ Enso = "Enso",
31
+ EnsoErc4626 = "Enso (Mint)",
32
+ RedeemBgt = "RedeemBgt",
33
+ Honey = "Honey",
34
+ }
35
+
36
+ export enum SwapReferrer {
37
+ SWAP = "SWAP",
38
+ ZAP = "ZAP",
39
+ }
@@ -1,4 +1,7 @@
1
+ export * from "./contracts";
1
2
  export * from "./dex";
3
+ export * from "./governance";
4
+ export * from "./honey";
2
5
  export * from "./polling";
3
6
  export * from "./slippage";
4
7
  export * from "./txnEnum";
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Maps the proposal state from the governor contract to a more human-readable format.
3
+ * Don't edit this enum manually, it's synced with the governor contract.
4
+ *
5
+ * @see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol
6
+ */
7
+ export enum ProposalState {
8
+ Pending = 0,
9
+ Active = 1,
10
+ Canceled = 2,
11
+ Defeated = 3,
12
+ Succeeded = 4,
13
+ Queued = 5,
14
+ Expired = 6,
15
+ Executed = 7,
16
+ }
17
+ export enum VoteEnum {
18
+ AGAINST = "no",
19
+ FOR = "yes",
20
+ ABSTAIN = "abstain",
21
+ }
22
+
23
+ export enum ProposalErrorCodes {
24
+ REQUIRED = "Required",
25
+ INVALID_AMOUNT = "Invalid amount",
26
+ NEGATIVE_AMOUNT = "Negative amount",
27
+ INVALID_ADDRESS = "Invalid address",
28
+ INVALID_ACTION = "Invalid action",
29
+ INVALID_ABI = "Invalid ABI",
30
+ MUST_BE_HTTPS = "Must be HTTPS",
31
+ MUST_BE_HTTPS_OR_IPFS = "Must be HTTPS or IPFS",
32
+ INVALID_BASEPATH = "Must be a berachain forum link",
33
+ /**
34
+ * Mainly used when it's not a reward vault
35
+ */
36
+ INVALID_CONTRACT = "This is not a valid contract",
37
+ }
38
+
39
+ export enum ProposalTypeEnum {
40
+ CUSTOM_PROPOSAL = "custom-action",
41
+ WHITELIST_REWARD_VAULT = "whitelist-reward-vault",
42
+ BLACKLIST_REWARD_VAULT = "blacklist-reward-vault",
43
+ ERC20_TRANSFER = "erc20-transfer",
44
+ WHITELIST_REWARD_VAULT_INCENTIVE = "whitelist-reward-vault-incentive",
45
+ }
46
+
47
+ export const VoteColorMap = {
48
+ yes: "#059669",
49
+ 1: "#059669",
50
+ no: "#DC2629",
51
+ 2: "#DC2629",
52
+ veto: "#0284C7",
53
+ 4: "#0284C7",
54
+ abstain: "#78716c",
55
+ 3: "#78716c",
56
+ yes_secondary: "#ECFDF5",
57
+ no_secondary: "#FEF2F2",
58
+ veto_secondary: "#F0F9FF",
59
+ abstain_secondary: "#E7E5E4",
60
+ default: "#57534e",
61
+ } as const;
@@ -0,0 +1,12 @@
1
+ export enum HoneySwapAction {
2
+ RESET_AMOUNTS = "RESET_AMOUNTS",
3
+ ACTION_TYPE_CHANGE = "ACTION_TYPE_CHANGE",
4
+ COLLATERALS_CHANGE = "COLLATERALS_CHANGE",
5
+ FROM_AMOUNT_CHANGE = "FROM_AMOUNT_CHANGE",
6
+ TO_AMOUNT_CHANGE = "TO_AMOUNT_CHANGE",
7
+ PREVIEW_CHANGE = "PREVIEW_CHANGE",
8
+ IS_BASKET_MODE_ENABLED_CHANGE = "IS_BASKET_MODE_ENABLED_CHANGE",
9
+ IS_TYPING_CHANGE = "IS_TYPING_CHANGE",
10
+ IS_SUBMITTING_CHANGE = "IS_SUBMITTING_CHANGE",
11
+ IS_LOADING_CHANGE = "IS_LOADING_CHANGE",
12
+ }
@@ -78,6 +78,7 @@ export enum TransactionActionType {
78
78
  APPLYING_COMMISSION_CHANGE = "Apply Commission Change",
79
79
 
80
80
  BONDING_BERA = "Stake BERA",
81
+ ZAP_STAKE_BERA = "Zap Stake BERA",
81
82
  UNBONDING_BERA = "Unstake BERA",
82
83
  QUEUE_UNBONDING_BERA = "Queue Unstake BERA",
83
84
 
@@ -1,11 +1,11 @@
1
- import type * as Sentry from "@sentry/nextjs";
2
1
  import { type Abi, BaseError } from "viem";
3
2
 
4
3
  import { appConfig } from "@berachain/config/internal";
5
4
 
6
5
  import { GENERAL_ERROR } from "./errorMap";
7
- import { getErrorMessage } from "./getErrorMessage";
6
+ import { findMatchingError } from "./getErrorMessage";
8
7
  import { parseViemError, rpcErrorToReason } from "./parseViemError";
8
+ import type { SeverityLevel } from "./severity";
9
9
 
10
10
  export interface IBeraErrorArgs {
11
11
  message?: string;
@@ -13,10 +13,11 @@ export interface IBeraErrorArgs {
13
13
  cause?: unknown;
14
14
  reason?: string;
15
15
  chainId?: number;
16
+ fingerprint?: string[];
16
17
  /**
17
- * The level of the error to be used for Sentry.
18
+ * The level of the error to be used for error reporting.
18
19
  */
19
- level?: Sentry.SeverityLevel;
20
+ level?: SeverityLevel;
20
21
  tags?: {
21
22
  [key in TagsKey]?: Primitive;
22
23
  };
@@ -27,9 +28,6 @@ export interface IBeraErrorArgs {
27
28
  abi?: Abi;
28
29
  }
29
30
 
30
- /**
31
- * Copy pasted from sentry types
32
- */
33
31
  type Primitive = number | string | boolean | bigint | symbol | null | undefined;
34
32
 
35
33
  /**
@@ -51,7 +49,22 @@ type TagsKey =
51
49
  | "operation.source.type";
52
50
 
53
51
  /**
54
- * This is a generic error class that can be used to handle errors in the SDK.
52
+ * Base error class for the entire berajs SDK.
53
+ *
54
+ * All errors should be a BeraError or one of its subclasses. Unknown errors should be
55
+ * normalized via `initBeraError({ cause })`.
56
+ *
57
+ * Key design: the constructor runs an **automatic reason detection pipeline** when `reason`
58
+ * is not explicitly provided. It calls `parseViemError` on the `cause` to extract a
59
+ * machine-readable reason code (e.g. "NotEnoughBalance", "BAL#508", "UserRejectedRequestError").
60
+ * That reason is then matched against `errorMap.ts` to resolve a user-friendly `displayMessage`.
61
+ *
62
+ * This means: for most viem errors, you only need to pass `cause` and everything else
63
+ * (reason, displayMessage, level) is derived automatically.
64
+ *
65
+ * @see parseViemError — the reason extraction engine
66
+ * @see errorMap.ts — reason → displayMessage mapping
67
+ * @see initBeraError — normalizes any error into a BeraError (preferred entry point)
55
68
  */
56
69
  export class BeraError extends Error {
57
70
  /**
@@ -80,6 +93,13 @@ export class BeraError extends Error {
80
93
  */
81
94
  reason: string | null = null;
82
95
 
96
+ /**
97
+ * The fingerprint for the error.
98
+ *
99
+ * This is typically used to group errors in Sentry.
100
+ */
101
+ fingerprint: string[] | undefined;
102
+
83
103
  private _tags: {
84
104
  [key: string | TagsKey]: Primitive;
85
105
  } = {};
@@ -101,7 +121,7 @@ export class BeraError extends Error {
101
121
  };
102
122
  }
103
123
 
104
- level: Sentry.SeverityLevel = "error";
124
+ level: SeverityLevel = "error";
105
125
 
106
126
  extra: Record<string, unknown> = {};
107
127
 
@@ -114,6 +134,7 @@ export class BeraError extends Error {
114
134
  abi,
115
135
  tags,
116
136
  chainId,
137
+ fingerprint,
117
138
  }: IBeraErrorArgs) {
118
139
  let message = m;
119
140
 
@@ -139,10 +160,19 @@ export class BeraError extends Error {
139
160
 
140
161
  this.name = "BeraError";
141
162
 
163
+ this.fingerprint = fingerprint;
164
+
142
165
  this.cause = cause;
143
166
 
144
167
  this.chainId = chainId;
145
168
 
169
+ // ── Automatic reason detection ──────────────────────────────────────
170
+ // If `reason` was provided explicitly, use it directly.
171
+ // Otherwise, attempt to extract it from the `cause` by unwrapping the viem error chain.
172
+ // parseViemError walks nested errors (ContractFunctionExecutionError →
173
+ // ContractFunctionRevertedError → RpcRequestError) and decodes revert data using ABI.
174
+ // The extracted reason (e.g. "NotEnoughBalance", "BAL#508") is the key that drives
175
+ // displayMessage resolution and Sentry fingerprinting.
146
176
  if (reason) {
147
177
  this.reason = reason;
148
178
  } else if (cause instanceof Error) {
@@ -155,10 +185,13 @@ export class BeraError extends Error {
155
185
 
156
186
  this.reason = parsed?.reason ?? null;
157
187
  } catch {
158
- // Maybe we can do something here
188
+ // parseViemError throws when it can't identify the error type and revertIfUnknown=true.
189
+ // In that case, reason stays null and displayMessage falls back to GENERAL_ERROR.
159
190
  }
160
191
  }
161
192
 
193
+ // ── Level inference ─────────────────────────────────────────────────
194
+ // User rejections are "info" (not actionable by devs), everything else defaults to "error".
162
195
  if (level) {
163
196
  this.level = level;
164
197
  } else if (this.reason === rpcErrorToReason("UserRejectedRequestError")) {
@@ -167,19 +200,34 @@ export class BeraError extends Error {
167
200
  this.level = "error";
168
201
  }
169
202
 
203
+ // ── displayMessage resolution ─────────────────────────────────────────
204
+ // Priority:
205
+ // 1. Explicit `displayMessage` passed by caller
206
+ // 2. Cascaded from a BeraError cause (if it has a non-generic message)
207
+ // 3. Looked up from errorMap.ts using the detected `reason` and `message`
208
+ // 4. GENERAL_ERROR fallback: "Something went wrong. Please try again later."
170
209
  let displayMessage = dm;
171
210
 
172
211
  if (
173
212
  this.cause instanceof BeraError &&
174
213
  this.cause.displayMessage !== GENERAL_ERROR
175
214
  ) {
176
- // If the cause is a BeraError, use the displayMessage of the cause
215
+ // Cascade: inner BeraError already resolved a good displayMessage, reuse it
177
216
  displayMessage = this.cause.displayMessage;
178
217
  }
179
218
 
180
- // Skip if displayMessage is already provided
181
219
  if (!displayMessage) {
182
- displayMessage = getErrorMessage(this);
220
+ // Match reason (exact) or message (keyword) against errorMap.ts
221
+ const matched = findMatchingError(this);
222
+ displayMessage = matched?.errorMSG;
223
+
224
+ // ── Reason normalization ──────────────────────────────────────────
225
+ // If the reason was resolved from a raw error message (e.g. "insufficient funds for
226
+ // gas * price + value: have X want Y") rather than a stable key (e.g. "InsufficientFundsError"),
227
+ // normalize it to the matched errorMap key (e.g. "NOT_ENOUGH_GAS") for stable Sentry fingerprinting.
228
+ if (matched && !matched.matchedByReason && this.reason) {
229
+ this.reason = matched.key;
230
+ }
183
231
  }
184
232
 
185
233
  this.displayMessage = displayMessage ?? GENERAL_ERROR;