The Smart Contract of LaunchVerse

Launch Verse
16 min readMar 18, 2022

--

The smart contract of LaunchVerse-XLV is created in the safest way for the investors. There is no way for the owner to rug or use the funds or tokens 100% safe

There is 11% tax in every transaction. And this can’t be increased by the owner. Max amount of tax can be 11% but by time the owner can reduce the tax.
There is no minting function in the contract so completely safe for the price.

Contract deployer’s rights are minimized to avoid any manipulation.
The contract has been written and audited in cooperation with Rugfreecoins.

Link to contract address:

LaunchVerse (XLV) Token Tracker | BscScan

// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.4;

abstract contract Context {

function _msgSender() internal view virtual returns (address) {

return msg.sender;

}

function _msgData() internal view virtual returns (bytes memory) {

this; // silence state mutability warning without generating bytecode — see https://github.com/ethereum/solidity/issues/2691

return msg.data;

}

}

interface IBEP20 {

function totalSupply() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);

function transfer(address recipient, uint256 amount)

external

returns (bool);

function allowance(address owner, address spender)

external

view

returns (uint256);

function approve(address spender, uint256 amount) external returns (bool);

function transferFrom(

address sender,

address recipient,

uint256 amount

) external returns (bool);

event Transfer(address indexed from, address indexed to, uint256 value);

event Approval(

address indexed owner,

address indexed spender,

uint256 value

);

}

library SafeMath {

/**

* @dev Returns the addition of two unsigned integers, with an overflow flag.

*

* _Available since v3.4._

*/

function tryAdd(uint256 a, uint256 b)

internal

pure

returns (bool, uint256)

{

unchecked {

uint256 c = a + b;

if (c < a) return (false, 0);

return (true, c);

}

}

/**

* @dev Returns the substraction of two unsigned integers, with an overflow flag.

*

* _Available since v3.4._

*/

function trySub(uint256 a, uint256 b)

internal

pure

returns (bool, uint256)

{

unchecked {

if (b > a) return (false, 0);

return (true, a — b);

}

}

/**

* @dev Returns the multiplication of two unsigned integers, with an overflow flag.

*

* _Available since v3.4._

*/

function tryMul(uint256 a, uint256 b)

internal

pure

returns (bool, uint256)

{

unchecked {

// Gas optimization: this is cheaper than requiring ‘a’ not being zero, but the

// benefit is lost if ‘b’ is also tested.

// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522

if (a == 0) return (true, 0);

uint256 c = a * b;

if (c / a != b) return (false, 0);

return (true, c);

}

}

/**

* @dev Returns the division of two unsigned integers, with a division by zero flag.

*

* _Available since v3.4._

*/

function tryDiv(uint256 a, uint256 b)

internal

pure

returns (bool, uint256)

{

unchecked {

if (b == 0) return (false, 0);

return (true, a / b);

}

}

/**

* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.

*

* _Available since v3.4._

*/

function tryMod(uint256 a, uint256 b)

internal

pure

returns (bool, uint256)

{

unchecked {

if (b == 0) return (false, 0);

return (true, a % b);

}

}

/**

* @dev Returns the addition of two unsigned integers, reverting on

* overflow.

*

* Counterpart to Solidity’s `+` operator.

*

* Requirements:

*

* — Addition cannot overflow.

*/

function add(uint256 a, uint256 b) internal pure returns (uint256) {

return a + b;

}

/**

* @dev Returns the subtraction of two unsigned integers, reverting on

* overflow (when the result is negative).

*

* Counterpart to Solidity’s `-` operator.

*

* Requirements:

*

* — Subtraction cannot overflow.

*/

function sub(uint256 a, uint256 b) internal pure returns (uint256) {

return a — b;

}

/**

* @dev Returns the multiplication of two unsigned integers, reverting on

* overflow.

*

* Counterpart to Solidity’s `*` operator.

*

* Requirements:

*

* — Multiplication cannot overflow.

*/

function mul(uint256 a, uint256 b) internal pure returns (uint256) {

return a * b;

}

/**

* @dev Returns the integer division of two unsigned integers, reverting on

* division by zero. The result is rounded towards zero.

*

* Counterpart to Solidity’s `/` operator.

*

* Requirements:

*

* — The divisor cannot be zero.

*/

function div(uint256 a, uint256 b) internal pure returns (uint256) {

return a / b;

}

/**

* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),

* reverting when dividing by zero.

*

* Counterpart to Solidity’s `%` operator. This function uses a `revert`

* opcode (which leaves remaining gas untouched) while Solidity uses an

* invalid opcode to revert (consuming all remaining gas).

*

* Requirements:

*

* — The divisor cannot be zero.

*/

function mod(uint256 a, uint256 b) internal pure returns (uint256) {

return a % b;

}

/**

* @dev Returns the subtraction of two unsigned integers, reverting with custom message on

* overflow (when the result is negative).

*

* CAUTION: This function is deprecated because it requires allocating memory for the error

* message unnecessarily. For custom revert reasons use {trySub}.

*

* Counterpart to Solidity’s `-` operator.

*

* Requirements:

*

* — Subtraction cannot overflow.

*/

function sub(

uint256 a,

uint256 b,

string memory errorMessage

) internal pure returns (uint256) {

unchecked {

require(b <= a, errorMessage);

return a — b;

}

}

/**

* @dev Returns the integer division of two unsigned integers, reverting with custom message on

* division by zero. The result is rounded towards zero.

*

* Counterpart to Solidity’s `%` operator. This function uses a `revert`

* opcode (which leaves remaining gas untouched) while Solidity uses an

* invalid opcode to revert (consuming all remaining gas).

*

* Counterpart to Solidity’s `/` operator. Note: this function uses a

* `revert` opcode (which leaves remaining gas untouched) while Solidity

* uses an invalid opcode to revert (consuming all remaining gas).

*

* Requirements:

*

* — The divisor cannot be zero.

*/

function div(

uint256 a,

uint256 b,

string memory errorMessage

) internal pure returns (uint256) {

unchecked {

require(b > 0, errorMessage);

return a / b;

}

}

/**

* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),

* reverting with custom message when dividing by zero.

*

* CAUTION: This function is deprecated because it requires allocating memory for the error

* message unnecessarily. For custom revert reasons use {tryMod}.

*

* Counterpart to Solidity’s `%` operator. This function uses a `revert`

* opcode (which leaves remaining gas untouched) while Solidity uses an

* invalid opcode to revert (consuming all remaining gas).

*

* Requirements:

*

* — The divisor cannot be zero.

*/

function mod(

uint256 a,

uint256 b,

string memory errorMessage

) internal pure returns (uint256) {

unchecked {

require(b > 0, errorMessage);

return a % b;

}

}

}

