Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rootstock chain #516

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/providers/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,32 @@ export const USDB_BLAST = new Token(
'USD Blast'
)

// Rootstock Tokens
export const DAI_ROOTSTOCK = new Token(
ChainId.ROOTSTOCK,
'0x6B1a73d547F4009A26B8485b63D7015D248AD406',
18,
'rDAI',
'Dai Stablecoin on RSK'
);

export const USDT_ROOTSTOCK = new Token(
ChainId.ROOTSTOCK,
'0xEf213441a85DF4d7acBdAe0Cf78004E1e486BB96',
18,
'rUSDT',
'Tether USD on ROOTSTOCK'
);

export const USDC_ROOTSTOCK = new Token(
ChainId.ROOTSTOCK,
'0x1BDa44fda023F2af8280a16FD1b01D1A493BA6c4',
18,
'rUSDC',
'USDC on ROOTSTOCK'
);


export class TokenProvider implements ITokenProvider {
constructor(
private chainId: ChainId,
Expand Down Expand Up @@ -861,6 +887,8 @@ export const DAI_ON = (chainId: ChainId): Token => {
return DAI_BNB;
case ChainId.AVALANCHE:
return DAI_AVAX;
case ChainId.ROOTSTOCK:
return DAI_ROOTSTOCK;
default:
throw new Error(`Chain id: ${chainId} not supported`);
}
Expand All @@ -882,6 +910,8 @@ export const USDT_ON = (chainId: ChainId): Token => {
return USDT_ARBITRUM;
case ChainId.BNB:
return USDT_BNB;
case ChainId.ROOTSTOCK:
return USDT_ROOTSTOCK;
default:
throw new Error(`Chain id: ${chainId} not supported`);
}
Expand Down Expand Up @@ -923,6 +953,8 @@ export const USDC_ON = (chainId: ChainId): Token => {
return USDC_BASE;
case ChainId.BASE_GOERLI:
return USDC_BASE_GOERLI;
case ChainId.ROOTSTOCK:
return USDC_ROOTSTOCK;
default:
throw new Error(`Chain id: ${chainId} not supported`);
}
Expand Down
2 changes: 2 additions & 0 deletions src/providers/v3/subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const SUBGRAPH_URL_BY_CHAIN: { [chainId in ChainId]?: string } = {
'https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-minimal',
// todo: add once subgraph is live
[ChainId.ARBITRUM_SEPOLIA]: '',
// todo: add once subgraph is live
[ChainId.ROOTSTOCK]: '',
[ChainId.POLYGON]:
'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon',
[ChainId.CELO]:
Expand Down
25 changes: 25 additions & 0 deletions src/routers/alpha-router/alpha-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,31 @@ export class AlphaRouter
}
);
break;
case ChainId.ROOTSTOCK:
this.onChainQuoteProvider = new OnChainQuoteProvider(
chainId,
provider,
this.multicall2Provider,
{
retries: 2,
minTimeout: 100,
maxTimeout: 1000,
},
{
multicallChunk: 200,
gasLimitPerCall: 6_800_000,
quoteMinSuccessRate: 0.1,
},
{
gasLimitOverride: 7_800_000,
multicallChunk: 100,
},
{
gasLimitOverride: 7_800_000,
multicallChunk: 100,
}
);
break;
case ChainId.CELO:
case ChainId.CELO_ALFAJORES:
this.onChainQuoteProvider = new OnChainQuoteProvider(
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 @@ -8,6 +8,7 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (
switch (chainId) {
// Optimism
case ChainId.OPTIMISM:
case ChainId.ROOTSTOCK:
case ChainId.OPTIMISM_GOERLI:
case ChainId.OPTIMISM_SEPOLIA:
case ChainId.BASE:
Expand Down
9 changes: 9 additions & 0 deletions src/routers/alpha-router/functions/get-candidate-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
USDC_ARBITRUM_SEPOLIA,
USDC_OPTIMISM_SEPOLIA,
USDT_OPTIMISM_SEPOLIA,
USDT_ROOTSTOCK,
USDC_ROOTSTOCK,
DAI_ROOTSTOCK,
V2SubgraphPool,
WBTC_OPTIMISM_SEPOLIA
} from '../../../providers';
Expand Down Expand Up @@ -187,6 +190,12 @@ const baseTokensByChain: { [chainId in ChainId]?: Token[] } = {
[ChainId.AVALANCHE]: [DAI_AVAX, USDC_AVAX],
[ChainId.BASE]: [USDC_BASE],
[ChainId.BLAST]: [WRAPPED_NATIVE_CURRENCY[ChainId.BLAST]!, USDB_BLAST],
[ChainId.ROOTSTOCK]: [
WRAPPED_NATIVE_CURRENCY[ChainId.ROOTSTOCK]!,
USDT_ROOTSTOCK,
USDC_ROOTSTOCK,
DAI_ROOTSTOCK,
],
};

class SubcategorySelectionPools<SubgraphPool> {
Expand Down
8 changes: 8 additions & 0 deletions src/routers/alpha-router/gas-models/gas-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import {
USDC_OPTIMISM_GOERLI,
USDC_OPTIMISM_SEPOLIA,
USDC_POLYGON,
USDC_ROOTSTOCK,
USDT_ROOTSTOCK,
DAI_ROOTSTOCK,
USDC_SEPOLIA,
USDC_WORMHOLE_CELO,
USDT_ARBITRUM,
Expand Down Expand Up @@ -115,6 +118,11 @@ export const usdGasTokensByChain: { [chainId in ChainId]?: Token[] } = {
],
[ChainId.BASE]: [USDC_BASE, USDC_NATIVE_BASE],
[ChainId.BLAST]: [USDB_BLAST],
[ChainId.ROOTSTOCK]: [
USDC_ROOTSTOCK,
USDT_ROOTSTOCK,
DAI_ROOTSTOCK,
],
};

export type L1ToL2GasCosts = {
Expand Down
10 changes: 9 additions & 1 deletion src/routers/legacy-router/bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import {
USDT_MAINNET,
WBTC_MAINNET,
WMATIC_POLYGON,
USDC_ROOTSTOCK,
USDT_ROOTSTOCK,
DAI_ROOTSTOCK,
WMATIC_POLYGON_MUMBAI
} from '../../providers/token-provider';
import { WRAPPED_NATIVE_CURRENCY } from '../../util/chains';
Expand Down Expand Up @@ -74,7 +77,12 @@ export const BASES_TO_CHECK_TRADES_AGAINST = (
[ChainId.BASE_GOERLI]: [WRAPPED_NATIVE_CURRENCY[ChainId.BASE_GOERLI]!],
[ChainId.ZORA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA]!],
[ChainId.ZORA_SEPOLIA]: [WRAPPED_NATIVE_CURRENCY[ChainId.ZORA_SEPOLIA]!],
[ChainId.ROOTSTOCK]: [WRAPPED_NATIVE_CURRENCY[ChainId.ROOTSTOCK]!],
[ChainId.ROOTSTOCK]: [
WRAPPED_NATIVE_CURRENCY[ChainId.ROOTSTOCK]!,
USDC_ROOTSTOCK,
USDT_ROOTSTOCK,
DAI_ROOTSTOCK,
],
[ChainId.BLAST]: [WRAPPED_NATIVE_CURRENCY[ChainId.BLAST]!, USDB_BLAST],
};
};
Expand Down
3 changes: 3 additions & 0 deletions src/util/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = {
CHAIN_TO_ADDRESSES_MAP[ChainId.BASE_GOERLI].v3CoreFactoryAddress,
[ChainId.BASE]: CHAIN_TO_ADDRESSES_MAP[ChainId.BASE].v3CoreFactoryAddress,
[ChainId.BLAST]: CHAIN_TO_ADDRESSES_MAP[ChainId.BLAST].v3CoreFactoryAddress,
[ChainId.ROOTSTOCK]: CHAIN_TO_ADDRESSES_MAP[ChainId.ROOTSTOCK].v3CoreFactoryAddress,
// TODO: Gnosis + Moonbeam contracts to be deployed
};

Expand All @@ -57,6 +58,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = {
CHAIN_TO_ADDRESSES_MAP[ChainId.BASE_GOERLI].quoterAddress,
[ChainId.BASE]: CHAIN_TO_ADDRESSES_MAP[ChainId.BASE].quoterAddress,
[ChainId.BLAST]: CHAIN_TO_ADDRESSES_MAP[ChainId.BLAST].quoterAddress,
[ChainId.ROOTSTOCK]: CHAIN_TO_ADDRESSES_MAP[ChainId.ROOTSTOCK].quoterAddress,
// TODO: Gnosis + Moonbeam contracts to be deployed
};

Expand Down Expand Up @@ -88,6 +90,7 @@ export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = {
CHAIN_TO_ADDRESSES_MAP[ChainId.BASE_GOERLI].multicallAddress,
[ChainId.BASE]: CHAIN_TO_ADDRESSES_MAP[ChainId.BASE].multicallAddress,
[ChainId.BLAST]: CHAIN_TO_ADDRESSES_MAP[ChainId.BLAST].multicallAddress,
[ChainId.ROOTSTOCK]: CHAIN_TO_ADDRESSES_MAP[ChainId.ROOTSTOCK].multicallAddress,
// TODO: Gnosis + Moonbeam contracts to be deployed
};

Expand Down
15 changes: 15 additions & 0 deletions src/util/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const SUPPORTED_CHAINS: ChainId[] = [
ChainId.AVALANCHE,
ChainId.BASE,
ChainId.BLAST,
ChainId.ROOTSTOCK,
// Gnosis and Moonbeam don't yet have contracts deployed yet
];

Expand Down Expand Up @@ -102,6 +103,8 @@ export const ID_TO_CHAIN_ID = (id: number): ChainId => {
return ChainId.BASE_GOERLI;
case 81457:
return ChainId.BLAST;
case 30:
return ChainId.ROOTSTOCK;
default:
throw new Error(`Unknown chain id: ${id}`);
}
Expand All @@ -128,6 +131,7 @@ export enum ChainName {
BASE = 'base-mainnet',
BASE_GOERLI = 'base-goerli',
BLAST = 'blast-mainnet',
ROOTSTOCK = 'rootstock',
}

export enum NativeCurrencyName {
Expand All @@ -139,6 +143,7 @@ export enum NativeCurrencyName {
MOONBEAM = 'GLMR',
BNB = 'BNB',
AVALANCHE = 'AVAX',
ROOTSTOCK = 'RBTC',
}

export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = {
Expand Down Expand Up @@ -212,6 +217,11 @@ export const NATIVE_NAMES_BY_ID: { [chainId: number]: string[] } = {
'ETHER',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
[ChainId.ROOTSTOCK]: [
'RBTC',
'RBTC',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
],
};

export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = {
Expand All @@ -234,6 +244,7 @@ export const NATIVE_CURRENCY: { [chainId: number]: NativeCurrencyName } = {
[ChainId.AVALANCHE]: NativeCurrencyName.AVALANCHE,
[ChainId.BASE]: NativeCurrencyName.ETHER,
[ChainId.BLAST]: NativeCurrencyName.ETHER,
[ChainId.ROOTSTOCK]: NativeCurrencyName.ROOTSTOCK,
};

export const ID_TO_NETWORK_NAME = (id: number): ChainName => {
Expand Down Expand Up @@ -278,6 +289,8 @@ export const ID_TO_NETWORK_NAME = (id: number): ChainName => {
return ChainName.BASE_GOERLI;
case 81457:
return ChainName.BLAST;
case 30:
return ChainName.ROOTSTOCK;
default:
throw new Error(`Unknown chain id: ${id}`);
}
Expand Down Expand Up @@ -323,6 +336,8 @@ export const ID_TO_PROVIDER = (id: ChainId): string => {
return process.env.JSON_RPC_PROVIDER_BASE!;
case ChainId.BLAST:
return process.env.JSON_RPC_PROVIDER_BLAST!;
case ChainId.ROOTSTOCK:
return process.env.JSON_RPC_PROVIDER_ROOTSTOCK!;
default:
throw new Error(`Chain id: ${id} not supported`);
}
Expand Down
Loading