diff --git a/src/__swaps__/screens/Swap/components/ReviewPanel.tsx b/src/__swaps__/screens/Swap/components/ReviewPanel.tsx index 0d2a8553086..b3fbbb45bb5 100644 --- a/src/__swaps__/screens/Swap/components/ReviewPanel.tsx +++ b/src/__swaps__/screens/Swap/components/ReviewPanel.tsx @@ -159,6 +159,19 @@ function FlashbotsToggle() { ); } +function DegenModeToggle() { + const { SwapSettings } = useSwapContext(); + + return ( + + ); +} + export function ReviewPanel() { const { navigate } = useNavigation(); const { isDarkMode } = useColorMode(); @@ -352,6 +365,36 @@ export function ReviewPanel() { + {/* + + + + 🐵 + + + + DEGEN MODE + + + + + 􀅴 + + + + + + + + + */} + diff --git a/src/__swaps__/screens/Swap/hooks/useSwapNavigation.ts b/src/__swaps__/screens/Swap/hooks/useSwapNavigation.ts index 6db9a40e795..496f8b2e713 100644 --- a/src/__swaps__/screens/Swap/hooks/useSwapNavigation.ts +++ b/src/__swaps__/screens/Swap/hooks/useSwapNavigation.ts @@ -19,6 +19,7 @@ export function useSwapNavigation({ quoteFetchingInterval, selectedInputAsset, selectedOutputAsset, + isDegenMode, }: { executeSwap: () => void; inputProgress: SharedValue; @@ -27,6 +28,7 @@ export function useSwapNavigation({ quoteFetchingInterval: ReturnType; selectedInputAsset: SharedValue; selectedOutputAsset: SharedValue; + isDegenMode: SharedValue; }) { const navigateBackToReview = useSharedValue(false); @@ -167,17 +169,18 @@ export function useSwapNavigation({ if (configProgress.value === NavigationSteps.SHOW_GAS) { if (navigateBackToReview.value) { navigateBackToReview.value = false; - handleShowReview(); - } else { - handleDismissGas(); + return handleShowReview(); } - } else if (configProgress.value === NavigationSteps.SHOW_REVIEW) { - // TODO: Handle long press - executeSwap(); - } else { - handleShowReview(); + + return handleDismissGas(); } - }, [configProgress, executeSwap, handleDismissGas, handleShowReview, navigateBackToReview]); + + if (isDegenMode.value || configProgress.value === NavigationSteps.SHOW_REVIEW) { + return executeSwap(); + } + + return handleShowReview(); + }, [configProgress.value, executeSwap, handleDismissGas, handleShowReview, isDegenMode.value, navigateBackToReview]); return { navigateBackToReview, diff --git a/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts b/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts index 4ff7cbb7f02..d7ff724439c 100644 --- a/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts +++ b/src/__swaps__/screens/Swap/hooks/useSwapSettings.ts @@ -9,10 +9,12 @@ import { SharedValue, runOnJS, useSharedValue } from 'react-native-reanimated'; export const useSwapSettings = ({ inputAsset }: { inputAsset: SharedValue }) => { const flashbots = useSharedValue(swapsStore.getState().flashbots); + const degenMode = useSharedValue(swapsStore.getState().degenMode); const slippage = useSharedValue(getDefaultSlippageWorklet(inputAsset.value?.chainId || ChainId.mainnet, getRemoteConfig())); const setSlippage = swapsStore(state => state.setSlippage); const setFlashbots = swapsStore(state => state.setFlashbots); + const setDegenMode = swapsStore(state => state.setFlashbots); const onToggleFlashbots = () => { 'worklet'; @@ -37,11 +39,21 @@ export const useSwapSettings = ({ inputAsset }: { inputAsset: SharedValue { + 'worklet'; + + const current = degenMode.value; + degenMode.value = !current; + runOnJS(setDegenMode)(!current); + }; + return { flashbots, slippage, + degenMode, onToggleFlashbots, onUpdateSlippage, + onToggleDegenMode, }; }; diff --git a/src/__swaps__/screens/Swap/providers/swap-provider.tsx b/src/__swaps__/screens/Swap/providers/swap-provider.tsx index 0cf5730ef2a..e75749d5872 100644 --- a/src/__swaps__/screens/Swap/providers/swap-provider.tsx +++ b/src/__swaps__/screens/Swap/providers/swap-provider.tsx @@ -47,12 +47,12 @@ import { swapsStore } from '@/state/swaps/swapsStore'; import { ethereumUtils, haptics } from '@/utils'; import { CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps'; +import { IS_IOS } from '@/env'; import { Address } from 'viem'; import { clearCustomGasSettings } from '../hooks/useCustomGas'; import { getGasSettingsBySpeed, getSelectedGas, getSelectedGasSpeed } from '../hooks/useSelectedGas'; import { useSwapOutputQuotesDisabled } from '../hooks/useSwapOutputQuotesDisabled'; import { SyncGasStateToSharedValues, SyncQuoteSharedValuesToState } from './SyncSwapStateAndSharedValues'; -import { IS_IOS } from '@/env'; const swapping = i18n.t(i18n.l.swap.actions.swapping); const tapToSwap = i18n.t(i18n.l.swap.actions.tap_to_swap); @@ -390,6 +390,7 @@ export const SwapProvider = ({ children }: SwapProviderProps) => { quoteFetchingInterval: SwapInputController.quoteFetchingInterval, selectedInputAsset: internalSelectedInputAsset, selectedOutputAsset: internalSelectedOutputAsset, + isDegenMode: SwapSettings.degenMode, }); const SwapWarning = useSwapWarning({ diff --git a/src/state/swaps/swapsStore.ts b/src/state/swaps/swapsStore.ts index 7485a79e5be..3ae62cd173d 100644 --- a/src/state/swaps/swapsStore.ts +++ b/src/state/swaps/swapsStore.ts @@ -32,6 +32,8 @@ export interface SwapsState { setSlippage: (slippage: string) => void; source: Source | 'auto'; setSource: (source: Source | 'auto') => void; + degenMode: boolean; + setDegenMode: (degenMode: boolean) => void; } const updateCustomGasSettingsForFlashbots = (flashbots: boolean, chainId: ChainId) => { @@ -75,6 +77,9 @@ export const swapsStore = createRainbowStore( setSlippage: (slippage: string) => set({ slippage }), source: 'auto', setSource: (source: Source | 'auto') => set({ source }), + + degenMode: false, + setDegenMode: (degenMode: boolean) => set({ degenMode }), }), { storageKey: 'swapsStore',