Skip to content

Commit

Permalink
TokensModal only show native token when possible
Browse files Browse the repository at this point in the history
Prevent users from receiving wrapped tokens when they could receive
the  native version.
  • Loading branch information
kev1n-peters committed Apr 12, 2024
1 parent 70d2589 commit 69f01fc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
12 changes: 11 additions & 1 deletion wormhole-connect/src/components/TokensModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ function TokensModal(props: Props) {

useEffect(() => {
// get tokens that exist on the chain and have a balance greater than 0
const filtered = supportedTokens.filter((t) => {
let filtered = supportedTokens.filter((t) => {
if (!t.tokenId && t.nativeChain !== chain) return false;

// if token is USDC and the chain is cctp enabled, only show native ones
Expand Down Expand Up @@ -511,6 +511,16 @@ function TokensModal(props: Props) {
const isNonzeroBalance = b !== null && b !== '0';
return isNonzeroBalance;
});

// If any of the tokens are native to the chain, only show those.
// This is to avoid users inadvertently receiving wrapped versions of the token.
if (type === 'dest') {
const nativeTokens = filtered.filter((t) => t.nativeChain === chain);
if (nativeTokens.length > 0) {
filtered = nativeTokens;
}
}

setTokens(filtered);
}, [chainBalancesCache, chain, supportedTokens, type]);

Expand Down
42 changes: 21 additions & 21 deletions wormhole-connect/src/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,27 @@ export const isIlliquidDestToken = (
return true;
}
}
// Users should send USDC to Fantom via NTT instead of the token bridge
if (
symbol === 'USDC' &&
nativeChain === 'ethereum' &&
destChain === 'fantom'
) {
return true;
}
if (
symbol === 'USDC' &&
nativeChain === 'fuji' &&
destChain === 'alfajores'
) {
return true;
}
if (
symbol === 'USDC.e' &&
(nativeChain === 'fantom' || nativeChain === 'alfajores')
) {
return true;
}
//// Users should send USDC to Fantom via NTT instead of the token bridge
//if (
// symbol === 'USDC' &&
// nativeChain === 'ethereum' &&
// destChain === 'fantom'
//) {
// return true;
//}
//if (
// symbol === 'USDC' &&
// nativeChain === 'fuji' &&
// destChain === 'alfajores'
//) {
// return true;
//}
//if (
// symbol === 'USDC.e' &&
// (nativeChain === 'fantom' || nativeChain === 'alfajores')
//) {
// return true;
//}
return false;
};

Expand Down

0 comments on commit 69f01fc

Please sign in to comment.