Share
Buy $MOVE
SafeDrive (Drive)

0xa321...265c

Buy tax: 8%

Sell tax: 7.5%

Overall Score

83/100

Decentralization

81/100

Security

90/100

Code Quality

74/100

1// Beginning of SafeDrive.sol
2/**
3*/
4
5pragma solidity ^0.6.12;
6
7// #SafeDrive $Drive
8// 8% Fees - 4% Redistributed To Holders, 4% Goes To Liquidity
9// SPDX-License-Identifier: Unlicensed
10
11
12interface IBEP20 {
13
14 function totalSupply() external view returns (uint256);
15
16 /**
17 * @dev Returns the amount of tokens owned by `account`.
18 */
19 function balanceOf(address account) external view returns (uint256);
20
21 /**
22 * @dev Moves `amount` tokens from the caller's account to `recipient`.
23 *
24 * Returns a boolean value indicating whether the operation succeeded.
25 *
26 * Emits a {Transfer} event.
27 */
28 function transfer(address recipient, uint256 amount) external returns (bool);
29
30 /**
31 * @dev Returns the remaining number of tokens that `spender` will be
32 * allowed to spend on behalf of `owner` through {transferFrom}. This is
33 * zero by default.
34 *
35 * This value changes when {approve} or {transferFrom} are called.
36 */
37 function allowance(address owner, address spender) external view returns (uint256);
38
39 /**
40 * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
41 *
42 * Returns a boolean value indicating whether the operation succeeded.
43 *
44 * IMPORTANT: Beware that changing an allowance with this method brings the risk
45 * that someone may use both the old and the new allowance by unfortunate
46 * transaction ordering. One possible solution to mitigate this race
47 * condition is to first reduce the spender's allowance to 0 and set the
48 * desired value afterwards:
49 * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
50 *
51 * Emits an {Approval} event.
52 */
53 function approve(address spender, uint256 amount) external returns (bool);
54
55 /**
56 * @dev Moves `amount` tokens from `sender` to `recipient` using the
57 * allowance mechanism. `amount` is then deducted from the caller's
58 * allowance.
59 *
60 * Returns a boolean value indicating whether the operation succeeded.
61 *
62 * Emits a {Transfer} event.
63 */
64 function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
65
66 /**
67 * @dev Emitted when `value` tokens are moved from one account (`from`) to
68 * another (`to`).
69 *
70 * Note that `value` may be zero.
71 */
72 event Transfer(address indexed from, address indexed to, uint256 value);
73
74 /**
75 * @dev Emitted when the allowance of a `spender` for an `owner` is set by
76 * a call to {approve}. `value` is the new allowance.
77 */
78 event Approval(address indexed owner, address indexed spender, uint256 value);
79}
80
81
82
83/**
84 * @dev Wrappers over Solidity's arithmetic operations with added overflow
85 * checks.
86 *
87 * Arithmetic operations in Solidity wrap on overflow. This can easily result
88 * in bugs, because programmers usually assume that an overflow raises an
89 * error, which is the standard behavior in high level programming languages.
90 * `SafeMath` restores this intuition by reverting the transaction when an
91 * operation overflows.
92 *
93 * Using this library instead of the unchecked operations eliminates an entire
94 * class of bugs, so it's recommended to use it always.
95 */
96
97library SafeMath {
98 /**
99 * @dev Returns the addition of two unsigned integers, reverting on
100 * overflow.
101 *
102 * Counterpart to Solidity's `+` operator.
103 *
104 * Requirements:
105 *
106 * - Addition cannot overflow.
107 */
108 function add(uint256 a, uint256 b) internal pure returns (uint256) {
109 uint256 c = a + b;
110 require(c >= a, "SafeMath: addition overflow");
111
112 return c;
113 }
114
115 /**
116 * @dev Returns the subtraction of two unsigned integers, reverting on
117 * overflow (when the result is negative).
118 *
119 * Counterpart to Solidity's `-` operator.
120 *
121 * Requirements:
122 *
123 * - Subtraction cannot overflow.
124 */
125 function sub(uint256 a, uint256 b) internal pure returns (uint256) {
126 return sub(a, b, "SafeMath: subtraction overflow");
127 }
128
129 /**
130 * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
131 * overflow (when the result is negative).
132 *
133 * Counterpart to Solidity's `-` operator.
134 *
135 * Requirements:
136 *
137 * - Subtraction cannot overflow.
138 */
139 function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
140 require(b <= a, errorMessage);
141 uint256 c = a - b;
142
143 return c;
144 }
145
146 /**
147 * @dev Returns the multiplication of two unsigned integers, reverting on
148 * overflow.
149 *
150 * Counterpart to Solidity's `*` operator.
151 *
152 * Requirements:
153 *
154 * - Multiplication cannot overflow.
155 */
156 function mul(uint256 a, uint256 b) internal pure returns (uint256) {
157 // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
158 // benefit is lost if 'b' is also tested.
159 // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
160 if (a == 0) {
161 return 0;
162 }
163
164 uint256 c = a * b;
165 require(c / a == b, "SafeMath: multiplication overflow");
166
167 return c;
168 }
169
170 /**
171 * @dev Returns the integer division of two unsigned integers. Reverts on
172 * division by zero. The result is rounded towards zero.
173 *
174 * Counterpart to Solidity's `/` operator. Note: this function uses a
175 * `revert` opcode (which leaves remaining gas untouched) while Solidity
176 * uses an invalid opcode to revert (consuming all remaining gas).
177 *
178 * Requirements:
179 *
180 * - The divisor cannot be zero.
181 */
182 function div(uint256 a, uint256 b) internal pure returns (uint256) {
183 return div(a, b, "SafeMath: division by zero");
184 }
185
186 /**
187 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
188 * division by zero. The result is rounded towards zero.
189 *
190 * Counterpart to Solidity's `/` operator. Note: this function uses a
191 * `revert` opcode (which leaves remaining gas untouched) while Solidity
192 * uses an invalid opcode to revert (consuming all remaining gas).
193 *
194 * Requirements:
195 *
196 * - The divisor cannot be zero.
197 */
198 function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
199 require(b > 0, errorMessage);
200 uint256 c = a / b;
201 // assert(a == b * c + a % b); // There is no case in which this doesn't hold
202
203 return c;
204 }
205
206 /**
207 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
208 * Reverts when dividing by zero.
209 *
210 * Counterpart to Solidity's `%` operator. This function uses a `revert`
211 * opcode (which leaves remaining gas untouched) while Solidity uses an
212 * invalid opcode to revert (consuming all remaining gas).
213 *
214 * Requirements:
215 *
216 * - The divisor cannot be zero.
217 */
218 function mod(uint256 a, uint256 b) internal pure returns (uint256) {
219 return mod(a, b, "SafeMath: modulo by zero");
220 }
221
222 /**
223 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
224 * Reverts with custom message when dividing by zero.
225 *
226 * Counterpart to Solidity's `%` operator. This function uses a `revert`
227 * opcode (which leaves remaining gas untouched) while Solidity uses an
228 * invalid opcode to revert (consuming all remaining gas).
229 *
230 * Requirements:
231 *
232 * - The divisor cannot be zero.
233 */
234 function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
235 require(b != 0, errorMessage);
236 return a % b;
237 }
238}
239
240abstract contract Context {
241 function _msgSender() internal view virtual returns (address payable) {
242 return msg.sender;
243 }
244
245 function _msgData() internal view virtual returns (bytes memory) {
246 this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
247 return msg.data;
248 }
249}
250
251
252/**
253 * @dev Collection of functions related to the address type
254 */
255library Address {
256 /**
257 * @dev Returns true if `account` is a contract.
258 *
259 * [IMPORTANT]
260 * ====
261 * It is unsafe to assume that an address for which this function returns
262 * false is an externally-owned account (EOA) and not a contract.
263 *
264 * Among others, `isContract` will return false for the following
265 * types of addresses:
266 *
267 * - an externally-owned account
268 * - a contract in construction
269 * - an address where a contract will be created
270 * - an address where a contract lived, but was destroyed
271 * ====
272 */
273 function isContract(address account) internal view returns (bool) {
274 // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
275 // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
276 // for accounts without code, i.e. `keccak256('')`
277 bytes32 codehash;
278 bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
279 // solhint-disable-next-line no-inline-assembly
280 assembly { codehash := extcodehash(account) }
281 return (codehash != accountHash && codehash != 0x0);
282 }
283
284 /**
285 * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
286 * `recipient`, forwarding all available gas and reverting on errors.
287 *
288 * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
289 * of certain opcodes, possibly making contracts go over the 2300 gas limit
290 * imposed by `transfer`, making them unable to receive funds via
291 * `transfer`. {sendValue} removes this limitation.
292 *
293 * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
294 *
295 * IMPORTANT: because control is transferred to `recipient`, care must be
296 * taken to not create reentrancy vulnerabilities. Consider using
297 * {ReentrancyGuard} or the
298 * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
299 */
300 function sendValue(address payable recipient, uint256 amount) internal {
301 require(address(this).balance >= amount, "Address: insufficient balance");
302
303 // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
304 (bool success, ) = recipient.call{ value: amount }("");
305 require(success, "Address: unable to send value, recipient may have reverted");
306 }
307
308 /**
309 * @dev Performs a Solidity function call using a low level `call`. A
310 * plain`call` is an unsafe replacement for a function call: use this
311 * function instead.
312 *
313 * If `target` reverts with a revert reason, it is bubbled up by this
314 * function (like regular Solidity function calls).
315 *
316 * Returns the raw returned data. To convert to the expected return value,
317 * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
318 *
319 * Requirements:
320 *
321 * - `target` must be a contract.
322 * - calling `target` with `data` must not revert.
323 *
324 * _Available since v3.1._
325 */
326 function functionCall(address target, bytes memory data) internal returns (bytes memory) {
327 return functionCall(target, data, "Address: low-level call failed");
328 }
329
330 /**
331 * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
332 * `errorMessage` as a fallback revert reason when `target` reverts.
333 *
334 * _Available since v3.1._
335 */
336 function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
337 return _functionCallWithValue(target, data, 0, errorMessage);
338 }
339
340 /**
341 * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
342 * but also transferring `value` wei to `target`.
343 *
344 * Requirements:
345 *
346 * - the calling contract must have an ETH balance of at least `value`.
347 * - the called Solidity function must be `payable`.
348 *
349 * _Available since v3.1._
350 */
351 function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
352 return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
353 }
354
355 /**
356 * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
357 * with `errorMessage` as a fallback revert reason when `target` reverts.
358 *
359 * _Available since v3.1._
360 */
361 function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
362 require(address(this).balance >= value, "Address: insufficient balance for call");
363 return _functionCallWithValue(target, data, value, errorMessage);
364 }
365
366 function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
367 require(isContract(target), "Address: call to non-contract");
368
369 // solhint-disable-next-line avoid-low-level-calls
370 (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
371 if (success) {
372 return returndata;
373 } else {
374 // Look for revert reason and bubble it up if present
375 if (returndata.length > 0) {
376 // The easiest way to bubble the revert reason is using memory via assembly
377
378 // solhint-disable-next-line no-inline-assembly
379 assembly {
380 let returndata_size := mload(returndata)
381 revert(add(32, returndata), returndata_size)
382 }
383 } else {
384 revert(errorMessage);
385 }
386 }
387 }
388}
389
390/**
391 * @dev Contract module which provides a basic access control mechanism, where
392 * there is an account (an owner) that can be granted exclusive access to
393 * specific functions.
394 *
395 * By default, the owner account will be the one that deploys the contract. This
396 * can later be changed with {transferOwnership}.
397 *
398 * This module is used through inheritance. It will make available the modifier
399 * `onlyOwner`, which can be applied to your functions to restrict their use to
400 * the owner.
401 */
402contract Ownable is Context {
403 address private _owner;
404 address private _previousOwner;
405 uint256 private _lockTime;
406
407 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
408
409 /**
410 * @dev Initializes the contract setting the deployer as the initial owner.
411 */
412 constructor () internal {
413 address msgSender = _msgSender();
414 _owner = msgSender;
415 emit OwnershipTransferred(address(0), msgSender);
416 }
417
418 /**
419 * @dev Returns the address of the current owner.
420 */
421 function owner() public view returns (address) {
422 return _owner;
423 }
424
425 /**
426 * @dev Throws if called by any account other than the owner.
427 */
428 modifier onlyOwner() {
429 require(_owner == _msgSender(), "Ownable: caller is not the owner");
430 _;
431 }
432
433 /**
434 * @dev Leaves the contract without owner. It will not be possible to call
435 * `onlyOwner` functions anymore. Can only be called by the current owner.
436 *
437 * NOTE: Renouncing ownership will leave the contract without an owner,
438 * thereby removing any functionality that is only available to the owner.
439 */
440 function renounceOwnership() public virtual onlyOwner {
441 emit OwnershipTransferred(_owner, address(0));
442 _owner = address(0);
443 }
444
445 /**
446 * @dev Transfers ownership of the contract to a new account (`newOwner`).
447 * Can only be called by the current owner.
448 */
449 function transferOwnership(address newOwner) public virtual onlyOwner {
450 require(newOwner != address(0), "Ownable: new owner is the zero address");
451 emit OwnershipTransferred(_owner, newOwner);
452 _owner = newOwner;
453 }
454
455 function geUnlockTime() public view returns (uint256) {
456 return _lockTime;
457 }
458
459 //Locks the contract for owner for the amount of time provided
460 function lock(uint256 time) public virtual onlyOwner {
461 _previousOwner = _owner;
462 _owner = address(0);
463 _lockTime = now + time;
464 emit OwnershipTransferred(_owner, address(0));
465 }
466
467 //Unlocks the contract for owner when _lockTime is exceeds
468 function unlock() public virtual {
469 require(_previousOwner == msg.sender, "You don't have permission to unlock");
470 require(now > _lockTime , "Contract is locked until 7 days");
471 emit OwnershipTransferred(_owner, _previousOwner);
472 _owner = _previousOwner;
473 }
474}
475
476// pragma solidity >=0.5.0;
477
478interface IUniswapV2Factory {
479 event PairCreated(address indexed token0, address indexed token1, address pair, uint);
480
481 function feeTo() external view returns (address);
482 function feeToSetter() external view returns (address);
483
484 function getPair(address tokenA, address tokenB) external view returns (address pair);
485 function allPairs(uint) external view returns (address pair);
486 function allPairsLength() external view returns (uint);
487
488 function createPair(address tokenA, address tokenB) external returns (address pair);
489
490 function setFeeTo(address) external;
491 function setFeeToSetter(address) external;
492}
493
494
495// pragma solidity >=0.5.0;
496
497interface IUniswapV2Pair {
498 event Approval(address indexed owner, address indexed spender, uint value);
499 event Transfer(address indexed from, address indexed to, uint value);
500
501 function name() external pure returns (string memory);
502 function symbol() external pure returns (string memory);
503 function decimals() external pure returns (uint8);
504 function totalSupply() external view returns (uint);
505 function balanceOf(address owner) external view returns (uint);
506 function allowance(address owner, address spender) external view returns (uint);
507
508 function approve(address spender, uint value) external returns (bool);
509 function transfer(address to, uint value) external returns (bool);
510 function transferFrom(address from, address to, uint value) external returns (bool);
511
512 function DOMAIN_SEPARATOR() external view returns (bytes32);
513 function PERMIT_TYPEHASH() external pure returns (bytes32);
514 function nonces(address owner) external view returns (uint);
515
516 function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
517
518 event Mint(address indexed sender, uint amount0, uint amount1);
519 event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
520 event Swap(
521 address indexed sender,
522 uint amount0In,
523 uint amount1In,
524 uint amount0Out,
525 uint amount1Out,
526 address indexed to
527 );
528 event Sync(uint112 reserve0, uint112 reserve1);
529
530 function MINIMUM_LIQUIDITY() external pure returns (uint);
531 function factory() external view returns (address);
532 function token0() external view returns (address);
533 function token1() external view returns (address);
534 function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
535 function price0CumulativeLast() external view returns (uint);
536 function price1CumulativeLast() external view returns (uint);
537 function kLast() external view returns (uint);
538
539 function mint(address to) external returns (uint liquidity);
540 function burn(address to) external returns (uint amount0, uint amount1);
541 function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
542 function skim(address to) external;
543 function sync() external;
544
545 function initialize(address, address) external;
546}
547
548// pragma solidity >=0.6.2;
549
550interface IUniswapV2Router01 {
551 function factory() external pure returns (address);
552 function WETH() external pure returns (address);
553
554 function addLiquidity(
555 address tokenA,
556 address tokenB,
557 uint amountADesired,
558 uint amountBDesired,
559 uint amountAMin,
560 uint amountBMin,
561 address to,
562 uint deadline
563 ) external returns (uint amountA, uint amountB, uint liquidity);
564 function addLiquidityETH(
565 address token,
566 uint amountTokenDesired,
567 uint amountTokenMin,
568 uint amountETHMin,
569 address to,
570 uint deadline
571 ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
572 function removeLiquidity(
573 address tokenA,
574 address tokenB,
575 uint liquidity,
576 uint amountAMin,
577 uint amountBMin,
578 address to,
579 uint deadline
580 ) external returns (uint amountA, uint amountB);
581 function removeLiquidityETH(
582 address token,
583 uint liquidity,
584 uint amountTokenMin,
585 uint amountETHMin,
586 address to,
587 uint deadline
588 ) external returns (uint amountToken, uint amountETH);
589 function removeLiquidityWithPermit(
590 address tokenA,
591 address tokenB,
592 uint liquidity,
593 uint amountAMin,
594 uint amountBMin,
595 address to,
596 uint deadline,
597 bool approveMax, uint8 v, bytes32 r, bytes32 s
598 ) external returns (uint amountA, uint amountB);
599 function removeLiquidityETHWithPermit(
600 address token,
601 uint liquidity,
602 uint amountTokenMin,
603 uint amountETHMin,
604 address to,
605 uint deadline,
606 bool approveMax, uint8 v, bytes32 r, bytes32 s
607 ) external returns (uint amountToken, uint amountETH);
608 function swapExactTokensForTokens(
609 uint amountIn,
610 uint amountOutMin,
611 address[] calldata path,
612 address to,
613 uint deadline
614 ) external returns (uint[] memory amounts);
615 function swapTokensForExactTokens(
616 uint amountOut,
617 uint amountInMax,
618 address[] calldata path,
619 address to,
620 uint deadline
621 ) external returns (uint[] memory amounts);
622 function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
623 external
624 payable
625 returns (uint[] memory amounts);
626 function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
627 external
628 returns (uint[] memory amounts);
629 function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
630 external
631 returns (uint[] memory amounts);
632 function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
633 external
634 payable
635 returns (uint[] memory amounts);
636
637 function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
638 function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
639 function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
640 function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
641 function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
642}
643
644
645
646// pragma solidity >=0.6.2;
647
648interface IUniswapV2Router02 is IUniswapV2Router01 {
649 function removeLiquidityETHSupportingFeeOnTransferTokens(
650 address token,
651 uint liquidity,
652 uint amountTokenMin,
653 uint amountETHMin,
654 address to,
655 uint deadline
656 ) external returns (uint amountETH);
657 function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
658 address token,
659 uint liquidity,
660 uint amountTokenMin,
661 uint amountETHMin,
662 address to,
663 uint deadline,
664 bool approveMax, uint8 v, bytes32 r, bytes32 s
665 ) external returns (uint amountETH);
666
667 function swapExactTokensForTokensSupportingFeeOnTransferTokens(
668 uint amountIn,
669 uint amountOutMin,
670 address[] calldata path,
671 address to,
672 uint deadline
673 ) external;
674 function swapExactETHForTokensSupportingFeeOnTransferTokens(
675 uint amountOutMin,
676 address[] calldata path,
677 address to,
678 uint deadline
679 ) external payable;
680 function swapExactTokensForETHSupportingFeeOnTransferTokens(
681 uint amountIn,
682 uint amountOutMin,
683 address[] calldata path,
684 address to,
685 uint deadline
686 ) external;
687}
688
689
690contract SafeDrive is Context, IBEP20, Ownable {
691 using SafeMath for uint256;
692 using Address for address;
693
694 mapping (address => uint256) private _rOwned;
695 mapping (address => uint256) private _tOwned;
696 mapping (address => mapping (address => uint256)) private _allowances;
697
698 mapping (address => bool) private _isExcludedFromFee;
699
700 mapping (address => bool) private _isExcluded;
701 address[] private _excluded;
702
703 uint256 private constant MAX = ~uint256(0);
704 uint256 private _tTotal = 210000000000 * 10**9;
705 uint256 private _rTotal = (MAX - (MAX % _tTotal));
706 uint256 private _tFeeTotal;
707
708 string private _name = "SafeDrive";
709 string private _symbol = "Drive";
710 uint8 private _decimals = 9;
711
712 uint256 public _taxFee = 4;
713 uint256 private _previousTaxFee = _taxFee;
714
715 uint256 public _liquidityFee = 4;
716 uint256 private _previousLiquidityFee = _liquidityFee;
717
718 IUniswapV2Router02 public immutable uniswapV2Router;
719 address public immutable uniswapV2Pair;
720
721 bool inSwapAndLiquify;
722 bool public swapAndLiquifyEnabled = true;
723
724 uint256 public _maxTxAmount = 5000000 * 10**6 * 10**9;
725 uint256 private numTokensSellToAddToLiquidity = 5000000 * 10**6 * 10**9;
726
727 event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
728 event SwapAndLiquifyEnabledUpdated(bool enabled);
729 event SwapAndLiquify(
730 uint256 tokensSwapped,
731 uint256 ethReceived,
732 uint256 tokensIntoLiqudity
733 );
734
735 modifier lockTheSwap {
736 inSwapAndLiquify = true;
737 _;
738 inSwapAndLiquify = false;
739 }
740
741 constructor () public {
742 _rOwned[_msgSender()] = _rTotal;
743
744 IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F);
745 // Create a uniswap pair for this new token
746 uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
747 .createPair(address(this), _uniswapV2Router.WETH());
748
749 // set the rest of the contract variables
750 uniswapV2Router = _uniswapV2Router;
751
752 //exclude owner and this contract from fee
753 _isExcludedFromFee[owner()] = true;
754 _isExcludedFromFee[address(this)] = true;
755
756 emit Transfer(address(0), _msgSender(), _tTotal);
757 }
758
759 function name() public view returns (string memory) {
760 return _name;
761 }
762
763 function symbol() public view returns (string memory) {
764 return _symbol;
765 }
766
767 function decimals() public view returns (uint8) {
768 return _decimals;
769 }
770
771 function totalSupply() public view override returns (uint256) {
772 return _tTotal;
773 }
774
775 function balanceOf(address account) public view override returns (uint256) {
776 if (_isExcluded[account]) return _tOwned[account];
777 return tokenFromReflection(_rOwned[account]);
778 }
779
780 function transfer(address recipient, uint256 amount) public override returns (bool) {
781 _transfer(_msgSender(), recipient, amount);
782 return true;
783 }
784
785 function allowance(address owner, address spender) public view override returns (uint256) {
786 return _allowances[owner][spender];
787 }
788
789 function approve(address spender, uint256 amount) public override returns (bool) {
790 _approve(_msgSender(), spender, amount);
791 return true;
792 }
793
794 function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
795 _transfer(sender, recipient, amount);
796 _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance"));
797 return true;
798 }
799
800 function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
801 _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
802 return true;
803 }
804
805 function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
806 _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero"));
807 return true;
808 }
809
810 function isExcludedFromReward(address account) public view returns (bool) {
811 return _isExcluded[account];
812 }
813
814 function totalFees() public view returns (uint256) {
815 return _tFeeTotal;
816 }
817
818 function deliver(uint256 tAmount) public {
819 address sender = _msgSender();
820 require(!_isExcluded[sender], "Excluded addresses cannot call this function");
821 (uint256 rAmount,,,,,) = _getValues(tAmount);
822 _rOwned[sender] = _rOwned[sender].sub(rAmount);
823 _rTotal = _rTotal.sub(rAmount);
824 _tFeeTotal = _tFeeTotal.add(tAmount);
825 }
826
827 function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
828 require(tAmount <= _tTotal, "Amount must be less than supply");
829 if (!deductTransferFee) {
830 (uint256 rAmount,,,,,) = _getValues(tAmount);
831 return rAmount;
832 } else {
833 (,uint256 rTransferAmount,,,,) = _getValues(tAmount);
834 return rTransferAmount;
835 }
836 }
837
838 function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
839 require(rAmount <= _rTotal, "Amount must be less than total reflections");
840 uint256 currentRate = _getRate();
841 return rAmount.div(currentRate);
842 }
843
844 function excludeFromReward(address account) public onlyOwner() {
845 // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
846 require(!_isExcluded[account], "Account is already excluded");
847 if(_rOwned[account] > 0) {
848 _tOwned[account] = tokenFromReflection(_rOwned[account]);
849 }
850 _isExcluded[account] = true;
851 _excluded.push(account);
852 }
853
854 function includeInReward(address account) external onlyOwner() {
855 require(_isExcluded[account], "Account is already excluded");
856 for (uint256 i = 0; i < _excluded.length; i++) {
857 if (_excluded[i] == account) {
858 _excluded[i] = _excluded[_excluded.length - 1];
859 _tOwned[account] = 0;
860 _isExcluded[account] = false;
861 _excluded.pop();
862 break;
863 }
864 }
865 }
866 function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
867 (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
868 _tOwned[sender] = _tOwned[sender].sub(tAmount);
869 _rOwned[sender] = _rOwned[sender].sub(rAmount);
870 _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
871 _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
872 _takeLiquidity(tLiquidity);
873 _reflectFee(rFee, tFee);
874 emit Transfer(sender, recipient, tTransferAmount);
875 }
876
877 function excludeFromFee(address account) public onlyOwner {
878 _isExcludedFromFee[account] = true;
879 }
880
881 function includeInFee(address account) public onlyOwner {
882 _isExcludedFromFee[account] = false;
883 }
884
885 function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
886 _taxFee = taxFee;
887 }
888
889 function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
890 _liquidityFee = liquidityFee;
891 }
892
893 function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
894 _maxTxAmount = _tTotal.mul(maxTxPercent).div(
895 10**2
896 );
897 }
898
899 function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
900 swapAndLiquifyEnabled = _enabled;
901 emit SwapAndLiquifyEnabledUpdated(_enabled);
902 }
903
904 //to recieve ETH from uniswapV2Router when swaping
905 receive() external payable {}
906
907 function _reflectFee(uint256 rFee, uint256 tFee) private {
908 _rTotal = _rTotal.sub(rFee);
909 _tFeeTotal = _tFeeTotal.add(tFee);
910 }
911
912 function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
913 (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
914 (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
915 return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
916 }
917
918 function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
919 uint256 tFee = calculateTaxFee(tAmount);
920 uint256 tLiquidity = calculateLiquidityFee(tAmount);
921 uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
922 return (tTransferAmount, tFee, tLiquidity);
923 }
924
925 function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
926 uint256 rAmount = tAmount.mul(currentRate);
927 uint256 rFee = tFee.mul(currentRate);
928 uint256 rLiquidity = tLiquidity.mul(currentRate);
929 uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
930 return (rAmount, rTransferAmount, rFee);
931 }
932
933 function _getRate() private view returns(uint256) {
934 (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
935 return rSupply.div(tSupply);
936 }
937
938 function _getCurrentSupply() private view returns(uint256, uint256) {
939 uint256 rSupply = _rTotal;
940 uint256 tSupply = _tTotal;
941 for (uint256 i = 0; i < _excluded.length; i++) {
942 if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
943 rSupply = rSupply.sub(_rOwned[_excluded[i]]);
944 tSupply = tSupply.sub(_tOwned[_excluded[i]]);
945 }
946 if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
947 return (rSupply, tSupply);
948 }
949
950 function _takeLiquidity(uint256 tLiquidity) private {
951 uint256 currentRate = _getRate();
952 uint256 rLiquidity = tLiquidity.mul(currentRate);
953 _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
954 if(_isExcluded[address(this)])
955 _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
956 }
957
958 function calculateTaxFee(uint256 _amount) private view returns (uint256) {
959 return _amount.mul(_taxFee).div(
960 10**2
961 );
962 }
963
964 function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
965 return _amount.mul(_liquidityFee).div(
966 10**2
967 );
968 }
969
970 function removeAllFee() private {
971 if(_taxFee == 0 && _liquidityFee == 0) return;
972
973 _previousTaxFee = _taxFee;
974 _previousLiquidityFee = _liquidityFee;
975
976 _taxFee = 0;
977 _liquidityFee = 0;
978 }
979
980 function restoreAllFee() private {
981 _taxFee = _previousTaxFee;
982 _liquidityFee = _previousLiquidityFee;
983 }
984
985 function isExcludedFromFee(address account) public view returns(bool) {
986 return _isExcludedFromFee[account];
987 }
988
989 function _approve(address owner, address spender, uint256 amount) private {
990 require(owner != address(0), "BEP20: approve from the zero address");
991 require(spender != address(0), "BEP20: approve to the zero address");
992
993 _allowances[owner][spender] = amount;
994 emit Approval(owner, spender, amount);
995 }
996
997 function _transfer(
998 address from,
999 address to,
1000 uint256 amount
1001 ) private {
1002 require(from != address(0), "BEP20: transfer from the zero address");
1003 require(to != address(0), "BEP20: transfer to the zero address");
1004 require(amount > 0, "Transfer amount must be greater than zero");
1005 if(from != owner() && to != owner())
1006 require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
1007
1008 // is the token balance of this contract address over the min number of
1009 // tokens that we need to initiate a swap + liquidity lock?
1010 // also, don't get caught in a circular liquidity event.
1011 // also, don't swap & liquify if sender is uniswap pair.
1012 uint256 contractTokenBalance = balanceOf(address(this));
1013
1014 if(contractTokenBalance >= _maxTxAmount)
1015 {
1016 contractTokenBalance = _maxTxAmount;
1017 }
1018
1019 bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
1020 if (
1021 overMinTokenBalance &&
1022 !inSwapAndLiquify &&
1023 from != uniswapV2Pair &&
1024 swapAndLiquifyEnabled
1025 ) {
1026 contractTokenBalance = numTokensSellToAddToLiquidity;
1027 //add liquidity
1028 swapAndLiquify(contractTokenBalance);
1029 }
1030
1031 //indicates if fee should be deducted from transfer
1032 bool takeFee = true;
1033
1034 //if any account belongs to _isExcludedFromFee account then remove the fee
1035 if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
1036 takeFee = false;
1037 }
1038
1039 //transfer amount, it will take tax, burn, liquidity fee
1040 _tokenTransfer(from,to,amount,takeFee);
1041 }
1042
1043 function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
1044 // split the contract balance into halves
1045 uint256 half = contractTokenBalance.div(2);
1046 uint256 otherHalf = contractTokenBalance.sub(half);
1047
1048 // capture the contract's current ETH balance.
1049 // this is so that we can capture exactly the amount of ETH that the
1050 // swap creates, and not make the liquidity event include any ETH that
1051 // has been manually sent to the contract
1052 uint256 initialBalance = address(this).balance;
1053
1054 // swap tokens for ETH
1055 swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
1056
1057 // how much ETH did we just swap into?
1058 uint256 newBalance = address(this).balance.sub(initialBalance);
1059
1060 // add liquidity to uniswap
1061 addLiquidity(otherHalf, newBalance);
1062
1063 emit SwapAndLiquify(half, newBalance, otherHalf);
1064 }
1065
1066 function swapTokensForEth(uint256 tokenAmount) private {
1067 // generate the uniswap pair path of token -> weth
1068 address[] memory path = new address[](2);
1069 path[0] = address(this);
1070 path[1] = uniswapV2Router.WETH();
1071
1072 _approve(address(this), address(uniswapV2Router), tokenAmount);
1073
1074 // make the swap
1075 uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
1076 tokenAmount,
1077 0, // accept any amount of ETH
1078 path,
1079 address(this),
1080 block.timestamp
1081 );
1082 }
1083
1084 function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
1085 // approve token transfer to cover all possible scenarios
1086 _approve(address(this), address(uniswapV2Router), tokenAmount);
1087
1088 // add the liquidity
1089 uniswapV2Router.addLiquidityETH{value: ethAmount}(
1090 address(this),
1091 tokenAmount,
1092 0, // slippage is unavoidable
1093 0, // slippage is unavoidable
1094 owner(),
1095 block.timestamp
1096 );
1097 }
1098
1099 //this method is responsible for taking all fee, if takeFee is true
1100 function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
1101 if(!takeFee)
1102 removeAllFee();
1103
1104 if (_isExcluded[sender] && !_isExcluded[recipient]) {
1105 _transferFromExcluded(sender, recipient, amount);
1106 } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
1107 _transferToExcluded(sender, recipient, amount);
1108 } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
1109 _transferStandard(sender, recipient, amount);
1110 } else if (_isExcluded[sender] && _isExcluded[recipient]) {
1111 _transferBothExcluded(sender, recipient, amount);
1112 } else {
1113 _transferStandard(sender, recipient, amount);
1114 }
1115
1116 if(!takeFee)
1117 restoreAllFee();
1118 }
1119
1120 function _transferStandard(address sender, address recipient, uint256 tAmount) private {
1121 (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
1122 _rOwned[sender] = _rOwned[sender].sub(rAmount);
1123 _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
1124 _takeLiquidity(tLiquidity);
1125 _reflectFee(rFee, tFee);
1126 emit Transfer(sender, recipient, tTransferAmount);
1127 }
1128
1129 function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
1130 (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
1131 _rOwned[sender] = _rOwned[sender].sub(rAmount);
1132 _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
1133 _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
1134 _takeLiquidity(tLiquidity);
1135 _reflectFee(rFee, tFee);
1136 emit Transfer(sender, recipient, tTransferAmount);
1137 }
1138
1139 function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
1140 (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
1141 _tOwned[sender] = _tOwned[sender].sub(tAmount);
1142 _rOwned[sender] = _rOwned[sender].sub(rAmount);
1143 _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
1144 _takeLiquidity(tLiquidity);
1145 _reflectFee(rFee, tFee);
1146 emit Transfer(sender, recipient, tTransferAmount);
1147 }
1148
1149}
1150// End of SafeDrive.sol
1151