AlthereumETH

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "AlthereumETH.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.24;\r
\r
/**\r
 * @title Althereum - Fair Launch Token Platform (Ethereum Mainnet)\r
 * @author Althereum Team\r
 * @notice ERC20 token with bonding curve mechanics and automatic liquidity provision\r
 * @dev Constant product AMM (x*y=k) bonding curve → Uniswap V2 integration\r
 * \r
 * Website: https://althereum.com\r
 * Twitter: https://x.com/althereumdotcom\r
 * Telegram: https://t.me/althereum\r
 * \r
 * Features:\r
 * - Two-phase system: Bonding curve (80%) → Automated liquidity (20%)\r
 * - Constant product formula (x*y=k) for fair, deterministic pricing\r
 * - Configurable fees with platform/creator revenue split\r
 * - Creator sell lock protection (1 hour after pre-buy)\r
 * - Automatic Uniswap V2 liquidity provision with LP burn\r
 * - Pull payment pattern for graceful failure handling\r
 * - **OWNERSHIP AUTO-RENOUNCED AFTER BONDING COMPLETES** (100% decentralized)\r
 */\r
\r
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";\r
import "@openzeppelin/contracts/access/Ownable.sol";\r
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";\r
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";\r
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";\r
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";\r
\r
contract AlthereumETH is ERC20, Ownable, ReentrancyGuard {\r
    // Token Configuration\r
    uint256 public constant TOTAL_TOKEN_SUPPLY     = 1_000_000_000 * 1e18;\r
    uint256 public constant BONDING_TOKEN_SUPPLY   = 800_000_000 * 1e18;\r
    uint256 public constant LIQUIDITY_TOKEN_SUPPLY = 200_000_000 * 1e18;\r
\r
    // Virtual Reserves (Constant Product AMM)\r
    uint256 public constant VIRTUAL_ETH_RESERVES    = 0.947 ether;\r
    uint256 public constant VIRTUAL_TOKEN_RESERVES  = 1_073_000_000 * 1e18;\r
    uint256 public constant K_CONSTANT              = VIRTUAL_ETH_RESERVES * VIRTUAL_TOKEN_RESERVES;\r
    uint256 public constant TARGET_ETH_COLLECTION   = 2.77 ether;\r
\r
    // Real Reserves\r
    uint256 public realEthCollected;\r
    uint256 public realTokensSold;\r
\r
    // Configurable Fees\r
    uint256 public bondingTotalFee;\r
    uint256 public uniswapTotalFee;\r
    uint256 public constant PLATFORM_BONDING_FEE = 50;\r
    uint256 public constant PLATFORM_UNISWAP_FEE = 25;\r
\r
    // Constants\r
    uint256 public constant PRECISION  = 1e18;\r
\r
    // Events\r
    event Trade(address indexed user, uint256 tokenAmount, uint256 ethAmount, uint256 costSpent, uint256 tradeType, uint256 timestamp);\r
    event BondingFinalized(address indexed token, address indexed uniswapPair, uint256 ethAdded, uint256 tokensAdded, uint256 lpTokensBurned, uint256 timestamp);\r
    event FeesDistributed(address indexed deployerRecipient, uint256 deployerFee, address indexed creatorRecipient, uint256 creatorFee, uint256 timestamp);\r
    event FeesDistributed(uint256 platformShare, uint256 creatorShare);\r
    event PriceUpdated(uint256 newPrice, uint256 bondingSold, uint256 timestamp);\r
    event SwapThresholdUpdated(uint256 newThreshold);\r
    event FeesAccumulated(uint256 amount, uint256 totalAccumulated);\r
    event AccumulatedFeesDistributed(uint256 tokensSwapped, uint256 ethReceived);\r
    event PaymentFailed(address indexed recipient, uint256 amount);\r
    event WithdrawalSuccessful(address indexed recipient, uint256 amount);\r
\r
    // State\r
    uint256 public bondingSold;\r
    bool public isBonded;\r
    IUniswapV2Pair public uniswapPair;\r
    address public deployerFeeRecipient;\r
    address public creatorFeeRecipient;\r
    address public uniswapRouter;\r
    string private _tokenName;\r
    string private _tokenSymbol;\r
    bool private _initialized;\r
    bool private _creatorPreBuyCompleted;\r
    uint256 public deploymentTimestamp;\r
\r
    // Creator sell lock\r
    uint256 public constant CREATOR_SELL_LOCK_PERIOD = 1 hours;\r
\r
    // Fee System\r
    mapping(address => bool) private _isExcludedFromFees;\r
    mapping(address => bool) public automatedMarketMakerPairs;\r
    bool private swapping;\r
    \r
    // Fee Accumulation\r
    uint256 public swapTokensAtAmount;\r
    uint256 public tokensForPlatform;\r
    uint256 public tokensForCreator;\r
    \r
    // Earnings Tracking\r
    uint256 public totalCreatorEthEarned;\r
    uint256 public totalPlatformEthEarned;\r
\r
    // Pull Payment Pattern - Pending payments for failed transfers\r
    mapping(address => uint256) public pendingWithdrawals;\r
\r
    constructor() ERC20("Uninitialized", "UNINIT") Ownable(msg.sender) {\r
        _initialized = false;\r
    }\r
\r
    function initialize(\r
        string memory name_,\r
        string memory symbol_,\r
        address _deployerFeeRecipient,\r
        address _creatorFeeRecipient,\r
        address _uniswapRouter,\r
        uint256 _bondingFeePercent,\r
        uint256 _uniswapFeePercent\r
    ) external {\r
        require(!_initialized);\r
        require(_deployerFeeRecipient != address(0) && _creatorFeeRecipient != address(0) && _uniswapRouter != address(0));\r
        require(_bondingFeePercent >= PLATFORM_BONDING_FEE && _bondingFeePercent <= 500);\r
        require(_uniswapFeePercent >= PLATFORM_UNISWAP_FEE && _uniswapFeePercent <= 300);\r
\r
        _tokenName = name_;\r
        _tokenSymbol = symbol_;\r
        deployerFeeRecipient = _deployerFeeRecipient;\r
        creatorFeeRecipient = _creatorFeeRecipient;\r
        uniswapRouter = _uniswapRouter;\r
        bondingTotalFee = _bondingFeePercent;\r
        uniswapTotalFee = _uniswapFeePercent;\r
\r
        _mint(address(this), TOTAL_TOKEN_SUPPLY);\r
        realEthCollected = 0;\r
        realTokensSold = 0;\r
        bondingSold = 0;\r
        isBonded = false;\r
        _initialized = true;\r
        _creatorPreBuyCompleted = false;\r
        deploymentTimestamp = block.timestamp;\r
        \r
        swapTokensAtAmount = TOTAL_TOKEN_SUPPLY * 5 / 10000; // 0.05% = 500,000 tokens\r
        tokensForPlatform = 0;\r
        tokensForCreator = 0;\r
        \r
        _isExcludedFromFees[address(this)] = true;\r
        _isExcludedFromFees[_creatorFeeRecipient] = true;\r
        _isExcludedFromFees[_deployerFeeRecipient] = true;\r
        _isExcludedFromFees[address(0xdead)] = true;\r
        _isExcludedFromFees[_uniswapRouter] = true;\r
        \r
        _transferOwnership(_creatorFeeRecipient);\r
    }\r
\r
    function name() public view override returns (string memory) { return _tokenName; }\r
    function symbol() public view override returns (string memory) { return _tokenSymbol; }\r
\r
    // Get current price using constant product formula\r
    function _getCurrentPrice() internal view returns (uint256) {\r
        uint256 totalEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
        uint256 totalTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
        return (totalEthReserves * PRECISION) / totalTokenReserves;\r
    }\r
\r
    // Creator Pre-Buy Function (constant product model)\r
    function creatorPreBuy(uint256 tokenAmount) external payable nonReentrant {\r
        require(!_creatorPreBuyCompleted);\r
        require(msg.sender == owner() || tx.origin == owner(), "Only owner can pre-buy");\r
        require(!isBonded);\r
        require(tokenAmount <= TOTAL_TOKEN_SUPPLY * 500 / 10000); // Max 5% of total supply (50M tokens)\r
        require(tokenAmount > 0);\r
\r
        uint256 fee = (msg.value * bondingTotalFee) / 10000;\r
        uint256 netAmount = msg.value - fee;\r
        \r
        // Calculate required ETH for exact token amount using constant product formula\r
        uint256 currentEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
        uint256 currentTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
        uint256 targetTokenReserves = currentTokenReserves - tokenAmount;\r
        uint256 requiredEthReserves = K_CONSTANT / targetTokenReserves;\r
        uint256 requiredNetEth = requiredEthReserves - currentEthReserves;\r
        \r
        require(netAmount >= requiredNetEth, "Insufficient ETH for requested tokens");\r
        require(realTokensSold + tokenAmount <= BONDING_TOKEN_SUPPLY);\r
\r
        _creatorPreBuyCompleted = true;\r
        realEthCollected += requiredNetEth;\r
        realTokensSold += tokenAmount;\r
        bondingSold = realTokensSold;\r
\r
        _transfer(address(this), owner(), tokenAmount);\r
        \r
        uint256 actualFee = (requiredNetEth * bondingTotalFee) / (10000 - bondingTotalFee);\r
        _distributeFees(actualFee);\r
        \r
        uint256 totalUsed = requiredNetEth + actualFee;\r
        if (msg.value > totalUsed) {\r
            (bool success, ) = msg.sender.call{value: msg.value - totalUsed}("");\r
            require(success, "Refund failed");\r
        }\r
\r
        emit PriceUpdated(_getCurrentPrice(), realTokensSold, block.timestamp);\r
        emit Trade(owner(), tokenAmount, totalUsed, requiredNetEth, 0, block.timestamp);\r
    }\r
\r
    // Buy Function (constant product model) - Enhanced with overpayment protection\r
    function buy() external payable nonReentrant {\r
        require(!isBonded);\r
        require(msg.value > 0);\r
        \r
        // Creator is locked from buying during bonding phase ONLY if they did pre-buy\r
        if (msg.sender == owner() && !isBonded && _creatorPreBuyCompleted) {\r
            require(block.timestamp >= deploymentTimestamp + CREATOR_SELL_LOCK_PERIOD, "Creator locked from trading");\r
        }\r
\r
        uint256 fee = (msg.value * bondingTotalFee) / 10000;\r
        uint256 netAmount = msg.value - fee;\r
\r
        // Constant product calculation: tokens_out = current_tokens - k/(current_eth + eth_in)\r
        uint256 currentEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
        uint256 currentTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
        uint256 newEthReserves = currentEthReserves + netAmount;\r
        uint256 newTokenReserves = K_CONSTANT / newEthReserves;\r
        uint256 tokensOut = currentTokenReserves - newTokenReserves;\r
\r
        require(tokensOut > 0);\r
        \r
        uint256 remainingTokens = BONDING_TOKEN_SUPPLY - realTokensSold;\r
        uint256 actualTokensOut = tokensOut;\r
        uint256 actualNetAmount = netAmount;\r
        uint256 actualFee = fee;\r
        uint256 refundAmount = 0;\r
        \r
        if (tokensOut > remainingTokens) {\r
            uint256 targetTokenReserves = currentTokenReserves - remainingTokens;\r
            uint256 requiredEthReserves = K_CONSTANT / targetTokenReserves;\r
            uint256 requiredNetEth = requiredEthReserves - currentEthReserves;\r
            \r
            uint256 requiredTotalEth = (requiredNetEth * 10000) / (10000 - bondingTotalFee);\r
            actualFee = requiredTotalEth - requiredNetEth;\r
            actualNetAmount = requiredNetEth;\r
            actualTokensOut = remainingTokens;\r
            \r
            refundAmount = msg.value - requiredTotalEth;\r
        }\r
\r
        require(realTokensSold + actualTokensOut <= BONDING_TOKEN_SUPPLY);\r
\r
        realEthCollected += actualNetAmount;\r
        realTokensSold += actualTokensOut;\r
        bondingSold = realTokensSold;\r
\r
        _transfer(address(this), msg.sender, actualTokensOut);\r
        _distributeFees(actualFee);\r
\r
        if (refundAmount > 0) {\r
            (bool success, ) = msg.sender.call{value: refundAmount}("");\r
            require(success, "Refund failed");\r
        }\r
\r
        emit PriceUpdated(_getCurrentPrice(), realTokensSold, block.timestamp);\r
\r
        // Direct finalization when bonding completes\r
        if (realTokensSold >= BONDING_TOKEN_SUPPLY) {\r
            _finalizeBonding();\r
        }\r
\r
        emit Trade(msg.sender, actualTokensOut, msg.value - refundAmount, actualNetAmount, 0, block.timestamp);\r
    }\r
\r
    // Sell Function (constant product model)\r
    function sell(uint256 tokenAmount) external nonReentrant {\r
        require(tokenAmount > 0);\r
        require(balanceOf(msg.sender) >= tokenAmount);\r
        \r
        // Creator is locked from selling during bonding phase ONLY if they did pre-buy\r
        if (msg.sender == owner() && !isBonded && _creatorPreBuyCompleted) {\r
            require(block.timestamp >= deploymentTimestamp + CREATOR_SELL_LOCK_PERIOD);\r
        }\r
\r
        if (!isBonded) {\r
            require(realTokensSold > 0);\r
            require(tokenAmount <= realTokensSold);\r
\r
            // Constant product calculation: eth_out = current_eth - k/(current_tokens + tokens_in)\r
            uint256 currentEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
            uint256 currentTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
            uint256 newTokenReserves = currentTokenReserves + tokenAmount;\r
            uint256 newEthReserves = K_CONSTANT / newTokenReserves;\r
            uint256 ethOut = currentEthReserves - newEthReserves;\r
\r
            uint256 fee = (ethOut * bondingTotalFee) / 10000;\r
            uint256 netEth = ethOut - fee;\r
\r
            require(address(this).balance >= netEth);\r
\r
            realEthCollected -= ethOut;\r
            realTokensSold -= tokenAmount;\r
            bondingSold = realTokensSold;\r
\r
            _transfer(msg.sender, address(this), tokenAmount);\r
\r
            (bool success, ) = msg.sender.call{value: netEth}("");\r
            require(success);\r
\r
            _distributeFees(fee);\r
            emit PriceUpdated(_getCurrentPrice(), realTokensSold, block.timestamp);\r
            emit Trade(msg.sender, tokenAmount, netEth, ethOut, 1, block.timestamp);\r
        } else {\r
            // Uniswap phase - fees handled in _transferWithFees\r
            // Transfer tokens to contract for swap\r
            _transfer(msg.sender, address(this), tokenAmount);\r
            \r
            // Approve router for the swap\r
            _approve(address(this), uniswapRouter, tokenAmount);\r
            \r
            // Execute the swap to ETH for user\r
            address[] memory path = new address[](2);\r
            path[0] = address(this);\r
            path[1] = IUniswapV2Router02(uniswapRouter).WETH();\r
            \r
            try IUniswapV2Router02(uniswapRouter).swapExactTokensForETHSupportingFeeOnTransferTokens(\r
                tokenAmount,\r
                0,\r
                path,\r
                msg.sender,\r
                block.timestamp + 300\r
            ) {\r
                // Swap successful\r
            } catch {\r
                revert("Uniswap swap failed");\r
            }\r
        }\r
    }\r
\r
    // Finalize Bonding (when 800M tokens sold)\r
    function _finalizeBonding() internal {\r
        require(!isBonded);\r
        require(realTokensSold >= BONDING_TOKEN_SUPPLY);\r
        isBonded = true;\r
        \r
        // Auto-renounce ownership\r
        renounceOwnership();\r
\r
        uint256 ethBal = realEthCollected;\r
        uint256 tokenBal = LIQUIDITY_TOKEN_SUPPLY;\r
        IUniswapV2Router02 router = IUniswapV2Router02(uniswapRouter);\r
        _approve(address(this), address(router), tokenBal);\r
\r
        address pairAddr = IUniswapV2Factory(router.factory()).createPair(address(this), router.WETH());\r
        uniswapPair = IUniswapV2Pair(pairAddr);\r
\r
        (,, uint256 lpAmount) = router.addLiquidityETH{value: ethBal}(\r
            address(this), tokenBal, 0, 0, address(this), block.timestamp\r
        );\r
\r
        IERC20(pairAddr).transfer(address(0xdead), lpAmount);\r
        \r
        automatedMarketMakerPairs[pairAddr] = true;\r
        \r
        emit BondingFinalized(address(this), pairAddr, ethBal, tokenBal, lpAmount, block.timestamp);\r
    }\r
\r
    // Fees - Using graceful failure handling to prevent DOS\r
    function _distributeFees(uint256 feeAmount) internal {\r
        if (feeAmount == 0) return;\r
        \r
        uint256 deployerShare = (feeAmount * PLATFORM_BONDING_FEE) / bondingTotalFee;\r
        uint256 creatorShare = feeAmount - deployerShare;\r
        \r
        if (deployerShare > 0) {\r
            totalPlatformEthEarned += deployerShare;\r
            (bool ok1, ) = deployerFeeRecipient.call{value: deployerShare}("");\r
            if (!ok1) {\r
                // Store for later withdrawal instead of reverting\r
                pendingWithdrawals[deployerFeeRecipient] += deployerShare;\r
                emit PaymentFailed(deployerFeeRecipient, deployerShare);\r
            }\r
        }\r
        \r
        if (creatorShare > 0) {\r
            totalCreatorEthEarned += creatorShare;\r
            (bool ok2, ) = creatorFeeRecipient.call{value: creatorShare}("");\r
            if (!ok2) {\r
                // Store for later withdrawal instead of reverting\r
                pendingWithdrawals[creatorFeeRecipient] += creatorShare;\r
                emit PaymentFailed(creatorFeeRecipient, creatorShare);\r
            }\r
        }\r
        \r
        emit FeesDistributed(deployerFeeRecipient, deployerShare, creatorFeeRecipient, creatorShare, block.timestamp);\r
    }\r
\r
    // Override public transfer functions to handle fees (safer approach)\r
    function transfer(address to, uint256 amount) public virtual override returns (bool) {\r
        address owner = _msgSender();\r
        _transferWithFees(owner, to, amount);\r
        return true;\r
    }\r
\r
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\r
        address spender = _msgSender();\r
        _spendAllowance(from, spender, amount);\r
        _transferWithFees(from, to, amount);\r
        return true;\r
    }\r
