Commit 5bc21beb authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

update summary details (#3254)

parent c3d67274
...@@ -10,7 +10,7 @@ import styled, { Color, ThemedText } from 'lib/theme' ...@@ -10,7 +10,7 @@ import styled, { Color, ThemedText } from 'lib/theme'
import { useMemo } from 'react' import { useMemo } from 'react'
import { currencyId } from 'utils/currencyId' import { currencyId } from 'utils/currencyId'
import { formatCurrencyAmount } from 'utils/formatCurrencyAmount' import { formatCurrencyAmount } from 'utils/formatCurrencyAmount'
import { computeRealizedPriceImpact } from 'utils/prices' import { computeRealizedLPFeeAmount, computeRealizedPriceImpact } from 'utils/prices'
import Row from '../../Row' import Row from '../../Row'
...@@ -47,6 +47,8 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) { ...@@ -47,6 +47,8 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) {
const outputCurrency = outputAmount.currency const outputCurrency = outputAmount.currency
const priceImpact = useMemo(() => computeRealizedPriceImpact(trade), [trade]) const priceImpact = useMemo(() => computeRealizedPriceImpact(trade), [trade])
const lpFeeAmount = useMemo(() => computeRealizedLPFeeAmount(trade), [trade])
const integrator = window.location.hostname const integrator = window.location.hostname
const feeOptions = useAtomValue(feeOptionsAtom) const feeOptions = useAtomValue(feeOptionsAtom)
...@@ -71,12 +73,20 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) { ...@@ -71,12 +73,20 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) {
} }
rows.push(priceImpactRow) rows.push(priceImpactRow)
if (trade.tradeType === TradeType.EXACT_INPUT) { if (lpFeeAmount) {
const localizedFeeAmount = formatCurrencyAmount(lpFeeAmount, 6, i18n.locale)
rows.push([
t`Liquidity provider fee`,
`${localizedFeeAmount} ${inputCurrency.symbol || currencyId(inputCurrency)}`,
])
}
if (trade.tradeType === TradeType.EXACT_OUTPUT) {
const localizedMaxSent = formatCurrencyAmount(trade.maximumAmountIn(allowedSlippage), 6, i18n.locale) const localizedMaxSent = formatCurrencyAmount(trade.maximumAmountIn(allowedSlippage), 6, i18n.locale)
rows.push([t`Maximum sent`, `${localizedMaxSent} ${inputCurrency.symbol}`]) rows.push([t`Maximum sent`, `${localizedMaxSent} ${inputCurrency.symbol}`])
} }
if (trade.tradeType === TradeType.EXACT_OUTPUT) { if (trade.tradeType === TradeType.EXACT_INPUT) {
const localizedMaxSent = formatCurrencyAmount(trade.minimumAmountOut(allowedSlippage), 6, i18n.locale) const localizedMaxSent = formatCurrencyAmount(trade.minimumAmountOut(allowedSlippage), 6, i18n.locale)
rows.push([t`Minimum received`, `${localizedMaxSent} ${outputCurrency.symbol}`]) rows.push([t`Minimum received`, `${localizedMaxSent} ${outputCurrency.symbol}`])
} }
...@@ -88,7 +98,18 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) { ...@@ -88,7 +98,18 @@ export default function Details({ trade, allowedSlippage }: DetailsProps) {
rows.push(slippageToleranceRow) rows.push(slippageToleranceRow)
return rows return rows
}, [allowedSlippage, feeOptions, inputCurrency, integrator, i18n, outputAmount, outputCurrency, priceImpact, trade]) }, [
feeOptions,
priceImpact,
lpFeeAmount,
trade,
allowedSlippage,
outputAmount,
i18n.locale,
integrator,
outputCurrency,
inputCurrency,
])
return ( return (
<> <>
{details.map(([label, detail, color]) => ( {details.map(([label, detail, color]) => (
......
...@@ -151,15 +151,15 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial ...@@ -151,15 +151,15 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial
<Trans>Output is estimated.</Trans> <Trans>Output is estimated.</Trans>
{independentField === Field.INPUT && ( {independentField === Field.INPUT && (
<Trans> <Trans>
You will send at most {formatCurrencyAmount(trade.maximumAmountIn(allowedSlippage), 6, i18n.locale)}{' '} You will receive at least{' '}
{inputCurrency.symbol} or the transaction will revert. {formatCurrencyAmount(trade.minimumAmountOut(allowedSlippage), 6, i18n.locale)} {outputCurrency.symbol}{' '}
or the transaction will revert.
</Trans> </Trans>
)} )}
{independentField === Field.OUTPUT && ( {independentField === Field.OUTPUT && (
<Trans> <Trans>
You will receive at least{' '} You will send at most {formatCurrencyAmount(trade.maximumAmountIn(allowedSlippage), 6, i18n.locale)}{' '}
{formatCurrencyAmount(trade.minimumAmountOut(allowedSlippage), 6, i18n.locale)} {outputCurrency.symbol}{' '} {inputCurrency.symbol} or the transaction will revert.
or the transaction will revert.
</Trans> </Trans>
)} )}
</Estimate> </Estimate>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment