From dcebcb708f120d1bcd89e4af6df97eef59712009 Mon Sep 17 00:00:00 2001 From: Siyu Jiang <91580504+jsy1218@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:48:41 -0700 Subject: [PATCH 1/2] feat: support zksync --- lib/config/ChainConfigManager.ts | 4 ++ package.json | 8 ++-- test/integ/quote-classic.test.ts | 7 ++- test/utils/tokens.ts | 6 ++- yarn.lock | 81 +++++++++++++++++++------------- 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/lib/config/ChainConfigManager.ts b/lib/config/ChainConfigManager.ts index 55e34e55..61436499 100644 --- a/lib/config/ChainConfigManager.ts +++ b/lib/config/ChainConfigManager.ts @@ -182,6 +182,10 @@ export abstract class ChainConfigManager { routingTypes: {}, alarmEnabled: false, }, + [ChainId.ZKSYNC]: { + routingTypes: {}, + alarmEnabled: false, + } }; private static _performedDependencyCheck = false; diff --git a/package.json b/package.json index ddd3da0a..34dcbb6e 100644 --- a/package.json +++ b/package.json @@ -68,12 +68,12 @@ "@swc/jest": "^0.2.29", "@typechain/ethers-v5": "^7.0.1", "@uniswap/default-token-list": "^11.7.0", - "@uniswap/permit2-sdk": "^1.2.0", + "@uniswap/permit2-sdk": "^1.3.0", "@uniswap/router-sdk": "^1.9.2", - "@uniswap/sdk-core": "^4.2.0", - "@uniswap/smart-order-router": "^3.33.1", + "@uniswap/sdk-core": "^5.3.0", + "@uniswap/smart-order-router": "^3.35.0", "@uniswap/uniswapx-sdk": "2.1.0-beta.4", - "@uniswap/universal-router-sdk": "^2.1.0", + "@uniswap/universal-router-sdk": "^2.2.0", "aws-cdk-lib": "2.85.0", "aws-embedded-metrics": "^4.1.0", "axios": "^1.2.1", diff --git a/test/integ/quote-classic.test.ts b/test/integ/quote-classic.test.ts index d89aa98e..bad89265 100644 --- a/test/integ/quote-classic.test.ts +++ b/test/integ/quote-classic.test.ts @@ -8,7 +8,7 @@ import { ID_TO_NETWORK_NAME, NATIVE_CURRENCY, USDB_BLAST, - USDC_ZORA, + USDC_ZORA } from '@uniswap/smart-order-router'; import { fail } from 'assert'; import { AxiosResponse } from 'axios'; @@ -456,6 +456,7 @@ describe('quote', function () { [ChainId.ZORA_SEPOLIA]: null, [ChainId.ROOTSTOCK]: null, [ChainId.BLAST]: USDB_BLAST, + [ChainId.ZKSYNC]: USDC_ON(ChainId.ZKSYNC), }; const TEST_ERC20_2: { [chainId in ChainId]: Token | null } = { @@ -482,6 +483,7 @@ describe('quote', function () { [ChainId.ZORA_SEPOLIA]: null, [ChainId.ROOTSTOCK]: null, [ChainId.BLAST]: WNATIVE_ON(ChainId.BLAST), + [ChainId.ZKSYNC]: WNATIVE_ON(ChainId.ZKSYNC), }; // TODO: Find valid pools/tokens on optimistic kovan and polygon mumbai. We skip those tests for now. @@ -584,9 +586,10 @@ describe('quote', function () { }); const native = NATIVE_CURRENCY[chain]; it(`${native} -> erc20`, async () => { - if (chain === ChainId.BLAST || chain === ChainId.ZORA) { + if (chain === ChainId.BLAST || chain === ChainId.ZORA || chain === ChainId.ZKSYNC) { // Blast doesn't have DAI or USDC yet // Zora doesn't have DAI + // Zksync doesn't have liquid USDC/DAI pool yet // This test will become ETH -> WETH quote, and it will throw INVARIANT ADDRESS from sdk-core. // Reasons explained in https://github.com/Uniswap/unified-routing-api/pull/425#discussion_r1611055408. diff --git a/test/utils/tokens.ts b/test/utils/tokens.ts index efcc6010..8cf1332f 100644 --- a/test/utils/tokens.ts +++ b/test/utils/tokens.ts @@ -24,13 +24,13 @@ import { USDC_OPTIMISM_GOERLI, USDC_POLYGON, USDC_POLYGON_MUMBAI, - USDC_SEPOLIA, + USDC_SEPOLIA, USDCE_ZKSYNC, USDT_ARBITRUM, USDT_BNB, USDT_GOERLI, USDT_MAINNET, USDT_OPTIMISM, - WRAPPED_NATIVE_CURRENCY, + WRAPPED_NATIVE_CURRENCY } from '@uniswap/smart-order-router'; import { BigNumber, ethers } from 'ethers'; import NodeCache from 'node-cache'; @@ -201,6 +201,8 @@ export const USDC_ON = (chainId: ChainId): Token => { return USDC_BASE_GOERLI; case ChainId.BASE: return USDC_BASE; + case ChainId.ZKSYNC: + return USDCE_ZKSYNC; default: throw new Error(`Chain id: ${chainId} not supported`); } diff --git a/yarn.lock b/yarn.lock index 1f398723..d60b9bc9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2062,14 +2062,6 @@ resolved "https://registry.npmjs.org/@uniswap/lib/-/lib-4.0.1-alpha.tgz" integrity sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA== -"@uniswap/permit2-sdk@^1.2.0": - version "1.2.0" - resolved "https://registry.npmjs.org/@uniswap/permit2-sdk/-/permit2-sdk-1.2.0.tgz" - integrity sha512-Ietv3FxN7+RCXcPSED/i/8b0a2GUZrMdyX05k3FsSztvYKyPFAMS/hBXojF0NZqYB1bHecqYc7Ej+7tV/rdYXg== - dependencies: - ethers "^5.3.1" - tiny-invariant "^1.3.1" - "@uniswap/permit2-sdk@^1.2.1": version "1.2.1" resolved "https://registry.npmjs.org/@uniswap/permit2-sdk/-/permit2-sdk-1.2.1.tgz#7f562d96a26de0538508ba9ea2b2f02150572bf2" @@ -2078,6 +2070,14 @@ ethers "^5.7.0" tiny-invariant "^1.1.0" +"@uniswap/permit2-sdk@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@uniswap/permit2-sdk/-/permit2-sdk-1.3.0.tgz#b54124e570f0adbaca9d39b2de3054fd7d3798a1" + integrity sha512-LstYQWP47dwpQrgqBJ+ysFstne9LgI5FGiKHc2ewjj91MTY8Mq1reocu6U/VDncdR5ef30TUOcZ7gPExRY8r6Q== + dependencies: + ethers "^5.7.0" + tiny-invariant "^1.1.0" + "@uniswap/router-sdk@^1.9.2": version "1.9.2" resolved "https://registry.yarnpkg.com/@uniswap/router-sdk/-/router-sdk-1.9.2.tgz#cc2411f0849467c2bd71ce34cdca9db2a584367d" @@ -2089,10 +2089,10 @@ "@uniswap/v2-sdk" "^4.3.2" "@uniswap/v3-sdk" "^3.11.2" -"@uniswap/sdk-core@^4.2.0": - version "4.2.1" - resolved "https://registry.yarnpkg.com/@uniswap/sdk-core/-/sdk-core-4.2.1.tgz#7b8c6fee48446bb67a4e6f2e9cb94c862034a6c3" - integrity sha512-hr7vwYrXScg+V8/rRc2UL/Ixc/p0P7yqe4D/OxzUdMRYr8RZd+8z5Iu9+WembjZT/DCdbTjde6lsph4Og0n1BQ== +"@uniswap/sdk-core@^5.0.0": + version "5.0.0" + resolved "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-5.0.0.tgz#7accd8c7372b14811777cbd1d92133d4de57c683" + integrity sha512-m5KmkqvvEz5rurRHdG3zGJappi1Crxet3B2dpgDFgq5MKoKd6qCbeChRkoQjTTJpY1MLGCsXj8ZtZ0/arisvLQ== dependencies: "@ethersproject/address" "^5.0.2" big.js "^5.2.2" @@ -2101,35 +2101,38 @@ tiny-invariant "^1.1.0" toformat "^2.0.0" -"@uniswap/sdk-core@^5.0.0": - version "5.0.0" - resolved "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-5.0.0.tgz#7accd8c7372b14811777cbd1d92133d4de57c683" - integrity sha512-m5KmkqvvEz5rurRHdG3zGJappi1Crxet3B2dpgDFgq5MKoKd6qCbeChRkoQjTTJpY1MLGCsXj8ZtZ0/arisvLQ== +"@uniswap/sdk-core@^5.3.0": + version "5.3.0" + resolved "https://registry.yarnpkg.com/@uniswap/sdk-core/-/sdk-core-5.3.0.tgz#4af6d7d794ce65c5303b2d4c58c87a917bbeb986" + integrity sha512-wbMzSY3wbByOkoirZXyeomof4a7goueT4bOa4YqoXDWqIftqrT70UuCgjk98nIBu3UqPxRNMptXusppxZVvwWA== dependencies: "@ethersproject/address" "^5.0.2" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "5.7.0" + "@ethersproject/strings" "5.7.0" big.js "^5.2.2" decimal.js-light "^2.5.0" jsbi "^3.1.4" tiny-invariant "^1.1.0" toformat "^2.0.0" -"@uniswap/smart-order-router@^3.33.1": - version "3.33.1" - resolved "https://registry.yarnpkg.com/@uniswap/smart-order-router/-/smart-order-router-3.33.1.tgz#026143b88e7e9c77904f0179cc456801d431e8dc" - integrity sha512-w6LaNgsMdsz3M+DX98M3PzosHg1nn2mIH/1uXVydNhYG9XyIRLS71x/75mx/jfp1MCoqw/OernLE2cMRq5YQUg== +"@uniswap/smart-order-router@^3.35.0": + version "3.35.0" + resolved "https://registry.yarnpkg.com/@uniswap/smart-order-router/-/smart-order-router-3.35.0.tgz#de79f23f05b039be3d1d6d52b8557f646554efc9" + integrity sha512-RNieO2HboHwPGkP02K0XLLwPKjnWprEL27zj07HqHaLHA2X9rGraypu7z4Sd8xf5L2NAehgixTMJAOdo1mWHUw== dependencies: "@eth-optimism/sdk" "^3.2.2" "@types/brotli" "^1.3.4" "@uniswap/default-token-list" "^11.13.0" - "@uniswap/permit2-sdk" "^1.2.0" + "@uniswap/permit2-sdk" "^1.3.0" "@uniswap/router-sdk" "^1.9.2" - "@uniswap/sdk-core" "^5.0.0" + "@uniswap/sdk-core" "^5.3.0" "@uniswap/swap-router-contracts" "^1.3.1" "@uniswap/token-lists" "^1.0.0-beta.31" "@uniswap/universal-router" "^1.6.0" - "@uniswap/universal-router-sdk" "^2.1.0" + "@uniswap/universal-router-sdk" "^2.2.0" "@uniswap/v2-sdk" "^4.3.2" - "@uniswap/v3-sdk" "^3.11.2" + "@uniswap/v3-sdk" "^3.13.0" async-retry "^1.3.1" await-timeout "^1.1.1" axios "^0.21.1" @@ -2172,17 +2175,17 @@ "@uniswap/sdk-core" "^5.0.0" ethers "^5.7.0" -"@uniswap/universal-router-sdk@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@uniswap/universal-router-sdk/-/universal-router-sdk-2.1.0.tgz#7b4e48af92a6162973d3503bcd6ccf4b52dcba4a" - integrity sha512-nLIIr0bZ6AfvwuYC97rM10tyEfqDIdujtG+Ahwqhv1EMWayh6abbqPUwvUQvk6Px4LOyuKtlciryW/MJMusn4w== +"@uniswap/universal-router-sdk@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@uniswap/universal-router-sdk/-/universal-router-sdk-2.2.0.tgz#fa3d99ae707526d2a250f3b23aa5408311f1e4a6" + integrity sha512-8ys8eVLLMBMuTya9d4LjqBQrlunkdTm9HNgcE6IXG/Ro3Lekxe1e0mak0MaIQEFfrE44JvaJu6M/BenxBYWqaw== dependencies: - "@uniswap/permit2-sdk" "^1.2.1" + "@uniswap/permit2-sdk" "^1.3.0" "@uniswap/router-sdk" "^1.9.2" - "@uniswap/sdk-core" "^5.0.0" + "@uniswap/sdk-core" "^5.3.0" "@uniswap/universal-router" "1.6.0" "@uniswap/v2-sdk" "^4.3.2" - "@uniswap/v3-sdk" "^3.11.2" + "@uniswap/v3-sdk" "^3.13.0" bignumber.js "^9.0.2" ethers "^5.7.0" @@ -2257,6 +2260,20 @@ tiny-invariant "^1.1.0" tiny-warning "^1.0.3" +"@uniswap/v3-sdk@^3.13.0": + version "3.13.0" + resolved "https://registry.yarnpkg.com/@uniswap/v3-sdk/-/v3-sdk-3.13.0.tgz#e9f1bc8711b734e36fc58ba4017089d7b79c437e" + integrity sha512-Jz8aEU7RrDK4LfFNLClXFr2hkBE08QANLEBTofmu+ueCCKoNoRd/OTR4q04HhIeMyXtzsSOzi32a5yS7OY9glg== + dependencies: + "@ethersproject/abi" "^5.5.0" + "@ethersproject/solidity" "^5.0.9" + "@uniswap/sdk-core" "^5.3.0" + "@uniswap/swap-router-contracts" "^1.3.0" + "@uniswap/v3-periphery" "^1.1.1" + "@uniswap/v3-staker" "1.0.0" + tiny-invariant "^1.1.0" + tiny-warning "^1.0.3" + "@uniswap/v3-staker@1.0.0": version "1.0.0" resolved "https://registry.npmjs.org/@uniswap/v3-staker/-/v3-staker-1.0.0.tgz" @@ -3858,7 +3875,7 @@ ethereumjs-util@^6.0.0, ethereumjs-util@^6.2.1: ethjs-util "0.1.6" rlp "^2.2.3" -ethers@^5.3.1, ethers@^5.7.0, ethers@^5.7.2: +ethers@^5.7.0, ethers@^5.7.2: version "5.7.2" resolved "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz" integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== From f04a7235c311dc6388bed736d0a12511302ff102 Mon Sep 17 00:00:00 2001 From: Siyu Jiang <91580504+jsy1218@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:23:37 -0700 Subject: [PATCH 2/2] feat: support zksync --- lib/config/ChainConfigManager.ts | 8 +++++--- test/utils/tokens.ts | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/config/ChainConfigManager.ts b/lib/config/ChainConfigManager.ts index 61436499..8ed13559 100644 --- a/lib/config/ChainConfigManager.ts +++ b/lib/config/ChainConfigManager.ts @@ -77,7 +77,7 @@ export abstract class ChainConfigManager { routingTypes: { [RoutingType.CLASSIC]: {}, [RoutingType.DUTCH_V2]: { - deadlineBufferSecs: 60 + deadlineBufferSecs: 60, }, }, alarmEnabled: true, @@ -183,9 +183,11 @@ export abstract class ChainConfigManager { alarmEnabled: false, }, [ChainId.ZKSYNC]: { - routingTypes: {}, + routingTypes: { + [RoutingType.CLASSIC]: {}, + }, alarmEnabled: false, - } + }, }; private static _performedDependencyCheck = false; diff --git a/test/utils/tokens.ts b/test/utils/tokens.ts index 8cf1332f..4ea4c9e0 100644 --- a/test/utils/tokens.ts +++ b/test/utils/tokens.ts @@ -24,7 +24,8 @@ import { USDC_OPTIMISM_GOERLI, USDC_POLYGON, USDC_POLYGON_MUMBAI, - USDC_SEPOLIA, USDCE_ZKSYNC, + USDC_SEPOLIA, + USDCE_ZKSYNC, USDT_ARBITRUM, USDT_BNB, USDT_GOERLI,