VaultModule
VaultModule
Addresses
| Chain | Address |
|---|
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)
See {IERC20-totalSupply}.
_balanceOf
function _balanceOf(address account) internal view returns (uint256)
See {IERC20-balanceOf}.
_allowance
function _allowance(address owner, address spender) internal view returns (uint256)
See {IERC20-allowance}.
_deposit
function _deposit(address caller, address receiver, uint256 assets, Shares shares) internal
Deposit/mint common workflow.
_distributeFee
Send fee to FeeDistributor and trigger distribution
function _distributeFee(uint256 fee, address caller) internal
Parameters
| Name | Type | Description |
|---|---|---|
fee | uint256 | Collateral units to be distributed |
caller | address | Account that paid the fee |
_mint
function _mint(address account, uint256 value) internal
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
Withdraw/redeem common workflow.
_spendAllowance
function _spendAllowance(address owner, address spender, uint256 value) internal
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
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:
ownercannot be the zero address.spendercannot 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
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
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
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
| Name | Type | Description |
|---|---|---|
shares | Shares | Request quantity |
penaltyRate | PerShare | Rate to apply |
maxPenaltySeconds | uint64 | Maximum penalty returned |
Return Values
| Name | Type | Description |
|---|---|---|
penalty | uint64 | Seconds 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
| Name | Type | Description |
|---|---|---|
owner | address | Address for which to check request |
Return Values
| Name | Type | Description |
|---|---|---|
status | bool | false 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
| Name | Type | Description |
|---|---|---|
owner | address | Address for which to check request |
Return Values
| Name | Type | Description |
|---|---|---|
status | bool | true 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
| Name | Type | Description |
|---|---|---|
props | struct VaultSchema | |
erc20 | struct ERC20Schema | |
erc4626 | struct ERC4626Schema | |
withdrawRequests | struct WithdrawRequestSchema |
struct VaultSlot {
struct VaultSchema props;
struct ERC20Schema erc20;
struct ERC4626Schema erc4626;
struct WithdrawRequestSchema withdrawRequests;
}
VaultModuleEvents
Addresses
| Chain | Address |
|---|
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)