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 withPurchaseSkeletonGenesisIdsStorage.sol
andNonFundedSubSkeletonGenesisIds.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, theupperGenesisId
will be set to2
. Thus, based on the above example, depending on the price at which an investor purchases fractions, they will receive:
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 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 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 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._
UnauthorizedInitialization
Thrown when trying to initialize from non admin account.
FractionsPurchased
Emitted at purchase()
.
initializePurchaseSkeleton
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
Name | Type | Description |
---|---|---|
signer_ | address | The address of the designated off-chain service that generates the required signatures. |
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).
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
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. |