@@ -13,6 +13,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
1313import { useCallback , useEffect , useRef , useState } from "react" ;
1414
1515import { useSorokit } from "@/context/useSorokit" ;
16+ import { useFeeData } from "@/hooks/useFeeData" ;
1617import type { SorobanResourceUsage } from "@/lib/client" ;
1718import { parseContractPanic } from "@/lib/diagnostics" ;
1819import { cn , toXLM } from "@/lib/utils" ;
@@ -249,6 +250,10 @@ export function GasOptimizer({
249250} : GasOptimizerProps ) {
250251 const { client, network, registerWatcher } = useSorokit ( ) ;
251252 const [ containerRef , isVisible ] = useIsVisible < HTMLDivElement > ( ) ;
253+ // Shares FeeEstimator's polling interval and cache instead of fetching the
254+ // base fee a second time: the hook dedupes concurrent callers down to one
255+ // `estimateFee()` request per tick regardless of how many components use it.
256+ const { fee : sharedFee } = useFeeData ( refreshInterval , isVisible ) ;
252257 const [ gasPriceData , setGasPriceData ] = useState < GasPriceData | null > ( null ) ;
253258 const [ estimate , setEstimate ] = useState < GasEstimate | null > ( null ) ;
254259 const [ loading , setLoading ] = useState ( true ) ;
@@ -438,7 +443,7 @@ export function GasOptimizer({
438443 gasMultiplier : customMultiplier ,
439444 multiplier : customMultiplier ,
440445 gasPrice : gasPriceData ?. gasPrice ?? "100" ,
441- baseFee : gasPriceData ?. baseFee ?? "100" ,
446+ baseFee : sharedFee ?. baseFee ?? gasPriceData ?. baseFee ?? "100" ,
442447 baseReserve : gasPriceData ?. baseReserve ?? "0.5" ,
443448 operations,
444449 resources : {
@@ -459,6 +464,7 @@ export function GasOptimizer({
459464 memoryBytes ,
460465 customMultiplier ,
461466 gasPriceData ,
467+ sharedFee ,
462468 operations ,
463469 ] ) ;
464470
0 commit comments