@@ -12,7 +12,10 @@ import type { Token } from 'config/tokens';
1212import config from 'config' ;
1313import { useTokens } from 'contexts/TokensContext' ;
1414import { getTokenSymbol } from 'utils' ;
15- import type { Balances } from 'utils/wallet/types' ;
15+ import {
16+ getWrappedNativeToken ,
17+ shouldFilterSameChainToken ,
18+ } from 'utils/wrappedNativeTokens' ;
1619import { unionBy } from 'es-toolkit' ;
1720
1821interface UseTokenListWithSearchParams {
@@ -22,8 +25,6 @@ interface UseTokenListWithSearchParams {
2225 isSource : boolean ;
2326 isSameChainSwap : boolean ;
2427 sourceToken ?: Token ;
25- balances : Balances ;
26- walletAddress : string ;
2728 tokenPastingEnabled ?: boolean ;
2829}
2930
@@ -46,8 +47,6 @@ export const useTokenListWithSearch = ({
4647 isSource,
4748 isSameChainSwap,
4849 sourceToken,
49- balances,
50- walletAddress,
5150 tokenPastingEnabled = true ,
5251} : UseTokenListWithSearchParams ) : UseTokenListWithSearchReturn => {
5352 const [ searchedTokens , setSearchedTokens ] = useState < Token [ ] > ( [ ] ) ;
@@ -60,6 +59,15 @@ export const useTokenListWithSearch = ({
6059 setSearchedTokens ( ( prev ) => [ ...prev , token ] ) ;
6160 } , [ ] ) ;
6261
62+ // Get wrapped native address for same-chain swaps (only for destination selection)
63+ const wrappedNativeAddr = useMemo ( ( ) => {
64+ if ( ! isSameChainSwap || ! chain || isSource ) {
65+ return undefined ;
66+ }
67+ const wrapped = getWrappedNativeToken ( config . network , chain ) ;
68+ return wrapped ?. toLowerCase ( ) ;
69+ } , [ isSameChainSwap , chain , isSource ] ) ;
70+
6371 useEffect ( ( ) => {
6472 if ( ! chain || ! tokenPastingEnabled || ! deferredSearch ) {
6573 setSearchedTokens ( [ ] ) ;
@@ -139,10 +147,10 @@ export const useTokenListWithSearch = ({
139147 } ) ;
140148 }
141149
142- // For destination token list in same-chain swaps, filter out the source token
143- if ( ! isSource && isSameChainSwap && sourceToken ) {
150+ // For destination token list in same-chain swaps, filter out invalid options
151+ if ( sourceToken && isSameChainSwap && ! isSource ) {
144152 tokens = tokens . filter (
145- ( t ) => t . addressString !== sourceToken . addressString ,
153+ ( t ) => ! shouldFilterSameChainToken ( sourceToken , wrappedNativeAddr , t ) ,
146154 ) ;
147155 }
148156
@@ -152,9 +160,10 @@ export const useTokenListWithSearch = ({
152160 searchedTokens ,
153161 deferredSearch ,
154162 searchLower ,
155- isSource ,
156- isSameChainSwap ,
157163 sourceToken ,
164+ isSameChainSwap ,
165+ isSource ,
166+ wrappedNativeAddr ,
158167 ] ) ;
159168
160169 const tokenPrices = useMemo (
0 commit comments