const currencyFormatter = new Intl . NumberFormat ( "en-us" , { style : "currency" , currency : "USD" , minimumFractionDigits : 2 , maximumFractionDigits : 2 , } ) ; export const decimalFormatter = new Intl . NumberFormat ( "en-us" , { style : "decimal" , minimumSignificantDigits : 1 , maximumSignificantDigits : 4 , } ) ; export const toUsd = ( value ) => currencyFormatter . format ( value ) ; export const limitDecimals = ( value ) => decimalFormatter . format ( value ) ; export const tokenValue = ( value , decimals ) => value / Math . pow ( 10 , decimals ) ; export const tokenValueTxt = ( value , decimals , symbol ) => { if ( typeof value === "number" ) { return `${ limitDecimals ( tokenValue ( value , decimals ) ) } ${ symbol }` ; } return `${ limitDecimals ( tokenValue ( Number ( value ) , decimals ) ) } ${ symbol }` ; } ; export const decimalToHexString = ( decimal ) => "0x" + decimal . toString ( 16 ) ; export const hexStringToDecimal = ( hexString ) => parseInt ( hexString , 16 ) ;