This guide provides step-by-step instructions for deploying the MultiHookAdapter system to testnet and mainnet networks. The deployment consists of a modular factory system optimized for Ethereum's contract size limits.
- Foundry (forge, anvil, cast)
- Git
- Node.js (for npm scripts, optional)
- Private key for deployment account
- RPC URL for target network
- Etherscan API key (optional, for contract verification)
- Uniswap V4 PoolManager address (when available)
# Clone and setup
cd multihook-adapter
forge install
# Copy environment template
cp .env.template .env
# Edit .env with your configuration
# Required: PRIVATE_KEY, SEPOLIA_RPC_URL
# Optional: ETHERSCAN_API_KEY# Easy deployment script
./scripts/deploy-testnet.sh
# Or manual deployment
forge script scripts/DeployFactory.s.sol --rpc-url $SEPOLIA_RPC_URL --broadcastforge script scripts/VerifyDeployment.s.sol --rpc-url $SEPOLIA_RPC_URLThe factory system consists of four contracts deployed in sequence:
- BasicAdapterFactory (1,767 bytes) - Deploys immutable adapters
- PermissionedAdapterFactory (1,358 bytes) - Deploys governance-controlled adapters
- MultiHookAdapterFactory (1,441 bytes) - Main coordinator factory
- AdapterDeploymentHelper (4,257 bytes) - High-level deployment workflows
# Deploy factory system
forge script scripts/DeployFactory.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--broadcast \
--verify \
--etherscan-api-key $ETHERSCAN_API_KEYExpected output:
BasicAdapterFactory deployed at: 0x...
PermissionedAdapterFactory deployed at: 0x...
MultiHookAdapterFactory deployed at: 0x...
AdapterDeploymentHelper deployed at: 0x...
Once the factory system is deployed, you can deploy specific adapter instances:
forge script scripts/DeployBasicAdapter.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--broadcastforge script scripts/DeployPermissionedAdapter.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--broadcastforge script scripts/DeployWithHelper.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--broadcast# Verify deployment integrity
forge script scripts/VerifyDeployment.s.sol --rpc-url $SEPOLIA_RPC_URL
# Run integration tests
forge test --rpc-url $SEPOLIA_RPC_URL# Required for deployment
PRIVATE_KEY=your_private_key_without_0x_prefix
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY
ETHERSCAN_API_KEY=your_etherscan_api_key
# Optional configuration
DEFAULT_FEE=3000 # 0.3% default fee
GOVERNANCE_ADDRESS=0x... # Custom governance address
HOOK_MANAGER_ADDRESS=0x... # Custom hook manager address
DEPLOYMENT_SALT=0x... # Custom deployment salt
# Network-specific PoolManager addresses (update when available)
SEPOLIA_POOL_MANAGER=0x...
MAINNET_POOL_MANAGER=0x...SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_PROJECT_ID
MAINNET_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_IDSEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEYSEPOLIA_RPC_URL=https://your-endpoint.sepolia.quiknode.pro/your-token/
MAINNET_RPC_URL=https://your-endpoint.ethereum.quiknode.pro/your-token/Network: Sepolia (Chain ID: 11155111)
BasicAdapterFactory: TBD
PermissionedAdapterFactory: TBD
MultiHookAdapterFactory: TBD
AdapterDeploymentHelper: TBD
Network: Mainnet (Chain ID: 1)
BasicAdapterFactory: TBD
PermissionedAdapterFactory: TBD
MultiHookAdapterFactory: TBD
AdapterDeploymentHelper: TBD
Addresses will be updated after deployment
| Script | Purpose | Gas Usage | Verification |
|---|---|---|---|
DeployFactory.s.sol |
Deploy complete factory system | ~2.5M gas | Auto-verify |
DeployBasicAdapter.s.sol |
Deploy immutable adapter | ~1.2M gas | Manual |
DeployPermissionedAdapter.s.sol |
Deploy governance adapter | ~1.5M gas | Manual |
DeployWithHelper.s.sol |
Advanced deployment workflows | Variable | Manual |
VerifyDeployment.s.sol |
Validate all deployments | Read-only | N/A |
| Script | Purpose |
|---|---|
deploy-testnet.sh |
Complete testnet deployment |
deploy-mainnet.sh |
Complete mainnet deployment (coming soon) |
| Contract | Deployment Gas | USD (20 gwei, $2000 ETH) |
|---|---|---|
| BasicAdapterFactory | ~400k gas | ~$16 |
| PermissionedAdapterFactory | ~350k gas | ~$14 |
| MultiHookAdapterFactory | ~300k gas | ~$12 |
| AdapterDeploymentHelper | ~500k gas | ~$20 |
| Total Factory System | ~1.55M gas | ~$62 |
| Adapter Type | Gas Cost | USD (20 gwei, $2000 ETH) |
|---|---|---|
| Basic Adapter | ~1.2M gas | ~$48 |
| Permissioned Adapter | ~1.5M gas | ~$60 |
// Approve hooks (as hook manager)
adapter.approveHook(hookAddress);
// Batch approve multiple hooks
address[] memory hooks = [hook1, hook2, hook3];
adapter.batchApproveHooks(hooks);// Register hooks for a specific pool
PoolKey memory poolKey = PoolKey({...});
address[] memory poolHooks = [hook1, hook2];
adapter.registerHooks(poolKey, poolHooks);// Set fee calculation method for a pool
adapter.setPoolFeeCalculationMethod(
poolId,
IFeeCalculationStrategy.FeeCalculationMethod.MEDIAN
);
// Set pool-specific fee override
adapter.setPoolSpecificFee(poolId, 2500); // 0.25%- Never commit private keys to version control
- Use hardware wallets for mainnet deployments
- Consider using multiple signatures for governance functions
- Always verify contracts on Etherscan
- Compare deployed bytecode with compiled bytecode
- Verify constructor parameters
- Double-check all addresses before deployment
- Verify PoolManager address is correct for the network
- Ensure governance addresses are properly controlled
- All contracts are optimized and should be under 24KB
- If this occurs, check for compiler version mismatch
- Ensure salt is unique across deployments
- Verify constructor parameters match prediction call
- Deploy factories in correct order
- Verify factory addresses in deployment file
- Check gas limit (use 8M gas limit for safety)
- Verify all constructor parameters
- Ensure sufficient ETH balance
# Check contract size
forge build --sizes | grep Factory
# Simulate deployment without broadcasting
forge script scripts/DeployFactory.s.sol --rpc-url $SEPOLIA_RPC_URL
# Check deployment file
cat deployments-11155111.env
# Verify specific contract
forge verify-contract $CONTRACT_ADDRESS $CONTRACT_PATH --chain sepoliaMainnet deployment will follow the same process with additional security measures:
- Multi-signature governance setup
- Time-locked deployments
- Comprehensive security audits
- Community governance proposals
For deployment issues or questions:
- Check this documentation
- Review the test suite for examples
- Open an issue on GitHub
- Join the community Discord
- Complete factory system
- Contract size optimization
- Comprehensive testing (241 tests)
- Production-ready deployment scripts