编译器
0.8.23+commit.f704f362
文件 1 的 12: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 的 12: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);
}
}
}
}
文件 3 的 12:ERC20Burnable.sol
pragma solidity ^0.8.20;
import {ERC20} from "../ERC20.sol";
import {Context} from "../../../utils/Context.sol";
abstract contract ERC20Burnable is Context, ERC20 {
function burn(uint256 value) public virtual {
_burn(_msgSender(), value);
}
function burnFrom(address account, uint256 value) public virtual {
_spendAllowance(account, _msgSender(), value);
_burn(account, value);
}
}
文件 4 的 12: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);
}
文件 5 的 12: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);
}
文件 6 的 12:IMoonshotToken.sol
pragma solidity ^0.8.23;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IMoonshotToken is IERC20 {
enum CurveType {
ConstantProductV1
}
struct ConstructorParams {
string name;
string symbol;
address creator;
uint256 totalSupply;
uint256 virtualTokenReserves;
uint256 virtualCollateralReserves;
uint256 feeBasisPoints;
uint256 dexFeeBasisPoints;
uint256 migrationFeeFixed;
uint256 poolCreationFee;
uint256 mcLowerLimit;
uint256 mcUpperLimit;
uint256 tokensMigrationThreshold;
address treasury;
address uniV2Router;
address dexTreasury;
}
error NotEnoughETHReserves();
error InsufficientTokenReserves();
error FailedToSendETH();
error NotEnoughtETHToBuyTokens();
error SlippageCheckFailed();
error MarketcapThresholdReached();
error SendingToPairIsNotAllowedBeforeMigration();
error TradingStopped();
error OnlyFactory();
function buyExactOut(
uint256 _tokenAmount,
uint256 _maxCollateralAmount
) external payable returns (uint256 collateralToPayWithFee, uint256 helioFee, uint256 dexFee);
function buyExactIn(
uint256 _amountOutMin
) external payable returns (uint256 collateralToPayWithFee, uint256 helioFee, uint256 dexFee);
function sellExactIn(
uint256 _tokenAmount,
uint256 _amountOutMin
) external payable returns (uint256 collateralToReceiveMinusFee, uint256 helioFee, uint256 dexFee);
function sellExactOut(
uint256 _tokenAmountMax,
uint256 _amountCollateral
)
external
payable
returns (uint256 collateralToReceiveMinusFee, uint256 tokensOut, uint256 helioFee, uint256 dexFee);
function getAmountOutAndFee(
uint256 _amountIn,
uint256 _reserveIn,
uint256 _reserveOut,
bool _paymentTokenIsIn
) external view returns (uint256 amountOut, uint256 fee);
function getAmountInAndFee(
uint256 _amountOut,
uint256 _reserveIn,
uint256 _reserveOut,
bool _paymentTokenIsOut
) external view returns (uint256 amountIn, uint256 fee);
function migrate() external returns (uint256 tokensToMigrate, uint256 tokensToBurn, uint256 collateralAmount);
function getCurveProgressBps() external view returns (uint256);
function getMarketCap() external view returns (uint256);
}
文件 7 的 12:IUniswapV2Factory.sol
pragma solidity ^0.8.23;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function createPair(address tokenA, address tokenB) external returns (address pair);
}
文件 8 的 12:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
function swapTokensForExactETH(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactTokensForETH(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapETHForExactTokens(
uint amountOut,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
文件 9 的 12:MoonshotToken.sol
pragma solidity ^0.8.23;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import {IUniswapV2Router02} from "./interfaces/IUniswapV2Router02.sol";
import {IUniswapV2Factory} from "./interfaces/IUniswapV2Factory.sol";
import {IMoonshotToken} from "./interfaces/IMoonshotToken.sol";
contract MoonshotToken is ERC20Burnable, IMoonshotToken, ReentrancyGuard {
CurveType public constant curveType = CurveType.ConstantProductV1;
uint256 public initalTokenSupply;
uint256 public virtualTokenReserves;
uint256 public virtualCollateralReserves;
uint256 public immutable virtualCollateralReservesInitial;
uint256 public immutable feeBPS;
uint256 public immutable dexFeeBPS;
uint256 public immutable mcLowerLimit;
uint256 public immutable mcUpperLimit;
uint256 public immutable tokensMigrationThreshold;
uint256 public immutable fixedMigrationFee;
uint256 public immutable poolCreationFee;
address public immutable creator;
address public immutable pair;
address public immutable treasury;
address public immutable dexTreasury;
address public immutable factory;
bool public tradingStopped;
bool public sendingToPairNotAllowed = true;
uint256 public constant MAX_BPS = 10_000;
IUniswapV2Router02 public immutable uniswapV2Router;
modifier buyChecks() {
if (tradingStopped) revert TradingStopped();
_;
_checkMcLower();
_checkMcUpperLimit();
}
modifier sellChecks() {
if (tradingStopped) revert TradingStopped();
_;
}
modifier onlyFactory() {
if (msg.sender != factory) revert OnlyFactory();
_;
}
constructor(ConstructorParams memory _params) ERC20(_params.name, _params.symbol) {
_mint(address(this), _params.totalSupply);
initalTokenSupply = _params.totalSupply;
virtualCollateralReserves = _params.virtualCollateralReserves;
virtualCollateralReservesInitial = _params.virtualCollateralReserves;
virtualTokenReserves = _params.virtualTokenReserves;
creator = _params.creator;
feeBPS = _params.feeBasisPoints;
dexFeeBPS = _params.dexFeeBasisPoints;
treasury = _params.treasury;
dexTreasury = _params.dexTreasury;
fixedMigrationFee = _params.migrationFeeFixed;
poolCreationFee = _params.poolCreationFee;
mcLowerLimit = _params.mcLowerLimit;
mcUpperLimit = _params.mcUpperLimit;
tokensMigrationThreshold = _params.tokensMigrationThreshold;
uniswapV2Router = IUniswapV2Router02(_params.uniV2Router);
factory = msg.sender;
(address token0, address token1) = address(this) < uniswapV2Router.WETH()
? (address(this), uniswapV2Router.WETH())
: (uniswapV2Router.WETH(), address(this));
pair = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
hex"ff",
address(uniswapV2Router.factory()),
keccak256(abi.encodePacked(token0, token1)),
hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"
)
)
)
)
);
}
function buyExactOut(
uint256 _tokenAmount,
uint256 _maxCollateralAmount
)
external
payable
onlyFactory
buyChecks
returns (uint256 collateralToPayWithFee, uint256 helioFee, uint256 dexFee)
{
if (balanceOf(address(this)) <= _tokenAmount) revert InsufficientTokenReserves();
uint256 collateralToSpend = (_tokenAmount * virtualCollateralReserves) / (virtualTokenReserves - _tokenAmount);
(helioFee, dexFee) = _calculateFee(collateralToSpend);
collateralToPayWithFee = collateralToSpend + helioFee + dexFee;
if (collateralToPayWithFee > _maxCollateralAmount) revert SlippageCheckFailed();
_transferCollateral(treasury, helioFee);
_transferCollateral(dexTreasury, dexFee);
virtualTokenReserves -= _tokenAmount;
virtualCollateralReserves += collateralToSpend;
uint256 refund;
if (msg.value > collateralToPayWithFee) {
refund = msg.value - collateralToPayWithFee;
_transferCollateral(msg.sender, refund);
} else if (msg.value < collateralToPayWithFee) {
revert NotEnoughtETHToBuyTokens();
}
_transfer(address(this), msg.sender, _tokenAmount);
}
function buyExactIn(
uint256 _amountOutMin
)
external
payable
onlyFactory
buyChecks
returns (uint256 collateralToPayWithFee, uint256 helioFee, uint256 dexFee)
{
if (balanceOf(address(this)) <= _amountOutMin) revert InsufficientTokenReserves();
collateralToPayWithFee = msg.value;
(helioFee, dexFee) = _calculateFee(collateralToPayWithFee);
uint256 collateralToSpendMinusFee = collateralToPayWithFee - helioFee - dexFee;
_transferCollateral(treasury, helioFee);
_transferCollateral(dexTreasury, dexFee);
uint256 tokensOut = (collateralToSpendMinusFee * virtualTokenReserves) /
(virtualCollateralReserves + collateralToSpendMinusFee);
if (tokensOut < _amountOutMin) revert SlippageCheckFailed();
virtualTokenReserves -= tokensOut;
virtualCollateralReserves += collateralToSpendMinusFee;
_transfer(address(this), msg.sender, tokensOut);
}
function sellExactIn(
uint256 _tokenAmount,
uint256 _amountCollateralMin
)
external
payable
onlyFactory
sellChecks
returns (uint256 collateralToReceiveMinusFee, uint256 helioFee, uint256 dexFee)
{
uint256 collaterallToReceive = (_tokenAmount * virtualCollateralReserves) /
(virtualTokenReserves + _tokenAmount);
(helioFee, dexFee) = _calculateFee(collaterallToReceive);
collateralToReceiveMinusFee = collaterallToReceive - helioFee - dexFee;
_transferCollateral(treasury, helioFee);
_transferCollateral(dexTreasury, dexFee);
if (collateralToReceiveMinusFee < _amountCollateralMin) revert SlippageCheckFailed();
virtualTokenReserves += _tokenAmount;
virtualCollateralReserves -= collaterallToReceive;
_transferCollateral(msg.sender, collateralToReceiveMinusFee);
_transfer(msg.sender, address(this), _tokenAmount);
}
function sellExactOut(
uint256 _tokenAmountMax,
uint256 _amountCollateral
)
external
payable
onlyFactory
sellChecks
returns (uint256 collateralToReceiveMinusFee, uint256 tokensOut, uint256 helioFee, uint256 dexFee)
{
(helioFee, dexFee) = _calculateFee(_amountCollateral);
collateralToReceiveMinusFee = _amountCollateral - helioFee - dexFee;
_transferCollateral(treasury, helioFee);
_transferCollateral(dexTreasury, dexFee);
tokensOut = (_amountCollateral * virtualTokenReserves) / (virtualCollateralReserves - _amountCollateral);
if (tokensOut > _tokenAmountMax) revert SlippageCheckFailed();
_transfer(msg.sender, address(this), tokensOut);
virtualTokenReserves += tokensOut;
virtualCollateralReserves -= _amountCollateral;
_transferCollateral(msg.sender, collateralToReceiveMinusFee);
}
function getAmountOutAndFee(
uint256 _amountIn,
uint256 _reserveIn,
uint256 _reserveOut,
bool _paymentTokenIsIn
) external view returns (uint256 amountOut, uint256 fee) {
if (_paymentTokenIsIn) {
(uint256 helioFee, uint256 dexFee) = _calculateFee(_amountIn);
fee = helioFee + dexFee;
amountOut = (_amountIn * _reserveOut) / (_reserveIn + _amountIn);
} else {
amountOut = (_amountIn * _reserveOut) / (_reserveIn + _amountIn);
(uint256 helioFee, uint256 dexFee) = _calculateFee(amountOut);
fee = helioFee + dexFee;
}
}
function getAmountInAndFee(
uint256 _amountOut,
uint256 _reserveIn,
uint256 _reserveOut,
bool _paymentTokenIsOut
) external view returns (uint256 amountIn, uint256 fee) {
if (_paymentTokenIsOut) {
(uint256 helioFee, uint256 dexFee) = _calculateFee(_amountOut);
fee = helioFee + dexFee;
amountIn = (_amountOut * _reserveIn) / (_reserveOut - _amountOut);
} else {
amountIn = (_amountOut * _reserveIn) / (_reserveOut - _amountOut);
(uint256 helioFee, uint256 dexFee) = _calculateFee(amountIn);
fee = helioFee + dexFee;
}
}
function migrate()
external
onlyFactory
returns (uint256 tokensToMigrate, uint256 tokensToBurn, uint256 collateralAmount)
{
sendingToPairNotAllowed = false;
uint256 tokensRemaining = balanceOf(address(this));
IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
this.approve(address(uniswapV2Router), tokensRemaining);
tokensToMigrate = _tokensToMigrate();
tokensToBurn = tokensRemaining - tokensToMigrate;
(uint256 treasuryFee, uint256 dexFee) = _splitFee(fixedMigrationFee);
_transferCollateral(treasury, treasuryFee + poolCreationFee);
_transferCollateral(dexTreasury, dexFee);
_burn(address(this), tokensToBurn);
collateralAmount =
virtualCollateralReserves -
virtualCollateralReservesInitial -
treasuryFee -
dexFee -
poolCreationFee;
(, , uint256 liquidity) = uniswapV2Router.addLiquidityETH{value: collateralAmount}(
address(this),
tokensToMigrate,
tokensToMigrate,
collateralAmount,
address(this),
block.timestamp + 10
);
if (address(this).balance > 0) {
_transferCollateral(treasury, address(this).balance);
}
IERC20(pair).transfer(address(0), liquidity);
}
function getMarketCap() public view returns (uint256) {
uint256 mc = (virtualCollateralReserves * 10 ** 18 * totalSupply()) / virtualTokenReserves;
return mc / 10 ** 18;
}
function getCurveProgressBps() external view returns (uint256) {
uint256 progress = ((initalTokenSupply - balanceOf(address(this))) * MAX_BPS) / tokensMigrationThreshold;
return progress < 100 ? 100 : (progress > MAX_BPS ? MAX_BPS : progress);
}
function _tokensToMigrate() internal view returns (uint256) {
uint256 collateralDeductedFee = address(this).balance - fixedMigrationFee - poolCreationFee;
return (virtualTokenReserves * collateralDeductedFee) / virtualCollateralReserves;
}
function _calculateFee(uint256 _amount) internal view returns (uint256 treasuryFee, uint256 dexFee) {
treasuryFee = (_amount * feeBPS) / MAX_BPS;
dexFee = (treasuryFee * dexFeeBPS) / MAX_BPS;
treasuryFee -= dexFee;
}
function _splitFee(uint256 _feeAmount) internal view returns (uint256 treasuryFee, uint256 dexFee) {
dexFee = (_feeAmount * dexFeeBPS) / MAX_BPS;
treasuryFee = _feeAmount - dexFee;
}
function _transferCollateral(address _to, uint256 _amount) internal {
(bool sent, ) = _to.call{value: _amount}("");
if (!sent) revert FailedToSendETH();
}
function _checkMcUpperLimit() internal view {
uint256 mc = getMarketCap();
if (mc > mcUpperLimit) revert MarketcapThresholdReached();
}
function _checkMcLower() internal {
uint256 mc = getMarketCap();
if (mc > mcLowerLimit) {
tradingStopped = true;
}
}
function transfer(address _to, uint256 _value) public override(ERC20, IERC20) returns (bool) {
if (_to == pair && sendingToPairNotAllowed) revert SendingToPairIsNotAllowedBeforeMigration();
return super.transfer(_to, _value);
}
}
文件 10 的 12: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);
}
}
文件 11 的 12: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;
}
}
文件 12 的 12: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": {
"contracts/MoonshotToken.sol": "MoonshotToken"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"viaIR": true
}
[{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"virtualTokenReserves","type":"uint256"},{"internalType":"uint256","name":"virtualCollateralReserves","type":"uint256"},{"internalType":"uint256","name":"feeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"dexFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"migrationFeeFixed","type":"uint256"},{"internalType":"uint256","name":"poolCreationFee","type":"uint256"},{"internalType":"uint256","name":"mcLowerLimit","type":"uint256"},{"internalType":"uint256","name":"mcUpperLimit","type":"uint256"},{"internalType":"uint256","name":"tokensMigrationThreshold","type":"uint256"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"uniV2Router","type":"address"},{"internalType":"address","name":"dexTreasury","type":"address"}],"internalType":"struct IMoonshotToken.ConstructorParams","name":"_params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"FailedToSendETH","type":"error"},{"inputs":[],"name":"InsufficientTokenReserves","type":"error"},{"inputs":[],"name":"MarketcapThresholdReached","type":"error"},{"inputs":[],"name":"NotEnoughETHReserves","type":"error"},{"inputs":[],"name":"NotEnoughtETHToBuyTokens","type":"error"},{"inputs":[],"name":"OnlyFactory","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"SendingToPairIsNotAllowedBeforeMigration","type":"error"},{"inputs":[],"name":"SlippageCheckFailed","type":"error"},{"inputs":[],"name":"TradingStopped","type":"error"},{"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":[{"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":"MAX_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"value","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":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountOutMin","type":"uint256"}],"name":"buyExactIn","outputs":[{"internalType":"uint256","name":"collateralToPayWithFee","type":"uint256"},{"internalType":"uint256","name":"helioFee","type":"uint256"},{"internalType":"uint256","name":"dexFee","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_maxCollateralAmount","type":"uint256"}],"name":"buyExactOut","outputs":[{"internalType":"uint256","name":"collateralToPayWithFee","type":"uint256"},{"internalType":"uint256","name":"helioFee","type":"uint256"},{"internalType":"uint256","name":"dexFee","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveType","outputs":[{"internalType":"enum IMoonshotToken.CurveType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dexFeeBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dexTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fixedMigrationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"},{"internalType":"uint256","name":"_reserveIn","type":"uint256"},{"internalType":"uint256","name":"_reserveOut","type":"uint256"},{"internalType":"bool","name":"_paymentTokenIsOut","type":"bool"}],"name":"getAmountInAndFee","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_reserveIn","type":"uint256"},{"internalType":"uint256","name":"_reserveOut","type":"uint256"},{"internalType":"bool","name":"_paymentTokenIsIn","type":"bool"}],"name":"getAmountOutAndFee","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurveProgressBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarketCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initalTokenSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mcLowerLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mcUpperLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrate","outputs":[{"internalType":"uint256","name":"tokensToMigrate","type":"uint256"},{"internalType":"uint256","name":"tokensToBurn","type":"uint256"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolCreationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_amountCollateralMin","type":"uint256"}],"name":"sellExactIn","outputs":[{"internalType":"uint256","name":"collateralToReceiveMinusFee","type":"uint256"},{"internalType":"uint256","name":"helioFee","type":"uint256"},{"internalType":"uint256","name":"dexFee","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmountMax","type":"uint256"},{"internalType":"uint256","name":"_amountCollateral","type":"uint256"}],"name":"sellExactOut","outputs":[{"internalType":"uint256","name":"collateralToReceiveMinusFee","type":"uint256"},{"internalType":"uint256","name":"tokensOut","type":"uint256"},{"internalType":"uint256","name":"helioFee","type":"uint256"},{"internalType":"uint256","name":"dexFee","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"sendingToPairNotAllowed","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":"tokensMigrationThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingStopped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualCollateralReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualCollateralReservesInitial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualTokenReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]