StaticPeriodLockFacet
Enables the application of 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 LockVariations facet, the lock periods for positions must match one of the periods defined in the associated campaign's set of accepted lock periods.
OnlyAdminCanInitialize
Thrown when a non-admin account attempts to call restricted initialization functions.
CampaignLockVariationsInitialized
Emitted at initLockVariationsFacet()
.
CampaignLockVariationsConfigured
Emitted at setCampaignLockVariations()
.
initLockVariationsFacet
Initializes the StaticPeriodLockFacetStorage
by registering the maximum accepted lock period
for campaigns.
_The maximum accepted lock period must be greater than 0.
Emits a {CampaignLockVariationsInitialized}
event.
This function can only be called by the Admin (see AccessControlStakingFacet.sol
)._
Parameters
Name | Type | Description |
---|---|---|
initLockVariationsData | bytes | The ABI-encoded data containing the following: - maxLockPeriod : The maximum accepted lock period (uint256), 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
.
Emits a {CampaignLockVariationsConfigured}
event.
IMPORTANT:
- All the periods within
lockPeriods
must be less than or equal to the campaign'smaxLockPeriod
(seeinitLockVariationsFacet()
). - If the staking campaign is intended to have no lock (e.g., when Rate-Based Open Reward Distribution is employed),
provide for
lockPeriods
an array containing only zero (i.e., [0])._
Parameters
Name | Type | Description |
---|---|---|
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 |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
timeLockPeriod | uint256 | The lock period to check, in seconds (unix period format). |