BridgeConfig.ts
1 import { ChainId } from '@aave/contract-helpers'; 2 import { 3 AaveV3Arbitrum, 4 AaveV3ArbitrumSepolia, 5 AaveV3Base, 6 AaveV3BaseSepolia, 7 AaveV3Ethereum, 8 AaveV3Sepolia, 9 GhoArbitrum, 10 GhoBase, 11 GhoEthereum, 12 } from '@bgd-labs/aave-address-book'; 13 import { constants } from 'ethers'; 14 import { TokenInfoWithBalance } from 'src/hooks/generic/useTokensBalance'; 15 import { BaseNetworkConfig, networkConfigs } from 'src/ui-config/networksConfig'; 16 import { ENABLE_TESTNET } from 'src/utils/marketsAndNetworksConfig'; 17 18 export const bridgeGasLimit = '252000'; 19 20 type Config = { 21 sourceChainId: ChainId; 22 router: string; 23 chainSelector: string; 24 subgraphUrl: string; 25 tokenOracle: string; // Used to get the GHO price 26 wrappedNativeOracle: string; // Used to get the fee price in USD 27 lockReleaseTokenPool?: string; // Only exists on Ethereum 28 burnMintTokenPool?: string; // Only exists on non-Ethereum networks 29 feeTokens: TokenInfoWithBalance[]; 30 }; 31 32 export enum MessageExecutionState { 33 UNTOUCHED = 0, 34 IN_PROGRESS, 35 SUCCESS, 36 FAILURE, 37 } 38 39 export interface SupportedNetworkWithChainId extends BaseNetworkConfig { 40 chainId: number; 41 } 42 43 const prodConfig: Config[] = [ 44 { 45 sourceChainId: ChainId.mainnet, 46 chainSelector: '5009297550715157269', 47 lockReleaseTokenPool: GhoEthereum.GHO_CCIP_TOKEN_POOL, 48 router: '0x80226fc0ee2b096224eeac085bb9a8cba1146f7d', 49 tokenOracle: '0x3f12643d3f6f874d39c2a4c9f2cd6f2dbac877fc', // CL Feed 50 wrappedNativeOracle: AaveV3Ethereum.ASSETS.WETH.ORACLE, 51 subgraphUrl: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/E11p8T4Ff1DHZbwSUC527hkUb5innVMdTuP6A2s1xtm1`, 52 feeTokens: [ 53 { 54 name: 'Gho Token', 55 address: AaveV3Ethereum.ASSETS.GHO.UNDERLYING, 56 symbol: 'GHO', 57 decimals: 18, 58 chainId: ChainId.mainnet, 59 logoURI: 60 'https://assets.coingecko.com/coins/images/30663/standard/gho-token-logo.png?1720517092', 61 oracle: AaveV3Ethereum.ASSETS.GHO.ORACLE, 62 extensions: { 63 isNative: false, 64 }, 65 balance: '0', 66 }, 67 { 68 name: 'Ethereum', 69 symbol: 'ETH', 70 decimals: 18, 71 address: constants.AddressZero, // Use zero address for network token ccip 72 chainId: ChainId.mainnet, 73 logoURI: 74 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 75 extensions: { 76 isNative: true, 77 }, 78 balance: '0', 79 }, 80 ], 81 }, 82 { 83 sourceChainId: ChainId.arbitrum_one, 84 chainSelector: '4949039107694359620', 85 burnMintTokenPool: GhoArbitrum.GHO_CCIP_TOKEN_POOL, 86 router: '0x141fa059441e0ca23ce184b6a78bafd2a517dde8', 87 tokenOracle: AaveV3Arbitrum.ASSETS.GHO.ORACLE, 88 wrappedNativeOracle: AaveV3Arbitrum.ASSETS.WETH.ORACLE, 89 subgraphUrl: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/GPpZfiGoDChLsiWoMG5fxXdRNEYrsVDrKJ39moGcbz6i`, 90 feeTokens: [ 91 { 92 name: 'Gho Token', 93 address: AaveV3Arbitrum.ASSETS.GHO.UNDERLYING, 94 symbol: 'GHO', 95 decimals: 18, 96 chainId: ChainId.arbitrum_one, 97 logoURI: 98 'https://assets.coingecko.com/coins/images/30663/standard/gho-token-logo.png?1720517092', 99 oracle: AaveV3Arbitrum.ASSETS.GHO.ORACLE, 100 extensions: { 101 isNative: false, 102 }, 103 balance: '0', 104 }, 105 { 106 name: 'Ethereum', 107 symbol: 'ETH', 108 decimals: 18, 109 address: constants.AddressZero, // Use zero address for network token ccip 110 chainId: ChainId.arbitrum_one, 111 logoURI: 112 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 113 extensions: { 114 isNative: true, 115 }, 116 balance: '0', 117 }, 118 ], 119 }, 120 { 121 sourceChainId: ChainId.base, 122 chainSelector: '15971525489660198786', 123 burnMintTokenPool: GhoBase.GHO_CCIP_TOKEN_POOL, 124 router: '0x881e3A65B4d4a04dD529061dd0071cf975F58bCD', 125 tokenOracle: '0x42868EFcee13C0E71af89c04fF7d96f5bec479b0', 126 wrappedNativeOracle: AaveV3Base.ASSETS.WETH.ORACLE, 127 subgraphUrl: `https://gateway.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/7RqaLvSMWBv4Z3xmv4kb6Jq3t59ikYG3wpcsTnLgBWzt`, 128 feeTokens: [ 129 { 130 name: 'Ethereum', 131 symbol: 'ETH', 132 decimals: 18, 133 address: constants.AddressZero, // Use zero address for network token ccip 134 chainId: ChainId.base, 135 logoURI: 136 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 137 extensions: { 138 isNative: true, 139 }, 140 balance: '0', 141 }, 142 ], 143 }, 144 ]; 145 146 const testnetConfig: Config[] = [ 147 { 148 sourceChainId: ChainId.sepolia, 149 lockReleaseTokenPool: '0xd8bDb685320f7118085d5C8D0c2016A644881D40', 150 chainSelector: '16015286601757825753', 151 router: '0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59', 152 tokenOracle: '0x98458D6A99489F15e6eB5aFa67ACFAcf6F211051', // mock oracle 153 wrappedNativeOracle: AaveV3Sepolia.ASSETS.WETH.ORACLE, 154 subgraphUrl: `https://gateway.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/8NWTrc4S6xwaBbajongofytQfQisqYm1zR2ghGEtRFSc`, 155 feeTokens: [ 156 // { 157 // name: 'Gho Token', 158 // address: AaveV3Sepolia.ASSETS.GHO.UNDERLYING, 159 // symbol: 'GHO', 160 // decimals: 18, 161 // chainId: 11155111, 162 // logoURI: 163 // 'https://assets.coingecko.com/coins/images/30663/standard/gho-token-logo.png?1720517092', 164 // oracle: AaveV3Sepolia.ASSETS.GHO.ORACLE, 165 // extensions: { 166 // isNative: false, 167 // }, 168 // balance: '0', 169 // }, 170 { 171 name: 'Ethereum', 172 symbol: 'ETH', 173 decimals: 18, 174 address: constants.AddressZero, // Use zero address for network token ccip 175 chainId: 11155111, 176 logoURI: 177 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 178 extensions: { 179 isNative: true, 180 }, 181 balance: '0', 182 }, 183 ], 184 }, 185 { 186 sourceChainId: ChainId.arbitrum_sepolia, 187 burnMintTokenPool: '0xb4A1e95A2FA7ed83195C6c16660fCCa720163FF6', 188 chainSelector: '3478487238524512106', 189 router: '0x2a9C5afB0d0e4BAb2BCdaE109EC4b0c4Be15a165', 190 tokenOracle: '0x1f885520b7BD528E46b390040F12E753Dce43004', // mock oracle 191 wrappedNativeOracle: AaveV3ArbitrumSepolia.ASSETS.WETH.ORACLE, 192 subgraphUrl: `https://gateway.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/8bpqvL6XBCVhN4heE9rdEwgTketeZ2U5vVGEh5fDoUEH`, 193 feeTokens: [ 194 // { 195 // name: 'Gho Token', 196 // address: AaveV3Sepolia.ASSETS.GHO.UNDERLYING, 197 // symbol: 'GHO', 198 // decimals: 18, 199 // chainId: 421614, 200 // logoURI: 201 // 'https://assets.coingecko.com/coins/images/30663/standard/gho-token-logo.png?1720517092', 202 // oracle: AaveV3Sepolia.ASSETS.GHO.ORACLE, 203 // extensions: { 204 // isNative: false, 205 // }, 206 // balance: '0', 207 // }, 208 { 209 name: 'Ethereum', 210 symbol: 'ETH', 211 decimals: 18, 212 address: constants.AddressZero, // Use zero address for network token ccip 213 chainId: 421614, // Arb 214 logoURI: 215 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 216 extensions: { 217 isNative: true, 218 }, 219 balance: '0', 220 }, 221 ], 222 }, 223 { 224 sourceChainId: ChainId.base_sepolia, 225 burnMintTokenPool: '0x2a33945f942913b730aB36A24150A96c3D0CC9E9', 226 chainSelector: '10344971235874465080', 227 router: '0xD3b06cEbF099CE7DA4AcCf578aaebFDBd6e88a93', 228 tokenOracle: '0xFD5ea2e57CDC98D371D8eA899d1F2C24bfFb39BD', 229 wrappedNativeOracle: AaveV3BaseSepolia.ASSETS.WETH.ORACLE, 230 subgraphUrl: `https://gateway.thegraph.com/api/${process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY}/subgraphs/id/8bpqvL6XBCVhN4heE9rdEwgTketeZ2U5vVGEh5fDoUEH`, 231 feeTokens: [ 232 { 233 name: 'Ethereum', 234 symbol: 'ETH', 235 decimals: 18, 236 address: constants.AddressZero, 237 chainId: ChainId.base_sepolia, 238 logoURI: 239 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png', 240 extensions: { 241 isNative: true, 242 }, 243 balance: '0', 244 }, 245 ], 246 }, 247 ]; 248 249 export const laneConfig = ENABLE_TESTNET ? testnetConfig : prodConfig; 250 251 export function getChainSelectorFor(chainId: ChainId) { 252 const chainSelector = laneConfig.find( 253 (config) => config.sourceChainId === chainId 254 )?.chainSelector; 255 if (!chainSelector) { 256 throw new Error(`No chainSelector found for chain ${chainId}`); 257 } 258 return chainSelector; 259 } 260 261 export function getChainIdFor(chainSelector: string) { 262 const chainId = laneConfig.find( 263 (config) => config.chainSelector === chainSelector 264 )?.sourceChainId; 265 if (!chainId) { 266 throw new Error(`No chainId found for chainSelector ${chainSelector}`); 267 } 268 return chainId; 269 } 270 271 export function getRouterFor(chainId: ChainId) { 272 const router = laneConfig.find((config) => config.sourceChainId === chainId)?.router; 273 if (!router) { 274 throw new Error(`No router found for chain ${chainId}`); 275 } 276 return router; 277 } 278 279 export function getSupportedSourceChains() { 280 return laneConfig.map((config) => config.sourceChainId); 281 } 282 283 export function getConfigFor(sourceChainId: ChainId) { 284 const config = laneConfig.find((config) => config.sourceChainId === sourceChainId); 285 if (!config) { 286 throw new Error(`No config found for chain ${sourceChainId}`); 287 } 288 return config; 289 } 290 291 export const supportedNetworksWithBridge: SupportedNetworkWithChainId[] = 292 getSupportedSourceChains().map((chainId) => ({ 293 ...networkConfigs[chainId], 294 chainId, 295 }));