From 9db9208f9b0fdaf0f8a423278f243066c84dd13c Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Thu, 21 Nov 2024 12:42:44 -0800 Subject: [PATCH 1/5] feat(sor): support routing on unichain mainnet --- .github/workflows/tests.yml | 43 ++++- README.md | 6 + package-lock.json | 170 +++++++----------- package.json | 12 +- src/providers/caching-subgraph-provider.ts | 16 +- src/providers/caching-token-provider.ts | 8 +- src/providers/on-chain-quote-provider.ts | 8 + src/providers/token-fee-fetcher.ts | 2 +- src/providers/token-provider.ts | 19 +- src/providers/v2/static-subgraph-provider.ts | 13 +- src/providers/v3/static-subgraph-provider.ts | 13 +- src/routers/alpha-router/alpha-router.ts | 3 +- src/routers/alpha-router/config.ts | 3 +- .../functions/get-candidate-pools.ts | 3 +- .../alpha-router/gas-models/gas-costs.ts | 9 +- .../alpha-router/gas-models/gas-model.ts | 6 +- src/routers/legacy-router/bases.ts | 13 +- src/util/addresses.ts | 32 ++-- src/util/chains.ts | 44 +++-- src/util/l2FeeChains.ts | 3 +- .../alpha-router.integration.test.ts | 29 +-- test/test-util/whales.ts | 24 ++- 22 files changed, 292 insertions(+), 187 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 97b856a6b..c7dd54c90 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -780,8 +780,8 @@ jobs: TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }} TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }} - integration-tests-quote-for-other-networks-astrochain: - name: Integration Tests - Quote For Other Networks AstroChain + integration-tests-quote-for-other-networks-unichain: + name: Integration Tests - Quote For Other Networks Unichain runs-on: ubuntu-latest steps: @@ -805,9 +805,44 @@ jobs: run: npm run build - name: Run Integration tests - run: npm run integ-test -- -t 'quote for other networks * astrochain' + run: npm run integ-test -- -t 'quote for other networks * unichain' env: - JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA: ${{ secrets.JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA }} + # TODO: add secret in github secrets + JSON_RPC_PROVIDER_UNICHAIN: ${{ secrets.JSON_RPC_PROVIDER_UNICHAIN }} + TENDERLY_BASE_URL: ${{ secrets.TENDERLY_BASE_URL }} + TENDERLY_USER: ${{ secrets.TENDERLY_USER }} + TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }} + TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }} + + integration-tests-quote-for-other-networks-unichain-sepolia: + name: Integration Tests - Quote For Other Networks Unichain Sepolia + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 18.x + registry-url: https://registry.npmjs.org + + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + + # This is required separately from yarn test because it generates the typechain definitions + - name: Compile + run: npm run build + + - name: Run Integration tests + run: npm run integ-test -- -t 'quote for other networks * unichain sepolia' + env: + # TODO: add secret in github secrets, similar value to 'JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA' + JSON_RPC_PROVIDER_UNICHAIN_SEPOLIA: ${{ secrets.JSON_RPC_PROVIDER_UNICHAIN_SEPOLIA }} TENDERLY_BASE_URL: ${{ secrets.TENDERLY_BASE_URL }} TENDERLY_USER: ${{ secrets.TENDERLY_USER }} TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }} diff --git a/README.md b/README.md index 7b94eb478..dc3c3afb8 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,12 @@ Total ticks crossed: 7 ./bin/cli quote --tokenIn 0x4200000000000000000000000000000000000006 --tokenOut 0x31d0220469e10c4E71834a79b1f276d740d3768F --amount 0.1 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 1301 ``` +## Unichain Mainnet + +``` +./bin/cli quote --tokenIn 0x4200000000000000000000000000000000000006 --tokenOut 0x???????????????????????????? --amount 0.1 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 130 +``` + ## Adding a new Chain The main components to complete are: diff --git a/package-lock.json b/package-lock.json index 9b0c9f46d..3aaa02bf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,15 +13,15 @@ "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.14.0", - "@uniswap/sdk-core": "^5.9.0", + "@uniswap/router-sdk": "^1.15.0", + "@uniswap/sdk-core": "^6.0.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": "^4.6.1", - "@uniswap/v2-sdk": "^4.6.1", - "@uniswap/v3-sdk": "^3.17.1", - "@uniswap/v4-sdk": "^1.10.0", + "@uniswap/universal-router-sdk": "file:/tmp/ur-sdk-001.tgz", + "@uniswap/v2-sdk": "^4.7.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0", "async-retry": "^1.3.1", "await-timeout": "^1.1.1", "axios": "^0.21.1", @@ -3262,22 +3262,22 @@ } }, "node_modules/@uniswap/router-sdk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/@uniswap/router-sdk/-/router-sdk-1.14.2.tgz", - "integrity": "sha512-RvTAsKANG5iLDMk9O/F05wZOMTg8qPw5BBCTkpQYM4o6Mz92wziaD5r52O6KzzOXvZizC/7YJ5BAAcr25slSQw==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@uniswap/router-sdk/-/router-sdk-1.15.0.tgz", + "integrity": "sha512-KYzpxHX07O2hon9qMudzmtu/+epmnTzva1ZngdJ29CmRXT7C56yz8vSeLXWVvVEp5/m7TcDxbBS5wkY+WHuLDA==", "dependencies": { "@ethersproject/abi": "^5.5.0", - "@uniswap/sdk-core": "^5.8.0", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/swap-router-contracts": "^1.3.0", - "@uniswap/v2-sdk": "^4.6.0", - "@uniswap/v3-sdk": "^3.17.0", - "@uniswap/v4-sdk": "^1.9.0" + "@uniswap/v2-sdk": "^4.7.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0" } }, "node_modules/@uniswap/sdk-core": { - "version": "5.9.0", - "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-5.9.0.tgz", - "integrity": "sha512-OME7WR6+5QwQs45A2079r+/FS0zU944+JCQwUX9GyIriCxqw2pGu4F9IEqmlwD+zSIMml0+MJnJJ47pFgSyWDw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-6.0.0.tgz", + "integrity": "sha512-6rwBG/Ut7rL2Dw4xtTF1dHSmtctT3h57q4vXIneLYjlePa1PT0mgp5D7cu/6xKEvO1MFtnMchImpWsclfafdUg==", "dependencies": { "@ethersproject/address": "^5.0.2", "@ethersproject/bytes": "^5.7.0", @@ -3344,20 +3344,20 @@ } }, "node_modules/@uniswap/universal-router-sdk": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@uniswap/universal-router-sdk/-/universal-router-sdk-4.6.1.tgz", - "integrity": "sha512-HfPYd8xz3/Sjb8if/wAPFOzj0+m7173PVLy+VzF4HrbBwDreU0amYHwf4zQBjffXmys2QtOdwfu7BfZrUwx0kQ==", + "resolved": "file:../../../../../tmp/ur-sdk-001.tgz", + "integrity": "sha512-YOljjERNiTE3HkK2wSPtm2rO23KXOhbWDs5aqI/LK1wgzSI0yD7cpH8kIgl1ObaNIyQS+HHKvBspH4LxzSME1g==", + "license": "MIT", "dependencies": { "@openzeppelin/contracts": "4.7.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.14.2", - "@uniswap/sdk-core": "^5.8.2", + "@uniswap/router-sdk": "^1.15.0", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/universal-router": "2.0.0-beta.2", "@uniswap/v2-core": "^1.0.1", - "@uniswap/v2-sdk": "^4.6.0", + "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-core": "1.0.0", - "@uniswap/v3-sdk": "^3.18.1", - "@uniswap/v4-sdk": "^1.10.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0", "bignumber.js": "^9.0.2", "ethers": "^5.7.0" }, @@ -3440,13 +3440,13 @@ } }, "node_modules/@uniswap/v2-sdk": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@uniswap/v2-sdk/-/v2-sdk-4.6.1.tgz", - "integrity": "sha512-oTJGBPecrNSPMEp4ujDYzyWPNgZ/kS1VR6MGotnjjGsvQ1btm55AO1OR2KoX85bEs7uUSDyQ/r/0p22+g2fgJA==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@uniswap/v2-sdk/-/v2-sdk-4.7.0.tgz", + "integrity": "sha512-CShitWRbydaigNF5GfNNCgGH9GXKMI/HD6ThI4T7FoSZkf2pgTXlX1fQ829xbl1ohKO61n4NjZs/HzGKIV5yjQ==", "dependencies": { "@ethersproject/address": "^5.0.2", "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.8.1", + "@uniswap/sdk-core": "^6.0.0", "tiny-invariant": "^1.1.0", "tiny-warning": "^1.0.3" }, @@ -3491,13 +3491,13 @@ } }, "node_modules/@uniswap/v3-sdk": { - "version": "3.18.1", - "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.18.1.tgz", - "integrity": "sha512-TGrKLToSWwfx6VV2d7fh4kwQMlgspXTLE49ep5zfYODVVqV6WhrRdbteHb3e0bjdjxGSj0gzoLmhsjmoJTE1/g==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.19.0.tgz", + "integrity": "sha512-HbX3YjHJRXI2LFCxLUWgPfRZX6N9a+cELJ3Dus5vYDPYYjFOwJr16c2esDsdHUe3TG2oOeA/u2wv9TDT2GSBIw==", "dependencies": { "@ethersproject/abi": "^5.5.0", "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.8.1", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/swap-router-contracts": "^1.3.0", "@uniswap/v3-periphery": "^1.1.1", "@uniswap/v3-staker": "1.0.0", @@ -3531,13 +3531,13 @@ } }, "node_modules/@uniswap/v4-sdk": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@uniswap/v4-sdk/-/v4-sdk-1.10.0.tgz", - "integrity": "sha512-aqA40tHgjZ8VwUAXehjR+d7v/8qnQ5CrbhHmMOLo/98jwGM63iHYLyq1kEyaQJl+JhCMXdTGczsEpZSj05iQgw==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@uniswap/v4-sdk/-/v4-sdk-1.12.0.tgz", + "integrity": "sha512-a1SpbjEYf55alEpmbM2G3frKEDkVBhz5arifxjGQS0FXr4sOC+baZuSYqu0JA5FTGjGV7V5MVQdivwX0+KyQnA==", "dependencies": { "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.3.1", - "@uniswap/v3-sdk": "3.12.0", + "@uniswap/sdk-core": "^6.0.0", + "@uniswap/v3-sdk": "3.19.0", "tiny-invariant": "^1.1.0", "tiny-warning": "^1.0.3" }, @@ -3545,24 +3545,6 @@ "node": ">=14" } }, - "node_modules/@uniswap/v4-sdk/node_modules/@uniswap/v3-sdk": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.12.0.tgz", - "integrity": "sha512-mUCg9HLKl20h6W8+QtELqN/uaO47/KDSf+EOht+W3C6jt2eGuzSANqS2CY7i8MsAsnZ+MjPhmN+JTOIvf7azfA==", - "dependencies": { - "@ethersproject/abi": "^5.5.0", - "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.0.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" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -14346,22 +14328,22 @@ } }, "@uniswap/router-sdk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/@uniswap/router-sdk/-/router-sdk-1.14.2.tgz", - "integrity": "sha512-RvTAsKANG5iLDMk9O/F05wZOMTg8qPw5BBCTkpQYM4o6Mz92wziaD5r52O6KzzOXvZizC/7YJ5BAAcr25slSQw==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@uniswap/router-sdk/-/router-sdk-1.15.0.tgz", + "integrity": "sha512-KYzpxHX07O2hon9qMudzmtu/+epmnTzva1ZngdJ29CmRXT7C56yz8vSeLXWVvVEp5/m7TcDxbBS5wkY+WHuLDA==", "requires": { "@ethersproject/abi": "^5.5.0", - "@uniswap/sdk-core": "^5.8.0", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/swap-router-contracts": "^1.3.0", - "@uniswap/v2-sdk": "^4.6.0", - "@uniswap/v3-sdk": "^3.17.0", - "@uniswap/v4-sdk": "^1.9.0" + "@uniswap/v2-sdk": "^4.7.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0" } }, "@uniswap/sdk-core": { - "version": "5.9.0", - "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-5.9.0.tgz", - "integrity": "sha512-OME7WR6+5QwQs45A2079r+/FS0zU944+JCQwUX9GyIriCxqw2pGu4F9IEqmlwD+zSIMml0+MJnJJ47pFgSyWDw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-6.0.0.tgz", + "integrity": "sha512-6rwBG/Ut7rL2Dw4xtTF1dHSmtctT3h57q4vXIneLYjlePa1PT0mgp5D7cu/6xKEvO1MFtnMchImpWsclfafdUg==", "requires": { "@ethersproject/address": "^5.0.2", "@ethersproject/bytes": "^5.7.0", @@ -14427,20 +14409,19 @@ } }, "@uniswap/universal-router-sdk": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@uniswap/universal-router-sdk/-/universal-router-sdk-4.6.1.tgz", - "integrity": "sha512-HfPYd8xz3/Sjb8if/wAPFOzj0+m7173PVLy+VzF4HrbBwDreU0amYHwf4zQBjffXmys2QtOdwfu7BfZrUwx0kQ==", + "version": "file:/tmp/ur-sdk-001.tgz", + "integrity": "sha512-YOljjERNiTE3HkK2wSPtm2rO23KXOhbWDs5aqI/LK1wgzSI0yD7cpH8kIgl1ObaNIyQS+HHKvBspH4LxzSME1g==", "requires": { "@openzeppelin/contracts": "4.7.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.14.2", - "@uniswap/sdk-core": "^5.8.2", + "@uniswap/router-sdk": "^1.15.0", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/universal-router": "2.0.0-beta.2", "@uniswap/v2-core": "^1.0.1", - "@uniswap/v2-sdk": "^4.6.0", + "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-core": "1.0.0", - "@uniswap/v3-sdk": "^3.18.1", - "@uniswap/v4-sdk": "^1.10.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0", "bignumber.js": "^9.0.2", "ethers": "^5.7.0" }, @@ -14498,13 +14479,13 @@ } }, "@uniswap/v2-sdk": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@uniswap/v2-sdk/-/v2-sdk-4.6.1.tgz", - "integrity": "sha512-oTJGBPecrNSPMEp4ujDYzyWPNgZ/kS1VR6MGotnjjGsvQ1btm55AO1OR2KoX85bEs7uUSDyQ/r/0p22+g2fgJA==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@uniswap/v2-sdk/-/v2-sdk-4.7.0.tgz", + "integrity": "sha512-CShitWRbydaigNF5GfNNCgGH9GXKMI/HD6ThI4T7FoSZkf2pgTXlX1fQ829xbl1ohKO61n4NjZs/HzGKIV5yjQ==", "requires": { "@ethersproject/address": "^5.0.2", "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.8.1", + "@uniswap/sdk-core": "^6.0.0", "tiny-invariant": "^1.1.0", "tiny-warning": "^1.0.3" } @@ -14539,13 +14520,13 @@ } }, "@uniswap/v3-sdk": { - "version": "3.18.1", - "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.18.1.tgz", - "integrity": "sha512-TGrKLToSWwfx6VV2d7fh4kwQMlgspXTLE49ep5zfYODVVqV6WhrRdbteHb3e0bjdjxGSj0gzoLmhsjmoJTE1/g==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.19.0.tgz", + "integrity": "sha512-HbX3YjHJRXI2LFCxLUWgPfRZX6N9a+cELJ3Dus5vYDPYYjFOwJr16c2esDsdHUe3TG2oOeA/u2wv9TDT2GSBIw==", "requires": { "@ethersproject/abi": "^5.5.0", "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.8.1", + "@uniswap/sdk-core": "^6.0.0", "@uniswap/swap-router-contracts": "^1.3.0", "@uniswap/v3-periphery": "^1.1.1", "@uniswap/v3-staker": "1.0.0", @@ -14571,32 +14552,15 @@ } }, "@uniswap/v4-sdk": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@uniswap/v4-sdk/-/v4-sdk-1.10.0.tgz", - "integrity": "sha512-aqA40tHgjZ8VwUAXehjR+d7v/8qnQ5CrbhHmMOLo/98jwGM63iHYLyq1kEyaQJl+JhCMXdTGczsEpZSj05iQgw==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@uniswap/v4-sdk/-/v4-sdk-1.12.0.tgz", + "integrity": "sha512-a1SpbjEYf55alEpmbM2G3frKEDkVBhz5arifxjGQS0FXr4sOC+baZuSYqu0JA5FTGjGV7V5MVQdivwX0+KyQnA==", "requires": { "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.3.1", - "@uniswap/v3-sdk": "3.12.0", + "@uniswap/sdk-core": "^6.0.0", + "@uniswap/v3-sdk": "3.19.0", "tiny-invariant": "^1.1.0", "tiny-warning": "^1.0.3" - }, - "dependencies": { - "@uniswap/v3-sdk": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.12.0.tgz", - "integrity": "sha512-mUCg9HLKl20h6W8+QtELqN/uaO47/KDSf+EOht+W3C6jt2eGuzSANqS2CY7i8MsAsnZ+MjPhmN+JTOIvf7azfA==", - "requires": { - "@ethersproject/abi": "^5.5.0", - "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "^5.0.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" - } - } } }, "abab": { diff --git a/package.json b/package.json index 989720e14..0ded1592d 100644 --- a/package.json +++ b/package.json @@ -37,15 +37,15 @@ "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.14.0", - "@uniswap/sdk-core": "^5.9.0", + "@uniswap/router-sdk": "^1.15.0", + "@uniswap/sdk-core": "^6.0.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": "^4.6.1", - "@uniswap/v2-sdk": "^4.6.1", - "@uniswap/v3-sdk": "^3.17.1", - "@uniswap/v4-sdk": "^1.10.0", + "@uniswap/universal-router-sdk": "file:/tmp/ur-sdk-001.tgz", + "@uniswap/v2-sdk": "^4.7.0", + "@uniswap/v3-sdk": "^3.19.0", + "@uniswap/v4-sdk": "^1.12.0", "async-retry": "^1.3.1", "await-timeout": "^1.1.1", "axios": "^0.21.1", diff --git a/src/providers/caching-subgraph-provider.ts b/src/providers/caching-subgraph-provider.ts index 4c0607f4a..c33b39f16 100644 --- a/src/providers/caching-subgraph-provider.ts +++ b/src/providers/caching-subgraph-provider.ts @@ -25,7 +25,6 @@ import { USDB_BLAST, USDCE_ZKSYNC, USDC_ARBITRUM, - USDC_ASTROCHAIN_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -34,6 +33,8 @@ import { USDC_NATIVE_ARBITRUM, USDC_OPTIMISM, USDC_POLYGON, + USDC_UNICHAIN, + USDC_UNICHAIN_SEPOLIA, USDC_WORLDCHAIN, USDC_ZKSYNC, USDT_ARBITRUM, @@ -155,10 +156,15 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { WLD_WORLDCHAIN, WBTC_WORLDCHAIN, ], - [ChainId.ASTROCHAIN_SEPOLIA]: [ - nativeOnChain(ChainId.ASTROCHAIN_SEPOLIA), - WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA]!, - USDC_ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: [ + nativeOnChain(ChainId.UNICHAIN_SEPOLIA), + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN_SEPOLIA]!, + USDC_UNICHAIN_SEPOLIA, + ], + [ChainId.UNICHAIN]: [ + nativeOnChain(ChainId.UNICHAIN), + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN]!, + USDC_UNICHAIN, ], }; diff --git a/src/providers/caching-token-provider.ts b/src/providers/caching-token-provider.ts index bc170a994..388dc0104 100644 --- a/src/providers/caching-token-provider.ts +++ b/src/providers/caching-token-provider.ts @@ -180,9 +180,13 @@ export const CACHE_SEED_TOKENS: { WBTC: WBTC_WORLDCHAIN, WETH: WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN], }, - [ChainId.ASTROCHAIN_SEPOLIA]: { + [ChainId.UNICHAIN_SEPOLIA]: { USDC: USDC_SEPOLIA, - WETH: WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA], + WETH: WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN_SEPOLIA], + }, + [ChainId.UNICHAIN]: { + USDC: USDC_SEPOLIA, + WETH: WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN], }, // Currently we do not have providers for Moonbeam mainnet or Gnosis testnet }; diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index ebf5126ef..b29ebe995 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -663,6 +663,12 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { _providerConfig?.blockNumber ?? originalBlockNumber + baseBlockOffset, }; + log.info(`routes length: ${routes.length}`); + log.info(`amounts length: ${amounts.length}`); + for (const amount of amounts) { + log.info(`amount: ${amount.quotient.toString()}`); + } + const inputs: QuoteInputType[] = _(routes) .flatMap((route) => { const encodedRoute = this.encodeRouteToPath(route, functionName); @@ -769,6 +775,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const expectedCallsMade = quoteStates.length; let totalCallsMade = 0; + log.info(`----> Tooooootal quoteStates: ${quoteStates.length}`); + const { results: quoteResults, blockNumber, diff --git a/src/providers/token-fee-fetcher.ts b/src/providers/token-fee-fetcher.ts index aff5575d3..8e07e1e33 100644 --- a/src/providers/token-fee-fetcher.ts +++ b/src/providers/token-fee-fetcher.ts @@ -54,7 +54,7 @@ const FEE_DETECTOR_ADDRESS = (chainId: ChainId) => { return '0x8269d47c4910B8c87789aA0eC128C11A8614dfC8'; case ChainId.WORLDCHAIN: return '0xbc708B192552e19A088b4C4B8772aEeA83bCf760'; - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: return '0xbc708B192552e19A088b4C4B8772aEeA83bCf760'; default: // just default to mainnet contract diff --git a/src/providers/token-provider.ts b/src/providers/token-provider.ts index 92f8e0dc7..0bfa68c59 100644 --- a/src/providers/token-provider.ts +++ b/src/providers/token-provider.ts @@ -734,14 +734,23 @@ export const WBTC_WORLDCHAIN = new Token( 'Wrapped BTC' ); -export const USDC_ASTROCHAIN_SEPOLIA = new Token( - ChainId.ASTROCHAIN_SEPOLIA, +export const USDC_UNICHAIN_SEPOLIA = new Token( + ChainId.UNICHAIN_SEPOLIA, '0x31d0220469e10c4E71834a79b1f276d740d3768F', 6, 'USDC', 'USDC Token' ); +export const USDC_UNICHAIN = new Token( + ChainId.UNICHAIN, + // TODO: validate USDC address is final / validated + '0x078D782b760474a361dDA0AF3839290b0EF57AD6', + 6, + 'USDC', + 'USD Token' +); + export class TokenProvider implements ITokenProvider { constructor( private chainId: ChainId, @@ -1017,8 +1026,10 @@ export const USDC_ON = (chainId: ChainId): Token => { return USDCE_ZKSYNC; case ChainId.WORLDCHAIN: return USDC_WORLDCHAIN; - case ChainId.ASTROCHAIN_SEPOLIA: - return USDC_ASTROCHAIN_SEPOLIA; + case ChainId.UNICHAIN_SEPOLIA: + return USDC_UNICHAIN_SEPOLIA; + case ChainId.UNICHAIN: + return USDC_UNICHAIN; default: throw new Error(`Chain id: ${chainId} not supported`); } diff --git a/src/providers/v2/static-subgraph-provider.ts b/src/providers/v2/static-subgraph-provider.ts index 3ac439ac8..38131be04 100644 --- a/src/providers/v2/static-subgraph-provider.ts +++ b/src/providers/v2/static-subgraph-provider.ts @@ -23,7 +23,6 @@ import { USDB_BLAST, USDCE_ZKSYNC, USDC_ARBITRUM, - USDC_ASTROCHAIN_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -32,6 +31,8 @@ import { USDC_NATIVE_ARBITRUM, USDC_OPTIMISM, USDC_POLYGON, + USDC_UNICHAIN, + USDC_UNICHAIN_SEPOLIA, USDC_WORLDCHAIN, USDC_ZKSYNC, USDT_ARBITRUM, @@ -130,9 +131,13 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { WLD_WORLDCHAIN, WBTC_WORLDCHAIN, ], - [ChainId.ASTROCHAIN_SEPOLIA]: [ - WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA]!, - USDC_ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN_SEPOLIA]!, + USDC_UNICHAIN_SEPOLIA, + ], + [ChainId.UNICHAIN]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN]!, + USDC_UNICHAIN, ], }; diff --git a/src/providers/v3/static-subgraph-provider.ts b/src/providers/v3/static-subgraph-provider.ts index 8d9c89adb..f2bd6be5f 100644 --- a/src/providers/v3/static-subgraph-provider.ts +++ b/src/providers/v3/static-subgraph-provider.ts @@ -35,7 +35,6 @@ import { USDCE_ZKSYNC, USDC_ARBITRUM, USDC_ARBITRUM_GOERLI, - USDC_ASTROCHAIN_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -47,6 +46,8 @@ import { USDC_OPTIMISM_GOERLI, USDC_POLYGON, USDC_SEPOLIA, + USDC_UNICHAIN, + USDC_UNICHAIN_SEPOLIA, USDC_WORLDCHAIN, USDC_ZKSYNC, USDT_ARBITRUM, @@ -185,9 +186,13 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { WLD_WORLDCHAIN, WBTC_WORLDCHAIN, ], - [ChainId.ASTROCHAIN_SEPOLIA]: [ - WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA]!, - USDC_ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN_SEPOLIA]!, + USDC_UNICHAIN_SEPOLIA, + ], + [ChainId.UNICHAIN]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN]!, + USDC_UNICHAIN, ], }; diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index 5c81c5b00..39563c531 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -664,7 +664,8 @@ export class AlphaRouter case ChainId.BLAST: case ChainId.ZORA: case ChainId.WORLDCHAIN: - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: + case ChainId.UNICHAIN: case ChainId.BASE_GOERLI: this.onChainQuoteProvider = new OnChainQuoteProvider( chainId, diff --git a/src/routers/alpha-router/config.ts b/src/routers/alpha-router/config.ts index 9b2d3f086..aae8f230d 100644 --- a/src/routers/alpha-router/config.ts +++ b/src/routers/alpha-router/config.ts @@ -14,7 +14,8 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = ( case ChainId.BASE_GOERLI: case ChainId.BLAST: case ChainId.WORLDCHAIN: - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: + case ChainId.UNICHAIN: return { v2PoolSelection: { topN: 3, diff --git a/src/routers/alpha-router/functions/get-candidate-pools.ts b/src/routers/alpha-router/functions/get-candidate-pools.ts index dbe72fd43..ef44f99bd 100644 --- a/src/routers/alpha-router/functions/get-candidate-pools.ts +++ b/src/routers/alpha-router/functions/get-candidate-pools.ts @@ -236,7 +236,8 @@ const baseTokensByChain: { [chainId in ChainId]?: Token[] } = { [ChainId.ZORA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA]!], [ChainId.ZKSYNC]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZKSYNC]!], [ChainId.WORLDCHAIN]: [WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN]!], - [ChainId.ASTROCHAIN_SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN]!], + [ChainId.UNICHAIN_SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN]!], + [ChainId.UNICHAIN]: [WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN]!], }; class SubcategorySelectionPools { diff --git a/src/routers/alpha-router/gas-models/gas-costs.ts b/src/routers/alpha-router/gas-models/gas-costs.ts index d9078acee..2c6d10fea 100644 --- a/src/routers/alpha-router/gas-models/gas-costs.ts +++ b/src/routers/alpha-router/gas-models/gas-costs.ts @@ -27,7 +27,8 @@ export const BASE_SWAP_COST = (id: ChainId): BigNumber => { case ChainId.BLAST: case ChainId.ZKSYNC: case ChainId.WORLDCHAIN: - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: + case ChainId.UNICHAIN: return BigNumber.from(2000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: @@ -67,7 +68,8 @@ export const COST_PER_INIT_TICK = (id: ChainId): BigNumber => { case ChainId.BLAST: case ChainId.ZKSYNC: case ChainId.WORLDCHAIN: - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: + case ChainId.UNICHAIN: return BigNumber.from(31000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: @@ -104,7 +106,8 @@ export const COST_PER_HOP = (id: ChainId): BigNumber => { case ChainId.BLAST: case ChainId.ZKSYNC: case ChainId.WORLDCHAIN: - case ChainId.ASTROCHAIN_SEPOLIA: + case ChainId.UNICHAIN_SEPOLIA: + case ChainId.UNICHAIN: return BigNumber.from(80000); case ChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_GOERLI: diff --git a/src/routers/alpha-router/gas-models/gas-model.ts b/src/routers/alpha-router/gas-models/gas-model.ts index e31b17375..5f8191091 100644 --- a/src/routers/alpha-router/gas-models/gas-model.ts +++ b/src/routers/alpha-router/gas-models/gas-model.ts @@ -27,7 +27,6 @@ import { USDC_ARBITRUM, USDC_ARBITRUM_GOERLI, USDC_ARBITRUM_SEPOLIA, - USDC_ASTROCHAIN_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, @@ -48,6 +47,8 @@ import { USDC_OPTIMISM_SEPOLIA, USDC_POLYGON, USDC_SEPOLIA, + USDC_UNICHAIN, + USDC_UNICHAIN_SEPOLIA, USDC_WORLDCHAIN, USDC_WORMHOLE_CELO, USDC_ZKSYNC, @@ -125,7 +126,8 @@ export const usdGasTokensByChain: { [chainId in ChainId]?: Token[] } = { [ChainId.ZORA]: [USDC_ZORA], [ChainId.ZKSYNC]: [DAI_ZKSYNC, USDCE_ZKSYNC, USDC_ZKSYNC], [ChainId.WORLDCHAIN]: [USDC_WORLDCHAIN], - [ChainId.ASTROCHAIN_SEPOLIA]: [USDC_ASTROCHAIN_SEPOLIA], + [ChainId.UNICHAIN_SEPOLIA]: [USDC_UNICHAIN_SEPOLIA], + [ChainId.UNICHAIN]: [USDC_UNICHAIN], }; export type L1ToL2GasCosts = { diff --git a/src/routers/legacy-router/bases.ts b/src/routers/legacy-router/bases.ts index 288dee803..62031b317 100644 --- a/src/routers/legacy-router/bases.ts +++ b/src/routers/legacy-router/bases.ts @@ -10,11 +10,12 @@ import { ITokenProvider, USDB_BLAST, USDCE_ZKSYNC, - USDC_ASTROCHAIN_SEPOLIA, USDC_AVAX, USDC_BASE, USDC_BNB, USDC_MAINNET, + USDC_UNICHAIN, + USDC_UNICHAIN_SEPOLIA, USDC_WORLDCHAIN, USDC_ZKSYNC, USDT_BNB, @@ -94,9 +95,13 @@ export const BASES_TO_CHECK_TRADES_AGAINST = ( WLD_WORLDCHAIN, WBTC_WORLDCHAIN, ], - [ChainId.ASTROCHAIN_SEPOLIA]: [ - WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA]!, - USDC_ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN_SEPOLIA]!, + USDC_UNICHAIN_SEPOLIA, + ], + [ChainId.UNICHAIN]: [ + WRAPPED_NATIVE_CURRENCY[ChainId.UNICHAIN]!, + USDC_UNICHAIN, ], }; }; diff --git a/src/util/addresses.ts b/src/util/addresses.ts index 080443c1c..a24e80037 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -45,9 +45,11 @@ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = { [ChainId.ZKSYNC]: CHAIN_TO_ADDRESSES_MAP[ChainId.ZKSYNC].v3CoreFactoryAddress, [ChainId.WORLDCHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.WORLDCHAIN].v3CoreFactoryAddress, - [ChainId.ASTROCHAIN_SEPOLIA]: - CHAIN_TO_ADDRESSES_MAP[ChainId.ASTROCHAIN_SEPOLIA].v3CoreFactoryAddress, + [ChainId.UNICHAIN_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].v3CoreFactoryAddress, // TODO: Gnosis + Moonbeam contracts to be deployed + [ChainId.UNICHAIN]: + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN].v3CoreFactoryAddress, }; export const QUOTER_V2_ADDRESSES: AddressMap = { @@ -74,9 +76,10 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { [ChainId.ZKSYNC]: CHAIN_TO_ADDRESSES_MAP[ChainId.ZKSYNC].quoterAddress, [ChainId.WORLDCHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.WORLDCHAIN].quoterAddress, - [ChainId.ASTROCHAIN_SEPOLIA]: - CHAIN_TO_ADDRESSES_MAP[ChainId.ASTROCHAIN_SEPOLIA].quoterAddress, + [ChainId.UNICHAIN_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].quoterAddress, // TODO: Gnosis + Moonbeam contracts to be deployed + [ChainId.UNICHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN].quoterAddress, }; export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { @@ -95,8 +98,9 @@ export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { [ChainId.ZKSYNC]: '0x071Bd2063dF031EDd110E27C6F4CDe50A3DeF2d4', [ChainId.WORLDCHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.WORLDCHAIN].quoterAddress, // TODO: deploy view-only-quoter to worldchain - [ChainId.ASTROCHAIN_SEPOLIA]: - CHAIN_TO_ADDRESSES_MAP[ChainId.ASTROCHAIN_SEPOLIA].quoterAddress, // TODO: deploy view-only-quoter to astrochain + [ChainId.UNICHAIN_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].quoterAddress, // TODO: deploy view-only-quoter to astrochain + [ChainId.UNICHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN].quoterAddress, // TODO: deploy view-only-quoter to unichain }; export const PROTOCOL_V4_QUOTER_ADDRESSES: AddressMap = { @@ -141,9 +145,10 @@ export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = { [ChainId.ZKSYNC]: CHAIN_TO_ADDRESSES_MAP[ChainId.ZKSYNC].multicallAddress, [ChainId.WORLDCHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.WORLDCHAIN].multicallAddress, - [ChainId.ASTROCHAIN_SEPOLIA]: - CHAIN_TO_ADDRESSES_MAP[ChainId.ASTROCHAIN_SEPOLIA].multicallAddress, + [ChainId.UNICHAIN_SEPOLIA]: + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].multicallAddress, // TODO: Gnosis + Moonbeam contracts to be deployed + [ChainId.UNICHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN].multicallAddress, }; export const SWAP_ROUTER_02_ADDRESSES = (chainId: number): string => { @@ -312,8 +317,15 @@ export const WETH9: { 'WETH', 'Wrapped Ether' ), - [ChainId.ASTROCHAIN_SEPOLIA]: new Token( - ChainId.ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: new Token( + ChainId.UNICHAIN_SEPOLIA, + '0x4200000000000000000000000000000000000006', + 18, + 'WETH', + 'Wrapped Ether' + ), + [ChainId.UNICHAIN]: new Token( + ChainId.UNICHAIN, '0x4200000000000000000000000000000000000006', 18, 'WETH', diff --git a/src/util/chains.ts b/src/util/chains.ts index dd0e1badf..62dcc3ed9 100644 --- a/src/util/chains.ts +++ b/src/util/chains.ts @@ -27,7 +27,8 @@ export const SUPPORTED_CHAINS: ChainId[] = [ ChainId.ZORA, ChainId.ZKSYNC, ChainId.WORLDCHAIN, - ChainId.ASTROCHAIN_SEPOLIA, + ChainId.UNICHAIN, + ChainId.UNICHAIN_SEPOLIA, // Gnosis and Moonbeam don't yet have contracts deployed yet ]; @@ -62,7 +63,8 @@ export const HAS_L1_FEE = [ ChainId.BLAST, ChainId.ZORA, ChainId.WORLDCHAIN, - ChainId.ASTROCHAIN_SEPOLIA, + ChainId.UNICHAIN_SEPOLIA, + ChainId.UNICHAIN, ]; export const NETWORKS_WITH_SAME_UNISWAP_ADDRESSES = [ @@ -123,7 +125,9 @@ export const ID_TO_CHAIN_ID = (id: number): ChainId => { case 480: return ChainId.WORLDCHAIN; case 1301: - return ChainId.ASTROCHAIN_SEPOLIA; + return ChainId.UNICHAIN_SEPOLIA; + case 130: + return ChainId.UNICHAIN; default: throw new Error(`Unknown chain id: ${id}`); } @@ -153,7 +157,8 @@ export enum ChainName { ZORA = 'zora-mainnet', ZKSYNC = 'zksync-mainnet', WORLDCHAIN = 'worldchain-mainnet', - ASTROCHAIN_SEPOLIA = 'astrochain-sepolia', + UNICHAIN_SEPOLIA = 'unichain-sepolia', + UNICHAIN = 'unichain-mainnet', } export enum NativeCurrencyName { @@ -253,7 +258,12 @@ export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = { 'ETHER', '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', ], - [ChainId.ASTROCHAIN_SEPOLIA]: [ + [ChainId.UNICHAIN_SEPOLIA]: [ + 'ETH', + 'ETHER', + '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + ], + [ChainId.UNICHAIN]: [ 'ETH', 'ETHER', '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', @@ -283,7 +293,8 @@ export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = { [ChainId.ZORA]: NativeCurrencyName.ETHER, [ChainId.ZKSYNC]: NativeCurrencyName.ETHER, [ChainId.WORLDCHAIN]: NativeCurrencyName.ETHER, - [ChainId.ASTROCHAIN_SEPOLIA]: NativeCurrencyName.ETHER, + [ChainId.UNICHAIN_SEPOLIA]: NativeCurrencyName.ETHER, + [ChainId.UNICHAIN]: NativeCurrencyName.ETHER, }; export const ID_TO_NETWORK_NAME = (id: number): ChainName => { @@ -335,7 +346,9 @@ export const ID_TO_NETWORK_NAME = (id: number): ChainName => { case 480: return ChainName.WORLDCHAIN; case 1301: - return ChainName.ASTROCHAIN_SEPOLIA; + return ChainName.UNICHAIN_SEPOLIA; + case 130: + return ChainName.UNICHAIN; default: throw new Error(`Unknown chain id: ${id}`); } @@ -387,8 +400,10 @@ export const ID_TO_PROVIDER = (id: ChainId): string => { return process.env.JSON_RPC_PROVIDER_ZKSYNC!; case ChainId.WORLDCHAIN: return process.env.JSON_RPC_PROVIDER_WORLDCHAIN!; - case ChainId.ASTROCHAIN_SEPOLIA: - return process.env.JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA!; + case ChainId.UNICHAIN_SEPOLIA: + return process.env.JSON_RPC_PROVIDER_UNICHAIN_SEPOLIA!; + case ChainId.UNICHAIN: + return process.env.JSON_RPC_PROVIDER_UNICHAIN!; default: throw new Error(`Chain id: ${id} not supported`); } @@ -572,8 +587,15 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId in ChainId]: Token } = { 'WETH', 'Wrapped Ether' ), - [ChainId.ASTROCHAIN_SEPOLIA]: new Token( - ChainId.ASTROCHAIN_SEPOLIA, + [ChainId.UNICHAIN_SEPOLIA]: new Token( + ChainId.UNICHAIN_SEPOLIA, + '0x4200000000000000000000000000000000000006', + 18, + 'WETH', + 'Wrapped Ether' + ), + [ChainId.UNICHAIN]: new Token( + ChainId.UNICHAIN, '0x4200000000000000000000000000000000000006', 18, 'WETH', diff --git a/src/util/l2FeeChains.ts b/src/util/l2FeeChains.ts index 6d95452c7..5270f6303 100644 --- a/src/util/l2FeeChains.ts +++ b/src/util/l2FeeChains.ts @@ -9,5 +9,6 @@ export const opStackChains = [ ChainId.BLAST, ChainId.ZORA, ChainId.WORLDCHAIN, - ChainId.ASTROCHAIN_SEPOLIA, + ChainId.UNICHAIN_SEPOLIA, + ChainId.UNICHAIN, ]; 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 8162f0f8a..3bbb19493 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -162,7 +162,8 @@ const GAS_ESTIMATE_DEVIATION_PERCENT: { [chainId in ChainId]: number } = { [ChainId.BLAST]: 34, [ChainId.ZKSYNC]: 40, [ChainId.WORLDCHAIN]: 50, - [ChainId.ASTROCHAIN_SEPOLIA]: 50, + [ChainId.UNICHAIN_SEPOLIA]: 50, + [ChainId.UNICHAIN]: 50, }; const V2_SUPPORTED_PAIRS = [ @@ -3538,7 +3539,8 @@ describe('quote for other networks', () => { [ChainId.BLAST]: () => USDB_BLAST, [ChainId.ZKSYNC]: () => USDC_ON(ChainId.ZKSYNC), [ChainId.WORLDCHAIN]: () => USDC_ON(ChainId.WORLDCHAIN), - [ChainId.ASTROCHAIN_SEPOLIA]: () => USDC_ON(ChainId.ASTROCHAIN_SEPOLIA), + [ChainId.UNICHAIN_SEPOLIA]: () => USDC_ON(ChainId.UNICHAIN_SEPOLIA), + [ChainId.UNICHAIN]: () => USDC_ON(ChainId.UNICHAIN), }; const TEST_ERC20_2: { [chainId in ChainId]: () => Token } = { [ChainId.MAINNET]: () => DAI_ON(1), @@ -3567,7 +3569,8 @@ describe('quote for other networks', () => { [ChainId.BLAST]: () => WNATIVE_ON(ChainId.BLAST), [ChainId.ZKSYNC]: () => WNATIVE_ON(ChainId.ZKSYNC), [ChainId.WORLDCHAIN]: () => WLD_WORLDCHAIN, - [ChainId.ASTROCHAIN_SEPOLIA]: () => WNATIVE_ON(ChainId.ASTROCHAIN_SEPOLIA), + [ChainId.UNICHAIN_SEPOLIA]: () => WNATIVE_ON(ChainId.UNICHAIN_SEPOLIA), + [ChainId.UNICHAIN]: () => WNATIVE_ON(ChainId.UNICHAIN), }; // TODO: Find valid pools/tokens on optimistic kovan and polygon mumbai. We skip those tests for now. @@ -3751,7 +3754,7 @@ describe('quote for other networks', () => { const tokenIn = wrappedNative; const tokenOut = erc1; - const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ? + const amount = chain === ChainId.UNICHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? parseAmount('0.001', tokenIn): parseAmount('0.001', tokenOut) : @@ -3818,7 +3821,7 @@ describe('quote for other networks', () => { // Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount const exactOutAmount = '1'; - const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ? + const amount = chain === ChainId.UNICHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? parseAmount('0.001', tokenIn): parseAmount('0.001', tokenOut) : @@ -3845,7 +3848,7 @@ describe('quote for other networks', () => { const native = NATIVE_CURRENCY[chain]; it(`${native} -> erc20`, async () => { - if (chain === ChainId.BLAST || chain === ChainId.ZORA || chain === ChainId.ZKSYNC || chain === ChainId.ASTROCHAIN_SEPOLIA) { + if (chain === ChainId.BLAST || chain === ChainId.ZORA || chain === ChainId.ZKSYNC || chain === ChainId.UNICHAIN_SEPOLIA) { // Blast doesn't have DAI or USDC yet // Zora doesn't have DAI // Zksync doesn't have liquid USDC/DAI pool yet @@ -3928,7 +3931,7 @@ describe('quote for other networks', () => { // Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount const exactOutAmount = '1'; - const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ? + const amount = chain === ChainId.UNICHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? parseAmount('0.001', tokenIn): parseAmount('0.001', tokenOut) : @@ -3974,7 +3977,7 @@ describe('quote for other networks', () => { // Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount const exactOutAmount = chain === ChainId.BLAST ? '0.002' : '1'; - const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ? + const amount = chain === ChainId.UNICHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? parseAmount('0.001', tokenIn): parseAmount('0.001', tokenOut) : @@ -4043,8 +4046,8 @@ describe('quote for other networks', () => { const tokenOut = erc1; const amount = tradeType == TradeType.EXACT_INPUT - ? parseAmount(chain === ChainId.ZORA || chain === ChainId.WORLDCHAIN || chain === ChainId.ASTROCHAIN_SEPOLIA ? '0.001' : '10', tokenIn) - : parseAmount(chain === ChainId.ASTROCHAIN_SEPOLIA ? '0.001' : '10', tokenOut); + ? parseAmount(chain === ChainId.ZORA || chain === ChainId.WORLDCHAIN || chain === ChainId.UNICHAIN_SEPOLIA ? '0.001' : '10', tokenIn) + : parseAmount(chain === ChainId.UNICHAIN_SEPOLIA ? '0.001' : '10', tokenOut); // Universal Router is not deployed on Gorli. const swapWithSimulationOptions: SwapOptions = @@ -4250,8 +4253,8 @@ describe('quote for other networks', () => { const tokenOut = erc2; const amount = tradeType === TradeType.EXACT_INPUT - ? parseAmount(chain === ChainId.ZORA || chain === ChainId.ASTROCHAIN_SEPOLIA ? '0.001' : '1', tokenIn) - : parseAmount(chain === ChainId.ZORA || chain === ChainId.ASTROCHAIN_SEPOLIA ? '0.001' : '1', tokenOut); + ? parseAmount(chain === ChainId.ZORA || chain === ChainId.UNICHAIN_SEPOLIA ? '0.001' : '1', tokenIn) + : parseAmount(chain === ChainId.ZORA || chain === ChainId.UNICHAIN_SEPOLIA ? '0.001' : '1', tokenOut); // Universal Router is not deployed on Gorli. const swapWithSimulationOptions: SwapOptions = @@ -4344,7 +4347,7 @@ describe('quote for other networks', () => { const native = NATIVE_CURRENCY[chain]; it(`${native} -> erc20`, async () => { - if (chain === ChainId.SEPOLIA || chain === ChainId.ASTROCHAIN_SEPOLIA) { + if (chain === ChainId.SEPOLIA || chain === ChainId.UNICHAIN_SEPOLIA) { // Sepolia doesn't have sufficient liquidity on DAI pools yet return; } diff --git a/test/test-util/whales.ts b/test/test-util/whales.ts index a0686d48d..cf367c9eb 100644 --- a/test/test-util/whales.ts +++ b/test/test-util/whales.ts @@ -15,7 +15,7 @@ import { USDC_NATIVE_BASE, USDC_NATIVE_OPTIMISM, USDC_NATIVE_POLYGON, - USDC_ON, + USDC_ON, USDC_UNICHAIN, USDC_WORLDCHAIN, USDC_ZORA, USDT_MAINNET, @@ -27,7 +27,7 @@ import { import { BULLET, BULLET_WITHOUT_TAX } from './mock-data'; export const WHALES = (token: Currency): string => { - let USDC_ASTROCHAIN_SEPOLIA; + let USDC_UNICHAIN_SEPOLIA; switch (token) { case Ether.onChain(ChainId.MAINNET) as Currency: return '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; @@ -109,7 +109,7 @@ export const WHALES = (token: Currency): string => { return '0xbC59f8F3b275AA56A90D13bAE7cCe5e6e11A3b17'; case USDC_NATIVE_BASE: return '0x20fe51a9229eef2cf8ad9e89d91cab9312cf3b7a'; - case USDC_ON(ChainId.ASTROCHAIN_SEPOLIA): + case USDC_ON(ChainId.UNICHAIN_SEPOLIA): return '0xca8cA8840c77589981E63f4D8122fFEc4b74e2a1'; case DAI_ON(ChainId.GOERLI): return '0x20918f71e99c09ae2ac3e33dbde33457d3be01f4'; @@ -145,12 +145,22 @@ export const WHALES = (token: Currency): string => { return '0x6348A4a4dF173F68eB28A452Ca6c13493e447aF1'; case WNATIVE_ON(ChainId.WORLDCHAIN): return '0x6348A4a4dF173F68eB28A452Ca6c13493e447aF1'; - case USDC_ASTROCHAIN_SEPOLIA: + case USDC_UNICHAIN_SEPOLIA: return '0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95'; - case nativeOnChain(ChainId.ASTROCHAIN_SEPOLIA): - return '0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95'; - case WNATIVE_ON(ChainId.ASTROCHAIN_SEPOLIA): + case nativeOnChain(ChainId.UNICHAIN_SEPOLIA): return '0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95'; + case WNATIVE_ON(ChainId.UNICHAIN_SEPOLIA): + return '0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95';// + case USDC_UNICHAIN: + // TODO: get a real whale address for unichain mainnet + return '0x440e9a5b9df01D7CFf465D391A883315A5e8f41c'; + case nativeOnChain(ChainId.UNICHAIN): + // TODO: get a real whale address for unichain mainnet + return '0x440e9a5b9df01D7CFf465D391A883315A5e8f41c'; + case WNATIVE_ON(ChainId.UNICHAIN): + // TODO: get a real whale address for unichain mainnet + return '0x440e9a5b9df01D7CFf465D391A883315A5e8f41c'; + default: return '0xf04a5cc80b1e94c69b48f5ee68a08cd2f09a7c3e'; } From ee0b78f812f793cb988393cb95367b1c1b58671b Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Thu, 21 Nov 2024 13:12:10 -0800 Subject: [PATCH 2/5] some unichain sepolia replacements --- .github/workflows/tests.yml | 2 +- src/util/addresses.ts | 2 +- .../integ/routers/alpha-router/alpha-router.integration.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7dd54c90..393dcd029 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -875,7 +875,7 @@ jobs: # This is to capture any new networks added into the integ-test suite - name: Run Integration tests - run: npm run integ-test -- -t 'quote for other networks * (?!(mainnet|optimism|arbitrum|polygon|sepolia|celo|bnb|avalanche|base|blast|zora|zksync|worldchain|astrochain-sepolia))' + run: npm run integ-test -- -t 'quote for other networks * (?!(mainnet|optimism|arbitrum|polygon|sepolia|celo|bnb|avalanche|base|blast|zora|zksync|worldchain|unichain-sepolia))' env: # We don't know which new networks will be added, so we have no way to provider RPC URL ahead of time # This will make remaining networks integ-test suite to fail, and dev is expected to manually add RPC URL for the new network diff --git a/src/util/addresses.ts b/src/util/addresses.ts index a24e80037..ead4e5940 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -99,7 +99,7 @@ export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { [ChainId.WORLDCHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.WORLDCHAIN].quoterAddress, // TODO: deploy view-only-quoter to worldchain [ChainId.UNICHAIN_SEPOLIA]: - CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].quoterAddress, // TODO: deploy view-only-quoter to astrochain + CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN_SEPOLIA].quoterAddress, // TODO: deploy view-only-quoter to unichain sepolia [ChainId.UNICHAIN]: CHAIN_TO_ADDRESSES_MAP[ChainId.UNICHAIN].quoterAddress, // TODO: deploy view-only-quoter to unichain }; 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 3bbb19493..d0232596c 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -3852,7 +3852,7 @@ describe('quote for other networks', () => { // Blast doesn't have DAI or USDC yet // Zora doesn't have DAI // Zksync doesn't have liquid USDC/DAI pool yet - // astrochain sepolia doesn't have liquid USDC/DAI pool yet + // unichain sepolia doesn't have liquid USDC/DAI pool yet return; } From 851c1c9375045b189eb979dabace7f47fd60b1f6 Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Mon, 25 Nov 2024 09:09:51 -0800 Subject: [PATCH 3/5] update universal-router-sdk version --- package-lock.json | 13 +++++++------ package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3aaa02bf8..c8cd96b66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@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": "file:/tmp/ur-sdk-001.tgz", + "@uniswap/universal-router-sdk": "4.7.0", "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-sdk": "^3.19.0", "@uniswap/v4-sdk": "^1.12.0", @@ -3344,9 +3344,9 @@ } }, "node_modules/@uniswap/universal-router-sdk": { - "resolved": "file:../../../../../tmp/ur-sdk-001.tgz", - "integrity": "sha512-YOljjERNiTE3HkK2wSPtm2rO23KXOhbWDs5aqI/LK1wgzSI0yD7cpH8kIgl1ObaNIyQS+HHKvBspH4LxzSME1g==", - "license": "MIT", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@uniswap/universal-router-sdk/-/universal-router-sdk-4.7.0.tgz", + "integrity": "sha512-auVZVRXUVxpvXcyPo7QWPprGB05KsYFVetM7s/ttlTcNNKwtVronGqdDMFZFIWjf7UM/sHbfSH08mhjogJKwgQ==", "dependencies": { "@openzeppelin/contracts": "4.7.0", "@uniswap/permit2-sdk": "^1.3.0", @@ -14409,8 +14409,9 @@ } }, "@uniswap/universal-router-sdk": { - "version": "file:/tmp/ur-sdk-001.tgz", - "integrity": "sha512-YOljjERNiTE3HkK2wSPtm2rO23KXOhbWDs5aqI/LK1wgzSI0yD7cpH8kIgl1ObaNIyQS+HHKvBspH4LxzSME1g==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@uniswap/universal-router-sdk/-/universal-router-sdk-4.7.0.tgz", + "integrity": "sha512-auVZVRXUVxpvXcyPo7QWPprGB05KsYFVetM7s/ttlTcNNKwtVronGqdDMFZFIWjf7UM/sHbfSH08mhjogJKwgQ==", "requires": { "@openzeppelin/contracts": "4.7.0", "@uniswap/permit2-sdk": "^1.3.0", diff --git a/package.json b/package.json index 0ded1592d..ba9ce3fd4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@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": "file:/tmp/ur-sdk-001.tgz", + "@uniswap/universal-router-sdk": "4.7.0", "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-sdk": "^3.19.0", "@uniswap/v4-sdk": "^1.12.0", From 412d49199cae7aa2612b3ffa3250484ba4c4dcc6 Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Mon, 25 Nov 2024 09:12:53 -0800 Subject: [PATCH 4/5] update universal-router-sdk version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8cd96b66..1d7f1289e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@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": "4.7.0", + "@uniswap/universal-router-sdk": "^4.7.0", "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-sdk": "^3.19.0", "@uniswap/v4-sdk": "^1.12.0", diff --git a/package.json b/package.json index ba9ce3fd4..b4911edbc 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@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": "4.7.0", + "@uniswap/universal-router-sdk": "^4.7.0", "@uniswap/v2-sdk": "^4.7.0", "@uniswap/v3-sdk": "^3.19.0", "@uniswap/v4-sdk": "^1.12.0", From 696ef90f1e3267f7279c2e09a3079b5e7ef99c98 Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Mon, 25 Nov 2024 09:22:31 -0800 Subject: [PATCH 5/5] remove debug logging --- src/providers/on-chain-quote-provider.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index b29ebe995..ebf5126ef 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -663,12 +663,6 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { _providerConfig?.blockNumber ?? originalBlockNumber + baseBlockOffset, }; - log.info(`routes length: ${routes.length}`); - log.info(`amounts length: ${amounts.length}`); - for (const amount of amounts) { - log.info(`amount: ${amount.quotient.toString()}`); - } - const inputs: QuoteInputType[] = _(routes) .flatMap((route) => { const encodedRoute = this.encodeRouteToPath(route, functionName); @@ -775,8 +769,6 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const expectedCallsMade = quoteStates.length; let totalCallsMade = 0; - log.info(`----> Tooooootal quoteStates: ${quoteStates.length}`); - const { results: quoteResults, blockNumber,