Quantillon Protocol

MetaMorphoStakingVaultAdapter

Git Source

Inherits: AccessControl, ReentrancyGuard, IExternalStakingVault

Title: MetaMorphoStakingVaultAdapter

Adapter for MetaMorpho ERC-4626 vaults such as 0xBEEFE94c8aD530842bfE7d8B397938fFc1cb83b2.

Constants

GOVERNANCE_ROLE

bytes32 public constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE")

VAULT_MANAGER_ROLE

bytes32 public constant VAULT_MANAGER_ROLE = keccak256("VAULT_MANAGER_ROLE")

USDC

IERC20 public immutable USDC

State Variables

metaMorphoVault

IERC4626 public metaMorphoVault

yieldShift

IYieldShift public yieldShift

yieldVaultId

uint256 public yieldVaultId

yieldSource

bytes32 public yieldSource

principalDeposited

uint256 public principalDeposited

Functions

constructor

constructor(
    address admin,
    address usdc_,
    address metaMorphoVault_,
    address yieldShift_,
    uint256 yieldVaultId_,
    bytes32 yieldSource_
) ;

depositUnderlying

Deposits USDC into the MetaMorpho ERC-4626 vault and tracks principal.

function depositUnderlying(uint256 usdcAmount)
    external
    override
    onlyRole(VAULT_MANAGER_ROLE)
    nonReentrant
    returns (uint256 sharesReceived);

Parameters

NameTypeDescription
usdcAmountuint256Amount of USDC to deposit.

Returns

NameTypeDescription
sharesReceiveduint256MetaMorpho shares minted to this adapter.

withdrawUnderlying

Withdraws tracked principal from MetaMorpho and returns USDC to the caller.

function withdrawUnderlying(uint256 usdcAmount)
    external
    override
    onlyRole(VAULT_MANAGER_ROLE)
    nonReentrant
    returns (uint256 usdcWithdrawn);

Parameters

NameTypeDescription
usdcAmountuint256Requested USDC amount.

Returns

NameTypeDescription
usdcWithdrawnuint256Actual USDC amount withdrawn.

harvestYield

Harvests accrued ERC-4626 share yield and routes it to YieldShift.

function harvestYield()
    external
    override
    onlyRole(VAULT_MANAGER_ROLE)
    nonReentrant
    returns (uint256 harvestedYield);

Returns

NameTypeDescription
harvestedYielduint256Yield harvested in USDC.

totalUnderlying

Returns the USDC value of this adapter's MetaMorpho shares.

function totalUnderlying() external view override returns (uint256 underlyingBalance);

setMetaMorphoVault

function setMetaMorphoVault(address newMetaMorphoVault) external onlyRole(GOVERNANCE_ROLE);

setYieldShift

function setYieldShift(address newYieldShift) external onlyRole(GOVERNANCE_ROLE);

setYieldVaultId

function setYieldVaultId(uint256 newYieldVaultId) external onlyRole(GOVERNANCE_ROLE);

setYieldSource

function setYieldSource(bytes32 newYieldSource) external onlyRole(GOVERNANCE_ROLE);

_totalUnderlying

function _totalUnderlying() internal view returns (uint256);

Events

MetaMorphoVaultUpdated

event MetaMorphoVaultUpdated(address indexed oldVault, address indexed newVault);

YieldShiftUpdated

event YieldShiftUpdated(address indexed oldYieldShift, address indexed newYieldShift);

YieldVaultIdUpdated

event YieldVaultIdUpdated(uint256 indexed oldVaultId, uint256 indexed newVaultId);

YieldSourceUpdated

event YieldSourceUpdated(bytes32 indexed oldSource, bytes32 indexed newSource);