import { Currency, Percent, TradeType } from '@uniswap/sdk-core' import { Trade as V2Trade } from '@uniswap/v2-sdk' import { Trade as V3Trade } from '@uniswap/v3-sdk' import React, { useContext, useState } from 'react' import { ArrowDown, AlertTriangle } from 'react-feather' import { Text } from 'rebass' import styled, { ThemeContext } from 'styled-components' import { useUSDCValue } from '../../hooks/useUSDCPrice' import { TYPE } from '../../theme' import { ButtonPrimary } from '../Button' import { isAddress, shortenAddress } from '../../utils' import { computeFiatValuePriceImpact } from '../../utils/computeFiatValuePriceImpact' import { AutoColumn } from '../Column' import { FiatValue } from '../CurrencyInputPanel/FiatValue' import CurrencyLogo from '../CurrencyLogo' import { RowBetween, RowFixed } from '../Row' import { TruncatedText, SwapShowAcceptChanges } from './styleds' import { AdvancedSwapDetails } from './AdvancedSwapDetails' import { LightCard } from '../Card' import { DarkGreyCard } from '../Card' import TradePrice from '../swap/TradePrice' export 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}; z-index: 2; ` export default function SwapModalHeader({ trade, allowedSlippage, recipient, showAcceptChanges, onAcceptChanges, }: { trade: V2Trade | V3Trade 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 ( From {trade.inputAmount.currency.symbol} {trade.inputAmount.toSignificant(6)} To {trade.outputAmount.currency.symbol} {trade.outputAmount.toSignificant(6)} {'Price:'} {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} ) }