Verified contractPartialMIT
PIPI
Address0xd0b0e59bb4945ab58b38e408bf7c6dacaa1a20cc
- Balance
0 ETH
- Transactions
24
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,449,903
- Creation transaction
- 0x3ac5e12cc4…cdf39b5a39
PIPI.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/*
* GTA Meme ($PIPI)
* PIPI the first meme coin in GTA found
*
* Telegram: https://t.me/PIPIGTA
*
* Uniswap V4 token. This contract is also the hook of its official ETH/PIPI pool.
* - Fixed supply, minted once at deploy. There is no mint function.
* - Tax is charged in ETH on the official pool and forwarded to the tax wallet.
* Launch tax: 20% buy / 20% sell
* Final tax: 0% buy / 0% sell
* Launch tax switches to final tax 5 minutes after trading opens.
* - Taxes can only be lowered, never raised. Hard caps: 30% launch, 10% final.
* - Trading opens once, only after liquidity is in the pool, and can never be closed again.
* - Once open, buys and sells are always allowed. No blacklist, no sell lock.
* - Only the owner can create the official pool, so nobody can front-run the launch price.
*/
interface IPoolManagerMinimal {
function take(address currency, address to, uint256 amount) external;
function extsload(bytes32 slot) external view returns (bytes32);
}
struct PoolKey {
address currency0;
address currency1;
uint24 fee;
int24 tickSpacing;
address hooks;
}
struct SwapParams {
bool zeroForOne;
int256 amountSpecified;
uint160 sqrtPriceLimitX96;
}
contract PIPI {
// ------------------------------------------------------------------ ERC20
string public constant name = "GTA Meme";
string public constant symbol = "PIPI";
uint8 public constant decimals = 18;
uint256 public constant totalSupply = 1000000000 * 1e18;
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);
// ------------------------------------------------------------------ launch config
IPoolManagerMinimal public constant poolManager = IPoolManagerMinimal(0x000000000004444c5dc75cB358380D2e3dE08A90);
uint160 internal constant HOOK_FLAGS = 0x20CC;
uint16 public constant MAX_LAUNCH_TAX_BPS = 3000;
uint16 public constant MAX_FINAL_TAX_BPS = 1000;
uint256 public constant LAUNCH_TAX_DURATION = 5 minutes;
uint256 public constant LAUNCH_TAX_BUYS = 0;
address public owner;
address public taxWallet;
uint16 public launchBuyTaxBps;
uint16 public launchSellTaxBps;
uint16 public finalBuyTaxBps;
uint16 public finalSellTaxBps;
bool public launchTaxEnded;
uint256 public buyCount;
bool public tradingEnabled;
uint256 public tradingEnabledAt;
bool public poolCreated;
bytes32 public poolId;
PoolKey public poolKey;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event TaxWalletChanged(address wallet);
event TaxesLowered(uint16 launchBuy, uint16 launchSell, uint16 finalBuy, uint16 finalSell);
event LaunchTaxEnded(uint256 timestamp);
event TradingEnabled(uint256 timestamp);
event PoolCreated(bytes32 indexed id, uint24 fee, int24 tickSpacing);
event Taxed(bool buy, uint256 ethAmount);
event TaxForwardFailed(uint256 ethAmount);
error NotOwner();
error NotPoolManager();
error ZeroAddress();
error InsufficientBalance();
error InsufficientAllowance();
error BadHookAddress();
error BadConfig();
error WrongPool();
error PoolAlreadyCreated();
error PoolNotCreated();
error NoLiquidity();
error TradingNotOpen();
error TradingAlreadyOpen();
error TaxCanOnlyGoDown();
error TaxTransferFailed();
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
modifier onlyPoolManager() {
if (msg.sender != address(poolManager)) revert NotPoolManager();
_;
}
constructor() {
// the hook permissions are encoded in the lowest 14 bits of this address
if ((uint160(address(this)) & 0x3FFF) != HOOK_FLAGS) revert BadHookAddress();
owner = 0xB46D9ed2FfA1870C87Aa4DD76Fa3EB886874B84B;
taxWallet = 0xB46D9ed2FfA1870C87Aa4DD76Fa3EB886874B84B;
launchBuyTaxBps = 2000;
launchSellTaxBps = 2000;
finalBuyTaxBps = 0;
finalSellTaxBps = 0;
if (launchBuyTaxBps > MAX_LAUNCH_TAX_BPS || launchSellTaxBps > MAX_LAUNCH_TAX_BPS) revert BadConfig();
if (finalBuyTaxBps > MAX_FINAL_TAX_BPS || finalSellTaxBps > MAX_FINAL_TAX_BPS) revert BadConfig();
if (finalBuyTaxBps > launchBuyTaxBps || finalSellTaxBps > launchSellTaxBps) revert BadConfig();
balanceOf[owner] = totalSupply;
emit Transfer(address(0), owner, totalSupply);
emit OwnershipTransferred(address(0), owner);
emit TaxWalletChanged(taxWallet);
}
receive() external payable {}
// ------------------------------------------------------------------ ERC20 logic
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) external returns (bool) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) external returns (bool) {
uint256 allowed = allowance[from][msg.sender];
if (allowed != type(uint256).max) {
if (allowed < value) revert InsufficientAllowance();
unchecked {
allowance[from][msg.sender] = allowed - value;
}
}
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
if (to == address(0)) revert ZeroAddress();
uint256 bal = balanceOf[from];
if (bal < value) revert InsufficientBalance();
unchecked {
balanceOf[from] = bal - value;
balanceOf[to] += value;
}
emit Transfer(from, to, value);
}
// ------------------------------------------------------------------ views
function launchTaxActive() public view returns (bool) {
if (launchTaxEnded) return false;
if (!tradingEnabled) return true;
if (block.timestamp >= tradingEnabledAt + LAUNCH_TAX_DURATION) return false;
if (LAUNCH_TAX_BUYS != 0 && buyCount >= LAUNCH_TAX_BUYS) return false;
return true;
}
function currentTaxes() public view returns (uint16 buyBps, uint16 sellBps) {
if (launchTaxActive()) return (launchBuyTaxBps, launchSellTaxBps);
return (finalBuyTaxBps, finalSellTaxBps);
}
/// Liquidity currently active in the official pool (read from the PoolManager).
function poolLiquidity() public view returns (uint128) {
if (!poolCreated) return 0;
bytes32 stateSlot = keccak256(abi.encodePacked(poolId, bytes32(uint256(6))));
return uint128(uint256(poolManager.extsload(bytes32(uint256(stateSlot) + 3))));
}
// ------------------------------------------------------------------ owner
/// Opens trading once. Requires the official pool to exist and hold liquidity. Irreversible.
function enableTrading() external onlyOwner {
if (tradingEnabled) revert TradingAlreadyOpen();
if (!poolCreated) revert PoolNotCreated();
if (poolLiquidity() == 0) revert NoLiquidity();
tradingEnabled = true;
tradingEnabledAt = block.timestamp;
emit TradingEnabled(block.timestamp);
}
/// Taxes can only go down. Final tax can never exceed launch tax.
function lowerTaxes(uint16 launchBuy, uint16 launchSell, uint16 finalBuy, uint16 finalSell) external onlyOwner {
if (launchBuy > launchBuyTaxBps || launchSell > launchSellTaxBps) revert TaxCanOnlyGoDown();
if (finalBuy > finalBuyTaxBps || finalSell > finalSellTaxBps) revert TaxCanOnlyGoDown();
if (finalBuy > launchBuy || finalSell > launchSell) revert BadConfig();
launchBuyTaxBps = launchBuy;
launchSellTaxBps = launchSell;
finalBuyTaxBps = finalBuy;
finalSellTaxBps = finalSell;
emit TaxesLowered(launchBuy, launchSell, finalBuy, finalSell);
}
/// Switch to the final tax right now (one-way).
function endLaunchTax() external onlyOwner {
launchTaxEnded = true;
emit LaunchTaxEnded(block.timestamp);
}
function setTaxWallet(address wallet) external onlyOwner {
if (wallet == address(0)) revert ZeroAddress();
taxWallet = wallet;
emit TaxWalletChanged(wallet);
}
/// Sends any tax held by the contract (ETH, or tokens from rare exact-output trades) to the tax wallet.
function withdrawTax() external {
uint256 tokens = balanceOf[address(this)];
if (tokens > 0) _transfer(address(this), taxWallet, tokens);
uint256 eth = address(this).balance;
if (eth > 0) {
(bool ok, ) = taxWallet.call{value: eth}("");
if (!ok) revert TaxTransferFailed();
}
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() external onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
// ------------------------------------------------------------------ Uniswap V4 hook
function beforeInitialize(address sender, PoolKey calldata key, uint160) external onlyPoolManager returns (bytes4) {
if (sender != owner) revert NotOwner();
if (poolCreated) revert PoolAlreadyCreated();
if (key.currency0 != address(0) || key.currency1 != address(this) || key.hooks != address(this)) revert WrongPool();
if (key.fee & 0x800000 != 0) revert WrongPool(); // no dynamic-fee pools
poolCreated = true;
poolId = keccak256(abi.encode(key));
poolKey = key;
emit PoolCreated(poolId, key.fee, key.tickSpacing);
return this.beforeInitialize.selector;
}
/// currency0 is native ETH, currency1 is this token: zeroForOne == buy.
function beforeSwap(address, PoolKey calldata, SwapParams calldata params, bytes calldata)
external
onlyPoolManager
returns (bytes4, int256, uint24)
{
if (!tradingEnabled) revert TradingNotOpen();
bool exactIn = params.amountSpecified < 0;
// ETH is the specified side on exact-input buys and exact-output sells: tax it here.
if (params.zeroForOne == exactIn) {
uint256 amount = exactIn ? uint256(-params.amountSpecified) : uint256(params.amountSpecified);
uint256 fee = _fee(amount, params.zeroForOne);
if (fee > 0) {
poolManager.take(address(0), address(this), fee);
emit Taxed(params.zeroForOne, fee);
return (this.beforeSwap.selector, int256(fee) << 128, 0);
}
}
return (this.beforeSwap.selector, 0, 0);
}
function afterSwap(address, PoolKey calldata, SwapParams calldata params, int256 delta, bytes calldata)
external
onlyPoolManager
returns (bytes4, int128)
{
bool exactIn = params.amountSpecified < 0;
int128 hookDelta;
// ETH is the unspecified side on exact-output buys and exact-input sells: tax it here.
if (params.zeroForOne != exactIn) {
int128 ethDelta = int128(delta >> 128);
uint256 amount = ethDelta < 0 ? uint256(uint128(-ethDelta)) : uint256(uint128(ethDelta));
uint256 fee = _fee(amount, params.zeroForOne);
if (fee > 0) {
poolManager.take(address(0), address(this), fee);
emit Taxed(params.zeroForOne, fee);
hookDelta = int128(int256(fee));
}
}
if (params.zeroForOne) {
unchecked {
++buyCount;
}
}
_forwardTax();
return (this.afterSwap.selector, hookDelta);
}
function _fee(uint256 amount, bool buy) internal view returns (uint256) {
(uint16 buyBps, uint16 sellBps) = currentTaxes();
return (amount * (buy ? buyBps : sellBps)) / 10_000;
}
/// Gas-capped and non-reverting: a tax wallet that can't receive never blocks a swap;
/// the ETH then stays here and anyone can push it with withdrawTax().
function _forwardTax() internal {
uint256 bal = address(this).balance;
if (bal == 0) return;
(bool ok, ) = taxWallet.call{value: bal, gas: 50_000}("");
if (!ok) emit TaxForwardFailed(bal);
}
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.