Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

feat: support ZkSync #428

Merged
merged 2 commits into from
Jun 11, 2024
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
8 changes: 7 additions & 1 deletion lib/config/ChainConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export abstract class ChainConfigManager {
routingTypes: {
[RoutingType.CLASSIC]: {},
[RoutingType.DUTCH_V2]: {
deadlineBufferSecs: 60
deadlineBufferSecs: 60,
},
},
alarmEnabled: true,
Expand Down Expand Up @@ -182,6 +182,12 @@ export abstract class ChainConfigManager {
routingTypes: {},
alarmEnabled: false,
},
[ChainId.ZKSYNC]: {
routingTypes: {
[RoutingType.CLASSIC]: {},
},
alarmEnabled: false,
},
};

private static _performedDependencyCheck = false;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions test/integ/quote-classic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 } = {
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion test/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import {
USDC_POLYGON,
USDC_POLYGON_MUMBAI,
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';
Expand Down Expand Up @@ -201,6 +202,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`);
}
Expand Down
81 changes: 49 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down
Loading