Skip to content

Commit

Permalink
chore: de-obfuscate custom slippage warning flag
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture committed Dec 21, 2023
1 parent 1dc5cf0 commit 005adca
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,19 @@ export const TradeQuoteLoaded: FC<TradeQuoteProps> = ({
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,
Expand All @@ -228,15 +233,15 @@ export const TradeQuoteLoaded: FC<TradeQuoteProps> = ({
<Skeleton isLoaded={!isLoading}>
<Tooltip label={tooltip}>
<Flex gap={2} alignItems='center'>
<RawText color={isError ? 'text.error' : 'text.subtle'}>
<RawText color={isUserSlippageNotApplied ? 'text.error' : 'text.subtle'}>
<SlippageIcon />
</RawText>
{quote.slippageTolerancePercentageDecimal !== undefined && (
<RawText color={isError ? 'text.error' : undefined}>
<RawText color={isUserSlippageNotApplied ? 'text.error' : undefined}>
{toPercent(quote.slippageTolerancePercentageDecimal)}
</RawText>
)}
{isError && <WarningIcon color='text.error' />}
{isUserSlippageNotApplied && <WarningIcon color='text.error' />}
</Flex>
</Tooltip>
</Skeleton>
Expand Down

0 comments on commit 005adca

Please sign in to comment.