2024-03-30 19:11:24 +01:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
import { ratioOceanToAsi, ratioAgixToAsi, ratioFetToAsi } from '@/constants'
|
2024-03-31 15:24:07 +02:00
|
|
|
import { Result } from '@/components/ResultRow'
|
2024-03-30 19:11:24 +01:00
|
|
|
import { useState } from 'react'
|
|
|
|
import { useDebounce } from 'use-debounce'
|
2024-03-30 20:50:51 +01:00
|
|
|
import stylesShared from './styles.module.css'
|
2024-03-30 19:11:24 +01:00
|
|
|
import { usePrices } from '@/hooks'
|
2024-03-30 20:50:51 +01:00
|
|
|
import { FormAmount } from '@/components/FormAmount'
|
2024-03-30 19:11:24 +01:00
|
|
|
|
|
|
|
export function Buy() {
|
2024-03-31 15:24:07 +02:00
|
|
|
const { prices, isValidating, isLoading } = usePrices()
|
2024-03-30 20:50:51 +01:00
|
|
|
const [amount, setAmount] = useState(100)
|
|
|
|
const [debouncedAmount] = useDebounce(amount, 500)
|
2024-03-30 19:11:24 +01:00
|
|
|
|
|
|
|
return (
|
2024-03-30 20:50:51 +01:00
|
|
|
<div className={stylesShared.results}>
|
|
|
|
<h3 className={stylesShared.title}>
|
|
|
|
Buying with{' '}
|
|
|
|
<FormAmount amount={amount} setAmount={setAmount} token="usd" isFiat />{' '}
|
|
|
|
right now gets you:
|
2024-03-30 19:11:24 +01:00
|
|
|
</h3>
|
|
|
|
<Result
|
|
|
|
tokenSymbol="OCEAN"
|
|
|
|
tokenAddress="0x967da4048cd07ab37855c090aaf366e4ce1b9f48"
|
2024-03-30 20:50:51 +01:00
|
|
|
amount={prices.ocean ? debouncedAmount / prices.ocean : 0}
|
2024-03-30 19:11:24 +01:00
|
|
|
amountAsi={
|
2024-03-30 20:50:51 +01:00
|
|
|
prices.ocean ? (debouncedAmount / prices.ocean) * ratioOceanToAsi : 0
|
2024-03-30 19:11:24 +01:00
|
|
|
}
|
|
|
|
amountFiat={
|
|
|
|
prices.ocean
|
2024-03-30 20:50:51 +01:00
|
|
|
? (debouncedAmount / prices.ocean) * ratioOceanToAsi * prices.asi
|
2024-03-30 19:11:24 +01:00
|
|
|
: 0
|
|
|
|
}
|
2024-03-31 05:32:11 +02:00
|
|
|
isValidating={isValidating}
|
2024-03-30 19:11:24 +01:00
|
|
|
/>
|
|
|
|
<Result
|
|
|
|
tokenSymbol="AGIX"
|
|
|
|
tokenAddress="0x5b7533812759b45c2b44c19e320ba2cd2681b542"
|
2024-03-30 20:50:51 +01:00
|
|
|
amount={prices.agix ? debouncedAmount / prices.agix : 0}
|
2024-03-30 19:11:24 +01:00
|
|
|
amountAsi={
|
2024-03-30 20:50:51 +01:00
|
|
|
prices.agix ? (debouncedAmount / prices.agix) * ratioAgixToAsi : 0
|
2024-03-30 19:11:24 +01:00
|
|
|
}
|
|
|
|
amountFiat={
|
|
|
|
prices.agix
|
2024-03-30 20:50:51 +01:00
|
|
|
? (debouncedAmount / prices.agix) * ratioAgixToAsi * prices.asi
|
2024-03-30 19:11:24 +01:00
|
|
|
: 0
|
|
|
|
}
|
2024-03-31 05:32:11 +02:00
|
|
|
isValidating={isValidating}
|
2024-03-30 19:11:24 +01:00
|
|
|
/>
|
|
|
|
<Result
|
|
|
|
tokenSymbol="FET"
|
|
|
|
tokenAddress="0xaea46a60368a7bd060eec7df8cba43b7ef41ad85"
|
2024-03-30 20:50:51 +01:00
|
|
|
amount={prices.fet ? debouncedAmount / prices.fet : 0}
|
2024-03-30 19:11:24 +01:00
|
|
|
amountAsi={
|
2024-03-30 20:50:51 +01:00
|
|
|
prices.fet ? (debouncedAmount / prices.fet) * ratioFetToAsi : 0
|
2024-03-30 19:11:24 +01:00
|
|
|
}
|
|
|
|
amountFiat={
|
|
|
|
prices.fet
|
2024-03-30 20:50:51 +01:00
|
|
|
? (debouncedAmount / prices.fet) * ratioFetToAsi * prices.asi
|
2024-03-30 19:11:24 +01:00
|
|
|
: 0
|
|
|
|
}
|
2024-03-31 05:32:11 +02:00
|
|
|
isValidating={isValidating}
|
2024-03-30 19:11:24 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|