Function calcPercentValue

  • Calculates the specified percentage of a given value.

    Parameters

    • value: string | number | bigint

      The value to calculate the percentage of

    • percentage: string | number | bigint

      The percentage to calculate

    • valueDecimals: number

      The decimals of the value.

    Returns bigint

    The percentage of the given value scaled according to the specified decimals

    Example

    calcPercentValue(100, 10, 6) // 10
    calcPercentValue(100, 25, 6) // 25
    calcPercentValue(100e18, 50, 18) // 50000000000000000000n || 50e18