Staking ProtocollockVariationsstaticPeriod

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

error OnlyAdminCanInitialize(address nonAdminAccount)

Thrown when a non-admin account attempts to call restricted initialization functions.

CampaignLockVariationsInitialized

event CampaignLockVariationsInitialized(uint256 maxLockPeriodForCampaigns)

Emitted at initLockVariationsFacet().

CampaignLockVariationsConfigured

event CampaignLockVariationsConfigured(uint256 campaignId, uint256[] acceptedLockPeriods)

Emitted at setCampaignLockVariations().

initLockVariationsFacet

function initLockVariationsFacet(bytes initLockVariationsData) external

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

NameTypeDescription
initLockVariationsDatabytesThe ABI-encoded data containing the following: - maxLockPeriod: The maximum accepted lock period (uint256), in seconds, for any campaign.

setCampaignLockVariations

function setCampaignLockVariations(uint256 campaignId, bytes campaignLockVariationsData) external

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's maxLockPeriod (see initLockVariationsFacet()).
  • 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

NameTypeDescription
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(uint256 campaignId, uint256 timeLockPeriod) external 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
campaignIduint256The unique identifier of the targeted staking campaign.
timeLockPerioduint256The lock period to check, in seconds (unix period format).

On this page