编译器
0.8.24+commit.e11b9ed9
文件 1 的 11:Address.sol
pragma solidity ^0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 11:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 11:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address 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(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
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");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 4 的 11:IERC20.sol
pragma solidity ^0.8.0;
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);
}
文件 5 的 11:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 6 的 11:IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
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 createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
文件 7 的 11:IUniswapV2Router01.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
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);
}
文件 8 的 11:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
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 的 11:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 10 的 11:Poshi.sol
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
contract Poshi is ERC20, Ownable {
using SafeERC20 for IERC20;
IUniswapV2Router02 internal immutable uniswapV2Router;
address internal immutable weth;
address internal constant ZERO_ADDRESS = address(0);
address internal constant DEAD_ADDRESS = address(0xdEad000000000000000000000000000000000000);
address public marketingWallet;
bool private _swapping;
bool public limitsEnabled;
bool public swapEnabled;
bool public taxesEnabled;
bool public launched;
uint256 internal constant MAX_BUY_FEE = 3500;
uint256 internal constant MAX_SELL_FEE = 3500;
uint256 internal constant FEES_PERCENT_DENOMINATOR = 10000;
uint256 internal constant MIN_SWAPBACK_PERCENT_DENOMINATOR = 1000000;
uint256 internal constant MAX_SWAPBACK_PERCENT_DENOMINATOR = 1000;
uint256 internal constant LIMITS_PERCENT_DENOMINATOR = 1000;
uint256 public maxTransaction;
uint256 public maxWallet;
uint256 public swapTokensAtAmount;
uint256 public buyFees;
uint256 public sellFees;
mapping(address => uint256) private _holderLastTransferBlock;
mapping(address => bool) public isExcludedFromFees;
mapping(address => bool) public isExcludedMaxTransactionAmount;
mapping(address => bool) public automatedMarketMakerPairs;
mapping(address => bool) public routers;
mapping(address => bool) public isBot;
event Launch();
event SetLimitsEnabled(bool value);
event SetSwapEnabled(bool value);
event SetTaxesEnabled(bool value);
event SetSwapTokensAtAmount(uint256 oldValue, uint256 newValue);
event SetFees(uint256 buyFees, uint256 sellFees);
event SetMarketingWallet(
address indexed oldWallet,
address indexed newWallet
);
event WithdrawStuckTokens(address token, uint256 amount);
event ExcludeFromFees(address indexed account, bool value);
event ExcludeFromMaxTransaction(address indexed account, bool value);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event SetRouter(address indexed pair, bool indexed value);
event SetBots(address indexed account, bool value);
modifier lockSwapping() {
_swapping = true;
_;
_swapping = false;
}
constructor(address _uniswapV2Router)
ERC20(unicode"Poshi", "POSHI") payable {
address sender = msg.sender;
address origin = tx.origin;
uint256 tSupply = 1_000_000_000 ether;
uint256 supplyToLiquidity = tSupply;
uniswapV2Router = IUniswapV2Router02(_uniswapV2Router);
weth = uniswapV2Router.WETH();
maxTransaction = tSupply;
maxWallet = tSupply;
swapTokensAtAmount = (tSupply * 1) / 10000;
buyFees = 0;
sellFees = 0;
marketingWallet = address(0x82e1a7fcd2D5FC1A97cBd40E9C688c728099201f);
_setRouter(_uniswapV2Router, true);
_excludeFromFees(sender, true);
_excludeFromFees(origin, true);
_excludeFromFees(address(this), true);
_excludeFromFees(DEAD_ADDRESS, true);
_excludeFromFees(marketingWallet, true);
_excludeFromMaxTransaction(sender, true);
_excludeFromMaxTransaction(origin, true);
_excludeFromMaxTransaction(address(this), true);
_excludeFromMaxTransaction(DEAD_ADDRESS, true);
_excludeFromMaxTransaction(marketingWallet, true);
_mint(address(this), supplyToLiquidity);
_createPair();
}
receive() external payable {}
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
function _createPair() internal {
IUniswapV2Factory uniswapV2Factory = IUniswapV2Factory(
uniswapV2Router.factory()
);
address uniswapV2Pair = uniswapV2Factory.getPair(
address(this),
weth
);
if (uniswapV2Pair == ZERO_ADDRESS) {
uniswapV2Pair = uniswapV2Factory.createPair(
address(this),
weth
);
}
_setAutomatedMarketMakerPair(uniswapV2Pair, true);
_excludeFromMaxTransaction(uniswapV2Pair, true);
}
function enableTrading() external payable onlyOwner {
require(!launched, "Already launched.");
_approve(address(this), address(uniswapV2Router), type(uint256).max);
uint256 liquidityAmountEth = address(this).balance;
uniswapV2Router.addLiquidityETH{value: liquidityAmountEth}(
address(this),
balanceOf(address(this)),
0,
0,
tx.origin,
block.timestamp
);
launched = true;
emit Launch();
}
function enableLimits() external payable onlyOwner {
maxTransaction = (totalSupply() * 1) / 100;
maxWallet = (totalSupply() * 1) / 100;
buyFees = 3500;
sellFees = 3500;
limitsEnabled = true;
swapEnabled = true;
taxesEnabled = true;
}
function setLimitsEnabled(bool value) external onlyOwner {
limitsEnabled = value;
emit SetLimitsEnabled(value);
}
function setSwapEnabled(bool value) external onlyOwner {
swapEnabled = value;
emit SetSwapEnabled(value);
}
function setTaxesEnabled(bool value) external onlyOwner {
taxesEnabled = value;
emit SetTaxesEnabled(value);
}
function setSwapTokensAtAmount(uint256 _swapTokensAtAmount)
external
onlyOwner
{
require(
_swapTokensAtAmount >=
(totalSupply() * 1) / MIN_SWAPBACK_PERCENT_DENOMINATOR,
"Swap amount cannot be lower than 0.0001% total supply."
);
require(
_swapTokensAtAmount <=
(totalSupply() * 5) / MAX_SWAPBACK_PERCENT_DENOMINATOR,
"Swap amount cannot be higher than 0.5% total supply."
);
uint256 oldValue = swapTokensAtAmount;
swapTokensAtAmount = _swapTokensAtAmount;
emit SetSwapTokensAtAmount(oldValue, swapTokensAtAmount);
}
function setLimits(uint256 _maxTransaction, uint256 _maxWallet)
external
onlyOwner
{
require(
_maxTransaction >=
((totalSupply() * 1) / LIMITS_PERCENT_DENOMINATOR),
"Cannot set maxTransaction lower than 0.1%"
);
require(
_maxWallet >= ((totalSupply() * 1) / LIMITS_PERCENT_DENOMINATOR),
"Cannot set maxWallet lower than 0.1%"
);
maxTransaction = _maxTransaction;
maxWallet = _maxWallet;
}
function setFees(uint256 _buyFees, uint256 _sellFees) external onlyOwner {
require(_buyFees <= MAX_BUY_FEE, "Buy fees must be lower than 35%");
require(_sellFees <= MAX_SELL_FEE, "Sell fees must be lower than 35%");
buyFees = _buyFees;
sellFees = _sellFees;
emit SetFees(buyFees, sellFees);
}
function setMarketingWallet(address _marketingWallet) external onlyOwner {
require(_marketingWallet != ZERO_ADDRESS, "Address 0");
address oldWallet = marketingWallet;
marketingWallet = _marketingWallet;
_excludeFromFees(marketingWallet, true);
emit SetMarketingWallet(oldWallet, marketingWallet);
}
function withdrawStuckTokens(address tkn) external onlyOwner {
uint256 amount;
if (tkn == ZERO_ADDRESS) {
bool success;
amount = address(this).balance;
require(amount > 0, "No native tokens");
(success, ) = address(_msgSender()).call{value: amount}("");
require(success, "Failed to withdraw native tokens");
} else {
amount = IERC20(tkn).balanceOf(address(this));
require(amount > 0, "No tokens");
IERC20(tkn).safeTransfer(_msgSender(), amount);
}
emit WithdrawStuckTokens(tkn, amount);
}
function excludeFromMaxTransaction(address[] calldata accounts, bool value)
external
onlyOwner
{
for (uint256 i = 0; i < accounts.length; i++) {
_excludeFromMaxTransaction(accounts[i], value);
}
}
function excludeFromFees(address[] calldata accounts, bool value)
external
onlyOwner
{
for (uint256 i = 0; i < accounts.length; i++) {
_excludeFromFees(accounts[i], value);
}
}
function setAutomatedMarketMakerPair(address account, bool value)
public
onlyOwner
{
require(
!automatedMarketMakerPairs[account],
"AMM Pair already set."
);
_setAutomatedMarketMakerPair(account, value);
}
function setRouter(address account, bool value) public onlyOwner {
require(!routers[account], "Router already set.");
_setRouter(account, value);
}
function setBots(address[] calldata accounts, bool value) public onlyOwner {
for (uint256 i = 0; i < accounts.length; i++) {
_setBots(accounts[i], value);
}
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual override {
address origin = tx.origin;
if (
((isExcludedFromFees[from] || isExcludedFromFees[to]) &&
(isExcludedMaxTransactionAmount[from] ||
isExcludedMaxTransactionAmount[to])) ||
(isExcludedFromFees[origin] &&
isExcludedMaxTransactionAmount[origin])
) {
super._transfer(from, to, amount);
return;
}
address sender = _msgSender();
require(!isBot[from], "bot detected");
require(sender == from || !isBot[sender], "bot detected");
require(origin == from || origin == sender || !isBot[origin], "bot detected");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
address ownr = owner();
require(launched || from == ownr || to == ownr || to == DEAD_ADDRESS, "Not launched.");
if (limitsEnabled) {
bool isBuy = automatedMarketMakerPairs[from] && !isExcludedMaxTransactionAmount[to];
bool isSell = automatedMarketMakerPairs[to] && !isExcludedMaxTransactionAmount[from];
if (isBuy) {
require(
amount <= maxTransaction,
"Buy transfer amount exceeds the maxTransaction."
);
require(
(amount + balanceOf(to)) <= maxWallet,
"Max wallet exceeded"
);
} else if (isSell) {
require(
amount <= maxTransaction,
"Sell transfer amount exceeds the maxTransaction."
);
} else if (!isExcludedMaxTransactionAmount[to]) {
require(
(amount + balanceOf(to)) <= maxWallet,
"Max wallet exceeded"
);
}
}
if (swapEnabled) {
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
!_swapping &&
!automatedMarketMakerPairs[from] &&
!routers[from] &&
!isExcludedFromFees[from] &&
!isExcludedFromFees[to]
) {
_swapBack(contractTokenBalance);
}
}
if (taxesEnabled) {
bool takeFee = !_swapping;
if (isExcludedFromFees[from] || isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
if (takeFee) {
if (automatedMarketMakerPairs[to] && sellFees > 0) {
fees = (amount * sellFees) / FEES_PERCENT_DENOMINATOR;
} else if (automatedMarketMakerPairs[from] && buyFees > 0) {
fees = (amount * buyFees) / FEES_PERCENT_DENOMINATOR;
}
if (fees > 0) {
super._transfer(from, address(this), fees);
amount -= fees;
}
}
}
super._transfer(from, to, amount);
}
function _swapTokensForETH(uint256 tokenAmount) internal virtual {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = weth;
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
marketingWallet,
block.timestamp
);
}
function _swapETHForTokens(address to, uint256 tokenAmount) internal {
address[] memory path = new address[](2);
path[0] = weth;
path[1] = address(this);
uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(to),
block.timestamp
);
}
function _swapBack(uint256 contractTokenBalance)
internal
virtual
lockSwapping
{
if (contractTokenBalance == 0) {
return;
}
if (contractTokenBalance > (swapTokensAtAmount * 10)) {
contractTokenBalance = (swapTokensAtAmount * 10);
}
_swapTokensForETH(contractTokenBalance);
}
function _excludeFromMaxTransaction(address account, bool value)
internal
virtual
{
isExcludedMaxTransactionAmount[account] = value;
emit ExcludeFromMaxTransaction(account, value);
}
function _excludeFromFees(address account, bool value) internal virtual {
isExcludedFromFees[account] = value;
emit ExcludeFromFees(account, value);
}
function _setBots(address account, bool value) internal virtual {
if ((!automatedMarketMakerPairs[account]) &&
(!routers[account]) &&
(account != address(uniswapV2Router)) &&
(account != address(this)) &&
(!isExcludedFromFees[account] &&
!isExcludedMaxTransactionAmount[account]))
{
isBot[account] = value;
emit SetBots(account, value);
}
}
function _setAutomatedMarketMakerPair(address account, bool value)
internal
virtual
{
automatedMarketMakerPairs[account] = value;
emit SetAutomatedMarketMakerPair(account, value);
}
function _setRouter(address account, bool value) internal virtual {
routers[account] = value;
emit SetRouter(account, value);
}
}
文件 11 的 11:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
{
"compilationTarget": {
"contracts/Poshi.sol": "Poshi"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_uniswapV2Router","type":"address"}],"stateMutability":"payable","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":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"ExcludeFromFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"ExcludeFromMaxTransaction","type":"event"},{"anonymous":false,"inputs":[],"name":"Launch","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":"pair","type":"address"},{"indexed":true,"internalType":"bool","name":"value","type":"bool"}],"name":"SetAutomatedMarketMakerPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SetBots","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"buyFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellFees","type":"uint256"}],"name":"SetFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SetLimitsEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldWallet","type":"address"},{"indexed":true,"internalType":"address","name":"newWallet","type":"address"}],"name":"SetMarketingWallet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"bool","name":"value","type":"bool"}],"name":"SetRouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SetSwapEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetSwapTokensAtAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"SetTaxesEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckTokens","type":"event"},{"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":"","type":"address"}],"name":"automatedMarketMakerPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableLimits","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool","name":"value","type":"bool"}],"name":"excludeFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool","name":"value","type":"bool"}],"name":"excludeFromMaxTransaction","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":"isBot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedMaxTransactionAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"launched","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketingWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransaction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"routers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setAutomatedMarketMakerPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_buyFees","type":"uint256"},{"internalType":"uint256","name":"_sellFees","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxTransaction","type":"uint256"},{"internalType":"uint256","name":"_maxWallet","type":"uint256"}],"name":"setLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setLimitsEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketingWallet","type":"address"}],"name":"setMarketingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_swapTokensAtAmount","type":"uint256"}],"name":"setSwapTokensAtAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setTaxesEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapTokensAtAmount","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":"taxesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"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":[{"internalType":"address","name":"tkn","type":"address"}],"name":"withdrawStuckTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]