import { useAsyncRetry } from 'react-use' ; import { EthereumTokenType , FungibleTokenDetailed , isSameAddress , useTokenConstants } from '@masknet/web3-shared-evm' ; import { TargetChainIdContext } from '../useTargetChainIdContext' ; export function useTrade ( inputToken ? , outputToken ? ) { const { targetChainId } = TargetChainIdContext . useContainer ( ) ; const { WNATIVE_ADDRESS } = useTokenConstants ( targetChainId ) ; return useAsyncRetry ( async ( ) => { if ( ! inputToken || ! outputToken ) return false ; if ( inputToken . type !== EthereumTokenType . Native && outputToken . type !== EthereumTokenType . Native ) return false ; if ( ! isSameAddress ( inputToken . address , WNATIVE_ADDRESS ) && ! isSameAddress ( outputToken . address , WNATIVE_ADDRESS ) ) return false ; return true ; } , [ WNATIVE_ADDRESS , inputToken , outputToken ] ) ; }