From 2812bd52afd30df06491b9053513a08c929d07ae Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 13 Dec 2024 15:14:33 +0000 Subject: [PATCH] Add uniswap list for base and base sepolia --- .github/scripts/generateMatrix.ts | 50 ++++++++++++++++++++----------- src/lib/token_list_gen.ts | 23 ++++++++++++++ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/.github/scripts/generateMatrix.ts b/.github/scripts/generateMatrix.ts index 57f1dd9a..0868bd69 100644 --- a/.github/scripts/generateMatrix.ts +++ b/.github/scripts/generateMatrix.ts @@ -14,7 +14,7 @@ const arbitrumCommands: Command[] = [ paths: ['ArbTokenLists/arbed_full.json'], version: false, command: - 'npm run fullList --l2NetworkID 42161 --newArbifiedList ./src/ArbTokenLists/arbed_full.json --skipValidation', + 'yarn fullList --l2NetworkID 42161 --newArbifiedList ./src/ArbTokenLists/arbed_full.json --skipValidation', }, { name: 'Arb1 Arbify Uniswap', @@ -94,6 +94,21 @@ const arbitrumCommands: Command[] = [ command: 'yarn arbify --l2NetworkID 421614 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/421614_arbed_coingecko.json', }, + // Base + { + name: 'Base Uniswap', + paths: ['ArbTokenLists/8453_uniswap_labs.json'], + version: true, + command: + 'yarn arbify --l2NetworkID 8453 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/8453_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/8453_uniswap_labs.json', + }, + { + name: 'Base Sepolia Uniswap', + paths: ['ArbTokenLists/84532_uniswap_labs.json'], + version: true, + command: + 'yarn arbify --l2NetworkID 84532 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/84532_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/84532_uniswap_labs.json', + }, ]; const orbitCommands: Command[] = []; @@ -128,22 +143,23 @@ async function addCommand({ } function getUniswapTokenListFromPartnerChainId(chainId: number) { - return ( - { - // L1 - 1: 'https://tokens.uniswap.org', - 11155111: 'https://tokens.uniswap.org', - 17000: 'https://tokens.uniswap.org', - // Arbitrum - 42161: - 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json', - 42170: - 'https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_uniswap_labs.json', - 421614: - 'https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_uniswap_labs.json', - // Base - }[chainId] ?? 'https://tokens.uniswap.org' - ); + return { + // L1 + 1: 'https://tokens.uniswap.org', + 11155111: 'https://tokens.uniswap.org', + 17000: 'https://tokens.uniswap.org', + // Arbitrum + 42161: + 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json', + 42170: + 'https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_uniswap_labs.json', + 421614: + 'https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_uniswap_labs.json', + // Base + 8453: 'https://tokenlist.arbitrum.io/ArbTokenLists/8453_uniswap_labs.json', + 84532: + 'https://tokenlist.arbitrum.io/ArbTokenLists/84532_uniswap_labs.json', + }[chainId]; } const l1ChainIds = [1, 11155111, 17000]; // Mainnet, sepolia, holesky (async () => { diff --git a/src/lib/token_list_gen.ts b/src/lib/token_list_gen.ts index 43c3d5e7..9eec97aa 100644 --- a/src/lib/token_list_gen.ts +++ b/src/lib/token_list_gen.ts @@ -376,6 +376,29 @@ export const arbifyL1List = async ( const prevArbTokenList = ignorePreviousList ? null : await getPrevList(prevArbifiedList); + + // We can't arbify token list for base, we filter out non-base tokens from uniswap list + const argv = getArgvs(); + if (argv.l2NetworkID === 8453 || argv.l2NetworkID === 84532) { + const tokens = l1TokenList.tokens + .filter((token) => token.chainId === argv.l2NetworkID) + .map(({ extensions, ...token }) => ({ + ...token, + })); + + const version = getVersion(prevArbTokenList, tokens); + return { + newList: { + ...l1TokenList, + name: `Uniswap labs ${argv.l2NetworkID}`, + timestamp: new Date().toISOString(), + version, + tokens, + }, + l1ListName: l1TokenList.name, + }; + } + const newList = await generateTokenList(l1TokenList, prevArbTokenList, { includeAllL1Tokens: false, includeOldDataFields,