UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 566 B
import{g as e}from"./getFormattedUsdFromLamports-B6EqSEho.mjs";function t(e,t=6,n=!1,r=!1){let o=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),i=r?"":" SOL";return n?`${o}${i}`:`${"0"===o?"<0.001":o}${i}`}function n({amount:n,fee:r,tokenPrice:o,isUsdc:i}){let a=BigInt(Math.floor(parseFloat(n)*10**(i?6:9))),s=i?a:a+r;return{fundingAmountInBaseUnit:a,fundingAmountInUsd:o?e(a,o):void 0,totalPriceInUsd:o?e(s,o):void 0,totalPriceInNativeCurrency:t(s),feePriceInNativeCurrency:t(r),feePriceInUsd:o?e(r,o):void 0}}export{n as a,t as g};