HardcapAmountFacet
HardcapAmountFacet
Enables the application of amount-based packet configurations for staking campaigns and handles amount-based checks that should be performed during staking and unstaking operations.
This implementation is designed to configure hardcaps on the total number of input packets that can be allocated to each campaign.
CampaignAmountsConfigured
Emitted at setCampaignAmountsData()
.
setCampaignAmountsData
Setter function for configuring amount-based packet constraints for the specified staking campaign.
_Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol
).
This function allows for setting an upper limit (hardcap) on the total number of input packets that can be staked within a campaign.
IMPORTANT: If packetsHardcap == 0
, then no upper limit is enforced on the specified campaign.
Emits a {CampaignAmountsConfigured}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignAmountsData | bytes | The ABI-encoded data containing the following: - packetsHardcap : The maximum number (uint256) of input packets that can be allocated to the campaign. |
checkInputPackets
Checks whether the specified amount of packets can be allocated within a given campaign's position.
_Reverts if amountOfPackets
is 0 or if it would cause the campaign's total staked packets to exceed the
configured hardcap.
IMPORTANT: If nftId == 0
, the check is performed for a new stake operation; otherwise, it is performed
for a restake operation._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
amountOfPackets | uint256 | The number of input packets to check. |
checkUnstakePackets
Checks whether the specified amount of packets can be withdrawn from a given campaign's position.
Reverts if amountOfPackets
is 0. For partial unstaking, it also reverts if amountOfPackets
is
greater than or equal to the position's total staked packets.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
amountOfPackets | uint256 | The number of input packets to check. |
isPartialUnstake | bool | A flag indicating whether the unstake is partial (true ) or full (false ). |