library SafeMathInt {

int256 private constant MIN_INT256 = int256(1) << 255;

int256 private constant MAX_INT256 = ~(int256(1) << 255);

/**

* @dev Multiplies two int256 variables and fails on overflow.

*/

function mul(int256 a, int256 b) internal pure returns (int256) {

int256 c = a * b;

// Detect overflow when multiplying MIN_INT256 with -1

require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));

require((b == 0) || (c / b == a));

return c;

}

/**

* @dev Division of two int256 variables and fails on overflow.

*/

function div(int256 a, int256 b) internal pure returns (int256) {

// Prevent overflow when dividing MIN_INT256 by -1

require(b != -1 || a != MIN_INT256);

// Solidity already throws when dividing by 0.

return a / b;

}

/**

* @dev Subtracts two int256 variables and fails on overflow.

*/

function sub(int256 a, int256 b) internal pure returns (int256) {

int256 c = a — b;

require((b >= 0 && c <= a) || (b < 0 && c > a));

return c;

}

/**

* @dev Adds two int256 variables and fails on overflow.

*/

function add(int256 a, int256 b) internal pure returns (int256) {

int256 c = a + b;

require((b >= 0 && c >= a) || (b < 0 && c < a));

return c;

}

/**

* @dev Converts to absolute value, and fails on overflow.

*/

function abs(int256 a) internal pure returns (int256) {

require(a != MIN_INT256);

return a < 0 ? -a : a;

}

function toUint256Safe(int256 a) internal pure returns (uint256) {

require(a >= 0);

return uint256(a);

}

}

library SafeMathUint {

function toInt256Safe(uint256 a) internal pure returns (int256) {

int256 b = int256(a);

require(b >= 0);

return b;

}

}

