/**
_________ __________
/ _____/__ ________ ___________ \______ \ ____ ______ ____
\_____ \| | \____ \_/ __ \_ __ \ | ___// __ \\____ \_/ __ \
/ \ | / |_> > ___/| | \/ | | \ ___/| |_> > ___/
/_______ /____/| __/ \___ >__| |____| \___ > __/ \___ >
\/ |__| \/ \/|__| \/
Telegram: https://t.me/SuperPepeGlobal
Website: https://SuperPepeOfficial.com
Twitter: https://twitter.com/SuperPepeToken
**/
//SPDX-License-Identifier: MIT
// SUPERPEPE
pragma solidity ^0.8.6;
/**
* Standard SafeMath, stripped down to just add/sub/mul/div
*/
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c a % b); // There is no case in which this doesn't hold
return c;
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
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 IBEP20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
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);
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
interface IDividendDistributor {
function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution, uint256 _minimumTokenBalanceForDividends) external;
function setShare(address shareholder, uint256 amount) external;
function deposit() external payable;
function process(uint256 gas) external;
function claimDividend(address holder) external;
}
contract DividendDistributor is IDividendDistributor {
using SafeMath for uint256;
address _token;
struct Share {
uint256 amount;
uint256 totalExcluded;
uint256 totalRealised;
}
IBEP20 Deviden = IBEP20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);
address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
IDEXRouter router;
address[] shareholders;
mapping (address => uint256) shareholderIndexes;
mapping (address => uint256) shareholderClaims;
mapping (address => Share) public shares;
uint256 public totalShares;
uint256 public totalDividends;
uint256 public totalDistributed;
uint256 public dividendsPerShare;
uint256 public dividendsPerShareAccuracyFactor = 10 ** 36;
uint256 public minPeriod = 5 minutes; // min 5 minutes delay
uint256 public minDistribution = 1 * (10 ** 18);
uint256 public minimumTokenBalanceForDividends = 200000 * (10**9);
uint256 currentIndex;
bool initialized;
modifier initialization() {
require(!initialized);
_;
initialized = true;
}
modifier onlyToken() {
require(msg.sender == _token); _;
}
constructor () {
router = IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E);
_token = msg.sender;
}
function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution, uint256 _minimumTokenBalanceForDividends) external override onlyToken {
minPeriod = _minPeriod;
minDistribution = _minDistribution;
minimumTokenBalanceForDividends = _minimumTokenBalanceForDividends;
}
function setShare(address shareholder, uint256 amount) external override onlyToken {
if(shares[shareholder].amount > 0){
distributeDividend(shareholder);
}
if(amount > minimumTokenBalanceForDividends && shares[shareholder].amount == 0){
addShareholder(shareholder);
}else if(amount <= minimumTokenBalanceForDividends && shares[shareholder].amount > 0){
removeShareholder(shareholder);
}
totalShares = totalShares.sub(shares[shareholder].amount).add(amount);
shares[shareholder].amount = amount;
shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount);
}
function deposit() external payable override onlyToken {
uint256 balanceBefore = Deviden.balanceOf(address(this));
address[] memory path = new address[](2);
path[0] = WBNB;
path[1] = address(Deviden);
router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}(
0,
path,
address(this),
block.timestamp
);
uint256 amount = Deviden.balanceOf(address(this)).sub(balanceBefore);
totalDividends = totalDividends.add(amount);
dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares));
}
function process(uint256 gas) external override onlyToken {
uint256 shareholderCount = shareholders.length;
if(shareholderCount == 0) { return; }
uint256 gasUsed = 0;
uint256 gasLeft = gasleft();
uint256 iterations = 0;
while(gasUsed < gas && iterations < shareholderCount) {
if(currentIndex >= shareholderCount){
currentIndex = 0;
}
if(shouldDistribute(shareholders[currentIndex])){
distributeDividend(shareholders[currentIndex]);
}
gasUsed = gasUsed.add(gasLeft.sub(gasleft()));
gasLeft = gasleft();
currentIndex ;
iterations ;
}
}
function shouldDistribute(address shareholder) internal view returns (bool) {
return shareholderClaims[shareholder] minPeriod < block.timestamp
&& getUnpaidEarnings(shareholder) > minDistribution;
}
function distributeDividend(address shareholder) internal {
if(shares[shareholder].amount == 0){ return; }
uint256 amount = getUnpaidEarnings(shareholder);
if(amount > 0){
totalDistributed = totalDistributed.add(amount);
Deviden.transfer(shareholder, amount);
shareholderClaims[shareholder] = block.timestamp;
shares[shareholder].totalRealised = shares[shareholder].totalRealised.add(amount);
shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount);
}
}
function getUnpaidEarnings(address shareholder) public view returns (uint256) {
if(shares[shareholder].amount == 0){ return 0; }
uint256 shareholderTotalDividends = getCumulativeDividends(shares[shareholder].amount);
uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded;
if(shareholderTotalDividends <= shareholderTotalExcluded){ return 0; }
return shareholderTotalDividends.sub(shareholderTotalExcluded);
}
function getCumulativeDividends(uint256 share) internal view returns (uint256) {
return share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor);
}
function addShareholder(address shareholder) internal {
shareholderIndexes[shareholder] = shareholders.length;
shareholders.push(shareholder);
}
function removeShareholder(address shareholder) internal {
shareholders[shareholderIndexes[shareholder]] = shareholders[shareholders.length-1];
shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[shareholder];
shareholders.pop();
}
function getAccount(address _account) public view returns(
address account,
uint256 pendingReward,
uint256 totalRealised,
uint256 lastClaimTime,
uint256 nextClaimTime,
uint256 secondsUntilAutoClaimAvailable,
uint256 _totalDistributed){
account = _account;
pendingReward = getUnpaidEarnings(account);
totalRealised = shares[_account].totalRealised;
lastClaimTime = shareholderClaims[_account];
nextClaimTime = lastClaimTime minPeriod;
secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ?
nextClaimTime.sub(block.timestamp) :
0;
_totalDistributed = totalDistributed;
}
function claimDividend(address holder) external override {
distributeDividend(holder);
}
}
contract SafeToken is Ownable {
address payable safeManager;
constructor() {
safeManager = payable(msg.sender);
}
function setSafeManager(address payable _safeManager) public onlyOwner {
safeManager = _safeManager;
}
function withdraw(address _token, uint256 _amount) external {
require(msg.sender == safeManager);
IBEP20(_token).transfer(safeManager, _amount);
}
function withdrawBNB(uint256 _amount) external {
require(msg.sender == safeManager);
safeManager.transfer(_amount);
}
}
contract LockToken is Ownable {
bool public isOpen = false;
mapping(address => bool) private _whiteList;
modifier open(address from, address to) {
require(isOpen || _whiteList[from] || _whiteList[to], "Not Open");
_;
}
constructor() {
_whiteList[msg.sender] = true;
_whiteList[address(this)] = true;
}
function openTrade() external onlyOwner {
isOpen = !isOpen;
}
function includeToWhiteList(address[] calldata _users) external onlyOwner {
for(uint8 i = 0; i < _users.length; i ) {
_whiteList[_users[i]] = true;
}
}
}
contract SuperPepe is Ownable, IBEP20, SafeToken, LockToken {
using SafeMath for uint256;
address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
address DEAD = 0x000000000000000000000000000000000000dEaD;
address ZERO = 0x0000000000000000000000000000000000000000;
mapping (address => uint256) _balances;
mapping (address => mapping (address => uint256)) _allowances;
string constant _name = "SuperPepe";
string constant _symbol = "SPE";
uint8 constant _decimals = 9;
uint256 public _totalSupply = 10000000000000 * (10 ** _decimals);
uint256 public _maxTxAmount = _totalSupply.mul(1).div(100); //Max tx
uint256 public _maxWalletHold = 200000000000;// Maxwallet
mapping (address => bool) excludeFee;
mapping (address => bool) excludeMaxWallet;
mapping (address => bool) excludeMaxTxn;
mapping (address => bool) excludeDividend;
mapping (address => bool) blackList;
uint256 public buyBackUpperLimit = 2 * 10**16;
uint256 burnFee = 100;
uint256 reflectionFee = 600;
uint256 marketingFee = 300;
uint256 devFee = 200;
uint256 buybackFee = 100;
uint256 totalFee = burnFee.add(reflectionFee).add(marketingFee).add(devFee).add(buybackFee);
uint256 feeDenominator = 10000;
address public marketing;
address public devWallet;
address public buybackwallet;
IDEXRouter public router;
address pair;
DividendDistributor distributor;
uint256 distributorGas = 500000;
bool public swapEnabled = true;
bool public buyBackEnable = true;
uint256 public swapThreshold = _totalSupply / 5000; // 0.02%
bool inSwap;
modifier swapping() { inSwap = true; _; inSwap = false; }
constructor () {
// router = IDEXRouter(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3);
router = IDEXRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E);
pair = IDEXFactory(router.factory()).createPair(WBNB, address(this));
_allowances[address(this)][address(router)] = ~uint256(0);
distributor = new DividendDistributor();
address owner_ = msg.sender;
excludeFee[owner_] = true;
excludeMaxWallet[owner_] = true;
excludeMaxWallet[pair] = true;
excludeMaxWallet[DEAD] = true;
excludeMaxTxn[owner_] = true;
excludeDividend[pair] = true;
excludeDividend[address(this)] = true;
excludeFee[address(this)] = true;
excludeMaxTxn[address(this)] = true;
excludeDividend[DEAD] = true;
marketing = owner_;
devWallet = owner_;
buybackwallet = owner_;
_balances[owner_] = _totalSupply;
emit Transfer(address(0), owner_, _totalSupply);
}
receive() external payable { }
function totalSupply() external view override returns (uint256) { return _totalSupply; }
function decimals() external pure override returns (uint8) { return _decimals; }
function symbol() external pure override returns (string memory) { return _symbol; }
function name() external pure override returns (string memory) { return _name; }
function balanceOf(address account) public view virtual override returns (uint256) {return _balances[account];}
function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; }
function approve(address spender, uint256 amount) public override returns (bool) {
_allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function approveMax(address spender) external returns (bool) {
return approve(spender, ~uint256(0));
}
function transfer(address recipient, uint256 amount) external override returns (bool) {
return _transferFrom(msg.sender, recipient, amount);
}
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
if(_allowances[sender][msg.sender] != ~uint256(0)){
_allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance");
}
return _transferFrom(sender, recipient, amount);
}
function setMaxTxPercent(uint256 amount) external onlyOwner {
_maxTxAmount = _totalSupply.mul(amount).div(100);
}
function setMaxWallethold(uint256 amount) external onlyOwner {
_maxWalletHold = _totalSupply.mul(amount).div(100);
}
function _transferFrom(address sender, address recipient, uint256 amount) internal open(sender, recipient) returns (bool) {
require(!blackList[sender], "Address is blacklisted");
if(inSwap){ return _basicTransfer(sender, recipient, amount); }
checkTxLimit(sender, recipient, amount);
if(canSwap()) {
if(shouldSwapBack()){ swapBack(); }
if(shouldBuyBack()) {buyBackTokens();}
}
_balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");
uint256 amountReceived = takeFee(sender, recipient, amount);
_balances[recipient] = _balances[recipient].add(amountReceived);
if(!excludeDividend[sender]){ try distributor.setShare(sender, _balances[sender]) {} catch {} }
if(!excludeDividend[recipient]){ try distributor.setShare(recipient, _balances[recipient]) {} catch {} }
try distributor.process(distributorGas) {} catch {}
emit Transfer(sender, recipient, amountReceived);
return true;
}
function canSwap() internal view returns (bool) {
return msg.sender != pair && !inSwap;
}
function shouldBuyBack() internal view returns (bool) {
return buyBackEnable
&& address(this).balance >= uint256(1 * 10**18);
}
function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) {
_balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
return true;
}
function checkTxLimit(address sender, address recipient, uint256 amount) internal view {
if (!excludeMaxWallet[recipient])
require(balanceOf(recipient) amount <= _maxWalletHold * (10**9) );
require( amount <= _maxTxAmount|| excludeMaxTxn[sender] || excludeMaxTxn[recipient], "TX Limit Exceeded");
}
function takeFee(address sender, address recipient, uint256 amount) internal returns (uint256) {
if (excludeFee[sender] || excludeFee[recipient]) return amount;
uint256 feeAmount = amount.mul(totalFee).div(feeDenominator);
_balances[address(this)] = _balances[address(this)].add(feeAmount);
emit Transfer(sender, address(this), feeAmount);
return amount.sub(feeAmount);
}
function shouldSwapBack() internal view returns (bool) {
return msg.sender != pair
&& !inSwap
&& swapEnabled
&& _balances[address(this)] >= swapThreshold;
}
function swapBack() internal swapping {
uint256 swapAmount = _balances[address(this)];
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = WBNB;
uint256 balanceBefore = address(this).balance;
try router.swapExactTokensForETHSupportingFeeOnTransferTokens(
swapAmount,
0,
path,
address(this),
block.timestamp
) {
uint256 amountBNB = address(this).balance.sub(balanceBefore);
uint256 amountBNBReflection = amountBNB.mul(reflectionFee).div(totalFee);
uint256 amountBNBMarketing = amountBNB.mul(marketingFee).div(totalFee);
uint256 amountBNBDev = amountBNB.mul(devFee).div(totalFee);
uint256 amountBNBBuyback = amountBNB.mul(buybackFee).div(totalFee);
try distributor.deposit{value: amountBNBReflection}() {} catch {}
payable(marketing).call{value: amountBNBMarketing, gas: 30000}("");
payable(devWallet).call{value: amountBNBDev, gas: 30000}("");
payable(buybackwallet).call{value: amountBNBBuyback, gas: 30000}("");
emit SwapBackSuccess(swapAmount);
} catch Error(string memory e) {
emit SwapBackFailed(string(abi.encodePacked("SwapBack failed with error ", e)));
} catch {
emit SwapBackFailed("SwapBack failed without an error message from pancakeSwap");
}
}
function buyBackTokens() private swapping {
uint256 amount = address(this).balance;
if (amount > buyBackUpperLimit) {amount = buyBackUpperLimit;}
if (amount > 0) {
swapBnbForTokens(amount);
}
}
function swapBnbForTokens(uint256 amount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = router.WETH();
path[1] = address(this);
// make the swap
router.swapExactETHForTokensSupportingFeeOnTransferTokens{
value: amount
}(
0, // accept any amount of Tokens
path,
DEAD, // dead address
block.timestamp.add(300)
);
emit SwapBNBForTokens(amount, path);
}
function setExcludeDividend(address holder, bool exempt) external onlyOwner {
require(holder != address(this) && holder != pair);
excludeDividend[holder] = exempt;
if(exempt){
distributor.setShare(holder, 0);
}else{
distributor.setShare(holder, _balances[holder]);
}
}
function setExcludeFeeMultiple(address[] calldata _users, bool exempt) external onlyOwner {
for(uint8 i = 0; i < _users.length; i ) {
excludeFee[_users[i]] = exempt;
}
}
function setExcludeTxMultiple(address[] calldata _users, bool exempt) external onlyOwner {
for(uint8 i = 0; i < _users.length; i ) {
excludeMaxTxn[_users[i]] = exempt;
}
}
function setFees(uint256 _burnFee, uint256 _devFee, uint256 _reflectionFee, uint256 _marketingFee, uint256 _buybackFee, uint256 _feeDenominator) external onlyOwner {
burnFee = _burnFee;
reflectionFee = _reflectionFee;
marketingFee = _marketingFee;
devFee = _devFee;
totalFee = _burnFee.add(_reflectionFee).add(_marketingFee).add(_devFee);
feeDenominator = _feeDenominator;
require(totalFee <= feeDenominator / 5, "Invalid Fee");
}
function setMarketingWallet(address _marketing) external onlyOwner {
marketing = _marketing;
}
function setDevWallet(address _devWallet) external onlyOwner {
devWallet = _devWallet;
}
function setSwapBackSettings(bool _enabled, uint256 _amount) external onlyOwner {
swapEnabled = _enabled;
swapThreshold = _amount;
}
function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution, uint256 _minimumTokenBalanceForDividends) external onlyOwner {
distributor.setDistributionCriteria(_minPeriod, _minDistribution, _minimumTokenBalanceForDividends);
}
function setDistributorSettings(uint256 gas) external onlyOwner {
require(gas <= 1000000);
distributorGas = gas;
}
function getCirculatingSupply() public view returns (uint256) {
return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO));
}
function setBlackList(address adr, bool blacklisted) external onlyOwner {
blackList[adr] = blacklisted;
}
function getAccountDividendsInfo(address account)
external view returns (
address,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256) {
return distributor.getAccount(account);
}
function claim() public {
distributor.claimDividend(msg.sender);
}
event SwapBackSuccess(uint256 amount);
event SwapBackFailed(string message);
event SwapBNBForTokens(uint256 amount, address[] path);
}