Skip to main content

MorphoMarketV1AdapterV2Factory

Factory contract for deploying MorphoMarketV1AdapterV2 adapter instances. Each factory is bound to a specific Morpho instance and Adaptive Curve IRM, ensuring consistent adapter configuration across deployments.

Overview

The MorphoMarketV1AdapterV2Factory uses CREATE2 deployment with a fixed salt (bytes32(0)) to create deterministic adapter addresses. It maintains registries to track deployed adapters and their parent vaults.
The IRM parameter must be the Adaptive Curve IRM for proper functionality.

Immutable variables

morpho
address
The address of the Morpho Blue instance that adapters will interact with.
adaptiveCurveIrm
address
The address of the Adaptive Curve IRM contract that markets must use.

State variables

morphoMarketV1AdapterV2
mapping(address => address)
Maps parent vault addresses to their deployed adapter addresses. Returns address(0) if no adapter exists for a vault.
isMorphoMarketV1AdapterV2
mapping(address => bool)
Returns true if an address is a MorphoMarketV1AdapterV2 deployed by this factory.

Constructor

constructor(address _morpho, address _adaptiveCurveIrm)
Initializes the factory with Morpho and IRM addresses.
_morpho
address
required
The Morpho Blue contract address
_adaptiveCurveIrm
address
required
The Adaptive Curve IRM contract address

Functions

createMorphoMarketV1AdapterV2

function createMorphoMarketV1AdapterV2(address parentVault) external returns (address)
Deploys a new MorphoMarketV1AdapterV2 for the specified parent vault.
parentVault
address
required
The VaultV2 address that will use this adapter
return
address
The address of the newly deployed adapter
Each parent vault can only have one adapter deployed through this factory. Calling this function multiple times with the same parentVault will revert during deployment.

Events

CreateMorphoMarketV1AdapterV2Factory

event CreateMorphoMarketV1AdapterV2Factory(address indexed morpho, address indexed adaptiveCurveIrm)
Emitted when the factory is created.

CreateMorphoMarketV1AdapterV2

event CreateMorphoMarketV1AdapterV2(address indexed parentVault, address indexed adapter)
Emitted when a new adapter is deployed.

Usage example

// Deploy factory
MorphoMarketV1AdapterV2Factory factory = new MorphoMarketV1AdapterV2Factory(
    morphoAddress,
    adaptiveCurveIrmAddress
);

// Create adapter for a vault
address adapter = factory.createMorphoMarketV1AdapterV2(vaultAddress);

// Check if address is a valid adapter
bool isAdapter = factory.isMorphoMarketV1AdapterV2(adapter);

// Get adapter for a vault
address existingAdapter = factory.morphoMarketV1AdapterV2(vaultAddress);