Token 10X: Africa's First Cryptocurrency Hub
Looney Moons Crypto Token
Looney Moons: An exciting multi-purpose token that is backed by several utilities and a DOXXED/KYC TEAM. It is designed to reward users in BNB and Tokens for playing our games and Hodling the token $LMS. %uD83D%uDCB0 Enjoy token rewards, staking, lotto, and beanstalk awards! We are developing a Cart...
About Looney Moons Crypto
Looney Moons: An exciting multi-purpose token that is backed by several utilities and a DOXXED/KYC TEAM. It is designed to reward users in BNB and Tokens for playing our games and Hodling the token $LMS. %uD83D%uDCB0 Enjoy token rewards, staking, lotto, and beanstalk awards! We are developing a Cartoon Series that will FEATURE THE CHARACTERS FROM THE NFTs! This series will be available exclusively on our YouTube channel. Join our presale and enjoy the benefits of being early to the token that will take off this year!
973 total visits
Token information and links
Circulating Supply
100000000000000000000
Token Contract (BSC Chain)
0X84E88F271042658D8ACA4EEB4563478F2907DABA
Contract license:
Launch Date
09/02/2022
KYC Information
No
Audit Information
None
Team Information
Team leader: None
Team leader contact: None
Contract source code
{{
"language": "Solidity",
"sources": {
"contracts/LMTtoken.sol": {
"content": "//________________________________________________\r\n// |\r\n// Welcome to Looney Moons |\r\n// |\r\n// We're thrilled to present Looney Moons: A |\r\n// token with rewards, staking, lotto, beanstalk |\r\n// awards, and more! |\r\n// |\r\n// Learn more: https://looneymoonscrypto.com/ |\r\n// Discuss: https://t.me/LooneyMoonsOfficial/ |\r\n// |\r\n//________________________________________________|\r\n\r\n//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.9;\r\n\r\n/**\r\n * SAFEMATH LIBRARY\r\n */\r\nlibrary SafeMath {\r\n function tryAdd(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n uint256 c = a b;\r\n if (c < a) return (false, 0);\r\n return (true, c);\r\n }\r\n }\r\n\r\n function trySub(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b > a) return (false, 0);\r\n return (true, a - b);\r\n }\r\n }\r\n\r\n function tryMul(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) return (true, 0);\r\n uint256 c = a * b;\r\n if (c / a != b) return (false, 0);\r\n return (true, c);\r\n }\r\n }\r\n\r\n function tryDiv(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b == 0) return (false, 0);\r\n return (true, a / b);\r\n }\r\n }\r\n\r\n function tryMod(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b == 0) return (false, 0);\r\n return (true, a % b);\r\n }\r\n }\r\n\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a b;\r\n }\r\n\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a - b;\r\n }\r\n\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a * b;\r\n }\r\n\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a / b;\r\n }\r\n\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a % b;\r\n }\r\n\r\n function sub(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b <= a, errorMessage);\r\n return a - b;\r\n }\r\n }\r\n\r\n function div(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b > 0, errorMessage);\r\n return a / b;\r\n }\r\n }\r\n\r\n function mod(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b > 0, errorMessage);\r\n return a % b;\r\n }\r\n }\r\n}\r\n\r\ninterface IBEP20 {\r\n function totalSupply() external view returns (uint256);\r\n\r\n function decimals() external view returns (uint8);\r\n\r\n function symbol() external view returns (string memory);\r\n\r\n function name() external view returns (string memory);\r\n\r\n function getOwner() external view returns (address);\r\n\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n returns (bool);\r\n\r\n function allowance(address _owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external returns (bool);\r\n\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\nabstract contract Ownable {\r\n address internal owner;\r\n\r\n constructor(address _owner) {\r\n owner = _owner;\r\n }\r\n\r\n modifier onlyOwner() {\r\n require(isOwner(msg.sender), \"NOT AN OWNER\");\r\n _;\r\n }\r\n\r\n function isOwner(address account) public view returns (bool) {\r\n return account == owner;\r\n }\r\n\r\n function transferOwnership(address payable adr) public onlyOwner {\r\n owner = adr;\r\n emit OwnershipTransferred(adr);\r\n }\r\n\r\n event OwnershipTransferred(address owner);\r\n}\r\n\r\ninterface IDEXFactory {\r\n function createPair(address tokenA, address tokenB)\r\n external\r\n returns (address pair);\r\n}\r\n\r\ninterface Irouter {\r\n function factory() external pure returns (address);\r\n\r\n function WETH() external pure returns (address);\r\n\r\n function addLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 amountADesired,\r\n uint256 amountBDesired,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n returns (\r\n uint256 amountA,\r\n uint256 amountB,\r\n uint256 liquidity\r\n );\r\n\r\n function addLiquidityETH(\r\n address token,\r\n uint256 amountTokenDesired,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n payable\r\n returns (\r\n uint256 amountToken,\r\n uint256 amountETH,\r\n uint256 liquidity\r\n );\r\n\r\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n\r\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable;\r\n\r\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n}\r\n\r\ninterface IDividendDistributor {\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external;\r\n\r\n function setShare(address shareholder, uint256 amount) external;\r\n\r\n function deposit() external payable;\r\n\r\n function process(uint256 gas) external;\r\n\r\n function claimDividend(address _user) external;\r\n\r\n function getPaidEarnings(address shareholder)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function getUnpaidEarnings(address shareholder)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function totalDistributed() external view returns (uint256);\r\n}\r\n\r\ncontract DividendDistributor is IDividendDistributor {\r\n using SafeMath for uint256;\r\n\r\n address _token;\r\n\r\n struct Share {\r\n uint256 amount;\r\n uint256 totalExcluded;\r\n uint256 totalRealised;\r\n }\r\n\r\n address WBNB;\r\n Irouter router;\r\n\r\n address[] shareholders;\r\n mapping(address => uint256) shareholderIndexes;\r\n mapping(address => uint256) shareholderClaims;\r\n\r\n mapping(address => Share) public shares;\r\n\r\n uint256 public totalShares;\r\n uint256 public totalDividends;\r\n uint256 public totalDistributed;\r\n uint256 public dividendsPerShare;\r\n uint256 public dividendsPerShareAccuracyFactor = 10**36;\r\n\r\n uint256 public minPeriod = 1 hours;\r\n uint256 public minDistribution = 1 * (10**18);\r\n\r\n uint256 currentIndex;\r\n\r\n bool initialized;\r\n modifier initialization() {\r\n require(!initialized);\r\n _;\r\n initialized = true;\r\n }\r\n\r\n modifier onlyToken() {\r\n require(msg.sender == _token);\r\n _;\r\n }\r\n\r\n constructor(address _router) {\r\n router = Irouter(_router);\r\n WBNB = router.WETH();\r\n _token = msg.sender;\r\n }\r\n\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external override onlyToken {\r\n minPeriod = _minPeriod;\r\n minDistribution = _minDistribution;\r\n }\r\n\r\n function setShare(address shareholder, uint256 amount)\r\n external\r\n override\r\n onlyToken\r\n {\r\n if (shares[shareholder].amount > 0) {\r\n distributeDividend(shareholder);\r\n }\r\n\r\n if (amount > 0 && shares[shareholder].amount == 0) {\r\n addShareholder(shareholder);\r\n } else if (amount == 0 && shares[shareholder].amount > 0) {\r\n removeShareholder(shareholder);\r\n }\r\n\r\n totalShares = totalShares.sub(shares[shareholder].amount).add(amount);\r\n shares[shareholder].amount = amount;\r\n shares[shareholder].totalExcluded = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n }\r\n\r\n function deposit() external payable override onlyToken {\r\n uint256 amount = msg.value;\r\n totalDividends = totalDividends.add(amount);\r\n dividendsPerShare = dividendsPerShare.add(\r\n dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)\r\n );\r\n }\r\n\r\n function process(uint256 gas) external override onlyToken {\r\n uint256 shareholderCount = shareholders.length;\r\n\r\n if (shareholderCount == 0) {\r\n return;\r\n }\r\n\r\n uint256 gasUsed = 0;\r\n uint256 gasLeft = gasleft();\r\n\r\n uint256 iterations = 0;\r\n\r\n while (gasUsed < gas && iterations < shareholderCount) {\r\n if (currentIndex >= shareholderCount) {\r\n currentIndex = 0;\r\n }\r\n\r\n if (shouldDistribute(shareholders[currentIndex])) {\r\n distributeDividend(shareholders[currentIndex]);\r\n }\r\n\r\n gasUsed = gasUsed.add(gasLeft.sub(gasleft()));\r\n gasLeft = gasleft();\r\n currentIndex ;\r\n iterations ;\r\n }\r\n }\r\n\r\n function shouldDistribute(address shareholder)\r\n internal\r\n view\r\n returns (bool)\r\n {\r\n return\r\n shareholderClaims[shareholder] minPeriod < block.timestamp &&\r\n getUnpaidEarnings(shareholder) > minDistribution;\r\n }\r\n\r\n function distributeDividend(address shareholder) internal {\r\n if (shares[shareholder].amount == 0) {\r\n return;\r\n }\r\n\r\n uint256 amount = getUnpaidEarnings(shareholder);\r\n if (amount > 0) {\r\n totalDistributed = totalDistributed.add(amount);\r\n payable(shareholder).transfer(amount);\r\n shareholderClaims[shareholder] = block.timestamp;\r\n shares[shareholder].totalRealised = shares[shareholder]\r\n .totalRealised\r\n .add(amount);\r\n shares[shareholder].totalExcluded = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n }\r\n }\r\n\r\n function claimDividend(address _user) public {\r\n distributeDividend(_user);\r\n }\r\n\r\n function getPaidEarnings(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n return shares[shareholder].totalRealised;\r\n }\r\n\r\n function getUnpaidEarnings(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n if (shares[shareholder].amount == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 shareholderTotalDividends = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded;\r\n\r\n if (shareholderTotalDividends <= shareholderTotalExcluded) {\r\n return 0;\r\n }\r\n\r\n return shareholderTotalDividends.sub(shareholderTotalExcluded);\r\n }\r\n\r\n function getCumulativeDividends(uint256 share)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n return\r\n share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor);\r\n }\r\n\r\n function addShareholder(address shareholder) internal {\r\n shareholderIndexes[shareholder] = shareholders.length;\r\n shareholders.push(shareholder);\r\n }\r\n\r\n function removeShareholder(address shareholder) internal {\r\n shareholders[shareholderIndexes[shareholder]] = shareholders[\r\n shareholders.length - 1\r\n ];\r\n shareholderIndexes[\r\n shareholders[shareholders.length - 1]\r\n ] = shareholderIndexes[shareholder];\r\n shareholders.pop();\r\n }\r\n}\r\n\r\ncontract TokenContract is IBEP20, Ownable {\r\n using SafeMath for uint256;\r\n\r\n address public WBNB;\r\n address DEAD = 0x000000000000000000000000000000000000dEaD;\r\n\r\n string constant _name = \"Looney Moons\";\r\n string constant _symbol = \"LMS\";\r\n uint8 constant _decimals = 9;\r\n\r\n uint256 _totalSupply = 100000000000 *1e9;\r\n uint256 public maxTxAmount = _totalSupply.div(100); // 0.1%\r\n\r\n mapping(address => uint256) _balances;\r\n mapping(address => mapping(address => uint256)) _allowances;\r\n\r\n mapping(address => bool) isFeeExempt;\r\n mapping(address => bool) isTxLimitExempt;\r\n mapping(address => bool) isDividendExempt;\r\n mapping(address => bool) isLotteryExempt;\r\n\r\n uint256 initialRewardFee = 100;\r\n uint256 lotteryFee = 300;\r\n uint256 marketFee = 300;\r\n uint256 rewardFee = initialRewardFee;\r\n uint256 feeDenominator = 10000;\r\n uint256 lotteryFeeCount;\r\n uint256 incFeePercent = 5;\r\n uint256 maxIncFeePercent = 1400;\r\n uint256 distributorGas = 500000;\r\n uint256 public swapThreshold = _totalSupply / 2000; // 0.005%\r\n uint256 public launchedAt;\r\n uint256 public launchedAtTimestamp;\r\n\r\n address[] holders;\r\n address[] public winners;\r\n Irouter public router;\r\n DividendDistributor distributor;\r\n address public pair;\r\n address public distributorAddress;\r\n address public autoLiquidityReceiver;\r\n address public marketFeeReceiver;\r\n\r\n bool public swapEnabled;\r\n bool public tradingOpen;\r\n bool public isLotteryEnable = true;\r\n bool inSwap;\r\n\r\n modifier swapping() {\r\n inSwap = true;\r\n _;\r\n inSwap = false;\r\n }\r\n\r\n constructor(\r\n address _router,\r\n address _market\r\n ) Ownable(msg.sender) {\r\n router = Irouter(_router);\r\n WBNB = router.WETH();\r\n pair = IDEXFactory(router.factory()).createPair(WBNB, address(this));\r\n _allowances[address(this)][address(router)] = _totalSupply;\r\n distributor = new DividendDistributor(_router);\r\n distributorAddress = address(distributor);\r\n\r\n isFeeExempt[msg.sender] = true;\r\n isTxLimitExempt[msg.sender] = true;\r\n isDividendExempt[pair] = true;\r\n isDividendExempt[address(this)] = true;\r\n isDividendExempt[DEAD] = true;\r\n isLotteryExempt[address(this)] = true;\r\n isLotteryExempt[pair] = true;\r\n isLotteryExempt[DEAD] = true;\r\n\r\n autoLiquidityReceiver = msg.sender;\r\n marketFeeReceiver = _market;\r\n\r\n approve(_router, _totalSupply);\r\n approve(address(pair), _totalSupply);\r\n _balances[msg.sender] = _totalSupply;\r\n\r\n emit Transfer(address(0), msg.sender, _totalSupply);\r\n }\r\n\r\n receive() external payable {}\r\n\r\n function totalSupply() external view override returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n function decimals() external pure override returns (uint8) {\r\n return _decimals;\r\n }\r\n\r\n function symbol() external pure override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n function name() external pure override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n function getOwner() external view override returns (address) {\r\n return owner;\r\n }\r\n\r\n function balanceOf(address account) public view override returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n function allowance(address holder, address spender)\r\n external\r\n view\r\n override\r\n returns (uint256)\r\n {\r\n return _allowances[holder][spender];\r\n }\r\n\r\n function approve(address spender, uint256 amount)\r\n public\r\n override\r\n returns (bool)\r\n {\r\n _allowances[msg.sender][spender] = amount;\r\n emit Approval(msg.sender, spender, amount);\r\n return true;\r\n }\r\n\r\n function approveMax(address spender) external returns (bool) {\r\n return approve(spender, _totalSupply);\r\n }\r\n\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n override\r\n returns (bool)\r\n {\r\n return _transferFrom(msg.sender, recipient, amount);\r\n }\r\n\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external override returns (bool) {\r\n if (_allowances[sender][msg.sender] != _totalSupply) {\r\n _allowances[sender][msg.sender] = _allowances[sender][msg.sender]\r\n .sub(amount, \"Insufficient Allowance\");\r\n }\r\n\r\n return _transferFrom(sender, recipient, amount);\r\n }\r\n\r\n function _transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) internal returns (bool) {\r\n if (!isTxLimitExempt[sender] && !isTxLimitExempt[recipient]) {\r\n // trading disable till launch\r\n if (!tradingOpen) {\r\n require(\r\n sender != pair && recipient != pair,\r\n \"Trading is not enabled yet\"\r\n );\r\n }\r\n\r\n require(amount <= maxTxAmount, \"TX Limit Exceeded\");\r\n }\r\n\r\n if (inSwap) {\r\n return _basicTransfer(sender, recipient, amount);\r\n }\r\n\r\n if (balanceOf(recipient) == 0 && !isLotteryExempt[recipient]) {\r\n holders.push(recipient);\r\n }\r\n\r\n if (shouldSwapBack()) {\r\n swapBack();\r\n }\r\n\r\n _balances[sender] = _balances[sender].sub(\r\n amount,\r\n \"Insufficient Balance\"\r\n );\r\n uint256 amountReceived;\r\n if (\r\n isFeeExempt[sender] ||\r\n isFeeExempt[recipient] ||\r\n (sender != pair && recipient != pair)\r\n ) {\r\n amountReceived = amount;\r\n } else {\r\n amountReceived = takeFee(sender, amount);\r\n\r\n if (sender == pair) {\r\n // reward fee increment handler\r\n if (rewardFee < maxIncFeePercent) {\r\n rewardFee = incFeePercent;\r\n } else {\r\n rewardFee = initialRewardFee;\r\n // lottery handler\r\n if (isLotteryEnable) {\r\n address winner;\r\n bool winnerFound = true;\r\n while (winnerFound) {\r\n uint256 winnerIndex = luckyDraw(\r\n 0,\r\n holders.length,\r\n amount\r\n );\r\n winner = holders[winnerIndex];\r\n if (\r\n balanceOf(winner) > 0 &&\r\n !isLotteryExempt[winner]\r\n ) {\r\n winnerFound = false;\r\n }\r\n }\r\n winners.push(winner);\r\n if (lotteryFeeCount > 0) {\r\n giveLottery(winner);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n _balances[recipient] = _balances[recipient].add(amountReceived);\r\n\r\n if (!isDividendExempt[sender]) {\r\n try distributor.setShare(sender, _balances[sender]) {} catch {}\r\n }\r\n if (!isDividendExempt[recipient]) {\r\n try\r\n distributor.setShare(recipient, _balances[recipient])\r\n {} catch {}\r\n }\r\n\r\n try distributor.process(distributorGas) {} catch {}\r\n\r\n emit Transfer(sender, recipient, amountReceived);\r\n return true;\r\n }\r\n\r\n function _basicTransfer(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) internal returns (bool) {\r\n _balances[sender] = _balances[sender].sub(\r\n amount,\r\n \"Insufficient Balance\"\r\n );\r\n _balances[recipient] = _balances[recipient].add(amount);\r\n emit Transfer(sender, recipient, amount);\r\n return true;\r\n }\r\n\r\n function takeFee(address sender, uint256 amount)\r\n internal\r\n returns (uint256)\r\n {\r\n uint256 feeAmount = amount.mul(rewardFee.add(marketFee).add(lotteryFee)).div(feeDenominator);\r\n lotteryFeeCount = lotteryFeeCount.add(amount.mul(lotteryFee).div(feeDenominator));\r\n _balances[address(this)] = _balances[address(this)].add(feeAmount);\r\n emit Transfer(sender, address(this), feeAmount);\r\n\r\n return amount.sub(feeAmount);\r\n }\r\n\r\n function shouldSwapBack() internal view returns (bool) {\r\n return\r\n msg.sender != pair &&\r\n !inSwap &&\r\n swapEnabled &&\r\n _balances[address(this)] >= swapThreshold;\r\n }\r\n\r\n function swapBack() internal swapping {\r\n uint256 amountToSwap = swapThreshold.sub(lotteryFeeCount);\r\n uint256 totalFee = rewardFee.add(marketFee);\r\n\r\n address[] memory path = new address[](2);\r\n path[0] = address(this);\r\n path[1] = WBNB;\r\n uint256 balanceBefore = address(this).balance;\r\n\r\n router.swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n amountToSwap,\r\n 0,\r\n path,\r\n address(this),\r\n block.timestamp\r\n );\r\n\r\n uint256 amountBNB = address(this).balance.sub(balanceBefore);\r\n\r\n uint256 amountBNBReflection = amountBNB.mul(rewardFee).div(\r\n totalFee\r\n );\r\n uint256 amountBNBMarketing = amountBNB.mul(marketFee).div(\r\n totalFee\r\n );\r\n\r\n try distributor.deposit{value: amountBNBReflection}() {} catch {}\r\n payable(marketFeeReceiver).transfer(amountBNBMarketing);\r\n\r\n }\r\n\r\n function luckyDraw(\r\n uint256 from,\r\n uint256 to,\r\n uint256 amount\r\n ) private view returns (uint256) {\r\n uint256 seed = uint256(\r\n keccak256(\r\n abi.encodePacked(\r\n block.timestamp \r\n block.difficulty \r\n ((\r\n uint256(keccak256(abi.encodePacked(block.coinbase)))\r\n ) / (block.timestamp)) \r\n block.gaslimit \r\n ((uint256(keccak256(abi.encodePacked(msg.sender)))) /\r\n (block.timestamp)) \r\n block.number \r\n amount\r\n )\r\n )\r\n );\r\n return seed.mod(to - from) from;\r\n }\r\n\r\n function giveLottery(address winner) internal {\r\n _balances[address(this)] = _balances[address(this)].sub(lotteryFeeCount);\r\n _balances[winner] = _balances[winner].add(lotteryFeeCount);\r\n emit Transfer(address(this), winner, lotteryFeeCount);\r\n lotteryFeeCount = 0;\r\n }\r\n\r\n function launched() internal view returns (bool) {\r\n return launchedAt != 0;\r\n }\r\n\r\n function launch() public onlyOwner {\r\n require(launchedAt == 0, \"Already launched boi\");\r\n launchedAt = block.number;\r\n launchedAtTimestamp = block.timestamp;\r\n tradingOpen = true;\r\n swapEnabled = true;\r\n }\r\n\r\n function setTxLimit(uint256 amount) external onlyOwner {\r\n require(amount >= _totalSupply / 1000);\r\n maxTxAmount = amount;\r\n }\r\n\r\n function setIsDividendExempt(address holder, bool exempt)\r\n external\r\n onlyOwner\r\n {\r\n require(holder != address(this) && holder != pair);\r\n isDividendExempt[holder] = exempt;\r\n if (exempt) {\r\n distributor.setShare(holder, 0);\r\n } else {\r\n distributor.setShare(holder, _balances[holder]);\r\n }\r\n }\r\n\r\n function setIsFeeExempt(address holder, bool exempt) external onlyOwner {\r\n isFeeExempt[holder] = exempt;\r\n }\r\n\r\n function setIsLotteryExempt(address holder, bool exempt) external onlyOwner {\r\n isLotteryExempt[holder] = exempt;\r\n }\r\n\r\n function setIsTxLimitExempt(address holder, bool exempt)\r\n external\r\n onlyOwner\r\n {\r\n isTxLimitExempt[holder] = exempt;\r\n }\r\n\r\n function setFees(\r\n uint256 _lotteryFee,\r\n uint256 _rewardFee,\r\n uint256 _marketFee,\r\n uint256 _feeDenominator\r\n ) external onlyOwner {\r\n lotteryFee = _lotteryFee;\r\n initialRewardFee = _rewardFee;\r\n marketFee = _marketFee;\r\n feeDenominator = _feeDenominator;\r\n }\r\n\r\n function setFeeReceivers(\r\n address _autoLiquidityReceiver,\r\n address _marketFeeReceiver\r\n ) external onlyOwner {\r\n autoLiquidityReceiver = _autoLiquidityReceiver;\r\n marketFeeReceiver = _marketFeeReceiver;\r\n }\r\n\r\n function setSwapBackSettings(bool _enabled, uint256 _amount)\r\n external\r\n onlyOwner\r\n {\r\n swapEnabled = _enabled;\r\n swapThreshold = _amount;\r\n }\r\n\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external onlyOwner {\r\n distributor.setDistributionCriteria(_minPeriod, _minDistribution);\r\n }\r\n\r\n function setDistributorSettings(uint256 gas) external onlyOwner {\r\n require(gas < 750000);\r\n distributorGas = gas;\r\n }\r\n // owner can remove stuck tokens in case of any issue\r\n function removeStuckToken(address _token, uint256 _amount)\r\n external\r\n onlyOwner\r\n {\r\n IBEP20(_token).transfer(owner, _amount);\r\n }\r\n\r\n\r\n function claimDividend() external {\r\n distributor.claimDividend(msg.sender);\r\n }\r\n\r\n function getPaidDividend(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n return distributor.getPaidEarnings(shareholder);\r\n }\r\n\r\n function getUnpaidDividend(address shareholder)\r\n external\r\n view\r\n returns (uint256)\r\n {\r\n return distributor.getUnpaidEarnings(shareholder);\r\n }\r\n\r\n function getTotalDistributedDividend() external view returns (uint256) {\r\n return distributor.totalDistributed();\r\n }\r\n\r\n function enableOrDisableLottery(bool _state) external onlyOwner {\r\n isLotteryEnable = _state;\r\n }\r\n\r\n function chnageIncrementInFee(uint256 _incFeePercent, uint256 _maxIncFee)external onlyOwner{\r\n incFeePercent = _incFeePercent;\r\n maxIncFeePercent = _maxIncFee;\r\n }\r\n}\r\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
"language": "Solidity",
"sources": {
"contracts/LMTtoken.sol": {
"content": "//________________________________________________\r\n// |\r\n// Welcome to Looney Moons |\r\n// |\r\n// We're thrilled to present Looney Moons: A |\r\n// token with rewards, staking, lotto, beanstalk |\r\n// awards, and more! |\r\n// |\r\n// Learn more: https://looneymoonscrypto.com/ |\r\n// Discuss: https://t.me/LooneyMoonsOfficial/ |\r\n// |\r\n//________________________________________________|\r\n\r\n//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.9;\r\n\r\n/**\r\n * SAFEMATH LIBRARY\r\n */\r\nlibrary SafeMath {\r\n function tryAdd(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n uint256 c = a b;\r\n if (c < a) return (false, 0);\r\n return (true, c);\r\n }\r\n }\r\n\r\n function trySub(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b > a) return (false, 0);\r\n return (true, a - b);\r\n }\r\n }\r\n\r\n function tryMul(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) return (true, 0);\r\n uint256 c = a * b;\r\n if (c / a != b) return (false, 0);\r\n return (true, c);\r\n }\r\n }\r\n\r\n function tryDiv(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b == 0) return (false, 0);\r\n return (true, a / b);\r\n }\r\n }\r\n\r\n function tryMod(uint256 a, uint256 b)\r\n internal\r\n pure\r\n returns (bool, uint256)\r\n {\r\n unchecked {\r\n if (b == 0) return (false, 0);\r\n return (true, a % b);\r\n }\r\n }\r\n\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a b;\r\n }\r\n\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a - b;\r\n }\r\n\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a * b;\r\n }\r\n\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a / b;\r\n }\r\n\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a % b;\r\n }\r\n\r\n function sub(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b <= a, errorMessage);\r\n return a - b;\r\n }\r\n }\r\n\r\n function div(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b > 0, errorMessage);\r\n return a / b;\r\n }\r\n }\r\n\r\n function mod(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n unchecked {\r\n require(b > 0, errorMessage);\r\n return a % b;\r\n }\r\n }\r\n}\r\n\r\ninterface IBEP20 {\r\n function totalSupply() external view returns (uint256);\r\n\r\n function decimals() external view returns (uint8);\r\n\r\n function symbol() external view returns (string memory);\r\n\r\n function name() external view returns (string memory);\r\n\r\n function getOwner() external view returns (address);\r\n\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n returns (bool);\r\n\r\n function allowance(address _owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external returns (bool);\r\n\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\nabstract contract Ownable {\r\n address internal owner;\r\n\r\n constructor(address _owner) {\r\n owner = _owner;\r\n }\r\n\r\n modifier onlyOwner() {\r\n require(isOwner(msg.sender), \"NOT AN OWNER\");\r\n _;\r\n }\r\n\r\n function isOwner(address account) public view returns (bool) {\r\n return account == owner;\r\n }\r\n\r\n function transferOwnership(address payable adr) public onlyOwner {\r\n owner = adr;\r\n emit OwnershipTransferred(adr);\r\n }\r\n\r\n event OwnershipTransferred(address owner);\r\n}\r\n\r\ninterface IDEXFactory {\r\n function createPair(address tokenA, address tokenB)\r\n external\r\n returns (address pair);\r\n}\r\n\r\ninterface Irouter {\r\n function factory() external pure returns (address);\r\n\r\n function WETH() external pure returns (address);\r\n\r\n function addLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 amountADesired,\r\n uint256 amountBDesired,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n returns (\r\n uint256 amountA,\r\n uint256 amountB,\r\n uint256 liquidity\r\n );\r\n\r\n function addLiquidityETH(\r\n address token,\r\n uint256 amountTokenDesired,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n payable\r\n returns (\r\n uint256 amountToken,\r\n uint256 amountETH,\r\n uint256 liquidity\r\n );\r\n\r\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n\r\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable;\r\n\r\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n}\r\n\r\ninterface IDividendDistributor {\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external;\r\n\r\n function setShare(address shareholder, uint256 amount) external;\r\n\r\n function deposit() external payable;\r\n\r\n function process(uint256 gas) external;\r\n\r\n function claimDividend(address _user) external;\r\n\r\n function getPaidEarnings(address shareholder)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function getUnpaidEarnings(address shareholder)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function totalDistributed() external view returns (uint256);\r\n}\r\n\r\ncontract DividendDistributor is IDividendDistributor {\r\n using SafeMath for uint256;\r\n\r\n address _token;\r\n\r\n struct Share {\r\n uint256 amount;\r\n uint256 totalExcluded;\r\n uint256 totalRealised;\r\n }\r\n\r\n address WBNB;\r\n Irouter router;\r\n\r\n address[] shareholders;\r\n mapping(address => uint256) shareholderIndexes;\r\n mapping(address => uint256) shareholderClaims;\r\n\r\n mapping(address => Share) public shares;\r\n\r\n uint256 public totalShares;\r\n uint256 public totalDividends;\r\n uint256 public totalDistributed;\r\n uint256 public dividendsPerShare;\r\n uint256 public dividendsPerShareAccuracyFactor = 10**36;\r\n\r\n uint256 public minPeriod = 1 hours;\r\n uint256 public minDistribution = 1 * (10**18);\r\n\r\n uint256 currentIndex;\r\n\r\n bool initialized;\r\n modifier initialization() {\r\n require(!initialized);\r\n _;\r\n initialized = true;\r\n }\r\n\r\n modifier onlyToken() {\r\n require(msg.sender == _token);\r\n _;\r\n }\r\n\r\n constructor(address _router) {\r\n router = Irouter(_router);\r\n WBNB = router.WETH();\r\n _token = msg.sender;\r\n }\r\n\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external override onlyToken {\r\n minPeriod = _minPeriod;\r\n minDistribution = _minDistribution;\r\n }\r\n\r\n function setShare(address shareholder, uint256 amount)\r\n external\r\n override\r\n onlyToken\r\n {\r\n if (shares[shareholder].amount > 0) {\r\n distributeDividend(shareholder);\r\n }\r\n\r\n if (amount > 0 && shares[shareholder].amount == 0) {\r\n addShareholder(shareholder);\r\n } else if (amount == 0 && shares[shareholder].amount > 0) {\r\n removeShareholder(shareholder);\r\n }\r\n\r\n totalShares = totalShares.sub(shares[shareholder].amount).add(amount);\r\n shares[shareholder].amount = amount;\r\n shares[shareholder].totalExcluded = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n }\r\n\r\n function deposit() external payable override onlyToken {\r\n uint256 amount = msg.value;\r\n totalDividends = totalDividends.add(amount);\r\n dividendsPerShare = dividendsPerShare.add(\r\n dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)\r\n );\r\n }\r\n\r\n function process(uint256 gas) external override onlyToken {\r\n uint256 shareholderCount = shareholders.length;\r\n\r\n if (shareholderCount == 0) {\r\n return;\r\n }\r\n\r\n uint256 gasUsed = 0;\r\n uint256 gasLeft = gasleft();\r\n\r\n uint256 iterations = 0;\r\n\r\n while (gasUsed < gas && iterations < shareholderCount) {\r\n if (currentIndex >= shareholderCount) {\r\n currentIndex = 0;\r\n }\r\n\r\n if (shouldDistribute(shareholders[currentIndex])) {\r\n distributeDividend(shareholders[currentIndex]);\r\n }\r\n\r\n gasUsed = gasUsed.add(gasLeft.sub(gasleft()));\r\n gasLeft = gasleft();\r\n currentIndex ;\r\n iterations ;\r\n }\r\n }\r\n\r\n function shouldDistribute(address shareholder)\r\n internal\r\n view\r\n returns (bool)\r\n {\r\n return\r\n shareholderClaims[shareholder] minPeriod < block.timestamp &&\r\n getUnpaidEarnings(shareholder) > minDistribution;\r\n }\r\n\r\n function distributeDividend(address shareholder) internal {\r\n if (shares[shareholder].amount == 0) {\r\n return;\r\n }\r\n\r\n uint256 amount = getUnpaidEarnings(shareholder);\r\n if (amount > 0) {\r\n totalDistributed = totalDistributed.add(amount);\r\n payable(shareholder).transfer(amount);\r\n shareholderClaims[shareholder] = block.timestamp;\r\n shares[shareholder].totalRealised = shares[shareholder]\r\n .totalRealised\r\n .add(amount);\r\n shares[shareholder].totalExcluded = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n }\r\n }\r\n\r\n function claimDividend(address _user) public {\r\n distributeDividend(_user);\r\n }\r\n\r\n function getPaidEarnings(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n return shares[shareholder].totalRealised;\r\n }\r\n\r\n function getUnpaidEarnings(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n if (shares[shareholder].amount == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 shareholderTotalDividends = getCumulativeDividends(\r\n shares[shareholder].amount\r\n );\r\n uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded;\r\n\r\n if (shareholderTotalDividends <= shareholderTotalExcluded) {\r\n return 0;\r\n }\r\n\r\n return shareholderTotalDividends.sub(shareholderTotalExcluded);\r\n }\r\n\r\n function getCumulativeDividends(uint256 share)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n return\r\n share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor);\r\n }\r\n\r\n function addShareholder(address shareholder) internal {\r\n shareholderIndexes[shareholder] = shareholders.length;\r\n shareholders.push(shareholder);\r\n }\r\n\r\n function removeShareholder(address shareholder) internal {\r\n shareholders[shareholderIndexes[shareholder]] = shareholders[\r\n shareholders.length - 1\r\n ];\r\n shareholderIndexes[\r\n shareholders[shareholders.length - 1]\r\n ] = shareholderIndexes[shareholder];\r\n shareholders.pop();\r\n }\r\n}\r\n\r\ncontract TokenContract is IBEP20, Ownable {\r\n using SafeMath for uint256;\r\n\r\n address public WBNB;\r\n address DEAD = 0x000000000000000000000000000000000000dEaD;\r\n\r\n string constant _name = \"Looney Moons\";\r\n string constant _symbol = \"LMS\";\r\n uint8 constant _decimals = 9;\r\n\r\n uint256 _totalSupply = 100000000000 *1e9;\r\n uint256 public maxTxAmount = _totalSupply.div(100); // 0.1%\r\n\r\n mapping(address => uint256) _balances;\r\n mapping(address => mapping(address => uint256)) _allowances;\r\n\r\n mapping(address => bool) isFeeExempt;\r\n mapping(address => bool) isTxLimitExempt;\r\n mapping(address => bool) isDividendExempt;\r\n mapping(address => bool) isLotteryExempt;\r\n\r\n uint256 initialRewardFee = 100;\r\n uint256 lotteryFee = 300;\r\n uint256 marketFee = 300;\r\n uint256 rewardFee = initialRewardFee;\r\n uint256 feeDenominator = 10000;\r\n uint256 lotteryFeeCount;\r\n uint256 incFeePercent = 5;\r\n uint256 maxIncFeePercent = 1400;\r\n uint256 distributorGas = 500000;\r\n uint256 public swapThreshold = _totalSupply / 2000; // 0.005%\r\n uint256 public launchedAt;\r\n uint256 public launchedAtTimestamp;\r\n\r\n address[] holders;\r\n address[] public winners;\r\n Irouter public router;\r\n DividendDistributor distributor;\r\n address public pair;\r\n address public distributorAddress;\r\n address public autoLiquidityReceiver;\r\n address public marketFeeReceiver;\r\n\r\n bool public swapEnabled;\r\n bool public tradingOpen;\r\n bool public isLotteryEnable = true;\r\n bool inSwap;\r\n\r\n modifier swapping() {\r\n inSwap = true;\r\n _;\r\n inSwap = false;\r\n }\r\n\r\n constructor(\r\n address _router,\r\n address _market\r\n ) Ownable(msg.sender) {\r\n router = Irouter(_router);\r\n WBNB = router.WETH();\r\n pair = IDEXFactory(router.factory()).createPair(WBNB, address(this));\r\n _allowances[address(this)][address(router)] = _totalSupply;\r\n distributor = new DividendDistributor(_router);\r\n distributorAddress = address(distributor);\r\n\r\n isFeeExempt[msg.sender] = true;\r\n isTxLimitExempt[msg.sender] = true;\r\n isDividendExempt[pair] = true;\r\n isDividendExempt[address(this)] = true;\r\n isDividendExempt[DEAD] = true;\r\n isLotteryExempt[address(this)] = true;\r\n isLotteryExempt[pair] = true;\r\n isLotteryExempt[DEAD] = true;\r\n\r\n autoLiquidityReceiver = msg.sender;\r\n marketFeeReceiver = _market;\r\n\r\n approve(_router, _totalSupply);\r\n approve(address(pair), _totalSupply);\r\n _balances[msg.sender] = _totalSupply;\r\n\r\n emit Transfer(address(0), msg.sender, _totalSupply);\r\n }\r\n\r\n receive() external payable {}\r\n\r\n function totalSupply() external view override returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n function decimals() external pure override returns (uint8) {\r\n return _decimals;\r\n }\r\n\r\n function symbol() external pure override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n function name() external pure override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n function getOwner() external view override returns (address) {\r\n return owner;\r\n }\r\n\r\n function balanceOf(address account) public view override returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n function allowance(address holder, address spender)\r\n external\r\n view\r\n override\r\n returns (uint256)\r\n {\r\n return _allowances[holder][spender];\r\n }\r\n\r\n function approve(address spender, uint256 amount)\r\n public\r\n override\r\n returns (bool)\r\n {\r\n _allowances[msg.sender][spender] = amount;\r\n emit Approval(msg.sender, spender, amount);\r\n return true;\r\n }\r\n\r\n function approveMax(address spender) external returns (bool) {\r\n return approve(spender, _totalSupply);\r\n }\r\n\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n override\r\n returns (bool)\r\n {\r\n return _transferFrom(msg.sender, recipient, amount);\r\n }\r\n\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external override returns (bool) {\r\n if (_allowances[sender][msg.sender] != _totalSupply) {\r\n _allowances[sender][msg.sender] = _allowances[sender][msg.sender]\r\n .sub(amount, \"Insufficient Allowance\");\r\n }\r\n\r\n return _transferFrom(sender, recipient, amount);\r\n }\r\n\r\n function _transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) internal returns (bool) {\r\n if (!isTxLimitExempt[sender] && !isTxLimitExempt[recipient]) {\r\n // trading disable till launch\r\n if (!tradingOpen) {\r\n require(\r\n sender != pair && recipient != pair,\r\n \"Trading is not enabled yet\"\r\n );\r\n }\r\n\r\n require(amount <= maxTxAmount, \"TX Limit Exceeded\");\r\n }\r\n\r\n if (inSwap) {\r\n return _basicTransfer(sender, recipient, amount);\r\n }\r\n\r\n if (balanceOf(recipient) == 0 && !isLotteryExempt[recipient]) {\r\n holders.push(recipient);\r\n }\r\n\r\n if (shouldSwapBack()) {\r\n swapBack();\r\n }\r\n\r\n _balances[sender] = _balances[sender].sub(\r\n amount,\r\n \"Insufficient Balance\"\r\n );\r\n uint256 amountReceived;\r\n if (\r\n isFeeExempt[sender] ||\r\n isFeeExempt[recipient] ||\r\n (sender != pair && recipient != pair)\r\n ) {\r\n amountReceived = amount;\r\n } else {\r\n amountReceived = takeFee(sender, amount);\r\n\r\n if (sender == pair) {\r\n // reward fee increment handler\r\n if (rewardFee < maxIncFeePercent) {\r\n rewardFee = incFeePercent;\r\n } else {\r\n rewardFee = initialRewardFee;\r\n // lottery handler\r\n if (isLotteryEnable) {\r\n address winner;\r\n bool winnerFound = true;\r\n while (winnerFound) {\r\n uint256 winnerIndex = luckyDraw(\r\n 0,\r\n holders.length,\r\n amount\r\n );\r\n winner = holders[winnerIndex];\r\n if (\r\n balanceOf(winner) > 0 &&\r\n !isLotteryExempt[winner]\r\n ) {\r\n winnerFound = false;\r\n }\r\n }\r\n winners.push(winner);\r\n if (lotteryFeeCount > 0) {\r\n giveLottery(winner);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n _balances[recipient] = _balances[recipient].add(amountReceived);\r\n\r\n if (!isDividendExempt[sender]) {\r\n try distributor.setShare(sender, _balances[sender]) {} catch {}\r\n }\r\n if (!isDividendExempt[recipient]) {\r\n try\r\n distributor.setShare(recipient, _balances[recipient])\r\n {} catch {}\r\n }\r\n\r\n try distributor.process(distributorGas) {} catch {}\r\n\r\n emit Transfer(sender, recipient, amountReceived);\r\n return true;\r\n }\r\n\r\n function _basicTransfer(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) internal returns (bool) {\r\n _balances[sender] = _balances[sender].sub(\r\n amount,\r\n \"Insufficient Balance\"\r\n );\r\n _balances[recipient] = _balances[recipient].add(amount);\r\n emit Transfer(sender, recipient, amount);\r\n return true;\r\n }\r\n\r\n function takeFee(address sender, uint256 amount)\r\n internal\r\n returns (uint256)\r\n {\r\n uint256 feeAmount = amount.mul(rewardFee.add(marketFee).add(lotteryFee)).div(feeDenominator);\r\n lotteryFeeCount = lotteryFeeCount.add(amount.mul(lotteryFee).div(feeDenominator));\r\n _balances[address(this)] = _balances[address(this)].add(feeAmount);\r\n emit Transfer(sender, address(this), feeAmount);\r\n\r\n return amount.sub(feeAmount);\r\n }\r\n\r\n function shouldSwapBack() internal view returns (bool) {\r\n return\r\n msg.sender != pair &&\r\n !inSwap &&\r\n swapEnabled &&\r\n _balances[address(this)] >= swapThreshold;\r\n }\r\n\r\n function swapBack() internal swapping {\r\n uint256 amountToSwap = swapThreshold.sub(lotteryFeeCount);\r\n uint256 totalFee = rewardFee.add(marketFee);\r\n\r\n address[] memory path = new address[](2);\r\n path[0] = address(this);\r\n path[1] = WBNB;\r\n uint256 balanceBefore = address(this).balance;\r\n\r\n router.swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n amountToSwap,\r\n 0,\r\n path,\r\n address(this),\r\n block.timestamp\r\n );\r\n\r\n uint256 amountBNB = address(this).balance.sub(balanceBefore);\r\n\r\n uint256 amountBNBReflection = amountBNB.mul(rewardFee).div(\r\n totalFee\r\n );\r\n uint256 amountBNBMarketing = amountBNB.mul(marketFee).div(\r\n totalFee\r\n );\r\n\r\n try distributor.deposit{value: amountBNBReflection}() {} catch {}\r\n payable(marketFeeReceiver).transfer(amountBNBMarketing);\r\n\r\n }\r\n\r\n function luckyDraw(\r\n uint256 from,\r\n uint256 to,\r\n uint256 amount\r\n ) private view returns (uint256) {\r\n uint256 seed = uint256(\r\n keccak256(\r\n abi.encodePacked(\r\n block.timestamp \r\n block.difficulty \r\n ((\r\n uint256(keccak256(abi.encodePacked(block.coinbase)))\r\n ) / (block.timestamp)) \r\n block.gaslimit \r\n ((uint256(keccak256(abi.encodePacked(msg.sender)))) /\r\n (block.timestamp)) \r\n block.number \r\n amount\r\n )\r\n )\r\n );\r\n return seed.mod(to - from) from;\r\n }\r\n\r\n function giveLottery(address winner) internal {\r\n _balances[address(this)] = _balances[address(this)].sub(lotteryFeeCount);\r\n _balances[winner] = _balances[winner].add(lotteryFeeCount);\r\n emit Transfer(address(this), winner, lotteryFeeCount);\r\n lotteryFeeCount = 0;\r\n }\r\n\r\n function launched() internal view returns (bool) {\r\n return launchedAt != 0;\r\n }\r\n\r\n function launch() public onlyOwner {\r\n require(launchedAt == 0, \"Already launched boi\");\r\n launchedAt = block.number;\r\n launchedAtTimestamp = block.timestamp;\r\n tradingOpen = true;\r\n swapEnabled = true;\r\n }\r\n\r\n function setTxLimit(uint256 amount) external onlyOwner {\r\n require(amount >= _totalSupply / 1000);\r\n maxTxAmount = amount;\r\n }\r\n\r\n function setIsDividendExempt(address holder, bool exempt)\r\n external\r\n onlyOwner\r\n {\r\n require(holder != address(this) && holder != pair);\r\n isDividendExempt[holder] = exempt;\r\n if (exempt) {\r\n distributor.setShare(holder, 0);\r\n } else {\r\n distributor.setShare(holder, _balances[holder]);\r\n }\r\n }\r\n\r\n function setIsFeeExempt(address holder, bool exempt) external onlyOwner {\r\n isFeeExempt[holder] = exempt;\r\n }\r\n\r\n function setIsLotteryExempt(address holder, bool exempt) external onlyOwner {\r\n isLotteryExempt[holder] = exempt;\r\n }\r\n\r\n function setIsTxLimitExempt(address holder, bool exempt)\r\n external\r\n onlyOwner\r\n {\r\n isTxLimitExempt[holder] = exempt;\r\n }\r\n\r\n function setFees(\r\n uint256 _lotteryFee,\r\n uint256 _rewardFee,\r\n uint256 _marketFee,\r\n uint256 _feeDenominator\r\n ) external onlyOwner {\r\n lotteryFee = _lotteryFee;\r\n initialRewardFee = _rewardFee;\r\n marketFee = _marketFee;\r\n feeDenominator = _feeDenominator;\r\n }\r\n\r\n function setFeeReceivers(\r\n address _autoLiquidityReceiver,\r\n address _marketFeeReceiver\r\n ) external onlyOwner {\r\n autoLiquidityReceiver = _autoLiquidityReceiver;\r\n marketFeeReceiver = _marketFeeReceiver;\r\n }\r\n\r\n function setSwapBackSettings(bool _enabled, uint256 _amount)\r\n external\r\n onlyOwner\r\n {\r\n swapEnabled = _enabled;\r\n swapThreshold = _amount;\r\n }\r\n\r\n function setDistributionCriteria(\r\n uint256 _minPeriod,\r\n uint256 _minDistribution\r\n ) external onlyOwner {\r\n distributor.setDistributionCriteria(_minPeriod, _minDistribution);\r\n }\r\n\r\n function setDistributorSettings(uint256 gas) external onlyOwner {\r\n require(gas < 750000);\r\n distributorGas = gas;\r\n }\r\n // owner can remove stuck tokens in case of any issue\r\n function removeStuckToken(address _token, uint256 _amount)\r\n external\r\n onlyOwner\r\n {\r\n IBEP20(_token).transfer(owner, _amount);\r\n }\r\n\r\n\r\n function claimDividend() external {\r\n distributor.claimDividend(msg.sender);\r\n }\r\n\r\n function getPaidDividend(address shareholder)\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n return distributor.getPaidEarnings(shareholder);\r\n }\r\n\r\n function getUnpaidDividend(address shareholder)\r\n external\r\n view\r\n returns (uint256)\r\n {\r\n return distributor.getUnpaidEarnings(shareholder);\r\n }\r\n\r\n function getTotalDistributedDividend() external view returns (uint256) {\r\n return distributor.totalDistributed();\r\n }\r\n\r\n function enableOrDisableLottery(bool _state) external onlyOwner {\r\n isLotteryEnable = _state;\r\n }\r\n\r\n function chnageIncrementInFee(uint256 _incFeePercent, uint256 _maxIncFee)external onlyOwner{\r\n incFeePercent = _incFeePercent;\r\n maxIncFeePercent = _maxIncFee;\r\n }\r\n}\r\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}