SupplyVault

Git Source

Inherits: ISupplyVault, ERC4626UpgradeableSafe, Ownable2StepUpgradeable

Author: Morpho Labs

ERC4626-upgradeable Tokenized Vault implementation for Morpho-Aave V3.

This vault is not fully compliant to EIP-4626 because maxDeposit & maxMint do not take into account the underlying market's pause status and AaveV3's supply cap. Symmetrically, maxWithdraw & maxRedeem do not take into account the underlying market's pause status and liquidity.

State Variables

_MORPHO

The main Morpho contract.

IMorpho internal immutable _MORPHO;

_maxIterations

The max iterations to use when this vault interacts with Morpho.

uint96 internal _maxIterations;

_recipient

The recipient of the rewards that will redistribute them to vault's users.

address internal _recipient;

__gap

This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps

uint256[48] private __gap;

Functions

constructor

Initializes network-wide immutables.

The implementation contract disables initialization upon deployment to avoid being hijacked.

constructor(address morpho);

Parameters

NameTypeDescription
morphoaddressThe address of the main Morpho contract.

initialize

Initializes the vault.

function initialize(
    address newUnderlying,
    address newRecipient,
    string calldata name,
    string calldata symbol,
    uint256 initialDeposit,
    uint96 newMaxIterations
) external initializer;

Parameters

NameTypeDescription
newUnderlyingaddressThe address of the underlying market to supply through this vault to Morpho.
newRecipientaddressThe recipient to receive skimmed funds.
namestringThe name of the ERC20 token associated to this tokenized vault.
symbolstringThe symbol of the ERC20 token associated to this tokenized vault.
initialDeposituint256The amount of the initial deposit used to prevent pricePerShare manipulation.
newMaxIterationsuint96The max iterations to use when this vault interacts with Morpho.

skim

Transfers the given ERC20 tokens to the vault recipient.

This is meant to be used to transfer rewards that are claimed to the vault or rescue tokens. The vault is not intended to hold any ERC20 tokens between calls.

function skim(address[] calldata tokens) external;

setMaxIterations

Sets the max iterations to use when this vault interacts with Morpho.

function setMaxIterations(uint96 newMaxIterations) external onlyOwner;

setRecipient

Sets the recipient for the skim function.

function setRecipient(address newRecipient) external onlyOwner;

MORPHO

The address of the Morpho contract this vault utilizes.

function MORPHO() external view returns (IMorpho);

recipient

The recipient of any ERC20 tokens skimmed from this contract.

function recipient() external view returns (address);

maxIterations

The max iterations to use when this vault interacts with Morpho.

function maxIterations() external view returns (uint96);

totalAssets

The amount of assets in the vault.

function totalAssets() public view virtual override(IERC4626Upgradeable, ERC4626Upgradeable) returns (uint256);

_deposit

Used in mint or deposit to deposit the underlying asset to Morpho.

function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override;

_withdraw

Used in redeem or withdraw to withdraw the underlying asset from Morpho.

function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)
    internal
    virtual
    override;

_setMaxIterations

Sets the max iterations to use when this vault interacts with Morpho.

function _setMaxIterations(uint96 newMaxIterations) internal;

_setRecipient

Sets the recipient for the skim function.

function _setRecipient(address newRecipient) internal;