@berachain/berajs 0.2.13 → 0.3.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 (387) hide show
  1. package/dist/actions/clients/BeraApolloClient.d.ts.map +1 -1
  2. package/dist/actions/clients/clientName.d.ts +10 -0
  3. package/dist/actions/clients/clientName.d.ts.map +1 -0
  4. package/dist/actions/clients/clientName.unit.test.d.ts +2 -0
  5. package/dist/actions/clients/clientName.unit.test.d.ts.map +1 -0
  6. package/dist/actions/clients/exports.d.ts +2 -0
  7. package/dist/actions/clients/exports.d.ts.map +1 -1
  8. package/dist/actions/clients/exports.mjs +26 -7
  9. package/dist/actions/clients/exports.mjs.map +1 -1
  10. package/dist/actions/clients/fetchBeep.d.ts +2 -2
  11. package/dist/actions/clients/fetchBeep.d.ts.map +1 -1
  12. package/dist/actions/clients/fetchEnso.d.ts +17 -0
  13. package/dist/actions/clients/fetchEnso.d.ts.map +1 -0
  14. package/dist/actions/clients/fetchLayerzero.d.ts +12 -0
  15. package/dist/actions/clients/fetchLayerzero.d.ts.map +1 -0
  16. package/dist/actions/clients/fetchOpenApi.d.ts +4 -1
  17. package/dist/actions/clients/fetchOpenApi.d.ts.map +1 -1
  18. package/dist/actions/clients/getApolloClient.d.ts.map +1 -1
  19. package/dist/actions/dex/aggregators/base.d.ts +30 -5
  20. package/dist/actions/dex/aggregators/base.d.ts.map +1 -1
  21. package/dist/actions/dex/aggregators/bex.d.ts +11 -1
  22. package/dist/actions/dex/aggregators/bex.d.ts.map +1 -1
  23. package/dist/actions/dex/aggregators/bgt.d.ts +2 -2
  24. package/dist/actions/dex/aggregators/bgt.d.ts.map +1 -1
  25. package/dist/actions/dex/aggregators/enso/enso.d.ts.map +1 -1
  26. package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts +1 -0
  27. package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts.map +1 -1
  28. package/dist/actions/dex/aggregators/erc4626.d.ts +2 -2
  29. package/dist/actions/dex/aggregators/erc4626.d.ts.map +1 -1
  30. package/dist/actions/dex/aggregators/fly.d.ts.map +1 -1
  31. package/dist/actions/dex/aggregators/haiku.d.ts +7 -1
  32. package/dist/actions/dex/aggregators/haiku.d.ts.map +1 -1
  33. package/dist/actions/dex/aggregators/honey.d.ts +2 -2
  34. package/dist/actions/dex/aggregators/honey.d.ts.map +1 -1
  35. package/dist/actions/dex/aggregators/kyberswap.d.ts.map +1 -1
  36. package/dist/actions/dex/aggregators/oogabooga.d.ts.map +1 -1
  37. package/dist/actions/dex/aggregators/openOcean.d.ts.map +1 -1
  38. package/dist/actions/dex/aggregators/wbera.d.ts +3 -2
  39. package/dist/actions/dex/aggregators/wbera.d.ts.map +1 -1
  40. package/dist/actions/dex/getAllPools.d.ts.map +1 -1
  41. package/dist/actions/dex/getApiPool.d.ts.map +1 -1
  42. package/dist/actions/enso/getEnsoUserTokensWithBalances.d.ts.map +1 -1
  43. package/dist/actions/enso/util.d.ts +1 -6
  44. package/dist/actions/enso/util.d.ts.map +1 -1
  45. package/dist/actions/exports.d.ts +3 -5
  46. package/dist/actions/exports.d.ts.map +1 -1
  47. package/dist/actions/exports.mjs +33 -64
  48. package/dist/actions/exports.mjs.map +1 -1
  49. package/dist/actions/governance/exports.mjs +3 -3
  50. package/dist/actions/honey/getChartData.d.ts +1 -1
  51. package/dist/actions/honey/getChartData.d.ts.map +1 -1
  52. package/dist/actions/honey/getHoney24hVolume.d.ts +2 -2
  53. package/dist/actions/honey/getHoney24hVolume.d.ts.map +1 -1
  54. package/dist/actions/honey/getHoneyCollaterals.d.ts +1 -1
  55. package/dist/actions/honey/getHoneyCollaterals.d.ts.map +1 -1
  56. package/dist/actions/honey/getHoneyTxns.d.ts +1 -1
  57. package/dist/actions/honey/getHoneyTxns.d.ts.map +1 -1
  58. package/dist/actions/pol/getBGTGlobalInfo.d.ts +0 -1
  59. package/dist/actions/pol/getBGTGlobalInfo.d.ts.map +1 -1
  60. package/dist/actions/pol/getBeraTokenTotalSupply.d.ts.map +1 -1
  61. package/dist/actions/pol/getEarnedStakedBeraVault.d.ts +4 -27
  62. package/dist/actions/pol/getEarnedStakedBeraVault.d.ts.map +1 -1
  63. package/dist/actions/pol/getLSTStakeConfig.d.ts.map +1 -1
  64. package/dist/actions/pol/getRewardVaults.d.ts.map +1 -1
  65. package/dist/actions/pol/getSWBeraVaultMetadata.d.ts +1 -14
  66. package/dist/actions/pol/getSWBeraVaultMetadata.d.ts.map +1 -1
  67. package/dist/actions/pol/getStakedBeraAPY.d.ts +14 -0
  68. package/dist/actions/pol/getStakedBeraAPY.d.ts.map +1 -0
  69. package/dist/actions/pol/getStakedBeraSnapshots.d.ts +14 -4
  70. package/dist/actions/pol/getStakedBeraSnapshots.d.ts.map +1 -1
  71. package/dist/actions/pol/getStakingDailyAssets.d.ts +2 -2
  72. package/dist/actions/pol/getStakingDailyAssets.d.ts.map +1 -1
  73. package/dist/actions/server/exports.mjs +5 -5
  74. package/dist/actions/server/exports.mjs.map +1 -1
  75. package/dist/actions/server/getDailyValidatorBlockStats.d.ts +1 -1
  76. package/dist/actions/server/getDailyValidatorBlockStats.d.ts.map +1 -1
  77. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts +1 -1
  78. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts.map +1 -1
  79. package/dist/actions/validators/getUserActiveValidators.d.ts +37 -1
  80. package/dist/actions/validators/getUserActiveValidators.d.ts.map +1 -1
  81. package/dist/actions/validators/getValidatorIncentiveDistribution.d.ts +1 -1
  82. package/dist/actions/validators/getValidatorIncentiveDistribution.d.ts.map +1 -1
  83. package/dist/actions/validators/getValidatorRewardAllocation.d.ts +4 -0
  84. package/dist/actions/validators/getValidatorRewardAllocation.d.ts.map +1 -1
  85. package/dist/chunk-3TRTSTDH.mjs +19 -0
  86. package/dist/chunk-3TRTSTDH.mjs.map +1 -0
  87. package/dist/{chunk-ZWTGVIPJ.mjs → chunk-4576RF2K.mjs} +29 -4
  88. package/dist/chunk-4576RF2K.mjs.map +1 -0
  89. package/dist/{chunk-PHYZRH4I.mjs → chunk-5MUCX35C.mjs} +9 -13
  90. package/dist/chunk-5MUCX35C.mjs.map +1 -0
  91. package/dist/{chunk-UA3Z47LT.mjs → chunk-6D4S3EAC.mjs} +97 -26
  92. package/dist/chunk-6D4S3EAC.mjs.map +1 -0
  93. package/dist/{chunk-AEN6IJFU.mjs → chunk-7KN7TDUC.mjs} +2 -2
  94. package/dist/{chunk-LE4CYW7S.mjs → chunk-FWRYUIJK.mjs} +3 -3
  95. package/dist/chunk-GDUKRUHE.mjs +29 -0
  96. package/dist/chunk-GDUKRUHE.mjs.map +1 -0
  97. package/dist/{chunk-PJRLHTGC.mjs → chunk-HPRLNT6R.mjs} +3 -3
  98. package/dist/{chunk-DOZJB6IJ.mjs → chunk-KY7JMIIS.mjs} +394 -346
  99. package/dist/chunk-KY7JMIIS.mjs.map +1 -0
  100. package/dist/{chunk-P3YZ7F22.mjs → chunk-LL7XR2H5.mjs} +34 -3
  101. package/dist/chunk-LL7XR2H5.mjs.map +1 -0
  102. package/dist/{chunk-EJIGERYM.mjs → chunk-M3MIGSH3.mjs} +2 -2
  103. package/dist/{chunk-NZAH3SGT.mjs → chunk-MVNQY2D4.mjs} +9 -4
  104. package/dist/chunk-MVNQY2D4.mjs.map +1 -0
  105. package/dist/{chunk-TGN55GKE.mjs → chunk-SC3BSCTN.mjs} +2 -2
  106. package/dist/{chunk-QQASX4LJ.mjs → chunk-TXWDUJOY.mjs} +2 -2
  107. package/dist/{chunk-EGAB6NFQ.mjs → chunk-UWJQ6UKG.mjs} +2 -2
  108. package/dist/chunk-XO2BFPTB.mjs +50 -0
  109. package/dist/chunk-XO2BFPTB.mjs.map +1 -0
  110. package/dist/{chunk-7TFV6UKF.mjs → chunk-XXKPXNQD.mjs} +1 -2
  111. package/dist/chunk-XXKPXNQD.mjs.map +1 -0
  112. package/dist/{chunk-IFNIPVTZ.mjs → chunk-Z337NBBW.mjs} +5 -49
  113. package/dist/chunk-Z337NBBW.mjs.map +1 -0
  114. package/dist/{chunk-J3LTASDE.mjs → chunk-ZHV3MQ4F.mjs} +4 -4
  115. package/dist/contexts/BeraFlags/BeraFlags.d.ts +1 -1
  116. package/dist/contexts/BeraFlags/BeraFlags.d.ts.map +1 -1
  117. package/dist/contexts/BeraFlags/defaultFlags.d.ts +2 -2
  118. package/dist/contexts/BeraFlags/defaultFlags.d.ts.map +1 -1
  119. package/dist/contexts/BexStatusProvider.d.ts +1 -1
  120. package/dist/contexts/BexStatusProvider.d.ts.map +1 -1
  121. package/dist/contexts/TokensProvider.d.ts +1 -1
  122. package/dist/contexts/TokensProvider.d.ts.map +1 -1
  123. package/dist/contexts/exports.mjs +9 -9
  124. package/dist/enum/contracts.d.ts +3 -0
  125. package/dist/enum/contracts.d.ts.map +1 -1
  126. package/dist/enum/exports.mjs +6 -4
  127. package/dist/enum/exports.mjs.map +1 -1
  128. package/dist/enum/txnEnum.d.ts +1 -1
  129. package/dist/enum/txnEnum.d.ts.map +1 -1
  130. package/dist/errors/RequestError.d.ts +19 -0
  131. package/dist/errors/RequestError.d.ts.map +1 -1
  132. package/dist/errors/errorMap.d.ts +4 -3
  133. package/dist/errors/errorMap.d.ts.map +1 -1
  134. package/dist/errors/exports.mjs +5 -5
  135. package/dist/errors/getErrorMessage.unit.test.d.ts +2 -0
  136. package/dist/errors/getErrorMessage.unit.test.d.ts.map +1 -0
  137. package/dist/generated/beep.d.ts +1597 -0
  138. package/dist/generated/beep.d.ts.map +1 -0
  139. package/dist/generated/enso.d.ts +4957 -0
  140. package/dist/generated/enso.d.ts.map +1 -0
  141. package/dist/generated/layerzero.d.ts +2057 -0
  142. package/dist/generated/layerzero.d.ts.map +1 -0
  143. package/dist/hooks/dex/useAggregatorsQuotes.d.ts.map +1 -1
  144. package/dist/hooks/dex/useAllUserPools.d.ts.map +1 -1
  145. package/dist/hooks/dex/useCrossChainNativeFee.d.ts +32 -0
  146. package/dist/hooks/dex/useCrossChainNativeFee.d.ts.map +1 -0
  147. package/dist/hooks/dex/useCrossChainNativeFee.unit.test.d.ts +2 -0
  148. package/dist/hooks/dex/useCrossChainNativeFee.unit.test.d.ts.map +1 -0
  149. package/dist/hooks/dex/useOnChainPoolData.d.ts.map +1 -1
  150. package/dist/hooks/dex/usePools.d.ts.map +1 -1
  151. package/dist/hooks/dex/useSingleAggregatorQuote.d.ts.map +1 -1
  152. package/dist/hooks/dex/useSingleAggregatorQuote.unit.test.d.ts +2 -0
  153. package/dist/hooks/dex/useSingleAggregatorQuote.unit.test.d.ts.map +1 -0
  154. package/dist/hooks/enso/useBendZapSupply.d.ts +2 -2
  155. package/dist/hooks/enso/useBendZapSupply.d.ts.map +1 -1
  156. package/dist/hooks/enso/useBendZapSupply.unit.test.d.ts +2 -0
  157. package/dist/hooks/enso/useBendZapSupply.unit.test.d.ts.map +1 -0
  158. package/dist/hooks/enso/useEnsoUserTokensWithBalances.d.ts.map +1 -1
  159. package/dist/hooks/enso/useEnsoUserTokensWithBalances.unit.test.d.ts +2 -0
  160. package/dist/hooks/enso/useEnsoUserTokensWithBalances.unit.test.d.ts.map +1 -0
  161. package/dist/hooks/enso/useZapStakeBera.d.ts.map +1 -1
  162. package/dist/hooks/enso/useZapStakeBera.unit.test.d.ts +2 -0
  163. package/dist/hooks/enso/useZapStakeBera.unit.test.d.ts.map +1 -0
  164. package/dist/hooks/exports.d.ts +2 -5
  165. package/dist/hooks/exports.d.ts.map +1 -1
  166. package/dist/hooks/exports.mjs +615 -911
  167. package/dist/hooks/exports.mjs.map +1 -1
  168. package/dist/hooks/governance/exports.mjs +4 -4
  169. package/dist/hooks/honey/useHoneyChartData.d.ts +4 -4
  170. package/dist/hooks/honey/useHoneyChartData.d.ts.map +1 -1
  171. package/dist/hooks/pol/useAutoclaimedIncentives.d.ts.map +1 -1
  172. package/dist/hooks/pol/useAutoclaimedIncentivesTxHash.d.ts.map +1 -1
  173. package/dist/hooks/pol/useRewardTokenToBeraRate.d.ts.map +1 -1
  174. package/dist/hooks/pol/useRewardVaultBalanceFromStakingToken.d.ts.map +1 -1
  175. package/dist/hooks/pol/useRewardVaults.d.ts.map +1 -1
  176. package/dist/hooks/pol/useStakedAPY.d.ts +11 -0
  177. package/dist/hooks/pol/useStakedAPY.d.ts.map +1 -0
  178. package/dist/hooks/pol/useStakedData.d.ts +4 -2
  179. package/dist/hooks/pol/useStakedData.d.ts.map +1 -1
  180. package/dist/hooks/pol/useStakedSnapshots.d.ts +1 -1
  181. package/dist/hooks/pol/useStakedSnapshots.d.ts.map +1 -1
  182. package/dist/hooks/pol/useStakingVaultsMetadata.d.ts +0 -1
  183. package/dist/hooks/pol/useStakingVaultsMetadata.d.ts.map +1 -1
  184. package/dist/hooks/tokens/useMultipleTokenInformation.d.ts +30 -0
  185. package/dist/hooks/tokens/useMultipleTokenInformation.d.ts.map +1 -1
  186. package/dist/hooks/tokens/useMultipleTokenInformation.unit.test.d.ts +2 -0
  187. package/dist/hooks/tokens/useMultipleTokenInformation.unit.test.d.ts.map +1 -0
  188. package/dist/hooks/tokens/usePollBalance.d.ts.map +1 -1
  189. package/dist/hooks/validators/useUserActiveValidators.d.ts +5 -0
  190. package/dist/hooks/validators/useUserActiveValidators.d.ts.map +1 -1
  191. package/dist/hooks/validators/useValidator.d.ts +0 -1
  192. package/dist/hooks/validators/useValidator.d.ts.map +1 -1
  193. package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts +4 -5
  194. package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts.map +1 -1
  195. package/dist/hooks/validators/useValidatorRewardAllocation.d.ts +1 -0
  196. package/dist/hooks/validators/useValidatorRewardAllocation.d.ts.map +1 -1
  197. package/dist/types/beep/exports.d.ts +2 -0
  198. package/dist/types/beep/exports.d.ts.map +1 -0
  199. package/dist/types/beep/exports.mjs +1 -0
  200. package/dist/types/beep/exports.mjs.map +1 -0
  201. package/dist/types/bribeBoost.d.ts +0 -49
  202. package/dist/types/dex.d.ts +17 -0
  203. package/dist/types/enso.d.ts +1 -27
  204. package/dist/types/global.d.ts +7 -0
  205. package/dist/types/pol.d.ts +3 -48
  206. package/dist/utils/crossChainBridge.d.ts +74 -0
  207. package/dist/utils/crossChainBridge.d.ts.map +1 -0
  208. package/dist/utils/crossChainBridge.unit.test.d.ts +2 -0
  209. package/dist/utils/crossChainBridge.unit.test.d.ts.map +1 -0
  210. package/dist/utils/exports.d.ts +1 -1
  211. package/dist/utils/exports.d.ts.map +1 -1
  212. package/dist/utils/exports.mjs +142 -72
  213. package/dist/utils/exports.mjs.map +1 -1
  214. package/dist/utils/getTestClient.d.ts +5 -3
  215. package/dist/utils/getTestClient.d.ts.map +1 -1
  216. package/dist/utils/parseWhiskToken.d.ts.map +1 -1
  217. package/package.json +14 -10
  218. package/src/actions/clients/BeraApolloClient.ts +4 -2
  219. package/src/actions/clients/clientName.ts +17 -0
  220. package/src/actions/clients/clientName.unit.test.ts +39 -0
  221. package/src/actions/clients/exports.ts +2 -0
  222. package/src/actions/clients/fetchBeep.ts +6 -4
  223. package/src/actions/clients/fetchEnso.ts +47 -0
  224. package/src/actions/clients/fetchLayerzero.ts +33 -0
  225. package/src/actions/clients/fetchOpenApi.ts +9 -2
  226. package/src/actions/clients/fetchOpenApi.unit.test.ts +27 -12
  227. package/src/actions/clients/getApolloClient.ts +3 -11
  228. package/src/actions/dex/__tests__/aggregators.unit.test.ts +231 -2
  229. package/src/actions/dex/aggregators/base.ts +75 -17
  230. package/src/actions/dex/aggregators/bex.ts +41 -1
  231. package/src/actions/dex/aggregators/bgt.ts +11 -6
  232. package/src/actions/dex/aggregators/enso/enso.ts +1 -0
  233. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +27 -9
  234. package/src/actions/dex/aggregators/erc4626.ts +19 -5
  235. package/src/actions/dex/aggregators/fly.ts +1 -0
  236. package/src/actions/dex/aggregators/haiku.ts +33 -2
  237. package/src/actions/dex/aggregators/honey.ts +17 -6
  238. package/src/actions/dex/aggregators/kyberswap.ts +1 -0
  239. package/src/actions/dex/aggregators/oogabooga.ts +1 -0
  240. package/src/actions/dex/aggregators/openOcean.ts +1 -0
  241. package/src/actions/dex/aggregators/wbera.ts +17 -11
  242. package/src/actions/enso/getBendMultiplyBundle.ts +1 -1
  243. package/src/actions/enso/getEnsoUserTokensWithBalances.ts +4 -8
  244. package/src/actions/enso/util.ts +0 -59
  245. package/src/actions/exports.ts +3 -5
  246. package/src/actions/honey/getChartData.ts +2 -3
  247. package/src/actions/honey/getHoney24hVolume.ts +4 -13
  248. package/src/actions/honey/getHoneyCollaterals.ts +1 -1
  249. package/src/actions/honey/getHoneyTxns.ts +2 -3
  250. package/src/actions/pol/getBGTGlobalInfo.ts +0 -2
  251. package/src/actions/pol/getBeraTokenTotalSupply.ts +3 -33
  252. package/src/actions/pol/getEarnedStakedBeraVault.ts +1 -1
  253. package/src/actions/pol/getLSTStakeConfig.ts +0 -6
  254. package/src/actions/pol/getRewardVaults.ts +0 -1
  255. package/src/actions/pol/getSWBeraVaultMetadata.ts +2 -106
  256. package/src/actions/pol/getStakedBeraAPY.ts +44 -0
  257. package/src/actions/pol/getStakedBeraSnapshots.ts +17 -34
  258. package/src/actions/pol/getStakingDailyAssets.ts +1 -1
  259. package/src/actions/server/getDailyValidatorBlockStats.ts +1 -2
  260. package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +1 -1
  261. package/src/actions/validators/getUserActiveValidators.ts +116 -54
  262. package/src/actions/validators/getValidatorIncentiveDistribution.ts +1 -2
  263. package/src/actions/validators/getValidatorRewardAllocation.ts +12 -1
  264. package/src/contexts/BeraFlags/BeraFlags.tsx +1 -4
  265. package/src/contexts/BeraFlags/defaultFlags.ts +1 -3
  266. package/src/contexts/BexStatusProvider.tsx +1 -1
  267. package/src/contexts/TokensProvider.tsx +1 -4
  268. package/src/enum/contracts.ts +3 -0
  269. package/src/enum/txnEnum.ts +1 -1
  270. package/src/errors/BeraError.unit.test.ts +23 -0
  271. package/src/errors/RequestError.ts +46 -9
  272. package/src/errors/RequestError.unit.test.ts +54 -0
  273. package/src/errors/errorMap.ts +8 -3
  274. package/src/errors/getErrorMessage.unit.test.ts +32 -0
  275. package/src/generated/beep.ts +1605 -0
  276. package/src/generated/enso.ts +4965 -0
  277. package/src/generated/layerzero.ts +2065 -0
  278. package/src/hooks/dex/useAggregatorsQuotes.ts +7 -1
  279. package/src/hooks/dex/useCrossChainNativeFee.ts +83 -0
  280. package/src/hooks/dex/useCrossChainNativeFee.unit.test.ts +63 -0
  281. package/src/hooks/dex/useOnChainPoolData.ts +30 -13
  282. package/src/hooks/dex/useSingleAggregatorQuote.ts +10 -5
  283. package/src/hooks/dex/useSingleAggregatorQuote.unit.test.ts +86 -0
  284. package/src/hooks/enso/useBendZapSupply.ts +10 -38
  285. package/src/hooks/enso/useBendZapSupply.unit.test.ts +98 -0
  286. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -3
  287. package/src/hooks/enso/useEnsoUserTokensWithBalances.unit.test.ts +69 -0
  288. package/src/hooks/enso/useZapStakeBera.ts +8 -1
  289. package/src/hooks/enso/useZapStakeBera.unit.test.ts +97 -0
  290. package/src/hooks/exports.ts +2 -5
  291. package/src/hooks/pol/useAutoclaimedIncentives.ts +6 -3
  292. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +5 -2
  293. package/src/hooks/pol/useRewardTokenToBeraRate.ts +5 -4
  294. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +0 -1
  295. package/src/hooks/pol/{useStakedAPR.ts → useStakedAPY.ts} +11 -9
  296. package/src/hooks/pol/useStakedData.ts +15 -14
  297. package/src/hooks/pol/useStakedSnapshots.ts +1 -1
  298. package/src/hooks/pol/useStakingVaultsMetadata.ts +3 -8
  299. package/src/hooks/tokens/useMultipleTokenInformation.ts +64 -21
  300. package/src/hooks/tokens/useMultipleTokenInformation.unit.test.ts +91 -0
  301. package/src/hooks/tokens/usePollBalance.ts +4 -2
  302. package/src/hooks/validators/useUserActiveValidators.ts +54 -9
  303. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -5
  304. package/src/types/beep/exports.ts +4 -0
  305. package/src/types/bribeBoost.d.ts +0 -49
  306. package/src/types/dex.d.ts +17 -0
  307. package/src/types/enso.d.ts +1 -27
  308. package/src/types/global.d.ts +7 -0
  309. package/src/types/pol.d.ts +3 -48
  310. package/src/utils/crossChainBridge.ts +290 -0
  311. package/src/utils/crossChainBridge.unit.test.ts +177 -0
  312. package/src/utils/exports.ts +1 -1
  313. package/dist/BeraError-7-A5JYy_.d.ts +0 -123
  314. package/dist/BexStatusProvider-DRymVlQf.d.ts +0 -70
  315. package/dist/HoneyConfigProvider-COOuDNra.d.ts +0 -390
  316. package/dist/RequestError-DkUbo3ro.d.ts +0 -145
  317. package/dist/actions/dex/b-sdk.d.ts +0 -3
  318. package/dist/actions/enso/getEnsoSwapBundle.d.ts +0 -3
  319. package/dist/actions/enso/getEnsoSwapBundle.d.ts.map +0 -1
  320. package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts +0 -10
  321. package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts.map +0 -1
  322. package/dist/actions/pol/getRewardProofsByValidator.d.ts +0 -9
  323. package/dist/actions/pol/getRewardProofsByValidator.d.ts.map +0 -1
  324. package/dist/actions/pol/getStakedBeraAPR.d.ts +0 -12
  325. package/dist/actions/pol/getStakedBeraAPR.d.ts.map +0 -1
  326. package/dist/actions/pol/getUserClaimableIncentives.d.ts +0 -9
  327. package/dist/actions/pol/getUserClaimableIncentives.d.ts.map +0 -1
  328. package/dist/actions/validators/getValidatorAnalytics.d.ts +0 -12
  329. package/dist/actions/validators/getValidatorAnalytics.d.ts.map +0 -1
  330. package/dist/chunk-7TFV6UKF.mjs.map +0 -1
  331. package/dist/chunk-BSOWLS3W.mjs +0 -40
  332. package/dist/chunk-BSOWLS3W.mjs.map +0 -1
  333. package/dist/chunk-DOZJB6IJ.mjs.map +0 -1
  334. package/dist/chunk-IFNIPVTZ.mjs.map +0 -1
  335. package/dist/chunk-NZAH3SGT.mjs.map +0 -1
  336. package/dist/chunk-P3YZ7F22.mjs.map +0 -1
  337. package/dist/chunk-PHYZRH4I.mjs.map +0 -1
  338. package/dist/chunk-UA3Z47LT.mjs.map +0 -1
  339. package/dist/chunk-ZWTGVIPJ.mjs.map +0 -1
  340. package/dist/contexts/block-time-provider.d.ts +0 -10
  341. package/dist/defaultFlags-D6KfkTZx.d.ts +0 -10
  342. package/dist/dex-C_BB0b0O.d.ts +0 -37
  343. package/dist/getApolloClient-MWm_iq4u.d.ts +0 -39
  344. package/dist/getProposalVotes-DAUrdX2n.d.ts +0 -12
  345. package/dist/getValidatorQueuedOperatorAddress-N2I7wHd6.d.ts +0 -511
  346. package/dist/global.d-CR3zicga.d.ts +0 -231
  347. package/dist/global.d-CiZJ2eHz.d.ts +0 -231
  348. package/dist/honey-CYm0RWf4.d.ts +0 -14
  349. package/dist/hooks/enso/useEnsoSwapBundle.d.ts +0 -26
  350. package/dist/hooks/enso/useEnsoSwapBundle.d.ts.map +0 -1
  351. package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts +0 -8
  352. package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts.map +0 -1
  353. package/dist/hooks/pol/useStakedAPR.d.ts +0 -11
  354. package/dist/hooks/pol/useStakedAPR.d.ts.map +0 -1
  355. package/dist/hooks/validators/useUserClaimableIncentives.d.ts +0 -8
  356. package/dist/hooks/validators/useUserClaimableIncentives.d.ts.map +0 -1
  357. package/dist/hooks/validators/useValidatorAnalytics.d.ts +0 -11
  358. package/dist/hooks/validators/useValidatorAnalytics.d.ts.map +0 -1
  359. package/dist/pol.d-CeRgXBL8.d.ts +0 -167
  360. package/dist/txnEnum-ByI5dtDi.d.ts +0 -106
  361. package/dist/types/bribe-boost.d.ts +0 -69
  362. package/dist/useHoneySwapState-CXVWAThr.d.ts +0 -32
  363. package/dist/useHoneySwapState-twi7NTaO.d.ts +0 -32
  364. package/dist/utils/formatIncentivesTokenMap.d.ts +0 -3
  365. package/dist/utils/formatIncentivesTokenMap.d.ts.map +0 -1
  366. package/dist/utils/layerZeroScan.d.ts +0 -39
  367. package/dist/utils/layerZeroScan.d.ts.map +0 -1
  368. package/src/actions/enso/getEnsoSwapBundle.ts +0 -72
  369. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +0 -28
  370. package/src/actions/pol/getRewardProofsByValidator.ts +0 -49
  371. package/src/actions/pol/getStakedBeraAPR.ts +0 -56
  372. package/src/actions/pol/getUserClaimableIncentives.ts +0 -40
  373. package/src/actions/validators/getValidatorAnalytics.ts +0 -37
  374. package/src/hooks/enso/useEnsoSwapBundle.ts +0 -121
  375. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +0 -34
  376. package/src/hooks/validators/useUserClaimableIncentives.ts +0 -148
  377. package/src/hooks/validators/useValidatorAnalytics.ts +0 -37
  378. package/src/utils/formatIncentivesTokenMap.ts +0 -19
  379. package/src/utils/layerZeroScan.ts +0 -124
  380. /package/dist/{chunk-AEN6IJFU.mjs.map → chunk-7KN7TDUC.mjs.map} +0 -0
  381. /package/dist/{chunk-LE4CYW7S.mjs.map → chunk-FWRYUIJK.mjs.map} +0 -0
  382. /package/dist/{chunk-PJRLHTGC.mjs.map → chunk-HPRLNT6R.mjs.map} +0 -0
  383. /package/dist/{chunk-EJIGERYM.mjs.map → chunk-M3MIGSH3.mjs.map} +0 -0
  384. /package/dist/{chunk-TGN55GKE.mjs.map → chunk-SC3BSCTN.mjs.map} +0 -0
  385. /package/dist/{chunk-QQASX4LJ.mjs.map → chunk-TXWDUJOY.mjs.map} +0 -0
  386. /package/dist/{chunk-EGAB6NFQ.mjs.map → chunk-UWJQ6UKG.mjs.map} +0 -0
  387. /package/dist/{chunk-J3LTASDE.mjs.map → chunk-ZHV3MQ4F.mjs.map} +0 -0
@@ -0,0 +1,17 @@
1
+ import { currentDapp } from "@berachain/config/internal";
2
+
3
+ /**
4
+ * Identifies the caller of a backend request for client-tracking metrics:
5
+ * `berachain.dapps` from a real dapp (hub/bend/honey), `berachain.berajs-test`
6
+ * in the test env, else `berachain.berajs` when berajs is consumed as a library.
7
+ *
8
+ * Used for both Stellate's GraphQL `x-graphql-client-name` and beep's
9
+ * `X-Client-Id` so the two stay in sync.
10
+ */
11
+ export function getClientName(): string {
12
+ if (currentDapp) return "berachain.dapps";
13
+ if (process.env.VERCEL_ENV === "test" || process.env.NODE_ENV === "test")
14
+ return "berachain.berajs-test";
15
+ // tracks usage of the berajs package in other packages
16
+ return "berachain.berajs";
17
+ }
@@ -0,0 +1,39 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+
3
+ // `currentDapp` is derived from env at config import time, so we mock it
4
+ // directly per case rather than stubbing the env and re-importing the chain.
5
+ const mocks = vi.hoisted(() => ({
6
+ currentDapp: undefined as string | undefined,
7
+ }));
8
+ vi.mock("@berachain/config/internal", () => ({
9
+ get currentDapp() {
10
+ return mocks.currentDapp;
11
+ },
12
+ }));
13
+
14
+ async function getClientName() {
15
+ return (await import("./clientName")).getClientName();
16
+ }
17
+
18
+ describe("getClientName", () => {
19
+ afterEach(() => {
20
+ mocks.currentDapp = undefined;
21
+ vi.unstubAllEnvs();
22
+ });
23
+
24
+ it("returns berachain.dapps when running inside a dapp", async () => {
25
+ mocks.currentDapp = "BeraHub";
26
+ expect(await getClientName()).toBe("berachain.dapps");
27
+ });
28
+
29
+ it("returns berachain.berajs-test in the test env", async () => {
30
+ vi.stubEnv("VERCEL_ENV", "test");
31
+ expect(await getClientName()).toBe("berachain.berajs-test");
32
+ });
33
+
34
+ it("falls back to berachain.berajs outside a dapp and outside test", async () => {
35
+ vi.stubEnv("NODE_ENV", "production");
36
+ vi.stubEnv("VERCEL_ENV", "");
37
+ expect(await getClientName()).toBe("berachain.berajs");
38
+ });
39
+ });
@@ -1,4 +1,6 @@
1
1
  export { fetchBeep } from "./fetchBeep";
