SupplyVaultBase

Git Source

Inherits: ISupplyVaultBase, ERC4626UpgradeableSafe, OwnableUpgradeable

Author: Morpho Labs.

ERC4626-upgradeable Tokenized Vault abstract implementation for Morpho-Aave V2.

State Variables

morpho

IMMUTABLES ///

IMorpho public immutable morpho;

morphoToken

ERC20 public immutable morphoToken;

lens

ILens public immutable lens;

recipient

address public immutable recipient;

poolToken

STORAGE ///

address public poolToken;

__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[49] private __gap;

Functions

constructor

CONSTRUCTOR ///

Initializes network-wide immutables.

constructor(address _morpho, address _morphoToken, address _lens, address _recipient);

Parameters

NameTypeDescription
_morphoaddressThe address of the main Morpho contract.
_morphoTokenaddressThe address of the Morpho Token.
_lensaddressThe address of the Morpho Lens.
_recipientaddressThe recipient of the rewards that will redistribute them to vault's users.

__SupplyVaultBase_init

INITIALIZER ///

Initializes the vault.

function __SupplyVaultBase_init(
    address _poolToken,
    string calldata _name,
    string calldata _symbol,
    uint256 _initialDeposit
) internal onlyInitializing;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the pool token corresponding to the market to supply through this vault.
_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.

__SupplyVaultBase_init_unchained

Initializes the vault whithout initializing parent contracts (avoid the double initialization problem).

function __SupplyVaultBase_init_unchained(address _poolToken)
    internal
    onlyInitializing
    returns (ERC20 underlyingToken);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the pool token corresponding to the market to supply through this vault.

transferRewards

EXTERNAL ///

Transfers the MORPHO rewards to the rewards recipient.

function transferRewards() external;

totalAssets

PUBLIC ///

The amount of assets in the vault.

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

deposit

Deposits an amount of assets into the vault and receive vault shares.

function deposit(uint256 assets, address receiver)
    public
    virtual
    override(IERC4626Upgradeable, ERC4626Upgradeable)
    returns (uint256);

Parameters

NameTypeDescription
assetsuint256The amount of assets to deposit.
receiveraddressThe recipient of the vault shares.

mint

Mints shares of the vault and transfers assets to the vault.

function mint(uint256 shares, address receiver)
    public
    virtual
    override(IERC4626Upgradeable, ERC4626Upgradeable)
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256The number of shares to mint.
receiveraddressThe recipient of the vault shares.

withdraw

Withdraws an amount of assets from the vault and burn an owner's shares.

function withdraw(uint256 assets, address receiver, address owner)
    public
    virtual
    override(IERC4626Upgradeable, ERC4626Upgradeable)
    returns (uint256);

Parameters

NameTypeDescription
assetsuint256The number of assets to withdraw.
receiveraddressThe recipient of the assets.
owneraddressThe owner of the vault shares.

redeem

Burn an amount of shares and receive assets.

function redeem(uint256 shares, address receiver, address owner)
    public
    virtual
    override(IERC4626Upgradeable, ERC4626Upgradeable)
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256The number of shares to burn.
receiveraddressThe recipient of the assets.
owneraddressThe owner of the assets.

_deposit

INTERNAL ///

function _deposit(address _caller, address _receiver, uint256 _assets, uint256 _shares) internal virtual override;

_withdraw

function _withdraw(address _caller, address _receiver, address _owner, uint256 _assets, uint256 _shares)
    internal
    virtual
    override;

Events

RewardsTransferred

EVENTS ///

Emitted when MORPHO rewards are transferred to recipient.

event RewardsTransferred(address recipient, uint256 amount);

Errors

ZeroAddress

ERRORS ///

Thrown when the zero address is passed as input or is the recipient address when calling transferRewards.

error ZeroAddress();