编译器
0.8.19+commit.7dd6d404
文件 1 的 14:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 14:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC20Metadata.sol";
import "./Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
文件 3 的 14:ERC20Burnable.sol
pragma solidity ^0.8.0;
import "./ERC20.sol";
import "./Context.sol";
abstract contract ERC20Burnable is Context, ERC20 {
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
文件 4 的 14:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
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);
}
文件 5 的 14:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 6 的 14:IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
文件 7 的 14:IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
文件 8 的 14:IUniswapV2Router01.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
文件 9 的 14:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
文件 10 的 14:Initializable.sol
pragma solidity ^0.8.0;
abstract contract Initializable {
bool private _initialized;
bool private _initializing;
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
}
文件 11 的 14:Ownable.sol
pragma solidity ^0.8.0;
import "./Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 12 的 14:Ownable2Step.sol
pragma solidity ^0.8.0;
import "./Ownable.sol";
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
function acceptOwnership() public virtual {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}
文件 13 的 14:Token.sol
pragma solidity 0.8.19;
import "./ERC20.sol";
import "./ERC20Burnable.sol";
import "./Ownable2Step.sol";
import "./TokenRecover.sol";
import "./Initializable.sol";
import "./IUniswapV2Factory.sol";
import "./IUniswapV2Pair.sol";
import "./IUniswapV2Router01.sol";
import "./IUniswapV2Router02.sol";
contract TOTO is ERC20, ERC20Burnable, Ownable2Step, TokenRecover, Initializable {
uint16 public swapThresholdRatio;
uint256 private _moonwalletPending;
uint256 private _liquidityPending;
address public moonwalletAddress;
uint16[3] public moonwalletFees;
uint16[3] public liquidityFees;
mapping (address => bool) public isExcludedFromFees;
uint16[3] public totalFees;
bool private _swapping;
IUniswapV2Router02 public routerV2;
address public pairV2;
mapping (address => bool) public AMMPairs;
mapping (address => bool) public isExcludedFromLimits;
uint256 public maxWalletAmount;
uint256 public maxBuyAmount;
uint256 public maxSellAmount;
uint256 public maxTransferAmount;
bool public tradingEnabled;
mapping (address => bool) public isExcludedFromTradingRestriction;
event SwapThresholdUpdated(uint16 swapThresholdRatio);
event moonwalletAddressUpdated(address moonwalletAddress);
event moonwalletFeesUpdated(uint16 buyFee, uint16 sellFee, uint16 transferFee);
event moonwalletFeeSent(address recipient, uint256 amount);
event liquidityFeesUpdated(uint16 buyFee, uint16 sellFee, uint16 transferFee);
event liquidityAdded(uint amountToken, uint amountCoin, uint liquidity);
event ForceLiquidityAdded(uint256 leftoverTokens, uint256 unaddedTokens);
event ExcludeFromFees(address indexed account, bool isExcluded);
event RouterV2Updated(address indexed routerV2);
event AMMPairsUpdated(address indexed AMMPair, bool isPair);
event ExcludeFromLimits(address indexed account, bool isExcluded);
event MaxWalletAmountUpdated(uint256 maxWalletAmount);
event MaxBuyAmountUpdated(uint256 maxBuyAmount);
event MaxSellAmountUpdated(uint256 maxSellAmount);
event MaxTransferAmountUpdated(uint256 maxTransferAmount);
event TradingEnabled();
event ExcludeFromTradingRestriction(address indexed account, bool isExcluded);
constructor()
ERC20(unicode"TOTO", unicode"TOTO")
{
address supplyRecipient = 0x9617a3ba5613CeF36d9c816171CaEA9ce593d1a7;
updateSwapThreshold(50);
moonwalletAddressSetup(0xC479488194c8DdCb9E30971ee5492fFbf482cec9);
moonwalletFeesSetup(100, 300, 0);
liquidityFeesSetup(100, 100, 0);
excludeFromFees(supplyRecipient, true);
excludeFromFees(address(this), true);
_excludeFromLimits(supplyRecipient, true);
_excludeFromLimits(address(this), true);
_excludeFromLimits(address(0), true);
updateMaxWalletAmount(36000000000000 * (10 ** decimals()) / 10);
updateMaxBuyAmount(36000000000000 * (10 ** decimals()) / 10);
updateMaxSellAmount(36000000000000 * (10 ** decimals()) / 10);
updateMaxTransferAmount(36000000000000 * (10 ** decimals()) / 10);
excludeFromTradingRestriction(supplyRecipient, true);
excludeFromTradingRestriction(address(this), true);
_mint(supplyRecipient, 1200000000000000 * (10 ** decimals()) / 10);
_transferOwnership(0x9617a3ba5613CeF36d9c816171CaEA9ce593d1a7);
}
function initialize(address _router) initializer external {
_updateRouterV2(_router);
}
receive() external payable {}
function decimals() public pure override returns (uint8) {
return 9;
}
function _swapTokensForCoin(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = routerV2.WETH();
_approve(address(this), address(routerV2), tokenAmount);
routerV2.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, address(this), block.timestamp);
}
function updateSwapThreshold(uint16 _swapThresholdRatio) public onlyOwner {
require(_swapThresholdRatio > 0 && _swapThresholdRatio <= 500, "SwapThreshold: Cannot exceed limits from 0.01% to 5% for new swap threshold");
swapThresholdRatio = _swapThresholdRatio;
emit SwapThresholdUpdated(_swapThresholdRatio);
}
function getSwapThresholdAmount() public view returns (uint256) {
return balanceOf(pairV2) * swapThresholdRatio / 10000;
}
function getAllPending() public view returns (uint256) {
return 0 + _moonwalletPending + _liquidityPending;
}
function moonwalletAddressSetup(address _newAddress) public onlyOwner {
require(_newAddress != address(0), "TaxesDefaultRouterWallet: Wallet tax recipient cannot be a 0x0 address");
moonwalletAddress = _newAddress;
excludeFromFees(_newAddress, true);
_excludeFromLimits(_newAddress, true);
emit moonwalletAddressUpdated(_newAddress);
}
function moonwalletFeesSetup(uint16 _buyFee, uint16 _sellFee, uint16 _transferFee) public onlyOwner {
totalFees[0] = totalFees[0] - moonwalletFees[0] + _buyFee;
totalFees[1] = totalFees[1] - moonwalletFees[1] + _sellFee;
totalFees[2] = totalFees[2] - moonwalletFees[2] + _transferFee;
require(totalFees[0] <= 2500 && totalFees[1] <= 2500 && totalFees[2] <= 2500, "TaxesDefaultRouter: Cannot exceed max total fee of 25%");
moonwalletFees = [_buyFee, _sellFee, _transferFee];
emit moonwalletFeesUpdated(_buyFee, _sellFee, _transferFee);
}
function _swapAndLiquify(uint256 tokenAmount) private returns (uint256 leftover) {
uint256 halfAmount = tokenAmount / 2;
uint256 otherHalf = tokenAmount - halfAmount;
_swapTokensForCoin(halfAmount);
uint256 coinBalance = address(this).balance;
if (coinBalance > 0) {
(uint amountToken, uint amountCoin, uint liquidity) = _addLiquidity(otherHalf, coinBalance);
emit liquidityAdded(amountToken, amountCoin, liquidity);
return otherHalf - amountToken;
} else {
return otherHalf;
}
}
function _addLiquidity(uint256 tokenAmount, uint256 coinAmount) private returns (uint, uint, uint) {
_approve(address(this), address(routerV2), tokenAmount);
return routerV2.addLiquidityETH{value: coinAmount}(address(this), tokenAmount, 0, 0, address(0), block.timestamp);
}
function addLiquidityFromLeftoverTokens() external {
uint256 leftoverTokens = balanceOf(address(this)) - getAllPending();
uint256 unaddedTokens = _swapAndLiquify(leftoverTokens);
emit ForceLiquidityAdded(leftoverTokens, unaddedTokens);
}
function liquidityFeesSetup(uint16 _buyFee, uint16 _sellFee, uint16 _transferFee) public onlyOwner {
totalFees[0] = totalFees[0] - liquidityFees[0] + _buyFee;
totalFees[1] = totalFees[1] - liquidityFees[1] + _sellFee;
totalFees[2] = totalFees[2] - liquidityFees[2] + _transferFee;
require(totalFees[0] <= 2500 && totalFees[1] <= 2500 && totalFees[2] <= 2500, "TaxesDefaultRouter: Cannot exceed max total fee of 25%");
liquidityFees = [_buyFee, _sellFee, _transferFee];
emit liquidityFeesUpdated(_buyFee, _sellFee, _transferFee);
}
function excludeFromFees(address account, bool isExcluded) public onlyOwner {
isExcludedFromFees[account] = isExcluded;
emit ExcludeFromFees(account, isExcluded);
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
if (!_swapping && amount > 0 && to != address(routerV2) && !isExcludedFromFees[from] && !isExcludedFromFees[to]) {
uint256 fees = 0;
uint8 txType = 3;
if (AMMPairs[from]) {
if (totalFees[0] > 0) txType = 0;
}
else if (AMMPairs[to]) {
if (totalFees[1] > 0) txType = 1;
}
else if (totalFees[2] > 0) txType = 2;
if (txType < 3) {
fees = amount * totalFees[txType] / 10000;
amount -= fees;
_moonwalletPending += fees * moonwalletFees[txType] / totalFees[txType];
_liquidityPending += fees * liquidityFees[txType] / totalFees[txType];
}
if (fees > 0) {
super._transfer(from, address(this), fees);
}
}
bool canSwap = getAllPending() >= getSwapThresholdAmount() && balanceOf(pairV2) > 0;
if (!_swapping && !AMMPairs[from] && from != address(routerV2) && canSwap) {
_swapping = true;
if (false || _moonwalletPending > 0) {
uint256 token2Swap = 0 + _moonwalletPending;
bool success = false;
_swapTokensForCoin(token2Swap);
uint256 coinsReceived = address(this).balance;
uint256 moonwalletPortion = coinsReceived * _moonwalletPending / token2Swap;
if (moonwalletPortion > 0) {
success = payable(moonwalletAddress).send(moonwalletPortion);
if (success) {
emit moonwalletFeeSent(moonwalletAddress, moonwalletPortion);
}
}
_moonwalletPending = 0;
}
if (_liquidityPending > 0) {
_swapAndLiquify(_liquidityPending);
_liquidityPending = 0;
}
_swapping = false;
}
super._transfer(from, to, amount);
}
function _updateRouterV2(address router) private {
routerV2 = IUniswapV2Router02(router);
pairV2 = IUniswapV2Factory(routerV2.factory()).createPair(address(this), routerV2.WETH());
_excludeFromLimits(router, true);
_setAMMPair(pairV2, true);
emit RouterV2Updated(router);
}
function setAMMPair(address pair, bool isPair) external onlyOwner {
require(pair != pairV2, "DefaultRouter: Cannot remove initial pair from list");
_setAMMPair(pair, isPair);
}
function _setAMMPair(address pair, bool isPair) private {
AMMPairs[pair] = isPair;
if (isPair) {
_excludeFromLimits(pair, true);
}
emit AMMPairsUpdated(pair, isPair);
}
function excludeFromLimits(address account, bool isExcluded) external onlyOwner {
_excludeFromLimits(account, isExcluded);
}
function _excludeFromLimits(address account, bool isExcluded) internal {
isExcludedFromLimits[account] = isExcluded;
emit ExcludeFromLimits(account, isExcluded);
}
function updateMaxWalletAmount(uint256 _maxWalletAmount) public onlyOwner {
require(_maxWalletAmount >= _maxWalletSafeLimit(), "MaxWallet: Limit too low");
maxWalletAmount = _maxWalletAmount;
emit MaxWalletAmountUpdated(_maxWalletAmount);
}
function _maxWalletSafeLimit() private view returns (uint256) {
return totalSupply() / 1000;
}
function _maxTxSafeLimit() private view returns (uint256) {
return totalSupply() * 5 / 10000;
}
function updateMaxBuyAmount(uint256 _maxBuyAmount) public onlyOwner {
require(_maxBuyAmount >= _maxTxSafeLimit(), "MaxTx: Limit too low");
maxBuyAmount = _maxBuyAmount;
emit MaxBuyAmountUpdated(_maxBuyAmount);
}
function updateMaxSellAmount(uint256 _maxSellAmount) public onlyOwner {
require(_maxSellAmount >= _maxTxSafeLimit(), "MaxTx: Limit too low");
maxSellAmount = _maxSellAmount;
emit MaxSellAmountUpdated(_maxSellAmount);
}
function updateMaxTransferAmount(uint256 _maxTransferAmount) public onlyOwner {
require(_maxTransferAmount >= _maxTxSafeLimit(), "MaxTx: Limit too low");
maxTransferAmount = _maxTransferAmount;
emit MaxTransferAmountUpdated(_maxTransferAmount);
}
function enableTrading() external onlyOwner {
require(!tradingEnabled, "EnableTrading: Trading was enabled already");
tradingEnabled = true;
emit TradingEnabled();
}
function excludeFromTradingRestriction(address account, bool isExcluded) public onlyOwner {
isExcludedFromTradingRestriction[account] = isExcluded;
emit ExcludeFromTradingRestriction(account, isExcluded);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
override
{
if (AMMPairs[from] && !isExcludedFromLimits[to]) {
require(amount <= maxBuyAmount, "MaxTx: Cannot exceed max buy limit");
}
if (AMMPairs[to] && !isExcludedFromLimits[from]) {
require(amount <= maxSellAmount, "MaxTx: Cannot exceed max sell limit");
}
if (!AMMPairs[to] && !isExcludedFromLimits[from]) {
require(amount <= maxTransferAmount, "MaxTx: Cannot exceed max transfer limit");
}
if ((AMMPairs[from] && !isExcludedFromTradingRestriction[to]) || (AMMPairs[to] && !isExcludedFromTradingRestriction[from])) {
require(tradingEnabled, "EnableTrading: Trading was not enabled yet");
}
super._beforeTokenTransfer(from, to, amount);
}
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override
{
if (!isExcludedFromLimits[to]) {
require(balanceOf(to) <= maxWalletAmount, "MaxWallet: Cannot exceed max wallet limit");
}
super._afterTokenTransfer(from, to, amount);
}
}
文件 14 的 14:TokenRecover.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./Ownable2Step.sol";
abstract contract TokenRecover is Ownable2Step {
function recoverERC20(address tokenAddress, uint256 amount) external onlyOwner {
require(tokenAddress != address(this), "TokenRecover: Cannot recover this token");
IERC20(tokenAddress).transfer(owner(), amount);
}
}
{
"compilationTarget": {
"Token.sol": "TOTO"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"AMMPair","type":"address"},{"indexed":false,"internalType":"bool","name":"isPair","type":"bool"}],"name":"AMMPairsUpdated","type":"event"},{"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":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludeFromFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludeFromLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludeFromTradingRestriction","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"leftoverTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unaddedTokens","type":"uint256"}],"name":"ForceLiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxBuyAmount","type":"uint256"}],"name":"MaxBuyAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxSellAmount","type":"uint256"}],"name":"MaxSellAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxTransferAmount","type":"uint256"}],"name":"MaxTransferAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxWalletAmount","type":"uint256"}],"name":"MaxWalletAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"routerV2","type":"address"}],"name":"RouterV2Updated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"swapThresholdRatio","type":"uint16"}],"name":"SwapThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"TradingEnabled","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountCoin","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"liquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"buyFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"sellFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"transferFee","type":"uint16"}],"name":"liquidityFeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"moonwalletAddress","type":"address"}],"name":"moonwalletAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"moonwalletFeeSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"buyFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"sellFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"transferFee","type":"uint16"}],"name":"moonwalletFeesUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"AMMPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addLiquidityFromLeftoverTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"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":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"excludeFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"excludeFromLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"excludeFromTradingRestriction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllPending","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapThresholdAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromLimits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromTradingRestriction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"liquidityFees","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_buyFee","type":"uint16"},{"internalType":"uint16","name":"_sellFee","type":"uint16"},{"internalType":"uint16","name":"_transferFee","type":"uint16"}],"name":"liquidityFeesSetup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxBuyAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSellAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransferAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWalletAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"moonwalletAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newAddress","type":"address"}],"name":"moonwalletAddressSetup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"moonwalletFees","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_buyFee","type":"uint16"},{"internalType":"uint16","name":"_sellFee","type":"uint16"},{"internalType":"uint16","name":"_transferFee","type":"uint16"}],"name":"moonwalletFeesSetup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pairV2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"routerV2","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"isPair","type":"bool"}],"name":"setAMMPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapThresholdRatio","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalFees","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","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":[{"internalType":"uint256","name":"_maxBuyAmount","type":"uint256"}],"name":"updateMaxBuyAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxSellAmount","type":"uint256"}],"name":"updateMaxSellAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxTransferAmount","type":"uint256"}],"name":"updateMaxTransferAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxWalletAmount","type":"uint256"}],"name":"updateMaxWalletAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_swapThresholdRatio","type":"uint16"}],"name":"updateSwapThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]