Staking Protocoltransfersinputerc1155

Erc1155InputFacetStorage

This library manages the storage and logic for handling the configuration of input packets for staking campaigns and facilitates their transfer.

_This implementation is designed for use in staking campaigns where the input packet is constructed solely from ERC1155 tokens.

IMPORTANT:

  • An input packet can encapsulate one (e.g., tokenA of ID X) or more (e.g., tokenA of ID X, tokenA of ID Y, ..., tokenX of ID Z) ERC1155 tokens._

CampaignNotOnCreationStateForSetting

error CampaignNotOnCreationStateForSetting(uint256 campaignId)

Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.

NoInputPacketDataProvided

error NoInputPacketDataProvided(uint256 campaignId)

Thrown at setter when no data provided for either tokenAddresses or tokenIds or amountOfTokensPerPacket.

InvalidInputPacketDataLengths

error InvalidInputPacketDataLengths(uint256 campaignId, uint256 tokenAddressesLength, uint256 tokenIdsLength, uint256 amountOfTokensPerPacketLength)

Thrown at setter when the lengths of tokenAddresses, tokenIds and amountOfTokensPerPacket do not match.

InvalidZeroInputPacketAddressData

error InvalidZeroInputPacketAddressData(uint256 campaignId, uint256 index)

Thrown at setter when an element of tokenAddresses is the zero address.

InvalidZeroInputPacketAmountData

error InvalidZeroInputPacketAmountData(uint256 campaignId, uint256 index)

Thrown at setter when an element of amountOfTokensPerPacket is zero.

STORAGE_SLOT

bytes32 STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored.

Layout

Struct for managing information related to campaigns' input packets.

struct Layout {
  mapping(uint256 => struct Erc1155InputFacetStorage.InputPacket) campaignsPacketInfo;
}

InputPacket

Struct containing the configuration information for an input packet.

struct InputPacket {
  uint256[] tokenIds;
  address[] tokenAddresses;
  mapping(address => uint256) amountOfTokensPerPacket;
}

layout

function layout() internal pure returns (struct Erc1155InputFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT unique identifier.

setCampaignTransferInput

function setCampaignTransferInput(struct Erc1155InputFacetStorage.Layout l, uint256 campaignId, bytes campaignTransferInputData) internal returns (address[], uint256[], uint256[])

Setter function for configuring the input packet for the specified staking campaign.

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

This setter function configures the input packet for a campaign, where only ERC1155 tokens should be included.

Requirements:

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

IMPORTANT:

  • The values in amountOfTokensPerPacket should be in whole units, since ERC1155 tokens do not have decimal places. ----------------------------------------------------------------------------------------------------------------_

Parameters

NameTypeDescription
lstruct Erc1155InputFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
campaignTransferInputDatabytesThe ABI-encoded data containing the following: - tokenAddresses: An address array containing the addresses of the ERC1155 tokens encapsulated by the input packet. - tokenIds: A uint256 array specifying the ID for each corresponding token in tokenAddresses. - amountOfTokensPerPacket: A uint256 array specifying the amount for each corresponding token in tokenAddresses.

transferInput

function transferInput(struct Erc1155InputFacetStorage.Layout l, uint256 campaignId, address from, address to, uint256 amountOfPackets) internal

Transfers the specified amount of a given campaign's input packets from the from address to the to address.

_This function iteratively executes transfers for all respective amounts of ERC1155 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 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 ERC1155 token interface._

Parameters

NameTypeDescription
lstruct Erc1155InputFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
fromaddressThe address from which the ERC1155 assets encapsulated by the specified number of input packets to be transferred.
toaddressThe address to receive the ERC1155 assets encapsulated by the specified number of input packets.
amountOfPacketsuint256The number of input packets to account for.

On this page