Skip to content

Commit

Permalink
fix: handle undefined fUSDC in SwapPro component
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] and af-afk committed Dec 13, 2024
1 parent 9e6cd05 commit 8e66c11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/src/components/SwapPro/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export const SwapPro = ({
});

const formattedTokenPrice = useMemo(() => {
// Early return if fUSDC is not available

Check warning on line 112 in web/src/components/SwapPro/index.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/SwapPro/index.tsx#L112

Added line #L112 was not covered by tests
if (!fUSDC) return "0";

Check warning on line 114 in web/src/components/SwapPro/index.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/SwapPro/index.tsx#L114

Added line #L114 was not covered by tests
const token0Price = token0SqrtPriceX96
? Number(
sqrtPriceX96ToPrice(token0SqrtPriceX96.result, token0.decimals),
Expand All @@ -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;
Expand Down

0 comments on commit 8e66c11

Please sign in to comment.