Verified contractExactMIT
LaunchSchedule
Address0x70e6b0e6da46e8e161c2d7caa7b54c7e90ee8e47
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.37
- Same code
Only this contract
Details
- Compiler
- solc 0.8.37+commit.f401782d
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,426,011
- Creation transaction
- 0xa303360f7d…f16b0ff700
contracts/collection/LaunchSchedule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.37;
interface ILaunchScheduleCollection {
function canPostponePresaleEnd() external view returns (bool);
function revealRequest() external view returns (bytes32);
function fullyRevealed() external view returns (bool);
}
/// @title Pocket Dragons launch schedule
/// @notice Presale start, presale end and full-reveal start times of the collection. Governance can only postpone
/// dates that have not yet passed, with at least 48 hours' public notice and taking effect before the date moved;
/// anyone can activate a queued postponement once its notice has elapsed.
/// @dev Dates are never brought forward and elapsed windows are never reopened. The 72-hour community phase and
/// the previous external phase length are preserved. The presale end cannot move once auction terms are announced,
/// a round is queued, the allocation is sealed or the shared opening is scheduled, and the full-reveal start cannot
/// move once a full-reveal request exists. If a collection check reverts, the postponement is refused.
contract LaunchSchedule {
uint64 public constant NOTICE = 48 hours;
uint64 public constant COMMUNITY_DURATION = 72 hours;
struct Postponement {
uint64 presaleStartsAt;
uint64 presaleEndsAt;
uint64 fullRevealStartsAt;
uint64 effectiveAt;
uint64 version;
}
ILaunchScheduleCollection public immutable collection;
address public immutable governance;
uint64 public immutable originalPresaleStartsAt;
uint64 public immutable originalPresaleEndsAt;
uint64 public immutable originalFullRevealStartsAt;
uint64 public presaleStartsAt;
uint64 public presaleEndsAt;
uint64 public fullRevealStartsAt;
uint64 public version = 1;
Postponement public pending;
error Unauthorized();
error InvalidSchedule();
error NoticeInvalid();
error BoundaryLocked();
event PostponementQueued(
uint64 indexed version,
uint64 presaleStartsAt,
uint64 presaleEndsAt,
uint64 fullRevealStartsAt,
uint64 effectiveAt
);
event PostponementCancelled(uint64 indexed version);
event PostponementActivated(
uint64 indexed version, uint64 presaleStartsAt, uint64 presaleEndsAt, uint64 fullRevealStartsAt
);
constructor(address collection_, address governance_, uint64 start, uint64 end, uint64 reveal) {
// The collection creates this controller during its constructor, before
// its own runtime code exists. Its address is still immutable and nonzero.
if (
collection_ == address(0) || governance_.code.length == 0 || start <= block.timestamp
|| uint256(end) <= uint256(start) + COMMUNITY_DURATION || reveal <= end
) revert InvalidSchedule();
collection = ILaunchScheduleCollection(collection_);
governance = governance_;
originalPresaleStartsAt = presaleStartsAt = start;
originalPresaleEndsAt = presaleEndsAt = end;
originalFullRevealStartsAt = fullRevealStartsAt = reveal;
}
modifier onlyGovernance() {
if (msg.sender != governance) revert Unauthorized();
_;
}
/// @notice Queues a postponement. Governance only; one at a time.
function queuePostponement(uint64 start, uint64 end, uint64 reveal, uint64 effectiveAt) external onlyGovernance {
if (pending.version != 0 || uint256(effectiveAt) < block.timestamp + NOTICE) revert NoticeInvalid();
_validate(start, end, reveal, effectiveAt);
pending = Postponement(start, end, reveal, effectiveAt, version + 1);
emit PostponementQueued(version + 1, start, end, reveal, effectiveAt);
}
/// @notice Cancels the queued postponement. Governance only.
function cancelPostponement() external onlyGovernance {
uint64 nextVersion = pending.version;
if (nextVersion == 0) revert NoticeInvalid();
delete pending;
emit PostponementCancelled(nextVersion);
}
/// @notice Applies the queued postponement once its notice has elapsed. Anyone can call.
function activatePostponement() external {
Postponement memory next = pending;
if (next.version == 0 || next.version != version + 1 || block.timestamp < next.effectiveAt) {
revert NoticeInvalid();
}
// Recheck auction commitments, elapsed deadlines and accepted randomness:
// a safe proposal can become unsafe during its public notice period.
_validate(next.presaleStartsAt, next.presaleEndsAt, next.fullRevealStartsAt, next.effectiveAt);
presaleStartsAt = next.presaleStartsAt;
presaleEndsAt = next.presaleEndsAt;
fullRevealStartsAt = next.fullRevealStartsAt;
version = next.version;
delete pending;
emit PostponementActivated(version, presaleStartsAt, presaleEndsAt, fullRevealStartsAt);
}
function _validate(uint64 start, uint64 end, uint64 reveal, uint64 effectiveAt) private view {
if (
start < presaleStartsAt || end < presaleEndsAt || reveal < fullRevealStartsAt
|| (start == presaleStartsAt && end == presaleEndsAt && reveal == fullRevealStartsAt)
|| uint256(end) <= uint256(start) + COMMUNITY_DURATION || reveal <= end
) revert InvalidSchedule();
if (start != presaleStartsAt) {
if (block.timestamp >= presaleStartsAt || effectiveAt >= presaleStartsAt) revert BoundaryLocked();
// Moving the whole start preserves both the 72h community period and
// at least the previously offered external purchase duration.
if (uint256(end) < uint256(presaleEndsAt) + uint256(start) - presaleStartsAt) revert InvalidSchedule();
}
if (end != presaleEndsAt) {
if (block.timestamp >= presaleEndsAt || effectiveAt >= presaleEndsAt || !collection.canPostponePresaleEnd())
{
revert BoundaryLocked();
}
}
if (reveal != fullRevealStartsAt) {
if (
block.timestamp >= fullRevealStartsAt || effectiveAt >= fullRevealStartsAt
|| collection.revealRequest() != bytes32(0) || collection.fullyRevealed()
) revert BoundaryLocked();
}
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"viaSSACFG": false,
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/=node_modules/@openzeppelin/"
],
"experimental": false
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.