FunLauncher

0xdf595c02f55b85401dd4a545e61c12b3285c1a26

Verification
Verified
v0.8.26+commit.8a97fa7a
Type
Contract
7,061 bytes
ABI entries
22
19 read · 1 write
License
none

Contract information

Address
0xdf595c02f55b85401dd4a545e61c12b3285c1a26
Chain
Robinhood Chain (4663)
Compiler
v0.8.26+commit.8a97fa7a
Optimization
Enabled
Creation tx
0x389b220d7e…84678b3ae5

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (19)

FEE()uint24
LAUNCH_FEE()uint256
MAX_WALLET_BPS()uint16
SQRT_INIT_TOKEN0()uint160
SQRT_INIT_TOKEN1()uint160
SUPPLY()uint256
TICK_END()int24
TICK_START()int24
allTokens(uint256)address
creatorOf(address)address
factory()address
locker()address
npm()address
platform()address
poolOf(address)address
positionOf(address)uint256
router()address
tokenCount()uint256
weth()address

Events (1)

Launched

ABI

[
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_npm",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_factory",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_weth",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_router",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_platform",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_locker",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "creator",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "pool",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "uint128",
        "name": "liquidity",
        "type": "uint128"
      },
      {
        "indexed": false,
        "internalType": "uint64",
        "name": "unlockAt",
        "type": "uint64"
      },
      {
        "indexed": false,
        "internalType": "string",
        "name": "name",
        "type": "string"
      },
      {
        "indexed": false,
        "internalType": "string",
        "name": "symbol",
        "type": "string"
      }
    ],
    "name": "Launched",
    "type": "event"
  },
  {
    "inputs": [],
    "name": "FEE",
    "outputs": [
      {
        "internalType": "uint24",
        "name": "",
        "type": "uint24"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "LAUNCH_FEE",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "MAX_WALLET_BPS",
    "outputs": [
      {
        "internalType": "uint16",
        "name": "",
        "type": "uint16"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "SQRT_INIT_TOKEN0",
    "outputs": [
      {
        "internalType": "uint160",
        "name": "",
        "type": "uint160"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "SQRT_INIT_TOKEN1",
    "outputs": [
      {
        "internalType": "uint160",
        "name": "",
        "type": "uint160"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "SUPPLY",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "TICK_END",
    "outputs": [
      {
        "internalType": "int24",
        "name": "",
        "type": "int24"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "TICK_START",
    "outputs": [
      {
        "internalType": "int24",
        "name": "",
        "type": "int24"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "name": "allTokens",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "creatorOf",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "factory",
    "outputs": [
      {
        "internalType": "contract IUniswapV3Factory",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "string",
        "name": "name",
        "type": "string"
      },
      {
        "internalType": "string",
        "name": "symbol",
        "type": "string"
      }
    ],
    "name": "launch",
    "outputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      }
    ],
    "stateMutability": "payable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "locker",
    "outputs": [
      {
        "internalType": "contract FunTimeLocker",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "npm",
    "outputs": [
      {
        "internalType": "contract INonfungiblePositionManager",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "platform",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "poolOf",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "positionOf",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "router",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "tokenCount",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "weth",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  }
]

Source code

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

import {INonfungiblePositionManager, IUniswapV3Factory} from "./interfaces/Uniswap.sol";
import {FunToken} from "./FunToken.sol";
import {FunTimeLocker} from "./FunTimeLocker.sol";

contract FunLauncher {
    INonfungiblePositionManager public immutable npm;
    IUniswapV3Factory public immutable factory;
    address public immutable weth;
    address public immutable router;
    address public immutable platform;
    FunTimeLocker public immutable locker;

    uint24 public constant FEE = 10000;
    uint256 public constant SUPPLY = 1_000_000_000e18;
    uint16 public constant MAX_WALLET_BPS = 400;

    int24 public constant TICK_START = -207200;
    int24 public constant TICK_END = -161200;
    uint160 public constant SQRT_INIT_TOKEN0 = 2510809139091789284100322;
    uint160 public constant SQRT_INIT_TOKEN1 = 2500031419217008302293562112940196;

    uint256 public constant LAUNCH_FEE = 0.001 ether;

    address[] public allTokens;
    mapping(address => address) public poolOf;
    mapping(address => address) public creatorOf;
    mapping(address => uint256) public positionOf;

    bool private _locked;

    event Launched(
        address indexed token,
        address indexed creator,
        address pool,
        uint256 tokenId,
        uint128 liquidity,
        uint64 unlockAt,
        string name,
        string symbol
    );

    modifier nonReentrant() {
        require(!_locked, "reentrant");
        _locked = true;
        _;
        _locked = false;
    }

    constructor(address _npm, address _factory, address _weth, address _router, address _platform, address _locker) {
        require(
            _npm != address(0) && _factory != address(0) && _weth != address(0) && _router != address(0)
                && _platform != address(0) && _locker != address(0),
            "zero"
        );
        npm = INonfungiblePositionManager(_npm);
        factory = IUniswapV3Factory(_factory);
        weth = _weth;
        router = _router;
        platform = _platform;
        locker = FunTimeLocker(_locker);
    }

    function launch(string calldata name, string calldata symbol)
        external
        payable
        nonReentrant
        returns (address token)
    {
        require(msg.value == LAUNCH_FEE, "launch fee");

        FunToken t = new FunToken(
            name, symbol, SUPPLY, MAX_WALLET_BPS, address(this), address(factory), weth, FEE, address(npm), router
        );
        token = address(t);

        bool tokenIsToken0 = token < weth;
        address token0 = tokenIsToken0 ? token : weth;
        address token1 = tokenIsToken0 ? weth : token;
        int24 tickLower;
        int24 tickUpper;
        uint160 sqrtInit;
        uint256 amount0Desired;
        uint256 amount1Desired;
        if (tokenIsToken0) {
            tickLower = TICK_START;
            tickUpper = TICK_END;
            sqrtInit = SQRT_INIT_TOKEN0;
            amount0Desired = SUPPLY;
        } else {
            tickLower = -TICK_END;
            tickUpper = -TICK_START;
            sqrtInit = SQRT_INIT_TOKEN1;
            amount1Desired = SUPPLY;
        }

        address pool = npm.createAndInitializePoolIfNecessary(token0, token1, FEE, sqrtInit);
        t.approve(address(npm), SUPPLY);
        (uint256 tokenId, uint128 liquidity,,) = npm.mint(
            INonfungiblePositionManager.MintParams({
                token0: token0,
                token1: token1,
                fee: FEE,
                tickLower: tickLower,
                tickUpper: tickUpper,
                amount0Desired: amount0Desired,
                amount1Desired: amount1Desired,
                amount0Min: 0,
                amount1Min: 0,
                recipient: address(locker),
                deadline: block.timestamp
            })
        );

        locker.lock(tokenId, msg.sender);

        (bool feeOk,) = platform.call{value: LAUNCH_FEE}("");
        require(feeOk, "fee pay");

        allTokens.push(token);
        poolOf[token] = pool;
        creatorOf[token] = msg.sender;
        positionOf[token] = tokenId;
        emit Launched(token, msg.sender, pool, tokenId, liquidity, locker.unlockAt(tokenId), name, symbol);
    }

    function tokenCount() external view returns (uint256) {
        return allTokens.length;
    }
}
Chain explorer2557msChain node80ms