编译器
0.8.23+commit.f704f362
文件 1 的 10:IDiamondCut.sol
pragma solidity ^0.8.23;
interface IDiamondCut {
enum FacetCutAction {Add, Replace, Remove}
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
function diamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external;
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}
文件 2 的 10:IDiamondLoupe.sol
pragma solidity ^0.8.23;
interface IDiamondLoupe {
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
function facets() external view returns (Facet[] memory facets_);
function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
function facetAddresses() external view returns (address[] memory facetAddresses_);
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);
}
文件 3 的 10:IERC165.sol
pragma solidity ^0.8.23;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 4 的 10:IERC173.sol
pragma solidity ^0.8.23;
interface IERC173 {
function owner() external view returns (address owner_);
function transferOwnership(address _newOwner) external;
}
文件 5 的 10:IERC20.sol
pragma solidity ^0.8.23;
interface IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256 balance);
function transferFrom(
address _from,
address _to,
uint256 _value
) external returns (bool success);
function transfer(address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) external returns (bool success);
function allowance(address _owner, address _spender) external view returns (uint256 remaining);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 6 的 10:INewToken.sol
pragma solidity ^0.8.23;
import { IPresale} from "./IPresale.sol";
interface INewToken {
struct InitParams {
address owner;
address taxWallet;
address stakingFacet;
address v2router;
bool isFreeTier;
uint256 minLiq;
uint256 supply;
uint256 initTaxType;
uint256 initInterval;
uint256 countInterval;
uint256 maxBuyTax;
uint256 minBuyTax;
uint256 maxSellTax;
uint256 minSellTax;
uint256 lpTax;
uint256 maxWallet;
uint256 maxTx;
uint256 preventSwap;
uint256 maxSwap;
uint256 taxSwapThreshold;
string name;
string symbol;
}
struct TeamParams {
address team1;
uint256 team1p;
uint256 cliffPeriod;
uint256 vestingPeriod;
bool isAdd;
}
function rescueERC20(address _address) external;
function increaseLimits(uint256 maxwallet, uint256 maxtx) external;
function startTrading(uint256 lockPeriod, bool shouldBurn, address router) external;
function addPresale(address presale, uint256 percent, IPresale.PresaleParams memory newdetails) external;
function finPresale() external;
function refPresale() external;
function addTeam(TeamParams memory params) external;
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
文件 7 的 10:IPresale.sol
pragma solidity ^0.8.23;
interface IPresale {
struct PresaleParams {
address owner;
address token;
uint256 softcap;
uint256 hardcap;
uint256 startTs;
uint256 finishTs;
uint256 duration;
uint256 liqPercent;
uint256 cliffPeriod;
uint256 vestingPeriod;
uint256 status;
uint256 sold;
uint256 maxEth;
uint256 maxBag;
uint256 fee;
}
function transferOwnership(address _newOwner) external;
function owner() external view returns (address);
function rescueERC20(address _address) external;
function setupPresale(PresaleParams memory params) external;
function buyTokens(uint256 _amount) external payable;
function claimTokens() external;
function getRefund() external;
function getPresaleDetails() external view returns(PresaleParams memory);
function finishPresale() external;
function claimEth() external;
function getClaimableTokens(address user) external view returns(uint256,uint256,uint256,uint256);
function refundPresale() external;
}
文件 8 的 10:LibAppStorage.sol
pragma solidity ^0.8.23;
import {LibDiamond} from "./LibDiamond.sol";
import {IUniswapV2Factory, IUniswapV2Router02} from "../interfaces/INewToken.sol";
struct AppStorage {
mapping(address => bool) validRouters;
mapping(address => bool) allowedTokens;
mapping(address => address) launchedTokens;
mapping(address => address) launchedPresale;
uint256 ethCost;
uint256 deployyyyerCost;
uint256 promoCostEth;
uint256 promoCostDeployyyyer;
address bridge;
mapping(address => uint256) myScore;
uint256 cScore;
bool isParent;
uint256 minLiq;
mapping(address => uint256) teamShare;
mapping(address => uint256) teamClaim;
uint256 teamBalance;
uint256 cliffPeriod;
uint256 vestingPeriod;
mapping(address => bool) isExTxLimit;
mapping(address => bool) isExWaLimit;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
address payable taxWallet;
address payable deployyyyerCa;
address payable stakingContract;
address stakingFacet;
address presaleFacet;
address tokenFacet;
uint256 stakingShare;
uint256 buyCount;
uint256 initTaxType;
uint256 initInterval;
uint256 countInterval;
uint256 taxBuy;
uint256 maxBuyTax;
uint256 minBuyTax;
uint256 taxSell;
uint256 maxSellTax;
uint256 minSellTax;
uint256 tradingOpened;
uint8 decimals;
uint256 tTotal;
string name;
string symbol;
uint256 preventSwap;
uint256 taxSwapThreshold;
uint256 maxTaxSwap;
uint256 maxWallet;
uint256 maxTx;
IUniswapV2Router02 uniswapV2Router;
address uniswapV2Pair;
bool tradingOpen;
bool inSwap;
bool walletLimited;
bool isFreeTier;
bool isBurnt;
bool isRetrieved;
uint256 lockPeriod;
uint256 lpTax;
uint256 halfLp;
uint256 lastSwap;
uint256 presaleTs;
uint256 presaleSt;
address presale;
}
contract Modifiers {
AppStorage internal s;
modifier onlyOwner() {
LibDiamond.enforceIsContractOwner();
_;
}
}
文件 9 的 10:LibDiamond.sol
pragma solidity ^0.8.23;
import { IDiamondCut } from "../interfaces/IDiamondCut.sol";
library LibDiamond {
bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
struct DiamondStorage {
mapping(bytes4 => bytes32) facets;
mapping(uint256 => bytes32) selectorSlots;
uint16 selectorCount;
mapping(bytes4 => bool) supportedInterfaces;
address contractOwner;
}
function diamondStorage() internal pure returns (DiamondStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function setContractOwner(address _newOwner) internal {
DiamondStorage storage ds = diamondStorage();
address previousOwner = ds.contractOwner;
ds.contractOwner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function contractOwner() internal view returns (address contractOwner_) {
contractOwner_ = diamondStorage().contractOwner;
}
function enforceIsContractOwner() internal view {
require(msg.sender == diamondStorage().contractOwner, "l0");
}
bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));
function diamondCut(
IDiamondCut.FacetCut[] memory _diamondCut,
address _init,
bytes memory _calldata
) internal {
DiamondStorage storage ds = diamondStorage();
uint256 originalSelectorCount = ds.selectorCount;
uint256 selectorCount = originalSelectorCount;
bytes32 selectorSlot;
if (selectorCount & 7 > 0) {
selectorSlot = ds.selectorSlots[selectorCount >> 3];
}
for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {
(selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(
selectorCount,
selectorSlot,
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].action,
_diamondCut[facetIndex].functionSelectors
);
}
if (selectorCount != originalSelectorCount) {
ds.selectorCount = uint16(selectorCount);
}
if (selectorCount & 7 > 0) {
ds.selectorSlots[selectorCount >> 3] = selectorSlot;
}
require(_init == address(0), "l1");
require(_calldata.length == 0, "l2");
}
function addReplaceRemoveFacetSelectors(
uint256 _selectorCount,
bytes32 _selectorSlot,
address _newFacetAddress,
IDiamondCut.FacetCutAction _action,
bytes4[] memory _selectors
) internal returns (uint256, bytes32) {
DiamondStorage storage ds = diamondStorage();
require(_selectors.length > 0, "l3");
if (_action == IDiamondCut.FacetCutAction.Add) {
enforceHasContractCode(_newFacetAddress, "l4");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
bytes32 oldFacet = ds.facets[selector];
require(address(bytes20(oldFacet)) == address(0), "l5");
ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount);
uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;
_selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
if (selectorInSlotPosition == 224) {
ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
_selectorSlot = 0;
}
_selectorCount++;
}
}
else {
revert("l6");
}
return (_selectorCount, _selectorSlot);
}
function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
uint256 contractSize;
assembly {
contractSize := extcodesize(_contract)
}
require(contractSize > 0, _errorMessage);
}
}
文件 10 的 10:TokenDiamond.sol
pragma solidity ^0.8.23;
import { LibDiamond } from "../libraries/LibDiamond.sol";
import { IDiamondCut } from "../interfaces/IDiamondCut.sol";
import "../interfaces/IDiamondLoupe.sol";
import "../interfaces/IDiamondCut.sol";
import "../interfaces/IERC173.sol";
import "../interfaces/IERC165.sol";
import "../interfaces/IERC20.sol";
import {AppStorage} from "../libraries/LibAppStorage.sol";
import { INewToken, IUniswapV2Router02 } from "../interfaces/INewToken.sol";
contract TokenDiamond {
AppStorage internal s;
event Transfer(address indexed from, address indexed to, uint256 value);
event IncreasedLimits(uint256 maxWallet, uint256 maxTx);
constructor(IDiamondCut.FacetCut[] memory _diamondCut, INewToken.InitParams memory params) {
require(params.owner != address(0));
LibDiamond.diamondCut(_diamondCut, address(0), new bytes(0));
LibDiamond.setContractOwner(params.owner);
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[type(IERC173).interfaceId] = true;
ds.supportedInterfaces[type(IERC20).interfaceId] = true;
s.deployyyyerCa = payable(msg.sender);
s.isParent = false;
s.tokenFacet = address(bytes20(ds.facets[IERC20.name.selector]));
s.stakingFacet = params.stakingFacet;
s.minLiq = params.minLiq;
s.taxBuy = params.maxBuyTax;
s.maxBuyTax = params.maxBuyTax;
s.minBuyTax = params.minBuyTax;
s.lpTax = params.lpTax;
s.taxSell = params.maxSellTax;
s.maxSellTax = params.maxSellTax;
s.minSellTax = params.minSellTax;
s.initTaxType = params.initTaxType;
s.initInterval = params.initInterval;
s.countInterval = params.countInterval;
s.buyCount = 0;
s.decimals = 18;
s.isFreeTier = params.isFreeTier;
s.taxWallet = payable(params.taxWallet);
s.name = params.name;
s.symbol = params.symbol;
s.tTotal = params.supply*10**18;
s.taxSwapThreshold = params.taxSwapThreshold*10**18;
s.maxTaxSwap = params.maxSwap*10**18;
s.walletLimited = true;
s.maxWallet = s.tTotal * params.maxWallet / 100;
s.maxTx = s.tTotal * params.maxTx / 100;
if (params.maxWallet == 100 && params.maxTx == 100) {
s.walletLimited = false;
}
emit IncreasedLimits(params.maxWallet, params.maxTx);
s.balances[address(this)] = s.tTotal;
emit Transfer(address(0), address(this), s.tTotal);
s.preventSwap = params.preventSwap;
}
fallback() external payable {
LibDiamond.DiamondStorage storage ds;
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
address facet = address(bytes20(ds.facets[msg.sig]));
require(facet != address(0), "T1");
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
receive() external payable {}
}
{
"compilationTarget": {
"contracts/facets/TokenDiamond.sol": "TokenDiamond"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamondCut.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct IDiamondCut.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"taxWallet","type":"address"},{"internalType":"address","name":"stakingFacet","type":"address"},{"internalType":"address","name":"v2router","type":"address"},{"internalType":"bool","name":"isFreeTier","type":"bool"},{"internalType":"uint256","name":"minLiq","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"initTaxType","type":"uint256"},{"internalType":"uint256","name":"initInterval","type":"uint256"},{"internalType":"uint256","name":"countInterval","type":"uint256"},{"internalType":"uint256","name":"maxBuyTax","type":"uint256"},{"internalType":"uint256","name":"minBuyTax","type":"uint256"},{"internalType":"uint256","name":"maxSellTax","type":"uint256"},{"internalType":"uint256","name":"minSellTax","type":"uint256"},{"internalType":"uint256","name":"lpTax","type":"uint256"},{"internalType":"uint256","name":"maxWallet","type":"uint256"},{"internalType":"uint256","name":"maxTx","type":"uint256"},{"internalType":"uint256","name":"preventSwap","type":"uint256"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"taxSwapThreshold","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"internalType":"struct INewToken.InitParams","name":"params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxWallet","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxTx","type":"uint256"}],"name":"IncreasedLimits","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":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]