@@ -20,6 +20,7 @@ import { LIFI_EXPLORER_URL } from '../../services/lifi/consts'
2020import {
2121 AMBIRE_WALLET_TOKEN_ON_BASE ,
2222 AMBIRE_WALLET_TOKEN_ON_ETHEREUM ,
23+ JPYC_TOKEN ,
2324 NULL_ADDRESS ,
2425 SOCKET_EXPLORER_URL ,
2526 ZERO_ADDRESS
@@ -31,11 +32,18 @@ import { TokenResult } from '../portfolio'
3132import { getTokenBalanceInUSD } from '../portfolio/helpers'
3233
3334/**
34- * Put a list of all the banned addresses (left side) with their
35- * corresponding valid/correct address (right side).
36- * This is fixing the case of token duplication like EURe. / CELO
37- * where if the incorrect (outdated) address is used instead of the
38- * new one in the swap, no routes will be found
35+ * Maps banned (or outdated) token addresses to their "valid" replacements,
36+ * "valid" meaning Swap & Bridge gives more relevant results with these replacements.
37+ * There are two use cases:
38+ *
39+ * 1. Token replacement (e.g., EURe, GBP.e, CELO): Maps banned (or outdated) addresses
40+ * to the "valid" ones. When these banned addresses are used - we automatically
41+ * map them to the "valid" address (when selected) to ensure routes can be found.
42+ *
43+ * 2. Token filtering (e.g., JPYC variants): Uses identity mapping (same address on both sides).
44+ * These addresses are only used to filter them out from the "to" token list display.
45+ * The valid token is added separately via addCustomTokensIfNeeded(), so these banned
46+ * variants ensure duplication is avoided in the UI.
3947 */
4048const getBannedToValidAddresses = ( ) : {
4149 [ chainId : string ] : { [ bannedAddr : string ] : string }
@@ -64,16 +72,34 @@ const getBannedToValidAddresses = (): {
6472 const bannedGbpeGnosis = '0x8E34bfEC4f6Eb781f9743D9b4af99CD23F9b7053'
6573 const validGbpeGnosis = '0x5Cb9073902F2035222B9749F8fB0c9BFe5527108'
6674
75+ /** ****************************************************
76+ * MAKE SURE ADDRESSES ARE CHECKSUMMED
77+ ****************************************************** */
78+ const bannedJPYC = '0x431D5dfF03120AFA4bDf332c61A6e1766eF37BDB'
79+ const bannedJPYCPos = '0x6AE7Dfc73E0dDE2aa99ac063DcF7e8A63265108c'
80+ const bannedJPYCv1 = '0x2370f9d504c7a6E775bf6E14B3F12846b594cD53'
81+ const bannedJPYsuper = '0xFBb291570DE4B87353B1e0f586Df97A1eD856470'
82+
6783 return {
84+ '1' : {
85+ [ bannedJPYC ] : bannedJPYC ,
86+ [ bannedJPYCv1 ] : bannedJPYCv1
87+ } ,
6888 '137' : {
69- [ bannedEurePolygon ] : validEurePolygon
89+ [ bannedEurePolygon ] : validEurePolygon ,
90+ [ bannedJPYC ] : bannedJPYC ,
91+ [ bannedJPYCPos ] : bannedJPYCPos ,
92+ [ bannedJPYsuper ] : bannedJPYsuper
7093 } ,
7194 '100' : {
7295 [ bannedEureGnosis ] : validEureGnosis ,
7396 [ bannedGbpeGnosis ] : validGbpeGnosis
7497 } ,
7598 '42220' : {
7699 [ bannedCelo ] : validCelo
100+ } ,
101+ '43114' : {
102+ [ bannedJPYC ] : bannedJPYC
77103 }
78104 }
79105}
@@ -402,6 +428,17 @@ const addCustomTokensIfNeeded = ({
402428 ( t ) => t . address !== AMBIRE_WALLET_TOKEN_ON_ETHEREUM . address
403429 )
404430 if ( shouldAddAmbireWalletToken ) newTokens . unshift ( AMBIRE_WALLET_TOKEN_ON_ETHEREUM )
431+
432+ const shouldAddJPYCToken = newTokens . every ( ( t ) => t . address !== JPYC_TOKEN . address )
433+ if ( shouldAddJPYCToken ) newTokens . unshift ( { ...JPYC_TOKEN , chainId : 1 } )
434+ }
435+ if ( chainId === 137 ) {
436+ const shouldAddJPYCToken = newTokens . every ( ( t ) => t . address !== JPYC_TOKEN . address )
437+ if ( shouldAddJPYCToken ) newTokens . unshift ( { ...JPYC_TOKEN , chainId : 137 } )
438+ }
439+ if ( chainId === 43114 ) {
440+ const shouldAddJPYCToken = newTokens . every ( ( t ) => t . address !== JPYC_TOKEN . address )
441+ if ( shouldAddJPYCToken ) newTokens . unshift ( { ...JPYC_TOKEN , chainId : 43114 } )
405442 }
406443 if ( chainId === 8453 ) {
407444 const shouldAddAmbireWalletToken = newTokens . every (
0 commit comments