From 8e66c11d87575d553ea9d7385e64d51c78fe9cf7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:38:55 +0000 Subject: [PATCH] fix: handle undefined fUSDC in SwapPro component Co-Authored-By: alex@fluidity.money --- web/src/components/SwapPro/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/components/SwapPro/index.tsx b/web/src/components/SwapPro/index.tsx index 243cfb50..d2166d4a 100644 --- a/web/src/components/SwapPro/index.tsx +++ b/web/src/components/SwapPro/index.tsx @@ -109,6 +109,9 @@ export const SwapPro = ({ }); const formattedTokenPrice = useMemo(() => { + // Early return if fUSDC is not available + if (!fUSDC) return "0"; + const token0Price = token0SqrtPriceX96 ? Number( sqrtPriceX96ToPrice(token0SqrtPriceX96.result, token0.decimals), @@ -135,8 +138,7 @@ export const SwapPro = ({ token1, token0SqrtPriceX96, token1SqrtPriceX96, - fUSDC.address, - fUSDC.decimals, + fUSDC, // Add fUSDC as a dependency since we use it in the callback ]); const transactions = poolSwapPro?.swaps.swaps;