asi-calculator/components/Strategies/Swap/Results.tsx

67 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-03-31 16:48:31 +02:00
import { Result } from '@/components/ResultRow'
2024-03-31 23:50:43 +02:00
import { ratioOceanToAsi, ratioAgixToAsi, ratioFetToAsi } from '@/constants'
2024-03-31 16:48:31 +02:00
import { usePrices } from '@/hooks'
2024-04-01 04:25:28 +02:00
import { getTokenBySymbol } from '@/lib/utils'
2024-03-31 16:48:31 +02:00
import { TokenSymbol } from '@/types'
2024-04-01 03:25:23 +02:00
import { useQuote } from '@/hooks'
2024-04-01 02:15:51 +02:00
2024-03-31 16:48:31 +02:00
export function SwapResults({
2024-03-31 23:50:43 +02:00
tokenSymbol,
2024-03-31 16:48:31 +02:00
amount
}: {
2024-03-31 23:50:43 +02:00
tokenSymbol: TokenSymbol
2024-03-31 16:48:31 +02:00
amount: number
}) {
2024-04-01 02:15:51 +02:00
const {
prices,
isValidating: isValidatingPrices,
isLoading: isLoadingPrices
} = usePrices()
2024-03-30 19:11:24 +01:00
2024-04-01 02:15:51 +02:00
const {
2024-04-01 03:25:23 +02:00
amountToOcean,
amountToAgix,
amountToFet,
isValidatingToAgix,
isLoadingToAgix,
isValidatingToFet,
isLoadingToFet,
isValidatingToOcean,
isLoadingToOcean
} = useQuote(tokenSymbol, amount)
2024-03-30 19:11:24 +01:00
return (
2024-03-31 16:48:31 +02:00
<>
2024-03-30 19:11:24 +01:00
<Result
2024-03-31 16:58:26 +02:00
token={getTokenBySymbol('OCEAN')}
2024-04-01 03:25:23 +02:00
amount={amountToOcean}
amountAsi={amountToOcean * ratioOceanToAsi}
amountFiat={amountToOcean * ratioOceanToAsi * prices.asi}
amountOriginalFiat={amountToOcean * prices.ocean}
2024-03-31 23:50:43 +02:00
isValidating={isValidatingToOcean || isValidatingPrices}
2024-04-01 02:15:51 +02:00
isLoading={isLoadingToOcean || isLoadingPrices}
2024-03-30 19:11:24 +01:00
/>
<Result
2024-03-31 16:58:26 +02:00
token={getTokenBySymbol('AGIX')}
2024-04-01 03:25:23 +02:00
amount={amountToAgix}
amountAsi={amountToAgix * ratioAgixToAsi}
amountFiat={amountToAgix * ratioAgixToAsi * prices.asi}
amountOriginalFiat={amountToAgix * prices.agix}
2024-03-31 23:50:43 +02:00
isValidating={isValidatingToAgix || isValidatingPrices}
2024-04-01 02:15:51 +02:00
isLoading={isLoadingToAgix || isLoadingPrices}
2024-03-30 19:11:24 +01:00
/>
<Result
2024-03-31 16:58:26 +02:00
token={getTokenBySymbol('FET')}
2024-04-01 03:25:23 +02:00
amount={amountToFet}
amountAsi={amountToFet * ratioFetToAsi}
amountFiat={amountToFet * prices.asi}
amountOriginalFiat={amountToFet * prices.asi}
2024-03-31 23:50:43 +02:00
isValidating={isValidatingToFet || isValidatingPrices}
2024-04-01 02:15:51 +02:00
isLoading={isLoadingToFet || isLoadingPrices}
2024-03-30 19:11:24 +01:00
/>
2024-03-31 16:48:31 +02:00
</>
2024-03-30 19:11:24 +01:00
)
}