creation_sourcecode: {"Token.sol":{"content":"// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.19;\r\n\r\n// Created with UniswapV3!\r\n\r\ninterface Callable {\r\n\tfunction tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external returns (bool);\r\n}\r\n\r\ninterface Router {\r\n\tstruct ExactInputSingleParams {\r\n\t\taddress tokenIn;\r\n\t\taddress tokenOut;\r\n\t\tuint24 fee;\r\n\t\taddress recipient;\r\n\t\tuint256 amountIn;\r\n\t\tuint256 amountOutMinimum;\r\n\t\tuint160 sqrtPriceLimitX96;\r\n\t}\r\n\tfunction factory() external view returns (address);\r\n\tfunction positionManager() external view returns (address);\r\n\tfunction WETH9() external view returns (address);\r\n\tfunction exactInputSingle(ExactInputSingleParams calldata) external payable returns (uint256);\r\n}\r\n\r\ninterface Factory {\r\n\tfunction createPool(address _tokenA, address _tokenB, uint24 _fee) external returns (address);\r\n}\r\n\r\ninterface Pool {\r\n\tfunction initialize(uint160 _sqrtPriceX96) external;\r\n}\r\n\r\ninterface PositionManager {\r\n\tstruct MintParams {\r\n\t\taddress token0;\r\n\t\taddress token1;\r\n\t\tuint24 fee;\r\n\t\tint24 tickLower;\r\n\t\tint24 tickUpper;\r\n\t\tuint256 amount0Desired;\r\n\t\tuint256 amount1Desired;\r\n\t\tuint256 amount0Min;\r\n\t\tuint256 amount1Min;\r\n\t\taddress recipient;\r\n\t\tuint256 deadline;\r\n\t}\r\n\tstruct CollectParams {\r\n\t\tuint256 tokenId;\r\n\t\taddress recipient;\r\n\t\tuint128 amount0Max;\r\n\t\tuint128 amount1Max;\r\n\t}\r\n\tfunction mint(MintParams calldata) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\r\n\tfunction collect(CollectParams calldata) external payable returns (uint256 amount0, uint256 amount1);\r\n}\r\n\r\ninterface ERC20 {\r\n\tfunction balanceOf(address) external view returns (uint256);\r\n\tfunction transfer(address, uint256) external returns (bool);\r\n}\r\n\r\ninterface WETH is ERC20 {\r\n\tfunction withdraw(uint256) external;\r\n}\r\n\r\n\r\ncontract Team {\r\n\r\n\tRouter constant private ROUTER = Router(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);\r\n\r\n\tstruct Share {\r\n\t\taddress payable user;\r\n\t\tuint256 shares;\r\n\t}\r\n\tShare[] public shares;\r\n\tuint256 public totalShares;\r\n\tERC20 public token;\r\n\r\n\r\n\tfunction initialize(address _creator) external {\r\n\t\trequire(totalShares == 0);\r\n\t\ttoken = ERC20(msg.sender);\r\n\t\t_addShare(_creator, 10);\r\n\t\t_addShare(0x5C54d7D434A2d8c00b8cA3FF293d43cb0e08f521, 6);\r\n\t\t_addShare(0x7ab854a7ffb5f72268681a868051c84726D48fF2, 3);\r\n\t\t_addShare(0x1A900F603C6048a630dCde5c1CdbdCfc429Fe523, 1);\r\n\t}\r\n\r\n\treceive() external payable {}\r\n\r\n\tfunction withdrawETH() public {\r\n\t\tuint256 _balance = address(this).balance;\r\n\t\tif (_balance \u003e 0) {\r\n\t\t\tfor (uint256 i = 0; i \u003c shares.length; i++) {\r\n\t\t\t\tShare memory _share = shares[i];\r\n\t\t\t\t!_share.user.send(_balance * _share.shares / totalShares);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction withdrawToken(ERC20 _token) public {\r\n\t\tWETH _weth = WETH(ROUTER.WETH9());\r\n\t\tif (address(_token) == address(_weth)) {\r\n\t\t\t_weth.withdraw(_weth.balanceOf(address(this)));\r\n\t\t\twithdrawETH();\r\n\t\t} else {\r\n\t\t\tuint256 _balance = _token.balanceOf(address(this));\r\n\t\t\tif (_balance \u003e 0) {\r\n\t\t\t\tfor (uint256 i = 0; i \u003c shares.length; i++) {\r\n\t\t\t\t\tShare memory _share = shares[i];\r\n\t\t\t\t\t_token.transfer(_share.user, _balance * _share.shares / totalShares);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction withdrawWETH() public {\r\n\t\twithdrawToken(ERC20(ROUTER.WETH9()));\r\n\t}\r\n\r\n\tfunction withdrawFees() external {\r\n\t\twithdrawWETH();\r\n\t\twithdrawToken(token);\r\n\t}\r\n\r\n\r\n\tfunction _addShare(address _user, uint256 _shares) internal {\r\n\t\tshares.push(Share(payable(_user), _shares));\r\n\t\ttotalShares += _shares;\r\n\t}\r\n}\r\n\r\n\r\ncontract Token {\r\n\r\n\tuint256 constant private UINT_MAX = type(uint256).max;\r\n\tuint128 constant private UINT128_MAX = type(uint128).max;\r\n\tuint256 constant private MAX_NAME_LENGTH = 32;\r\n\tuint256 constant private MIN_SUPPLY = 1e16; // 0.01 tokens\r\n\tuint256 constant private MAX_SUPPLY = 1e33; // 1 quadrillion tokens\r\n\tuint256 constant private PERCENT_PRECISION = 1000; // 1 = 0.1%\r\n\tuint256 constant private MAX_TIME_LIMIT = 24 hours;\r\n\tRouter constant private ROUTER = Router(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);\r\n\r\n\tint24 constant internal MIN_TICK = -887272;\r\n\tint24 constant internal MAX_TICK = -MIN_TICK;\r\n\tuint160 constant internal MIN_SQRT_RATIO = 4295128739;\r\n\tuint160 constant internal MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\r\n\r\n\tstring public name;\r\n\tstring public symbol;\r\n\tuint8 constant public decimals = 18;\r\n\r\n\tstring constant public source = \"UniswapV3\";\r\n\r\n\r\n\tstruct User {\r\n\t\tuint256 balance;\r\n\t\tmapping(address =\u003e uint256) allowance;\r\n\t}\r\n\r\n\tstruct Info {\r\n\t\tbool locked;\r\n\t\tTeam team;\r\n\t\taddress pool;\r\n\t\taddress creator;\r\n\t\tuint256 totalSupply;\r\n\t\tuint256 initialMarketCap;\r\n\t\tuint256 upperMarketCap;\r\n\t\tuint256 concentratedPercent;\r\n\t\tuint256 creatorFee;\r\n\t\tuint256 transferLimit;\r\n\t\tuint256 transferLimitEnd;\r\n\t\tmapping(address =\u003e User) users;\r\n\t\tuint256 positionId;\r\n\t\tstring website;\r\n\t\tstring twitter;\r\n\t\tstring telegram;\r\n\t\tstring discord;\r\n\t\tstring additionalInfo;\r\n\t}\r\n\tInfo private info;\r\n\r\n\r\n\tevent Transfer(address indexed from, address indexed to, uint256 tokens);\r\n\tevent Approval(address indexed owner, address indexed spender, uint256 tokens);\r\n\r\n\r\n\tmodifier _onlyCreator() {\r\n\t\trequire(msg.sender == creator());\r\n\t\t_;\r\n\t}\r\n\r\n\t\r\n\tfunction lock() external {\r\n\t\trequire(!info.locked);\r\n\t\trequire(totalSupply() == 0);\r\n\t\tinfo.locked = true;\r\n\t}\r\n\t\r\n\tfunction initialize(address _creator, string memory _name, string memory _symbol, uint256 _totalSupply, uint256 _initialMarketCap, uint256 _upperMarketCap, uint256 _creatorFee, uint256 _transferLimit, uint256 _transferLimitTime) external payable {\r\n\t\trequire(!info.locked);\r\n\t\trequire(totalSupply() == 0);\r\n\t\trequire(bytes(_name).length \u003e 0 \u0026\u0026 bytes(_name).length \u003c= MAX_NAME_LENGTH);\r\n\t\trequire(bytes(_symbol).length \u003e 0 \u0026\u0026 bytes(_symbol).length \u003c= MAX_NAME_LENGTH);\r\n\t\trequire(_totalSupply \u003e= MIN_SUPPLY \u0026\u0026 _totalSupply \u003c= MAX_SUPPLY);\r\n\t\trequire(_initialMarketCap \u003e 0 \u0026\u0026 _upperMarketCap \u003e _initialMarketCap);\r\n\t\trequire(_creatorFee \u003c= PERCENT_PRECISION / 10);\r\n\t\trequire(_transferLimitTime \u003c= MAX_TIME_LIMIT);\r\n\t\tinfo.team = new Team();\r\n\t\tinfo.team.initialize(_creator);\r\n\t\tinfo.creator = _creator;\r\n\t\tname = _name;\r\n\t\tsymbol = _symbol;\r\n\t\tinfo.totalSupply = _totalSupply;\r\n\t\tinfo.users[address(this)].balance = _totalSupply;\r\n\t\temit Transfer(address(0x0), address(this), _totalSupply);\r\n\t\tinfo.initialMarketCap = _initialMarketCap;\r\n\t\tinfo.upperMarketCap = _upperMarketCap;\r\n\t\tinfo.creatorFee = _creatorFee;\r\n\t\t_createLP(_initialMarketCap, _upperMarketCap, _creatorFee);\r\n\t\tinfo.transferLimit = _transferLimit;\r\n\t\tinfo.transferLimitEnd = block.timestamp + _transferLimitTime;\r\n\t}\r\n\r\n\tfunction updateAll(string memory _website, string memory _twitter, string memory _telegram, string memory _discord, string memory _info) external _onlyCreator {\r\n\t\tinfo.website = _website;\r\n\t\tinfo.twitter = _twitter;\r\n\t\tinfo.telegram = _telegram;\r\n\t\tinfo.discord = _discord;\r\n\t\tinfo.additionalInfo = _info;\r\n\t}\r\n\r\n\tfunction updateWebsite(string memory _website) external _onlyCreator {\r\n\t\tinfo.website = _website;\r\n\t}\r\n\r\n\tfunction updateTwitter(string memory _twitter) external _onlyCreator {\r\n\t\tinfo.twitter = _twitter;\r\n\t}\r\n\r\n\tfunction updateTelegram(string memory _telegram) external _onlyCreator {\r\n\t\tinfo.telegram = _telegram;\r\n\t}\r\n\r\n\tfunction updateDiscord(string memory _discord) external _onlyCreator {\r\n\t\tinfo.discord = _discord;\r\n\t}\r\n\r\n\tfunction updateInfo(string memory _info) external _onlyCreator {\r\n\t\tinfo.additionalInfo = _info;\r\n\t}\r\n\r\n\tfunction collectTradingFees() external {\r\n\t\tPositionManager _pm = PositionManager(ROUTER.positionManager());\r\n\t\t_pm.collect(PositionManager.CollectParams({\r\n\t\t\ttokenId: info.positionId,\r\n\t\t\trecipient: team(),\r\n\t\t\tamount0Max: UINT128_MAX,\r\n\t\t\tamount1Max: UINT128_MAX\r\n\t\t}));\r\n\t\tinfo.team.withdrawFees();\r\n\t}\r\n\r\n\tfunction transfer(address _to, uint256 _tokens) external returns (bool) {\r\n\t\treturn _transfer(msg.sender, _to, _tokens);\r\n\t}\r\n\r\n\tfunction approve(address _spender, uint256 _tokens) external returns (bool) {\r\n\t\treturn _approve(msg.sender, _spender, _tokens);\r\n\t}\r\n\r\n\tfunction transferFrom(address _from, address _to, uint256 _tokens) external returns (bool) {\r\n\t\tunchecked {\r\n\t\t\tuint256 _allowance = allowance(_from, msg.sender);\r\n\t\t\trequire(_allowance \u003e= _tokens);\r\n\t\t\tif (_allowance != UINT_MAX) {\r\n\t\t\t\tinfo.users[_from].allowance[msg.sender] -= _tokens;\r\n\t\t\t}\r\n\t\t\treturn _transfer(_from, _to, _tokens);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction transferAndCall(address _to, uint256 _tokens, bytes calldata _data) external returns (bool) {\r\n\t\t_transfer(msg.sender, _to, _tokens);\r\n\t\tuint32 _size;\r\n\t\tassembly {\r\n\t\t\t_size := extcodesize(_to)\r\n\t\t}\r\n\t\tif (_size \u003e 0) {\r\n\t\t\trequire(Callable(_to).tokenCallback(msg.sender, _tokens, _data));\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\r\n\tfunction creator() public view returns (address) {\r\n\t\treturn info.creator;\r\n\t}\r\n\t\r\n\tfunction team() public view returns (address) {\r\n\t\treturn address(info.team);\r\n\t}\r\n\r\n\tfunction pool() public view returns (address) {\r\n\t\treturn info.pool;\r\n\t}\r\n\r\n\tfunction totalSupply() public view returns (uint256) {\r\n\t\treturn info.totalSupply;\r\n\t}\r\n\r\n\tfunction balanceOf(address _user) public view returns (uint256) {\r\n\t\treturn info.users[_user].balance;\r\n\t}\r\n\r\n\tfunction allowance(address _user, address _spender) public view returns (uint256) {\r\n\t\treturn info.users[_user].allowance[_spender];\r\n\t}\r\n\r\n\tfunction position() external view returns (uint256) {\r\n\t\treturn info.positionId;\r\n\t}\r\n\r\n\tfunction initialMarketCap() external view returns (string memory) {\r\n\t\treturn string(abi.encodePacked(_uint2str(info.initialMarketCap, 18, 5), \" ETH\"));\r\n\t}\r\n\r\n\tfunction upperMarketCap() external view returns (string memory) {\r\n\t\treturn string(abi.encodePacked(_uint2str(info.upperMarketCap, 18, 5), \" ETH\"));\r\n\t}\r\n\r\n\tfunction creatorFee() external view returns (string memory) {\r\n\t\treturn string(abi.encodePacked(_uint2str(info.creatorFee * 100, 3, 3), \"%\"));\r\n\t}\r\n\r\n\tfunction transferLimit() public view returns (uint256 limit, uint256 until, bool active) {\r\n\t\tlimit = info.transferLimit;\r\n\t\tuntil = info.transferLimitEnd;\r\n\t\tactive = limit \u003e 0 \u0026\u0026 block.timestamp \u003c until;\r\n\t}\r\n\r\n\tfunction website() external view returns (string memory) {\r\n\t\treturn info.website;\r\n\t}\r\n\r\n\tfunction twitter() external view returns (string memory) {\r\n\t\treturn info.twitter;\r\n\t}\r\n\r\n\tfunction telegram() external view returns (string memory) {\r\n\t\treturn info.telegram;\r\n\t}\r\n\r\n\tfunction discord() external view returns (string memory) {\r\n\t\treturn info.discord;\r\n\t}\r\n\r\n\tfunction additionalInfo() external view returns (string memory) {\r\n\t\treturn info.additionalInfo;\r\n\t}\r\n\r\n\r\n\tfunction _createLP(uint256 _initialMarketCap, uint256 _upperMarketCap, uint256 _creatorFee) internal {\r\n\t\tunchecked {\r\n\t\t\taddress _this = address(this);\r\n\t\t\taddress _weth = ROUTER.WETH9();\r\n\t\t\tbool _weth0 = _weth \u003c _this;\r\n\t\t\t(uint160 _initialSqrtPrice, ) = _getPriceAndTickFromValues(_weth0, totalSupply(), _initialMarketCap);\r\n\t\t\tinfo.pool = Factory(ROUTER.factory()).createPool(_this, _weth, 10000);\r\n\t\t\tPool(pool()).initialize(_initialSqrtPrice);\r\n\t\t\tPositionManager _pm = PositionManager(ROUTER.positionManager());\r\n\t\t\t_approve(_this, address(_pm), totalSupply());\r\n\t\t\t( , int24 _minTick) = _getPriceAndTickFromValues(_weth0, totalSupply(), _initialMarketCap);\r\n\t\t\t( , int24 _maxTick) = _getPriceAndTickFromValues(_weth0, totalSupply(), _upperMarketCap);\r\n\t\t\tif (_creatorFee \u003e 0) {\r\n\t\t\t\t_pm.mint(PositionManager.MintParams({\r\n\t\t\t\t\ttoken0: _weth0 ? _weth : _this,\r\n\t\t\t\t\ttoken1: !_weth0 ? _weth : _this,\r\n\t\t\t\t\tfee: 10000,\r\n\t\t\t\t\ttickLower: _weth0 ? _maxTick : _minTick,\r\n\t\t\t\t\ttickUpper: !_weth0 ? _maxTick : _minTick,\r\n\t\t\t\t\tamount0Desired: _weth0 ? 0 :  totalSupply() * _creatorFee / PERCENT_PRECISION,\r\n\t\t\t\t\tamount1Desired: !_weth0 ? 0 : totalSupply() * _creatorFee / PERCENT_PRECISION,\r\n\t\t\t\t\tamount0Min: 0,\r\n\t\t\t\t\tamount1Min: 0,\r\n\t\t\t\t\trecipient: creator(),\r\n\t\t\t\t\tdeadline: block.timestamp\r\n\t\t\t\t}));\r\n\t\t\t}\r\n\t\t\t(info.positionId, , , ) = _pm.mint(PositionManager.MintParams({\r\n\t\t\t\ttoken0: _weth0 ? _weth : _this,\r\n\t\t\t\ttoken1: !_weth0 ? _weth : _this,\r\n\t\t\t\tfee: 10000,\r\n\t\t\t\ttickLower: _weth0 ? _maxTick : _minTick,\r\n\t\t\t\ttickUpper: !_weth0 ? _maxTick : _minTick,\r\n\t\t\t\tamount0Desired: _weth0 ? 0 :  totalSupply() * (PERCENT_PRECISION - _creatorFee) / PERCENT_PRECISION,\r\n\t\t\t\tamount1Desired: !_weth0 ? 0 : totalSupply() * (PERCENT_PRECISION - _creatorFee) / PERCENT_PRECISION,\r\n\t\t\t\tamount0Min: 0,\r\n\t\t\t\tamount1Min: 0,\r\n\t\t\t\trecipient: _this,\r\n\t\t\t\tdeadline: block.timestamp\r\n\t\t\t}));\r\n\t\t\tif (_this.balance \u003e 0) {\r\n\t\t\t\tROUTER.exactInputSingle{value:_this.balance}(Router.ExactInputSingleParams({\r\n\t\t\t\t\ttokenIn: _weth,\r\n\t\t\t\t\ttokenOut: _this,\r\n\t\t\t\t\tfee: 10000,\r\n\t\t\t\t\trecipient: creator(),\r\n\t\t\t\t\tamountIn: _this.balance,\r\n\t\t\t\t\tamountOutMinimum: 0,\r\n\t\t\t\t\tsqrtPriceLimitX96: 0\r\n\t\t\t\t}));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tfunction _approve(address _owner, address _spender, uint256 _tokens) internal returns (bool) {\r\n\t\tinfo.users[_owner].allowance[_spender] = _tokens;\r\n\t\temit Approval(_owner, _spender, _tokens);\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tfunction _transfer(address _from, address _to, uint256 _tokens) internal returns (bool) {\r\n\t\tunchecked {\r\n\t\t\trequire(_tokens \u003e 0);\r\n\t\t\t(uint256 _limit, , bool _active) = transferLimit();\r\n\t\t\tif (_active) {\r\n\t\t\t\trequire(_tokens \u003c= _limit);\r\n\t\t\t}\r\n\t\t\trequire(balanceOf(_from) \u003e= _tokens);\r\n\t\t\tinfo.users[_from].balance -= _tokens;\r\n\t\t\tinfo.users[_to].balance += _tokens;\r\n\t\t\temit Transfer(_from, _to, _tokens);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tfunction _getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\r\n\t\tunchecked {\r\n\t\t\tuint256 absTick = tick \u003c 0 ? uint256(-int256(tick)) : uint256(int256(tick));\r\n\t\t\trequire(absTick \u003c= uint256(int256(MAX_TICK)), \u0027T\u0027);\r\n\r\n\t\t\tuint256 ratio = absTick \u0026 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\r\n\t\t\tif (absTick \u0026 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) \u003e\u003e 128;\r\n\t\t\tif (absTick \u0026 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) \u003e\u003e 128;\r\n\r\n\t\t\tif (tick \u003e 0) ratio = type(uint256).max / ratio;\r\n\r\n\t\t\tsqrtPriceX96 = uint160((ratio \u003e\u003e 32) + (ratio % (1 \u003c\u003c 32) == 0 ? 0 : 1));\r\n\t\t}\r\n\t}\r\n\r\n\tfunction _getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\r\n\t\tunchecked {\r\n\t\t\trequire(sqrtPriceX96 \u003e= MIN_SQRT_RATIO \u0026\u0026 sqrtPriceX96 \u003c MAX_SQRT_RATIO, \u0027R\u0027);\r\n\t\t\tuint256 ratio = uint256(sqrtPriceX96) \u003c\u003c 32;\r\n\r\n\t\t\tuint256 r = ratio;\r\n\t\t\tuint256 msb = 0;\r\n\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(5, gt(r, 0xFFFFFFFF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(4, gt(r, 0xFFFF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(3, gt(r, 0xFF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(2, gt(r, 0xF))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := shl(1, gt(r, 0x3))\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tlet f := gt(r, 0x1)\r\n\t\t\t\tmsb := or(msb, f)\r\n\t\t\t}\r\n\r\n\t\t\tif (msb \u003e= 128) r = ratio \u003e\u003e (msb - 127);\r\n\t\t\telse r = ratio \u003c\u003c (127 - msb);\r\n\r\n\t\t\tint256 log_2 = (int256(msb) - 128) \u003c\u003c 64;\r\n\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(63, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(62, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(61, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(60, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(59, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(58, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(57, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(56, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(55, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(54, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(53, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(52, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(51, f))\r\n\t\t\t\tr := shr(f, r)\r\n\t\t\t}\r\n\t\t\tassembly {\r\n\t\t\t\tr := shr(127, mul(r, r))\r\n\t\t\t\tlet f := shr(128, r)\r\n\t\t\t\tlog_2 := or(log_2, shl(50, f))\r\n\t\t\t}\r\n\r\n\t\t\tint256 log_sqrt10001 = log_2 * 255738958999603826347141;\r\n\r\n\t\t\tint24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) \u003e\u003e 128);\r\n\t\t\tint24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) \u003e\u003e 128);\r\n\r\n\t\t\ttick = tickLow == tickHi ? tickLow : _getSqrtRatioAtTick(tickHi) \u003c= sqrtPriceX96 ? tickHi : tickLow;\r\n\t\t}\r\n\t}\r\n\r\n\tfunction _sqrt(uint256 _n) internal pure returns (uint256 result) {\r\n\t\tunchecked {\r\n\t\t\tuint256 _tmp = (_n + 1) / 2;\r\n\t\t\tresult = _n;\r\n\t\t\twhile (_tmp \u003c result) {\r\n\t\t\t\tresult = _tmp;\r\n\t\t\t\t_tmp = (_n / _tmp + _tmp) / 2;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction _getPriceAndTickFromValues(bool _weth0, uint256 _tokens, uint256 _weth) internal pure returns (uint160 price, int24 tick) {\r\n\t\tuint160 _tmpPrice = uint160(_sqrt(2**192 / (!_weth0 ? _tokens : _weth) * (_weth0 ? _tokens : _weth)));\r\n\t\ttick = _getTickAtSqrtRatio(_tmpPrice);\r\n\t\ttick = tick - (tick % 200);\r\n\t\tprice = _getSqrtRatioAtTick(tick);\r\n\t}\r\n\r\n\tfunction _uint2str(uint256 _value, uint256 _scale, uint256 _maxDecimals) internal pure returns (string memory str) {\r\n\t\tuint256 _d = _scale \u003e _maxDecimals ? _maxDecimals : _scale;\r\n\t\tuint256 _n = _value / 10**(_scale \u003e _d ? _scale - _d : 0);\r\n\t\tif (_n == 0) {\r\n\t\t\treturn \"0\";\r\n\t\t}\r\n\t\tuint256 _digits = 1;\r\n\t\tuint256 _tmp = _n;\r\n\t\twhile (_tmp \u003e 9) {\r\n\t\t\t_tmp /= 10;\r\n\t\t\t_digits++;\r\n\t\t}\r\n\t\t_tmp = _digits \u003e _d ? _digits : _d + 1;\r\n\t\tuint256 _offset = (_tmp \u003e _d + 1 ? _tmp - _d - 1 \u003e _d ? _d : _tmp - _d - 1 : 0);\r\n\t\tfor (uint256 i = 0; i \u003c _tmp - _offset; i++) {\r\n\t\t\tuint256 _dec = i \u003c _tmp - _digits ? 0 : (_n / (10**(_tmp - i - 1))) % 10;\r\n\t\t\tbytes memory _char = new bytes(1);\r\n\t\t\t_char[0] = bytes1(uint8(_dec) + 48);\r\n\t\t\tstr = string(abi.encodePacked(str, string(_char)));\r\n\t\t\tif (i \u003c _tmp - _d - 1) {\r\n\t\t\t\tif ((i + 1) % 3 == (_tmp - _d) % 3) {\r\n\t\t\t\t\tstr = string(abi.encodePacked(str, \",\"));\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tif ((_n / 10**_offset) % 10**(_tmp - _offset - i - 1) == 0) {\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t} else if (i == _tmp - _d - 1) {\r\n\t\t\t\t\tstr = string(abi.encodePacked(str, \".\"));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"},"UniswapV3.sol":{"content":"// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.19;\r\n\r\nimport \"./Token.sol\";\r\n\r\ncontract Bakery {\r\n\r\n\tstruct Info {\r\n\t\tToken[] tokens;\r\n\t\tmapping(address =\u003e uint256) nonce;\r\n\t\taddress template;\r\n\t\taddress team;\r\n\t}\r\n\tInfo private info;\r\n\r\n\r\n\tevent NewToken(address indexed creator, address indexed token, bool proxy, string name, string symbol, uint256 totalSupply, uint256 initialMarketCap, uint256 upperMarketCap, uint256 creatorFee, uint256 transferLimit, uint256 transferLimitTime, uint256 value, uint256 launchTime);\r\n\r\n\r\n\tconstructor() {\r\n\t\tToken _template = new Token();\r\n\t\t_template.lock();\r\n\t\tinfo.template = address(_template);\r\n\t\tTeam _team = new Team();\r\n\t\t_team.initialize(msg.sender);\r\n\t\tinfo.team = address(_team);\r\n\t}\r\n\t\r\n\tfunction salt() public returns (bytes32) {\r\n\t\treturn keccak256(abi.encodePacked(msg.sender, info.nonce[msg.sender]++));\r\n\t}\r\n\r\n\tfunction launch(bool _deployProxy, string memory _name, string memory _symbol, uint256 _totalSupply, uint256 _initialMarketCap, uint256 _upperMarketCap, uint256 _creatorFee, uint256 _transferLimit, uint256 _transferLimitTime) external payable returns (address) {\r\n\t\tToken _token;\r\n\t\t{\r\n\t\t\tbytes32 _salt = salt();\r\n\t\t\tif (_deployProxy) {\r\n\t\t\t\taddress _proxy;\r\n\t\t\t\tbytes20 _template = bytes20(info.template);\r\n\t\t\t\tassembly {\r\n\t\t\t\t\tlet _clone := mload(0x40)\r\n\t\t\t\t\tmstore(_clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\r\n\t\t\t\t\tmstore(add(_clone, 0x14), _template)\r\n\t\t\t\t\tmstore(add(_clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\r\n\t\t\t\t\t_proxy := create2(0, _clone, 0x37, _salt)\r\n\t\t\t\t}\r\n\t\t\t\t_token = Token(_proxy);\r\n\t\t\t} else {\r\n\t\t\t\t_token = new Token{salt:_salt}();\r\n\t\t\t}\r\n\t\t}\r\n\t\t_token.initialize{value:msg.value}(msg.sender, _name, _symbol, _totalSupply, _initialMarketCap, _upperMarketCap, _creatorFee, _transferLimit, _transferLimitTime);\r\n\t\tinfo.tokens.push(_token);\r\n\t\temit NewToken(msg.sender, address(_token), _deployProxy, _name, _symbol, _totalSupply, _initialMarketCap, _upperMarketCap, _creatorFee, _transferLimit, _transferLimitTime, msg.value, block.timestamp);\r\n\t\treturn address(_token);\r\n\t}\r\n\r\n\r\n\tfunction template() public view returns (address) {\r\n\t\treturn info.template;\r\n\t}\r\n\r\n\tfunction teamTemplate() public view returns (address) {\r\n\t\treturn info.team;\r\n\t}\r\n\t\r\n\tfunction totalTokens() public view returns (uint256) {\r\n\t\treturn info.tokens.length;\r\n\t}\r\n\r\n\tfunction tokenAtIndex(uint256 _index) public view returns (Token) {\r\n\t\treturn info.tokens[_index];\r\n\t}\r\n\r\n\tfunction allTokens() public view returns (Token[] memory) {\r\n\t\treturn info.tokens;\r\n\t}\r\n}"}}