FundingErc20PacketsFacet
This facet handles the configuration of funding packets (a.k.a input packets) for fractionalization campaigns and facilitates the transfer of these funding packets.
_This implementation is designed for use in campaigns where the funding packet is constructed solely from ERC20 tokens.
IMPORTANT:
- Extra care should be taken when specifying token amounts, especially when dealing with tokens of
varying decimal precision (see
setAndCheckFundingPacket()for more details). - A funding packet can encapsulate one (e.g., tokenA) or more (e.g., tokenA, tokenB, ..., tokenX) ERC20 tokens._
FundingPacketInitialized
Emitted at initFundingPacketFacet().
CampaignFundingPacketConfigured
Emitted at setAndCheckFundingPacket().
FundingTokenAdded
Emitted when adding/removing funding tokens at addAcceptedFundingToken() and removeAcceptedFundingToken().
FundingTokenRemoved
UnauthorizedInitialization
Thrown when trying to initialize from non admin account.
OnlyAdminCanAddOrRemoveTokenAddress
Thrown when trying to add or remove a funding token address from non admin account.
initFundingPacketFacet
Initializes the FundingErc20PacketsFacetStorage by setting the approved ERC20 tokens.
These tokens serve as valid funding currencies within the platform.
Parameters
| Name | Type | Description |
|---|---|---|
| initFundingPacketData | bytes | The ABI-encoded data containing the following: approvedTokens: An array of ERC20 token addresses approved for inclusion in input packets. |
setAndCheckFundingPacket
Configures and validates the funding packet of a campaign.
_Set and Check functions are executed during the creation process of campaigns (see CreateFractionsSkeleton.sol).
This function configures the funding packet for a campaign, where only ERC20 tokens should be included.
Emits a {CampaignFundingPacketConfigured} event.
Requirements:
- The
tokenAddressesandamountOfTokensPerPacketarrays must have the same length. tokenAddressesmust contain approved ERC20 token addresses (seeinitFundingPacketFacet()).amountOfTokensPerPacketmust contain non-zero values.
IMPORTANT:
-
If all ERC20 tokens in
tokenAddresseshave the same decimal places, two configuration options exist:-
Parse values in
amountOfTokensPerPacketusing the common decimal precision (wei values). In this case, funding packet amounts should be specified in whole units at the API level. This option is only viable when no Discount & no Interest mechanisms are featured in the campaign. -
Specify values in
amountOfTokensPerPacketin whole units, thus, funding packet amounts should be parsed with the appropriate number of decimal digits at the API level (e.g., inBuybackSekelton.buyback()etc.).
-
-
If any ERC20 token in
tokenAddresseshas a different decimal precision than others, only one option is valid:- Parse
amountOfTokensPerPacketusing each token’s specific decimal precision (wei values). Funding packet amounts must then be specified in whole units at the API level forpurchase(), etc. As stated above, such a funding packet cannot be used in campaigns featuring Discount or Interest mechanisms. ----------------------------------------------------------------------------------------------------------------------------_
- Parse
Parameters
| Name | Type | Description |
|---|---|---|
| postFractionFundingPacketData | 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. |
transferFundingPackets
Transfers the specified amount of a given campaign's input packets from the from address
to the to address.
Emits a {CampaignFundingPacketsTransferred} event.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted 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. |