contract Ownable is Context {

address private _owner;

address private _previousOwner;

event OwnershipTransferred(

address indexed previousOwner,

address indexed newOwner

);

constructor(address initialOwner) {

_owner = initialOwner;

emit OwnershipTransferred(address(0), initialOwner);

}

function owner() public view returns (address) {

return _owner;

}

modifier onlyOwner() {

require(_owner == _msgSender(), “Ownable: caller is not the owner”);

_;

}

function renounceOwnership() public virtual onlyOwner {

emit OwnershipTransferred(_owner, address(0));

_owner = address(0);

}

function transferOwnership(address newOwner) public virtual onlyOwner {

require(

newOwner != address(0),

“Ownable: new owner is the zero address”

);

emit OwnershipTransferred(_owner, newOwner);

_owner = newOwner;

}

}

interface IUniswapV2Factory {

event PairCreated(

address indexed token0,

address indexed token1,

address pair,

uint256

);

function feeTo() external view returns (address);

function feeToSetter() external view returns (address);

function getPair(address tokenA, address tokenB)

external

view

returns (address pair);

function allPairs(uint256) external view returns (address pair);

function allPairsLength() external view returns (uint256);

function createPair(address tokenA, address tokenB)

external

returns (address pair);

function setFeeTo(address) external;

function setFeeToSetter(address) external;

}

interface IUniswapV2Pair {

event Approval(

address indexed owner,

address indexed spender,

uint256 value

);

event Transfer(address indexed from, address indexed to, uint256 value);

function name() external pure returns (string memory);

function symbol() external pure returns (string memory);

function decimals() external pure returns (uint8);

function totalSupply() external view returns (uint256);

function balanceOf(address owner) external view returns (uint256);

function allowance(address owner, address spender)

external

view

returns (uint256);

function approve(address spender, uint256 value) external returns (bool);

function transfer(address to, uint256 value) external returns (bool);

function transferFrom(

address from,

address to,

uint256 value

) external returns (bool);

function DOMAIN_SEPARATOR() external view returns (bytes32);

function PERMIT_TYPEHASH() external pure returns (bytes32);

function nonces(address owner) external view returns (uint256);

function permit(

address owner,

address spender,

uint256 value,

uint256 deadline,

uint8 v,

bytes32 r,

bytes32 s

) external;

event Mint(address indexed sender, uint256 amount0, uint256 amount1);

event Burn(

address indexed sender,

uint256 amount0,

uint256 amount1,

address indexed to

);

event Swap(

address indexed sender,

uint256 amount0In,

uint256 amount1In,

uint256 amount0Out,

uint256 amount1Out,

address indexed to

);

event Sync(uint112 reserve0, uint112 reserve1);

function MINIMUM_LIQUIDITY() external pure returns (uint256);

function factory() external view returns (address);

function token0() external view returns (address);

function token1() external view returns (address);

function getReserves()

external

view

returns (

uint112 reserve0,

uint112 reserve1,

uint32 blockTimestampLast

);

function price0CumulativeLast() external view returns (uint256);

function price1CumulativeLast() external view returns (uint256);

function kLast() external view returns (uint256);

function mint(address to) external returns (uint256 liquidity);

function burn(address to)

external

returns (uint256 amount0, uint256 amount1);

function swap(

uint256 amount0Out,

uint256 amount1Out,

address to,

bytes calldata data

) external;

function skim(address to) external;

function sync() external;

function initialize(address, address) external;

}

