Staking ProtocollockVariationstwoBorderTimeLockFacet

TwoBorderTimeLockFacetStorage

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 minimum and maximum lock durations for staked assets in positions within any campaign.

CampaignNotOnCreationStateForSetting

error CampaignNotOnCreationStateForSetting(uint256 campaignId)

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

InvalidZeroMaxLockPeriod

error InvalidZeroMaxLockPeriod()

Thrown at setter when the maximum lock period is attempted to be set to zero for a campaign.

MaxLockPeriodLessThanMin

error MaxLockPeriodLessThanMin(uint256 campaignId, uint256 minLockPeriodSpecified, uint256 maxLockPeriodSpecified)

Thrown when the specified maximum lock period is less than the minimum for a campaign.

InvalidTimeLockPeriod

error InvalidTimeLockPeriod(uint256 campaignId, uint256 requestedLockPeriod, uint256 minLockPeriod, uint256 maxLockPeriod)

Thrown when a specified time lock period is not within the accepted range for a 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 => struct TwoBorderTimeLockFacetStorage.CampaignLockPeriods) campaignLockPeriods;
}

CampaignLockPeriods

Struct containing the time-based lock configuration for a staking campaign.

struct CampaignLockPeriods {
  uint256 minAcceptedLockPeriod;
  uint256 maxAcceptedLockPeriod;
}

layout

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

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

setCampaignLockVariations

function setCampaignLockVariations(struct TwoBorderTimeLockFacetStorage.Layout l, uint256 campaignId, bytes campaignLockVariationsData) internal returns (uint256, 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 minimum and maximum lock periods (in unix period format) that any position within the campaign can support. All lock periods for positions in the campaign must fall within the configured minAcceptedLockPeriod and maxAcceptedLockPeriod.

IMPORTANT:

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

Parameters

NameTypeDescription
lstruct TwoBorderTimeLockFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
campaignLockVariationsDatabytesThe ABI-encoded data containing the following: - minAcceptedLockPeriod: The minimum required time duration in seconds, that staked assets must be locked when the positions are either created (stake) or increased (restake). - maxAcceptedLockPeriod: The maximum allowed time duration in seconds, that staked assets can be locked when the positions are either created (stake) or increased (restake).

checkTimeLock

function checkTimeLock(struct TwoBorderTimeLockFacetStorage.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 is less than the campaign's configured minAcceptedLockPeriod (see setCampaignLockVariations()).
  • timeLockPeriod is greater than the campaign's configured maxAcceptedLockPeriod (see setCampaignLockVariations())._

Parameters

NameTypeDescription
lstruct TwoBorderTimeLockFacetStorage.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).

On this page