VenusERC4626 is an upgradeable, ERC4626-compliant vault that wraps a Venus vToken, enabling standard ERC4626 vault interactions with the Venus Protocol. It manages deposits, withdrawals, minting, redeeming, and reward distribution, with additional access control and loop limit protections.
NO_ERROR (uint256, internal constant):
Error code representing no errors in Venus operations.
vToken (VToken, public):
The Venus vToken associated with this ERC4626 vault.
comptroller (IComptroller, public):
The Venus Comptroller contract responsible for market operations.
rewardRecipient (address, public):
The address that receives rewards distributed by the Venus Protocol.
ClaimRewards(uint256 amount, address indexed rewardToken)
Emitted when rewards are claimed.
amount: The amount of reward tokens claimed.
rewardToken: The address of the reward token claimed.
RewardRecipientUpdated(address indexed oldRecipient, address indexed newRecipient)
Emitted when the reward recipient address is updated.
oldRecipient: The previous reward recipient address.
newRecipient: The new reward recipient address.
SweepToken(address indexed token, address indexed receiver, uint256 amount)
Emitted when tokens are swept from the contract.
token: The token address.
receiver: The receiver address.
amount: The amount swept.
VenusERC4626__VenusError(uint256 errorCode)
Thrown when a Venus protocol call returns an error.
errorCode: The error code returned by Venus.
ERC4626__DepositMoreThanMax()
Thrown when a deposit exceeds the maximum allowed.
ERC4626__MintMoreThanMax()
Thrown when a mint operation exceeds the maximum allowed.
ERC4626__WithdrawMoreThanMax()
Thrown when a withdrawal exceeds the maximum available assets.
ERC4626__RedeemMoreThanMax()
Thrown when a redemption exceeds the maximum redeemable shares.
ERC4626__ZeroAmount(string operation)
Thrown when attempting an operation with a zero amount.
operation: The name of the operation (e.g., “deposit”, “withdraw”, “mint”, “redeem”).
@custom:oz-upgrades-unsafe-allow constructor
Disables initializers for the upgradeable contract pattern.
Initializes the VenusERC4626 vault with the associated vToken address.
function initialize ( address vToken_ ) public initializer
Name Type Description vToken_ address The vToken associated with the vault, representing the yield-bearing asset.
Only the vToken address is set in this function.
initialize2 must be called to complete the configuration.
Completes the configuration of the VenusERC4626 vault by setting additional attributes.
function initialize2 ( address accessControlManager_ , address rewardRecipient_ , uint256 loopsLimit_ , address vaultOwner_ ) public
Name Type Description accessControlManager_ address The address of the access control manager contract. rewardRecipient_ address The initial recipient of rewards. loopsLimit_ uint256 The maximum number of loops for certain operations to enhance security. vaultOwner_ address The address of the vault owner.
Can only be called once.
Use with caution to avoid misconfiguration.
Sets the maximum number of loops for certain operations.
function setMaxLoopsLimit ( uint256 loopsLimit ) external
Name Type Description loopsLimit uint256 The new maximum loops limit to be set.
Emits MaxLoopsLimitUpdated on success.
Controlled by the Access Control Manager (ACM).
Sets a new recipient for rewards distributed by the Venus Protocol.
function setRewardRecipient ( address newRecipient ) external
Name Type Description newRecipient address The address of the new reward recipient.
Emits RewardRecipientUpdated on success.
Sweeps the specified token from the contract and sends it to the contract owner.
function sweepToken ( IERC20Upgradeable token ) external onlyOwner
Name Type Description token IERC20Upgradeable Address of the token.
Emits SweepToken on success.
Claims rewards from all reward distributors associated with the vToken and transfers them to the reward recipient.
function claimRewards () external
Iterates through all reward distributors fetched from the comptroller, claims rewards, and transfers them if available.
Deposits assets into the vault, minting corresponding shares to the receiver.
function deposit ( uint256 assets , address receiver ) public override nonReentrant returns ( uint256 )
Name Type Description assets uint256 The amount of assets to deposit. receiver address The address to receive shares.
Name Type Description shares uint256 Amount of shares minted.
Overrides ERC4626Upgradeable deposit.
Includes non-reentrant protection and custom Venus logic.
Mints new shares of the vault, allocating the corresponding amount of assets to the receiver.
function mint ( uint256 shares , address receiver ) public override nonReentrant returns ( uint256 )
Name Type Description shares uint256 The amount of shares to mint. receiver address The address to receive shares.
Name Type Description assets uint256 Amount of assets deposited.
Overrides ERC4626Upgradeable mint.
Includes non-reentrant protection and custom Venus logic.
Withdraws assets from the vault, burning the corresponding amount of shares from the owner’s balance.
function withdraw ( uint256 assets , address receiver , address owner ) public override nonReentrant returns ( uint256 )
Name Type Description assets uint256 The amount of assets to withdraw. receiver address The address to receive assets. owner address The address whose shares are burned.
Name Type Description shares uint256 Amount of shares burned.
Overrides ERC4626Upgradeable withdraw.
Includes non-reentrant protection and custom Venus logic.
Redeems shares of the vault, returning the corresponding amount of assets to the receiver.
function redeem ( uint256 shares , address receiver , address owner ) public override nonReentrant returns ( uint256 )
Name Type Description shares uint256 The amount of shares to redeem. receiver address The address to receive assets. owner address The address whose shares are redeemed.
Name Type Description assets uint256 Amount of assets returned.
Overrides ERC4626Upgradeable redeem.
Includes non-reentrant protection and custom Venus logic.
Returns the total amount of assets managed by the vault, including both deposited assets and accrued rewards.
function totalAssets () public view virtual override returns ( uint256 )
Name Type Description assets uint256 Total assets managed by the vault.
Overrides ERC4626Upgradeable totalAssets.
Returns the maximum deposit allowed, based on Venus supply caps.
function maxDeposit ( address account ) public view virtual override returns ( uint256 )
Name Type Description account address The address of the account.
Name Type Description amount uint256 Maximum assets that can be deposited.
Returns 0 if minting is paused or the supply cap has been reached.
Returns the maximum amount of shares that can be minted.
function maxMint ( address account ) public view virtual override returns ( uint256 )
Name Type Description account address The address of the account.
Name Type Description shares uint256 Maximum shares that can be minted.
Derived from the maximum deposit amount converted to shares.
Returns the maximum amount of assets that can be withdrawn.
function maxWithdraw ( address receiver ) public view virtual override returns ( uint256 )
Name Type Description receiver address The address of the account withdrawing.
Name Type Description amount uint256 Maximum assets that can be withdrawn.
This value is limited by the available cash in the vault.
Returns the maximum amount of shares that can be redeemed.
function maxRedeem ( address receiver ) public view virtual override returns ( uint256 )
Name Type Description receiver address The address of the account redeeming.
Name Type Description shares uint256 Maximum shares that can be redeemed.
Limited by the available cash in the vault.