OraclePriceFacet
Manages the configuration of fraction pricing in terms of funding packets (a.k.a input packets) within fractionalization campaigns. It defines the number of funding packets required to obtain a single fraction per campaign.
_This PriceFacet implementation is intended for campaigns where the price of fractions are set by an Oracle and may vary throughout the campaign lifecycle. Each campaign is configured separately.
IMPORTANT:
- Extra care should be taken when setting the oracle address (see
setAndCheckPriceFacet()) as it is closely tied to the configuration of the campaign's funding packet (see FundingPackets facets)._
OracleAddressConfigured
Emitted at setAndCheckPriceFacet().
UnauthorizedInitialization
Thrown when trying to initialize from non admin account.
initPriceFacet
setAndCheckPriceFacet
Sets the oracle address cappable to set the price of a fraction, in terms of funding packets, for a campaign.
_Defines the oracle address as the address that is allowed to set the price of a fraction in an associated campaign.
Emits a {OracleAddressConfigured} event._
Parameters
| Name | Type | Description |
|---|---|---|
| postFractionPriceData | bytes | The ABI-encoded data containing the following: - oracleAddress: The address of the oracle that will set the price of a fraction in an associated campaign. |
setPrice
Sets the price of a fraction, in terms of funding packets, for a campaign.
_Defines the price as the number of funding packets required to purchase a single fraction in an associated campaign.
This function is callable only by the oracle address set in setAndCheckPriceFacet().
Emits a {CampaignPriceConfigured} event.
IMPORTANT:
There are two ways to configure price and funding packets at the API level, depending on
the decimal precision of tokens in the campaign's funding packet:
-
Uniform Decimal Precision (All funding tokens have the same decimal precision—no mixed ERCs allowed):
- Either:
- Set the funding packet's
tokenAmountvalues (seeFundingPackets Facets) in whole units (e.g.,2 wei). - Set
pricescaled by the token’s decimal precision (e.g., for 6 decimals,price = 10 * 10^6).
- Set the funding packet's
- Or:
- Set
tokenAmountvalues already scaled by the decimal precision (e.g.,2 * 10^6). - Set
pricein whole units (e.g.,price = 10).
- Set
- Either:
-
Mixed Decimal Precision (Funding tokens have different decimal precision-mixed ERCs allowed):
- The
tokenAmountvalues in the funding packet must always be scaled to the respective decimal precision. - The
pricemust be set in whole units.
- The
Discount & Interest Mechanisms:
-
If discount & interest mechanisms are configured, the
tokenAmount(s)of funding packet must be defined in whole units (e.g.,2 wei), andpricemust always be scaled according to the funding token decimal precision (e.g., for 6 decimals,price = 10 * 10^6). This requirement should be enforced at the API level and within front-end applications. -
To prevent truncation,
priceshould be scaled by at least 1e6, considering that percentages are 1e6 scaled. -
This ensures that percentage-based discount & interest mechanisms (e.g.,
BurnFungibleForDiscount) can correctly compute discounted and interest-adjusted prices without truncation. Percentages are based on10^6, meaning10^6 == 100%.
Example:
- If the campaign's funding packet has been configured (see
FundingPackets Facets) as 2 wei of $TOKEN (suppose $TOKEN has 18 decimals), andprice == 1 * 10^18, then to purchase a single fraction, investors will need to provide 10^18 funding packets which corresponds to 2 $TOKEN per fraction (2 wei * 10^18 == 2 * 10^18)._
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| price | uint256 | The price (in terms of funding packets) required to purchase a single fraction. |
getPurchasePrice
getCurrentPrice
Retrieves the price of a single fraction within a specified campaign.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | uint256 The amount of funding packets required to purchase a single fraction in campaignId. |

