Verified contractExactMIT
TokenFactory
Address0xbc1993889e992835b35708bb50e99ed2871ece24
- Balance
0 ETH
- Transactions
13
- Compiler
solc 0.8.31
- Same code
Only this contract
Details
- Compiler
- solc 0.8.31+commit.fd3a2265
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,154,289
- Creation transaction
- 0xdc3a82ab09…95fa42bd3d
contracts/TokenFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./StandardToken.sol";
import "./interfaces/IUniswapV3Factory.sol";
import "./interfaces/IUniswapV3Pool.sol";
import "./interfaces/INonfungiblePositionManager.sol";
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "Reentrant");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
interface IWETH9 {
function deposit() external payable;
function withdraw(uint256) external;
function approve(address spender, uint256 amount) external returns (bool);
function balanceOf(address owner) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
}
interface ISwapRouter {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}
interface ILockerHelper {
function registerTokenInfo(
uint256 positionId,
address token,
address creator,
address pool,
bool autoLock
) external;
}
/**
* @title TokenFactory
* @dev Token factory for Ethereum Mainnet using Uniswap V3
* Deploys tokens with one-sided liquidity at target market caps
*/
contract TokenFactory is ReentrancyGuard {
// Ethereum Mainnet Uniswap V3 Addresses
address public constant UNISWAP_V3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
address public constant POSITION_MANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88;
address public constant SWAP_ROUTER = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;
address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address public constant WETH_USDC_POOL = 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640; // 0.05% fee tier
uint256 public constant LOCK_DURATION = 10 * 365 days;
uint24 public constant POOL_FEE = 10000; // 1% fee tier
uint256 public deploymentFee = 0.015 ether;
uint256 public constant MIN_SUPPLY = 1_000_000 * 10**18;
uint256 public constant MAX_SUPPLY = 1_000_000_000_000 * 10**18;
uint256 public constant MIN_DEV_BUY = 0.001 ether;
uint256 public constant MAX_DEV_BUY = 1 ether;
uint256 public constant MCAP_OPTION_1 = 4000 * 10**18; // Degen
uint256 public constant MCAP_OPTION_2 = 8000 * 10**18; // Standard
uint256 public constant MCAP_OPTION_3 = 12000 * 10**18; // Safe
uint256 public constant MCAP_OPTION_4 = 16000 * 10**18; // Conservative
address public owner;
address public factoryWallet;
address public lockerHelper;
bool public autoSendToLocker;
mapping(address => TokenInfo) public tokenInfo;
mapping(address => TokenMetadata) public tokenMetadata;
mapping(address => address[]) public creatorTokens;
address[] public allTokens;
uint256 public totalPlatformFeesCollected;
uint256 public totalTradingFeesDistributed;
uint256 public totalCreatorFeesDistributed;
uint256 public totalFactoryFeesDistributed;
uint256 public totalDevBuyVolume;
mapping(address => uint256) public tokenToPositionId;
mapping(uint256 => address) public positionIdToToken;
mapping(address => uint256) public tokenToLockId;
mapping(uint256 => address) public lockIdToToken;
enum DeploymentMethod {
ONESIDED_4K,
ONESIDED_8K,
ONESIDED_12K,
ONESIDED_16K
}
struct TokenInfo {
address creator;
address pool;
uint256 positionId;
uint256 lockId;
uint256 createdAt;
uint256 liquidityETH;
uint256 totalSupply;
uint256 initialMcap;
string name;
string symbol;
DeploymentMethod deployMethod;
bool feesCollected;
uint256 devBuyAmount;
}
struct TokenMetadata {
string imageUrl;
string description;
string website;
string twitter;
string telegram;
}
event TokenDeployed(
address indexed token,
address indexed creator,
address pool,
uint256 positionId,
DeploymentMethod deployMethod,
uint256 devBuyAmount
);
event DevBuyExecuted(
address indexed token,
address indexed buyer,
uint256 ethAmount,
uint256 tokenAmount
);
event DeploymentFeeChanged(
uint256 oldFee,
uint256 newFee
);
event PositionLocked(
address indexed token,
uint256 positionId,
uint256 lockId
);
event FeesCollected(
uint256 indexed positionId,
address indexed token,
uint256 amount0,
uint256 amount1
);
event FeesDistributed(
address indexed creator,
uint256 creatorShare,
uint256 factoryShare
);
modifier onlyOwner() {
require(msg.sender == owner, "!owner");
_;
}
constructor() {
owner = msg.sender;
factoryWallet = 0x4C077f7D5c39514778b615D72c64097FFec32F64;
lockerHelper = address(0);
autoSendToLocker = false;
}
function deployToken(
string memory name,
string memory symbol,
uint256 totalSupply,
uint256 targetMarketCap,
uint256 devBuyAmount,
TokenMetadata memory metadata
) external payable nonReentrant returns (address token, address pool, uint256 positionId) {
_validateDeployment(name, symbol, totalSupply, targetMarketCap);
uint256 totalRequired = deploymentFee + devBuyAmount;
require(msg.value >= totalRequired, "!payment");
if (devBuyAmount > 0) {
require(devBuyAmount >= MIN_DEV_BUY, "!min");
require(devBuyAmount <= MAX_DEV_BUY, "!max");
}
token = address(new StandardToken(name, symbol, totalSupply, address(this)));
tokenMetadata[token] = metadata;
pool = _createPoolWithMcap(token, totalSupply, targetMarketCap);
positionId = _mintAndStorePosition(token, pool, totalSupply, targetMarketCap, devBuyAmount, name, symbol);
if (devBuyAmount > 0) {
uint256 tokensBought = _executeDevBuy(token, devBuyAmount);
emit DevBuyExecuted(token, msg.sender, devBuyAmount, tokensBought);
totalDevBuyVolume += devBuyAmount;
}
totalPlatformFeesCollected += deploymentFee;
uint256 excess = msg.value - totalRequired;
if (excess > 0) {
(bool refunded, ) = msg.sender.call{value: excess}("");
require(refunded, "!refund");
}
emit TokenDeployed(token, msg.sender, pool, positionId, _getDeploymentMethod(targetMarketCap), devBuyAmount);
return (token, pool, positionId);
}
function _executeDevBuy(address token, uint256 ethAmount) private returns (uint256) {
IWETH9(WETH).deposit{value: ethAmount}();
IWETH9(WETH).approve(SWAP_ROUTER, ethAmount);
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: WETH,
tokenOut: token,
fee: POOL_FEE,
recipient: msg.sender,
amountIn: ethAmount,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
});
uint256 tokenAmount = ISwapRouter(SWAP_ROUTER).exactInputSingle(params);
return tokenAmount;
}
function _mintAndStorePosition(
address token,
address pool,
uint256 totalSupply,
uint256 targetMarketCap,
uint256 devBuyAmount,
string memory name,
string memory symbol
) private returns (uint256 positionId) {
address mintTo = (autoSendToLocker && lockerHelper != address(0)) ? lockerHelper : address(this);
positionId = _addOneSidedLiquidity(token, pool, totalSupply, targetMarketCap, mintTo);
_storeTokenInfo(token, pool, positionId, totalSupply, targetMarketCap, devBuyAmount, name, symbol);
_storeMappings(token, positionId);
if (mintTo == lockerHelper) {
_handleLockerRegistration(token, pool, positionId);
}
return positionId;
}
function _storeMappings(address token, uint256 positionId) private {
tokenToPositionId[token] = positionId;
positionIdToToken[positionId] = token;
creatorTokens[msg.sender].push(token);
allTokens.push(token);
}
function _storeTokenInfo(
address token,
address pool,
uint256 positionId,
uint256 totalSupply,
uint256 targetMarketCap,
uint256 devBuyAmount,
string memory name,
string memory symbol
) private {
TokenInfo storage info = tokenInfo[token];
info.creator = msg.sender;
info.pool = pool;
info.positionId = positionId;
info.lockId = 0;
info.createdAt = block.timestamp;
info.liquidityETH = 0;
info.totalSupply = totalSupply;
info.initialMcap = targetMarketCap;
info.name = name;
info.symbol = symbol;
info.deployMethod = _getDeploymentMethod(targetMarketCap);
info.feesCollected = false;
info.devBuyAmount = devBuyAmount;
}
function _handleLockerRegistration(address token, address pool, uint256 positionId) private {
ILockerHelper(lockerHelper).registerTokenInfo(
positionId,
token,
msg.sender,
pool,
true
);
uint256 lockId = positionId + 2000000;
tokenInfo[token].lockId = lockId;
tokenToLockId[token] = lockId;
lockIdToToken[lockId] = token;
}
function _validateDeployment(
string memory name,
string memory symbol,
uint256 totalSupply,
uint256 targetMarketCap
) private pure {
require(totalSupply >= MIN_SUPPLY && totalSupply <= MAX_SUPPLY, "!supply");
require(
targetMarketCap == MCAP_OPTION_1 ||
targetMarketCap == MCAP_OPTION_2 ||
targetMarketCap == MCAP_OPTION_3 ||
targetMarketCap == MCAP_OPTION_4,
"Invalid market cap"
);
require(bytes(name).length > 0 && bytes(name).length <= 50, "!name");
require(bytes(symbol).length > 0 && bytes(symbol).length <= 10, "!symbol");
}
function _getDeploymentMethod(uint256 targetMarketCap) private pure returns (DeploymentMethod) {
if (targetMarketCap == MCAP_OPTION_1) {
return DeploymentMethod.ONESIDED_4K;
} else if (targetMarketCap == MCAP_OPTION_2) {
return DeploymentMethod.ONESIDED_8K;
} else if (targetMarketCap == MCAP_OPTION_3) {
return DeploymentMethod.ONESIDED_12K;
} else {
return DeploymentMethod.ONESIDED_16K;
}
}
function markAsLocked(address token) external {
TokenInfo storage info = tokenInfo[token];
require(info.positionId != 0, "!deployed");
require(info.lockId == 0, "!locked");
require(msg.sender == owner || msg.sender == info.creator, "!auth");
uint256 lockId = info.positionId + 1000000;
info.lockId = lockId;
tokenToLockId[token] = lockId;
lockIdToToken[lockId] = token;
emit PositionLocked(token, info.positionId, lockId);
}
function collectAndDistributeFees(uint256 positionId) external nonReentrant {
address token = positionIdToToken[positionId];
require(token != address(0), "!position");
TokenInfo storage info = tokenInfo[token];
INonfungiblePositionManager positionManager = INonfungiblePositionManager(POSITION_MANAGER);
INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({
tokenId: positionId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
(uint256 amount0, uint256 amount1) = positionManager.collect(params);
uint256 wethAmount = 0;
IUniswapV3Pool poolContract = IUniswapV3Pool(info.pool);
address token0 = poolContract.token0();
if (token0 == WETH) {
wethAmount = amount0;
} else {
wethAmount = amount1;
}
if (wethAmount > 0) {
IWETH9(WETH).withdraw(wethAmount);
uint256 creatorShare = wethAmount / 2;
uint256 platformShare = wethAmount - creatorShare;
if (creatorShare > 0) {
(bool sentCreator, ) = info.creator.call{value: creatorShare}("");
require(sentCreator, "!creator");
totalCreatorFeesDistributed += creatorShare;
}
address platformWallet = 0x4C077f7D5c39514778b615D72c64097FFec32F64;
if (platformShare > 0) {
(bool sentPlatform, ) = platformWallet.call{value: platformShare}("");
require(sentPlatform, "!platform");
totalFactoryFeesDistributed += platformShare;
}
totalTradingFeesDistributed += wethAmount;
emit FeesDistributed(info.creator, creatorShare, platformShare);
}
emit FeesCollected(positionId, token, amount0, amount1);
}
function getCreatorTokens(address creator) external view returns (address[] memory) {
return creatorTokens[creator];
}
function getCurrentETHPrice() public view returns (uint256) {
IUniswapV3Pool pool = IUniswapV3Pool(WETH_USDC_POOL);
(uint160 sqrtPriceX96,,,,,,) = pool.slot0();
// On Ethereum: USDC is token0, WETH is token1
// sqrtPriceX96 = sqrt(WETH/USDC), but we need USDC/WETH (USD per ETH)
// So we need to invert: price = 1 / (sqrtPriceX96^2 / 2^192)
// = 2^192 / sqrtPriceX96^2
// Then adjust for decimals: USDC has 6, WETH has 18
// Final: (2^192 * 10^6) / (sqrtPriceX96^2) * 10^18 / 10^18
uint256 sqrtPriceSq = uint256(sqrtPriceX96) * uint256(sqrtPriceX96);
// Price = (2^192 * 10^18 * 10^12) / sqrtPriceSq
// The 10^12 adjusts for USDC 6 decimals vs WETH 18 decimals
uint256 price = (uint256(2**192) * 10**12) / sqrtPriceSq;
return price * 10**18;
}
function _calculateMcapSqrtPrice(bool wethIsToken0, uint256 totalSupply, uint256 marketCap) private view returns (uint160) {
uint256 ethPriceUSD = getCurrentETHPrice();
if (ethPriceUSD < 100 * 10**18 || ethPriceUSD > 100000 * 10**18) {
ethPriceUSD = 3000 * 10**18;
}
uint256 marketCapInETH = (marketCap * 10**18) / ethPriceUSD;
uint160 sqrtPriceX96;
if (wethIsToken0) {
uint256 sqrtSupply = _sqrt(totalSupply);
uint256 sqrtMarketCapETH = _sqrt(marketCapInETH);
sqrtPriceX96 = uint160((sqrtSupply * 2**96) / sqrtMarketCapETH);
} else {
uint256 sqrtMarketCapETH = _sqrt(marketCapInETH);
uint256 sqrtSupply = _sqrt(totalSupply);
sqrtPriceX96 = uint160((sqrtMarketCapETH * 2**96) / sqrtSupply);
}
return sqrtPriceX96;
}
function _sqrt(uint256 x) private pure returns (uint256) {
if (x == 0) return 0;
uint256 z = (x + 1) / 2;
uint256 y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
return y;
}
function _createPoolWithMcap(address token, uint256 totalSupply, uint256 targetMcap) private returns (address pool) {
IUniswapV3Factory factory = IUniswapV3Factory(UNISWAP_V3_FACTORY);
(address token0, address token1) = token < WETH ? (token, WETH) : (WETH, token);
pool = factory.getPool(token0, token1, POOL_FEE);
if (pool == address(0)) {
pool = factory.createPool(token0, token1, POOL_FEE);
uint160 sqrtPriceX96 = _calculateMcapSqrtPrice(token0 == WETH, totalSupply, targetMcap);
IUniswapV3Pool(pool).initialize(sqrtPriceX96);
}
return pool;
}
function _addOneSidedLiquidity(address token, address pool, uint256 totalSupply, uint256 targetMarketCap, address mintTo) private returns (uint256 positionId) {
StandardToken(token).approve(POSITION_MANAGER, totalSupply);
(
int24 tickLower,
int24 tickUpper,
uint256 amount0Desired,
uint256 amount1Desired
) = _prepareOneSidedParams(token, pool, totalSupply, targetMarketCap);
(address token0, address token1) = token < WETH ? (token, WETH) : (WETH, token);
positionId = _mintPosition(
token0,
token1,
tickLower,
tickUpper,
amount0Desired,
amount1Desired,
mintTo
);
return positionId;
}
function _prepareOneSidedParams(address token, address pool, uint256 totalSupply, uint256 targetMarketCap)
private
view
returns (int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired)
{
(, int24 currentTick, , , , , ) = IUniswapV3Pool(pool).slot0();
bool tokenIsToken0 = token < WETH;
int24 tickSpacing = 200;
int24 OPTIMIZED_TICK_RANGE = _getOptimalTickRange(totalSupply, targetMarketCap);
if (tokenIsToken0) {
tickLower = ((currentTick / tickSpacing) * tickSpacing) + tickSpacing;
tickUpper = tickLower + OPTIMIZED_TICK_RANGE;
if (tickUpper > 887272) {
tickUpper = 887272;
}
amount0Desired = totalSupply;
amount1Desired = 0;
} else {
tickUpper = ((currentTick / tickSpacing) * tickSpacing) - tickSpacing;
tickLower = tickUpper - OPTIMIZED_TICK_RANGE;
if (tickLower < -887272) {
tickLower = -887272;
}
amount0Desired = 0;
amount1Desired = totalSupply;
}
}
function _getOptimalTickRange(uint256 totalSupply, uint256 targetMcap)
private
pure
returns (int24)
{
int24 tickRange;
if (totalSupply >= 500_000_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 460000;
else if (targetMcap == MCAP_OPTION_2) tickRange = 430000;
else if (targetMcap == MCAP_OPTION_3) tickRange = 400000;
else tickRange = 368000;
} else if (totalSupply >= 100_000_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 383000;
else if (targetMcap == MCAP_OPTION_2) tickRange = 358000;
else if (targetMcap == MCAP_OPTION_3) tickRange = 333000;
else tickRange = 306600;
} else if (totalSupply >= 10_000_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 307000;
else if (targetMcap == MCAP_OPTION_2) tickRange = 286600;
else if (targetMcap == MCAP_OPTION_3) tickRange = 266000;
else tickRange = 245400;
} else if (totalSupply >= 1_000_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 230000;
else if (targetMcap == MCAP_OPTION_2) tickRange = 215000;
else if (targetMcap == MCAP_OPTION_3) tickRange = 200000;
else tickRange = 184000;
} else if (totalSupply >= 100_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 153500;
else if (targetMcap == MCAP_OPTION_2) tickRange = 143300;
else if (targetMcap == MCAP_OPTION_3) tickRange = 133000;
else tickRange = 122700;
} else if (totalSupply >= 10_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 115000;
else if (targetMcap == MCAP_OPTION_2) tickRange = 107500;
else if (targetMcap == MCAP_OPTION_3) tickRange = 100000;
else tickRange = 92000;
} else if (totalSupply >= 5_000_000 * 10**18) {
if (targetMcap == MCAP_OPTION_1) tickRange = 96200;
else if (targetMcap == MCAP_OPTION_2) tickRange = 90000;
else if (targetMcap == MCAP_OPTION_3) tickRange = 83500;
else tickRange = 77000;
} else {
if (targetMcap == MCAP_OPTION_1) tickRange = 76800;
else if (targetMcap == MCAP_OPTION_2) tickRange = 71600;
else if (targetMcap == MCAP_OPTION_3) tickRange = 66500;
else tickRange = 61400;
}
return tickRange;
}
function _mintPosition(
address token0,
address token1,
int24 tickLower,
int24 tickUpper,
uint256 amount0Desired,
uint256 amount1Desired,
address mintTo
) private returns (uint256 positionId) {
INonfungiblePositionManager positionManager = INonfungiblePositionManager(POSITION_MANAGER);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({
token0: token0,
token1: token1,
fee: POOL_FEE,
tickLower: tickLower,
tickUpper: tickUpper,
amount0Desired: amount0Desired,
amount1Desired: amount1Desired,
amount0Min: 0,
amount1Min: 0,
recipient: mintTo,
deadline: block.timestamp + 300
});
(positionId, , , ) = positionManager.mint(params);
}
function setFactoryWallet(address _factoryWallet) external onlyOwner {
factoryWallet = _factoryWallet;
}
function setLockerHelper(address _lockerHelper) external onlyOwner {
lockerHelper = _lockerHelper;
}
function setAutoSendToLocker(bool _autoSend) external onlyOwner {
autoSendToLocker = _autoSend;
}
function setDeploymentFee(uint256 _newFee) external onlyOwner {
require(_newFee <= 0.1 ether, "!fee");
uint256 oldFee = deploymentFee;
deploymentFee = _newFee;
emit DeploymentFeeChanged(oldFee, _newFee);
}
function withdrawETH() external onlyOwner nonReentrant {
uint256 balance = address(this).balance;
require(balance > 0, "!balance");
payable(owner).transfer(balance);
}
function withdrawToken(address tokenAddress, uint256 amount) external onlyOwner nonReentrant {
IERC20(tokenAddress).transfer(owner, amount);
}
function getAllTokens() external view returns (address[] memory) {
return allTokens;
}
function getPlatformStats() external view returns (
uint256 totalTokens,
uint256 platformFeesCollected,
uint256 tradingFeesDistributed,
uint256 creatorFeesDistributed,
uint256 factoryFeesDistributed,
uint256 totalValueLocked
) {
totalTokens = allTokens.length;
platformFeesCollected = totalPlatformFeesCollected;
tradingFeesDistributed = totalTradingFeesDistributed;
creatorFeesDistributed = totalCreatorFeesDistributed;
factoryFeesDistributed = totalFactoryFeesDistributed;
uint256 tvl = 0;
for (uint256 i = 0; i < allTokens.length; i++) {
TokenInfo memory info = tokenInfo[allTokens[i]];
tvl += info.liquidityETH;
}
totalValueLocked = tvl;
}
function getAllTokenInfo() external view returns (
address[] memory tokens,
TokenInfo[] memory infos,
TokenMetadata[] memory metadatas
) {
uint256 length = allTokens.length;
tokens = new address[](length);
infos = new TokenInfo[](length);
metadatas = new TokenMetadata[](length);
for (uint256 i = 0; i < length; i++) {
address tokenAddr = allTokens[i];
tokens[i] = tokenAddr;
infos[i] = tokenInfo[tokenAddr];
metadatas[i] = tokenMetadata[tokenAddr];
}
return (tokens, infos, metadatas);
}
function getAllTokenInfoPaginated(uint256 offset, uint256 limit) external view returns (
address[] memory tokens,
TokenInfo[] memory infos,
TokenMetadata[] memory metadatas,
uint256 total
) {
total = allTokens.length;
uint256 end = offset + limit;
if (end > total) {
end = total;
}
uint256 actualLength = end > offset ? end - offset : 0;
tokens = new address[](actualLength);
infos = new TokenInfo[](actualLength);
metadatas = new TokenMetadata[](actualLength);
for (uint256 i = 0; i < actualLength; i++) {
address tokenAddr = allTokens[offset + i];
tokens[i] = tokenAddr;
infos[i] = tokenInfo[tokenAddr];
metadatas[i] = tokenMetadata[tokenAddr];
}
return (tokens, infos, metadatas, total);
}
function getTokenDetails(address token) external view returns (TokenInfo memory) {
TokenInfo memory info = tokenInfo[token];
require(info.creator != address(0), "!token");
return info;
}
function getTokenMetadata(address token) external view returns (
string memory imageUrl,
string memory description,
string memory website,
string memory twitter,
string memory telegram
) {
TokenMetadata memory metadata = tokenMetadata[token];
return (
metadata.imageUrl,
metadata.description,
metadata.website,
metadata.twitter,
metadata.telegram
);
}
function getLockInfo(address token) external view returns (
uint256 lockId,
uint256 unlockDate,
address lockOwner,
address collectAddress
) {
lockId = tokenToLockId[token];
if (lockId == 0) {
return (0, 0, address(0), address(0));
}
return (lockId, type(uint256).max, address(this), address(this));
}
receive() external payable {}
}
contracts/StandardToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, 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);
}
/**
* @title StandardToken
* @dev Standard ERC20 token with fixed supply for Ethereum Mainnet
* Implements IERC20 interface for better compatibility
*/
contract StandardToken is IERC20 {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string public name;
string public symbol;
uint8 public constant decimals = 18;
// Maximum supply cap (1 trillion tokens with 18 decimals)
uint256 public constant MAX_SUPPLY = 1_000_000_000_000 * 10**18;
constructor(
string memory _name,
string memory _symbol,
uint256 _supply,
address _initialHolder
) {
require(_initialHolder != address(0), "Initial holder cannot be zero address");
require(_supply > 0, "Supply must be greater than 0");
require(_supply <= MAX_SUPPLY, "Supply exceeds maximum");
require(bytes(_name).length > 0, "Name cannot be empty");
require(bytes(_symbol).length > 0, "Symbol cannot be empty");
name = _name;
symbol = _symbol;
_totalSupply = _supply;
_balances[_initialHolder] = _supply;
emit Transfer(address(0), _initialHolder, _supply);
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public override returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
uint256 currentAllowance = _allowances[from][msg.sender];
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(from, msg.sender, currentAllowance - amount);
}
}
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
address owner = msg.sender;
_approve(owner, spender, _allowances[owner][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
address owner = msg.sender;
uint256 currentAllowance = _allowances[owner][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(address from, address to, uint256 amount) internal {
require(from != address(0), "ERC20: transfer from zero address");
require(to != address(0), "ERC20: transfer to zero address");
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
}
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from zero address");
require(spender != address(0), "ERC20: approve to zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contracts/interfaces/INonfungiblePositionManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface INonfungiblePositionManager {
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
function mint(MintParams calldata params)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
function increaseLiquidity(IncreaseLiquidityParams calldata params)
external
payable
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
function collect(CollectParams calldata params)
external
payable
returns (uint256 amount0, uint256 amount1);
// Position query functions
function positions(uint256 tokenId)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
// ERC721 functions
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function transferFrom(address from, address to, uint256 tokenId) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool approved) external;
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address owner) external view returns (uint256);
}contracts/interfaces/IUniswapV3Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IUniswapV3Factory {
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
function getPool(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address pool);
}contracts/interfaces/IUniswapV3Pool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IUniswapV3Pool {
function initialize(uint160 sqrtPriceX96) external;
function token0() external view returns (address);
function token1() external view returns (address);
function fee() external view returns (uint24);
function tickSpacing() external view returns (int24);
function liquidity() external view returns (uint128);
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
// Additional functions that might be useful
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}
// Callback interface for swaps
interface IUniswapV3SwapCallback {
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.