Skip to content

Add estimateFeeForAmount with bigint precision to feeEstimator #615

Description

@Kingsman-99

Description

src/feeEstimator.ts estimates transaction fees but does not expose a helper that takes a payment amount and returns the estimated fee as a percentage and absolute value. Callers must read raw fee stats and do the math themselves.

Acceptance Criteria

  • estimateFeeForAmount(amount: bigint, feeStats: FeeStats): { feeLumens: bigint; feePercent: number; totalWithFee: bigint } exported from src/feeEstimator.ts
  • feeLumens is derived from feeStats.baseFee; totalWithFee = amount + feeLumens
  • feePercent is Number(feeLumens) / Number(amount) * 100 — returns 0 when amount === 0n
  • Throws SdkError with code INVALID_RECIPIENT if amount is negative
  • FeeStats type: { baseFee: bigint; p50Fee: bigint; p99Fee: bigint } — add to src/types.ts if not present
  • Exported from src/index.ts
  • Unit tests: correct fee calculation for known amount/stats, zero amount returns 0 percent, negative amount throws

Context

  • Target files: src/feeEstimator.ts, src/types.ts, src/index.ts
  • feeLumens must remain bigint throughout — only convert to number for feePercent

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions