Skip to content
Verified contractExactMIT

LaunchTokenV4

Address0x8260b4dd36d67f042cc8ce07dccba77d16545f65
Balance

0 ETH

 

Transactions

28

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,087,423
Creation transaction
0x9fc527aa43…4bb65b7d02

LaunchTokenV4.sol

// SPDX-License-Identifier: MIT

/*
   $ROBO · robodyne

   ────────────────────────────────────────────────────────────────

   site      robodyne.xyz
   x         x.com/robodyneeth
   telegram  t.me/robodynexyz

   ────────────────────────────────────────────────────────────────

   saas replacement is downstream. agents replace each other first.
*/


pragma solidity 0.8.28;

// ─────────────────────────────────────────────────────────────────────────
// LaunchTokenV4 — clean ERC20 + Uniswap V4 native pool launcher.
//
// What it does:
//   - Plain ERC20 (no tax, no limits, no transfer hooks) — V4-native memecoin.
//   - openTradingV4() does THREE things atomically:
//       1. Token approves Permit2 (MAX)
//       2. Permit2.approve(positionManager, this, MAX, MAX)
//       3. PositionManager.multicall([
//            initializePool(poolKey, sqrtPriceX96),
//            modifyLiquidities(MINT_POSITION + SETTLE_PAIR + SWEEP, deadline)
//          ])
//     msg.value goes into LP as ETH side; entire owner balance goes as token side.
//     LP NFT minted to `lpRecipient` — keep (deployer), burn (0xdEaD), or lock-contract.
//
// Why no tax/limits in V4:
//   V4 swaps go through PoolManager directly — no token._transfer hook fires on a swap path.
//   Tax-on-transfer only works via a custom V4 hook (separate contract), which requires
//   CREATE2-mining the hook address with the right flag bits. Out of scope for this template.
//
// Liquidity math:
//   sqrtPriceX96, tickLower, tickUpper, liquidity are all computed OFF-CHAIN by the bot.
//   sqrtPriceX96 = sqrt(tokens/ETH) × 2^96
//   Default range: full-range (MIN_USABLE_TICK / MAX_USABLE_TICK for the chosen tickSpacing)
//   liquidity is calculated via Uniswap LiquidityAmounts.getLiquidityForAmounts ported in JS.
//
// Removal:
//   For lpPolicy=keep, the LP NFT is held by deployer wallet → PositionManager.modifyLiquidities
//   with BURN_POSITION + TAKE_PAIR pulls it. See engine/remove_lp_v4.mjs (private mempool).
// ─────────────────────────────────────────────────────────────────────────

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// V4 PoolKey: identifies a pool. Ordering currency0 < currency1 enforced (ETH=0x0 always wins).
struct PoolKey {
    address currency0;
    address currency1;
    uint24 fee;
    int24 tickSpacing;
    address hooks;
}

interface IPositionManager {
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory);
    function initializePool(PoolKey calldata key, uint160 sqrtPriceX96) external payable returns (int24);
    function modifyLiquidities(bytes calldata unlockData, uint256 deadline) external payable;
    function nextTokenId() external view returns (uint256);
}

interface IPermit2 {
    // Spec from Permit2 mainnet: token, spender, amount(uint160), expiration(uint48)
    function approve(address token, address spender, uint160 amount, uint48 expiration) external;
}

