Fraction ProtocolinternalFacetspurchasePhaseFacetspurchaseAmountFacetstwoCap

TwoCapPurchaseAmountFacetStorage

TwoCapPurchaseAmountFacetStorage

AlreadyInitialized

error AlreadyInitialized()

Thrown when attempting to re-initialize.

InvalidZeroMaxHardcap

error InvalidZeroMaxHardcap()

Thrown at initialization when attempting to pass max hardcap as 0.

InvalidInputAmounts

error InvalidInputAmounts(uint256 campaignId, uint256 softCap, uint256 hardCap)

Thrown when attempting to pass invalid input amounts for softcap and hardcap.

HardcapExceedsMaxHardcap

error HardcapExceedsMaxHardcap(uint256 campaignId, uint256 hardCap, uint256 maxHardCap)

Thrown when attempting to pass hardcap that exceeds max hardcap.

HardcapPerAccountExceedsHardcap

error HardcapPerAccountExceedsHardcap(uint256 campaignId, uint256 hardCapPerAccount, uint256 hardCap)

Thrown when attempting to pass hardcap per account that exceeds hardcap.

SoftcapPerAccountExceedsSoftcap

error SoftcapPerAccountExceedsSoftcap(uint256 campaignId, uint256 softCapPerAccount, uint256 softCap)

Thrown when attempting to pass softcap per account that exceeds softcap.

SoftcapPerAccountExceedsHardcapPerAccount

error SoftcapPerAccountExceedsHardcapPerAccount(uint256 campaignId, uint256 softCapPerAccount, uint256 hardCapPerAccount)

notice Thrown when attempting to pass softcap per account that exceeds hardcap per account.

InvalidZeroAmountOfFractionsToPurchase

error InvalidZeroAmountOfFractionsToPurchase(uint256 campaignId, address account)

Thrown when attempting to purchase 0 amount of fractions.

InvalidOverHardcapPurchase

error InvalidOverHardcapPurchase(uint256 campaignId, address account)

Thrown when attempting to purchase more fractions than available.

InvalidOverAccountHardcapPurchase

error InvalidOverAccountHardcapPurchase(uint256 campaignId, uint256 hardCapPerAccount, address account)

Thrown when attempting to purchase more fractions than account hardcap allows.

InvalidUnderAccountSoftcapPurchase

error InvalidUnderAccountSoftcapPurchase(uint256 campaignId, uint256 softCapPerAccount, address account)

Thrown when attempting to purchase less fractions than account softcap allows.

STORAGE_SLOT

bytes32 STORAGE_SLOT

================================================== STORAGE =================================================

Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: 0x80289af729f64dfcd230ded31d365fe80f029d0b25b8ca23db30fd92fc014800

Layout

struct Layout {
  uint256 maxHardCap;
  mapping(uint256 => uint256) softCapForId;
  mapping(uint256 => uint256) hardCapForId;
  mapping(uint256 => uint256) hardCapPerAccountForId;
  mapping(uint256 => uint256) softCapPerAccountForId;
  mapping(uint256 => mapping(address => uint256)) fractionsPurchasedByAccountForId;
}

layout

function layout() internal pure returns (struct TwoCapPurchaseAmountFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at a specified storage slot

initPurchaseAmountFacet

function initPurchaseAmountFacet(struct TwoCapPurchaseAmountFacetStorage.Layout l, bytes initPurchaseAmountData) internal returns (uint256)

setAndCheckPurchaseAmounts

function setAndCheckPurchaseAmounts(struct TwoCapPurchaseAmountFacetStorage.Layout l, bytes postFractionsAmountData) internal returns (uint256, uint256, uint256, uint256, uint256)

Sets the amount-based fraction caps (both campaign-wide and per-account) for a campaign's purchase phase.

_To disable a campaign's:

  • softCap: Set its value to 1 (1 fraction purchased guarantees a successful campaign).
  • hardCap : Set its value to type(uint256).max.
  • softCapPerAccount: Set its value to 1.
  • hardCapPerAccount: Set its value to hardCap._

Parameters

NameTypeDescription
lstruct TwoCapPurchaseAmountFacetStorage.LayoutA reference to the Layout struct in storage.
postFractionsAmountDatabytesABI-encoded data containing the following (uint256 values): - softCap: The minimum amount of fractions that must be collectively purchased for the campaign to succeed. - hardCap: The maximum amount of fractions that can be collectively purchased in the campaign. - softCapPerAccount: The minumum amount of fractions that any account can purchase in the campaign (minimum participation) - hardCapPerAccount: The maximum amount of fractions that any account can purchase in the campaign (maximum participation).

Return Values

NameTypeDescription
[0]uint256campaignId The ID of the targeted campaign.
[1]uint256softCap The softCap set.
[2]uint256hardCap The hardCap set.
[3]uint256softCapPerAccount The softCapPerAccount set.
[4]uint256hardCapPerAccount The hardCapPerAccount set.

checkPurchaseAmounts

function checkPurchaseAmounts(struct TwoCapPurchaseAmountFacetStorage.Layout l, uint256 campaignId, uint256 amountOfFractions, address account) internal

Sets the fractions purchased by account for a campaign.

Parameters

NameTypeDescription
lstruct TwoCapPurchaseAmountFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The ID of the targeted campaign.
amountOfFractionsuint256The amount of fractions to purchase.
accountaddressThe account to purchase the fractions from.

isTotalAmountValid

function isTotalAmountValid(struct TwoCapPurchaseAmountFacetStorage.Layout l, uint256 campaignId) internal view returns (bool)

Checks if the total amount of fractions purchased is valid.

Parameters

NameTypeDescription
lstruct TwoCapPurchaseAmountFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The ID of the targeted campaign.

Return Values

NameTypeDescription
[0]boolbool True if the total amount of fractions purchased is valid, false otherwise.

getTotalFractionsPurchased

function getTotalFractionsPurchased(uint256 campaignId) internal view returns (uint256)

Gets the total amount of fractions purchased for a campaign.

Parameters

NameTypeDescription
campaignIduint256The ID of the targeted campaign.

Return Values

NameTypeDescription
[0]uint256uint256 The total amount of fractions purchased for the campaign.

setMaxHardCap

function setMaxHardCap(struct TwoCapPurchaseAmountFacetStorage.Layout l, uint256 maxHardCap) internal

Sets the max hardcap for a campaign.

Parameters

NameTypeDescription
lstruct TwoCapPurchaseAmountFacetStorage.LayoutA reference to the Layout struct in storage.
maxHardCapuint256The max hardcap to set.