Staking ProtocolcampaignTimesonlyStartingTimestampCampaign

OnlyStartingTimestampCampaign

Enables the configuration of essential timestamps (e.g., starting timestamp) for staking campaigns and handles campaigns' time checks that should be performed during stake and restake operations.

This implementation is designed to configure only the starting timestamp of staking campaigns and checks solely that campaigns have already started during stake and restake operations.

IMPORTANT: This implementation is intended for use in staking campaigns where stake and restake operations, as well as rewards accrual, are perpetual. In such campaigns rewards begin accruing from the moment a user creates a position and continue indefinitely as long as the position remains active. Thus, stakes and restakes are instantly active._

CampaignNotOnCreationStateForSetting

error CampaignNotOnCreationStateForSetting(uint256 campaignId)

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

InvalidCampaignStartingTimestamp

error InvalidCampaignStartingTimestamp(uint256 campaignId, uint256 invalidStartingTimestamp)

Thrown when an attempt is made to set a campaign's starting timestamp in the past.

CannotStakeCampaignNotStarted

error CannotStakeCampaignNotStarted(uint256 campaignId, uint256 campaignStartingTimestamp)

Thrown when an attempt is made to stake before the campaign's starting timestamp has been reached.

CampaignTimesConfigured

event CampaignTimesConfigured(uint256 campaignId, uint256 startingTimestamp)

Emitted at setCampaignTimesData().

setCampaignTimesData

function setCampaignTimesData(uint256 campaignId, bytes campaignTimesData) external

Setter function for configuring the starting timestamp for the specified staking campaign.

_Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol).

Emits a {CampaignTimesConfigured} event.

IMPORTANT:

  • startingTimestamp must not be a past timestamp reference._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
campaignTimesDatabytesThe ABI-encoded data containing the following: - startingTimestamp: The Unix timestamp indicating when the campaign starts.

checkCampaignTimesOnStake

function checkCampaignTimesOnStake(uint256 campaignId) external view returns (uint256)

Checks, during a stake or restake operation, whether the specified campaign has started.

_Reverts if:

  • block.timestamp is less than the campaign's configured starting timestamp (see setCampaignTimesData())._

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.

Return Values

NameTypeDescription
[0]uint256The current block.timestamp, representing the timestamp of the stake or restake operation. This timestamp also serves as the lock starting point if a lock period is specified during the operation.

On this page