\r
    // Custom transfer function that handles fees\r
    function _transferWithFees(address from, address to, uint256 amount) internal {\r
        require(from != address(0));\r
        require(to != address(0));\r
        \r
        if (amount == 0) {\r
            _transfer(from, to, 0);\r
            return;\r
        }\r
\r
        // TRANSFER RESTRICTIONS DURING BONDING PHASE\r
        // Prevent user-to-user transfers to stop early pair creation\r
        if (!isBonded) {\r
            // Allow only contract-related transfers (buy/sell operations)\r
            require(\r
                from == address(this) || to == address(this),\r
                "Transfers locked during bonding phase"\r
            );\r
        }\r
\r
        // Only apply fees during Uniswap phase\r
        if (isBonded && !swapping) {\r
            // Check if we should swap accumulated fees\r
            uint256 contractTokenBalance = balanceOf(address(this));\r
            bool canSwap = contractTokenBalance >= swapTokensAtAmount;\r
            \r
            if (canSwap &&\r
                !automatedMarketMakerPairs[from] && // Don't swap during buys\r
                !_isExcludedFromFees[from] &&\r
                !_isExcludedFromFees[to]\r
            ) {\r
                swapping = true;\r
                swapBack();\r
                swapping = false;\r
            }\r
            \r
            bool takeFee = !_isExcludedFromFees[from] && !_isExcludedFromFees[to];\r
            \r
            uint256 fees = 0;\r
            // Fee logic for both buys and sells\r
            if (takeFee) {\r
                // on sell (to AMM)\r
                if (automatedMarketMakerPairs[to] && uniswapTotalFee > 0) {\r
                    fees = (amount * uniswapTotalFee) / 10000;\r
                    tokensForPlatform += fees * PLATFORM_UNISWAP_FEE / uniswapTotalFee;\r
                    tokensForCreator += fees * (uniswapTotalFee - PLATFORM_UNISWAP_FEE) / uniswapTotalFee;\r
                }\r
                // on buy (from AMM)\r
                else if (automatedMarketMakerPairs[from] && uniswapTotalFee > 0) {\r
                    fees = (amount * uniswapTotalFee) / 10000;\r
                    tokensForPlatform += fees * PLATFORM_UNISWAP_FEE / uniswapTotalFee;\r
                    tokensForCreator += fees * (uniswapTotalFee - PLATFORM_UNISWAP_FEE) / uniswapTotalFee;\r
                }\r
                \r
                if (fees > 0) {\r
                    _transfer(from, address(this), fees);\r
                    amount -= fees;\r
                }\r
            }\r
        }\r
        \r
        _transfer(from, to, amount);\r
    }\r
