diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c278a568473a..91278d051619 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -3440,6 +3440,10 @@ "swapSlippageNegative": { "message": "Slippage must be greater or equal to zero" }, + "swapSlippagePercent": { + "message": "$1%", + "description": "$1 is the amount of % for slippage" + }, "swapSource": { "message": "Liquidity source" }, diff --git a/shared/constants/swaps.js b/shared/constants/swaps.js index 10db41a2e634..8482709caf09 100644 --- a/shared/constants/swaps.js +++ b/shared/constants/swaps.js @@ -206,3 +206,8 @@ export const TOKEN_BUCKET_PRIORITY = { OWNED: 'owned', TOP: 'top', }; + +export const SLIPPAGE = { + DEFAULT: 2, + HIGH: 3, +}; diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index a2fe1b53c27e..30a3b65b9f58 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -80,6 +80,7 @@ import { SWAP_FAILED_ERROR, SWAPS_FETCH_ORDER_CONFLICT, ALLOWED_SMART_TRANSACTIONS_CHAIN_IDS, + SLIPPAGE, } from '../../../shared/constants/swaps'; import { TRANSACTION_TYPES, @@ -108,7 +109,7 @@ const initialState = { fromTokenInputValue: '', fromTokenError: null, isFeatureFlagLoaded: false, - maxSlippage: 3, + maxSlippage: SLIPPAGE.DEFAULT, quotesFetchStartTime: null, reviewSwapClickedTimestamp: null, topAssets: {}, @@ -733,7 +734,7 @@ export const fetchQuotesAndSetQuoteState = ( token_to: toTokenSymbol, request_type: balanceError ? 'Quote' : 'Order', slippage: maxSlippage, - custom_slippage: maxSlippage !== 2, + custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT, is_hardware_wallet: hardwareWalletUsed, hardware_wallet_type: hardwareWalletType, stx_enabled: smartTransactionsEnabled, @@ -787,7 +788,7 @@ export const fetchQuotesAndSetQuoteState = ( token_to: toTokenSymbol, request_type: balanceError ? 'Quote' : 'Order', slippage: maxSlippage, - custom_slippage: maxSlippage !== 2, + custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT, is_hardware_wallet: hardwareWalletUsed, hardware_wallet_type: hardwareWalletType, stx_enabled: smartTransactionsEnabled, @@ -812,7 +813,7 @@ export const fetchQuotesAndSetQuoteState = ( ), request_type: balanceError ? 'Quote' : 'Order', slippage: maxSlippage, - custom_slippage: maxSlippage !== 2, + custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT, response_time: Date.now() - fetchStartTime, best_quote_source: newSelectedQuote.aggregator, available_quotes: Object.values(fetchedQuotes)?.length, diff --git a/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js b/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js index 30a587df1300..5bc56817c9e2 100644 --- a/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js +++ b/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js @@ -5,6 +5,7 @@ import { renderWithProvider, createSwapsMockStore, } from '../../../../test/jest'; +import { SLIPPAGE } from '../../../../shared/constants/swaps'; import AwaitingSwap from '.'; const createProps = (customProps = {}) => { @@ -14,7 +15,7 @@ const createProps = (customProps = {}) => { tokensReceived: 'tokens received:', submittingSwap: true, inputValue: 5, - maxSlippage: 3, + maxSlippage: SLIPPAGE.DEFAULT, ...customProps, }; }; diff --git a/ui/pages/swaps/build-quote/__snapshots__/build-quote.test.js.snap b/ui/pages/swaps/build-quote/__snapshots__/build-quote.test.js.snap index 4314aea3a33e..b0551966d1c6 100644 --- a/ui/pages/swaps/build-quote/__snapshots__/build-quote.test.js.snap +++ b/ui/pages/swaps/build-quote/__snapshots__/build-quote.test.js.snap @@ -6,16 +6,16 @@ exports[`BuildQuote renders the component with initial props 1`] = ` role="radiogroup" >