Skip to main content

Function: decimalRoundingUp()

Gala Launchpad SDK 9.0.0-rc.5


Gala Launchpad SDK 9.0.0-rc.5 / index / decimalRoundingUp

Function: decimalRoundingUp()

decimalRoundingUp(value, decimals): BigNumber

Defined in: packages/launchpad-sdk/dist/utils/numeric-patterns.d.ts:184

Round decimal up to specified precision (ceiling rounding)

Always rounds UP to the specified decimal places. This ensures system accuracy and prevents shortchanging calculations (e.g., fee calculations always round up to protect the fee recipient).

Consolidates 3 occurrences of Math.ceil with decimal precision patterns.

Parameters​

value​

string | number | BigNumber

Value to round (string, number, or BigNumber)

decimals​

number

Number of decimal places to preserve

Returns​

BigNumber

Rounded value as BigNumber

Throws​

Error if decimals is negative

Example​

// Fee calculations that always round up
const fee = decimalRoundingUp('1.234', 2); // 1.24 (rounds up from 1.23)

// Preserve more decimals
const precise = decimalRoundingUp('1.23456', 4); // 1.2346

// Integer rounding
const integer = decimalRoundingUp('1.1', 0); // 2 (rounds up to next integer)

// Very small values
const tiny = decimalRoundingUp('0.00001', 4); // 0.0001