Skip to content

Add estimateFeeForAmount with bigint precision to feeEstimator - #722

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
bobo-24:bobo
Aug 29, 2026
Merged

Add estimateFeeForAmount with bigint precision to feeEstimator#722
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
bobo-24:bobo

Conversation

@bobo-24

@bobo-24 bobo-24 commented Aug 27, 2026

Copy link
Copy Markdown

Summary:
This PR adds a new method, estimateFeeForAmount, to the feeEstimator module. The method uses bigint precision to calculate fees for arbitrary amounts, ensuring accuracy for large values that exceed JavaScript’s Number safe integer range.

Changes Introduced:

Implemented estimateFeeForAmount(amount: bigint): bigint in feeEstimator.

Leveraged bigint arithmetic for fee calculations to avoid precision loss.

Added unit tests covering:

Small amounts (within safe integer range).

Large amounts (beyond Number.MAX_SAFE_INTEGER).

Edge cases (zero, negative values, extremely large inputs).

Updated documentation (/docs/fee-estimator.md) with usage examples.

Refactored existing fee estimation logic to delegate to the new method where appropriate.

Rationale:

Current fee estimation relies on Number, which can introduce rounding errors for large values.

Using bigint ensures exact precision, critical for financial and blockchain-related calculations.

Provides developers with a safe and consistent API for fee estimation across all input sizes.

Next Steps:

Review by maintainers for API design consistency.

Rollout plan to replace legacy Number-based fee estimation in dependent modules.

Update developer guides to highlight the new bigint-based method.
Close #615

@Kingsman-99
Kingsman-99 merged commit 4fe5b46 into Stellar-split:main Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add estimateFeeForAmount with bigint precision to feeEstimator

2 participants