Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

InternalTrait

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait

pub trait InternalTrait<TContractState, +HasComponent<TContractState>, impl Hooks: ERC4626HooksTrait<TContractState, +HasComponent<TContractState>>, impl Immutable: ImmutableConfig, impl ERC20: HasComponent<TContractState>, impl Assets: AssetsManagementTrait<TContractState, +HasComponent<TContractState>>, impl FeeConfig: FeeConfigTrait<TContractState, +HasComponent<TContractState>>, +LimitConfigTrait<TContractState>, impl ERC20HooksTrait<TContractState>: ERC20HooksTrait<TContractState>, +Drop<TContractState>>

Trait functions

initializer

Validates the ImmutableConfig constants and sets the asset_address to the vault. This should be set in the contract’s constructor.

Requirements:

  • asset_address cannot be the zero address.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>, asset_address: ContractAddress)

_preview_deposit

Internal preview function for deposit operations. Returns the actual assets the user will spend and shares the user will receive. Asset fees are included in assets, share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_deposit

fn _preview_deposit(self: @ComponentState<TContractState>, assets: u256) -> Preview

_preview_mint

Internal preview function for mint operations. Returns the actual assets the user will spend and shares the user will receive. Asset fees are included in assets, share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_mint

fn _preview_mint(self: @ComponentState<TContractState>, shares: u256) -> Preview

_preview_withdraw

Internal preview function for withdraw operations. Returns the actual assets the user will receive and shares the user will spend. Asset fees are excluded from assets, share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_withdraw

fn _preview_withdraw(self: @ComponentState<TContractState>, assets: u256) -> Preview

_preview_redeem

Internal preview function for redeem operations. Returns the actual assets the user will receive and shares the user will spend. Asset fees are excluded from assets, share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_redeem

fn _preview_redeem(self: @ComponentState<TContractState>, shares: u256) -> Preview

_deposit

Internal logic for deposit and mint. Transfers assets from caller to the Vault contract then mints shares to receiver. Fees can be transferred in the ERC4626Hooks::after_deposit hook which is executed after assets are transferred and shares are minted.

Requirements:

  • ERC20::transfer_from must return true.

Emits two ERC20::Transfer events (ERC20::mint and ERC20::transfer_from). Emits a Deposit event.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_deposit

fn _deposit(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

_withdraw

Internal logic for withdraw and redeem. Burns shares from owner and then transfers assets to receiver. Fees can be transferred in the ERC4626Hooks::before_withdraw hook which is executed before shares are burned and assets are transferred.

Requirements:

  • ERC20::transfer must return true.

Emits two ERC20::Transfer events (ERC20::burn and ERC20::transfer).

Emits a Withdraw event.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_withdraw

fn _withdraw(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    owner: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

_convert_to_shares

Internal conversion function (from assets to shares) with support for rounding direction.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_convert_to_shares

fn _convert_to_shares(
    self: @ComponentState<TContractState>, assets: u256, rounding: Rounding,
) -> u256

_convert_to_assets

Internal conversion function (from shares to assets) with support for rounding direction.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_convert_to_assets

fn _convert_to_assets(
    self: @ComponentState<TContractState>, shares: u256, rounding: Rounding,
) -> u256