Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

FeeConfigTrait

The logic for calculating entry and exit fees is expected to be defined at the contract level. Defaults to no entry or exit fees.

NOTE: The FeeConfigTrait hooks directly into the preview methods of the ERC4626 component. The preview methods must return as close to the exact amount of shares or assets as possible if the actual (previewed) operation occurred in the same transaction (according to EIP-4626 spec). All operations use their corresponding preview method as the value of assets or shares being moved to or from the user. The fees calculated in FeeConfigTrait are used to adjust the final asset and share amounts used in both the preview and the actual operations.

NOTE: To transfer fees, this trait needs to be coordinated with ERC4626Component::ERC4626Hooks. See the ERC4626AssetsFeesMock and ERC4626SharesFeesMock examples: https://github.com/OpenZeppelin/cairo-contracts/tree/main/packages/test_common/src/mocks/erc4626.cairo

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

pub trait FeeConfigTrait<TContractState, +HasComponent<TContractState>>

Trait functions

calculate_deposit_fee

Calculates the entry fee for a deposit during preview_deposit. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the after_deposit hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be minted to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_deposit_fee

fn calculate_deposit_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_mint_fee

Calculates the entry fee for a mint during preview_mint. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the after_deposit hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be minted to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_mint_fee

fn calculate_mint_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_withdraw_fee

Calculates the exit fee for a withdraw during preview_withdraw. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the before_withdraw hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be transferred from the owner to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_withdraw_fee

fn calculate_withdraw_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_redeem_fee

Calculates the exit fee for a redeem during preview_redeem. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the before_withdraw hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be transferred from the owner to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_redeem_fee

fn calculate_redeem_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>