Erc20InputExplicitFacet
This explicit facet handles the configuration of input packets for staking campaigns and facilitates the transfer of these input packets.
_This implementation is designed for use in staking campaigns where the input packet is not solely constructed from ERC20 tokens (any other ERC can be accounted for if the respective explicit facet is available). However, this implementation only handles the configuration and transfer of ERC20 tokens within the input packet.
IMPORTANT:
- This implementation should awlays be used in conjuction with the
TransferInputMixer.sol
. - Extra care should be taken when specifying token amounts, especially when dealing with tokens of
varying decimal precision (see
setCampaignTransferErc20Input()
for more details). - An input packet can encapsulate one (e.g., tokenA) or more (e.g., tokenA, tokenB, ..., tokenX) ERC20 tokens._
CampaignERC20InputConfigured
Emitted at setCampaignTransferErc20Input()
.
CampaignERC20InputPacketAssetsTransferred
Emitted at transferErc20Input()
.
setCampaignTransferErc20Input
Setter function for configuring the ERC20 assets within the input packet for the specified staking campaign. This function configures only the content of the input packet associated with ERC20 assets.
_selector: 0x48fb0948
Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol
)
Requirements:
- The
tokenAddresses
andamountOfTokensPerPacket
arrays must have the same length. tokenAddresses
must contain valid, non-zero ERC20 token addresses.amountOfTokensPerPacket
must contain non-zero values.
Emits a {CampaignERC20InputConfigured}
event.
IMPORTANT:
- The input packet should not encapsulate only ERC20 tokens; for configurations involving only ERC20 tokens,
use
ERC20InputFacet.sol
instead. Since other ERCs may or may not have decimal places, only one configuration option is valid: Parse the values inamountOfTokensPerPacket
with each token's decimal precision (using wei values), thus, input packet amounts should be specified in whole units at the API level forstake()
,restake()
,partialUnstake()
, andfullyUnstake()
(seeStakingSkeleton.sol
). ----------------------------------------------------------------------------------------------------------------_
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignTransferErc20InputData | bytes | The ABI-encoded data containing the following: - tokenAddresses : An address array containing the addresses of the ERC20 tokens encapsulated by the input packet. - amountOfTokensPerPacket : A uint256 array specifying the amount for each corresponding token in tokenAddresses . |
transferErc20Input
Transfers the ERC20 assets associated with the specified amount of a given campaign's input packets
from the from
address to the to
address.
_selector: 0x310e2e17
This function iteratively executes transfers for all respective amounts of ERC20 tokens defined
in the campaign's input packet (see setCampaignTransferInput()
) in a single transaction.
The amounts to be transferred are calculated as
amountOfTokensPerPacket[i] * amountOfPackets
for each ERC20 token in the input packet, where i
is the index of the token in the tokenAddresses
array. The transfer is performed using
the safeTransferFrom
method of the ERC20 token interface.
Emits a {CampaignERC20InputPacketAssetsTransferred}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
from | address | The address from which the ERC20 assets encapsulated by the specified number of input packets to be transferred. |
to | address | The address to receive the ERC20 assets encapsulated by the specified number of input packets. |
amountOfPackets | uint256 | The number of input packets to account for. |