contract LaunchTokenV4 is IERC20 {
    // ─── Errors ─────────────────────────────────────────────────────────
    error NotOwner();
    error ZeroAddress();
    error InsufficientAllowance();
    error PermitExpired();
    error InvalidSignature();
    error MaxWalletExceeded();
    error MaxTxExceeded();
    error MaxBpsTooLow();

    // ─── Per-launch unique identifier ───────────────────────────────────
    // Compile-time constant patched per launch by engine/compile_token.mjs to a
    // keccak256 over (symbol, name, timestamp, deployer). Embeds 32 bytes into the
    // bytecode body, making EVERY launch produce a distinct compiled bytecode. This
    // breaks Etherscan's "Similar Match" auto-deduplication — without it, all our
    // LaunchTokenV4 deploys collapse to a single canonical source on Etherscan
    // (the FIRST one verified), causing later launches to display the older project's
    // branding header. Cost: 32 bytes of bytecode, no runtime overhead.
    bytes32 public constant LAUNCH_ID =
        0x1fee1e2b33d319285256e8549bd7feea5ec2d11d1bbcd66c6e153e72df2dae9d;

    // ─── Storage ────────────────────────────────────────────────────────
    address public owner;
    string  public name;
    string  public symbol;
    uint8   public constant decimals = 18;
    uint256 public immutable totalSupply;

    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    // V4 mainnet addresses
    address constant POSITION_MANAGER = 0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e;
    address constant POOL_MANAGER     = 0x000000000004444c5dc75cB358380D2e3dE08A90;
    address constant UNIVERSAL_ROUTER = 0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af;
    address constant PERMIT2          = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    // ─── Anti-whale limits ──────────────────────────────────────────────
    // Maestro / Banana Gun / Photon scanners detect max-wallet by simulating a > N% buy
    // and seeing if it reverts. A reasonable maxWallet (1-3%) shows green "anti-whale"
    // in their UI and discourages snipe-bundles. Auto-lifts after `limitsLiftBlock` so
    // late buyers can accumulate freely. owner / V4 infra addresses are excluded so
    // LP setup and swaps work normally.
    uint16  public maxWalletBps;        // 0 = no limit; e.g. 200 = 2%; min enforced 100 (1%) to avoid honeypot
    uint16  public maxTxBps;            // 0 = no limit; e.g. 200 = 2% per single tx (anti-bundle-snipe)
    uint32  public limitsLiftBlock;     // block at which limits stop applying (0 = manual-only)
    bool    public limitsLifted;
    mapping(address => bool) public isExcludedFromLimits;

    event LimitsLifted();

    // V4 action opcodes (subset used here)
    uint8 constant ACTION_MINT_POSITION = 0x02;
    uint8 constant ACTION_SETTLE_PAIR   = 0x0d;
    uint8 constant ACTION_SWEEP         = 0x14;

    // No `tradingOpen` / `poolId` storage on purpose — heuristic scanners (Padre, Bubblemap) flag
    // ANY ERC20 with a launch-phase boolean as "transfers can be blocked after init" even when the
    // _transfer path doesn't read it. Keeping bytecode minimal = clean score. Pool state lives on
    // the V4 PoolManager; off-chain indexers compute poolId from emitted event args.

    // EIP-2612 Permit (gasless approve)
    bytes32 public constant PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    bytes32 private immutable _DOMAIN_SEPARATOR;
    mapping(address => uint256) public nonces;

    // ─── Events ─────────────────────────────────────────────────────────
    event TradingOpenedV4(
        bytes32 indexed poolId,
        uint160 sqrtPriceX96,
        uint256 ethAdded,
        uint256 tokensAdded,
        address lpRecipient
    );
    event Renounced();

    // ─── Modifiers ──────────────────────────────────────────────────────
    modifier onlyOwner() { if (msg.sender != owner) revert NotOwner(); _; }

    // ─── Constructor ────────────────────────────────────────────────────
    constructor(string memory name_, string memory symbol_, uint256 supply_) {
        owner = msg.sender;
        name = name_;
        symbol = symbol_;
        totalSupply = supply_;
        _balances[msg.sender] = supply_;
        emit Transfer(address(0), msg.sender, supply_);

        _DOMAIN_SEPARATOR = keccak256(abi.encode(
            keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
            keccak256(bytes(name_)),
            keccak256("1"),
            block.chainid,
            address(this)
        ));
    }

    // ─── ERC20 ──────────────────────────────────────────────────────────
    function balanceOf(address a) external view returns (uint256) { return _balances[a]; }
    function allowance(address o, address s) external view returns (uint256) { return _allowances[o][s]; }
    function DOMAIN_SEPARATOR() external view returns (bytes32) { return _DOMAIN_SEPARATOR; }

    function approve(address spender, uint256 amount) external returns (bool) {
        if (spender == address(0)) revert ZeroAddress();
        _allowances[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, amount);
        return true;
    }

    function transfer(address to, uint256 amount) external returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    function transferFrom(address from, address to, uint256 amount) external returns (bool) {
        uint256 a = _allowances[from][msg.sender];
        if (a < amount) revert InsufficientAllowance();
        if (a != type(uint256).max) _allowances[from][msg.sender] = a - amount;
        _transfer(from, to, amount);
        return true;
    }

    // ERC20 transfer with optional anti-whale max-wallet enforcement (auto-lifts after
    // `limitsLiftBlock`). No tax, no fee-on-transfer, no blacklist, no reentrancy guard.
    // Limits only apply when set during openTradingV4Curve; before trade-open they're 0.
    function _transfer(address from, address to, uint256 amount) private {
        if (from == address(0) || to == address(0)) revert ZeroAddress();

        // Lazy auto-lift: once block window passes, flip the flag (1 SSTORE forever) so
        // subsequent transfers skip the maxWallet check entirely (1 SLOAD/transfer cost).
        if (!limitsLifted && limitsLiftBlock != 0 && block.number >= limitsLiftBlock) {
            limitsLifted = true;
            emit LimitsLifted();
        }

        // Enforce limits only when active and recipient is not in exclusions list. V4 infra
        // (PoolManager, PositionManager, UniversalRouter, Permit2, owner, contract self,
        // lpRecipient) is excluded so LP setup and swaps flow unrestricted. Both maxTx and
        // maxWallet apply on the same path; standard pattern from AWF/ELIEN-class memecoins.
        if (!limitsLifted && !isExcludedFromLimits[to]) {
            if (maxTxBps != 0) {
                uint256 maxTxAmt = (totalSupply * maxTxBps) / 10000;
                if (amount > maxTxAmt) revert MaxTxExceeded();
            }
            if (maxWalletBps != 0) {
                uint256 maxBal = (totalSupply * maxWalletBps) / 10000;
                if (_balances[to] + amount > maxBal) revert MaxWalletExceeded();
            }
        }

        _balances[from] = _balances[from] - amount;
        _balances[to]   = _balances[to]   + amount;
        emit Transfer(from, to, amount);
    }

    // ─── EIP-2612 Permit (gasless approve) ──────────────────────────────
    function permit(
        address owner_, address spender, uint256 value, uint256 deadline,
        uint8 v, bytes32 r, bytes32 s
    ) external {
        if (block.timestamp > deadline) revert PermitExpired();
        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner_, spender, value, nonces[owner_]++, deadline));
        bytes32 digest = keccak256(abi.encodePacked("\x19\x01", _DOMAIN_SEPARATOR, structHash));
        address recovered = ecrecover(digest, v, r, s);
        if (recovered == address(0) || recovered != owner_) revert InvalidSignature();
        _allowances[owner_][spender] = value;
        emit Approval(owner_, spender, value);
    }

    // ─── V4 launch ──────────────────────────────────────────────────────
    /**
     * @param sqrtPriceX96  Initial sqrt(price) × 2^96. price = currency1/currency0 = tokens/ETH.
     * @param tickLower     Lower tick. Use MIN_USABLE_TICK(tickSpacing) for full-range.
     * @param tickUpper     Upper tick. Use MAX_USABLE_TICK(tickSpacing) for full-range.
     * @param liquidity     LP units, computed off-chain via LiquidityAmounts.getLiquidityForAmounts.
     * @param fee           Pool fee in pips (3000 = 0.3%, 10000 = 1%).
     * @param tickSpacing   Spacing matching fee (60 for 3000, 200 for 10000).
     * @param lpRecipient   NFT recipient. msg.sender = keep, 0xdEaD = burn, lock-contract = lock.
     * @param autoRenounce  Renounce ownership in same tx after pool opens.
     */
    function openTradingV4(
        uint160 sqrtPriceX96,
        int24 tickLower,
        int24 tickUpper,
        uint256 liquidity,
        uint24 fee,
        int24 tickSpacing,
        address lpRecipient,
        bool autoRenounce
    ) external payable onlyOwner {
        // No tradingOpen check — PoolManager.initialize reverts on second call (pool already
        // initialized) so double-launch is naturally impossible.
        if (lpRecipient == address(0)) revert ZeroAddress();

        // Move owner's tokens into this contract — the LP token side comes from here.
        uint256 ownerBal = _balances[owner];
        _balances[owner] = 0;
        _balances[address(this)] = _balances[address(this)] + ownerBal;
        emit Transfer(owner, address(this), ownerBal);

        // Token → Permit2 (MAX, infinite). Permit2 is the canonical V4 spender.
        _allowances[address(this)][PERMIT2] = type(uint256).max;
        emit Approval(address(this), PERMIT2, type(uint256).max);

        // Permit2 → PositionManager (MAX, MAX expiration). Lets PositionManager pull tokens.
        IPermit2(PERMIT2).approve(address(this), POSITION_MANAGER, type(uint160).max, type(uint48).max);

        // Build PoolKey: ETH (currency0=address(0)) / token (currency1=this), no hooks.
        PoolKey memory key = PoolKey({
            currency0:   address(0),
            currency1:   address(this),
            fee:         fee,
            tickSpacing: tickSpacing,
            hooks:       address(0)
        });
        bytes32 _poolId = keccak256(abi.encode(key));  // local-only; emitted in event below

        // Build modifyLiquidities calldata:
        //   actions = [MINT_POSITION, SETTLE_PAIR, SWEEP]
        //   params  = [
        //       MINT params: (poolKey, tickLower, tickUpper, liquidity, amount0Max, amount1Max, owner, hookData),
        //       SETTLE_PAIR params: (currency0, currency1),
        //       SWEEP params: (currency0=ETH, recipient=owner)  ← refund excess ETH
        //   ]
        bytes memory actions = abi.encodePacked(ACTION_MINT_POSITION, ACTION_SETTLE_PAIR, ACTION_SWEEP);
        bytes[] memory params = new bytes[](3);
        params[0] = abi.encode(
            key,
            tickLower,
            tickUpper,
            liquidity,
            uint128(msg.value),                  // amount0Max — cap on ETH spent
            uint128(_balances[address(this)]),   // amount1Max — cap on tokens spent
            lpRecipient,
            bytes("")
        );
        params[1] = abi.encode(key.currency0, key.currency1);
        params[2] = abi.encode(key.currency0, owner);     // any leftover ETH back to deployer
        bytes memory unlockData = abi.encode(actions, params);

        // Atomic: initialize pool + mint position via PositionManager.multicall
        bytes[] memory calls = new bytes[](2);
        calls[0] = abi.encodeWithSignature(
            "initializePool((address,address,uint24,int24,address),uint160)",
            key,
            sqrtPriceX96
        );
        calls[1] = abi.encodeWithSignature(
            "modifyLiquidities(bytes,uint256)",
            unlockData,
            block.timestamp + 60
        );
        IPositionManager(POSITION_MANAGER).multicall{value: msg.value}(calls);

        emit TradingOpenedV4(_poolId, sqrtPriceX96, msg.value, ownerBal, lpRecipient);

        if (autoRenounce) {
            owner = address(0);
            emit Renounced();
        }
    }

    /**
     * Curve-launch (pump.fun-style): single-sided LP that holds ALL tokens above currentPrice
     * with NO ETH committed by the deployer. As buyers swap ETH → token, price descends through
     * the band and the position releases tokens / collects ETH automatically (CLAMM math).
     *
     * Same pattern uniGPT (0x4728…0040), Klik, Stroid, Livo bonding-curves use.
     *
     * Off-chain JS picks (sqrtPriceX96, tickLower, tickUpper, liquidity) from desired (start_mc,
     * grad_mc, supply, tickSpacing). See engine/v4_math.mjs::computeCurveLaunchParams.
     *
     * @param sqrtPriceX96  Initial sqrt(price) × 2^96. Derived from desired START market cap:
     *                      sqrtPriceX96 = sqrt(supply / start_mc_wei) × Q96.
     * @param tickLower     Bottom of curve = price at GRADUATION market cap (curve cap-out).
     * @param tickUpper     Top of curve = JUST below currentTick so position is "fully token-side"
     *                      at deploy. Buyers immediately enter the band on first swap.
     * @param liquidity     LP units. = supply × Q96 / (sqrtB − sqrtA), packs full supply into band.
     */
    function openTradingV4Curve(
        uint160 sqrtPriceX96,
        int24 tickLower,
        int24 tickUpper,
        uint256 liquidity,
        uint24 fee,
        int24 tickSpacing,
        address lpRecipient,
        bool autoRenounce,
        uint16 maxWalletBps_,    // 0 = disabled; e.g. 200 = 2% per wallet (min 100 = 1% to avoid honeypot)
        uint16 maxTxBps_,        // 0 = disabled; e.g. 200 = 2% per single tx (anti-bundle-snipe)
        uint32 limitsBlocks_     // 0 = manual-lift only; e.g. 25 = ~5 min auto-lift on mainnet (12s/block)
    ) external onlyOwner {
        // NOT payable — deployer doesn't seed ETH side. msg.value forced to 0 by ABI.
        if (lpRecipient == address(0)) revert ZeroAddress();
        if (maxWalletBps_ != 0 && maxWalletBps_ < 100) revert MaxBpsTooLow();
        if (maxTxBps_ != 0 && maxTxBps_ < 100) revert MaxBpsTooLow();

        // Exclude V4 infra + internal addresses BEFORE setting limits so the internal supply
        // move and the LP mint flow through unhindered.
        isExcludedFromLimits[address(this)]    = true;
        isExcludedFromLimits[owner]            = true;
        isExcludedFromLimits[POSITION_MANAGER] = true;
        isExcludedFromLimits[POOL_MANAGER]     = true;
        isExcludedFromLimits[PERMIT2]          = true;
        isExcludedFromLimits[UNIVERSAL_ROUTER] = true;
        isExcludedFromLimits[lpRecipient]      = true;

        // Apply limits
        maxWalletBps    = maxWalletBps_;
        maxTxBps        = maxTxBps_;
        limitsLiftBlock = limitsBlocks_ != 0 ? uint32(block.number) + limitsBlocks_ : 0;

        // Move owner's tokens into this contract (LP token side).
        uint256 ownerBal = _balances[owner];
        _balances[owner] = 0;
        _balances[address(this)] = _balances[address(this)] + ownerBal;
        emit Transfer(owner, address(this), ownerBal);

        // Token → Permit2 (MAX). Permit2 → PositionManager.
        _allowances[address(this)][PERMIT2] = type(uint256).max;
        emit Approval(address(this), PERMIT2, type(uint256).max);
        IPermit2(PERMIT2).approve(address(this), POSITION_MANAGER, type(uint160).max, type(uint48).max);

        PoolKey memory key = PoolKey({
            currency0:   address(0),
            currency1:   address(this),
            fee:         fee,
            tickSpacing: tickSpacing,
            hooks:       address(0)
        });
        bytes32 _poolId = keccak256(abi.encode(key));

        // Actions: MINT_POSITION + SETTLE_PAIR + SWEEP×2 (mirror uniGPT's 0x020d1414 layout).
        // Two sweeps refund any dust on EITHER side back to deployer.
        bytes memory actions = abi.encodePacked(
            ACTION_MINT_POSITION,
            ACTION_SETTLE_PAIR,
            ACTION_SWEEP,
            ACTION_SWEEP
        );
        bytes[] memory params = new bytes[](4);
        params[0] = abi.encode(
            key,
            tickLower,
            tickUpper,
            liquidity,
            uint128(0),                          // amount0Max = 0  ← single-sided, no ETH
            uint128(_balances[address(this)]),   // amount1Max = full token supply
            lpRecipient,
            bytes("")
        );
        params[1] = abi.encode(key.currency0, key.currency1);
        params[2] = abi.encode(key.currency0, owner);   // ETH dust → owner (would be 0 anyway)
        params[3] = abi.encode(key.currency1, owner);   // token dust → owner (rounding leftover)
        bytes memory unlockData = abi.encode(actions, params);

        bytes[] memory calls = new bytes[](2);
        calls[0] = abi.encodeWithSignature(
            "initializePool((address,address,uint24,int24,address),uint160)",
            key,
            sqrtPriceX96
        );
        calls[1] = abi.encodeWithSignature(
            "modifyLiquidities(bytes,uint256)",
            unlockData,
            block.timestamp + 60
        );
        // No {value: ...} — single-sided launch, deployer pays only gas.
        IPositionManager(POSITION_MANAGER).multicall(calls);

        emit TradingOpenedV4(_poolId, sqrtPriceX96, 0, ownerBal, lpRecipient);

        if (autoRenounce) {
            owner = address(0);
            emit Renounced();
        }
    }

    // ─── Anti-whale limit controls ──────────────────────────────────────
    /// Manually lift max-wallet limits before the auto-lift block fires.
    function liftLimitsNow() external onlyOwner {
        limitsLifted = true;
        emit LimitsLifted();
    }

    /// Whitelist/blacklist an address from max-wallet enforcement (e.g. a future lock contract).
    function setExcluded(address account, bool flag) external onlyOwner {
        isExcludedFromLimits[account] = flag;
    }

    function renounceOwnership() external onlyOwner {
        owner = address(0);
        emit Renounced();
    }

    // accept ETH refunds (SWEEP)
    receive() external payable {}
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.