14.05.2026 rip
This commit is contained in:
@@ -3,13 +3,11 @@ import { PrimaryButton } from '@shared/ui'
|
||||
import { useWalletBalance, useWalletAddresses, useTokensList, useRelayQuote, type Chain } from '@features/wallet'
|
||||
import { useDebounce } from '@shared/lib/hooks/useDebounce'
|
||||
import { TOKENS_LIST, buildTokensFromBalance, useSwapForm } from '../model/useSwapForm'
|
||||
import { RateRow } from './RateRow'
|
||||
import { SwapCard } from './SwapCard'
|
||||
import { SwapDirectionButton } from './SwapDirectionButton'
|
||||
import { SwapInfoPanel } from './SwapInfoPanel'
|
||||
import styles from './SwapForm.module.css'
|
||||
|
||||
const RATE = 82.2578
|
||||
|
||||
const CHAIN_ID: Record<string, number> = { ETH: 1, BSC: 56, SOL: 792703809 }
|
||||
const NATIVE_ADDR: Record<string, string> = {
|
||||
@@ -24,8 +22,7 @@ export function SwapForm() {
|
||||
const {
|
||||
fromAmount, fromUsd,
|
||||
fromToken, toToken,
|
||||
isRefreshing,
|
||||
setFromAmount, setPercent, swapTokens, refreshRate,
|
||||
setFromAmount, setPercent, swapTokens,
|
||||
setFromToken, setToToken,
|
||||
} = useSwapForm()
|
||||
|
||||
@@ -47,27 +44,27 @@ export function SwapForm() {
|
||||
const chainId = CHAIN_ID[fromNetwork]
|
||||
const walletAddress = addresses?.find(a => a.chain === fromNetwork)?.address
|
||||
const fromContract = tokensList?.find(t => t.chain === fromNetwork && t.symbol === fromToken.symbol)?.contract ?? nativeAddr(fromNetwork)
|
||||
const toContract = tokensList?.find(t => t.chain === fromNetwork && t.symbol === toToken.symbol)?.contract ?? nativeAddr(fromNetwork)
|
||||
const toContract = tokensList?.find(t => t.chain === fromNetwork && t.symbol === toToken.symbol)?.contract ?? nativeAddr(fromNetwork)
|
||||
|
||||
const parsedAmount = parseFloat(debouncedAmount)
|
||||
const quotePayload = chainId && walletAddress && parsedAmount > 0
|
||||
? {
|
||||
user: walletAddress,
|
||||
recipient: walletAddress,
|
||||
originChainId: chainId,
|
||||
destinationChainId: chainId,
|
||||
originCurrency: fromContract,
|
||||
destinationCurrency: toContract,
|
||||
amount: Math.round(parsedAmount * Math.pow(10, fromToken.decimals)).toString(),
|
||||
tradeType: 'EXACT_INPUT' as const,
|
||||
}
|
||||
user: walletAddress,
|
||||
recipient: walletAddress,
|
||||
originChainId: chainId,
|
||||
destinationChainId: chainId,
|
||||
originCurrency: fromContract,
|
||||
destinationCurrency: toContract,
|
||||
amount: Math.round(parsedAmount * Math.pow(10, fromToken.decimals)).toString(),
|
||||
tradeType: 'EXACT_INPUT' as const,
|
||||
}
|
||||
: null
|
||||
|
||||
const { data: quoteData } = useRelayQuote(quotePayload)
|
||||
|
||||
const displayToAmount = quoteData?.details.currencyOut.amountFormatted ?? '0'
|
||||
const displayToUsd = quoteData?.details.currencyOut.amountUsd
|
||||
const gasFee = quoteData?.fees.gas.amountUsd
|
||||
const displayToUsd = quoteData?.details.currencyOut.amountUsd
|
||||
const gasFee = quoteData?.fees.gas.amountUsd
|
||||
|
||||
return (
|
||||
<div className={styles.form}>
|
||||
@@ -95,14 +92,6 @@ export function SwapForm() {
|
||||
onTokenChange={setToToken}
|
||||
/>
|
||||
|
||||
<RateRow
|
||||
fromSymbol={fromToken.symbol}
|
||||
toSymbol={toToken.symbol}
|
||||
rate={RATE}
|
||||
isRefreshing={isRefreshing}
|
||||
onRefresh={refreshRate}
|
||||
/>
|
||||
|
||||
<SwapInfoPanel gasFee={gasFee} />
|
||||
|
||||
<PrimaryButton />
|
||||
|
||||
Reference in New Issue
Block a user