Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/EOFactory.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IEOMultiFeedAdapter } from "./interfaces/IEOMultiFeedAdapter.sol";
import { IEOSingleFeedAdapter } from "./interfaces/IEOSingleFeedAdapter.sol";
import { IEOFeedAdapterBase } from "./interfaces/IEOFeedAdapterBase.sol";
import { IEOLPYAPFeed } from "./interfaces/IEOLPYAPFeed.sol";
import { IEOPendlePTFeedTWAP } from "./interfaces/IEOPendlePTFeedTWAP.sol";
import { IEOPendlePTFeedLinearDiscount } from "./interfaces/IEOPendlePTFeedLinearDiscount.sol";
import { IEOSpectraPTFeed } from "./interfaces/IEOSpectraPTFeed.sol";
import { IEOPendlePTFeedHybrid } from "./interfaces/IEOPendlePTFeedHybrid.sol";
import { IEOSpectraPTFeedHybrid } from "./interfaces/IEOSpectraPTFeedHybrid.sol";
import { IEOPendleLPFeed } from "./interfaces/IEOPendleLPFeed.sol";
import { IEOERC4626CappedFeedAdapter } from "./interfaces/IEOERC4626CappedFeedAdapter.sol";
import { IMorphoChainlinkOracleV2Factory } from "./interfaces/morpho-chainlink/IMorphoChainlinkOracleV2Factory.sol";
import { AggregatorV3Interface } from "./interfaces/morpho-chainlink/AggregatorV3Interface.sol";
import { IERC4626 } from "./interfaces/morpho-chainlink/IERC4626.sol";
import { IDecimals } from "./interfaces/IDecimals.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { IEOFactory } from "./interfaces/IEOFactory.sol";
import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol";
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
/**
* @title EOFactory
* @author EO
* @notice The factory for creating new EO artifacts
* @dev (PT TWAP, PT Linear Discount, PT Hybrid, Spectra PT, Multi Feed Adapter, Morpho Oracle, LP YAP Feed, Single Feed
* Adapter, Pendle LP Feed, Spectra PT Hybrid, ERC4626 Capped Feed Adapter)
*/
contract EOFactory is IEOFactory, AccessControlUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @notice The deployer role, can deploy new artifacts
*/
bytes32 public constant DEPLOYER_ROLE = keccak256("DEPLOYER_ROLE");
/**
* @notice The morpho factory, used to create morpho oracles
*/
address internal _morphoFactory;
/**
* @notice The address of the Pendle PT oracle
*/
address internal _pendlePTOracle;
/**
* @notice The mapping of the artifacts, deployed via the factory
*/
mapping(address artifactAddress => FactoryArtifact artifact) internal _artifacts;
/**
* @notice The set of the artifacts addresses, deployed via the factory
*/
EnumerableSet.AddressSet internal _artifactsAddresses;
/**
* @notice The mapping of the implementation addresses, deployed via the factory
*/
mapping(ArtifactType artifactType => address implementationAddress) internal _implementationAddresses;
uint256 internal _deprecated;
/**
* @notice The address of the initial proxy owner
*/
address internal _initialProxyOwner;
/**
* @notice The proxy pattern, enum ProxyPattern
*/
ProxyPattern internal _proxyPattern;
/**
* @notice The gap for the upgradeable contract.
*/
uint256[50] internal __gap;
/**
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor() {
_disableInitializers();
}
/**
* @notice Initialize the factory
* @param implementations The addresses of the implementations, where the index is the enum ArtifactType
* @param morphoFactory The address of the morpho factory
* @param ptOracle The address of the Pendle PT oracle
* @param owner The address of the owner
* @param deployer The address of the deployer
* @param artifactsInitialProxyOwner The address of the initial proxy owner
* @param proxyPattern The proxy pattern, enum ProxyPattern (0 = CLONE, 2 = TRANSPARENT)
*/
function initialize(
address[] memory implementations,
address morphoFactory,
address ptOracle,
address owner,
address deployer,
address artifactsInitialProxyOwner,
ProxyPattern proxyPattern
)
external
initializer
{
__AccessControl_init();
if (owner == address(0)) revert OwnerZeroAddress();
if (deployer == address(0)) revert DeployerZeroAddress();
_grantRole(DEFAULT_ADMIN_ROLE, owner);
_grantRole(DEPLOYER_ROLE, owner);
_grantRole(DEPLOYER_ROLE, deployer);
_setMorphoFactory(morphoFactory);
_setPendlePTOracle(ptOracle);
_setInitialProxyOwner(artifactsInitialProxyOwner);
_setProxyPattern(proxyPattern);
_setImplementations(implementations);
}
/**
* @notice Create a new Pendle PT TWAP feed
* @param ptMarket The address of the Pendle PT market
* @param description The description of the feed
* @param twapDuration The duration of the TWAP
* @param twapType The type of the TWAP, either PT_TO_SY (0) or PT_TO_ASSET (1)
* @return The address of the new feed
*/
function createPendlePTFeedTWAP(
address ptMarket,
string memory description,
uint32 twapDuration,
IEOPendlePTFeedTWAP.TWAPType twapType
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.PENDLE_PT_TWAP);
IEOPendlePTFeedTWAP(deployedFeed).initialize(_pendlePTOracle, ptMarket, description, twapDuration, twapType);
emit PendlePTTWAPFeedCreated(deployedFeed, twapType, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.PENDLE_PT_TWAP, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Pendle PT linear discount feed
* @param ptToken The address of the Pendle PT token
* @param description The description of the feed
* @param baseDiscountPerYear The base discount per year
* @return The address of the new feed
*/
function createPendlePTFeedLinearDiscount(
address ptToken,
string memory description,
uint256 baseDiscountPerYear
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.PENDLE_PT_LINEAR_DISCOUNT);
IEOPendlePTFeedLinearDiscount(deployedFeed).initialize(ptToken, description, baseDiscountPerYear);
emit PendlePTLinearDiscountFeedCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.PENDLE_PT_LINEAR_DISCOUNT, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Pendle PT hybrid feed
* @param ptMarket The address of the Pendle PT market
* @param description The description of the feed
* @param twapDuration The duration of the TWAP
* @param baseDiscountPerYear The base discount per year
* @return The address of the new feed
*/
function createPendlePTFeedHybrid(
address ptMarket,
string memory description,
uint32 twapDuration,
uint256 baseDiscountPerYear
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.PENDLE_PT_HYBRID);
IEOPendlePTFeedHybrid(deployedFeed).initialize(
_pendlePTOracle, ptMarket, description, twapDuration, baseDiscountPerYear
);
emit PendlePTHybridFeedCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.PENDLE_PT_HYBRID, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Pendle LP feed
* @param ptMarket The address of the Pendle PT market
* @param description The description of the feed
* @return The address of the new feed
*/
function createPendleLPFeed(
address ptMarket,
string memory description,
uint32 twapDuration
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.PENDLE_LP_FEED);
IEOPendleLPFeed(deployedFeed).initialize(_pendlePTOracle, ptMarket, description, twapDuration);
emit PendleLPFeedCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.PENDLE_LP_FEED, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Spectra PT linear discount feed
* @param ptToken The address of the Spectra PT token
* @param description The description of the feed
* @param initialImpliedAPY The initial implied APY
* @param discountType The type of the discount, for now only LINEAR (0) is supported
* @param decimals The decimals of the price feed, if 0 - use the underlying decimals
* @return The address of the new feed
*/
function createSpectraPTFeed(
address ptToken,
string memory description,
uint256 initialImpliedAPY,
IEOSpectraPTFeed.DiscountType discountType,
uint8 decimals
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.SPECTRA_PT);
IEOSpectraPTFeed(deployedFeed).initialize(ptToken, description, initialImpliedAPY, discountType, decimals);
emit SpectraPTFeedCreated(deployedFeed, discountType, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.SPECTRA_PT, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Spectra PT hybrid feed
* @param pool The address of the Spectra pool
* @param description The description of the feed
* @param initialImpliedAPY The initial implied APY
* @param decimals The decimals of the price feed, if 0 - use the underlying decimals
* @return The address of the new feed
*/
function createSpectraPTFeedHybrid(
address pool,
string memory description,
uint256 initialImpliedAPY,
uint8 decimals
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.SPECTRA_PT_HYBRID);
IEOSpectraPTFeedHybrid(deployedFeed).initialize(pool, description, initialImpliedAPY, decimals);
emit SpectraPTHybridFeedCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.SPECTRA_PT_HYBRID, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new LP YAP feed
* @param lpYAP The address of the LP YAP
* @param tokenAFeed The address of the token A feed
* @param tokenBFeed The address of the token B feed
* @param maxTickDeviation The maximum tick deviation in 8 decimals format
* @param description The description of the feed
* @return The address of the new feed
*/
function createLPYAPFeed(
address lpYAP,
address tokenAFeed,
address tokenBFeed,
uint256 maxTickDeviation,
string memory description
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.LP_YAP_FEED);
IEOLPYAPFeed(deployedFeed).initialize(lpYAP, tokenAFeed, tokenBFeed, maxTickDeviation, description);
emit LPYAPFeedCreated(deployedFeed, tokenAFeed, tokenBFeed, maxTickDeviation, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.LP_YAP_FEED, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Single Feed Adapter
* @param feed The address of the feed
* @param description The description of the feed
* @return The address of the new feed
*/
function createSingleFeedAdapter(
IEOFeedAdapterBase.Feed memory feed,
uint8 outputDecimals,
string memory description
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.SINGLE_FEED_ADAPTER);
IEOSingleFeedAdapter(deployedFeed).initialize(feed, outputDecimals, description);
emit SingleFeedAdapterCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.SINGLE_FEED_ADAPTER, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Multi Feed Adapter
* @dev calculation of the final price is based on baseFeeds and quoteFeeds, adjusted to the outputDecimals
* @param baseFeeds The base feeds
* @param quoteFeeds The quote feeds
* @param outputDecimals The output decimals
* @param description The description of the feed
* @return The address of the new feed
*/
function createEOMultiFeedAdapter(
IEOFeedAdapterBase.Feed[] memory baseFeeds,
IEOFeedAdapterBase.Feed[] memory quoteFeeds,
uint8 outputDecimals,
string memory description
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.MULTI_FEED_ADAPTER);
IEOMultiFeedAdapter(deployedFeed).initialize(baseFeeds, quoteFeeds, outputDecimals, description);
emit MultiFeedAdapterCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.MULTI_FEED_ADAPTER, msg.sender);
return deployedFeed;
}
/**
* @notice Create a new Morpho Oracle
* @param baseVault The address of the base vault
* @param baseFeed1 The address of the first base feed
* @param baseFeed2 The address of the second base feed
* @param quoteFeed1 The address of the quote feed
* @param baseTokenDecimals The decimals of the base token
* @param quoteTokenDecimals The decimals of the quote token
* @return The address of the new oracle
*/
function createMorphoOracle(
address baseVault,
address baseFeed1,
address baseFeed2,
address quoteFeed1,
uint8 baseTokenDecimals,
uint8 quoteTokenDecimals,
string memory description
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
if (_morphoFactory == address(0)) revert MorphoFactoryZeroAddress();
uint256 baseVaultConversionSample = baseVault != address(0) ? 10 ** IDecimals(baseVault).decimals() : 1;
address deployedOracle = address(
IMorphoChainlinkOracleV2Factory(_morphoFactory).createMorphoChainlinkOracleV2(
IERC4626(baseVault), // baseVault
baseVaultConversionSample, // baseVaultConversionSample
AggregatorV3Interface(baseFeed1), // baseFeed1
AggregatorV3Interface(baseFeed2), // baseFeed2
baseTokenDecimals, // baseTokenDecimals
IERC4626(address(0)), // quoteVault
1, // quoteVaultConversionSample
AggregatorV3Interface(quoteFeed1), // quoteFeed1
AggregatorV3Interface(address(0)), // quoteFeed2
quoteTokenDecimals, // quoteTokenDecimals
bytes32(0) // salt
)
);
// slither-disable-next-line reentrancy-no-eth
_addArtifact(deployedOracle, description, ArtifactType.MORPHO_ORACLE, msg.sender);
emit MorphoOracleCreated(deployedOracle, msg.sender);
return deployedOracle;
}
/**
* @notice Create a new ERC4626 Capped Feed Adapter
* @param vault The address of the ERC4626 vault
* @param description The description of the feed
* @param maxYearlyGrowthPercent The maximum allowed annual growth rate (0-100)
* @param maxUpdateStep The maximum allowed increase in maxYearlyGrowthPercent during an update (0-100)
* @return The address of the new feed
*/
function createERC4626CappedFeedAdapter(
address vault,
string memory description,
uint256 maxYearlyGrowthPercent,
uint256 maxUpdateStep
)
external
onlyRole(DEPLOYER_ROLE)
returns (address)
{
address deployedFeed = _deployArtifact(ArtifactType.ERC4626_CAPPED_FEED_ADAPTER);
IEOERC4626CappedFeedAdapter(deployedFeed).initialize(
_initialProxyOwner, vault, description, maxYearlyGrowthPercent, maxUpdateStep
);
emit ERC4626CappedFeedAdapterCreated(deployedFeed, msg.sender);
_addArtifact(deployedFeed, description, ArtifactType.ERC4626_CAPPED_FEED_ADAPTER, msg.sender);
return deployedFeed;
}
/**
* @notice Set the morpho factory
* @param morphoFactory The address of the morpho factory
*/
function setMorphoFactory(address morphoFactory) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setMorphoFactory(morphoFactory);
}
/**
* @notice Set the Pendle PT oracle
* @param pendlePTOracle The address of the Pendle PT oracle
*/
function setPendlePTOracle(address pendlePTOracle) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setPendlePTOracle(pendlePTOracle);
}
/**
* @notice Set the implementation address for a given artifact type
* @dev artifactType enum 0: PENDLE_PT_TWAP, 1: PENDLE_PT_LINEAR_DISCOUNT, 2: SPECTRA_PT, 3: MULTI_FEED_ADAPTER,
* 4: MORPHO_ORACLE (zero address), 5: PENDLE_PT_HYBRID, 6: LP_YAP_FEED, 7: SINGLE_FEED_ADAPTER, 8: PENDLE_LP_FEED,
* 9: SPECTRA_PT_HYBRID, 10: ERC4626_CAPPED_FEED_ADAPTER
* @param artifactType The type of the artifact, enum ArtifactType
* @param implementation The address of the implementation
*/
function setImplementation(
ArtifactType artifactType,
address implementation
)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
_setImplementation(artifactType, implementation);
}
/**
* @notice Delete an artifact from storage
* @param artifactAddress The address of the artifact
*/
function deleteArtifact(address artifactAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
_deleteArtifact(artifactAddress);
}
/**
* @notice Add an artifact to storage
* @param artifactAddress The address of the artifact
* @param description The description of the artifact
* @param artifactType The type of the artifact, enum ArtifactType
* PENDLE_PT_TWAP(0), PENDLE_PT_LINEAR_DISCOUNT(1), SPECTRA_PT(2), MULTI_FEED_ADAPTER(3), MORPHO_ORACLE(4),
* PENDLE_PT_HYBRID(5), LP_YAP_FEED(6), SINGLE_FEED_ADAPTER(7), PENDLE_LP_FEED(8), SPECTRA_PT_HYBRID(9),
* ERC4626_CAPPED_FEED_ADAPTER(10)
* @param deployer The address of the deployer
*/
function addArtifact(
address artifactAddress,
string memory description,
ArtifactType artifactType,
address deployer
)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
_addArtifact(artifactAddress, description, artifactType, deployer);
}
/**
* @notice Set the proxy pattern
* @dev ProxyPattern enum: CLONE(0), TRANSPARENT(2)
* @param proxyPattern The proxy pattern, enum ProxyPattern
*/
function setProxyPattern(ProxyPattern proxyPattern) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setProxyPattern(proxyPattern);
}
/**
* @notice Set the initial proxy owner
* @param initialProxyOwner The address of the initial proxy owner
*/
function setInitialProxyOwner(address initialProxyOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setInitialProxyOwner(initialProxyOwner);
}
/**
* @notice Get an artifact from storage
* @param artifactAddress The address of the artifact
* @return The artifact, struct FactoryArtifact: description, artifactType, deployer
* where artifactType(PENDLE_PT_TWAP:0, PENDLE_PT_LINEAR_DISCOUNT:1, SPECTRA_PT:2, MULTI_FEED_ADAPTER:3,
* MORPHO_ORACLE:4, PENDLE_PT_HYBRID:5, LP_YAP_FEED:6, SINGLE_FEED_ADAPTER:7, PENDLE_LP_FEED:8)
*/
function getArtifactByAddress(address artifactAddress) external view returns (FactoryArtifact memory) {
return _artifacts[artifactAddress];
}
/**
* @notice Get all artifact addresses
* @return The artifact addresses
*/
function getArtifactAddresses() external view returns (address[] memory) {
return _artifactsAddresses.values();
}
/**
* @notice Get the number of artifacts
* @return The number of artifacts
*/
function getArtifactsAmount() external view returns (uint256) {
return _artifactsAddresses.length();
}
/**
* @notice Get the Pendle PT oracle
* @return The Pendle PT oracle
*/
function getPendlePTOracle() external view returns (address) {
return _pendlePTOracle;
}
/**
* @notice Get the Morpho factory
* @return The Morpho factory
*/
function getMorphoFactory() external view returns (address) {
return _morphoFactory;
}
/**
* @notice Get the implementation addresses
* @dev artifactType enum 0: PENDLE_PT_TWAP, 1: PENDLE_PT_LINEAR_DISCOUNT, 2: SPECTRA_PT, 3: MULTI_FEED_ADAPTER,
* 4: MORPHO_ORACLE (zero address), 5: PENDLE_PT_HYBRID, 6: LP_YAP_FEED, 7: SINGLE_FEED_ADAPTER, 8: PENDLE_LP_FEED,
* 9: SPECTRA_PT_HYBRID, 10: ERC4626_CAPPED_FEED_ADAPTER
* @return The implementation addresses array
*/
function getImplementations() external view returns (address[] memory) {
address[] memory implementations = new address[](uint256(ArtifactType.LENGTH));
for (uint256 i = 0; i < uint256(ArtifactType.LENGTH); i++) {
implementations[i] = _implementationAddresses[ArtifactType(i)];
}
return implementations;
}
/**
* @notice Get the implementation address for a given artifact type
* @dev artifactType enum 0: PENDLE_PT_TWAP, 1: PENDLE_PT_LINEAR_DISCOUNT, 2: SPECTRA_PT, 3: MULTI_FEED_ADAPTER,
* 4: MORPHO_ORACLE (zero address), 5: PENDLE_PT_HYBRID, 6: LP_YAP_FEED, 7: SINGLE_FEED_ADAPTER, 8: PENDLE_LP_FEED,
* 9: SPECTRA_PT_HYBRID, 10: ERC4626_CAPPED_FEED_ADAPTER
* @param artifactType The type of the artifact, enum ArtifactType
* @return The implementation address
*/
function getImplementation(ArtifactType artifactType) external view returns (address) {
return _implementationAddresses[artifactType];
}
/**
* @notice Get the proxy pattern
* @dev ProxyPattern enum: CLONE(0), TRANSPARENT(2)
* @return The proxy pattern, enum ProxyPattern
*/
function getProxyPattern() external view returns (ProxyPattern) {
return _proxyPattern;
}
/**
* @notice Set the proxy pattern
* @param proxyPattern The proxy pattern, enum ProxyPattern
*/
function _setProxyPattern(ProxyPattern proxyPattern) internal {
_proxyPattern = proxyPattern;
emit ProxyPatternSet(proxyPattern);
}
/**
* @notice Deploy an artifact depending on the configured proxy pattern
* @param artifactType The type of the artifact, enum ArtifactType
* @return deployedArtifact The address of the deployed artifact
*/
function _deployArtifact(ArtifactType artifactType) internal returns (address deployedArtifact) {
if (_implementationAddresses[artifactType] == address(0)) revert ImplementationZeroAddress();
if (_proxyPattern == ProxyPattern.CLONE) {
deployedArtifact = Clones.clone(_implementationAddresses[artifactType]);
} else if (_proxyPattern == ProxyPattern.TRANSPARENT) {
deployedArtifact =
address(new TransparentUpgradeableProxy(_implementationAddresses[artifactType], _initialProxyOwner, ""));
} else {
revert InvalidProxyPattern();
}
}
/**
* @notice Add an artifact to storage
* @param artifactAddress The address of the artifact
* @param description The description of the artifact
* @param artifactType The type of the artifact, enum ArtifactType
* @param deployer The address of the deployer
*/
function _addArtifact(
address artifactAddress,
string memory description,
ArtifactType artifactType,
address deployer
)
internal
{
_artifacts[artifactAddress] =
FactoryArtifact({ description: description, artifactType: artifactType, deployer: deployer });
_artifactsAddresses.add(artifactAddress);
}
/**
* @notice Delete an artifact from storage
* @param artifactAddress The address of the artifact
*/
function _deleteArtifact(address artifactAddress) internal {
delete _artifacts[artifactAddress];
_artifactsAddresses.remove(artifactAddress);
}
/**
* @notice Set the Morpho factory internal function
* @param morphoFactory The address of the Morpho factory, could be zero address, some chains don't have it deployed
*/
function _setMorphoFactory(address morphoFactory) internal {
_morphoFactory = morphoFactory;
emit MorphoFactorySet(morphoFactory);
}
/**
* @notice Set the Pendle PT oracle
* @param pendlePTOracle The address of the Pendle PT oracle, could be zero address, some chains don't have it
* deployed
*/
function _setPendlePTOracle(address pendlePTOracle) internal {
_pendlePTOracle = pendlePTOracle;
emit PendlePTOracleSet(pendlePTOracle);
}
/**
* @notice Set the implementations
* @param implementations The implementations
*/
function _setImplementations(address[] memory implementations) internal {
if (implementations.length != uint256(ArtifactType.LENGTH)) revert InvalidImplementationsLength();
for (uint256 i = 0; i < uint256(ArtifactType.LENGTH); i++) {
// if not morpho, which has no implementation, set the implementation
if (i != uint256(ArtifactType.MORPHO_ORACLE)) {
_setImplementation(ArtifactType(i), implementations[i]);
}
}
}
/**
* @notice Set the implementation address for a given artifact type
* @param artifactType The type of the artifact, enum ArtifactType
* @param implementation The address of the implementation
*/
function _setImplementation(ArtifactType artifactType, address implementation) internal {
if (implementation == address(0)) revert ImplementationZeroAddress();
_implementationAddresses[artifactType] = implementation;
emit ImplementationSet(artifactType, implementation);
}
/**
* @notice Set the initial proxy owner
* @param initialProxyOwner The address of the initial proxy owner
*/
function _setInitialProxyOwner(address initialProxyOwner) internal {
if (initialProxyOwner == address(0)) revert InitialProxyOwnerZeroAddress();
_initialProxyOwner = initialProxyOwner;
emit InitialProxyOwnerSet(initialProxyOwner);
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
"
},
"src/interfaces/IEOMultiFeedAdapter.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import { IEOFeedAdapterBase } from "./IEOFeedAdapterBase.sol";
/**
* @title IEOMultiFeedAdapter
* @author EO
* @notice Interface for the EOMultiFeedAdapter contract.
*/
interface IEOMultiFeedAdapter is IEOFeedAdapterBase {
/**
* @notice The error emitted when the maximum number of base feeds is exceeded.
*/
error MaxBaseFeedsExceeded();
/**
* @notice The error emitted when the maximum number of quote feeds is exceeded.
*/
error MaxQuoteFeedsExceeded();
/**
* @notice The error emitted when the maximum number of decimals is exceeded.
*/
error MaxDecimalsExceeded();
/**
* @notice The error emitted when no feeds are provided.
*/
error NoFeedsProvided();
/**
* @notice The error emitted when the potential rate overflow is detected.
*/
error PotentialRateOverflow();
function initialize(
Feed[] memory baseFeeds_,
Feed[] memory quoteFeeds_,
uint8 outputDecimals_,
string memory description_
)
external;
function getBaseFeeds() external view returns (Feed[] memory);
function getBaseFeed(uint256 index) external view returns (Feed memory);
function getQuoteFeeds() external view returns (Feed[] memory);
function getQuoteFeed(uint256 index) external view returns (Feed memory);
}
"
},
"src/interfaces/IEOSingleFeedAdapter.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import { IEOFeedAdapterBase } from "./IEOFeedAdapterBase.sol";
/**
* @title IEOSingleFeedAdapter
* @author EO
* @notice Interface for the EOSingleFeedAdapter contract.
*/
interface IEOSingleFeedAdapter is IEOFeedAdapterBase {
function initialize(Feed memory feed_, uint8 outputDecimals_, string memory description_) external;
function getFeed() external view returns (Feed memory);
}
"
},
"src/interfaces/IEOFeedAdapterBase.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOFeedAdapterBase
* @author EO
* @notice Interface for the Feed Adapter contracts.
*/
interface IEOFeedAdapterBase {
/**
* @notice The enum of the feed interfaces.
* @dev supports the following interfaces:
* 0: MinimalAggregatorV3Interface,
* 1: IERC4626,
* 2: ICustomAdapter
*/
enum FeedInterface {
MINIMAL_AGGREGATOR_V3_INTERFACE,
IERC4626_VAULT,
CUSTOM_ADAPTER_INTERFACE
}
/**
* @notice The struct of the feed.
* @param feedInterface The interface of the feed
* @param feedAddress The address of the feed.
* @param customAdapterAddress The address of the custom adapter.
*/
struct Feed {
FeedInterface feedInterface;
address feedAddress;
address customAdapterAddress; // only used if feedInterface is CUSTOM_ADAPTER_INTERFACE
}
/**
* @notice The error emitted when the feed address is invalid.
*/
error InvalidFeedAddress();
}
"
},
"src/interfaces/IEOLPYAPFeed.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOLPYAPFeed
* @author EO
* @notice Interface for the EOLPYAPFeed contract.
*/
interface IEOLPYAPFeed {
/**
* @notice The error for the LP YAP token address is zero.
*/
error LPYAPTokenAddressIsZero();
/**
* @notice The error for the token A feed address is zero.
*/
error TokenAFeedAddressIsZero();
/**
* @notice The error for the token B feed address is zero.
*/
error TokenBFeedAddressIsZero();
/**
* @notice The error for the maximum tick deviation is zero.
*/
error MaxTickDeviationIsZero();
/**
* @notice The error for the total supply is zero.
*/
error TotalSupplyIsZero();
/**
* @notice The error for the rate feed A is zero.
*/
error RateFeedAIsZero();
/**
* @notice The error for the rate feed B is zero.
*/
error RateFeedBIsZero();
/**
* @notice The error for the tick deviation exceeded.
*/
error TickDeviationExceeded();
function initialize(
address lpYAPToken_,
address tokenAFeed_,
address tokenBFeed_,
uint256 maxTickDeviation_,
string memory description_
)
external;
}
"
},
"src/interfaces/IEOPendlePTFeedTWAP.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOPendlePTFeedTWAP
* @author EO
* @notice Interface for Pendle PT TWAP feed oracle
*/
interface IEOPendlePTFeedTWAP {
/**
* @notice The type of the TWAP
* @dev PT_TO_SY: 0
* @dev PT_TO_ASSET: 1
*/
enum TWAPType {
PT_TO_SY,
PT_TO_ASSET
}
/**
* @notice Error thrown when the PT market address is zero.
*/
error PTMarketAddressIsZero();
/**
* @notice Error thrown when the PT oracle address is zero.
*/
error PTOracleAddressIsZero();
/**
* @notice Error thrown when the TWAP duration is zero.
*/
error TwapDurationIsZero();
/**
* @notice Error thrown when the TWAP duration is less than the minimum duration.
*/
error TwapDurationIsLessThanMin();
/**
* @notice Error thrown when the Pendle market oldest observation is not satisfied.
*/
error PendleMarketOldestObservationIsNotSatisfied();
/**
* @notice Error thrown when the Pendle market cardinality is low and needs to be increased.
* @param cardinalityRequired The required cardinality
*/
error PendleMarketCardinalityIsLow(uint16 cardinalityRequired);
/**
* @notice Error thrown when the Pendle market PT to SY rate returns 0.
*/
error PendleMarketPTToSYRateIsZero();
/**
* @notice Error thrown when the Pendle market PT to Asset rate returns 0.
*/
error PendleMarketPTToAssetRateIsZero();
/**
* @notice Error thrown when the TWAP type is invalid.
*/
error InvalidTWAPType();
function initialize(
address ptOracle_,
address ptMarket_,
string memory description_,
uint32 twapDuration_,
TWAPType twapType_
)
external;
}
"
},
"src/interfaces/IEOPendlePTFeedLinearDiscount.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOPendlePTFeedLinearDiscount
* @author EO
* @notice Interface for Pendle PT linear discount feed oracle.
*/
interface IEOPendlePTFeedLinearDiscount {
/**
* @notice Error thrown when the PT token address is zero.
*/
error PTTokenAddressIsZero();
/**
* @notice Error thrown when the base discount per year is less than 1e18.
*/
error BaseDiscountPerYearIsTooHigh();
/**
* @notice Error thrown when the discount overflows.
*/
error DiscountOverflow();
function initialize(address ptToken_, string memory description_, uint256 baseDiscountPerYear_) external;
}
"
},
"src/interfaces/IEOSpectraPTFeed.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOSpectraPTFeed
* @author EO
* @notice Interface for Spectra PT feed oracle, based on selected discount type.
*/
interface IEOSpectraPTFeed {
/**
* @notice The type of the discount
* @dev LINEAR: 0
*/
enum DiscountType {
LINEAR
}
/**
* @notice Error thrown when the PT token address is zero.
*/
error PTTokenAddressIsZero();
/**
* @notice Error thrown when the discount type is invalid.
*/
error InvalidDiscountType();
/**
* @notice Error thrown when the price is zero.
*/
error PriceMustBeGreaterThanZero();
function initialize(
address ptToken_,
string memory description_,
uint256 initialImpliedAPY_,
DiscountType discountType_,
uint8 decimals_
)
external;
}
"
},
"src/interfaces/IEOPendlePTFeedHybrid.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOPendlePTFeedHybrid
* @author EO
* @notice Interface for Pendle PT Hybrid feed oracle
*/
interface IEOPendlePTFeedHybrid {
/**
* @notice Error thrown when the PT market address is zero.
*/
error PTMarketAddressIsZero();
/**
* @notice Error thrown when the PT oracle address is zero.
*/
error PTOracleAddressIsZero();
/**
* @notice Error thrown when the TWAP duration is zero.
*/
error TwapDurationIsZero();
/**
* @notice Error thrown when the TWAP duration is less than the minimum duration.
*/
error TwapDurationIsLessThanMin();
/**
* @notice Error thrown when the Pendle market oldest observation is not satisfied.
*/
error PendleMarketOldestObservationIsNotSatisfied();
/**
* @notice Error thrown when the Pendle market cardinality is low and needs to be increased.
* @param cardinalityRequired The required cardinality
*/
error PendleMarketCardinalityIsLow(uint16 cardinalityRequired);
/**
* @notice Error thrown when the Pendle market PT to Asset rate returns 0.
*/
error PendleMarketPTToAssetRateIsZero();
/**
* @notice Error thrown when the base discount per year is less than 1e18.
*/
error BaseDiscountPerYearIsTooHigh();
/**
* @notice Error thrown when the discount overflows.
*/
error DiscountOverflow();
function initialize(
address ptOracle_,
address ptMarket_,
string memory description_,
uint32 twapDuration_,
uint256 baseDiscountPerYear_
)
external;
}
"
},
"src/interfaces/IEOSpectraPTFeedHybrid.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOSpectraPTFeedHybrid
* @author EO
* @notice Interface for Spectra PT Hybrid feed oracle
*/
interface IEOSpectraPTFeedHybrid {
/**
* @notice Error thrown when the pool address is zero.
*/
error PoolAddressIsZero();
/**
* @notice Error thrown when the pool type is not supported.
*/
error PoolTypeNotSupported();
function initialize(
address pool_,
string memory description_,
uint256 initialImpliedAPY_,
uint8 decimals_
)
external;
}
"
},
"src/interfaces/IEOPendleLPFeed.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IEOPendleLPFeed
* @author EO
* @notice Interface for Pendle LP feed oracle
*/
interface IEOPendleLPFeed {
/**
* @notice Error thrown when the PT market address is zero.
*/
error PTMarketAddressIsZero();
/**
* @notice Error thrown when the PT oracle address is zero.
*/
error PTOracleAddressIsZero();
/**
* @notice Error thrown when the TWAP duration is zero.
*/
error TwapDurationIsZero();
/**
* @notice Error thrown when the TWAP duration is less than the minimum duration.
*/
error TwapDurationIsLessThanMin();
/**
* @notice Error thrown when the Pendle market oldest observation is not satisfied.
*/
error PendleMarketOldestObservationIsNotSatisfied();
/**
* @notice Error thrown when the Pendle market cardinality is low and needs to be increased.
* @param cardinalityRequired The required cardinality
*/
error PendleMarketCardinalityIsLow(uint16 cardinalityRequired);
/**
* @notice Error thrown when the Pendle market LP to SY rate returns 0.
*/
error PendleMarketLPToSYRateIsZero();
function initialize(
address ptOracle_,
address ptMarket_,
string memory description_,
uint32 twapDuration_
)
external;
}
"
},
"src/interfaces/IEOERC4626CappedFeedAdapter.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import { CapUtils } from "../libraries/CapUtils.sol";
/**
* @title IEOERC4626CappedFeedAdapter
* @author EO
* @notice Interface for the EOERC4626CappedFeedAdapter contract.
*/
interface IEOERC4626CappedFeedAdapter {
/**
* @notice Event emitted when maxYearlyGrowthPercent is updated.
* @param oldValue The old maxYearlyGrowthPercent value.
* @param newValue The new maxYearlyGrowthPercent value.
*/
event MaxYearlyGrowthPercentUpdated(uint256 oldValue, uint256 newValue);
/**
* @notice The error emitted when an invalid feed address is provided.
*/
error InvalidFeedAddress();
function initialize(
address owner_,
address vault_,
string memory description_,
uint256 maxYearlyGrowthPercent_,
uint256 maxUpdateStep_
)
external;
function setMaxYearlyGrowthPercent(uint256 maxYearlyGrowthPercentNew) external;
function getVault() external view returns (IERC4626);
function getCapConfig() external view returns (CapUtils.CapConfig memory);
}
"
},
"src/interfaces/morpho-chainlink/IMorphoChainlinkOracleV2Factory.sol": {
"content": "// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.25;
import { IERC4626 } from "./IERC4626.sol";
import { AggregatorV3Interface } from "./AggregatorV3Interface.sol";
import { IMorphoChainlinkOracleV2 } from "./IMorphoChainlinkOracleV2.sol";
/// @title IMorphoChainlinkOracleV2Factory
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Interface for MorphoChainlinkOracleV2Factory
interface IMorphoChainlinkOracleV2Factory {
/// @notice Emitted when a new Chainlink oracle is created.
/// @param oracle The address of the Chainlink oracle.
/// @param caller The caller of the function.
event CreateMorphoChainlinkOracleV2(address caller, address oracle);
/// @notice Whether a Chainlink oracle vault was created with the factory.
function isMorphoChainlinkOracleV2(address target) external view returns (bool);
/// @dev Here is the list of assumptions that guarantees the oracle behaves as expected:
/// - The vaults, if set, are ERC4626-compliant.
/// - The feeds, if set, are Chainlink-interface-compliant.
/// - Decimals passed as argument are correct.
/// - The base vaults's sample shares quoted as assets and the base feed prices don't overflow when multiplied.
/// - The quote vault's sample shares quoted as assets and the quote feed prices don't overflow when multiplied.
/// @param baseVault Base vault. Pass address zero to omit this parameter.
/// @param baseVaultConversionSample The sample amount of base vault shares used to convert to underlying.
/// Pass 1 if the base asset is not a vault. Should be chosen such that converting `baseVaultConversionSample` to
/// assets has enough precision.
/// @param baseFeed1 First base feed. Pass address zero if the price = 1.
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
/// @param baseTokenDecimals Base token decimals.
/// @param quoteVault Quote vault. Pass address zero to omit this parameter.
/// @param quoteVaultConversionSample The sample amount of quote vault shares used to convert to underlying.
/// Pass 1 if the quote asset is not a vault. Should be chosen such that converting `quoteVaultConversionSample` to
/// assets has enough precision.
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
/// @param quoteTokenDecimals Quote token decimals.
/// @param salt The salt to use for the CREATE2.
/// @dev The base asset should be the collateral token and the quote asset the loan token.
function createMorphoChainlinkOracleV2(
IERC4626 baseVault,
uint256 baseVaultConversionSample,
AggregatorV3Interface baseFeed1,
AggregatorV3Interface baseFeed2,
uint256 baseTokenDecimals,
IERC4626 quoteVault,
uint256 quoteVaultConversionSample,
AggregatorV3Interface quoteFeed1,
AggregatorV3Interface quoteFeed2,
uint256 quoteTokenDecimals,
bytes32 salt
)
external
returns (IMorphoChainlinkOracleV2 oracle);
}
"
},
"src/interfaces/morpho-chainlink/AggregatorV3Interface.sol": {
"content": "// SPDX-License-Identifier: MIT
// solhint-disable compiler-version
pragma solidity 0.8.25;
// solhint-disable max-line-length
/// @dev From
/// https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}
"
},
"src/interfaces/morpho-chainlink/IERC4626.sol": {
"content": "// SPDX-License-Identifier: GPL-2.0-or-later
// solhint-disable compiler-version
pragma solidity 0.8.25;
interface IERC4626 {
function convertToAssets(uint256) external view returns (uint256);
}
"
},
"src/interfaces/IDecimals.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @title IDecimals
* @author EO
* @notice Interface for the contract with decimals method.
*/
interface IDecimals {
/**
* @notice The function to get the decimals.
* @return The decimals.
*/
function decimals() external view returns (uint8);
}
"
},
"lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
import {Arrays} from "../Arrays.sol";
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
* - Set can be cleared (all elements removed) in O(n).
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function _clear(Set storage set) private {
uint256 len = _length(set);
for (uint256 i = 0; i < len; ++i) {
delete set._positions[set._values[i]];
}
Arrays.unsafeSetLength(set._values, 0);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32Set storage set) internal {
_clear(set._inner);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a
Submitted on: 2025-10-28 14:29:52
Comments
Log in to comment.
No comments yet.