\r
    // Swap accumulated fees to ETH and distribute\r
    function swapBack() private {\r
        uint256 contractBalance = balanceOf(address(this));\r
        uint256 totalTokensToSwap = tokensForPlatform + tokensForCreator;\r
        \r
        if (contractBalance == 0 || totalTokensToSwap == 0) {\r
            return;\r
        }\r
        \r
        // Limit swap amount to prevent large price impact\r
        if (contractBalance > swapTokensAtAmount * 20) {\r
            contractBalance = swapTokensAtAmount * 20;\r
        }\r
        \r
        uint256 initialETHBalance = address(this).balance;\r
        \r
        // Swap all tokens for ETH\r
        swapTokensForETH(contractBalance);\r
        \r
        uint256 ethBalance = address(this).balance - initialETHBalance;\r
        \r
        // Calculate proportional ETH distribution\r
        uint256 ethForPlatform = (ethBalance * tokensForPlatform) / totalTokensToSwap;\r
        uint256 ethForCreator = ethBalance - ethForPlatform;\r
        \r
        // Reset token counters\r
        tokensForPlatform = 0;\r
        tokensForCreator = 0;\r
        \r
        // Update earnings tracking\r
        totalPlatformEthEarned += ethForPlatform;\r
        totalCreatorEthEarned += ethForCreator;\r
        \r
        // Handle failures gracefully to prevent DOS\r
        (bool success1,) = address(deployerFeeRecipient).call{value: ethForPlatform}("");\r
        if (!success1) {\r
            pendingWithdrawals[deployerFeeRecipient] += ethForPlatform;\r
            emit PaymentFailed(deployerFeeRecipient, ethForPlatform);\r
        }\r
        \r
        (bool success2,) = address(creatorFeeRecipient).call{value: ethForCreator}("");\r
        if (!success2) {\r
            pendingWithdrawals[creatorFeeRecipient] += ethForCreator;\r
            emit PaymentFailed(creatorFeeRecipient, ethForCreator);\r
        }\r
        \r
        emit FeesDistributed(ethForPlatform, ethForCreator);\r
    }\r
