import { Trans } from '@lingui/macro' import { Currency, Percent, TradeType } from '@uniswap/sdk-core' import { useContext, useState } from 'react' import { AlertTriangle, ArrowDown } from 'react-feather' import { Text } from 'rebass' import { InterfaceTrade } from 'state/routing/types' import styled, { ThemeContext } from 'styled-components/macro' import { useUSDCValue } from '../../hooks/useUSDCPrice' import { ThemedText } from '../../theme' import { isAddress, shortenAddress } from '../../utils' import { computeFiatValuePriceImpact } from '../../utils/computeFiatValuePriceImpact' import { ButtonPrimary } from '../Button' import { LightCard } from '../Card' import { AutoColumn } from '../Column' import { FiatValue } from '../CurrencyInputPanel/FiatValue' import CurrencyLogo from '../CurrencyLogo' import { RowBetween, RowFixed } from '../Row' import TradePrice from '../swap/TradePrice' import { AdvancedSwapDetails } from './AdvancedSwapDetails' import { SwapShowAcceptChanges, TruncatedText } from './styleds' const ArrowWrapper = styled.div` padding: 4px; border-radius: 12px; height: 32px; width: 32px; position: relative; margin-top: -18px; margin-bottom: -18px; left: calc(50% - 16px); display: flex; justify-content: center; align-items: center; background-color: ${({ theme }) => theme.bg1}; border: 4px solid; border-color: ${({ theme }) => theme.bg0}; z-index: 2; ` export default function SwapModalHeader({ trade, allowedSlippage, recipient, showAcceptChanges, onAcceptChanges, }: { trade: InterfaceTrade allowedSlippage: Percent recipient: string | null showAcceptChanges: boolean onAcceptChanges: () => void }) { const theme = useContext(ThemeContext) const [showInverted, setShowInverted] = useState(false) const fiatValueInput = useUSDCValue(trade.inputAmount) const fiatValueOutput = useUSDCValue(trade.outputAmount) return ( {trade.inputAmount.toSignificant(6)} {trade.inputAmount.currency.symbol} {trade.outputAmount.toSignificant(6)} {trade.outputAmount.currency.symbol} {showAcceptChanges ? ( Price Updated Accept ) : null} {trade.tradeType === TradeType.EXACT_INPUT ? ( Output is estimated. You will receive at least{' '} {trade.minimumAmountOut(allowedSlippage).toSignificant(6)} {trade.outputAmount.currency.symbol} {' '} or the transaction will revert. ) : ( Input is estimated. You will sell at most{' '} {trade.maximumAmountIn(allowedSlippage).toSignificant(6)} {trade.inputAmount.currency.symbol} {' '} or the transaction will revert. )} {recipient !== null ? ( Output will be sent to{' '} {isAddress(recipient) ? shortenAddress(recipient) : recipient} ) : null} ) }