Fraction ProtocolprivateFacetspreFractionsFacets

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

error AlreadyInitialized()

Thrown when attempting to re-initialize.

WrongInitializationData

error WrongInitializationData()

Thrown when passing invalid initialization data.

MissingInitialization

error MissingInitialization()

Thrown when acquireWrappedAssetsFees is invoked, but initialization has not occurred.

UnsupportedTypeForOperation

error UnsupportedTypeForOperation()

Thrown when acquireWrappedAssetsFees attempts to extract a fee from a non-fungible asset.

STORAGE_SLOT

bytes32 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.

struct Layout {
  bool isInitialized;
  address feeCollector;
  uint256 feeProportion;
}

layout

function layout() internal pure returns (struct PropWrappedAssetsFeeCollectorFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT unique identifier.

initWrappedAssetsFeeCollectorFacet

function initWrappedAssetsFeeCollectorFacet(struct PropWrappedAssetsFeeCollectorFacetStorage.Layout l, bytes initWrappedAssetsFeeCollectorData) internal returns (address, uint256)

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

NameTypeDescription
lstruct PropWrappedAssetsFeeCollectorFacetStorage.LayoutA reference to the Layout struct in storage.
initWrappedAssetsFeeCollectorDatabytesABI-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

function acquireWrappedAssetsFees(struct PropWrappedAssetsFeeCollectorFacetStorage.Layout l, uint256 wrapperNftId, enum IWrapper.WrappedObjectType[] wtypes, address[] tokens, uint256[] ids, uint256[] values) internal returns (uint256[], uint256[])

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

NameTypeDescription
lstruct PropWrappedAssetsFeeCollectorFacetStorage.LayoutA reference to the Layout struct in storage.
wrapperNftIduint256The ID of the NFT representing the Wrapper's Vault that holds the wrapped assets.
wtypesenum IWrapper.WrappedObjectType[]An array of codes representing the types (ERCs) of the assets (e.g., 0 = ERC20, 1 = ERC721, 2 = ERC1155).
tokensaddress[]An array of asset (token) contract addresses.
idsuint256[]An array of token IDs (relevant only for semi-fungible and non-fungible assets).
valuesuint256[]An array of asset amounts (relevant only for fungible and semi-fungible assets).

Return Values

NameTypeDescription
[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.

On this page