Skip to content

Commit

Permalink
add sepolia (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ra-phael authored Nov 16, 2023
1 parent 21eac30 commit 72d01fc
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ Value: 0x00
Total ticks crossed: 7
```

## Sepolia

```
./bin/cli quote --tokenIn 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14 --tokenOut 0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8 --amount 10 --exactOut --minSplits 1 --router alpha --chainId 11155111
```

## Rinkeby

```
Expand Down
11 changes: 11 additions & 0 deletions src/providers/caching-token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import {
DAI_POLYGON_MUMBAI,
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_SEPOLIA,
EUROC_MAINNET,
EURS_SEPOLIA,
ITokenProvider,
LINK_SEPOLIA,
LsETH_MAINNET,
TokenAccessor,
UNI_ARBITRUM_RINKEBY,
Expand All @@ -38,6 +41,7 @@ import {
USDC_OPTIMISM_GOERLI,
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_MAINNET,
Expand Down Expand Up @@ -68,6 +72,13 @@ export const CACHE_SEED_TOKENS: {
CBETH: cbETH_MAINNET,
LSETH: LsETH_MAINNET,
},
[ChainId.SEPOLIA]: {
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA]!,
USDC: USDC_SEPOLIA,
DAI: DAI_SEPOLIA,
LINK: LINK_SEPOLIA,
EURS: EURS_SEPOLIA,
},
[ChainId.RINKEBY]: {
WETH: WRAPPED_NATIVE_CURRENCY[ChainId.RINKEBY]!,
DAI_1: DAI_RINKEBY_1,
Expand Down
33 changes: 33 additions & 0 deletions src/providers/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ export const UNI_MAINNET = new Token(
'Uniswap'
);


export const USDC_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8',
18,
'USDC',
'USDC Token'
);
export const DAI_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357',
18,
'DAI',
'DAI Token'
);
export const EURS_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0x6d906e526a4e2Ca02097BA9d0caA3c382F52278E',
18,
'EURS',
'STASIS EURS Token'
);
export const LINK_SEPOLIA = new Token(
ChainId.SEPOLIA,
'0xf8Fb3713D459D7C1018BD0A49D19b4C44290EBE5',
18,
'LINK',
'Chainlink Token'
);
export const USDC_ROPSTEN = new Token(
ChainId.ROPSTEN,
'0x07865c6e87b9f70255377e024ace6630c1eaa37f',
Expand Down Expand Up @@ -704,6 +733,8 @@ export const DAI_ON = (chainId: ChainId): Token => {
switch (chainId) {
case ChainId.MAINNET:
return DAI_MAINNET;
case ChainId.SEPOLIA:
return DAI_SEPOLIA;
case ChainId.ROPSTEN:
return DAI_ROPSTEN;
case ChainId.RINKEBY:
Expand Down Expand Up @@ -772,6 +803,8 @@ export const USDC_ON = (chainId: ChainId): Token => {
return USDC_MAINNET;
case ChainId.ROPSTEN:
return USDC_ROPSTEN;
case ChainId.SEPOLIA:
return USDC_SEPOLIA;
case ChainId.RINKEBY:
return USDC_RINKEBY;
case ChainId.GOERLI:
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.GOERLI]: [WRAPPED_NATIVE_CURRENCY[ChainId.GOERLI]!],
[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
7 changes: 7 additions & 0 deletions src/providers/v3/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_ROPSTEN,
DAI_SEPOLIA,
UNI_ARBITRUM_RINKEBY,
USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI,
Expand All @@ -43,6 +44,7 @@ import {
USDC_POLYGON,
USDC_RINKEBY,
USDC_ROPSTEN,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_GOERLI,
Expand Down Expand Up @@ -103,6 +105,11 @@ const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
WBTC_GOERLI,
DAI_GOERLI,
],
[ChainId.SEPOLIA]: [
WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA]!,
USDC_SEPOLIA,
DAI_SEPOLIA,
],
[ChainId.KOVAN]: [
WRAPPED_NATIVE_CURRENCY[ChainId.KOVAN]!,
USDC_KOVAN,
Expand Down
3 changes: 3 additions & 0 deletions src/routers/alpha-router/functions/get-candidate-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DAI_POLYGON_MUMBAI,
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_SEPOLIA,
FEI_MAINNET,
ITokenProvider,
USDC_ARBITRUM,
Expand All @@ -32,6 +33,7 @@ import {
USDC_OPTIMISM_GOERLI,
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_MAINNET,
Expand Down Expand Up @@ -132,6 +134,7 @@ const baseTokensByChain: { [chainId in ChainId]?: Token[] } = {
FEI_MAINNET,
],
[ChainId.RINKEBY]: [DAI_RINKEBY_1, DAI_RINKEBY_2],
[ChainId.SEPOLIA]: [USDC_SEPOLIA, DAI_SEPOLIA],
[ChainId.OPTIMISM]: [
DAI_OPTIMISM,
USDC_OPTIMISM,
Expand Down
3 changes: 3 additions & 0 deletions src/routers/alpha-router/gas-models/gas-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
DAI_RINKEBY_1,
DAI_RINKEBY_2,
DAI_ROPSTEN,
DAI_SEPOLIA,
USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI,
USDC_ETHEREUM_GNOSIS,
Expand All @@ -27,6 +28,7 @@ import {
USDC_OPTIMISTIC_KOVAN,
USDC_POLYGON,
USDC_ROPSTEN,
USDC_SEPOLIA,
USDT_ARBITRUM,
USDT_ARBITRUM_RINKEBY,
USDT_GOERLI,
Expand Down Expand Up @@ -73,6 +75,7 @@ export const usdGasTokensByChain: { [chainId in ChainId]?: Token[] } = {
[ChainId.KOVAN]: [DAI_KOVAN, USDC_KOVAN, USDT_KOVAN],
[ChainId.GOERLI]: [DAI_GOERLI, USDC_GOERLI, USDT_GOERLI, WBTC_GOERLI],
[ChainId.ROPSTEN]: [DAI_ROPSTEN, USDC_ROPSTEN, USDT_ROPSTEN],
[ChainId.SEPOLIA]: [DAI_SEPOLIA, USDC_SEPOLIA],
[ChainId.POLYGON]: [USDC_POLYGON],
[ChainId.POLYGON_MUMBAI]: [DAI_POLYGON_MUMBAI],
[ChainId.CELO]: [CUSD_CELO],
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.GOERLI:
case ChainId.SEPOLIA:
case ChainId.OPTIMISM:
case ChainId.OPTIMISM_GOERLI:
case ChainId.OPTIMISTIC_KOVAN:
Expand Down Expand Up @@ -42,6 +43,7 @@ export const COST_PER_INIT_TICK = (id: ChainId): BigNumber => {
case ChainId.ROPSTEN:
case ChainId.RINKEBY:
case ChainId.GOERLI:
case ChainId.SEPOLIA:
case ChainId.KOVAN:
return BigNumber.from(31000);
case ChainId.OPTIMISM:
Expand Down Expand Up @@ -71,6 +73,7 @@ export const COST_PER_HOP = (id: ChainId): BigNumber => {
case ChainId.ROPSTEN:
case ChainId.RINKEBY:
case ChainId.GOERLI:
case ChainId.SEPOLIA:
case ChainId.OPTIMISM:
case ChainId.OPTIMISM_GOERLI:
case ChainId.OPTIMISTIC_KOVAN:
Expand Down
19 changes: 19 additions & 0 deletions src/util/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const MAINNET_QUOTER_V2 = '0x8443289e5dd694eFA46440B52C7Fe4b828E668D6';
const MAINNET_MAUVE_MULTICALL_ADDRESS =
'0xDB98e266D090b1A6538d56459CbEE0fE0f38d879';

// SEPOLIA Deployment
const SEPOLIA_FACTORY_ADDRESS =
'0x1a0917A5d4ca70D9982D0988a0DEA3373d162F6d';
const SEPOLIA_QUOTER = '0x398Ac7008037CA54526Ce6e8c0Cd4E8808B09D91';
const SEPOLIA_QUOTER_V2 = '0x90f1e4d85e19883CA8f01F380c9F584581b19260';
const SEPOLIA_MAUVE_MULTICALL_ADDRESS =
'0x29e2C6276A59C8dD8631Bc49cf16E685d43fA221';

export const V3_CORE_FACTORY_ADDRESSES: AddressMap = {
...constructSameAddressMap(MAINNET_FACTORY_ADDRESS),
// [ChainId.CELO]: CELO_V3_CORE_FACTORY_ADDRESSES,
Expand All @@ -34,6 +42,7 @@ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = {
[ChainId.MAINNET]: MAINNET_FACTORY_ADDRESS,
[ChainId.GOERLI]: GOERLI_FACTORY_ADDRESS,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_FACTORY_ADDRESS,
[ChainId.SEPOLIA]: SEPOLIA_FACTORY_ADDRESS,
};

export const QUOTER_V2_ADDRESSES: AddressMap = {
Expand All @@ -47,6 +56,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = {
[ChainId.MAINNET]: MAINNET_QUOTER_V2,
[ChainId.GOERLI]: GOERLI_QUOTER_V2,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_QUOTER_V2,
[ChainId.SEPOLIA]: SEPOLIA_QUOTER_V2,
};

export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = {
Expand All @@ -56,6 +66,7 @@ export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = {
// // override GOERLI
[ChainId.GOERLI]: GOERLI_QUOTER,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_QUOTER,
[ChainId.SEPOLIA]: SEPOLIA_QUOTER,
};

export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = {
Expand All @@ -67,6 +78,7 @@ export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = {
// TODO: Gnosis + Moonbeam contracts to be deployed
[ChainId.MAINNET]: MAINNET_MAUVE_MULTICALL_ADDRESS,
[ChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_MAUVE_MULTICALL_ADDRESS,
[ChainId.SEPOLIA]: SEPOLIA_MAUVE_MULTICALL_ADDRESS,
};

export const OVM_GASPRICE_ADDRESS =
Expand Down Expand Up @@ -120,6 +132,13 @@ export const WETH9: {
'WETH',
'Wrapped Ether'
),
[ChainId.SEPOLIA]: new Token(
ChainId.SEPOLIA,
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
18,
'WETH',
'Wrapped Ether'
),
[ChainId.RINKEBY]: new Token(
ChainId.RINKEBY,
'0xc778417E063141139Fce010982780140Aa0cD5Ab',
Expand Down
22 changes: 22 additions & 0 deletions src/util/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum ChainId {
RINKEBY = 4,
GOERLI = 5,
KOVAN = 42,
SEPOLIA = 11155111,
OPTIMISM = 10,
OPTIMISTIC_KOVAN = 69,
OPTIMISM_GOERLI = 420,
Expand All @@ -28,6 +29,7 @@ export enum ChainId {
// WIP: Gnosis, Moonbeam
export const SUPPORTED_CHAINS: ChainId[] = [
ChainId.MAINNET,
ChainId.SEPOLIA,
// ChainId.RINKEBY,
// ChainId.ROPSTEN,
// ChainId.KOVAN,
Expand Down Expand Up @@ -84,6 +86,8 @@ export const ID_TO_CHAIN_ID = (id: number): ChainId => {
return ChainId.RINKEBY;
case 5:
return ChainId.GOERLI;
case 11155111:
return ChainId.SEPOLIA;
case 42:
return ChainId.KOVAN;
case 10:
Expand Down Expand Up @@ -121,6 +125,7 @@ export enum ChainName {
RINKEBY = 'rinkeby',
GOERLI = 'goerli',
KOVAN = 'kovan',
SEPOLIA = 'sepolia',
OPTIMISM = 'optimism-mainnet',
OPTIMISM_GOERLI = 'optimism-goerli',
OPTIMISTIC_KOVAN = 'optimism-kovan',
Expand Down Expand Up @@ -169,6 +174,11 @@ export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = {
'ETHER',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
[ChainId.SEPOLIA]: [
'ETH',
'ETHER',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
[ChainId.OPTIMISM]: [
'ETH',
'ETHER',
Expand Down Expand Up @@ -216,6 +226,7 @@ export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = {
[ChainId.RINKEBY]: NativeCurrencyName.ETHER,
[ChainId.GOERLI]: NativeCurrencyName.ETHER,
[ChainId.KOVAN]: NativeCurrencyName.ETHER,
[ChainId.SEPOLIA]: NativeCurrencyName.ETHER,
[ChainId.OPTIMISM]: NativeCurrencyName.ETHER,
[ChainId.OPTIMISM_GOERLI]: NativeCurrencyName.ETHER,
[ChainId.OPTIMISTIC_KOVAN]: NativeCurrencyName.ETHER,
Expand All @@ -242,6 +253,8 @@ export const ID_TO_NETWORK_NAME = (id: number): ChainName => {
return ChainName.GOERLI;
case 42:
return ChainName.KOVAN;
case 11155111:
return ChainName.SEPOLIA;
case 10:
return ChainName.OPTIMISM;
case 420:
Expand Down Expand Up @@ -285,6 +298,8 @@ export const ID_TO_PROVIDER = (id: ChainId): string => {
return process.env.JSON_RPC_PROVIDER_GORLI!;
case ChainId.KOVAN:
return process.env.JSON_RPC_PROVIDER_KOVAN!;
case ChainId.SEPOLIA:
return process.env.JSON_RPC_PROVIDER_SEPOLIA!;
case ChainId.OPTIMISM:
return process.env.JSON_RPC_PROVIDER_OPTIMISM!;
case ChainId.OPTIMISM_GOERLI:
Expand Down Expand Up @@ -318,6 +333,13 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId in ChainId]: Token } = {
'WETH',
'Wrapped Ether'
),
[ChainId.SEPOLIA]: new Token(
11155111,
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
18,
'WETH',
'Wrapped Ether'
),
[ChainId.ROPSTEN]: new Token(
3,
'0xc778417E063141139Fce010982780140Aa0cD5Ab',
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 @@ -53,6 +53,8 @@ export const WHALES = (token: Currency): string => {
return '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503';
case USDC_ON(ChainId.ROPSTEN):
return '0x366d1dd8558b59398439a01fb6935f6f40ebcd60';
case USDC_ON(ChainId.SEPOLIA):
return '0x33FaabBe19057C30d1405Fd8d16039255ff7EEf4';
case USDC_ON(ChainId.RINKEBY):
return '0x65671d573fc0e62139fbde470bfd03a38b4d5f26';
case UNI_GOERLI:
Expand All @@ -77,6 +79,8 @@ export const WHALES = (token: Currency): string => {
return '0x48520ff9b32d8b5bf87abf789ea7b3c394c95ebe';
case DAI_ON(ChainId.ROPSTEN):
return '0x922b992698381c7dc8d23684e2caef396b0b73a4';
case DAI_ON(ChainId.SEPOLIA):
return '0x33FaabBe19057C30d1405Fd8d16039255ff7EEf4';
case DAI_ON(ChainId.RINKEBY):
return '0xcea4e535d03086dbaa04c71675129654e92cc055';
case DAI_ON(ChainId.GOERLI):
Expand Down

0 comments on commit 72d01fc

Please sign in to comment.