From b5df129f10cd717d5c4e0d20ecbcfdca89020b01 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 18 Sep 2023 10:11:17 +0700 Subject: [PATCH] fix: crash zap (#2245) --- src/pages/RemoveLiquidity/ZapOut.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pages/RemoveLiquidity/ZapOut.tsx b/src/pages/RemoveLiquidity/ZapOut.tsx index 532f19021f..375f5626ef 100644 --- a/src/pages/RemoveLiquidity/ZapOut.tsx +++ b/src/pages/RemoveLiquidity/ZapOut.tsx @@ -510,16 +510,14 @@ export default function ZapOut({ parsedAmounts[independentTokenField] && independentTokenPrice ? parseFloat((parsedAmounts[independentTokenField] as TokenAmount).toSignificant(6)) * independentTokenPrice : 0 - + const noZapDependentAmount = noZapAmounts[dependentTokenField] const priceImpact = priceToSwap && - noZapAmounts[dependentTokenField] && + noZapDependentAmount && amountOut && - computePriceImpact( - priceToSwap, - noZapAmounts[dependentTokenField] as CurrencyAmount, - amountOut as CurrencyAmount, - ) + !priceToSwap.equalTo(0) && + !noZapDependentAmount.equalTo(0) && + computePriceImpact(priceToSwap, noZapDependentAmount, amountOut as CurrencyAmount) const priceImpactWithoutFee = pair && priceImpact ? computePriceImpactWithoutFee([pair], priceImpact) : undefined