diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 0661b338c..604d670f3 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1958,8 +1958,8 @@ "swapSelectQuotePopoverDescription": { "message": "Below are all the quotes gathered from multiple liquidity sources." }, - "swapSlippageTooLow": { - "message": "Slippage must be greater than zero" + "swapSlippageNegative": { + "message": "Slippage must be greater or equal to zero" }, "swapSource": { "message": "Liquidity source" diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index c85673d74..8c4dc1d7f 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -1690,9 +1690,6 @@ "swapSelectQuotePopoverDescription": { "message": "A continuación se muestran todas las cotizaciones recopiladas de múltiples fuentes de liquidez." }, - "swapSlippageTooLow": { - "message": "El deslizamiento debe ser mayor que cero" - }, "swapSource": { "message": "Fuente de liquidez" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 1fe79aad6..293f5ad08 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -1690,9 +1690,6 @@ "swapSelectQuotePopoverDescription": { "message": "A continuación se muestran todas las cotizaciones recopiladas de múltiples fuentes de liquidez." }, - "swapSlippageTooLow": { - "message": "El deslizamiento debe ser mayor que cero" - }, "swapSource": { "message": "Fuente de liquidez" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index c222c9c13..0dca37b75 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -1660,9 +1660,6 @@ "swapSelectQuotePopoverDescription": { "message": "नीचे दिए गए सभी उद्धरण कई चलनिधि स्रोतों से एकत्र किए गए हैं।" }, - "swapSlippageTooLow": { - "message": "स्लिपेज शून्य से अधिक होना चाहिए" - }, "swapSource": { "message": "चलनिधि का स्रोत" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index e497c2eb0..e7c1fd9c3 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -1660,9 +1660,6 @@ "swapSelectQuotePopoverDescription": { "message": "Di bawah ini adalah semua kuota yang dikumpulkan dari beberapa sumber likuiditas." }, - "swapSlippageTooLow": { - "message": "Slippage harus lebih besar dari nol" - }, "swapSource": { "message": "Sumber likuiditas" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index a312707c4..bb3c59c2e 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -1702,9 +1702,6 @@ "swapSelectQuotePopoverDescription": { "message": "Sotto trovi tutte le quotazioni raccolte da multiple sorgenti di liquidità." }, - "swapSlippageTooLow": { - "message": "Lo slippage deve essere maggiore di zero" - }, "swapSource": { "message": "Sorgente di liquidità" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index 78d2132a2..ca3dfab66 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -1690,9 +1690,6 @@ "swapSelectQuotePopoverDescription": { "message": "以下は複数の流動性ソースから収集したすべての見積です。" }, - "swapSlippageTooLow": { - "message": "スリッページは 0 より多くする必要があります。" - }, "swapSource": { "message": "流動性ソース" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 5cd7c37fc..cee0020f3 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -1660,9 +1660,6 @@ "swapSelectQuotePopoverDescription": { "message": "다음은 여러 유동성 소스에서 수집한 전체 견적입니다." }, - "swapSlippageTooLow": { - "message": "슬리패지는 0보다 커야 합니다." - }, "swapSource": { "message": "유동성 소스" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 7208b08fe..41d25a030 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -1660,9 +1660,6 @@ "swapSelectQuotePopoverDescription": { "message": "Ниже приведены все котировки, собранные из нескольких источников ликвидности." }, - "swapSlippageTooLow": { - "message": "Проскальзывание должно быть больше нуля" - }, "swapSource": { "message": "Источник ликвидности" }, diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 70b7b8ad8..fbde2f6b3 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -1657,9 +1657,6 @@ "swapSelectQuotePopoverDescription": { "message": "Makikita sa ibaba ang lahat ng quote na nakuha mula sa maraming pinagkukunan ng liquidity." }, - "swapSlippageTooLow": { - "message": "Dapat ay mas malaki sa zero ang slippage" - }, "swapSource": { "message": "Pinagkunan ng liquidity" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index 883c2f67d..e55933c10 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -1660,9 +1660,6 @@ "swapSelectQuotePopoverDescription": { "message": "Dưới đây là tất cả các báo giá thu thập từ nhiều nguồn thanh khoản." }, - "swapSlippageTooLow": { - "message": "Mức trượt giá phải lớn hơn 0" - }, "swapSource": { "message": "Nguồn thanh khoản" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 1c0071709..782ff4f29 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -1690,9 +1690,6 @@ "swapSelectQuotePopoverDescription": { "message": "以下是从多个流动资金来源收集到的所有报价。" }, - "swapSlippageTooLow": { - "message": "滑点必须大于零" - }, "swapSource": { "message": "流动资金来源" }, diff --git a/ui/pages/swaps/build-quote/build-quote.js b/ui/pages/swaps/build-quote/build-quote.js index 22ed85d30..d9c0ea7c3 100644 --- a/ui/pages/swaps/build-quote/build-quote.js +++ b/ui/pages/swaps/build-quote/build-quote.js @@ -533,7 +533,7 @@ export default function BuildQuote({ !isFeatureFlagLoaded || !Number(inputValue) || !selectedToToken?.address || - Number(maxSlippage) === 0 || + Number(maxSlippage) < 0 || Number(maxSlippage) > MAX_ALLOWED_SLIPPAGE || (toTokenIsNotDefault && occurances < 2 && !verificationClicked) } diff --git a/ui/pages/swaps/slippage-buttons/slippage-buttons.js b/ui/pages/swaps/slippage-buttons/slippage-buttons.js index 83b230062..66a11f43b 100644 --- a/ui/pages/swaps/slippage-buttons/slippage-buttons.js +++ b/ui/pages/swaps/slippage-buttons/slippage-buttons.js @@ -13,8 +13,12 @@ export default function SlippageButtons({ }) { const t = useContext(I18nContext); const [customValue, setCustomValue] = useState(() => { - if (currentSlippage && currentSlippage !== 2 && currentSlippage !== 3) { - return currentSlippage; + if ( + typeof currentSlippage === 'number' && + currentSlippage !== 2 && + currentSlippage !== 3 + ) { + return currentSlippage.toString(); } return ''; }); @@ -24,7 +28,7 @@ export default function SlippageButtons({ return 1; } else if (currentSlippage === 2) { return 0; - } else if (currentSlippage) { + } else if (typeof currentSlippage === 'number') { return 2; } return 1; // Choose activeButtonIndex = 1 for 3% slippage by default. @@ -33,9 +37,12 @@ export default function SlippageButtons({ let errorText = ''; if (customValue) { - if (Number(customValue) <= 0) { - errorText = t('swapSlippageTooLow'); - } else if (Number(customValue) < 0.5) { + // customValue is a string, e.g. '0' + if (Number(customValue) < 0) { + errorText = t('swapSlippageNegative'); + } else if (Number(customValue) > 0 && Number(customValue) <= 1) { + // We will not show this warning for 0% slippage, because we will only + // return non-slippage quotes from off-chain makers. errorText = t('swapLowSlippageError'); } else if ( Number(customValue) >= 5 && @@ -136,10 +143,6 @@ export default function SlippageButtons({ ref={setInputRef} onBlur={() => { setEnteringCustomValue(false); - if (customValue === '0') { - setCustomValue(''); - setActiveButtonIndex(1); - } }} value={customValue || ''} />