Staking ProtocollockVariationsstaticPeriod

StaticPeriodLockFacetStorage

This library manages the storage and logic for applying time-based lock configurations for staking campaigns and handles lock duration checks that should be performed during staking and restaking operations.

This implementation is designed to configure a distinct set of lock periods for any campaign. When using this implementation, the lock periods for positions must match one of the periods defined in the associated campaign's set of lock periods.

AlreadyInitialized

error AlreadyInitialized()

Thrown when attempting to re-initialize.

InvalidZeroMaxLockPeriodForCampaigns

error InvalidZeroMaxLockPeriodForCampaigns()

Thrown at initializer when the maximum lock period is attempted to be set to zero.

CampaignNotOnCreationStateForSetting

error CampaignNotOnCreationStateForSetting(uint256 campaignId)

Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.

NoAcceptedLockPeriodsSpecified

error NoAcceptedLockPeriodsSpecified(uint256 campaignId)

Thrown at setter when no lock accepted periods are specified for a campaign.

ExceedsMaxAllowedLockPeriod

error ExceedsMaxAllowedLockPeriod(uint256 campaignId, uint256 providedLockPeriod, uint256 maxAllowedLockPeriod)

Thrown at setter when a specified lock period exceeds the maximum allowed lock period for campaigns.

UnsupportedLockPeriodRequest

error UnsupportedLockPeriodRequest(uint256 campaignId, uint256 requestedLockPeriod)

Thrown at checker when a specified lock period is not supported for a given campaign.

STORAGE_SLOT

bytes32 STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored.

Layout

Struct for managing time-based lock configurations for staking campaigns.

struct Layout {
  mapping(uint256 => mapping(uint256 => bool)) isLockPeriodSupportedForCampaign;
  uint256 maxLockPeriod;
}

layout

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

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

initLockVariationsFacet

function initLockVariationsFacet(struct StaticPeriodLockFacetStorage.Layout l, bytes initLockVariationsData) internal returns (uint256)

Initializes the StaticPeriodLockFacetStorage by registering the maximum accepted lock period for campaigns.

The maximum accepted lock period must be greater than 0.

Parameters

NameTypeDescription
lstruct StaticPeriodLockFacetStorage.LayoutA reference to the Layout struct in storage.
initLockVariationsDatabytesThe ABI-encoded data containing the following: - maxLockPeriod: The maximum accepted lock period, in seconds, for any campaign.

setCampaignLockVariations

function setCampaignLockVariations(struct StaticPeriodLockFacetStorage.Layout l, uint256 campaignId, bytes campaignLockVariationsData) internal returns (uint256[])

Setter function for configuring time-based lock 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 accepted lock periods (in unix period format) that any position within the campaign can support. All lock periods for positions in the campaign must match one of the periods defined in lockPeriods.

IMPORTANT:

  • All the periods within lockPeriods must be less than or equal to the campaign's maxLockPeriod (see initLockVariationsFacet())._

Parameters

NameTypeDescription
lstruct StaticPeriodLockFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
campaignLockVariationsDatabytesThe ABI-encoded data containing the following: - lockPeriods: A uint256 array of lock periods, in seconds, defining the accepted lock periods for the campaign.

checkTimeLock

function checkTimeLock(struct StaticPeriodLockFacetStorage.Layout l, uint256 campaignId, uint256 timeLockPeriod) internal view

Checks whether the specified lock period complies with the configured time-based lock constraints of the given campaign.

_Reverts if:

  • timeLockPeriod does not match any of the periods defined int the campaign's configured lockPeriods (see setCampaignLockVariations())._

Parameters

NameTypeDescription
lstruct StaticPeriodLockFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
timeLockPerioduint256The lock period to check, in seconds (unix period format).