PropWrappedAssetsFeeCollectorFacetStorage
This library handles the storage and logic for the PropWrappedAssetsFeeCollectorFacet
private facet.
_TBD: A better approach would be to call wrapAssets
a second time, using only the proportion of assets
corresponding to the fee. This way, the wrapper will return a second NFT ID that represents just the fee-related
assets. The fee collector can then call a designated function at the appropriate state to claim either the NFT ID
or the underlying wrapped assets associated with the fee.
NOTE:
- We do not use the
custom:storage-location
annotation because the Layout struct is defined in a library, which, as of now, does not support automated storage layout validation. However, the implementation adheres to the ERC-7201 structure in spirit by ensuring unique and collision-free storage slots using the ERC-7201 formula._
AlreadyInitialized
Thrown when attempting to re-initialize.
WrongInitializationData
Thrown when passing invalid initialization data.
MissingInitialization
Thrown when acquireWrappedAssetsFees
is invoked, but initialization has not occurred.
UnsupportedTypeForOperation
Thrown when acquireWrappedAssetsFees
attempts to extract a fee from a non-fungible asset.
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: TO-DO
Layout
Struct containing the fee schema configuration information.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
initWrappedAssetsFeeCollectorFacet
Initializes the PropWrappedAssetsFeeCollectorFacetStorage
by registering the eligible fee collector and the fee rate
to be applied to campaigns' wrapped assets.
_For example, if the feeRate
is set to 10%, then a campaign wrapping 100 ERC20 $token will result in 10 $token
being transferred to the feeCollector
when the campaign is created.
IMPORTANT:
- Rates and percentages are represented with a base of 10^6 (e.g., 0.1 -> 10% is
100000
). feeCollector
cannot be set to the zero address._
Parameters
Name | Type | Description |
---|---|---|
l | struct PropWrappedAssetsFeeCollectorFacetStorage.Layout | A reference to the Layout struct in storage. |
initWrappedAssetsFeeCollectorData | bytes | ABI-encoded data containing: - feeCollector : The eligible address that will be receiving the fees (if any). - feeRate : The rate defining what portion of a campaign’s wrapped assets is charged as a fee. |
acquireWrappedAssetsFees
Calculates the fee from the given asset(s) based on the configured feeRate
, and transfers the corresponding
amount(s) to the designated feeCollector
(see initWrappedAssetsFeeCollectorFacet()
).
Reverts if any entry in the wtypes
array corresponds to non-fungible assets (i.e., code 1
for ERC721).
Parameters
Name | Type | Description |
---|---|---|
l | struct PropWrappedAssetsFeeCollectorFacetStorage.Layout | A reference to the Layout struct in storage. |
wrapperNftId | uint256 | The ID of the NFT representing the Wrapper's Vault that holds the wrapped assets. |
wtypes | enum IWrapper.WrappedObjectType[] | An array of codes representing the types (ERCs) of the assets (e.g., 0 = ERC20, 1 = ERC721, 2 = ERC1155). |
tokens | address[] | An array of asset (token) contract addresses. |
ids | uint256[] | An array of token IDs (relevant only for semi-fungible and non-fungible assets). |
values | uint256[] | An array of asset amounts (relevant only for fungible and semi-fungible assets). |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256[] | An array of uint256 values representing the remaining amounts of tokens after the fee deduction. |
[1] | uint256[] | An array of uint256 values representing the amounts of tokens collected as a fee. |