interface IUniswapV2Router01 {

function factory() external pure returns (address);

function WETH() external pure returns (address);

function addLiquidity(

address tokenA,

address tokenB,

uint256 amountADesired,

uint256 amountBDesired,

uint256 amountAMin,

uint256 amountBMin,

address to,

uint256 deadline

)

external

returns (

uint256 amountA,

uint256 amountB,

uint256 liquidity

);

function addLiquidityETH(

address token,

uint256 amountTokenDesired,

uint256 amountTokenMin,

uint256 amountETHMin,

address to,

uint256 deadline

)

external

payable

returns (

uint256 amountToken,

uint256 amountETH,

uint256 liquidity

);

function removeLiquidity(

address tokenA,

address tokenB,

uint256 liquidity,

uint256 amountAMin,

uint256 amountBMin,

address to,

uint256 deadline

) external returns (uint256 amountA, uint256 amountB);

function removeLiquidityETH(

address token,

uint256 liquidity,

uint256 amountTokenMin,

uint256 amountETHMin,

address to,

uint256 deadline

) external returns (uint256 amountToken, uint256 amountETH);

function removeLiquidityWithPermit(

address tokenA,

address tokenB,

uint256 liquidity,

uint256 amountAMin,

uint256 amountBMin,

address to,

uint256 deadline,

bool approveMax,

uint8 v,

bytes32 r,

bytes32 s

) external returns (uint256 amountA, uint256 amountB);

function removeLiquidityETHWithPermit(

address token,

uint256 liquidity,

uint256 amountTokenMin,

uint256 amountETHMin,

address to,

uint256 deadline,

bool approveMax,

uint8 v,

bytes32 r,

bytes32 s

) external returns (uint256 amountToken, uint256 amountETH);

function swapExactTokensForTokens(

uint256 amountIn,

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);

function swapTokensForExactTokens(

uint256 amountOut,

uint256 amountInMax,

address[] calldata path,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);

function swapExactETHForTokens(

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external payable returns (uint256[] memory amounts);

function swapTokensForExactETH(

uint256 amountOut,

uint256 amountInMax,

address[] calldata path,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);

function swapExactTokensForETH(

uint256 amountIn,

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);

function swapETHForExactTokens(

uint256 amountOut,

address[] calldata path,

address to,

uint256 deadline

) external payable returns (uint256[] memory amounts);

function quote(

uint256 amountA,

uint256 reserveA,

uint256 reserveB

) external pure returns (uint256 amountB);

function getAmountOut(

uint256 amountIn,

uint256 reserveIn,

uint256 reserveOut

) external pure returns (uint256 amountOut);

function getAmountIn(

uint256 amountOut,

uint256 reserveIn,

uint256 reserveOut

) external pure returns (uint256 amountIn);

function getAmountsOut(uint256 amountIn, address[] calldata path)

external

view

returns (uint256[] memory amounts);

function getAmountsIn(uint256 amountOut, address[] calldata path)

external

view

returns (uint256[] memory amounts);

}

interface IUniswapV2Router02 is IUniswapV2Router01 {

function removeLiquidityETHSupportingFeeOnTransferTokens(

address token,

uint256 liquidity,

uint256 amountTokenMin,

uint256 amountETHMin,

address to,

uint256 deadline

) external returns (uint256 amountETH);

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(

address token,

uint256 liquidity,

uint256 amountTokenMin,

uint256 amountETHMin,

address to,

uint256 deadline,

bool approveMax,

uint8 v,

bytes32 r,

bytes32 s

) external returns (uint256 amountETH);

function swapExactTokensForTokensSupportingFeeOnTransferTokens(

uint256 amountIn,

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external;

function swapExactETHForTokensSupportingFeeOnTransferTokens(

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external payable;

function swapExactTokensForETHSupportingFeeOnTransferTokens(

uint256 amountIn,

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external;

}

contract XLV is Context, IBEP20, Ownable {

using SafeMath for uint256;

mapping(address => uint256) private _rOwned;

mapping(address => uint256) private _tOwned;

mapping(address => bool) private _isExcludedFromFee;

mapping(address => bool) private _isExcluded;

mapping(address => mapping(address => uint256)) private _allowances;

mapping(address => bool) public _isExcludedFromAutoLiquidity;

address[] private _excluded;

address public marketinganddevelopment =

0x8Ec0955BdBe4A1d9FA9Cb92f05487ce404B33eA0;

address public _investmentWallet =

0xc7a1875adf86720ACb946808F543209E59FFe6CB;

address private burnAddress = 0x000000000000000000000000000000000000dEaD;

uint256 private constant MAX = ~uint256(0);

uint256 private _tTotal = 1000 * 10**6 * 10**9;

uint256 private _rTotal = (MAX — (MAX % _tTotal));

uint256 private _tFeeTotal;

string private _name = “LaunchVerse”;

string private _symbol = “XLV”;

uint8 private _decimals = 9;

uint256 public _taxFee = 1000;

uint256 public _liquidityFee = 1000;

uint256 public _marketingAndDevelopmentFee = 4000;

uint256 public _investmentFee = 4000;

uint256 public _burnFee = 1000;

uint256 private _totalFeesToContract = 9000;

uint256 public _maxWalletToken = _tTotal.mul(2).div(100);

uint256 public _swapTokensAt = 100 * 10**5 * 10**9;

bool public tradeEnable = false;

// auto liquidity

bool public _swapAndLiquifyEnabled = true;

bool _inSwapAndLiquify;

IUniswapV2Router02 public _uniswapV2Router;

address public _uniswapV2Pair;

event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);

event SwapAndLiquifyEnabledUpdated(bool enabled);

event SwapAndLiquify(

uint256 tokensSwapped,

uint256 bnbReceived,

uint256 tokensIntoLiqudity

);

modifier lockTheSwap() {

_inSwapAndLiquify = true;

_;

_inSwapAndLiquify = false;

}

constructor(address cOwner) Ownable(cOwner) {

_rOwned[cOwner] = _rTotal;

// uniswap

IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(

0x10ED43C718714eb63d5aA57B78B54704E256024E

);

_uniswapV2Router = uniswapV2Router;

_uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())

.createPair(address(this), uniswapV2Router.WETH());

// exclude system contracts

_isExcludedFromFee[owner()] = true;

_isExcludedFromFee[address(this)] = true;

_isExcludedFromFee[marketinganddevelopment] = true;

_isExcludedFromAutoLiquidity[_uniswapV2Pair] = true;

_isExcludedFromAutoLiquidity[address(_uniswapV2Router)] = true;

_isExcluded[_uniswapV2Pair] = true;

_excluded.push(_uniswapV2Pair);

_isExcluded[burnAddress] = true;

_excluded.push(burnAddress);

_isExcluded[address(this)] = true;

_excluded.push(address(this));

emit Transfer(address(0), cOwner, _tTotal);

}

function name() public view returns (string memory) {

return _name;

}

function symbol() public view returns (string memory) {

return _symbol;

}

function decimals() public view returns (uint8) {

return _decimals;

}

function totalSupply() public view override returns (uint256) {

return _tTotal;

}

function balanceOf(address account) public view override returns (uint256) {

if (_isExcluded[account]) return _tOwned[account];

return tokenFromReflection(_rOwned[account]);

}

function transfer(address recipient, uint256 amount)

public

override

returns (bool)

{

_transfer(_msgSender(), recipient, amount);

return true;

}

function allowance(address owner, address spender)

public

view

override

returns (uint256)

{

return _allowances[owner][spender];

}

function approve(address spender, uint256 amount)

public

override

returns (bool)

{

_approve(_msgSender(), spender, amount);

return true;

}

function transferFrom(

address sender,

address recipient,

uint256 amount

) public override returns (bool) {

_transfer(sender, recipient, amount);

_approve(

sender,

_msgSender(),

_allowances[sender][_msgSender()].sub(

amount,

“BEP20: transfer amount exceeds allowance”

)

);

return true;

}

function increaseAllowance(address spender, uint256 addedValue)

public

virtual

returns (bool)

{

_approve(

_msgSender(),

spender,

_allowances[_msgSender()][spender].add(addedValue)

);

return true;

}

function decreaseAllowance(address spender, uint256 subtractedValue)

public

virtual

returns (bool)

{

_approve(

_msgSender(),

spender,

_allowances[_msgSender()][spender].sub(

subtractedValue,

“BEP20: decreased allowance below zero”

)

);

return true;

}

function isExcludedFromReward(address account) public view returns (bool) {

return _isExcluded[account];

}

function totalFees() public view returns (uint256) {

return _tFeeTotal;

}

function deliver(uint256 tAmount) public {

address sender = _msgSender();

require(

!_isExcluded[sender],

“Excluded addresses cannot call this function”

);

(, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);

uint256 currentRate = _getRate();

(uint256 rAmount, , ) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

_rOwned[sender] = _rOwned[sender].sub(rAmount);

_rTotal = _rTotal.sub(rAmount);

_tFeeTotal = _tFeeTotal.add(tAmount);

}

function reflectionFromToken(uint256 tAmount, bool deductTransferFee)

public

view

returns (uint256)

{

require(tAmount <= _tTotal, “Amount must be less than supply”);

(, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);

uint256 currentRate = _getRate();

if (!deductTransferFee) {

(uint256 rAmount, , ) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

return rAmount;

} else {

(, uint256 rTransferAmount, ) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

return rTransferAmount;

}

}

function tokenFromReflection(uint256 rAmount)

public

view

returns (uint256)

{

require(

rAmount <= _rTotal,

“Amount must be less than total reflections”

);

uint256 currentRate = _getRate();

return rAmount.div(currentRate);

}

function excludeFromReward(address account) public onlyOwner {

require(!_isExcluded[account], “Account is already excluded”);

if (_rOwned[account] > 0) {

_tOwned[account] = tokenFromReflection(_rOwned[account]);

}

_isExcluded[account] = true;

_excluded.push(account);

}

function includeInReward(address account) external onlyOwner {

require(_isExcluded[account], “Account is already excluded”);

for (uint256 i = 0; i < _excluded.length; i++) {

if (_excluded[i] == account) {

_excluded[i] = _excluded[_excluded.length — 1];

_tOwned[account] = 0;

_isExcluded[account] = false;

_excluded.pop();

break;

}

}

}

function setMarketingWallet(address marketingWallet) external onlyOwner {

marketinganddevelopment = marketingWallet;

}

function setInvestmentWallet(address newWallet) external onlyOwner {

_investmentWallet = newWallet;

}

function changeMaxWalletToken(uint256 _amount) external onlyOwner {

_maxWalletToken = _amount;

}

function changeSwapAmount(uint256 amount) external onlyOwner {

_swapTokensAt = amount;

}

function setExcludedFromFee(address account, bool e) external onlyOwner {

_isExcludedFromFee[account] = e;

}

function tradingEnable() external onlyOwner {

tradeEnable = true;

}

// update fees

function updateFees(

uint256 rewardFee,

uint256 liquidityFee,

uint256 marketingFee,

uint256 prizeFee,

uint256 burnFee

) external onlyOwner {

// calculate total fee to contract

_totalFeesToContract = liquidityFee.add(marketingFee).add(prizeFee).add(

burnFee

);

// calculate total fees

uint256 totalTxFee = _totalFeesToContract.add(rewardFee);

require(totalTxFee <= 11000, “Total Fees can not greater than 11%”);

_taxFee = rewardFee;

_liquidityFee = liquidityFee;

_marketingAndDevelopmentFee = marketingFee;

_investmentFee = prizeFee;

_burnFee = burnFee;

}

function setSwapAndLiquifyEnabled(bool e) public onlyOwner {

_swapAndLiquifyEnabled = e;

emit SwapAndLiquifyEnabledUpdated(e);

}

receive() external payable {}

function setUniswapRouter(address r) external onlyOwner {

IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(r);

_uniswapV2Router = uniswapV2Router;

}

function setUniswapPair(address p) external onlyOwner {

_uniswapV2Pair = p;

}

function setExcludedFromAutoLiquidity(address a, bool b)

external

onlyOwner

{

_isExcludedFromAutoLiquidity[a] = b;

}

function _reflectFee(uint256 rFee, uint256 tFee) private {

_rTotal = _rTotal.sub(rFee);

_tFeeTotal = _tFeeTotal.add(tFee);

}

function _getTValues(uint256 tAmount)

private

view

returns (

uint256,

uint256,

uint256

)

{

uint256 tFee = calculateFee(tAmount, _taxFee);

uint256 tLiquidity = calculateFee(tAmount, _totalFeesToContract);

uint256 tTransferAmount = tAmount.sub(tFee);

tTransferAmount = tTransferAmount.sub(tLiquidity);

return (tTransferAmount, tFee, tLiquidity);

}

function _getRValues(

uint256 tAmount,

uint256 tFee,

uint256 tLiquidity,

uint256 currentRate

)

private

pure

returns (

uint256,

uint256,

uint256

)

{

uint256 rAmount = tAmount.mul(currentRate);

uint256 rFee = tFee.mul(currentRate);

uint256 rLiquidity = tLiquidity.mul(currentRate);

uint256 rTransferAmount = rAmount.sub(rFee);

rTransferAmount = rTransferAmount.sub(rLiquidity);

return (rAmount, rTransferAmount, rFee);

}

function _getRate() private view returns (uint256) {

(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();

return rSupply.div(tSupply);

}

function _getCurrentSupply() private view returns (uint256, uint256) {

uint256 rSupply = _rTotal;

uint256 tSupply = _tTotal;

for (uint256 i = 0; i < _excluded.length; i++) {

if (

_rOwned[_excluded[i]] > rSupply ||

_tOwned[_excluded[i]] > tSupply

) return (_rTotal, _tTotal);

rSupply = rSupply.sub(_rOwned[_excluded[i]]);

tSupply = tSupply.sub(_tOwned[_excluded[i]]);

}

if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);

return (rSupply, tSupply);

}

function takeTokenFees(uint256 tokenAmount, uint256 currentRate) private {

if (tokenAmount <= 0) {

return;

}

uint256 tokensToBurn = tokenAmount.mul(_burnFee).div(

_totalFeesToContract

);

uint256 tokensToSendContract = tokenAmount.sub(tokensToBurn);

// send tokens to burn

takeTransactionFee(burnAddress, tokensToBurn, currentRate);

// send tokens to contract

takeTransactionFee(address(this), tokensToSendContract, currentRate);

}

function takeTransactionFee(

address to,

uint256 tAmount,

uint256 currentRate

) private {

if (tAmount <= 0) {

return;

}

uint256 rAmount = tAmount.mul(currentRate);

_rOwned[to] = _rOwned[to].add(rAmount);

if (_isExcluded[to]) {

_tOwned[to] = _tOwned[to].add(tAmount);

}

}

function calculateFee(uint256 amount, uint256 fee)

private

pure

returns (uint256)

{

return amount.mul(fee).div(100000);

}

function isExcludedFromFee(address account) public view returns (bool) {

return _isExcludedFromFee[account];

}

function _approve(

address owner,

address spender,

uint256 amount

) private {

require(owner != address(0), “BEP20: approve from the zero address”);

require(spender != address(0), “BEP20: approve to the zero address”);

_allowances[owner][spender] = amount;

emit Approval(owner, spender, amount);

}

function _transfer(

address from,

address to,

uint256 amount

) private {

require(from != address(0), “BEP20: transfer from the zero address”);

require(to != address(0), “BEP20: transfer to the zero address”);

require(amount > 0, “Transfer amount must be greater than zero”);

if (from != owner() && to != owner() && !_isExcludedFromFee[from]) {

require(tradeEnable, “Trading not enabled yet.”);

uint256 reciverTokenBalance = balanceOf(to);

if (to != _uniswapV2Pair) {

require(

reciverTokenBalance + amount <= _maxWalletToken,

“Max Wallet Token Exceeded.”

);

}

}

/*

- swapAndLiquify will be initiated when token balance of this contract

has accumulated enough over the minimum number of tokens required.

- don’t get caught in a circular liquidity event.

- don’t swapAndLiquify if sender is uniswap pair.

*/

uint256 contractTokenBalance = balanceOf(address(this));

bool isOverMinTokenBalance = contractTokenBalance >= _swapTokensAt;

if (

isOverMinTokenBalance &&

!_inSwapAndLiquify &&

!_isExcludedFromAutoLiquidity[from] &&

_swapAndLiquifyEnabled

) {

// contractTokenBalance = _swapTokensAt;

swapAndSendBnb(contractTokenBalance);

}

bool takeFee = true;

if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {

takeFee = false;

}

_tokenTransfer(from, to, amount, takeFee);

}

function swapAndSendBnb(uint256 contractTokenBalance) private lockTheSwap {

uint256 totalSwapFee = _totalFeesToContract.sub(_burnFee);

uint256 tokensToAddLiquidity = contractTokenBalance

.mul(_liquidityFee)

.div(totalSwapFee);

uint256 tokensToSwap = contractTokenBalance.sub(tokensToAddLiquidity);

// swap tokens in to bnb

swapTokensForBnb(tokensToSwap);

uint256 swappedBnb = address(this).balance;

uint256 bnbForCoverGasFees = swappedBnb.mul(10).div(100);

uint256 bnbForDistribute = swappedBnb.sub(bnbForCoverGasFees);

// calculate total bnb ratio

uint256 totalBnbRatio = _marketingAndDevelopmentFee.add(_investmentFee);

uint256 bnbToMarketing = bnbForDistribute

.mul(_marketingAndDevelopmentFee)

.div(totalBnbRatio);

uint256 bnbToPrize = bnbForDistribute.mul(_investmentFee).div(

totalBnbRatio

);

payable(_investmentWallet).transfer(bnbToPrize);

// send bnb to marketing wallet

payable(marketinganddevelopment).transfer(bnbToMarketing);

// add liquidity

swapAndLiquify(tokensToAddLiquidity);

}

function swapAndLiquify(uint256 contractTokenBalance) private {

// split contract balance into halves

uint256 half = contractTokenBalance.div(2);

uint256 otherHalf = contractTokenBalance.sub(half);

/*

capture the contract’s current BNB balance.

this is so that we can capture exactly the amount of BNB that

the swap creates, and not make the liquidity event include any BNB

that has been manually sent to the contract.

*/

uint256 initialBalance = address(this).balance;

// swap tokens for BNB

swapTokensForBnb(half);

// this is the amount of BNB that we just swapped into

uint256 newBalance = address(this).balance.sub(initialBalance);

// add liquidity to uniswap

addLiquidity(otherHalf, newBalance);

emit SwapAndLiquify(half, newBalance, otherHalf);

}

function swapTokensForBnb(uint256 tokenAmount) private {

// generate the uniswap pair path of token -> weth

address[] memory path = new address[](2);

path[0] = address(this);

path[1] = _uniswapV2Router.WETH();

_approve(address(this), address(_uniswapV2Router), tokenAmount);

// make the swap

_uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(

tokenAmount,

0, // accept any amount of BNB

path,

address(this),

block.timestamp

);

}

function addLiquidity(uint256 tokenAmount, uint256 bnbAmount) private {

// approve token transfer to cover all possible scenarios

_approve(address(this), address(_uniswapV2Router), tokenAmount);

// add the liquidity

_uniswapV2Router.addLiquidityETH{value: bnbAmount}(

address(this),

tokenAmount,

0, // slippage is unavoidable

0, // slippage is unavoidable

address(this),

block.timestamp

);

}

function _tokenTransfer(

address sender,

address recipient,

uint256 amount,

bool takeFee

) private {

uint256 previousTaxFee = _taxFee;

uint256 previousContractFee = _totalFeesToContract;

if (!takeFee) {

_taxFee = 0;

_totalFeesToContract = 0;

}

if (_isExcluded[sender] && !_isExcluded[recipient]) {

_transferFromExcluded(sender, recipient, amount);

} else if (!_isExcluded[sender] && _isExcluded[recipient]) {

_transferToExcluded(sender, recipient, amount);

} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {

_transferStandard(sender, recipient, amount);

} else if (_isExcluded[sender] && _isExcluded[recipient]) {

_transferBothExcluded(sender, recipient, amount);

} else {

_transferStandard(sender, recipient, amount);

}

if (!takeFee) {

_taxFee = previousTaxFee;

_totalFeesToContract = previousContractFee;

}

}

function _transferStandard(

address sender,

address recipient,

uint256 tAmount

) private {

(

uint256 tTransferAmount,

uint256 tFee,

uint256 tLiquidity

) = _getTValues(tAmount);

uint256 currentRate = _getRate();

(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

_reflectFee(rFee, tFee);

_rOwned[sender] = _rOwned[sender].sub(rAmount);

_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);

takeTokenFees(tLiquidity, currentRate);

emit Transfer(sender, recipient, tTransferAmount);

}

function _transferBothExcluded(

address sender,

address recipient,

uint256 tAmount

) private {

(

uint256 tTransferAmount,

uint256 tFee,

uint256 tLiquidity

) = _getTValues(tAmount);

uint256 currentRate = _getRate();

(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

_tOwned[sender] = _tOwned[sender].sub(tAmount);

_rOwned[sender] = _rOwned[sender].sub(rAmount);

_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);

_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);

takeTokenFees(tLiquidity, currentRate);

_reflectFee(rFee, tFee);

emit Transfer(sender, recipient, tTransferAmount);

}

function _transferToExcluded(

address sender,

address recipient,

uint256 tAmount

) private {

(

uint256 tTransferAmount,

uint256 tFee,

uint256 tLiquidity

) = _getTValues(tAmount);

uint256 currentRate = _getRate();

(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

_rOwned[sender] = _rOwned[sender].sub(rAmount);

_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);

_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);

takeTokenFees(tLiquidity, currentRate);

_reflectFee(rFee, tFee);

emit Transfer(sender, recipient, tTransferAmount);

}

function _transferFromExcluded(

address sender,

address recipient,

uint256 tAmount

) private {

(

uint256 tTransferAmount,

uint256 tFee,

uint256 tLiquidity

) = _getTValues(tAmount);

uint256 currentRate = _getRate();

(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(

tAmount,

tFee,

tLiquidity,

currentRate

);

_tOwned[sender] = _tOwned[sender].sub(tAmount);

_rOwned[sender] = _rOwned[sender].sub(rAmount);

_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);

takeTokenFees(tLiquidity, currentRate);

_reflectFee(rFee, tFee);

emit Transfer(sender, recipient, tTransferAmount);

}

}

--

--

Launch Verse
Launch Verse

Written by Launch Verse

LaunchVerse is a crypto IDO platform focussing on upcoming projects in the market and other Launchpads’ performances over the IDOs launched on their platforms.

No responses yet