This guide explains how to add support for new blockchain networks to the Seamless Protocol frontend application.
File: src/lib/config/wagmi.config.ts
Add your new chain to the wagmi configuration:
import { base, mainnet, polygon } from 'wagmi/chains' // Import your chain
// Add RPC URL resolution for your chain
const polygonRpc =
(rpcMap?.['137'] || rpcMap?.['polygon']) ??
(import.meta.env['VITE_POLYGON_RPC_URL'] || 'https://polygon-rpc.com')
// Update the config
export const config = getDefaultConfig({
appName: 'Seamless Protocol',
projectId: walletConnectProjectId || 'YOUR_PROJECT_ID',
chains: [base, mainnet, polygon], // Add your chain here
transports: {
[base.id]: http(baseRpc),
[mainnet.id]: http(mainnetRpc),
[polygon.id]: http(polygonRpc), // Add transport for your chain
},
ssr: false,
syncConnectedChain: true,
})File: src/lib/contracts/addresses.ts
Add your chain's contract addresses:
// Update the SupportedChainId type
export type SupportedChainId = typeof mainnet.id | typeof base.id | typeof polygon.id
// Add your chain's contract addresses
const polygonContracts: ContractAddresses = {
// Core Protocol
leverageTokenFactory: '0x...' as Address,
leverageManager: '0x...' as Address,
leverageRouter: '0x...' as Address,
leverageManagerV2: '0x...' as Address,
leverageRouterV2: '0x...' as Address,
// Tokens
seamlessToken: '0x...' as Address,
tokens: {
usdc: '0x...' as Address,
weth: '0x...' as Address,
// Add other tokens as needed
},
// Add other contract addresses...
}
// Update the contractAddresses record
export const contractAddresses: Record<number, ContractAddresses> = {
[base.id]: baseContracts,
[mainnet.id]: mainnetContracts,
[polygon.id]: polygonContracts, // Add your chain
}File: src/components/icons/logos/polygon-logo.tsx
Create a logo component for your chain:
import type { SVGProps } from 'react'
import { useId } from 'react'
export function PolygonLogo({ className, ...props }: SVGProps<SVGSVGElement>) {
const logoId = useId()
return (
<svg
className={className}
fill="none"
preserveAspectRatio="none"
viewBox="0 0 32 32"
role="img"
aria-labelledby={logoId}
{...props}
>
<title id={logoId}>Polygon Logo</title>
{/* Your SVG content here */}
</svg>
)
}File: src/components/icons/logos/index.ts
Export your new logo:
export { BaseLogo } from './base-logo'
export { EthereumLogo } from './ethereum-logo'
export { PolygonLogo } from './polygon-logo' // Add your logo
// ... other exportsFile: src/lib/env.ts
Add your chain's RPC URL to required environment variables:
const REQUIRED_ENV_VARS = [
'VITE_WALLETCONNECT_PROJECT_ID',
'VITE_BASE_RPC_URL',
'VITE_ETHEREUM_RPC_URL',
'VITE_POLYGON_RPC_URL', // Add your chain's RPC URL
'VITE_THEGRAPH_API_KEY',
] as constFile: src/lib/graphql/utils.ts
Add your chain to GraphQL endpoints:
const SUBGRAPH_ENDPOINTS = {
8453: 'https://api.thegraph.com/subgraphs/name/seamless-protocol/base',
1: 'https://api.thegraph.com/subgraphs/name/seamless-protocol/ethereum',
137: 'https://api.thegraph.com/subgraphs/name/seamless-protocol/polygon', // Add your chain
} as const
export type SupportedChainId = keyof typeof SUBGRAPH_ENDPOINTSFile: src/lib/config/uniswapV3.ts
Add your chain to Uniswap V3 configuration:
const UNISWAP_V3_CONFIGS: Record<number, UniswapV3ChainConfig> = {
8453: { // Base
factory: '0x...',
quoter: '0x...',
router: '0x...',
},
1: { // Ethereum
factory: '0x...',
quoter: '0x...',
router: '0x...',
},
137: { // Polygon
factory: '0x...',
quoter: '0x...',
router: '0x...',
},
}File: src/vite-env.d.ts
Add your chain's environment variables:
interface ImportMetaEnv {
// ... existing variables
readonly VITE_POLYGON_RPC_URL?: string
// Add other chain-specific variables
}You'll need the following contract addresses for your new chain:
Core Protocol:
leverageTokenFactory- Factory contract for creating leverage tokensleverageManager- V1 manager contractleverageManagerV2- V2 manager contractleverageRouter- V1 router contractleverageRouterV2- V2 router contractleverageTokenImpl- Implementation contract for leverage tokens
Adapters:
morphoLendingAdapterFactory- Morpho lending adapter factorymorphoLendingAdapterImpl- Morpho lending adapter implementationrebalanceAdapter- Rebalancing adapterlendingAdapter- General lending adapterveloraAdapter- Velora adapterpricingAdapter- Price oracle adapter
Tokens:
seamlessToken- SEAM token addressstakedSeam- Staked SEAM tokentokens.usdc- USDC token addresstokens.weth- WETH token addresstokens.weeth- weETH token address (if applicable)
Governance:
governance- Governor contract addresstimelockShort- Short timelock contracttimelockLong- Long timelock contract
Helpers:
multicall- Multicall contract addresspriceOracle- Price oracle contract
You'll need reliable RPC endpoints for your chain:
# Add to your .env file
VITE_POLYGON_RPC_URL=https://polygon-rpc.com