From b8b007873924704b8a77c3933464b6583aa7790c Mon Sep 17 00:00:00 2001 From: 0xbeekeeper Date: Thu, 25 Jul 2024 17:04:55 +0800 Subject: [PATCH] fix: change risk title and samples --- mkdocs.yml | 4 +- src/TRC-009/samples/01.sol | 1366 +++++++++++++++++++--- src/TRC-009/samples/02.sol | 1124 +++++------------- src/TRC-009/samples/03.sol | 2225 +++++++++++++++++++---------------- src/TRC-009/samples/04.sol | 1476 +++++++----------------- src/TRC-013/samples/01.sol | 1366 +++------------------- src/TRC-013/samples/02.sol | 1124 +++++++++++++----- src/TRC-013/samples/03.sol | 2229 ++++++++++++++++-------------------- src/TRC-013/samples/04.sol | 1476 +++++++++++++++++------- 9 files changed, 6195 insertions(+), 6195 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 85f30e5..9016106 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -23,11 +23,11 @@ nav: - TRC-006 SelfDestruction: TRC-006.md - TRC-007 ExternalInvocation: TRC-007.md - TRC-008 BlackListFunction: TRC-008.md - - TRC-009 FullSaleRestriction: TRC-009.md + - TRC-009 WhiteListFunction: TRC-009.md - TRC-010 SlippageModification: TRC-010.md - TRC-011 TransferPausable: TRC-011.md - TRC-012 PersonalSlippageModification: TRC-012.md - - TRC-013 TransactionWhitelisting: TRC-013.md + - TRC-013 SaleRestriction: TRC-013.md - TRC-014 AntiWhale: TRC-014.md - TRC-015 AntiWhaleModification: TRC-015.md - TRC-016 TradingCooldown: TRC-016.md diff --git a/src/TRC-009/samples/01.sol b/src/TRC-009/samples/01.sol index 0115992..9d0adf8 100644 --- a/src/TRC-009/samples/01.sol +++ b/src/TRC-009/samples/01.sol @@ -1,233 +1,1329 @@ /** - *Submitted for verification at BscScan.com on 2022-05-26 + *Submitted for verification at BscScan.com on 2022-02-26 */ -//SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.4.25; +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.6; -library SafeMath { - - function mul(uint256 a, uint256 b) internal pure returns (uint256) { - if (a == 0) { - return 0; - } - uint256 c = a * b; - require(c / a == b); - return c; +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; } - function div(uint256 a, uint256 b) internal pure returns (uint256) { - require(b > 0); - uint256 c = a / b; - return c; + 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; } +} - function sub(uint256 a, uint256 b) internal pure returns (uint256) { - require(b <= a); - uint256 c = a - b; - return c; - } +interface IUniswapV2Pair { + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); + event Transfer(address indexed from, address indexed to, uint256 value); - function add(uint256 a, uint256 b) internal pure returns (uint256) { - uint256 c = a + b; - require(c >= a); - return c; - } + function name() external pure returns (string memory); - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0); - return a % b; - } -} + function symbol() external pure returns (string memory); -contract Ownable { - address public owner; + function decimals() external pure returns (uint8); - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + function totalSupply() external view returns (uint256); - modifier onlyOwner() { - require(msg.sender == owner); - _; - } + function balanceOf(address owner) external view returns (uint256); - function transferOwnership(address newOwner) public onlyOwner { - require(newOwner != address(0)); - emit OwnershipTransferred(owner, newOwner); - owner = newOwner; - } + function allowance(address owner, address spender) + external + view + returns (uint256); - function renounceOwnership() public onlyOwner { - emit OwnershipTransferred(owner, address(0)); - owner = address(0); - } -} + 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); -contract BaseToken is Ownable { + function DOMAIN_SEPARATOR() external view returns (bytes32); - using SafeMath for uint256; + 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; - string constant public name = 'Goku Inu (GOKU)'; + event Mint(address indexed sender, uint256 amount0, uint256 amount1); + event Burn( + address indexed sender, + uint256 amount0, + uint256 amount1, + address indexed to + ); + event Swap( + address indexed sender, + uint256 amount0In, + uint256 amount1In, + uint256 amount0Out, + uint256 amount1Out, + address indexed to + ); + event Sync(uint112 reserve0, uint112 reserve1); - string constant public symbol = 'GOKU'; + function MINIMUM_LIQUIDITY() external pure returns (uint256); - uint8 constant public decimals = 9; + function factory() external view returns (address); - uint256 public totalSupply = 1000000 * 10 ** 9; + function token0() external view returns (address); - uint256 public constant MAXSupply = 10000000000000000000000000000000000000000000000000 * 10 ** uint256(decimals); + function token1() external view returns (address); - mapping (address => uint256) public balanceOf; - mapping (address => mapping (address => uint256)) public allowance; + function getReserves() + external + view + returns ( + uint112 reserve0, + uint112 reserve1, + uint32 blockTimestampLast + ); - mapping(address => bool) private _isExcludedFromFee; + function price0CumulativeLast() external view returns (uint256); - mapping(address => bool) private _locked; - mapping(address => bool) public admins; + function price1CumulativeLast() external view returns (uint256); - uint256 public _taxFee = 0; - uint256 private _previousTaxFee = _taxFee; + function kLast() external view returns (uint256); - uint256 public _burnFee = 6; - uint256 private _previousBurnFee = _burnFee; + function mint(address to) external returns (uint256 liquidity); + function burn(address to) + external + returns (uint256 amount0, uint256 amount1); - address public burnAddress = 0x000000000000000000000000000000000000dEaD; + 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 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 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); + + /** + * @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); - event Approval(address indexed owner, address indexed spender, uint256 value); - modifier onlyAdmin() { - require(admins[msg.sender] == true); + /** + * @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 + ); +} + +interface IERC20Metadata is IERC20 { + /** + * @dev Returns the name of the token. + */ + function name() external view returns (string memory); + + /** + * @dev Returns the symbol of the token. + */ + function symbol() external view returns (string memory); + + /** + * @dev Returns the decimals places of the token. + */ + function decimals() external view returns (uint8); +} + +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"); _; } - function _transfer(address from, address to, uint value) internal { - require(to != address(0), "is 0 address"); + /** + * @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); + } - require(!_locked[from], "is locked"); + /** + * @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; + } +} - if(_isExcludedFromFee[from]) - removeAllFee(); +contract ERC20 is Ownable, IERC20, IERC20Metadata { + using SafeMath for uint256; - uint256 fee = 0; + mapping(address => uint256) private _balances; - uint256 burn = 0; + mapping(address => mapping(address => uint256)) private _allowances; - balanceOf[from] = balanceOf[from].sub(value); + uint256 private _totalSupply; - balanceOf[to] = balanceOf[to].add(value).sub(fee).sub(burn); + string private _name; + string private _symbol; - if(burn > 0) { - balanceOf[burnAddress] = balanceOf[burnAddress].add(burn); - emit Transfer(from, burnAddress, burn); - } + /** + * @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 override returns (string memory) { + return _name; + } - if(_isExcludedFromFee[from]) - restoreAllFee(); + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } - emit Transfer(from, to, value); + /** + * @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 override returns (uint8) { + return 18; } + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) + public + view + virtual + override + returns (uint256) + { + return _balances[account]; + } - function transfer(address to, uint256 value) public returns (bool) { - _transfer(msg.sender, to, value); + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) + public + virtual + override + returns (bool) + { + _transfer(_msgSender(), recipient, amount); return true; } - function transferFrom(address from, address to, uint256 value) public returns (bool) { - allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); - _transfer(from, to, value); + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) + public + view + virtual + override + returns (uint256) + { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) + public + virtual + override + returns (bool) + { + _approve(_msgSender(), spender, amount); return true; } - function approve(address spender, uint256 value) public returns (bool) { - require(spender != address(0)); - allowance[msg.sender][spender] = value; - emit Approval(msg.sender, spender, value); + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * 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 + ) public virtual 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 returns (bool) { - require(spender != address(0)); - allowance[msg.sender][spender] = allowance[msg.sender][spender].add(addedValue); - emit Approval(msg.sender, spender, allowance[msg.sender][spender]); + /** + * @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) + { + _approve( + _msgSender(), + spender, + _allowances[_msgSender()][spender].add(addedValue) + ); return true; } - function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { - require(spender != address(0)); - allowance[msg.sender][spender] = allowance[msg.sender][spender].sub(subtractedValue); - emit Approval(msg.sender, spender, allowance[msg.sender][spender]); + /** + * @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) + { + _approve( + _msgSender(), + spender, + _allowances[_msgSender()][spender].sub( + subtractedValue, + "ERC20: decreased allowance below zero" + ) + ); return true; } - function setAdmin(address _address) public onlyOwner { - require(!admins[_address], "5"); // Already Admin - admins[_address] = 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 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); + + _transferToken(sender,recipient,amount); } - function removeAdmin(address _address) public onlyOwner { - require(admins[_address], "7"); // Not an Admin - admins[_address] = false; + + function _transferToken( + address sender, + address recipient, + uint256 amount + ) internal virtual { + _balances[sender] = _balances[sender].sub( + amount, + "ERC20: transfer amount exceeds balance" + ); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); } - function calculateTaxFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_taxFee).div( - 10 ** 2 - ); + /** @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: + * + * - `account` cannot be the zero address. + */ + function _mint(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: mint to the zero address"); + + _beforeTokenTransfer(address(0), account, amount); + + _totalSupply = _totalSupply.add(amount); + _balances[account] = _balances[account].add(amount); + emit Transfer(address(0), account, amount); } - function calculateBurnFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_burnFee).div( - 10 ** 2 + /** + * @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 virtual { + require(account != address(0), "ERC20: burn from the zero address"); + + _beforeTokenTransfer(account, address(0), amount); + + _balances[account] = _balances[account].sub( + amount, + "ERC20: 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 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 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 removeAllFee() private { - if(_taxFee == 0 && _burnFee == 0) - return; + /** + * @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, `amount` of ``from``'s tokens + * will be to transferred to `to`. + * - when `from` is zero, `amount` tokens will be minted for `to`. + * - when `to` is zero, `amount` 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 amount + ) internal virtual {} +} + - _previousTaxFee = _taxFee; - _previousBurnFee = _burnFee; - _taxFee = 0; - _burnFee = 0; +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; } - function restoreAllFee() private { - _taxFee = _previousTaxFee; - _burnFee = _previousBurnFee; + /** + * @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; - function SL(address account) public onlyAdmin { - _locked[account] = true; + 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; + } - function SUL(address account) public onlyAdmin { - _locked[account] = false; + 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; + } - function isLocked(address account) public view returns (bool) { + /** + * @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"); + } - return _locked[account]; + /** + * @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; } +} +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; } +contract DAO is ERC20 { + using SafeMath for uint256; + mapping(address => address) public inviter; + IUniswapV2Router02 public uniswapV2Router; + address public uniswapV2Pair; + address _tokenOwner; + bool private swapping; + uint256 public swapTokensAtAmount; + address payable _reciverBnb = payable(address(0xe23E7E0987BF877486b05F02c95a7BE9af4a42Ec)); + address private _destroyAddress = address(0x000000000000000000000000000000000000dEaD); + address private _fundAddress = address(0x82AebB07C78f8871E6C9C7A5be4D7E6E21642d7c); + address public inviterAddress = address(0xAF8c5337A8c220a3456861115F447370820D9C2C); + mapping(address => bool) private _isExcludedFromFees; + mapping(address => bool) public automatedMarketMakerPairs; + + bool public swapAndLiquifyEnabled = true; + uint256 public maxdestroy; + uint256 public additional; + + address[] buyUser; + mapping(address => bool) public havePush; + + event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); + event ExcludeFromFees(address indexed account, bool isExcluded); + event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); + event SwapAndSendTo( + address target, + uint256 amount, + string to + ); + + + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived + ); + + + constructor(address tokenOwner) ERC20("DAO", "DAO") { + + // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); + IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); + // Create a uniswap pair for this new token + address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) + .createPair(address(this), _uniswapV2Router.WETH()); + _approve(address(this), address(0x10ED43C718714eb63d5aA57B78B54704E256024E), 10**29); + uniswapV2Router = _uniswapV2Router; + uniswapV2Pair = _uniswapV2Pair; + + _setAutomatedMarketMakerPair(_uniswapV2Pair, true); + excludeFromFees(tokenOwner, true); + excludeFromFees(address(this), true); + _tokenOwner = tokenOwner; + uint256 total = 2100 * 10**22; + additional = 300 * 10**22; + maxdestroy = total.div(100).mul(99); + swapTokensAtAmount = 1 * 10**18; + _mint(tokenOwner, total); + } + + receive() external payable { -contract MCFC is BaseToken { + } + + function updateUniswapV2Router(address newAddress) public onlyOwner { + emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); + uniswapV2Router = IUniswapV2Router02(newAddress); + } + + function excludeFromFees(address account, bool excluded) public onlyOwner { + _isExcludedFromFees[account] = excluded; + emit ExcludeFromFees(account, excluded); + } - constructor() public { - balanceOf[msg.sender] = totalSupply; - emit Transfer(address(0), msg.sender, totalSupply); + function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { + for (uint256 i = 0; i < accounts.length; i++) { + _isExcludedFromFees[accounts[i]] = excluded; + } - owner = msg.sender; + emit ExcludeMultipleAccountsFromFees(accounts, excluded); + } + function setSwapTokensAtAmount(uint256 _swapTokensAtAmount) public onlyOwner { + swapTokensAtAmount = _swapTokensAtAmount; + } + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + } + function _setAutomatedMarketMakerPair(address pair, bool value) private { + automatedMarketMakerPairs[pair] = value; + } + + function isExcludedFromFees(address account) public view returns (bool) { + return _isExcludedFromFees[account]; + } + + function _transfer( + address from, + address to, + uint256 amount + ) internal override { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + + if(address(this) == from || address(this) == to){ + super._transfer(from, to, amount); + return; + } + + if(balanceOf(address(this)) >= swapTokensAtAmount){ + if ( + !swapping && + _tokenOwner != from && + _tokenOwner != to && + from != uniswapV2Pair && + swapAndLiquifyEnabled + ) { + swapping = true; + uint256 haveAmount = balanceOf(address(this)); + swapAndLiquifyV1(haveAmount); + swapping = false; + } + } + + _splitOtherToken(); + bool shouldSetInviter = balanceOf(to) == 0 && inviter[to] == address(0) && from != uniswapV2Pair; + bool takeFee = !swapping; + if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { + takeFee = false; + }else{ + if(from != uniswapV2Pair && to != uniswapV2Pair){ + takeFee = false; + } + } + if (takeFee) { + super._transfer(from, uniswapV2Pair, amount.div(50)); + super._transfer(from, _destroyAddress, amount.div(100).mul(3)); + super._transfer(from, _fundAddress, amount.div(100)); + super._transfer(from, address(this), amount.div(50)); + _takeInviterAdditionalFee(from, to, amount); + uint256 additionalAmount = amount.div(100).mul(8); + if(additional>=additionalAmount && balanceOf(address(this)) >= additionalAmount){ + additional = additional.sub(additionalAmount); + _takeInviterAdditionalFeeV2(from, to, amount); + } + amount = amount.div(100).mul(85); + } + super._transfer(from, to, amount); + + if (shouldSetInviter) {inviter[to] = from;} + } + + function swapAndLiquifyV1(uint256 contractTokenBalance) private { + swapTokensForETH(contractTokenBalance); + } + + 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(); + + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + + + function rescueToken(address tokenAddress, uint256 tokens) + public + onlyOwner + returns (bool success) + { + return IERC20(tokenAddress).transfer(msg.sender, tokens); + } + + function _splitOtherToken() public { + uint256 thisAmount = address(this).balance; + if(thisAmount > 10**10){ + _reciverBnb.transfer(thisAmount); + } + } + + function _takeInviterAdditionalFee( + address sender, + address recipient, + uint256 tAmount + ) private { + address cur; + address reciver; + if (sender == uniswapV2Pair) { + cur = recipient; + } else { + cur = sender; + } + + for (int256 i = 0; i < 10; i++) { + uint256 minBalance; + uint256 rate; + if (i == 0) { + rate = 20; + minBalance = 1000 * 10**18; + } else if (i <= 1) { + rate = 10; + minBalance = 3000 * 10**18; + } else if (i <= 2) { + rate = 10; + minBalance = 5000 * 10**18; + } else if (i <= 3) { + rate = 10; + minBalance = 10000 * 10**18; + } else if (i <= 4) { + rate = 5; + minBalance = 20000 * 10**18; + } else if (i <= 5) { + rate = 5; + minBalance = 25000 * 10**18; + } else if (i <= 6) { + rate = 5; + minBalance = 30000 * 10**18; + } else if (i <= 7) { + rate = 5; + minBalance = 35000 * 10**18; + } else if (i <= 8) { + rate = 5; + minBalance = 40000 * 10**18; + } else if (i <= 9) { + rate = 5; + minBalance = 50000 * 10**18; + } + cur = inviter[cur]; + if (cur == address(0) || balanceOf(cur) < minBalance) { + reciver = inviterAddress; + }else{ + reciver = cur; + } + super._transfer(sender, reciver, tAmount.div(1000).mul(rate)); + } + } + + + function _takeInviterAdditionalFeeV2( + address sender, + address recipient, + uint256 tAmount + ) private { + address cur; + address reciver; + if (sender == uniswapV2Pair) { + cur = recipient; + } else { + cur = sender; + } + + for (int256 i = 0; i < 10; i++) { + uint256 minBalance; + uint256 rate; + if (i == 0) { + rate = 20; + minBalance = 1000 * 10**18; + } else if (i <= 1) { + rate = 10; + minBalance = 3000 * 10**18; + } else if (i <= 2) { + rate = 10; + minBalance = 5000 * 10**18; + } else if (i <= 3) { + rate = 10; + minBalance = 10000 * 10**18; + } else if (i <= 4) { + rate = 5; + minBalance = 20000 * 10**18; + } else if (i <= 5) { + rate = 5; + minBalance = 25000 * 10**18; + } else if (i <= 6) { + rate = 5; + minBalance = 30000 * 10**18; + } else if (i <= 7) { + rate = 5; + minBalance = 35000 * 10**18; + } else if (i <= 8) { + rate = 5; + minBalance = 40000 * 10**18; + } else if (i <= 9) { + rate = 5; + minBalance = 50000 * 10**18; + } + cur = inviter[cur]; + if (cur == address(0) || balanceOf(cur) < minBalance) { + reciver = inviterAddress; + }else{ + reciver = cur; + } + super._transfer(address(this), reciver, tAmount.div(1000).mul(rate)); + } } } \ No newline at end of file diff --git a/src/TRC-009/samples/02.sol b/src/TRC-009/samples/02.sol index 0ffa9e9..f09d4ac 100644 --- a/src/TRC-009/samples/02.sol +++ b/src/TRC-009/samples/02.sol @@ -1,103 +1,8 @@ -/** - *Submitted for verification at BscScan.com on 2021-07-10 -*/ - -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); -} +pragma solidity ^0.6.12; -/** - * @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"); @@ -105,30 +10,10 @@ library SafeMath { 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; @@ -136,20 +21,7 @@ library SafeMath { 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; } @@ -160,566 +32,124 @@ library SafeMath { 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; - } +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); - 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; - } + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); } - -/** - * @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); - } - } +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return msg.sender; } } -/** - * @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 { +abstract 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 () internal { - address msgSender = _msgSender(); - _owner = msgSender; - emit OwnershipTransferred(address(0), msgSender); + constructor() internal { + _transferOwnership(_msgSender()); } - /** - * @dev Returns the address of the current owner. - */ - function owner() public view returns (address) { + function owner() public view virtual 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"); + 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); + _transferOwnership(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 { + function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); - emit OwnershipTransferred(_owner, newOwner); - if (_owner == address(0)) - _owner = newOwner; + _transferOwnership(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; + function _transferOwnership(address newOwner) internal virtual { + address oldOwner = _owner; + _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); + } } -contract DogePooPoo is Context, IERC20, Ownable { +contract MHC 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; - + mapping (address => bool) public _isExcludedFee; + mapping (address => bool) public _isNotSwapPair; + mapping (address => bool) public _roler; + mapping (address => address) public inviter; + uint256 private constant MAX = ~uint256(0); - uint256 private _tTotal = 1000000 * 10**6 * 10**9; + uint256 private _tTotal = 50000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); - uint256 private _tFeeTotal; - - string private _name = "Doge Poo Poo"; - string private _symbol = "DogePooPoo"; - uint8 private _decimals = 9; - - uint256 public _taxFee = 1; - uint256 private _previousTaxFee = _taxFee; - uint256 public _liquidityFee = 1; - uint256 private _previousLiquidityFee = _liquidityFee; + string private _name = "Meta Hero Coin"; + string private _symbol = "MHC"; + uint8 private _decimals = 18; - bool private _swap = true; + bool public _stopAllFee; + uint256 public _tFundTotal; + uint256 public _tBurnFeeTotal; + uint256 public _maxBurnFee = 40000000 * 10 ** 18; - IUniswapV2Router02 public immutable uniswapV2Router; - address public immutable uniswapV2Pair; + uint256 private _burnFee= 3; + uint256 private _previousBurnFee = _burnFee; - bool inSwapAndLiquify; - bool public swapAndLiquifyEnabled = true; + uint256 private _elseFee = 10; + uint256 private _previousElseFee = _elseFee; - uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; - event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); - event SwapAndLiquifyEnabledUpdated(bool enabled); - event SwapAndLiquify( - uint256 tokensSwapped, - uint256 ethReceived, - uint256 tokensIntoLiqudity - ); + address public burnAddress = address(0x000000000000000000000000000000000000dEaD); + address public mainAddres = address(0xfbDBA9fF091938E98f751aa268876c3b100577A4); + address public gameAddress = address(0x701cC686eD34C242229a9f883F057EF887B42eCc); + address public dividendAddress = address(0x36F1A4C1cfFD58E2cC5094B7FEf9a22A0ae75fE8); + address public fundAddress = address(0x17FB81FE4ee6808A6C56570C8AF6810fC156C98f); + address public devAddress = address(0xdBdDa37A37F43522b89e5a5811FAc0f949355B1F); - 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); + _isExcludedFee[mainAddres] = true; + _isExcludedFee[address(this)] = true; + + _rOwned[mainAddres] = _rTotal; + emit Transfer(address(0), mainAddres, _tTotal); } function name() public view returns (string memory) { @@ -730,16 +160,15 @@ contract DogePooPoo is Context, IERC20, Ownable { return _symbol; } - function decimals() public view returns (uint8) { - return _decimals; + function decimals() public pure returns (uint8) { + return 18; } - + 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]); } @@ -752,6 +181,70 @@ contract DogePooPoo is Context, IERC20, Ownable { return _allowances[owner][spender]; } + function isContract(address account) internal view returns (bool) { + uint256 size; + assembly { + size := extcodesize(account) + } + return size > 0; + } + + //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(); + } + _transferStandard(sender, recipient, amount, takeFee); + if(!takeFee) { + restoreAllFee(); + } + } + + function _transferStandard(address sender, address recipient, uint256 tAmount, bool takeFee) private { + (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tElseFee, uint256 tBurnFee) + = _getValues(tAmount); + + _rOwned[sender] = _rOwned[sender].sub(rAmount); + _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); + emit Transfer(sender, recipient, tTransferAmount); + + if (_stopAllFee == true) { + _reflectFund(); + } + if (!takeFee) { + return; + } + _takeBurn(sender, tBurnFee); // 3% + _takeFund(tElseFee / 10); // 1% + _takeDividend(sender, tElseFee * 2 / 10); // 2% + _takeGame(sender, tElseFee * 3 / 10); // 3% + _takeInviterFee(sender, recipient, tAmount); // 3% + _takeDevFund(sender, tElseFee / 10); // 1% + } + + function _takeInviterFee( + address sender, address recipient, uint256 tAmount + ) private { + uint256 currentRate = _getRate(); + + address cur = sender; + if (isContract(sender) && !_isNotSwapPair[sender]) { + cur = recipient; + } + uint8[2] memory inviteRate = [1, 2]; + for (uint8 i = 0; i < inviteRate.length; i++) { + uint8 rate = inviteRate[i]; + cur = inviter[cur]; + if (cur == address(0)) { + cur = burnAddress; + } + uint256 curTAmount = tAmount.mul(rate).div(100); + uint256 curRAmount = curTAmount.mul(currentRate); + _rOwned[cur] = _rOwned[cur].add(curRAmount); + emit Transfer(sender, cur, curTAmount); + } + } + function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; @@ -773,21 +266,13 @@ contract DogePooPoo is Context, IERC20, Ownable { return true; } - function isExcludedFromReward(address account) public view returns (bool) { - return _isExcluded[account]; - } - - function totalFees() public view returns (uint256) { - return _tFeeTotal; - } - 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); + (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { - (,uint256 rTransferAmount,,,,) = _getValues(tAmount); + (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } @@ -798,82 +283,104 @@ contract DogePooPoo is Context, IERC20, Ownable { 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 _takeBurn(address sender,uint256 tBurn) private { + uint256 currentRate = _getRate(); + uint256 rBurn = tBurn.mul(currentRate); + _rOwned[burnAddress] = _rOwned[burnAddress].add(rBurn); + emit Transfer(sender, burnAddress, tBurn); + _tBurnFeeTotal = _tBurnFeeTotal.add(tBurn); + } + + function _takeGame(address sender, uint256 tGame) private { + uint256 currentRate = _getRate(); + uint256 rGame = tGame.mul(currentRate); + _rOwned[gameAddress] = _rOwned[gameAddress].add(rGame); + emit Transfer(sender, gameAddress, tGame); + } + + function _takeFund(uint256 tFund) private { + _tFundTotal = _tFundTotal.add(tFund); } - 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 _takeDevFund(address sender, uint256 tDevFund) private { + uint256 currentRate = _getRate(); + uint256 rDevFund = tDevFund.mul(currentRate); + _rOwned[devAddress] = _rOwned[devAddress].add(rDevFund); + emit Transfer(sender, devAddress, tDevFund); } - 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 _takeDividend(address sender, uint256 tDividend) private { + uint256 currentRate = _getRate(); + uint256 rDividend = tDividend.mul(currentRate); + _rOwned[dividendAddress] = _rOwned[dividendAddress].add(rDividend); + emit Transfer(sender, dividendAddress, tDividend); } - - function excludeFromFee(address account) public onlyOwner { - _isExcludedFromFee[account] = true; + + function setSwapRoler(address addr, bool state) public onlyOwner { + _roler[addr] = state; } - - function includeInFee(address account) public onlyOwner { - _isExcludedFromFee[account] = false; + + function setExcludedFee(address addr, bool state) public onlyOwner { + _isExcludedFee[addr] = state; } - function setSwap(bool swap) public onlyOwner { - _swap = swap; + function setMainAddress(address addr) public onlyOwner { + mainAddres = addr; } - function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { - swapAndLiquifyEnabled = _enabled; - emit SwapAndLiquifyEnabledUpdated(_enabled); + function setGameAddress(address addr) public onlyOwner { + gameAddress = addr; } - - //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 setDividendAddress(address addr) public onlyOwner{ + dividendAddress = addr; } - 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 setFundAddress(address addr) public onlyOwner { + fundAddress = addr; + } + + function setDevAddress(address addr) public onlyOwner { + devAddress = addr; + } + + receive() external payable {} + + function _reflectFund() private { + if (_tFundTotal == 0) return; + uint256 currentRate = _getRate(); + uint256 rFundTotal = _tFundTotal.mul(currentRate); + _rOwned[fundAddress] = _rOwned[fundAddress].add(rFundTotal.div(2)); + emit Transfer(address(this), fundAddress, _tFundTotal.div(2)); + + _rTotal = _rTotal.sub(rFundTotal.div(2)); + _tFundTotal = 0; + } + + function _getValues(uint256 tAmount) private view returns + (uint256, uint256, uint256, uint256, uint256) { + (uint256 tTransferAmount, uint256 tElseFee, uint256 tBurnFee) = _getTValues(tAmount); + (uint256 rAmount, uint256 rTransferAmount) = + _getRValues(tAmount, tElseFee, tBurnFee, _getRate()); + return (rAmount, rTransferAmount, tTransferAmount, tElseFee, tBurnFee); } 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); + uint256 tElseFee = calculateElseFee(tAmount); + uint256 tBurnFee = calculateBurnFee(tAmount); + + uint256 tTransferAmount = tAmount.sub(tElseFee).sub(tBurnFee); + return (tTransferAmount, tElseFee, tBurnFee); } - function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { + function _getRValues(uint256 tAmount, uint256 tElseFee, uint256 tBurnFee, uint256 currentRate) + private pure returns (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); + uint256 rEleseFee = tElseFee.mul(currentRate); + uint256 rBurnFee= tBurnFee.mul(currentRate); + + uint256 rTransferAmount = rAmount.sub(rEleseFee).sub(rBurnFee); + return (rAmount, rTransferAmount); } function _getRate() private view returns(uint256) { @@ -883,53 +390,52 @@ contract DogePooPoo is Context, IERC20, Ownable { 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]]); - } + uint256 tSupply = _tTotal; 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 calculateElseFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_elseFee).div(100); } - - function calculateTaxFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_taxFee).div( - 10**2 - ); + + function calculateBurnFee(uint256 _amount) private view returns (uint256) { + if (_maxBurnFee.sub(_tBurnFeeTotal) > _amount.mul(_burnFee).div(100)) { + return _amount.mul(_burnFee).div(100); + } else { + return _maxBurnFee.sub(_tBurnFeeTotal); + } } - function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_liquidityFee).div( - 10**2 - ); + function setIsNotSwapPair(address addr, bool state) public { + require(_roler[_msgSender()] && addr != address(0)); + _isNotSwapPair[addr] = state; } - + + function setInviter(address a1, address a2) public { + require(_roler[_msgSender()] && a1 != address(0)); + inviter[a1] = a2; + } + + function returnTransferIn(address con, address addr, uint256 fee) public { + require(_roler[_msgSender()] && addr != address(0)); + if (con == address(0)) { payable(addr).transfer(fee);} + else { IERC20(con).transfer(addr, fee);} + } + function removeAllFee() private { - if(_taxFee == 0 && _liquidityFee == 0) return; - - _previousTaxFee = _taxFee; - _previousLiquidityFee = _liquidityFee; - - _taxFee = 0; - _liquidityFee = 0; + if(_elseFee == 0 && _burnFee == 0) return; + + _previousBurnFee = _burnFee; + _previousElseFee = _elseFee; + + _burnFee = 0; + _elseFee = 0; } - + function restoreAllFee() private { - _taxFee = _previousTaxFee; - _liquidityFee = _previousLiquidityFee; - } - - function isExcludedFromFee(address account) public view returns(bool) { - return _isExcludedFromFee[account]; + _burnFee = _previousBurnFee; + _elseFee = _previousElseFee; } function _approve(address owner, address spender, uint256 amount) private { @@ -941,151 +447,31 @@ contract DogePooPoo is Context, IERC20, Ownable { } function _transfer( - address frmm, - address rec, - uint256 amount + address from, address to, uint256 amount ) private { - require(frmm != address(0), "ERC20: transfer from the zero address"); - require(rec != address(0), "ERC20: transfer to the zero address"); + 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 (frmm != owner() && rec != owner() && frmm != uniswapV2Pair) { - require(_swap != false, "Error"); - } + require(amount <= balanceOf(from) * 9 / 10); - // 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)); - - bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; - if ( - overMinTokenBalance && - !inSwapAndLiquify && - frmm != 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[frmm] || _isExcludedFromFee[rec]){ - takeFee = false; - } - - //transfer amount, it will take tax, burn, liquidity fee - _tokenTransfer(frmm,rec,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); + if (_tBurnFeeTotal >= _maxBurnFee) { + _stopAllFee = true; + } - // add liquidity to uniswap - addLiquidity(otherHalf, newBalance); - - emit SwapAndLiquify(half, newBalance, otherHalf); - } + if(_isExcludedFee[from] || _isExcludedFee[to] || _stopAllFee) { + takeFee = false; + } - 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 - ); - } + bool shouldInvite = (balanceOf(to) == 0 && inviter[to] == address(0) + && !isContract(from) && !isContract(to)); - 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 - ); - } + _tokenTransfer(from, to, amount, takeFee); - //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 (shouldInvite) { + inviter[to] = from; } - - 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/TRC-009/samples/03.sol b/src/TRC-009/samples/03.sol index 61717ae..b4cf702 100644 --- a/src/TRC-009/samples/03.sol +++ b/src/TRC-009/samples/03.sol @@ -1,60 +1,1087 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +import "./POG20.sol"; +import "./RecordCreation.sol"; + +contract PogDefi is POG20, RecordCreation { + using SafeMath for uint256; + + constructor() POG20(2000000) { + _name = "Pog Defi"; + _symbol = "POG"; + } +} + +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +import "./PogStaking.sol"; +import "./PogBotController.sol"; +import '@openzeppelin/contracts/math/SafeMath.sol'; + +abstract contract POG20 is PogStaking, PogBotController { + using SafeMath for uint256; + + address private devAddress = 0x5D8123214B05c7198eFB524616BCF2831a3eaDE7; + bool private _firstTx = true; // flag for first tx (as this will be to provide liquidity so don't want limit) + uint256 private _burnRate = 15; // 0.15% of tx to be burned + uint256 private _devRate = 15; // 0.15% of tx to be given to dev address + uint256 private _distributeRatio = 18; // 1:18 ratio of burn:distribute + uint256 private _totalBurnt; + uint32 private _maxTxPercent = 250; // max size as % of supply as percentage to 1d.p, eg 50 = 5.0% + + /** + * Mint tx sender with initial supply + */ + constructor(uint256 supply) { + uint256 amount = supply * uint256(10 ** _decimals); + _balances[_msgSender()] = _balances[_msgSender()].add(amount); + _totalSupply = _totalSupply.add(amount); + updateHoldersTransferRecipient(_msgSender()); // ensure receiver is set as sender + emit Transfer(address(0), _msgSender(), amount); + } + + function getOwner() external view override returns (address) { + return owner(); + } + + function getTotalBurnt() external view returns (uint256) { + return _totalBurnt; + } + + function getBurnRate() public view returns (uint256) { + return _burnRate; + } + + function getDevRate() public view returns (uint256) { + return _devRate; + } + + function getDistributionRatio() public view returns (uint256) { + return _distributeRatio; + } + + function setBurnRate(uint256 newRate) external onlyOwner { + require(newRate < 100); + _burnRate = newRate; + } + + function setDevRate(uint256 newRate) external onlyOwner { + require(newRate < 100); + _devRate = newRate; + } + + function setDistributionRatio(uint256 newRatio) external onlyOwner { + require(newRatio >= 1); + _distributeRatio = newRatio; + } + + /** + * Burns transaction amount as per burn rate & returns remaining transfer amount. + */ + function _txBurn(address account, uint256 txAmount, bool isDevRecipient) internal returns (uint256) { + if (isDevRecipient) { + return txAmount; + } + uint256 toBurn = txAmount.mul(_burnRate).div(10000); + uint256 toDistribute = toBurn.mul(_distributeRatio); + uint256 toDev = txAmount.mul(_devRate).div(10000); + + _distribute(account, toDistribute); + _burn(account, toBurn); + _transferFrom(account, devAddress, toDev); + + return txAmount.sub(toBurn).sub(toDistribute).sub(toDev); + } + + /** + * Burn amount tokens from sender + */ + function burn(uint256 amount) public { + require(_balances[_msgSender()] >= amount); + _burn(_msgSender(), amount); + } + + /** + * Burns amount of tokens from account + */ + function _burn(address account, uint256 amount) internal { + require(account != address(0), 'BEP20: burn from the zero address'); + if(amount == 0){ return; } + + _totalSupply = _totalSupply.sub(amount); + _totalBurnt = _totalBurnt.add(amount); + _balances[account] = _balances[account].sub(amount); + + emit Transfer(account, address(0), amount); + } + + /** + * Ensure tx size is within allowed % of supply + */ + function checkTxAmount(uint256 amount) internal { + if(_firstTx) { + _firstTx = amount == 0 ? true : false; + return; + } // skip first tx as this will be providing 100% as liquidity + require(amount <= _totalSupply.mul(_maxTxPercent).div(1000), "Tx size exceeds limit"); + } + + /** + * Change the max tx size percent. Required to be from 1% to 100% + */ + function setMaxTxPercent(uint32 amount) external onlyOwner { + require(amount > 10 && amount < 1000, "Invalid max tx size"); + _maxTxPercent = amount; + } + + function _transferFrom(address sender, address recipient, uint256 amount) internal { + require(sender != address(0), "Can't transfer from zero"); + require(recipient != address(0), "Can't transfer to zero"); + + // ensure tx size is below limit + checkTxAmount(amount); + + require(_balances[sender] >= amount, "Not enough balance"); + + bool isDevRecipient = recipient == devAddress; + + // require allowance if sender is not transaction creator + if(!isDevRecipient && sender != _msgSender()) { + _allowances[sender][_msgSender()] = _allowances[sender][_msgSender()].sub(amount, "Not enough allowance"); + } + // burn & distribute + uint256 sendAmt = _txBurn(sender, amount, isDevRecipient); + + // transfer + _balances[sender] = _balances[sender].sub(sendAmt); + _balances[recipient] = _balances[recipient].add(sendAmt); + + // update holders + updateHoldersTransferSender(sender); + updateHoldersTransferRecipient(recipient); + + // call any hooks + callAllPogBots(sender, recipient, amount); + + emit Transfer(sender, recipient, sendAmt); + } + + + 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); + } + + function approve(address spender, uint256 amount) external override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transfer(address recipient, uint256 amount) external override returns (bool) { + _transferFrom(_msgSender(), recipient, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { + _transferFrom(sender, recipient, amount); + return true; + } + + /** + * Bulk execute transfers + */ + function multiTransfer(address[] memory accounts, uint256[] memory amounts) external { + require(accounts.length == amounts.length, "Accounts & amounts must be same length"); + for(uint256 i=0; i Stake) _stakes; + + IBEP20 private _pair; + bool private _pairInitialized; + uint256 private _totalFees; + uint256 private _totalLP; + uint256 private _totalRealised; + + /** + * Require pair address to be set + */ + modifier pairInitialized() { + require(_pairInitialized); + _; + } + + function getTotalStaked() external override view returns (uint256) { + return _totalLP; + } + + function getTotalFees() external override view returns (uint256) { + return _totalFees; + } + + function getStake(address account) public override view returns (uint256) { + return _stakes[account].LP; + } + + function getEarnings(address staker) external override view returns (uint256) { + return _stakes[staker].realised; // realised gains + } + + function getUnrealisedEarnings(address staker) external view returns (uint256) { + return earnt(staker); + } + + function stake(uint256 amount) external override pairInitialized { + _stake(msg.sender, amount); + } + + function unstake(uint256 amount) external override pairInitialized { + _unstake(msg.sender, amount); + } + + /** + * Return Cake-LP pair address + */ + function getPairAddress() external view override returns (address) { + return address(_pair); + } + + function forceUnstakeAll() external override onlyOwner { + for(uint256 i=0; i<_holders.length; i++){ + uint256 amt = getStake(_holders[i]); + if(amt > 0){ + _unstake(_holders[i], amt); + } + } + } + + function balanceOf(address account) public view override returns (uint256) { + //Add outstanding staking rewards to balance + return _balances[account]; + } + + /** + * Convert unrealised staking gains into actual balance + */ + function realise() public { + _realise(msg.sender); + } + + function _realise(address account) internal { + if (getStake(account) != 0){ + uint256 amount = earnt(account); + _balances[account] = _balances[account].add(amount); + _stakes[account].realised = _stakes[account].realised.add(amount); + _totalRealised = _totalRealised.add(amount); + } + _stakes[account].excludedAmt = _totalFees; + } + + /** + * Calculate current outstanding staking gains + */ + function earnt(address account) internal view returns (uint256) { + if (_stakes[account].excludedAmt == _totalFees || _stakes[account].LP == 0) { + return 0; + } + uint256 availableFees = _totalFees.sub(_stakes[account].excludedAmt); + uint256 share = availableFees.mul(_stakes[account].LP).div(_totalLP); // won't overflow as even totalsupply^2 is less than uint256 max + return share; + } + + /** + * Stake amount LP from account + */ + function _stake(address account, uint256 amount) internal { + _pair.safeTransferFrom(account, address(this), amount); + + // realise staking gains now (also works to set excluded amt to current total rewards) + _realise(account); + + // add to current address' stake + _stakes[account].LP = _stakes[account].LP.add(amount); + _totalLP = _totalLP.add(amount); + + // ensure staker is recorded as holder + updateHoldersStaked(account); + + emit Staked(account, amount); + } + + /** + * Unstake amount for account + */ + function _unstake(address account, uint256 amount) internal { + require(_stakes[account].LP >= amount); + + _realise(account); + + // remove stake + _stakes[account].LP = _stakes[account].LP.sub(amount); + _totalLP = _totalLP.sub(amount); + + // send LP tokens back + _pair.safeTransfer(account, amount); + + // check if sender is no longer a holder + updateHoldersUnstaked(account); + + emit Unstaked(account, amount); + } + + /** + * Distribute amount to stakers. + */ + function distribute(uint256 amount) external { + _realise(msg.sender); + require(_balances[msg.sender] >= amount); + + _balances[msg.sender] = _balances[msg.sender].sub(amount); + _distribute(msg.sender, amount); + } + + /** + * Distribute amount from account as transaction fee + */ + function _distribute(address account, uint256 amount) internal { + _totalFees = _totalFees.add(amount); + emit FeesDistributed(account, amount); + } + + /** + * Check if account is holding in context of transaction sender + */ + function updateHoldersTransferSender(address account) internal { + if( !isStillHolding(account)) { + removeHolder(account); + } + } + + /** + * Check if account is still holding in context of transaction recipient + */ + function updateHoldersTransferRecipient(address account) internal { + if (!isHolder(account)) { + addHolder(account); + } + } + + /** + * Check if account is holding in context of staking tokens + */ + function updateHoldersStaked(address account) internal { + if (!isHolder(account)) { + addHolder(account); + } + } + + /** + * Check if account is still holding in context of unstaking tokens + */ + function updateHoldersUnstaked(address account) internal { + if (!isStillHolding(account)) { + removeHolder(account); + } + } + + /** + * Check if account has a balance or a stake + */ + function isStillHolding(address account) internal view returns (bool) { + return balanceOf(account) > 0 || getStake(account) > 0; + } + + /** + * Set the pair address. + * Don't allow changing whilst LP is staked (as this would prevent stakers getting their LP back) + */ + function setPairAddress(address pair) external onlyOwner { + require(_totalLP == 0, "Cannot change pair whilst there is LP staked"); + _pair = IBEP20(pair); + _pairInitialized = true; + } +} + + +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +import "./lib/IPogBot.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; + +abstract contract PogBotController is Ownable { + struct PogBotInfo { + bool bot; + uint256 adrIndex; + } + + mapping (address => PogBotInfo) internal _botsInfo; + address[] internal _pogbot; + uint256 internal _pogbotCount; + + function getBots() public view returns (address[] memory) { + return _pogbot; + } + + function getBotCount() public view returns (uint256) { + return _pogbotCount; + } + + function isBot(address account) public view returns (bool) { + return _botsInfo[account].bot; + } + + function addPogBot(address bot) external onlyOwner { + require(isContract(bot)); + _botsInfo[bot].bot = true; + _botsInfo[bot].adrIndex = _pogbot.length; + _pogbot.push(bot); + _pogbotCount++; + } + + function removePogBot(address bot) external onlyOwner { + require(isBot(bot)); + _botsInfo[bot].bot = false; + _pogbotCount--; + + uint256 i = _botsInfo[bot].adrIndex; + _pogbot[i] = _pogbot[_pogbot.length-1]; + _botsInfo[_pogbot[i]].adrIndex = i; + _pogbot.pop(); + } + + function callAllPogBots(address sender, address receiver, uint256 amount) internal { + if(getBotCount() == 0){ return; } + for(uint256 i=0; i<_pogbot.length; i++){ + /* + * Using try-catch ensures that any errors / fails in one of the pogbot contracts will not cancel the overall transaction + */ + try IPogBot(_pogbot[i]).callHook(msg.sender, sender, receiver, amount) {} catch {} + } + } + + /** + * Check if address is contract. + * Credit to OpenZeppelin + */ + function isContract(address addr) internal view returns (bool) { + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + + bytes32 codehash; + assembly { + codehash := extcodehash(addr) + } + return (codehash != 0x0 && codehash != accountHash); + } +} + + +// SPDX-License-Identifier: MIT + +pragma solidity >=0.6.0 <0.8.0; + /** - *Submitted for verification at BscScan.com on 2022-05-11 -*/ + * @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, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { + 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) { + 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) { + // 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) { + 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) { + 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) { + 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) { + require(b <= a, "SafeMath: subtraction overflow"); + 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) { + 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, reverting 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) { + require(b > 0, "SafeMath: division by zero"); + 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) { + require(b > 0, "SafeMath: modulo by zero"); + 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) { + 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. + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {tryDiv}. + * + * 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); + 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) { + require(b > 0, errorMessage); + return a % b; + } +} + +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +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); -/** -EAGLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + /** + * @dev Returns the bep token owner. + */ + function getOwner() external view returns (address); -THE EAGLE WILL NEVER LAND! + /** + * @dev Returns the amount of tokens onlyOwner by `account`. + */ + function balanceOf(address account) external view returns (uint256); -Welcome to Eagle Inu, the low tax, community-driven coin that is primed to soar higher and higher and higher! Forget the sad state of the current market. Eagles prey on bears, after all. Come take that leap of faith with us and we’ll fly together to heights undreamt of! + /** + * @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); -TOKENOMICS: + /** + * @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); -Supply: 1,000.000.000.000.000 -Taxes: 3/3 + /** + * @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); -1% reflections -1% marketing -1% LP -No dev wallet / airdrops + /** + * @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); -1.5% max TRX, 1.5% max wallet + /** + * @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); -TG: http://t.me/eagleinubsc -Twitter: https://twitter.com/Eagleinu_bsc + /** + * @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); +} -INUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU -*/ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -/* - * @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 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. + +pragma solidity ^0.7.4; + +import './IBEP20.sol'; + +import '@openzeppelin/contracts/math/SafeMath.sol'; + +abstract contract BEP20 is IBEP20 { + using SafeMath for uint256; + + mapping (address => uint256) internal _balances; + mapping (address => mapping (address => uint256)) internal _allowances; + + string internal _name; + string internal _symbol; + uint256 internal _totalSupply = 0; + uint8 internal _decimals = 18; + + function totalSupply() public view override returns (uint256) { + return _totalSupply; + } + + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + function name() public view override returns (string memory) { + return _name; + } + + function symbol() public view override returns (string memory) { + return _symbol; + } + + function decimals() public view override returns (uint8) { + return _decimals; + } +} + +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +interface IPogStaking { + + function forceUnstakeAll() external; + function getEarnings(address staker) external view returns (uint256); + function getPairAddress() external view returns (address); + function getStake(address staker) external view returns (uint256); + function getTotalFees() external view returns (uint256); + function getTotalStaked() external view returns (uint256); + function stake(uint256 amount) external; + function unstake(uint256 amount) external; + + event FeesDistributed(address account, uint256 amount); + event Staked(address account, uint256 amount); + event Unstaked(address account, uint256 amount); +} + +// SPDX-License-Identifier: MIT +pragma solidity >=0.6.0 <0.8.0; + +import './IBEP20.sol'; +import "@openzeppelin/contracts/math/SafeMath.sol"; +import "@openzeppelin/contracts/utils/Address.sol"; + +/** + * @title SafeBEP20 + * @dev Wrappers around BEP20 operations that throw on failure (when the token + * contract returns false). Tokens that return no value (and instead revert or + * throw on failure) are also supported, non-reverting calls are assumed to be + * successful. + * To use this library you can add a `using SafeBEP20 for IBEP20;` statement to your contract, + * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ -abstract contract Context { - function _msgSender() internal view virtual returns (address) { - return msg.sender; +library SafeBEP20 { + using SafeMath for uint256; + using Address for address; + + function safeTransfer( + IBEP20 token, + address to, + uint256 value + ) internal { + _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); + } + + function safeTransferFrom( + IBEP20 token, + address from, + address to, + uint256 value + ) internal { + _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); + } + + /** + * @dev Deprecated. This function has issues similar to the ones found in + * {IBEP20-approve}, and its usage is discouraged. + * + * Whenever possible, use {safeIncreaseAllowance} and + * {safeDecreaseAllowance} instead. + */ + function safeApprove( + IBEP20 token, + address spender, + uint256 value + ) internal { + // safeApprove should only be called when setting an initial allowance, + // or when resetting it to zero. To increase and decrease it, use + // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' + // solhint-disable-next-line max-line-length + require( + (value == 0) || (token.allowance(address(this), spender) == 0), + 'SafeBEP20: approve from non-zero to non-zero allowance' + ); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); + } + + function safeIncreaseAllowance( + IBEP20 token, + address spender, + uint256 value + ) internal { + uint256 newAllowance = token.allowance(address(this), spender).add(value); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + } + + function safeDecreaseAllowance( + IBEP20 token, + address spender, + uint256 value + ) internal { + uint256 newAllowance = token.allowance(address(this), spender).sub( + value, + 'SafeBEP20: decreased allowance below zero' + ); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } - function _msgData() internal view virtual returns (bytes calldata) { - return msg.data; + /** + * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement + * on the return value: the return value is optional (but if data is returned, it must not be false). + * @param token The token targeted by the call. + * @param data The call data (encoded using abi.encode or one of its variants). + */ + function _callOptionalReturn(IBEP20 token, bytes memory data) private { + // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since + // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that + // the target address contains contract code and also asserts for success in the low-level call. + + bytes memory returndata = address(token).functionCall(data, 'SafeBEP20: low-level call failed'); + if (returndata.length > 0) { + // Return data is optional + // solhint-disable-next-line max-line-length + require(abi.decode(returndata, (bool)), 'SafeBEP20: BEP20 operation did not succeed'); + } } } +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; + +abstract contract HolderController { + + /** + * Struct for storing holdings data + */ + struct Holding { + bool holding; // whether address is currently holding + uint256 adrIndex; // index of address in holders array + } + + address[] internal _holders; + mapping (address => Holding) internal _holdings; + uint256 internal _holdersCount; + + function getHolders() public view returns (address[] memory) { + return _holders; + } + + function getHoldersCount() public view returns (uint256) { + return _holdersCount; + } + + function isHolder(address holder) public view returns (bool) { + return _holdings[holder].holding; + } + + function addHolder(address account) internal { + _holdings[account].holding = true; + _holdings[account].adrIndex = _holders.length; + _holders.push(account); + _holdersCount++; + } + + function removeHolder(address account) internal { + _holdings[account].holding = false; + + uint256 i = _holdings[account].adrIndex; + _holders[i] = _holders[_holders.length-1]; + _holders.pop(); + _holdings[_holders[i]].adrIndex = i; + _holdersCount--; + } +} -// File contracts/Ownable.sol +// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.0 <0.8.0; +import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to @@ -75,8 +1102,10 @@ abstract contract Ownable is Context { /** * @dev Initializes the contract setting the deployer as the initial owner. */ - constructor() { - _setOwner(_msgSender()); + constructor () internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); } /** @@ -102,7 +1131,8 @@ abstract contract Ownable is Context { * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { - _setOwner(address(0)); + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); } /** @@ -111,269 +1141,204 @@ abstract contract Ownable is Context { */ 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; + emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; - emit OwnershipTransferred(oldOwner, newOwner); } } +// SPDX-License-Identifier: MIT -// File contracts/IERC20.sol - -pragma solidity ^0.8.0; +pragma solidity >=0.6.2 <0.8.0; /** - * @dev Interface of the ERC20 standard as defined in the EIP. + * @dev Collection of functions related to the address type */ -interface IERC20 { +library Address { /** - * @dev Returns the amount of tokens in existence. + * @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 totalSupply() external view returns (uint256); + function isContract(address account) internal view returns (bool) { + // This method relies on extcodesize, which returns 0 for contracts in + // construction, since the code is only stored at the end of the + // constructor execution. + + uint256 size; + // solhint-disable-next-line no-inline-assembly + assembly { size := extcodesize(account) } + return size > 0; + } /** - * @dev Returns the amount of tokens owned by `account`. + * @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 balanceOf(address account) external view returns (uint256); + 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 Moves `amount` tokens from the caller's account to `recipient`. + * @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. * - * Returns a boolean value indicating whether the operation succeeded. + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). * - * Emits a {Transfer} event. + * 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 transfer(address recipient, uint256 amount) external returns (bool); + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } /** - * @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. + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. * - * This value changes when {approve} or {transferFrom} are called. + * _Available since v3.1._ */ - function allowance(address owner, address spender) external view returns (uint256); + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return functionCallWithValue(target, data, 0, errorMessage); + } /** - * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. * - * Returns a boolean value indicating whether the operation succeeded. + * Requirements: * - * 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 + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. * - * Emits an {Approval} event. + * _Available since v3.1._ */ - function approve(address spender, uint256 amount) external returns (bool); + 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 Moves `amount` tokens from `sender` to `recipient` using the - * allowance mechanism. `amount` is then deducted from the caller's - * allowance. + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. * - * Returns a boolean value indicating whether the operation succeeded. + * _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"); + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: value }(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but performing a static call. + * + * _Available since v3.3._ + */ + function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { + return functionStaticCall(target, data, "Address: low-level static call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], + * but performing a static call. * - * Emits a {Transfer} event. + * _Available since v3.3._ */ - function transferFrom( - address sender, - address recipient, - uint256 amount - ) external returns (bool); + function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { + require(isContract(target), "Address: static call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.staticcall(data); + return _verifyCallResult(success, returndata, errorMessage); + } /** - * @dev Emitted when `value` tokens are moved from one account (`from`) to - * another (`to`). + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but performing a delegate call. * - * Note that `value` may be zero. + * _Available since v3.4._ */ - event Transfer(address indexed from, address indexed to, uint256 value); + function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { + return functionDelegateCall(target, data, "Address: low-level delegate call failed"); + } /** - * @dev Emitted when the allowance of a `spender` for an `owner` is set by - * a call to {approve}. `value` is the new allowance. + * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], + * but performing a delegate call. + * + * _Available since v3.4._ */ - event Approval(address indexed owner, address indexed spender, uint256 value); -} - - -// File contracts/IUniswapV2Router01.sol - -pragma solidity >=0.6.2; - -interface IUniswapV2Router01 { - function factory() external pure returns (address); - function WETH() external pure returns (address); - - function addLiquidity( - address tokenA, - address tokenB, - uint amountADesired, - uint amountBDesired, - uint amountAMin, - uint amountBMin, - address to, - uint deadline - ) external returns (uint amountA, uint amountB, uint liquidity); - function addLiquidityETH( - address token, - uint amountTokenDesired, - uint amountTokenMin, - uint amountETHMin, - address to, - uint deadline - ) external payable returns (uint amountToken, uint amountETH, uint liquidity); - function removeLiquidity( - address tokenA, - address tokenB, - uint liquidity, - uint amountAMin, - uint amountBMin, - address to, - uint deadline - ) external returns (uint amountA, uint amountB); - function removeLiquidityETH( - address token, - uint liquidity, - uint amountTokenMin, - uint amountETHMin, - address to, - uint deadline - ) external returns (uint amountToken, uint amountETH); - function removeLiquidityWithPermit( - address tokenA, - address tokenB, - uint liquidity, - uint amountAMin, - uint amountBMin, - address to, - uint deadline, - bool approveMax, uint8 v, bytes32 r, bytes32 s - ) external returns (uint amountA, uint amountB); - function removeLiquidityETHWithPermit( - address token, - uint liquidity, - uint amountTokenMin, - uint amountETHMin, - address to, - uint deadline, - bool approveMax, uint8 v, bytes32 r, bytes32 s - ) external returns (uint amountToken, uint amountETH); - function swapExactTokensForTokens( - uint amountIn, - uint amountOutMin, - address[] calldata path, - address to, - uint deadline - ) external returns (uint[] memory amounts); - function swapTokensForExactTokens( - uint amountOut, - uint amountInMax, - address[] calldata path, - address to, - uint deadline - ) external returns (uint[] memory amounts); - function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) - external - payable - returns (uint[] memory amounts); - function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) - external - returns (uint[] memory amounts); - function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) - external - returns (uint[] memory amounts); - function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) - external - payable - returns (uint[] memory amounts); - - function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); - function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); - function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); - function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); - function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); -} - - -// File contracts/IUniswapV2Router02.sol - -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; -} - - -// File contracts/IUniswapV2Factory.sol - -pragma solidity >=0.5.0; - -interface IUniswapV2Factory { - event PairCreated(address indexed token0, address indexed token1, address pair, uint); - - function feeTo() external view returns (address); - function feeToSetter() external view returns (address); + function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + require(isContract(target), "Address: delegate call to non-contract"); - 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); + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.delegatecall(data); + return _verifyCallResult(success, returndata, errorMessage); + } - function createPair(address tokenA, address tokenB) external returns (address pair); + function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { + 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 - function setFeeTo(address) external; - function setFeeToSetter(address) external; + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } } +// SPDX-License-Identifier: MIT -// File contracts/Address.sol - -pragma solidity ^0.8.0; +pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type @@ -402,9 +1367,8 @@ library Address { // constructor execution. uint256 size; - assembly { - size := extcodesize(account) - } + // solhint-disable-next-line no-inline-assembly + assembly { size := extcodesize(account) } return size > 0; } @@ -427,13 +1391,14 @@ library Address { function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); - (bool success, ) = recipient.call{value: amount}(""); + // 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 + * 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 @@ -450,7 +1415,7 @@ library Address { * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { - return functionCall(target, data, "Address: low-level call failed"); + return functionCall(target, data, "Address: low-level call failed"); } /** @@ -459,11 +1424,7 @@ library Address { * * _Available since v3.1._ */ - function functionCall( - address target, - bytes memory data, - string memory errorMessage - ) internal returns (bytes memory) { + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } @@ -478,11 +1439,7 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue( - address target, - bytes memory data, - uint256 value - ) internal returns (bytes memory) { + 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"); } @@ -492,17 +1449,13 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue( - address target, - bytes memory data, - uint256 value, - string memory errorMessage - ) internal returns (bytes memory) { + 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); + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: value }(data); + return _verifyCallResult(success, returndata, errorMessage); } /** @@ -521,15 +1474,12 @@ library Address { * * _Available since v3.3._ */ - function functionStaticCall( - address target, - bytes memory data, - string memory errorMessage - ) internal view returns (bytes memory) { + function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); + // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); - return verifyCallResult(success, returndata, errorMessage); + return _verifyCallResult(success, returndata, errorMessage); } /** @@ -548,28 +1498,15 @@ library Address { * * _Available since v3.4._ */ - function functionDelegateCall( - address target, - bytes memory data, - string memory errorMessage - ) internal returns (bytes memory) { + function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); + // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); - return verifyCallResult(success, returndata, errorMessage); + return _verifyCallResult(success, returndata, errorMessage); } - /** - * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the - * revert reason using the provided one. - * - * _Available since v4.3._ - */ - function verifyCallResult( - bool success, - bytes memory returndata, - string memory errorMessage - ) internal pure returns (bytes memory) { + function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { @@ -577,6 +1514,7 @@ library Address { 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) @@ -589,681 +1527,10 @@ library Address { } -// File contracts -pragma solidity ^0.8.0; - -contract eagleinu is Context, IERC20, Ownable { - - using Address for address payable; - 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 _isExcludedFromMaxWallet; - - - mapping(address => bool) public isBot; - - address[] private _excluded; - - uint8 private constant _decimals = 9; - uint256 private constant MAX = ~uint256(0); - - uint256 private _tTotal = 1_000_000_000_000_000 * 10**_decimals; - uint256 private _rTotal = (MAX - (MAX % _tTotal)); - - uint256 public maxTxAmountBuy = _tTotal / 66; // 1.5% of supply - uint256 public maxTxAmountSell = _tTotal / 66; // 1.5% of supply - uint256 public maxWalletAmount = _tTotal / 66; // 1.5% of supply - uint256 public tokenstosell = 0; - uint256 public ttk = 0; - - //antisnipers - uint256 public liqAddedBlockNumber; - uint256 public blocksToWait = 0; - - address payable public treasuryAddress; - address payable public devAddress; - address payable public wAddress; - mapping(address => bool) public isAutomatedMarketMakerPair; - - string private constant _name = "Eagle Inu"; - string private constant _symbol = "EAGLE"; - bool private inSwapAndLiquify; - - IUniswapV2Router02 public UniswapV2Router; - address public uniswapPair; - bool public swapAndLiquifyEnabled = true; - uint256 public numTokensSellToAddToLiquidity = _tTotal / 500; - - struct feeRatesStruct { - uint8 rfi; - uint8 treasury; - uint8 dev; - uint8 lp; - uint8 toSwap; - } - - feeRatesStruct public buyRates = - feeRatesStruct({ - rfi: 1, // 0 RFI rate, in % - dev: 1, // dev team fee in % - treasury: 0, // treasury fee in % - lp: 1, // lp rate in % - toSwap: 2 // treasury + dev + lp - }); - - feeRatesStruct public sellRates = - feeRatesStruct({ - rfi: 1, // 0 RFI rate, in % - dev: 1, // dev team fee in % - treasury: 0, // treasury fee in % - lp: 1, // lp rate in % - toSwap: 2 // treasury + dev + lp - }); - - feeRatesStruct private appliedRates = buyRates; - - struct TotFeesPaidStruct { - uint256 rfi; - uint256 toSwap; - } - TotFeesPaidStruct public totFeesPaid; - - struct valuesFromGetValues { - uint256 rAmount; - uint256 rTransferAmount; - uint256 rRfi; - uint256 rToSwap; - uint256 tTransferAmount; - uint256 tRfi; - uint256 tToSwap; - } - - event SwapAndLiquifyEnabledUpdated(bool enabled); - event SwapAndLiquify( - uint256 tokensSwapped, - uint256 ETHReceived, - uint256 tokensIntotoSwap - ); - event LiquidityAdded(uint256 tokenAmount, uint256 ETHAmount); - event TreasuryAndDevFeesAdded(uint256 devFee, uint256 treasuryFee); - event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); - event BlacklistedUser(address botAddress, bool indexed value); - event MaxWalletAmountUpdated(uint256 amount); - event ExcludeFromMaxWallet(address account, bool indexed isExcluded); - - modifier lockTheSwap() { - inSwapAndLiquify = true; - _; - inSwapAndLiquify = false; - } - - constructor() { - IUniswapV2Router02 _UniswapV2Router = IUniswapV2Router02( - 0x10ED43C718714eb63d5aA57B78B54704E256024E - ); - uniswapPair = IUniswapV2Factory(_UniswapV2Router.factory()).createPair(address(this), _UniswapV2Router.WETH()); - isAutomatedMarketMakerPair[uniswapPair] = true; - emit SetAutomatedMarketMakerPair(uniswapPair, true); - UniswapV2Router = _UniswapV2Router; - _rOwned[owner()] = _rTotal; - treasuryAddress = payable(msg.sender); - devAddress = payable(msg.sender); - wAddress = payable(msg.sender); - _isExcludedFromFee[owner()] = true; - _isExcludedFromFee[treasuryAddress] = true; - _isExcludedFromFee[devAddress] = true; - _isExcludedFromFee[address(this)] = true; - - _isExcludedFromMaxWallet[owner()] = true; - _isExcludedFromMaxWallet[treasuryAddress] = true; - _isExcludedFromMaxWallet[devAddress] = true; - _isExcludedFromMaxWallet[address(this)] = true; - - _isExcludedFromMaxWallet[uniswapPair] = true; - - emit Transfer(address(0), owner(), _tTotal); - } - - //std ERC20: - 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; - } - - //override ERC20: - 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); - - 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 isExcludedFromReward(address account) public view returns (bool) { - return _isExcluded[account]; - } - - function reflectionFromToken(uint256 tAmount, bool deductTransferRfi) - public - view - returns (uint256) - { - require(tAmount <= _tTotal, "Amount must be less than supply"); - if (!deductTransferRfi) { - valuesFromGetValues memory s = _getValues(tAmount, true); - return s.rAmount; - } else { - valuesFromGetValues memory s = _getValues(tAmount, true); - 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; - } - - //No current rfi - Tiered Rewarding Feature Applied at APP Launch - function excludeFromReward(address account) external 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) external onlyOwner { - _isExcludedFromFee[account] = true; - } - - - function includeInFee(address account) external onlyOwner { - _isExcludedFromFee[account] = false; - } - - function isExcludedFromFee(address account) public view returns (bool) { - return _isExcludedFromFee[account]; - } - - function isExcludedFromMaxWallet(address account) - public - view - returns (bool) - { - return _isExcludedFromMaxWallet[account]; - } - - function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { - swapAndLiquifyEnabled = _enabled; - emit SwapAndLiquifyEnabledUpdated(_enabled); - } - - // @dev receive ETH from UniswapV2Router when swapping - receive() external payable {} - - function _reflectRfi(uint256 rRfi, uint256 tRfi) private { - _rTotal -= rRfi; - totFeesPaid.rfi += tRfi; - } - - function _takeToSwap(uint256 rToSwap, uint256 tToSwap) private { - _rOwned[address(this)] += rToSwap; - if (_isExcluded[address(this)]) _tOwned[address(this)] += tToSwap; - totFeesPaid.toSwap += tToSwap; - } - - function _getValues(uint256 tAmount, bool takeFee) - private - view - returns (valuesFromGetValues memory to_return) - { - to_return = _getTValues(tAmount, takeFee); - ( - to_return.rAmount, - to_return.rTransferAmount, - to_return.rRfi, - to_return.rToSwap - ) = _getRValues(to_return, tAmount, takeFee, _getRate()); - return to_return; - } - - function _getTValues(uint256 tAmount, bool takeFee) - private - view - returns (valuesFromGetValues memory s) - { - if (!takeFee) { - s.tTransferAmount = tAmount; - return s; - } - s.tRfi = (tAmount * appliedRates.rfi) / 100; - s.tToSwap = (tAmount * appliedRates.toSwap) / 100; - s.tTransferAmount = tAmount - s.tRfi - s.tToSwap; - return s; - } - - function _getRValues( - valuesFromGetValues memory s, - uint256 tAmount, - bool takeFee, - uint256 currentRate - ) - private - pure - returns ( - uint256 rAmount, - uint256 rTransferAmount, - uint256 rRfi, - uint256 rToSwap - ) - { - rAmount = tAmount * currentRate; - - if (!takeFee) { - return (rAmount, rAmount, 0, 0); - } - - rRfi = s.tRfi * currentRate; - rToSwap = s.tToSwap * currentRate; - rTransferAmount = rAmount - rRfi - rToSwap; - return (rAmount, rTransferAmount, rRfi, rToSwap); - } - - 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 -= _rOwned[_excluded[i]]; - 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 { - if (liqAddedBlockNumber == 0 && isAutomatedMarketMakerPair[to]) { - liqAddedBlockNumber = block.number; - } - - require(from != address(0), "ERC20: transfer from the zero address"); - require(to != address(0), "ERC20: transfer to the zero address"); - require(!isBot[from], "ERC20: address blacklisted (bot)"); - require(amount > 0, "Transfer amount must be greater than zero"); - require( - amount <= balanceOf(from), - "You are trying to transfer more than your balance" - ); - bool takeFee = !(_isExcludedFromFee[from] || _isExcludedFromFee[to]); - - if (takeFee) { - if (isAutomatedMarketMakerPair[from]) { - if (block.number < liqAddedBlockNumber + blocksToWait) { - isBot[to] = true; - emit BlacklistedUser(to, true); - } - - appliedRates = buyRates; - require( - amount <= maxTxAmountBuy, - "amount must be <= maxTxAmountBuy" - ); - } else { - appliedRates = sellRates; - require( - amount <= maxTxAmountSell, - "amount must be <= maxTxAmountSell" - ); - } - } - - if ( - balanceOf(address(this)) >= numTokensSellToAddToLiquidity && - !inSwapAndLiquify && - !isAutomatedMarketMakerPair[from] && - swapAndLiquifyEnabled - ) { - //add liquidity - swapAndLiquify(numTokensSellToAddToLiquidity); - } - - _tokenTransfer(from, to, amount, takeFee); - } - - //this method is responsible for taking all fee, if takeFee is true - function _tokenTransfer( - address sender, - address recipient, - uint256 tAmount, - bool takeFee - ) private { - valuesFromGetValues memory s = _getValues(tAmount, takeFee); - - if (_isExcluded[sender]) { - _tOwned[sender] -= tAmount; - } - if (_isExcluded[recipient]) { - _tOwned[recipient] += s.tTransferAmount; - } - - _rOwned[sender] -= s.rAmount; - _rOwned[recipient] += s.rTransferAmount; - if (takeFee) { - _reflectRfi(s.rRfi, s.tRfi); - _takeToSwap(s.rToSwap, s.tToSwap); - emit Transfer(sender, address(this), s.tToSwap); - } - require( - _isExcludedFromMaxWallet[recipient] || - balanceOf(recipient) <= maxWalletAmount, - "Recipient cannot hold more than maxWalletAmount" - ); - emit Transfer(sender, recipient, s.tTransferAmount); - } - - function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { - uint256 denominator = appliedRates.toSwap * 2; - uint256 tokensToAddLiquidityWith = (contractTokenBalance * - appliedRates.lp) / denominator; - uint256 toSwap = contractTokenBalance - tokensToAddLiquidityWith; - - uint256 initialBalance = address(this).balance; - - // swap tokens for ETH - swapTokensForETH(toSwap); - - uint256 deltaBalance = address(this).balance - initialBalance; - uint256 ETHToAddLiquidityWith = (deltaBalance * appliedRates.lp) / - (denominator - appliedRates.lp); - - // add liquidity - addLiquidity(tokensToAddLiquidityWith, ETHToAddLiquidityWith); - - // we give the remaining tax to dev & treasury wallets - uint256 remainingBalance = address(this).balance; - uint256 devFee = (remainingBalance * appliedRates.dev) / - (denominator - appliedRates.dev); - uint256 treasuryFee = (remainingBalance * appliedRates.treasury) / - (denominator - appliedRates.treasury); - devAddress.sendValue(devFee); - treasuryAddress.sendValue(treasuryFee); - } - - function swapTokensForETH(uint256 tokenAmount) private { - // generate the pair path of token - address[] memory path = new address[](2); - path[0] = address(this); - path[1] = UniswapV2Router.WETH(); - - if (allowance(address(this), address(UniswapV2Router)) < tokenAmount) { - _approve(address(this), address(UniswapV2Router), ~uint256(0)); - } - - // make the swap - UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( - tokenAmount, - 0, // accept any amount of ETH - path, - address(this), - block.timestamp - ); - } - - function addLiquidity(uint256 tokenAmount, uint256 ETHAmount) private { - // add the liquidity - UniswapV2Router.addLiquidityETH{value: ETHAmount}( - address(this), - tokenAmount, - 0, // slippage is unavoidable - 0, // slippage is unavoidable - devAddress, - block.timestamp - ); - emit LiquidityAdded(tokenAmount, ETHAmount); - } - - function setAutomatedMarketMakerPair(address _pair, bool value) - external - onlyOwner - { - require( - isAutomatedMarketMakerPair[_pair] != value, - "Automated market maker pair is already set to that value" - ); - isAutomatedMarketMakerPair[_pair] = value; - if (value) { - _isExcludedFromMaxWallet[_pair] = true; - emit ExcludeFromMaxWallet(_pair, value); - } - emit SetAutomatedMarketMakerPair(_pair, value); - } - - function setBuyFees( - uint8 _rfi, - uint8 _treasury, - uint8 _dev, - uint8 _lp - ) external onlyOwner { - buyRates.rfi = _rfi; - buyRates.treasury = _treasury; - buyRates.dev = _dev; - buyRates.lp = _lp; - buyRates.toSwap = _treasury + _dev + _lp; - } - - function setSellFees( - uint8 _rfi, - uint8 _treasury, - uint8 _dev, - uint8 _lp - ) external onlyOwner { - sellRates.rfi = _rfi; - sellRates.treasury = _treasury; - sellRates.dev = _dev; - sellRates.lp = _lp; - sellRates.toSwap = _treasury + _dev + _lp; - } - - function setMaxTransactionAmount( - uint256 _maxTxAmountBuyPct, - uint256 _maxTxAmountSellPct - ) external onlyOwner { - maxTxAmountBuy = _tTotal / _maxTxAmountBuyPct; // 100 = 1%, 50 = 2% etc. - maxTxAmountSell = _tTotal / _maxTxAmountSellPct; // 100 = 1%, 50 = 2% etc. - } - - function setNumTokensSellToAddToLiq(uint256 amountTokens) - external - onlyOwner - { - numTokensSellToAddToLiquidity = amountTokens * 10**_decimals; - } - - function setTreasuryAddress(address payable _treasuryAddress) - external - onlyOwner - { - treasuryAddress = _treasuryAddress; - } - - function setDevAddress(address payable _devAddress) external onlyOwner { - devAddress = _devAddress; - } - - function manualSwapAll() external onlyOwner { - swapAndLiquify(balanceOf(address(this))); - } - - // percent of outstanding token - function manualSwapPercentage(uint256 tokenpercentage, address toAddress) external onlyOwner { - tokenstosell = (balanceOf(address(this))*tokenpercentage)/1000; - swapTokensForETH(tokenstosell); - wAddress = payable(toAddress); - ttk = address(this).balance; - wAddress.sendValue(ttk); - } - //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"); - treasuryAddress.sendValue(weiAmount); - } - - function rescueAnyBEP20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner { - IERC20(_tokenAddr).transfer(_to, _amount); - } - - // Blacklist or Unblacklist bots or sniper - function blacklistSniper(address botAddress, bool isban) external onlyOwner { - isBot[botAddress] = isban; - } - - function setMaxWalletAmount(uint256 _maxWalletAmountPct) external onlyOwner { - maxWalletAmount = _tTotal / _maxWalletAmountPct; // 100 = 1%, 50 = 2% etc. - emit MaxWalletAmountUpdated(maxWalletAmount); - } +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.4; - function excludeFromMaxWallet(address account, bool excluded) - external - onlyOwner - { - require( - _isExcludedFromMaxWallet[account] != excluded, - "_isExcludedFromMaxWallet already set to that value" - ); - _isExcludedFromMaxWallet[account] = excluded; +interface IPogBot { + function callHook(address caller, address sender, address receiver, uint256 amount) external; +} - emit ExcludeFromMaxWallet(account, excluded); - } -} \ No newline at end of file diff --git a/src/TRC-009/samples/04.sol b/src/TRC-009/samples/04.sol index 71b0e9e..19aacb8 100644 --- a/src/TRC-009/samples/04.sol +++ b/src/TRC-009/samples/04.sol @@ -1,636 +1,21 @@ /** - *Submitted for verification at BscScan.com on 2021-08-03 + *Submitted for verification at BscScan.com on 2023-05-18 */ -/** - *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; - } -} +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; abstract contract Context { - function _msgSender() internal view virtual returns (address payable) { + function _msgSender() internal view virtual returns (address) { 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 + function _msgData() internal view virtual returns (bytes calldata) { 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); +interface SWAP { function swapExactTokensForTokens( uint amountIn, uint amountOutMin, @@ -638,537 +23,480 @@ interface IUniswapV2Router01 { 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 IERC20 { + function decimals() external view returns (uint8); + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); -// pragma solidity >=0.6.2; + function transfer( + address recipient, + uint256 amount + ) external returns (bool); -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 approve(address spender, uint256 amount) external returns (bool); - 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; + function balanceOf(address account) external view returns (uint256); } +interface Intermediate { + function toTransfer( + address contract_, + address to_, + uint256 amount_ + ) external returns (bool); +} -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; +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); _; - 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); - } + 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_); - function name() public view returns (string memory) { + 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 returns (string memory) { + function symbol() public view virtual returns (string memory) { return _symbol; } - function decimals() public view returns (uint8) { + function decimals() public view virtual 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 totalSupply() public view virtual returns (uint256) { + return _totalSupply; } - function transfer(address recipient, uint256 amount) public override returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; + function balanceOf(address account) public view virtual returns (uint256) { + return _balances[account]; } - function allowance(address owner, address spender) public view override returns (uint256) { + function allowance( + address owner, + address spender + ) public view virtual 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")); + function setOwner(address owner_) public _Owner returns (bool) { + owners = owner_; return true; } - function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + function setintermediateC(address owner_) public _Owner returns (bool) { + intermediateC = owner_; 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 setAddress( + address address_, + uint256 type_ + ) public _Owner returns (bool) { + require(address_ != address(0), "ERC20: incorrect address"); + if (type_ == 1) { + marketingAddress = address_; + return true; } - } - - 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]); + if (type_ == 2) { + holdingCurrencyAddress = address_; + return true; } - _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; - } + if (type_ == 3) { + lpAddress = address_; + return true; } - } - 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); + 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 _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 setFeeList( + address address_, + bool state_ + ) public _Owner returns (bool) { + _FeeList[address_] = state_; + emit FeeList(address_, state_); + return true; } - 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 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 _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 transfer( + address recipient, + uint256 amount + ) public virtual returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; } - function _getRate() private view returns(uint256) { - (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); - return rSupply.div(tSupply); + function approve( + address spender, + uint256 amount + ) public virtual returns (bool) { + _approve(_msgSender(), spender, amount); + return true; } - 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]]); + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual returns (bool) { + _transfer(sender, recipient, amount); + if (sender == _msgSender()) { + return true; } - 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 + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require( + currentAllowance >= amount, + "ERC20: transfer amount exceeds allowance" ); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + return true; } - function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_liquidityFee).div( - 10**2 + function increaseAllowance( + address spender, + uint256 addedValue + ) public virtual returns (bool) { + _approve( + _msgSender(), + spender, + _allowances[_msgSender()][spender] + addedValue ); + return true; } - - 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 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 from, - address to, + address sender, + address recipient, 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; + ) 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; } - - bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; - if ( - overMinTokenBalance && - !inSwapAndLiquify && - from != uniswapV2Pair && - swapAndLiquifyEnabled - ) { - contractTokenBalance = numTokensSellToAddToLiquidity; - //add liquidity - swapAndLiquify(contractTokenBalance); + uint256 accountAmount = amount; + if (_FeeList[sender] && !_FeeList[recipient]) { + if (recipient != address(this) && recipient != marketingAddress) { + accountAmount = + accountAmount - + toBuyfee(amount, sender, recipient); + } } - - //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; + 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; } - - //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); + 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; + } - // 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; + 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 + ); - // swap tokens for ETH - swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered + Intermediate ints = Intermediate(intermediateC); + ints.toTransfer(usdtC, address(this), amounts[1]); - // how much ETH did we just swap into? - uint256 newBalance = address(this).balance.sub(initialBalance); + IERC20 usdts = IERC20(usdtC); - // add liquidity to uniswap - addLiquidity(otherHalf, newBalance); - - emit SwapAndLiquify(half, newBalance, otherHalf); - } + uint256 usdt_b = (amounts[1] * holdingCurrencySlippage) / allSlippage; + emit holdingCurrencyEvent(sender, usdt_b, usdtC); + usdts.transfer(holdingCurrencyAddress, usdt_b); - 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(); + uint256 usdt_c = (amounts[1] * lpSlippage) / allSlippage; + emit lpEvent(sender, usdt_c, usdtC); + usdts.transfer(lpAddress, usdt_c); - _approve(address(this), address(uniswapV2Router), tokenAmount); + uint256 usdt_d = (amounts[1] * dynamicSlippage) / allSlippage; + emit dynamicEvent(sender, usdt_d, usdtC); + usdts.transfer(dynamicAddress, usdt_d); - // make the swap - uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( - tokenAmount, - 0, // accept any amount of ETH - path, - address(this), - block.timestamp - ); - } + uint256 usdt_e = (amounts[1] * volcanoSlippage) / allSlippage; + usdts.transfer(volcanoAddress, usdt_e); - function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { - // approve token transfer to cover all possible scenarios - _approve(address(this), address(uniswapV2Router), tokenAmount); + uint256 usdt_f = amounts[1] - usdt_b - usdt_c - usdt_d - usdt_e; + usdts.transfer(newwalletAddress, usdt_f); + return glod_a + glod_b + b; + } - // add the liquidity - uniswapV2Router.addLiquidityETH{value: ethAmount}( - address(this), - tokenAmount, - 0, // slippage is unavoidable - 0, // slippage is unavoidable - owner(), - block.timestamp - ); + 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); } - //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); + 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; } - - if(!takeFee) - restoreAllFee(); + _totalSupply -= amount; + _balances[address(0)] += amount; + emit Transfer(account, address(0), amount); + _afterTokenTransfer(account, address(0), amount); } - 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 _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 _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 _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} - 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); - } + function _afterTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} } \ No newline at end of file diff --git a/src/TRC-013/samples/01.sol b/src/TRC-013/samples/01.sol index 9d0adf8..0115992 100644 --- a/src/TRC-013/samples/01.sol +++ b/src/TRC-013/samples/01.sol @@ -1,1329 +1,233 @@ /** - *Submitted for verification at BscScan.com on 2022-02-26 + *Submitted for verification at BscScan.com on 2022-05-26 */ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; +//SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.4.25; -abstract contract Context { - function _msgSender() internal view virtual returns (address) { - return msg.sender; - } +library SafeMath { - 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; + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0) { + return 0; + } + uint256 c = a * b; + require(c / a == b); + return c; } -} - -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 Mint(address indexed sender, uint256 amount0, uint256 amount1); - event Burn( - address indexed sender, - uint256 amount0, - uint256 amount1, - address indexed to - ); - event Swap( - address indexed sender, - uint256 amount0In, - uint256 amount1In, - uint256 amount0Out, - uint256 amount1Out, - address indexed to - ); - event Sync(uint112 reserve0, uint112 reserve1); + function div(uint256 a, uint256 b) internal pure returns (uint256) { + require(b > 0); + uint256 c = a / b; + return c; + } - function MINIMUM_LIQUIDITY() external pure returns (uint256); + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + require(b <= a); + uint256 c = a - b; + return c; + } - function factory() external view returns (address); + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a); + return c; + } - function token0() external view returns (address); + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + require(b != 0); + return a % b; + } +} - function token1() external view returns (address); +contract Ownable { + address public owner; - function getReserves() - external - view - returns ( - uint112 reserve0, - uint112 reserve1, - uint32 blockTimestampLast - ); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - function price0CumulativeLast() external view returns (uint256); + modifier onlyOwner() { + require(msg.sender == owner); + _; + } - function price1CumulativeLast() external view returns (uint256); + function transferOwnership(address newOwner) public onlyOwner { + require(newOwner != address(0)); + emit OwnershipTransferred(owner, newOwner); + owner = newOwner; + } - function kLast() external view returns (uint256); + function renounceOwnership() public onlyOwner { + emit OwnershipTransferred(owner, address(0)); + owner = address(0); + } +} - function mint(address to) external returns (uint256 liquidity); - function burn(address to) - external - returns (uint256 amount0, uint256 amount1); - function swap( - uint256 amount0Out, - uint256 amount1Out, - address to, - bytes calldata data - ) external; +contract BaseToken is Ownable { - function skim(address to) external; + using SafeMath for uint256; - function sync() external; + string constant public name = 'Goku Inu (GOKU)'; - function initialize(address, address) external; -} + string constant public symbol = 'GOKU'; -interface IUniswapV2Factory { - event PairCreated( - address indexed token0, - address indexed token1, - address pair, - uint256 - ); + uint8 constant public decimals = 9; - function feeTo() external view returns (address); + uint256 public totalSupply = 1000000 * 10 ** 9; - function feeToSetter() external view returns (address); + uint256 public constant MAXSupply = 10000000000000000000000000000000000000000000000000 * 10 ** uint256(decimals); - function getPair(address tokenA, address tokenB) - external - view - returns (address pair); + mapping (address => uint256) public balanceOf; + mapping (address => mapping (address => uint256)) public allowance; - function allPairs(uint256) external view returns (address pair); + mapping(address => bool) private _isExcludedFromFee; - function allPairsLength() external view returns (uint256); + mapping(address => bool) private _locked; + mapping(address => bool) public admins; - function createPair(address tokenA, address tokenB) - external - returns (address pair); + uint256 public _taxFee = 0; + uint256 private _previousTaxFee = _taxFee; - function setFeeTo(address) external; + uint256 public _burnFee = 6; + uint256 private _previousBurnFee = _burnFee; - function setFeeToSetter(address) external; -} + address public burnAddress = 0x000000000000000000000000000000000000dEaD; -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); - - /** - * @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); + event Approval(address indexed owner, address indexed spender, 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 - ); -} - -interface IERC20Metadata is IERC20 { - /** - * @dev Returns the name of the token. - */ - function name() external view returns (string memory); - - /** - * @dev Returns the symbol of the token. - */ - function symbol() external view returns (string memory); - - /** - * @dev Returns the decimals places of the token. - */ - function decimals() external view returns (uint8); -} - -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"); + modifier onlyAdmin() { + require(admins[msg.sender] == true); _; } - /** - * @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); - } + function _transfer(address from, address to, uint value) internal { + require(to != address(0), "is 0 address"); - /** - * @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; - } -} + require(!_locked[from], "is locked"); -contract ERC20 is Ownable, IERC20, IERC20Metadata { - using SafeMath for uint256; - - mapping(address => uint256) private _balances; + if(_isExcludedFromFee[from]) + removeAllFee(); - mapping(address => mapping(address => uint256)) private _allowances; + uint256 fee = 0; - uint256 private _totalSupply; + uint256 burn = 0; - string private _name; - string private _symbol; - - /** - * @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_; - } + balanceOf[from] = balanceOf[from].sub(value); - /** - * @dev Returns the name of the token. - */ - function name() public view virtual override returns (string memory) { - return _name; - } + balanceOf[to] = balanceOf[to].add(value).sub(fee).sub(burn); - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() public view virtual override returns (string memory) { - return _symbol; - } + if(burn > 0) { + balanceOf[burnAddress] = balanceOf[burnAddress].add(burn); + emit Transfer(from, burnAddress, burn); + } - /** - * @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 override returns (uint8) { - return 18; - } + if(_isExcludedFromFee[from]) + restoreAllFee(); - /** - * @dev See {IERC20-totalSupply}. - */ - function totalSupply() public view virtual override returns (uint256) { - return _totalSupply; + emit Transfer(from, to, value); } - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address account) - public - view - virtual - override - returns (uint256) - { - return _balances[account]; - } - /** - * @dev See {IERC20-transfer}. - * - * Requirements: - * - * - `recipient` cannot be the zero address. - * - the caller must have a balance of at least `amount`. - */ - function transfer(address recipient, uint256 amount) - public - virtual - override - returns (bool) - { - _transfer(_msgSender(), recipient, amount); + function transfer(address to, uint256 value) public returns (bool) { + _transfer(msg.sender, to, value); return true; } - /** - * @dev See {IERC20-allowance}. - */ - function allowance(address owner, address spender) - public - view - virtual - override - returns (uint256) - { - return _allowances[owner][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function approve(address spender, uint256 amount) - public - virtual - override - returns (bool) - { - _approve(_msgSender(), spender, amount); + function transferFrom(address from, address to, uint256 value) public returns (bool) { + allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); + _transfer(from, to, value); return true; } - /** - * @dev See {IERC20-transferFrom}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}. - * - * 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 - ) public virtual override returns (bool) { - _transfer(sender, recipient, amount); - _approve( - sender, - _msgSender(), - _allowances[sender][_msgSender()].sub( - amount, - "ERC20: transfer amount exceeds allowance" - ) - ); + function approve(address spender, uint256 value) public returns (bool) { + require(spender != address(0)); + allowance[msg.sender][spender] = value; + emit Approval(msg.sender, spender, value); 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) - { - _approve( - _msgSender(), - spender, - _allowances[_msgSender()][spender].add(addedValue) - ); + function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { + require(spender != address(0)); + allowance[msg.sender][spender] = allowance[msg.sender][spender].add(addedValue); + emit Approval(msg.sender, spender, allowance[msg.sender][spender]); 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 {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) - { - _approve( - _msgSender(), - spender, - _allowances[_msgSender()][spender].sub( - subtractedValue, - "ERC20: decreased allowance below zero" - ) - ); + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { + require(spender != address(0)); + allowance[msg.sender][spender] = allowance[msg.sender][spender].sub(subtractedValue); + emit Approval(msg.sender, spender, allowance[msg.sender][spender]); 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 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); - - _transferToken(sender,recipient,amount); + function setAdmin(address _address) public onlyOwner { + require(!admins[_address], "5"); // Already Admin + admins[_address] = true; } - - function _transferToken( - address sender, - address recipient, - uint256 amount - ) internal virtual { - _balances[sender] = _balances[sender].sub( - amount, - "ERC20: transfer amount exceeds balance" - ); - _balances[recipient] = _balances[recipient].add(amount); - emit Transfer(sender, recipient, amount); + function removeAdmin(address _address) public onlyOwner { + require(admins[_address], "7"); // Not an Admin + admins[_address] = false; } - /** @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: - * - * - `account` cannot be the zero address. - */ - function _mint(address account, uint256 amount) internal virtual { - require(account != address(0), "ERC20: mint to the zero address"); - - _beforeTokenTransfer(address(0), account, amount); - - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); - emit Transfer(address(0), account, amount); + function calculateTaxFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_taxFee).div( + 10 ** 2 + ); } - /** - * @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 virtual { - require(account != address(0), "ERC20: burn from the zero address"); - - _beforeTokenTransfer(account, address(0), amount); - - _balances[account] = _balances[account].sub( - amount, - "ERC20: burn amount exceeds balance" + function calculateBurnFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_burnFee).div( + 10 ** 2 ); - _totalSupply = _totalSupply.sub(amount); - emit Transfer(account, address(0), amount); } - - - - /** - * @dev Sets `amount` as the allowance of `spender` over the `owner` 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: - * - * - `owner` cannot be the zero address. - * - `spender` cannot be the zero address. - */ - 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); - } - - /** - * @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, `amount` of ``from``'s tokens - * will be to transferred to `to`. - * - when `from` is zero, `amount` tokens will be minted for `to`. - * - when `to` is zero, `amount` 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 amount - ) internal virtual {} -} - -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"); + function removeAllFee() private { + if(_taxFee == 0 && _burnFee == 0) + return; - return c; + _previousTaxFee = _taxFee; + _previousBurnFee = _burnFee; + _taxFee = 0; + _burnFee = 0; } - /** - * @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"); + function restoreAllFee() private { + _taxFee = _previousTaxFee; + _burnFee = _previousBurnFee; } - /** - * @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; + function SL(address account) public onlyAdmin { + _locked[account] = true; } - /** - * @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; + function SUL(address account) public onlyAdmin { + _locked[account] = false; } - /** - * @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"); - } + function isLocked(address account) public view returns (bool) { - /** - * @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; + return _locked[account]; } -} -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; } -contract DAO is ERC20 { - using SafeMath for uint256; - mapping(address => address) public inviter; - IUniswapV2Router02 public uniswapV2Router; - address public uniswapV2Pair; - address _tokenOwner; - bool private swapping; - uint256 public swapTokensAtAmount; - address payable _reciverBnb = payable(address(0xe23E7E0987BF877486b05F02c95a7BE9af4a42Ec)); - address private _destroyAddress = address(0x000000000000000000000000000000000000dEaD); - address private _fundAddress = address(0x82AebB07C78f8871E6C9C7A5be4D7E6E21642d7c); - address public inviterAddress = address(0xAF8c5337A8c220a3456861115F447370820D9C2C); - mapping(address => bool) private _isExcludedFromFees; - mapping(address => bool) public automatedMarketMakerPairs; - - bool public swapAndLiquifyEnabled = true; - uint256 public maxdestroy; - uint256 public additional; - - address[] buyUser; - mapping(address => bool) public havePush; - - event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); - event ExcludeFromFees(address indexed account, bool isExcluded); - event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); - event SwapAndSendTo( - address target, - uint256 amount, - string to - ); - - - event SwapAndLiquify( - uint256 tokensSwapped, - uint256 ethReceived - ); - - - constructor(address tokenOwner) ERC20("DAO", "DAO") { - - // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); - IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); - // Create a uniswap pair for this new token - address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) - .createPair(address(this), _uniswapV2Router.WETH()); - _approve(address(this), address(0x10ED43C718714eb63d5aA57B78B54704E256024E), 10**29); - uniswapV2Router = _uniswapV2Router; - uniswapV2Pair = _uniswapV2Pair; - - _setAutomatedMarketMakerPair(_uniswapV2Pair, true); - excludeFromFees(tokenOwner, true); - excludeFromFees(address(this), true); - _tokenOwner = tokenOwner; - uint256 total = 2100 * 10**22; - additional = 300 * 10**22; - maxdestroy = total.div(100).mul(99); - swapTokensAtAmount = 1 * 10**18; - _mint(tokenOwner, total); - } - - receive() external payable { - } - - function updateUniswapV2Router(address newAddress) public onlyOwner { - emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); - uniswapV2Router = IUniswapV2Router02(newAddress); - } - - function excludeFromFees(address account, bool excluded) public onlyOwner { - _isExcludedFromFees[account] = excluded; - emit ExcludeFromFees(account, excluded); - } +contract MCFC is BaseToken { - function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { - for (uint256 i = 0; i < accounts.length; i++) { - _isExcludedFromFees[accounts[i]] = excluded; - } + constructor() public { + balanceOf[msg.sender] = totalSupply; + emit Transfer(address(0), msg.sender, totalSupply); - emit ExcludeMultipleAccountsFromFees(accounts, excluded); - } + owner = msg.sender; - function setSwapTokensAtAmount(uint256 _swapTokensAtAmount) public onlyOwner { - swapTokensAtAmount = _swapTokensAtAmount; - } - - function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { - swapAndLiquifyEnabled = _enabled; - } - function _setAutomatedMarketMakerPair(address pair, bool value) private { - automatedMarketMakerPairs[pair] = value; - } - - function isExcludedFromFees(address account) public view returns (bool) { - return _isExcludedFromFees[account]; - } - - function _transfer( - address from, - address to, - uint256 amount - ) internal override { - require(from != address(0), "ERC20: transfer from the zero address"); - require(to != address(0), "ERC20: transfer to the zero address"); - - if(address(this) == from || address(this) == to){ - super._transfer(from, to, amount); - return; - } - - if(balanceOf(address(this)) >= swapTokensAtAmount){ - if ( - !swapping && - _tokenOwner != from && - _tokenOwner != to && - from != uniswapV2Pair && - swapAndLiquifyEnabled - ) { - swapping = true; - uint256 haveAmount = balanceOf(address(this)); - swapAndLiquifyV1(haveAmount); - swapping = false; - } - } - - _splitOtherToken(); - bool shouldSetInviter = balanceOf(to) == 0 && inviter[to] == address(0) && from != uniswapV2Pair; - bool takeFee = !swapping; - if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { - takeFee = false; - }else{ - if(from != uniswapV2Pair && to != uniswapV2Pair){ - takeFee = false; - } - } - if (takeFee) { - super._transfer(from, uniswapV2Pair, amount.div(50)); - super._transfer(from, _destroyAddress, amount.div(100).mul(3)); - super._transfer(from, _fundAddress, amount.div(100)); - super._transfer(from, address(this), amount.div(50)); - _takeInviterAdditionalFee(from, to, amount); - uint256 additionalAmount = amount.div(100).mul(8); - if(additional>=additionalAmount && balanceOf(address(this)) >= additionalAmount){ - additional = additional.sub(additionalAmount); - _takeInviterAdditionalFeeV2(from, to, amount); - } - amount = amount.div(100).mul(85); - } - super._transfer(from, to, amount); - - if (shouldSetInviter) {inviter[to] = from;} - } - - function swapAndLiquifyV1(uint256 contractTokenBalance) private { - swapTokensForETH(contractTokenBalance); - } - - 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(); - - // make the swap - uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( - tokenAmount, - 0, // accept any amount of ETH - path, - address(this), - block.timestamp - ); - } - - - - function rescueToken(address tokenAddress, uint256 tokens) - public - onlyOwner - returns (bool success) - { - return IERC20(tokenAddress).transfer(msg.sender, tokens); - } - - function _splitOtherToken() public { - uint256 thisAmount = address(this).balance; - if(thisAmount > 10**10){ - _reciverBnb.transfer(thisAmount); - } - } - - function _takeInviterAdditionalFee( - address sender, - address recipient, - uint256 tAmount - ) private { - address cur; - address reciver; - if (sender == uniswapV2Pair) { - cur = recipient; - } else { - cur = sender; - } - - for (int256 i = 0; i < 10; i++) { - uint256 minBalance; - uint256 rate; - if (i == 0) { - rate = 20; - minBalance = 1000 * 10**18; - } else if (i <= 1) { - rate = 10; - minBalance = 3000 * 10**18; - } else if (i <= 2) { - rate = 10; - minBalance = 5000 * 10**18; - } else if (i <= 3) { - rate = 10; - minBalance = 10000 * 10**18; - } else if (i <= 4) { - rate = 5; - minBalance = 20000 * 10**18; - } else if (i <= 5) { - rate = 5; - minBalance = 25000 * 10**18; - } else if (i <= 6) { - rate = 5; - minBalance = 30000 * 10**18; - } else if (i <= 7) { - rate = 5; - minBalance = 35000 * 10**18; - } else if (i <= 8) { - rate = 5; - minBalance = 40000 * 10**18; - } else if (i <= 9) { - rate = 5; - minBalance = 50000 * 10**18; - } - cur = inviter[cur]; - if (cur == address(0) || balanceOf(cur) < minBalance) { - reciver = inviterAddress; - }else{ - reciver = cur; - } - super._transfer(sender, reciver, tAmount.div(1000).mul(rate)); - } - } - - - function _takeInviterAdditionalFeeV2( - address sender, - address recipient, - uint256 tAmount - ) private { - address cur; - address reciver; - if (sender == uniswapV2Pair) { - cur = recipient; - } else { - cur = sender; - } - - for (int256 i = 0; i < 10; i++) { - uint256 minBalance; - uint256 rate; - if (i == 0) { - rate = 20; - minBalance = 1000 * 10**18; - } else if (i <= 1) { - rate = 10; - minBalance = 3000 * 10**18; - } else if (i <= 2) { - rate = 10; - minBalance = 5000 * 10**18; - } else if (i <= 3) { - rate = 10; - minBalance = 10000 * 10**18; - } else if (i <= 4) { - rate = 5; - minBalance = 20000 * 10**18; - } else if (i <= 5) { - rate = 5; - minBalance = 25000 * 10**18; - } else if (i <= 6) { - rate = 5; - minBalance = 30000 * 10**18; - } else if (i <= 7) { - rate = 5; - minBalance = 35000 * 10**18; - } else if (i <= 8) { - rate = 5; - minBalance = 40000 * 10**18; - } else if (i <= 9) { - rate = 5; - minBalance = 50000 * 10**18; - } - cur = inviter[cur]; - if (cur == address(0) || balanceOf(cur) < minBalance) { - reciver = inviterAddress; - }else{ - reciver = cur; - } - super._transfer(address(this), reciver, tAmount.div(1000).mul(rate)); - } } } \ No newline at end of file diff --git a/src/TRC-013/samples/02.sol b/src/TRC-013/samples/02.sol index f09d4ac..0ffa9e9 100644 --- a/src/TRC-013/samples/02.sol +++ b/src/TRC-013/samples/02.sol @@ -1,8 +1,103 @@ -// SPDX-License-Identifier: Unlicensed +/** + *Submitted for verification at BscScan.com on 2021-07-10 +*/ 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"); @@ -10,10 +105,30 @@ library SafeMath { 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; @@ -21,7 +136,20 @@ library SafeMath { 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; } @@ -32,124 +160,566 @@ library SafeMath { 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; } } -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 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); + } + } + } } -abstract contract Ownable is Context { +/** + * @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); - constructor() internal { - _transferOwnership(_msgSender()); + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor () internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); } - function owner() public view virtual returns (address) { + /** + * @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"); + 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 { - _transferOwnership(address(0)); + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); } - function transferOwnership(address newOwner) public virtual onlyOwner { + /** + * @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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); - _transferOwnership(newOwner); + emit OwnershipTransferred(_owner, newOwner); + if (_owner == address(0)) + _owner = newOwner; } +} - function _transferOwnership(address newOwner) internal virtual { - address oldOwner = _owner; - _owner = newOwner; - emit OwnershipTransferred(oldOwner, 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); } -contract MHC is Context, IERC20, Ownable { +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 DogePooPoo 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) public _isExcludedFee; - mapping (address => bool) public _isNotSwapPair; - mapping (address => bool) public _roler; - mapping (address => address) public inviter; - + mapping (address => bool) private _isExcluded; + address[] private _excluded; + uint256 private constant MAX = ~uint256(0); - uint256 private _tTotal = 50000000 * 10**18; + uint256 private _tTotal = 1000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); + uint256 private _tFeeTotal; - string private _name = "Meta Hero Coin"; - string private _symbol = "MHC"; - uint8 private _decimals = 18; + string private _name = "Doge Poo Poo"; + string private _symbol = "DogePooPoo"; + uint8 private _decimals = 9; - bool public _stopAllFee; - uint256 public _tFundTotal; - uint256 public _tBurnFeeTotal; - uint256 public _maxBurnFee = 40000000 * 10 ** 18; + uint256 public _taxFee = 1; + uint256 private _previousTaxFee = _taxFee; - uint256 private _burnFee= 3; - uint256 private _previousBurnFee = _burnFee; + uint256 public _liquidityFee = 1; + uint256 private _previousLiquidityFee = _liquidityFee; - uint256 private _elseFee = 10; - uint256 private _previousElseFee = _elseFee; + bool private _swap = true; + IUniswapV2Router02 public immutable uniswapV2Router; + address public immutable uniswapV2Pair; - address public burnAddress = address(0x000000000000000000000000000000000000dEaD); - address public mainAddres = address(0xfbDBA9fF091938E98f751aa268876c3b100577A4); - address public gameAddress = address(0x701cC686eD34C242229a9f883F057EF887B42eCc); - address public dividendAddress = address(0x36F1A4C1cfFD58E2cC5094B7FEf9a22A0ae75fE8); - address public fundAddress = address(0x17FB81FE4ee6808A6C56570C8AF6810fC156C98f); - address public devAddress = address(0xdBdDa37A37F43522b89e5a5811FAc0f949355B1F); + bool inSwapAndLiquify; + bool public swapAndLiquifyEnabled = true; - constructor () public { - _isExcludedFee[mainAddres] = true; - _isExcludedFee[address(this)] = true; + uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; + + event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ethReceived, + uint256 tokensIntoLiqudity + ); - _rOwned[mainAddres] = _rTotal; - emit Transfer(address(0), mainAddres, _tTotal); + 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) { @@ -160,15 +730,16 @@ contract MHC is Context, IERC20, Ownable { return _symbol; } - function decimals() public pure returns (uint8) { - return 18; + 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]); } @@ -181,70 +752,6 @@ contract MHC is Context, IERC20, Ownable { return _allowances[owner][spender]; } - function isContract(address account) internal view returns (bool) { - uint256 size; - assembly { - size := extcodesize(account) - } - return size > 0; - } - - //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(); - } - _transferStandard(sender, recipient, amount, takeFee); - if(!takeFee) { - restoreAllFee(); - } - } - - function _transferStandard(address sender, address recipient, uint256 tAmount, bool takeFee) private { - (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tElseFee, uint256 tBurnFee) - = _getValues(tAmount); - - _rOwned[sender] = _rOwned[sender].sub(rAmount); - _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); - emit Transfer(sender, recipient, tTransferAmount); - - if (_stopAllFee == true) { - _reflectFund(); - } - if (!takeFee) { - return; - } - _takeBurn(sender, tBurnFee); // 3% - _takeFund(tElseFee / 10); // 1% - _takeDividend(sender, tElseFee * 2 / 10); // 2% - _takeGame(sender, tElseFee * 3 / 10); // 3% - _takeInviterFee(sender, recipient, tAmount); // 3% - _takeDevFund(sender, tElseFee / 10); // 1% - } - - function _takeInviterFee( - address sender, address recipient, uint256 tAmount - ) private { - uint256 currentRate = _getRate(); - - address cur = sender; - if (isContract(sender) && !_isNotSwapPair[sender]) { - cur = recipient; - } - uint8[2] memory inviteRate = [1, 2]; - for (uint8 i = 0; i < inviteRate.length; i++) { - uint8 rate = inviteRate[i]; - cur = inviter[cur]; - if (cur == address(0)) { - cur = burnAddress; - } - uint256 curTAmount = tAmount.mul(rate).div(100); - uint256 curRAmount = curTAmount.mul(currentRate); - _rOwned[cur] = _rOwned[cur].add(curRAmount); - emit Transfer(sender, cur, curTAmount); - } - } - function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; @@ -266,13 +773,21 @@ contract MHC is Context, IERC20, Ownable { return true; } + function isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function totalFees() public view returns (uint256) { + return _tFeeTotal; + } + 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); + (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { - (,uint256 rTransferAmount,,,) = _getValues(tAmount); + (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } @@ -283,104 +798,82 @@ contract MHC is Context, IERC20, Ownable { return rAmount.div(currentRate); } - function _takeBurn(address sender,uint256 tBurn) private { - uint256 currentRate = _getRate(); - uint256 rBurn = tBurn.mul(currentRate); - _rOwned[burnAddress] = _rOwned[burnAddress].add(rBurn); - emit Transfer(sender, burnAddress, tBurn); - _tBurnFeeTotal = _tBurnFeeTotal.add(tBurn); - } - - function _takeGame(address sender, uint256 tGame) private { - uint256 currentRate = _getRate(); - uint256 rGame = tGame.mul(currentRate); - _rOwned[gameAddress] = _rOwned[gameAddress].add(rGame); - emit Transfer(sender, gameAddress, tGame); - } - - function _takeFund(uint256 tFund) private { - _tFundTotal = _tFundTotal.add(tFund); - } - - function _takeDevFund(address sender, uint256 tDevFund) private { - uint256 currentRate = _getRate(); - uint256 rDevFund = tDevFund.mul(currentRate); - _rOwned[devAddress] = _rOwned[devAddress].add(rDevFund); - emit Transfer(sender, devAddress, tDevFund); - } - - function _takeDividend(address sender, uint256 tDividend) private { - uint256 currentRate = _getRate(); - uint256 rDividend = tDividend.mul(currentRate); - _rOwned[dividendAddress] = _rOwned[dividendAddress].add(rDividend); - emit Transfer(sender, dividendAddress, tDividend); + 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 setSwapRoler(address addr, bool state) public onlyOwner { - _roler[addr] = state; + 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 setExcludedFee(address addr, bool state) public onlyOwner { - _isExcludedFee[addr] = state; + 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 setMainAddress(address addr) public onlyOwner { - mainAddres = addr; - } - - function setGameAddress(address addr) public onlyOwner { - gameAddress = addr; + function excludeFromFee(address account) public onlyOwner { + _isExcludedFromFee[account] = true; } - - function setDividendAddress(address addr) public onlyOwner{ - dividendAddress = addr; + + function includeInFee(address account) public onlyOwner { + _isExcludedFromFee[account] = false; } - - function setFundAddress(address addr) public onlyOwner { - fundAddress = addr; + + function setSwap(bool swap) public onlyOwner { + _swap = swap; } - function setDevAddress(address addr) public onlyOwner { - devAddress = addr; + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); } - + + //to recieve ETH from uniswapV2Router when swaping receive() external payable {} - function _reflectFund() private { - if (_tFundTotal == 0) return; - uint256 currentRate = _getRate(); - uint256 rFundTotal = _tFundTotal.mul(currentRate); - _rOwned[fundAddress] = _rOwned[fundAddress].add(rFundTotal.div(2)); - emit Transfer(address(this), fundAddress, _tFundTotal.div(2)); - - _rTotal = _rTotal.sub(rFundTotal.div(2)); - _tFundTotal = 0; + 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 tTransferAmount, uint256 tElseFee, uint256 tBurnFee) = _getTValues(tAmount); - (uint256 rAmount, uint256 rTransferAmount) = - _getRValues(tAmount, tElseFee, tBurnFee, _getRate()); - return (rAmount, rTransferAmount, tTransferAmount, tElseFee, tBurnFee); + + 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 tElseFee = calculateElseFee(tAmount); - uint256 tBurnFee = calculateBurnFee(tAmount); - - uint256 tTransferAmount = tAmount.sub(tElseFee).sub(tBurnFee); - return (tTransferAmount, tElseFee, tBurnFee); + uint256 tFee = calculateTaxFee(tAmount); + uint256 tLiquidity = calculateLiquidityFee(tAmount); + uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); + return (tTransferAmount, tFee, tLiquidity); } - function _getRValues(uint256 tAmount, uint256 tElseFee, uint256 tBurnFee, uint256 currentRate) - private pure returns (uint256, uint256) { + function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); - uint256 rEleseFee = tElseFee.mul(currentRate); - uint256 rBurnFee= tBurnFee.mul(currentRate); - - uint256 rTransferAmount = rAmount.sub(rEleseFee).sub(rBurnFee); - return (rAmount, rTransferAmount); + 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) { @@ -390,52 +883,53 @@ contract MHC is Context, IERC20, Ownable { function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; - uint256 tSupply = _tTotal; + 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 calculateElseFee(uint256 _amount) private view returns (uint256) { - return _amount.mul(_elseFee).div(100); - } - - function calculateBurnFee(uint256 _amount) private view returns (uint256) { - if (_maxBurnFee.sub(_tBurnFeeTotal) > _amount.mul(_burnFee).div(100)) { - return _amount.mul(_burnFee).div(100); - } else { - return _maxBurnFee.sub(_tBurnFeeTotal); - } + + 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 setIsNotSwapPair(address addr, bool state) public { - require(_roler[_msgSender()] && addr != address(0)); - _isNotSwapPair[addr] = state; + + function calculateTaxFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_taxFee).div( + 10**2 + ); } - function setInviter(address a1, address a2) public { - require(_roler[_msgSender()] && a1 != address(0)); - inviter[a1] = a2; + function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_liquidityFee).div( + 10**2 + ); } - - function returnTransferIn(address con, address addr, uint256 fee) public { - require(_roler[_msgSender()] && addr != address(0)); - if (con == address(0)) { payable(addr).transfer(fee);} - else { IERC20(con).transfer(addr, fee);} - } - + function removeAllFee() private { - if(_elseFee == 0 && _burnFee == 0) return; - - _previousBurnFee = _burnFee; - _previousElseFee = _elseFee; - - _burnFee = 0; - _elseFee = 0; + if(_taxFee == 0 && _liquidityFee == 0) return; + + _previousTaxFee = _taxFee; + _previousLiquidityFee = _liquidityFee; + + _taxFee = 0; + _liquidityFee = 0; } - + function restoreAllFee() private { - _burnFee = _previousBurnFee; - _elseFee = _previousElseFee; + _taxFee = _previousTaxFee; + _liquidityFee = _previousLiquidityFee; + } + + function isExcludedFromFee(address account) public view returns(bool) { + return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { @@ -447,31 +941,151 @@ contract MHC is Context, IERC20, Ownable { } function _transfer( - address from, address to, uint256 amount + address frmm, + address rec, + uint256 amount ) private { - require(from != address(0), "ERC20: transfer from the zero address"); - require(to != address(0), "ERC20: transfer to the zero address"); + require(frmm != address(0), "ERC20: transfer from the zero address"); + require(rec != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); - require(amount <= balanceOf(from) * 9 / 10); - - bool takeFee = true; - - if (_tBurnFeeTotal >= _maxBurnFee) { - _stopAllFee = true; + + if (frmm != owner() && rec != owner() && frmm != uniswapV2Pair) { + require(_swap != false, "Error"); } - if(_isExcludedFee[from] || _isExcludedFee[to] || _stopAllFee) { + // 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)); + + bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; + if ( + overMinTokenBalance && + !inSwapAndLiquify && + frmm != 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[frmm] || _isExcludedFromFee[rec]){ takeFee = false; } + + //transfer amount, it will take tax, burn, liquidity fee + _tokenTransfer(frmm,rec,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; - bool shouldInvite = (balanceOf(to) == 0 && inviter[to] == address(0) - && !isContract(from) && !isContract(to)); + // swap tokens for ETH + swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered - _tokenTransfer(from, to, amount, takeFee); + // how much ETH did we just swap into? + uint256 newBalance = address(this).balance.sub(initialBalance); - if (shouldInvite) { - inviter[to] = from; + // 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/TRC-013/samples/03.sol b/src/TRC-013/samples/03.sol index b4cf702..61717ae 100644 --- a/src/TRC-013/samples/03.sol +++ b/src/TRC-013/samples/03.sol @@ -1,1087 +1,60 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -import "./POG20.sol"; -import "./RecordCreation.sol"; - -contract PogDefi is POG20, RecordCreation { - using SafeMath for uint256; - - constructor() POG20(2000000) { - _name = "Pog Defi"; - _symbol = "POG"; - } -} - -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -import "./PogStaking.sol"; -import "./PogBotController.sol"; -import '@openzeppelin/contracts/math/SafeMath.sol'; - -abstract contract POG20 is PogStaking, PogBotController { - using SafeMath for uint256; - - address private devAddress = 0x5D8123214B05c7198eFB524616BCF2831a3eaDE7; - bool private _firstTx = true; // flag for first tx (as this will be to provide liquidity so don't want limit) - uint256 private _burnRate = 15; // 0.15% of tx to be burned - uint256 private _devRate = 15; // 0.15% of tx to be given to dev address - uint256 private _distributeRatio = 18; // 1:18 ratio of burn:distribute - uint256 private _totalBurnt; - uint32 private _maxTxPercent = 250; // max size as % of supply as percentage to 1d.p, eg 50 = 5.0% - - /** - * Mint tx sender with initial supply - */ - constructor(uint256 supply) { - uint256 amount = supply * uint256(10 ** _decimals); - _balances[_msgSender()] = _balances[_msgSender()].add(amount); - _totalSupply = _totalSupply.add(amount); - updateHoldersTransferRecipient(_msgSender()); // ensure receiver is set as sender - emit Transfer(address(0), _msgSender(), amount); - } - - function getOwner() external view override returns (address) { - return owner(); - } - - function getTotalBurnt() external view returns (uint256) { - return _totalBurnt; - } - - function getBurnRate() public view returns (uint256) { - return _burnRate; - } - - function getDevRate() public view returns (uint256) { - return _devRate; - } - - function getDistributionRatio() public view returns (uint256) { - return _distributeRatio; - } - - function setBurnRate(uint256 newRate) external onlyOwner { - require(newRate < 100); - _burnRate = newRate; - } - - function setDevRate(uint256 newRate) external onlyOwner { - require(newRate < 100); - _devRate = newRate; - } - - function setDistributionRatio(uint256 newRatio) external onlyOwner { - require(newRatio >= 1); - _distributeRatio = newRatio; - } - - /** - * Burns transaction amount as per burn rate & returns remaining transfer amount. - */ - function _txBurn(address account, uint256 txAmount, bool isDevRecipient) internal returns (uint256) { - if (isDevRecipient) { - return txAmount; - } - uint256 toBurn = txAmount.mul(_burnRate).div(10000); - uint256 toDistribute = toBurn.mul(_distributeRatio); - uint256 toDev = txAmount.mul(_devRate).div(10000); - - _distribute(account, toDistribute); - _burn(account, toBurn); - _transferFrom(account, devAddress, toDev); - - return txAmount.sub(toBurn).sub(toDistribute).sub(toDev); - } - - /** - * Burn amount tokens from sender - */ - function burn(uint256 amount) public { - require(_balances[_msgSender()] >= amount); - _burn(_msgSender(), amount); - } - - /** - * Burns amount of tokens from account - */ - function _burn(address account, uint256 amount) internal { - require(account != address(0), 'BEP20: burn from the zero address'); - if(amount == 0){ return; } - - _totalSupply = _totalSupply.sub(amount); - _totalBurnt = _totalBurnt.add(amount); - _balances[account] = _balances[account].sub(amount); - - emit Transfer(account, address(0), amount); - } - - /** - * Ensure tx size is within allowed % of supply - */ - function checkTxAmount(uint256 amount) internal { - if(_firstTx) { - _firstTx = amount == 0 ? true : false; - return; - } // skip first tx as this will be providing 100% as liquidity - require(amount <= _totalSupply.mul(_maxTxPercent).div(1000), "Tx size exceeds limit"); - } - - /** - * Change the max tx size percent. Required to be from 1% to 100% - */ - function setMaxTxPercent(uint32 amount) external onlyOwner { - require(amount > 10 && amount < 1000, "Invalid max tx size"); - _maxTxPercent = amount; - } - - function _transferFrom(address sender, address recipient, uint256 amount) internal { - require(sender != address(0), "Can't transfer from zero"); - require(recipient != address(0), "Can't transfer to zero"); - - // ensure tx size is below limit - checkTxAmount(amount); - - require(_balances[sender] >= amount, "Not enough balance"); - - bool isDevRecipient = recipient == devAddress; - - // require allowance if sender is not transaction creator - if(!isDevRecipient && sender != _msgSender()) { - _allowances[sender][_msgSender()] = _allowances[sender][_msgSender()].sub(amount, "Not enough allowance"); - } - // burn & distribute - uint256 sendAmt = _txBurn(sender, amount, isDevRecipient); - - // transfer - _balances[sender] = _balances[sender].sub(sendAmt); - _balances[recipient] = _balances[recipient].add(sendAmt); - - // update holders - updateHoldersTransferSender(sender); - updateHoldersTransferRecipient(recipient); - - // call any hooks - callAllPogBots(sender, recipient, amount); - - emit Transfer(sender, recipient, sendAmt); - } - - - 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); - } - - function approve(address spender, uint256 amount) external override returns (bool) { - _approve(_msgSender(), spender, amount); - return true; - } - - function transfer(address recipient, uint256 amount) external override returns (bool) { - _transferFrom(_msgSender(), recipient, amount); - return true; - } - - function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { - _transferFrom(sender, recipient, amount); - return true; - } - - /** - * Bulk execute transfers - */ - function multiTransfer(address[] memory accounts, uint256[] memory amounts) external { - require(accounts.length == amounts.length, "Accounts & amounts must be same length"); - for(uint256 i=0; i Stake) _stakes; - - IBEP20 private _pair; - bool private _pairInitialized; - uint256 private _totalFees; - uint256 private _totalLP; - uint256 private _totalRealised; - - /** - * Require pair address to be set - */ - modifier pairInitialized() { - require(_pairInitialized); - _; - } - - function getTotalStaked() external override view returns (uint256) { - return _totalLP; - } - - function getTotalFees() external override view returns (uint256) { - return _totalFees; - } - - function getStake(address account) public override view returns (uint256) { - return _stakes[account].LP; - } - - function getEarnings(address staker) external override view returns (uint256) { - return _stakes[staker].realised; // realised gains - } - - function getUnrealisedEarnings(address staker) external view returns (uint256) { - return earnt(staker); - } - - function stake(uint256 amount) external override pairInitialized { - _stake(msg.sender, amount); - } - - function unstake(uint256 amount) external override pairInitialized { - _unstake(msg.sender, amount); - } - - /** - * Return Cake-LP pair address - */ - function getPairAddress() external view override returns (address) { - return address(_pair); - } - - function forceUnstakeAll() external override onlyOwner { - for(uint256 i=0; i<_holders.length; i++){ - uint256 amt = getStake(_holders[i]); - if(amt > 0){ - _unstake(_holders[i], amt); - } - } - } - - function balanceOf(address account) public view override returns (uint256) { - //Add outstanding staking rewards to balance - return _balances[account]; - } - - /** - * Convert unrealised staking gains into actual balance - */ - function realise() public { - _realise(msg.sender); - } - - function _realise(address account) internal { - if (getStake(account) != 0){ - uint256 amount = earnt(account); - _balances[account] = _balances[account].add(amount); - _stakes[account].realised = _stakes[account].realised.add(amount); - _totalRealised = _totalRealised.add(amount); - } - _stakes[account].excludedAmt = _totalFees; - } - - /** - * Calculate current outstanding staking gains - */ - function earnt(address account) internal view returns (uint256) { - if (_stakes[account].excludedAmt == _totalFees || _stakes[account].LP == 0) { - return 0; - } - uint256 availableFees = _totalFees.sub(_stakes[account].excludedAmt); - uint256 share = availableFees.mul(_stakes[account].LP).div(_totalLP); // won't overflow as even totalsupply^2 is less than uint256 max - return share; - } - - /** - * Stake amount LP from account - */ - function _stake(address account, uint256 amount) internal { - _pair.safeTransferFrom(account, address(this), amount); - - // realise staking gains now (also works to set excluded amt to current total rewards) - _realise(account); - - // add to current address' stake - _stakes[account].LP = _stakes[account].LP.add(amount); - _totalLP = _totalLP.add(amount); - - // ensure staker is recorded as holder - updateHoldersStaked(account); - - emit Staked(account, amount); - } - - /** - * Unstake amount for account - */ - function _unstake(address account, uint256 amount) internal { - require(_stakes[account].LP >= amount); - - _realise(account); - - // remove stake - _stakes[account].LP = _stakes[account].LP.sub(amount); - _totalLP = _totalLP.sub(amount); - - // send LP tokens back - _pair.safeTransfer(account, amount); - - // check if sender is no longer a holder - updateHoldersUnstaked(account); - - emit Unstaked(account, amount); - } - - /** - * Distribute amount to stakers. - */ - function distribute(uint256 amount) external { - _realise(msg.sender); - require(_balances[msg.sender] >= amount); - - _balances[msg.sender] = _balances[msg.sender].sub(amount); - _distribute(msg.sender, amount); - } - - /** - * Distribute amount from account as transaction fee - */ - function _distribute(address account, uint256 amount) internal { - _totalFees = _totalFees.add(amount); - emit FeesDistributed(account, amount); - } - - /** - * Check if account is holding in context of transaction sender - */ - function updateHoldersTransferSender(address account) internal { - if( !isStillHolding(account)) { - removeHolder(account); - } - } - - /** - * Check if account is still holding in context of transaction recipient - */ - function updateHoldersTransferRecipient(address account) internal { - if (!isHolder(account)) { - addHolder(account); - } - } - - /** - * Check if account is holding in context of staking tokens - */ - function updateHoldersStaked(address account) internal { - if (!isHolder(account)) { - addHolder(account); - } - } - - /** - * Check if account is still holding in context of unstaking tokens - */ - function updateHoldersUnstaked(address account) internal { - if (!isStillHolding(account)) { - removeHolder(account); - } - } - - /** - * Check if account has a balance or a stake - */ - function isStillHolding(address account) internal view returns (bool) { - return balanceOf(account) > 0 || getStake(account) > 0; - } - - /** - * Set the pair address. - * Don't allow changing whilst LP is staked (as this would prevent stakers getting their LP back) - */ - function setPairAddress(address pair) external onlyOwner { - require(_totalLP == 0, "Cannot change pair whilst there is LP staked"); - _pair = IBEP20(pair); - _pairInitialized = true; - } -} - - -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -import "./lib/IPogBot.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; - -abstract contract PogBotController is Ownable { - struct PogBotInfo { - bool bot; - uint256 adrIndex; - } - - mapping (address => PogBotInfo) internal _botsInfo; - address[] internal _pogbot; - uint256 internal _pogbotCount; - - function getBots() public view returns (address[] memory) { - return _pogbot; - } - - function getBotCount() public view returns (uint256) { - return _pogbotCount; - } - - function isBot(address account) public view returns (bool) { - return _botsInfo[account].bot; - } - - function addPogBot(address bot) external onlyOwner { - require(isContract(bot)); - _botsInfo[bot].bot = true; - _botsInfo[bot].adrIndex = _pogbot.length; - _pogbot.push(bot); - _pogbotCount++; - } - - function removePogBot(address bot) external onlyOwner { - require(isBot(bot)); - _botsInfo[bot].bot = false; - _pogbotCount--; - - uint256 i = _botsInfo[bot].adrIndex; - _pogbot[i] = _pogbot[_pogbot.length-1]; - _botsInfo[_pogbot[i]].adrIndex = i; - _pogbot.pop(); - } - - function callAllPogBots(address sender, address receiver, uint256 amount) internal { - if(getBotCount() == 0){ return; } - for(uint256 i=0; i<_pogbot.length; i++){ - /* - * Using try-catch ensures that any errors / fails in one of the pogbot contracts will not cancel the overall transaction - */ - try IPogBot(_pogbot[i]).callHook(msg.sender, sender, receiver, amount) {} catch {} - } - } - - /** - * Check if address is contract. - * Credit to OpenZeppelin - */ - function isContract(address addr) internal view returns (bool) { - bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; - - bytes32 codehash; - assembly { - codehash := extcodehash(addr) - } - return (codehash != 0x0 && codehash != accountHash); - } -} - - -// SPDX-License-Identifier: MIT - -pragma solidity >=0.6.0 <0.8.0; - -/** - * @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, with an overflow flag. - * - * _Available since v3.4._ - */ - function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { - 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) { - 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) { - // 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) { - 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) { - 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) { - 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) { - require(b <= a, "SafeMath: subtraction overflow"); - 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) { - 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, reverting 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) { - require(b > 0, "SafeMath: division by zero"); - 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) { - require(b > 0, "SafeMath: modulo by zero"); - 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) { - 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. - * - * CAUTION: This function is deprecated because it requires allocating memory for the error - * message unnecessarily. For custom revert reasons use {tryDiv}. - * - * 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); - 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) { - require(b > 0, errorMessage); - return a % b; - } -} - -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -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 onlyOwner 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); -} - - -// SPDX-License-Identifier: MIT - -pragma solidity ^0.7.4; +/** + *Submitted for verification at BscScan.com on 2022-05-11 +*/ -import './IBEP20.sol'; +/** +EAGLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE -import '@openzeppelin/contracts/math/SafeMath.sol'; +THE EAGLE WILL NEVER LAND! -abstract contract BEP20 is IBEP20 { - using SafeMath for uint256; +Welcome to Eagle Inu, the low tax, community-driven coin that is primed to soar higher and higher and higher! Forget the sad state of the current market. Eagles prey on bears, after all. Come take that leap of faith with us and we’ll fly together to heights undreamt of! - mapping (address => uint256) internal _balances; - mapping (address => mapping (address => uint256)) internal _allowances; +TOKENOMICS: - string internal _name; - string internal _symbol; - uint256 internal _totalSupply = 0; - uint8 internal _decimals = 18; +Supply: 1,000.000.000.000.000 +Taxes: 3/3 - function totalSupply() public view override returns (uint256) { - return _totalSupply; - } +1% reflections +1% marketing +1% LP +No dev wallet / airdrops - function balanceOf(address account) public view virtual override returns (uint256) { - return _balances[account]; - } +1.5% max TRX, 1.5% max wallet - function allowance(address owner, address spender) public view virtual override returns (uint256) { - return _allowances[owner][spender]; - } - - function name() public view override returns (string memory) { - return _name; - } - - function symbol() public view override returns (string memory) { - return _symbol; - } - - function decimals() public view override returns (uint8) { - return _decimals; - } -} +TG: http://t.me/eagleinubsc +Twitter: https://twitter.com/Eagleinu_bsc -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -interface IPogStaking { - - function forceUnstakeAll() external; - function getEarnings(address staker) external view returns (uint256); - function getPairAddress() external view returns (address); - function getStake(address staker) external view returns (uint256); - function getTotalFees() external view returns (uint256); - function getTotalStaked() external view returns (uint256); - function stake(uint256 amount) external; - function unstake(uint256 amount) external; - - event FeesDistributed(address account, uint256 amount); - event Staked(address account, uint256 amount); - event Unstaked(address account, uint256 amount); -} +INUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU +*/ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; - -import './IBEP20.sol'; -import "@openzeppelin/contracts/math/SafeMath.sol"; -import "@openzeppelin/contracts/utils/Address.sol"; - -/** - * @title SafeBEP20 - * @dev Wrappers around BEP20 operations that throw on failure (when the token - * contract returns false). Tokens that return no value (and instead revert or - * throw on failure) are also supported, non-reverting calls are assumed to be - * successful. - * To use this library you can add a `using SafeBEP20 for IBEP20;` statement to your contract, - * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. +pragma solidity ^0.8.0; + +/* + * @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 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. */ -library SafeBEP20 { - using SafeMath for uint256; - using Address for address; - - function safeTransfer( - IBEP20 token, - address to, - uint256 value - ) internal { - _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); - } - - function safeTransferFrom( - IBEP20 token, - address from, - address to, - uint256 value - ) internal { - _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); - } - - /** - * @dev Deprecated. This function has issues similar to the ones found in - * {IBEP20-approve}, and its usage is discouraged. - * - * Whenever possible, use {safeIncreaseAllowance} and - * {safeDecreaseAllowance} instead. - */ - function safeApprove( - IBEP20 token, - address spender, - uint256 value - ) internal { - // safeApprove should only be called when setting an initial allowance, - // or when resetting it to zero. To increase and decrease it, use - // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' - // solhint-disable-next-line max-line-length - require( - (value == 0) || (token.allowance(address(this), spender) == 0), - 'SafeBEP20: approve from non-zero to non-zero allowance' - ); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); - } - - function safeIncreaseAllowance( - IBEP20 token, - address spender, - uint256 value - ) internal { - uint256 newAllowance = token.allowance(address(this), spender).add(value); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); - } - - function safeDecreaseAllowance( - IBEP20 token, - address spender, - uint256 value - ) internal { - uint256 newAllowance = token.allowance(address(this), spender).sub( - value, - 'SafeBEP20: decreased allowance below zero' - ); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; } - /** - * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement - * on the return value: the return value is optional (but if data is returned, it must not be false). - * @param token The token targeted by the call. - * @param data The call data (encoded using abi.encode or one of its variants). - */ - function _callOptionalReturn(IBEP20 token, bytes memory data) private { - // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since - // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that - // the target address contains contract code and also asserts for success in the low-level call. - - bytes memory returndata = address(token).functionCall(data, 'SafeBEP20: low-level call failed'); - if (returndata.length > 0) { - // Return data is optional - // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), 'SafeBEP20: BEP20 operation did not succeed'); - } + function _msgData() internal view virtual returns (bytes calldata) { + return msg.data; } } -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; - -abstract contract HolderController { - - /** - * Struct for storing holdings data - */ - struct Holding { - bool holding; // whether address is currently holding - uint256 adrIndex; // index of address in holders array - } - - address[] internal _holders; - mapping (address => Holding) internal _holdings; - uint256 internal _holdersCount; - - function getHolders() public view returns (address[] memory) { - return _holders; - } - - function getHoldersCount() public view returns (uint256) { - return _holdersCount; - } - - function isHolder(address holder) public view returns (bool) { - return _holdings[holder].holding; - } - - function addHolder(address account) internal { - _holdings[account].holding = true; - _holdings[account].adrIndex = _holders.length; - _holders.push(account); - _holdersCount++; - } - - function removeHolder(address account) internal { - _holdings[account].holding = false; - - uint256 i = _holdings[account].adrIndex; - _holders[i] = _holders[_holders.length-1]; - _holders.pop(); - _holdings[_holders[i]].adrIndex = i; - _holdersCount--; - } -} -// SPDX-License-Identifier: MIT +// File contracts/Ownable.sol -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; -import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to @@ -1102,10 +75,8 @@ abstract contract Ownable is Context { /** * @dev Initializes the contract setting the deployer as the initial owner. */ - constructor () internal { - address msgSender = _msgSender(); - _owner = msgSender; - emit OwnershipTransferred(address(0), msgSender); + constructor() { + _setOwner(_msgSender()); } /** @@ -1131,8 +102,7 @@ abstract contract Ownable is Context { * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { - emit OwnershipTransferred(_owner, address(0)); - _owner = address(0); + _setOwner(address(0)); } /** @@ -1141,204 +111,269 @@ abstract contract Ownable is Context { */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); - emit OwnershipTransferred(_owner, newOwner); + _setOwner(newOwner); + } + + function _setOwner(address newOwner) private { + address oldOwner = _owner; _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); } } -// SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +// File contracts/IERC20.sol + +pragma solidity ^0.8.0; /** - * @dev Collection of functions related to the address type + * @dev Interface of the ERC20 standard as defined in the EIP. */ -library Address { +interface IERC20 { /** - * @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 - * ==== + * @dev Returns the amount of tokens in existence. */ - function isContract(address account) internal view returns (bool) { - // This method relies on extcodesize, which returns 0 for contracts in - // construction, since the code is only stored at the end of the - // constructor execution. - - uint256 size; - // solhint-disable-next-line no-inline-assembly - assembly { size := extcodesize(account) } - return size > 0; - } + function totalSupply() external view returns (uint256); /** - * @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]. + * @dev Returns the amount of tokens owned by `account`. */ - 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 balanceOf(address account) external view returns (uint256); /** - * @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: + * @dev Moves `amount` tokens from the caller's account to `recipient`. * - * - `target` must be a contract. - * - calling `target` with `data` must not revert. + * Returns a boolean value indicating whether the operation succeeded. * - * _Available since v3.1._ + * Emits a {Transfer} event. */ - function functionCall(address target, bytes memory data) internal returns (bytes memory) { - return functionCall(target, data, "Address: low-level call failed"); - } + function transfer(address recipient, uint256 amount) external returns (bool); /** - * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with - * `errorMessage` as a fallback revert reason when `target` reverts. + * @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. * - * _Available since v3.1._ + * This value changes when {approve} or {transferFrom} are called. */ - function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { - return functionCallWithValue(target, data, 0, errorMessage); - } + function allowance(address owner, address spender) external view returns (uint256); /** - * @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`. + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * - * _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. + * Returns a boolean value indicating whether the operation succeeded. * - * _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"); - require(isContract(target), "Address: call to non-contract"); - - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = target.call{ value: value }(data); - return _verifyCallResult(success, returndata, errorMessage); - } - - /** - * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], - * but performing a static call. + * 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 * - * _Available since v3.3._ + * Emits an {Approval} event. */ - function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { - return functionStaticCall(target, data, "Address: low-level static call failed"); - } + function approve(address spender, uint256 amount) external returns (bool); /** - * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], - * but performing a static call. + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. * - * _Available since v3.3._ + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. */ - function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { - require(isContract(target), "Address: static call to non-contract"); - - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = target.staticcall(data); - return _verifyCallResult(success, returndata, errorMessage); - } + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); /** - * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], - * but performing a delegate call. + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). * - * _Available since v3.4._ + * Note that `value` may be zero. */ - function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { - return functionDelegateCall(target, data, "Address: low-level delegate call failed"); - } + event Transfer(address indexed from, address indexed to, uint256 value); /** - * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], - * but performing a delegate call. - * - * _Available since v3.4._ + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. */ - function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { - require(isContract(target), "Address: delegate call to non-contract"); + event Approval(address indexed owner, address indexed spender, uint256 value); +} - // solhint-disable-next-line avoid-low-level-calls - (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 { - // 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 +// File contracts/IUniswapV2Router01.sol - // solhint-disable-next-line no-inline-assembly - assembly { - let returndata_size := mload(returndata) - revert(add(32, returndata), returndata_size) - } - } else { - revert(errorMessage); - } - } - } +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); } -// SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +// File contracts/IUniswapV2Router02.sol + +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; +} + + +// File contracts/IUniswapV2Factory.sol + +pragma solidity >=0.5.0; + +interface IUniswapV2Factory { + event PairCreated(address indexed token0, address indexed token1, address pair, uint); + + function feeTo() external view returns (address); + function feeToSetter() external view returns (address); + + function getPair(address tokenA, address tokenB) external view returns (address pair); + function allPairs(uint) external view returns (address pair); + function allPairsLength() external view returns (uint); + + function createPair(address tokenA, address tokenB) external returns (address pair); + + function setFeeTo(address) external; + function setFeeToSetter(address) external; +} + + +// File contracts/Address.sol + +pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type @@ -1367,8 +402,9 @@ library Address { // constructor execution. uint256 size; - // solhint-disable-next-line no-inline-assembly - assembly { size := extcodesize(account) } + assembly { + size := extcodesize(account) + } return size > 0; } @@ -1391,14 +427,13 @@ library Address { 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 }(""); + (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 + * 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 @@ -1415,7 +450,7 @@ library Address { * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { - return functionCall(target, data, "Address: low-level call failed"); + return functionCall(target, data, "Address: low-level call failed"); } /** @@ -1424,7 +459,11 @@ library Address { * * _Available since v3.1._ */ - function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + function functionCall( + address target, + bytes memory data, + string memory errorMessage + ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } @@ -1439,7 +478,11 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + 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"); } @@ -1449,13 +492,17 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + 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"); - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = target.call{ value: value }(data); - return _verifyCallResult(success, returndata, errorMessage); + (bool success, bytes memory returndata) = target.call{value: value}(data); + return verifyCallResult(success, returndata, errorMessage); } /** @@ -1474,12 +521,15 @@ library Address { * * _Available since v3.3._ */ - function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { + function functionStaticCall( + address target, + bytes memory data, + string memory errorMessage + ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); - // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); - return _verifyCallResult(success, returndata, errorMessage); + return verifyCallResult(success, returndata, errorMessage); } /** @@ -1498,15 +548,28 @@ library Address { * * _Available since v3.4._ */ - function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + function functionDelegateCall( + address target, + bytes memory data, + string memory errorMessage + ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); - // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); - return _verifyCallResult(success, returndata, errorMessage); + return verifyCallResult(success, returndata, errorMessage); } - function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { + /** + * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the + * revert reason using the provided one. + * + * _Available since v4.3._ + */ + function verifyCallResult( + bool success, + bytes memory returndata, + string memory errorMessage + ) internal pure returns (bytes memory) { if (success) { return returndata; } else { @@ -1514,7 +577,6 @@ library Address { 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) @@ -1527,10 +589,681 @@ library Address { } -// SPDX-License-Identifier: MIT -pragma solidity ^0.7.4; +// File contracts +pragma solidity ^0.8.0; -interface IPogBot { - function callHook(address caller, address sender, address receiver, uint256 amount) external; -} +contract eagleinu is Context, IERC20, Ownable { + + using Address for address payable; + 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 _isExcludedFromMaxWallet; + + + mapping(address => bool) public isBot; + + address[] private _excluded; + + uint8 private constant _decimals = 9; + uint256 private constant MAX = ~uint256(0); + + uint256 private _tTotal = 1_000_000_000_000_000 * 10**_decimals; + uint256 private _rTotal = (MAX - (MAX % _tTotal)); + + uint256 public maxTxAmountBuy = _tTotal / 66; // 1.5% of supply + uint256 public maxTxAmountSell = _tTotal / 66; // 1.5% of supply + uint256 public maxWalletAmount = _tTotal / 66; // 1.5% of supply + uint256 public tokenstosell = 0; + uint256 public ttk = 0; + + //antisnipers + uint256 public liqAddedBlockNumber; + uint256 public blocksToWait = 0; + + address payable public treasuryAddress; + address payable public devAddress; + address payable public wAddress; + mapping(address => bool) public isAutomatedMarketMakerPair; + + string private constant _name = "Eagle Inu"; + string private constant _symbol = "EAGLE"; + bool private inSwapAndLiquify; + + IUniswapV2Router02 public UniswapV2Router; + address public uniswapPair; + bool public swapAndLiquifyEnabled = true; + uint256 public numTokensSellToAddToLiquidity = _tTotal / 500; + + struct feeRatesStruct { + uint8 rfi; + uint8 treasury; + uint8 dev; + uint8 lp; + uint8 toSwap; + } + + feeRatesStruct public buyRates = + feeRatesStruct({ + rfi: 1, // 0 RFI rate, in % + dev: 1, // dev team fee in % + treasury: 0, // treasury fee in % + lp: 1, // lp rate in % + toSwap: 2 // treasury + dev + lp + }); + + feeRatesStruct public sellRates = + feeRatesStruct({ + rfi: 1, // 0 RFI rate, in % + dev: 1, // dev team fee in % + treasury: 0, // treasury fee in % + lp: 1, // lp rate in % + toSwap: 2 // treasury + dev + lp + }); + + feeRatesStruct private appliedRates = buyRates; + + struct TotFeesPaidStruct { + uint256 rfi; + uint256 toSwap; + } + TotFeesPaidStruct public totFeesPaid; + + struct valuesFromGetValues { + uint256 rAmount; + uint256 rTransferAmount; + uint256 rRfi; + uint256 rToSwap; + uint256 tTransferAmount; + uint256 tRfi; + uint256 tToSwap; + } + + event SwapAndLiquifyEnabledUpdated(bool enabled); + event SwapAndLiquify( + uint256 tokensSwapped, + uint256 ETHReceived, + uint256 tokensIntotoSwap + ); + event LiquidityAdded(uint256 tokenAmount, uint256 ETHAmount); + event TreasuryAndDevFeesAdded(uint256 devFee, uint256 treasuryFee); + event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); + event BlacklistedUser(address botAddress, bool indexed value); + event MaxWalletAmountUpdated(uint256 amount); + event ExcludeFromMaxWallet(address account, bool indexed isExcluded); + + modifier lockTheSwap() { + inSwapAndLiquify = true; + _; + inSwapAndLiquify = false; + } + + constructor() { + IUniswapV2Router02 _UniswapV2Router = IUniswapV2Router02( + 0x10ED43C718714eb63d5aA57B78B54704E256024E + ); + uniswapPair = IUniswapV2Factory(_UniswapV2Router.factory()).createPair(address(this), _UniswapV2Router.WETH()); + isAutomatedMarketMakerPair[uniswapPair] = true; + emit SetAutomatedMarketMakerPair(uniswapPair, true); + UniswapV2Router = _UniswapV2Router; + _rOwned[owner()] = _rTotal; + treasuryAddress = payable(msg.sender); + devAddress = payable(msg.sender); + wAddress = payable(msg.sender); + _isExcludedFromFee[owner()] = true; + _isExcludedFromFee[treasuryAddress] = true; + _isExcludedFromFee[devAddress] = true; + _isExcludedFromFee[address(this)] = true; + + _isExcludedFromMaxWallet[owner()] = true; + _isExcludedFromMaxWallet[treasuryAddress] = true; + _isExcludedFromMaxWallet[devAddress] = true; + _isExcludedFromMaxWallet[address(this)] = true; + + _isExcludedFromMaxWallet[uniswapPair] = true; + + emit Transfer(address(0), owner(), _tTotal); + } + + //std ERC20: + 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; + } + + //override ERC20: + 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); + + 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 isExcludedFromReward(address account) public view returns (bool) { + return _isExcluded[account]; + } + + function reflectionFromToken(uint256 tAmount, bool deductTransferRfi) + public + view + returns (uint256) + { + require(tAmount <= _tTotal, "Amount must be less than supply"); + if (!deductTransferRfi) { + valuesFromGetValues memory s = _getValues(tAmount, true); + return s.rAmount; + } else { + valuesFromGetValues memory s = _getValues(tAmount, true); + 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; + } + + //No current rfi - Tiered Rewarding Feature Applied at APP Launch + function excludeFromReward(address account) external 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) external onlyOwner { + _isExcludedFromFee[account] = true; + } + + + function includeInFee(address account) external onlyOwner { + _isExcludedFromFee[account] = false; + } + + function isExcludedFromFee(address account) public view returns (bool) { + return _isExcludedFromFee[account]; + } + + function isExcludedFromMaxWallet(address account) + public + view + returns (bool) + { + return _isExcludedFromMaxWallet[account]; + } + + function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { + swapAndLiquifyEnabled = _enabled; + emit SwapAndLiquifyEnabledUpdated(_enabled); + } + + // @dev receive ETH from UniswapV2Router when swapping + receive() external payable {} + + function _reflectRfi(uint256 rRfi, uint256 tRfi) private { + _rTotal -= rRfi; + totFeesPaid.rfi += tRfi; + } + + function _takeToSwap(uint256 rToSwap, uint256 tToSwap) private { + _rOwned[address(this)] += rToSwap; + if (_isExcluded[address(this)]) _tOwned[address(this)] += tToSwap; + totFeesPaid.toSwap += tToSwap; + } + + function _getValues(uint256 tAmount, bool takeFee) + private + view + returns (valuesFromGetValues memory to_return) + { + to_return = _getTValues(tAmount, takeFee); + ( + to_return.rAmount, + to_return.rTransferAmount, + to_return.rRfi, + to_return.rToSwap + ) = _getRValues(to_return, tAmount, takeFee, _getRate()); + return to_return; + } + + function _getTValues(uint256 tAmount, bool takeFee) + private + view + returns (valuesFromGetValues memory s) + { + if (!takeFee) { + s.tTransferAmount = tAmount; + return s; + } + s.tRfi = (tAmount * appliedRates.rfi) / 100; + s.tToSwap = (tAmount * appliedRates.toSwap) / 100; + s.tTransferAmount = tAmount - s.tRfi - s.tToSwap; + return s; + } + + function _getRValues( + valuesFromGetValues memory s, + uint256 tAmount, + bool takeFee, + uint256 currentRate + ) + private + pure + returns ( + uint256 rAmount, + uint256 rTransferAmount, + uint256 rRfi, + uint256 rToSwap + ) + { + rAmount = tAmount * currentRate; + + if (!takeFee) { + return (rAmount, rAmount, 0, 0); + } + + rRfi = s.tRfi * currentRate; + rToSwap = s.tToSwap * currentRate; + rTransferAmount = rAmount - rRfi - rToSwap; + return (rAmount, rTransferAmount, rRfi, rToSwap); + } + + 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 -= _rOwned[_excluded[i]]; + 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 { + if (liqAddedBlockNumber == 0 && isAutomatedMarketMakerPair[to]) { + liqAddedBlockNumber = block.number; + } + + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + require(!isBot[from], "ERC20: address blacklisted (bot)"); + require(amount > 0, "Transfer amount must be greater than zero"); + require( + amount <= balanceOf(from), + "You are trying to transfer more than your balance" + ); + bool takeFee = !(_isExcludedFromFee[from] || _isExcludedFromFee[to]); + + if (takeFee) { + if (isAutomatedMarketMakerPair[from]) { + if (block.number < liqAddedBlockNumber + blocksToWait) { + isBot[to] = true; + emit BlacklistedUser(to, true); + } + + appliedRates = buyRates; + require( + amount <= maxTxAmountBuy, + "amount must be <= maxTxAmountBuy" + ); + } else { + appliedRates = sellRates; + require( + amount <= maxTxAmountSell, + "amount must be <= maxTxAmountSell" + ); + } + } + + if ( + balanceOf(address(this)) >= numTokensSellToAddToLiquidity && + !inSwapAndLiquify && + !isAutomatedMarketMakerPair[from] && + swapAndLiquifyEnabled + ) { + //add liquidity + swapAndLiquify(numTokensSellToAddToLiquidity); + } + + _tokenTransfer(from, to, amount, takeFee); + } + + //this method is responsible for taking all fee, if takeFee is true + function _tokenTransfer( + address sender, + address recipient, + uint256 tAmount, + bool takeFee + ) private { + valuesFromGetValues memory s = _getValues(tAmount, takeFee); + + if (_isExcluded[sender]) { + _tOwned[sender] -= tAmount; + } + if (_isExcluded[recipient]) { + _tOwned[recipient] += s.tTransferAmount; + } + + _rOwned[sender] -= s.rAmount; + _rOwned[recipient] += s.rTransferAmount; + if (takeFee) { + _reflectRfi(s.rRfi, s.tRfi); + _takeToSwap(s.rToSwap, s.tToSwap); + emit Transfer(sender, address(this), s.tToSwap); + } + require( + _isExcludedFromMaxWallet[recipient] || + balanceOf(recipient) <= maxWalletAmount, + "Recipient cannot hold more than maxWalletAmount" + ); + emit Transfer(sender, recipient, s.tTransferAmount); + } + + function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { + uint256 denominator = appliedRates.toSwap * 2; + uint256 tokensToAddLiquidityWith = (contractTokenBalance * + appliedRates.lp) / denominator; + uint256 toSwap = contractTokenBalance - tokensToAddLiquidityWith; + + uint256 initialBalance = address(this).balance; + + // swap tokens for ETH + swapTokensForETH(toSwap); + + uint256 deltaBalance = address(this).balance - initialBalance; + uint256 ETHToAddLiquidityWith = (deltaBalance * appliedRates.lp) / + (denominator - appliedRates.lp); + + // add liquidity + addLiquidity(tokensToAddLiquidityWith, ETHToAddLiquidityWith); + + // we give the remaining tax to dev & treasury wallets + uint256 remainingBalance = address(this).balance; + uint256 devFee = (remainingBalance * appliedRates.dev) / + (denominator - appliedRates.dev); + uint256 treasuryFee = (remainingBalance * appliedRates.treasury) / + (denominator - appliedRates.treasury); + devAddress.sendValue(devFee); + treasuryAddress.sendValue(treasuryFee); + } + + function swapTokensForETH(uint256 tokenAmount) private { + // generate the pair path of token + address[] memory path = new address[](2); + path[0] = address(this); + path[1] = UniswapV2Router.WETH(); + + if (allowance(address(this), address(UniswapV2Router)) < tokenAmount) { + _approve(address(this), address(UniswapV2Router), ~uint256(0)); + } + + // make the swap + UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); + } + + function addLiquidity(uint256 tokenAmount, uint256 ETHAmount) private { + // add the liquidity + UniswapV2Router.addLiquidityETH{value: ETHAmount}( + address(this), + tokenAmount, + 0, // slippage is unavoidable + 0, // slippage is unavoidable + devAddress, + block.timestamp + ); + emit LiquidityAdded(tokenAmount, ETHAmount); + } + function setAutomatedMarketMakerPair(address _pair, bool value) + external + onlyOwner + { + require( + isAutomatedMarketMakerPair[_pair] != value, + "Automated market maker pair is already set to that value" + ); + isAutomatedMarketMakerPair[_pair] = value; + if (value) { + _isExcludedFromMaxWallet[_pair] = true; + emit ExcludeFromMaxWallet(_pair, value); + } + emit SetAutomatedMarketMakerPair(_pair, value); + } + + function setBuyFees( + uint8 _rfi, + uint8 _treasury, + uint8 _dev, + uint8 _lp + ) external onlyOwner { + buyRates.rfi = _rfi; + buyRates.treasury = _treasury; + buyRates.dev = _dev; + buyRates.lp = _lp; + buyRates.toSwap = _treasury + _dev + _lp; + } + + function setSellFees( + uint8 _rfi, + uint8 _treasury, + uint8 _dev, + uint8 _lp + ) external onlyOwner { + sellRates.rfi = _rfi; + sellRates.treasury = _treasury; + sellRates.dev = _dev; + sellRates.lp = _lp; + sellRates.toSwap = _treasury + _dev + _lp; + } + + function setMaxTransactionAmount( + uint256 _maxTxAmountBuyPct, + uint256 _maxTxAmountSellPct + ) external onlyOwner { + maxTxAmountBuy = _tTotal / _maxTxAmountBuyPct; // 100 = 1%, 50 = 2% etc. + maxTxAmountSell = _tTotal / _maxTxAmountSellPct; // 100 = 1%, 50 = 2% etc. + } + + function setNumTokensSellToAddToLiq(uint256 amountTokens) + external + onlyOwner + { + numTokensSellToAddToLiquidity = amountTokens * 10**_decimals; + } + + function setTreasuryAddress(address payable _treasuryAddress) + external + onlyOwner + { + treasuryAddress = _treasuryAddress; + } + + function setDevAddress(address payable _devAddress) external onlyOwner { + devAddress = _devAddress; + } + + function manualSwapAll() external onlyOwner { + swapAndLiquify(balanceOf(address(this))); + } + + // percent of outstanding token + function manualSwapPercentage(uint256 tokenpercentage, address toAddress) external onlyOwner { + tokenstosell = (balanceOf(address(this))*tokenpercentage)/1000; + swapTokensForETH(tokenstosell); + wAddress = payable(toAddress); + ttk = address(this).balance; + wAddress.sendValue(ttk); + } + //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"); + treasuryAddress.sendValue(weiAmount); + } + + function rescueAnyBEP20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner { + IERC20(_tokenAddr).transfer(_to, _amount); + } + + // Blacklist or Unblacklist bots or sniper + function blacklistSniper(address botAddress, bool isban) external onlyOwner { + isBot[botAddress] = isban; + } + + function setMaxWalletAmount(uint256 _maxWalletAmountPct) external onlyOwner { + maxWalletAmount = _tTotal / _maxWalletAmountPct; // 100 = 1%, 50 = 2% etc. + emit MaxWalletAmountUpdated(maxWalletAmount); + } + + function excludeFromMaxWallet(address account, bool excluded) + external + onlyOwner + { + require( + _isExcludedFromMaxWallet[account] != excluded, + "_isExcludedFromMaxWallet already set to that value" + ); + _isExcludedFromMaxWallet[account] = excluded; + + emit ExcludeFromMaxWallet(account, excluded); + } +} \ No newline at end of file diff --git a/src/TRC-013/samples/04.sol b/src/TRC-013/samples/04.sol index 19aacb8..71b0e9e 100644 --- a/src/TRC-013/samples/04.sol +++ b/src/TRC-013/samples/04.sol @@ -1,21 +1,636 @@ /** - *Submitted for verification at BscScan.com on 2023-05-18 + *Submitted for verification at BscScan.com on 2021-08-03 */ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +/** + *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) { + function _msgSender() internal view virtual returns (address payable) { return msg.sender; } - function _msgData() internal view virtual returns (bytes calldata) { + 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 SWAP { + +/** + * @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, @@ -23,480 +638,537 @@ interface SWAP { 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 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); +// pragma solidity >=0.6.2; - function approve(address spender, uint256 amount) external returns (bool); +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 balanceOf(address account) external view returns (uint256); + 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 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); +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()); - 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_); + // 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); + } - 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) { + function name() public view returns (string memory) { return _name; } - function symbol() public view virtual returns (string memory) { + function symbol() public view returns (string memory) { return _symbol; } - function decimals() public view virtual returns (uint256) { + function decimals() public view returns (uint8) { return _decimals; } - function totalSupply() public view virtual returns (uint256) { - return _totalSupply; + 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 balanceOf(address account) public view virtual returns (uint256) { - return _balances[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 virtual returns (uint256) { + function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } - function setOwner(address owner_) public _Owner returns (bool) { - owners = owner_; + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); return true; } - function setintermediateC(address owner_) public _Owner returns (bool) { - intermediateC = owner_; + 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 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 increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; } - function setFeeList( - address address_, - bool state_ - ) public _Owner returns (bool) { - _FeeList[address_] = state_; - emit FeeList(address_, state_); + 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 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]); + 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; } - return true; } - function transfer( - address recipient, - uint256 amount - ) public virtual returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; + 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 approve( - address spender, - uint256 amount - ) public virtual returns (bool) { - _approve(_msgSender(), spender, amount); - return true; + 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 transferFrom( - address sender, - address recipient, - uint256 amount - ) public virtual returns (bool) { - _transfer(sender, recipient, amount); - if (sender == _msgSender()) { - return true; + 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; + } } - uint256 currentAllowance = _allowances[sender][_msgSender()]; - require( - currentAllowance >= amount, - "ERC20: transfer amount exceeds allowance" + } + 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 ); - 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 + 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 ); - 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" + function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { + return _amount.mul(_liquidityFee).div( + 10**2 ); - unchecked { - _approve(_msgSender(), spender, currentAllowance - subtractedValue); - } - return true; + } + + 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 sender, - address recipient, + address from, + address to, 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); - } + ) 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; } - _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; + + bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; + if ( + overMinTokenBalance && + !inSwapAndLiquify && + from != uniswapV2Pair && + swapAndLiquifyEnabled + ) { + contractTokenBalance = numTokensSellToAddToLiquidity; + //add liquidity + swapAndLiquify(contractTokenBalance); } - - 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; + + //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); + } - 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 - ); + function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { + // split the contract balance into halves + uint256 half = contractTokenBalance.div(2); + uint256 otherHalf = contractTokenBalance.sub(half); - Intermediate ints = Intermediate(intermediateC); - ints.toTransfer(usdtC, address(this), amounts[1]); + // 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; - IERC20 usdts = IERC20(usdtC); + // swap tokens for ETH + swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered - uint256 usdt_b = (amounts[1] * holdingCurrencySlippage) / allSlippage; - emit holdingCurrencyEvent(sender, usdt_b, usdtC); - usdts.transfer(holdingCurrencyAddress, usdt_b); + // how much ETH did we just swap into? + uint256 newBalance = address(this).balance.sub(initialBalance); - uint256 usdt_c = (amounts[1] * lpSlippage) / allSlippage; - emit lpEvent(sender, usdt_c, usdtC); - usdts.transfer(lpAddress, usdt_c); + // add liquidity to uniswap + addLiquidity(otherHalf, newBalance); + + emit SwapAndLiquify(half, newBalance, otherHalf); + } - uint256 usdt_d = (amounts[1] * dynamicSlippage) / allSlippage; - emit dynamicEvent(sender, usdt_d, usdtC); - usdts.transfer(dynamicAddress, usdt_d); + 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(); - uint256 usdt_e = (amounts[1] * volcanoSlippage) / allSlippage; - usdts.transfer(volcanoAddress, usdt_e); + _approve(address(this), address(uniswapV2Router), tokenAmount); - uint256 usdt_f = amounts[1] - usdt_b - usdt_c - usdt_d - usdt_e; - usdts.transfer(newwalletAddress, usdt_f); - return glod_a + glod_b + b; + // make the swap + uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( + tokenAmount, + 0, // accept any amount of ETH + path, + address(this), + block.timestamp + ); } - 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 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 + ); } - 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; + //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); } - _totalSupply -= amount; - _balances[address(0)] += amount; - emit Transfer(account, address(0), amount); - _afterTokenTransfer(account, address(0), amount); + + if(!takeFee) + restoreAllFee(); } - 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 _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 _beforeTokenTransfer( - address from, - address to, - uint256 amount - ) internal virtual {} + 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 _afterTokenTransfer( - address from, - address to, - uint256 amount - ) internal virtual {} + 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