Verified contractExactMIT
CryptoJunkieToken
Address0xa26f25b09ef405a78361b3865d2136e804660ecc
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 200 runs
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,379,402
- Creation transaction
- 0xfbbb02c3ac…0dbe030e23
<stdin>
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
// CryptoJunkiePortal — Clanker-style launchpad for Ethereum mainnet.
//
// One transaction = ERC20 token + IPFS-pinned logo/metadata stored on-chain +
// a one-sided bonding-curve band opened in a Uniswap v4 pool, so the pool is
// discoverable by indexers the moment the tx mines.
//
// Everything is in one source file so the factory AND every token it creates
// verify against the same standard-json input (no import-path metadata drift).
interface IERC20 {
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address owner) external view returns (uint256);
}
interface IPoolManager {
struct PoolKey {
address currency0;
address currency1;
uint24 fee;
int24 tickSpacing;
address hooks;
}
struct ModifyLiquidityParams {
int24 tickLower;
int24 tickUpper;
int256 liquidityDelta;
bytes32 salt;
}
function initialize(PoolKey calldata key, uint160 sqrtPriceX96) external returns (int24);
function unlock(bytes calldata data) external returns (bytes memory);
function modifyLiquidity(
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (int256 callerDelta, int256 feesAccrued);
function sync(address currency) external;
function settle() external returns (uint256);
function take(address currency, address to, uint256 amount) external;
}
/// @notice minimal ERC20 carrying the launch metadata, Clanker-style:
/// image + metadata are on-chain strings (IPFS URIs) and admin-updatable.
contract CryptoJunkieToken {
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 public totalSupply;
address public admin;
string public image;
string public metadata;
string public context;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event ImageUpdated(string image);
event MetadataUpdated(string metadata);
error OnlyAdmin();
error InsufficientBalance();
error InsufficientAllowance();
constructor(
string memory name_,
string memory symbol_,
string memory image_,
string memory metadata_,
string memory context_,
address admin_,
uint256 supply_,
address recipient_
) {
name = name_;
symbol = symbol_;
image = image_;
metadata = metadata_;
context = context_;
admin = admin_;
totalSupply = supply_;
balanceOf[recipient_] = supply_;
emit Transfer(address(0), recipient_, supply_);
}
function transfer(address to, uint256 amount) external returns (bool) {
_move(msg.sender, to, amount);
return true;
}
function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) external returns (bool) {
uint256 a = allowance[from][msg.sender];
if (a != type(uint256).max) {
if (a < amount) revert InsufficientAllowance();
allowance[from][msg.sender] = a - amount;
}
_move(from, to, amount);
return true;
}
function setImage(string calldata newImage) external {
if (msg.sender != admin) revert OnlyAdmin();
image = newImage;
emit ImageUpdated(newImage);
}
function setMetadata(string calldata newMetadata) external {
if (msg.sender != admin) revert OnlyAdmin();
metadata = newMetadata;
emit MetadataUpdated(newMetadata);
}
function _move(address from, address to, uint256 amount) private {
uint256 b = balanceOf[from];
if (b < amount) revert InsufficientBalance();
unchecked {
balanceOf[from] = b - amount;
}
balanceOf[to] += amount;
emit Transfer(from, to, amount);
}
}
/// @notice launch factory: token + curve band + creator fee claim, all owned by you
contract CryptoJunkiePortal {
address public constant PM = 0x000000000004444c5dc75cB358380D2e3dE08A90;
uint256 public constant SUPPLY = 100_000_000_000 ether;
uint24 public constant FEE = 100;
int24 public constant SPACING = 200;
uint256 internal constant Q96 = 0x1000000000000000000000000;
address public owner;
uint256 public launchFee;
struct LaunchInfo {
address token;
address creator;
address paired;
bytes32 poolId;
int24 tickLower;
int24 tickUpper;
uint128 liquidity;
uint64 createdAt;
}
struct Params {
string name;
string symbol;
string image;
string metadata;
string context;
address paired;
uint160 sqrtPriceToken0; // sqrtPriceX96 of the pool when the new token is currency0
int24 anchorTick; // tick of that same price, token-c0 frame (multiple of SPACING)
int24 width; // band width in ticks (multiple of SPACING)
uint128 liquidityToken0; // liquidity to add when the new token is currency0
uint128 liquidityToken1; // liquidity to add when the new token is currency1
}
mapping(address => LaunchInfo) public launches;
address[] private _tokens;
event TokenCreated(
address indexed token,
address indexed creator,
address paired,
string name,
string symbol,
string image,
string metadata,
string context,
bytes32 poolId,
int24 tickLower,
int24 tickUpper,
uint128 liquidity
);
event FeeClaimed(address indexed token, address indexed creator, address currency, uint256 amount);
error FeeTooLow();
error BadBand();
error BadPair();
error BadPrice();
error OnlyOwner();
error OnlyPM();
error NotCreator();
error NotOneSided();
constructor(address owner_) {
owner = owner_;
}
receive() external payable {}
function setLaunchFee(uint256 fee) external {
if (msg.sender != owner) revert OnlyOwner();
launchFee = fee;
}
function withdrawFees() external {
if (msg.sender != owner) revert OnlyOwner();
(bool ok, ) = owner.call{value: address(this).balance}("");
require(ok, "send");
}
function tokenCount() external view returns (uint256) {
return _tokens.length;
}
function tokenAt(uint256 i) external view returns (address) {
return _tokens[i];
}
function poolIdOf(IPoolManager.PoolKey memory key) public pure returns (bytes32) {
return keccak256(abi.encode(key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks));
}
/// @notice deploy a token and open its one-sided curve band in one tx
function launch(Params calldata p) external payable returns (address token) {
if (msg.value < launchFee) revert FeeTooLow();
if (p.width <= 0 || p.width % SPACING != 0) revert BadBand();
if (p.anchorTick % SPACING != 0) revert BadBand();
if (p.liquidityToken0 == 0 && p.liquidityToken1 == 0) revert BadBand();
if (p.paired == address(0) || p.paired == address(this)) revert BadPair();
if (p.sqrtPriceToken0 < 1e18) revert BadPrice();
token = address(new CryptoJunkieToken(
p.name, p.symbol, p.image, p.metadata, p.context, msg.sender, SUPPLY, address(this)
));
bool tokenIsC0 = uint160(token) < uint160(p.paired);
address c0 = tokenIsC0 ? token : p.paired;
address c1 = tokenIsC0 ? p.paired : token;
IPoolManager.PoolKey memory key = IPoolManager.PoolKey(c0, c1, FEE, SPACING, address(0));
uint160 sqrtP = tokenIsC0
? p.sqrtPriceToken0
: uint160((Q96 * Q96) / uint256(p.sqrtPriceToken0));
int24 anchor = tokenIsC0 ? p.anchorTick : -p.anchorTick;
int24 lo = tokenIsC0 ? anchor : anchor - p.width;
int24 hi = tokenIsC0 ? anchor + p.width : anchor;
uint128 L = tokenIsC0 ? p.liquidityToken0 : p.liquidityToken1;
IPoolManager(PM).initialize(key, sqrtP);
IPoolManager(PM).unlock(abi.encode(uint8(0), token, key, lo, hi, L));
uint256 left = IERC20(token).balanceOf(address(this));
if (left > 0) IERC20(token).transfer(msg.sender, left);
bytes32 pid = poolIdOf(key);
launches[token] = LaunchInfo(token, msg.sender, p.paired, pid, lo, hi, L, uint64(block.timestamp));
_tokens.push(token);
emit TokenCreated(
token, msg.sender, p.paired, p.name, p.symbol, p.image, p.metadata, p.context,
pid, lo, hi, L
);
}
/// @notice creator claims the paired-token fees the band has earned
function collect(address token) external returns (uint256 amount0, uint256 amount1) {
LaunchInfo memory info = launches[token];
if (info.creator != msg.sender) revert NotCreator();
IPoolManager.PoolKey memory key = _keyOf(info);
return abi.decode(
IPoolManager(PM).unlock(abi.encode(uint8(1), key, info.tickLower, info.tickUpper, msg.sender)),
(uint256, uint256)
);
}
function unlockCallback(bytes calldata data) external returns (bytes memory) {
if (msg.sender != PM) revert OnlyPM();
uint8 mode = abi.decode(data, (uint8));
if (mode == 0) {
(address token, IPoolManager.PoolKey memory key, int24 lo, int24 hi, uint128 L) =
abi.decode(data[32:], (address, IPoolManager.PoolKey, int24, int24, uint128));
(int256 d0, ) = IPoolManager(PM).modifyLiquidity(
key,
IPoolManager.ModifyLiquidityParams(lo, hi, int256(uint256(L)), bytes32(0)),
""
);
int128 a0 = int128(uint128(uint256(d0 >> 128)));
int128 a1 = int128(uint128(uint256(d0)));
if (a0 < 0 && a1 < 0) revert NotOneSided();
if (a0 < 0) _pay(key.currency0, token, uint128(-a0));
if (a1 < 0) _pay(key.currency1, token, uint128(-a1));
return "";
}
(IPoolManager.PoolKey memory key, int24 lo, int24 hi, address to) =
abi.decode(data[32:], (IPoolManager.PoolKey, int24, int24, address));
(int256 d0, ) = IPoolManager(PM).modifyLiquidity(
key,
IPoolManager.ModifyLiquidityParams(lo, hi, 0, bytes32(0)),
""
);
uint256 out0 = uint256(uint128(uint256(d0 >> 128)));
uint256 out1 = uint256(uint128(uint256(d0)));
if (out0 > 0) IPoolManager(PM).take(key.currency0, to, out0);
if (out1 > 0) IPoolManager(PM).take(key.currency1, to, out1);
return abi.encode(out0, out1);
}
function _pay(address currency, address token, uint128 amount) private {
if (currency != token) revert NotOneSided();
IPoolManager pm = IPoolManager(PM);
pm.sync(currency);
require(IERC20(currency).transfer(address(pm), uint256(amount)), "pay");
pm.settle();
}
function _keyOf(LaunchInfo memory info) private pure returns (IPoolManager.PoolKey memory) {
bool tokenIsC0 = uint160(info.token) < uint160(info.paired);
return IPoolManager.PoolKey(
tokenIsC0 ? info.token : info.paired,
tokenIsC0 ? info.paired : info.token,
FEE, SPACING, address(0)
);
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.