FundingPacketMixer
This Mixer implementation ensembles Funding Packets Explicit Facets enabling the configuration of campaigns' funding packets that can encapsulate diverse asset types (e.g., ERC20, ERC1155 etc.), and facilitate the transfer of these funding packets. The Explicit Facets are always called exclusively through their associated Mixer.
_The Explicit facets are essentially of the same implementation as their Non-Explicit counterparts,
(e.g., FundingErc20PacketsExplicitFacet.sol
vs FundingErc20PacketsFacet.sol
), with the only difference being the naming
of their functions (e.g., transferFundingErc20Packets()
vs transferFundingPackets()
) in order to generate unique function
selectors, thus establishing a clear distinction between them. Since all Non-Explicit facets of the same category
(e.g., FundingErc20PacketsFacet
and FundingErc1155PacketsFacet
) share the same function selectors but implement
different logic, the role of any mixer associated with a category of facets is to aggregate the logic and
access the storage of such facets without conflicts. This is achieved by having its functions share the names
of the Non-Explicit facets of the same category but interacting exclusively with their Explicit counterparts.
IMPORTANT: When a Mixer of a category of facets is integrated as a facet to a tmi-fractions platform (diamond proxy), only Explicit facets of this category should be added as facets._
OnlyAdminCanInitialize
Thrown when a non-admin account attempts to call restricted initialization functions.
FundingPacketMixerInitialized
Emitted at initFundingPacketFacet()
.
CampaignFundingPacketConfigured
Emitted at setAndCheckFundingPacket()
.
initFundingPacketFacet
Initializes the FundingPacketMixerStorage
by registering the selectors for the setter and
transferFundingPackets functions of the supported FundingPackets Explicit facets, along with code schema for
representing the ERC types handled by these Explicit facets.
_This function can only be called by the Admin (see AccessControlFacet.sol
).
Emits a {FundingPacketMixerInitialized} event.
----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
initFundingPacketData | bytes | The ABI encoded data containing the following: - selectors : An array of FunctionSelectors structs, each with the setter and transferFundingPackets function selectors of the supported FundingPackets Explicit facets. - fundingAssetTypeCodes : The code schema that identifies the ERC (asset type) each supported FundingPackets Explicit facet hanldles. |
setAndCheckFundingPacket
Configures and validates the funding packet of a campaign.
_This Set and Check function configures the funding packet for a campaign, where any of the supported asset types can be included. For instance, if ERC20 and ERC1155 FundingPackets Explicit facets are supported, a packet could be configured as follows:
- { 100 TokenA (ERC20), 20.5 tokenB (ERC20), 10 tokenC ID 2 (ERC1155), 5 tokenD ID 1 (ERC1155) }
The construction of the funding packet is at the discreation of the campaign creator, as
any possible combination of the supported FundingPackets Explicit facets can be employed.
These explicit facets must be already registered via initFundingPacketFacet()
.
Set and Check functions are executed during the creation process of campaigns (see CreateFractionsSkeleton.sol
).
Emits a {CampaignFundingPacketConfigured} event.
Requirements:
- The
fundingPacketsData
andfundingAssetTypeCodes
arrays must have the same length.
IMPORTANT:
-
The asset type codes specified in
fundingAssetTypeCodes
should be valid, meaning that they should already be registered in the FundingPacket Mixer storage (seeinitFundingPacketFacet()
). -
The i-th member of the
fundingAssetTypeCodes
array should correspond to the i-th member of thefundingPacketsData
array. -
If ERC20 tokens are opted for inclusion in the input packet (i.e., via
FundingErc20PacketsExplicitFacet.sol
), or any other token standards with decimal precision, then the amounts of these tokens should be parsed with their respective decimal precision at the API level. ----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
postFractionFundingPacketData | bytes | The ABI-encoded settings data containing the following: - fundingPacketsData : An bytes array with the ABI encoded data to be consumed as input by the Set and Check functions of the targeted Funding Packets Explicit facets. - fundingAssetTypeCodes : A uint256 array with the respective configured codes indicating the targeted Funding Packets Explicit facets to be used. |
transferFundingPackets
Transfers the specified amount of a given campaign's funding packets from the from
address
to the to
address.
_This function iteratively executes the respective transferFundingPackets
functions of all
FundingPackets Explicit facets associated with the funding packet.
Emits a {CampaignFundingPacketsTransferred} event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted campaign. |
from | address | The address from which the assets encapsulated by the specified number of funding packets to be transferred. |
to | address | The address to receive the assets encapsulated by the specified number of funding packets. |
amountOfPackets | uint256 | The number of funding packets to account for. |