Advertisement
zakimzf

bep20-token

Jan 10th, 2022
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.42 KB | None | 0 0
  1. /**
  2. *Submitted for verification at BscScan.com on 2021-11-25
  3. */
  4.  
  5. // SPDX-License-Identifier: Unlicensed
  6.  
  7.  
  8. pragma solidity ^0.8.4;
  9.  
  10.  
  11. interface IERC20 {
  12.  
  13. function totalSupply() external view returns (uint256);
  14. function balanceOf(address account) external view returns (uint256);
  15. function transfer(address recipient, uint256 amount) external returns (bool);
  16. function allowance(address owner, address spender) external view returns (uint256);
  17. function approve(address spender, uint256 amount) external returns (bool);
  18. function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
  19. event Transfer(address indexed from, address indexed to, uint256 value);
  20. event Approval(address indexed owner, address indexed spender, uint256 value);
  21. }
  22.  
  23. library SafeMath {
  24.  
  25.  
  26. function add(uint256 a, uint256 b) internal pure returns (uint256) {
  27. return a + b;
  28. }
  29.  
  30. function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  31. return a - b;
  32. }
  33.  
  34. function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  35. return a * b;
  36. }
  37.  
  38. function div(uint256 a, uint256 b) internal pure returns (uint256) {
  39. return a / b;
  40. }
  41.  
  42. function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  43. unchecked {
  44. require(b <= a, errorMessage);
  45. return a - b;
  46. }
  47. }
  48.  
  49. function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  50. unchecked {
  51. require(b > 0, errorMessage);
  52. return a / b;
  53. }
  54. }
  55.  
  56. }
  57.  
  58.  
  59.  
  60. abstract contract Context {
  61. function _msgSender() internal view virtual returns (address) {
  62. return msg.sender;
  63. }
  64.  
  65. function _msgData() internal view virtual returns (bytes calldata) {
  66. this;
  67. return msg.data;
  68. }
  69. }
  70.  
  71.  
  72. library Address {
  73.  
  74. function isContract(address account) internal view returns (bool) {
  75. uint256 size;
  76. assembly { size := extcodesize(account) }
  77. return size > 0;
  78. }
  79.  
  80. function sendValue(address payable recipient, uint256 amount) internal {
  81. require(address(this).balance >= amount, "Address: insufficient balance");
  82. (bool success, ) = recipient.call{ value: amount }("");
  83. require(success, "Address: unable to send value, recipient may have reverted");
  84. }
  85.  
  86. function functionCall(address target, bytes memory data) internal returns (bytes memory) {
  87. return functionCall(target, data, "Address: low-level call failed");
  88. }
  89.  
  90. function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
  91. return functionCallWithValue(target, data, 0, errorMessage);
  92. }
  93.  
  94. function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
  95. return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
  96. }
  97.  
  98. function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
  99. require(address(this).balance >= value, "Address: insufficient balance for call");
  100. require(isContract(target), "Address: call to non-contract");
  101. (bool success, bytes memory returndata) = target.call{ value: value }(data);
  102. return _verifyCallResult(success, returndata, errorMessage);
  103. }
  104.  
  105. function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
  106. return functionStaticCall(target, data, "Address: low-level static call failed");
  107. }
  108.  
  109. function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
  110. require(isContract(target), "Address: static call to non-contract");
  111. (bool success, bytes memory returndata) = target.staticcall(data);
  112. return _verifyCallResult(success, returndata, errorMessage);
  113. }
  114.  
  115. function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
  116. return functionDelegateCall(target, data, "Address: low-level delegate call failed");
  117. }
  118.  
  119. function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
  120. require(isContract(target), "Address: delegate call to non-contract");
  121. (bool success, bytes memory returndata) = target.delegatecall(data);
  122. return _verifyCallResult(success, returndata, errorMessage);
  123. }
  124.  
  125. function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
  126. if (success) {
  127. return returndata;
  128. } else {
  129. if (returndata.length > 0) {
  130. assembly {
  131. let returndata_size := mload(returndata)
  132. revert(add(32, returndata), returndata_size)
  133. }
  134. } else {
  135. revert(errorMessage);
  136. }
  137. }
  138. }
  139. }
  140.  
  141.  
  142.  
  143. abstract contract Ownable is Context {
  144. address private _owner;
  145.  
  146. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  147. constructor () {
  148. _owner = msg.sender;
  149. emit OwnershipTransferred(address(0), _owner);
  150. }
  151. function owner() public view virtual returns (address) {
  152. return _owner;
  153. }
  154. modifier onlyOwner() {
  155. require(owner() == _msgSender(), "Ownable: caller is not the owner");
  156. _;
  157. }
  158.  
  159.  
  160. function renounceOwnership() public virtual onlyOwner {
  161. emit OwnershipTransferred(_owner, address(0));
  162. _owner = address(0);
  163. }
  164.  
  165.  
  166. function transferOwnership(address newOwner) public virtual onlyOwner {
  167. require(newOwner != address(0), "Ownable: new owner is the zero address");
  168. emit OwnershipTransferred(_owner, newOwner);
  169. _owner = newOwner;
  170. }
  171. }
  172.  
  173. interface IUniswapV2Factory {
  174. event PairCreated(address indexed token0, address indexed token1, address pair, uint);
  175. function feeTo() external view returns (address);
  176. function feeToSetter() external view returns (address);
  177. function getPair(address tokenA, address tokenB) external view returns (address pair);
  178. function allPairs(uint) external view returns (address pair);
  179. function allPairsLength() external view returns (uint);
  180. function createPair(address tokenA, address tokenB) external returns (address pair);
  181. function setFeeTo(address) external;
  182. function setFeeToSetter(address) external;
  183. }
  184.  
  185. interface IUniswapV2Pair {
  186. event Approval(address indexed owner, address indexed spender, uint value);
  187. event Transfer(address indexed from, address indexed to, uint value);
  188. function name() external pure returns (string memory);
  189. function symbol() external pure returns (string memory);
  190. function decimals() external pure returns (uint8);
  191. function totalSupply() external view returns (uint);
  192. function balanceOf(address owner) external view returns (uint);
  193. function allowance(address owner, address spender) external view returns (uint);
  194. function approve(address spender, uint value) external returns (bool);
  195. function transfer(address to, uint value) external returns (bool);
  196. function transferFrom(address from, address to, uint value) external returns (bool);
  197. function DOMAIN_SEPARATOR() external view returns (bytes32);
  198. function PERMIT_TYPEHASH() external pure returns (bytes32);
  199. function nonces(address owner) external view returns (uint);
  200. function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
  201. event Mint(address indexed sender, uint amount0, uint amount1);
  202. event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
  203. event Swap(
  204. address indexed sender,
  205. uint amount0In,
  206. uint amount1In,
  207. uint amount0Out,
  208. uint amount1Out,
  209. address indexed to
  210. );
  211. event Sync(uint112 reserve0, uint112 reserve1);
  212. function MINIMUM_LIQUIDITY() external pure returns (uint);
  213. function factory() external view returns (address);
  214. function token0() external view returns (address);
  215. function token1() external view returns (address);
  216. function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
  217. function price0CumulativeLast() external view returns (uint);
  218. function price1CumulativeLast() external view returns (uint);
  219. function kLast() external view returns (uint);
  220. function mint(address to) external returns (uint liquidity);
  221. function burn(address to) external returns (uint amount0, uint amount1);
  222. function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
  223. function skim(address to) external;
  224. function sync() external;
  225. function initialize(address, address) external;
  226. }
  227.  
  228. interface IUniswapV2Router01 {
  229. function factory() external pure returns (address);
  230. function WETH() external pure returns (address);
  231. function addLiquidity(
  232. address tokenA,
  233. address tokenB,
  234. uint amountADesired,
  235. uint amountBDesired,
  236. uint amountAMin,
  237. uint amountBMin,
  238. address to,
  239. uint deadline
  240. ) external returns (uint amountA, uint amountB, uint liquidity);
  241. function addLiquidityETH(
  242. address token,
  243. uint amountTokenDesired,
  244. uint amountTokenMin,
  245. uint amountETHMin,
  246. address to,
  247. uint deadline
  248. ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
  249. function removeLiquidity(
  250. address tokenA,
  251. address tokenB,
  252. uint liquidity,
  253. uint amountAMin,
  254. uint amountBMin,
  255. address to,
  256. uint deadline
  257. ) external returns (uint amountA, uint amountB);
  258. function removeLiquidityETH(
  259. address token,
  260. uint liquidity,
  261. uint amountTokenMin,
  262. uint amountETHMin,
  263. address to,
  264. uint deadline
  265. ) external returns (uint amountToken, uint amountETH);
  266. function removeLiquidityWithPermit(
  267. address tokenA,
  268. address tokenB,
  269. uint liquidity,
  270. uint amountAMin,
  271. uint amountBMin,
  272. address to,
  273. uint deadline,
  274. bool approveMax, uint8 v, bytes32 r, bytes32 s
  275. ) external returns (uint amountA, uint amountB);
  276. function removeLiquidityETHWithPermit(
  277. address token,
  278. uint liquidity,
  279. uint amountTokenMin,
  280. uint amountETHMin,
  281. address to,
  282. uint deadline,
  283. bool approveMax, uint8 v, bytes32 r, bytes32 s
  284. ) external returns (uint amountToken, uint amountETH);
  285. function swapExactTokensForTokens(
  286. uint amountIn,
  287. uint amountOutMin,
  288. address[] calldata path,
  289. address to,
  290. uint deadline
  291. ) external returns (uint[] memory amounts);
  292. function swapTokensForExactTokens(
  293. uint amountOut,
  294. uint amountInMax,
  295. address[] calldata path,
  296. address to,
  297. uint deadline
  298. ) external returns (uint[] memory amounts);
  299. function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
  300. external
  301. payable
  302. returns (uint[] memory amounts);
  303. function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
  304. external
  305. returns (uint[] memory amounts);
  306. function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
  307. external
  308. returns (uint[] memory amounts);
  309. function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
  310. external
  311. payable
  312. returns (uint[] memory amounts);
  313.  
  314. function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
  315. function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
  316. function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
  317. function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
  318. function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
  319. }
  320.  
  321. interface IUniswapV2Router02 is IUniswapV2Router01 {
  322. function removeLiquidityETHSupportingFeeOnTransferTokens(
  323. address token,
  324. uint liquidity,
  325. uint amountTokenMin,
  326. uint amountETHMin,
  327. address to,
  328. uint deadline
  329. ) external returns (uint amountETH);
  330. function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
  331. address token,
  332. uint liquidity,
  333. uint amountTokenMin,
  334. uint amountETHMin,
  335. address to,
  336. uint deadline,
  337. bool approveMax, uint8 v, bytes32 r, bytes32 s
  338. ) external returns (uint amountETH);
  339.  
  340. function swapExactTokensForTokensSupportingFeeOnTransferTokens(
  341. uint amountIn,
  342. uint amountOutMin,
  343. address[] calldata path,
  344. address to,
  345. uint deadline
  346. ) external;
  347. function swapExactETHForTokensSupportingFeeOnTransferTokens(
  348. uint amountOutMin,
  349. address[] calldata path,
  350. address to,
  351. uint deadline
  352. ) external payable;
  353. function swapExactTokensForETHSupportingFeeOnTransferTokens(
  354. uint amountIn,
  355. uint amountOutMin,
  356. address[] calldata path,
  357. address to,
  358. uint deadline
  359. ) external;
  360. }
  361.  
  362. contract SOLIDRAY is Context, IERC20, Ownable {
  363. using SafeMath for uint256;
  364. using Address for address;
  365.  
  366. mapping (address => uint256) private _rOwned;
  367. mapping (address => uint256) private _tOwned;
  368. mapping (address => mapping (address => uint256)) private _allowances;
  369. mapping (address => bool) private _isExcludedFromFee;
  370. mapping (address => bool) private _isExcluded;
  371.  
  372.  
  373. address[] private _excluded;
  374. address payable private _marketingWalletAddress = payable(0x8932E9d9639af7DbBc5bcb05fbEEaD5B0d67F92f);
  375. address payable private _utilityDevelopmentWallet = payable(0xC2210688f36516d6F4ab33D4369F96453D8F85d0);
  376. address payable private _devWalletAddress = payable(0x337F73b4F595261024216f2BD88EB68a057eBeF1);
  377.  
  378. uint256 private constant MAX = ~uint256(0);
  379. uint8 private _decimals = 18;
  380. uint256 private _tTotal = 10 * 10**9 * 10**_decimals;
  381. uint256 private _rTotal = (MAX - (MAX % _tTotal));
  382. uint256 private _tFeeTotal;
  383. string private _name = "MZF Token";
  384. string private _symbol = "MZF";
  385.  
  386.  
  387. uint256 public _reflectionFee = 1;
  388. uint256 private _previousReflectionFee = _reflectionFee;
  389.  
  390. uint256 public _liquidityFee = 2;
  391. uint256 private _previousLiquidityFee = _liquidityFee;
  392.  
  393. uint256 public _marketingFee = 3;
  394. uint256 private _previousMarketingFee = _marketingFee;
  395.  
  396. uint256 public _utilityDevelopmentFee = 2;
  397. uint256 private _previousUtilityDevelopmentFee = _utilityDevelopmentFee;
  398.  
  399. uint256 public _devFee = 2;
  400. uint256 private _previousDevFee = _devFee;
  401.  
  402. // Max wallet holding of 100%
  403. uint256 public _maxWalletToken = _tTotal * 100 / 100;
  404.  
  405. IUniswapV2Router02 public immutable uniswapV2Router;
  406. address public immutable uniswapV2Pair;
  407. bool inSwapAndLiquify;
  408. bool public swapAndLiquifyEnabled = true;
  409.  
  410. // Max transaction amount of 1%
  411. uint256 public _maxTxAmount = _tTotal * 1 / 100;
  412.  
  413. //_isBlacklisted = Can not buy or sell or transfer tokens at all
  414. // mapping (address => bool) public _isBlacklisted;
  415.  
  416. // Cooldown & timer functionality
  417. bool public buyCooldownEnabled = true;
  418. uint256 public cooldownTimerInterval = 60;
  419. mapping (address => uint) private cooldownTimer;
  420.  
  421. // Starts/Stops Trading
  422. bool public tradingOpen = true;
  423.  
  424. // Change it later, should trigger more often
  425. uint256 public _numTokensSellToAddToLiquidity = _tTotal * 1 / 10000;
  426. event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
  427. event SwapAndLiquifyEnabledUpdated(bool enabled);
  428. event SwapAndLiquify(
  429. uint256 tokensSwapped,
  430. uint256 ethReceived,
  431. uint256 tokensIntoLiqudity
  432.  
  433. );
  434.  
  435. modifier lockTheSwap {
  436. inSwapAndLiquify = true;
  437. _;
  438. inSwapAndLiquify = false;
  439. }
  440.  
  441. constructor () {
  442. _rOwned[owner()] = _rTotal;
  443.  
  444. IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);
  445. uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
  446. .createPair(address(this), _uniswapV2Router.WETH());
  447. uniswapV2Router = _uniswapV2Router;
  448. _isExcludedFromFee[owner()] = true;
  449. _isExcludedFromFee[address(this)] = true;
  450. _isExcludedFromFee[address(0x000000000000000000000000000000000000dEaD)] = true;
  451.  
  452.  
  453.  
  454. emit Transfer(address(0), owner(), _tTotal);
  455. }
  456.  
  457. function name() public view returns (string memory) {
  458. return _name;
  459. }
  460.  
  461. function symbol() public view returns (string memory) {
  462. return _symbol;
  463. }
  464.  
  465. function decimals() public view returns (uint8) {
  466. return _decimals;
  467. }
  468.  
  469. function totalSupply() public view override returns (uint256) {
  470. return _tTotal;
  471. }
  472.  
  473. function balanceOf(address account) public view override returns (uint256) {
  474. if (_isExcluded[account]) return _tOwned[account];
  475. return tokenFromReflection(_rOwned[account]);
  476. }
  477.  
  478. function transfer(address recipient, uint256 amount) public override returns (bool) {
  479. _transfer(_msgSender(), recipient, amount);
  480. return true;
  481. }
  482.  
  483. function allowance(address owner, address spender) public view override returns (uint256) {
  484. return _allowances[owner][spender];
  485. }
  486.  
  487. function approve(address spender, uint256 amount) public override returns (bool) {
  488. _approve(_msgSender(), spender, amount);
  489. return true;
  490. }
  491.  
  492. function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
  493. _transfer(sender, recipient, amount);
  494. _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
  495. return true;
  496. }
  497.  
  498. function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
  499. _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
  500. return true;
  501. }
  502.  
  503. function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
  504. _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
  505. return true;
  506. }
  507.  
  508. function isExcludedFromReward(address account) public view returns (bool) {
  509. return _isExcluded[account];
  510. }
  511.  
  512. function totalFees() public view returns (uint256) {
  513. return _tFeeTotal;
  514. }
  515.  
  516. // function manageBlacklist(address[] calldata addresses, bool status) external onlyOwner {
  517. // for (uint256 i; i < addresses.length; ++i) {
  518. // _isBlacklisted[addresses[i]] = status;
  519. // }
  520. // }
  521.  
  522. // enable cooldown between trades
  523. function cooldownEnabled(bool _status, uint256 _interval) external onlyOwner {
  524. buyCooldownEnabled = _status;
  525. cooldownTimerInterval = _interval;
  526. }
  527.  
  528. //switch Trading
  529. function tradingStatus(bool _status) external onlyOwner {
  530. tradingOpen = _status;
  531. }
  532.  
  533. // convert all stored tokens for LP into LP Pairs
  534. function convertLiquidityBalance(uint256 tokensToConvert) public onlyOwner {
  535.  
  536. uint256 contractTokenBalance = balanceOf(address(this));
  537.  
  538. if(tokensToConvert == 0){
  539. tokensToConvert = contractTokenBalance;
  540. } else if(tokensToConvert > contractTokenBalance){
  541. tokensToConvert = contractTokenBalance;
  542. }
  543. swapAndLiquify(tokensToConvert);
  544.  
  545. }
  546.  
  547.  
  548.  
  549. function deliver(uint256 tAmount) public {
  550. address sender = _msgSender();
  551. require(!_isExcluded[sender], "Excluded addresses cannot call this function");
  552. (uint256 rAmount,,,,,) = _getValues(tAmount);
  553. _rOwned[sender] = _rOwned[sender].sub(rAmount);
  554. _rTotal = _rTotal.sub(rAmount);
  555. _tFeeTotal = _tFeeTotal.add(tAmount);
  556. }
  557.  
  558. function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
  559. require(tAmount <= _tTotal, "Amount must be less than supply");
  560. if (!deductTransferFee) {
  561. (uint256 rAmount,,,,,) = _getValues(tAmount);
  562. return rAmount;
  563. } else {
  564. (,uint256 rTransferAmount,,,,) = _getValues(tAmount);
  565. return rTransferAmount;
  566. }
  567. }
  568.  
  569. function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
  570. require(rAmount <= _rTotal, "Amount must be less than total reflections");
  571. uint256 currentRate = _getRate();
  572. return rAmount.div(currentRate);
  573. }
  574.  
  575. function excludeFromReward(address account) public onlyOwner() {
  576. require(!_isExcluded[account], "Account is already excluded");
  577. if(_rOwned[account] > 0) {
  578. _tOwned[account] = tokenFromReflection(_rOwned[account]);
  579. }
  580. _isExcluded[account] = true;
  581. _excluded.push(account);
  582. }
  583.  
  584. function includeInReward(address account) external onlyOwner() {
  585. require(_isExcluded[account], "Account is already included");
  586. for (uint256 i = 0; i < _excluded.length; i++) {
  587. if (_excluded[i] == account) {
  588. _excluded[i] = _excluded[_excluded.length - 1];
  589. _tOwned[account] = 0;
  590. _isExcluded[account] = false;
  591. _excluded.pop();
  592. break;
  593. }
  594. }
  595. }
  596. function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
  597. (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  598. _tOwned[sender] = _tOwned[sender].sub(tAmount);
  599. _rOwned[sender] = _rOwned[sender].sub(rAmount);
  600. _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
  601. _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  602. _takeLiquidity(tLiquidity);
  603. _reflectFee(rFee, tFee);
  604. emit Transfer(sender, recipient, tTransferAmount);
  605. }
  606.  
  607. function excludeFromFee(address account) public onlyOwner {
  608. _isExcludedFromFee[account] = true;
  609. }
  610.  
  611. function includeInFee(address account) public onlyOwner {
  612. _isExcludedFromFee[account] = false;
  613. }
  614.  
  615. function setNumTokensToLiquidity(uint256 numTokensSellToAddToLiquidity) external onlyOwner() {
  616. _numTokensSellToAddToLiquidity = numTokensSellToAddToLiquidity;
  617. }
  618.  
  619. function feeSetReflect(uint256 reflectionFee) external onlyOwner() {
  620. _reflectionFee = reflectionFee;
  621. }
  622.  
  623.  
  624. function feeSetLiquidity(uint256 liquidityFee) external onlyOwner() {
  625. _liquidityFee = liquidityFee;
  626. }
  627.  
  628. function feeSetMarketing(uint256 marketingFee) external onlyOwner() {
  629. _marketingFee = marketingFee;
  630. }
  631.  
  632. function feeSetUtilityDevelopment(uint256 utilityDevelopmentFee) external onlyOwner() {
  633. _utilityDevelopmentFee = utilityDevelopmentFee;
  634. }
  635.  
  636. function feeSetDev(uint256 devFee) external onlyOwner() {
  637. _devFee = devFee;
  638. }
  639.  
  640. function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
  641. _maxTxAmount = _tTotal.mul(maxTxPercent).div(
  642. 10**2
  643. );
  644. }
  645.  
  646. function setMaxHoldPercent(uint256 maxWallPercent) external onlyOwner() {
  647. _maxWalletToken = _tTotal.mul(maxWallPercent).div(
  648. 10**2
  649. );
  650. }
  651.  
  652. function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
  653. swapAndLiquifyEnabled = _enabled;
  654. emit SwapAndLiquifyEnabledUpdated(_enabled);
  655. }
  656.  
  657. receive() external payable {}
  658.  
  659. function _reflectFee(uint256 rFee, uint256 tFee) private {
  660. _rTotal = _rTotal.sub(rFee);
  661. _tFeeTotal = _tFeeTotal.add(tFee);
  662. }
  663.  
  664.  
  665. function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
  666. (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
  667. (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
  668. return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
  669. }
  670.  
  671. function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
  672. uint256 tFee = calculateReflectionFee(tAmount);
  673. uint256 tLiquidity = calculateLiquidityFee(tAmount);
  674. uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
  675. return (tTransferAmount, tFee, tLiquidity);
  676. }
  677.  
  678. function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
  679. uint256 rAmount = tAmount.mul(currentRate);
  680. uint256 rFee = tFee.mul(currentRate);
  681. uint256 rLiquidity = tLiquidity.mul(currentRate);
  682. uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
  683. return (rAmount, rTransferAmount, rFee);
  684. }
  685.  
  686. function _getRate() private view returns(uint256) {
  687. (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
  688. return rSupply.div(tSupply);
  689. }
  690.  
  691. function _getCurrentSupply() private view returns(uint256, uint256) {
  692. uint256 rSupply = _rTotal;
  693. uint256 tSupply = _tTotal;
  694. for (uint256 i = 0; i < _excluded.length; i++) {
  695. if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
  696. rSupply = rSupply.sub(_rOwned[_excluded[i]]);
  697. tSupply = tSupply.sub(_tOwned[_excluded[i]]);
  698. }
  699. if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
  700. return (rSupply, tSupply);
  701. }
  702.  
  703. function _takeLiquidity(uint256 tLiquidity) private {
  704. uint256 currentRate = _getRate();
  705. uint256 rLiquidity = tLiquidity.mul(currentRate);
  706. _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
  707. if(_isExcluded[address(this)])
  708. _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
  709. }
  710.  
  711. function calculateReflectionFee(uint256 _amount) private view returns (uint256) {
  712. return _amount.mul(_reflectionFee).div(
  713. 10**2
  714. );
  715. }
  716.  
  717.  
  718. function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
  719. return _amount.mul(_liquidityFee).div(
  720. 10**2
  721. );
  722. }
  723.  
  724. function calculateMarketingFee(uint256 _amount) private view returns (uint256) {
  725. return _amount.mul(_marketingFee).div(
  726. 10**2
  727. );
  728. }
  729.  
  730. function calculateDevFee(uint256 _amount) private view returns (uint256) {
  731. return _amount.mul(_devFee).div(
  732. 10**2
  733. );
  734. }
  735.  
  736. function removeAllFee() private {
  737. if(_reflectionFee == 0 && _liquidityFee == 0 && _marketingFee == 0 && _devFee == 0) return;
  738.  
  739. _previousReflectionFee = _reflectionFee;
  740. _previousLiquidityFee = _liquidityFee;
  741. _previousMarketingFee = _marketingFee;
  742. _previousDevFee = _devFee;
  743.  
  744. _reflectionFee = 0;
  745. _liquidityFee = 0;
  746. _marketingFee = 0;
  747. _devFee = 0;
  748. }
  749.  
  750. function restoreAllFee() private {
  751. _reflectionFee = _previousReflectionFee;
  752. _liquidityFee = _previousLiquidityFee;
  753. _marketingFee = _previousMarketingFee;
  754. _devFee = _previousDevFee;
  755.  
  756. }
  757.  
  758. function isExcludedFromFee(address account) public view returns(bool) {
  759. return _isExcludedFromFee[account];
  760. }
  761.  
  762. function _approve(address owner, address spender, uint256 amount) private {
  763. require(owner != address(0), "Nope, can't do that. Sorry, the owner is... dead!");
  764. require(spender != address(0), "No puedo hacer esta, disculpa.");
  765.  
  766. _allowances[owner][spender] = amount;
  767. emit Approval(owner, spender, amount);
  768. }
  769.  
  770. function _transfer(
  771. address from,
  772. address to,
  773. uint256 amount
  774. ) private {
  775.  
  776.  
  777. if (to != owner() && to != address(this) && to != address(0x000000000000000000000000000000000000dEaD) && to != uniswapV2Pair && to != _marketingWalletAddress){
  778. uint256 heldTokens = balanceOf(to);
  779. require((heldTokens + amount) <= _maxWalletToken,"Max wallet holding reached");
  780. }
  781.  
  782. require(from != address(0), "from 0 address");
  783. require(to != address(0), "to 0 address");
  784. require(amount > 0, "must be value");
  785.  
  786. if(from != owner() && to != owner()){
  787. require(amount <= _maxTxAmount, "over max transaction limit");
  788. }
  789.  
  790. if(from != owner()){
  791. require(tradingOpen,"Trading not open yet");
  792. }
  793.  
  794. // Blacklisting
  795. // require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted");
  796.  
  797. // cooldown timer, so a bot doesnt do quick trades! 5min gap between 2 trades
  798. if (from == uniswapV2Pair &&
  799. buyCooldownEnabled &&
  800. !_isExcludedFromFee[to] &&
  801. to != address(this) &&
  802. to != address(0x000000000000000000000000000000000000dEaD)) {
  803. require(cooldownTimer[to] < block.timestamp,"Please wait for cooldown between buys");
  804. cooldownTimer[to] = block.timestamp + cooldownTimerInterval;
  805. }
  806.  
  807.  
  808. uint256 contractTokenBalance = balanceOf(address(this));
  809.  
  810. if(contractTokenBalance >= _maxTxAmount)
  811. {
  812. contractTokenBalance = _maxTxAmount;
  813. }
  814.  
  815. bool overMinTokenBalance = contractTokenBalance >= _numTokensSellToAddToLiquidity;
  816. if (
  817. overMinTokenBalance &&
  818. !inSwapAndLiquify &&
  819. from != uniswapV2Pair &&
  820. swapAndLiquifyEnabled
  821. ) {
  822. contractTokenBalance = _numTokensSellToAddToLiquidity;
  823. swapAndLiquify(contractTokenBalance);
  824. }
  825.  
  826. bool takeFee = true;
  827. require(to != address(0), "ERC20: transfer to the zero address");
  828.  
  829. if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
  830. takeFee = false;
  831. }
  832.  
  833. _tokenTransfer(from,to,amount,takeFee);
  834. }
  835.  
  836. function sendToMarketingWallet(uint256 amount) private {
  837. _marketingWalletAddress.transfer(amount);
  838. }
  839.  
  840. function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
  841.  
  842. uint256 __splitMarketing = 0;
  843. uint256 __tokensToMarketing = 0;
  844.  
  845.  
  846.  
  847. if (_marketingFee != 0){
  848.  
  849. __splitMarketing = 100/_marketingFee*_marketingFee;
  850. __tokensToMarketing = contractTokenBalance*__splitMarketing/100;
  851.  
  852. uint256 balanceBeforeMarketingWallet = address(this).balance;
  853. swapTokensForEth(__tokensToMarketing);
  854. uint256 balanceToSendMarketing = address(this).balance - balanceBeforeMarketingWallet;
  855. sendToMarketingWallet(balanceToSendMarketing);
  856. }
  857.  
  858. if (_liquidityFee != 0){
  859. uint256 __tokenstoLP = contractTokenBalance-__tokensToMarketing;
  860. uint256 firstHalf = __tokenstoLP.div(2);
  861. uint256 secondHalf = __tokenstoLP.sub(firstHalf);
  862. uint256 balanceBeforeLP = address(this).balance;
  863. swapTokensForEth(firstHalf);
  864. uint256 swappedLP = address(this).balance.sub(balanceBeforeLP);
  865. addLiquidity(secondHalf, swappedLP);
  866. emit SwapAndLiquify(firstHalf, swappedLP, secondHalf);
  867. }
  868. }
  869.  
  870.  
  871. function swapTokensForEth(uint256 tokenAmount) private {
  872. address[] memory path = new address[](2);
  873. path[0] = address(this);
  874. path[1] = uniswapV2Router.WETH();
  875. _approve(address(this), address(uniswapV2Router), tokenAmount);
  876. uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
  877. tokenAmount,
  878. 0,
  879. path,
  880. address(this),
  881. block.timestamp
  882. );
  883. }
  884.  
  885. function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
  886. _approve(address(this), address(uniswapV2Router), tokenAmount);
  887. uniswapV2Router.addLiquidityETH{value: ethAmount}(
  888. address(this),
  889. tokenAmount,
  890. 0,
  891. 0,
  892. owner(),
  893. block.timestamp
  894. );
  895. }
  896.  
  897. //safety flush
  898. function process_TokensFromContract(uint256 tokenAmount) public onlyOwner {
  899. uint256 tokensOnWallet = balanceOf(address(this));
  900. if (tokenAmount > tokensOnWallet) {tokenAmount = tokensOnWallet;}
  901. uint256 balanceBefore = address(this).balance;
  902. swapTokensForEth(tokenAmount);
  903. uint256 balanceToSend = address(this).balance - balanceBefore;
  904. sendToMarketingWallet(balanceToSend);
  905. }
  906. //safety flush 2
  907. function process_BNBFromContract(uint256 bnbAmount) public onlyOwner {
  908. uint256 contractBNB = address(this).balance;
  909. if (contractBNB > 0) {
  910. if (bnbAmount > contractBNB) {bnbAmount = contractBNB;}
  911. sendToMarketingWallet(bnbAmount);
  912. }
  913. }
  914.  
  915.  
  916. function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
  917.  
  918. if(!takeFee)
  919. removeAllFee();
  920.  
  921. if (_isExcluded[sender] && !_isExcluded[recipient]) {
  922. _transferFromExcluded(sender, recipient, amount);
  923. } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
  924. _transferToExcluded(sender, recipient, amount);
  925. } else if (_isExcluded[sender] && _isExcluded[recipient]) {
  926. _transferBothExcluded(sender, recipient, amount);
  927. } else {
  928. _transferStandard(sender, recipient, amount);
  929. }
  930.  
  931. if(!takeFee)
  932. restoreAllFee();
  933. }
  934.  
  935. function _transferStandard(address sender, address recipient, uint256 tAmount) private {
  936. (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  937.  
  938. _rOwned[sender] = _rOwned[sender].sub(rAmount);
  939. _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  940. _takeLiquidity(tLiquidity);
  941. _reflectFee(rFee, tFee);
  942. emit Transfer(sender, recipient, tTransferAmount);
  943. }
  944.  
  945. function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
  946. (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  947.  
  948. _rOwned[sender] = _rOwned[sender].sub(rAmount);
  949. _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
  950. _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  951. _takeLiquidity(tLiquidity);
  952. _reflectFee(rFee, tFee);
  953. emit Transfer(sender, recipient, tTransferAmount);
  954. }
  955.  
  956. function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
  957. (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
  958.  
  959. _tOwned[sender] = _tOwned[sender].sub(tAmount);
  960. _rOwned[sender] = _rOwned[sender].sub(rAmount);
  961. _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
  962. _takeLiquidity(tLiquidity);
  963. _reflectFee(rFee, tFee);
  964. emit Transfer(sender, recipient, tTransferAmount);
  965. }
  966.  
  967. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement