Skip to content

Commit

Permalink
Add Rootstock
Browse files Browse the repository at this point in the history
  • Loading branch information
MirthFutures committed Sep 29, 2024
1 parent 7846868 commit 9101f94
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/address-book/src/address-book/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { mode } from './mode/index.js';
import { manta } from './manta/index.js';
import { real } from './real/index.js';
import { sei } from './sei/index.js';
import { rootstock } from './rootstock/index.js';

export { ChainId }; // enum which is compiled to a JS object
export type { Chain };
Expand Down Expand Up @@ -67,6 +68,7 @@ export const addressBook: ReadonlyRecord<ChainIdKey, Chain> = {
manta,
real,
sei,
rootstock,
} as const;

export const addressBookByChainId: ReadonlyRecord<`${ChainId}`, Chain> = {
Expand Down Expand Up @@ -100,4 +102,5 @@ export const addressBookByChainId: ReadonlyRecord<`${ChainId}`, Chain> = {
[ChainId.manta]: manta,
[ChainId.real]: real,
[ChainId.sei]: sei,
[ChainId.rootstock]: rootstock,
} as const;
10 changes: 10 additions & 0 deletions packages/address-book/src/address-book/rootstock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Chain } from '../../types/chain.js';
import { convertSymbolTokenMapToAddressTokenMap } from '../../util/convertSymbolTokenMapToAddressTokenMap.js';
import * as platforms from './platforms/index.js';
import { tokens } from './tokens/tokens.js';

export const rootstock = {
platforms,
tokens,
tokenAddressMap: convertSymbolTokenMapToAddressTokenMap(tokens),
} as const satisfies Chain;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const devMultisig = '0xB7775ce77ea0dE48699ee5fce86DbD32aAb3B741';
const treasuryMultisig = '0x2052e5744d1dC4D095e758120779E0f5a660f655';

export const beefyfinance = {
devMultisig: devMultisig,
treasuryMultisig: treasuryMultisig,
strategyOwner: '0x09D19184F46A32213DF06b981122e06882B61309',
vaultOwner: '0xf2EeC1baC39306C0761c816d1D33cF7C9Ad6C0Fe',
keeper: '0x4fED5491693007f0CD49f4614FFC38Ab6A04B619',
treasurer: treasuryMultisig,
launchpoolOwner: devMultisig,
rewardPool: '0x0000000000000000000000000000000000000000',
treasury: treasuryMultisig,
beefyFeeRecipient: '0x02Ae4716B9D5d48Db1445814b0eDE39f5c28264B',
multicall: '0x3B60F7f25b09E71356cdFFC6475c222A466a2AC9',
bifiMaxiStrategy: '0x0000000000000000000000000000000000000000',
voter: '0x5e1caC103F943Cd84A1E92dAde4145664ebf692A',
beefyFeeConfig: '0xfc69704cC3cAac545cC7577009Ea4AA04F1a61Eb',
vaultFactory: '0xe103ab2f922aa1a56EC058AbfDA2CeEa1e95bCd7',
//zap: '0x6f66F246Bb436B6f4E66A992C2218b57cD906109',
//zapTokenManager: '0xD3D46FF34cD495d5B91b8F3C5C552E81E5e3eab5',
/*
/// CLM Contracts
clmFactory: '0xD19ab62F83380908D65E344567378cF104cE46c2',
clmStrategyFactory: '0xaF0f1B33Ef5A61b88F84BA2Ed2388f2C69fEaB55',
clmRewardPoolFactory: '0x3C0b1765C379833b86A1704997019A7496Afdfae',*/

/// Beefy Swapper Contracts
beefySwapper: '0x3C0b1765C379833b86A1704997019A7496Afdfae',
beefyOracle: '0x70127945067E4224d7B6ABfDc6f57e3ea45d5CA4',
beefyOracleUniswapV3: '0xA5Cd8A60a05571141370D184e255777e5c2d5968',
} as const;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { beefyfinance } from './beefyfinance.js';
21 changes: 21 additions & 0 deletions packages/address-book/src/address-book/rootstock/tokens/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Token } from '../../../types/token.js';

const RBTC = {
name: 'Wrapped Rootstock BTC',
address: '0x542fDA317318eBF1d3DEAf76E0b632741A7e677d',
symbol: 'WRBTC',
oracleId: 'WRBTC',
decimals: 18,
chainId: 30,
website: 'https://rootstock.io/rbtc/',
description: 'RBTC, the smart version of Bitcoin.Allowing BTC owners to interact with DeFi protocols and dApps on Rootstock network for minting, swaps, gas fees and more.',
bridge: 'rootstock-canonical',
logoURI: '',
documentation: 'https://dev.rootstock.io/concepts/rbtc/?_gl=1*jp93v6*_gcl_au*ODQ3NTgwNDM3LjE3MjcyNjIwNDI.',
} as const satisfies Token;

export const tokens = {
RBTC,
WRBTC: RBTC,
WNATIVE: RBTC,
} as const satisfies Record<string, Token>;
1 change: 1 addition & 0 deletions packages/address-book/src/types/chainid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum ChainId {
manta = 169,
real = 111188,
sei = 1329,
rootstock = 30,
}

type ChainIdType = typeof ChainId;
Expand Down
1 change: 1 addition & 0 deletions packages/address-book/src/util/chainIdMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const chainIdMap = {
manta: 169,
real: 111188,
sei: 1329,
rootstock: 30,
} satisfies ChainIdMap;

// back-compat
Expand Down
25 changes: 25 additions & 0 deletions src/api/rpc/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MANTA_RPC,
REAL_RPC,
SEI_RPC,
ROOTSTOCK_RPC,
} from '../../constants';
import { ChainId } from '../../../packages/address-book/src/address-book';

Expand Down Expand Up @@ -764,6 +765,29 @@ const seiChain = {
},
} as const satisfies Chain;

const rootstockChain = {
id: 30,
name: 'Rootstock',
network: 'rootstock',
nativeCurrency: {
decimals: 18,
name: 'WRBTC',
symbol: 'WRBTC',
},
rpcUrls: {
public: { http: [ROOTSTOCK_RPC] },
default: { http: [ROOTSTOCK_RPC] },
},
blockExplorers: {
default: { name: 'rootstock explorer', url: 'https://rootstock.blockscout.com/' },
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
},
},
} as const satisfies Chain;

