Skip to content

Commit

Permalink
feat: support routing on worldchain and astrochain (#733)
Browse files Browse the repository at this point in the history
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
feature

- **What is the current behavior?** (You can also link to an open issue here)
no routing on worldchain and astrochain

- **What is the new behavior (if this is a feature change)?**
support routing on worldchain and astrochain

- **Other information**:
  • Loading branch information
jsy1218 authored Oct 2, 2024
1 parent 5891a8c commit 89f603c
Show file tree
Hide file tree
Showing 22 changed files with 347 additions and 71 deletions.
44 changes: 43 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,48 @@ jobs:
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
TENDERLY_NODE_API_KEY: ${{ secrets.TENDERLY_NODE_API_KEY }}

integration-tests-quote-for-other-networks-worldchain:
name: Integration Tests - Quote For Other Networks WorldChain
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 * worldchain'
env:
JSON_RPC_PROVIDER_WORLDCHAIN: ${{ secrets.JSON_RPC_PROVIDER_WORLDCHAIN }}
TENDERLY_BASE_URL: ${{ secrets.TENDERLY_BASE_URL }}
TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}

- name: Run Integration tests
run: npm run integ-test -- -t 'quote for other networks * astrochain-sepolia'
env:
JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA: ${{ secrets.JSON_RPC_PROVIDER_ASTROCHAIN_SEPOLIA }}
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-remaining-networks:
name: Integration Tests - Quote For Other Networks Remaining Networks
runs-on: ubuntu-latest
Expand Down Expand Up @@ -774,7 +816,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))'
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))'
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
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ Total ticks crossed: 7
./bin/cli quote --tokenIn 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91 --tokenOut 0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4 --amount 10 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 324
```

## WorldChain Mainnet

```
./bin/cli quote --tokenIn 0x4200000000000000000000000000000000000006 --tokenOut 0x79A02482A880bCE3F13e09Da970dC34db4CD24d1 --amount 0.1 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 480
```

## AstroChain Sepolia

```
./bin/cli quote --tokenIn 0x4200000000000000000000000000000000000006 --tokenOut 0x31d0220469e10c4E71834a79b1f276d740d3768F --amount 0.1 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 1301
```

## Adding a new Chain

Expand Down
106 changes: 53 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
"@types/brotli": "^1.3.4",
"@uniswap/default-token-list": "^11.13.0",
"@uniswap/permit2-sdk": "^1.3.0",
"@uniswap/router-sdk": "^1.12.1",
"@uniswap/sdk-core": "^5.4.0",
"@uniswap/router-sdk": "^1.14.0",
"@uniswap/sdk-core": "^5.8.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": "^3.1.2",
"@uniswap/v2-sdk": "^4.3.2",
"@uniswap/v3-sdk": "^3.13.0",
"@uniswap/universal-router-sdk": "^3.3.0",
"@uniswap/v2-sdk": "^4.6.0",
"@uniswap/v3-sdk": "^3.17.0",
"@uniswap/v4-sdk": "^1.6.3",
"async-retry": "^1.3.1",
"await-timeout": "^1.1.1",
Expand Down
14 changes: 14 additions & 0 deletions src/providers/caching-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
USDB_BLAST,
USDCE_ZKSYNC,
USDC_ARBITRUM,
USDC_ASTROCHAIN_SEPOLIA,
USDC_AVAX,
USDC_BASE,
USDC_BNB,
Expand All @@ -33,6 +34,7 @@ import {
USDC_NATIVE_ARBITRUM,
USDC_OPTIMISM,
USDC_POLYGON,
USDC_WORLDCHAIN,
USDC_ZKSYNC,
USDT_ARBITRUM,
USDT_BNB,
Expand All @@ -42,7 +44,9 @@ import {
WBTC_MAINNET,
WBTC_MOONBEAM,
WBTC_OPTIMISM,
WBTC_WORLDCHAIN,
WETH_POLYGON,
WLD_WORLDCHAIN,
WMATIC_POLYGON,
WSTETH_MAINNET,
} from './token-provider';
Expand Down Expand Up @@ -121,6 +125,16 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
USDCE_ZKSYNC,
USDC_ZKSYNC,
],
[ChainId.WORLDCHAIN]: [
WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN]!,
USDC_WORLDCHAIN,
WLD_WORLDCHAIN,
WBTC_WORLDCHAIN,
],
[ChainId.ASTROCHAIN_SEPOLIA]: [
WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA]!,
USDC_ASTROCHAIN_SEPOLIA,
],
};

export interface IV3SubgraphProvider {
Expand Down
13 changes: 13 additions & 0 deletions src/providers/caching-token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
USDC_OPTIMISM_SEPOLIA,
USDC_POLYGON,
USDC_SEPOLIA,
USDC_WORLDCHAIN,
USDT_ARBITRUM,
USDT_BNB,
USDT_MAINNET,
Expand All @@ -54,6 +55,8 @@ import {
WBTC_OPTIMISM,
WBTC_OPTIMISM_GOERLI,
WBTC_OPTIMISM_SEPOLIA,
WBTC_WORLDCHAIN,
WLD_WORLDCHAIN,
WMATIC_POLYGON,
WMATIC_POLYGON_MUMBAI,
} from './token-provider';
Expand Down Expand Up @@ -171,6 +174,16 @@ export const CACHE_SEED_TOKENS: {
[ChainId.ZKSYNC]: {
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.ZKSYNC],
},
[ChainId.WORLDCHAIN]: {
USDC: USDC_WORLDCHAIN,
WLD: WLD_WORLDCHAIN,
WBTC: WBTC_WORLDCHAIN,
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.WORLDCHAIN],
},
[ChainId.ASTROCHAIN_SEPOLIA]: {
USDC: USDC_SEPOLIA,
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.ASTROCHAIN_SEPOLIA],
},
// Currently we do not have providers for Moonbeam mainnet or Gnosis testnet
};

Expand Down
1 change: 1 addition & 0 deletions src/providers/tenderly-simulation-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export const TENDERLY_NOT_SUPPORTED_CHAINS = [
ChainId.CELO,
ChainId.CELO_ALFAJORES,
ChainId.ZKSYNC,
ChainId.ASTROCHAIN_SEPOLIA,
];

// We multiply tenderly gas limit by this to overestimate gas limit
Expand Down
Loading

0 comments on commit 89f603c

Please sign in to comment.