Skip to content

Commit d71c199

Browse files
authored
Merge pull request #1898 from AmbireTech/feature/add-jpyc-to-main
Feature / Add JPYC as a fee token in the extension
2 parents 6995c83 + 4ddaf9b commit d71c199

3 files changed

Lines changed: 72 additions & 6 deletions

File tree

src/consts/gasTankFeeTokens.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ export default [
184184
decimals: 18,
185185
icon: 'https://assets.coingecko.com/coins/images/2518/small/weth.png?1628852295'
186186
},
187+
{
188+
address: '0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29',
189+
symbol: 'jpyc',
190+
chainId: 1n,
191+
decimals: 18,
192+
icon: 'https://assets.coingecko.com/coins/images/70314/standard/JPYC_400x400.jpg'
193+
},
187194
{
188195
address: '0x1abaea1f7c830bd89acc67ec4af516284b1bc33c',
189196
symbol: 'eurc',
@@ -337,6 +344,13 @@ export default [
337344
decimals: 18,
338345
icon: 'https://assets.coingecko.com/coins/images/14073/small/matic.png'
339346
},
347+
{
348+
address: '0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29',
349+
symbol: 'jpyc',
350+
chainId: 137n,
351+
decimals: 18,
352+
icon: 'https://assets.coingecko.com/coins/images/70314/standard/JPYC_400x400.jpg'
353+
},
340354
{
341355
address: '0x03b54a6e9a984069379fae1a4fc4dbae93b3bccd',
342356
symbol: 'wsteth',
@@ -531,6 +545,13 @@ export default [
531545
decimals: 18,
532546
icon: 'https://assets.coingecko.com/coins/images/15075/small/wrapped-avax.png'
533547
},
548+
{
549+
address: '0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29',
550+
symbol: 'jpyc',
551+
chainId: 43114n,
552+
decimals: 18,
553+
icon: 'https://assets.coingecko.com/coins/images/70314/standard/JPYC_400x400.jpg'
554+
},
534555
{
535556
address: '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70',
536557
symbol: 'dai',

src/libs/swapAndBridge/swapAndBridge.ts

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { LIFI_EXPLORER_URL } from '../../services/lifi/consts'
2020
import {
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'
3132
import { 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
*/
4048
const 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(

src/services/socket/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export const AMBIRE_WALLET_TOKEN_ON_BASE: SwapAndBridgeToToken = {
3232
...AMBIRE_WALLET_TOKEN_COMMON_PROPS
3333
}
3434

35+
export const JPYC_TOKEN = {
36+
name: 'JPY Coin',
37+
symbol: 'JPYC',
38+
decimals: 18,
39+
address: '0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29',
40+
icon: 'https://assets.coingecko.com/coins/images/70314/standard/JPYC_400x400.jpg'
41+
}
42+
3543
export const AMBIRE_FEE_TAKER_ADDRESSES: { [chainId: number]: string } = {
3644
324: '0x942f9CE5D9a33a82F88D233AEb3292E680230348',
3745
1101: '0x942f9CE5D9a33a82F88D233AEb3292E680230348',

0 commit comments

Comments
 (0)