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
Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.
InvalidCampaignStartingTimestamp
Thrown when an attempt is made to set a campaign's starting timestamp in the past.
InvalidCampaignTimestamps
Thrown when attempting to set an invalid combination of timestamps for a campaign.
CannotStakeCampaignNotStarted
Thrown when an attempt is made to stake before the campaign's starting timestamp has been reached.
CannotStakeCampaignEnded
Thrown when an attempt is made to stake after the campaign's ending timestamp has been reached.
CampaignTimesConfigured
Emitted at setCampaignTimesData()
.
setCampaignTimesData
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 thestartingTimestamp
.rewardsEndingTimestamp
must be greater than or equal toendingTimestamp
._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignTimesData | bytes | The 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
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 (seesetCampaignTimesData()
).block.timestamp
is greater than the campaign's configured ending timestamp (seesetCampaignTimesData()
)._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The ending timestamp of the campaign since rewards are to be distributed after the campaign ends. |