mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
Show a slippage notification again before submitting a swap, improve content for slippage notifications (#20364)
This commit is contained in:
parent
d76b458235
commit
679d6686e3
15
app/_locales/de/messages.json
generated
15
app/_locales/de/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Limit bearbeiten"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Transaktionseinstellungen anpassen"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Dies ist erforderlich und gibt MetaMask die Erlaubnis, Ihren $1 zu swappen.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Maximale Slippage ist zu niedrig, weswegen Ihre Transaktion fehlschlagen könnte."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Slippage erhöhen, um Fehlschlag der Transaktion zu verhindern"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Wenn sich der Kurs zwischen der Aufgabe Ihrer Bestellung und der Bestätigung ändert, nennt man das „Slippage”. Ihr Swap wird automatisch storniert, wenn die Abweichung die von Ihnen eingestellte „Abweichungstoleranz” überschreitet."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Die eingegebene Slippage wird als sehr hoch angesehen und könnte einen schlechten Kurs bewirken"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Sehr hohe Slippage"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Es gibt weniger Anbieter mit Null-Slippage, was in einem weniger konkurrenzfähigen Angebot resultieren könne."
|
||||
},
|
||||
|
15
app/_locales/el/messages.json
generated
15
app/_locales/el/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Επεξεργασία ορίου"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Επεξεργασία ρυθμίσεων συναλλαγών"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Αυτό απαιτείται και δίνει άδεια στο MetaMask για να ανταλλάξετε το $1 σας.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Η μέγιστη απόκλιση είναι πολύ χαμηλή, με αποτέλεσμα την αποτυχία της συναλλαγής σας."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Αυξήστε την απόκλιση για να αποφύγετε την αποτυχία της συναλλαγής"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Εάν η τιμή αλλάξει μεταξύ της ώρας που η εντολή αγοράς σας υποβάλλεται και επιβεβαιώνεται, αυτό ονομάζεται «ολίσθηση». Η συναλλαγή θα ακυρωθεί αυτόματα εάν η ολίσθηση υπερβαίνει τη ρύθμιση «ανοχή ολίσθησης»."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Η απόκλιση που καταχωρήθηκε θεωρείται πολύ υψηλή και μπορεί να οδηγήσει σε δυσμενή τιμή"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Πολύ υψηλή απόκλιση"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Υπάρχουν λίγοι πάροχοι προσφορών με μηδενική απόκλιση, γεγονός που θα οδηγήσει σε λιγότερο ανταγωνιστική προσφορά."
|
||||
},
|
||||
|
40
app/_locales/en/messages.json
generated
40
app/_locales/en/messages.json
generated
@ -4364,6 +4364,9 @@
|
||||
"swap": {
|
||||
"message": "Swap"
|
||||
},
|
||||
"swapAdjustSlippage": {
|
||||
"message": "Adjust slippage"
|
||||
},
|
||||
"swapAggregator": {
|
||||
"message": "Aggregator"
|
||||
},
|
||||
@ -4422,9 +4425,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Edit limit"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Edit transaction settings"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "This is required and gives MetaMask permission to swap your $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4485,6 +4485,9 @@
|
||||
"message": "Gas fees are paid to crypto miners who process transactions on the $1 network. MetaMask does not profit from gas fees.",
|
||||
"description": "$1 is the selected network, e.g. Ethereum or BSC"
|
||||
},
|
||||
"swapHighSlippage": {
|
||||
"message": "High slippage"
|
||||
},
|
||||
"swapHighSlippageWarning": {
|
||||
"message": "Slippage amount is very high."
|
||||
},
|
||||
@ -4499,6 +4502,9 @@
|
||||
"swapLearnMore": {
|
||||
"message": "Learn more about Swaps"
|
||||
},
|
||||
"swapLowSlippage": {
|
||||
"message": "Low slippage"
|
||||
},
|
||||
"swapLowSlippageError": {
|
||||
"message": "Transaction may fail, max slippage too low."
|
||||
},
|
||||
@ -4609,6 +4615,20 @@
|
||||
"swapShowLatestQuotes": {
|
||||
"message": "Show latest quotes"
|
||||
},
|
||||
"swapSlippageHighDescription": {
|
||||
"message": "The slippage entered ($1%) is considered very high and may result in a bad rate",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageHighTitle": {
|
||||
"message": "High slippage"
|
||||
},
|
||||
"swapSlippageLowDescription": {
|
||||
"message": "A value this low ($1%) may result in a failed swap",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageLowTitle": {
|
||||
"message": "Low slippage"
|
||||
},
|
||||
"swapSlippageNegative": {
|
||||
"message": "Slippage must be greater or equal to zero"
|
||||
},
|
||||
@ -4622,27 +4642,15 @@
|
||||
"message": "Slippage tolerance must be 15% or less. Anything higher will result in a bad rate."
|
||||
},
|
||||
"swapSlippageOverLimitTitle": {
|
||||
"message": "Reduce slippage to continue"
|
||||
"message": "Very high slippage"
|
||||
},
|
||||
"swapSlippagePercent": {
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Max slippage is too low which may cause your transaction to fail."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Increase slippage to avoid transaction failure"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "If the price changes between the time your order is placed and confirmed it’s called “slippage”. Your swap will automatically cancel if slippage exceeds your “slippage tolerance” setting."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "The slippage entered is considered very high and may result in a bad rate"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Very high slippage"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "There are fewer zero-slippage quote providers which will result in a less competitive quote."
|
||||
},
|
||||
|
15
app/_locales/es/messages.json
generated
15
app/_locales/es/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Editar límite"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Editar la configuración de la transacción"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Esta acción es obligatoria y le da permiso a MetaMask para canjear su $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "El desfase máximo es demasiado bajo, lo que puede hacer que su transacción fracase."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Aumente el desfase para evitar fallas en las transacciones"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Si el precio cambia entre el momento en que hace el pedido y cuando se confirma, se denomina \"desfase\". El canje se cancelará automáticamente si el desfase supera lo establecido en la configuración de la \"tolerancia de desfase\"."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "El desfase ingresado se considera muy alto y puede resultar en una mala tasa"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Desfase muy alto"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Hay menos proveedores de cotizaciones de deslizamiento cero, lo que resultará en una cotización menos competitiva."
|
||||
},
|
||||
|
15
app/_locales/fr/messages.json
generated
15
app/_locales/fr/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Modifier la limite"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Modifier les paramètres de la transaction"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Cette information est nécessaire et autorise MetaMask à effectuer le swap de vos $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1 %",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "La transaction peut échouer, car le slippage maximal est trop faible."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Augmentez le slippage pour éviter l’échec de la transaction"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Si le prix fluctue entre le moment où vous placez un ordre et le moment où il est exécuté, on parle alors d’un « effet de glissement » ou « slippage ». Votre swap sera automatiquement annulé si ce phénomène dépasse le « seuil de glissement toléré » que vous avez fixé."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Le slippage saisi est considéré comme très élevé et peut donner lieu à un taux de change désavantageux"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Slippage très élevé"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Il y a moins de prestataires de services d’investissement sans slippage, ce qui se traduit par une cotation moins compétitive."
|
||||
},
|
||||
|
15
app/_locales/hi/messages.json
generated
15
app/_locales/hi/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "सीमा संपादित करें"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "लेन-देन सेटिंग्स को संपादित करें"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "यह आवश्यक है और MetaMask को आपके $1 को स्वैप करने की अनुमति देता है।",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "अधिकतम स्लिपेज बहुत कम है जिसके कारण आपका लेन-देन विफल हो सकता है।"
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "लेन-देन की विफलता से बचने के लिए स्लिपेज बढ़ाएं"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "यदि आपके ऑर्डर किए जाने और पुष्टि किए जाने के समय के बीच मूल्य में परिवर्तन होता है, तो इसे \"स्लिपेज\" कहा जाता है। यदि स्लिपेज आपकी \"स्लिपेज टॉलरेंस\" सेटिंग से अधिक हो जाता है, तो आपका स्वैप स्वतः रद्द हो जाएगा।"
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "दर्ज किया गया स्लिपेज बहुत अधिक माना जाता है और इसका परिणाम खराब दर हो सकता है"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "बहुत अधिक स्लिपेज"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "शून्य-स्लिपेज उद्धरण प्रदाता कम हैं, जिसके परिणामस्वरूप कम प्रतिस्पर्धी उद्धरण होगा।"
|
||||
},
|
||||
|
15
app/_locales/id/messages.json
generated
15
app/_locales/id/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Edit batas"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Edit pengaturan transaksi"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Ini diwajibkan dan memberikan MetaMask izin untuk menukar $1 Anda.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Selip maks terlalu rendah sehingga dapat menyebabkan transaksi gagal."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Tingkatkan selip untuk menghindari kegagalan transaksi"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Jika harga berubah antara waktu penempatan dan konfirmasi order Anda, ini disebut “slippage”. Swap Anda akan otomatis dibatalkan jika slippage melebihi pengaturan “slippage tolerance”."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Selip yang dimasukkan dianggap sangat tinggi dan dapat mengakibatkan tarif yang tidak efektif"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Selip sangat tinggi"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Ada lebih sedikit penyedia kuotasi nol selip sehingga akan menghasilkan kuotasi yang kurang kompetitif."
|
||||
},
|
||||
|
15
app/_locales/ja/messages.json
generated
15
app/_locales/ja/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "限度額を編集"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "トランザクション設定を編集"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "これは必須であり、MetaMaskに$1をスワップする許可を付与します。",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "最大スリッページが低すぎ、トランザクションが失敗する可能性があります。"
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "トランザクションの失敗を防ぐために、スリッページを増やしてください。"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "注文から確定までの間に価格が変動することを「スリッページ」といいます。スリッページが「スリッページ許容範囲」の設定を超えた場合、スワップは自動的にキャンセルされます。"
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "入力されたスリッページが非常に高いため、不利なレートになる可能性があります"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "非常に高いスリッページ"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "スリッページがゼロのプロバイダーは少ないため、不利なクォートになる可能性があります。"
|
||||
},
|
||||
|
15
app/_locales/ko/messages.json
generated
15
app/_locales/ko/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "한도 편집"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "거래 설정 편집"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "MetaMask에게 $1 스왑 권한을 부여하는 것으로, 이는 필수입니다.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "최대 슬리피지가 너무 낮아 거래가 실패할 수 있습니다"
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "거래 실패를 막으려면 슬리피지를 높이세요"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "주문 시점과 확인 시점 사이에 가격이 변동되는 현상을 \"슬리패지\"라고 합니다. 슬리패지가 \"최대 슬리패지\" 설정을 초과하면 스왑이 자동으로 취소됩니다."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "입력한 슬리피지는 너무 높아 가격이 낮아질 수 있습니다"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "너무 높은 슬리피지"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "제로 슬리피지 견적 제공자가 거의 없어 견적의 경쟁력이 약화될 수 있습니다"
|
||||
},
|
||||
|
15
app/_locales/pt/messages.json
generated
15
app/_locales/pt/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Editar limite"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Editar configurações de transação"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Isso é obrigatório e dá à MetaMask permissão para trocar o seu $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "O slippage máximo está muito baixo, o que pode fazer sua transação falhar."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Aumente o slippage para evitar falha na transação"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Chamamos de \"slippage\" quando o preço muda entre o momento de realização da ordem e sua confirmação. Seu swap será cancelado automaticamente se o slippage exceder sua configuração de \"tolerância a slippage\"."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "O slippage inserido é considerado muito alto e pode resultar em uma taxa ruim"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Slippage muito alto"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Há menos provedores de cotação com slippage zero, o que resultará em uma cotação menos competitiva."
|
||||
},
|
||||
|
15
app/_locales/ru/messages.json
generated
15
app/_locales/ru/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Изменить лимит"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Изменить настройки транзакции"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Это необходимо и дает MetaMask разрешение на обмен вашего $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Максимальное проскальзывание слишком мало, что может привести к сбою транзакции."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Увеличьте проскальзывание, чтобы избежать неудачной транзакции"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Изменение цены в период между размещением заказа и подтверждением называется «проскальзыванием». Обмен будет автоматически отменен, если фактическое проскальзывание превысит установленный «допуск проскальзывания»."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Введенное проскальзывание считается очень высоким и может привести к неудачной ставке"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Очень высокое проскальзывание"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Существует меньше поставщиков котировок с нулевым проскальзыванием, что приводит к менее конкурентоспособным котировкам."
|
||||
},
|
||||
|
15
app/_locales/tl/messages.json
generated
15
app/_locales/tl/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "I-edit ang limitasyon"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "I-edit ang mga setting ng transaksyon"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Kinakailangan ito at nagbibigay ito ng pahintulot sa MetaMask na i-swap ang iyong $1.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Masyadong mababa ang max slippage na maaaring maging sanhi para mabigo ang iyong transaksyon."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Dagdagan ang slippage para maiwasan ang pagkabigo ng transaksyon"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Kung magbabago ang presyo sa pagitan ng oras na nailagay at nakumpirma ang iyong order, tinatawag itong \"slippage\". Awtomatikong makakansela ang iyong swap kung lalampas ang slippage sa iyong setting ng “pagpapahintulot sa slippage”."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Itinuturing na napakataas ng inilagay na slippage at maaari itong magresulta sa hindi magandang rate"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Napakataas na slippage"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Kakaunti ang mga tagapagbigay ng zero-slippage quote at maaari itong magresulta sa hindi gaanong mapagkumpitensyang quote."
|
||||
},
|
||||
|
15
app/_locales/tr/messages.json
generated
15
app/_locales/tr/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Limiti düzenle"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "İşlem ayarlarını düzenleyin"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Bu gereklidir ve MetaMask'e $1 takası yapma izni verir.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "%$1",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Maks. fark çok düşük ve bu durum işleminizin başarısız olmasına neden olabilir."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "İşlemin başarısız olmasını önlemek için farkı artırın"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Emrinizin verildiği ve onaylandığı zamanlar arasında fiyat farkı oluşursa buna \"fark\" denir. Fark, \"fark toleransı\" ayarınızı aşarsa takas işleminiz otomatik olarak iptal edilir."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Girilen fark çok yüksek kabul ediliyor ve kötü bir oranla sonuçlanabilir"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Fark çok yüksek"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Daha az rekabetçi bir kota ile sonuçlanacak olan az sayıda sıfır fark kotalı sağlayıcı var."
|
||||
},
|
||||
|
15
app/_locales/vi/messages.json
generated
15
app/_locales/vi/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "Chỉnh sửa giới hạn"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "Chỉnh sửa cài đặt giao dịch"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "Thao tác này là bắt buộc và cấp cho MetaMask quyền hoán đổi $1 của bạn.",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "Mức trượt giá tối đa quá thấp có thể khiến giao dịch của bạn không thành công."
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "Tăng mức trượt giá để tránh giao dịch thất bại"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "Khi giá giữa thời điểm đặt lệnh và thời điểm xác nhận lệnh thay đổi, hiện tượng này được gọi là \"trượt giá\". Giao dịch hoán đổi của bạn sẽ tự động hủy nếu mức trượt giá vượt quá \"mức trượt giá cho phép\" đã đặt."
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "Mức trượt giá đã nhập được xem là quá cao và có thể dẫn đến tỷ giá không sinh lời"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "Mức trượt giá quá cao"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "Có ít nhà cung cấp báo giá có mức trượt giá bằng 0 hơn sẽ dẫn đến báo giá kém cạnh tranh hơn."
|
||||
},
|
||||
|
15
app/_locales/zh_CN/messages.json
generated
15
app/_locales/zh_CN/messages.json
generated
@ -4419,9 +4419,6 @@
|
||||
"swapEditLimit": {
|
||||
"message": "编辑限制"
|
||||
},
|
||||
"swapEditTransactionSettings": {
|
||||
"message": "编辑交易设置"
|
||||
},
|
||||
"swapEnableDescription": {
|
||||
"message": "这是必须的,并且允许 MetaMask 兑换您的 $1。",
|
||||
"description": "Gives the user info about the required approval transaction for swaps. $1 will be the symbol of a token being approved for swaps."
|
||||
@ -4625,21 +4622,9 @@
|
||||
"message": "$1%",
|
||||
"description": "$1 is the amount of % for slippage"
|
||||
},
|
||||
"swapSlippageTooLowDescription": {
|
||||
"message": "最大滑点太低,可能导致交易失败。"
|
||||
},
|
||||
"swapSlippageTooLowTitle": {
|
||||
"message": "提高滑点以避免交易失败"
|
||||
},
|
||||
"swapSlippageTooltip": {
|
||||
"message": "如果价格于下单到订单确认期间发生变化,这被称为“滑点”。如果滑点超过“最大滑点”设置,您的兑换将会自动取消。"
|
||||
},
|
||||
"swapSlippageVeryHighDescription": {
|
||||
"message": "输入的滑点被认为非常高,可能导致不良费率"
|
||||
},
|
||||
"swapSlippageVeryHighTitle": {
|
||||
"message": "非常高的滑点"
|
||||
},
|
||||
"swapSlippageZeroDescription": {
|
||||
"message": "零滑点报价供应商较少,这将导致报价竞争力下降。"
|
||||
},
|
||||
|
@ -15,11 +15,13 @@ export const QUOTES_NOT_AVAILABLE_ERROR = 'quotes-not-avilable';
|
||||
export const CONTRACT_DATA_DISABLED_ERROR = 'contract-data-disabled';
|
||||
export const OFFLINE_FOR_MAINTENANCE = 'offline-for-maintenance';
|
||||
export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict';
|
||||
export const SLIPPAGE_OVER_LIMIT_ERROR = 'slippage-over-limit';
|
||||
export const SLIPPAGE_VERY_HIGH_ERROR = 'slippage-very-high';
|
||||
export const SLIPPAGE_TOO_LOW_ERROR = 'slippage-too-low';
|
||||
export const SLIPPAGE_HIGH_ERROR = 'slippage-high';
|
||||
export const SLIPPAGE_LOW_ERROR = 'slippage-low';
|
||||
export const SLIPPAGE_NEGATIVE_ERROR = 'slippage-negative';
|
||||
|
||||
export const MAX_ALLOWED_SLIPPAGE = 15;
|
||||
|
||||
// An address that the metaswap-api recognizes as the default token for the current network,
|
||||
// in place of the token address that ERC-20 tokens have
|
||||
const DEFAULT_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
@ -171,17 +171,17 @@ describe('Swaps - notifications', function () {
|
||||
});
|
||||
await driver.fill('input[data-testid*="slippage"]', '1');
|
||||
await checkNotification(driver, {
|
||||
title: 'Increase slippage to avoid transaction failure',
|
||||
text: 'Max slippage is too low which may cause your transaction to fail.',
|
||||
title: 'Low slippage',
|
||||
text: 'A value this low (1%) may result in a failed swap',
|
||||
});
|
||||
await driver.fill('input[data-testid*="slippage"]', '15');
|
||||
await checkNotification(driver, {
|
||||
title: 'Very high slippage',
|
||||
text: 'The slippage entered is considered very high and may result in a bad rate',
|
||||
title: 'High slippage',
|
||||
text: 'The slippage entered (15%) is considered very high and may result in a bad rate',
|
||||
});
|
||||
await driver.fill('input[data-testid*="slippage"]', '20');
|
||||
await checkNotification(driver, {
|
||||
title: 'Reduce slippage to continue',
|
||||
title: 'Very high slippage',
|
||||
text: 'Slippage tolerance must be 15% or less. Anything higher will result in a bad rate.',
|
||||
});
|
||||
await driver.fill('input[data-testid*="slippage"]', '4');
|
||||
|
@ -81,6 +81,7 @@ import {
|
||||
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP,
|
||||
SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
|
||||
TokenBucketPriority,
|
||||
MAX_ALLOWED_SLIPPAGE,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
|
||||
import {
|
||||
@ -110,8 +111,6 @@ const fuseSearchKeys = [
|
||||
{ name: 'address', weight: 0.002 },
|
||||
];
|
||||
|
||||
const MAX_ALLOWED_SLIPPAGE = 15;
|
||||
|
||||
let timeoutIdForQuotesPrefetching;
|
||||
|
||||
export default function BuildQuote({
|
||||
|
@ -90,6 +90,7 @@ import {
|
||||
ERROR_FETCHING_QUOTES,
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
QUOTES_EXPIRED_ERROR,
|
||||
MAX_ALLOWED_SLIPPAGE,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import {
|
||||
resetSwapsPostFetchState,
|
||||
@ -137,8 +138,6 @@ import SmartTransactionsPopover from './smart-transactions-popover';
|
||||
import QuotesLoadingAnimation from './quotes-loading-animation';
|
||||
import ReviewQuote from './review-quote';
|
||||
|
||||
const MAX_ALLOWED_SLIPPAGE = 15;
|
||||
|
||||
let timeoutIdForQuotesPrefetching;
|
||||
|
||||
export default function PrepareSwapPage({
|
||||
@ -1077,7 +1076,10 @@ export default function PrepareSwapPage({
|
||||
)}
|
||||
{swapsErrorKey && (
|
||||
<Box display={DISPLAY.FLEX} marginTop={2}>
|
||||
<SwapsBannerAlert swapsErrorKey={swapsErrorKey} />
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={swapsErrorKey}
|
||||
currentSlippage={maxSlippage}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
{transactionSettingsOpened &&
|
||||
|
@ -97,7 +97,12 @@ import {
|
||||
formatSwapsValueForDisplay,
|
||||
} from '../swaps.util';
|
||||
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
||||
import { QUOTES_EXPIRED_ERROR } from '../../../../shared/constants/swaps';
|
||||
import {
|
||||
QUOTES_EXPIRED_ERROR,
|
||||
SLIPPAGE_HIGH_ERROR,
|
||||
SLIPPAGE_LOW_ERROR,
|
||||
MAX_ALLOWED_SLIPPAGE,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import { GasRecommendations } from '../../../../shared/constants/gas';
|
||||
import CountdownTimer from '../countdown-timer';
|
||||
import SwapsFooter from '../swaps-footer';
|
||||
@ -107,23 +112,23 @@ import {
|
||||
JustifyContent,
|
||||
DISPLAY,
|
||||
AlignItems,
|
||||
FLEX_DIRECTION,
|
||||
TextVariant,
|
||||
FRACTIONS,
|
||||
TEXT_ALIGN,
|
||||
Size,
|
||||
FlexDirection,
|
||||
Severity,
|
||||
} from '../../../helpers/constants/design-system';
|
||||
import {
|
||||
BannerAlert,
|
||||
ButtonLink,
|
||||
Text,
|
||||
} from '../../../components/component-library';
|
||||
import {
|
||||
MetaMetricsEventCategory,
|
||||
MetaMetricsEventName,
|
||||
MetaMetricsEventErrorType,
|
||||
} from '../../../../shared/constants/metametrics';
|
||||
import {
|
||||
ButtonLink,
|
||||
Text,
|
||||
BannerAlert,
|
||||
} from '../../../components/component-library';
|
||||
import { isEqualCaseInsensitive } from '../../../../shared/modules/string-utils';
|
||||
import { parseStandardTokenTransactionData } from '../../../../shared/modules/transaction.utils';
|
||||
import { getTokenValueParam } from '../../../../shared/lib/metamask-controller-utils';
|
||||
@ -139,6 +144,7 @@ import ExchangeRateDisplay from '../exchange-rate-display';
|
||||
import InfoTooltip from '../../../components/ui/info-tooltip';
|
||||
import useRamps from '../../../hooks/experiences/useRamps';
|
||||
import ViewQuotePriceDifference from './view-quote-price-difference';
|
||||
import SlippageNotificationModal from './slippage-notification-modal';
|
||||
|
||||
let intervalId;
|
||||
|
||||
@ -165,6 +171,8 @@ export default function ReviewQuote({ setReceiveToAmount }) {
|
||||
|
||||
const [acknowledgedPriceDifference, setAcknowledgedPriceDifference] =
|
||||
useState(false);
|
||||
const [slippageNotificationModalOpened, setSlippageNotificationModalOpened] =
|
||||
useState(false);
|
||||
const priceDifferenceRiskyBuckets = [
|
||||
GasRecommendations.high,
|
||||
GasRecommendations.medium,
|
||||
@ -230,6 +238,16 @@ export default function ReviewQuote({ setReceiveToAmount }) {
|
||||
const isSmartTransaction =
|
||||
currentSmartTransactionsEnabled && smartTransactionsOptInStatus;
|
||||
|
||||
const [slippageErrorKey] = useState(() => {
|
||||
const slippage = Number(fetchParams?.slippage);
|
||||
if (slippage > 0 && slippage <= 1) {
|
||||
return SLIPPAGE_LOW_ERROR;
|
||||
} else if (slippage >= 5 && slippage <= MAX_ALLOWED_SLIPPAGE) {
|
||||
return SLIPPAGE_HIGH_ERROR;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
/* istanbul ignore next */
|
||||
const getTranslatedNetworkName = () => {
|
||||
switch (chainId) {
|
||||
@ -1048,9 +1066,50 @@ export default function ReviewQuote({ setReceiveToAmount }) {
|
||||
</span>
|
||||
);
|
||||
|
||||
const onSwapSubmit = ({ acknowledgedSlippage = false }) => {
|
||||
if (slippageErrorKey && !acknowledgedSlippage) {
|
||||
setSlippageNotificationModalOpened(true);
|
||||
return;
|
||||
}
|
||||
setSubmitClicked(true);
|
||||
if (!balanceError) {
|
||||
if (isSmartTransaction && smartTransactionFees?.tradeTxFees) {
|
||||
dispatch(
|
||||
signAndSendSwapsSmartTransaction({
|
||||
unsignedTransaction,
|
||||
trackEvent,
|
||||
history,
|
||||
additionalTrackingParams,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
dispatch(
|
||||
signAndSendTransactions(
|
||||
history,
|
||||
trackEvent,
|
||||
additionalTrackingParams,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (destinationToken.symbol === defaultSwapsToken.symbol) {
|
||||
history.push(DEFAULT_ROUTE);
|
||||
} else {
|
||||
history.push(`${ASSET_ROUTE}/${destinationToken.address}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="review-quote">
|
||||
<div className="review-quote__content">
|
||||
<SlippageNotificationModal
|
||||
isOpen={slippageNotificationModalOpened}
|
||||
setSlippageNotificationModalOpened={
|
||||
setSlippageNotificationModalOpened
|
||||
}
|
||||
slippageErrorKey={slippageErrorKey}
|
||||
onSwapSubmit={onSwapSubmit}
|
||||
currentSlippage={fetchParams?.slippage}
|
||||
/>
|
||||
{
|
||||
/* istanbul ignore next */
|
||||
selectQuotePopoverShown && (
|
||||
@ -1105,7 +1164,7 @@ export default function ReviewQuote({ setReceiveToAmount }) {
|
||||
marginTop={1}
|
||||
marginBottom={0}
|
||||
display={DISPLAY.FLEX}
|
||||
flexDirection={FLEX_DIRECTION.COLUMN}
|
||||
flexDirection={FlexDirection.Column}
|
||||
className="review-quote__overview"
|
||||
>
|
||||
<Box
|
||||
@ -1294,35 +1353,7 @@ export default function ReviewQuote({ setReceiveToAmount }) {
|
||||
</Box>
|
||||
</div>
|
||||
<SwapsFooter
|
||||
onSubmit={
|
||||
/* istanbul ignore next */ () => {
|
||||
setSubmitClicked(true);
|
||||
if (!balanceError) {
|
||||
if (isSmartTransaction && smartTransactionFees?.tradeTxFees) {
|
||||
dispatch(
|
||||
signAndSendSwapsSmartTransaction({
|
||||
unsignedTransaction,
|
||||
trackEvent,
|
||||
history,
|
||||
additionalTrackingParams,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
dispatch(
|
||||
signAndSendTransactions(
|
||||
history,
|
||||
trackEvent,
|
||||
additionalTrackingParams,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (destinationToken.symbol === defaultSwapsToken.symbol) {
|
||||
history.push(DEFAULT_ROUTE);
|
||||
} else {
|
||||
history.push(`${ASSET_ROUTE}/${destinationToken.address}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
onSubmit={onSwapSubmit}
|
||||
submitText={
|
||||
isSmartTransaction && swapsSTXLoading ? t('preparingSwap') : t('swap')
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { StoryFn, Meta } from '@storybook/react';
|
||||
import { useArgs } from '@storybook/client-api';
|
||||
|
||||
import { BUTTON_VARIANT, Button } from '../../../components/component-library';
|
||||
import { SLIPPAGE_HIGH_ERROR } from '../../../../shared/constants/swaps';
|
||||
import SlippageNotificationModal from './slippage-notification-modal';
|
||||
|
||||
export default {
|
||||
title: 'Pages/Swaps/SlippageNotificationModal',
|
||||
component: SlippageNotificationModal,
|
||||
argTypes: {
|
||||
isShowingModal: {
|
||||
control: 'boolean',
|
||||
},
|
||||
},
|
||||
} as Meta<typeof SlippageNotificationModal>;
|
||||
|
||||
export const DefaultStory: StoryFn<typeof SlippageNotificationModal> = () => {
|
||||
const [{ isShowingModal }, updateArgs] = useArgs();
|
||||
const toggleModal = () => updateArgs({ isShowingModal: !isShowingModal });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button variant={BUTTON_VARIANT.PRIMARY} onClick={toggleModal}>
|
||||
Open modal
|
||||
</Button>
|
||||
{isShowingModal && (
|
||||
<SlippageNotificationModal
|
||||
isOpen={isShowingModal}
|
||||
slippageErrorKey={SLIPPAGE_HIGH_ERROR}
|
||||
onSwapSubmit={() => {
|
||||
console.log('onSwapSubmit');
|
||||
}}
|
||||
currentSlippage={10}
|
||||
setSlippageNotificationModalOpened={toggleModal}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
DefaultStory.storyName = 'Default';
|
@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
import {
|
||||
renderWithProvider,
|
||||
fireEvent,
|
||||
createSwapsMockStore,
|
||||
screen,
|
||||
} from '../../../../test/jest';
|
||||
import {
|
||||
SLIPPAGE_HIGH_ERROR,
|
||||
SLIPPAGE_LOW_ERROR,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import SlippageNotificationModal from './slippage-notification-modal';
|
||||
|
||||
const middleware = [thunk];
|
||||
|
||||
const createProps = (customProps = {}) => {
|
||||
return {
|
||||
isOpen: true,
|
||||
slippageErrorKey: SLIPPAGE_HIGH_ERROR,
|
||||
setSlippageNotificationModalOpened: jest.fn(),
|
||||
onSwapSubmit: jest.fn(),
|
||||
currentSlippage: 1,
|
||||
...customProps,
|
||||
};
|
||||
};
|
||||
|
||||
describe('SlippageNotificationModal', () => {
|
||||
it('renders the component with the SLIPPAGE_HIGH_ERROR, clicks on "Swap anyway"', () => {
|
||||
const store = configureMockStore(middleware)(createSwapsMockStore());
|
||||
const props = createProps({ currentSlippage: 10 });
|
||||
const { getByText } = renderWithProvider(
|
||||
<SlippageNotificationModal {...props} />,
|
||||
store,
|
||||
);
|
||||
expect(screen.getByTestId('swaps-banner-title')).toHaveTextContent(
|
||||
'High slippage',
|
||||
);
|
||||
expect(
|
||||
getByText(
|
||||
'The slippage entered (10%) is considered very high and may result in a bad rate',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
const swapAnywayButton = getByText('Swap anyway');
|
||||
expect(swapAnywayButton).toBeInTheDocument();
|
||||
fireEvent.click(swapAnywayButton);
|
||||
expect(props.onSwapSubmit).toHaveBeenCalledWith({
|
||||
acknowledgedSlippage: true,
|
||||
});
|
||||
expect(props.setSlippageNotificationModalOpened).not.toHaveBeenCalledWith(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_LOW_ERROR, clicks on "Swap anyway"', () => {
|
||||
const store = configureMockStore(middleware)(createSwapsMockStore());
|
||||
const props = createProps({
|
||||
slippageErrorKey: SLIPPAGE_LOW_ERROR,
|
||||
});
|
||||
const { getByText } = renderWithProvider(
|
||||
<SlippageNotificationModal {...props} />,
|
||||
store,
|
||||
);
|
||||
expect(screen.getByTestId('swaps-banner-title')).toHaveTextContent(
|
||||
'Low slippage',
|
||||
);
|
||||
expect(
|
||||
getByText('A value this low (1%) may result in a failed swap'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
expect(getByText('Swap anyway')).toBeInTheDocument();
|
||||
const swapAnywayButton = getByText('Swap anyway');
|
||||
expect(swapAnywayButton).toBeInTheDocument();
|
||||
fireEvent.click(swapAnywayButton);
|
||||
expect(props.onSwapSubmit).toHaveBeenCalledWith({
|
||||
acknowledgedSlippage: true,
|
||||
});
|
||||
expect(props.setSlippageNotificationModalOpened).not.toHaveBeenCalledWith(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,96 @@
|
||||
import React, { useContext, useState } from 'react';
|
||||
|
||||
import { I18nContext } from '../../../contexts/i18n';
|
||||
import {
|
||||
FlexDirection,
|
||||
Display,
|
||||
JustifyContent,
|
||||
AlignItems,
|
||||
} from '../../../helpers/constants/design-system';
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Box,
|
||||
ButtonPrimary,
|
||||
} from '../../../components/component-library';
|
||||
import {
|
||||
SLIPPAGE_HIGH_ERROR,
|
||||
SLIPPAGE_LOW_ERROR,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import SwapsBannerAlert from '../swaps-banner-alert/swaps-banner-alert';
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
slippageErrorKey: string;
|
||||
setSlippageNotificationModalOpened: (isOpen: boolean) => void;
|
||||
onSwapSubmit: (opts: { acknowledgedSlippage: boolean }) => void;
|
||||
currentSlippage: number;
|
||||
}
|
||||
|
||||
export default function SlippageNotificationModal({
|
||||
isOpen,
|
||||
slippageErrorKey,
|
||||
setSlippageNotificationModalOpened,
|
||||
onSwapSubmit,
|
||||
currentSlippage,
|
||||
}: Props) {
|
||||
const t = useContext(I18nContext);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const getSlippageModalTitle = () => {
|
||||
if (slippageErrorKey === SLIPPAGE_HIGH_ERROR) {
|
||||
return t('swapHighSlippage');
|
||||
} else if (slippageErrorKey === SLIPPAGE_LOW_ERROR) {
|
||||
return t('swapLowSlippage');
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const primaryButtonText = submitting ? t('preparingSwap') : t('swapAnyway');
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onClose={() => setSlippageNotificationModalOpened(false)}
|
||||
isOpen={isOpen}
|
||||
isClosedOnOutsideClick
|
||||
isClosedOnEscapeKey
|
||||
className="mm-modal__custom-scrollbar"
|
||||
>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader onClose={() => setSlippageNotificationModalOpened(false)}>
|
||||
{getSlippageModalTitle()}
|
||||
</ModalHeader>
|
||||
<Box
|
||||
display={Display.Flex}
|
||||
flexDirection={FlexDirection.Column}
|
||||
justifyContent={JustifyContent.spaceBetween}
|
||||
alignItems={AlignItems.stretch}
|
||||
className="high-slippage__content"
|
||||
marginTop={7}
|
||||
>
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={slippageErrorKey}
|
||||
showTransactionSettingsLink
|
||||
currentSlippage={currentSlippage}
|
||||
/>
|
||||
<Box marginTop={5}>
|
||||
<ButtonPrimary
|
||||
onClick={() => {
|
||||
setSubmitting(true);
|
||||
onSwapSubmit({ acknowledgedSlippage: true });
|
||||
}}
|
||||
block
|
||||
data-testid="high-slippage-continue-anyway"
|
||||
disabled={submitting}
|
||||
>
|
||||
{primaryButtonText}
|
||||
</ButtonPrimary>
|
||||
</Box>
|
||||
</Box>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
}
|
@ -23,59 +23,72 @@ import {
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
OFFLINE_FOR_MAINTENANCE,
|
||||
SLIPPAGE_OVER_LIMIT_ERROR,
|
||||
SLIPPAGE_VERY_HIGH_ERROR,
|
||||
SLIPPAGE_TOO_LOW_ERROR,
|
||||
SLIPPAGE_HIGH_ERROR,
|
||||
SLIPPAGE_LOW_ERROR,
|
||||
SLIPPAGE_NEGATIVE_ERROR,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import { setTransactionSettingsOpened } from '../../../ducks/swaps/swaps';
|
||||
|
||||
export default function SwapsBannerAlert({ swapsErrorKey }) {
|
||||
export default function SwapsBannerAlert({
|
||||
swapsErrorKey,
|
||||
showTransactionSettingsLink,
|
||||
currentSlippage,
|
||||
}) {
|
||||
const t = useContext(I18nContext);
|
||||
const dispatch = useDispatch();
|
||||
let severity = SEVERITIES.DANGER;
|
||||
let title;
|
||||
let description;
|
||||
|
||||
const transactionSettingsLink = (
|
||||
<Text variant={TextVariant.bodyMd}>
|
||||
<ButtonLink
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
dispatch(setTransactionSettingsOpened(true));
|
||||
}}
|
||||
size={ButtonLinkSize.Inherit}
|
||||
>
|
||||
{t('swapAdjustSlippage')}
|
||||
</ButtonLink>
|
||||
</Text>
|
||||
);
|
||||
|
||||
switch (swapsErrorKey) {
|
||||
case SLIPPAGE_OVER_LIMIT_ERROR:
|
||||
case SLIPPAGE_VERY_HIGH_ERROR:
|
||||
title = t('swapSlippageOverLimitTitle');
|
||||
description = (
|
||||
<Box>
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageOverLimitDescription')}
|
||||
</Text>
|
||||
<ButtonLink
|
||||
size={ButtonLinkSize.Inherit}
|
||||
textProps={{
|
||||
variant: TextVariant.bodyMd,
|
||||
alignItems: AlignItems.flexStart,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
dispatch(setTransactionSettingsOpened(true));
|
||||
}}
|
||||
>
|
||||
{t('swapEditTransactionSettings')}
|
||||
</ButtonLink>
|
||||
{transactionSettingsLink}
|
||||
</Box>
|
||||
);
|
||||
break;
|
||||
case SLIPPAGE_VERY_HIGH_ERROR:
|
||||
case SLIPPAGE_HIGH_ERROR:
|
||||
severity = SEVERITIES.WARNING;
|
||||
title = t('swapSlippageVeryHighTitle');
|
||||
title = t('swapSlippageHighTitle');
|
||||
description = (
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageVeryHighDescription')}
|
||||
</Text>
|
||||
<Box>
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageHighDescription', [currentSlippage])}
|
||||
</Text>
|
||||
{showTransactionSettingsLink && transactionSettingsLink}
|
||||
</Box>
|
||||
);
|
||||
break;
|
||||
case SLIPPAGE_TOO_LOW_ERROR:
|
||||
case SLIPPAGE_LOW_ERROR:
|
||||
severity = SEVERITIES.WARNING;
|
||||
title = t('swapSlippageTooLowTitle');
|
||||
title = t('swapSlippageLowTitle');
|
||||
description = (
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageTooLowDescription')}
|
||||
</Text>
|
||||
<Box>
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageLowDescription', [currentSlippage])}
|
||||
</Text>
|
||||
{showTransactionSettingsLink && transactionSettingsLink}
|
||||
</Box>
|
||||
);
|
||||
break;
|
||||
case SLIPPAGE_NEGATIVE_ERROR:
|
||||
@ -85,19 +98,7 @@ export default function SwapsBannerAlert({ swapsErrorKey }) {
|
||||
<Text variant={TextVariant.bodyMd} as="h6">
|
||||
{t('swapSlippageNegativeDescription')}
|
||||
</Text>
|
||||
<ButtonLink
|
||||
size={ButtonLinkSize.Inherit}
|
||||
textProps={{
|
||||
variant: TextVariant.bodyMd,
|
||||
alignItems: AlignItems.flexStart,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
dispatch(setTransactionSettingsOpened(true));
|
||||
}}
|
||||
>
|
||||
{t('swapEditTransactionSettings')}
|
||||
</ButtonLink>
|
||||
{transactionSettingsLink}
|
||||
</Box>
|
||||
);
|
||||
break;
|
||||
@ -175,4 +176,6 @@ export default function SwapsBannerAlert({ swapsErrorKey }) {
|
||||
|
||||
SwapsBannerAlert.propTypes = {
|
||||
swapsErrorKey: PropTypes.string,
|
||||
showTransactionSettingsLink: PropTypes.bool,
|
||||
currentSlippage: PropTypes.number,
|
||||
};
|
||||
|
@ -13,9 +13,9 @@ import {
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
OFFLINE_FOR_MAINTENANCE,
|
||||
SLIPPAGE_OVER_LIMIT_ERROR,
|
||||
SLIPPAGE_VERY_HIGH_ERROR,
|
||||
SLIPPAGE_TOO_LOW_ERROR,
|
||||
SLIPPAGE_HIGH_ERROR,
|
||||
SLIPPAGE_LOW_ERROR,
|
||||
SLIPPAGE_NEGATIVE_ERROR,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import SwapsBannerAlert from './swaps-banner-alert';
|
||||
@ -23,52 +23,95 @@ import SwapsBannerAlert from './swaps-banner-alert';
|
||||
const middleware = [thunk];
|
||||
|
||||
describe('SwapsBannerAlert', () => {
|
||||
it('renders the component with the SLIPPAGE_OVER_LIMIT_ERROR', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert swapsErrorKey={SLIPPAGE_OVER_LIMIT_ERROR} />,
|
||||
store,
|
||||
);
|
||||
expect(getByText('Reduce slippage to continue')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText(
|
||||
'Slippage tolerance must be 15% or less. Anything higher will result in a bad rate.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Edit transaction settings')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_VERY_HIGH_ERROR', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert swapsErrorKey={SLIPPAGE_VERY_HIGH_ERROR} />,
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={SLIPPAGE_VERY_HIGH_ERROR}
|
||||
currentSlippage={16}
|
||||
/>,
|
||||
store,
|
||||
);
|
||||
expect(getByText('Very high slippage')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText(
|
||||
'The slippage entered is considered very high and may result in a bad rate',
|
||||
'Slippage tolerance must be 15% or less. Anything higher will result in a bad rate.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_HIGH_ERROR', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={SLIPPAGE_HIGH_ERROR}
|
||||
currentSlippage={5}
|
||||
/>,
|
||||
store,
|
||||
);
|
||||
expect(getByText('High slippage')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText(
|
||||
'The slippage entered (5%) is considered very high and may result in a bad rate',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_TOO_LOW_ERROR', () => {
|
||||
it('renders the component with the SLIPPAGE_HIGH_ERROR with the "Adjust slippage" link', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert swapsErrorKey={SLIPPAGE_TOO_LOW_ERROR} />,
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={SLIPPAGE_HIGH_ERROR}
|
||||
showTransactionSettingsLink
|
||||
currentSlippage={10}
|
||||
/>,
|
||||
store,
|
||||
);
|
||||
expect(
|
||||
getByText('Increase slippage to avoid transaction failure'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('High slippage')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText(
|
||||
'Max slippage is too low which may cause your transaction to fail.',
|
||||
'The slippage entered (10%) is considered very high and may result in a bad rate',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_LOW_ERROR', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={SLIPPAGE_LOW_ERROR}
|
||||
currentSlippage={1}
|
||||
/>,
|
||||
store,
|
||||
);
|
||||
expect(getByText('Low slippage')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText('A value this low (1%) may result in a failed swap'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_LOW_ERROR with the "Adjust slippage" link', () => {
|
||||
const mockStore = createSwapsMockStore();
|
||||
const store = configureMockStore(middleware)(mockStore);
|
||||
const { getByText } = renderWithProvider(
|
||||
<SwapsBannerAlert
|
||||
swapsErrorKey={SLIPPAGE_LOW_ERROR}
|
||||
showTransactionSettingsLink
|
||||
currentSlippage={1}
|
||||
/>,
|
||||
store,
|
||||
);
|
||||
expect(getByText('Low slippage')).toBeInTheDocument();
|
||||
expect(
|
||||
getByText('A value this low (1%) may result in a failed swap'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the SLIPPAGE_NEGATIVE_ERROR', () => {
|
||||
@ -82,7 +125,7 @@ describe('SwapsBannerAlert', () => {
|
||||
expect(
|
||||
getByText('Slippage must be greater or equal to zero'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('Edit transaction settings')).toBeInTheDocument();
|
||||
expect(getByText('Adjust slippage')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the component with the QUOTES_NOT_AVAILABLE_ERROR', () => {
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
import { getTranslatedStxErrorMessage } from '../swaps.util';
|
||||
import {
|
||||
Slippage,
|
||||
SLIPPAGE_OVER_LIMIT_ERROR,
|
||||
SLIPPAGE_VERY_HIGH_ERROR,
|
||||
SLIPPAGE_NEGATIVE_ERROR,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
import {
|
||||
@ -101,20 +101,20 @@ export default function TransactionSettings({
|
||||
// We will not show this warning for 0% slippage, because we will only
|
||||
// return non-slippage quotes from off-chain makers.
|
||||
notificationSeverity = SEVERITIES.WARNING;
|
||||
notificationText = t('swapSlippageTooLowDescription');
|
||||
notificationTitle = t('swapSlippageTooLowTitle');
|
||||
notificationText = t('swapSlippageLowDescription', [newSlippage]);
|
||||
notificationTitle = t('swapSlippageLowTitle');
|
||||
} else if (
|
||||
Number(customValue) >= 5 &&
|
||||
Number(customValue) <= maxAllowedSlippage
|
||||
) {
|
||||
notificationSeverity = SEVERITIES.WARNING;
|
||||
notificationText = t('swapSlippageVeryHighDescription');
|
||||
notificationTitle = t('swapSlippageVeryHighTitle');
|
||||
notificationText = t('swapSlippageHighDescription', [newSlippage]);
|
||||
notificationTitle = t('swapSlippageHighTitle');
|
||||
} else if (Number(customValue) > maxAllowedSlippage) {
|
||||
notificationSeverity = SEVERITIES.DANGER;
|
||||
notificationText = t('swapSlippageOverLimitDescription');
|
||||
notificationTitle = t('swapSlippageOverLimitTitle');
|
||||
dispatch(setSwapsErrorKey(SLIPPAGE_OVER_LIMIT_ERROR));
|
||||
dispatch(setSwapsErrorKey(SLIPPAGE_VERY_HIGH_ERROR));
|
||||
} else if (Number(customValue) === 0) {
|
||||
notificationSeverity = SEVERITIES.INFO;
|
||||
notificationText = t('swapSlippageZeroDescription');
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
// import { useDispatch } from 'react-redux';
|
||||
|
||||
import {
|
||||
renderWithProvider,
|
||||
|
Loading…
Reference in New Issue
Block a user