Перейти к содержимому
Проверенный контрактЧастичноеMIT

VITAToken

Адрес0x3afd2f72675e7d5ca6ea7b8fd17dd03e548f6b1d
Баланс

0 ETH

 

Транзакций

4 340

 

Компилятор

solc 0.8.26

 

Тот же код

ещё 1 контракт

 

Подробности

Компилятор
solc 0.8.26+commit.8a97fa7a
Язык
solidity
Оптимизация
Да, 200 прогонов
Версия EVM
cancun
Лицензия
MIT
Совпадение
Частичноекод создания: да, код в сети: да
Проверен на Sourcify
Создан в блоке
25 215 459
Транзакция создания
0xf1088301e1…75cd668d58

project/contracts/vita/token/VITAToken.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { IVitaSeedLedger } from "../interfaces/IVitaSeedLedger.sol";
import { IStartableToken } from "../interfaces/IStartableToken.sol";
import { Random } from "../libraries/VitaRandom.sol";
import { BuyAmountExceedsMaxBuy, ZeroAddress, UnauthorizedCaller, AlreadyStarted, SeedLedgerNotConfigured, AuthorizedBuyIndexOutOfBounds } from "../libraries/VitaErrors.sol";

/// @notice Standard VITA ERC-20 token that mints non-transferable seeds on official buys.
contract VITAToken is ERC20, Ownable, IStartableToken {
	uint256 private constant _AUTHORIZED_BUY_GLOBAL_COUNT_TAG = 1;
	uint256 private constant _AUTHORIZED_BUY_GLOBAL_HEAD_TAG = 2;
	uint256 private constant _AUTHORIZED_BUY_RECIPIENT_TAG = 3;
	uint256 private constant _AUTHORIZED_BUY_AMOUNT_TAG = 4;
	uint256 private constant _AUTHORIZED_BUY_RANDOM_SEED_TAG = 5;

	bytes32 private constant _COUNT_SLOT = keccak256(abi.encode(uint256(1)));
	bytes32 private constant _HEAD_SLOT = keccak256(abi.encode(uint256(2)));

	/// @notice Fixed initial supply minted once at deployment.
	uint256 public constant INITIAL_SUPPLY = 10_000e18;
	/// @notice Initial per-transaction official-pool buy limit at startup.
	uint256 public constant INITIAL_MAX_BUY = 25e18;
	/// @notice Final per-transaction official-pool buy limit after startup growth.
	uint256 public constant FINAL_MAX_BUY = INITIAL_SUPPLY;
	/// @notice Duration required for maxBuy to grow from initial to final.
	uint256 public constant MAX_BUY_GROWTH_DURATION = 25_200;

	/// @notice Hook contract allowed to start pool sync logic.
	address public hook;
	/// @notice Official pool address used as the source for buy detection.
	address public pool;
	/// @notice Timestamp when the official pool start logic was first enabled.
	uint256 public startTime;
	/// @notice Seed ledger updated when pool transfers VITA to a user.
	IVitaSeedLedger public seedLedger;

	/// @notice Emitted when the hook contract is updated.
	event HookUpdated(address indexed hook);
	/// @notice Emitted when the seed ledger is updated.
	event SeedLedgerUpdated(address indexed seedLedger);
	/// @notice Emitted when the official pool address is started.
	event PoolStarted(address indexed pool);
	/// @notice Emitted when the hook authorizes a future official buy transfer.
	event OfficialBuyAuthorized(address indexed recipient, uint256 amount, uint256 randomSeed);
	/// @notice Emitted when the next authorized buy is discarded after a mismatched pool outflow.
	event AuthorizationDiscarded(address indexed recipient, uint256 amount);

	/// @notice Creates the VITA token and mints the full fixed supply to the owner.
	/// @param initialOwner Receiver of the full initial supply.
	constructor(address initialOwner) ERC20("Vita.fun", "VITA") Ownable(initialOwner) {
		if (initialOwner == address(0)) {
			revert ZeroAddress();
		}
		_mint(initialOwner, INITIAL_SUPPLY);
	}

	/// @notice Updates the hook and random seed provider to the same contract.
	/// @param newHook Hook contract address.
	function setHook(address newHook) external onlyOwner {
		if (newHook == address(0)) {
			revert ZeroAddress();
		}
		hook = newHook;
		emit HookUpdated(newHook);
	}

	/// @notice Updates the seed ledger dependency.
	/// @param newSeedLedger Seed ledger contract address.
	function setSeedLedger(IVitaSeedLedger newSeedLedger) external onlyOwner {
		if (address(newSeedLedger) == address(0)) {
			revert ZeroAddress();
		}
		seedLedger = newSeedLedger;
		emit SeedLedgerUpdated(address(newSeedLedger));
	}

	/// @inheritdoc IStartableToken
	function start(address newPool) external {
		if (msg.sender != hook) {
			revert UnauthorizedCaller();
		}
		if (newPool == address(0)) {
			revert ZeroAddress();
		}
		if (pool != address(0)) {
			revert AlreadyStarted();
		}

		startTime = block.timestamp;
		pool = newPool;
		emit PoolStarted(newPool);
	}

	/// @inheritdoc IStartableToken
	function isStarted() public view returns (bool) {
		return pool != address(0);
	}

	/// @notice Returns the current per-transaction max buy for official-pool buys.
	/// @return Current maximum VITA amount that one official buy may receive.
	function maxBuy() public view returns (uint256) {
		if (pool == address(0)) {
			return 0;
		}

		if (block.timestamp <= startTime) {
			return INITIAL_MAX_BUY;
		}

		uint256 elapsed = block.timestamp - startTime;
		if (elapsed >= MAX_BUY_GROWTH_DURATION) {
			return FINAL_MAX_BUY;
		}

		uint256 pendingGrowth = FINAL_MAX_BUY - INITIAL_MAX_BUY;
		return INITIAL_MAX_BUY + (pendingGrowth * elapsed) / MAX_BUY_GROWTH_DURATION;
	}

	/// @notice Records a buy authorization emitted from the official pool hook.
	/// @param recipient Final wallet expected to receive VITA from PoolManager.
	/// @param amount Authorized VITA amount for this buy.
	/// @param rootRandomSeed Root random seed snapshot captured by the hook.
	function authorizeOfficialBuy(address recipient, uint256 amount, uint256 rootRandomSeed) external {
		if (msg.sender != hook) {
			revert UnauthorizedCaller();
		}

		uint256 count = _tload(_authorizedBuyCountSlot());
		_tstore(_authorizedBuyRecipientSlot(count), uint160(recipient));
		_tstore(_authorizedBuyAmountSlot(count), amount);
		_tstore(_authorizedBuyRandomSeedSlot(count), rootRandomSeed);
		_tstore(_authorizedBuyCountSlot(), count + 1);
		emit OfficialBuyAuthorized(recipient, amount, rootRandomSeed);
	}

	/// @notice Overrides ERC20 update logic to mint seeds on pool-to-user transfers.
	/// @param from Token sender.
	/// @param to Token recipient.
	/// @param value Transfer amount.
	function _update(address from, address to, uint256 value) internal override {
		super._update(from, to, value);

		// Ignore minting and all transfers before the official pool is started.
		if (pool == address(0) || from == address(0)) {
			return;
		}

		_onTokenTransfer(from, to, value);
	}

	/// @notice Applies seed minting logic to a token transfer.
	/// @param from Token sender.
	/// @param to Token recipient.
	/// @param amount Transfer amount.
	function _onTokenTransfer(address from, address to, uint256 amount) internal {
		// Only official pool outflows count as buys that create seeds.
		if (from != pool || to == address(0)) {
			return;
		}

		(
			bool matchedAuthorizedBuy,
			address authorizedRecipient,
			uint256 rootRandomSeed,
			uint256 authorizationHead
		) = _peekNextAuthorizedBuy(amount);
		if (!matchedAuthorizedBuy) {
			_discardAuthorizedBuyIfPending(authorizationHead);
			return;
		}

		IVitaSeedLedger currentSeedLedger = seedLedger;
		if (address(currentSeedLedger) == address(0)) {
			revert SeedLedgerNotConfigured();
		}
		uint256 currentMaxBuy = maxBuy();
		if (amount > currentMaxBuy) {
			revert BuyAmountExceedsMaxBuy(currentMaxBuy, amount);
		}
		_consumeAuthorizedBuyAndMintSeeds(
			authorizedRecipient,
			amount,
			rootRandomSeed,
			authorizationHead,
			currentSeedLedger
		);
	}

	/// @notice Returns whether the next authorized buy entry matches the observed pool outflow amount.
	/// @param amount Observed transfer amount.
	/// @return matched Whether the next authorized buy matches.
	/// @return recipient Seed recipient recorded by the hook authorization.
	/// @return randomSeed Root random seed snapshot attached to the matching authorization.
	/// @return head Active authorization head index.
	function _peekNextAuthorizedBuy(
		uint256 amount
	) internal view returns (bool matched, address recipient, uint256 randomSeed, uint256 head) {
		uint256 count = _tload(_authorizedBuyCountSlot());
		head = _tload(_authorizedBuyHeadSlot());

		if (head >= count) {
			return (false, address(0), 0, head);
		}

		recipient = address(uint160(_tload(_authorizedBuyRecipientSlot(head))));
		uint256 authorizedAmount = _tload(_authorizedBuyAmountSlot(head));
		if (authorizedAmount != amount) {
			return (false, recipient, 0, head);
		}

		return (true, recipient, _tload(_authorizedBuyRandomSeedSlot(head)), head);
	}

	/// @notice Consumes the matching authorized buy entry and mints seeds.
	/// @param recipient Seed recipient recorded by the hook authorization.
	/// @param amount Observed transfer amount.
	/// @param rootRandomSeed Root random seed snapshot attached to the matched authorization.
	/// @param authorizationHead Active authorization head index being consumed.
	/// @param currentSeedLedger Seed ledger to mint into.
	function _consumeAuthorizedBuyAndMintSeeds(
		address recipient,
		uint256 amount,
		uint256 rootRandomSeed,
		uint256 authorizationHead,
		IVitaSeedLedger currentSeedLedger
	) internal {
		currentSeedLedger.mintFromBuy(recipient, amount, Random({ seed: rootRandomSeed, nonce: 0 }));

		// Only a matched official-buy transfer consumes the next authorization slot.
		_tstore(_authorizedBuyRecipientSlot(authorizationHead), 0);
		_tstore(_authorizedBuyAmountSlot(authorizationHead), 0);
		_tstore(_authorizedBuyRandomSeedSlot(authorizationHead), 0);
		_tstore(_authorizedBuyHeadSlot(), authorizationHead + 1);
	}

	/// @notice Discards the next stale authorized buy entry after a mismatched pool outflow.
	/// @param authorizationHead Active authorization head index to discard.
	function _discardAuthorizedBuyIfPending(uint256 authorizationHead) internal {
		uint256 count = _tload(_authorizedBuyCountSlot());
		if (authorizationHead >= count) {
			return;
		}

		address recipient = address(uint160(_tload(_authorizedBuyRecipientSlot(authorizationHead))));
		uint256 amount = _tload(_authorizedBuyAmountSlot(authorizationHead));
		_tstore(_authorizedBuyRecipientSlot(authorizationHead), 0);
		_tstore(_authorizedBuyAmountSlot(authorizationHead), 0);
		_tstore(_authorizedBuyRandomSeedSlot(authorizationHead), 0);
		_tstore(_authorizedBuyHeadSlot(), authorizationHead + 1);
		emit AuthorizationDiscarded(recipient, amount);
	}

	/// @notice Returns the pending authorized buy count for a recipient.
	/// @param recipient Wallet to inspect.
	/// @return pendingCount Number of queued authorizations not yet consumed.
	function pendingAuthorizedBuyCount(address recipient) external view returns (uint256 pendingCount) {
		uint256 count = _tload(_authorizedBuyCountSlot());
		uint256 head = _tload(_authorizedBuyHeadSlot());

		for (uint256 i = head; i < count; ++i) {
			if (address(uint160(_tload(_authorizedBuyRecipientSlot(i)))) == recipient) {
				++pendingCount;
			}
		}
	}

	/// @notice Returns a queued authorized buy entry by active index.
	/// @param recipient Wallet to inspect.
	/// @param index Zero-based index in the active authorization window.
	/// @return amount Authorized amount.
	/// @return randomSeed Root random seed snapshot.
	function pendingAuthorizedBuyAt(
		address recipient,
		uint256 index
	) external view returns (uint256 amount, uint256 randomSeed) {
		uint256 count = _tload(_authorizedBuyCountSlot());
		uint256 head = _tload(_authorizedBuyHeadSlot());
		uint256 matched;

		for (uint256 i = head; i < count; ++i) {
			if (address(uint160(_tload(_authorizedBuyRecipientSlot(i)))) == recipient) {
				if (matched == index) {
					return (_tload(_authorizedBuyAmountSlot(i)), _tload(_authorizedBuyRandomSeedSlot(i)));
				}
				++matched;
			}
		}

		revert AuthorizedBuyIndexOutOfBounds();
	}

	function _authorizedBuyCountSlot() internal pure returns (bytes32) {
		return _COUNT_SLOT;
	}

	function _authorizedBuyHeadSlot() internal pure returns (bytes32) {
		return _HEAD_SLOT;
	}

	function _authorizedBuyRecipientSlot(uint256 index) internal pure returns (bytes32) {
		return keccak256(abi.encode(_AUTHORIZED_BUY_RECIPIENT_TAG, index));
	}

	function _authorizedBuyAmountSlot(uint256 index) internal pure returns (bytes32) {
		return keccak256(abi.encode(_AUTHORIZED_BUY_AMOUNT_TAG, index));
	}

	function _authorizedBuyRandomSeedSlot(uint256 index) internal pure returns (bytes32) {
		return keccak256(abi.encode(_AUTHORIZED_BUY_RANDOM_SEED_TAG, index));
	}

	function _tstore(bytes32 slot, uint256 value) internal {
		assembly ("memory-safe") {
			tstore(slot, value)
		}
	}

	function _tload(bytes32 slot) internal view returns (uint256 value) {
		assembly ("memory-safe") {
			value := tload(slot)
		}
	}

	function version() public view returns (string memory) {
		return "1.0.1";
	}
}

