@@ -103,6 +103,7 @@ const SwapComponent: React.FC = () => {
103103 const [ availableChains , setAvailableChains ] = useState < Chain [ ] > ( [ ] ) ;
104104 const [ isChainsLoading , setIsChainsLoading ] = useState ( true ) ;
105105 const [ liquidityError , setLiquidityError ] = useState < boolean > ( false ) ;
106+ const [ aggregatorDown , setAggregatorDown ] = useState < boolean > ( false ) ;
106107 const [ insufficientFunds , setInsufficientFunds ] = useState < boolean > ( false ) ;
107108 const [ isPriceEstimating , setIsPriceEstimating ] = useState ( false ) ;
108109 const [ isDistributing , setIsDistributing ] = useState ( false ) ;
@@ -292,6 +293,7 @@ const SwapComponent: React.FC = () => {
292293 if ( ! isConnected || ! address || ! fromToken ) return ;
293294 setTotalUsdAmount ( null ) ;
294295 setLiquidityError ( false ) ;
296+ setAggregatorDown ( false ) ;
295297 setIsPriceEstimating ( true ) ;
296298
297299 // Cancel any previous price estimate operations
@@ -309,6 +311,8 @@ const SwapComponent: React.FC = () => {
309311
310312 // Reset insufficient funds state at the beginning of new price estimation
311313 setInsufficientFunds ( false ) ;
314+ setLiquidityError ( false ) ;
315+ setAggregatorDown ( false ) ;
312316
313317 try {
314318 const bzzAmount = calculateTotalAmount ( ) . toString ( ) ;
@@ -416,7 +420,21 @@ const SwapComponent: React.FC = () => {
416420 if ( ! abortSignal . aborted ) {
417421 console . error ( 'Error estimating price:' , error ) ;
418422 setTotalUsdAmount ( null ) ;
419- setLiquidityError ( true ) ;
423+
424+ // Check if this is a LI.FI aggregator 404 error
425+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
426+ const isLiFiNotFoundError =
427+ errorMessage . includes ( '404' ) ||
428+ errorMessage . includes ( 'Not Found' ) ||
429+ errorMessage . includes ( 'No available quotes for the requested transfer' ) ||
430+ errorMessage . includes ( 'NotFoundError' ) ;
431+
432+ if ( isLiFiNotFoundError ) {
433+ console . log ( 'LI.FI aggregator appears to be down or no quotes available' ) ;
434+ setAggregatorDown ( true ) ;
435+ } else {
436+ setLiquidityError ( true ) ;
437+ }
420438 }
421439 } finally {
422440 // Only update loading state if not aborted
@@ -1606,6 +1624,7 @@ const SwapComponent: React.FC = () => {
16061624 setTotalUsdAmount ( null ) ;
16071625 setInsufficientFunds ( false ) ;
16081626 setLiquidityError ( false ) ;
1627+ setAggregatorDown ( false ) ;
16091628 setIsPriceEstimating ( false ) ;
16101629 }
16111630
@@ -1666,19 +1685,25 @@ const SwapComponent: React.FC = () => {
16661685
16671686 { selectedDays && totalUsdAmount !== null && Number ( totalUsdAmount ) !== 0 && (
16681687 < p className = { styles . priceInfo } >
1669- { liquidityError
1670- ? 'Not enough liquidity for this swap'
1671- : insufficientFunds
1672- ? `Cost ($${ Number ( totalUsdAmount ) . toFixed ( 2 ) } ) exceeds your balance`
1673- : `Cost without gas ~ $${ Number ( totalUsdAmount ) . toFixed ( 2 ) } ` }
1688+ { aggregatorDown
1689+ ? 'Aggregator down, use BZZ directly'
1690+ : liquidityError
1691+ ? 'Not enough liquidity for this swap'
1692+ : insufficientFunds
1693+ ? `Cost ($${ Number ( totalUsdAmount ) . toFixed ( 2 ) } ) exceeds your balance`
1694+ : `Cost without gas ~ $${ Number ( totalUsdAmount ) . toFixed ( 2 ) } ` }
16741695 </ p >
16751696 ) }
16761697
16771698 < button
16781699 className = { `${ styles . button } ${
16791700 ! isConnected
16801701 ? ''
1681- : ! selectedDays || ! fromToken || liquidityError || insufficientFunds
1702+ : ! selectedDays ||
1703+ ! fromToken ||
1704+ liquidityError ||
1705+ aggregatorDown ||
1706+ insufficientFunds
16821707 ? styles . buttonDisabled
16831708 : ''
16841709 } ${ isPriceEstimating ? styles . calculatingButton : '' } `}
@@ -1687,6 +1712,7 @@ const SwapComponent: React.FC = () => {
16871712 ( ! selectedDays ||
16881713 ! fromToken ||
16891714 liquidityError ||
1715+ aggregatorDown ||
16901716 insufficientFunds ||
16911717 isPriceEstimating )
16921718 }
@@ -1702,6 +1728,8 @@ const SwapComponent: React.FC = () => {
17021728 'No Token Available'
17031729 ) : isPriceEstimating ? (
17041730 'Calculating Cost...'
1731+ ) : aggregatorDown ? (
1732+ 'Aggregator Down - Use BZZ'
17051733 ) : liquidityError ? (
17061734 "Cannot Swap - Can't Find Route"
17071735 ) : insufficientFunds ? (
0 commit comments