Skip to main content

VaultModule

VaultModule

Addresses

ChainAddress

Functions

props

function props() internal view returns (struct VaultSchema)

erc20

function erc20() internal view returns (struct ERC20Schema)

erc4626

function erc4626() internal view returns (struct ERC4626Schema)

withdrawRequests

function withdrawRequests() internal view returns (struct WithdrawRequestSchema)

__VaultModule_ctor

function __VaultModule_ctor(
struct StorageInstance app_,
ContractName contractName_,
uint256 contractVersion_
) internal

__VaultModule_init

function __VaultModule_init(
struct StorageInstance app_,
ContractName contractName_,
uint256 contractVersion_
) internal

__VaultModule_setup

function __VaultModule_setup() internal

_balance

function _balance() internal view returns (uint256)

_asset

function _asset() internal view virtual returns (contract IERC20)

_totalSupply

function _totalSupply() internal view returns (uint256)
Dev note

See {IERC20-totalSupply}.

_balanceOf

function _balanceOf(address account) internal view returns (uint256)
Dev note

See {IERC20-balanceOf}.

_allowance

function _allowance(address owner, address spender) internal view returns (uint256)
Dev note

See {IERC20-allowance}.

_deposit

function _deposit(address caller, address receiver, uint256 assets, Shares shares) internal
Dev note

Deposit/mint common workflow.

_distributeFee

Send fee to FeeDistributor and trigger distribution

function _distributeFee(uint256 fee, address caller) internal

Parameters

NameTypeDescription
feeuint256Collateral units to be distributed
calleraddressAccount that paid the fee

_mint

function _mint(address account, uint256 value) internal
Dev note

Creates a value amount of tokens and assigns them to account, by transferring it from address(0). Relies on the _update mechanism

Emits a {Transfer} event with from set to the zero address.

NOTE: This function is not virtual, {_update} should be overridden instead.

_withdraw

function _withdraw(address caller, address receiver, address owner, uint256 assets, Shares shares) internal
Dev note

Withdraw/redeem common workflow.

_spendAllowance

function _spendAllowance(address owner, address spender, uint256 value) internal
Dev note

Updates owner s allowance for spender based on spent value.

Does not update the allowance value in case of infinite allowance. Revert if not enough allowance is available.

Does not emit an {Approval} event.

_approve

function _approve(address owner, address spender, uint256 value) internal
Dev note

Sets value as the allowance of spender over the owner s tokens.

This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc.

Emits an {Approval} event.

Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.

Overrides to this logic should be done to the variant with an additional bool emitEvent argument.

_approve

function _approve(address owner, address spender, uint256 value, bool emitEvent) internal
Dev note

Variant of {_approve} with an optional flag to enable or disable the {Approval} event.

By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by _spendAllowance during the transferFrom operation set the flag to false. This saves gas by not emitting any Approval event during transferFrom operations.

Anyone who wishes to continue emitting Approval events on thetransferFrom operation can force the flag to true using the following override:

function _approve(address owner, address spender, uint256 value, bool) internal virtual override \{
super._approve(owner, spender, value, true);
\}

Requirements are the same as {_approve}.

_decimalsOffset

function _decimalsOffset() internal pure returns (uint8)

_transfer

function _transfer(address from, address to, uint256 value) internal
Dev note

Moves a value amount of tokens from from to to.

This internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc.

Emits a {Transfer} event.

NOTE: This function is not virtual, {_update} should be overridden instead.

_burn

function _burn(address account, uint256 value) internal
Dev note

Destroys a value amount of tokens from account, lowering the total supply. Relies on the _update mechanism.

Emits a {Transfer} event with to set to the zero address.

NOTE: This function is not virtual, {_update} should be overridden instead

_update

function _update(address from, address to, uint256 value) internal

_computePenalty

Apply a given penalty rate to a shares quantity

function _computePenalty(
Shares shares,
PerShare penaltyRate,
uint64 maxPenaltySeconds
) internal view returns (
uint64 penalty
)

Parameters

NameTypeDescription
sharesSharesRequest quantity
penaltyRatePerShareRate to apply
maxPenaltySecondsuint64Maximum penalty returned

Return Values

NameTypeDescription
penaltyuint64Seconds that must be waited before request begins

_previewPenalty

Get the next penalty rate/max for a user, based on an existing expired request. User MUST have an expired request.

function _previewPenalty(address user) internal view returns (PerShare nextRate, uint64 remainingSeconds)

_activeWithdrawRequest

Whether owner has an active withdraw request

function _activeWithdrawRequest(address owner) internal view returns (bool status)

Parameters

NameTypeDescription
owneraddressAddress for which to check request

Return Values

NameTypeDescription
statusboolfalse if request is nonexistent, complete, or expired, true otherwise

_expiredWithdrawRequest

Whether owner has an expired withdraw request

function _expiredWithdrawRequest(address owner) internal view returns (bool status)

Parameters

NameTypeDescription
owneraddressAddress for which to check request

Return Values

NameTypeDescription
statusbooltrue if request expired, false if it's active, nonexistent, or completed

vaultFormulas

function vaultFormulas() internal view returns (contract IVaultFormulas)

vaultShares

function vaultShares() internal view returns (contract IVaultShareFormulas)

vaultRequestHandler

function vaultRequestHandler() internal view returns (contract IVaultRequestHandler)

vaultPenaltyHandler

function vaultPenaltyHandler() internal view returns (contract IVaultPenaltyHandler)

vaultDepositHandler

function vaultDepositHandler() internal view returns (contract IVaultDepositHandler)

vaultWithdrawHandler

function vaultWithdrawHandler() internal view returns (contract IVaultWithdrawHandler)

vaultTransferHandler

function vaultTransferHandler() internal view returns (contract IVaultTransferHandler)

vaultDistributionHandler

function vaultDistributionHandler() internal view returns (contract IVaultDistributionHandler)

Types

VaultSlot

Fields

NameTypeDescription
propsstruct VaultSchema
erc20struct ERC20Schema
erc4626struct ERC4626Schema
withdrawRequestsstruct WithdrawRequestSchema
struct VaultSlot {
struct VaultSchema props;
struct ERC20Schema erc20;
struct ERC4626Schema erc4626;
struct WithdrawRequestSchema withdrawRequests;
}

VaultModuleEvents

Addresses

ChainAddress

Functions

emitTransfer

function emitTransfer(address from, address to, uint256 value) internal

emitApproval

function emitApproval(address owner, address spender, uint256 value) internal

Events

Transfer

event Transfer(address from, address to, uint256 value)

Approval

event Approval(address owner, address spender, uint256 value)