This guide provides step-by-step instructions for adding a new blockchain to the Morpho SDK. Follow these steps carefully to ensure proper integration.
File: packages/blue-sdk/src/chain.ts
Add your new chain ID to the ChainId enum:
export enum ChainId {
// ... existing chains
YourNewChain = 12345, // Replace with actual chain ID
}File: packages/blue-sdk/src/chain.ts
Add your chain's metadata to the CHAIN_METADATA object:
[ChainId.YourNewChain]: {
name: "Your Chain Name",
id: ChainId.YourNewChain,
nativeCurrency: {
name: "Native Token Name",
symbol: "SYMBOL",
decimals: 18
},
explorerUrl: "https://explorer.yourchain.com",
identifier: "yourchain",
},File: packages/blue-sdk/src/addresses.ts
Add your chain's contract addresses to the _addressesRegistry mapping:
[ChainId.YourNewChain]: {
morpho: "0x...", // Morpho protocol address
bundler3: {
bundler3: "0x...",
generalAdapter1: "0x...",
},
adaptiveCurveIrm: "0x...",
publicAllocator: "0x...",
metaMorphoFactory: "0x...",
chainlinkOracleFactory: "0x...",
preLiquidationFactory: "0x...",
wNative: "0x...", // Wrapped native token address
// Add other required addresses as needed
// If USDC is provided, it must implement permit version 2
},Remember to register the USDC address if it supports ERC-2612 permit version 2, otherwise the signature will default to permit version 1 (if hasSimplePermit is set to true).
Also make sure to add the Permit2 contract (if available) to enable transactional flows using Permit2, otherwise the approval will default to the classic erc20 approval.
File: packages/blue-sdk/src/addresses.ts
Add deployment block numbers to the _deployments mapping:
[ChainId.YourNewChain]: {
morpho: 12345678n,
bundler3: {
bundler3: 12345679n,
generalAdapter1: 12345680n,
},
adaptiveCurveIrm: 12345681n,
publicAllocator: 12345682n,
metaMorphoFactory: 12345683n,
chainlinkOracleFactory: 12345684n,
preLiquidationFactory: 12345685n,
wNative: 12345686n,
// Add deployment blocks for all contracts
},File: packages/blue-sdk/src/addresses.ts
Add the wrapped native token mapping to _unwrappedTokensMapping:
[ChainId.YourNewChain]: {
[_addressesRegistry[ChainId.YourNewChain].wNative]: NATIVE_ADDRESS,
// Add other unwrapped token mappings if needed
},File: packages/liquidation-sdk-viem/src/addresses.ts
Add an empty object if you don't have Midas information:
[ChainId.YourNewChain]: {},Add the preLiquidation factory configuration:
[ChainId.YourNewChain]: {
address: addressesRegistry[ChainId.YourNewChain].preLiquidationFactory,
startBlock: 12345685n, // Same as deployment block
},Before submitting your changes, ensure:
- Chain ID is unique and correctly formatted
- All contract addresses are valid and checksummed
- Deployment blocks are accurate
- Native currency information is correct
- Explorer URL is functional
- No duplicate entries exist
- All required contracts are included
- Wrapped native token mapping is correct