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
andNON_FUNDED
).
- Supports campaigns featuring discount mechanisms (i.e., the platform must have
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 provideddiscountOperationData
(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 providedpostPurchaseData
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
Emitted at purchase()
.
purchase
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
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted campaign. |
amountOfFractions | uint256 | The number of fractions to purchase. |
discountOperationData | bytes | ABI-encoded data required for applying discounts (if any). |
postPurchaseData | bytes | ABI-encoded data required for the post-purchase phase. |
chainId | uint32 | The ID of the blockchain network where the purchased fractions will be received or utilized. |