编译器
0.8.22+commit.4fc1097e
文件 1 的 14:Address.sol
pragma solidity ^0.8.20;
library Address {
error AddressInsufficientBalance(address account);
error AddressEmptyCode(address target);
error FailedInnerCall();
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
function _revert(bytes memory returndata) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
文件 2 的 14:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 14:ERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
文件 4 的 14: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);
}
}
文件 5 的 14:IERC20.sol
pragma solidity ^0.8.20;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 6 的 14:IERC20Metadata.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 7 的 14:IERC20Permit.sol
pragma solidity ^0.8.20;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 8 的 14: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;
}
文件 9 的 14: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);
}
文件 10 的 14: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;
}
文件 11 的 14:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 12 的 14:SafeERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
library SafeERC20 {
using Address for address;
error SafeERC20FailedOperation(address token);
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
文件 13 的 14:YieldMagnetToken.sol
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
struct StakingContract {
address contractAddress;
uint8 percentage;
}
contract YieldMagnetToken is ERC20, Ownable {
using SafeERC20 for IERC20;
struct WalletState {
bool isMarketPair;
bool isExemptFromTax;
}
mapping(address => WalletState) public walletStates;
uint8 public buyTax = 0;
uint8 public sellTax = 0;
uint8 public platformPercentage = 60;
uint8 public stakerPercentage = 20;
uint8 public lpPercentage = 20;
bool private _isTaxRenounced = false;
bool private _isTaxEnabled = true;
bool public isTradingOpen = false;
bool private _inSwap = false;
uint256 public taxDistributionThreshold = 5_000_000 * 10 ** 18;
IUniswapV2Router02 public uniswapV2Router;
address public taxAddress;
address public lpAddress;
StakingContract[] private _stakingContracts;
event TaxDistributed(
uint256 platformCut,
uint256 stakersCut,
uint256 liquidityCut
);
event LiquidityAdded(uint256 tokenAmount, uint256 ethAmount);
event PlatformTaxDistributed(uint256 amount);
event UniswapRouterUpdated(address newRouter);
event ExcludedFromFeesUpdated(address wallet, bool isExcluded);
event MarketPairUpdated(address pair, bool isMarketPair);
event StakingContractsUpdated(
address[] stakingContracts,
uint8[] percentages
);
event TaxAddressUpdated(address newTaxAddress);
event LpAddressUpdated(address newLpAddress);
event TradingOpen();
event TaxRenounced();
event TaxStatusUpdated(bool isTaxEnabled);
event TaxesUpdated(uint8 buyTax, uint8 sellTax);
event DistributionThresholdUpdated(uint256 newThreshold);
event DistributionPercentagesUpdated(
uint8 platformPercentage,
uint8 stakerPercentage,
uint8 lpPercentage
);
constructor() ERC20("Yield Magnet", "MAGNET") Ownable(msg.sender) {
super._update(address(0), msg.sender, (1_000_000_000 * 10 ** 18));
address uniswapV2Router02Address = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
uniswapV2Router02Address
);
address uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
_approve(address(this), uniswapV2Router02Address, type(uint256).max);
setMarketPair(uniswapV2Pair, true);
taxAddress = msg.sender;
lpAddress = msg.sender;
walletStates[msg.sender] = WalletState({
isMarketPair: false,
isExemptFromTax: true
});
emit ExcludedFromFeesUpdated(msg.sender, true);
walletStates[address(this)] = WalletState({
isMarketPair: false,
isExemptFromTax: true
});
emit ExcludedFromFeesUpdated(address(this), true);
walletStates[uniswapV2Router02Address] = WalletState({
isMarketPair: false,
isExemptFromTax: true
});
emit ExcludedFromFeesUpdated(uniswapV2Router02Address, true);
}
receive() external payable {}
function isTaxExempt(address account_) external view returns (bool) {
return walletStates[account_].isExemptFromTax;
}
function isTaxEnabled() external view returns (bool) {
return _isTaxEnabled;
}
function isTaxRenounced() external view returns (bool) {
return _isTaxRenounced;
}
function _update(
address from,
address to,
uint256 amount
) internal override {
uint256 fromBalance = balanceOf(from);
require(
fromBalance >= amount,
"ERC20: transfer amount exceeds balance"
);
WalletState memory fromState = walletStates[from];
WalletState memory toState = walletStates[to];
bool isTaxExempt_ = (fromState.isExemptFromTax || toState.isExemptFromTax);
uint256 taxAmount;
if(fromState.isMarketPair || toState.isMarketPair) {
require(isTradingOpen || msg.sender == owner() || tx.origin == owner(), "Trading not open yet");
}
if (fromState.isMarketPair && isTaxExempt_ == false && _isTaxEnabled) {
taxAmount = (amount * buyTax) / 100;
} else if (
toState.isMarketPair && isTaxExempt_ == false && _isTaxEnabled
) {
taxAmount = (amount * sellTax) / 100;
} else {
taxAmount = 0;
}
if (
balanceOf(address(this)) > taxDistributionThreshold &&
_inSwap == false &&
fromState.isMarketPair == false &&
toState.isMarketPair == true
) {
try this.distributeTax() {} catch(bytes memory) {}
}
if (taxAmount != 0 && _inSwap == false) {
super._update(from, to, amount - taxAmount);
super._update(from, address(this), taxAmount);
} else {
super._update(from, to, amount);
}
}
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
function distributeTax() external lockTheSwap {
require(msg.sender == address(this) || msg.sender == owner(), "owner/contract only");
uint256 contractBalance = balanceOf(address(this));
uint256 platformCut = (contractBalance * platformPercentage) / 100;
uint256 stakerCut = (contractBalance * stakerPercentage) / 100;
uint256 lpCut = (contractBalance * lpPercentage) / 100;
require(
(platformCut + stakerCut + lpCut) <= balanceOf(address(this)),
"YieldMagnet: Can't distribute the funds"
);
_distributeStakersCut(stakerCut);
_handleLiquidityAndPlatformCut(platformCut, lpCut);
emit TaxDistributed(platformCut, stakerCut, lpCut);
}
function _distributeStakersCut(uint256 stakersCut_) private {
for (uint256 i = 0; i < _stakingContracts.length; i++) {
StakingContract memory sc = _stakingContracts[i];
uint256 stakerContractCut = (sc.percentage * stakersCut_) / 100;
super._update(address(this), sc.contractAddress, stakerContractCut);
}
}
function _handleLiquidityAndPlatformCut(uint256 platformCut, uint256 lpCut) private {
uint256 initBal = address(this).balance;
_swapTokensForEth(lpCut/2 - 1 + platformCut);
if(lpCut > 0) {
uint256 receiveBalance = address(this).balance - initBal;
uint256 ethForLiq = receiveBalance * lpCut / (lpCut + platformCut);
_addLiquidity(lpCut/2, ethForLiq);
emit LiquidityAdded(lpCut/2, ethForLiq);
}
uint256 amount = address(this).balance;
(bool success,) = taxAddress.call{value: amount}("");
require(success, "YieldMagnet: Failed to send ETH to tax address");
emit PlatformTaxDistributed(amount);
}
function _swapTokensForEth(uint256 tokenAmount_) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
require(
tokenAmount_ > 0,
"YieldMagnet: Token amount less then 0 for token swap"
);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount_,
0,
path,
address(this),
block.timestamp
);
}
function _addLiquidity(uint256 tokenAmount_, uint256 ethAmount_) private {
uniswapV2Router.addLiquidityETH{value: ethAmount_}(
address(this),
tokenAmount_,
0,
0,
lpAddress,
block.timestamp
);
}
function getStakingContracts()
public
view
returns (StakingContract[] memory)
{
return _stakingContracts;
}
function updateStakingContracts(
address[] memory stakingContracts_,
uint8[] memory percentages_
) external onlyOwner {
require(
stakingContracts_.length == percentages_.length,
"YieldMagnet: No of address and No of Percentages doesn't match!"
);
require(stakingContracts_.length <= 10, "YieldMagnet: Max 10 staking contracts allowed!");
delete _stakingContracts;
uint8 totalPercent = 0;
for (uint256 i = 0; i < stakingContracts_.length; i++) {
require(
percentages_[i] >= 0 && percentages_[i] <= 100,
"YieldMagnet: percentage should be between 0 to 100!"
);
require(
stakingContracts_[i] != address(0),
"YieldMagnet: Staking contract may not be 0x0"
);
_stakingContracts.push(
StakingContract(stakingContracts_[i], percentages_[i])
);
totalPercent += percentages_[i];
}
require(
totalPercent == 100,
"YieldMagnet: Total Percentage should be 100."
);
emit StakingContractsUpdated(stakingContracts_, percentages_);
}
function openTrading() external onlyOwner {
require(isTradingOpen == false, "Trading already open");
isTradingOpen = true;
buyTax = 10;
sellTax = 10;
emit TradingOpen();
}
function renounceTax() public onlyOwner {
_isTaxRenounced = true;
emit TaxRenounced();
}
function updateUniswapRouter(address newRouter) external onlyOwner {
address oldAddress = address(uniswapV2Router);
require(oldAddress != newRouter, "Address already set");
_approve(address(this), oldAddress, 0);
_approve(address(this), newRouter, type(uint256).max);
uniswapV2Router = IUniswapV2Router02(newRouter);
emit UniswapRouterUpdated(newRouter);
}
function setTaxExempt(address account, bool isExempt) external onlyOwner {
require(account != address(this), "Can't change contract");
WalletState memory state = walletStates[account];
state.isExemptFromTax = isExempt;
walletStates[account] = state;
emit ExcludedFromFeesUpdated(account, isExempt);
}
function setTaxEnabled(bool taxStatus_) external onlyOwner {
_isTaxEnabled = taxStatus_;
emit TaxStatusUpdated(taxStatus_);
}
function setTaxAddress(address newTaxAddress_) external onlyOwner {
taxAddress = newTaxAddress_;
emit TaxAddressUpdated(newTaxAddress_);
}
function setLpAddress(address newLpAddress_) external onlyOwner {
lpAddress = newLpAddress_;
emit LpAddressUpdated(newLpAddress_);
}
function setTaxAmount(
uint8 newBuyTax_,
uint8 newSellTax_
) external onlyOwner {
require(_isTaxRenounced == false, "YieldMagnet: Tax is renounced!");
require(
newBuyTax_ <= 10 && newSellTax_ <= 10,
"YieldMagnet: Tax Should be less then 10!"
);
buyTax = newBuyTax_;
sellTax = newSellTax_;
emit TaxesUpdated(newBuyTax_, newSellTax_);
}
function setMarketPair(address account, bool value) public onlyOwner {
require(account != address(this), "cant change contract");
WalletState memory state = walletStates[account];
state.isMarketPair = value;
walletStates[account] = state;
emit MarketPairUpdated(account, value);
}
function setDistributionPercentage(
uint8 platformPercentage_,
uint8 stakerPercentage_,
uint8 lpPercentage_
) external onlyOwner {
require(
(platformPercentage_ + stakerPercentage_ + lpPercentage_) == 100,
"YieldMagnet: Percentage should sum to 100!"
);
platformPercentage = platformPercentage_;
stakerPercentage = stakerPercentage_;
lpPercentage = lpPercentage_;
emit DistributionPercentagesUpdated(
platformPercentage_,
stakerPercentage_,
lpPercentage_
);
}
function changeTaxDistributionThreshold(
uint256 newTaxDistributionThreshold_
) external onlyOwner {
require(
newTaxDistributionThreshold_ > 0,
"YieldMagnet: Threshold can't be 0"
);
taxDistributionThreshold = newTaxDistributionThreshold_ * 10 ** 18;
emit DistributionThresholdUpdated(newTaxDistributionThreshold_);
}
function rescueStuckTokens(
address tokenAddress_,
uint256 amount_
) external onlyOwner {
require(amount_ > 0, "YieldMagnet: amount can't be 0");
IERC20 token = IERC20(tokenAddress_);
token.safeTransfer(msg.sender, amount_);
}
function rescueStuckETH(uint256 amount_) external onlyOwner {
require(amount_ > 0, "YieldMagnet: amount can't be 0");
(bool success,) = msg.sender.call{value: amount_}("");
require(success, "failed to send eth");
}
}
文件 14 的 14:draft-IERC6093.sol
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"YieldMagnetToken.sol": "YieldMagnetToken"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"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":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","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":false,"internalType":"uint8","name":"platformPercentage","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"stakerPercentage","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"lpPercentage","type":"uint8"}],"name":"DistributionPercentagesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newThreshold","type":"uint256"}],"name":"DistributionThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"wallet","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludedFromFeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"LiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newLpAddress","type":"address"}],"name":"LpAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"bool","name":"isMarketPair","type":"bool"}],"name":"MarketPairUpdated","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":"amount","type":"uint256"}],"name":"PlatformTaxDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"stakingContracts","type":"address[]"},{"indexed":false,"internalType":"uint8[]","name":"percentages","type":"uint8[]"}],"name":"StakingContractsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newTaxAddress","type":"address"}],"name":"TaxAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"platformCut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakersCut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidityCut","type":"uint256"}],"name":"TaxDistributed","type":"event"},{"anonymous":false,"inputs":[],"name":"TaxRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isTaxEnabled","type":"bool"}],"name":"TaxStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"buyTax","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"sellTax","type":"uint8"}],"name":"TaxesUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"TradingOpen","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":"newRouter","type":"address"}],"name":"UniswapRouterUpdated","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":"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":[],"name":"buyTax","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newTaxDistributionThreshold_","type":"uint256"}],"name":"changeTaxDistributionThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributeTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getStakingContracts","outputs":[{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint8","name":"percentage","type":"uint8"}],"internalType":"struct StakingContract[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTaxEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"isTaxExempt","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTaxRenounced","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTradingOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platformPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"rescueStuckETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"rescueStuckTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellTax","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"platformPercentage_","type":"uint8"},{"internalType":"uint8","name":"stakerPercentage_","type":"uint8"},{"internalType":"uint8","name":"lpPercentage_","type":"uint8"}],"name":"setDistributionPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newLpAddress_","type":"address"}],"name":"setLpAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setMarketPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTaxAddress_","type":"address"}],"name":"setTaxAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"newBuyTax_","type":"uint8"},{"internalType":"uint8","name":"newSellTax_","type":"uint8"}],"name":"setTaxAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"taxStatus_","type":"bool"}],"name":"setTaxEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isExempt","type":"bool"}],"name":"setTaxExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakerPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxDistributionThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"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":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"stakingContracts_","type":"address[]"},{"internalType":"uint8[]","name":"percentages_","type":"uint8[]"}],"name":"updateStakingContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRouter","type":"address"}],"name":"updateUniswapRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"walletStates","outputs":[{"internalType":"bool","name":"isMarketPair","type":"bool"},{"internalType":"bool","name":"isExemptFromTax","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]