//build a map from chainId to chain object
export const getChain: Partial<Record<ChainId, Chain>> = {
[ChainId.avax]: avalancheChain,
Expand Down Expand Up @@ -796,4 +820,5 @@ export const getChain: Partial<Record<ChainId, Chain>> = {
[ChainId.manta]: mantaChain,
[ChainId.real]: realChain,
[ChainId.sei]: seiChain,
[ChainId.rootstock]: rootstockChain,
} as const;
1 change: 1 addition & 0 deletions src/api/rpc/rpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ const rpcs: Record<ChainId, string[]> = {
[ChainId.manta]: ['https://manta-pacific.drpc.org'],
[ChainId.real]: ['https://real.drpc.org'],
[ChainId.sei]: ['https://evm-rpc.sei-apis.com'],
[ChainId.rootstock]: ['https://public-node.rsk.co'],
};

export const getChainRpcs = (chainId: ChainId): string[] => rpcs[chainId] ?? [];
1 change: 1 addition & 0 deletions src/api/zap/swap/blocked-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,5 @@ export const blockedTokensByChain: Record<ApiChain, Set<string>> = {
manta: new Set([]),
real: new Set([]),
sei: new Set([]),
rootstock: new Set([]),
};
10 changes: 9 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const MODE_RPC = process.env.MODE_RPC || 'https://mode.drpc.org';
const MANTA_RPC = process.env.MANTA_RPC || 'https://manta-pacific.drpc.org';
const REAL_RPC = process.env.REAL_RPC || 'https://real.drpc.org';
const SEI_RPC = process.env.SEI_RPC || 'https://evm-rpc.sei-apis.com';
const ROOTSTOCK_RPC = process.env.ROOTSTOCK_RPC || 'https://public-node.rsk.co';

const BSC_CHAIN_ID = ChainId.bsc;
const HECO_CHAIN_ID = ChainId.heco;
Expand Down Expand Up @@ -95,7 +96,7 @@ const MODE_CHAIN_ID = ChainId.mode;
const MANTA_CHAIN_ID = ChainId.manta;
const REAL_CHAIN_ID = ChainId.real;
const SEI_CHAIN_ID = ChainId.sei;

const ROOTSTOCK_CHAIN_ID = ChainId.rootstock;
const SUSHI_LPF = 0.003;
const PCS_LPF = 0.0017;
const SPOOKY_LPF = 0.002;
Expand Down Expand Up @@ -140,6 +141,7 @@ const MULTICHAIN_RPC: Record<ChainId, string> = {
[ChainId.manta]: MANTA_RPC,
[ChainId.real]: REAL_RPC,
[ChainId.sei]: SEI_RPC,
[ChainId.rootstock]: ROOTSTOCK_RPC,
};

const BSC_VAULTS_ENDPOINT =
Expand Down Expand Up @@ -202,6 +204,8 @@ const REAL_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/real.json';
const SEI_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/sei.json';
const ROOTSTOCK_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/rootstock.json';

const MULTICHAIN_ENDPOINTS: Partial<Record<ApiChain, string>> = {
bsc: BSC_VAULTS_ENDPOINT,
Expand Down Expand Up @@ -234,6 +238,7 @@ const MULTICHAIN_ENDPOINTS: Partial<Record<ApiChain, string>> = {
manta: MANTA_VAULTS_ENDPOINT,
real: REAL_VAULTS_ENDPOINT,
sei: SEI_VAULTS_ENDPOINT,
// rootstock: ROOTSTOCK_VAULTS_ENDPOINT,
} as const;

const EXCLUDED_IDS_FROM_TVL = ['venus-wbnb'];
Expand Down Expand Up @@ -331,6 +336,9 @@ export {
SEI_RPC,
SEI_CHAIN_ID,
SEI_VAULTS_ENDPOINT,
ROOTSTOCK_RPC,
ROOTSTOCK_CHAIN_ID,
ROOTSTOCK_VAULTS_ENDPOINT,
BASE_HPY,
MINUTELY_HPY,
HOURLY_HPY,
Expand Down
9 changes: 8 additions & 1 deletion src/utils/ethersHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import {
REAL_CHAIN_ID,
SEI_RPC,
SEI_CHAIN_ID,
ROOTSTOCK_RPC,
ROOTSTOCK_CHAIN_ID,
} from '../constants';

console.log(addressBookByChainId[ChainId.fantom].platforms.beefyfinance.multicall);
Expand Down Expand Up @@ -97,6 +99,7 @@ const MULTICALLS: Record<ChainId, Pick<BeefyFinance, 'multicall'>['multicall']>
[ChainId.manta]: addressBookByChainId[ChainId.manta].platforms.beefyfinance.multicall,
[ChainId.real]: addressBookByChainId[ChainId.real].platforms.beefyfinance.multicall,
[ChainId.sei]: addressBookByChainId[ChainId.sei].platforms.beefyfinance.multicall,
[ChainId.rootstock]: addressBookByChainId[ChainId.rootstock].platforms.beefyfinance.multicall,
};

const clients: Record<keyof typeof ChainId, ethers.providers.JsonRpcProvider[]> = {
Expand Down Expand Up @@ -130,6 +133,7 @@ const clients: Record<keyof typeof ChainId, ethers.providers.JsonRpcProvider[]>
manta: [],
real: [],
sei: [],
rootstock: [],
};
BSC_RPC_ENDPOINTS.forEach(endpoint => {
clients.bsc.push(new ethers.providers.JsonRpcProvider(endpoint));
Expand Down Expand Up @@ -163,7 +167,7 @@ clients.mode.push(new ethers.providers.JsonRpcProvider(MODE_RPC));
clients.manta.push(new ethers.providers.JsonRpcProvider(MANTA_RPC));
clients.real.push(new ethers.providers.JsonRpcProvider(REAL_RPC));
clients.sei.push(new ethers.providers.JsonRpcProvider(SEI_RPC));

clients.rootstock.push(new ethers.providers.JsonRpcProvider(ROOTSTOCK_RPC));
export const chainRandomClients = {
bscRandomClient: () => clients.bsc[~~(clients.bsc.length * Math.random())],
hecoRandomClient: () => clients.heco[~~(clients.heco.length * Math.random())],
Expand Down Expand Up @@ -195,6 +199,7 @@ export const chainRandomClients = {
mantaRandomClient: () => clients.manta[~~(clients.manta.length * Math.random())],
realRandomClient: () => clients.real[~~(clients.real.length * Math.random())],
seiRandomClient: () => clients.sei[~~(clients.sei.length * Math.random())],
rootstockRandomClient: () => clients.rootstock[~~(clients.rootstock.length * Math.random())],
};

export const _ethersFactory = (chainId: ChainId) => {
Expand Down Expand Up @@ -259,6 +264,8 @@ export const _ethersFactory = (chainId: ChainId) => {
return chainRandomClients.realRandomClient();
case SEI_CHAIN_ID:
return chainRandomClients.seiRandomClient();
case ROOTSTOCK_CHAIN_ID:
return chainRandomClients.rootstockRandomClient();
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/utils/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ module.exports = {
get seiWeb3() {
return chainRandomClients.seiRandomClient();
},
get rootstockWeb3() {
return chainRandomClients.rootstockRandomClient();
},

web3Factory: _web3Factory,

Expand Down
10 changes: 9 additions & 1 deletion src/utils/web3Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ import {
REAL_CHAIN_ID,
SEI_RPC,
SEI_CHAIN_ID,
ROOTSTOCK_RPC,
ROOTSTOCK_CHAIN_ID,
} from '../constants';
import { real } from '../../packages/address-book/src/address-book/real';

Expand Down Expand Up @@ -98,6 +100,7 @@ const MULTICALLS: Record<ChainId, Pick<BeefyFinance, 'multicall'>['multicall']>
[ChainId.manta]: addressBookByChainId[ChainId.manta].platforms.beefyfinance.multicall,
[ChainId.real]: addressBookByChainId[ChainId.real].platforms.beefyfinance.multicall,
[ChainId.sei]: addressBookByChainId[ChainId.sei].platforms.beefyfinance.multicall,
[ChainId.rootstock]: addressBookByChainId[ChainId.rootstock].platforms.beefyfinance.multicall,
};

export const MULTICALL_V3: Partial<Readonly<Record<ChainId, string>>> = {
Expand Down Expand Up @@ -131,6 +134,7 @@ export const MULTICALL_V3: Partial<Readonly<Record<ChainId, string>>> = {
[ChainId.manta]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.real]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.sei]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.rootstock]: '0xcA11bde05977b3631167028862bE2a173976CA11',
};

const clients: Record<keyof typeof ChainId, Web3[]> = {
Expand Down Expand Up @@ -164,6 +168,7 @@ const clients: Record<keyof typeof ChainId, Web3[]> = {
manta: [],
real: [],
sei: [],
rootstock: [],
};
BSC_RPC_ENDPOINTS.forEach(endpoint => {
clients.bsc.push(new Web3(endpoint));
Expand Down Expand Up @@ -197,7 +202,7 @@ clients.mode.push(new Web3(MODE_RPC));
clients.manta.push(new Web3(MANTA_RPC));
clients.real.push(new Web3(REAL_RPC));
clients.sei.push(new Web3(SEI_RPC));

clients.rootstock.push(new Web3(ROOTSTOCK_RPC));
export const chainRandomClients = {
bscRandomClient: () => clients.bsc[~~(clients.bsc.length * Math.random())],
hecoRandomClient: () => clients.heco[~~(clients.heco.length * Math.random())],
Expand Down Expand Up @@ -229,6 +234,7 @@ export const chainRandomClients = {
mantaRandomClient: () => clients.manta[~~(clients.manta.length * Math.random())],
realRandomClient: () => clients.real[~~(clients.real.length * Math.random())],
seiRandomClient: () => clients.sei[~~(clients.sei.length * Math.random())],
rootstockRandomClient: () => clients.rootstock[~~(clients.rootstock.length * Math.random())],
};

export const _web3Factory = (chainId: ChainId) => {
Expand Down Expand Up @@ -293,6 +299,8 @@ export const _web3Factory = (chainId: ChainId) => {
return chainRandomClients.realRandomClient();
case SEI_CHAIN_ID:
return chainRandomClients.seiRandomClient();
case ROOTSTOCK_CHAIN_ID:
return chainRandomClients.rootstockRandomClient();
}
};

Expand Down

0 comments on commit 9101f94

Please sign in to comment.