Guest User

Token

a guest
Jun 16th, 2021
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  pragma solidity ^0.8.4;
  2.   // SPDX-License-Identifier: Unlicensed
  3.   interface IERC20 {
  4.  
  5.       function totalSupply() external view returns (uint256);
  6.  
  7.  
  8.       function balanceOf(address account) external view returns (uint256);
  9.  
  10.  
  11.       function transfer(address recipient, uint256 amount) external returns (bool);
  12.  
  13.  
  14.       function allowance(address owner, address spender) external view returns (uint256);
  15.  
  16.       function approve(address spender, uint256 amount) external returns (bool);
  17.  
  18.       function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
  19.  
  20.  
  21.       event Transfer(address indexed from, address indexed to, uint256 value);
  22.  
  23.  
  24.       event Approval(address indexed owner, address indexed spender, uint256 value);
  25.   }
  26.  
  27.  
  28.   library SafeMath {
  29.  
  30.       function add(uint256 a, uint256 b) internal pure returns (uint256) {
  31.           uint256 c = a + b;
  32.           require(c >= a, "SafeMath: addition overflow");
  33.  
  34.           return c;
  35.       }
  36.  
  37.  
  38.       function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  39.           return sub(a, b, "SafeMath: subtraction overflow");
  40.       }
  41.  
  42.       function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  43.           require(b <= a, errorMessage);
  44.           uint256 c = a - b;
  45.  
  46.           return c;
  47.       }
  48.  
  49.  
  50.       function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  51.           // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
  52.           // benefit is lost if 'b' is also tested.
  53.           // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
  54.           if (a == 0) {
  55.               return 0;
  56.           }
  57.  
  58.           uint256 c = a * b;
  59.           require(c / a == b, "SafeMath: multiplication overflow");
  60.  
  61.           return c;
  62.       }
  63.  
  64.  
  65.       function div(uint256 a, uint256 b) internal pure returns (uint256) {
  66.           return div(a, b, "SafeMath: division by zero");
  67.       }
  68.  
  69.       function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  70.           require(b > 0, errorMessage);
  71.           uint256 c = a / b;
  72.           // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  73.  
  74.           return c;
  75.       }
  76.  
  77.  
  78.       function mod(uint256 a, uint256 b) internal pure returns (uint256) {
  79.           return mod(a, b, "SafeMath: modulo by zero");
  80.       }
  81.  
  82.  
  83.       function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  84.           require(b != 0, errorMessage);
  85.           return a % b;
  86.       }
  87.   }
  88.  
  89.   abstract contract Context {
  90.     //   function _msgSender(address payable _receiver) external payable {
  91.       function _msgSender() internal view virtual returns (address payable) {
  92.           return msg.sender;
  93.       }
  94.  
  95.       function _msgData() internal view virtual returns (bytes memory) {
  96.           this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  97.           return msg.data;
  98.       }
  99.   }
  100.  
  101.  
  102.   /**
  103.    * @dev Collection of functions related to the address type
  104.    */
  105.   library Address {
  106.  
  107.       function isContract(address account) internal view returns (bool) {
  108.           bytes32 codehash;
  109.           bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
  110.           // solhint-disable-next-line no-inline-assembly
  111.           assembly { codehash := extcodehash(account) }
  112.           return (codehash != accountHash && codehash != 0x0);
  113.       }
  114.  
  115.       function sendValue(address payable recipient, uint256 amount) internal {
  116.           require(address(this).balance >= amount, "Address: insufficient balance");
  117.  
  118.           // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
  119.           (bool success, ) = recipient.call{ value: amount }("");
  120.           require(success, "Address: unable to send value, recipient may have reverted");
  121.       }
  122.  
  123.  
  124.       function functionCall(address target, bytes memory data) internal returns (bytes memory) {
  125.         return functionCall(target, data, "Address: low-level call failed");
  126.       }
  127.  
  128.       function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
  129.           return _functionCallWithValue(target, data, 0, errorMessage);
  130.       }
  131.  
  132.  
  133.       function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
  134.           return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
  135.       }
  136.  
  137.  
  138.       function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
  139.           require(address(this).balance >= value, "Address: insufficient balance for call");
  140.           return _functionCallWithValue(target, data, value, errorMessage);
  141.       }
  142.  
  143.       function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
  144.           require(isContract(target), "Address: call to non-contract");
  145.  
  146.           // solhint-disable-next-line avoid-low-level-calls
  147.           (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
  148.           if (success) {
  149.               return returndata;
  150.           } else {
  151.               // Look for revert reason and bubble it up if present
  152.               if (returndata.length > 0) {
  153.                   // The easiest way to bubble the revert reason is using memory via assembly
  154.  
  155.                   // solhint-disable-next-line no-inline-assembly
  156.                   assembly {
  157.                       let returndata_size := mload(returndata)
  158.                       revert(add(32, returndata), returndata_size)
  159.                   }
  160.               } else {
  161.                   revert(errorMessage);
  162.               }
  163.           }
  164.       }
  165.   }
  166.  
  167.  
  168.   contract Ownable is Context {
  169.       address private _owner;
  170.       address private _previousOwner;
  171.       uint256 private _lockTime;
  172.  
  173.       event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  174.  
  175.       /**
  176.        * @dev Initializes the contract setting the deployer as the initial owner.
  177.        */
  178.       constructor () {
  179.           address msgSender = _msgSender();
  180.           _owner = msgSender;
  181.           emit OwnershipTransferred(address(0), msgSender);
  182.       }
  183.  
  184.       /**
  185.        * @dev Returns the address of the current owner.
  186.        */
  187.       function owner() public view returns (address) {
  188.           return _owner;
  189.       }
  190.  
  191.       /**
  192.        * @dev Throws if called by any account other than the owner.
  193.        */
  194.       modifier onlyOwner() {
  195.           require(_owner == _msgSender(), "Ownable: caller is not the owner");
  196.           _;
  197.       }
  198.  
  199.       function renounceOwnership() public virtual onlyOwner {
  200.           emit OwnershipTransferred(_owner, address(0));
  201.           _owner = address(0);
  202.       }
  203.  
  204.  
  205.       function transferOwnership(address newOwner) public virtual onlyOwner {
  206.           require(newOwner != address(0), "Ownable: new owner is the zero address");
  207.           emit OwnershipTransferred(_owner, newOwner);
  208.           _owner = newOwner;
  209.       }
  210.  
  211.       function geUnlockTime() public view returns (uint256) {
  212.           return _lockTime;
  213.       }
  214.  
  215.       //Locks the contract for owner for the amount of time provided
  216.       function lock(uint256 time) public virtual onlyOwner {
  217.           _previousOwner = _owner;
  218.           _owner = address(0);
  219.           _lockTime = block.timestamp + time;
  220.           emit OwnershipTransferred(_owner, address(0));
  221.       }
  222.  
  223.       //Unlocks the contract for owner when _lockTime is exceeds
  224.       function unlock() public virtual {
  225.           require(_previousOwner == msg.sender, "You don't have permission to unlock");
  226.           require(block.timestamp > _lockTime , "Contract is locked until 7 days");
  227.           emit OwnershipTransferred(_owner, _previousOwner);
  228.           _owner = _previousOwner;
  229.       }
  230.   }
  231.  
  232.   // pragma solidity >=0.5.0;
  233.  
  234.   interface IUniswapV2Factory {
  235.       event PairCreated(address indexed token0, address indexed token1, address pair, uint);
  236.  
  237.       function feeTo() external view returns (address);
  238.       function feeToSetter() external view returns (address);
  239.  
  240.       function getPair(address tokenA, address tokenB) external view returns (address pair);
  241.       function allPairs(uint) external view returns (address pair);
  242.       function allPairsLength() external view returns (uint);
  243.  
  244.       function createPair(address tokenA, address tokenB) external returns (address pair);
  245.  
  246.       function setFeeTo(address) external;
  247.       function setFeeToSetter(address) external;
  248.   }
  249.  
  250.  
  251.   // pragma solidity >=0.5.0;
  252.  
  253.   interface IUniswapV2Pair {
  254.       event Approval(address indexed owner, address indexed spender, uint value);
  255.       event Transfer(address indexed from, address indexed to, uint value);
  256.  
  257.       function name() external pure returns (string memory);
  258.       function symbol() external pure returns (string memory);
  259.       function decimals() external pure returns (uint8);
  260.       function totalSupply() external view returns (uint);
  261.       function balanceOf(address owner) external view returns (uint);
  262.       function allowance(address owner, address spender) external view returns (uint);
  263.  
  264.       function approve(address spender, uint value) external returns (bool);
  265.       function transfer(address to, uint value) external returns (bool);
  266.       function transferFrom(address from, address to, uint value) external returns (bool);
  267.  
  268.       function DOMAIN_SEPARATOR() external view returns (bytes32);
  269.       function PERMIT_TYPEHASH() external pure returns (bytes32);
  270.       function nonces(address owner) external view returns (uint);
  271.  
  272.       function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
  273.  
  274.       event Mint(address indexed sender, uint amount0, uint amount1);
  275.       event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
  276.       event Swap(
  277.           address indexed sender,
  278.           uint amount0In,
  279.           uint amount1In,
  280.           uint amount0Out,
  281.           uint amount1Out,
  282.           address indexed to
  283.       );
  284.       event Sync(uint112 reserve0, uint112 reserve1);
  285.  
  286.       function MINIMUM_LIQUIDITY() external pure returns (uint);
  287.       function factory() external view returns (address);
  288.       function token0() external view returns (address);
  289.       function token1() external view returns (address);
  290.       function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
  291.       function price0CumulativeLast() external view returns (uint);
  292.       function price1CumulativeLast() external view returns (uint);
  293.       function kLast() external view returns (uint);
  294.  
  295.       function mint(address to) external returns (uint liquidity);
  296.       function burn(address to) external returns (uint amount0, uint amount1);
  297.       function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
  298.       function skim(address to) external;
  299.       function sync() external;
  300.  
  301.       function initialize(address, address) external;
  302.   }
  303.  
  304.   // pragma solidity >=0.6.2;
  305.  
  306.   interface IUniswapV2Router01 {
  307.       function factory() external pure returns (address);
  308.       function WETH() external pure returns (address);
  309.  
  310.       function addLiquidity(
  311.           address tokenA,
  312.           address tokenB,
  313.           uint amountADesired,
  314.           uint amountBDesired,
  315.           uint amountAMin,
  316.           uint amountBMin,
  317.           address to,
  318.           uint deadline
  319.       ) external returns (uint amountA, uint amountB, uint liquidity);
  320.       function addLiquidityETH(
  321.           address token,
  322.           uint amountTokenDesired,
  323.           uint amountTokenMin,
  324.           uint amountETHMin,
  325.           address to,
  326.           uint deadline
  327.       ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
  328.       function removeLiquidity(
  329.           address tokenA,
  330.           address tokenB,
  331.           uint liquidity,
  332.           uint amountAMin,
  333.           uint amountBMin,
  334.           address to,
  335.           uint deadline
  336.       ) external returns (uint amountA, uint amountB);
  337.       function removeLiquidityETH(
  338.           address token,
  339.           uint liquidity,
  340.           uint amountTokenMin,
  341.           uint amountETHMin,
  342.           address to,
  343.           uint deadline
  344.       ) external returns (uint amountToken, uint amountETH);
  345.       function removeLiquidityWithPermit(
  346.           address tokenA,
  347.           address tokenB,
  348.           uint liquidity,
  349.           uint amountAMin,
  350.           uint amountBMin,
  351.           address to,
  352.           uint deadline,
  353.           bool approveMax, uint8 v, bytes32 r, bytes32 s
  354.       ) external returns (uint amountA, uint amountB);
  355.       function removeLiquidityETHWithPermit(
  356.           address token,
  357.           uint liquidity,
  358.           uint amountTokenMin,
  359.           uint amountETHMin,
  360.           address to,
  361.           uint deadline,
  362.           bool approveMax, uint8 v, bytes32 r, bytes32 s
  363.       ) external returns (uint amountToken, uint amountETH);
  364.       function swapExactTokensForTokens(
  365.           uint amountIn,
  366.           uint amountOutMin,
  367.           address[] calldata path,
  368.           address to,
  369.           uint deadline
  370.       ) external returns (uint[] memory amounts);
  371.       function swapTokensForExactTokens(
  372.           uint amountOut,
  373.           uint amountInMax,
  374.           address[] calldata path,
  375.           address to,
  376.           uint deadline
  377.       ) external returns (uint[] memory amounts);
  378.       function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
  379.           external
  380.           payable
  381.           returns (uint[] memory amounts);
  382.       function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
  383.           external
  384.           returns (uint[] memory amounts);
  385.       function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
  386.           external
  387.           returns (uint[] memory amounts);
  388.       function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
  389.           external
  390.           payable
  391.           returns (uint[] memory amounts);
  392.  
  393.       function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
  394.       function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
  395.       function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
  396.       function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
  397.       function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
  398.   }
  399.  
  400.  
  401.  
  402.   // pragma solidity >=0.6.2;
  403.  
  404.   interface IUniswapV2Router02 is IUniswapV2Router01 {
  405.       function removeLiquidityETHSupportingFeeOnTransferTokens(
  406.           address token,
  407.           uint liquidity,
  408.           uint amountTokenMin,
  409.           uint amountETHMin,
  410.           address to,
  411.           uint deadline
  412.       ) external returns (uint amountETH);
  413.       function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
  414.           address token,
  415.           uint liquidity,
  416.           uint amountTokenMin,
  417.           uint amountETHMin,
  418.           address to,
  419.           uint deadline,
  420.           bool approveMax, uint8 v, bytes32 r, bytes32 s
  421.       ) external returns (uint amountETH);
  422.  
  423.       function swapExactTokensForTokensSupportingFeeOnTransferTokens(
  424.           uint amountIn,
  425.           uint amountOutMin,
  426.           address[] calldata path,
  427.           address to,
  428.           uint deadline
  429.       ) external;
  430.       function swapExactETHForTokensSupportingFeeOnTransferTokens(
  431.           uint amountOutMin,
  432.           address[] calldata path,
  433.           address to,
  434.           uint deadline
  435.       ) external payable;
  436.       function swapExactTokensForETHSupportingFeeOnTransferTokens(
  437.           uint amountIn,
  438.           uint amountOutMin,
  439.           address[] calldata path,
  440.           address to,
  441.           uint deadline
  442.       ) external;
  443.   }
  444.  
  445.  
  446.   contract CoinTool is Context, IERC20, Ownable {
  447.       using SafeMath for uint256;
  448.       using Address for address;
  449.  
  450.       mapping (address => uint256) private _rOwned;
  451.       mapping (address => uint256) private _tOwned;
  452.       mapping (address => mapping (address => uint256)) private _allowances;
  453.  
  454.       mapping (address => bool) private _isExcludedFromFee;
  455.  
  456.       mapping (address => bool) private _isExcluded;
  457.       address[] private _excluded;
  458.  
  459.       uint256 private constant MAX = ~uint256(0);
  460.       uint256 private _tTotal = 1000000000 * 10**6 * 10**9;
  461.       uint256 private _rTotal = (MAX - (MAX % _tTotal));
  462.       uint256 private _tFeeTotal;
  463.  
  464.       string private _name = "CoinTool";
  465.       string private _symbol = "CoinTool";
  466.       uint8 private _decimals = 9;
  467.  
  468.       uint256 public _taxFee = 5;
  469.       uint256 private _previousTaxFee = _taxFee;
  470.  
  471.       uint256 public _liquidityFee = 5;
  472.       uint256 private _previousLiquidityFee = _liquidityFee;
  473.  
  474.       IUniswapV2Router02 public immutable uniswapV2Router;
  475.       address public immutable uniswapV2Pair;
  476.  
  477.       bool inSwapAndLiquify;
  478.       bool public swapAndLiquifyEnabled = true;
  479.  
  480.       uint256 public _maxTxAmount = 5000000 * 10**6 * 10**9;
  481.       uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9;
  482.  
  483.       address public routerAddress;
  484.  
  485.       event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
  486.       event SwapAndLiquifyEnabledUpdated(bool enabled);
  487.       event SwapAndLiquify(
  488.           uint256 tokensSwapped,
  489.           uint256 ethReceived,
  490.           uint256 tokensIntoLiqudity
  491.       );
  492.  
  493.       modifier lockTheSwap {
  494.           inSwapAndLiquify = true;
  495.           _;
  496.           inSwapAndLiquify = false;
  497.       }
  498.  
  499.       constructor () public {
  500.           _rOwned[_msgSender()] = _rTotal;
  501.  
  502.           IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(routerAddress);
  503.            // Create a uniswap pair for this new token
  504.           uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
  505.               .createPair(address(this), _uniswapV2Router.WETH());
  506.  
  507.           // set the rest of the contract variables
  508.           uniswapV2Router = _uniswapV2Router;
  509.  
  510.           //exclude owner and this contract from fee
  511.           _isExcludedFromFee[owner()] = true;
  512.           _isExcludedFromFee[address(this)] = true;
  513.  
  514.           emit Transfer(address(0), _msgSender(), _tTotal);
  515.       }
  516.  
  517.       function name() public view returns (string memory) {
  518.           return _name;
  519.       }
  520.  
  521.       function symbol() public view returns (string memory) {
  522.           return _symbol;
  523.       }
  524.  
  525.       function decimals() public view returns (uint8) {
  526.           return _decimals;
  527.       }
  528.  
  529.       function totalSupply() public view override returns (uint256) {
  530.           return _tTotal;
  531.       }
  532.  
  533.       function balanceOf(address account) public view override returns (uint256) {
  534.           if (_isExcluded[account]) return _tOwned[account];
  535.           return tokenFromReflection(_rOwned[account]);
  536.       }
  537.  
  538.       function transfer(address recipient, uint256 amount) public override returns (bool) {
  539.           _transfer(_msgSender(), recipient, amount);
  540.           return true;
  541.       }
  542.  
  543.       function allowance(address owner, address spender) public view override returns (uint256) {
  544.           return _allowances[owner][spender];
  545.       }
  546.  
  547.       function approve(address spender, uint256 amount) public override returns (bool) {
  548.           _approve(_msgSender(), spender, amount);
  549.           return true;
  550.       }
  551.  
  552.       function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
  553.           _transfer(sender, recipient, amount);
  554.           _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
  555.           return true;
  556.       }
  557.  
  558.       function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
  559.           _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
  560.           return true;
  561.       }
  562.  
  563.       function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
  564.           _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
  565.           return true;
  566.       }
  567.  
  568.       function isExcludedFromReward(address account) public view returns (bool) {
  569.           return _isExcluded[account];
  570.       }
  571.  
  572.       function totalFees() public view returns (uint256) {
  573.           return _tFeeTotal;
  574.       }
  575.  
  576.       function deliver(uint256 tAmount) public {
  577.           address sender = _msgSender();
  578.           require(!_isExcluded[sender], "Excluded addresses cannot call this function");
  579.           (uint256 rAmount,,,,,) = _getValues(tAmount);
  580.           _rOwned[sender] = _rOwned[sender].sub(rAmount);
  581.           _rTotal = _rTotal.sub(rAmount);
  582.           _tFeeTotal = _tFeeTotal.add(tAmount);
  583.       }
  584.  
  585.       function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
  586.           require(tAmount <= _tTotal, "Amount must be less than supply");
  587.           if (!deductTransferFee) {
  588.               (uint256 rAmount,,,,,) = _getValues(tAmount);
  589.               return rAmount;
  590.           } else {
  591.               (,uint256 rTransferAmount,,,,) = _getValues(tAmount);
  592.               return rTransferAmount;
  593.           }
  594.       }
  595.  
  596.       function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
  597.           require(rAmount <= _rTotal, "Amount must be less than total reflections");
  598.           uint256 currentRate =  _getRate();
  599.           return rAmount.div(currentRate);
  600.       }
  601.  
  602.       function excludeFromReward(address account) public onlyOwner() {
  603.           // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
  604.           require(!_isExcluded[account], "Account is already excluded");
  605.           if(_rOwned[account] > 0) {
  606.               _tOwned[account] = tokenFromReflection(_rOwned[account]);
  607.           }
  608.           _isExcluded[account] = true;
  609.           _excluded.push(account);
  610.       }
  611.  
  612.       function includeInReward(address account) external onlyOwner() {
  613.           require(_isExcluded[account], "Account is already excluded");
  614.           for (uint256 i = 0; i < _excluded.length; i++) {
  615.               if (_excluded[i] == account) {
  616.                   _excluded[i] = _excluded[_excluded.length - 1];
  617.                   _tOwned[account] = 0;
  618.                   _isExcluded[account] = false;
  619.                   _excluded.pop();
  620.                   break;
  621.               }
  622.           }
  623.       }
  624.           function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
  625.           (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  626.           _tOwned[sender] = _tOwned[sender].sub(tAmount);
  627.           _rOwned[sender] = _rOwned[sender].sub(rAmount);
  628.           _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
  629.           _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  630.           _takeLiquidity(tLiquidity);
  631.           _reflectFee(rFee, tFee);
  632.           emit Transfer(sender, recipient, tTransferAmount);
  633.       }
  634.  
  635.           function excludeFromFee(address account) public onlyOwner {
  636.           _isExcludedFromFee[account] = true;
  637.       }
  638.  
  639.       function includeInFee(address account) public onlyOwner {
  640.           _isExcludedFromFee[account] = false;
  641.       }
  642.  
  643.       function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
  644.           _taxFee = taxFee;
  645.       }
  646.  
  647.       function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
  648.           _liquidityFee = liquidityFee;
  649.       }
  650.  
  651.       function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
  652.           _maxTxAmount = _tTotal.mul(maxTxPercent).div(
  653.               10**2
  654.           );
  655.       }
  656.  
  657.       function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
  658.           swapAndLiquifyEnabled = _enabled;
  659.           emit SwapAndLiquifyEnabledUpdated(_enabled);
  660.       }
  661.  
  662.        //to recieve ETH from uniswapV2Router when swaping
  663.       receive() external payable {}
  664.  
  665.       function _reflectFee(uint256 rFee, uint256 tFee) private {
  666.           _rTotal = _rTotal.sub(rFee);
  667.           _tFeeTotal = _tFeeTotal.add(tFee);
  668.       }
  669.  
  670.       function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
  671.           (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
  672.           (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
  673.           return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
  674.       }
  675.  
  676.       function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
  677.           uint256 tFee = calculateTaxFee(tAmount);
  678.           uint256 tLiquidity = calculateLiquidityFee(tAmount);
  679.           uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
  680.           return (tTransferAmount, tFee, tLiquidity);
  681.       }
  682.  
  683.       function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
  684.           uint256 rAmount = tAmount.mul(currentRate);
  685.           uint256 rFee = tFee.mul(currentRate);
  686.           uint256 rLiquidity = tLiquidity.mul(currentRate);
  687.           uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
  688.           return (rAmount, rTransferAmount, rFee);
  689.       }
  690.  
  691.       function _getRate() private view returns(uint256) {
  692.           (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
  693.           return rSupply.div(tSupply);
  694.       }
  695.  
  696.       function _getCurrentSupply() private view returns(uint256, uint256) {
  697.           uint256 rSupply = _rTotal;
  698.           uint256 tSupply = _tTotal;
  699.           for (uint256 i = 0; i < _excluded.length; i++) {
  700.               if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
  701.               rSupply = rSupply.sub(_rOwned[_excluded[i]]);
  702.               tSupply = tSupply.sub(_tOwned[_excluded[i]]);
  703.           }
  704.           if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
  705.           return (rSupply, tSupply);
  706.       }
  707.  
  708.       function _takeLiquidity(uint256 tLiquidity) private {
  709.           uint256 currentRate =  _getRate();
  710.           uint256 rLiquidity = tLiquidity.mul(currentRate);
  711.           _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
  712.           if(_isExcluded[address(this)])
  713.               _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
  714.       }
  715.  
  716.       function calculateTaxFee(uint256 _amount) private view returns (uint256) {
  717.           return _amount.mul(_taxFee).div(
  718.               10**2
  719.           );
  720.       }
  721.  
  722.       function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
  723.           return _amount.mul(_liquidityFee).div(
  724.               10**2
  725.           );
  726.       }
  727.  
  728.       function removeAllFee() private {
  729.           if(_taxFee == 0 && _liquidityFee == 0) return;
  730.  
  731.           _previousTaxFee = _taxFee;
  732.           _previousLiquidityFee = _liquidityFee;
  733.  
  734.           _taxFee = 0;
  735.           _liquidityFee = 0;
  736.       }
  737.  
  738.       function restoreAllFee() private {
  739.           _taxFee = _previousTaxFee;
  740.           _liquidityFee = _previousLiquidityFee;
  741.       }
  742.  
  743.       function isExcludedFromFee(address account) public view returns(bool) {
  744.           return _isExcludedFromFee[account];
  745.       }
  746.  
  747.       function _approve(address owner, address spender, uint256 amount) private {
  748.           require(owner != address(0), "ERC20: approve from the zero address");
  749.           require(spender != address(0), "ERC20: approve to the zero address");
  750.  
  751.           _allowances[owner][spender] = amount;
  752.           emit Approval(owner, spender, amount);
  753.       }
  754.  
  755.       function _transfer(
  756.           address from,
  757.           address to,
  758.           uint256 amount
  759.       ) private {
  760.           require(from != address(0), "ERC20: transfer from the zero address");
  761.           require(to != address(0), "ERC20: transfer to the zero address");
  762.           require(amount > 0, "Transfer amount must be greater than zero");
  763.           if(from != owner() && to != owner())
  764.               require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
  765.  
  766.           // is the token balance of this contract address over the min number of
  767.           // tokens that we need to initiate a swap + liquidity lock?
  768.           // also, don't get caught in a circular liquidity event.
  769.           // also, don't swap & liquify if sender is uniswap pair.
  770.           uint256 contractTokenBalance = balanceOf(address(this));
  771.  
  772.           if(contractTokenBalance >= _maxTxAmount)
  773.           {
  774.               contractTokenBalance = _maxTxAmount;
  775.           }
  776.  
  777.           bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
  778.           if (
  779.               overMinTokenBalance &&
  780.               !inSwapAndLiquify &&
  781.               from != uniswapV2Pair &&
  782.               swapAndLiquifyEnabled
  783.           ) {
  784.               contractTokenBalance = numTokensSellToAddToLiquidity;
  785.               //add liquidity
  786.               swapAndLiquify(contractTokenBalance);
  787.           }
  788.  
  789.           //indicates if fee should be deducted from transfer
  790.           bool takeFee = true;
  791.  
  792.           //if any account belongs to _isExcludedFromFee account then remove the fee
  793.           if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
  794.               takeFee = false;
  795.           }
  796.  
  797.           //transfer amount, it will take tax, burn, liquidity fee
  798.           _tokenTransfer(from,to,amount,takeFee);
  799.       }
  800.  
  801.       function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
  802.           // split the contract balance into halves
  803.           uint256 half = contractTokenBalance.div(2);
  804.           uint256 otherHalf = contractTokenBalance.sub(half);
  805.  
  806.           // capture the contract's current ETH balance.
  807.           // this is so that we can capture exactly the amount of ETH that the
  808.           // swap creates, and not make the liquidity event include any ETH that
  809.           // has been manually sent to the contract
  810.           uint256 initialBalance = address(this).balance;
  811.  
  812.           // swap tokens for ETH
  813.           swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
  814.  
  815.           // how much ETH did we just swap into?
  816.           uint256 newBalance = address(this).balance.sub(initialBalance);
  817.  
  818.           // add liquidity to uniswap
  819.           addLiquidity(otherHalf, newBalance);
  820.  
  821.           emit SwapAndLiquify(half, newBalance, otherHalf);
  822.       }
  823.  
  824.       function swapTokensForEth(uint256 tokenAmount) private {
  825.           // generate the uniswap pair path of token -> weth
  826.           address[] memory path = new address[](2);
  827.           path[0] = address(this);
  828.           path[1] = uniswapV2Router.WETH();
  829.  
  830.           _approve(address(this), address(uniswapV2Router), tokenAmount);
  831.  
  832.           // make the swap
  833.           uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
  834.               tokenAmount,
  835.               0, // accept any amount of ETH
  836.               path,
  837.               address(this),
  838.               block.timestamp
  839.           );
  840.       }
  841.  
  842.       function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
  843.           // approve token transfer to cover all possible scenarios
  844.           _approve(address(this), address(uniswapV2Router), tokenAmount);
  845.  
  846.           // add the liquidity
  847.           uniswapV2Router.addLiquidityETH{value: ethAmount}(
  848.               address(this),
  849.               tokenAmount,
  850.               0, // slippage is unavoidable
  851.               0, // slippage is unavoidable
  852.               owner(),
  853.               block.timestamp
  854.           );
  855.       }
  856.  
  857.       //this method is responsible for taking all fee, if takeFee is true
  858.       function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
  859.           if(!takeFee)
  860.               removeAllFee();
  861.  
  862.           if (_isExcluded[sender] && !_isExcluded[recipient]) {
  863.               _transferFromExcluded(sender, recipient, amount);
  864.           } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
  865.               _transferToExcluded(sender, recipient, amount);
  866.           } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
  867.               _transferStandard(sender, recipient, amount);
  868.           } else if (_isExcluded[sender] && _isExcluded[recipient]) {
  869.               _transferBothExcluded(sender, recipient, amount);
  870.           } else {
  871.               _transferStandard(sender, recipient, amount);
  872.           }
  873.  
  874.           if(!takeFee)
  875.               restoreAllFee();
  876.       }
  877.  
  878.       function _transferStandard(address sender, address recipient, uint256 tAmount) private {
  879.           (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  880.           _rOwned[sender] = _rOwned[sender].sub(rAmount);
  881.           _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  882.           _takeLiquidity(tLiquidity);
  883.           _reflectFee(rFee, tFee);
  884.           emit Transfer(sender, recipient, tTransferAmount);
  885.       }
  886.  
  887.       function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
  888.           (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  889.           _rOwned[sender] = _rOwned[sender].sub(rAmount);
  890.           _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
  891.           _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  892.           _takeLiquidity(tLiquidity);
  893.           _reflectFee(rFee, tFee);
  894.           emit Transfer(sender, recipient, tTransferAmount);
  895.       }
  896.  
  897.       function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
  898.           (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  899.           _tOwned[sender] = _tOwned[sender].sub(tAmount);
  900.           _rOwned[sender] = _rOwned[sender].sub(rAmount);
  901.           _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  902.           _takeLiquidity(tLiquidity);
  903.           _reflectFee(rFee, tFee);
  904.           emit Transfer(sender, recipient, tTransferAmount);
  905.       }
  906.  
  907.  
  908.  
  909.  
  910.   }
RAW Paste Data