2021-04-24 01:54:24 +03:00
|
|
|
import { Currency, Token } from '@uniswap/sdk-core'
|
|
|
|
import { useMemo } from 'react'
|
|
|
|
import { useUnsupportedTokens } from './Tokens'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the input currency or output currency cannot be traded in the interface
|
|
|
|
* @param currencyIn the input currency to check
|
|
|
|
* @param currencyOut the output currency to check
|
|
|
|
*/
|
2021-09-02 20:57:01 +03:00
|
|
|
export function useIsSwapUnsupported(currencyIn?: Currency | null, currencyOut?: Currency | null): boolean {
|
2021-04-24 01:54:24 +03:00
|
|
|
const unsupportedTokens: { [address: string]: Token } = useUnsupportedTokens()
|
|
|
|
|
|
|
|
return useMemo(() => {
|
|
|
|
// if unsupported list loaded & either token on list, mark as unsupported
|
|
|
|
return Boolean(
|
|
|
|
unsupportedTokens &&
|
2021-05-12 19:43:25 +03:00
|
|
|
((currencyIn?.isToken && unsupportedTokens[currencyIn.address]) ||
|
|
|
|
(currencyOut?.isToken && unsupportedTokens[currencyOut.address]))
|
2021-04-24 01:54:24 +03:00
|
|
|
)
|
|
|
|
}, [currencyIn, currencyOut, unsupportedTokens])
|
|
|
|
}
|