dAppBooster
    Preparing search index...

    Function formatFiatPrice

    • Formats a numeric value as a price in the specified currency.

      Unlike formatUSDPrice, this function allows for formatting prices in any currency using the browser's Intl.NumberFormat API. It applies the appropriate currency symbol and number formatting based on the specified currency code.

      Parameters

      • price: Nullish<number>

        The price value to format

      • Optionalcurrency: string = 'USD'

        The ISO 4217 currency code (e.g., 'USD', 'EUR', 'JPY')

      Returns string

      The formatted price as a string with appropriate currency symbol, or '-' if input is null or undefined

      // Format a USD price (default)
      formatFiatPrice(1234.56);
      // Returns: '$1,234.56'
      // Format a Euro price
      formatFiatPrice(1234.56, 'EUR');
      // Returns: '€1,234.56'
      // Format a Japanese Yen price
      formatFiatPrice(1234.56, 'JPY');
      // Returns: '¥1,235'
      // Handle null input
      formatFiatPrice(null);
      // Returns: '-'