bridge_ui: WETH warning
Change-Id: Ib1c4df3309ec4e90f29160bb7ce13542df084982
This commit is contained in:
parent
18f3262b89
commit
d14277f3ca
|
@ -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({
|
|||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<TokenBlacklistWarning
|
||||
<TokenWarning
|
||||
sourceChain={sourceChain}
|
||||
tokenAddress={parsedTokenAccount?.mintKey}
|
||||
symbol={parsedTokenAccount?.symbol}
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
} from "../../store/selectors";
|
||||
import { CHAINS_BY_ID } from "../../utils/consts";
|
||||
import SmartAddress from "../SmartAddress";
|
||||
import TokenBlacklistWarning from "./TokenBlacklistWarning";
|
||||
import TokenWarning from "./TokenWarning";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
description: {
|
||||
|
@ -46,7 +46,7 @@ export default function SourcePreview() {
|
|||
>
|
||||
{explainerContent}
|
||||
</Typography>
|
||||
<TokenBlacklistWarning
|
||||
<TokenWarning
|
||||
sourceChain={sourceChain}
|
||||
tokenAddress={sourceParsedTokenAccount?.mintKey}
|
||||
symbol={sourceParsedTokenAccount?.symbol}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import { ChainId } from "@certusone/wormhole-sdk";
|
||||
import { Alert } from "@material-ui/lab";
|
||||
import useTokenBlacklistWarning from "../../hooks/useTokenBlacklistWarning";
|
||||
|
||||
export default function TokenBlacklistWarning({
|
||||
sourceChain,
|
||||
tokenAddress,
|
||||
symbol,
|
||||
}: {
|
||||
sourceChain: ChainId;
|
||||
tokenAddress: string | undefined;
|
||||
symbol: string | undefined;
|
||||
}) {
|
||||
const tokenBlacklistWarning = useTokenBlacklistWarning(
|
||||
sourceChain,
|
||||
tokenAddress,
|
||||
symbol
|
||||
);
|
||||
return tokenBlacklistWarning ? (
|
||||
<Alert severity="warning">{tokenBlacklistWarning}</Alert>
|
||||
) : null;
|
||||
}
|
|
@ -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 ? (
|
||||
<Alert severity="warning">{tokenConflictingNativeWarning}</Alert>
|
||||
) : sourceChain === CHAIN_ID_ETH && tokenAddress === WETH_ADDRESS ? (
|
||||
<Alert severity="warning">
|
||||
As of 2021-09-30, markets for Wormhole v2 wrapped WETH have not yet been
|
||||
created.
|
||||
</Alert>
|
||||
) : sourceChain === CHAIN_ID_ETH &&
|
||||
tokenAddress &&
|
||||
ETH_TOKENS_THAT_CAN_BE_SWAPPED_ON_SOLANA.includes(
|
||||
getAddress(tokenAddress)
|
||||
) ? (
|
||||
//TODO: will this be accurate with Terra support?
|
||||
<Alert severity="info">
|
||||
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.
|
||||
</Alert>
|
||||
) : 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]
|
||||
);
|
||||
}
|
|
@ -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
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue