// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)pragmasolidity ^0.8.0;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
Contract Source Code
File 2 of 7: IERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransfer(address to, uint256 amount) externalreturns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/functionapprove(address spender, uint256 amount) externalreturns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransferFrom(addressfrom, address to, uint256 amount) externalreturns (bool);
}
//SPDX-License-Identifier: MITpragmasolidity ^0.8.14;import"@openzeppelin/contracts/access/Ownable.sol";
import"@openzeppelin/contracts/token/ERC20/IERC20.sol";
import"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
contractPOGEXisIERC20, Ownable{
address DEAD =0x000000000000000000000000000000000000dEaD;
address ZERO =0x0000000000000000000000000000000000000000;
stringconstant _name ="PogeX";
stringconstant _symbol ="POGEX";
uint8constant _decimals =18;
uint256 _totalSupply =1000000000* (10** _decimals); // One hundred billionsmapping(address=>uint256) _balances;
mapping(address=>mapping(address=>uint256)) _allowances;
mapping(address=>bool) public isFeeExempt;
mapping(address=>bool) public isAuthorized;
addresspublic marketingWallet;
// Feesuint256public buyLiquidityFee =1;
uint256public buyMarketingFee =2;
uint256public buyTotalFee =3;
uint256public sellLiquidityFee =1;
uint256public sellMarketingFee =2;
uint256public sellTotalFee =3;
IUniswapV2Router02 public router;
addresspublic pair;
boolpublic getTransferFees =true;
uint256public swapThreshold = (_totalSupply *1) /10000; // 0.001% of supplyboolpublic contractSwapEnabled =true;
boolpublic isTradeEnabled =false;
bool inContractSwap;
modifierswapping() {
inContractSwap =true;
_;
inContractSwap =false;
}
eventSetIsFeeExempt(address holder, bool status);
eventAddAuthorizedWallet(address holder, bool status);
eventSetDoContractSwap(bool status);
eventDoContractSwap(uint256 amount, uint256 time);
eventAutoLiquify(uint256 amountBNB, uint256 amountBOG);
constructor() {
router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
pair = IUniswapV2Factory(router.factory()).createPair(
router.WETH(),
address(this)
);
_allowances[address(this)][address(router)] =type(uint256).max;
marketingWallet =0xf56eCBc1b59F6B6139CDC85c85FD820A3B71E21c;
address newOwner =0x94308271862C8229f977708d6192274CD64fB7FF;
isFeeExempt[newOwner] =true;
isFeeExempt[address(this)] =true;
isFeeExempt[marketingWallet] =true;
isAuthorized[newOwner] =true;
isAuthorized[pair] =true;
isAuthorized[address(this)] =true;
isAuthorized[ZERO] =true;
isAuthorized[DEAD] =true;
isAuthorized[marketingWallet] =true;
_balances[newOwner] = _totalSupply;
emit Transfer(address(0), newOwner, _totalSupply);
transferOwnership(newOwner);
}
receive() externalpayable{}
functiontotalSupply() externalviewoverridereturns (uint256) {
return _totalSupply;
}
functionname() publicpurereturns (stringmemory) {
return _name;
}
functionsymbol() publicpurereturns (stringmemory) {
return _symbol;
}
functiondecimals() publicpurereturns (uint8) {
return _decimals;
}
functionbalanceOf(address account) publicviewoverridereturns (uint256) {
return _balances[account];
}
functionallowance(address holder,
address spender
) externalviewoverridereturns (uint256) {
return _allowances[holder][spender];
}
functionapprove(address spender,
uint256 amount
) publicoverridereturns (bool) {
_allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
returntrue;
}
function_approve(address owner,
address spender,
uint256 amount
) internalvirtual{
require(owner !=address(0), "ERC20: approve from the zero address");
require(spender !=address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
functionapproveMax(address spender) externalreturns (bool) {
return approve(spender, type(uint256).max);
}
functiontransfer(address recipient,
uint256 amount
) externaloverridereturns (bool) {
return _transferFrom(msg.sender, recipient, amount);
}
functiontransferFrom(address sender,
address recipient,
uint256 amount
) externaloverridereturns (bool) {
if (_allowances[sender][msg.sender] !=type(uint256).max) {
require(
_allowances[sender][msg.sender] >= amount,
"Insufficient Allowance"
);
_allowances[sender][msg.sender] =
_allowances[sender][msg.sender] -
amount;
}
return _transferFrom(sender, recipient, amount);
}
function_transferFrom(address sender,
address recipient,
uint256 amount
) internalreturns (bool) {
if (!isTradeEnabled) require(isAuthorized[sender], "Trading disabled");
if (inContractSwap) {
return _basicTransfer(sender, recipient, amount);
}
if (shouldDoContractSwap()) {
doContractSwap();
}
require(_balances[sender] >= amount, "Insufficient Balance");
_balances[sender] = _balances[sender] - amount;
uint256 amountReceived = shouldTakeFee(sender, recipient)
? takeFee(sender, recipient, amount)
: amount;
_balances[recipient] = _balances[recipient] + amountReceived;
emit Transfer(sender, recipient, amountReceived);
returntrue;
}
functionshouldDoContractSwap() internalviewreturns (bool) {
return (msg.sender!= pair &&!inContractSwap &&
contractSwapEnabled &&
sellTotalFee >0&&
_balances[address(this)] >= swapThreshold);
}
functiontakeFee(address sender,
address recipient,
uint256 amount
) internalreturns (uint256) {
uint256 feeToken;
if (recipient == pair) feeToken = (amount * sellTotalFee) /100;
else feeToken = (amount * buyTotalFee) /100;
_balances[address(this)] = _balances[address(this)] + feeToken;
emit Transfer(sender, address(this), feeToken);
return (amount - feeToken);
}
function_basicTransfer(address sender,
address recipient,
uint256 amount
) internalreturns (bool) {
require(_balances[sender] >= amount, "Insufficient Balance");
_balances[sender] = _balances[sender] - amount;
_balances[recipient] = _balances[recipient] + amount;
emit Transfer(sender, recipient, amount);
returntrue;
}
functionshouldTakeFee(address sender,
address to
) internalviewreturns (bool) {
if (!getTransferFees) {
if (sender != pair && to != pair) returnfalse;
}
if (isFeeExempt[sender] || isFeeExempt[to]) {
returnfalse;
} else {
returntrue;
}
}
functionisFeeExcluded(address _wallet) publicviewreturns (bool) {
return isFeeExempt[_wallet];
}
functiondoContractSwap() internalswapping{
uint256 contractTokenBalance = _balances[address(this)];
uint256 tokensToLp = (contractTokenBalance * sellLiquidityFee) /
sellTotalFee;
uint256 marketingFee = contractTokenBalance - tokensToLp;
if (marketingFee >0) {
swapTokensForEth(marketingFee);
uint256 swappedTokens =address(this).balance;
if (swappedTokens >0)
payable(marketingWallet).transfer(swappedTokens);
}
if (tokensToLp >0) swapAndLiquify(tokensToLp);
}
// All tax wallets receive BUSD instead of BNBfunctionswapTokensForTokens(uint256 tokenAmount,
address tokenToSwap
) private{
address[] memory path =newaddress[](3);
path[0] =address(this);
path[1] = router.WETH();
path[2] = tokenToSwap;
_approve(address(this), address(router), tokenAmount);
router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of tokens
path,
address(this),
block.timestamp
);
}
functionswapAndLiquify(uint256 tokens) private{
// split the contract balance into halvesuint256 half = tokens /2;
uint256 otherHalf = tokens - half;
// capture the contract's current ETH balance.// this is so that we can capture exactly the amount of ETH that the// swap creates, and not make the liquidity event include any ETH that// has been manually sent to the contractuint256 initialBalance =address(this).balance;
// swap tokens for ETH
swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered// how much ETH did we just swap into?uint256 newBalance =address(this).balance- initialBalance;
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit AutoLiquify(newBalance, otherHalf);
}
functionswapTokensForEth(uint256 tokenAmount) private{
// generate the uniswap pair path of token -> wethaddress[] memory path =newaddress[](2);
path[0] =address(this);
path[1] = router.WETH();
_approve(address(this), address(router), tokenAmount);
// make the swap
router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
functionaddLiquidity(uint256 tokenAmount, uint256 bnbAmount) private{
_approve(address(this), address(router), tokenAmount);
// add the liquidity
router.addLiquidityETH{value: bnbAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable0, // slippage is unavoidable
DEAD,
block.timestamp
);
}
functionsetIsFeeExempt(address holder, bool exempt) externalonlyOwner{
isFeeExempt[holder] = exempt;
emit SetIsFeeExempt(holder, exempt);
}
functionsetDoContractSwap(bool _enabled) externalonlyOwner{
contractSwapEnabled = _enabled;
emit SetDoContractSwap(_enabled);
}
functionchangeMarketingWallet(address _wallet) externalonlyOwner{
marketingWallet = _wallet;
}
functionchangeBuyFees(uint256 _liquidityFee,
uint256 _marketingFee
) externalonlyOwner{
buyLiquidityFee = _liquidityFee;
buyMarketingFee = _marketingFee;
buyTotalFee = _liquidityFee + _marketingFee;
require(buyTotalFee <=10, "Total fees can not greater than 10%");
}
functionchangeSellFees(uint256 _liquidityFee,
uint256 _marketingFee
) externalonlyOwner{
sellLiquidityFee = _liquidityFee;
sellMarketingFee = _marketingFee;
sellTotalFee = _liquidityFee + _marketingFee;
require(sellTotalFee <=10, "Total fees can not greater than 10%");
}
functionenableTrading() externalonlyOwner{
isTradeEnabled =true;
}
functionsetAuthorizedWallets(address _wallet,
bool _status
) externalonlyOwner{
isAuthorized[_wallet] = _status;
}
functionrescueEth() externalonlyOwner{
uint256 balance =address(this).balance;
require(balance >0, "No enough ETH to transfer");
payable(msg.sender).transfer(balance);
}
functionchangeGetFeesOnTransfer(bool _status) externalonlyOwner{
getTransferFees = _status;
}
}
Contract Source Code
File 7 of 7: Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)pragmasolidity ^0.8.0;import"../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/abstractcontractOwnableisContext{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
require(newOwner !=address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}