asi-calculator/features/strategies/components/Swap/Swap.tsx
Matthias Kretschmann 436babf4ba
add CUDOS calculations (#40)
* add CUDOS calculations

* content updates

* token order switch

* uniswap quote fix

* list & link community proposals

* migration tool scenario simplification

* rename Uniswap label

* ratio harmonization

* buy ratio fix

* copy updates

* copy updates

* default to 1000 CUDOS
2024-09-19 21:01:39 +01:00

45 lines
1.2 KiB
TypeScript

'use client'
import {
FormAmount,
FormMarket,
type Market,
usePersistentState
} from '@/features/strategies'
import stylesShared from '@/features/strategies/styles/shared.module.css'
import type { TokenSymbol } from '@/types'
import { useDebounce } from 'use-debounce'
import { SwapResults } from './Results'
export function Swap() {
const [amount, setAmount] = usePersistentState('swapAmount', 1000)
const [debouncedAmount] = useDebounce(amount, 500)
const [tokenSymbol, setTokenSymbol] = usePersistentState<TokenSymbol>(
'swapTokenSymbol',
'CUDOS'
)
const [market, setMarket] = usePersistentState<Market>('swapMarket', 'all')
return (
<div className={stylesShared.results}>
<h3 className={stylesShared.title}>
Holding or swapping{' '}
<FormAmount
amount={amount}
token={tokenSymbol}
setAmount={setAmount}
setToken={setTokenSymbol}
/>{' '}
on <FormMarket market={market} setMarket={setMarket} /> right now gets
you:
</h3>
<SwapResults
tokenSymbol={tokenSymbol}
amount={debouncedAmount}
market={market}
/>
</div>
)
}