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
Thrown when attempting to re-initialize.
WrongInitializationData
Thrown when passing invalid initialization data.
MissingInitialization
Thrown when acquireDoReceiveFees
is invoked, but initialization of storage has not occurred.
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.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
initDoReceiveFeeCollectorFacet
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
andlimitSetter
cannot be set to the zero address._
Parameters
Name | Type | Description |
---|---|---|
l | struct PropPacketsGatheredFeeCollectorFacetStorage.Layout | A reference to the Layout struct in storage. |
initDoReceiveFeeCollectorData | bytes | ABI-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
Calculates the fee from totalPacketsGathered
based on the configured feeRate
, and transfers the corresponding amount
to the designated feeCollector
via IFundingPacketFacet.transferFundingPackets()
.
Parameters
Name | Type | Description |
---|---|---|
l | struct PropPacketsGatheredFeeCollectorFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted campaign. |
totalPacketsGathered | uint256 | The total number of funding packets gathered in campaignId . |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The number of funding packets remaining after the fee has been deducted. |
[1] | uint256 | The number of funding packets collected as a fee. |
setFeeLimitOnCampaign
Sets a cap on the maximum amount (funding packets) to which the fee rate applies for a specified campaign's gathered funds.
Parameters
Name | Type | Description |
---|---|---|
l | struct PropPacketsGatheredFeeCollectorFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted campaign. |
packetsLimit | uint256 | The cap to set (in terms of funding packets) |