Function: calculateScaledFeeAmount()
Gala Launchpad SDK 9.0.0-rc.5 / index / calculateScaledFeeAmount
Function: calculateScaledFeeAmount()
calculateScaledFeeAmount(
baseAmount,feeFactor):BigNumber
Defined in: packages/launchpad-sdk/dist/utils/numeric-patterns.d.ts:288
Calculate reverse bonding curve fee amount with precision handling
Consolidates the pattern of applying a fee factor to a base amount with integer rounding (down). Used extensively in bonding curve calculations for reverse fee computation and scaled amount operations.
Formula: new BigNumber(baseAmount).multipliedBy(feeFactor).integerValue(BigNumber.ROUND_DOWN)
Consolidates 3 occurrences of fee scaling patterns in trading services.
Parameters
baseAmount
string | number | BigNumber
The base amount to apply fee factor to (string, number, or BigNumber)
feeFactor
number
The fee factor as decimal (e.g., 0.1 for 10%, 0.005 for 0.5%)
Returns
BigNumber
The scaled fee amount (rounded down to integer)
Throws
Error if feeFactor is negative
Example
// Calculate 1% fee on 1000 GALA
const baseAmount = new BigNumber('1000');
const fee = calculateScaledFeeAmount(baseAmount, 0.01); // BigNumber(10)
// Calculate 0.5% reverse bonding curve fee
const feeAmount = calculateScaledFeeAmount('5000', 0.005); // BigNumber(25)
// Fee factor from pool: reverseBondingCurveFee = 0.123456
const reversed = calculateScaledFeeAmount(amount, reverseBondingCurveFee);
// Returns: rounded-down result of amount * 0.123456