diff --git a/apps/web/src/views/Swap/V3Swap/utils/exchange.ts b/apps/web/src/views/Swap/V3Swap/utils/exchange.ts index 46f9513156790..8fc4e7df8018f 100644 --- a/apps/web/src/views/Swap/V3Swap/utils/exchange.ts +++ b/apps/web/src/views/Swap/V3Swap/utils/exchange.ts @@ -82,13 +82,19 @@ export function computeTradePriceBreakdown(trade?: TradeEssentialForPriceBreakdo routeFeePercent.multiply(Percent.toPercent(parseNumberToFraction(percent / 100) || new Fraction(0))), ) - const midPrice = SmartRouter.getMidPrice(route) - outputAmountWithoutPriceImpact = outputAmountWithoutPriceImpact.add( - CurrencyAmount.fromRawAmount( - trade.outputAmount.currency, - midPrice.wrapped.quote(routeInputAmount.wrapped).quotient, - ), - ) + try { + const midPrice = SmartRouter.getMidPrice(route) + outputAmountWithoutPriceImpact = outputAmountWithoutPriceImpact.add( + CurrencyAmount.fromRawAmount( + trade.outputAmount.currency, + midPrice.wrapped.quote(routeInputAmount.wrapped).quotient, + ), + ) + } catch (error) { + console.error('Error calculating output amount:', error) + outputAmountWithoutPriceImpact = CurrencyAmount.fromRawAmount(trade.outputAmount.currency, 0) + break + } } if (outputAmountWithoutPriceImpact.quotient === ZERO) {