\r
    // Swap tokens for ETH using Uniswap\r
    function swapTokensForETH(uint256 tokenAmount) private {\r
        address[] memory path = new address[](2);\r
        path[0] = address(this);\r
        path[1] = IUniswapV2Router02(uniswapRouter).WETH();\r
\r
        _approve(address(this), uniswapRouter, tokenAmount);\r
\r
        IUniswapV2Router02(uniswapRouter).swapExactTokensForETHSupportingFeeOnTransferTokens(\r
            tokenAmount,\r
            0, // Accept any amount of ETH\r
            path,\r
            address(this),\r
            block.timestamp\r
        );\r
    }\r
\r
    // Manual swap trigger (emergency use)\r
    function manualSwapBack() external onlyOwner {\r
        require(balanceOf(address(this)) > 0, "No tokens to swap");\r
        swapping = true;\r
        swapBack();\r
        swapping = false;\r
    }\r
\r
    // Check if excluded from fees\r
    function isExcludedFromFees(address account) external view returns (bool) {\r
        return _isExcludedFromFees[account];\r
    }\r
    \r
    // Get accumulated fees info\r
    function getAccumulatedFeesInfo() external view returns (\r
        uint256 currentAccumulated,\r
        uint256 threshold,\r
        uint256 percentageToThreshold,\r
        bool readyToSwap\r
    ) {\r
        currentAccumulated = tokensForPlatform + tokensForCreator;\r
        threshold = swapTokensAtAmount;\r
        percentageToThreshold = threshold > 0 ? (currentAccumulated * 10000) / threshold : 0;\r
        readyToSwap = currentAccumulated >= threshold && currentAccumulated > 0;\r
    }\r
    \r
    // Get detailed fee system status\r
    function getFeeSystemStatus() external view returns (\r
        bool isUniswapPhase,\r
        uint256 currentFees,\r
        uint256 threshold,\r
        uint256 thresholdPercentage,\r
        bool canDistribute,\r
        bool isSwapping,\r
        uint256 totalFeesCollectedAllTime\r
    ) {\r
        isUniswapPhase = isBonded;\r
        currentFees = tokensForPlatform + tokensForCreator;\r
        threshold = swapTokensAtAmount;\r
        thresholdPercentage = (threshold * 10000) / TOTAL_TOKEN_SUPPLY; // In basis points\r
        canDistribute = currentFees >= threshold && currentFees > 0 && !swapping;\r
        isSwapping = swapping;\r
        // Note: totalFeesCollectedAllTime would need a separate counter to track\r
        totalFeesCollectedAllTime = 0; // Could be implemented with additional state variable\r
    }\r
    \r
    // Manual fee distribution (only owner, emergency use)\r
    function manualDistributeFees() external onlyOwner {\r
        require(tokensForPlatform > 0, "No fees to distribute");\r
        swapping = true;\r
        swapBack();\r
        swapping = false;\r
    }\r
