@@ -45,6 +45,7 @@ import { useRewards } from '../../../hooks/bridge/useRewards';
4545import { RewardsBadge } from '../../../components/app/rewards/RewardsBadge' ;
4646import AddRewardsAccount from '../../../components/app/rewards/AddRewardsAccount' ;
4747import { Skeleton } from '../../../components/component-library/skeleton' ;
48+ import { getGasFeesSponsoredNetworkEnabled } from '../../../selectors/selectors' ;
4849import { BridgeQuotesModal } from './bridge-quotes-modal' ;
4950
5051const getTimerColor = ( timeInSeconds : number ) => {
@@ -87,6 +88,9 @@ export const MultichainBridgeQuoteCard = ({
8788 const dispatch = useDispatch ( ) ;
8889
8990 const isToOrFromNonEvm = useSelector ( getIsToOrFromNonEvm ) ;
91+ const gasFeesSponsoredNetworkEnabled = useSelector (
92+ getGasFeesSponsoredNetworkEnabled ,
93+ ) ;
9094
9195 const [ showAllQuotes , setShowAllQuotes ] = useState ( false ) ;
9296
@@ -97,7 +101,43 @@ export const MultichainBridgeQuoteCard = ({
97101 const gasIncluded = activeQuote ?. quote ?. gasIncluded ?? false ;
98102 const gasIncluded7702 = activeQuote ?. quote ?. gasIncluded7702 ?? false ;
99103 const gasSponsored = activeQuote ?. quote ?. gasSponsored ?? false ;
100- const isGasless = gasIncluded7702 || gasIncluded || gasSponsored ;
104+
105+ const isCurrentNetworkGasSponsored = useMemo ( ( ) => {
106+ if ( ! fromChain ?. chainId || ! gasFeesSponsoredNetworkEnabled ) {
107+ return false ;
108+ }
109+ return Boolean (
110+ gasFeesSponsoredNetworkEnabled [
111+ fromChain . chainId as keyof typeof gasFeesSponsoredNetworkEnabled
112+ ] ,
113+ ) ;
114+ } , [ fromChain ?. chainId , gasFeesSponsoredNetworkEnabled ] ) ;
115+
116+ const shouldShowGasSponsored = useMemo ( ( ) => {
117+ if ( gasSponsored ) {
118+ return true ;
119+ }
120+
121+ // For the insufficientBal workaround, validate it's a same-chain swap
122+ if ( insufficientBal && isCurrentNetworkGasSponsored ) {
123+ // Gas sponsorship only applies to same-chain swaps, not cross-chain bridges
124+ const isSameChain =
125+ fromToken ?. chainId &&
126+ toToken ?. chainId &&
127+ fromToken . chainId === toToken . chainId ;
128+ return Boolean ( isSameChain ) ;
129+ }
130+
131+ return false ;
132+ } , [
133+ gasSponsored ,
134+ insufficientBal ,
135+ isCurrentNetworkGasSponsored ,
136+ fromToken ?. chainId ,
137+ toToken ?. chainId ,
138+ ] ) ;
139+
140+ const isGasless = gasIncluded7702 || gasIncluded || shouldShowGasSponsored ;
101141
102142 const nativeTokenSymbol = fromChain
103143 ? getNativeAssetForChainId ( fromChain . chainId ) . symbol
@@ -266,7 +306,7 @@ export const MultichainBridgeQuoteCard = ({
266306 { t ( 'networkFeeExplanation' ) }
267307 </ Tooltip >
268308 </ Row >
269- { gasSponsored && (
309+ { shouldShowGasSponsored && (
270310 < Row gap = { 1 } data-testid = "network-fees-sponsored" >
271311 < Text
272312 variant = { TextVariant . bodySm }
@@ -283,7 +323,7 @@ export const MultichainBridgeQuoteCard = ({
283323 </ Tooltip >
284324 </ Row >
285325 ) }
286- { ! gasSponsored && activeQuote . quote . gasIncluded && (
326+ { ! shouldShowGasSponsored && activeQuote . quote . gasIncluded && (
287327 < Row gap = { 1 } data-testid = "network-fees-included" >
288328 < Text
289329 variant = { TextVariant . bodySm }
@@ -308,7 +348,7 @@ export const MultichainBridgeQuoteCard = ({
308348 </ Text >
309349 </ Row >
310350 ) }
311- { ! gasSponsored && ! activeQuote . quote . gasIncluded && (
351+ { ! shouldShowGasSponsored && ! activeQuote . quote . gasIncluded && (
312352 < Text
313353 variant = { TextVariant . bodySm }
314354 color = { TextColor . textAlternative }
0 commit comments