Skip to content

Commit

Permalink
feat: support blast (Uniswap#511)
Browse files Browse the repository at this point in the history
* bump sdk versions

* add blast new chain sor process

* fix remaining compiling error

* fix integ-test compiling error

* fix missing gas deviation in integ-test

* add blast integ-test

* add blast into integ-test

* add blast into github workflow

* fix base token ordering and blast env var

* fix import for USDB_BLAST

* skip blast tenderly simulation integ-test

* fix exact out low weth amount and github test for remaining setup

* style

* blast subgraph v3
  • Loading branch information
jsy1218 authored Mar 12, 2024
1 parent d46da1a commit 1fb8f53
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 78 deletions.
36 changes: 35 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,40 @@ jobs:
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}

integration-tests-quote-for-other-networks-blast:
name: Integration Tests - Quote For Other Networks Blast
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 * blast'
env:
JSON_RPC_PROVIDER_BLAST: ${{ secrets.JSON_RPC_PROVIDER_BLAST }}
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 @@ -684,7 +718,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|goerli|sepolia|celo|bnb|avalanche|base))'
run: npm run integ-test -- -t 'quote for other networks * (?!(mainnet|optimism|arbitrum|polygon|goerli|sepolia|celo|bnb|avalanche|base|blast))'
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
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 @@ -34,14 +34,14 @@
"@types/brotli": "^1.3.4",
"@uniswap/default-token-list": "^11.13.0",
"@uniswap/permit2-sdk": "^1.2.0",
"@uniswap/router-sdk": "^1.8.0",
"@uniswap/sdk-core": "^4.1.3",
"@uniswap/router-sdk": "^1.9.0",
"@uniswap/sdk-core": "^4.2.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": "^1.7.1",
"@uniswap/v2-sdk": "^4.2.1",
"@uniswap/v3-sdk": "^3.10.2",
"@uniswap/universal-router-sdk": "^1.8.1",
"@uniswap/v2-sdk": "^4.3.0",
"@uniswap/v3-sdk": "^3.11.0",
"async-retry": "^1.3.1",
"await-timeout": "^1.1.1",
"axios": "^0.21.1",
Expand Down
7 changes: 6 additions & 1 deletion src/providers/caching-token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ETH_BNB,
ITokenProvider,
TokenAccessor,
USDB_BLAST,
USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI,
USDC_ARBITRUM_SEPOLIA,
Expand Down Expand Up @@ -54,7 +55,7 @@ import {
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.
Expand Down Expand Up @@ -160,6 +161,10 @@ export const CACHE_SEED_TOKENS: {
USDC: USDC_BASE,
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.BASE],
},
[ChainId.BLAST]: {
USDB: USDB_BLAST,
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.BLAST],
},
// Currently we do not have providers for Moonbeam mainnet or Gnosis testnet
};

Expand Down
9 changes: 9 additions & 0 deletions src/providers/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,15 @@ export const WBTC_MOONBEAM = new Token(
'Wrapped BTC bridged using Multichain'
);

// Blast Tokens
export const USDB_BLAST = new Token(
ChainId.BLAST,
'0x4300000000000000000000000000000000000003',
18,
'USDB',
'USD Blast'
)

export class TokenProvider implements ITokenProvider {
constructor(
private chainId: ChainId,
Expand Down
8 changes: 6 additions & 2 deletions src/providers/v2/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
DAI_MOONBEAM,
DAI_OPTIMISM,
ETH_BNB,
OP_OPTIMISM,
OP_OPTIMISM, USDB_BLAST,
USDC_ARBITRUM,
USDC_AVAX,
USDC_BASE,
Expand All @@ -38,7 +38,7 @@ import {
WBTC_MOONBEAM,
WBTC_OPTIMISM,
WETH_POLYGON,
WMATIC_POLYGON,
WMATIC_POLYGON
} from '../token-provider';

import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider';
Expand Down Expand Up @@ -106,6 +106,10 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
],
[ChainId.BASE_GOERLI]: [],
[ChainId.BASE]: [WRAPPED_NATIVE_CURRENCY[ChainId.BASE], USDC_BASE],
[ChainId.ZORA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA]!],
[ChainId.ZORA_SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA_SEPOLIA]!],
[ChainId.ROOTSTOCK]: [WRAPPED_NATIVE_CURRENCY[ChainId.ROOTSTOCK]!],
[ChainId.BLAST]: [WRAPPED_NATIVE_CURRENCY[ChainId.BLAST]!, USDB_BLAST],
};

/**
Expand Down
7 changes: 6 additions & 1 deletion src/providers/v3/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
DAI_POLYGON_MUMBAI,
ETH_BNB,
OP_OPTIMISM,
USDB_BLAST,
USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI,
USDC_AVAX,
Expand Down Expand Up @@ -60,7 +61,7 @@ import {
WETH_POLYGON,
WMATIC_POLYGON,
WMATIC_POLYGON_MUMBAI,
WXDAI_GNOSIS,
WXDAI_GNOSIS
} from '../token-provider';

import { IV3PoolProvider } from './pool-provider';
Expand Down Expand Up @@ -161,6 +162,10 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
],
[ChainId.BASE_GOERLI]: [WRAPPED_NATIVE_CURRENCY[ChainId.BASE_GOERLI]],
[ChainId.BASE]: [WRAPPED_NATIVE_CURRENCY[ChainId.BASE], USDC_BASE],
[ChainId.ZORA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA]!],
[ChainId.ZORA_SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA_SEPOLIA]!],
[ChainId.ROOTSTOCK]: [WRAPPED_NATIVE_CURRENCY[ChainId.ROOTSTOCK]!],
[ChainId.BLAST]: [WRAPPED_NATIVE_CURRENCY[ChainId.BLAST]!, USDB_BLAST],
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/providers/v3/subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const SUBGRAPH_URL_BY_CHAIN: { [chainId in ChainId]?: string } = {
'https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax',
[ChainId.BASE]:
'https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest',
[ChainId.BLAST]: 'https://gateway-arbitrum.network.thegraph.com/api/0ae45f0bf40ae2e73119b44ccd755967/subgraphs/id/2LHovKznvo8YmKC9ZprPjsYAZDCc4K5q4AYz8s3cnQn1',
};

const PAGE_SIZE = 1000; // 1k is max possible query size from subgraph.
Expand Down
1 change: 1 addition & 0 deletions src/routers/alpha-router/alpha-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ export class AlphaRouter
);
break;
case ChainId.BASE:
case ChainId.BLAST:
case ChainId.BASE_GOERLI:
this.onChainQuoteProvider = new OnChainQuoteProvider(
chainId,
Expand Down
1 change: 1 addition & 0 deletions src/routers/alpha-router/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (
case ChainId.OPTIMISM_SEPOLIA:
case ChainId.BASE:
case ChainId.BASE_GOERLI:
case ChainId.BLAST:
return {
v2PoolSelection: {
topN: 3,
Expand Down
Loading

0 comments on commit 1fb8f53

Please sign in to comment.