diff --git a/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts b/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts index de8ea866af8..4ff7cbb7f02 100644 --- a/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts +++ b/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts @@ -1,15 +1,15 @@ import { ExtendedAnimatedAssetWithColors } from '@/__swaps__/types/assets'; -import { SharedValue, runOnJS, useSharedValue } from 'react-native-reanimated'; -import { swapsStore } from '@/state/swaps/swapsStore'; import { slippageStep } from '@/__swaps__/screens/Swap/constants'; -import { getDefaultSlippageWorklet } from '@/__swaps__/utils/swaps'; import { ChainId } from '@/__swaps__/types/chains'; -import { DEFAULT_CONFIG } from '@/model/remoteConfig'; +import { getDefaultSlippageWorklet } from '@/__swaps__/utils/swaps'; +import { getRemoteConfig } from '@/model/remoteConfig'; +import { swapsStore } from '@/state/swaps/swapsStore'; +import { SharedValue, runOnJS, useSharedValue } from 'react-native-reanimated'; export const useSwapSettings = ({ inputAsset }: { inputAsset: SharedValue }) => { const flashbots = useSharedValue(swapsStore.getState().flashbots); - const slippage = useSharedValue(getDefaultSlippageWorklet(inputAsset.value?.chainId ?? ChainId.mainnet, DEFAULT_CONFIG)); + const slippage = useSharedValue(getDefaultSlippageWorklet(inputAsset.value?.chainId || ChainId.mainnet, getRemoteConfig())); const setSlippage = swapsStore(state => state.setSlippage); const setFlashbots = swapsStore(state => state.setFlashbots); diff --git a/src/__swaps__/utils/swaps.ts b/src/__swaps__/utils/swaps.ts index 3186a369bb5..9c6ffcbff5e 100644 --- a/src/__swaps__/utils/swaps.ts +++ b/src/__swaps__/utils/swaps.ts @@ -449,11 +449,11 @@ export const DEFAULT_SLIPPAGE_BIPS = { [ChainId.blast]: 200, }; -export const slippageInBipsToString = (slippageInBips: number) => (slippageInBips / 100).toString(); +export const slippageInBipsToString = (slippageInBips: number) => (slippageInBips / 100).toFixed(1); export const slippageInBipsToStringWorklet = (slippageInBips: number) => { 'worklet'; - return (slippageInBips / 100).toFixed(1).toString(); + return (slippageInBips / 100).toFixed(1); }; export const getDefaultSlippage = (chainId: ChainId, config: RainbowConfig) => { diff --git a/src/state/swaps/swapsStore.ts b/src/state/swaps/swapsStore.ts index 4be4acaef32..42e879473e0 100644 --- a/src/state/swaps/swapsStore.ts +++ b/src/state/swaps/swapsStore.ts @@ -1,7 +1,7 @@ import { ExtendedAnimatedAssetWithColors, ParsedSearchAsset } from '@/__swaps__/types/assets'; import { ChainId } from '@/__swaps__/types/chains'; import { getDefaultSlippage } from '@/__swaps__/utils/swaps'; -import { DEFAULT_CONFIG } from '@/model/remoteConfig'; +import { getRemoteConfig } from '@/model/remoteConfig'; import { createRainbowStore } from '@/state/internal/createRainbowStore'; import { CrosschainQuote, Quote, QuoteError, Source } from '@rainbow-me/swaps'; @@ -33,7 +33,7 @@ export const swapsStore = createRainbowStore( isSwapsOpen: false, setIsSwapsOpen: (isSwapsOpen: boolean) => set({ isSwapsOpen }), - inputAsset: null, // TODO: Default to their largest balance asset (or ETH mainnet if user has no assets) + inputAsset: null, outputAsset: null, quote: null, @@ -43,7 +43,7 @@ export const swapsStore = createRainbowStore( flashbots: false, setFlashbots: (flashbots: boolean) => set({ flashbots }), - slippage: getDefaultSlippage(ChainId.mainnet, DEFAULT_CONFIG), + slippage: getDefaultSlippage(ChainId.mainnet, getRemoteConfig()), setSlippage: (slippage: string) => set({ slippage }), source: 'auto', setSource: (source: Source | 'auto') => set({ source }), @@ -56,7 +56,6 @@ export const swapsStore = createRainbowStore( return { flashbots: state.flashbots, source: state.source, - slippage: state.slippage, }; }, }