Staking ProtocolcampaignTimestwoBorderTimestampCampaign

TwoBorderTimestampCampaign_

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

_This implementation is designed to configure the Starting timestamp, Ending timestamp, and Rewards Ending timestamp of staking campaigns and checks that campaigns have started and have not yet ended during stake and restake operations.

IMPORTANT: This implementation is intended for use in staking campaigns where stake and restake operations can only occur within a designated timeframe defined by the configured startingTimestamp and endingTimestamp. Rewards start accruing from the moment the campaign reaches its endingTimestamp and continue until the rewardsEndingTimestamp, rather than from the moment positions are created. Thus, stakes and restakes are active from the moment endingTimestamp is reached up until the rewardsEndingTimestamp is reached._

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.

InvalidCampaignTimestamps

error InvalidCampaignTimestamps(uint256 campaignId, uint256 startingTimestampToSet, uint256 endingTimestampToSet, uint256 rewardsEndingTimestampToSet)

Thrown when attempting to set an invalid combination of timestamps for a campaign.

CannotStakeCampaignNotStarted

error CannotStakeCampaignNotStarted(uint256 campaignId, uint256 campaignStartingTimestamp)

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

CannotStakeCampaignEnded

error CannotStakeCampaignEnded(uint256 campaignId, uint256 campaignEndingTimestamp)

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

CampaignTimesConfigured

event CampaignTimesConfigured(uint256 campaignId, uint256 startingTimestamp, uint256 endingTimestamp, uint256 rewardsEndingTimestamp)

Emitted at setCampaignTimesData().

setCampaignTimesData

function setCampaignTimesData(uint256 campaignId, bytes campaignTimesData) external

Setter function for configuring the Starting timestamp, Ending timestamp, and Rewards Ending 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.
  • endingTimestamp must be greater than the startingTimestamp.
  • rewardsEndingTimestamp must be greater than or equal to endingTimestamp._

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. - endingTimestamp: The Unix timestamp indicating when the campaign ends. - rewardsEndingTimestamp: The Unix timestamp indicating when the rewards stop.

checkCampaignTimesOnStake

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

Checks, during a stake or restake operation, whether the specified campaign has started and has not yet ended.

_Reverts if:

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

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.

Return Values

NameTypeDescription
[0]uint256The ending timestamp of the campaign since rewards are to be distributed after the campaign ends.

On this page