├── .babelrc ├── .gitignore ├── migrations ├── 2_deploy.js └── 1_initial_migration._js ├── README.md ├── compiledsize.js ├── contracts ├── Context.sol ├── IUniswapV2Factory.sol ├── IUniswapV2Router02.sol ├── IUniswapV2Pair.sol ├── IERC20.sol ├── Ownable.sol ├── IUniswapV2Router01.sol ├── SafeMath.sol ├── Address.sol └── Tokenify.sol ├── package.json └── truffle-config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | presets: ["@babel/preset-env"] 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .git 2 | .vscode 3 | .idea 4 | 5 | package-lock.json 6 | 7 | .env 8 | node_modules -------------------------------------------------------------------------------- /migrations/2_deploy.js: -------------------------------------------------------------------------------- 1 | let Tokenify = artifacts.require("Tokenify"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Tokenify); 5 | }; -------------------------------------------------------------------------------- /migrations/1_initial_migration._js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tokenify-Contract 2 | 3 | ### TOKENOMICS 4 | Total supply will be 1000T. 5 | - 5% fee will be distributed among all holders. 6 | - 3% goes to Liquidity Pool 7 | - 2% to burn wallet 8 | - Price at launch: 0.000000001 9 | 10 | ### Contract Address 11 | [0x3df029da66528968e09fb270d3663fec6a5e0238](https://bscscan.com/address/0x3df029da66528968e09fb270d3663fec6a5e0238) 12 | -------------------------------------------------------------------------------- /compiledsize.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require("fs"); 3 | 4 | let dir = './build/contracts'; 5 | files = fs.readdirSync(dir); 6 | 7 | for (f of files) { 8 | let contents = fs.readFileSync(path.join(dir, f)); 9 | let jsonContent = JSON.parse(contents); 10 | 11 | let size = jsonContent.deployedBytecode.length / 2 - 1; 12 | let maxSize = 0x6000; 13 | console.log(jsonContent.contractName, size, (100 * size / maxSize).toFixed(2) + "%" ); 14 | } -------------------------------------------------------------------------------- /contracts/Context.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | abstract contract Context { 5 | function _msgSender() internal view virtual returns (address payable) { 6 | return msg.sender; 7 | } 8 | 9 | function _msgData() internal view virtual returns (bytes memory) { 10 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 11 | return msg.data; 12 | } 13 | } -------------------------------------------------------------------------------- /contracts/IUniswapV2Factory.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | interface IUniswapV2Factory { 5 | event PairCreated(address indexed token0, address indexed token1, address pair, uint); 6 | 7 | function feeTo() external view returns (address); 8 | function feeToSetter() external view returns (address); 9 | 10 | function getPair(address tokenA, address tokenB) external view returns (address pair); 11 | function allPairs(uint) external view returns (address pair); 12 | function allPairsLength() external view returns (uint); 13 | 14 | function createPair(address tokenA, address tokenB) external returns (address pair); 15 | 16 | function setFeeTo(address) external; 17 | function setFeeToSetter(address) external; 18 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "erc-1155", 3 | "version": "1.0.0", 4 | "description": "ERC-1155 Reference Implementation", 5 | "main": "truffle-config.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "dependencies": { 10 | "@babel/polyfill": "^7.4.0", 11 | "bignumber.js": "^4.1.0", 12 | "dotenv": "^8.2.0" 13 | }, 14 | "devDependencies": { 15 | "@babel/core": "^7.4.0", 16 | "@babel/preset-env": "^7.4.2", 17 | "@babel/register": "^7.4.0", 18 | "truffle": "^5.1.47", 19 | "truffle-hdwallet-provider": "^1.0.17" 20 | }, 21 | "scripts": { 22 | "test": "npx truffle test" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "git+https://github.com/enjin/erc-1155.git" 27 | }, 28 | "keywords": [ 29 | "enjin", 30 | "coin", 31 | "ethereum" 32 | ], 33 | "author": "Enjin PTE LTD", 34 | "license": "Apache-2.0", 35 | "bugs": { 36 | "url": "https://github.com/enjin/erc-1155/issues" 37 | }, 38 | "homepage": "https://github.com/enjin/erc-1155#readme" 39 | } 40 | -------------------------------------------------------------------------------- /contracts/IUniswapV2Router02.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | import './IUniswapV2Router01.sol'; 4 | 5 | // SPDX-License-Identifier: MIT 6 | interface IUniswapV2Router02 is IUniswapV2Router01 { 7 | function removeLiquidityETHSupportingFeeOnTransferTokens( 8 | address token, 9 | uint liquidity, 10 | uint amountTokenMin, 11 | uint amountETHMin, 12 | address to, 13 | uint deadline 14 | ) external returns (uint amountETH); 15 | function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( 16 | address token, 17 | uint liquidity, 18 | uint amountTokenMin, 19 | uint amountETHMin, 20 | address to, 21 | uint deadline, 22 | bool approveMax, uint8 v, bytes32 r, bytes32 s 23 | ) external returns (uint amountETH); 24 | 25 | function swapExactTokensForTokensSupportingFeeOnTransferTokens( 26 | uint amountIn, 27 | uint amountOutMin, 28 | address[] calldata path, 29 | address to, 30 | uint deadline 31 | ) external; 32 | function swapExactETHForTokensSupportingFeeOnTransferTokens( 33 | uint amountOutMin, 34 | address[] calldata path, 35 | address to, 36 | uint deadline 37 | ) external payable; 38 | function swapExactTokensForETHSupportingFeeOnTransferTokens( 39 | uint amountIn, 40 | uint amountOutMin, 41 | address[] calldata path, 42 | address to, 43 | uint deadline 44 | ) external; 45 | } -------------------------------------------------------------------------------- /contracts/IUniswapV2Pair.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | interface IUniswapV2Pair { 5 | event Approval(address indexed owner, address indexed spender, uint value); 6 | event Transfer(address indexed from, address indexed to, uint value); 7 | 8 | function name() external pure returns (string memory); 9 | function symbol() external pure returns (string memory); 10 | function decimals() external pure returns (uint8); 11 | function totalSupply() external view returns (uint); 12 | function balanceOf(address owner) external view returns (uint); 13 | function allowance(address owner, address spender) external view returns (uint); 14 | 15 | function approve(address spender, uint value) external returns (bool); 16 | function transfer(address to, uint value) external returns (bool); 17 | function transferFrom(address from, address to, uint value) external returns (bool); 18 | 19 | function DOMAIN_SEPARATOR() external view returns (bytes32); 20 | function PERMIT_TYPEHASH() external pure returns (bytes32); 21 | function nonces(address owner) external view returns (uint); 22 | 23 | function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; 24 | 25 | event Mint(address indexed sender, uint amount0, uint amount1); 26 | event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); 27 | event Swap( 28 | address indexed sender, 29 | uint amount0In, 30 | uint amount1In, 31 | uint amount0Out, 32 | uint amount1Out, 33 | address indexed to 34 | ); 35 | event Sync(uint112 reserve0, uint112 reserve1); 36 | 37 | function MINIMUM_LIQUIDITY() external pure returns (uint); 38 | function factory() external view returns (address); 39 | function token0() external view returns (address); 40 | function token1() external view returns (address); 41 | function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); 42 | function price0CumulativeLast() external view returns (uint); 43 | function price1CumulativeLast() external view returns (uint); 44 | function kLast() external view returns (uint); 45 | 46 | function mint(address to) external returns (uint liquidity); 47 | function burn(address to) external returns (uint amount0, uint amount1); 48 | function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; 49 | function skim(address to) external; 50 | function sync() external; 51 | 52 | function initialize(address, address) external; 53 | } -------------------------------------------------------------------------------- /contracts/IERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | 5 | interface IERC20 { 6 | 7 | function totalSupply() external view returns (uint256); 8 | 9 | /** 10 | * @dev Returns the amount of tokens owned by `account`. 11 | */ 12 | function balanceOf(address account) external view returns (uint256); 13 | 14 | /** 15 | * @dev Moves `amount` tokens from the caller's account to `recipient`. 16 | * 17 | * Returns a boolean value indicating whether the operation succeeded. 18 | * 19 | * Emits a {Transfer} event. 20 | */ 21 | function transfer(address recipient, uint256 amount) external returns (bool); 22 | 23 | /** 24 | * @dev Returns the remaining number of tokens that `spender` will be 25 | * allowed to spend on behalf of `owner` through {transferFrom}. This is 26 | * zero by default. 27 | * 28 | * This value changes when {approve} or {transferFrom} are called. 29 | */ 30 | function allowance(address owner, address spender) external view returns (uint256); 31 | 32 | /** 33 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. 34 | * 35 | * Returns a boolean value indicating whether the operation succeeded. 36 | * 37 | * IMPORTANT: Beware that changing an allowance with this method brings the risk 38 | * that someone may use both the old and the new allowance by unfortunate 39 | * transaction ordering. One possible solution to mitigate this race 40 | * condition is to first reduce the spender's allowance to 0 and set the 41 | * desired value afterwards: 42 | * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 43 | * 44 | * Emits an {Approval} event. 45 | */ 46 | function approve(address spender, uint256 amount) external returns (bool); 47 | 48 | /** 49 | * @dev Moves `amount` tokens from `sender` to `recipient` using the 50 | * allowance mechanism. `amount` is then deducted from the caller's 51 | * allowance. 52 | * 53 | * Returns a boolean value indicating whether the operation succeeded. 54 | * 55 | * Emits a {Transfer} event. 56 | */ 57 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 58 | 59 | /** 60 | * @dev Emitted when `value` tokens are moved from one account (`from`) to 61 | * another (`to`). 62 | * 63 | * Note that `value` may be zero. 64 | */ 65 | event Transfer(address indexed from, address indexed to, uint256 value); 66 | 67 | /** 68 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by 69 | * a call to {approve}. `value` is the new allowance. 70 | */ 71 | event Approval(address indexed owner, address indexed spender, uint256 value); 72 | } 73 | -------------------------------------------------------------------------------- /contracts/Ownable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | 5 | import './Context.sol'; 6 | 7 | contract Ownable is Context { 8 | address private _owner; 9 | address private _previousOwner; 10 | uint256 private _lockTime; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev Initializes the contract setting the deployer as the initial owner. 16 | */ 17 | constructor () internal { 18 | address msgSender = _msgSender(); 19 | _owner = msgSender; 20 | emit OwnershipTransferred(address(0), msgSender); 21 | } 22 | 23 | /** 24 | * @dev Returns the address of the current owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 35 | _; 36 | } 37 | 38 | /** 39 | * @dev Leaves the contract without owner. It will not be possible to call 40 | * `onlyOwner` functions anymore. Can only be called by the current owner. 41 | * 42 | * NOTE: Renouncing ownership will leave the contract without an owner, 43 | * thereby removing any functionality that is only available to the owner. 44 | */ 45 | function renounceOwnership() public virtual onlyOwner { 46 | emit OwnershipTransferred(_owner, address(0)); 47 | _owner = address(0); 48 | } 49 | 50 | /** 51 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 52 | * Can only be called by the current owner. 53 | */ 54 | function transferOwnership(address newOwner) public virtual onlyOwner { 55 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 56 | emit OwnershipTransferred(_owner, newOwner); 57 | _owner = newOwner; 58 | } 59 | 60 | function geUnlockTime() public view returns (uint256) { 61 | return _lockTime; 62 | } 63 | 64 | //Locks the contract for owner for the amount of time provided 65 | function lock(uint256 time) public virtual onlyOwner { 66 | _previousOwner = _owner; 67 | _owner = address(0); 68 | _lockTime = now + time; 69 | emit OwnershipTransferred(_owner, address(0)); 70 | } 71 | 72 | //Unlocks the contract for owner when _lockTime is exceeds 73 | function unlock() public virtual { 74 | require(_previousOwner == msg.sender, "You don't have permission to unlock"); 75 | require(now > _lockTime , "Contract is locked until 7 days"); 76 | emit OwnershipTransferred(_owner, _previousOwner); 77 | _owner = _previousOwner; 78 | } 79 | } -------------------------------------------------------------------------------- /truffle-config.js: -------------------------------------------------------------------------------- 1 | require('@babel/register'); 2 | require('@babel/polyfill'); 3 | 4 | /** 5 | * Use this file to configure your truffle project. It's seeded with some 6 | * common settings for different networks and features like migrations, 7 | * compilation and testing. Uncomment the ones you need or modify 8 | * them to suit your project as necessary. 9 | * 10 | * More information about configuration can be found at: 11 | * 12 | * trufflesuite.com/docs/advanced/configuration 13 | * 14 | * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) 15 | * to sign your transactions before they're sent to a remote public node. Infura accounts 16 | * are available for free at: infura.io/register. 17 | * 18 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 19 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 20 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 21 | * 22 | */ 23 | 24 | // const HDWalletProvider = require('@truffle/hdwallet-provider'); 25 | // const infuraKey = "fj4jll3k....."; 26 | // 27 | // const fs = require('fs'); 28 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 29 | require('dotenv').config(); 30 | const HDWalletProvider = require('truffle-hdwallet-provider'); 31 | const privateKey = process.env.privateKey; 32 | const mnemonic = process.env.mnemonic; 33 | const infuraKey = process.env.infuraKey; 34 | module.exports = { 35 | /** 36 | * Networks define how you connect to your ethereum client and let you set the 37 | * defaults web3 uses to send transactions. If you don't specify one truffle 38 | * will spin up a development blockchain for you on port 9545 when you 39 | * run `develop` or `test`. You can ask a truffle command to use a specific 40 | * network from the command line, e.g 41 | * 42 | * $ truffle test --network 43 | */ 44 | 45 | networks: { 46 | 47 | bsc_test: { 48 | provider: function () { 49 | let privateKeys = [privateKey]; 50 | return new HDWalletProvider(privateKeys, "https://data-seed-prebsc-1-s1.binance.org:8545") 51 | }, 52 | network_id: 97, 53 | gas: 30000000, // BSC Testnet gas limit 54 | confirmations: 10, 55 | timeoutBlocks: 200, 56 | skipDryRun: true 57 | }, 58 | // bsc_live: { 59 | // provider: () => new HDWalletProvider(mnemonic, `https://bsc-dataseed1.binance.org`), 60 | // network_id: 56, 61 | // confirmations: 10, 62 | // timeoutBlocks: 200, 63 | // skipDryRun: true 64 | // }, 65 | }, 66 | 67 | // Set default mocha options here, use special reporters etc. 68 | mocha: { 69 | // timeout: 100000 70 | }, 71 | 72 | // Configure your compilers 73 | compilers: { 74 | solc: { 75 | version: "^0.6.12", // Fetch exact version from solc-bin (default: truffle's version) 76 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 77 | // settings: { // See the solidity docs for advice about optimization and evmVersion 78 | optimizer: { 79 | enabled: false, 80 | runs: 200 81 | }, 82 | // evmVersion: "byzantium" 83 | evmVersion: "istanbul" 84 | // } 85 | }, 86 | }, 87 | }; 88 | -------------------------------------------------------------------------------- /contracts/IUniswapV2Router01.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | interface IUniswapV2Router01 { 5 | function factory() external pure returns (address); 6 | function WETH() external pure returns (address); 7 | 8 | function addLiquidity( 9 | address tokenA, 10 | address tokenB, 11 | uint amountADesired, 12 | uint amountBDesired, 13 | uint amountAMin, 14 | uint amountBMin, 15 | address to, 16 | uint deadline 17 | ) external returns (uint amountA, uint amountB, uint liquidity); 18 | function addLiquidityETH( 19 | address token, 20 | uint amountTokenDesired, 21 | uint amountTokenMin, 22 | uint amountETHMin, 23 | address to, 24 | uint deadline 25 | ) external payable returns (uint amountToken, uint amountETH, uint liquidity); 26 | function removeLiquidity( 27 | address tokenA, 28 | address tokenB, 29 | uint liquidity, 30 | uint amountAMin, 31 | uint amountBMin, 32 | address to, 33 | uint deadline 34 | ) external returns (uint amountA, uint amountB); 35 | function removeLiquidityETH( 36 | address token, 37 | uint liquidity, 38 | uint amountTokenMin, 39 | uint amountETHMin, 40 | address to, 41 | uint deadline 42 | ) external returns (uint amountToken, uint amountETH); 43 | function removeLiquidityWithPermit( 44 | address tokenA, 45 | address tokenB, 46 | uint liquidity, 47 | uint amountAMin, 48 | uint amountBMin, 49 | address to, 50 | uint deadline, 51 | bool approveMax, uint8 v, bytes32 r, bytes32 s 52 | ) external returns (uint amountA, uint amountB); 53 | function removeLiquidityETHWithPermit( 54 | address token, 55 | uint liquidity, 56 | uint amountTokenMin, 57 | uint amountETHMin, 58 | address to, 59 | uint deadline, 60 | bool approveMax, uint8 v, bytes32 r, bytes32 s 61 | ) external returns (uint amountToken, uint amountETH); 62 | function swapExactTokensForTokens( 63 | uint amountIn, 64 | uint amountOutMin, 65 | address[] calldata path, 66 | address to, 67 | uint deadline 68 | ) external returns (uint[] memory amounts); 69 | function swapTokensForExactTokens( 70 | uint amountOut, 71 | uint amountInMax, 72 | address[] calldata path, 73 | address to, 74 | uint deadline 75 | ) external returns (uint[] memory amounts); 76 | function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) 77 | external 78 | payable 79 | returns (uint[] memory amounts); 80 | function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) 81 | external 82 | returns (uint[] memory amounts); 83 | function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) 84 | external 85 | returns (uint[] memory amounts); 86 | function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) 87 | external 88 | payable 89 | returns (uint[] memory amounts); 90 | 91 | function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); 92 | function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); 93 | function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); 94 | function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); 95 | function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); 96 | } -------------------------------------------------------------------------------- /contracts/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | 5 | library SafeMath { 6 | /** 7 | * @dev Returns the addition of two unsigned integers, reverting on 8 | * overflow. 9 | * 10 | * Counterpart to Solidity's `+` operator. 11 | * 12 | * Requirements: 13 | * 14 | * - Addition cannot overflow. 15 | */ 16 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 17 | uint256 c = a + b; 18 | require(c >= a, "SafeMath: addition overflow"); 19 | 20 | return c; 21 | } 22 | 23 | /** 24 | * @dev Returns the subtraction of two unsigned integers, reverting on 25 | * overflow (when the result is negative). 26 | * 27 | * Counterpart to Solidity's `-` operator. 28 | * 29 | * Requirements: 30 | * 31 | * - Subtraction cannot overflow. 32 | */ 33 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 34 | return sub(a, b, "SafeMath: subtraction overflow"); 35 | } 36 | 37 | /** 38 | * @dev Returns the subtraction of two unsigned integers, reverting with custom message on 39 | * overflow (when the result is negative). 40 | * 41 | * Counterpart to Solidity's `-` operator. 42 | * 43 | * Requirements: 44 | * 45 | * - Subtraction cannot overflow. 46 | */ 47 | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 48 | require(b <= a, errorMessage); 49 | uint256 c = a - b; 50 | 51 | return c; 52 | } 53 | 54 | /** 55 | * @dev Returns the multiplication of two unsigned integers, reverting on 56 | * overflow. 57 | * 58 | * Counterpart to Solidity's `*` operator. 59 | * 60 | * Requirements: 61 | * 62 | * - Multiplication cannot overflow. 63 | */ 64 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 65 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 66 | // benefit is lost if 'b' is also tested. 67 | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 68 | if (a == 0) { 69 | return 0; 70 | } 71 | 72 | uint256 c = a * b; 73 | require(c / a == b, "SafeMath: multiplication overflow"); 74 | 75 | return c; 76 | } 77 | 78 | /** 79 | * @dev Returns the integer division of two unsigned integers. Reverts on 80 | * division by zero. The result is rounded towards zero. 81 | * 82 | * Counterpart to Solidity's `/` operator. Note: this function uses a 83 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 84 | * uses an invalid opcode to revert (consuming all remaining gas). 85 | * 86 | * Requirements: 87 | * 88 | * - The divisor cannot be zero. 89 | */ 90 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 91 | return div(a, b, "SafeMath: division by zero"); 92 | } 93 | 94 | /** 95 | * @dev Returns the integer division of two unsigned integers. Reverts with custom message on 96 | * division by zero. The result is rounded towards zero. 97 | * 98 | * Counterpart to Solidity's `/` operator. Note: this function uses a 99 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 100 | * uses an invalid opcode to revert (consuming all remaining gas). 101 | * 102 | * Requirements: 103 | * 104 | * - The divisor cannot be zero. 105 | */ 106 | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 107 | require(b > 0, errorMessage); 108 | uint256 c = a / b; 109 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 110 | 111 | return c; 112 | } 113 | 114 | /** 115 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 116 | * Reverts when dividing by zero. 117 | * 118 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 119 | * opcode (which leaves remaining gas untouched) while Solidity uses an 120 | * invalid opcode to revert (consuming all remaining gas). 121 | * 122 | * Requirements: 123 | * 124 | * - The divisor cannot be zero. 125 | */ 126 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 127 | return mod(a, b, "SafeMath: modulo by zero"); 128 | } 129 | 130 | /** 131 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 132 | * Reverts with custom message when dividing by zero. 133 | * 134 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 135 | * opcode (which leaves remaining gas untouched) while Solidity uses an 136 | * invalid opcode to revert (consuming all remaining gas). 137 | * 138 | * Requirements: 139 | * 140 | * - The divisor cannot be zero. 141 | */ 142 | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 143 | require(b != 0, errorMessage); 144 | return a % b; 145 | } 146 | } -------------------------------------------------------------------------------- /contracts/Address.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | /** 5 | * @dev Collection of functions related to the address type 6 | */ 7 | library Address { 8 | /** 9 | * @dev Returns true if `account` is a contract. 10 | * 11 | * [IMPORTANT] 12 | * ==== 13 | * It is unsafe to assume that an address for which this function returns 14 | * false is an externally-owned account (EOA) and not a contract. 15 | * 16 | * Among others, `isContract` will return false for the following 17 | * types of addresses: 18 | * 19 | * - an externally-owned account 20 | * - a contract in construction 21 | * - an address where a contract will be created 22 | * - an address where a contract lived, but was destroyed 23 | * ==== 24 | */ 25 | function isContract(address account) internal view returns (bool) { 26 | // According to EIP-1052, 0x0 is the value returned for not-yet created accounts 27 | // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned 28 | // for accounts without code, i.e. `keccak256('')` 29 | bytes32 codehash; 30 | bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; 31 | // solhint-disable-next-line no-inline-assembly 32 | assembly { codehash := extcodehash(account) } 33 | return (codehash != accountHash && codehash != 0x0); 34 | } 35 | 36 | /** 37 | * @dev Replacement for Solidity's `transfer`: sends `amount` wei to 38 | * `recipient`, forwarding all available gas and reverting on errors. 39 | * 40 | * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost 41 | * of certain opcodes, possibly making contracts go over the 2300 gas limit 42 | * imposed by `transfer`, making them unable to receive funds via 43 | * `transfer`. {sendValue} removes this limitation. 44 | * 45 | * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. 46 | * 47 | * IMPORTANT: because control is transferred to `recipient`, care must be 48 | * taken to not create reentrancy vulnerabilities. Consider using 49 | * {ReentrancyGuard} or the 50 | * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. 51 | */ 52 | function sendValue(address payable recipient, uint256 amount) internal { 53 | require(address(this).balance >= amount, "Address: insufficient balance"); 54 | 55 | // solhint-disable-next-line avoid-low-level-calls, avoid-call-value 56 | (bool success, ) = recipient.call{ value: amount }(""); 57 | require(success, "Address: unable to send value, recipient may have reverted"); 58 | } 59 | 60 | /** 61 | * @dev Performs a Solidity function call using a low level `call`. A 62 | * plain`call` is an unsafe replacement for a function call: use this 63 | * function instead. 64 | * 65 | * If `target` reverts with a revert reason, it is bubbled up by this 66 | * function (like regular Solidity function calls). 67 | * 68 | * Returns the raw returned data. To convert to the expected return value, 69 | * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. 70 | * 71 | * Requirements: 72 | * 73 | * - `target` must be a contract. 74 | * - calling `target` with `data` must not revert. 75 | * 76 | * _Available since v3.1._ 77 | */ 78 | function functionCall(address target, bytes memory data) internal returns (bytes memory) { 79 | return functionCall(target, data, "Address: low-level call failed"); 80 | } 81 | 82 | /** 83 | * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with 84 | * `errorMessage` as a fallback revert reason when `target` reverts. 85 | * 86 | * _Available since v3.1._ 87 | */ 88 | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { 89 | return _functionCallWithValue(target, data, 0, errorMessage); 90 | } 91 | 92 | /** 93 | * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], 94 | * but also transferring `value` wei to `target`. 95 | * 96 | * Requirements: 97 | * 98 | * - the calling contract must have an ETH balance of at least `value`. 99 | * - the called Solidity function must be `payable`. 100 | * 101 | * _Available since v3.1._ 102 | */ 103 | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { 104 | return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); 105 | } 106 | 107 | /** 108 | * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but 109 | * with `errorMessage` as a fallback revert reason when `target` reverts. 110 | * 111 | * _Available since v3.1._ 112 | */ 113 | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { 114 | require(address(this).balance >= value, "Address: insufficient balance for call"); 115 | return _functionCallWithValue(target, data, value, errorMessage); 116 | } 117 | 118 | function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { 119 | require(isContract(target), "Address: call to non-contract"); 120 | 121 | // solhint-disable-next-line avoid-low-level-calls 122 | (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 123 | if (success) { 124 | return returndata; 125 | } else { 126 | // Look for revert reason and bubble it up if present 127 | if (returndata.length > 0) { 128 | // The easiest way to bubble the revert reason is using memory via assembly 129 | 130 | // solhint-disable-next-line no-inline-assembly 131 | assembly { 132 | let returndata_size := mload(returndata) 133 | revert(add(32, returndata), returndata_size) 134 | } 135 | } else { 136 | revert(errorMessage); 137 | } 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /contracts/Tokenify.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.12; 2 | 3 | // SPDX-License-Identifier: MIT 4 | /** 5 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 6 | * checks. 7 | * 8 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 9 | * in bugs, because programmers usually assume that an overflow raises an 10 | * error, which is the standard behavior in high level programming languages. 11 | * `SafeMath` restores this intuition by reverting the transaction when an 12 | * operation overflows. 13 | * 14 | * Using this library instead of the unchecked operations eliminates an entire 15 | * class of bugs, so it's recommended to use it always. 16 | */ 17 | import "./Context.sol"; 18 | import "./IERC20.sol"; 19 | import "./Ownable.sol"; 20 | import "./SafeMath.sol"; 21 | import "./Address.sol"; 22 | import "./IUniswapV2Router02.sol"; 23 | import "./IUniswapV2Factory.sol"; 24 | 25 | contract Tokenify is Context, IERC20, Ownable { 26 | using SafeMath for uint256; 27 | using Address for address; 28 | 29 | mapping(address => uint256) private _rOwned; 30 | mapping(address => uint256) private _tOwned; 31 | mapping(address => mapping(address => uint256)) private _allowances; 32 | 33 | mapping(address => bool) private _isExcludedFromFee; 34 | 35 | mapping(address => bool) private _isExcluded; 36 | address[] private _excluded; 37 | 38 | uint256 private constant MAX = ~uint256(0); 39 | uint256 private _tTotal = 1000000000000000 * 10**8; 40 | uint256 private _rTotal = (MAX - (MAX % _tTotal)); 41 | uint256 private _tFeeTotal; 42 | 43 | string private _name = "Tokenify"; 44 | string private _symbol = "TKN"; 45 | uint8 private _decimals = 8; 46 | 47 | uint256 public _taxFee = 0; 48 | uint256 private _previousTaxFee = _taxFee; 49 | 50 | uint256 public _liquidityFee = 0; 51 | uint256 private _previousLiquidityFee = _liquidityFee; 52 | 53 | uint256 public _burnFee = 0; 54 | uint256 private _previousBurnFee = _burnFee; 55 | 56 | uint256 public _DeadFee = 0; 57 | address public DeadWallet = 0x0000000000000000000000000000000000000000; 58 | uint256 private _previousDeadFee = _DeadFee; 59 | 60 | IUniswapV2Router02 public immutable uniswapV2Router; 61 | address public immutable uniswapV2Pair; 62 | 63 | bool inSwapAndLiquify; 64 | bool public swapAndLiquifyEnabled = false; 65 | 66 | uint256 public _maxTxAmount = 1000000000000000 * 10**8; 67 | uint256 private numTokensSellToAddToLiquidity = 50000000 * 10**8; 68 | 69 | event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); 70 | event SwapAndLiquifyEnabledUpdated(bool enabled); 71 | event SwapAndLiquify( 72 | uint256 tokensSwapped, 73 | uint256 ethReceived, 74 | uint256 tokensIntoLiqudity 75 | ); 76 | 77 | modifier lockTheSwap { 78 | inSwapAndLiquify = true; 79 | _; 80 | inSwapAndLiquify = false; 81 | } 82 | 83 | constructor() public { 84 | _rOwned[_msgSender()] = _rTotal; 85 | 86 | IUniswapV2Router02 _uniswapV2Router = 87 | IUniswapV2Router02(0xD99D1c33F9fC3444f8101754aBC46c52416550D1); // PCS V2 testnet 88 | // IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); // PCS V2 89 | // Create a uniswap pair for this new token 90 | uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) 91 | .createPair(address(this), _uniswapV2Router.WETH()); 92 | 93 | // set the rest of the contract variables 94 | uniswapV2Router = _uniswapV2Router; 95 | 96 | //exclude owner and this contract from fee 97 | _isExcludedFromFee[owner()] = true; 98 | _isExcludedFromFee[address(this)] = true; 99 | 100 | emit Transfer(address(0), _msgSender(), _tTotal); 101 | } 102 | 103 | function name() public view returns (string memory) { 104 | return _name; 105 | } 106 | 107 | function symbol() public view returns (string memory) { 108 | return _symbol; 109 | } 110 | 111 | function decimals() public view returns (uint8) { 112 | return _decimals; 113 | } 114 | 115 | function totalSupply() public view override returns (uint256) { 116 | return _tTotal; 117 | } 118 | 119 | function balanceOf(address account) public view override returns (uint256) { 120 | if (_isExcluded[account]) return _tOwned[account]; 121 | return tokenFromReflection(_rOwned[account]); 122 | } 123 | 124 | function transfer(address recipient, uint256 amount) 125 | public 126 | override 127 | returns (bool) 128 | { 129 | _transfer(_msgSender(), recipient, amount); 130 | return true; 131 | } 132 | 133 | function allowance(address owner, address spender) 134 | public 135 | view 136 | override 137 | returns (uint256) 138 | { 139 | return _allowances[owner][spender]; 140 | } 141 | 142 | function approve(address spender, uint256 amount) 143 | public 144 | override 145 | returns (bool) 146 | { 147 | _approve(_msgSender(), spender, amount); 148 | return true; 149 | } 150 | 151 | function transferFrom( 152 | address sender, 153 | address recipient, 154 | uint256 amount 155 | ) public override returns (bool) { 156 | _transfer(sender, recipient, amount); 157 | _approve( 158 | sender, 159 | _msgSender(), 160 | _allowances[sender][_msgSender()].sub( 161 | amount, 162 | "ERC20: transfer amount exceeds allowance" 163 | ) 164 | ); 165 | return true; 166 | } 167 | 168 | function increaseAllowance(address spender, uint256 addedValue) 169 | public 170 | virtual 171 | returns (bool) 172 | { 173 | _approve( 174 | _msgSender(), 175 | spender, 176 | _allowances[_msgSender()][spender].add(addedValue) 177 | ); 178 | return true; 179 | } 180 | 181 | function decreaseAllowance(address spender, uint256 subtractedValue) 182 | public 183 | virtual 184 | returns (bool) 185 | { 186 | _approve( 187 | _msgSender(), 188 | spender, 189 | _allowances[_msgSender()][spender].sub( 190 | subtractedValue, 191 | "ERC20: decreased allowance below zero" 192 | ) 193 | ); 194 | return true; 195 | } 196 | 197 | function isExcludedFromReward(address account) public view returns (bool) { 198 | return _isExcluded[account]; 199 | } 200 | 201 | function totalFees() public view returns (uint256) { 202 | return _tFeeTotal; 203 | } 204 | 205 | function deliver(uint256 tAmount) public { 206 | address sender = _msgSender(); 207 | require( 208 | !_isExcluded[sender], 209 | "Excluded addresses cannot call this function" 210 | ); 211 | (uint256 rAmount, , , , , ) = _getValues(tAmount); 212 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 213 | _rTotal = _rTotal.sub(rAmount); 214 | _tFeeTotal = _tFeeTotal.add(tAmount); 215 | } 216 | 217 | function reflectionFromToken(uint256 tAmount, bool deductTransferFee) 218 | public 219 | view 220 | returns (uint256) 221 | { 222 | require(tAmount <= _tTotal, "Amount must be less than supply"); 223 | if (!deductTransferFee) { 224 | (uint256 rAmount, , , , , ) = _getValues(tAmount); 225 | return rAmount; 226 | } else { 227 | (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); 228 | return rTransferAmount; 229 | } 230 | } 231 | 232 | function tokenFromReflection(uint256 rAmount) 233 | public 234 | view 235 | returns (uint256) 236 | { 237 | require( 238 | rAmount <= _rTotal, 239 | "Amount must be less than total reflections" 240 | ); 241 | uint256 currentRate = _getRate(); 242 | return rAmount.div(currentRate); 243 | } 244 | 245 | function excludeFromReward(address account) public onlyOwner() { 246 | require( 247 | account != 0x10ED43C718714eb63d5aA57B78B54704E256024E, 248 | "We can not exclude Pancake router." 249 | ); 250 | require(!_isExcluded[account], "Account is already excluded"); 251 | if (_rOwned[account] > 0) { 252 | _tOwned[account] = tokenFromReflection(_rOwned[account]); 253 | } 254 | _isExcluded[account] = true; 255 | _excluded.push(account); 256 | } 257 | 258 | function includeInReward(address account) external onlyOwner() { 259 | require(_isExcluded[account], "Account is already excluded"); 260 | for (uint256 i = 0; i < _excluded.length; i++) { 261 | if (_excluded[i] == account) { 262 | _excluded[i] = _excluded[_excluded.length - 1]; 263 | _tOwned[account] = 0; 264 | _isExcluded[account] = false; 265 | _excluded.pop(); 266 | break; 267 | } 268 | } 269 | } 270 | 271 | function _transferBothExcluded( 272 | address sender, 273 | address recipient, 274 | uint256 tAmount 275 | ) private { 276 | ( 277 | uint256 rAmount, 278 | uint256 rTransferAmount, 279 | uint256 rFee, 280 | uint256 tTransferAmount, 281 | uint256 tFee, 282 | uint256 tLiquidity 283 | ) = _getValues(tAmount); 284 | _tOwned[sender] = _tOwned[sender].sub(tAmount); 285 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 286 | _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); 287 | _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); 288 | _takeLiquidity(tLiquidity); 289 | _reflectFee(rFee, tFee); 290 | emit Transfer(sender, recipient, tTransferAmount); 291 | } 292 | 293 | //to recieve ETH from uniswapV2Router when swaping 294 | receive() external payable {} 295 | 296 | function _reflectFee(uint256 rFee, uint256 tFee) private { 297 | _rTotal = _rTotal.sub(rFee); 298 | _tFeeTotal = _tFeeTotal.add(tFee); 299 | } 300 | 301 | function _getValues(uint256 tAmount) 302 | private 303 | view 304 | returns ( 305 | uint256, 306 | uint256, 307 | uint256, 308 | uint256, 309 | uint256, 310 | uint256 311 | ) 312 | { 313 | (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = 314 | _getTValues(tAmount); 315 | (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = 316 | _getRValues(tAmount, tFee, tLiquidity, _getRate()); 317 | return ( 318 | rAmount, 319 | rTransferAmount, 320 | rFee, 321 | tTransferAmount, 322 | tFee, 323 | tLiquidity 324 | ); 325 | } 326 | 327 | function _getTValues(uint256 tAmount) 328 | private 329 | view 330 | returns ( 331 | uint256, 332 | uint256, 333 | uint256 334 | ) 335 | { 336 | uint256 tFee = calculateTaxFee(tAmount); 337 | uint256 tLiquidity = calculateLiquidityFee(tAmount); 338 | uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); 339 | return (tTransferAmount, tFee, tLiquidity); 340 | } 341 | 342 | function _getRValues( 343 | uint256 tAmount, 344 | uint256 tFee, 345 | uint256 tLiquidity, 346 | uint256 currentRate 347 | ) 348 | private 349 | pure 350 | returns ( 351 | uint256, 352 | uint256, 353 | uint256 354 | ) 355 | { 356 | uint256 rAmount = tAmount.mul(currentRate); 357 | uint256 rFee = tFee.mul(currentRate); 358 | uint256 rLiquidity = tLiquidity.mul(currentRate); 359 | uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); 360 | return (rAmount, rTransferAmount, rFee); 361 | } 362 | 363 | function _getRate() private view returns (uint256) { 364 | (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); 365 | return rSupply.div(tSupply); 366 | } 367 | 368 | function _getCurrentSupply() private view returns (uint256, uint256) { 369 | uint256 rSupply = _rTotal; 370 | uint256 tSupply = _tTotal; 371 | for (uint256 i = 0; i < _excluded.length; i++) { 372 | if ( 373 | _rOwned[_excluded[i]] > rSupply || 374 | _tOwned[_excluded[i]] > tSupply 375 | ) return (_rTotal, _tTotal); 376 | rSupply = rSupply.sub(_rOwned[_excluded[i]]); 377 | tSupply = tSupply.sub(_tOwned[_excluded[i]]); 378 | } 379 | if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); 380 | return (rSupply, tSupply); 381 | } 382 | 383 | function _takeLiquidity(uint256 tLiquidity) private { 384 | uint256 currentRate = _getRate(); 385 | uint256 rLiquidity = tLiquidity.mul(currentRate); 386 | _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); 387 | if (_isExcluded[address(this)]) 388 | _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); 389 | } 390 | 391 | function calculateTaxFee(uint256 _amount) private view returns (uint256) { 392 | return _amount.mul(_taxFee).div(10**2); 393 | } 394 | 395 | function calculateLiquidityFee(uint256 _amount) 396 | private 397 | view 398 | returns (uint256) 399 | { 400 | return _amount.mul(_liquidityFee).div(10**2); 401 | } 402 | 403 | function removeAllFee() private { 404 | _taxFee = 0; 405 | _liquidityFee = 0; 406 | _burnFee = 0; 407 | _DeadFee = 0; 408 | } 409 | 410 | function restoreAllFee() private { 411 | _taxFee = 5; 412 | _liquidityFee = 3; 413 | _DeadFee = 0; 414 | _burnFee = 2; 415 | } 416 | 417 | function isExcludedFromFee(address account) public view returns (bool) { 418 | return _isExcludedFromFee[account]; 419 | } 420 | 421 | function _approve( 422 | address owner, 423 | address spender, 424 | uint256 amount 425 | ) private { 426 | require(owner != address(0), "ERC20: approve from the zero address"); 427 | require(spender != address(0), "ERC20: approve to the zero address"); 428 | 429 | _allowances[owner][spender] = amount; 430 | emit Approval(owner, spender, amount); 431 | } 432 | 433 | function _transfer( 434 | address from, 435 | address to, 436 | uint256 amount 437 | ) private { 438 | require(from != address(0), "ERC20: transfer from the zero address"); 439 | require(to != address(0), "ERC20: transfer to the zero address"); 440 | require(amount > 0, "Transfer amount must be greater than zero"); 441 | 442 | // is the token balance of this contract address over the min number of 443 | // tokens that we need to initiate a swap + liquidity lock? 444 | // also, don't get caught in a circular liquidity event. 445 | // also, don't swap & liquify if sender is uniswap pair. 446 | uint256 contractTokenBalance = balanceOf(address(this)); 447 | bool overMinTokenBalance = 448 | contractTokenBalance >= numTokensSellToAddToLiquidity; 449 | if ( 450 | overMinTokenBalance && 451 | !inSwapAndLiquify && 452 | from != uniswapV2Pair && 453 | swapAndLiquifyEnabled 454 | ) { 455 | contractTokenBalance = numTokensSellToAddToLiquidity; 456 | //add liquidity 457 | swapAndLiquify(contractTokenBalance); 458 | } 459 | 460 | //transfer amount, it will take tax, burn, liquidity fee 461 | _tokenTransfer(from, to, amount); 462 | } 463 | 464 | function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { 465 | // split the contract balance into halves 466 | uint256 half = contractTokenBalance.div(2); 467 | uint256 otherHalf = contractTokenBalance.sub(half); 468 | 469 | // capture the contract's current ETH balance. 470 | // this is so that we can capture exactly the amount of ETH that the 471 | // swap creates, and not make the liquidity event include any ETH that 472 | // has been manually sent to the contract 473 | uint256 initialBalance = address(this).balance; 474 | 475 | // swap tokens for ETH 476 | swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered 477 | 478 | // how much ETH did we just swap into? 479 | uint256 newBalance = address(this).balance.sub(initialBalance); 480 | 481 | // add liquidity to uniswap 482 | addLiquidity(otherHalf, newBalance); 483 | 484 | emit SwapAndLiquify(half, newBalance, otherHalf); 485 | } 486 | 487 | function swapTokensForEth(uint256 tokenAmount) private { 488 | // generate the uniswap pair path of token -> weth 489 | address[] memory path = new address[](2); 490 | path[0] = address(this); 491 | path[1] = uniswapV2Router.WETH(); 492 | 493 | _approve(address(this), address(uniswapV2Router), tokenAmount); 494 | 495 | // make the swap 496 | uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( 497 | tokenAmount, 498 | 0, // accept any amount of ETH 499 | path, 500 | address(this), 501 | block.timestamp 502 | ); 503 | } 504 | 505 | function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { 506 | // approve token transfer to cover all possible scenarios 507 | _approve(address(this), address(uniswapV2Router), tokenAmount); 508 | 509 | // add the liquidity 510 | uniswapV2Router.addLiquidityETH{value: ethAmount}( 511 | address(this), 512 | tokenAmount, 513 | 0, // slippage is unavoidable 514 | 0, // slippage is unavoidable 515 | owner(), 516 | block.timestamp 517 | ); 518 | } 519 | 520 | //this method is responsible for taking all fee, if takeFee is true 521 | function _tokenTransfer( 522 | address sender, 523 | address recipient, 524 | uint256 amount 525 | ) private { 526 | if (_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) { 527 | removeAllFee(); 528 | } else { 529 | require( 530 | amount <= _maxTxAmount, 531 | "Transfer amount exceeds the maxTxAmount." 532 | ); 533 | } 534 | 535 | //Calculate burn amount and Dead amount 536 | uint256 burnAmt = amount.mul(_burnFee).div(100); 537 | uint256 DeadAmt = amount.mul(_DeadFee).div(100); 538 | 539 | if (_isExcluded[sender] && !_isExcluded[recipient]) { 540 | _transferFromExcluded( 541 | sender, 542 | recipient, 543 | (amount.sub(burnAmt).sub(DeadAmt)) 544 | ); 545 | } else if (!_isExcluded[sender] && _isExcluded[recipient]) { 546 | _transferToExcluded( 547 | sender, 548 | recipient, 549 | (amount.sub(burnAmt).sub(DeadAmt)) 550 | ); 551 | } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { 552 | _transferStandard( 553 | sender, 554 | recipient, 555 | (amount.sub(burnAmt).sub(DeadAmt)) 556 | ); 557 | } else if (_isExcluded[sender] && _isExcluded[recipient]) { 558 | _transferBothExcluded( 559 | sender, 560 | recipient, 561 | (amount.sub(burnAmt).sub(DeadAmt)) 562 | ); 563 | } else { 564 | _transferStandard( 565 | sender, 566 | recipient, 567 | (amount.sub(burnAmt).sub(DeadAmt)) 568 | ); 569 | } 570 | 571 | //Temporarily remove fees to transfer to burn address and Dead wallet 572 | _taxFee = 0; 573 | _liquidityFee = 0; 574 | 575 | //Send transfers to burn and Dead wallet 576 | _transferStandard(sender, address(0), burnAmt); 577 | _transferStandard(sender, DeadWallet, DeadAmt); 578 | 579 | //Restore tax and liquidity fees 580 | _taxFee = _previousTaxFee; 581 | _liquidityFee = _previousLiquidityFee; 582 | 583 | if (_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) 584 | restoreAllFee(); 585 | } 586 | 587 | function _transferStandard( 588 | address sender, 589 | address recipient, 590 | uint256 tAmount 591 | ) private { 592 | ( 593 | uint256 rAmount, 594 | uint256 rTransferAmount, 595 | uint256 rFee, 596 | uint256 tTransferAmount, 597 | uint256 tFee, 598 | uint256 tLiquidity 599 | ) = _getValues(tAmount); 600 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 601 | _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); 602 | _takeLiquidity(tLiquidity); 603 | _reflectFee(rFee, tFee); 604 | emit Transfer(sender, recipient, tTransferAmount); 605 | } 606 | 607 | function _transferToExcluded( 608 | address sender, 609 | address recipient, 610 | uint256 tAmount 611 | ) private { 612 | ( 613 | uint256 rAmount, 614 | uint256 rTransferAmount, 615 | uint256 rFee, 616 | uint256 tTransferAmount, 617 | uint256 tFee, 618 | uint256 tLiquidity 619 | ) = _getValues(tAmount); 620 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 621 | _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); 622 | _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); 623 | _takeLiquidity(tLiquidity); 624 | _reflectFee(rFee, tFee); 625 | emit Transfer(sender, recipient, tTransferAmount); 626 | } 627 | 628 | function _transferFromExcluded( 629 | address sender, 630 | address recipient, 631 | uint256 tAmount 632 | ) private { 633 | ( 634 | uint256 rAmount, 635 | uint256 rTransferAmount, 636 | uint256 rFee, 637 | uint256 tTransferAmount, 638 | uint256 tFee, 639 | uint256 tLiquidity 640 | ) = _getValues(tAmount); 641 | _tOwned[sender] = _tOwned[sender].sub(tAmount); 642 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 643 | _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); 644 | _takeLiquidity(tLiquidity); 645 | _reflectFee(rFee, tFee); 646 | emit Transfer(sender, recipient, tTransferAmount); 647 | } 648 | 649 | function excludeFromFee(address account) public onlyOwner { 650 | _isExcludedFromFee[account] = true; 651 | } 652 | 653 | function includeInFee(address account) public onlyOwner { 654 | _isExcludedFromFee[account] = false; 655 | } 656 | 657 | //Call this function after finalizing the presale 658 | function enableAllFees() external onlyOwner() { 659 | _taxFee = 5; 660 | _previousTaxFee = _taxFee; 661 | _liquidityFee = 3; 662 | _previousLiquidityFee = _liquidityFee; 663 | _DeadFee = 0; 664 | _previousDeadFee = _DeadFee; 665 | _burnFee = 2; 666 | _previousBurnFee = _taxFee; 667 | inSwapAndLiquify = true; 668 | emit SwapAndLiquifyEnabledUpdated(true); 669 | } 670 | 671 | function disableAllFees() external onlyOwner() { 672 | _taxFee = 0; 673 | _previousTaxFee = _taxFee; 674 | _liquidityFee = 0; 675 | _previousLiquidityFee = _liquidityFee; 676 | _burnFee = 0; 677 | _previousBurnFee = _taxFee; 678 | _DeadFee = 0; 679 | _previousDeadFee = _DeadFee; 680 | inSwapAndLiquify = false; 681 | emit SwapAndLiquifyEnabledUpdated(false); 682 | } 683 | 684 | function setDeadWallet(address newWallet) external onlyOwner() { 685 | DeadWallet = newWallet; 686 | } 687 | 688 | function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { 689 | require( 690 | maxTxPercent > 10, 691 | "Cannot set transaction amount less than 10 percent!" 692 | ); 693 | _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); 694 | } 695 | 696 | function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { 697 | swapAndLiquifyEnabled = _enabled; 698 | emit SwapAndLiquifyEnabledUpdated(_enabled); 699 | } 700 | } 701 | --------------------------------------------------------------------------------