From 486c8d14fea7c1c9596bb8335c9a74f89b7e3a56 Mon Sep 17 00:00:00 2001 From: viet-nv Date: Mon, 27 Nov 2023 17:37:07 +0700 Subject: [PATCH] chore: clean up token defination to reduce work when expand chain --- src/constants/bases.ts | 160 +++--------------- src/constants/tokens.ts | 215 +++--------------------- src/hooks/useAllCurrencyCombinations.ts | 17 +- src/state/user/hooks.tsx | 17 +- src/state/user/reducer.ts | 6 - 5 files changed, 50 insertions(+), 365 deletions(-) diff --git a/src/constants/bases.ts b/src/constants/bases.ts index 808d2b0641..60b043790d 100644 --- a/src/constants/bases.ts +++ b/src/constants/bases.ts @@ -1,7 +1,5 @@ import { ChainId, Token, WETH } from '@kyberswap/ks-sdk-core' -import { AMPL, COMP, DAI, MKR, USDC, USDT, WBTC_ARBITRUM } from './tokens' - // a list of tokens by chain type ChainTokenList = { readonly [chainId in ChainId]: Token[] @@ -33,152 +31,44 @@ const WETH_ONLY: ChainTokenList = { } // used to construct intermediary pairs for trading +// => Only used for elastic swap export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ...WETH_ONLY, [ChainId.MAINNET]: [ WETH[ChainId.MAINNET], - DAI[ChainId.MAINNET], - USDC[ChainId.MAINNET], - USDT[ChainId.MAINNET], - COMP, - MKR, - ], - [ChainId.MUMBAI]: [...WETH_ONLY[ChainId.MUMBAI], DAI[ChainId.MUMBAI], USDC[ChainId.MUMBAI], USDT[ChainId.MUMBAI]], - [ChainId.MATIC]: [ - ...WETH_ONLY[ChainId.MATIC], - DAI[ChainId.MATIC], - USDC[ChainId.MATIC], - USDT[ChainId.MATIC], - new Token(ChainId.MATIC, '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', 18, 'ETH', 'Ether'), - ], - - [ChainId.BSCTESTNET]: [ - ...WETH_ONLY[ChainId.BSCTESTNET], - DAI[ChainId.BSCTESTNET], - USDC[ChainId.BSCTESTNET], - USDT[ChainId.BSCTESTNET], - ], - [ChainId.BSCMAINNET]: [ - ...WETH_ONLY[ChainId.BSCMAINNET], - DAI[ChainId.BSCMAINNET], - USDC[ChainId.BSCMAINNET], - USDT[ChainId.BSCMAINNET], - new Token(ChainId.BSCMAINNET, '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', 18, 'BUSD', 'BUSD'), - ], - [ChainId.AVAXTESTNET]: [ - ...WETH_ONLY[ChainId.AVAXTESTNET], - DAI[ChainId.AVAXTESTNET], - USDC[ChainId.AVAXTESTNET], - USDT[ChainId.AVAXTESTNET], - ], - [ChainId.AVAXMAINNET]: [ - ...WETH_ONLY[ChainId.AVAXMAINNET], - DAI[ChainId.AVAXMAINNET], - USDC[ChainId.AVAXMAINNET], - USDT[ChainId.AVAXMAINNET], + new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'DAI'), + new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC', 'USD Coin'), + new Token(ChainId.MAINNET, '0xdAC17F958D2ee523a2206206994597C13D831ec7', 6, 'USDT', 'Tether USD'), ], - [ChainId.FANTOM]: [...WETH_ONLY[ChainId.FANTOM], DAI[ChainId.FANTOM], USDC[ChainId.FANTOM], USDT[ChainId.FANTOM]], - [ChainId.CRONOS]: [...WETH_ONLY[ChainId.CRONOS], DAI[ChainId.CRONOS], USDC[ChainId.CRONOS], USDT[ChainId.CRONOS]], - [ChainId.AURORA]: [...WETH_ONLY[ChainId.AURORA], DAI[ChainId.AURORA], USDC[ChainId.AURORA], USDT[ChainId.AURORA]], - [ChainId.BTTC]: [ - ...WETH_ONLY[ChainId.BTTC], - DAI[ChainId.BTTC], - USDC[ChainId.BTTC], - USDT[ChainId.BTTC], - new Token(ChainId.BTTC, '0xdB28719F7f938507dBfe4f0eAe55668903D34a15', 6, 'USDT_t', 'USDT_t'), - new Token(ChainId.BTTC, '0xE887512ab8BC60BcC9224e1c3b5Be68E26048B8B', 6, 'USDT_e', 'USDT_e'), - new Token(ChainId.BTTC, '0xedf53026aea60f8f75fca25f8830b7e2d6200662', 6, 'TRX', 'TRX'), - ], - [ChainId.OPTIMISM]: [...WETH_ONLY[ChainId.OPTIMISM], USDC[ChainId.OPTIMISM], USDT[ChainId.OPTIMISM]], - [ChainId.SOLANA]: [...WETH_ONLY[ChainId.SOLANA], DAI[ChainId.SOLANA], USDC[ChainId.SOLANA], USDT[ChainId.SOLANA]], -} - -/** - * Some tokens can only be swapped via certain pairs, so we override the list of bases that are considered for these - * tokens. - */ -export const CUSTOM_BASES: { [chainId in ChainId]?: { [tokenAddress: string]: Token[] } } = { - [ChainId.MAINNET]: { - [AMPL.address]: [DAI[ChainId.MAINNET], WETH[ChainId.MAINNET]], - }, -} - -// used for display common base in currency search -export const SUGGESTED_BASES: ChainTokenList = { - ...WETH_ONLY, - [ChainId.MAINNET]: [ - ...WETH_ONLY[ChainId.MAINNET], - DAI[ChainId.MAINNET], - USDC[ChainId.MAINNET], - USDT[ChainId.MAINNET], - new Token(ChainId.MAINNET, '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', 18, 'wstETH', 'Wrapped stETH (Lido)'), - ], - [ChainId.GÖRLI]: [...WETH_ONLY[ChainId.GÖRLI], DAI[ChainId.GÖRLI], USDC[ChainId.GÖRLI], USDT[ChainId.GÖRLI]], [ChainId.MATIC]: [ - ...WETH_ONLY[ChainId.MATIC], - DAI[ChainId.MATIC], - USDC[ChainId.MATIC], - USDT[ChainId.MATIC], - new Token(ChainId.MATIC, '0xa3Fa99A148fA48D14Ed51d610c367C61876997F1', 18, 'MAI', 'MAI'), - new Token(ChainId.MATIC, '0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4', 18, 'stMATIC', 'Staked MATIC (PoS)'), + WETH[ChainId.MATIC], + new Token(ChainId.MATIC, '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063', 18, 'DAI', 'DAI'), + new Token(ChainId.MATIC, '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', 6, 'USDC', 'USD Coin'), + new Token(ChainId.MATIC, '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', 6, 'USDT', 'Tether USD'), + new Token(ChainId.MATIC, '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', 18, 'WETH', 'Ether'), ], [ChainId.BSCMAINNET]: [ - ...WETH_ONLY[ChainId.BSCMAINNET], - DAI[ChainId.BSCMAINNET], - USDC[ChainId.BSCMAINNET], - USDT[ChainId.BSCMAINNET], + WETH[ChainId.BSCMAINNET], + new Token(ChainId.BSCMAINNET, '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3', 18, 'DAI', 'DAI'), + new Token(ChainId.BSCMAINNET, '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', 18, 'USDC', 'USDC'), + new Token(ChainId.BSCMAINNET, '0x55d398326f99059fF775485246999027B3197955', 18, 'USDT', 'Tether USD'), new Token(ChainId.BSCMAINNET, '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', 18, 'BUSD', 'BUSD'), ], [ChainId.AVAXMAINNET]: [ - ...WETH_ONLY[ChainId.AVAXMAINNET], - USDC[ChainId.AVAXMAINNET], - USDT[ChainId.AVAXMAINNET], - new Token(ChainId.AVAXMAINNET, '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7', 6, 'USDt', 'TetherToken'), - new Token(ChainId.AVAXMAINNET, '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', 6, 'USDC', 'USD Coin'), - new Token(ChainId.AVAXMAINNET, '0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE', 18, 'sAVAX', 'Staked AVAX'), - ], - [ChainId.FANTOM]: [...WETH_ONLY[ChainId.FANTOM], DAI[ChainId.FANTOM], USDC[ChainId.FANTOM], USDT[ChainId.FANTOM]], - [ChainId.CRONOS]: [...WETH_ONLY[ChainId.CRONOS], DAI[ChainId.CRONOS], USDC[ChainId.CRONOS], USDT[ChainId.CRONOS]], - [ChainId.AURORA]: [ - ...WETH_ONLY[ChainId.AURORA], - DAI[ChainId.AURORA], - USDC[ChainId.AURORA], - USDT[ChainId.AURORA], - new Token(ChainId.AURORA, '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', 18, 'Aurora', 'Aurora'), + WETH[ChainId.AVAXMAINNET], + new Token(ChainId.AVAXMAINNET, '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70', 18, 'DAI', 'DAI'), + new Token(ChainId.AVAXMAINNET, '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664', 6, 'USDC.e', 'USDC.e'), + new Token(ChainId.AVAXMAINNET, '0xc7198437980c041c805A1EDcbA50c1Ce5db95118', 6, 'USDT.e', 'Tether USD'), ], - [ChainId.ARBITRUM]: [ - ...WETH_ONLY[ChainId.ARBITRUM], - new Token(ChainId.ARBITRUM, '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', 6, 'USDC', 'USDC'), - DAI[ChainId.ARBITRUM], - USDC[ChainId.ARBITRUM], // USDC.e - USDT[ChainId.ARBITRUM], - WBTC_ARBITRUM, - new Token(ChainId.ARBITRUM, '0x5979D7b546E38E414F7E9822514be443A4800529', 18, 'wstETH', 'Lido Wrapped Staked ETH'), + [ChainId.FANTOM]: [ + WETH[ChainId.FANTOM], + new Token(ChainId.FANTOM, '0x91a40C733c97a6e1BF876EaF9ed8c08102eB491f', 18, 'DAI', 'DAI'), + new Token(ChainId.FANTOM, '0x28a92dde19D9989F39A49905d7C9C2FAc7799bDf', 6, 'USDC', 'USD Coin'), + new Token(ChainId.FANTOM, '0xcc1b99dDAc1a33c201a742A1851662E87BC7f22C', 6, 'fUSDT', 'Tether USD'), ], - [ChainId.BTTC]: [...WETH_ONLY[ChainId.BTTC], DAI[ChainId.BTTC], USDC[ChainId.BTTC], USDT[ChainId.BTTC]], [ChainId.OPTIMISM]: [ - ...WETH_ONLY[ChainId.OPTIMISM], - USDC[ChainId.OPTIMISM], - new Token(ChainId.OPTIMISM, '0x4200000000000000000000000000000000000042', 18, 'OP', 'Optimism'), - USDT[ChainId.OPTIMISM], - DAI[ChainId.OPTIMISM], - new Token(ChainId.OPTIMISM, '0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb', 18, 'wstETH', 'Lido Wrapped Staked ETH'), - ], - [ChainId.SOLANA]: [...WETH_ONLY[ChainId.SOLANA], USDC[ChainId.SOLANA], USDT[ChainId.SOLANA]], - [ChainId.ZKSYNC]: [ - ...WETH_ONLY[ChainId.ZKSYNC], - USDC[ChainId.ZKSYNC], - USDT[ChainId.ZKSYNC], - new Token(ChainId.ZKSYNC, '0xfC7E56298657B002b3e656400E746b7212912757', 6, 'zkUSD', 'zkUSD'), - new Token(ChainId.ZKSYNC, '0x8e86e46278518efc1c5ced245cba2c7e3ef11557', 6, 'USD+', 'USD+'), - new Token(ChainId.ZKSYNC, '0x503234f203fc7eb888eec8513210612a43cf6115', 18, 'LUSD', 'LUSD'), - new Token(ChainId.ZKSYNC, '0xbbeb516fb02a01611cbbe0453fe3c580d7281011', 8, 'wBTC', 'wBTC'), - ], - [ChainId.ZKEVM]: [...WETH_ONLY[ChainId.ZKEVM], USDC[ChainId.ZKEVM], USDT[ChainId.ZKEVM], DAI[ChainId.ZKEVM]], - [ChainId.LINEA]: [ - ...WETH_ONLY[ChainId.LINEA], - new Token(ChainId.LINEA, '0x7d43aabc515c356145049227cee54b608342c0ad', 18, 'BUSD', 'BUSD'), + WETH[ChainId.OPTIMISM], + new Token(ChainId.OPTIMISM, '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', 6, 'USDC', 'USD Coin'), + new Token(ChainId.OPTIMISM, '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', 6, 'USDT', 'Tether USD'), ], - [ChainId.BASE]: [...WETH_ONLY[ChainId.BASE], USDC[ChainId.BASE], DAI[ChainId.BASE]], - [ChainId.SCROLL]: [...WETH_ONLY[ChainId.SCROLL], USDT[ChainId.SCROLL], USDC[ChainId.SCROLL], DAI[ChainId.SCROLL]], } diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index f2161ddeb6..e20ca60e35 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -206,174 +206,6 @@ export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = { [ChainId.SOLANA_DEVNET]: [], } -export const DAI: { [chainId in ChainId]: Token } = { - [ChainId.MAINNET]: new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'DAI'), - [ChainId.GÖRLI]: new Token(ChainId.GÖRLI, '0x1BBeeEdCF32dc2c1Ebc2F138e3FC7f3DeCD44D6A', 18, 'DAI', 'DAI'), - [ChainId.MATIC]: new Token(ChainId.MATIC, '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063', 18, 'DAI', 'DAI'), - [ChainId.MUMBAI]: new Token(ChainId.MUMBAI, '0x5e2de02472aC02736b43054f095837725A5870eF', 18, 'DAI', 'DAI'), - [ChainId.BSCTESTNET]: new Token(ChainId.BSCTESTNET, '0xBb843a2296F9AA49070EB2Dcd482f23548238f65', 18, 'DAI', 'DAI'), - [ChainId.BSCMAINNET]: new Token(ChainId.BSCMAINNET, '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3', 18, 'DAI', 'DAI'), - [ChainId.AVAXTESTNET]: new Token(ChainId.AVAXTESTNET, '0xE50c0F38a1890Db49d64ac1C4A5B4fe2f02f819d', 18, 'DAI', 'DAI'), - [ChainId.AVAXMAINNET]: new Token(ChainId.AVAXMAINNET, '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70', 18, 'DAI', 'DAI'), - [ChainId.FANTOM]: new Token(ChainId.FANTOM, '0x91a40C733c97a6e1BF876EaF9ed8c08102eB491f', 18, 'DAI', 'DAI'), - [ChainId.CRONOS]: new Token(ChainId.CRONOS, '0xF2001B145b43032AAF5Ee2884e456CCd805F677D', 18, 'DAI', 'DAI'), - [ChainId.ARBITRUM]: new Token( - ChainId.ARBITRUM, - '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', - 18, - 'DAI_e', - 'DAI_Ethereum', - ), - [ChainId.BTTC]: new Token(ChainId.BTTC, '0xe7dC549AE8DB61BDE71F22097BEcc8dB542cA100', 18, 'DAI', 'DAI'), - [ChainId.AURORA]: new Token(ChainId.AURORA, '0xe3520349F477A5F6EB06107066048508498A291b', 18, 'DAI', 'DAI'), - [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0xC5015b9d9161Dca7e18e32f6f25C4aD850731Fd4', 18, 'DAI', 'Dai'), - [ChainId.LINEA]: new Token(ChainId.LINEA, '0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5', 18, 'DAI', 'Dai'), - [ChainId.BASE]: new Token(ChainId.BASE, '0x50c5725949a6f0c72e6c4a641f24049a917db0cb', 18, 'DAI', 'Dai'), - - [ChainId.OPTIMISM]: new Token(ChainId.OPTIMISM, '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', 18, 'DAI', 'DAI'), - [ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, '0x4BEf76b6b7f2823C6c1f4FcfEACD85C24548ad7e', 18, 'DAI', 'Dai'), - [ChainId.SOLANA]: new Token( - ChainId.SOLANA, - 'EjmyN6qEC1Tf1JxiG1ae7UTJhUxSwk1TCWNWqxWV4J6o', - 8, - 'DAI', - 'DAI (Wormhole)', - ), - [ChainId.SOLANA_DEVNET]: new Token( - ChainId.SOLANA_DEVNET, - 'EjmyN6qEC1Tf1JxiG1ae7UTJhUxSwk1TCWNWqxWV4J6o', - 8, - 'DAI', - 'DAI (Wormhole)', - ), - // TDOD: Get real DAI - [ChainId.SCROLL]: new Token(ChainId.SCROLL, '0x50c5725949a6f0c72e6c4a641f24049a917db0cb', 18, 'DAI', 'Dai'), -} - -export const USDC: { [chainId in ChainId]: Token } = { - [ChainId.MAINNET]: new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC', 'USD Coin'), - [ChainId.GÖRLI]: new Token(ChainId.GÖRLI, '0x8e9Bd30D15420bAe4B7EC0aC014B7ECeE864373C', 18, 'USDC', 'USD Coin'), - [ChainId.MATIC]: new Token(ChainId.MATIC, '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', 6, 'USDC', 'USD Coin'), - [ChainId.MUMBAI]: new Token(ChainId.MUMBAI, '0x2CeC76B26A8d96BF3072D34A01BB3a4edE7c06BE', 6, 'USDC', 'USD Coin'), - [ChainId.BSCTESTNET]: new Token(ChainId.BSCTESTNET, '0xb448B701807E644f141a4E4a269aD2F567526505', 6, 'USDC', 'USDC'), - [ChainId.BSCMAINNET]: new Token(ChainId.BSCMAINNET, '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', 18, 'USDC', 'USDC'), - [ChainId.AVAXTESTNET]: new Token( - ChainId.AVAXTESTNET, - '0x5973774202E8b0ad563A69D502bb0e670e7d00Dd', - 6, - 'USDC', - 'USDC', - ), - [ChainId.AVAXMAINNET]: new Token( - ChainId.AVAXMAINNET, - '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664', - 6, - 'USDC.e', - 'USDC', - ), - [ChainId.FANTOM]: new Token(ChainId.FANTOM, '0x28a92dde19D9989F39A49905d7C9C2FAc7799bDf', 6, 'USDC', 'USD Coin'), - [ChainId.CRONOS]: new Token(ChainId.CRONOS, '0xc21223249CA28397B4B6541dfFaEcC539BfF0c59', 6, 'USDC', 'USD Coin'), - [ChainId.ARBITRUM]: new Token(ChainId.ARBITRUM, '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', 6, 'USDC', 'USD Coin'), - [ChainId.BTTC]: new Token(ChainId.BTTC, '0xCa424b845497f7204D9301bd13Ff87C0E2e86FCF', 18, 'USDC_b', 'USD Coin_BSC'), - [ChainId.AURORA]: new Token(ChainId.AURORA, '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', 6, 'USDC', 'USD Coin'), - [ChainId.OPTIMISM]: new Token(ChainId.OPTIMISM, '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', 6, 'USDC', 'USD Coin'), - [ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, '0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4', 6, 'USDC', 'USD Coin'), - [ChainId.SOLANA]: new Token(ChainId.SOLANA, 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 6, 'USDC', 'USD Coin'), - [ChainId.SOLANA_DEVNET]: new Token( - ChainId.SOLANA_DEVNET, - 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', - 6, - 'USDC', - 'USD Coin', - ), - [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035', 6, 'USDC', 'USD Coin'), - [ChainId.LINEA]: new Token(ChainId.LINEA, '0x176211869cA2b568f2A7D4EE941E073a821EE1ff', 6, 'USDC', 'USD Coin'), - [ChainId.BASE]: new Token(ChainId.BASE, '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', 6, 'USDC', 'USD Coin'), - // TODO: verify this USDC on Scroll - [ChainId.SCROLL]: new Token(ChainId.SCROLL, '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', 6, 'USDC', 'USD Coin'), -} - -export const USDT: { [chainId in ChainId]: Token } = { - [ChainId.MAINNET]: new Token(ChainId.MAINNET, '0xdAC17F958D2ee523a2206206994597C13D831ec7', 6, 'USDT', 'Tether USD'), - [ChainId.GÖRLI]: new Token(ChainId.GÖRLI, '0x2bf64acf7ead856209749d0d125e9ade2d908e7f', 18, 'USDT', 'Tether USD'), - [ChainId.MATIC]: new Token(ChainId.MATIC, '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', 6, 'USDT', 'Tether USD'), - [ChainId.MUMBAI]: new Token(ChainId.MUMBAI, '0x064B91Bda6d178DfE03835de9450BFe78201c43F', 6, 'USDT', 'Tether USD'), - [ChainId.BSCTESTNET]: new Token( - ChainId.BSCTESTNET, - '0x3d8f2Ada8e97e4eF19e4ccBf6ec1Ca52900406aA', - 6, - 'USDT', - 'Tether USD', - ), - [ChainId.BSCMAINNET]: new Token( - ChainId.BSCMAINNET, - '0x55d398326f99059fF775485246999027B3197955', - 18, - 'USDT', - 'Tether USD', - ), - [ChainId.AVAXTESTNET]: new Token( - ChainId.AVAXTESTNET, - '0x42296280d753ecdfafe9dbdfa912c9e6221a4e05', - 18, - 'USDT', - 'Tether USD', - ), - [ChainId.AVAXMAINNET]: new Token( - ChainId.AVAXMAINNET, - '0xc7198437980c041c805A1EDcbA50c1Ce5db95118', - 6, - 'USDT.e', - 'Tether USD', - ), - [ChainId.FANTOM]: new Token(ChainId.FANTOM, '0xcc1b99dDAc1a33c201a742A1851662E87BC7f22C', 6, 'fUSDT', 'Tether USD'), - [ChainId.CRONOS]: new Token(ChainId.CRONOS, '0x66e428c3f67a68878562e79A0234c1F83c208770', 6, 'USDT', 'Tether USD'), - [ChainId.ARBITRUM]: new Token( - ChainId.ARBITRUM, - '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', - 6, - 'USDT', - 'Tether USD', - ), - [ChainId.BTTC]: new Token(ChainId.BTTC, '0x9B5F27f6ea9bBD753ce3793a07CbA3C74644330d', 18, 'USDT_b', 'Tether USD_BSC'), - [ChainId.AURORA]: new Token(ChainId.AURORA, '0x4988a896b1227218e4A686fdE5EabdcAbd91571f', 6, 'USDT', 'Tether USD'), - [ChainId.OPTIMISM]: new Token( - ChainId.OPTIMISM, - '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', - 6, - 'USDT', - 'Tether USD', - ), - [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0x1E4a5963aBFD975d8c9021ce480b42188849D41d', 6, 'USDT', 'Tether USD'), - [ChainId.LINEA]: new Token(ChainId.LINEA, '0xA219439258ca9da29E9Cc4cE5596924745e12B93', 6, 'USDT', 'Tether USD'), - - [ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, '0x493257fd37edb34451f62edf8d2a0c418852ba4c', 6, 'USDT', 'Tether USD'), - [ChainId.SOLANA]: new Token(ChainId.SOLANA, 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', 6, 'USDT', 'Tether USD'), - [ChainId.SOLANA_DEVNET]: new Token( - ChainId.SOLANA_DEVNET, - 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', - 6, - 'USDT', - 'Tether USD', - ), - - // not existed - [ChainId.BASE]: new Token(ChainId.BASE, '0xA219439258ca9da29E9Cc4cE5596924745e12B93', 6, 'USDT', 'Tether USD'), - // TODO: verify this address - [ChainId.SCROLL]: new Token(ChainId.SCROLL, '0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df', 6, 'USDT', 'Tether USD'), -} - -export const COMP = new Token(ChainId.MAINNET, '0xc00e94Cb662C3520282E6f5717214004A7f26888', 18, 'COMP', 'Compound') -export const MKR = new Token(ChainId.MAINNET, '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2', 18, 'MKR', 'Maker') -export const AMPL = new Token(ChainId.MAINNET, '0xD46bA6D942050d489DBd938a2C909A5d5039A161', 9, 'AMPL', 'Ampleforth') -export const WBTC_ARBITRUM = new Token( - ChainId.ARBITRUM, - '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f', - 8, - 'WBTC', - 'Wrapped BTC', -) - export const KNC_ADDRESS = '0xdeFA4e8a7bcBA345F687a2f1456F5Edd9CE97202' export const KNCL_ADDRESS = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200' @@ -412,35 +244,30 @@ export const KNC: { [chainId in ChainId]: Token } = { ), } -export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = { - [ChainId.MAINNET]: [ - [ - new Token(ChainId.MAINNET, '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643', 8, 'cDAI', 'Compound Dai'), - new Token(ChainId.MAINNET, '0x39AA39c021dfbaE8faC545936693aC917d5E7563', 8, 'cUSDC', 'Compound USD Coin'), - ], - [USDC[ChainId.MAINNET], USDT[ChainId.MAINNET]], - [DAI[ChainId.MAINNET], USDT[ChainId.MAINNET]], - ], -} - export const DEFAULT_OUTPUT_TOKEN_BY_CHAIN: Partial> = { - [ChainId.MAINNET]: USDT[ChainId.MAINNET], - [ChainId.MATIC]: USDT[ChainId.MATIC], + [ChainId.MAINNET]: new Token(ChainId.MAINNET, '0xdAC17F958D2ee523a2206206994597C13D831ec7', 6, 'USDT', 'Tether USD'), + [ChainId.MATIC]: new Token(ChainId.MATIC, '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', 6, 'USDT', 'Tether USD'), [ChainId.BSCMAINNET]: new Token(ChainId.BSCMAINNET, '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', 18, 'BUSD', 'BUSD'), - [ChainId.AVAXMAINNET]: USDC[ChainId.AVAXMAINNET], // USDC.e - [ChainId.FANTOM]: USDC[ChainId.FANTOM], - [ChainId.CRONOS]: USDC[ChainId.CRONOS], + [ChainId.AVAXMAINNET]: new Token( + ChainId.AVAXMAINNET, + '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664', + 6, + 'USDC.e', + 'USDC.e', + ), + [ChainId.FANTOM]: new Token(ChainId.FANTOM, '0x28a92dde19D9989F39A49905d7C9C2FAc7799bDf', 6, 'USDC', 'USD Coin'), + [ChainId.CRONOS]: new Token(ChainId.CRONOS, '0xc21223249CA28397B4B6541dfFaEcC539BfF0c59', 6, 'USDC', 'USD Coin'), [ChainId.ARBITRUM]: new Token(ChainId.ARBITRUM, '0x912CE59144191C1204E64559FE8253a0e49E6548', 18, 'ARB', 'Arbitrum'), - [ChainId.OPTIMISM]: USDC[ChainId.OPTIMISM], - [ChainId.AURORA]: USDC[ChainId.AURORA], - [ChainId.BTTC]: USDT[ChainId.BTTC], // USDT_b - [ChainId.SOLANA]: USDC[ChainId.SOLANA], - [ChainId.GÖRLI]: USDT[ChainId.GÖRLI], - [ChainId.ZKSYNC]: USDC[ChainId.ZKSYNC], - [ChainId.ZKEVM]: USDT[ChainId.ZKEVM], - [ChainId.LINEA]: USDC[ChainId.LINEA], - [ChainId.BASE]: USDC[ChainId.BASE], - [ChainId.SCROLL]: USDT[ChainId.SCROLL], + [ChainId.OPTIMISM]: new Token(ChainId.OPTIMISM, '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', 6, 'USDC', 'USD Coin'), + [ChainId.AURORA]: new Token(ChainId.AURORA, '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', 6, 'USDC', 'USD Coin'), + [ChainId.BTTC]: new Token(ChainId.BTTC, '0x9B5F27f6ea9bBD753ce3793a07CbA3C74644330d', 18, 'USDT_b', 'Tether USD_BSC'), + [ChainId.GÖRLI]: new Token(ChainId.GÖRLI, '0x2bf64acf7ead856209749d0d125e9ade2d908e7f', 18, 'USDT', 'Tether USD'), + [ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, '0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4', 6, 'USDC', 'USD Coin'), + [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0x1E4a5963aBFD975d8c9021ce480b42188849D41d', 6, 'USDT', 'Tether USD'), + [ChainId.LINEA]: new Token(ChainId.LINEA, '0x176211869cA2b568f2A7D4EE941E073a821EE1ff', 6, 'USDC', 'USD Coin'), + [ChainId.BASE]: new Token(ChainId.BASE, '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', 6, 'USDC', 'USD Coin'), + [ChainId.SCROLL]: new Token(ChainId.SCROLL, '0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df', 6, 'USDT', 'Tether USD'), + [ChainId.SOLANA]: new Token(ChainId.SOLANA, 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 6, 'USDC', 'USD Coin'), } export const DEFAULT_SWAP_FEE_STABLE_PAIRS = 4 diff --git a/src/hooks/useAllCurrencyCombinations.ts b/src/hooks/useAllCurrencyCombinations.ts index 9a3e81e4be..18cce397d2 100644 --- a/src/hooks/useAllCurrencyCombinations.ts +++ b/src/hooks/useAllCurrencyCombinations.ts @@ -1,7 +1,7 @@ import { Currency, Token } from '@kyberswap/ks-sdk-core' import { useMemo } from 'react' -import { BASES_TO_CHECK_TRADES_AGAINST, CUSTOM_BASES } from 'constants/bases' +import { BASES_TO_CHECK_TRADES_AGAINST } from 'constants/bases' import { useActiveWeb3React } from './index' @@ -59,21 +59,6 @@ export function useAllCurrencyCombinations(currencyA?: Currency, currencyB?: Cur ] .filter((tokens): tokens is [Token, Token] => Boolean(tokens[0] && tokens[1])) .filter(([t0, t1]) => t0.address !== t1.address) - .filter(([tokenA, tokenB]) => { - if (!chainId) return true - const customBases = CUSTOM_BASES[chainId] - if (!customBases) return true - - const customBasesA: Token[] | undefined = customBases[tokenA.address] - const customBasesB: Token[] | undefined = customBases[tokenB.address] - - if (!customBasesA && !customBasesB) return true - - if (customBasesA && !customBasesA.find(base => tokenB.equals(base))) return false - if (customBasesB && !customBasesB.find(base => tokenA.equals(base))) return false - - return true - }) : [] }, [chainId, currencyA, currencyB]) } diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index 78fc322394..402902fb0e 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -3,10 +3,8 @@ import { useCallback, useMemo } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useGetParticipantInfoQuery, useLazyGetParticipantInfoQuery } from 'services/kyberAISubscription' -import { SUGGESTED_BASES } from 'constants/bases' import { INITIAL_ALLOWED_SLIPPAGE, TERM_FILES_PATH } from 'constants/index' import { SupportedLocale } from 'constants/locales' -import { PINNED_PAIRS } from 'constants/tokens' import { useActiveWeb3React } from 'hooks' import { useAllTokens } from 'hooks/Tokens' import { @@ -322,9 +320,6 @@ export function useLiquidityPositionTokenPairs(): [Token, Token][] { const { chainId } = useActiveWeb3React() const allTokens = useAllTokens() - // pinned pairs - const pinnedPairs = useMemo(() => (chainId ? PINNED_PAIRS[chainId] ?? [] : []), [chainId]) - const { data: userLiquidityPositions } = useUserLiquidityPositions() // get pairs that has liquidity @@ -360,10 +355,7 @@ export function useLiquidityPositionTokenPairs(): [Token, Token][] { }) }, [savedSerializedPairs, chainId]) - const combinedList = useMemo( - () => userPairs.concat(generatedPairs).concat(pinnedPairs), - [generatedPairs, pinnedPairs, userPairs], - ) + const combinedList = useMemo(() => userPairs.concat(generatedPairs), [generatedPairs, userPairs]) return useMemo(() => { // dedupes pairs of tokens in the combined list @@ -428,19 +420,16 @@ export const useUserFavoriteTokens = (customChain?: ChainId) => { const dispatch = useDispatch() const { favoriteTokensByChainIdv2: favoriteTokensByChainId } = useSelector((state: AppState) => state.user) const { commonTokens } = useKyberSwapConfig(chainId) - const defaultTokens = useMemo(() => { - return commonTokens || SUGGESTED_BASES[chainId || ChainId.MAINNET].map(e => e.address) - }, [commonTokens, chainId]) const favoriteTokens = useMemo(() => { if (!chainId) return undefined const favoritedTokens = favoriteTokensByChainId?.[chainId] || {} - const favoritedTokenAddresses = defaultTokens + const favoritedTokenAddresses = (commonTokens || []) .filter(address => favoritedTokens[address.toLowerCase()] !== false) .concat(Object.keys(favoritedTokens).filter(address => favoritedTokens[address])) return [...new Set(favoritedTokenAddresses.map(a => a.toLowerCase()))] - }, [chainId, favoriteTokensByChainId, defaultTokens]) + }, [chainId, favoriteTokensByChainId, commonTokens]) const toggleFavoriteToken = useCallback( (payload: ToggleFavoriteTokenPayload) => { diff --git a/src/state/user/reducer.ts b/src/state/user/reducer.ts index 373102e0ea..9a21ecf3d4 100644 --- a/src/state/user/reducer.ts +++ b/src/state/user/reducer.ts @@ -1,7 +1,6 @@ import { ChainId } from '@kyberswap/ks-sdk-core' import { createReducer } from '@reduxjs/toolkit' -import { SUGGESTED_BASES } from 'constants/bases' import { DEFAULT_DEADLINE_FROM_NOW, DEFAULT_SLIPPAGE, @@ -142,11 +141,6 @@ function pairKey(token0Address: string, token1Address: string) { return `${token0Address};${token1Address}` } -export const getFavoriteTokenDefault = (chainId: ChainId) => ({ - addresses: SUGGESTED_BASES[chainId].map(e => e.address), - includeNativeToken: true, -}) - export const CROSS_CHAIN_SETTING_DEFAULT = { isSlippageControlPinned: true, slippageTolerance: INITIAL_ALLOWED_SLIPPAGE,