diff --git a/bridge_ui/src/components/Transfer/Source.tsx b/bridge_ui/src/components/Transfer/Source.tsx index 546894771..c1c368455 100644 --- a/bridge_ui/src/components/Transfer/Source.tsx +++ b/bridge_ui/src/components/Transfer/Source.tsx @@ -25,7 +25,7 @@ import KeyAndBalance from "../KeyAndBalance"; import LowBalanceWarning from "../LowBalanceWarning"; import StepDescription from "../StepDescription"; import { TokenSelector } from "../TokenSelectors/SourceTokenSelector"; -import TokenBlacklistWarning from "./TokenBlacklistWarning"; +import TokenWarning from "./TokenWarning"; const useStyles = makeStyles((theme) => ({ transferField: { @@ -122,7 +122,7 @@ function Source({ ) : ( <> - ({ description: { @@ -46,7 +46,7 @@ export default function SourcePreview() { > {explainerContent} - {tokenBlacklistWarning} - ) : null; -} diff --git a/bridge_ui/src/components/Transfer/TokenWarning.tsx b/bridge_ui/src/components/Transfer/TokenWarning.tsx new file mode 100644 index 000000000..7817e3bc5 --- /dev/null +++ b/bridge_ui/src/components/Transfer/TokenWarning.tsx @@ -0,0 +1,59 @@ +import { + ChainId, + CHAIN_ID_ETH, + CHAIN_ID_SOLANA, +} from "@certusone/wormhole-sdk"; +import { getAddress } from "@ethersproject/address"; +import { Alert } from "@material-ui/lab"; +import { useMemo } from "react"; +import { + ETH_TOKENS_THAT_CAN_BE_SWAPPED_ON_SOLANA, + ETH_TOKENS_THAT_EXIST_ELSEWHERE, + SOLANA_TOKENS_THAT_EXIST_ELSEWHERE, + WETH_ADDRESS, +} from "../../utils/consts"; + +export default function TokenWarning({ + sourceChain, + tokenAddress, + symbol, +}: { + sourceChain: ChainId; + tokenAddress: string | undefined; + symbol: string | undefined; +}) { + const tokenConflictingNativeWarning = useMemo( + () => + tokenAddress && + ((sourceChain === CHAIN_ID_SOLANA && + SOLANA_TOKENS_THAT_EXIST_ELSEWHERE.includes(tokenAddress)) || + (sourceChain === CHAIN_ID_ETH && + ETH_TOKENS_THAT_EXIST_ELSEWHERE.includes(getAddress(tokenAddress)))) + ? `Bridging ${ + symbol ? symbol : "the token" + } via Wormhole will not produce native ${ + symbol ? symbol : "assets" + }. It will produce a wrapped version which might have no liquidity or utility on the target chain.` + : undefined, + [sourceChain, tokenAddress, symbol] + ); + return tokenConflictingNativeWarning ? ( + {tokenConflictingNativeWarning} + ) : sourceChain === CHAIN_ID_ETH && tokenAddress === WETH_ADDRESS ? ( + + As of 2021-09-30, markets for Wormhole v2 wrapped WETH have not yet been + created. + + ) : sourceChain === CHAIN_ID_ETH && + tokenAddress && + ETH_TOKENS_THAT_CAN_BE_SWAPPED_ON_SOLANA.includes( + getAddress(tokenAddress) + ) ? ( + //TODO: will this be accurate with Terra support? + + Bridging {symbol ? symbol : "the token"} via Wormhole will not produce + native {symbol ? symbol : "assets"}. It will produce a wrapped version + which can be swapped using a stable swap protocol. + + ) : null; +} diff --git a/bridge_ui/src/hooks/useTokenBlacklistWarning.ts b/bridge_ui/src/hooks/useTokenBlacklistWarning.ts deleted file mode 100644 index 6bd01c718..000000000 --- a/bridge_ui/src/hooks/useTokenBlacklistWarning.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { - ChainId, - CHAIN_ID_ETH, - CHAIN_ID_SOLANA, -} from "@certusone/wormhole-sdk"; -import { useMemo } from "react"; -import { - ETH_TOKENS_THAT_EXIST_ELSEWHERE, - SOLANA_TOKENS_THAT_EXIST_ELSEWHERE, -} from "../utils/consts"; - -export default function useTokenBlacklistWarning( - chainId: ChainId, - tokenAddress: string | undefined, - symbol: string | undefined -) { - return useMemo( - () => - tokenAddress && - ((chainId === CHAIN_ID_SOLANA && - SOLANA_TOKENS_THAT_EXIST_ELSEWHERE.includes(tokenAddress)) || - (chainId === CHAIN_ID_ETH && - ETH_TOKENS_THAT_EXIST_ELSEWHERE.includes(tokenAddress))) - ? `Bridging ${ - symbol ? symbol : "the token" - } via Wormhole will not produce native ${ - symbol ? symbol : "assets" - }. It will produce a wrapped version which might have no liquidity or utility on the target chain.` - : undefined, - [chainId, tokenAddress, symbol] - ); -} diff --git a/bridge_ui/src/utils/consts.ts b/bridge_ui/src/utils/consts.ts index 66203dbb5..469c6b2ed 100644 --- a/bridge_ui/src/utils/consts.ts +++ b/bridge_ui/src/utils/consts.ts @@ -215,7 +215,6 @@ export const SOLANA_TOKENS_THAT_EXIST_ELSEWHERE = [ ]; export const ETH_TOKENS_THAT_EXIST_ELSEWHERE = [ getAddress("0x476c5E26a75bd202a9683ffD34359C0CC15be0fF"), // SRM - getAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"), // USDC getAddress("0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5"), // KIN getAddress("0xeb4c2781e4eba804ce9a9803c67d0893436bb27d"), // renBTC getAddress("0x52d87F22192131636F93c5AB18d0127Ea52CB641"), // renLUNA @@ -224,6 +223,9 @@ export const ETH_TOKENS_THAT_EXIST_ELSEWHERE = [ getAddress("0x3832d2F059E55934220881F831bE501D180671A7"), // renDOGE getAddress("0x1c5db575e2ff833e46a2e9864c22f4b22e0b37c2"), // renZEC getAddress("0xD5147bc8e386d91Cc5DBE72099DAC6C9b99276F5"), // renFIL +]; +export const ETH_TOKENS_THAT_CAN_BE_SWAPPED_ON_SOLANA = [ + getAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"), // USDC getAddress("0xdac17f958d2ee523a2206206994597c13d831ec7"), // USDT ];