Skip to content

Create a Morpho Vault V2

Deploying a Morpho Vault V2 is a permissionless process that anyone can initiate. While the vault can be created directly via the VaultV2 constructor, the recommended approach is to use the deployment scripts that handle the complete setup process.

This guide covers two methods for deploying your vault:

  1. Using the Deployment Script (Recommended): The most efficient and reliable method, allowing you to create, configure, and assign roles for your vault in a single, automated process.
  2. Using Etherscan: A manual approach suitable for simple deployments or for those who prefer interacting directly with contracts.

Method 1: Create and Configure a Vault via Script

For a seamless and powerful setup experience, we highly recommend using the official Morpho Vaults V2 deployment repository. This approach allows you to bundle multiple setup actions into a single, cohesive script.

Repository: https://github.com/morpho-org/vault-v2-deployment

The Power of Scripted Deployment

The key advantage of using the deployment repository is simplicity and efficiency. The DeployVaultV2.s.sol script performs the entire initial configuration in one go, leveraging the fact that new vaults have a zero-second timelock by default.

The deployment script performs the following actions:

  1. Vault Creation: Deploys a new VaultV2 instance directly (not via factory).
  2. Role Assignment: Assigns the Owner, Curator, Allocator, and optionally Sentinel roles.
  3. Core Configuration:
    • Deploys a MorphoVaultV1Adapter for the specified Vault V1.
    • Deploys a SingleMorphoVaultV1Vic (Vault Interest Controller).
    • Enables the adapter and sets the VIC on the vault.
    • Sets the initial risk caps (absolute and relative).
    • Configures the adapter as the liquidityAdapter.
  4. Timelock Hardening: Optionally sets timelocks to secure the vault for production use.

Running the Deployment Script

First, clone the deployment repository and install dependencies:

git clone https://github.com/morpho-org/vault-v2-deployment
cd vault-v2-deployment
forge install

Set up your environment variables in a .env file:

# Required addresses
OWNER=0x...           # Final owner of the vault (ideally a multisig)
CURATOR=0x...         # Curator address (ideally a multisig)
ALLOCATOR=0x...       # Allocator address
VAULT_V1=0x...        # Target Morpho Vault V1 address
 
# Optional
SENTINEL=0x...        # Sentinel address (leave empty if not needed)
TIMELOCK_DURATION=86400  # 1 day in seconds (leave empty for 0)

Run the deployment:

# Without block explorer verification
forge script script/DeployVaultV2.s.sol:DeployVaultV2 \
  --rpc-url $RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast
# With verification on Etherscan
forge script script/DeployVaultV2.s.sol:DeployVaultV2 \
  --rpc-url $RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --etherscan-api-key $ETHERSCAN_API_KEY \
  --verify

The script will output the addresses of all deployed contracts and confirm each configuration step.

Understanding the Deployment Steps

Here's what the script does internally:

// Step 1: Deploy VaultV2 with broadcaster as temporary owner
VaultV2 vaultV2 = new VaultV2(broadcaster, vaultV1.asset());
 
// Step 2: Set broadcaster as temporary curator
vaultV2.setCurator(broadcaster);
 
// Step 3: Deploy MorphoVaultV1Adapter
address morphoVaultV1Adapter = address(new MorphoVaultV1Adapter(address(vaultV2), address(vaultV1)));
 
// Step 4: Deploy SingleMorphoVaultV1Vic
address singleMorphoVaultV1Vic = address(new SingleMorphoVaultV1Vic(morphoVaultV1Adapter));
 
// Step 5-6: Submit and execute all timelocked actions
// (Since timelock is 0 initially, these can be executed immediately)
 
// Step 7: Set the liquidity adapter
vaultV2.setLiquidityAdapterAndData(morphoVaultV1Adapter, bytes(""));
 
// Step 8-10: Set timelocks and transfer roles to final addresses

Method 2: Create a Vault Manually via Etherscan

If you prefer a manual approach, you can deploy a vault directly by interacting with the contracts on a block explorer.

Prerequisites

  • An Ethereum wallet (e.g., MetaMask) connected to the desired network.
  • The address of the ERC-20 token the vault will use as its asset.
  • The address you want to designate as the initial owner.

Step-by-Step Guide

1. Deploy a New VaultV2 Contract

Since Vault V2 doesn't use a factory pattern, you'll need to deploy the contract directly. This typically requires using a development environment like Remix or Foundry.

For Remix:

  1. Copy the VaultV2.sol contract and its dependencies.
  2. Compile with Solidity 0.8.28.
  3. Deploy with constructor parameters:
    • _owner: The initial owner address (ideally your multisig).
    • _asset: The ERC-20 token address (e.g., USDC, WETH).

2. Verify the Contract

After deployment, verify the contract on Etherscan to enable the Write Contract interface.

3. Configure the Vault

Once deployed and verified, you'll need to:

  1. Set up roles (see Manage Vault V2 Roles).
  2. Deploy and configure adapters (see (De)List Adapters).
  3. Set up a VIC (see (De)List Vault Interest Controller).

Congratulations! Your vault is now deployed. For a production-ready setup, we strongly recommend using the deployment script method as it ensures all components are properly configured.