TransferRewardMixer
This Mixer implementation ensembles Transfer Reward Explicit Facets enabling the configuration of campaings' reward packets that can encapsulate diverse asset types (e.g., ERC20, ERC1155 etc.), and facilitate the transfer of these reward 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., ERC20RewardMinterExplicitFacet.sol
vs ERC20RewardMinterFacet.sol
), with the only difference being
the naming of their functions (e.g., transferErc20MinterReward()
vs transferReward()
) 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., ERC20RewardMinterFacet
and ERC1155RewardMinterFacet
) share the same function names
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 interact exclusively with their Explicit counterparts.
IMPORTANT: When a Mixer of a category of facets is integrated as a facet to the staking platform (diamond), only Explicit facets of this category should be added as facets._
OnlyAdminCanInitialize
Thrown when a non-admin account attempts to call restricted initialization functions.
RewardMixerInitialized
Emitted at initTransferReward()
.
CampaignRewardConfigured
Emitted at setCampaignTransferRewards()
.
CampaignRewardPacketsTransferred
Emitted at transferReward()
.
initTransferReward
Initializes the TransferRewardMixerStorage
by registering the selectors for the setter and
transferReward functions of the supported TransferReward 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 AccessControlStakingFacet.sol
).
The selectors provided must belong to the TransferReward Explicit facets that will be used for constructing reward packets of campaigns and for transferring assets encapsulated within a campaing's reward packet.
Requirements:
- The
selectors
andrewardAssetTypeCodes
arrays must have the same length.
Emits a {RewardMixerInitialized}
event.
IMPORTANT:
-
The code schema for supported ERCs in campaigns' reward packets helps identify the asset type that each registered TransferReward Mixer 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 (e.g., 20 for ERC20, 1155 for ERC1155 etc.) as codes for clarity and consistency.
-
A
FunctionSelectors
struct contains two bytes4 fields:setterSelector
&transferSelector
. The order of these fields matters when constructing theselectors
array at the API level.s -
The i-th member of the
rewardAssetTypeCodes
array should correspond to the i-th member of theselectors
array. ----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
initTransferRewardData | bytes | The ABI encoded data containing the following: - selectors : An array of FunctionSelectors structs, each with the setter and transferReward function selectors of the supported TransferReward Explicit facets. - rewardAssetTypeCodes : The code schema that identifies the ERC (asset type) each supported TransferReward Explicit facet hanldles. |
setCampaignTransferRewards
Setter function for configuring the reward packet for the specified staking campaign.
_This setter function configures the reward packet for a campaign, where any of the supported asset types can be included. For instance, if ERC20 and ERC1155 Transfer Reward Explicit facets are supported, a packet could be configured as follows:
The construction of the reward packet is at the discreation of the campaign creator, as
any possible combination of the supported Transfer Reward Explicit facets can be employed.
These explicit facets must be already registered via initTransferReward()
.
Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol
).
Requirements:
- The
campaignRewardData
andrewardAssetTypeCodes
arrays must have the same length.
Emits a {CampaignRewardConfigured}
event.
IMPORTANT:
-
The asset type codes specified in
rewardAssetTypeCodes
should be valid, meaning that they should already be registered in the TransferReward Mixer storage (seeinitTransferReward()
). -
The i-th member of the
rewardAssetTypeCodes
array should correspond to the i-th member of thecampaignRewardData
array. -
If ERC20 tokens are opted for inclusion in the reward packet (e.g., via
ERC20RewardMinterExplicitFacet.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 |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignTransferRewardsData | bytes | The ABI-encoded settings data containing the following: - campaignRewardData : An bytes array with the ABI encoded data to be consumed as input by the setter functions of the targeted TransferReward Explicit facets. - rewardAssetTypeCodes : A uint256 array with the respective configured codes indicating the targeted TransferReward Explicit facets to be used. |
transferReward
Transfers the specified amount of a given campaign's reward packets from the from
address
to the to
address.
_This function iteratively executes the respective transferReward
functions of all
Reward Explicit facets associated with the reward packet.
Emits a {CampaignRewardPacketsTransferred}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
from | address | The address from which the assets encapsulated by the specified number of reward packets to be transferred. |
to | address | The address to receive the assets encapsulated by the specified number of reward packets. |
amountOfPackets | uint256 | The number of reward packets to account for. |