编译器
0.8.24+commit.e11b9ed9
文件 1 的 8:Context.sol
pragma solidity ^0.8.9;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return payable(msg.sender);
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 2 的 8:ERC20.sol
pragma solidity ^0.8.9;
import "./Context.sol";
import "./IERC20.sol";
import "./SafeMath.sol";
import "./IUniswapV2Router02.sol";
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
IUniswapV2Router02 public uniswapRouter;
address public wethAddress;
address[] public pairsList;
address public lpPair;
bool public isTradingEnabled = false;
mapping (address => uint256) private _balances;
mapping (address => bool) public isExcludedFromFee;
mapping (address => bool) public isPair;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint256 public transferFee = 0;
uint256 public buyFee = 20;
uint256 public sellFee = 20;
string private _name;
string private _symbol;
uint8 private _decimals;
bool inSwap;
bool public contractSwapEnabled = false;
uint256 public swapThreshold;
uint256 public swapAmount;
bool public piContractSwapsEnabled;
uint256 public piSwapPercent;
struct TaxWallets {
address payable development;
}
TaxWallets public _taxWallets = TaxWallets({
development: payable(0x3a5198c44E14C61C5Af67C8b44DbA19533FeD23d)
});
event SwapTokensForETH(uint256 tokenAmount, address[] path);
event LiquidityAdded(uint256 amountTokenA, uint256 amountETH);
event ContractSwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, 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) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
bool buy = false;
bool sell = false;
bool other = false;
if (isPair[sender]) {
buy = true;
} else if (isPair[recipient]) {
sell = true;
} else {
other = true;
}
_beforeTokenTransfer(sender, recipient, amount);
if (!isExcludedFromFee[sender] && !isExcludedFromFee[recipient]) {
require(isTradingEnabled, "ERC20: Trading is not enabled yet..");
if (sell) {
if (!inSwap) {
if (contractSwapEnabled) {
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= swapThreshold) {
uint256 swapAmt = swapAmount;
if (piContractSwapsEnabled) { swapAmt = (balanceOf(lpPair) * piSwapPercent); }
if (contractTokenBalance >= swapAmt) { contractTokenBalance = swapAmt; }
contractSwap(contractTokenBalance);
}
}
}
}
if (!isPair[sender] && !isPair[recipient]) {
uint256 fee = amount.mul(transferFee).div(100);
amount = amount.sub(fee);
_balances[sender] = _balances[sender].sub(fee, "ERC20: transfer amount exceeds balance");
_balances[address(this)] = _balances[address(this)].add(fee);
emit Transfer(sender, address(this), fee);
}
if (isPair[sender]) {
uint256 fee = amount.mul(buyFee).div(100);
amount = amount.sub(fee);
_balances[sender] = _balances[sender].sub(fee, "ERC20: transfer amount exceeds balance");
_balances[address(this)] = _balances[address(this)].add(fee);
emit Transfer(sender, address(this), fee);
}
if (isPair[recipient]) {
uint256 fee = amount.mul(sellFee).div(100);
amount = amount.sub(fee);
_balances[sender] = _balances[sender].sub(fee, "ERC20: transfer amount exceeds balance");
_balances[address(this)] = _balances[address(this)].add(fee);
emit Transfer(sender, address(this), fee);
}
}
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function contractSwap(uint256 contractTokenBalance) internal lockTheSwap {
if(_allowances[address(this)][address(uniswapRouter)] != type(uint256).max) {
_allowances[address(this)][address(uniswapRouter)] = type(uint256).max;
}
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapRouter.WETH();
try uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0,
path,
address(this),
block.timestamp
) {} catch {
return;
}
uint256 amtBalance = address(this).balance;
bool success;
uint256 developmentBalance = amtBalance;
(success,) = _taxWallets.development.call{value: developmentBalance, gas: 35000}("");
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(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 _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
文件 3 的 8:IERC20.sol
pragma solidity ^0.8.9;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, 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 sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 4 的 8:IUniswapV2Router01.sol
pragma solidity ^0.8.9;
interface IUniswapV2Router01 {
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);
}
文件 5 的 8:IUniswapV2Router02.sol
pragma solidity ^0.8.9;
import "./IUniswapV2Router01.sol";
interface IUniswapV2Router02 is IUniswapV2Router01 {
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;
}
文件 6 的 8:JUICE.sol
pragma solidity ^0.8.9;
import "./ERC20.sol";
import "./Ownable.sol";
contract JUICE is ERC20, Ownable {
uint256 constant private startingSupply = 10_000_000;
uint256 constant private _tTotal = startingSupply * 10 **18;
constructor(address _router) ERC20("JUICE", "JUICE") {
_mint(msg.sender, _tTotal);
uniswapRouter = IUniswapV2Router02(_router);
isExcludedFromFee[address(this)] = true;
isExcludedFromFee[msg.sender] = true;
}
function enableTrading() public onlyOwner {
require(!isTradingEnabled, "JUICE: Trading is alredy enabled");
require(pairsList.length > 0, "JUICE: Please add all the pairs first");
isTradingEnabled = true;
contractSwapEnabled = true;
emit ContractSwapEnabledUpdated(true);
}
function excludeOrInclude(address user, bool value) public onlyOwner {
require(isExcludedFromFee[user] != value, "JUICE: Already set as same value");
isExcludedFromFee[user] = value;
}
function addOrRemovePairs(address pair, bool value) public onlyOwner {
require(isPair[pair] != value, "JUICE: Already set as same value");
isPair[pair] = value;
pairsList.push(pair);
if (lpPair == address(0)) {
lpPair = pair;
}
}
function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner {
swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor;
swapAmount = (_tTotal * amountPercent) / amountDivisor;
require(swapThreshold <= swapAmount, "Threshold cannot be above amount.");
require(swapAmount <= (balanceOf(lpPair) * 20) / 1000, "Cannot be above 2% of current PI.");
require(swapAmount >= _tTotal / 10_000_000, "Cannot be lower than 0.00001% of total supply.");
require(swapThreshold >= _tTotal / 10_000_000, "Cannot be lower than 0.00001% of total supply.");
}
function setPriceImpactSwapAmount(uint256 priceImpactSwapPercent) external onlyOwner {
require(priceImpactSwapPercent <= 100, "Cannot set above 1%.");
piSwapPercent = priceImpactSwapPercent;
}
function setContractSwapEnabled(bool swapEnabled, bool priceImpactSwapEnabled) external onlyOwner {
contractSwapEnabled = swapEnabled;
piContractSwapsEnabled = priceImpactSwapEnabled;
emit ContractSwapEnabledUpdated(swapEnabled);
}
function updateDevelopmentAddress(address payable development) public onlyOwner {
require(_taxWallets.development != development, "JUICE: Already set as same address");
_taxWallets.development = payable(development);
}
function updateFees(uint256 transfer, uint256 buy, uint256 sell) public onlyOwner {
transferFee = transfer;
buyFee = buy;
sellFee = sell;
}
function transferEther() public onlyOwner {
payable(owner()).transfer(address(this).balance);
}
function transferAnyERC20Tokens(address tokenAddress, address recipient, uint256 amount) public onlyOwner {
require(amount > 0, "JUICE: amount must be greater than 0");
require(recipient != address(0), "JUICE: recipient is the zero address");
IERC20(tokenAddress).transfer(recipient, amount);
}
receive() external payable { }
}
文件 7 的 8:Ownable.sol
pragma solidity ^0.8.9;
import "./Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 8 的 8:SafeMath.sol
pragma solidity ^0.8.9;
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;
}
}
{
"compilationTarget": {
"contracts/JUICE.sol": "JUICE"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"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":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"ContractSwapEnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountTokenA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountETH","type":"uint256"}],"name":"LiquidityAdded","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":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"}],"name":"SwapTokensForETH","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":"_taxWallets","outputs":[{"internalType":"address payable","name":"development","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"addOrRemovePairs","outputs":[],"stateMutability":"nonpayable","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":"buyFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractSwapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"excludeOrInclude","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPair","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTradingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpPair","outputs":[{"internalType":"address","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":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pairsList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"piContractSwapsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"piSwapPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"swapEnabled","type":"bool"},{"internalType":"bool","name":"priceImpactSwapEnabled","type":"bool"}],"name":"setContractSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"priceImpactSwapPercent","type":"uint256"}],"name":"setPriceImpactSwapAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"thresholdPercent","type":"uint256"},{"internalType":"uint256","name":"thresholdDivisor","type":"uint256"},{"internalType":"uint256","name":"amountPercent","type":"uint256"},{"internalType":"uint256","name":"amountDivisor","type":"uint256"}],"name":"setSwapSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferAnyERC20Tokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","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":[],"name":"uniswapRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"development","type":"address"}],"name":"updateDevelopmentAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"transfer","type":"uint256"},{"internalType":"uint256","name":"buy","type":"uint256"},{"internalType":"uint256","name":"sell","type":"uint256"}],"name":"updateFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wethAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]