diff --git a/packages/synapse-interface/slices/bridge/reducer.ts b/packages/synapse-interface/slices/bridge/reducer.ts index 5e93696ea7..3f92f0ee2a 100644 --- a/packages/synapse-interface/slices/bridge/reducer.ts +++ b/packages/synapse-interface/slices/bridge/reducer.ts @@ -456,6 +456,9 @@ export const bridgeSlice = createSlice({ setBridgeQuote: (state, action: PayloadAction) => { state.bridgeQuote = action.payload }, + resetBridgeQuote: (state) => { + state.bridgeQuote = initialState.bridgeQuote + }, updateFromValue: (state, action: PayloadAction) => { state.fromValue = action.payload }, @@ -563,6 +566,7 @@ export const bridgeSlice = createSlice({ export const { setBridgeQuote, + resetBridgeQuote, setFromChainId, setToChainId, setFromToken, diff --git a/packages/synapse-interface/slices/bridge/updater.tsx b/packages/synapse-interface/slices/bridge/updater.tsx index f035ec7e44..100f31c03f 100644 --- a/packages/synapse-interface/slices/bridge/updater.tsx +++ b/packages/synapse-interface/slices/bridge/updater.tsx @@ -10,6 +10,7 @@ import { updateDebouncedFromValue, updateDebouncedToTokensFromValue, } from './actions' +import { resetBridgeQuote } from './reducer' import { Token } from '@/utils/types' import { stringToBigInt } from '@/utils/bigint/format' import { useSynapseContext } from '@/utils/providers/SynapseProvider' @@ -25,6 +26,7 @@ export default function Updater(): null { toToken, toTokens, fromValue, + bridgeQuote, debouncedFromValue, debouncedToTokensFromValue, }: BridgeState = useBridgeState() @@ -106,6 +108,13 @@ export default function Updater(): null { } }, [debouncedToTokensFromValue, toTokens]) + // Clear bridge quote if input is empty + useEffect(() => { + if (debouncedFromValue === initialState.debouncedFromValue) { + dispatch(resetBridgeQuote()) + } + }, [debouncedFromValue, bridgeQuote]) + return null }