Staking Protocoltransfersrewarderc20transferrer

Erc20RewardTransferExplicitFacet

This explicit facet handles the configuration of reward packets for staking campaigns and facilitates the transfer of the assets encapsulated within these reward packets.

_This implementation is designed for use in staking campaigns where the reward 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 reward packet.

IMPORTANT:

  • This implementation should awlays be used in conjuction with the TransferRewardMixer.sol.
  • The campaign's reward asset handler must have sufficient balances of the ERC20 assets specified in the reward packet, else the campaign will fail to provide the appropriate rewards.
  • Extra care should be taken when specifying token amounts, especially when dealing with tokens of varying decimal precision (see setCampaignTransferErc20Rewards() for more details).
  • A reward packet can encapsulate one (e.g., tokenA) or more (e.g., tokenA, tokenB, ..., tokenX) ERC20 tokens._

CampaignERC20RewardConfigured

event CampaignERC20RewardConfigured(uint256 campaignId, address[] tokenAddresses, uint256[] amountOfTokensPerPacket)

Emitted at setCampaignTransferErc20Rewards().

CampaignERC20RewardPacketAssetsTransferred

event CampaignERC20RewardPacketAssetsTransferred(uint256 campaignId, address from, address to, uint256 amountOfPackets)

Emitted at transferErc20Reward().

setCampaignTransferErc20Rewards

function setCampaignTransferErc20Rewards(uint256 campaignId, bytes campaignTransferErc20RewardsData) external

Setter function for configuring the ERC20 assets within the reward packet for the specified staking campaign. This function configures only the content of the reward packet associated with ERC20 assets.

_selector: 0xd5378110

Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol)

Requirements:

  • The tokenAddresses and amountOfTokensPerPacket arrays must have the same length.
  • tokenAddresses must contain valid, non-zero ERC20 token addresses.
  • amountOfTokensPerPacket must contain non-zero values.

Emits a {CampaignERC20RewardConfigured} event.


IMPORTANT:

  • The reward packet should not encapsulate only ERC20 tokens; for configurations involving only ERC20 tokens, use ERC20RewardMinterFacet.sol or ERC20RewardTransferFacet.sol instead. Since other ERCs may or may not have decimal places, the values inamountOfTokensPerPacket should be parsed with each token's decimal precision (using wei values) at the API level. ----------------------------------------------------------------------------------------------------------------_

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
campaignTransferErc20RewardsDatabytesThe ABI-encoded data containing the following: - tokenAddresses: An address array containing the addresses of the ERC20 tokens encapsulated by the reward packet. - amountOfTokensPerPacket: A uint256 array specifying the amount for each corresponding token in tokenAddresses.

transferErc20Reward

function transferErc20Reward(uint256 campaignId, address from, address to, uint256 amountOfPackets) external

Transfers the ERC20 assets associated with the specified amount of a given campaign's reward packets from the from address to the to address.

_selector: 0x04df5c3d

This function iteratively executes transfer functions for all respective amounts of ERC20 tokens defined in the campaign's reward packet (see setCampaignTransferErc20Rewards()) in a single transaction.

The amounts to be transferred are calculated as amountOfTokensPerPacket[i] * amountOfPackets for each ERC20 token in the reward 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 {CampaignERC20RewardPacketAssetsTransferred} event._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
fromaddressThe address from which the ERC20 assets encapsulated by the specified number of rewards packets to be "ransferred.
toaddressThe address to receive the ERC20 assets encapsulated by the specified number of reward packets.
amountOfPacketsuint256The number of reward packets to account for.

On this page