Description
The SDK cannot currently advise callers on appropriate base fees because it has no visibility into recent ledger fee trends. Fee spikes during network congestion cause submitted transactions to be rejected without useful guidance, and manual fee tuning is tedious. A fee trend analyzer would query Horizon's /fee_stats endpoint on a rolling basis, compute percentile estimates over a sliding window, and expose a recommended fee for a caller-specified acceptance-percentile target.
Technical Context
New module src/fees/trend.ts exposing a FeeTrendAnalyzer class. Calls Horizon.Server.feeStats() from @stellar/stellar-sdk. Stores a configurable rolling window of samples using a fixed-capacity circular buffer in src/utils/circularBuffer.ts. Percentile computation extracted to src/utils/stats.ts. Configuration via FeeTrendOptions interface in src/types.ts.
Acceptance Criteria
Description
The SDK cannot currently advise callers on appropriate base fees because it has no visibility into recent ledger fee trends. Fee spikes during network congestion cause submitted transactions to be rejected without useful guidance, and manual fee tuning is tedious. A fee trend analyzer would query Horizon's
/fee_statsendpoint on a rolling basis, compute percentile estimates over a sliding window, and expose a recommended fee for a caller-specified acceptance-percentile target.Technical Context
New module
src/fees/trend.tsexposing aFeeTrendAnalyzerclass. CallsHorizon.Server.feeStats()from@stellar/stellar-sdk. Stores a configurable rolling window of samples using a fixed-capacity circular buffer insrc/utils/circularBuffer.ts. Percentile computation extracted tosrc/utils/stats.ts. Configuration viaFeeTrendOptionsinterface insrc/types.ts.Acceptance Criteria
FeeTrendAnalyzer.sample()fetches the current fee stats snapshot and appends it to the rolling window, evicting the oldest entry when capacity is reachedFeeTrendAnalyzer.recommendedFee(percentile: 50 | 75 | 95 | 99): numberreturns the fee (in stroops) at the requested percentile across all stored samples