2
+ export { fetchEnso } from "./fetchEnso";
3
+ export { fetchLayerzero } from "./fetchLayerzero";
2
4
  export { fetchOpenApi } from "./fetchOpenApi";
3
5
  export {
4
6
  getApolloClient,
@@ -1,6 +1,6 @@
1
- import type { paths } from "@berachain/graphql/beep";
2
-
1
+ import type { paths } from "../../generated/beep";
3
2
  import { parseBaseArgs } from "../../utils/parseBaseArgs";
3
+ import { getClientName } from "./clientName";
4
4
  import {
5
5
  type DefinedParams,
6
6
  fetchOpenApi,
@@ -12,7 +12,7 @@ import {
12
12
  * Typed GET against the next-gen "beep" backend.
13
13
  *
14
14
  * The `path`, its path/query params and the response are all type-checked
15
- * against the beep schema (`@berachain/graphql/beep`), so route shapes (e.g.
15
+ * against the beep schema (`src/generated/beep`), so route shapes (e.g.
16
16
  * the `/v0/stake/*` namespace) can never drift out of sync with the backend.
17
17
  * The base URL is resolved from `config.beep`.
18
18
  */
@@ -23,5 +23,7 @@ export function fetchBeep<P extends GetPath<paths>>(
23
23
  ): Promise<GetResponse<paths, P>> {
24
24
  const { config } = parseBaseArgs(args);
25
25
 
26
- return fetchOpenApi<paths, P>(config.beep, path, params, "beep");
26
+ return fetchOpenApi<paths, P>(config.beep, path, params, "beep", {
27
+ "X-Client-Id": getClientName(),
28
+ });
27
29
  }
@@ -0,0 +1,47 @@
1
+ import { appConfig } from "@berachain/config/internal";
2
+
3
+ import type { paths } from "../../generated/enso";
4
+ import { parseBaseArgs } from "../../utils/parseBaseArgs";
5
+ import {
6
+ type DefinedParams,
7
+ fetchOpenApi,
8
+ type GetPath,
9
+ type GetResponse,
10
+ } from "./fetchOpenApi";
11
+
12
+ const isProduction =
13
+ process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test";
14
+
15
+ /** Enso's public API origin. Schema paths already carry the `/api/v1` prefix. */
16
+ const ENSO_API_ORIGIN = "https://api.enso.build";
17
+
18
+ /**
19
+ * Typed GET against the Enso API.
20
+ *
21
+ * The `path`, its path/query params and the response are all type-checked
22
+ * against the Enso schema (`src/generated/enso`). Base URL and auth mirror
23
+ * {@link getEnsoClient}: in production requests go through the aggregators proxy
24
+ * (which injects Enso auth), and in dev/test they hit Enso directly with the
25
+ * public API key.
26
+ *
27
+ * Enso covers relay/bridge-check routes today, but callers should treat this as
28
+ * "the Enso implementation" of those flows — if we later relay such txns
29
+ * without Enso, swap the helper at the call site rather than generalizing this.
30
+ */
31
+ export function fetchEnso<P extends GetPath<paths>>(
32
+ path: P,
33
+ params: DefinedParams<paths, P>,
34
+ args: BeraJS.BaseFunctionArgs = {},
35
+ ): Promise<GetResponse<paths, P>> {
36
+ const { config } = parseBaseArgs(args);
37
+
38
+ // Proxy in prod (auth handled by the proxy); direct + public key otherwise.
39
+ const origin = isProduction
40
+ ? `${config.bex.aggregatorsProxyUrl}/enso`
41
+ : ENSO_API_ORIGIN;
42
+ const headers = isProduction
43
+ ? undefined
44
+ : { Authorization: `Bearer ${appConfig.apiKeys.public.enso}` };
45
+
46
+ return fetchOpenApi<paths, P>(origin, path, params, "enso", headers);
47
+ }
@@ -0,0 +1,33 @@
1
+ import type { paths } from "../../generated/layerzero";
2
+ import {
3
+ type DefinedParams,
4
+ fetchOpenApi,
5
+ type GetPath,
6
+ type GetResponse,
7
+ } from "./fetchOpenApi";
8
+
9
+ /**
10
+ * LayerZero Scan API origin. Schema paths are relative to this base (e.g.
11
+ * `/messages/tx/{tx}`).
12
+ */
13
+ const LAYERZERO_SCAN_ORIGIN = "https://scan.layerzero-api.com/v1";
14
+
15
+ /**
16
+ * Typed GET against the LayerZero Scan API.
17
+ *
18
+ * The `path`, its path/query params and the response are all type-checked
19
+ * against the LayerZero schema (`src/generated/layerzero`). The Scan API is
20
+ * public (no auth), so requests hit it directly — no proxy split like
21
+ * {@link fetchEnso}.
22
+ */
23
+ export function fetchLayerzero<P extends GetPath<paths>>(
24
+ path: P,
25
+ params: DefinedParams<paths, P>,
26
+ ): Promise<GetResponse<paths, P>> {
27
+ return fetchOpenApi<paths, P>(
28
+ LAYERZERO_SCAN_ORIGIN,
29
+ path,
30
+ params,
31
+ "layerzero",
32
+ );
33
+ }
@@ -55,13 +55,17 @@ export type DefinedParams<Paths extends AnyPaths, P extends GetPath<Paths>> = {
55
55
  * @param path An OpenAPI path template, e.g. `/v0/stake/{vault}/stats-by-day`.
56
56
  * @param params Path and query params, typed from the schema for `path`.
57
57
  * @param fallbackName Monitoring name to use when `link` is a bare string.
58
+ * @param headers Request headers. Kept minimal by default — extra headers
59
+ * (e.g. `X-Client-Id`, which only beep needs) trigger a CORS
60
+ * preflight that third-party gateways like Enso reject.
58
61
  */
59
- // biome-ignore lint/complexity/useMaxParams: internal helper; the wrapper (fetchBeep) is the public surface.
62
+ // biome-ignore lint/complexity/useMaxParams: internal helper; the wrappers (fetchBeep, fetchEnso) are the public surface.
60
63
  export function fetchOpenApi<Paths extends AnyPaths, P extends GetPath<Paths>>(
61
64
  link: HttpLink,
62
65
  path: P,
63
66
  params: DefinedParams<Paths, P>,
64
67
  fallbackName: string,
68
+ headers?: Record<string, string>,
65
69
  ): Promise<GetResponse<Paths, P>> {
66
70
  const { path: pathParams, query } = params as {
67
71
  path?: Record<string, string | number>;
@@ -93,5 +97,8 @@ export function fetchOpenApi<Paths extends AnyPaths, P extends GetPath<Paths>>(
93
97
  const url = `${getUriFromLink(link)}${resolvedPath}${search ? `?${search}` : ""}`;
94
98
  const name = typeof link === "string" ? fallbackName : link.name;
95
99
 
96
- return beraFetchJson<GetResponse<Paths, P>>({ url, name, type: "rest" });
100
+ return beraFetchJson<GetResponse<Paths, P>>(
101
+ { url, name, type: "rest" },
102
+ { headers },
103
+ );
97
104
  }
@@ -16,11 +16,16 @@ import type {
16
16
  StakeEarningResponse,
17
17
  StakeStatsByDayResponse,
18
18
  ValidatorsResponse,
19
- } from "@berachain/graphql/beep";
20
-
19
+ } from "../../generated/beep";
20
+ import { getClientName } from "./clientName";
21
21
  import { fetchBeep } from "./fetchBeep";
22
22
  import { fetchOpenApi } from "./fetchOpenApi";
23
23
 
24
+ // fetchBeep is the only wrapper that sends X-Client-Id; the bare fetchOpenApi
25
+ // helper forwards nothing so third-party gateways (Enso) skip a CORS preflight.
26
+ const CLIENT_HEADERS = { headers: { "X-Client-Id": getClientName() } };
27
+ const NO_HEADERS = { headers: undefined };
28
+
24
29
  // Mock the network layer so we can assert exactly what the helpers build and
25
30
  // pass through, without hitting a backend.
26
31
  const beraFetchJson = vi.fn();
@@ -49,11 +54,14 @@ describe("fetchOpenApi", () => {
49
54
  );
50
55
 
51
56
  expect(beraFetchJson).toHaveBeenCalledTimes(1);
52
- expect(beraFetchJson).toHaveBeenCalledWith({
53
- url: `${BASE}/v0/stake/${VAULT}/stats-by-day?days=30`,
54
- name: "Berachain Beep",
55
- type: "rest",
56
- });
57
+ expect(beraFetchJson).toHaveBeenCalledWith(
58
+ {
59
+ url: `${BASE}/v0/stake/${VAULT}/stats-by-day?days=30`,
60
+ name: "Berachain Beep",
61
+ type: "rest",
62
+ },
63
+ NO_HEADERS,
64
+ );
57
65
  });
58
66
 
59
67
  it("substitutes multiple path params and omits the query when absent", async () => {
@@ -64,11 +72,14 @@ describe("fetchOpenApi", () => {
64
72
  "beep",
65
73
  );
66
74
 
67
- expect(beraFetchJson).toHaveBeenCalledWith({
68
- url: `${BASE}/v0/stake/${VAULT}/earnings/${OWNER}`,
69
- name: "Berachain Beep",
70
- type: "rest",
71
- });
75
+ expect(beraFetchJson).toHaveBeenCalledWith(
76
+ {
77
+ url: `${BASE}/v0/stake/${VAULT}/earnings/${OWNER}`,
78
+ name: "Berachain Beep",
79
+ type: "rest",
80
+ },
81
+ NO_HEADERS,
82
+ );
72
83
  });
73
84
 
74
85
  it("omits query params whose value is undefined", async () => {
@@ -85,6 +96,7 @@ describe("fetchOpenApi", () => {
85
96
  expect.objectContaining({
86
97
  url: `${BASE}/v0/honey/transactions/latest?perPage=10`,
87
98
  }),
99
+ NO_HEADERS,
88
100
  );
89
101
  });
90
102
 
@@ -101,6 +113,7 @@ describe("fetchOpenApi", () => {
101
113
  expect.objectContaining({
102
114
  url: `${BASE}/v0/validators/a%2Fb%20c/incentives`,
103
115
  }),
116
+ NO_HEADERS,
104
117
  );
105
118
  });
106
119
 
@@ -114,6 +127,7 @@ describe("fetchOpenApi", () => {
114
127
 
115
128
  expect(beraFetchJson).toHaveBeenCalledWith(
116
129
  expect.objectContaining({ name: "beep" }),
130
+ NO_HEADERS,
117
131
  );
118
132
  });
119
133
 
@@ -166,6 +180,7 @@ describe("fetchBeep", () => {
166
180
  name: "Berachain Beep",
167
181
  type: "rest",
168
182
  }),
183
+ CLIENT_HEADERS,
169
184
  );
170
185
  });
171
186
  });
@@ -3,13 +3,14 @@ import { HttpLink } from "@apollo/client/link/http";
3
3
 
4
4
  import type { HttpLink as BeraConfigHttpLink } from "@berachain/config";
5
5
  import { getUriFromLink } from "@berachain/config";
6
- import { currentDapp, goldskyBaseUrl } from "@berachain/config/internal";
6
+ import { goldskyBaseUrl } from "@berachain/config/internal";
7
7
 
8
8
  import apiResults from "@berachain/graphql/dex/api";
9
9
 
10
10
  import { BeraError } from "../../errors/BeraError";
11
11
  import { parseBaseArgs } from "../../utils/parseBaseArgs";
12
12
  import { BeraApolloClient } from "./BeraApolloClient";
13
+ import { getClientName } from "./clientName";
13
14
 
14
15
  /**
15
16
  * If currentDapp is set, it will add the stellate client name and version to the headers.
@@ -17,8 +18,6 @@ import { BeraApolloClient } from "./BeraApolloClient";
17
18
  */
18
19
  function applyStellateClientName(url: BeraConfigHttpLink): BeraConfigHttpLink {
19
20
  const headers = typeof url === "string" ? undefined : url.headers;
20
- const isDapp = !!currentDapp;
21
- const isTest = process.env.VERCEL_ENV === "test";
22
21
 
23
22
  const uri = getUriFromLink(url);
24
23
  const name = typeof url === "string" ? "unknown" : url.name;
@@ -28,14 +27,7 @@ function applyStellateClientName(url: BeraConfigHttpLink): BeraConfigHttpLink {
28
27
  name,
29
28
  headers: {
30
29
  ...headers,
31
- "x-graphql-client-name": `berachain.${
32
- isDapp
33
- ? "dapps"
34
- : isTest
35
- ? "test"
36
- : // this tracks usage of the berajs package in other packages
37
- "berajs"
38
- }`,
30
+ "x-graphql-client-name": getClientName(),
39
31
  "x-graphql-client-version": `${process.env.VERCEL_TARGET_ENV}.${process.env.VERCEL_GIT_COMMIT_SHA}`,
40
32
  },
41
33
  };
@@ -1,11 +1,20 @@
1
1
  import { beforeEach, describe, expect, test } from "vitest";
2
2
 
3
- import { ChainId } from "@berachain/config/internal";
3
+ import { ChainId, chainConfigs } from "@berachain/config/internal";
4
4
 
5
5
  import { Aggregators } from "../../../enum/dex";
6
6
  import { BeraError } from "../../../errors/BeraError";
7
- import type { IAggregatorArgs, IRawAggregatorQuote } from "../../../types/dex";
7
+ import type {
8
+ IAggregatorArgs,
9
+ IRawAggregatorQuote,
10
+ MinimalERC20,
11
+ } from "../../../types/dex";
8
12
  import { BaseAggregator } from "../aggregators/base";
13
+ import { bex } from "../aggregators/bex";
14
+ import { enso } from "../aggregators/enso/enso";
15
+ import { ensoErc4626 } from "../aggregators/enso/ensoErc4626";
16
+ import { haiku } from "../aggregators/haiku";
17
+ import { wberaSwap } from "../aggregators/wbera";
9
18
 
10
19
  // Test implementation of BaseAggregator to access protected methods
11
20
  class TestAggregator extends BaseAggregator {
@@ -107,3 +116,223 @@ describe("BaseAggregator.getAmountAfterFees", () => {
107
116
  expect(result).toBe("996");
108
117
  });
109
118
  });
119
+
120
+ describe("BexAggregator.getUnsupportedReason opt-outs (HUB-A6D, HUB-A5R)", () => {
121
+ function token(
122
+ decimals: number,
123
+ address = "0x0000000000000000000000000000000000000001",
124
+ ): MinimalERC20 {
125
+ return {
126
+ address: address as `0x${string}`,
127
+ decimals,
128
+ symbol: "TKN",
129
+ name: "Token",
130
+ chainId: ChainId.MAINNET,
131
+ };
132
+ }
133
+
134
+ const bgt = token(18, chainConfigs[ChainId.MAINNET].tokens.bgt);
135
+ const tokenA = token(18, "0x0000000000000000000000000000000000000001");
136
+ const tokenB = token(6, "0x0000000000000000000000000000000000000002");
137
+
138
+ test("supports a normal 0–18 decimal pair", () => {
139
+ expect(
140
+ bex.getUnsupportedReason({ tokenIn: tokenA, tokenOut: tokenB }),
141
+ ).toBeNull();
142
+ });
143
+
144
+ // b-sdk's `TokenAmount` scales by `pow10[18 - decimals]`; a token with >18
145
+ // decimals (e.g. 27-decimal ctBeraUSDe) or non-integer decimals throws
146
+ // "Cannot mix BigInt and other types".
147
+ test("rejects a token with >18 decimals", () => {
148
+ const highDecimals = token(
149
+ 27,
150
+ "0x0000000000000000000000000000000000000003",
151
+ );
152
+ expect(
153
+ bex.getUnsupportedReason({ tokenIn: highDecimals, tokenOut: tokenB }),
154
+ ).not.toBeNull();
155
+ });
156
+
157
+ test("rejects a token with non-integer decimals", () => {
158
+ const nanDecimals = token(
159
+ Number.NaN,
160
+ "0x0000000000000000000000000000000000000004",
161
+ );
162
+ expect(
163
+ bex.getUnsupportedReason({ tokenIn: tokenA, tokenOut: nanDecimals }),
164
+ ).not.toBeNull();
165
+ });
166
+
167
+ // BGT has no Balancer pool (redeemed via the BGT aggregator), so a bex quote
168
+ // always throws NO_SWAP_PATHS — opt out whether it's in or out.
169
+ test("rejects BGT as tokenIn", () => {
170
+ expect(
171
+ bex.getUnsupportedReason({ tokenIn: bgt, tokenOut: token(18) }),
172
+ ).not.toBeNull();
173
+ });
174
+
175
+ test("rejects BGT as tokenOut", () => {
176
+ expect(
177
+ bex.getUnsupportedReason({ tokenIn: token(18), tokenOut: bgt }),
178
+ ).not.toBeNull();
179
+ });
180
+ });
181
+
182
+ describe("getUnsupportedReason BERA↔WBERA normalization (HUB-9FQ)", () => {
183
+ function token(address: string): MinimalERC20 {
184
+ return {
185
+ address: address as `0x${string}`,
186
+ decimals: 18,
187
+ symbol: "TKN",
188
+ name: "Token",
189
+ chainId: ChainId.MAINNET,
190
+ };
191
+ }
192
+
193
+ const bera = token("0x0000000000000000000000000000000000000000");
194
+ const wbera = token(chainConfigs[ChainId.MAINNET].tokens.wbera);
195
+ const honey = token(chainConfigs[ChainId.MAINNET].honey.token);
196
+
197
+ // Aggregators that normalize native BERA → WBERA collapse this pair to
198
+ // WBERA↔WBERA — the router 400s with "tokenIn and tokenOut cannot be the
199
+ // same". supportsBeraWrap is false for these, so the base gate rejects it.
200
+ test("rejects native BERA against WBERA for non-wrap aggregators", () => {
201
+ expect(
202
+ enso.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
203
+ ).not.toBeNull();
204
+ expect(
205
+ enso.getUnsupportedReason({ tokenIn: wbera, tokenOut: bera }),
206
+ ).not.toBeNull();
207
+ expect(
208
+ bex.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
209
+ ).not.toBeNull();
210
+ });
211
+
212
+ // The wrap/unwrap aggregator sets supportsBeraWrap, so it still accepts it.
213
+ test("keeps supporting BERA↔WBERA for the wrap aggregator", () => {
214
+ expect(
215
+ wberaSwap.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
216
+ ).toBeNull();
217
+ expect(
218
+ wberaSwap.getUnsupportedReason({ tokenIn: wbera, tokenOut: bera }),
219
+ ).toBeNull();
220
+ });
221
+
222
+ test("still supports a normal distinct pair", () => {
223
+ expect(
224
+ enso.getUnsupportedReason({ tokenIn: wbera, tokenOut: honey }),
225
+ ).toBeNull();
226
+ });
227
+
228
+ // getUnsupportedReason carries the reason; assertChainSupport used to throw a
229
+ // misleading "does not support chain ID" — it now surfaces the real reason.
230
+ test("carries an accurate BERA↔WBERA reason", () => {
231
+ expect(
232
+ enso.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
233
+ ).toMatch(/BERA and WBERA/);
234
+ expect(() =>
235
+ enso.assertChainSupport({ tokenIn: bera, tokenOut: wbera }),
236
+ ).toThrow(/BERA and WBERA/);
237
+ });
238
+ });
239
+
240
+ // Haiku's zap-haiku proxy key is restricted and 400s on reward-vault staking
241
+ // (HUB-9FN/HUB-9FR). Opt out up-front so the quote hook never fires the request.
242
+ describe("HaikuAggregator.getUnsupportedReason — reward-vault staking", () => {
243
+ function token(address: string): MinimalERC20 {
244
+ return {
245
+ address: address as `0x${string}`,
246
+ decimals: 18,
247
+ symbol: "TKN",
248
+ name: "Token",
249
+ chainId: ChainId.MAINNET,
250
+ };
251
+ }
252
+
253
+ const tokenA = token("0x0000000000000000000000000000000000000001");
254
+ const tokenB = token("0x0000000000000000000000000000000000000002");
255
+ const rewardVault = "0x0000000000000000000000000000000000000003" as const;
256
+
257
+ test("rejects a reward-vault zap", () => {
258
+ expect(
259
+ haiku.getUnsupportedReason({
260
+ tokenIn: tokenA,
261
+ tokenOut: tokenB,
262
+ rewardVault,
263
+ }),
264
+ ).not.toBeNull();
265
+ });
266
+
267
+ test("still supports a normal swap (no reward vault)", () => {
268
+ expect(
269
+ haiku.getUnsupportedReason({ tokenIn: tokenA, tokenOut: tokenB }),
270
+ ).toBeNull();
271
+ });
272
+ });
273
+
274
+ // A cross-chain pair (tokenIn.chainId !== tokenOut.chainId) is rejected up-front
275
+ // unless the aggregator sets supportsBridging, so the swap-page fan-out can be
276
+ // handed multichain pairs safely.
277
+ describe("getUnsupportedReason cross-chain routing", () => {
278
+ // supportedChains: null isolates the bridging gate from the chain-support gate.
279
+ class NonBridgingAggregator extends BaseAggregator {
280
+ name = Aggregators.Fly;
281
+ readonly type = "rest";
282
+ supportedChains = null;
283
+
284
+ async getQuote(_args: IAggregatorArgs): Promise<IRawAggregatorQuote> {
285
+ throw new Error("Not implemented for testing");
286
+ }
287
+ }
288
+ const singleChain = new NonBridgingAggregator();
289
+
290
+ function token(chainId: number, address: string): MinimalERC20 {
291
+ return {
292
+ address: address as `0x${string}`,
293
+ decimals: 18,
294
+ symbol: "TKN",
295
+ name: "Token",
296
+ chainId,
297
+ };
298
+ }
299
+
300
+ const beraToken = token(
301
+ ChainId.MAINNET,
302
+ "0x0000000000000000000000000000000000000001",
303
+ );
304
+ const foreignToken = token(
305
+ ChainId.BEPOLIA,
306
+ "0x0000000000000000000000000000000000000002",
307
+ );
308
+
309
+ test("rejects a cross-chain pair on a non-cross-chain aggregator", () => {
310
+ expect(
311
+ singleChain.getUnsupportedReason({
312
+ tokenIn: foreignToken,
313
+ tokenOut: beraToken,
314
+ }),
315
+ ).toMatch(/cannot route across chains/);
316
+ });
317
+
318
+ test("allows the same cross-chain pair on ensoErc4626", () => {
319
+ expect(
320
+ ensoErc4626.getUnsupportedReason({
321
+ tokenIn: foreignToken,
322
+ tokenOut: beraToken,
323
+ }),
324
+ ).toBeNull();
325
+ });
326
+
327
+ test("still allows a same-chain pair on a non-cross-chain aggregator", () => {
328
+ expect(
329
+ singleChain.getUnsupportedReason({
330
+ tokenIn: beraToken,
331
+ tokenOut: token(
332
+ ChainId.MAINNET,
333
+ "0x0000000000000000000000000000000000000003",
334
+ ),
335
+ }),
336
+ ).toBeNull();
337
+ });
338
+ });