Skip to main content

Overview

Chain configuration utilities and constants for Ethereum, Base, Arbitrum, and BNB Chain. Includes RPC URLs, explorer links, Aave v3 addresses, Morpho Blue addresses, and asset configurations.

Functions

getChainConfig

Retrieves the configuration for a supported chain by chain ID.
function getChainConfig(chainId: number | null | undefined): ChainConfig | null
chainId
number | null | undefined
required
The numeric chain ID (e.g., 1 for Ethereum, 8453 for Base)
returns
ChainConfig | null
The chain configuration object, or null if the chain is not supported
Example:
import { getChainConfig } from "@/lib/chains";

const ethereumConfig = getChainConfig(1);
if (ethereumConfig) {
  console.log(ethereumConfig.name); // "Ethereum"
  console.log(ethereumConfig.aaveV3PoolAddress);
  console.log(ethereumConfig.rpcUrl);
}

const unsupported = getChainConfig(999);
console.log(unsupported); // null

Constants

SUPPORTED_CHAINS

Array of all supported chain configurations.
const SUPPORTED_CHAINS: readonly ChainConfig[] = [
  {
    id: 1,
    name: "Ethereum",
    nativeSymbol: "ETH",
    rpcUrl: "https://rpc.ankr.com/eth",
    explorerBaseUrl: "https://etherscan.io",
    aaveV3PoolAddress: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
    aaveV3WethGatewayAddress: "0x893411580e590D62dDBca8a703d61Cc4A8c7b2b9",
    aaveV3ProtocolDataProviderAddress: "0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3",
    aaveV3PoolAddressesProvider: "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e",
    aaveV3UiPoolDataProviderAddress: "0x91c0eA31b49B69Ea18607702c5d9aC360bf3dE7d",
    aaveV3UiIncentiveDataProviderAddress: "0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6",
    morphoBlueAddress: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
  },
  // ... Base, Arbitrum, BNB Chain
]
Supported Networks:

CHAIN_ASSETS

Token configurations for USDC and BTC collateral on each supported chain.
const CHAIN_ASSETS: Record<SupportedChainId, ChainAssets> = {
  1: {
    usdc: { symbol: "USDC", address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", decimals: 6 },
    btcCollateral: { symbol: "WBTC", address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", decimals: 8 },
  },
  8453: {
    usdc: { symbol: "USDC", address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", decimals: 6 },
    btcCollateral: { symbol: "cbBTC", address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf", decimals: 8 },
  },
  42161: {
    usdc: { symbol: "USDC", address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", decimals: 6 },
    btcCollateral: { symbol: "WBTC", address: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", decimals: 8 },
  },
  56: {
    usdc: { symbol: "USDC", address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", decimals: 18 },
    btcCollateral: { symbol: "BTCB", address: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c", decimals: 18 },
  },
}
Example:
import { CHAIN_ASSETS } from "@/lib/assets";

const ethereumUsdc = CHAIN_ASSETS[1].usdc;
console.log(ethereumUsdc.address); // "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
console.log(ethereumUsdc.decimals); // 6

const baseCollateral = CHAIN_ASSETS[8453].btcCollateral;
console.log(baseCollateral.symbol); // "cbBTC"

Type Definitions

ChainConfig

Configuration object for a supported blockchain network.
type ChainConfig = {
  id: SupportedChainId;
  name: string;
  nativeSymbol: string;
  rpcUrl: string;
  explorerBaseUrl: string;
  aaveV3PoolAddress: `0x${string}` | null;
  aaveV3WethGatewayAddress: `0x${string}` | null;
  aaveV3ProtocolDataProviderAddress: `0x${string}` | null;
  aaveV3PoolAddressesProvider: `0x${string}` | null;
  aaveV3UiPoolDataProviderAddress: `0x${string}` | null;
  aaveV3UiIncentiveDataProviderAddress: `0x${string}` | null;
  morphoBlueAddress: `0x${string}` | null;
};
id
SupportedChainId
Chain ID: 1 (Ethereum), 8453 (Base), 42161 (Arbitrum), or 56 (BNB Chain)
name
string
Human-readable chain name
nativeSymbol
string
Native token symbol (e.g., “ETH”, “BNB”)
rpcUrl
string
Public RPC endpoint URL
explorerBaseUrl
string
Block explorer base URL (e.g., “https://etherscan.io”)
aaveV3PoolAddress
Address | null
Aave v3 Pool contract address
aaveV3WethGatewayAddress
Address | null
Aave v3 WETH Gateway contract address
aaveV3ProtocolDataProviderAddress
Address | null
Aave v3 Protocol Data Provider contract address
aaveV3PoolAddressesProvider
Address | null
Aave v3 Pool Addresses Provider contract address
aaveV3UiPoolDataProviderAddress
Address | null
Aave v3 UI Pool Data Provider contract address
aaveV3UiIncentiveDataProviderAddress
Address | null
Aave v3 UI Incentive Data Provider contract address
morphoBlueAddress
Address | null
Morpho Blue protocol contract address

SupportedChainId

type SupportedChainId = 1 | 8453 | 42161 | 56
Union type of supported chain IDs.

ChainAssets

Token configurations for a specific chain.
type ChainAssets = {
  usdc: TokenConfig;
  btcCollateral: TokenConfig;
};

TokenConfig

ERC-20 token configuration.
type TokenConfig = {
  symbol: string;
  address: `0x${string}`;
  decimals: number;
};
symbol
string
Token symbol (e.g., “USDC”, “WBTC”, “cbBTC”)
address
Address
Token contract address
decimals
number
Number of decimals (e.g., 6 for USDC, 8 for WBTC, 18 for most ERC-20s)

Usage Examples

Multi-Chain Transaction Building

import { getChainConfig } from "@/lib/chains";
import { CHAIN_ASSETS } from "@/lib/assets";
import { encodeAaveRepay } from "@/lib/protocols/aave";

async function repayOnChain(chainId: number, userAddress: Address) {
  const config = getChainConfig(chainId);
  if (!config?.aaveV3PoolAddress) {
    throw new Error("Aave not supported on this chain");
  }

  const assets = CHAIN_ASSETS[chainId as SupportedChainId];
  const repayCalldata = encodeAaveRepay({
    asset: assets.usdc.address,
    amount: 1000000n, // 1 USDC (6 decimals)
    interestRateMode: 2n,
    onBehalfOf: userAddress,
  });

  // Submit to Aave Pool on the target chain
  return {
    to: config.aaveV3PoolAddress,
    data: repayCalldata,
  };
}
import { getChainConfig } from "@/lib/chains";

function getTransactionUrl(chainId: number, txHash: string): string {
  const config = getChainConfig(chainId);
  return config ? `${config.explorerBaseUrl}/tx/${txHash}` : "";
}

function getAddressUrl(chainId: number, address: string): string {
  const config = getChainConfig(chainId);
  return config ? `${config.explorerBaseUrl}/address/${address}` : "";
}

Build docs developers (and LLMs) love