\r
    // Public function to check and distribute fees if threshold is met\r
    function checkAndDistributeFees() external {\r
        if (tokensForPlatform + tokensForCreator >= swapTokensAtAmount && !swapping) {\r
            swapping = true;\r
            swapBack();\r
            swapping = false;\r
        }\r
    }\r
\r
    // Creator Pre-Buy Utils\r
    function getCreatorPreBuyInfo(uint256 tokenAmount) external view returns (\r
        bool available,\r
        uint256 totalCost,\r
        uint256 fees,\r
        uint256 totalRequired,\r
        uint256 maxTokens\r
    ) {\r
        available = !_creatorPreBuyCompleted && !isBonded;\r
        maxTokens = TOTAL_TOKEN_SUPPLY * 500 / 10000; // 5% max (50M tokens)\r
        \r
        if (tokenAmount > maxTokens) {\r
            tokenAmount = maxTokens;\r
        }\r
        \r
        // Use constant product formula to calculate required ETH (same as creatorPreBuy function)\r
        uint256 currentEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
        uint256 currentTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
        uint256 targetTokenReserves = currentTokenReserves - tokenAmount;\r
        uint256 requiredEthReserves = K_CONSTANT / targetTokenReserves;\r
        uint256 netEthRequired = requiredEthReserves - currentEthReserves;\r
        \r
        totalCost = netEthRequired;\r
        fees = (totalCost * bondingTotalFee) / (10000 - bondingTotalFee); // Adjust for fee calculation\r
        totalRequired = totalCost + fees;\r
    }\r
