'use client' import useSWR from 'swr' import { useDebounce } from 'use-debounce' import styles from './Prices.module.css' import { Result } from './Result' import { tokens, ratioOceanToAsi, ratioAgixToAsi, ratioFetToAsi } from '@/constants' import { useState } from 'react' import { FormAmount } from './FormAmount' import { fetcher, formatNumber } from '@/utils' import { Content } from '@/components/Content' export function Prices() { const [amountSwap, setAmountSwap] = useState(100) const [debouncedAmountSwap] = useDebounce(amountSwap, 500) const [amountBuy, setAmountBuy] = useState(100) const [debouncedAmountBuy] = useDebounce(amountBuy, 500) const { data: dataPrices } = useSWR( `/api/prices/?tokens=${tokens.toString()}`, fetcher ) const { data: dataSwapOceanToAgix } = useSWR( `/api/quote/?tokenIn=${tokens[0]}&tokenOut=${tokens[2]}&amountIn=${debouncedAmountSwap}`, fetcher ) const { data: dataSwapOceanToFet } = useSWR( `/api/quote/?tokenIn=${tokens[0]}&tokenOut=${tokens[1]}&amountIn=${debouncedAmountSwap}`, fetcher ) const priceOcean = dataPrices?.[tokens[0]]?.usd || 0 const priceFet = dataPrices?.[tokens[1]]?.usd || 0 const priceAgix = dataPrices?.[tokens[2]]?.usd || 0 const priceAsi = priceFet return ( <>

Swapping{' '} OCEAN ( {formatNumber(debouncedAmountSwap * priceOcean, 'USD')}) right now gets you:

Buying with $ right now gets you:

) }