require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`);let t=require(`ethers`);var n=e=>t.ethers.parseEther(e),r=e=>BigInt(t.ethers.hexlify(t.ethers.randomBytes(e))),i=(e,n)=>t.ethers.formatUnits(n,e.decimals),a=(n,r)=>{let i=10**(18-n.decimals);try{return t.ethers.parseUnits(r)/BigInt(i)}catch{throw Error(e.transactionErrorCodes.DECIMALS_LIMIT)}},o=e=>{let[t,n]=e.toFixed(30).split(`.`),r=n?n.length:0,i=`${t}${n||``}`;return[BigInt(i),r]},s=(e,t)=>{try{return a(e,t)}catch{return BigInt(0)}},c=(n,r,i)=>{let a=t.ethers.formatUnits(n,r.decimals),o=BigInt(10**(18-i));try{let e=t.ethers.parseUnits(a)/o;return t.ethers.formatUnits(e,i)}catch{throw Error(e.transactionErrorCodes.DECIMALS_LIMIT)}},l=(e,t,n,r)=>{let[i,a]=o(n);return{totalValueDollarsBigInt:t*i/BigInt(10**(e.decimals-r))/BigInt(10**a),precision:r}},u=(e,t)=>!e||!t?`0`:c(t??0n,e,e.decimals).toString()??`0`;exports.calculateDollarValue=l,exports.ethToWei=n,exports.getAmountInToken=i,exports.getAmountInWei=a,exports.getAmountInWeiOrZero=s,exports.getAmountWithPrecision=c,exports.getAmountWithPrecisionOrZero=u,exports.randomBigInt=r,exports.toBigIntWithDecimals=o;