Fraction ProtocolskeletonFacetspurchaseSkeletons

PurchaseSkeletonDiscount

Implementation of the Purchase skeleton facet 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 works only on open funds campaigns without vesting, supporting both fungible (ERC20) and semi-fungible non-genesis (ERC1155) fractions, with discount mechanism(s).

  • This implementation is limited to Platforms with these traits:

    • Supports campaigns featuring discount mechanisms (i.e., the platform must have PurchaseDiscount facet(s)).
    • Supports stable fraction pricing (i.e., StablePriceFacet.sol) and dynamic fraction pricing (i.e., LinearCurvePriceFacet.sol)
    • Does NOT support campaigns that feature vesting schedules.
    • Only supports open funds campaigns (i.e., do not feature FUNDED and NON_FUNDED).

The purchase process of fungible or semi-fungible fractions (depending on the campaign's setup) is triggered when purchase() is executed, 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 can occur.

  • 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., 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 current price (e.g., dynamic or stable) 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._

FractionsPurchased

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

Emitted at purchase().

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).

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