Fraction ProtocolskeletonFacetsNIDpurchaseSkeletons

PurchaseSkeletonGenesisIdsNID

Implementation of the Purchase skeleton facet with Compilot gating for the TMI-Fraction Protocol.

_This facet serves as a core component (skeleton) of a TMI-Fraction Platform, enabling investors to purchase fractions from campaigns.


IMPORTANT:

  • This implementation relies on genesisIds and must always be used in conjunction with PurchaseSkeletonGenesisIdsStorage.sol and NonFundedSubSkeletonGenesisIds.sol (if the non-funded state is applicable), as well as internal facets that rely on it.

  • This implementation can ONLY be utilized by Platforms with the following traits:

    • Supports campaigns that issue only semi-fungible (ERC1155) fractions and feature vesting and/or discount mechanisms.
    • The price of fractions within campaigns is stable (i.e., works only in conjunction with Generic StablePriceFacet.sol).
  • The genesisId identification schema for semi-fungible (ERC1155) fractions enables precise tracking of purchased prices within campaigns. This is achieved by assigning fraction genesis IDs based on the price at which they were purchased. For example, if a campaign offers three different prices (full price, and two discounted prices) for its fractions, the upperGenesisId will be set to 2. Thus, based on the above example, depending on the price at which an investor purchases fractions, they will receive:

      - Fractions purchased at full price → ID = `0`
      - Fractions purchased at 20% discount → ID = `1`
      - Fractions purchased at 50% discount → ID = `2`

The process of investors purchasing genesisIds semi-fungible fractions is signatured-based gated (see TxAuthDataVerifierFacet) and is triggered when purchase() is called, following a sequential pipeline of seven phases:

  • State Check: The Platform interacts with its PurchaseState Internal facet to verify that the current state of the targeted campaign is the correct state for the purchase to occur.

  • Time Check: The Platform interacts with its PurchaseTime Internal facet to verify that the current timestamp is within the campaign's configured time-window during which purchases are expected to happen.

  • Eligibility Check: The Platform interacts with its PurchaseEligibility internal facet to verify that the user (caller) meets the campaign's eligibility criteria to purchase fractions.

  • Amount Check: The Platform interacts with its PurchaseAmount Internal facet to verify that the requested amount of fractions meets the campaign's constraints (e.g., softcap, hardcap etc.).

  • Discount Application: The Platform interacts with its PurchaseDiscount Internal facet to retrieve any applicable discount on the price of fractions and execute the required actions for the discount to take effect based on the provided discountOperationData (e.g., burning reputation tokens in exchange for a discount), if applicable.

  • Purchase Action: The Platform interacts with its DoPurchase Internal facet to transfer the required funds from the user (caller) to the Platform. The required funds are based on either the full stable price or a respective discounted price if the user has opted into any applicable discount mechanism.

  • Post-Purchase Action: The Platform interacts with its PostPurchase Internal facet based on the provided postPurchaseData to handle the purchased fractions accordingly (e.g., transferring them to the user's account or utilizing them in another supported manner, such as staking), thereby finalizing the purchase._

UnauthorizedInitialization

error UnauthorizedInitialization(address account)

Thrown when trying to initialize from non admin account.

FractionsPurchased

event FractionsPurchased(uint256 campaignId, uint32 chainId, address purchaser, uint256 amountOfFractions)

Emitted at purchase().

initializePurchaseSkeleton

function initializePurchaseSkeleton(address signer_) external

Initializes the TxAuthDataVerifierFacetStorage by registering the attestor address.

_This function can only be called by the Admin (see AccessControlFacet.sol).

IMPORTANT:

  • If the platform uses multiple NID skeletons or subskeletons, only one of them can be initialized._

Parameters

NameTypeDescription
signer_addressThe address of the designated off-chain service that generates the required signatures.

purchase

function purchase(uint256 campaignId, uint256 amountOfFractions, bytes discountOperationData, bytes postPurchaseData, uint32 chainId) external payable

Executes the purchase of fractions from a specified campaign.

_Users must meet eligibility criteria (see purchase Eligibility internal facets) and comply with the campaign's constraints (e.g., amount-related constraints).

This function can only be executed if the transaction calldata contains the required signature and expiration block (see requireTxDataAuth modifier).

Emits a {FractionsPurchased} event._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted campaign.
amountOfFractionsuint256The number of fractions to purchase.
discountOperationDatabytesABI-encoded data required for applying discounts (if any).
postPurchaseDatabytesABI-encoded data required for the post-purchase phase.
chainIduint32The ID of the blockchain network where the purchased fractions will be received or utilized.

On this page