Verified contractExactMIT
EtherPot
Address0x4ea97893fe3d09b2cab3738da16adbbb913ddc1f
- Balance
0 ETH
- Transactions
16
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,001,823
- Creation transaction
- 0x13bb65f9ba…2ec1339222
contracts/etherpot.sol
/*
░▒▓████████▓▒░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░▒▓██████▓▒░ ░▒▓███████▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓████████▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
Be the last. Take the pot.
• Last-buyer-wins jackpot on Ethereum.
• New round every ~5 min. 99% to winner.
• Self-funded by 5% trading tax.
https://x.com/EtherPotCash
https://etherpot.cash
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
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);
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external payable returns (uint256, uint256, uint256);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function getAmountsOut(uint256 amountIn, address[] calldata path)
external view returns (uint256[] memory amounts);
}
contract EtherPot is IERC20 {
string private constant _name = "EtherPot";
string private constant _symbol = "EPOT";
uint8 private constant _decimals = 9;
uint256 private constant TOTAL = 1_000_000_000 * 10**9;
address public constant DEAD = 0x000000000000000000000000000000000000dEaD;
// Ethereum mainnet Uniswap V2 router.
address private constant ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
uint256 public constant MIN_QUALIFYING_BUY_ETH = 0.0044 ether;
uint256 private constant EMERGENCY_DELAY = 24 hours;
uint256 private constant MAX_SELLS_PER_BLOCK = 5;
mapping(address => uint256) private _bal;
mapping(address => mapping(address => uint256)) private _allow;
mapping(address => bool) public feeExcluded;
mapping(address => bool) public txExcluded;
mapping(address => bool) public blocked;
address private _owner;
IUniswapV2Router02 public router;
address public pair;
uint256 public buyTax = 5;
uint256 public sellTax = 5;
uint256 public potBps = 8000;
uint256 public burnBps = 2000;
uint256 public maxTx = TOTAL / 40;
uint256 public maxWallet = TOTAL / 25;
uint256 public swapMin = TOTAL / 1000;
uint256 public swapMax = TOTAL * 3 / 100;
uint256 public slipBps = 300;
bool public tradingOpen;
bool public swapEnabled;
bool public limitsRemoved;
bool public distDone;
bool private _swapping;
bool private _entered;
uint256 private _lastSellBlock;
uint256 private _sellCount;
uint256 private _entropy;
uint256 public emergencyUnlockAt;
struct Round {
uint256 id;
uint256 startBlock;
uint256 closingBlock;
uint256 pot;
address lastBuyer;
uint256 lastBuyBlock;
bool closed;
address winner;
uint256 paid;
}
uint256 public roundCounter;
mapping(uint256 => Round) public rounds;
uint256[] public completedRounds;
event RoundStarted(uint256 indexed id, uint256 startBlock, uint256 closingBlock);
event RoundClosed(uint256 indexed id, address indexed winner, uint256 prize, address caller);
event RoundRolledOver(uint256 indexed id, uint256 potCarried);
event QualifyingBuy(uint256 indexed roundId, address indexed buyer, uint256 amount, uint256 block);
event PotFunded(uint256 indexed roundId, uint256 ethAdded);
event BuybackBurn(uint256 ethSpent, uint256 tokensBurned);
event TradingOpened();
event Blocked(address indexed addr, bool blocked);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
modifier onlyOwner() {
require(msg.sender == _owner, "Not owner");
_;
}
modifier nonReentrant() {
require(!_entered, "Reentrant");
_entered = true;
_;
_entered = false;
}
modifier lockSwap() {
_swapping = true;
_;
_swapping = false;
}
constructor() {
_owner = msg.sender;
router = IUniswapV2Router02(ROUTER);
_bal[msg.sender] = TOTAL;
feeExcluded[msg.sender] = true;
feeExcluded[address(this)] = true;
txExcluded[msg.sender] = true;
txExcluded[address(this)] = true;
txExcluded[ROUTER] = true;
txExcluded[DEAD] = true;
emit Transfer(address(0), msg.sender, TOTAL);
emit OwnershipTransferred(address(0), msg.sender);
}
// ---------- ERC-20 ----------
function name() external pure returns (string memory) { return _name; }
function symbol() external pure returns (string memory) { return _symbol; }
function decimals() external pure returns (uint8) { return _decimals; }
function totalSupply() external pure returns (uint256) { return TOTAL; }
function balanceOf(address a) external view returns (uint256) { return _bal[a]; }
function allowance(address o, address s) external view returns (uint256) { return _allow[o][s]; }
function owner() public view returns (address) { return _owner; }
function approve(address spender, uint256 amount) external returns (bool) {
_allow[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) external returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) external returns (bool) {
uint256 cur = _allow[from][msg.sender];
require(cur >= amount, "Allowance");
if (cur != type(uint256).max) {
unchecked { _allow[from][msg.sender] = cur - amount; }
}
_transfer(from, to, amount);
return true;
}
// ---------- Core transfer ----------
function _transfer(address from, address to, uint256 amt) private {
require(from != address(0) && to != address(0), "Zero addr");
require(amt > 0, "Zero amt");
require(!blocked[from] && !blocked[to], "Blocked");
if (_swapping || feeExcluded[from] || feeExcluded[to]) {
_basicTransfer(from, to, amt);
return;
}
require(tradingOpen, "Trading not open");
bool isBuy = (from == pair);
bool isSell = (to == pair);
// Auto-close if window elapsed (before processing this trade)
if (roundCounter > 0) {
Round storage cur = rounds[roundCounter];
if (!cur.closed && block.number >= cur.closingBlock) {
_executeRoundClose(msg.sender);
}
}
// Per-tx / per-wallet limits
if (!txExcluded[from] && !txExcluded[to] && !limitsRemoved) {
require(amt <= maxTx, "Exceeds maxTx");
if (to != pair) {
require(_bal[to] + amt <= maxWallet, "Exceeds maxWallet");
}
}
// Anti-MEV: max 5 sells per block
if (isSell && !feeExcluded[from]) {
if (block.number > _lastSellBlock) _sellCount = 0;
require(_sellCount < MAX_SELLS_PER_BLOCK, "Max 5 sells/block");
unchecked { _sellCount++; }
_lastSellBlock = block.number;
}
// Tax accumulation: trigger swap on sell when threshold hit
uint256 contractBal = _bal[address(this)];
if (isSell && !_swapping && swapEnabled && contractBal >= swapMin) {
uint256 swapAmt = contractBal > swapMax ? swapMax : contractBal;
_processTax(swapAmt);
}
uint256 taxAmt;
if (isBuy) {
taxAmt = (amt * buyTax) / 100;
} else if (isSell) {
taxAmt = (amt * sellTax) / 100;
}
require(_bal[from] >= amt, "Insufficient");
unchecked { _bal[from] -= amt; }
if (taxAmt > 0) {
unchecked { _bal[address(this)] += taxAmt; }
emit Transfer(from, address(this), taxAmt);
}
uint256 sendAmt = amt - taxAmt;
unchecked { _bal[to] += sendAmt; }
emit Transfer(from, to, sendAmt);
// Mix entropy from each taxed transfer
unchecked {
_entropy = uint256(keccak256(abi.encode(_entropy, from, to, amt, block.number)));
}
// Last-buyer tracking with 2-block anti-snipe buffer
if (isBuy && roundCounter > 0) {
Round storage cur = rounds[roundCounter];
if (!cur.closed && block.number + 2 <= cur.closingBlock && _isQualifyingBuy(amt)) {
cur.lastBuyer = to;
cur.lastBuyBlock = block.number;
emit QualifyingBuy(cur.id, to, amt, block.number);
}
}
}
function _basicTransfer(address from, address to, uint256 amt) private {
require(_bal[from] >= amt, "Insufficient");
unchecked {
_bal[from] -= amt;
_bal[to] += amt;
}
emit Transfer(from, to, amt);
}
// ---------- Round mechanics ----------
function _isQualifyingBuy(uint256 tokenAmount) private view returns (bool) {
address[] memory path = new address[](2);
path[0] = router.WETH();
path[1] = address(this);
try router.getAmountsOut(MIN_QUALIFYING_BUY_ETH, path) returns (uint256[] memory amounts) {
return tokenAmount >= amounts[1];
} catch {
return false;
}
}
function _calculateClosingBlock(uint256 startBlock) private view returns (uint256) {
uint256 baseDuration = 25;
uint256 maxOffset = 5;
uint256 seed = uint256(keccak256(abi.encodePacked(
blockhash(block.number - 1),
blockhash(block.number > 3 ? block.number - 3 : block.number - 1),
_entropy,
startBlock,
block.timestamp
)));
uint256 offset = seed % (maxOffset + 1);
return startBlock + baseDuration + offset;
}
function _startNewRound() private {
unchecked { roundCounter++; }
uint256 startBlock = block.number;
uint256 closingBlock = _calculateClosingBlock(startBlock);
rounds[roundCounter] = Round({
id: roundCounter,
startBlock: startBlock,
closingBlock: closingBlock,
pot: 0,
lastBuyer: address(0),
lastBuyBlock: 0,
closed: false,
winner: address(0),
paid: 0
});
emit RoundStarted(roundCounter, startBlock, closingBlock);
}
function _executeRoundClose(address caller) private {
Round storage current = rounds[roundCounter];
if (current.closed) return;
current.closed = true;
address lastBuyer = current.lastBuyer;
uint256 totalPot = current.pot;
if (lastBuyer == address(0) || totalPot == 0) {
emit RoundRolledOver(current.id, totalPot);
_startNewRound();
if (totalPot > 0) rounds[roundCounter].pot = totalPot;
return;
}
uint256 callerReward = totalPot / 100;
uint256 winnerPrize = totalPot - callerReward;
// Pay caller reward. If caller can't receive (contract w/o receive, OOG, etc),
// fold the reward back into the winner prize.
if (callerReward > 0 && caller != address(0) && caller != address(this)) {
(bool callerOk,) = payable(caller).call{value: callerReward, gas: 30_000}("");
if (!callerOk) winnerPrize += callerReward;
}
// Pay winner. If winner can't receive, roll over only the portion we attempted
// to send to the winner (winnerPrize). Caller reward, if successfully sent, stays sent.
(bool winnerOk,) = payable(lastBuyer).call{value: winnerPrize, gas: 30_000}("");
if (!winnerOk) {
emit RoundRolledOver(current.id, winnerPrize);
_startNewRound();
rounds[roundCounter].pot = winnerPrize;
return;
}
// Success — record winner only after payouts succeed so completedRounds stays clean.
current.winner = lastBuyer;
current.paid = winnerPrize;
completedRounds.push(current.id);
emit RoundClosed(current.id, lastBuyer, winnerPrize, caller);
_startNewRound();
}
function closeRound() external nonReentrant {
require(roundCounter > 0, "No active round");
Round storage current = rounds[roundCounter];
require(!current.closed, "Round already closed");
require(block.number >= current.closingBlock, "Round still active");
_executeRoundClose(msg.sender);
}
// ---------- Tax / swap / buyback ----------
function _processTax(uint256 amt) private lockSwap nonReentrant {
uint256 ethReceived = _swapToETH(amt);
if (ethReceived == 0) return;
uint256 forPot = (ethReceived * potBps) / 10000;
uint256 forBuyback = ethReceived - forPot;
if (forPot > 0 && roundCounter > 0 && !rounds[roundCounter].closed) {
rounds[roundCounter].pot += forPot;
emit PotFunded(roundCounter, forPot);
}
if (forBuyback > 0) {
_buybackAndBurn(forBuyback);
}
}
function _swapToETH(uint256 tokenAmt) private returns (uint256 ethReceived) {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = router.WETH();
_safeApproveRouter(tokenAmt);
uint256 minOut = 0;
try router.getAmountsOut(tokenAmt, path) returns (uint256[] memory amounts) {
minOut = (amounts[1] * (10000 - slipBps)) / 10000;
} catch {}
uint256 balanceBefore = address(this).balance;
try router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmt, minOut, path, address(this), block.timestamp + 15 minutes
) {
ethReceived = address(this).balance - balanceBefore;
} catch {
ethReceived = 0;
}
}
function _buybackAndBurn(uint256 ethAmount) private {
if (ethAmount == 0) return;
address[] memory path = new address[](2);
path[0] = router.WETH();
path[1] = address(this);
// Slippage-protected minOut so we can't be sandwiched on the buyback leg.
uint256 minOut = 0;
try router.getAmountsOut(ethAmount, path) returns (uint256[] memory amounts) {
minOut = (amounts[1] * (10000 - slipBps)) / 10000;
} catch {}
uint256 balanceBefore = _bal[address(this)];
bool success = false;
try router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: ethAmount}(
minOut, path, address(this), block.timestamp + 15 minutes
) {
uint256 bought = _bal[address(this)] - balanceBefore;
if (bought > 0) {
unchecked {
_bal[address(this)] -= bought;
_bal[DEAD] += bought;
}
emit Transfer(address(this), DEAD, bought);
emit BuybackBurn(ethAmount, bought);
success = true;
}
} catch {}
// Fallback: if the buyback failed (slippage, sandwich, router quirk, etc.),
// redirect the ETH to the current round's pot. Prevents stuck ETH and
// keeps tokenomics healthy: the worst case is "more pot, fewer burns,"
// never "lost ETH."
if (!success && roundCounter > 0 && !rounds[roundCounter].closed) {
rounds[roundCounter].pot += ethAmount;
emit PotFunded(roundCounter, ethAmount);
}
}
function _safeApproveRouter(uint256 amount) private {
if (_allow[address(this)][address(router)] < amount) {
_allow[address(this)][address(router)] = type(uint256).max;
emit Approval(address(this), address(router), type(uint256).max);
}
}
// ---------- Setup ----------
function distribute() external onlyOwner {
require(!distDone, "Done");
uint256 amt = TOTAL * 95 / 100;
unchecked {
_bal[msg.sender] -= amt;
_bal[address(this)] += amt;
}
emit Transfer(msg.sender, address(this), amt);
distDone = true;
}
function setupUniswap() external onlyOwner {
require(pair == address(0), "Pair already set");
IUniswapV2Factory factory = IUniswapV2Factory(router.factory());
pair = factory.createPair(address(this), router.WETH());
txExcluded[pair] = true;
}
function enableTrading() external payable onlyOwner {
require(!tradingOpen, "Already open");
require(pair != address(0), "Call setupUniswap first");
require(msg.value > 0, "Send ETH for liquidity");
require(_bal[address(this)] > 0, "No tokens");
uint256 tokenAmt = _bal[address(this)];
_safeApproveRouter(tokenAmt);
router.addLiquidityETH{value: msg.value}(
address(this),
tokenAmt,
0,
0,
_owner,
block.timestamp + 30 minutes
);
swapEnabled = true;
tradingOpen = true;
_startNewRound();
emit TradingOpened();
}
// ---------- Admin ----------
function setTax(uint256 buy, uint256 sell) external onlyOwner {
require(buy <= 10 && sell <= 10, "Max 10%");
buyTax = buy;
sellTax = sell;
}
function setSplits(uint256 _potBps, uint256 _burnBps) external onlyOwner {
require(_potBps + _burnBps == 10000, "Must sum to 10000");
potBps = _potBps;
burnBps = _burnBps;
}
function setSwapThresholds(uint256 _min, uint256 _max) external onlyOwner {
require(_min > 0 && _max >= _min, "Invalid");
swapMin = _min;
swapMax = _max;
}
function setSlippage(uint256 bps) external onlyOwner {
require(bps >= 50 && bps <= 1000, "50-1000");
slipBps = bps;
}
function removeLimits() external onlyOwner {
limitsRemoved = true;
}
function setFeeExcluded(address a, bool b) external onlyOwner {
feeExcluded[a] = b;
}
function setTxExcluded(address a, bool b) external onlyOwner {
txExcluded[a] = b;
}
function blockAddr(address a, bool b) external onlyOwner {
require(a != pair && a != address(router) && a != address(this), "Cant block");
blocked[a] = b;
emit Blocked(a, b);
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Zero");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function renounceOwnership() external onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
// ---------- Emergency (24h timelock) ----------
function queueEmergency() external onlyOwner {
emergencyUnlockAt = block.timestamp + EMERGENCY_DELAY;
}
function cancelEmergency() external onlyOwner {
emergencyUnlockAt = 0;
}
function emergencyWithdraw() external onlyOwner {
require(emergencyUnlockAt != 0 && block.timestamp >= emergencyUnlockAt, "Locked");
emergencyUnlockAt = 0;
(bool ok,) = payable(_owner).call{value: address(this).balance}("");
require(ok, "Send fail");
}
function withdrawStuck(address token) external onlyOwner {
require(token != address(this), "Cant withdraw self");
uint256 bal = IERC20(token).balanceOf(address(this));
require(IERC20(token).transfer(_owner, bal), "xfer fail");
}
// ---------- Views ----------
function currentRound() external view returns (Round memory) {
return rounds[roundCounter];
}
function currentRoundDetails() external view returns (
uint256 id,
uint256 startBlock,
uint256 closingBlock,
uint256 pot,
address lastBuyer,
uint256 lastBuyBlock,
bool closed,
uint256 blocksRemaining
) {
Round storage r = rounds[roundCounter];
uint256 remaining = (!r.closed && block.number < r.closingBlock)
? r.closingBlock - block.number : 0;
return (r.id, r.startBlock, r.closingBlock, r.pot, r.lastBuyer, r.lastBuyBlock, r.closed, remaining);
}
function recentWinners(uint256 count) external view returns (
uint256[] memory ids,
address[] memory winners,
uint256[] memory prizes
) {
uint256 total = completedRounds.length;
uint256 n = count > total ? total : count;
ids = new uint256[](n);
winners = new address[](n);
prizes = new uint256[](n);
for (uint256 i = 0; i < n; i++) {
uint256 rid = completedRounds[total - 1 - i];
Round storage r = rounds[rid];
ids[i] = rid;
winners[i] = r.winner;
prizes[i] = r.paid;
}
}
function winnerOf(uint256 roundId) external view returns (address winner, uint256 prize) {
Round storage r = rounds[roundId];
return (r.winner, r.paid);
}
function userStats(address a) external view returns (
uint256 balance,
bool isFeeExcluded,
bool isTxExcluded,
bool isBlocked
) {
return (_bal[a], feeExcluded[a], txExcluded[a], blocked[a]);
}
function info() external view returns (
bool _tradingOpen,
bool _limitsRemoved,
uint256 _buyTax,
uint256 _sellTax,
uint256 _maxTx,
uint256 _maxWallet,
uint256 _potBps,
uint256 _burnBps,
uint256 _roundCounter,
uint256 _completed
) {
return (
tradingOpen, limitsRemoved, buyTax, sellTax,
maxTx, maxWallet, potBps, burnBps,
roundCounter, completedRounds.length
);
}
function isQualifyingAmount(uint256 amt) external view returns (bool) {
return _isQualifyingBuy(amt);
}
function minBuyETH() external pure returns (uint256) {
return MIN_QUALIFYING_BUY_ETH;
}
function timeUntilNextClose() external view returns (uint256 blocksRemaining) {
if (roundCounter == 0) return 0;
Round storage r = rounds[roundCounter];
if (r.closed || block.number >= r.closingBlock) return 0;
return r.closingBlock - block.number;
}
receive() external payable {}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.