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
Thrown when attempting to re-initialize.
InvalidZeroMaxLockPeriodForCampaigns
Thrown at initializer when the maximum lock period is attempted to be set to zero.
CampaignNotOnCreationStateForSetting
Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.
NoAcceptedLockPeriodsSpecified
Thrown at setter when no lock accepted periods are specified for a campaign.
ExceedsMaxAllowedLockPeriod
Thrown at setter when a specified lock period exceeds the maximum allowed lock period for campaigns.
UnsupportedLockPeriodRequest
Thrown at checker when a specified lock period is not supported for a given campaign.
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.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
initLockVariationsFacet
Initializes the StaticPeriodLockFacetStorage
by registering the maximum accepted lock period
for campaigns.
The maximum accepted lock period must be greater than 0.
Parameters
Name | Type | Description |
---|---|---|
l | struct StaticPeriodLockFacetStorage.Layout | A reference to the Layout struct in storage. |
initLockVariationsData | bytes | The ABI-encoded data containing the following: - maxLockPeriod : The maximum accepted lock period, in seconds, for any campaign. |
setCampaignLockVariations
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'smaxLockPeriod
(seeinitLockVariationsFacet()
)._
Parameters
Name | Type | Description |
---|---|---|
l | struct StaticPeriodLockFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignLockVariationsData | bytes | The ABI-encoded data containing the following: - lockPeriods : A uint256 array of lock periods, in seconds, defining the accepted lock periods for the campaign. |
checkTimeLock
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 configuredlockPeriods
(seesetCampaignLockVariations()
)._
Parameters
Name | Type | Description |
---|---|---|
l | struct StaticPeriodLockFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
timeLockPeriod | uint256 | The lock period to check, in seconds (unix period format). |