dAppBooster
    Preparing search index...

    Function formatUSDPrice

    • Formats a numeric value as a USD price using the FiatTokenPrice formatter by default.

      This function is a convenience wrapper around formatNumberOrString that specifically handles USD price formatting. It applies the appropriate currency symbol, decimal places, and abbreviations (like K, M, B) according to the provided number type.

      Parameters

      • price: Nullish<string | number>

        The USD price value to format

      • Optionaltype: NumberType = NumberType.FiatTokenPrice

        The specific USD price formatting type to apply

      Returns string

      The formatted USD price as a string (e.g. '$1,234.57', '<$0.01', '$1.23M')

      // Format a standard USD price
      formatUSDPrice(1234.567);
      // Returns: '$1,234.57'
      // Format a very small USD price
      formatUSDPrice(0.000000009876);
      // Returns: '<$0.00000001'
      // Format a large USD price
      formatUSDPrice(1234567.891);
      // Returns: '$1.23M'
      // Format USD price with specific type
      formatUSDPrice(0.0099, NumberType.FiatGasPrice);
      // Returns: '<$0.01'