@berachain/berajs 0.2.8-beta.9 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
  2. package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
  3. package/dist/{RequestError-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
  4. package/dist/abi/exports.mjs +4452 -2
  5. package/dist/actions/clients/exports.d.ts +2 -0
  6. package/dist/actions/clients/exports.mjs +12 -0
  7. package/dist/actions/exports.d.ts +104 -189
  8. package/dist/actions/exports.mjs +853 -2
  9. package/dist/actions/governance/exports.d.ts +140 -0
  10. package/dist/actions/governance/exports.mjs +226 -0
  11. package/dist/actions/server/exports.d.ts +13 -0
  12. package/dist/actions/server/exports.mjs +27 -0
  13. package/dist/chunk-3EARVV7K.mjs +414 -0
  14. package/dist/chunk-4Z4AK6SH.mjs +211 -0
  15. package/dist/chunk-75M6TF7M.mjs +25 -0
  16. package/dist/chunk-AFN4CVD3.mjs +326 -0
  17. package/dist/chunk-BGMRHTBQ.mjs +23 -0
  18. package/dist/chunk-CDFWPU2R.mjs +473 -0
  19. package/dist/chunk-CDK4YV3D.mjs +571 -0
  20. package/dist/chunk-DKMAIU74.mjs +62 -0
  21. package/dist/chunk-EXIUPSFN.mjs +86 -0
  22. package/dist/chunk-FFB5LFDW.mjs +35 -0
  23. package/dist/chunk-HQCOU6GY.mjs +243 -0
  24. package/dist/chunk-HSSJKHZ4.mjs +135 -0
  25. package/dist/chunk-J5I45WGQ.mjs +1769 -0
  26. package/dist/chunk-KQUMKB66.mjs +89 -0
  27. package/dist/chunk-NBYLMO2L.mjs +14 -0
  28. package/dist/chunk-NPBQLVL3.mjs +80 -0
  29. package/dist/chunk-O2NQFKJK.mjs +170 -0
  30. package/dist/chunk-QJIXTYTZ.mjs +4054 -0
  31. package/dist/chunk-SGIJVHZO.mjs +12 -0
  32. package/dist/chunk-SZ5C44L5.mjs +35 -0
  33. package/dist/chunk-WXXOISTU.mjs +96 -0
  34. package/dist/chunk-XIYN6AL6.mjs +160 -0
  35. package/dist/contexts/exports.d.ts +2 -2
  36. package/dist/contexts/exports.mjs +85 -2
  37. package/dist/enum/exports.d.ts +1 -1
  38. package/dist/enum/exports.mjs +46 -2
  39. package/dist/enum/governance/exports.d.ts +60 -0
  40. package/dist/enum/governance/exports.mjs +14 -0
  41. package/dist/errors/exports.d.ts +4 -3
  42. package/dist/errors/exports.mjs +48 -2
  43. package/dist/exports-BcUTGFUb.d.ts +40 -0
  44. package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
  45. package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
  46. package/dist/hooks/exports.d.ts +69 -211
  47. package/dist/hooks/exports.mjs +7434 -4
  48. package/dist/hooks/governance/exports.d.ts +181 -0
  49. package/dist/hooks/governance/exports.mjs +888 -0
  50. package/dist/pol.d-CqPA9K6m.d.ts +142 -0
  51. package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
  52. package/dist/types/exports.d.ts +9 -9
  53. package/dist/types/exports.mjs +0 -1
  54. package/dist/types/governance/exports.d.ts +109 -0
  55. package/dist/types/governance/exports.mjs +0 -0
  56. package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
  57. package/dist/utils/exports.d.ts +15 -6
  58. package/dist/utils/exports.mjs +825 -2
  59. package/package.json +49 -13
  60. package/src/actions/__test/transports.ts +61 -0
  61. package/src/actions/clients/exports.ts +4 -0
  62. package/src/actions/clients/getApolloClient.ts +58 -23
  63. package/src/actions/clients/getEnsoClient.ts +20 -9
  64. package/src/actions/dex/aggregators/enso/enso.ts +27 -17
  65. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
  66. package/src/actions/dex/aggregators/kyberswap.ts +18 -23
  67. package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
  68. package/src/actions/exports.ts +4 -9
  69. package/src/actions/governance/exports.ts +9 -0
  70. package/src/actions/governance/getAllProposals.ts +10 -65
  71. package/src/actions/governance/getProposalDetails.ts +6 -33
  72. package/src/actions/governance/getProposalVotes.ts +8 -15
  73. package/src/actions/honey/getChartData.ts +27 -21
  74. package/src/actions/honey/getHoney24hVolume.ts +19 -22
  75. package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
  76. package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
  77. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
  78. package/src/actions/pol/getEarnedStakedBeraVault.ts +7 -11
  79. package/src/actions/pol/getGlobalData.ts +1 -0
  80. package/src/actions/pol/getHeroEarnVaults.ts +62 -0
  81. package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
  82. package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
  83. package/src/actions/pol/getStakingDailyAssets.ts +7 -10
  84. package/src/actions/server/exports.ts +1 -0
  85. package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
  86. package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
  87. package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
  88. package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
  89. package/src/actions/validators/getValidatorAnalytics.ts +20 -21
  90. package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
  91. package/src/enum/contracts.ts +1 -0
  92. package/src/enum/exports.ts +0 -1
  93. package/src/enum/governance/exports.ts +1 -0
  94. package/src/errors/BeraError.ts +47 -7
  95. package/src/errors/BeraTracing.unit.test.ts +65 -0
  96. package/src/errors/RequestError.ts +13 -1
  97. package/src/errors/exports.ts +5 -0
  98. package/src/errors/getRevertReason.integration.test.ts +3 -3
  99. package/src/errors/spanStatus.ts +78 -0
  100. package/src/errors/spanStatus.unit.test.ts +62 -0
  101. package/src/hooks/dex/useCreatePool.ts +1 -88
  102. package/src/hooks/dex/useOnChainPoolData.ts +27 -2
  103. package/src/hooks/dex/usePriceImpact.ts +12 -5
  104. package/src/hooks/enso/useBendDemultiply.ts +9 -1
  105. package/src/hooks/enso/useBendMultiply.ts +9 -1
  106. package/src/hooks/enso/useBendZapSupply.ts +26 -7
  107. package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
  108. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
  109. package/src/hooks/exports.ts +2 -15
  110. package/src/hooks/governance/exports.ts +14 -0
  111. package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
  112. package/src/hooks/pol/useStakedAPR.ts +2 -2
  113. package/src/hooks/pol/useStakedSnapshots.ts +5 -9
  114. package/src/hooks/validators/useValidator.ts +2 -0
  115. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
  116. package/src/types/bribe-boost.d.ts +8 -0
  117. package/src/types/exports.ts +0 -1
  118. package/src/types/governance/exports.ts +1 -0
  119. package/src/utils/beraFetch.ts +9 -3
  120. package/src/utils/exports.ts +1 -0
  121. package/src/utils/getServerSideClient.ts +4 -2
  122. package/src/utils/sanitizeRpcUrl.ts +22 -0
  123. package/src/utils/tracedTransport.ts +35 -0
  124. package/dist/BeraError-_mQdkanr.d.ts +0 -94
  125. package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
  126. package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
  127. package/dist/RequestError-DSUzJ1Iy.d.cts +0 -144
  128. package/dist/abi/exports.cjs +0 -2
  129. package/dist/abi/exports.cjs.map +0 -1
  130. package/dist/abi/exports.d.cts +0 -6574
  131. package/dist/abi/exports.mjs.map +0 -1
  132. package/dist/actions/exports.cjs +0 -2
  133. package/dist/actions/exports.cjs.map +0 -1
  134. package/dist/actions/exports.d.cts +0 -1650
  135. package/dist/actions/exports.mjs.map +0 -1
  136. package/dist/chunk-45HIEVNI.cjs +0 -4
  137. package/dist/chunk-45HIEVNI.cjs.map +0 -1
  138. package/dist/chunk-47ILYVHC.mjs +0 -2
  139. package/dist/chunk-47ILYVHC.mjs.map +0 -1
  140. package/dist/chunk-575OK77P.mjs +0 -2
  141. package/dist/chunk-575OK77P.mjs.map +0 -1
  142. package/dist/chunk-5NVZG5N6.mjs +0 -2
  143. package/dist/chunk-5NVZG5N6.mjs.map +0 -1
  144. package/dist/chunk-6DIA6PXV.cjs +0 -2
  145. package/dist/chunk-6DIA6PXV.cjs.map +0 -1
  146. package/dist/chunk-6JJIZCVY.cjs +0 -2
  147. package/dist/chunk-6JJIZCVY.cjs.map +0 -1
  148. package/dist/chunk-7F72ZH4Q.mjs +0 -2
  149. package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
  150. package/dist/chunk-AUA42YIG.mjs +0 -4
  151. package/dist/chunk-AUA42YIG.mjs.map +0 -1
  152. package/dist/chunk-BC2WX6O6.cjs +0 -2
  153. package/dist/chunk-BC2WX6O6.cjs.map +0 -1
  154. package/dist/chunk-CJOZC5Z2.cjs +0 -2
  155. package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
  156. package/dist/chunk-D6L7LTA2.cjs +0 -2
  157. package/dist/chunk-D6L7LTA2.cjs.map +0 -1
  158. package/dist/chunk-DDEQFR3M.cjs +0 -2
  159. package/dist/chunk-DDEQFR3M.cjs.map +0 -1
  160. package/dist/chunk-GXV2JA36.mjs +0 -2
  161. package/dist/chunk-GXV2JA36.mjs.map +0 -1
  162. package/dist/chunk-ISYNEDET.mjs +0 -2
  163. package/dist/chunk-ISYNEDET.mjs.map +0 -1
  164. package/dist/chunk-JDDRTHFG.mjs +0 -2
  165. package/dist/chunk-JDDRTHFG.mjs.map +0 -1
  166. package/dist/chunk-JDZGYU5T.mjs +0 -2
  167. package/dist/chunk-JDZGYU5T.mjs.map +0 -1
  168. package/dist/chunk-LVOXBZMA.cjs +0 -2
  169. package/dist/chunk-LVOXBZMA.cjs.map +0 -1
  170. package/dist/chunk-MK5NS5B5.mjs +0 -2
  171. package/dist/chunk-MK5NS5B5.mjs.map +0 -1
  172. package/dist/chunk-NAXAZJJY.mjs +0 -2
  173. package/dist/chunk-NAXAZJJY.mjs.map +0 -1
  174. package/dist/chunk-NLVWRMGD.mjs +0 -2
  175. package/dist/chunk-NLVWRMGD.mjs.map +0 -1
  176. package/dist/chunk-OGBD5YOG.mjs +0 -2
  177. package/dist/chunk-OGBD5YOG.mjs.map +0 -1
  178. package/dist/chunk-OGJMSGB2.mjs +0 -2
  179. package/dist/chunk-OGJMSGB2.mjs.map +0 -1
  180. package/dist/chunk-OIYXOKTT.cjs +0 -2
  181. package/dist/chunk-OIYXOKTT.cjs.map +0 -1
  182. package/dist/chunk-OUD27MU7.cjs +0 -2
  183. package/dist/chunk-OUD27MU7.cjs.map +0 -1
  184. package/dist/chunk-PRLVZIKD.mjs +0 -2
  185. package/dist/chunk-PRLVZIKD.mjs.map +0 -1
  186. package/dist/chunk-Q2SNRLW3.cjs +0 -2
  187. package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
  188. package/dist/chunk-REWME3FY.cjs +0 -2
  189. package/dist/chunk-REWME3FY.cjs.map +0 -1
  190. package/dist/chunk-RJN36GBU.mjs +0 -2
  191. package/dist/chunk-RJN36GBU.mjs.map +0 -1
  192. package/dist/chunk-RWOICHRW.cjs +0 -2
  193. package/dist/chunk-RWOICHRW.cjs.map +0 -1
  194. package/dist/chunk-S4CDSVLK.cjs +0 -2
  195. package/dist/chunk-S4CDSVLK.cjs.map +0 -1
  196. package/dist/chunk-SFEULGSX.cjs +0 -2
  197. package/dist/chunk-SFEULGSX.cjs.map +0 -1
  198. package/dist/chunk-WBTS6KFG.mjs +0 -2
  199. package/dist/chunk-WBTS6KFG.mjs.map +0 -1
  200. package/dist/chunk-WRFDB3QJ.cjs +0 -2
  201. package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
  202. package/dist/chunk-XNJLSA6P.cjs +0 -2
  203. package/dist/chunk-XNJLSA6P.cjs.map +0 -1
  204. package/dist/contexts/exports.cjs +0 -2
  205. package/dist/contexts/exports.cjs.map +0 -1
  206. package/dist/contexts/exports.d.cts +0 -66
  207. package/dist/contexts/exports.mjs.map +0 -1
  208. package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
  209. package/dist/dex-C_BB0b0O.d.cts +0 -37
  210. package/dist/enum/exports.cjs +0 -2
  211. package/dist/enum/exports.cjs.map +0 -1
  212. package/dist/enum/exports.d.cts +0 -23
  213. package/dist/enum/exports.mjs.map +0 -1
  214. package/dist/errors/exports.cjs +0 -2
  215. package/dist/errors/exports.cjs.map +0 -1
  216. package/dist/errors/exports.d.cts +0 -327
  217. package/dist/errors/exports.mjs.map +0 -1
  218. package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
  219. package/dist/global.d-B7IeayVX.d.cts +0 -474
  220. package/dist/honey-CYm0RWf4.d.cts +0 -14
  221. package/dist/hooks/exports.cjs +0 -4
  222. package/dist/hooks/exports.cjs.map +0 -1
  223. package/dist/hooks/exports.d.cts +0 -1734
  224. package/dist/hooks/exports.mjs.map +0 -1
  225. package/dist/polling-BKnyavLI.d.cts +0 -8
  226. package/dist/txnEnum-7_o92X3N.d.ts +0 -164
  227. package/dist/types/exports.cjs +0 -1
  228. package/dist/types/exports.cjs.map +0 -1
  229. package/dist/types/exports.d.cts +0 -90
  230. package/dist/types/exports.mjs.map +0 -1
  231. package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
  232. package/dist/utils/exports.cjs +0 -2
  233. package/dist/utils/exports.cjs.map +0 -1
  234. package/dist/utils/exports.d.cts +0 -420
  235. package/dist/utils/exports.mjs.map +0 -1
  236. package/src/actions/dex/getIsTokenExploited.ts +0 -63
  237. package/src/hooks/dex/useExploitedTokens.ts +0 -57
@@ -1,2 +1,853 @@
1
- import{$ as rt,A as ve,Aa as Rt,B as De,Ba as Tt,C as Re,Ca as It,D as Te,Da as Mt,E as Ie,Ea as Vt,F as Me,Fa as Ot,G as Ve,Ga as Wt,H as Oe,I as We,J as Je,K as Ue,L as _e,M as He,N as Ee,O as Ge,P as $e,Q as Le,R as qe,S as ze,T as Xe,U as je,V as Ke,W as Ze,X as Qe,Y as Ye,Z as et,_ as tt,a as ae,aa as ot,b as R,ba as nt,c as T,ca as at,d as I,da as it,e as se,ea as st,f as me,fa as mt,g as de,ga as dt,h as ce,ha as ct,i as pe,ia as pt,j as ue,ja as ut,k as le,ka as lt,l as fe,la as yt,m as ge,ma as bt,n as ye,na as At,o as be,oa as xt,p as Ae,pa as ht,q as xe,qa as Ct,r as he,ra as Pt,s as Ce,sa as wt,t as Pe,ta as kt,u as we,ua as Bt,v as ke,va as Ft,w as Be,wa as Nt,x as Fe,xa as St,y as Ne,ya as vt,z as Se,za as Dt}from"../chunk-AUA42YIG.mjs";import"../chunk-NLVWRMGD.mjs";import{a as ie,b as ft,c as gt}from"../chunk-47ILYVHC.mjs";import"../chunk-NAXAZJJY.mjs";import"../chunk-OGJMSGB2.mjs";import"../chunk-RJN36GBU.mjs";import{b as h,c as l,d as C}from"../chunk-WBTS6KFG.mjs";import{a as u,d as A,l as P,q as w}from"../chunk-JDDRTHFG.mjs";import{a as d,e as x}from"../chunk-5NVZG5N6.mjs";import"../chunk-PRLVZIKD.mjs";import"../chunk-GXV2JA36.mjs";import{formatEther as M}from"viem";import{metaMorphoV11Abi as V}from"@berachain/abis/bend-metamorpho/metaMorphoV11";async function _t({vaultAddress:e,publicClient:t}){let r=await t.readContract({address:e,abi:V,functionName:"maxDeposit",args:[e]});return M(r)}import{mapPoolType as O}from"@berachain-foundation/berancer-sdk";var Gt=e=>({type:O(e.type),protocolVersion:e.protocolVersion,tokens:e.tokens.map(t=>({...t,address:t.address})),id:e.id,address:e.address});import{vaultAbi as W}from"@berachain/abis/bex/vault";async function zt({publicClient:e,...t}){let{config:r}=d(t);return(await e.readContract({address:r.bex.vault,abi:W,functionName:"getPausedState"}))[0]}import{decodeFunctionData as B,erc20Abi as J,pad as U,toFunctionSignature as _,trim as k}from"viem";import{appConfig as H,defaultChainId as E}from"@berachain/config/internal";import{beraChefAbi as G}from"@berachain/abis/pol/rewards/beraChef";import{rewardVaultAbi as $}from"@berachain/abis/pol/rewards/rewardVault";function L(e){return e.some(t=>{let r=t;return r.name==="implementation"||r.name==="proxyType"||r.type==="constructor"&&r.inputs?.[0]?.name==="implementation"})}async function F({contractAddress:e,chainId:t,publicClient:r}){let o=`https://api.etherscan.io/v2/api?module=contract&action=getabi&address=${e}&apikey=${H.apiKeys.private.etherscan}&chainId=${t}`,n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch ABI: ${n.statusText}`);let a=await n.json();if(a.status==="0")throw new Error(a.result);let m=JSON.parse(a.result);if(!L(m))return m;let i=await r.getStorageAt({address:e,slot:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"});if(!i||k(i)==="0x00")return m;let s=U(k(i),{size:20});return F({contractAddress:s,chainId:t,publicClient:r})}async function q({address:e,callData:t,knownAbi:r,chainId:o,publicClient:n}){try{if(B({data:t,abi:r}))return r}catch{}return F({contractAddress:e,chainId:o,publicClient:n}).catch(()=>{})}function z(e,t){try{return B({data:e,abi:t})}catch{return}}function X(e,t){return e.find(r=>r.type==="function"&&r.name===t)}function j(e){if(e)try{return _(e)}catch(t){console.error(t)}}async function Yt({address:e,callData:t,chainId:r=E,publicClient:o}){let n=[...G,...$,...J],a=await q({address:e,callData:t,knownAbi:n,chainId:r,publicClient:o}),m=z(t,a);if(!a||!m)return{args:[]};let i=X(a,m.functionName),s=j(i);return{abiItem:i,functionSignature:s,functionName:m.functionName,args:m.args}}import{formatUnits as g}from"viem";import{honeyFactoryAbi as b}from"@berachain/abis/honey/honeyFactory";async function nr({client:e,collateralList:t,...r}){let{config:o}=d(r);try{let n={mint:[],redeem:[]};for(let s of t)n.mint.push(e.readContract({address:o.honey.factory,abi:b,functionName:"mintRates",args:[s.address]})),n.redeem.push(e.readContract({address:o.honey.factory,abi:b,functionName:"redeemRates",args:[s.address]}));let[a,m,i]=await Promise.all([Promise.all(n.mint),Promise.all(n.redeem),e.readContract({address:o.honey.factory,abi:b,functionName:"getWeights"})]);return t.reduce((s,c)=>{let p=t.indexOf(c);return s.single[c.address]={mintFee:1-+g(a[p],18),redeemFee:1-+g(m[p],18)},s.basket.mintFee+=s.single[c.address].mintFee*+g(i[p],18),s.basket.redeemFee+=s.single[c.address].redeemFee*+g(i[p],18),s},{single:{},basket:{mintFee:0,redeemFee:0}})}catch(n){throw console.log(n),n}}import{honeyAbi as K}from"@berachain/abis/honey/honey";async function mr({client:e,...t}){let{config:r}=d(t),o=r.honey.token;return await e.readContract({address:o,abi:K,functionName:"paused"})}import{rootPriceOracleAbi as Z}from"@berachain/abis/extras/rootPriceOracle";async function pr({pythOracle:e,publicClient:t}){return t.readContract({address:e,abi:Z,functionName:"pythOracle"})}import{honeyFactoryAbi as Q}from"@berachain/abis/honey/honeyFactory";async function gr({publicClient:e,factory:t,...r}){let{config:o}=d(r);return e.readContract({address:t??o.honey.factory,abi:Q,functionName:"priceOracle"})}async function hr({defaultBlockTime:e,publicClient:t,blocksSpan:r,...o}){l(t);let{config:n}=d(o),a=e??n.averageBlockTime,m=r??Math.floor(w(1)/a),i=await t?.getBlock({blockTag:"latest"}),s=await t?.getBlock({blockNumber:i.number-BigInt(m)});return(P(Date.now())-Number(s?.timestamp))/(Number(i?.number)-Number(s?.number))}import{lstStakerVaultAbi as Y}from"@berachain/abis/pol/lst/lstStakerVault";async function Fr({tokenList:e,publicClient:t,lstStakingVaults:r,...o}){l(t);let{config:n}=d({...o,chainId:t.chain?.id??o.chainId}),a=e.filter(i=>r.includes(i.address));return a.length===0?[]:(await Promise.all(a.map(async i=>({assetTokenAddress:await t.readContract({address:i.address,abi:Y,functionName:"asset"}),stakingToken:i})))).reduce((i,{assetTokenAddress:s,stakingToken:c})=>{let p=e.find(y=>x(y,s));return p&&i.push({id:c.address,receiptToken:c,inputTokens:[p]}),i},[])}import{rewardVaultAbi as v}from"@berachain/abis/pol/rewards/rewardVault";import{rewardVaultFactoryAbi as ee}from"@berachain/abis/pol/rewards/rewardVaultFactory";var N=[{inputs:[{internalType:"address",name:"initialOwner",type:"address"},{internalType:"address",name:"initialImplementation",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"NewImplementationHasNoCode",type:"error"},{inputs:[],name:"NewOwnerIsZeroAddress",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{inputs:[],name:"implementation",outputs:[{internalType:"address",name:"result",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"result",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"}];async function S({publicClient:e,...t}){let{config:r}=d(t),o=r.pol.factory;h(e,"publicClient"),C(r.pol.factory,"factoryAddress");let n=await e.readContract({address:o,abi:ee,functionName:"beacon"});return e.readContract({address:n,abi:N,functionName:"implementation"})}async function Wr({publicClient:e,...t}){l(e);let r=await S({publicClient:e,...t}),[o,n]=await Promise.all([e.readContract({address:r,abi:v,functionName:"MIN_REWARD_DURATION"}),e.readContract({address:r,abi:v,functionName:"MAX_REWARD_DURATION"})]);return{minRewardDuration:Number(o),maxRewardDuration:Number(n)}}import{zeroAddress as te}from"viem";import{rewardVaultFactoryAbi as re}from"@berachain/abis/pol/rewards/rewardVaultFactory";async function Er({tokenAddress:e,publicClient:t,factoryAddress:r,...o}){let{config:n}=d(o),a=await t.readContract({address:r??n.pol.factory,abi:re,functionName:"getVault",args:[e]});return a===te?null:a}import{pythPriceOracleAbi as oe}from"@berachain/abis/extras/pythPriceOracle";async function qr({tokenList:e,publicClient:t,...r}){let{config:o}=d(r);try{let n=await Promise.all(e.map(a=>t.readContract({address:o.honey.pythOracle,abi:oe,functionName:"feeds",args:[a]})));return e.reduce((a,m,i)=>({...a,[m]:n[i]}),{})}catch(n){throw console.error("getPythPriceFeedId",n),n}}async function Kr({url:e,...t}={}){let{config:r}=d(t);return(await A({url:e??r.lists.tokenList,type:"rest",name:"GitHub"})).tokens??[]}import{bgtAbi as D}from"@berachain/abis/pol/bgt";import{beraChefAbi as f}from"@berachain/abis/pol/rewards/beraChef";async function to({publicClient:e,ui:t,...r}){let{config:o}=d(r),[n,a,m,i,s,c,p,y]=await Promise.all([e.readContract({address:o.pol.beraChef,abi:f,functionName:"MAX_COMMISSION_RATE"}),e.readContract({address:o.pol.beraChef,abi:f,functionName:"commissionChangeDelay"}),e.readContract({address:o.pol.beraChef,abi:f,functionName:"rewardAllocationBlockDelay"}),e.readContract({address:o.pol.beraChef,abi:f,functionName:"maxWeightPerVault"}),e.readContract({address:o.pol.beraChef,abi:f,functionName:"maxNumWeightsPerRewardAllocation"}),e.readContract({address:o.tokens.bgt,abi:D,functionName:"dropBoostDelay"}),e.readContract({address:o.tokens.bgt,abi:D,functionName:"activateBoostDelay"}),e.readContract({address:o.pol.beraChef,abi:f,functionName:"rewardAllocationInactivityBlockSpan"})]);return{maxCommissionRate:Number(n)/1e4,boostDelay:Number(p),unboostDelay:Number(c),commissionChangeDelay:Number(a),rewardAllocationBlockDelay:Number(m),maxWeightPerVault:Number(i)/1e4,maxNumWeightsPerRewardAllocation:Number(s),rewardAllocationInactivityBlockSpan:Number(y),ui:t}}function no({rewardAllocationWeights:e,activeOnly:t=!0}){let r=e.filter(o=>o?.receivingVault).reduce((o,n)=>{for(let a of n.receivingVault?.activeIncentives??[]){if(t&&a.remainingAmount==="0")continue;let m=new u(a.incentiveRate).times(n.percentage),i=new u(a.incentiveRateUsd).times(n.percentage),s=a.token.address.toLowerCase(),c=o.get(s);c?o.set(s,{...c,incentiveRate:new u(c.incentiveRate).plus(m).toString(),incentiveRateUsd:new u(c.incentiveRateUsd).plus(i).toString(),remainingAmount:new u(c.remainingAmount).plus(a.remainingAmount).toString(),remainingAmountUsd:new u(c.remainingAmountUsd).plus(a.remainingAmountUsd).toString()}):o.set(s,{...a,tokenAddress:a.token.address,token:a.token,incentiveRate:m.toString(),incentiveRateUsd:i.toString(),remainingAmount:a.remainingAmount})}return o},new Map);return Array.from(r.values())}function ne(e){return e?.rewardAllocationWeights?.reduce((t,r)=>{if(!r)return t;let o=r.receivingVault?.activeIncentives.filter(n=>Number(n.remainingAmount)>0).reduce((n,a)=>{let m=Number(a.remainingAmountUsd)/Number(a.remainingAmount);return n+Number(a.incentiveRate)*m},0)??0;return t+o*r.percentage},0)}function io({validator:e,bgtPrice:t}){let r=Number(e.dynamicData?.activeBoostAmount??0),o=ne(e);return!o||!r?0:o*Number(e.dynamicData?.lastDayDistributedBGTAmount??0)*365/(r*t)}export{me as BalancerApi,se as BaseAggregator,R as BeraApolloClient,Te as HoneyPreviewMethod,be as MOCKED_PROPOSAL_STATUSES,He as RewardVaultDistributionMode,no as aggregateValidatorIncentives,bt as beraWriteContract,ye as checkProposalField,Ae as computeActualStatus,Pt as formatValidatorRewardAllocation,to as getActiveBoostAndCommissionChangeDelay,de as getAllPools,xe as getAllProposals,At as getAllValidators,lt as getAllowances,xt as getApiEnrichedAllocation,ce as getApiPool,ht as getApiValidator,T as getApolloClient,ft as getBalanceCall,Ge as getBgtAprSimulation,hr as getBlockTime,_e as getBlockTimestamp,he as getBodyErrors,Be as getChartData,Fe as getCollateralWeights,ae as getConvertToAssets,Ct as getDailyValidatorBlockStats,Yt as getDecodedFunctionData,Ft as getDefaultRewardAllocation,$e as getEarnedStakedBeraVault,ie as getEnsoClient,De as getGlobalCapLimit,qe as getGlobalData,pe as getGlobalLiquidityAndSwapVolume,Re as getHoney24hVolume,Se as getHoneyCollaterals,nr as getHoneyFees,mr as getHoneyPausedState,Ie as getHoneyPreview,qr as getHoneyPythFeeds,pr as getHoneyPythOracle,gr as getHoneyRootPriceOracle,Me as getHoneyVaultsBalance,ze as getIncentiveFeeClaimStats,Fr as getLSTStakeConfig,Xe as getMarkets,_t as getMaxDeposit,le as getOnChainPool,fe as getPoolEvents,ge as getPoolHistoricalData,ue as getPoolPausedState,Gt as getPoolState,Ce as getProposalDetails,we as getProposalFromTx,ke as getProposalVotes,Ve as getPythLatestPrices,We as getPythUpdateFee,Oe as getRelativeCapLimit,je as getRewardProofsByValidator,Ke as getRewardTokenToBeraRate,Ze as getRewardVault,Wr as getRewardVaultDurationConstants,Er as getRewardVaultFromToken,Qe as getRewardVaultIncentives,Ee as getRewardVaultRewards,Ye as getRewardVaultStakingToken,Le as getRewardVaults,ot as getSWBeraVaultMetadata,nt as getSWBeraWithdrawal,rt as getStakeWithdrawalCooldown,et as getStakedBeraAPR,tt as getStakedBeraSnapshots,Nt as getStakingPoolBatch,Je as getSwapPayload,ut as getTokenCurrentPrices,Ne as getTokenInformation,Kr as getTokens,at as getTotalStakedAmount,vt as getUserActiveValidators,St as getUserBoostsOnValidator,it as getUserClaimableIncentives,Dt as getUserStakingPositions,mt as getUserVaultInfo,dt as getUserVaults,st as getUserVaultsReward,Rt as getValidatorAnalytics,io as getValidatorBoostApy,Tt as getValidatorCommission,It as getValidatorEstimatedBgtPerYear,Mt as getValidatorOperatorAddress,Vt as getValidatorQueuedCommission,Ot as getValidatorQueuedOperatorAddress,Wt as getValidatorQueuedRewardAllocation,ne as getValidatorReturnPerBgt,kt as getValidatorRewardAllocation,ct as getVaultHistory,zt as getVaultPausedState,pt as getVaultValidators,gt as getWalletBalances,I as gql,ve as isBadCollateralAsset,Ue as isBasketModeEnabled,Bt as isDefaultRewardAllocation,yt as isImpersonateAccount,wt as isSameRewardAllocation,Pe as parseProposalBody};
2
- //# sourceMappingURL=exports.mjs.map
1
+ import {
2
+ BalancerApi,
3
+ BaseAggregator,
4
+ HoneyPreviewMethod,
5
+ RewardVaultDistributionMode,
6
+ beraWriteContract,
7
+ formatValidatorRewardAllocation,
8
+ getAllPools,
9
+ getAllValidators,
10
+ getAllowances,
11
+ getApiEnrichedAllocation,
12
+ getApiPool,
13
+ getApiValidator,
14
+ getAutoclaimedIncentives,
15
+ getBgtAprSimulation,
16
+ getBlockTimestamp,
17
+ getChartData,
18
+ getCollateralWeights,
19
+ getConvertToAssets,
20
+ getDailyValidatorBlockStats,
21
+ getDefaultRewardAllocation,
22
+ getEarnedStakedBeraVault,
23
+ getGlobalCapLimit,
24
+ getGlobalData,
25
+ getGlobalLiquidityAndSwapVolume,
26
+ getHoney24hVolume,
27
+ getHoneyCollaterals,
28
+ getHoneyPreview,
29
+ getHoneyVaultsBalance,
30
+ getIncentiveFeeClaimStats,
31
+ getMarkets,
32
+ getOnChainPool,
33
+ getPoolEvents,
34
+ getPoolHistoricalData,
35
+ getPoolPausedState,
36
+ getPythLatestPrices,
37
+ getPythUpdateFee,
38
+ getRelativeCapLimit,
39
+ getRewardProofsByValidator,
40
+ getRewardTokenToBeraRate,
41
+ getRewardVault,
42
+ getRewardVaultIncentives,
43
+ getRewardVaultRewards,
44
+ getRewardVaultStakingToken,
45
+ getRewardVaults,
46
+ getSWBeraVaultMetadata,
47
+ getSWBeraWithdrawal,
48
+ getStakeWithdrawalCooldown,
49
+ getStakedBeraAPR,
50
+ getStakedBeraSnapshots,
51
+ getStakingPoolBatch,
52
+ getSwapPayload,
53
+ getTokenCurrentPrices,
54
+ getTokenInformation,
55
+ getTotalStakedAmount,
56
+ getUserActiveValidators,
57
+ getUserBoostsOnValidator,
58
+ getUserClaimableIncentives,
59
+ getUserStakingPositions,
60
+ getUserVaultInfo,
61
+ getUserVaults,
62
+ getUserVaultsReward,
63
+ getValidatorAnalytics,
64
+ getValidatorCommission,
65
+ getValidatorEstimatedBgtPerYear,
66
+ getValidatorOperatorAddress,
67
+ getValidatorQueuedCommission,
68
+ getValidatorQueuedOperatorAddress,
69
+ getValidatorQueuedRewardAllocation,
70
+ getValidatorRewardAllocation,
71
+ getVaultHistory,
72
+ getVaultValidators,
73
+ isBadCollateralAsset,
74
+ isBasketModeEnabled,
75
+ isDefaultRewardAllocation,
76
+ isImpersonateAccount,
77
+ isSameRewardAllocation
78
+ } from "../chunk-QJIXTYTZ.mjs";
79
+ import {
80
+ BeraApolloClient,
81
+ getApolloClient,
82
+ gql
83
+ } from "../chunk-4Z4AK6SH.mjs";
84
+ import "../chunk-CDK4YV3D.mjs";
85
+ import {
86
+ getBalanceCall,
87
+ getEnsoClient,
88
+ getWalletBalances
89
+ } from "../chunk-HSSJKHZ4.mjs";
90
+ import "../chunk-HQCOU6GY.mjs";
91
+ import "../chunk-WXXOISTU.mjs";
92
+ import "../chunk-EXIUPSFN.mjs";
93
+ import {
94
+ assertAddress,
95
+ assertDefined,
96
+ assertPublicClient
97
+ } from "../chunk-KQUMKB66.mjs";
98
+ import {
99
+ beraFetchJson,
100
+ bignumber_js_default,
101
+ hoursInSeconds,
102
+ msToSeconds
103
+ } from "../chunk-CDFWPU2R.mjs";
104
+ import {
105
+ isToken
106
+ } from "../chunk-NPBQLVL3.mjs";
107
+ import {
108
+ parseBaseArgs
109
+ } from "../chunk-75M6TF7M.mjs";
110
+ import "../chunk-SZ5C44L5.mjs";
111
+ import "../chunk-XIYN6AL6.mjs";
112
+ import "../chunk-J5I45WGQ.mjs";
113
+
114
+ // src/actions/bend/getMaxDeposit.ts
115
+ import { formatEther } from "viem";
116
+ import { metaMorphoV11Abi as metaMorphoAbi } from "@berachain/abis/bend-metamorpho/metaMorphoV11";
117
+ async function getMaxDeposit({
118
+ vaultAddress,
119
+ publicClient
120
+ }) {
121
+ const maxDeposit = await publicClient.readContract({
122
+ address: vaultAddress,
123
+ abi: metaMorphoAbi,
124
+ functionName: "maxDeposit",
125
+ args: [vaultAddress]
126
+ });
127
+ return formatEther(maxDeposit);
128
+ }
129
+
130
+ // src/actions/dex/getPoolWithState.ts
131
+ import {
132
+ mapPoolType
133
+ } from "@berachain-foundation/berancer-sdk";
134
+ var getPoolState = (apiPool) => {
135
+ return {
136
+ type: mapPoolType(apiPool.type),
137
+ protocolVersion: apiPool.protocolVersion,
138
+ tokens: apiPool.tokens.map(
139
+ (pt) => ({
140
+ ...pt,
141
+ address: pt.address
142
+ })
143
+ ),
144
+ id: apiPool.id,
145
+ address: apiPool.address
146
+ };
147
+ };
148
+
149
+ // src/actions/dex/getVaultPausedState.ts
150
+ import { vaultAbi as balancerVaultAbi } from "@berachain/abis/bex/vault";
151
+ async function getVaultPausedState({
152
+ publicClient,
153
+ ...args
154
+ }) {
155
+ const { config } = parseBaseArgs(args);
156
+ const vaultPausedState = await publicClient.readContract({
157
+ address: config.bex.vault,
158
+ abi: balancerVaultAbi,
159
+ functionName: "getPausedState"
160
+ });
161
+ return vaultPausedState[0];
162
+ }
163
+
164
+ // src/actions/honey/getHoneyFees.ts
165
+ import { formatUnits } from "viem";
166
+ import { honeyFactoryAbi } from "@berachain/abis/honey/honeyFactory";
167
+ async function getHoneyFees({
168
+ client,
169
+ collateralList,
170
+ ...args
171
+ }) {
172
+ const { config } = parseBaseArgs(args);
173
+ try {
174
+ const promiseList = {
175
+ mint: [],
176
+ redeem: []
177
+ };
178
+ for (const coll of collateralList) {
179
+ promiseList.mint.push(
180
+ client.readContract({
181
+ address: config.honey.factory,
182
+ abi: honeyFactoryAbi,
183
+ functionName: "mintRates",
184
+ args: [coll.address]
185
+ })
186
+ );
187
+ promiseList.redeem.push(
188
+ client.readContract({
189
+ address: config.honey.factory,
190
+ abi: honeyFactoryAbi,
191
+ functionName: "redeemRates",
192
+ args: [coll.address]
193
+ })
194
+ );
195
+ }
196
+ const [mintRates, redeemRates, collateralWeights] = await Promise.all([
197
+ Promise.all(promiseList.mint),
198
+ Promise.all(promiseList.redeem),
199
+ // fetch the collateral weights, needed to calculate the weighted basket rates
200
+ client.readContract({
201
+ address: config.honey.factory,
202
+ abi: honeyFactoryAbi,
203
+ functionName: "getWeights"
204
+ })
205
+ ]);
206
+ return collateralList.reduce(
207
+ (acc, coll) => {
208
+ const collIdx = collateralList.indexOf(coll);
209
+ acc.single[coll.address] = {
210
+ mintFee: 1 - +formatUnits(mintRates[collIdx], 18),
211
+ redeemFee: 1 - +formatUnits(redeemRates[collIdx], 18)
212
+ };
213
+ acc.basket.mintFee += acc.single[coll.address].mintFee * +formatUnits(collateralWeights[collIdx], 18);
214
+ acc.basket.redeemFee += acc.single[coll.address].redeemFee * +formatUnits(collateralWeights[collIdx], 18);
215
+ return acc;
216
+ },
217
+ {
218
+ single: {},
219
+ basket: { mintFee: 0, redeemFee: 0 }
220
+ }
221
+ );
222
+ } catch (e) {
223
+ console.log(e);
224
+ throw e;
225
+ }
226
+ }
227
+
228
+ // src/actions/honey/getHoneyPausedState.ts
229
+ import { honeyAbi } from "@berachain/abis/honey/honey";
230
+ async function getHoneyPausedState({
231
+ client,
232
+ ...args
233
+ }) {
234
+ const { config } = parseBaseArgs(args);
235
+ const honeyAddress = config.honey.token;
236
+ const honeyPausedState = await client.readContract({
237
+ address: honeyAddress,
238
+ abi: honeyAbi,
239
+ functionName: "paused"
240
+ });
241
+ return honeyPausedState;
242
+ }
243
+
244
+ // src/actions/honey/getHoneyPythPriceOracle.ts
245
+ import { rootPriceOracleAbi as honeyRootOracleAbi } from "@berachain/abis/extras/rootPriceOracle";
246
+ async function getHoneyPythOracle({
247
+ pythOracle,
248
+ publicClient
249
+ }) {
250
+ return publicClient.readContract({
251
+ address: pythOracle,
252
+ abi: honeyRootOracleAbi,
253
+ functionName: "pythOracle"
254
+ });
255
+ }
256
+
257
+ // src/actions/honey/getHoneyRootPriceOracle.ts
258
+ import { honeyFactoryAbi as honeyFactoryAbi2 } from "@berachain/abis/honey/honeyFactory";
259
+ async function getHoneyRootPriceOracle({
260
+ publicClient,
261
+ factory,
262
+ ...args
263
+ }) {
264
+ const { config } = parseBaseArgs(args);
265
+ return publicClient.readContract({
266
+ address: factory ?? config.honey.factory,
267
+ abi: honeyFactoryAbi2,
268
+ functionName: "priceOracle"
269
+ });
270
+ }
271
+
272
+ // src/actions/pol/getBeraTokenTotalSupply.ts
273
+ import { ChainId } from "@berachain/config";
274
+ async function getBeraTokenTotalSupply(args = {}) {
275
+ const { config } = parseBaseArgs(args);
276
+ const network = config.chainId === ChainId.MAINNET ? "mainnet" : "bepolia";
277
+ const supplyMonitor = config.pol.supplyMonitor;
278
+ const baseUrl = typeof supplyMonitor === "string" ? supplyMonitor : supplyMonitor.uri;
279
+ const data = await beraFetchJson(
280
+ {
281
+ url: `${baseUrl}/api/stats/bera?network=${network}`,
282
+ name: typeof supplyMonitor === "string" ? "supply-monitor-bera" : supplyMonitor.name,
283
+ type: "rest"
284
+ },
285
+ { cache: "no-store" }
286
+ );
287
+ return data.totalSupply.toString();
288
+ }
289
+
290
+ // src/actions/pol/getBgtIncentiveDistributorPaused.ts
291
+ import { bgtIncentiveDistributorAbi } from "@berachain/abis/pol/rewards/bgtIncentiveDistributor";
292
+ async function getBgtIncentiveDistributorPaused({
293
+ publicClient,
294
+ ...args
295
+ }) {
296
+ assertPublicClient(publicClient);
297
+ const { config } = parseBaseArgs(args);
298
+ try {
299
+ const paused = await publicClient.readContract({
300
+ address: config.pol.bgtIncentiveDistributor,
301
+ abi: bgtIncentiveDistributorAbi,
302
+ functionName: "paused"
303
+ });
304
+ return paused;
305
+ } catch {
306
+ return false;
307
+ }
308
+ }
309
+
310
+ // src/actions/pol/getBlockTime.ts
311
+ async function getBlockTime({
312
+ defaultBlockTime,
313
+ publicClient,
314
+ blocksSpan,
315
+ ...args
316
+ }) {
317
+ assertPublicClient(publicClient);
318
+ const { config } = parseBaseArgs(args);
319
+ const blockTime = defaultBlockTime ?? config.averageBlockTime;
320
+ const span = blocksSpan ?? Math.floor(hoursInSeconds(1) / blockTime);
321
+ const currentBlock = await publicClient?.getBlock({ blockTag: "latest" });
322
+ const oldestBlock = await publicClient?.getBlock({
323
+ blockNumber: currentBlock.number - BigInt(span)
324
+ });
325
+ return (
326
+ // we need to use current timestamp as the latest block might not have been minted (chain halted)
327
+ (msToSeconds(Date.now()) - Number(oldestBlock?.timestamp)) / (Number(currentBlock?.number) - Number(oldestBlock?.number))
328
+ );
329
+ }
330
+
331
+ // src/actions/pol/getHeroEarnVaults.ts
332
+ import {
333
+ GetHeroEarnVaults
334
+ } from "@berachain/graphql/pol/api";
335
+ async function getHeroEarnVaults({
336
+ bestAprExcludedAddresses = [],
337
+ ...args
338
+ } = {}) {
339
+ const bexApiGraphqlClient = getApolloClient("api", args);
340
+ const res = await bexApiGraphqlClient.query({
341
+ query: GetHeroEarnVaults,
342
+ variables: { bestAprExcludedAddresses }
343
+ });
344
+ return {
345
+ bestApr: res.data.bestApr.vaults,
346
+ bendRewardVault: res.data.bendRewardVault.vaults,
347
+ bendVaults: res.data.bendVaults
348
+ };
349
+ }
350
+
351
+ // src/actions/pol/getLSTStakeConfig.ts
352
+ import { lstStakerVaultAbi } from "@berachain/abis/pol/lst/lstStakerVault";
353
+ async function getLSTStakeConfig({
354
+ tokenList,
355
+ publicClient,
356
+ lstStakingVaults,
357
+ ...args
358
+ }) {
359
+ assertPublicClient(publicClient);
360
+ const { config } = parseBaseArgs({
361
+ ...args,
362
+ chainId: publicClient.chain?.id ?? args.chainId
363
+ });
364
+ const lstStakingTokens = tokenList.filter(
365
+ (token) => lstStakingVaults.includes(token.address)
366
+ );
367
+ if (lstStakingTokens.length === 0) {
368
+ return [];
369
+ }
370
+ const assets = await Promise.all(
371
+ lstStakingTokens.map(async (stakingToken) => {
372
+ const assetTokenAddress = await publicClient.readContract({
373
+ address: stakingToken.address,
374
+ abi: lstStakerVaultAbi,
375
+ functionName: "asset"
376
+ });
377
+ return { assetTokenAddress, stakingToken };
378
+ })
379
+ );
380
+ return assets.reduce(
381
+ (acc, { assetTokenAddress, stakingToken }) => {
382
+ const assetToken = tokenList.find(
383
+ (token) => isToken(token, assetTokenAddress)
384
+ );
385
+ if (!assetToken) return acc;
386
+ acc.push({
387
+ id: stakingToken.address,
388
+ receiptToken: stakingToken,
389
+ inputTokens: [assetToken]
390
+ });
391
+ return acc;
392
+ },
393
+ []
394
+ );
395
+ }
396
+
397
+ // src/actions/pol/getRewardVaultDurationConstants.ts
398
+ import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
399
+
400
+ // src/actions/pol/getRewardVaultBeaconImplementation.ts
401
+ import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
402
+
403
+ // src/abi/utils/upgradableBeacon.ts
404
+ var upgradableBeaconAbi = [
405
+ {
406
+ inputs: [
407
+ { internalType: "address", name: "initialOwner", type: "address" },
408
+ {
409
+ internalType: "address",
410
+ name: "initialImplementation",
411
+ type: "address"
412
+ }
413
+ ],
414
+ stateMutability: "payable",
415
+ type: "constructor"
416
+ },
417
+ { inputs: [], name: "NewImplementationHasNoCode", type: "error" },
418
+ { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" },
419
+ { inputs: [], name: "Unauthorized", type: "error" },
420
+ {
421
+ anonymous: false,
422
+ inputs: [
423
+ {
424
+ indexed: true,
425
+ internalType: "address",
426
+ name: "oldOwner",
427
+ type: "address"
428
+ },
429
+ {
430
+ indexed: true,
431
+ internalType: "address",
432
+ name: "newOwner",
433
+ type: "address"
434
+ }
435
+ ],
436
+ name: "OwnershipTransferred",
437
+ type: "event"
438
+ },
439
+ {
440
+ anonymous: false,
441
+ inputs: [
442
+ {
443
+ indexed: true,
444
+ internalType: "address",
445
+ name: "implementation",
446
+ type: "address"
447
+ }
448
+ ],
449
+ name: "Upgraded",
450
+ type: "event"
451
+ },
452
+ {
453
+ inputs: [],
454
+ name: "implementation",
455
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
456
+ stateMutability: "view",
457
+ type: "function"
458
+ },
459
+ {
460
+ inputs: [],
461
+ name: "owner",
462
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
463
+ stateMutability: "view",
464
+ type: "function"
465
+ },
466
+ {
467
+ inputs: [],
468
+ name: "renounceOwnership",
469
+ outputs: [],
470
+ stateMutability: "nonpayable",
471
+ type: "function"
472
+ },
473
+ {
474
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
475
+ name: "transferOwnership",
476
+ outputs: [],
477
+ stateMutability: "nonpayable",
478
+ type: "function"
479
+ },
480
+ {
481
+ inputs: [
482
+ { internalType: "address", name: "newImplementation", type: "address" }
483
+ ],
484
+ name: "upgradeTo",
485
+ outputs: [],
486
+ stateMutability: "nonpayable",
487
+ type: "function"
488
+ }
489
+ ];
490
+
491
+ // src/actions/pol/getRewardVaultBeaconImplementation.ts
492
+ async function getRewardVaultBeaconImplementation({
493
+ publicClient,
494
+ ...args
495
+ }) {
496
+ const { config } = parseBaseArgs(args);
497
+ const factoryAddress = config.pol.factory;
498
+ assertDefined(publicClient, "publicClient");
499
+ assertAddress(config.pol.factory, "factoryAddress");
500
+ const beacon = await publicClient.readContract({
501
+ address: factoryAddress,
502
+ abi: rewardVaultFactoryAbi,
503
+ functionName: "beacon"
504
+ });
505
+ return publicClient.readContract({
506
+ address: beacon,
507
+ abi: upgradableBeaconAbi,
508
+ functionName: "implementation"
509
+ });
510
+ }
511
+
512
+ // src/actions/pol/getRewardVaultDurationConstants.ts
513
+ async function getRewardVaultDurationConstants({
514
+ publicClient,
515
+ ...baseArgs
516
+ }) {
517
+ assertPublicClient(publicClient);
518
+ const beaconImplementation = await getRewardVaultBeaconImplementation({
519
+ publicClient,
520
+ ...baseArgs
521
+ });
522
+ const [minRewardDuration, maxRewardDuration] = await Promise.all([
523
+ publicClient.readContract({
524
+ address: beaconImplementation,
525
+ abi: rewardVaultAbi,
526
+ functionName: "MIN_REWARD_DURATION"
527
+ }),
528
+ publicClient.readContract({
529
+ address: beaconImplementation,
530
+ abi: rewardVaultAbi,
531
+ functionName: "MAX_REWARD_DURATION"
532
+ })
533
+ ]);
534
+ return {
535
+ minRewardDuration: Number(minRewardDuration),
536
+ maxRewardDuration: Number(maxRewardDuration)
537
+ };
538
+ }
539
+
540
+ // src/actions/pol/getRewardVaultFromToken.ts
541
+ import { zeroAddress } from "viem";
542
+ import { rewardVaultFactoryAbi as rewardVaultFactoryAbi2 } from "@berachain/abis/pol/rewards/rewardVaultFactory";
543
+ async function getRewardVaultFromToken({
544
+ tokenAddress,
545
+ publicClient,
546
+ factoryAddress,
547
+ ...args
548
+ }) {
549
+ const { config } = parseBaseArgs(args);
550
+ const vaultAddress = await publicClient.readContract({
551
+ address: factoryAddress ?? config.pol.factory,
552
+ abi: rewardVaultFactoryAbi2,
553
+ functionName: "getVault",
554
+ args: [tokenAddress]
555
+ });
556
+ if (vaultAddress === zeroAddress) {
557
+ return null;
558
+ }
559
+ return vaultAddress;
560
+ }
561
+
562
+ // src/actions/pyth/getHoneyPythFeeds.ts
563
+ import { pythPriceOracleAbi } from "@berachain/abis/extras/pythPriceOracle";
564
+ async function getHoneyPythFeeds({
565
+ tokenList,
566
+ publicClient,
567
+ ...args
568
+ }) {
569
+ const { config } = parseBaseArgs(args);
570
+ try {
571
+ const priceFeedIds = await Promise.all(
572
+ tokenList.map(
573
+ (token) => publicClient.readContract({
574
+ address: config.honey.pythOracle,
575
+ abi: pythPriceOracleAbi,
576
+ functionName: "feeds",
577
+ args: [token]
578
+ })
579
+ )
580
+ );
581
+ return tokenList.reduce(
582
+ (acc, token, index) => ({
583
+ ...acc,
584
+ [token]: priceFeedIds[index]
585
+ }),
586
+ {}
587
+ );
588
+ } catch (e) {
589
+ console.error("getPythPriceFeedId", e);
590
+ throw e;
591
+ }
592
+ }
593
+
594
+ // src/actions/tokens/getTokens.ts
595
+ async function getTokens({
596
+ url,
597
+ ...args
598
+ } = {}) {
599
+ const { config } = parseBaseArgs(args);
600
+ const tokenList = await beraFetchJson({
601
+ url: url ?? config.lists.tokenList,
602
+ type: "rest",
603
+ name: "GitHub"
604
+ });
605
+ return tokenList.tokens ?? [];
606
+ }
607
+
608
+ // src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts
609
+ import { bgtAbi } from "@berachain/abis/pol/bgt";
610
+ import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
611
+ async function getActiveBoostAndCommissionChangeDelay({
612
+ publicClient,
613
+ ui,
614
+ ...args
615
+ }) {
616
+ const { config } = parseBaseArgs(args);
617
+ const [
618
+ maxCommissionRate,
619
+ commissionChangeDelay,
620
+ rewardAllocationBlockDelay,
621
+ maxWeightPerVault,
622
+ maxNumWeightsPerRewardAllocation,
623
+ dropBoostDelay,
624
+ activateBoostDelay,
625
+ rewardAllocationInactivityBlockSpan
626
+ ] = await Promise.all([
627
+ publicClient.readContract({
628
+ address: config.pol.beraChef,
629
+ abi: beraChefAbi,
630
+ functionName: "MAX_COMMISSION_RATE"
631
+ }),
632
+ publicClient.readContract({
633
+ address: config.pol.beraChef,
634
+ abi: beraChefAbi,
635
+ functionName: "commissionChangeDelay"
636
+ }),
637
+ publicClient.readContract({
638
+ address: config.pol.beraChef,
639
+ abi: beraChefAbi,
640
+ functionName: "rewardAllocationBlockDelay"
641
+ }),
642
+ publicClient.readContract({
643
+ address: config.pol.beraChef,
644
+ abi: beraChefAbi,
645
+ functionName: "maxWeightPerVault"
646
+ }),
647
+ publicClient.readContract({
648
+ address: config.pol.beraChef,
649
+ abi: beraChefAbi,
650
+ functionName: "maxNumWeightsPerRewardAllocation"
651
+ }),
652
+ publicClient.readContract({
653
+ address: config.tokens.bgt,
654
+ abi: bgtAbi,
655
+ functionName: "dropBoostDelay"
656
+ }),
657
+ publicClient.readContract({
658
+ address: config.tokens.bgt,
659
+ abi: bgtAbi,
660
+ functionName: "activateBoostDelay"
661
+ }),
662
+ publicClient.readContract({
663
+ address: config.pol.beraChef,
664
+ abi: beraChefAbi,
665
+ functionName: "rewardAllocationInactivityBlockSpan"
666
+ })
667
+ ]);
668
+ return {
669
+ maxCommissionRate: Number(maxCommissionRate) / 1e4,
670
+ boostDelay: Number(activateBoostDelay),
671
+ unboostDelay: Number(dropBoostDelay),
672
+ commissionChangeDelay: Number(commissionChangeDelay),
673
+ rewardAllocationBlockDelay: Number(rewardAllocationBlockDelay),
674
+ maxWeightPerVault: Number(maxWeightPerVault) / 1e4,
675
+ maxNumWeightsPerRewardAllocation: Number(maxNumWeightsPerRewardAllocation),
676
+ rewardAllocationInactivityBlockSpan: Number(
677
+ rewardAllocationInactivityBlockSpan
678
+ ),
679
+ ui
680
+ };
681
+ }
682
+
683
+ // src/actions/validators/utils/aggregateValidatorIncentives.ts
684
+ function aggregateValidatorIncentives({
685
+ rewardAllocationWeights,
686
+ activeOnly = true
687
+ }) {
688
+ const map = rewardAllocationWeights.filter((x) => x?.receivingVault).reduce((acc, rv) => {
689
+ for (const incentive of rv.receivingVault?.activeIncentives ?? []) {
690
+ if (activeOnly && incentive.remainingAmount === "0") {
691
+ continue;
692
+ }
693
+ const incentiveRate = new bignumber_js_default(incentive.incentiveRate).times(
694
+ rv.percentage
695
+ );
696
+ const incentiveRateUsd = new bignumber_js_default(
697
+ incentive.incentiveRateUsd
698
+ ).times(rv.percentage);
699
+ const token = incentive.token.address.toLowerCase();
700
+ const existing = acc.get(token);
701
+ if (existing) {
702
+ acc.set(token, {
703
+ ...existing,
704
+ incentiveRate: new bignumber_js_default(existing.incentiveRate).plus(incentiveRate).toString(),
705
+ incentiveRateUsd: new bignumber_js_default(existing.incentiveRateUsd).plus(incentiveRateUsd).toString(),
706
+ remainingAmount: new bignumber_js_default(existing.remainingAmount).plus(incentive.remainingAmount).toString(),
707
+ remainingAmountUsd: new bignumber_js_default(existing.remainingAmountUsd).plus(incentive.remainingAmountUsd).toString()
708
+ });
709
+ } else {
710
+ acc.set(token, {
711
+ ...incentive,
712
+ tokenAddress: incentive.token.address,
713
+ token: incentive.token,
714
+ incentiveRate: incentiveRate.toString(),
715
+ incentiveRateUsd: incentiveRateUsd.toString(),
716
+ remainingAmount: incentive.remainingAmount
717
+ });
718
+ }
719
+ }
720
+ return acc;
721
+ }, /* @__PURE__ */ new Map());
722
+ return Array.from(map.values());
723
+ }
724
+
725
+ // src/actions/validators/utils/getValidatorBoostApy.ts
726
+ function getValidatorReturnPerBgt(validator) {
727
+ return validator?.rewardAllocationWeights?.reduce((acc, ab) => {
728
+ if (!ab) return acc;
729
+ const totalIncentiveValue = ab.receivingVault?.activeIncentives.filter((inc) => Number(inc.remainingAmount) > 0).reduce((totalIncentiveValue2, currIncentive) => {
730
+ const tokenPrice = Number(currIncentive.remainingAmountUsd) / Number(currIncentive.remainingAmount);
731
+ return totalIncentiveValue2 + Number(currIncentive.incentiveRate) * tokenPrice;
732
+ }, 0) ?? 0;
733
+ return acc + totalIncentiveValue * ab.percentage;
734
+ }, 0);
735
+ }
736
+ function getValidatorBoostApy({
737
+ validator,
738
+ bgtPrice
739
+ }) {
740
+ const validatorActiveBoostAmount = Number(
741
+ validator.dynamicData?.activeBoostAmount ?? 0
742
+ );
743
+ const returnPerBgt = getValidatorReturnPerBgt(validator);
744
+ if (!returnPerBgt || !validatorActiveBoostAmount) {
745
+ return 0;
746
+ }
747
+ const boostApy = returnPerBgt * Number(validator.dynamicData?.lastDayDistributedBGTAmount ?? 0) * 365 / (validatorActiveBoostAmount * bgtPrice);
748
+ return boostApy;
749
+ }
750
+ export {
751
+ BalancerApi,
752
+ BaseAggregator,
753
+ BeraApolloClient,
754
+ HoneyPreviewMethod,
755
+ RewardVaultDistributionMode,
756
+ aggregateValidatorIncentives,
757
+ beraWriteContract,
758
+ formatValidatorRewardAllocation,
759
+ getActiveBoostAndCommissionChangeDelay,
760
+ getAllPools,
761
+ getAllValidators,
762
+ getAllowances,
763
+ getApiEnrichedAllocation,
764
+ getApiPool,
765
+ getApiValidator,
766
+ getApolloClient,
767
+ getAutoclaimedIncentives,
768
+ getBalanceCall,
769
+ getBeraTokenTotalSupply,
770
+ getBgtAprSimulation,
771
+ getBgtIncentiveDistributorPaused,
772
+ getBlockTime,
773
+ getBlockTimestamp,
774
+ getChartData,
775
+ getCollateralWeights,
776
+ getConvertToAssets,
777
+ getDailyValidatorBlockStats,
778
+ getDefaultRewardAllocation,
779
+ getEarnedStakedBeraVault,
780
+ getEnsoClient,
781
+ getGlobalCapLimit,
782
+ getGlobalData,
783
+ getGlobalLiquidityAndSwapVolume,
784
+ getHeroEarnVaults,
785
+ getHoney24hVolume,
786
+ getHoneyCollaterals,
787
+ getHoneyFees,
788
+ getHoneyPausedState,
789
+ getHoneyPreview,
790
+ getHoneyPythFeeds,
791
+ getHoneyPythOracle,
792
+ getHoneyRootPriceOracle,
793
+ getHoneyVaultsBalance,
794
+ getIncentiveFeeClaimStats,
795
+ getLSTStakeConfig,
796
+ getMarkets,
797
+ getMaxDeposit,
798
+ getOnChainPool,
799
+ getPoolEvents,
800
+ getPoolHistoricalData,
801
+ getPoolPausedState,
802
+ getPoolState,
803
+ getPythLatestPrices,
804
+ getPythUpdateFee,
805
+ getRelativeCapLimit,
806
+ getRewardProofsByValidator,
807
+ getRewardTokenToBeraRate,
808
+ getRewardVault,
809
+ getRewardVaultDurationConstants,
810
+ getRewardVaultFromToken,
811
+ getRewardVaultIncentives,
812
+ getRewardVaultRewards,
813
+ getRewardVaultStakingToken,
814
+ getRewardVaults,
815
+ getSWBeraVaultMetadata,
816
+ getSWBeraWithdrawal,
817
+ getStakeWithdrawalCooldown,
818
+ getStakedBeraAPR,
819
+ getStakedBeraSnapshots,
820
+ getStakingPoolBatch,
821
+ getSwapPayload,
822
+ getTokenCurrentPrices,
823
+ getTokenInformation,
824
+ getTokens,
825
+ getTotalStakedAmount,
826
+ getUserActiveValidators,
827
+ getUserBoostsOnValidator,
828
+ getUserClaimableIncentives,
829
+ getUserStakingPositions,
830
+ getUserVaultInfo,
831
+ getUserVaults,
832
+ getUserVaultsReward,
833
+ getValidatorAnalytics,
834
+ getValidatorBoostApy,
835
+ getValidatorCommission,
836
+ getValidatorEstimatedBgtPerYear,
837
+ getValidatorOperatorAddress,
838
+ getValidatorQueuedCommission,
839
+ getValidatorQueuedOperatorAddress,
840
+ getValidatorQueuedRewardAllocation,
841
+ getValidatorReturnPerBgt,
842
+ getValidatorRewardAllocation,
843
+ getVaultHistory,
844
+ getVaultPausedState,
845
+ getVaultValidators,
846
+ getWalletBalances,
847
+ gql,
848
+ isBadCollateralAsset,
849
+ isBasketModeEnabled,
850
+ isDefaultRewardAllocation,
851
+ isImpersonateAccount,
852
+ isSameRewardAllocation
853
+ };