From 005adcaa4a644f3b0b969dc71e46ec69105fe9ea Mon Sep 17 00:00:00 2001 From: woodenfurniture <125113430+woodenfurniture@users.noreply.github.com> Date: Thu, 21 Dec 2023 10:35:53 +1100 Subject: [PATCH] chore: de-obfuscate custom slippage warning flag --- .../components/TradeQuotes/TradeQuote.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx index 279f8a20a8b..148e3fde92a 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx @@ -205,14 +205,19 @@ export const TradeQuoteLoaded: FC = ({ const slippage = useMemo(() => { if (!quote) return - const isError = + // user slippage setting was not applied if: + // - the user did not input a custom value + // - the slippage on the quote is different to the custom value + const isUserSlippageNotApplied = userSlippagePercentageDecimal !== undefined && quote.slippageTolerancePercentageDecimal !== userSlippagePercentageDecimal - if (!isError && quote.slippageTolerancePercentageDecimal === undefined) return + if (!isUserSlippageNotApplied && quote.slippageTolerancePercentageDecimal === undefined) { + return + } const tooltip = (() => { - if (isError) { + if (isUserSlippageNotApplied) { return translate('trade.quote.cantSetSlippage', { userSlippageFormatted: toPercent(userSlippagePercentageDecimal), swapperName: quoteData.swapperName, @@ -228,15 +233,15 @@ export const TradeQuoteLoaded: FC = ({ - + {quote.slippageTolerancePercentageDecimal !== undefined && ( - + {toPercent(quote.slippageTolerancePercentageDecimal)} )} - {isError && } + {isUserSlippageNotApplied && }