Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up token defination to reduce work when expand chain #2405

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 25 additions & 135 deletions src/constants/bases.ts
Original file line number Diff line number Diff line change
@@ -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[]
Expand Down Expand Up @@ -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]],
}
Loading
Loading