Skip to content
Verified contractExactMIT

StockMemeBoostRegistry

Address0x8cfc8cfdadd66e73f6a0cd21eb893a8b9a507052
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.24

 

Same code

4 more contracts

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 100 runs
EVM version
paris
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,933,406
Creation transaction
0x15b883fa6a…bd0702701b
Main copy (most transactions)
0xb9699faf…79b37129

contracts/StockMemeBoostRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

interface IStockMemeLaunchFactory {
    function isLaunch(address token) external view returns (bool);
    function launchIdOf(address token) external view returns (uint256);
    function launches(uint256 launchId)
        external
        view
        returns (
            address token,
            bytes32 poolId,
            bytes32 positionSalt,
            address creator,
            address quoteToken,
            uint64 createdBlock
        );
}

/// @notice Transparent, time-bound paid placement for STOCKMEME markets.
/// @dev This registry is deliberately separate from token, pool, locker, and trading logic.
contract StockMemeBoostRegistry is Ownable2Step, Pausable, ReentrancyGuard {
    uint256 public constant MAX_PACKAGE_PRICE = 0.5 ether;
    /// @dev A finite, UI-safe timestamp representing permanent deployer placement.
    uint64 public constant PERMANENT_BOOST_END = 4_102_444_800; // 2100-01-01 UTC

    IStockMemeLaunchFactory public immutable factory;
    address public immutable freeBoostCreator;
    address public treasury;
    uint256 public accruedRevenue;

    mapping(uint8 packageId => uint64 duration) public packageDuration;
    mapping(uint8 packageId => uint256 price) public packagePrice;
    mapping(address token => uint64 endTime) private _paidBoostEndsAt;
    mapping(address token => bool blocked) public blockedToken;

    event BoostPurchased(
        address indexed token,
        address indexed buyer,
        uint8 indexed packageId,
        uint256 amount,
        uint64 startsAt,
        uint64 endsAt
    );
    event PackagePriceSet(uint8 indexed packageId, uint256 previousPrice, uint256 newPrice);
    event TreasurySet(address indexed previousTreasury, address indexed newTreasury);
    event TokenBlockSet(address indexed token, bool blocked);
    event RevenueWithdrawn(address indexed treasury, uint256 amount);

    error InvalidAddress();
    error InvalidPackage();
    error InvalidPrice();
    error InvalidPayment();
    error UnsupportedToken();
    error TokenBlocked();
    error NothingToWithdraw();
    error TreasuryOnly();
    error NativeTransferFailed();
    error FreeBoostAlreadyActive();

    constructor(address factory_, address treasury_, address owner_, address freeBoostCreator_) Ownable(owner_) {
        if (
            factory_ == address(0) || treasury_ == address(0) || owner_ == address(0)
                || freeBoostCreator_ == address(0)
        ) revert InvalidAddress();
        factory = IStockMemeLaunchFactory(factory_);
        freeBoostCreator = freeBoostCreator_;
        treasury = treasury_;

        packageDuration[0] = 1 hours;
        packageDuration[1] = 6 hours;
        packageDuration[2] = 12 hours;
        packageDuration[3] = 24 hours;

        packagePrice[0] = 0.03 ether;
        packagePrice[1] = 0.05 ether;
        packagePrice[2] = 0.07 ether;
        packagePrice[3] = 0.1 ether;
    }

    function buyBoost(address token, uint8 packageId) external payable nonReentrant whenNotPaused {
        uint64 duration = packageDuration[packageId];
        if (duration == 0) revert InvalidPackage();
        if (msg.value != packagePrice[packageId]) revert InvalidPayment();
        if (!factory.isLaunch(token)) revert UnsupportedToken();
        if (blockedToken[token]) revert TokenBlocked();
        if (isFreeBoostEligible(token)) revert FreeBoostAlreadyActive();

        uint64 currentEnd = _paidBoostEndsAt[token];
        uint64 startsAt = currentEnd > block.timestamp ? currentEnd : uint64(block.timestamp);
        uint64 endsAt = startsAt + duration;
        _paidBoostEndsAt[token] = endsAt;
        accruedRevenue += msg.value;

        emit BoostPurchased(token, msg.sender, packageId, msg.value, startsAt, endsAt);
    }

    function paidBoostEndsAt(address token) external view returns (uint64) {
        return _paidBoostEndsAt[token];
    }

    function boostEndsAt(address token) public view returns (uint64) {
        if (isFreeBoostEligible(token)) return PERMANENT_BOOST_END;
        return _paidBoostEndsAt[token];
    }

    function isFreeBoostEligible(address token) public view returns (bool) {
        if (!factory.isLaunch(token)) return false;
        uint256 launchId = factory.launchIdOf(token);
        (address recordedToken,,, address creator,,) = factory.launches(launchId);
        return recordedToken == token && creator == freeBoostCreator;
    }

    function isActive(address token) external view returns (bool) {
        return !blockedToken[token] && boostEndsAt(token) > block.timestamp;
    }

    function setPackagePrice(uint8 packageId, uint256 price) external onlyOwner {
        if (packageDuration[packageId] == 0) revert InvalidPackage();
        if (price == 0 || price > MAX_PACKAGE_PRICE) revert InvalidPrice();
        emit PackagePriceSet(packageId, packagePrice[packageId], price);
        packagePrice[packageId] = price;
    }

    function setTreasury(address treasury_) external onlyOwner {
        if (treasury_ == address(0)) revert InvalidAddress();
        emit TreasurySet(treasury, treasury_);
        treasury = treasury_;
    }

    function setTokenBlocked(address token, bool blocked) external onlyOwner {
        if (token == address(0)) revert InvalidAddress();
        blockedToken[token] = blocked;
        emit TokenBlockSet(token, blocked);
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function withdrawRevenue() external nonReentrant {
        if (msg.sender != treasury && msg.sender != owner()) revert TreasuryOnly();
        uint256 amount = accruedRevenue;
        if (amount == 0) revert NothingToWithdraw();
        accruedRevenue = 0;
        (bool ok,) = payable(treasury).call{value: amount}("");
        if (!ok) revert NativeTransferFailed();
        emit RevenueWithdrawn(treasury, amount);
    }
}

@openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

@openzeppelin/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

@openzeppelin/contracts/utils/Pausable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

@openzeppelin/contracts/utils/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 100,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.