SupplyVault
Inherits: ISupplyVault, SupplyVaultBase
Author: Morpho Labs.
ERC4626-upgradeable Tokenized Vault implementation for Morpho-Compound, which tracks rewards from Compound's pool accrued by its users.
State Variables
rewardsIndex
STORAGE ///
uint256 public rewardsIndex;
userRewards
mapping(address => UserRewardsData) public userRewards;
Functions
constructor
CONSTRUCTOR ///
Initializes immutable state variables.
constructor(address _morpho, address _morphoToken, address _lens, address _recipient)
SupplyVaultBase(_morpho, _morphoToken, _lens, _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. |
initialize
INITIALIZER ///
Initializes the vault.
function initialize(address _poolToken, string calldata _name, string calldata _symbol, uint256 _initialDeposit)
external
initializer;
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 the ERC20 token associated to this tokenized vault. |
_symbol | string | The symbol of the ERC20 token associated to this tokenized vault. |
_initialDeposit | uint256 | The amount of the initial deposit used to prevent pricePerShare manipulation. |
claimRewards
EXTERNAL ///
Claims rewards on behalf of _user
.
function claimRewards(address _user) external returns (uint256 rewardsAmount);
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user to claim rewards for. |
Returns
Name | Type | Description |
---|---|---|
rewardsAmount | uint256 | The amount of rewards claimed. |
_beforeTokenTransfer
INTERNAL ///
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override;
_claimVaultRewards
function _claimVaultRewards() internal returns (uint256 newRewardsIndex);
_accrueUnclaimedRewards
function _accrueUnclaimedRewards(address _user) internal returns (uint256 unclaimed);
_accrueUnclaimedRewardsFromRewardsIndex
function _accrueUnclaimedRewardsFromRewardsIndex(address _user, uint256 _newRewardsIndex)
internal
returns (uint256 unclaimed);
Events
Accrued
EVENTS ///
Emitted when a user accrues its rewards.
event Accrued(address indexed user, uint256 index, uint256 unclaimed);
Claimed
Emitted when a user claims its rewards.
event Claimed(address indexed user, uint256 claimed);
Structs
UserRewardsData
STRUCTS ///
struct UserRewardsData {
uint128 index;
uint128 unclaimed;
}