Skip to content

Commit

Permalink
feat: [wip] add sepolia (Uniswap#237)
Browse files Browse the repository at this point in the history
* init

* add some files

* add sepolia log to readme

* change to uniswap deployed weth addresses

* fix failing test

* remove based on eric comment

* change dai token and readme test command for sepolia

---------

Co-authored-by: Miguel Cervera <[email protected]>
  • Loading branch information
lynnshaoyu and mikeki authored May 31, 2023
1 parent e68cdf9 commit a57a926
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ Total ticks crossed: 7
./bin/cli quote --tokenIn 0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea --tokenOut 0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b --amount 200000 --exactIn --minSplits 1 --router alpha --chainId 4
```

## Sepolia

```
./bin/cli quote --tokenIn 0x7AF17A48a6336F7dc1beF9D485139f7B6f4FB5C8 --tokenOut 0x6f14C02Fc1F78322cFd7d707aB90f18baD3B54f5 --amount 10 --exactIn --minSplits 1 --router alpha --chainId 11155111
```

## Kovan

```
Expand Down
4 changes: 4 additions & 0 deletions src/providers/caching-token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
USDC_OPTIMISM_GOERLI,
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_BSC,
Expand Down Expand Up @@ -83,6 +84,9 @@ export const CACHE_SEED_TOKENS: {
DAI_1: DAI_RINKEBY_1,
DAI_2: DAI_RINKEBY_2,
},
[ChainId.SEPOLIA]: {
USDC: USDC_SEPOLIA,
},
[ChainId.OPTIMISM]: {
USDC: USDC_OPTIMISM,
USDT: USDT_OPTIMISM,
Expand Down
19 changes: 18 additions & 1 deletion src/providers/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,20 @@ export const USDT_RINKEBY = new Token(
'USDT',
'Tether USD'
);

export const USDC_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0x6f14C02Fc1F78322cFd7d707aB90f18baD3B54f5',
18,
'USDC',
'USDC Token'
);
export const DAI_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0x7AF17A48a6336F7dc1beF9D485139f7B6f4FB5C8',
18,
'DAI',
'DAI Token'
);
export const USDC_GÖRLI = new Token(
ChainId.GÖRLI,
'0x07865c6e87b9f70255377e024ace6630c1eaa37f',
Expand Down Expand Up @@ -790,6 +803,8 @@ export const DAI_ON = (chainId: ChainId): Token => {
return DAI_RINKEBY_1;
case ChainId.GÖRLI:
return DAI_GÖRLI;
case ChainId.SEPOLIA:
return DAI_SEPOLIA;
case ChainId.KOVAN:
return DAI_KOVAN;
case ChainId.OPTIMISM:
Expand Down Expand Up @@ -860,6 +875,8 @@ export const USDC_ON = (chainId: ChainId): Token => {
return USDC_RINKEBY;
case ChainId.GÖRLI:
return USDC_GÖRLI;
case ChainId.SEPOLIA:
return USDC_SEPOLIA;
case ChainId.KOVAN:
return USDC_KOVAN;
case ChainId.OPTIMISM:
Expand Down
1 change: 1 addition & 0 deletions src/providers/v2/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
DAI_RINKEBY_2,
],
[ChainId.GÖRLI]: [WRAPPED_NATIVE_CURRENCY[ChainId.GÖRLI]!],
[ChainId.SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA]!],
[ChainId.KOVAN]: [WRAPPED_NATIVE_CURRENCY[ChainId.KOVAN]!],
//v2 not deployed on [optimism, arbitrum, polygon, celo, gnosis, moonbeam] and their testnets
[ChainId.OPTIMISM]: [],
Expand Down
5 changes: 5 additions & 0 deletions src/providers/v3/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
USDC_POLYGON,
USDC_RINKEBY,
USDC_ROPSTEN,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_BSC,
Expand Down Expand Up @@ -111,6 +112,10 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
WBTC_GÖRLI,
DAI_GÖRLI,
],
[ChainId.SEPOLIA]: [
WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA]!,
USDC_SEPOLIA,
],
[ChainId.KOVAN]: [
WRAPPED_NATIVE_CURRENCY[ChainId.KOVAN]!,
USDC_KOVAN,
Expand Down
6 changes: 6 additions & 0 deletions src/routers/alpha-router/functions/get-candidate-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DAI_POLYGON_MUMBAI,
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_SEPOLIA,
FEI_MAINNET,
ITokenProvider,
USDC_ARBITRUM,
Expand All @@ -34,6 +35,7 @@ import {
USDC_OPTIMISM_GOERLI,
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_BSC,
Expand Down Expand Up @@ -135,6 +137,10 @@ const baseTokensByChain: { [chainId in ChainId]?: Token[] } = {
USDT_OPTIMISM,
WBTC_OPTIMISM,
],
[ChainId.SEPOLIA]: [
DAI_SEPOLIA,
USDC_SEPOLIA,
],
[ChainId.OPTIMISM_GOERLI]: [
DAI_OPTIMISM_GOERLI,
USDC_OPTIMISM_GOERLI,
Expand Down
9 changes: 4 additions & 5 deletions src/routers/alpha-router/gas-models/gas-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_ROPSTEN,
DAI_SEPOLIA,
USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI,
USDC_BSC,
Expand All @@ -30,6 +31,7 @@ import {
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_ROPSTEN,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_BSC,
Expand All @@ -43,11 +45,7 @@ import {
WBTC_GÖRLI,
} from '../../../providers/token-provider';
import { IV2PoolProvider } from '../../../providers/v2/pool-provider';
import {
ArbitrumGasData,
IL2GasDataProvider,
OptimismGasData,
} from '../../../providers/v3/gas-data-provider';
import { ArbitrumGasData, IL2GasDataProvider, OptimismGasData, } from '../../../providers/v3/gas-data-provider';
import { IV3PoolProvider } from '../../../providers/v3/pool-provider';
import { CurrencyAmount } from '../../../util/amounts';
import { ChainId } from '../../../util/chains';
Expand Down Expand Up @@ -77,6 +75,7 @@ export const usdGasTokensByChain: { [chainId in ChainId]?: Token[] } = {
[ChainId.ARBITRUM_GOERLI]: [USDC_ARBITRUM_GOERLI],
[ChainId.KOVAN]: [DAI_KOVAN, USDC_KOVAN, USDT_KOVAN],
[ChainId.GÖRLI]: [DAI_GÖRLI, USDC_GÖRLI, USDT_GÖRLI, WBTC_GÖRLI],
[ChainId.SEPOLIA]: [USDC_SEPOLIA, DAI_SEPOLIA],
[ChainId.ROPSTEN]: [DAI_ROPSTEN, USDC_ROPSTEN, USDT_ROPSTEN],
[ChainId.POLYGON]: [USDC_POLYGON],
[ChainId.POLYGON_MUMBAI]: [DAI_POLYGON_MUMBAI],
Expand Down
3 changes: 3 additions & 0 deletions src/routers/alpha-router/gas-models/v3/gas-costs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const BASE_SWAP_COST = (id: ChainId): BigNumber => {
case ChainId.ROPSTEN:
case ChainId.RINKEBY:
case ChainId.GÖRLI:
case ChainId.SEPOLIA:
case ChainId.OPTIMISM:
case ChainId.OPTIMISM_GOERLI:
case ChainId.OPTIMISTIC_KOVAN:
Expand Down Expand Up @@ -43,6 +44,7 @@ export const COST_PER_INIT_TICK = (id: ChainId): BigNumber => {
case ChainId.ROPSTEN:
case ChainId.RINKEBY:
case ChainId.GÖRLI:
case ChainId.SEPOLIA:
case ChainId.BSC:
case ChainId.KOVAN:
return BigNumber.from(31000);
Expand Down Expand Up @@ -73,6 +75,7 @@ export const COST_PER_HOP = (id: ChainId): BigNumber => {
case ChainId.ROPSTEN:
case ChainId.RINKEBY:
case ChainId.GÖRLI:
case ChainId.SEPOLIA:
case ChainId.KOVAN:
case ChainId.BSC:
case ChainId.OPTIMISM:
Expand Down
1 change: 1 addition & 0 deletions src/routers/legacy-router/bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const BASES_TO_CHECK_TRADES_AGAINST = (
[ChainId.ROPSTEN]: [WRAPPED_NATIVE_CURRENCY[ChainId.ROPSTEN]!],
[ChainId.RINKEBY]: [WRAPPED_NATIVE_CURRENCY[ChainId.RINKEBY]!],
[ChainId.GÖRLI]: [WRAPPED_NATIVE_CURRENCY[ChainId.GÖRLI]!],
[ChainId.SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA]!],
[ChainId.KOVAN]: [WRAPPED_NATIVE_CURRENCY[ChainId.KOVAN]!],
[ChainId.OPTIMISM]: [WRAPPED_NATIVE_CURRENCY[ChainId.OPTIMISM]!],
[ChainId.OPTIMISM_GOERLI]: [
Expand Down
14 changes: 14 additions & 0 deletions src/util/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const OPTIMISM_GOERLI_QUOTER_ADDRESSES =
const OPTIMISM_GOERLI_MULTICALL_ADDRESS =
'0x07F2D8a2a02251B62af965f22fC4744A5f96BCCd';

const SEPOLIA_V3_CORE_FACTORY_ADDRESSES = '0x0227628f3F023bb0B980b67D528571c95c6DaC1c'
const SEPOLIA_QUOTER_ADDRESSES = '0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3'
const SEPOLIA_MULTICALL_ADDRESS = '0xD7F33bCdb21b359c8ee6F0251d30E94832baAd07'

const BSC_V3_CORE_FACTORY_ADDRESSES =
'0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7';
const BSC_QUOTER_ADDRESSES = '0x78D78E420Da98ad378D7799bE8f4AF69033EB077';
Expand All @@ -41,6 +45,7 @@ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = {
[ChainId.CELO]: CELO_V3_CORE_FACTORY_ADDRESSES,
[ChainId.CELO_ALFAJORES]: CELO_V3_CORE_FACTORY_ADDRESSES,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_V3_CORE_FACTORY_ADDRESSES,
[ChainId.SEPOLIA]: SEPOLIA_V3_CORE_FACTORY_ADDRESSES,
[ChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_V3_CORE_FACTORY_ADDRESSES,
[ChainId.BSC]: BSC_V3_CORE_FACTORY_ADDRESSES,
// TODO: Gnosis + Moonbeam contracts to be deployed
Expand All @@ -51,6 +56,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = {
[ChainId.CELO]: CELO_QUOTER_ADDRESSES,
[ChainId.CELO_ALFAJORES]: CELO_QUOTER_ADDRESSES,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_QUOTER_ADDRESSES,
[ChainId.SEPOLIA]: SEPOLIA_QUOTER_ADDRESSES,
[ChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_QUOTER_ADDRESSES,
[ChainId.BSC]: BSC_QUOTER_ADDRESSES,
// TODO: Gnosis + Moonbeam contracts to be deployed
Expand All @@ -68,6 +74,7 @@ export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = {
[ChainId.CELO]: CELO_MULTICALL_ADDRESS,
[ChainId.CELO_ALFAJORES]: CELO_MULTICALL_ADDRESS,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_MULTICALL_ADDRESS,
[ChainId.SEPOLIA]: SEPOLIA_MULTICALL_ADDRESS,
[ChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_MULTICALL_ADDRESS,
[ChainId.BSC]: BSC_MULTICALL_ADDRESS,
// TODO: Gnosis + Moonbeam contracts to be deployed
Expand Down Expand Up @@ -145,6 +152,13 @@ export const WETH9: {
'WETH',
'Wrapped Ether'
),
[ChainId.SEPOLIA]: new Token(
ChainId.SEPOLIA,
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
18,
'WETH',
'Wrapped Ether'
),
[ChainId.KOVAN]: new Token(
ChainId.KOVAN,
'0xd0A1E359811322d97991E03f863a0C30C2cF029C',
Expand Down
23 changes: 23 additions & 0 deletions src/util/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ChainId {
ROPSTEN = 3,
RINKEBY = 4,
GÖRLI = 5,
SEPOLIA = 11155111,
KOVAN = 42,
OPTIMISM = 10,
OPTIMISM_GOERLI = 420,
Expand Down Expand Up @@ -37,6 +38,7 @@ export const SUPPORTED_CHAINS: ChainId[] = [
ChainId.POLYGON,
ChainId.POLYGON_MUMBAI,
ChainId.GÖRLI,
ChainId.SEPOLIA,
ChainId.CELO_ALFAJORES,
ChainId.CELO,
ChainId.BSC,
Expand All @@ -47,6 +49,7 @@ export const V2_SUPPORTED = [
ChainId.MAINNET,
ChainId.KOVAN,
ChainId.GÖRLI,
ChainId.SEPOLIA,
ChainId.RINKEBY,
ChainId.ROPSTEN,
];
Expand Down Expand Up @@ -84,6 +87,8 @@ export const ID_TO_CHAIN_ID = (id: number): ChainId => {
return ChainId.RINKEBY;
case 5:
return ChainId.GÖRLI;
case 11155111:
return ChainId.SEPOLIA;
case 42:
return ChainId.KOVAN;
case 56:
Expand Down Expand Up @@ -122,6 +127,7 @@ export enum ChainName {
ROPSTEN = 'ropsten',
RINKEBY = 'rinkeby',
GÖRLI = 'goerli',
SEPOLIA = 'sepolia',
KOVAN = 'kovan',
OPTIMISM = 'optimism-mainnet',
OPTIMISM_GOERLI = 'optimism-goerli',
Expand Down Expand Up @@ -164,6 +170,11 @@ export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = {
'ETHER',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
[ChainId.SEPOLIA]: [
'ETH',
'ETHER',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
[ChainId.KOVAN]: [
'ETH',
'ETHER',
Expand Down Expand Up @@ -227,6 +238,7 @@ export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = {
[ChainId.ROPSTEN]: NativeCurrencyName.ETHER,
[ChainId.RINKEBY]: NativeCurrencyName.ETHER,
[ChainId.GÖRLI]: NativeCurrencyName.ETHER,
[ChainId.SEPOLIA]: NativeCurrencyName.ETHER,
[ChainId.KOVAN]: NativeCurrencyName.ETHER,
[ChainId.OPTIMISM]: NativeCurrencyName.ETHER,
[ChainId.OPTIMISM_GOERLI]: NativeCurrencyName.ETHER,
Expand All @@ -253,6 +265,8 @@ export const ID_TO_NETWORK_NAME = (id: number): ChainName => {
return ChainName.RINKEBY;
case 5:
return ChainName.GÖRLI;
case 11155111:
return ChainName.SEPOLIA;
case 42:
return ChainName.KOVAN;
case 56:
Expand Down Expand Up @@ -300,6 +314,8 @@ export const ID_TO_PROVIDER = (id: ChainId): string => {
return process.env.JSON_RPC_PROVIDER_RINKEBY!;
case ChainId.GÖRLI:
return process.env.JSON_RPC_PROVIDER_GORLI!;
case ChainId.SEPOLIA:
return process.env.JSON_RPC_PROVIDER_SEPOLIA!;
case ChainId.KOVAN:
return process.env.JSON_RPC_PROVIDER_KOVAN!;
case ChainId.OPTIMISM:
Expand Down Expand Up @@ -358,6 +374,13 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId in ChainId]: Token } = {
'WETH',
'Wrapped Ether'
),
[ChainId.SEPOLIA]: new Token(
11155111,
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
18,
'WETH',
'Wrapped Ether'
),
[ChainId.KOVAN]: new Token(
42,
'0xd0A1E359811322d97991E03f863a0C30C2cF029C',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,7 @@ describe('quote for other networks', () => {
[ChainId.ROPSTEN]: USDC_ON(ChainId.ROPSTEN),
[ChainId.RINKEBY]: USDC_ON(ChainId.RINKEBY),
[ChainId.GÖRLI]: UNI_GÖRLI,
[ChainId.SEPOLIA]: USDC_ON(ChainId.SEPOLIA),
[ChainId.KOVAN]: USDC_ON(ChainId.KOVAN),
[ChainId.OPTIMISM]: USDC_ON(ChainId.OPTIMISM),
[ChainId.OPTIMISM_GOERLI]: USDC_ON(ChainId.OPTIMISM_GOERLI),
Expand All @@ -2569,6 +2570,7 @@ describe('quote for other networks', () => {
[ChainId.ROPSTEN]: DAI_ON(ChainId.ROPSTEN),
[ChainId.RINKEBY]: DAI_ON(ChainId.RINKEBY),
[ChainId.GÖRLI]: DAI_ON(ChainId.GÖRLI),
[ChainId.SEPOLIA]: DAI_ON(ChainId.SEPOLIA),
[ChainId.KOVAN]: DAI_ON(ChainId.KOVAN),
[ChainId.OPTIMISM]: DAI_ON(ChainId.OPTIMISM),
[ChainId.OPTIMISM_GOERLI]: DAI_ON(ChainId.OPTIMISM_GOERLI),
Expand Down Expand Up @@ -2599,7 +2601,8 @@ describe('quote for other networks', () => {
c != ChainId.ARBITRUM_GOERLI &&
c != ChainId.OPTIMISM && /// @dev infura has been having issues with optimism lately
// Tests are failing https://github.com/Uniswap/smart-order-router/issues/104
c != ChainId.CELO_ALFAJORES
c != ChainId.CELO_ALFAJORES &&
c != ChainId.SEPOLIA
)) {
for (const tradeType of [TradeType.EXACT_INPUT, TradeType.EXACT_OUTPUT]) {
const erc1 = TEST_ERC20_1[chain];
Expand Down
4 changes: 4 additions & 0 deletions test/test-util/whales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const WHALES = (token: Currency): string => {
return '0xa2aad83466241232290bebcd43dcbff6a7f8d23a';
case USDC_ON(ChainId.ARBITRUM_GOERLI):
return '0x7e3114fcbc1d529fd96de61d65d4a03071609c56';
case USDC_ON(ChainId.SEPOLIA):
return '0xe2a3422f3168149AD2d11b4dE2B97b05f1ebF76e';
case USDC_ON(ChainId.POLYGON):
return '0xe7804c37c13166ff0b37f5ae0bb07a3aebb6e245';
case USDC_ON(ChainId.POLYGON_MUMBAI):
Expand All @@ -81,6 +83,8 @@ export const WHALES = (token: Currency): string => {
return '0xcea4e535d03086dbaa04c71675129654e92cc055';
case DAI_ON(ChainId.GÖRLI):
return '0x20918f71e99c09ae2ac3e33dbde33457d3be01f4';
case DAI_ON(ChainId.SEPOLIA):
return '0x67550Df3290415611F6C140c81Cd770Ff1742cb9';
case DAI_ON(ChainId.KOVAN):
return '0x9b332466798a7e98bff1107d0846c195a99c1fc5';
case DAI_ON(ChainId.OPTIMISM):
Expand Down

0 comments on commit a57a926

Please sign in to comment.