Fraction ProtocolgenericFacetsfundingPacketFacetfundingErc20Packets

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

event FundingPacketInitialized(address[] tokenAddresses)

Emitted at initFundingPacketFacet().

CampaignFundingPacketConfigured

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

Emitted at setAndCheckFundingPacket().

FundingTokenAdded

event FundingTokenAdded(address tokenAddress)

Emitted when adding/removing funding tokens at addAcceptedFundingToken() and removeAcceptedFundingToken().

FundingTokenRemoved

event FundingTokenRemoved(address tokenAddress)

UnauthorizedInitialization

error UnauthorizedInitialization(address account)

Thrown when trying to initialize from non admin account.

OnlyAdminCanAddOrRemoveTokenAddress

error OnlyAdminCanAddOrRemoveTokenAddress(address account)

Thrown when trying to add or remove a funding token address from non admin account.

initFundingPacketFacet

function initFundingPacketFacet(bytes initFundingPacketData) external

Initializes the FundingErc20PacketsFacetStorage by setting the approved ERC20 tokens.

These tokens serve as valid funding currencies within the platform.

Parameters

NameTypeDescription
initFundingPacketDatabytesThe ABI-encoded data containing the following: approvedTokens: An array of ERC20 token addresses approved for inclusion in input packets.

setAndCheckFundingPacket

function setAndCheckFundingPacket(bytes postFractionFundingPacketData) external

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 tokenAddresses and amountOfTokensPerPacket arrays must have the same length.
  • tokenAddresses must contain approved ERC20 token addresses (see initFundingPacketFacet()).
  • amountOfTokensPerPacket must contain non-zero values.

IMPORTANT:

  • If all ERC20 tokens in tokenAddresses have the same decimal places, two configuration options exist:

    1. Parse values in amountOfTokensPerPacket using 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.

    2. Specify values in amountOfTokensPerPacket in whole units, thus, funding packet amounts should be parsed with the appropriate number of decimal digits at the API level (e.g., in BuybackSekelton.buyback() etc.).

  • If any ERC20 token in tokenAddresses has a different decimal precision than others, only one option is valid:

    • Parse amountOfTokensPerPacket using each token’s specific decimal precision (wei values). Funding packet amounts must then be specified in whole units at the API level for purchase(), etc. As stated above, such a funding packet cannot be used in campaigns featuring Discount or Interest mechanisms. ----------------------------------------------------------------------------------------------------------------------------_

Parameters

NameTypeDescription
postFractionFundingPacketDatabytesThe 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

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

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

Emits a {CampaignFundingPacketsTransferred} event.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted campaign.
fromaddressThe address from which the ERC20 assets encapsulated by the specified number of input packets to be transferred.
toaddressThe address to receive the ERC20 assets encapsulated by the specified number of input packets.
amountOfPacketsuint256The number of input packets to account for.

addAcceptedFundingToken

function addAcceptedFundingToken(address tokenAddress) external

removeAcceptedFundingToken

function removeAcceptedFundingToken(address tokenAddress) external