Staking ProtocolcampaignAmountstwoBorderAmountFacet

TwoBorderAmountFacet

TwoBorderAmountFacet

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 minimum and maximum limits on the number of input packets supported by positions within any campaign.

CampaignAmountsConfigured

event CampaignAmountsConfigured(uint256 campaignId, uint256 minAmountOfInputPackets, uint256 maxAmountOfInputPackets)

Emitted at setCampaignAmountsData().

setCampaignAmountsData

function setCampaignAmountsData(uint256 campaignId, bytes campaignAmountsData) external

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 the minimum and maximum limits on the number of input packets that a campaign's position can support.

Emits an {CampaignAmountsConfigured} event.

IMPORTANT:

  • maxAmountOfPackets must be strictly greater than 0 (if no upper limit is required, use type(uint256).max).
  • minAmountOfPackets must be less than or equal to maxAmountOfPackets._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
campaignAmountsDatabytesThe ABI-encoded data containing the following: - minAmountOfPackets: The minimum number (uint256) of input packets required to create and maintain a position within the campaign. - maxAmountOfPackets: The maximum number (uint256) of input packets that a position can support within the campaign.

checkInputPackets

function checkInputPackets(uint256 campaignId, uint256 nftId, uint256 amountOfPackets) external view

Checks whether the specified amount of packets can be allocated within a given campaign's position.

_Reverts if amountOfPackets is 0 or outside the configured limits for the campaign (see setCampaignAmountsData()).

IMPORTANT: If nftId == 0, the check is performed for a new stake operation; otherwise, it is performed for a restake operation._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256The unique identifier of the NFT associated with the position.
amountOfPacketsuint256The number of input packets to check.

checkUnstakePackets

function checkUnstakePackets(uint256 campaignId, uint256 nftId, uint256 amountOfPackets, bool isPartialUnstake) external view

Checks whether the specified amount of packets can be withdrawn from a given campaign's position.

_Reverts if:

  • amountOfPackets is 0.
  • For partial unstaking, if amountOfPackets is greater than or equal to the position's total staked packets, or if the position's remaining staked packets would fall below the campaign's configured minAmountOfPackets (see setCampaignAmountsData()), which is required to maintain active positions._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256The unique identifier of the NFT associated with the position.
amountOfPacketsuint256The number of input packets to check.
isPartialUnstakeboolA flag indicating whether the unstake is partial (true) or full (false).

On this page