|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.10;
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract Context {
|
|
function _msgSender() internal view virtual returns (address) {
|
|
return msg.sender;
|
|
}
|
|
|
|
function _msgData() internal view virtual returns (bytes calldata) {
|
|
return msg.data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract Ownable is Context {
|
|
address private _owner;
|
|
|
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
_transferOwnership(_msgSender());
|
|
}
|
|
|
|
|
|
|
|
|
|
function owner() public view virtual returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner() {
|
|
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
|
_;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renounceOwnership() public virtual onlyOwner {
|
|
_transferOwnership(address(0));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
_transferOwnership(newOwner);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _transferOwnership(address newOwner) internal virtual {
|
|
address oldOwner = _owner;
|
|
_owner = newOwner;
|
|
emit OwnershipTransferred(oldOwner, newOwner);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC20 {
|
|
|
|
|
|
|
|
function totalSupply() external view returns (uint256);
|
|
|
|
/**
|
|
* @dev Returns the amount of tokens owned by `account`.
|
|
*/
|
|
function balanceOf(address account) external view returns (uint256);
|
|
|
|
/**
|
|
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
|
*
|
|
* Returns a boolean value indicating whether the operation succeeded.
|
|
*
|
|
* Emits a {Transfer} event.
|
|
*/
|
|
function transfer(address recipient, uint256 amount) external returns (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.
|
|
*/
|
|
function allowance(address owner, address spender) external view returns (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.
|
|
*/
|
|
function approve(address spender, uint256 amount) external returns (bool);
|
|
|
|
/**
|
|
* @dev Moves `amount` tokens from `sender` to `recipient` 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.
|
|
*/
|
|
function transferFrom(
|
|
address sender,
|
|
address recipient,
|
|
uint256 amount
|
|
) external returns (bool);
|
|
|
|
/**
|
|
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
|
* another (`to`).
|
|
*
|
|
* Note that `value` may be zero.
|
|
*/
|
|
event Transfer(address indexed from, address indexed 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.
|
|
*/
|
|
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC20Metadata is IERC20 {
|
|
|
|
|
|
|
|
function name() external view returns (string memory);
|
|
|
|
/**
|
|
* @dev Returns the symbol of the token.
|
|
*/
|
|
function symbol() external view returns (string memory);
|
|
|
|
/**
|
|
* @dev Returns the decimals places of the token.
|
|
*/
|
|
function decimals() external view returns (uint8);
|
|
}
|
|
|
|
////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
|
|
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
|
|
|
|
/* pragma solidity ^0.8.0; */
|
|
|
|
/* import "./IERC20.sol"; */
|
|
/* import "./extensions/IERC20Metadata.sol"; */
|
|
/* import "../../utils/Context.sol"; */
|
|
|
|
/**
|
|
* @dev Implementation of the {IERC20} interface.
|
|
*
|
|
* This implementation is agnostic to the way tokens are created. This means
|
|
* that a supply mechanism has to be added in a derived contract using {_mint}.
|
|
* For a generic mechanism see {ERC20PresetMinterPauser}.
|
|
*
|
|
* TIP: For a detailed writeup see our guide
|
|
* https:
|
|
* to implement supply mechanisms].
|
|
*
|
|
* We have followed general OpenZeppelin Contracts guidelines: functions revert
|
|
* instead returning `false` on failure. This behavior is nonetheless
|
|
* conventional and does not conflict with the expectations of ERC20
|
|
* applications.
|
|
*
|
|
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
|
|
* This allows applications to reconstruct the allowance for all accounts just
|
|
* by listening to said events. Other implementations of the EIP may not emit
|
|
* these events, as it isn't required by the specification.
|
|
*
|
|
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
|
|
* functions have been added to mitigate the well-known issues around setting
|
|
* allowances. See {IERC20-approve}.
|
|
*/
|
|
contract ERC20 is Context, IERC20, IERC20Metadata {
|
|
mapping(address => uint256) private _balances;
|
|
|
|
mapping(address => mapping(address => uint256)) private _allowances;
|
|
|
|
uint256 private _totalSupply;
|
|
|
|
string private _name;
|
|
string private _symbol;
|
|
|
|
/**
|
|
* @dev Sets the values for {name} and {symbol}.
|
|
*
|
|
* The default value of {decimals} is 18. To select a different value for
|
|
* {decimals} you should overload it.
|
|
*
|
|
* All two of these values are immutable: they can only be set once during
|
|
* construction.
|
|
*/
|
|
constructor(string memory name_, string memory symbol_) {
|
|
_name = name_;
|
|
_symbol = symbol_;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the name of the token.
|
|
*/
|
|
function name() public view virtual override returns (string memory) {
|
|
return _name;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the symbol of the token, usually a shorter version of the
|
|
* name.
|
|
*/
|
|
function symbol() public view virtual override returns (string memory) {
|
|
return _symbol;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the number of decimals used to get its user representation.
|
|
* For example, if `decimals` equals `2`, a balance of `505` tokens should
|
|
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
|
|
*
|
|
* Tokens usually opt for a value of 18, imitating the relationship between
|
|
* Ether and Wei. This is the value {ERC20} uses, unless this function is
|
|
* overridden;
|
|
*
|
|
* NOTE: This information is only used for _display_ purposes: it in
|
|
* no way affects any of the arithmetic of the contract, including
|
|
* {IERC20-balanceOf} and {IERC20-transfer}.
|
|
*/
|
|
function decimals() public view virtual override returns (uint8) {
|
|
return 18;
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-totalSupply}.
|
|
*/
|
|
function totalSupply() public view virtual override returns (uint256) {
|
|
return _totalSupply;
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-balanceOf}.
|
|
*/
|
|
function balanceOf(address account) public view virtual override returns (uint256) {
|
|
return _balances[account];
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-transfer}.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `recipient` cannot be the zero address.
|
|
* - the caller must have a balance of at least `amount`.
|
|
*/
|
|
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
|
|
_transfer(_msgSender(), recipient, amount);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-allowance}.
|
|
*/
|
|
function allowance(address owner, address spender) public view virtual override returns (uint256) {
|
|
return _allowances[owner][spender];
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-approve}.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `spender` cannot be the zero address.
|
|
*/
|
|
function approve(address spender, uint256 amount) public virtual override returns (bool) {
|
|
_approve(_msgSender(), spender, amount);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC20-transferFrom}.
|
|
*
|
|
* Emits an {Approval} event indicating the updated allowance. This is not
|
|
* required by the EIP. See the note at the beginning of {ERC20}.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `sender` and `recipient` cannot be the zero address.
|
|
* - `sender` must have a balance of at least `amount`.
|
|
* - the caller must have allowance for ``sender``'s tokens of at least
|
|
* `amount`.
|
|
*/
|
|
function transferFrom(
|
|
address sender,
|
|
address recipient,
|
|
uint256 amount
|
|
) public virtual override returns (bool) {
|
|
_transfer(sender, recipient, amount);
|
|
|
|
uint256 currentAllowance = _allowances[sender][_msgSender()];
|
|
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
|
|
unchecked {
|
|
_approve(sender, _msgSender(), currentAllowance - amount);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _transfer(
|
|
address sender,
|
|
address recipient,
|
|
uint256 amount
|
|
) internal virtual {
|
|
require(sender != address(0), "ERC20: transfer from the zero address");
|
|
require(recipient != address(0), "ERC20: transfer to the zero address");
|
|
|
|
_beforeTokenTransfer(sender, recipient, amount);
|
|
|
|
uint256 senderBalance = _balances[sender];
|
|
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
|
|
unchecked {
|
|
_balances[sender] = senderBalance - amount;
|
|
}
|
|
_balances[recipient] += amount;
|
|
|
|
emit Transfer(sender, recipient, amount);
|
|
|
|
_afterTokenTransfer(sender, recipient, amount);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _mint(address account, uint256 amount) internal virtual {
|
|
require(account != address(0), "ERC20: mint to the zero address");
|
|
|
|
_beforeTokenTransfer(address(0), account, amount);
|
|
|
|
_totalSupply += amount;
|
|
_balances[account] += amount;
|
|
emit Transfer(address(0), account, amount);
|
|
|
|
_afterTokenTransfer(address(0), account, amount);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _approve(
|
|
address owner,
|
|
address spender,
|
|
uint256 amount
|
|
) internal virtual {
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _beforeTokenTransfer(
|
|
address from,
|
|
address to,
|
|
uint256 amount
|
|
) internal virtual {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _afterTokenTransfer(
|
|
address from,
|
|
address to,
|
|
uint256 amount
|
|
) internal virtual {}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
library SafeMath {
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
|
unchecked {
|
|
if (b > a) return (false, 0);
|
|
return (true, a - b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
|
unchecked {
|
|
|
|
|
|
|
|
if (a == 0) return (true, 0);
|
|
uint256 c = a * b;
|
|
if (c / a != b) return (false, 0);
|
|
return (true, c);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
|
unchecked {
|
|
if (b == 0) return (false, 0);
|
|
return (true, a / b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
|
unchecked {
|
|
if (b == 0) return (false, 0);
|
|
return (true, a % b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a + b;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a - b;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a * b;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a / b;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a % b;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sub(
|
|
uint256 a,
|
|
uint256 b,
|
|
string memory errorMessage
|
|
) internal pure returns (uint256) {
|
|
unchecked {
|
|
require(b <= a, errorMessage);
|
|
return a - b;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function div(
|
|
uint256 a,
|
|
uint256 b,
|
|
string memory errorMessage
|
|
) internal pure returns (uint256) {
|
|
unchecked {
|
|
require(b > 0, errorMessage);
|
|
return a / b;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mod(
|
|
uint256 a,
|
|
uint256 b,
|
|
string memory errorMessage
|
|
) internal pure returns (uint256) {
|
|
unchecked {
|
|
require(b > 0, errorMessage);
|
|
return a % b;
|
|
}
|
|
}
|
|
}
|
|
|
|
interface IUniswapV2Factory {
|
|
event PairCreated(
|
|
address indexed token0,
|
|
address indexed token1,
|
|
address pair,
|
|
uint256
|
|
);
|
|
|
|
function createPair(address tokenA, address tokenB)
|
|
external
|
|
returns (address pair);
|
|
}
|
|
|
|
interface IUniswapV2Router02 {
|
|
function factory() external pure returns (address);
|
|
|
|
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
|
uint256 amountIn,
|
|
uint256 amountOutMin,
|
|
address[] calldata path,
|
|
address to,
|
|
uint256 deadline
|
|
) external;
|
|
}
|
|
|
|
contract PEPEBET is ERC20, Ownable {
|
|
using SafeMath for uint256;
|
|
|
|
IUniswapV2Router02 public immutable uniswapV2Router;
|
|
address public immutable uniswapV2Pair;
|
|
address public constant deadAddress = address(0xdead);
|
|
address public USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
|
|
bool private swapping;
|
|
address public devWallet;
|
|
uint256 public maxTransactionAmount;
|
|
uint256 public swapTokensAtAmount;
|
|
uint256 public maxWallet;
|
|
|
|
bool public limitsInEffect = true;
|
|
bool public tradingActive = false;
|
|
bool public swapEnabled = false;
|
|
|
|
uint256 public buyTotalFees;
|
|
uint256 public buyDevFee;
|
|
|
|
uint256 public sellTotalFees;
|
|
uint256 public sellDevFee;
|
|
|
|
|
|
|
|
|
|
mapping(address => bool) private _isExcludedFromFees;
|
|
mapping(address => bool) public _isExcludedMaxTransactionAmount;
|
|
|
|
event ExcludeFromFees(address indexed account, bool isExcluded);
|
|
|
|
event devWalletUpdated(
|
|
address indexed newWallet,
|
|
address indexed oldWallet
|
|
);
|
|
|
|
constructor() ERC20("PEPE.bet Token", "PEPEBET") {
|
|
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
|
|
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
|
|
);
|
|
|
|
excludeFromMaxTransaction(address(_uniswapV2Router), true);
|
|
uniswapV2Router = _uniswapV2Router;
|
|
|
|
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
|
|
.createPair(address(this), USDC);
|
|
excludeFromMaxTransaction(address(uniswapV2Pair), true);
|
|
|
|
|
|
uint256 _buyDevFee = 5;
|
|
uint256 _sellDevFee = 7;
|
|
|
|
uint256 totalSupply = 100_000_000 * 1e19;
|
|
|
|
maxTransactionAmount = totalSupply * 1 / 100;
|
|
maxWallet = totalSupply * 2 / 100;
|
|
swapTokensAtAmount = (totalSupply * 10) / 10000;
|
|
|
|
buyDevFee = _buyDevFee;
|
|
buyTotalFees = buyDevFee;
|
|
|
|
sellDevFee = _sellDevFee;
|
|
sellTotalFees = sellDevFee;
|
|
|
|
devWallet = address(0x53A21453255910766d952DB76473b41C3913Ac0e);
|
|
excludeFromFees(owner(), true);
|
|
excludeFromFees(address(this), true);
|
|
excludeFromFees(address(0xdead), true);
|
|
|
|
excludeFromMaxTransaction(owner(), true);
|
|
excludeFromMaxTransaction(address(this), true);
|
|
excludeFromMaxTransaction(address(0xdead), true);
|
|
|
|
|
|
|
|
|
|
|
|
_mint(msg.sender, totalSupply);
|
|
}
|
|
|
|
receive() external payable {}
|
|
|
|
|
|
function enableTrading() external onlyOwner {
|
|
tradingActive = true;
|
|
swapEnabled = true;
|
|
}
|
|
|
|
|
|
function removeLimits() external onlyOwner returns (bool) {
|
|
limitsInEffect = false;
|
|
return true;
|
|
}
|
|
|
|
|
|
function updateSwapTokensAtAmount(uint256 newAmount)
|
|
external
|
|
onlyOwner
|
|
returns (bool)
|
|
{
|
|
require(
|
|
newAmount >= (totalSupply() * 1) / 100000,
|
|
"Swap amount cannot be lower than 0.001% total supply."
|
|
);
|
|
require(
|
|
newAmount <= (totalSupply() * 5) / 1000,
|
|
"Swap amount cannot be higher than 0.5% total supply."
|
|
);
|
|
swapTokensAtAmount = newAmount;
|
|
return true;
|
|
}
|
|
|
|
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
|
|
require(
|
|
newNum >= ((totalSupply() * 1) / 1000) / 1e19,
|
|
"Cannot set maxTransactionAmount lower than 0.1%"
|
|
);
|
|
maxTransactionAmount = newNum * (10**19);
|
|
}
|
|
|
|
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
|
|
require(
|
|
newNum >= ((totalSupply() * 5) / 1000) / 1e19,
|
|
"Cannot set maxWallet lower than 0.5%"
|
|
);
|
|
maxWallet = newNum * (10**19);
|
|
}
|
|
|
|
function excludeFromMaxTransaction(address updAds, bool isEx)
|
|
public
|
|
onlyOwner
|
|
{
|
|
_isExcludedMaxTransactionAmount[updAds] = isEx;
|
|
}
|
|
|
|
function updateSwapEnabled(bool enabled) external onlyOwner {
|
|
swapEnabled = enabled;
|
|
}
|
|
|
|
function updateBuyFees(
|
|
uint256 _devFee
|
|
) external onlyOwner {
|
|
buyDevFee = _devFee;
|
|
buyTotalFees = buyDevFee;
|
|
require(buyTotalFees <= 5, "Must keep fees at 5% or less");
|
|
}
|
|
|
|
function updateSellFees(
|
|
uint256 _devFee
|
|
) external onlyOwner {
|
|
sellDevFee = _devFee;
|
|
sellTotalFees = sellDevFee;
|
|
require(sellTotalFees <= 10, "Must keep fees at 10% or less");
|
|
}
|
|
|
|
function excludeFromFees(address account, bool excluded) public onlyOwner {
|
|
_isExcludedFromFees[account] = excluded;
|
|
emit ExcludeFromFees(account, excluded);
|
|
}
|
|
|
|
function updateDevWallet(address newDevWallet)
|
|
external
|
|
onlyOwner
|
|
{
|
|
emit devWalletUpdated(newDevWallet, devWallet);
|
|
devWallet = newDevWallet;
|
|
}
|
|
|
|
|
|
function isExcludedFromFees(address account) public view returns (bool) {
|
|
return _isExcludedFromFees[account];
|
|
}
|
|
|
|
function _transfer(
|
|
address from,
|
|
address to,
|
|
uint256 amount
|
|
) internal override {
|
|
require(from != address(0), "ERC20: transfer from the zero address");
|
|
require(to != address(0), "ERC20: transfer to the zero address");
|
|
|
|
if (amount == 0) {
|
|
super._transfer(from, to, 0);
|
|
return;
|
|
}
|
|
|
|
if (limitsInEffect) {
|
|
if (
|
|
from != owner() &&
|
|
to != owner() &&
|
|
to != address(0) &&
|
|
to != address(0xdead) &&
|
|
!swapping
|
|
) {
|
|
if (!tradingActive) {
|
|
require(
|
|
_isExcludedFromFees[from] || _isExcludedFromFees[to],
|
|
"Trading is not active."
|
|
);
|
|
}
|
|
|
|
|
|
if (
|
|
from == uniswapV2Pair &&
|
|
!_isExcludedMaxTransactionAmount[to]
|
|
) {
|
|
require(
|
|
amount <= maxTransactionAmount,
|
|
"Buy transfer amount exceeds the maxTransactionAmount."
|
|
);
|
|
require(
|
|
amount + balanceOf(to) <= maxWallet,
|
|
"Max wallet exceeded"
|
|
);
|
|
}
|
|
else if (!_isExcludedMaxTransactionAmount[to]) {
|
|
require(
|
|
amount + balanceOf(to) <= maxWallet,
|
|
"Max wallet exceeded"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
uint256 contractTokenBalance = balanceOf(address(this));
|
|
|
|
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
|
|
|
|
if (
|
|
canSwap &&
|
|
swapEnabled &&
|
|
!swapping &&
|
|
to == uniswapV2Pair &&
|
|
!_isExcludedFromFees[from] &&
|
|
!_isExcludedFromFees[to]
|
|
) {
|
|
swapping = true;
|
|
swapBack();
|
|
swapping = false;
|
|
}
|
|
|
|
bool takeFee = !swapping;
|
|
|
|
|
|
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
|
|
takeFee = false;
|
|
}
|
|
|
|
uint256 fees = 0;
|
|
uint256 tokensForDev = 0;
|
|
|
|
if (takeFee) {
|
|
|
|
if (to == uniswapV2Pair && sellTotalFees > 0) {
|
|
fees = amount.mul(sellTotalFees).div(100);
|
|
tokensForDev = (fees * sellDevFee) / sellTotalFees;
|
|
}
|
|
|
|
else if (from == uniswapV2Pair && buyTotalFees > 0) {
|
|
fees = amount.mul(buyTotalFees).div(100);
|
|
tokensForDev = (fees * buyDevFee) / buyTotalFees;
|
|
}
|
|
|
|
if (fees> 0) {
|
|
super._transfer(from, address(this), fees);
|
|
}
|
|
|
|
amount -= fees;
|
|
}
|
|
|
|
super._transfer(from, to, amount);
|
|
}
|
|
|
|
function swapTokensForUSDC(uint256 tokenAmount) private {
|
|
|
|
address[] memory path = new address[](2);
|
|
path[0] = address(this);
|
|
path[1] = USDC;
|
|
|
|
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
|
|
|
|
|
uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
|
tokenAmount,
|
|
0,
|
|
path,
|
|
devWallet,
|
|
block.timestamp
|
|
);
|
|
}
|
|
|
|
function swapBack() private {
|
|
uint256 contractBalance = balanceOf(address(this));
|
|
if (contractBalance == 0) {
|
|
return;
|
|
}
|
|
|
|
if (contractBalance > swapTokensAtAmount * 20) {
|
|
contractBalance = swapTokensAtAmount * 20;
|
|
}
|
|
|
|
swapTokensForUSDC(contractBalance);
|
|
}
|
|
|
|
} |