-
Notifications
You must be signed in to change notification settings - Fork 27
feat(vault-v1&2): add factory check in fetch utilities #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Rubilmax
merged 18 commits into
main
from
feature/consu-4354-validate-that-vaults-are-vaults-in-sdk-fetchers-v1-and-2
Feb 9, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c1b6f00
feat(vault-v2): add factory check in fetch utility
Foulks-Plb 43af991
refactor(errors): streamline error class constructors and add Unknown…
Foulks-Plb 3a8c02c
feat(vault-v2): implement factory checks in adapter queries and add U…
Foulks-Plb c426f64
fix(vault-v2): add factory deployment checks in Morpho adapter queries
Foulks-Plb 05e102c
refactor(vault-v2): consolidate error handling
Foulks-Plb f6085a0
feat(vault-v2): check vaultV1
Foulks-Plb f704df7
fix(vault-v2): improve error handling for MetaMorpho factory checks
Foulks-Plb 0d64d6e
refactor(vault-v2): clean up code formatting and improve readability …
Foulks-Plb dab1db8
refactor(vault-v2): enhance fetchVault function with improved error h…
Foulks-Plb 48a7881
refactor(vault-v2): rename UnknownToFactory and revert if deployless …
Foulks-Plb 22e1606
refactor(errors): streamline error class constructors and improve for…
Foulks-Plb 6e58392
Merge branch 'main' into feature/consu-4354-validate-that-vaults-are-…
Foulks-Plb 3482ce4
refactor(vault-v2): introduce isUnknownOfFactoryError utility for imp…
Foulks-Plb f08d40e
refactor(vault-v2): update isMetaMorpho handling and put it in promise
Foulks-Plb c4fba26
Merge branch 'main' into feature/consu-4354-validate-that-vaults-are-…
Foulks-Plb 7ec7c74
Merge branch 'main' into feature/consu-4354-validate-that-vaults-are-…
Foulks-Plb 6411b67
fix(vault-v2): remove duplicate import of MarketParams in VaultV2.ts
Foulks-Plb d72bbeb
fix(vault-v2): update contract code in GetVaultV2.ts for improved fun…
Foulks-Plb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/blue-sdk-viem/contracts/interfaces/IMetaMorphoFactory.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| pragma solidity >=0.5.0; | ||
|
|
||
| import {IMetaMorpho} from "./IMetaMorpho.sol"; | ||
|
|
||
| /// @title IMetaMorphoFactory | ||
| /// @author Morpho Labs | ||
| /// @custom:contact security@morpho.org | ||
| /// @notice Interface of MetaMorpho's factory. | ||
| interface IMetaMorphoFactory { | ||
| /// @notice The address of the Morpho contract. | ||
| function MORPHO() external view returns (address); | ||
|
|
||
| /// @notice Whether a MetaMorpho vault was created with the factory. | ||
| function isMetaMorpho(address target) external view returns (bool); | ||
|
|
||
| /// @notice Creates a new MetaMorpho vault. | ||
| /// @param initialOwner The owner of the vault. | ||
| /// @param initialTimelock The initial timelock of the vault. | ||
| /// @param asset The address of the underlying asset. | ||
| /// @param name The name of the vault. | ||
| /// @param symbol The symbol of the vault. | ||
| /// @param salt The salt to use for the MetaMorpho vault's CREATE2 address. | ||
| function createMetaMorpho( | ||
| address initialOwner, | ||
| uint256 initialTimelock, | ||
| address asset, | ||
| string memory name, | ||
| string memory symbol, | ||
| bytes32 salt | ||
| ) external returns (IMetaMorpho metaMorpho); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/blue-sdk-viem/contracts/vault-v2/interfaces/IMorphoMarketV1AdapterFactory.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| // Copyright (c) 2025 Morpho Association | ||
| pragma solidity >=0.5.0; | ||
|
|
||
| interface IMorphoMarketV1AdapterFactory { | ||
| /* EVENTS */ | ||
|
|
||
| event CreateMorphoMarketV1Adapter( | ||
| address indexed parentVault, address indexed morpho, address indexed morphoMarketV1Adapter | ||
| ); | ||
|
|
||
| /* FUNCTIONS */ | ||
|
|
||
| function morphoMarketV1Adapter(address parentVault, address morpho) external view returns (address); | ||
| function isMorphoMarketV1Adapter(address account) external view returns (bool); | ||
| function createMorphoMarketV1Adapter(address parentVault, address morpho) external returns (address); | ||
| } |
15 changes: 15 additions & 0 deletions
15
packages/blue-sdk-viem/contracts/vault-v2/interfaces/IVaultV2Factory.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| // Copyright (c) 2025 Morpho Association | ||
| pragma solidity >=0.5.0; | ||
|
|
||
| interface IVaultV2Factory { | ||
| /* EVENTS */ | ||
|
|
||
| event CreateVaultV2(address indexed owner, address indexed asset, bytes32 salt, address indexed newVaultV2); | ||
|
|
||
| /* FUNCTIONS */ | ||
|
|
||
| function isVaultV2(address account) external view returns (bool); | ||
| function vaultV2(address owner, address asset, bytes32 salt) external view returns (address); | ||
| function createVaultV2(address owner, address asset, bytes32 salt) external returns (address newVaultV2); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { BaseError, ContractFunctionRevertedError } from "viem"; | ||
|
|
||
| /** | ||
| * Checks if an error is a contract revert with the "UnknownOfFactory" error name. | ||
| * Used to propagate factory validation errors instead of falling back to multicall. | ||
| */ | ||
| export function isUnknownOfFactoryError(error: unknown): boolean { | ||
| if (!(error instanceof BaseError)) return false; | ||
|
|
||
| const revertError = error.walk( | ||
| (err) => err instanceof ContractFunctionRevertedError, | ||
| ); | ||
|
|
||
| return ( | ||
| revertError instanceof ContractFunctionRevertedError && | ||
| revertError.data?.errorName === "UnknownOfFactory" | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.