\r
    function isCreatorPreBuyCompleted() external view returns (bool) {\r
        return _creatorPreBuyCompleted;\r
    }\r
\r
    // Creator sell lock info\r
    function getCreatorSellLockInfo() external view returns (\r
        bool isLocked,\r
        uint256 unlockTime,\r
        uint256 remainingSeconds\r
    ) {\r
        // If bonding is complete, creator is not locked\r
        if (isBonded) {\r
            return (false, 0, 0);\r
        }\r
        \r
        // If creator hasn't pre-bought, they are not locked (can buy/sell normally)\r
        if (!_creatorPreBuyCompleted) {\r
            return (false, 0, 0);\r
        }\r
        \r
        // Creator is locked only if they did pre-buy\r
        unlockTime = deploymentTimestamp + CREATOR_SELL_LOCK_PERIOD;\r
        isLocked = block.timestamp < unlockTime;\r
        remainingSeconds = isLocked ? unlockTime - block.timestamp : 0;\r
    }\r
\r
    // Essential utility functions only\r
\r
    // Simplified buy calculation\r
    function calculateBuyInfo(uint256 ethAmount) external view returns (\r
        uint256 tokensReceived,\r
        uint256 totalFees,\r
        uint256 netCost,\r
        bool canComplete\r
    ) {\r
        require(!isBonded);\r
        require(ethAmount > 0);\r
        \r
        totalFees = (ethAmount * bondingTotalFee) / 10000;\r
        netCost = ethAmount - totalFees;\r
        \r
        // Constant product calculation: tokens_out = current_tokens - k/(current_eth + eth_in)\r
        uint256 currentEthReserves = VIRTUAL_ETH_RESERVES + realEthCollected;\r
        uint256 currentTokenReserves = VIRTUAL_TOKEN_RESERVES - realTokensSold;\r
        uint256 newEthReserves = currentEthReserves + netCost;\r
        uint256 newTokenReserves = K_CONSTANT / newEthReserves;\r
        uint256 tokensOut = currentTokenReserves - newTokenReserves;\r
\r
        canComplete = tokensOut > 0;\r
        if (canComplete) {\r
            tokensReceived = tokensOut;\r
        }\r
    }\r
