asi-calculator/features/strategies/components/Swap/Swap.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-03-31 16:48:31 +02:00
'use client'
import {
FormAmount,
FormMarket,
type Market,
usePersistentState
} from '@/features/strategies'
2024-04-01 14:42:08 +02:00
import stylesShared from '@/features/strategies/styles/shared.module.css'
import type { TokenSymbol } from '@/types'
import { useDebounce } from 'use-debounce'
import { SwapResults } from './Results'
2024-03-31 16:48:31 +02:00
export function Swap() {
const [amount, setAmount] = usePersistentState('swapAmount', 100)
2024-03-31 16:48:31 +02:00
const [debouncedAmount] = useDebounce(amount, 500)
const [tokenSymbol, setTokenSymbol] = usePersistentState<TokenSymbol>(
'swapTokenSymbol',
'OCEAN'
)
const [market, setMarket] = usePersistentState<Market>('swapMarket', 'all')
2024-03-31 16:48:31 +02:00
return (
<div className={stylesShared.results}>
<h3 className={stylesShared.title}>
Holding or swapping{' '}
<FormAmount
amount={amount}
2024-03-31 23:50:43 +02:00
token={tokenSymbol}
2024-03-31 16:48:31 +02:00
setAmount={setAmount}
2024-03-31 23:50:43 +02:00
setToken={setTokenSymbol}
2024-03-31 16:48:31 +02:00
/>{' '}
2024-04-01 14:42:08 +02:00
on <FormMarket market={market} setMarket={setMarket} /> right now gets
you:
2024-03-31 16:48:31 +02:00
</h3>
2024-04-01 14:42:08 +02:00
<SwapResults
tokenSymbol={tokenSymbol}
amount={debouncedAmount}
market={market}
/>
2024-03-31 16:48:31 +02:00
</div>
)
}