import { Result } from '@/components/ResultRow' import { ratioOceanToAsi, ratioAgixToAsi, ratioFetToAsi } from '@/constants' import { usePrices } from '@/hooks' import { fetcher, getTokenAddressBySymbol, getTokenBySymbol } from '@/utils' import useSWR from 'swr' import { TokenSymbol } from '@/types' const options = { keepPreviousData: true // so loading UI can kick in properly } export function SwapResults({ tokenSymbol, amount }: { tokenSymbol: TokenSymbol amount: number }) { const { prices, isValidating: isValidatingPrices, isLoading: isLoadingPrices } = usePrices() // -> AGIX const { data: dataSwapToAgix, isValidating: isValidatingToAgix, isLoading: isLoadingToAgix } = useSWR( `/api/quote/?tokenIn=${getTokenAddressBySymbol( tokenSymbol )}&tokenOut=${getTokenAddressBySymbol('AGIX')}&amountIn=${amount}`, fetcher, options ) // -> FET const { data: dataSwapToFet, isValidating: isValidatingToFet, isLoading: isLoadingToFet } = useSWR( `/api/quote/?tokenIn=${getTokenAddressBySymbol( tokenSymbol )}&tokenOut=${getTokenAddressBySymbol('FET')}&amountIn=${amount}`, fetcher, options ) // -> OCEAN const { data: dataSwapToOcean, isValidating: isValidatingToOcean, isLoading: isLoadingToOcean } = useSWR( `/api/quote/?tokenIn=${getTokenAddressBySymbol( tokenSymbol )}&tokenOut=${getTokenAddressBySymbol('OCEAN')}&amountIn=${amount}`, fetcher, options ) return ( <> ) }