\r
    // Essential functions only\r
\r
    // Utils\r
    function getCurrentPrice() external view returns (uint256) {\r
        return _getCurrentPrice();\r
    }\r
\r
    // Check if creator can sell right now\r
    function canCreatorSell() external view returns (bool) {\r
        if (isBonded || !_creatorPreBuyCompleted) return true;\r
        return block.timestamp >= deploymentTimestamp + CREATOR_SELL_LOCK_PERIOD;\r
    }\r
\r
    // Pull payment pattern - withdraw failed payments\r
    function withdrawPendingPayment() external nonReentrant {\r
        uint256 amount = pendingWithdrawals[msg.sender];\r
        require(amount > 0, "No pending withdrawal");\r
        \r
        pendingWithdrawals[msg.sender] = 0;\r
        \r
        (bool success, ) = msg.sender.call{value: amount}("");\r
        require(success, "Withdrawal failed");\r
        \r
        emit WithdrawalSuccessful(msg.sender, amount);\r
    }\r
\r
    receive() external payable {}\r
\r
    // Get total earnings info\r
    function getTotalEarningsInfo() external view returns (\r
        uint256 creatorTotalEth,\r
        uint256 platformTotalEth,\r
        uint256 pendingTokenFees,\r
        uint256 pendingEthValue,\r
        bool readyToDistribute\r
    ) {\r
        creatorTotalEth = totalCreatorEthEarned;\r
        platformTotalEth = totalPlatformEthEarned;\r
        pendingTokenFees = tokensForPlatform + tokensForCreator;\r
        \r
        if (pendingTokenFees > 0 && isBonded) {\r
            pendingEthValue = pendingTokenFees;\r
        }\r
        \r
        readyToDistribute = pendingTokenFees >= swapTokensAtAmount;\r
    }\r
}"
    },
    "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol": {
      "content": "// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}
"
    },
    "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
      "content": "// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}
"
    },
    "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": {
      "content": "// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}
"
    },
    "@openzeppelin/contracts/security/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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;

    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
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // 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;
    }
}
"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// 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/token/ERC20/ERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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;
    }

    /// @inheritdoc IERC20
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /// @inheritdoc IERC20
    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;
    }

    /// @inheritdoc IERC20
    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);
            }
        }
    }
}
"
    },
    "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
"
    },
    "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;

/**
 * @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);
}
"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// 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/

Tags:
ERC20, Multisig, Mintable, Burnable, Swap, Liquidity, Upgradeable, Multi-Signature, Factory|addr:0xb2b9fa1ed24c49130de968195229409e3542d193|verified:true|block:23642985|tx:0xa61e0f64c5c08acca67c4f362673124536c643d5972b1a69b825fc8f0394569e|first_check:1761315219

Submitted on: 2025-10-24 16:13:42

Comments

Log in to comment.

No comments yet.