From f8dd7b3b7f3fafc30c3ab388cf46791230521c91 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:44:46 -0800 Subject: [PATCH] feat: support arb-sepolia (#493) * support arb-sepolia * fix prettier * fix compiling error --- package-lock.json | 14 +++++------ package.json | 2 +- src/providers/caching-token-provider.ts | 20 ++++++++++++---- src/providers/multicall-uniswap-provider.ts | 2 +- src/providers/token-fee-fetcher.ts | 2 +- src/providers/token-provider.ts | 21 ++++++++++++++++ src/providers/v2/static-subgraph-provider.ts | 1 + src/providers/v3/static-subgraph-provider.ts | 5 +++- src/providers/v3/subgraph-provider.ts | 2 ++ src/routers/alpha-router/alpha-router.ts | 1 + src/routers/alpha-router/config.ts | 1 + .../alpha-router/functions/best-swap-route.ts | 6 ++--- .../functions/get-candidate-pools.ts | 9 +++++-- .../alpha-router/gas-models/gas-model.ts | 4 +++- .../alpha-router/gas-models/v3/gas-costs.ts | 3 +++ src/routers/legacy-router/bases.ts | 3 +++ src/routers/router.ts | 2 +- src/util/addresses.ts | 15 +++++++++++- src/util/chains.ts | 24 ++++++++++++++++++- src/util/gas-factory-helpers.ts | 4 ++-- src/util/methodParameters.ts | 4 ++-- .../alpha-router.integration.test.ts | 4 ++++ 22 files changed, 120 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index cef4301f3..7969b6082 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@uniswap/default-token-list": "^11.2.0", "@uniswap/permit2-sdk": "^1.2.0", "@uniswap/router-sdk": "^1.7.5", - "@uniswap/sdk-core": "^4.0.9", + "@uniswap/sdk-core": "^4.1.2", "@uniswap/swap-router-contracts": "^1.3.0", "@uniswap/token-lists": "^1.0.0-beta.31", "@uniswap/universal-router": "^1.6.0", @@ -3135,9 +3135,9 @@ } }, "node_modules/@uniswap/sdk-core": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-4.0.10.tgz", - "integrity": "sha512-RiobXJKXvVVb+wfNM09Ik8djOMOuRQGfyRP5pHgUjojicK/7nscZILjZ87DjVCGjXEoD8yTSIps0UAQuz6pJIw==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-4.1.2.tgz", + "integrity": "sha512-bk/oHiNCofy48ix84Q8aK/HHDmMVmk+SaoTq6U/93MmJ/nE7hbsckmY1c3MG2Vz1+jnGMCX9AmdBbnSF7VR5Ow==", "dependencies": { "@ethersproject/address": "^5.0.2", "big.js": "^5.2.2", @@ -14099,9 +14099,9 @@ } }, "@uniswap/sdk-core": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-4.0.10.tgz", - "integrity": "sha512-RiobXJKXvVVb+wfNM09Ik8djOMOuRQGfyRP5pHgUjojicK/7nscZILjZ87DjVCGjXEoD8yTSIps0UAQuz6pJIw==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-4.1.2.tgz", + "integrity": "sha512-bk/oHiNCofy48ix84Q8aK/HHDmMVmk+SaoTq6U/93MmJ/nE7hbsckmY1c3MG2Vz1+jnGMCX9AmdBbnSF7VR5Ow==", "requires": { "@ethersproject/address": "^5.0.2", "big.js": "^5.2.2", diff --git a/package.json b/package.json index 31be863c9..c51f4abb8 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@uniswap/default-token-list": "^11.2.0", "@uniswap/permit2-sdk": "^1.2.0", "@uniswap/router-sdk": "^1.7.5", - "@uniswap/sdk-core": "^4.0.9", + "@uniswap/sdk-core": "^4.1.2", "@uniswap/swap-router-contracts": "^1.3.0", "@uniswap/token-lists": "^1.0.0-beta.31", "@uniswap/universal-router": "^1.6.0", diff --git a/src/providers/caching-token-provider.ts b/src/providers/caching-token-provider.ts index a9f59a40e..2803e03ca 100644 --- a/src/providers/caching-token-provider.ts +++ b/src/providers/caching-token-provider.ts @@ -13,6 +13,7 @@ import { CUSD_CELO, CUSD_CELO_ALFAJORES, DAI_ARBITRUM, + DAI_ARBITRUM_SEPOLIA, DAI_AVAX, DAI_BNB, DAI_CELO, @@ -20,13 +21,15 @@ import { DAI_MAINNET, DAI_MOONBEAM, DAI_OPTIMISM, - DAI_OPTIMISM_GOERLI, DAI_OPTIMISM_SEPOLIA, + DAI_OPTIMISM_GOERLI, + DAI_OPTIMISM_SEPOLIA, DAI_POLYGON_MUMBAI, ETH_BNB, ITokenProvider, TokenAccessor, USDC_ARBITRUM, USDC_ARBITRUM_GOERLI, + USDC_ARBITRUM_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -34,21 +37,24 @@ import { USDC_MAINNET, USDC_MOONBEAM, USDC_OPTIMISM, - USDC_OPTIMISM_GOERLI, USDC_OPTIMISM_SEPOLIA, + USDC_OPTIMISM_GOERLI, + USDC_OPTIMISM_SEPOLIA, USDC_POLYGON, USDC_SEPOLIA, USDT_ARBITRUM, USDT_BNB, USDT_MAINNET, USDT_OPTIMISM, - USDT_OPTIMISM_GOERLI, USDT_OPTIMISM_SEPOLIA, + USDT_OPTIMISM_GOERLI, + USDT_OPTIMISM_SEPOLIA, WBTC_ARBITRUM, WBTC_MAINNET, WBTC_MOONBEAM, WBTC_OPTIMISM, - WBTC_OPTIMISM_GOERLI, WBTC_OPTIMISM_SEPOLIA, + WBTC_OPTIMISM_GOERLI, + WBTC_OPTIMISM_SEPOLIA, WMATIC_POLYGON, - WMATIC_POLYGON_MUMBAI + WMATIC_POLYGON_MUMBAI, } from './token-provider'; // These tokens will added to the Token cache on initialization. @@ -102,6 +108,10 @@ export const CACHE_SEED_TOKENS: { [ChainId.ARBITRUM_GOERLI]: { USDC: USDC_ARBITRUM_GOERLI, }, + [ChainId.ARBITRUM_SEPOLIA]: { + USDC: USDC_ARBITRUM_SEPOLIA, + DAI: DAI_ARBITRUM_SEPOLIA, + }, [ChainId.POLYGON]: { WMATIC: WMATIC_POLYGON, USDC: USDC_POLYGON, diff --git a/src/providers/multicall-uniswap-provider.ts b/src/providers/multicall-uniswap-provider.ts index 12edec030..2f047ca80 100644 --- a/src/providers/multicall-uniswap-provider.ts +++ b/src/providers/multicall-uniswap-provider.ts @@ -4,8 +4,8 @@ import { ChainId } from '@uniswap/sdk-core'; import _ from 'lodash'; import stats from 'stats-lite'; -import { UniswapInterfaceMulticall } from '../types/v3/UniswapInterfaceMulticall'; import { UniswapInterfaceMulticall__factory } from '../types/v3/factories/UniswapInterfaceMulticall__factory'; +import { UniswapInterfaceMulticall } from '../types/v3/UniswapInterfaceMulticall'; import { UNISWAP_MULTICALL_ADDRESSES } from '../util/addresses'; import { log } from '../util/log'; diff --git a/src/providers/token-fee-fetcher.ts b/src/providers/token-fee-fetcher.ts index a3b20b6d2..0c9b1eba2 100644 --- a/src/providers/token-fee-fetcher.ts +++ b/src/providers/token-fee-fetcher.ts @@ -2,8 +2,8 @@ import { BigNumber } from '@ethersproject/bignumber'; import { BaseProvider } from '@ethersproject/providers'; import { ChainId } from '@uniswap/sdk-core'; -import { TokenFeeDetector } from '../types/other/TokenFeeDetector'; import { TokenFeeDetector__factory } from '../types/other/factories/TokenFeeDetector__factory'; +import { TokenFeeDetector } from '../types/other/TokenFeeDetector'; import { log, metric, diff --git a/src/providers/token-provider.ts b/src/providers/token-provider.ts index f8a8a70c6..53cf99a30 100644 --- a/src/providers/token-provider.ts +++ b/src/providers/token-provider.ts @@ -299,6 +299,14 @@ export const DAI_ARBITRUM_GOERLI = new Token( 'Dai Stablecoin' ); +export const DAI_ARBITRUM_SEPOLIA = new Token( + ChainId.ARBITRUM_SEPOLIA, + '0xc3826E277485c33F3D99C9e0CBbf8449513210EE', + 18, + 'DAI', + 'Dai Stablecoin' +); + // Bridged version of official Goerli USDC export const USDC_ARBITRUM_GOERLI = new Token( ChainId.ARBITRUM_GOERLI, @@ -308,6 +316,15 @@ export const USDC_ARBITRUM_GOERLI = new Token( 'USD//C' ); +// Bridged version of official Sepolia USDC +export const USDC_ARBITRUM_SEPOLIA = new Token( + ChainId.ARBITRUM_SEPOLIA, + '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', + 6, + 'USDC', + 'USD//C' +); + //polygon tokens export const WMATIC_POLYGON = new Token( ChainId.POLYGON, @@ -819,6 +836,8 @@ export const DAI_ON = (chainId: ChainId): Token => { return DAI_ARBITRUM; case ChainId.ARBITRUM_GOERLI: return DAI_ARBITRUM_GOERLI; + case ChainId.ARBITRUM_SEPOLIA: + return DAI_ARBITRUM_SEPOLIA; case ChainId.POLYGON: return DAI_POLYGON; case ChainId.POLYGON_MUMBAI: @@ -877,6 +896,8 @@ export const USDC_ON = (chainId: ChainId): Token => { return USDC_ARBITRUM; case ChainId.ARBITRUM_GOERLI: return USDC_ARBITRUM_GOERLI; + case ChainId.ARBITRUM_SEPOLIA: + return USDC_ARBITRUM_SEPOLIA; case ChainId.POLYGON: return USDC_POLYGON; case ChainId.POLYGON_MUMBAI: diff --git a/src/providers/v2/static-subgraph-provider.ts b/src/providers/v2/static-subgraph-provider.ts index 834e97dea..4f41c2ef7 100644 --- a/src/providers/v2/static-subgraph-provider.ts +++ b/src/providers/v2/static-subgraph-provider.ts @@ -76,6 +76,7 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ARB_ARBITRUM, ], [ChainId.ARBITRUM_GOERLI]: [], + [ChainId.ARBITRUM_SEPOLIA]: [], [ChainId.OPTIMISM_GOERLI]: [], [ChainId.OPTIMISM_SEPOLIA]: [], [ChainId.POLYGON]: [USDC_POLYGON, WETH_POLYGON, WMATIC_POLYGON], diff --git a/src/providers/v3/static-subgraph-provider.ts b/src/providers/v3/static-subgraph-provider.ts index 4de9afdcb..f2e735004 100644 --- a/src/providers/v3/static-subgraph-provider.ts +++ b/src/providers/v3/static-subgraph-provider.ts @@ -96,7 +96,7 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ], // todo: once subgraph is created [ChainId.OPTIMISM_SEPOLIA]: [ - // WRAPPED_NATIVE_CURRENCY[ChainId.OPTIMISM_SEPOLIA]!, + // WRAPPED_NATIVE_CURRENCY[ChainId.OPTIMISM_SEPOLIA]!, ], [ChainId.ARBITRUM_ONE]: [ WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_ONE]!, @@ -110,6 +110,9 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_GOERLI]!, USDC_ARBITRUM_GOERLI, ], + [ChainId.ARBITRUM_SEPOLIA]: [ + // WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_SEPOLIA]!, + ], [ChainId.OPTIMISM_GOERLI]: [ WRAPPED_NATIVE_CURRENCY[ChainId.OPTIMISM_GOERLI]!, USDC_OPTIMISM_GOERLI, diff --git a/src/providers/v3/subgraph-provider.ts b/src/providers/v3/subgraph-provider.ts index 908d622ad..1eaf9d8d5 100644 --- a/src/providers/v3/subgraph-provider.ts +++ b/src/providers/v3/subgraph-provider.ts @@ -53,6 +53,8 @@ const SUBGRAPH_URL_BY_CHAIN: { [chainId in ChainId]?: string } = { [ChainId.OPTIMISM_SEPOLIA]: '', [ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-minimal', + // todo: add once subgraph is live + [ChainId.ARBITRUM_SEPOLIA]: '', [ChainId.POLYGON]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon', [ChainId.CELO]: diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index 16693e337..4eecddaa8 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -583,6 +583,7 @@ export class AlphaRouter break; case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: + case ChainId.ARBITRUM_SEPOLIA: this.onChainQuoteProvider = new OnChainQuoteProvider( chainId, provider, diff --git a/src/routers/alpha-router/config.ts b/src/routers/alpha-router/config.ts index 4311443be..b9bdfff40 100644 --- a/src/routers/alpha-router/config.ts +++ b/src/routers/alpha-router/config.ts @@ -40,6 +40,7 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = ( // have to adjust the routing config so we explore fewer routes. case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: + case ChainId.ARBITRUM_SEPOLIA: case ChainId.CELO: case ChainId.CELO_ALFAJORES: return { diff --git a/src/routers/alpha-router/functions/best-swap-route.ts b/src/routers/alpha-router/functions/best-swap-route.ts index 73498decd..a9dd11c0d 100644 --- a/src/routers/alpha-router/functions/best-swap-route.ts +++ b/src/routers/alpha-router/functions/best-swap-route.ts @@ -522,9 +522,9 @@ export async function getBestSwapRouteBy( gasCostsL1ToL2.gasCostL1USD = v2GasCostL1.gasCostL1USD; } gasCostsL1ToL2.gasCostL1QuoteToken = - gasCostsL1ToL2.gasCostL1QuoteToken.add( - v2GasCostL1.gasCostL1QuoteToken - ); + gasCostsL1ToL2.gasCostL1QuoteToken.add( + v2GasCostL1.gasCostL1QuoteToken + ); } } const v3Routes = bestSwap.filter( diff --git a/src/routers/alpha-router/functions/get-candidate-pools.ts b/src/routers/alpha-router/functions/get-candidate-pools.ts index 77e3ff92c..4572a87eb 100644 --- a/src/routers/alpha-router/functions/get-candidate-pools.ts +++ b/src/routers/alpha-router/functions/get-candidate-pools.ts @@ -6,8 +6,12 @@ import _ from 'lodash'; import { DAI_OPTIMISM_SEPOLIA, ITokenListProvider, - IV2SubgraphProvider, USDC_OPTIMISM_SEPOLIA, USDT_OPTIMISM_SEPOLIA, - V2SubgraphPool, WBTC_OPTIMISM_SEPOLIA + IV2SubgraphProvider, + USDC_ARBITRUM_SEPOLIA, + USDC_OPTIMISM_SEPOLIA, + USDT_OPTIMISM_SEPOLIA, + V2SubgraphPool, + WBTC_OPTIMISM_SEPOLIA, } from '../../../providers'; import { CELO, @@ -162,6 +166,7 @@ const baseTokensByChain: { [chainId in ChainId]?: Token[] } = { USDT_ARBITRUM, ], [ChainId.ARBITRUM_GOERLI]: [USDC_ARBITRUM_GOERLI], + [ChainId.ARBITRUM_SEPOLIA]: [USDC_ARBITRUM_SEPOLIA], [ChainId.POLYGON]: [USDC_POLYGON, WMATIC_POLYGON], [ChainId.POLYGON_MUMBAI]: [DAI_POLYGON_MUMBAI, WMATIC_POLYGON_MUMBAI], [ChainId.CELO]: [CUSD_CELO, CEUR_CELO, CELO], diff --git a/src/routers/alpha-router/gas-models/gas-model.ts b/src/routers/alpha-router/gas-models/gas-model.ts index 851bddfbe..0362d36cc 100644 --- a/src/routers/alpha-router/gas-models/gas-model.ts +++ b/src/routers/alpha-router/gas-models/gas-model.ts @@ -23,6 +23,7 @@ import { DAI_SEPOLIA, USDC_ARBITRUM, USDC_ARBITRUM_GOERLI, + USDC_ARBITRUM_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -51,7 +52,7 @@ import { USDT_OPTIMISM, USDT_OPTIMISM_GOERLI, USDT_OPTIMISM_SEPOLIA, - WBTC_GOERLI + WBTC_GOERLI, } from '../../../providers/token-provider'; import { IV2PoolProvider } from '../../../providers/v2/pool-provider'; import { @@ -96,6 +97,7 @@ export const usdGasTokensByChain: { [chainId in ChainId]?: Token[] } = { USDT_OPTIMISM_SEPOLIA, ], [ChainId.ARBITRUM_GOERLI]: [USDC_ARBITRUM_GOERLI], + [ChainId.ARBITRUM_SEPOLIA]: [USDC_ARBITRUM_SEPOLIA], [ChainId.GOERLI]: [DAI_GOERLI, USDC_GOERLI, USDT_GOERLI, WBTC_GOERLI], [ChainId.SEPOLIA]: [USDC_SEPOLIA, DAI_SEPOLIA], [ChainId.POLYGON]: [USDC_POLYGON, USDC_NATIVE_POLYGON], diff --git a/src/routers/alpha-router/gas-models/v3/gas-costs.ts b/src/routers/alpha-router/gas-models/v3/gas-costs.ts index d4a23d7ae..c70aaa1db 100644 --- a/src/routers/alpha-router/gas-models/v3/gas-costs.ts +++ b/src/routers/alpha-router/gas-models/v3/gas-costs.ts @@ -23,6 +23,7 @@ export const BASE_SWAP_COST = (id: ChainId): BigNumber => { return BigNumber.from(2000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: + case ChainId.ARBITRUM_SEPOLIA: return BigNumber.from(5000); case ChainId.POLYGON: case ChainId.POLYGON_MUMBAI: @@ -55,6 +56,7 @@ export const COST_PER_INIT_TICK = (id: ChainId): BigNumber => { return BigNumber.from(31000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: + case ChainId.ARBITRUM_SEPOLIA: return BigNumber.from(31000); case ChainId.POLYGON: case ChainId.POLYGON_MUMBAI: @@ -84,6 +86,7 @@ export const COST_PER_HOP = (id: ChainId): BigNumber => { return BigNumber.from(80000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: + case ChainId.ARBITRUM_SEPOLIA: return BigNumber.from(80000); case ChainId.POLYGON: case ChainId.POLYGON_MUMBAI: diff --git a/src/routers/legacy-router/bases.ts b/src/routers/legacy-router/bases.ts index 269fdadde..636cbcc50 100644 --- a/src/routers/legacy-router/bases.ts +++ b/src/routers/legacy-router/bases.ts @@ -48,6 +48,9 @@ export const BASES_TO_CHECK_TRADES_AGAINST = ( [ChainId.ARBITRUM_GOERLI]: [ WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_GOERLI]!, ], + [ChainId.ARBITRUM_SEPOLIA]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_SEPOLIA]!, + ], [ChainId.POLYGON]: [WMATIC_POLYGON], [ChainId.POLYGON_MUMBAI]: [WMATIC_POLYGON_MUMBAI], [ChainId.CELO]: [WRAPPED_NATIVE_CURRENCY[ChainId.CELO]], diff --git a/src/routers/router.ts b/src/routers/router.ts index 0efeae4b4..7754f11f6 100644 --- a/src/routers/router.ts +++ b/src/routers/router.ts @@ -15,9 +15,9 @@ import { import { SwapOptions as UniversalRouterSwapOptions } from '@uniswap/universal-router-sdk'; import { Route as V2RouteRaw } from '@uniswap/v2-sdk'; import { + MethodParameters as SDKMethodParameters, Pool, Position, - MethodParameters as SDKMethodParameters, Route as V3RouteRaw, } from '@uniswap/v3-sdk'; diff --git a/src/util/addresses.ts b/src/util/addresses.ts index e7d779326..1c13f4cc8 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -1,4 +1,4 @@ -import { CHAIN_TO_ADDRESSES_MAP, ChainId, Token } from '@uniswap/sdk-core'; +import { ChainId, CHAIN_TO_ADDRESSES_MAP, Token } from '@uniswap/sdk-core'; import { FACTORY_ADDRESS } from '@uniswap/v3-sdk'; import { NETWORKS_WITH_SAME_UNISWAP_ADDRESSES } from './chains'; @@ -25,6 +25,8 @@ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = { CHAIN_TO_ADDRESSES_MAP[ChainId.SEPOLIA].v3CoreFactoryAddress, [ChainId.ARBITRUM_GOERLI]: CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_GOERLI].v3CoreFactoryAddress, + [ChainId.ARBITRUM_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_SEPOLIA].v3CoreFactoryAddress, [ChainId.BNB]: CHAIN_TO_ADDRESSES_MAP[ChainId.BNB].v3CoreFactoryAddress, [ChainId.AVALANCHE]: CHAIN_TO_ADDRESSES_MAP[ChainId.AVALANCHE].v3CoreFactoryAddress, @@ -46,6 +48,8 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { [ChainId.SEPOLIA]: CHAIN_TO_ADDRESSES_MAP[ChainId.SEPOLIA].quoterAddress, [ChainId.ARBITRUM_GOERLI]: CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_GOERLI].quoterAddress, + [ChainId.ARBITRUM_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_SEPOLIA].quoterAddress, [ChainId.BNB]: CHAIN_TO_ADDRESSES_MAP[ChainId.BNB].quoterAddress, [ChainId.AVALANCHE]: CHAIN_TO_ADDRESSES_MAP[ChainId.AVALANCHE].quoterAddress, [ChainId.BASE_GOERLI]: @@ -73,6 +77,8 @@ export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = { [ChainId.SEPOLIA]: CHAIN_TO_ADDRESSES_MAP[ChainId.SEPOLIA].multicallAddress, [ChainId.ARBITRUM_GOERLI]: CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_GOERLI].multicallAddress, + [ChainId.ARBITRUM_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.ARBITRUM_SEPOLIA].multicallAddress, [ChainId.BNB]: CHAIN_TO_ADDRESSES_MAP[ChainId.BNB].multicallAddress, [ChainId.AVALANCHE]: CHAIN_TO_ADDRESSES_MAP[ChainId.AVALANCHE].multicallAddress, @@ -185,6 +191,13 @@ export const WETH9: { 'WETH', 'Wrapped Ether' ), + [ChainId.ARBITRUM_SEPOLIA]: new Token( + ChainId.ARBITRUM_SEPOLIA, + '0xc556bAe1e86B2aE9c22eA5E036b07E55E7596074', + 18, + 'WETH', + 'Wrapped Ether' + ), [ChainId.BASE_GOERLI]: new Token( ChainId.BASE_GOERLI, '0x4200000000000000000000000000000000000006', diff --git a/src/util/chains.ts b/src/util/chains.ts index 5104a4133..cac908199 100644 --- a/src/util/chains.ts +++ b/src/util/chains.ts @@ -14,6 +14,7 @@ export const SUPPORTED_CHAINS: ChainId[] = [ ChainId.OPTIMISM_SEPOLIA, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI, + ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON, ChainId.POLYGON_MUMBAI, ChainId.GOERLI, @@ -44,6 +45,7 @@ export const HAS_L1_FEE = [ ChainId.OPTIMISM_SEPOLIA, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI, + ChainId.ARBITRUM_SEPOLIA, ChainId.BASE, ChainId.BASE_GOERLI, ]; @@ -77,6 +79,8 @@ export const ID_TO_CHAIN_ID = (id: number): ChainId => { return ChainId.ARBITRUM_ONE; case 421613: return ChainId.ARBITRUM_GOERLI; + case 421614: + return ChainId.ARBITRUM_SEPOLIA; case 137: return ChainId.POLYGON; case 80001: @@ -106,9 +110,10 @@ export enum ChainName { SEPOLIA = 'sepolia', OPTIMISM = 'optimism-mainnet', OPTIMISM_GOERLI = 'optimism-goerli', - OPTIMISM_SEPOLIA = 'op-sepolia', + OPTIMISM_SEPOLIA = 'optimism-sepolia', ARBITRUM_ONE = 'arbitrum-mainnet', ARBITRUM_GOERLI = 'arbitrum-goerli', + ARBITRUM_SEPOLIA = 'arbitrum-sepolia', POLYGON = 'polygon-mainnet', POLYGON_MUMBAI = 'polygon-mumbai', CELO = 'celo-mainnet', @@ -173,6 +178,11 @@ export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = { 'ETHER', '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', ], + [ChainId.ARBITRUM_SEPOLIA]: [ + 'ETH', + 'ETHER', + '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + ], [ChainId.POLYGON]: ['MATIC', '0x0000000000000000000000000000000000001010'], [ChainId.POLYGON_MUMBAI]: [ 'MATIC', @@ -204,6 +214,7 @@ export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = { [ChainId.OPTIMISM_SEPOLIA]: NativeCurrencyName.ETHER, [ChainId.ARBITRUM_ONE]: NativeCurrencyName.ETHER, [ChainId.ARBITRUM_GOERLI]: NativeCurrencyName.ETHER, + [ChainId.ARBITRUM_SEPOLIA]: NativeCurrencyName.ETHER, [ChainId.POLYGON]: NativeCurrencyName.MATIC, [ChainId.POLYGON_MUMBAI]: NativeCurrencyName.MATIC, [ChainId.CELO]: NativeCurrencyName.CELO, @@ -235,6 +246,8 @@ export const ID_TO_NETWORK_NAME = (id: number): ChainName => { return ChainName.ARBITRUM_ONE; case 421613: return ChainName.ARBITRUM_GOERLI; + case 421614: + return ChainName.ARBITRUM_SEPOLIA; case 137: return ChainName.POLYGON; case 80001: @@ -280,6 +293,8 @@ export const ID_TO_PROVIDER = (id: ChainId): string => { return process.env.JSON_RPC_PROVIDER_ARBITRUM_ONE!; case ChainId.ARBITRUM_GOERLI: return process.env.JSON_RPC_PROVIDER_ARBITRUM_GOERLI!; + case ChainId.ARBITRUM_SEPOLIA: + return process.env.JSON_RPC_PROVIDER_ARBITRUM_SEPOLIA!; case ChainId.POLYGON: return process.env.JSON_RPC_PROVIDER_POLYGON!; case ChainId.POLYGON_MUMBAI: @@ -363,6 +378,13 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId in ChainId]: Token } = { 'WETH', 'Wrapped Ether' ), + [ChainId.ARBITRUM_SEPOLIA]: new Token( + ChainId.ARBITRUM_SEPOLIA, + '0xc556bAe1e86B2aE9c22eA5E036b07E55E7596074', + 18, + 'WETH', + 'Wrapped Ether' + ), [ChainId.POLYGON]: new Token( ChainId.POLYGON, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', diff --git a/src/util/gas-factory-helpers.ts b/src/util/gas-factory-helpers.ts index 4a9a430b1..d7da98a24 100644 --- a/src/util/gas-factory-helpers.ts +++ b/src/util/gas-factory-helpers.ts @@ -25,13 +25,13 @@ import { SwapType, usdGasTokensByChain, V2RouteWithValidQuote, - V3RouteWithValidQuote + V3RouteWithValidQuote, } from '../routers'; import { CurrencyAmount, log, WRAPPED_NATIVE_CURRENCY } from '../util'; +import { Pair } from '@uniswap/v2-sdk'; import { opStackChains } from './l2FeeChains'; import { buildSwapMethodParameters, buildTrade } from './methodParameters'; -import { Pair } from '@uniswap/v2-sdk'; export async function getV2NativePool( token: Token, diff --git a/src/util/methodParameters.ts b/src/util/methodParameters.ts index 4f02125c0..603fd356d 100644 --- a/src/util/methodParameters.ts +++ b/src/util/methodParameters.ts @@ -6,8 +6,8 @@ import { } from '@uniswap/router-sdk'; import { ChainId, Currency, TradeType } from '@uniswap/sdk-core'; import { - UNIVERSAL_ROUTER_ADDRESS, SwapRouter as UniversalRouter, + UNIVERSAL_ROUTER_ADDRESS, } from '@uniswap/universal-router-sdk'; import { Route as V2RouteRaw } from '@uniswap/v2-sdk'; import { Route as V3RouteRaw } from '@uniswap/v3-sdk'; @@ -18,9 +18,9 @@ import { MethodParameters, MixedRouteWithValidQuote, RouteWithValidQuote, - SWAP_ROUTER_02_ADDRESSES, SwapOptions, SwapType, + SWAP_ROUTER_02_ADDRESSES, V2RouteWithValidQuote, V3RouteWithValidQuote, } from '..'; diff --git a/test/integ/routers/alpha-router/alpha-router.integration.test.ts b/test/integ/routers/alpha-router/alpha-router.integration.test.ts index afc171edc..4414f348d 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -124,6 +124,7 @@ const GAS_ESTIMATE_DEVIATION_PERCENT: { [chainId in ChainId]: number } = { [ChainId.OPTIMISM_SEPOLIA]: 30, [ChainId.ARBITRUM_ONE]: 53, [ChainId.ARBITRUM_GOERLI]: 50, + [ChainId.ARBITRUM_SEPOLIA]: 50, [ChainId.POLYGON]: 38, [ChainId.POLYGON_MUMBAI]: 30, [ChainId.CELO]: 30, @@ -3305,6 +3306,7 @@ describe('quote for other networks', () => { [ChainId.ARBITRUM_ONE]: () => USDC_ON(ChainId.ARBITRUM_ONE), [ChainId.ARBITRUM_ONE]: () => USDC_NATIVE_ARBITRUM, [ChainId.ARBITRUM_GOERLI]: () => USDC_ON(ChainId.ARBITRUM_GOERLI), + [ChainId.ARBITRUM_SEPOLIA]: () => USDC_ON(ChainId.ARBITRUM_SEPOLIA), [ChainId.POLYGON]: () => USDC_ON(ChainId.POLYGON), [ChainId.POLYGON]: () => USDC_NATIVE_POLYGON, [ChainId.POLYGON_MUMBAI]: () => USDC_ON(ChainId.POLYGON_MUMBAI), @@ -3328,6 +3330,7 @@ describe('quote for other networks', () => { [ChainId.OPTIMISM_SEPOLIA]: () => USDC_ON(ChainId.OPTIMISM_SEPOLIA), [ChainId.ARBITRUM_ONE]: () => DAI_ON(ChainId.ARBITRUM_ONE), [ChainId.ARBITRUM_GOERLI]: () => DAI_ON(ChainId.ARBITRUM_GOERLI), + [ChainId.ARBITRUM_SEPOLIA]: () => DAI_ON(ChainId.ARBITRUM_SEPOLIA), [ChainId.POLYGON]: () => DAI_ON(ChainId.POLYGON), [ChainId.POLYGON_MUMBAI]: () => DAI_ON(ChainId.POLYGON_MUMBAI), [ChainId.CELO]: () => CEUR_CELO, @@ -3348,6 +3351,7 @@ describe('quote for other networks', () => { c != ChainId.OPTIMISM_SEPOLIA && c != ChainId.POLYGON_MUMBAI && c != ChainId.ARBITRUM_GOERLI && + c != ChainId.ARBITRUM_SEPOLIA && // Tests are failing https://github.com/Uniswap/smart-order-router/issues/104 c != ChainId.CELO_ALFAJORES && c != ChainId.SEPOLIA