npm/@openzeppelin/[email protected]/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);
    }
}

npm/@openzeppelin/[email protected]/interfaces/draft-IERC6093.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

npm/@openzeppelin/[email protected]/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * Both values are immutable: they can only be set once during construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner`'s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance < type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

npm/@openzeppelin/[email protected]/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

npm/@openzeppelin/[email protected]/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

npm/@openzeppelin/[email protected]/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;
    }
}

project/contracts/vita/interfaces/IStartableToken.sol

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

/// @notice Interface for a token that starts syncing once the official pool is live.
interface IStartableToken {
	/// @notice Marks the official pool address used for sync logic.
	/// @param newPool Pool address to mark as started.
	function start(address newPool) external;

	/// @notice Returns whether the token sync logic has started.
	/// @return Whether the token sync logic has started.
	function isStarted() external view returns (bool);

	/// @notice Returns the timestamp when the official pool start logic was enabled.
	/// @return Timestamp when the official pool start logic was enabled.
	function startTime() external view returns (uint256);
}

project/contracts/vita/interfaces/IVitaSeedLedger.sol

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

import { Random } from "../libraries/VitaRandom.sol";

/// @notice Interface for the non-transferable seed ledger.
interface IVitaSeedLedger {
	/// @notice Mints seeds from a single official pool buy.
	/// @param buyer Seed recipient wallet.
	/// @param vitaAmountOut VITA amount received from the swap.
	/// @param random Random state used to derive per-seed values.
	/// @return seeds Number of seeds minted for this buy.
	function mintFromBuy(address buyer, uint256 vitaAmountOut, Random memory random) external returns (uint256 seeds);

	/// @notice Consumes seeds for hatching.
	/// @param owner Wallet whose seeds are consumed.
	/// @param amount Number of seeds to consume.
	/// @return seedValues Random values carried by the consumed seeds.
	function consume(address owner, uint256 amount) external returns (uint256[] memory seedValues);

	/// @notice Returns currently available seeds for a wallet.
	/// @param owner Wallet to query.
	/// @return Current available seed count.
	function availableSeeds(address owner) external view returns (uint256);

	/// @notice Returns cumulative minted seeds for a wallet.
	/// @param owner Wallet to query.
	/// @return Total minted seeds.
	function mintedSeeds(address owner) external view returns (uint256);

	/// @notice Returns cumulative consumed seeds for a wallet.
	/// @param owner Wallet to query.
	/// @return Total consumed seeds.
	function consumedSeeds(address owner) external view returns (uint256);
}

project/contracts/vita/libraries/VitaErrors.sol

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

/// @notice Thrown when a zero address is not allowed.
error ZeroAddress();
/// @notice Thrown when the provided amount is zero or out of range.
error InvalidAmount();
/// @notice Thrown when a wallet tries to consume more seeds than available.
error InsufficientSeeds(uint256 available, uint256 required);
/// @notice Thrown when a non-owner tries to redeem a living NFT.
error NotTokenOwner(address caller, address owner);
/// @notice Thrown when a renderer contract has not been configured.
error RendererNotSet();
/// @notice Thrown when hookData cannot be decoded into the expected buyer format.
error InvalidHookData();
/// @notice Thrown when an official pool key or its fixed config does not match the deployment rules.
error InvalidOfficialPoolKey();
/// @notice Thrown when the caller is not the configured privileged contract.
error UnauthorizedCaller();
/// @notice Thrown when the token launch path is started more than once.
error AlreadyStarted();
/// @notice Thrown when the seed ledger dependency is missing.
error SeedLedgerNotConfigured();
/// @notice Thrown when the random seed provider dependency is missing.
error RandomSeedProviderNotConfigured();
/// @notice Thrown when an official buy exceeds the current per-transaction max buy.
error BuyAmountExceedsMaxBuy(uint256 maxBuy, uint256 requested);
/// @notice Thrown when an authorized buy index is out of bounds.
error AuthorizedBuyIndexOutOfBounds();
/// @notice Thrown when a VITA pool swap is attempted before the launch switch is turned on.
error TokenNotStarted();

project/contracts/vita/libraries/VitaRandom.sol

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

/// @notice Pseudo-random generator state used across the VITA protocol.
struct Random {
	/// @dev Root seed supplied by the random seed provider.
	uint256 seed;
	/// @dev Incrementing nonce used to derive distinct outputs.
	uint256 nonce;
}

/// @notice Utility library for deriving deterministic pseudo-random values.
library RandomLibrary {
	/// @notice Derives the next pseudo-random value and increments the nonce.
	/// @param random Generator state to mutate in memory.
	/// @return Next derived pseudo-random value.
	function next(Random memory random) internal pure returns (uint256) {
		return uint256(keccak256(abi.encodePacked(random.seed, ++random.nonce)));
	}
}
Настройки компилятораПоказать
{
  "metadata": {
    "bytecodeHash": "none",
    "useLiteralContent": true
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "npm/@openzeppelin/[email protected]/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
    "npm/@openzeppelin/[email protected]/:@uniswap/v4-core/=npm/@uniswap/[email protected]/",
    "project/:@openzeppelin/contracts-upgradeable/=npm/@openzeppelin/[email protected]/",
    "project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
    "project/:@openzeppelin/uniswap-hooks/=npm/@openzeppelin/[email protected]/",
    "project/:@uniswap/v4-core/=npm/@uniswap/[email protected]/",
    "project/:forge-std/=npm/[email protected]/src/",
    "project/:solady/=npm/[email protected]/"
  ]
}

Исходный код и метаданные: Sourcify.

Исходный код принадлежит авторам контракта.