编译器
0.8.22+commit.4fc1097e
文件 1 的 15:AntiWhaleToken.sol
pragma solidity ^0.8.0;
import "./ERC20Base.sol";
abstract contract AntiWhaleToken is ERC20Base {
uint256 public maxTokenPerWallet;
event MaxTokenPerWalletUpdated(uint256 amount);
modifier antiWhale(
address sender,
address recipient,
uint256 amount
) {
if (maxTokenPerWallet != 0 && !isExcludedFromAntiWhale(recipient)) {
require(balanceOf(recipient) + amount <= maxTokenPerWallet, "Wallet exceeds max");
}
_;
}
constructor(uint256 maxTokenPerWallet_) {
maxTokenPerWallet = maxTokenPerWallet_;
}
function isExcludedFromAntiWhale(address account) public view virtual returns (bool);
function _setMaxTokenPerWallet(uint256 amount) internal {
require(amount == 0 || amount > (totalSupply() * 5) / 1000, "Amount too low");
maxTokenPerWallet = amount;
emit MaxTokenPerWalletUpdated(amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override antiWhale(from, to, amount) {
super._beforeTokenTransfer(from, to, amount);
}
}
文件 2 的 15: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 的 15:DORK.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "../libraries/AntiWhaleToken.sol";
import "../libraries/ERC20Base.sol";
import "../libraries/ERC20Burnable.sol";
import "../libraries/TaxableToken.sol";
contract DORK is
ERC20Base,
AntiWhaleToken,
ERC20Burnable,
Ownable,
TaxableToken
{
uint256 public constant initialSupply_ = 100_000_000_000 * 1 ether;
address private constant swapRouter_ = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address[] private collectors_ = [0x17b1F15F038bF0A1F872fa64345204210Cd1a5e5];
uint256[] private shares_ = [10000];
mapping(address => bool) private _excludedFromAntiWhale;
event ExcludedFromAntiWhale(address indexed account, bool excluded);
constructor()
ERC20Base(
"DORK",
"DORK",
18)
AntiWhaleToken(initialSupply_ / 100)
TaxableToken(
true,
initialSupply_ / 10000,
swapRouter_,
FeeConfiguration({
feesInToken: false,
buyFees: 200,
sellFees: 200,
transferFees: 0,
burnFeeRatio: 0,
liquidityFeeRatio: 0,
collectorsFeeRatio: 10000
})
)
TaxDistributor(collectors_, shares_)
{
_excludedFromAntiWhale[_msgSender()] = true;
_excludedFromAntiWhale[swapPair] = true;
_excludedFromAntiWhale[BURN_ADDRESS] = true;
_mint(_msgSender(), initialSupply_);
}
function setMaxTokenPerWallet(uint256 amount) external onlyOwner {
_setMaxTokenPerWallet(amount);
}
function setPairToken(address token) external onlyOwner {
swapPair = token;
}
function isExcludedFromAntiWhale(address account) public view override returns (bool) {
return _excludedFromAntiWhale[account];
}
function setIsExcludedFromAntiWhale(address account, bool excluded) external onlyOwner {
_excludedFromAntiWhale[account] = excluded;
emit ExcludedFromAntiWhale(account, excluded);
}
function burn(uint256 amount) external override onlyOwner {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) external override onlyOwner {
_burnFrom(account, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override(ERC20, AntiWhaleToken) {
super._beforeTokenTransfer(from, to, amount);
}
function setAutoprocessFees(bool autoProcess) external override onlyOwner {
require(autoProcessFees != autoProcess, "Already set");
autoProcessFees = autoProcess;
}
function addFeeCollector(address account, uint256 share) external override onlyOwner {
_addFeeCollector(account, share);
}
function setIsLpPool(address pairAddress, bool isLp) external override onlyOwner {
_setIsLpPool(pairAddress, isLp);
}
function setIsExcludedFromFees(address account, bool excluded) external override onlyOwner {
_setIsExcludedFromFees(account, excluded);
}
function distributeFees(uint256 amount, bool inToken) external override onlyOwner {
if (inToken) {
require(balanceOf(address(this)) >= amount, "Not enough balance");
} else {
require(address(this).balance >= amount, "Not enough balance");
}
_distributeFees(amount, inToken);
}
function processFees(uint256 amount, uint256 minAmountOut) external override onlyOwner {
require(amount <= balanceOf(address(this)), "Amount too high");
_processFees(amount, minAmountOut);
}
function removeFeeCollector(address account) external override onlyOwner {
_removeFeeCollector(account);
}
function setLiquidityOwner(address newOwner) external override onlyOwner {
liquidityOwner = newOwner;
}
function setNumTokensToSwap(uint256 amount) external override onlyOwner {
numTokensToSwap = amount;
}
function updateFeeCollectorShare(address account, uint256 share) external override onlyOwner {
_updateFeeCollectorShare(account, share);
}
function setFeeConfiguration(FeeConfiguration calldata configuration) external override onlyOwner {
_setFeeConfiguration(configuration);
}
function setSwapRouter(address newRouter) external override onlyOwner {
_setSwapRouter(newRouter);
}
function _transfer(address from, address to, uint256 amount) internal override(ERC20, TaxableToken) {
super._transfer(from, to, amount);
}
}
文件 4 的 15: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 to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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;
unchecked {
_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 _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 5 的 15:ERC20Base.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
abstract contract ERC20Base is ERC20 {
uint8 private immutable _decimals;
uint256 public immutable TOKEN_CODE;
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_
) ERC20(name_, symbol_) {
_decimals = decimals_;
}
function decimals() public view override returns (uint8) {
return _decimals;
}
}
文件 6 的 15:ERC20Burnable.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Context.sol";
import "./ERC20Base.sol";
abstract contract ERC20Burnable is Context, ERC20Base {
function burn(uint256 amount) external virtual {
_burn(_msgSender(), amount);
}
function _burnFrom(address account, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20Burnable: burn amount exceeds allowance");
unchecked {
_approve(account, _msgSender(), currentAllowance - amount);
}
_burn(account, amount);
}
function burnFrom(address account, uint256 amount) external virtual {
_burnFrom(account, amount);
}
}
文件 7 的 15:EnumerableSet.sol
pragma solidity ^0.8.20;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping(bytes32 value => uint256) _positions;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 position = set._positions[value];
if (position != 0) {
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
set._values[valueIndex] = lastValue;
set._positions[lastValue] = position;
}
set._values.pop();
delete set._positions[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
struct Bytes32Set {
Set _inner;
}
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly {
result := store
}
return result;
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
文件 8 的 15: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);
}
文件 9 的 15: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);
}
文件 10 的 15: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;
}
文件 11 的 15: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);
}
文件 12 的 15: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;
}
文件 13 的 15: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());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
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);
}
}
文件 14 的 15:TaxDistributor.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./ERC20Base.sol";
abstract contract TaxDistributor is ERC20Base {
using EnumerableSet for EnumerableSet.AddressSet;
EnumerableSet.AddressSet private _collectors;
mapping(address => uint256) private _shares;
uint256 public totalFeeCollectorsShares;
event FeeCollectorAdded(address indexed account, uint256 share);
event FeeCollectorUpdated(address indexed account, uint256 oldShare, uint256 newShare);
event FeeCollectorRemoved(address indexed account);
event FeeCollected(address indexed receiver, uint256 amount);
constructor(address[] memory collectors_, uint256[] memory shares_) {
require(collectors_.length == shares_.length, "Invalid fee collectors");
for (uint256 i = 0; i < collectors_.length; i++) {
_addFeeCollector(collectors_[i], shares_[i]);
}
}
function isFeeCollector(address account) public view returns (bool) {
return _collectors.contains(account);
}
function feeCollectorShare(address account) public view returns (uint256) {
return _shares[account];
}
function _addFeeCollector(address account, uint256 share) internal {
require(!_collectors.contains(account), "Already fee collector");
require(share > 0, "Invalid share");
_collectors.add(account);
_shares[account] = share;
totalFeeCollectorsShares += share;
emit FeeCollectorAdded(account, share);
}
function _removeFeeCollector(address account) internal {
require(_collectors.contains(account), "Not fee collector");
_collectors.remove(account);
totalFeeCollectorsShares -= _shares[account];
delete _shares[account];
emit FeeCollectorRemoved(account);
}
function _updateFeeCollectorShare(address account, uint256 share) internal {
require(_collectors.contains(account), "Not fee collector");
require(share > 0, "Invalid share");
uint256 oldShare = _shares[account];
totalFeeCollectorsShares -= oldShare;
_shares[account] = share;
totalFeeCollectorsShares += share;
emit FeeCollectorUpdated(account, oldShare, share);
}
function _distributeFees(uint256 amount, bool inToken) internal returns (bool) {
if (amount == 0) return false;
if (totalFeeCollectorsShares == 0) return false;
uint256 distributed = 0;
uint256 len = _collectors.length();
for (uint256 i = 0; i < len; i++) {
address collector = _collectors.at(i);
uint256 share = i == len - 1
? amount - distributed
: (amount * _shares[collector]) / totalFeeCollectorsShares;
if (inToken) {
_transfer(address(this), collector, share);
} else {
payable(collector).transfer(share);
}
emit FeeCollected(collector, share);
distributed += share;
}
return true;
}
function addFeeCollector(address account, uint256 share) external virtual;
function removeFeeCollector(address account) external virtual;
function updateFeeCollectorShare(address account, uint256 share) external virtual;
function distributeFees(uint256 amount, bool inToken) external virtual;
}
文件 15 的 15:TaxableToken.sol
pragma solidity ^0.8.0;
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "./ERC20Base.sol";
import "./TaxDistributor.sol";
abstract contract TaxableToken is ERC20Base, TaxDistributor {
struct FeeConfiguration {
bool feesInToken;
uint16 buyFees;
uint16 sellFees;
uint16 transferFees;
uint16 burnFeeRatio;
uint16 liquidityFeeRatio;
uint16 collectorsFeeRatio;
}
address public constant BURN_ADDRESS = address(0x000000000000000000000000000000000000dEaD);
uint16 public constant MAX_FEE = 2000;
uint16 public constant FEE_PRECISION = 10000;
IUniswapV2Router02 public swapRouter;
address public swapPair;
address public liquidityOwner;
bool private _processingFees;
bool public autoProcessFees;
uint256 public numTokensToSwap;
FeeConfiguration public feeConfiguration;
mapping(address => bool) private _excludedFromFees;
mapping(address => bool) private _lpPools;
event FeeConfigurationUpdated(FeeConfiguration configuration);
event SwapRouterUpdated(address indexed router, address indexed pair);
event ExcludedFromFees(address indexed account, bool excluded);
event SetLpPool(address indexed pairAddress, bool isLp);
modifier lockTheSwap() {
_processingFees = true;
_;
_processingFees = false;
}
constructor(
bool autoProcessFees_,
uint256 numTokensToSwap_,
address swapRouter_,
FeeConfiguration memory feeConfiguration_
) {
numTokensToSwap = numTokensToSwap_;
autoProcessFees = autoProcessFees_;
liquidityOwner = _msgSender();
swapRouter = IUniswapV2Router02(swapRouter_);
swapPair = _pairFor(swapRouter.factory(), address(this), swapRouter.WETH());
_lpPools[swapPair] = true;
_setIsExcludedFromFees(_msgSender(), true);
_setIsExcludedFromFees(address(this), true);
_setFeeConfiguration(feeConfiguration_);
}
receive() external payable {}
function isExcludedFromFees(address account) public view returns (bool) {
return _excludedFromFees[account];
}
function _setIsExcludedFromFees(address account, bool excluded) internal {
require(_excludedFromFees[account] != excluded, "Already set");
_excludedFromFees[account] = excluded;
emit ExcludedFromFees(account, excluded);
}
function _setIsLpPool(address pairAddress, bool isLp) internal {
require(_lpPools[pairAddress] != isLp, "Already set");
_lpPools[pairAddress] = isLp;
emit SetLpPool(pairAddress, isLp);
}
function isLpPool(address pairAddress) public view returns (bool) {
return _lpPools[pairAddress];
}
function _setSwapRouter(address _newRouter) internal {
require(_newRouter != address(0), "Invalid router");
swapRouter = IUniswapV2Router02(_newRouter);
IUniswapV2Factory factory = IUniswapV2Factory(swapRouter.factory());
require(address(factory) != address(0), "Invalid factory");
address weth = swapRouter.WETH();
swapPair = factory.getPair(address(this), weth);
if (swapPair == address(0)) {
swapPair = factory.createPair(address(this), weth);
}
require(swapPair != address(0), "Invalid pair address.");
emit SwapRouterUpdated(address(swapRouter), swapPair);
}
function _setFeeConfiguration(FeeConfiguration memory configuration) internal {
require(configuration.buyFees <= MAX_FEE, "Invalid buy fee");
require(configuration.sellFees <= MAX_FEE, "Invalid sell fee");
require(configuration.transferFees <= MAX_FEE, "Invalid transfer fee");
uint16 totalShare = configuration.burnFeeRatio +
configuration.liquidityFeeRatio +
configuration.collectorsFeeRatio;
require(totalShare == 0 || totalShare == FEE_PRECISION, "Invalid fee share");
feeConfiguration = configuration;
emit FeeConfigurationUpdated(configuration);
}
function _processFees(uint256 tokenAmount, uint256 minAmountOut) internal lockTheSwap {
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= tokenAmount) {
uint256 liquidityAmount = (tokenAmount * feeConfiguration.liquidityFeeRatio) /
(FEE_PRECISION - feeConfiguration.burnFeeRatio);
uint256 liquidityTokens = liquidityAmount / 2;
uint256 collectorsAmount = tokenAmount - liquidityAmount;
uint256 liquifyAmount = liquidityAmount - liquidityTokens;
if (!feeConfiguration.feesInToken) {
liquifyAmount += collectorsAmount;
}
if (liquifyAmount > 0) {
if (balanceOf(swapPair) == 0) {
return;
}
uint256 initialBalance = address(this).balance;
_swapTokensForEth(liquifyAmount, minAmountOut);
uint256 swapBalance = address(this).balance - initialBalance;
uint256 liquidityETH = (swapBalance * liquidityTokens) / liquifyAmount;
if (liquidityETH > 0) {
_addLiquidity(liquidityTokens, liquidityETH);
}
}
if (feeConfiguration.feesInToken) {
_distributeFees(collectorsAmount, true);
} else {
_distributeFees(address(this).balance, false);
}
}
}
function _swapTokensForEth(uint256 tokenAmount, uint256 minAmountOut) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = swapRouter.WETH();
_approve(address(this), address(swapRouter), tokenAmount);
swapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
minAmountOut,
path,
address(this),
block.timestamp
);
}
function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(swapRouter), tokenAmount);
swapRouter.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0,
0,
liquidityOwner,
block.timestamp
);
}
function _pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(
uint160(
uint(
keccak256(
abi.encodePacked(
hex"ff",
factory,
keccak256(abi.encodePacked(token0, token1)),
hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"
)
)
)
)
);
}
function _transfer(address from, address to, uint256 amount) internal virtual override {
require(amount > 0, "Transfer <= 0");
uint256 taxFee = 0;
bool processFee = !_processingFees && autoProcessFees;
if (!_processingFees) {
bool fromExcluded = isExcludedFromFees(from);
bool toExcluded = isExcludedFromFees(to);
bool fromLP = isLpPool(from);
bool toLP = isLpPool(to);
if (fromLP && !toLP && !toExcluded && to != address(swapRouter)) {
taxFee = feeConfiguration.buyFees;
} else if (toLP && !fromExcluded && !toExcluded) {
taxFee = feeConfiguration.sellFees;
} else if (!fromLP && !toLP && from != address(swapRouter) && !fromExcluded) {
taxFee = feeConfiguration.transferFees;
}
}
if (processFee && taxFee > 0 && !_lpPools[from]) {
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= numTokensToSwap) {
_processFees(numTokensToSwap, 0);
}
}
if (taxFee > 0) {
uint256 taxAmount = (amount * taxFee) / FEE_PRECISION;
uint256 sendAmount = amount - taxAmount;
uint256 burnAmount = (taxAmount * feeConfiguration.burnFeeRatio) / FEE_PRECISION;
if (burnAmount > 0) {
taxAmount -= burnAmount;
super._transfer(from, BURN_ADDRESS, burnAmount);
}
if (taxAmount > 0) {
super._transfer(from, address(this), taxAmount);
}
if (sendAmount > 0) {
super._transfer(from, to, sendAmount);
}
} else {
super._transfer(from, to, amount);
}
}
function setAutoprocessFees(bool autoProcess) external virtual;
function setIsLpPool(address pairAddress, bool isLp) external virtual;
function setIsExcludedFromFees(address account, bool excluded) external virtual;
function processFees(uint256 amount, uint256 minAmountOut) external virtual;
function setLiquidityOwner(address newOwner) external virtual;
function setNumTokensToSwap(uint256 amount) external virtual;
function setFeeConfiguration(FeeConfiguration calldata configuration) external virtual;
function setSwapRouter(address newRouter) external virtual;
}
{
"compilationTarget": {
"contracts/DORK.sol": "DORK"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"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":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"excluded","type":"bool"}],"name":"ExcludedFromAntiWhale","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"excluded","type":"bool"}],"name":"ExcludedFromFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"}],"name":"FeeCollectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"FeeCollectorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldShare","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newShare","type":"uint256"}],"name":"FeeCollectorUpdated","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"bool","name":"feesInToken","type":"bool"},{"internalType":"uint16","name":"buyFees","type":"uint16"},{"internalType":"uint16","name":"sellFees","type":"uint16"},{"internalType":"uint16","name":"transferFees","type":"uint16"},{"internalType":"uint16","name":"burnFeeRatio","type":"uint16"},{"internalType":"uint16","name":"liquidityFeeRatio","type":"uint16"},{"internalType":"uint16","name":"collectorsFeeRatio","type":"uint16"}],"indexed":false,"internalType":"struct TaxableToken.FeeConfiguration","name":"configuration","type":"tuple"}],"name":"FeeConfigurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MaxTokenPerWalletUpdated","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":"pairAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isLp","type":"bool"}],"name":"SetLpPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"router","type":"address"},{"indexed":true,"internalType":"address","name":"pair","type":"address"}],"name":"SwapRouterUpdated","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":"BURN_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_PRECISION","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_CODE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"share","type":"uint256"}],"name":"addFeeCollector","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":[],"name":"autoProcessFees","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":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"inToken","type":"bool"}],"name":"distributeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"feeCollectorShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeConfiguration","outputs":[{"internalType":"bool","name":"feesInToken","type":"bool"},{"internalType":"uint16","name":"buyFees","type":"uint16"},{"internalType":"uint16","name":"sellFees","type":"uint16"},{"internalType":"uint16","name":"transferFees","type":"uint16"},{"internalType":"uint16","name":"burnFeeRatio","type":"uint16"},{"internalType":"uint16","name":"liquidityFeeRatio","type":"uint16"},{"internalType":"uint16","name":"collectorsFeeRatio","type":"uint16"}],"stateMutability":"view","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":[],"name":"initialSupply_","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromAntiWhale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isFeeCollector","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pairAddress","type":"address"}],"name":"isLpPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTokenPerWallet","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":"numTokensToSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"processFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"autoProcess","type":"bool"}],"name":"setAutoprocessFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bool","name":"feesInToken","type":"bool"},{"internalType":"uint16","name":"buyFees","type":"uint16"},{"internalType":"uint16","name":"sellFees","type":"uint16"},{"internalType":"uint16","name":"transferFees","type":"uint16"},{"internalType":"uint16","name":"burnFeeRatio","type":"uint16"},{"internalType":"uint16","name":"liquidityFeeRatio","type":"uint16"},{"internalType":"uint16","name":"collectorsFeeRatio","type":"uint16"}],"internalType":"struct TaxableToken.FeeConfiguration","name":"configuration","type":"tuple"}],"name":"setFeeConfiguration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"excluded","type":"bool"}],"name":"setIsExcludedFromAntiWhale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"excluded","type":"bool"}],"name":"setIsExcludedFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pairAddress","type":"address"},{"internalType":"bool","name":"isLp","type":"bool"}],"name":"setIsLpPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setLiquidityOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMaxTokenPerWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setNumTokensToSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"setPairToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRouter","type":"address"}],"name":"setSwapRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFeeCollectorsShares","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":"amount","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":"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":"account","type":"address"},{"internalType":"uint256","name":"share","type":"uint256"}],"name":"updateFeeCollectorShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]