Launchpad4663Pool
0xc0d33a72a4660cd5cd02847714beba726f18cbda
Verification
Verified
v0.8.26+commit.8a97fa7a
Type
Contract
13,826 bytes
ABI entries
38
24 read · 6 write
License
none
Contract information
- Address
- 0xc0d33a72a4660cd5cd02847714beba726f18cbda
- Chain
- Robinhood Chain (4663)
- Compiler
- v0.8.26+commit.8a97fa7a
- Optimization
- Enabled
- Creator
- 0xE5cF73F96F…727A2FAb04
- Creation tx
- 0xb6d3228619…2ffe4cf33d
Token
Not a token
This contract does not expose ERC-20 metadata.
Read contract (24)
FEE_TIER() → uint24
INITIAL_BUY() → uint256
SUPPLY_TOTAL() → uint256
VP_PER_ETH() → uint256
feeWallet() → address
getToken(uint256) → tuple
idOfPool(address) → uint256
idOfToken(address) → uint256
launchCost() → uint256
pendingName() → string
pendingSymbol() → string
platformFeesEth() → uint256
platformStats() → uint256, uint256, uint256, uint256
poolOf(uint256) → address
predictToken(bytes32) → address
sponsorFloat() → uint256
tokenCount() → uint256
tokenInitCodeHash() → bytes32
tokens(uint256) → address, address, address, bool, uint256, uint256
totalVolumeEth() → uint256
traderVolume(address) → uint256
uniFactory() → address
vpOf(address) → uint256
weth() → address
Events (6)
BoughtFeesCollectedInitialBuySkippedPoolCreatedSoldTokenCreated
ABI
[
{
"inputs": [
{
"internalType": "address",
"name": "feeWallet_",
"type": "address"
},
{
"internalType": "address",
"name": "uniFactory_",
"type": "address"
},
{
"internalType": "address",
"name": "weth_",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "buyer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "ethIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokensOut",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newSold",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newReserve",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "spot",
"type": "uint256"
}
],
"name": "Bought",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "wethAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokenAmount",
"type": "uint256"
}
],
"name": "FeesCollected",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "InitialBuySkipped",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "pool",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "tokenIsToken0",
"type": "bool"
}
],
"name": "PoolCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "seller",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokensIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "ethOut",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newSold",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newReserve",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "spot",
"type": "uint256"
}
],
"name": "Sold",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "creator",
"type": "address"
},
{
"indexed": false,
"internalType": "string",
"name": "name",
"type": "string"
},
{
"indexed": false,
"internalType": "string",
"name": "symbol",
"type": "string"
}
],
"name": "TokenCreated",
"type": "event"
},
{
"inputs": [],
"name": "FEE_TIER",
"outputs": [
{
"internalType": "uint24",
"name": "",
"type": "uint24"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "INITIAL_BUY",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "SUPPLY_TOTAL",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VP_PER_ETH",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minTokensOut",
"type": "uint256"
}
],
"name": "buy",
"outputs": [
{
"internalType": "uint256",
"name": "out",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "collectFees",
"outputs": [
{
"internalType": "uint256",
"name": "wethAmt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenAmt",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "n",
"type": "string"
},
{
"internalType": "string",
"name": "s",
"type": "string"
},
{
"internalType": "bytes32",
"name": "salt",
"type": "bytes32"
}
],
"name": "createToken",
"outputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "pool",
"type": "address"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "feeWallet",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "getToken",
"outputs": [
{
"components": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "address",
"name": "creator",
"type": "address"
},
{
"internalType": "uint256",
"name": "curveSold",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserve",
"type": "uint256"
},
{
"internalType": "bool",
"name": "graduated",
"type": "bool"
},
{
"internalType": "bool",
"name": "liquidityClaimed",
"type": "bool"
},
{
"internalType": "uint256",
"name": "spot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "curveProgressBps",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "marketCapWei",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "volumeEth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "createdAt",
"type": "uint256"
}
],
"internalType": "struct Launchpad4663Pool.TokenView",
"name": "v",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "idOfPool",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "idOfToken",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "launchCost",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "pendingName",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pendingSymbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "platformFeesEth",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "platformStats",
"outputs": [
{
"internalType": "uint256",
"name": "tokens_",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "volume",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "fees",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "vpIssued",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "poolOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "salt",
"type": "bytes32"
}
],
"name": "predictToken",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokensIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minEthOut",
"type": "uint256"
}
],
"name": "sell",
"outputs": [
{
"internalType": "uint256",
"name": "ethOut",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "sponsorFloat",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenCount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenInitCodeHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "tokens",
"outputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "pool",
"type": "address"
},
{
"internalType": "address",
"name": "creator",
"type": "address"
},
{
"internalType": "bool",
"name": "tokenIsToken0",
"type": "bool"
},
{
"internalType": "uint256",
"name": "createdAt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "volumeEth",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalVolumeEth",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "traderVolume",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "uniFactory",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount0Owed",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount1Owed",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "uniswapV3MintCallback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "amount0Delta",
"type": "int256"
},
{
"internalType": "int256",
"name": "amount1Delta",
"type": "int256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "uniswapV3SwapCallback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "who",
"type": "address"
}
],
"name": "vpOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "weth",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]Source code
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/*
──────────────────────────────────────────────────────────────────────────────
4 - 6 - 6 - 3 . f u n · POOL LAUNCH · Robinhood Chain (4663)
Noxa/Clanker-style: every token launches DIRECTLY into a real Uniswap V3
pool with single-sided concentrated liquidity. Visible on DexScreener from
the first trade. No bonding curve, no graduation.
• 1,000,000,000 fixed supply · NO creator premine (nobody gets free tokens)
• Entire supply seeded single-sided into a token/WETH V3 pool (1% fee tier)
• Pool opens at ~$5K FDV (1.69 gwei/token); buyers supply the WETH side
• Liquidity is PERMANENTLY LOCKED: this contract owns the position and has
no function to withdraw principal, only to collect swap fees
• The 1% pool fees are collectable to the feeWallet by anyone (collectFees)
• Built-in router: buy()/sell() swap through the pool AND track Feather
(traderVolume) on-chain, 10 per 1 ETH volume
• CREATE2 vanity token addresses ending in 4663 (pre-mined salts), with a
salt=0 fallback so launches never block
web https://4-6-6-3.fun · x community 1993064047185420340
──────────────────────────────────────────────────────────────────────────────
*/
interface IUniV3Factory { function createPool(address, address, uint24) external returns (address); }
interface IUniV3Pool {
function initialize(uint160 sqrtPriceX96) external;
function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data) external returns (uint256, uint256);
function swap(address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data) external returns (int256 amount0, int256 amount1);
function burn(int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256, uint256);
function collect(address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128, uint128);
function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16, uint16, uint16, uint8, bool);
}
interface IWETH {
function deposit() external payable;
function withdraw(uint256) external;
function transfer(address, uint256) external returns (bool);
function balanceOf(address) external view returns (uint256);
}
interface IFactoryMeta {
function pendingName() external view returns (string memory);
function pendingSymbol() external view returns (string memory);
}
contract VanityToken {
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 public immutable totalSupply;
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);
constructor() {
name = IFactoryMeta(msg.sender).pendingName();
symbol = IFactoryMeta(msg.sender).pendingSymbol();
totalSupply = 1_000_000_000e18;
balanceOf[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function transfer(address to, uint256 v) external returns (bool) { return _t(msg.sender, to, v); }
function transferFrom(address f, address to, uint256 v) external returns (bool) {
uint256 a = allowance[f][msg.sender];
if (a != type(uint256).max) { require(a >= v, "allowance"); unchecked { allowance[f][msg.sender] = a - v; } }
return _t(f, to, v);
}
function approve(address s, uint256 v) external returns (bool) { allowance[msg.sender][s] = v; emit Approval(msg.sender, s, v); return true; }
function _t(address f, address to, uint256 v) internal returns (bool) {
require(to != address(0), "zero to");
uint256 b = balanceOf[f]; require(b >= v, "balance");
unchecked { balanceOf[f] = b - v; balanceOf[to] += v; }
emit Transfer(f, to, v); return true;
}
}
contract Launchpad4663Pool {
uint256 public constant SUPPLY_TOTAL = 1_000_000_000e18;
uint24 public constant FEE_TIER = 10000; // 1% pool
// launching is COMPLETELY FREE for the user. The platform sponsors the
// automatic first buy below from this contract's ETH float.
uint256 public constant INITIAL_BUY = 0.001 ether; // sponsored first swap at launch:
// creates the pool's first transaction so DexScreener and other terminals index
// the token immediately. The launcher pays it and receives the tokens at the
// exact market price (a real swap, NOT a free premine).
uint256 public constant VP_PER_ETH = 10;
// ── pool constants (precomputed off-chain; see repo notes) ──────────────
// CASE A: token < weth (token is token0). price = 1.6667e-9 WETH/token.
uint160 internal constant SQRT_PRICE_A = 3234476190304153087556629;
int24 internal constant TICK_LOWER_A = -202000;
int24 internal constant TICK_UPPER_A = 887200;
uint128 internal constant LIQ_A = 41096194225741735395328;
// CASE B: weth < token (token is token1). price = 6e8 token/WETH.
uint160 internal constant SQRT_PRICE_B = 1940685714182491852533977682922057;
int24 internal constant TICK_LOWER_B = -887200;
int24 internal constant TICK_UPPER_B = 202000;
uint128 internal constant LIQ_B = 41096194225741743783936;
uint160 internal constant MIN_SQRT_PLUS1 = 4295128740;
uint160 internal constant MAX_SQRT_MINUS1 = 1461446703485210103287273052203988822378723970341;
address internal constant DEAD = 0x000000000000000000000000000000000000dEaD;
address public immutable feeWallet;
address public immutable uniFactory;
address public immutable weth;
string public pendingName;
string public pendingSymbol;
struct TokenInfo {
address token; address pool; address creator;
bool tokenIsToken0;
uint256 createdAt; uint256 volumeEth;
}
uint256 public tokenCount;
mapping(uint256 => TokenInfo) public tokens;
mapping(address => uint256) public idOfToken;
mapping(address => uint256) public idOfPool;
mapping(address => uint256) public traderVolume;
uint256 public totalVolumeEth;
uint256 public platformFeesEth;
uint256 private _lock = 1;
modifier nonReentrant() { require(_lock == 1, "reentrancy"); _lock = 2; _; _lock = 1; }
event TokenCreated(uint256 indexed id, address indexed token, address indexed creator, string name, string symbol);
event PoolCreated(uint256 indexed id, address indexed pool, bool tokenIsToken0);
event Bought(uint256 indexed id, address indexed buyer, uint256 ethIn, uint256 tokensOut, uint256 newSold, uint256 newReserve, uint256 spot);
event Sold(uint256 indexed id, address indexed seller, uint256 tokensIn, uint256 ethOut, uint256 newSold, uint256 newReserve, uint256 spot);
event FeesCollected(uint256 indexed id, uint256 wethAmount, uint256 tokenAmount);
event InitialBuySkipped(uint256 indexed id);
constructor(address feeWallet_, address uniFactory_, address weth_) {
require(feeWallet_ != address(0) && uniFactory_ != address(0) && weth_ != address(0), "zero addr");
feeWallet = feeWallet_; uniFactory = uniFactory_; weth = weth_;
}
receive() external payable {} // for WETH.withdraw
function tokenInitCodeHash() external pure returns (bytes32) {
return keccak256(type(VanityToken).creationCode);
}
function predictToken(bytes32 salt) external view returns (address) {
bytes32 h = keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(type(VanityToken).creationCode)));
return address(uint160(uint256(h)));
}
// ── launch: deploy token + create pool + seed single-sided liquidity ────
function createToken(string calldata n, string calldata s, bytes32 salt)
external payable nonReentrant returns (uint256 id, address token, address pool)
{
require(bytes(n).length >= 1 && bytes(n).length <= 32, "name");
require(bytes(s).length >= 1 && bytes(s).length <= 10, "symbol");
bytes32 useSalt = salt == bytes32(0)
? keccak256(abi.encodePacked(block.timestamp, msg.sender, tokenCount))
: salt;
pendingName = n; pendingSymbol = s;
VanityToken t = new VanityToken{salt: useSalt}();
token = address(t);
require(idOfToken[token] == 0, "salt used");
delete pendingName; delete pendingSymbol;
bool tokenIs0 = token < weth;
pool = IUniV3Factory(uniFactory).createPool(token, weth, FEE_TIER);
IUniV3Pool(pool).initialize(tokenIs0 ? SQRT_PRICE_A : SQRT_PRICE_B);
id = ++tokenCount;
tokens[id] = TokenInfo(token, pool, msg.sender, tokenIs0, block.timestamp, 0);
idOfToken[token] = id;
idOfPool[pool] = id;
// single-sided mint: entire supply into the range; callback pays tokens
if (tokenIs0) IUniV3Pool(pool).mint(address(this), TICK_LOWER_A, TICK_UPPER_A, LIQ_A, abi.encode(id));
else IUniV3Pool(pool).mint(address(this), TICK_LOWER_B, TICK_UPPER_B, LIQ_B, abi.encode(id));
// burn the rounding dust so the factory holds nothing
uint256 dust = t.balanceOf(address(this));
if (dust > 0) t.transfer(DEAD, dust);
emit TokenCreated(id, token, msg.sender, n, s);
emit PoolCreated(id, pool, tokenIs0);
// sponsored first buy: the pool's first transaction, so terminals index it.
// Paid from this contract's ETH float (top up by sending ETH here);
// the sponsored tokens go to the feeWallet. Skipped if the float is dry
// so a launch can never fail for lack of sponsor funds.
if (address(this).balance - msg.value >= INITIAL_BUY) {
_buyInternal(id, INITIAL_BUY, feeWallet);
} else {
emit InitialBuySkipped(id);
}
if (msg.value > 0) _pay(msg.sender, msg.value); // nothing to pay: full refund
}
function launchCost() external pure returns (uint256) { return 0; }
function sponsorFloat() external view returns (uint256) { return address(this).balance; }
function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external {
uint256 id = abi.decode(data, (uint256));
TokenInfo storage t = tokens[id];
require(msg.sender == t.pool, "bad pool");
if (t.tokenIsToken0) {
require(amount1Owed == 0, "weth owed"); // strictly single-sided
require(amount0Owed <= SUPPLY_TOTAL, "over supply");
VanityToken(t.token).transfer(msg.sender, amount0Owed);
} else {
require(amount0Owed == 0, "weth owed");
require(amount1Owed <= SUPPLY_TOTAL, "over supply");
VanityToken(t.token).transfer(msg.sender, amount1Owed);
}
}
// ── built-in router: swaps through the pool, tracks Feather on-chain ────
function buy(uint256 id, uint256 minTokensOut) external payable nonReentrant returns (uint256 out) {
require(msg.value > 0, "zero ETH");
out = _buyInternal(id, msg.value, msg.sender);
require(out >= minTokensOut, "slippage");
}
function _buyInternal(uint256 id, uint256 ethIn, address recipient) internal returns (uint256 out) {
TokenInfo storage t = tokens[id];
require(t.pool != address(0), "unknown");
IWETH(weth).deposit{value: ethIn}();
bool zeroForOne = !t.tokenIsToken0; // WETH in
(int256 a0, int256 a1) = IUniV3Pool(t.pool).swap(
recipient, zeroForOne, int256(ethIn),
zeroForOne ? MIN_SQRT_PLUS1 : MAX_SQRT_MINUS1,
abi.encode(id, address(this))
);
out = uint256(-(t.tokenIsToken0 ? a0 : a1));
require(out > 0, "zero out");
t.volumeEth += ethIn;
traderVolume[recipient] += ethIn;
totalVolumeEth += ethIn;
(uint256 sold, uint256 reserve, uint256 spot) = _stats(t);
emit Bought(id, recipient, ethIn, out, sold, reserve, spot);
}
function sell(uint256 id, uint256 tokensIn, uint256 minEthOut) external nonReentrant returns (uint256 ethOut) {
TokenInfo storage t = tokens[id];
require(t.pool != address(0), "unknown");
require(tokensIn > 0, "zero in");
bool zeroForOne = t.tokenIsToken0; // TOKEN in
(int256 a0, int256 a1) = IUniV3Pool(t.pool).swap(
address(this), zeroForOne, int256(tokensIn),
zeroForOne ? MIN_SQRT_PLUS1 : MAX_SQRT_MINUS1,
abi.encode(id, msg.sender)
);
ethOut = uint256(-(t.tokenIsToken0 ? a1 : a0));
require(ethOut >= minEthOut && ethOut > 0, "slippage");
IWETH(weth).withdraw(ethOut);
t.volumeEth += ethOut;
traderVolume[msg.sender] += ethOut;
totalVolumeEth += ethOut;
(uint256 sold, uint256 reserve, uint256 spot) = _stats(t);
emit Sold(id, msg.sender, tokensIn, ethOut, sold, reserve, spot);
_pay(msg.sender, ethOut);
}
function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {
(uint256 id, address payer) = abi.decode(data, (uint256, address));
TokenInfo storage t = tokens[id];
require(msg.sender == t.pool, "bad pool");
// pay the positive delta in the owed token
if (amount0Delta > 0) {
if (t.tokenIsToken0) VanityToken(t.token).transferFrom(payer, msg.sender, uint256(amount0Delta));
else IWETH(weth).transfer(msg.sender, uint256(amount0Delta));
}
if (amount1Delta > 0) {
if (t.tokenIsToken0) IWETH(weth).transfer(msg.sender, uint256(amount1Delta));
else VanityToken(t.token).transferFrom(payer, msg.sender, uint256(amount1Delta));
}
}
// ── fee collection: anyone can trigger; proceeds → feeWallet ────────────
// The position principal is UNTOUCHABLE: burn(…, 0) only poke-updates fees.
function collectFees(uint256 id) external nonReentrant returns (uint256 wethAmt, uint256 tokenAmt) {
TokenInfo storage t = tokens[id];
require(t.pool != address(0), "unknown");
(int24 lo, int24 hi) = t.tokenIsToken0 ? (TICK_LOWER_A, TICK_UPPER_A) : (TICK_LOWER_B, TICK_UPPER_B);
IUniV3Pool(t.pool).burn(lo, hi, 0); // poke: updates tokensOwed, removes nothing
(uint128 c0, uint128 c1) = IUniV3Pool(t.pool).collect(feeWallet, lo, hi, type(uint128).max, type(uint128).max);
(wethAmt, tokenAmt) = t.tokenIsToken0 ? (uint256(c1), uint256(c0)) : (uint256(c0), uint256(c1));
platformFeesEth += wethAmt; // running total of collected pool fees
emit FeesCollected(id, wethAmt, tokenAmt);
}
// ── views (dashboard-compatible tuple) ──────────────────────────────────
function _stats(TokenInfo storage t) internal view returns (uint256 sold, uint256 reserve, uint256 spot) {
sold = SUPPLY_TOTAL - VanityToken(t.token).balanceOf(t.pool);
reserve = IWETH(weth).balanceOf(t.pool);
(uint160 sqrtP, , , , , , ) = IUniV3Pool(t.pool).slot0();
if (t.tokenIsToken0) {
spot = uint256(sqrtP) * uint256(sqrtP) / (1 << 96) * 1e18 >> 96;
} else {
spot = (uint256(1) << 192) / uint256(sqrtP) * 1e18 / uint256(sqrtP);
}
}
struct TokenView {
address token; string name; string symbol; address creator;
uint256 curveSold; uint256 reserve; bool graduated; bool liquidityClaimed;
uint256 spot; uint256 curveProgressBps; uint256 marketCapWei; uint256 volumeEth; uint256 createdAt;
}
function getToken(uint256 id) external view returns (TokenView memory v) {
TokenInfo storage t = tokens[id];
if (t.token == address(0)) return v;
(uint256 sold, uint256 reserve, uint256 spot) = _stats(t);
v.token = t.token;
v.name = VanityToken(t.token).name();
v.symbol = VanityToken(t.token).symbol();
v.creator = t.creator;
v.curveSold = sold;
v.reserve = reserve;
v.graduated = true; // live on Uniswap from block one
v.liquidityClaimed = true;
v.spot = spot;
v.curveProgressBps = sold * 10_000 / SUPPLY_TOTAL;
v.marketCapWei = spot * SUPPLY_TOTAL / 1e18;
v.volumeEth = t.volumeEth;
v.createdAt = t.createdAt;
}
function poolOf(uint256 id) external view returns (address) { return tokens[id].pool; }
function vpOf(address who) external view returns (uint256) { return traderVolume[who] * VP_PER_ETH / 1e18; }
function platformStats() external view returns (uint256 tokens_, uint256 volume, uint256 fees, uint256 vpIssued) {
return (tokenCount, totalVolumeEth, platformFeesEth, totalVolumeEth * VP_PER_ETH / 1e18);
}
function _pay(address to, uint256 amount) internal { (bool ok, ) = to.call{value: amount}(""); require(ok, "eth send"); }
}
Chain explorer3301msChain node88ms