Description
Stellar's base fee rises during network congestion, making hard-coded fee values cause transaction failures during surges. The SDK currently uses a fixed fee from StellarSplitConfig and does not react to real-time ledger fee data. A surge detector should monitor recent ledger fee statistics via Horizon and automatically recommend or apply an adjusted fee multiplier when the network is congested.
Technical Context
Extend src/feeEstimator.ts and src/fee.ts. Uses @stellar/stellar-sdk Server.feeStats() which returns FeeStatsRecord with p10, p50, p95 fee percentiles. Add FeeSurgeConfig and FeeRecommendation to src/types.ts. Integrate with src/txBuilder.ts so the surge-adjusted fee is applied before transaction signing. Optionally emits a feeSurgeDetected event via src/events.ts.
Acceptance Criteria
Description
Stellar's base fee rises during network congestion, making hard-coded fee values cause transaction failures during surges. The SDK currently uses a fixed fee from
StellarSplitConfigand does not react to real-time ledger fee data. A surge detector should monitor recent ledger fee statistics via Horizon and automatically recommend or apply an adjusted fee multiplier when the network is congested.Technical Context
Extend
src/feeEstimator.tsandsrc/fee.ts. Uses@stellar/stellar-sdkServer.feeStats()which returnsFeeStatsRecordwithp10,p50,p95fee percentiles. AddFeeSurgeConfigandFeeRecommendationtosrc/types.ts. Integrate withsrc/txBuilder.tsso the surge-adjusted fee is applied before transaction signing. Optionally emits afeeSurgeDetectedevent viasrc/events.ts.Acceptance Criteria
detectFeeSurge(): Promise<FeeRecommendation>fetches current fee stats and computes a recommended base fee at a configurable percentile (default p75)feeSurgeDetectedevent with the recommended feesrc/txBuilder.tscallsdetectFeeSurge()before building each transaction and applies the recommendation whenautoFeeAdjust: trueis set in configfeeStats()feeStats()responses and assert correct surge detection at various percentile thresholds