Skip to main content

Function: calculateLinearFeeInterpolation()

Gala Launchpad SDK 9.0.0-rc.5


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

Function: calculateLinearFeeInterpolation()

calculateLinearFeeInterpolation(progress, minFee, maxFee): BigNumber

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

Calculate linearly interpolated fee between min and max based on progress

Maps a progress value (0 to 1) to a fee between minFee and maxFee using linear interpolation. This is the core pattern used in bonding curve calculations where fees scale from minFeePortion to maxFeePortion based on token supply progress (supply / maxSupply).

Formula: minFee + (maxFee - minFee) * progress

Consolidates 4 occurrences in bondingCurveCalculations and related services.

Parameters​

progress​

number | BigNumber

Progress ratio from 0 to 1 (e.g., currentSupply / maxSupply)

minFee​

number

Minimum fee value (as decimal, e.g., 0.1 for 10%)

maxFee​

number

Maximum fee value (as decimal, e.g., 0.5 for 50%)

Returns​

BigNumber

Interpolated fee amount as BigNumber

Throws​

Error if progress is outside [0, 1] or if maxFee < minFee

Example​

// Fee scales from 10% to 50% as supply increases
const progress = toBigNumber('500000').dividedBy('10000000'); // 0.05 = 5%
const fee = calculateLinearFeeInterpolation(progress, 0.1, 0.5);
// Returns: 0.1 + (0.5 - 0.1) * 0.05 = 0.12 (12%)

// At max supply (100%), fee reaches 50%
const fee = calculateLinearFeeInterpolation(1, 0.1, 0.5);
// Returns: 0.5

// At zero supply (0%), fee is minimum
const fee = calculateLinearFeeInterpolation(0, 0.1, 0.5);
// Returns: 0.1