index/functions/calculateLinearFeeInterpolation.md
calculateLinearFeeInterpolation(
progress,minFee,maxFee):BigNumber
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.
min fee max big number
Parameters
| Parameter | Type | Description |
|---|---|---|
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%) |
big number min fee max
Returns
BigNumber
Interpolated fee amount as BigNumber
big number
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