Fraction ProtocolprivateFacetsdoReceiveFacets

PropPacketsGatheredFeeCollectorFacetStorage

This library handles the storage and logic for the PropPacketsGatheredFeeCollectorFacet private facet.

NOTE:

  • We do not use the custom:storage-location annotation because the Layout struct is defined in a library, which, as of now, does not support automated storage layout validation. However, the implementation adheres to the ERC-7201 structure in spirit by ensuring unique and collision-free storage slots using the ERC-7201 formula.

AlreadyInitialized

error AlreadyInitialized()

Thrown when attempting to re-initialize.

WrongInitializationData

error WrongInitializationData()

Thrown when passing invalid initialization data.

MissingInitialization

error MissingInitialization(uint256 campaignId)

Thrown when acquireDoReceiveFees is invoked, but initialization of storage has not occurred.

STORAGE_SLOT

bytes32 STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: TO-DO

Layout

Struct containing the fee schema configuration information.

struct Layout {
  bool isInitialized;
  address feeCollector;
  address limitSetter;
  uint256 feeProportion;
  mapping(uint256 => uint256) campaignPacketsFeeLimit;
}

layout

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

Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT unique identifier.

initDoReceiveFeeCollectorFacet

function initDoReceiveFeeCollectorFacet(struct PropPacketsGatheredFeeCollectorFacetStorage.Layout l, bytes initDoReceiveFeeCollectorData) internal returns (address, address, uint256)

Initializes the PropPacketsGatheredFeeCollectorFacetStorage by registering the eligible fee collector and limit setter addresses, as well as the fee rate to be applied to campaigns' gathered funds.

_For example, if the feeRate is set to 10%, then a campaign raising 100 funding packets will result in 10 funding packets being transferred to the feeCollector when the campaign creator (or the designated account) claims the funds.

IMPORTANT:

  • Rates and percentages are represented with a base of 10^6 (e.g., 0.1 -> 10% is 100000).
  • feeCollector and limitSetter cannot be set to the zero address._

Parameters

NameTypeDescription
lstruct PropPacketsGatheredFeeCollectorFacetStorage.LayoutA reference to the Layout struct in storage.
initDoReceiveFeeCollectorDatabytesABI-encoded data containing: - feeCollector: The eligible address that will be receiving the fees (if any). - limitSetter: The address allowed to set a cap on the maximum amount (funding packets) to which the fee rate applies. - feeRate: The rate defining what portion of a campaign’s gathered funds (in terms of packets) is charged as a fee.

acquireDoReceiveFees

function acquireDoReceiveFees(struct PropPacketsGatheredFeeCollectorFacetStorage.Layout l, uint256 campaignId, uint256 totalPacketsGathered) internal returns (uint256, uint256)

Calculates the fee from totalPacketsGathered based on the configured feeRate, and transfers the corresponding amount to the designated feeCollector via IFundingPacketFacet.transferFundingPackets().

Parameters

NameTypeDescription
lstruct PropPacketsGatheredFeeCollectorFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
totalPacketsGathereduint256The total number of funding packets gathered in campaignId.

Return Values

NameTypeDescription
[0]uint256The number of funding packets remaining after the fee has been deducted.
[1]uint256The number of funding packets collected as a fee.

setFeeLimitOnCampaign

function setFeeLimitOnCampaign(struct PropPacketsGatheredFeeCollectorFacetStorage.Layout l, uint256 campaignId, uint256 packetsLimit) internal

Sets a cap on the maximum amount (funding packets) to which the fee rate applies for a specified campaign's gathered funds.

Parameters

NameTypeDescription
lstruct PropPacketsGatheredFeeCollectorFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
packetsLimituint256The cap to set (in terms of funding packets)

On this page