文件 1 的 7:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 7:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
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;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), 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 _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
文件 3 的 7:ERC20Burnable.sol
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
abstract contract ERC20Burnable is Context, ERC20 {
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
文件 4 的 7:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
}
文件 5 的 7:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 6 的 7:MOJI.sol
pragma solidity 0.8.6;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
contract MOJI is IERC20Metadata, Ownable, ERC20Burnable {
event LPPairSet(address indexed pair, bool enabled);
event LiquidityHolderSet(address indexed account, bool flag);
event FeesLockedForever();
event SniperBotProtectionDisabledForever();
event BlacklistSet(address indexed account, bool flag);
event BlacklistAddRestrictedForever();
event BuyFeeNumeratorSet(uint256 value);
event SellFeeNumeratorSet(uint256 value);
event TreasurySet(address[] treasuryList, uint256[] treasuryShares);
event BuyFeePaid(address indexed from, uint256 amount);
event SellFeePaid(address indexed from, uint256 amount);
struct AccountInfo {
bool isLPPool;
bool isLiquidityHolder;
bool isBlackListed;
}
mapping (address => AccountInfo) public accountInfo;
string constant private _name = "Meme2earN";
string constant private _symbol = "MOJI";
uint256 constant private TOTAL_SUPPLY = 100_000_000 * (10 ** 18);
uint256 constant public DENOMINATOR = 10000;
uint256 constant public MAX_BUY_FEE_NUMERATOR = 500;
uint256 constant public MAX_SELL_FEE_NUMERATOR = 500;
uint256 public buyFeeNumerator;
uint256 public _sellFeeNumerator;
uint256[] public treasuryShares;
address[] public treasuryList;
bool public feesAreLockedForever;
bool public sniperBotProtectionDisabledForever;
bool public blacklistAddRestrictedForever;
uint256 public immutable deployTimestamp;
constructor(
address[] memory _treasuryList,
uint256[] memory _treasuryShares,
uint256 _buyFeeNumeratorValue,
uint256 _sellFeeNumeratorValue
) Ownable() ERC20(_name, _symbol) {
_mint(msg.sender, TOTAL_SUPPLY);
setLiquidityHolder(msg.sender, true);
setTreasury(_treasuryList, _treasuryShares);
setBuyFeeNumerator(_buyFeeNumeratorValue);
setSellFeeNumerator(_sellFeeNumeratorValue);
deployTimestamp = block.timestamp;
}
function setTreasury(
address[] memory _treasuryList,
uint256[] memory _treasuryShares
) public onlyOwner {
require(_treasuryShares.length == _treasuryList.length, "lengths mismatch");
uint256 sumShares = 0;
for (uint256 i=0; i<_treasuryShares.length; i++) {
sumShares += _treasuryShares[i];
require(_treasuryShares[i] != 0, "wrong share");
}
require(sumShares == DENOMINATOR, "wrong shares (sum != 10000)");
treasuryList = _treasuryList;
treasuryShares = _treasuryShares;
emit TreasurySet(_treasuryList, _treasuryShares);
}
function lockFeesForever() external onlyOwner {
require(!feesAreLockedForever, "already set");
feesAreLockedForever = true;
emit FeesLockedForever();
}
function restrictBlacklistAddForever() external onlyOwner {
require(!blacklistAddRestrictedForever, "already set");
blacklistAddRestrictedForever = true;
emit BlacklistAddRestrictedForever();
}
function setLpPair(address pair, bool enabled) external onlyOwner {
accountInfo[pair].isLPPool = enabled;
emit LPPairSet(pair, enabled);
}
function setBlacklisted(address account, bool isBlacklisted) external onlyOwner {
if (isBlacklisted) {
require(!blacklistAddRestrictedForever, "Blacklist add restricted forever");
}
accountInfo[account].isBlackListed = isBlacklisted;
emit BlacklistSet(account, isBlacklisted);
}
function setBuyFeeNumerator(uint256 value) public onlyOwner {
require(!feesAreLockedForever, "Fees are locked forever");
require(value <= MAX_BUY_FEE_NUMERATOR, "Exceeds maximum buy fee");
buyFeeNumerator = value;
emit BuyFeeNumeratorSet(value);
}
function setSellFeeNumerator(uint256 value) public onlyOwner {
require(!feesAreLockedForever, "Fees are locked forever");
require(value <= MAX_SELL_FEE_NUMERATOR, "Exceeds maximum buy fee");
_sellFeeNumerator = value;
emit SellFeeNumeratorSet(value);
}
function sellFeeNumerator() public view returns(uint256) {
if (sniperBotProtectionDisabledForever) {
return _sellFeeNumerator;
}
return DENOMINATOR;
}
function disableSniperBotProtectionForever() external onlyOwner {
require(!sniperBotProtectionDisabledForever, "already set");
sniperBotProtectionDisabledForever = true;
emit SniperBotProtectionDisabledForever();
}
function setLiquidityHolder(address account, bool flag) public onlyOwner {
accountInfo[account].isLiquidityHolder = flag;
emit LiquidityHolderSet(account, flag);
}
function _hasLimits(AccountInfo memory fromInfo, AccountInfo memory toInfo) internal pure returns(bool) {
return !fromInfo.isLiquidityHolder && !toInfo.isLiquidityHolder;
}
event TakenFee(address to, uint256 amount);
function _distributeFees(address from, uint256 amount) internal {
for (uint256 i=0; i<treasuryList.length; ++i) {
address _treasury = treasuryList[i];
uint256 _share = treasuryShares[i];
uint256 amountShare = amount * _share / DENOMINATOR;
if (_treasury == address(0)) {
_burn(from, amountShare);
} else {
super._transfer(from, _treasury, amountShare);
}
emit TakenFee(_treasury, amountShare);
}
}
function _transfer(address from, address to, uint256 amount) internal override {
AccountInfo memory fromInfo = accountInfo[from];
AccountInfo memory toInfo = accountInfo[to];
require(!fromInfo.isBlackListed && !toInfo.isBlackListed, "Blacklisted");
if (!_hasLimits(fromInfo, toInfo) ||
(fromInfo.isLPPool && toInfo.isLPPool)
) {
super._transfer(from, to, amount);
return;
}
if (fromInfo.isLPPool) {
uint256 buyFeeAmount = amount * buyFeeNumerator / DENOMINATOR;
_distributeFees(from, buyFeeAmount);
emit BuyFeePaid(from, buyFeeAmount);
unchecked {
amount -= buyFeeAmount;
}
} else if (toInfo.isLPPool) {
uint256 sellFeeAmount = amount * sellFeeNumerator() / DENOMINATOR;
_distributeFees(from, sellFeeAmount);
emit SellFeePaid(from, sellFeeAmount);
unchecked {
amount -= sellFeeAmount;
}
} else {
}
super._transfer(from, to, amount);
if (block.timestamp - deployTimestamp < 1 hours) {
require(balanceOf(to) < 4_000_000 * 1e18 || toInfo.isLiquidityHolder, "wheel protection");
}
}
}
文件 7 的 7:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
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);
}
}
{
"compilationTarget": {
"contracts/MOJI.sol": "MOJI"
},
"evmVersion": "berlin",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address[]","name":"_treasuryList","type":"address[]"},{"internalType":"uint256[]","name":"_treasuryShares","type":"uint256[]"},{"internalType":"uint256","name":"_buyFeeNumeratorValue","type":"uint256"},{"internalType":"uint256","name":"_sellFeeNumeratorValue","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"BlacklistAddRestrictedForever","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"flag","type":"bool"}],"name":"BlacklistSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BuyFeeNumeratorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BuyFeePaid","type":"event"},{"anonymous":false,"inputs":[],"name":"FeesLockedForever","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"LPPairSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"flag","type":"bool"}],"name":"LiquidityHolderSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SellFeeNumeratorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SellFeePaid","type":"event"},{"anonymous":false,"inputs":[],"name":"SniperBotProtectionDisabledForever","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TakenFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"treasuryList","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"treasuryShares","type":"uint256[]"}],"name":"TreasurySet","type":"event"},{"inputs":[],"name":"DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_BUY_FEE_NUMERATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SELL_FEE_NUMERATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accountInfo","outputs":[{"internalType":"bool","name":"isLPPool","type":"bool"},{"internalType":"bool","name":"isLiquidityHolder","type":"bool"},{"internalType":"bool","name":"isBlackListed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blacklistAddRestrictedForever","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deployTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableSniperBotProtectionForever","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feesAreLockedForever","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockFeesForever","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"restrictBlacklistAddForever","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isBlacklisted","type":"bool"}],"name":"setBlacklisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setBuyFeeNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"flag","type":"bool"}],"name":"setLiquidityHolder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setLpPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setSellFeeNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_treasuryList","type":"address[]"},{"internalType":"uint256[]","name":"_treasuryShares","type":"uint256[]"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sniperBotProtectionDisabledForever","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"treasuryList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"treasuryShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]