编译器
0.8.23+commit.f704f362
文件 1 的 14:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 2 的 14:DividendTracker.sol
pragma solidity ^0.8.23;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IDividendTracker} from "./interfaces/IDividendTracker.sol";
import {SafeMath, SafeMathUint, SafeMathInt} from "./libs/SafeMath.sol";
abstract contract DividendTracker is ERC20, IDividendTracker {
using SafeMath for uint256;
using SafeMathUint for uint256;
using SafeMathInt for int256;
uint256 internal constant magnitude = 2 ** 128;
uint256 internal magnifiedDividendPerShare;
mapping(address => int256) internal magnifiedDividendCorrections;
mapping(address => uint256) internal withdrawnDividends;
uint256 public totalDividendsDistributed;
uint256 public totalDividendsWithdrawn;
constructor(
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {}
function _distribute(uint256 amount) internal virtual {
require(totalSupply() > 0);
if (amount > 0) {
magnifiedDividendPerShare = magnifiedDividendPerShare.add(
(amount).mul(magnitude) / totalSupply()
);
emit DividendsDistributed(msg.sender, amount);
totalDividendsDistributed = totalDividendsDistributed.add(amount);
}
}
function _withdrawDividendOfUser(
address payable user
) internal returns (uint256) {
uint256 _withdrawableDividend = withdrawableDividendOf(user);
if (_withdrawableDividend > 0) {
withdrawnDividends[user] = withdrawnDividends[user].add(
_withdrawableDividend
);
totalDividendsWithdrawn += _withdrawableDividend;
emit DividendWithdrawn(user, _withdrawableDividend);
(bool success, ) = user.call{value: _withdrawableDividend}("");
if (!success) {
withdrawnDividends[user] = withdrawnDividends[user].sub(
_withdrawableDividend
);
totalDividendsWithdrawn -= _withdrawableDividend;
return 0;
}
return _withdrawableDividend;
}
return 0;
}
function dividendOf(address _owner) public view override returns (uint256) {
return withdrawableDividendOf(_owner);
}
function withdrawableDividendOf(
address _owner
) public view override returns (uint256) {
return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]);
}
function withdrawnDividendOf(
address _owner
) public view override returns (uint256) {
return withdrawnDividends[_owner];
}
function accumulativeDividendOf(
address _owner
) public view override returns (uint256) {
return
magnifiedDividendPerShare
.mul(balanceOf(_owner))
.toInt256Safe()
.add(magnifiedDividendCorrections[_owner])
.toUint256Safe() / magnitude;
}
function transfer(
address to,
uint256 value
) public override returns (bool) {
super.transfer(to, value);
address from = _msgSender();
int256 _magCorrection = magnifiedDividendPerShare
.mul(value)
.toInt256Safe();
magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from]
.add(_magCorrection);
magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(
_magCorrection
);
return true;
}
function transferFrom(
address from,
address to,
uint256 value
) public override returns (bool) {
super.transferFrom(from, to, value);
int256 _magCorrection = magnifiedDividendPerShare
.mul(value)
.toInt256Safe();
magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from]
.add(_magCorrection);
magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(
_magCorrection
);
return true;
}
function mint(address account, uint256 value) public virtual {
super._mint(account, value);
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[
account
].sub((magnifiedDividendPerShare.mul(value)).toInt256Safe());
}
function burn(address account, uint256 value) public virtual {
super._burn(account, value);
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[
account
].add((magnifiedDividendPerShare.mul(value)).toInt256Safe());
}
}
文件 3 的 14:ERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => 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 returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
文件 4 的 14:ERC315.sol
pragma solidity ^0.8.23;
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {IERC315} from "./interfaces/IERC315.sol";
import {ERC315LPToken} from "./ERC315LPToken.sol";
abstract contract ERC315 is IERC315, Context {
uint256 private _totalSupply;
string private _name;
string private _symbol;
address payable public lp;
uint256 public X;
mapping(address account => uint256) private _balances;
mapping(address account => uint32) private lastTransaction;
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_,
address _initTransferAddr
) {
_name = name_;
_symbol = symbol_;
_totalSupply = totalSupply_;
_balances[_initTransferAddr] = totalSupply_;
emit Transfer(address(0), _initTransferAddr, totalSupply_);
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
require(value > 0, "invalid amount");
_transfer(_msgSender(), to, value);
return true;
}
function _transfer(
address from,
address to,
uint256 value
) internal virtual {
require(
lastTransaction[_msgSender()] != block.number,
"You can't make two transactions in the same block"
);
lastTransaction[_msgSender()] = uint32(block.number);
require(
_balances[from] >= value,
"ERC20: transfer amount exceeds balance"
);
unchecked {
_balances[from] = _balances[from] - value;
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function getReserves() public view returns (uint256, uint256) {
return (address(this).balance, _balances[address(this)]);
}
function _getAmountOut(
uint256 value,
bool isbuy,
uint256 msgValue
) internal view returns (uint256) {
require(X > 0, "Liquidity not init");
(uint256 reserveETH, uint256 reserveToken) = getReserves();
reserveETH = reserveETH - msgValue;
if (isbuy) {
return (value * reserveToken) / (X * value + X * reserveETH);
} else {
return (value * X * reserveETH) / (value + reserveToken);
}
}
function _getEthLPInitAmount(
uint256 tokenAmount,
uint256 tokenEthPrice
) internal pure returns (uint256) {
return (tokenAmount / tokenEthPrice);
}
function _getLPAmount(
uint256 amountTokenIn
) internal view returns (uint256 liquidity) {
liquidity =
(amountTokenIn * ERC315LPToken(lp).totalSupply()) /
_balances[address(this)];
}
function initiateLiquidity(
uint256 _tokenAmount,
uint256 _tokenEthPrice,
uint256 _x
) public payable virtual {
require(_x > 0, "Invalid X");
require(X == 0, "Liquidity already initiated");
require(_tokenAmount > 0, "Invalid token amount");
require(_tokenEthPrice > 0, "Invalid token price");
_transfer(_msgSender(), address(this), _tokenAmount);
X = _x;
uint256 ethAmount = _getEthLPInitAmount(_tokenAmount, _tokenEthPrice);
require(msg.value >= ethAmount, "Invalid ETH amount");
if (msg.value > ethAmount) {
_safeTransferETH(_msgSender(), msg.value - ethAmount);
}
lp = payable(address(new ERC315LPToken()));
ERC315LPToken(lp).mint(_msgSender(), _tokenAmount);
}
function getETHInputAddLP(
uint256 tokenAmount
) public view returns (uint256) {
return _getETHInputAddLP(tokenAmount, 0);
}
function _getETHInputAddLP(
uint256 tokenAmount,
uint256 msgValue
) internal view returns (uint256) {
(uint256 reserveETH, uint256 reserveToken) = getReserves();
reserveETH = reserveETH - msgValue;
return (tokenAmount * reserveETH) / reserveToken;
}
function getOutputRemoveLP(
uint256 lpAmount
) public view returns (uint256 token, uint256 eth) {
(uint256 reserveETH, uint256 reserveToken) = getReserves();
token = (lpAmount * reserveToken) / ERC315LPToken(lp).totalSupply();
eth = (lpAmount * reserveETH) / ERC315LPToken(lp).totalSupply();
}
function addLiquidity(
uint256 _tokenAmount,
uint256 _amountOutMin
) public payable virtual {
require(X > 0, "Liquidity not initiated");
require(_tokenAmount > 0, "Invalid token amount");
uint256 ethRequired = _getETHInputAddLP(_tokenAmount, msg.value);
require(
msg.value > 0 && msg.value >= ethRequired,
"invalid ETH amount"
);
uint256 amountLp = _getLPAmount(_tokenAmount);
_transfer(_msgSender(), address(this), _tokenAmount);
if (_amountOutMin > 0) {
require(amountLp >= _amountOutMin, "Slippage limit exceeded");
}
ERC315LPToken(lp).mint(_msgSender(), amountLp);
if (msg.value > ethRequired) {
_safeTransferETH(_msgSender(), msg.value - ethRequired);
}
emit RAddLiquidity(_msgSender(), _tokenAmount, ethRequired, amountLp);
}
function removeLiquidity(
uint256 _lpAmount,
uint256 _amountTokenMin,
uint256 _amountEthMin
) public virtual {
require(X > 0, "Liquidity not initiated");
require(_lpAmount > 0, "Invalid LP amount");
(uint256 amountToken, uint256 amountEth) = getOutputRemoveLP(_lpAmount);
if (_amountTokenMin > 0) {
require(
amountToken >= _amountTokenMin,
"Slippage limit exceeded Token amount"
);
}
if (_amountEthMin > 0) {
require(
amountEth >= _amountEthMin,
"Slippage limit exceeded ETH amount"
);
}
ERC315LPToken(lp).burn(_msgSender(), _lpAmount);
_transfer(address(this), _msgSender(), amountToken);
_safeTransferETH(_msgSender(), amountEth);
emit RRemoveLiquidity(_msgSender(), _lpAmount, amountToken, amountEth);
}
function _buy(uint256 _amountEth, address _to) internal virtual {
require(_amountEth > 0, "eth amount too low");
uint256 token_amount = _getAmountOut(_amountEth, true, _amountEth);
_transfer(address(this), _to, token_amount);
emit RSwap(_to, _amountEth, 0, 0, token_amount);
}
function _sell(uint256 _amountToken, address _to) internal virtual {
require(_amountToken > 0, "token amount too low");
uint256 ethAmount = _getAmountOut(_amountToken, false, 0);
require(ethAmount > 0, "Sell amount too low");
require(
address(this).balance >= ethAmount,
"Insufficient ETH in reserves"
);
_transfer(_to, address(this), _amountToken);
_safeTransferETH(_to, ethAmount);
emit RSwap(_to, 0, _amountToken, ethAmount, 0);
}
function _safeTransferETH(address to, uint256 amount) internal {
(bool sent, ) = payable(to).call{value: amount}("");
require(sent, "Failed to send Ether");
}
}
文件 5 的 14:ERC315LPToken.sol
pragma solidity ^0.8.23;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {DividendTracker} from "./DividendTracker.sol";
contract ERC315LPToken is DividendTracker, Ownable {
event Claim(address indexed account, uint256 amount);
struct AccountInfo {
address account;
uint256 withdrawableDividends;
uint256 totalDividends;
uint256 lastClaimTime;
}
constructor()
DividendTracker("Liquidity Provide ERC315s", "LP-ERC315")
Ownable(_msgSender())
{}
mapping(address => uint256) public lastClaimTimes;
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, "LPToken: LOCKED");
unlocked = 0;
_;
unlocked = 1;
}
function claimRewards() external {
uint256 amount = _withdrawDividendOfUser(payable(_msgSender()));
if (amount > 0) {
lastClaimTimes[_msgSender()] = block.timestamp;
emit Claim(_msgSender(), amount);
}
}
function getAccount(
address account
) public view returns (address, uint256, uint256, uint256, uint256) {
AccountInfo memory info;
info.account = account;
info.withdrawableDividends = withdrawableDividendOf(account);
info.totalDividends = accumulativeDividendOf(account);
info.lastClaimTime = lastClaimTimes[account];
return (
info.account,
info.withdrawableDividends,
info.totalDividends,
info.lastClaimTime,
totalDividendsWithdrawn
);
}
function mint(address to, uint256 amount) public override lock onlyOwner {
super.mint(to, amount);
}
function burn(address from, uint256 amount) public override lock onlyOwner {
super.burn(from, amount);
}
function burnLP(uint256 amount) public lock {
super.burn(_msgSender(), amount);
}
receive() external payable {
uint256 totalAmount = msg.value;
if (totalSupply() > 0) {
_distribute(totalAmount);
}
}
}
文件 6 的 14:ERC315Token.sol
pragma solidity ^0.8.23;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ERC315} from "./ERC315.sol";
contract ERC315Token is ERC315, Ownable, ReentrancyGuard {
event FeeAddressChanged(address newAddress);
event LimitRemoved();
uint256 public constant LIQUIDITY_PROVIDE_SHARE = 300;
uint256 public immutable TOTAL_SUPPLY;
uint256 public immutable BUY_TAX;
uint256 public immutable SELL_TAX;
uint256 public MAX_WALLET;
mapping(address => bool) private _isExcludedFromFees;
address public feeAddress;
constructor(
uint256 _buyTax,
uint256 _sellTax,
string memory _name,
string memory _symbol,
uint256 _initSupply,
address _initOwner,
uint256 _maxBuyAmount
) ERC315(_name, _symbol, _initSupply, _initOwner) Ownable(_initOwner) {
require(_buyTax <= 5, "Buy tax too high");
require(_sellTax <= 5, "Sell tax too high");
feeAddress = _initOwner;
BUY_TAX = _buyTax;
SELL_TAX = _sellTax;
TOTAL_SUPPLY = _initSupply;
MAX_WALLET = _maxBuyAmount;
}
function excludedFromFees(
address _address,
bool _value
) external onlyOwner {
_isExcludedFromFees[_address] = _value;
}
function removeLimits() external onlyOwner {
require(MAX_WALLET != TOTAL_SUPPLY, "Limits already removed");
MAX_WALLET = TOTAL_SUPPLY;
emit LimitRemoved();
}
function getExcludedFromFees(address _address) public view returns (bool) {
return _isExcludedFromFees[_address];
}
function getEthLPInitAmount(
uint256 tokenAmount,
uint256 tokenEthPrice
) public pure returns (uint256) {
return _getEthLPInitAmount(tokenAmount, tokenEthPrice);
}
function getAmountOut(
uint256 value,
bool isbuy
) public view returns (uint256) {
return _getAmountOut(value, isbuy, 0);
}
function getLPAmount(uint256 amountTokenIn) public view returns (uint256) {
return _getLPAmount(amountTokenIn);
}
function initiateLiquidity(
uint256 _tokenAmount,
uint256 _tokenEthPrice,
uint256 _x
) public payable override onlyOwner {
super.initiateLiquidity(_tokenAmount, _tokenEthPrice, _x);
}
function addLiquidity(
uint256 _tokenAmount,
uint256 _amountOutMin
) public payable override nonReentrant {
super.addLiquidity(_tokenAmount, _amountOutMin);
}
function removeLiquidity(
uint256 _lpAmount,
uint256 _tokenAmountMin,
uint256 _ethAmountMin
) public override nonReentrant {
super.removeLiquidity(_lpAmount, _tokenAmountMin, _ethAmountMin);
}
function sellAntiBot(
uint256 _amountToken,
uint256 _amountOutMin
) external nonReentrant {
uint256 ethAmount = _getAmountOut(_amountToken, false, 0);
if (_amountOutMin > 0) {
require(ethAmount >= _amountOutMin, "Slippage limit exceeded");
}
_sell(_amountToken, _msgSender());
}
function buyAntiBot(uint256 _amountOutMin) external payable nonReentrant {
require(X > 0, "Liquidity not initiated");
uint256 token_amount = _getAmountOut(msg.value, true, msg.value);
if (_amountOutMin > 0) {
require(token_amount >= _amountOutMin, "Slippage limit exceeded");
}
_buy(msg.value, _msgSender());
}
function _transfer(
address from,
address to,
uint256 value
) internal override {
if (from == address(this)) {
require(value + balanceOf(to) < MAX_WALLET, "Max amount exceeded");
}
super._transfer(from, to, value);
}
function _buy(uint256 ethAmount, address to) internal override {
if (!_isExcludedFromFees[to] && BUY_TAX > 0) {
uint256 fee = (ethAmount * BUY_TAX) / 100;
if (fee > 0) {
_safeTransferETH(feeAddress, fee);
}
uint256 LPS = (ethAmount * LIQUIDITY_PROVIDE_SHARE) / 100000;
if (LPS > 0) {
_safeTransferETH(lp, LPS);
}
ethAmount = ethAmount - fee - LPS;
}
super._buy(ethAmount, to);
}
function _sell(uint256 tokenAmount, address to) internal override {
require(tokenAmount > 0, "token amount too low");
_transfer(to, address(this), tokenAmount);
uint256 ethAmount = _getAmountOut(tokenAmount, false, 0);
require(ethAmount > 0, "Sell amount too low");
if (address(this).balance < ethAmount) {
ethAmount = address(this).balance;
}
emit RSwap(to, 0, tokenAmount, ethAmount, 0);
if (!_isExcludedFromFees[to] && SELL_TAX > 0) {
uint256 fee = (ethAmount * SELL_TAX) / 100;
if (fee > 0) {
_safeTransferETH(feeAddress, fee);
}
uint256 LPS = (ethAmount * LIQUIDITY_PROVIDE_SHARE) / 100000;
if (LPS > 0) {
_safeTransferETH(lp, LPS);
}
ethAmount = ethAmount - fee - LPS;
}
_safeTransferETH(to, ethAmount);
}
function transfer(
address to,
uint256 value
) public override returns (bool) {
if (to == address(this)) {
_sell(value, _msgSender());
} else {
super.transfer(to, value);
}
return true;
}
function changeFeeAddress(address _newAddress) external {
require(
_msgSender() == owner() || _msgSender() == feeAddress,
"caller is not the owner"
);
feeAddress = _newAddress;
emit FeeAddressChanged(_newAddress);
}
receive() external payable {
uint256 ethAmount = msg.value;
_buy(ethAmount, _msgSender());
}
}
文件 7 的 14:IDividendTracker.sol
pragma solidity ^0.8.23;
interface IDividendTracker {
function dividendOf(address _owner) external view returns (uint256);
function withdrawableDividendOf(
address _owner
) external view returns (uint256);
function withdrawnDividendOf(
address _owner
) external view returns (uint256);
function accumulativeDividendOf(
address _owner
) external view returns (uint256);
event DividendsDistributed(address indexed from, uint256 weiAmount);
event DividendWithdrawn(address indexed to, uint256 weiAmount);
}
文件 8 的 14:IERC20.sol
pragma solidity ^0.8.20;
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 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 9 的 14:IERC20Metadata.sol
pragma solidity ^0.8.20;
import {IERC20} from "../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);
}
文件 10 的 14:IERC315.sol
pragma solidity ^0.8.23;
interface IERC315 {
event Transfer(address indexed from, address indexed to, uint256 value);
event RAddLiquidity(
address indexed from,
uint256 token,
uint256 eth,
uint256 liquidity
);
event RRemoveLiquidity(
address indexed from,
uint256 token,
uint256 eth,
uint256 liquidity
);
event RSwap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out
);
}
文件 11 的 14:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 12 的 14:ReentrancyGuard.sol
pragma solidity ^0.8.20;
abstract contract ReentrancyGuard {
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
_status = ENTERED;
}
function _nonReentrantAfter() private {
_status = NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
文件 13 的 14:SafeMath.sol
pragma solidity ^0.8.6;
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) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != -1 || a != MIN_INT256);
return a / b;
}
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
}
library SafeMathUint {
function toInt256Safe(uint256 a) internal pure returns (int256) {
int256 b = int256(a);
require(b >= 0);
return b;
}
}
文件 14 的 14:draft-IERC6093.sol
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"src/ERC315Token.sol": "ERC315Token"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"_buyTax","type":"uint256"},{"internalType":"uint256","name":"_sellTax","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_initSupply","type":"uint256"},{"internalType":"address","name":"_initOwner","type":"address"},{"internalType":"uint256","name":"_maxBuyAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"FeeAddressChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"LimitRemoved","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":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"RAddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"RRemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"}],"name":"RSwap","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"},{"inputs":[],"name":"BUY_TAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIQUIDITY_PROVIDE_SHARE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WALLET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SELL_TAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOTAL_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"X","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_amountOutMin","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountOutMin","type":"uint256"}],"name":"buyAntiBot","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAddress","type":"address"}],"name":"changeFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_value","type":"bool"}],"name":"excludedFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"isbuy","type":"bool"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"getETHInputAddLP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint256","name":"tokenEthPrice","type":"uint256"}],"name":"getEthLPInitAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountTokenIn","type":"uint256"}],"name":"getLPAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"getOutputRemoveLP","outputs":[{"internalType":"uint256","name":"token","type":"uint256"},{"internalType":"uint256","name":"eth","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_tokenEthPrice","type":"uint256"},{"internalType":"uint256","name":"_x","type":"uint256"}],"name":"initiateLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"lp","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","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":"removeLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpAmount","type":"uint256"},{"internalType":"uint256","name":"_tokenAmountMin","type":"uint256"},{"internalType":"uint256","name":"_ethAmountMin","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken","type":"uint256"},{"internalType":"uint256","name":"_amountOutMin","type":"uint256"}],"name":"sellAntiBot","outputs":[],"stateMutability":"nonpayable","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":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]