SupplyVaultBase
Inherits: ISupplyVaultBase, ERC4626UpgradeableSafe, OwnableUpgradeable
Author: Morpho Labs.
ERC4626-upgradeable Tokenized Vault abstract implementation for Morpho-Compound.
State Variables
morpho
IMMUTABLES ///
IMorpho public immutable morpho;
wEth
address public immutable wEth;
comp
ERC20 public immutable comp;
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
Name | Type | Description |
---|---|---|
_morpho | address | The address of the main Morpho contract. |
_morphoToken | address | The address of the Morpho Token. |
_lens | address | The address of the Morpho Lens. |
_recipient | address | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the pool token corresponding to the market to supply through this vault. |
_name | string | The name of this tokenized vault. |
_symbol | string | The symbol of this tokenized vault. |
_initialDeposit | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to deposit. |
receiver | address | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | The number of shares to mint. |
receiver | address | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | The number of assets to withdraw. |
receiver | address | The recipient of the assets. |
owner | address | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | The number of shares to burn. |
receiver | address | The recipient of the assets. |
owner | address | The 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();