SupplyVault

Git Source

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

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.

initialize

INITIALIZER ///

Initializes the vault.

function initialize(address _poolToken, string calldata _name, string calldata _symbol, uint256 _initialDeposit)
    external
    initializer;

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.

claimRewards

EXTERNAL ///

Claims rewards on behalf of _user.

function claimRewards(address _user) external returns (uint256 rewardsAmount);

Parameters

NameTypeDescription
_useraddressThe address of the user to claim rewards for.

Returns

NameTypeDescription
rewardsAmountuint256The 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;
}