TransferInputMixerStorage
This library implementation ensembles Transfer Input Explicit Facets enabling the configuration of campaings' input packets that can encapsulate diverse asset types (e.g., ERC20, ERC1155 etc.), and facilitate the transfer of these input packets.
AlreadyInitialized
Thrown when attempting to re-initialize.
InvalidInputMixerInitDataLengths
Thrown at initializer when the lengths of selectors
and inputAssetTypeCodes
do not match.
CampaignNotOnCreationStateForSetting
Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.
InvalidInputMixerSetterDataLengths
Thrown at setter when the lengths of campaignInputData
and inputAssetTypeCodes
arrays do not match.
UnsupportedInputAssetType
Thrown at setter when an unsupported asset type code is specified as input for a campaign.
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored.
FunctionSelectors
Struct containing selectors of setter & transfer functions implemented in a TransferInput Explicit Facet.
CampaignInputAssetInfo
Struct containing the local codes for the asset types supported within input packets of a staking campaign.
Layout
Struct for managing information related to the Transfer Input Mixer and campaigns configuration.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
initTransferInput
Initializes the TransferInputMixerStorage
by registering the selectors for the setter and
transferInput functions of the supported TransferInput Explicit facets, along with code schema for
representing the ERC types handled by these Explicit facets.
_The selectors provided must belong to the TransferInput Explicit facets that will be used for constructing input packets of campaigns and for transferring assets encapsulated within a campaing's input packet.
Requirements:
- The
selectors
andinputAssetTypeCodes
arrays must have the same length.
IMPORTANT:
-
The code schema for supported ERCs in campaigns' input packets helps identify the asset type that each registered Transfer Input Explicit facet handles. While the construction of this shcema is at the discreation of the Admin, it is advised to use the numerical suffix of the ERC standards of the ERCs (e.g., 20 for ERC20, 1155 for ERC1155 etc.) as codes for clarity and consistency.
-
The i-th member of the
inputAssetTypeCodes
array should correspond to the i-th member of theselectors
array. ----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
l | struct TransferInputMixerStorage.Layout | A reference to the Layout struct in storage. |
initTransferInputData | bytes | The ABI encoded data containing the following: - selectors : An array of FunctionSelectors structs, each with the setter and transferInput function selectors of the supported TransferInput Explicit facets. - inputAssetTypeCodes : The code schema that identifies the ERC (asset type) each supported TransferInput Explicit facet hanldles. |
setCampaignTransferInput
Setter function for configuring the input packet for the specified staking campaign.
_This setter function configures the input packet for a campaign, where any of the supported asset types can be included. For instance, if ERC20 and ERC1155 Transfer Input Explicit facets are supported, a packet could be configured as follows:
The construction of the input packet is at the discreation of the campaign creator, as
any possible combination of the supported Transfer Input Explicit facets can be employed.
These explicit facets must be already registered via initTransferInput()
.
Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol
).
Requirements:
- The
campaignInputData
andinputAssetTypeCodes
arrays must have the same length.
IMPORTANT:
-
The asset type codes specified in
inputAssetTypeCodes
should be valid, meaning that they should already be registered in the TransferInput Mixer storage (seeinitTransferInput()
). -
The i-th member of the
inputAssetTypeCodes
array should correspond to the i-th member of thecampaignInputData
array. ----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
l | struct TransferInputMixerStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignTransferInputData | bytes | The ABI-encoded settings data containing the following: - campaignInputData : An bytes array with the ABI encoded data to be consumed as input by the setter functions of the targeted TransferInput Explicit facets. - inputAssetTypeCodes : A uint256 array with the respective configured codes indicating the targeted TransferInput Explicit facets to be used. |
transferInput
Transfers the specified amount of a given campaign's input packets from the from
address
to the to
address.
This function iteratively executes the respective transferInput
functions of all
Input Explicit facets associated with the input packet.
Parameters
Name | Type | Description |
---|---|---|
l | struct TransferInputMixerStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
from | address | The address from which the assets encapsulated by the specified number of input packets to be transferred. |
to | address | The address to receive the assets encapsulated by the specified number of input packets. |
amountOfPackets | uint256 | The number of input packets to account for. |