Verified contractPartialUnlicensed
DonationToken
Address0xfed729aff56770cc907fbff017e6bba57c7c646d
- Balance
0 ETH
- Transactions
84
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- Unlicensed
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,549,787
- Creation transaction
- 0x9ead310147…cb826fdd3c
src/templates/DonationToken.sol
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.7;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
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
);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor(address owner_) {
_owner = owner_;
emit OwnershipTransferred(address(0), owner_);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function transferOwnership(address _newOwner) public virtual onlyOwner {
emit OwnershipTransferred(_owner, _newOwner);
_owner = _newOwner;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(
address tokenA,
address tokenB
) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
}
contract DonationToken is Context, IERC20, Ownable {
using SafeMath for uint256;
struct TokenConfig {
string name;
string symbol;
uint256 totalSupply;
}
struct FeeConfig {
uint256 buyFee;
uint256 sellFee;
uint256 deployFeeEth;
uint256 devSupplyBps;
uint256 donationSupplyBps;
uint256 donationBuyFee;
uint256 donationSellFee;
address payable donationWallet;
}
struct LimitConfig {
uint256 maxTxBps;
uint256 maxWalletBps;
uint256 minBalanceBps;
uint256 maxCaSellBps;
uint256 clogBps;
uint256 donationDailySellLimitBps;
}
struct InfraConfig {
address owner;
address payable botFeeWallet;
LaunchPoolConfig launchPool;
}
struct LaunchPoolConfig {
address lpRecipient;
address v2Router;
}
struct Airdrop {
address wallet;
uint256 amount;
}
struct ExtraAirdrop {
address wallet;
uint256 amount;
}
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => uint256) private cooldown;
uint256 private _tax;
uint256 private _tTotal;
uint256 private buyFee;
uint256 private sellFee;
uint256 private donationBuyFee;
uint256 private donationSellFee;
string private _name;
string private _symbol;
uint256 private _maxTxAmount;
uint256 private _maxWalletAmount;
uint256 private minBalance;
uint256 private maxCaSell;
uint256 private clogAmount;
uint256 private deployerTaxDrainRemaining = 0;
uint256 private immutable donationDailySellLimitBps;
uint256 private donationTransferWindowStart;
uint256 private donationTransferredInWindow;
bool private donationTransferWindowActive = false;
bool private isClogDrained = false;
bool private donationModeActive = false;
uint8 private _decimals;
address payable private immutable _deployer;
address payable private immutable donationWallet;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
address public launchLpRecipient;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private limitsEnabled = true;
modifier lockTheSwap() {
inSwap = true;
_;
inSwap = false;
}
constructor(
TokenConfig memory token_,
FeeConfig memory fees_,
LimitConfig memory limits_,
InfraConfig memory infra_,
Airdrop[] memory airdrops_,
ExtraAirdrop[] memory extraAirdrops_
) payable Ownable(infra_.owner) {
_collectDeployFee(infra_.botFeeWallet, fees_.deployFeeEth);
_name = token_.name;
_symbol = token_.symbol;
_tTotal = token_.totalSupply;
_decimals = 9;
buyFee = fees_.buyFee;
sellFee = fees_.sellFee;
_maxTxAmount = _tTotal.mul(limits_.maxTxBps).div(10000);
_maxWalletAmount = _tTotal.mul(limits_.maxWalletBps).div(10000);
minBalance = _tTotal.mul(limits_.minBalanceBps).div(10000);
maxCaSell = _tTotal.mul(limits_.maxCaSellBps).div(10000);
clogAmount = _tTotal.mul(limits_.clogBps).div(10000);
require(
limits_.donationDailySellLimitBps <= 10000,
"donation daily limit too high"
);
donationDailySellLimitBps = limits_.donationDailySellLimitBps;
_deployer = payable(infra_.owner);
donationWallet = fees_.donationWallet;
require(donationWallet != address(0), "donation wallet is zero");
donationBuyFee = fees_.donationBuyFee;
donationSellFee = fees_.donationSellFee;
if (clogAmount == 0) {
isClogDrained = true;
_activateDonationMode();
}
uint256 supplyToBot = _tTotal.mul(50).div(10000); // 0.5% of supply to bot fee wallet
uint256 supplyToDev = _tTotal.mul(fees_.devSupplyBps).div(10000);
uint256 supplyToDonation = _tTotal.mul(fees_.donationSupplyBps).div(
10000
);
uint256 totalAllocated = supplyToBot.add(supplyToDev).add(
supplyToDonation
).add(clogAmount);
for (uint256 i = 0; i < airdrops_.length; i++) {
totalAllocated = totalAllocated.add(airdrops_[i].amount);
}
require(totalAllocated < _tTotal, "allocations exceed supply");
_tOwned[address(this)] = _tTotal.sub(supplyToBot).sub(supplyToDev).sub(
supplyToDonation
);
_tOwned[infra_.botFeeWallet] = supplyToBot;
if (supplyToDev > 0) {
_tOwned[owner()] = supplyToDev;
}
if (supplyToDonation > 0) {
_tOwned[donationWallet] = supplyToDonation;
_isExcludedFromFee[donationWallet] = true;
}
uint256 totalAirdropped;
for (uint256 i = 0; i < airdrops_.length; i++) {
uint256 amt = airdrops_[i].amount;
_tOwned[airdrops_[i].wallet] = amt;
_isExcludedFromFee[airdrops_[i].wallet] = true;
totalAirdropped = totalAirdropped.add(amt);
emit Transfer(address(0), airdrops_[i].wallet, amt);
}
_tOwned[address(this)] = _tOwned[address(this)].sub(totalAirdropped);
for (uint256 i = 0; i < extraAirdrops_.length; i++) {
uint256 amt = extraAirdrops_[i].amount;
_tOwned[extraAirdrops_[i].wallet] = amt;
_isExcludedFromFee[extraAirdrops_[i].wallet] = true;
}
uniswapV2Pair = _configureLaunchPool(infra_.launchPool);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[msg.sender] = true;
_isExcludedFromFee[infra_.botFeeWallet] = true;
_isExcludedFromFee[uniswapV2Pair] = true;
emit Transfer(address(0), address(this), _tOwned[address(this)]);
emit Transfer(address(0), infra_.botFeeWallet, supplyToBot);
if (supplyToDev > 0) {
emit Transfer(address(0), owner(), supplyToDev);
}
if (supplyToDonation > 0) {
emit Transfer(address(0), donationWallet, supplyToDonation);
}
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function getBuyFee() public view returns (uint256) {
return buyFee;
}
function getSellFee() public view returns (uint256) {
return sellFee;
}
function areLimitsEnabled() public view returns (bool) {
return limitsEnabled;
}
function liquidityPool() public view returns (address) {
return uniswapV2Pair;
}
function balanceOf(address account) public view override returns (uint256) {
return _tOwned[account];
}
function transfer(
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(
address owner,
address spender
) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(
address spender,
uint256 amount
) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function changeMinBalance(uint256 newMin) public onlyOwner {
minBalance = newMin;
}
function removeLimits() public onlyOwner {
limitsEnabled = false;
}
function excludeFromFees(address target) public onlyOwner {
_isExcludedFromFee[target] = true;
}
function setFees(uint256 _buyFee, uint256 _sellFee) public onlyOwner {
buyFee = _buyFee;
sellFee = _sellFee;
}
function _approve(address owner, address spender, uint256 amount) private {
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 _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_enforceDonationDailyTransferLimit(from, amount);
// Router transfers performed while adding the initial liquidity (and
// during swapback) must not be taxed.
_tax = inSwap ? 0 : buyFee;
if (from != _deployer && to != _deployer) {
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
limitsEnabled
) {
if (_maxWalletAmount > 0) {
require(
(_tOwned[to] + amount) <= _maxWalletAmount,
"Max wallet exceeded"
);
}
if (_maxTxAmount > 0) {
require(amount <= _maxTxAmount);
}
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (
!inSwap &&
from != uniswapV2Pair &&
swapEnabled &&
!_isExcludedFromFee[from]
) {
uint256 contractTokenBalance = balanceOf(address(this));
uint256 deployerDrainRemaining = _remainingDeployerDrainTokens();
if (!donationModeActive && deployerDrainRemaining == 0) {
_activateDonationMode();
}
bool drainingDeployer = !donationModeActive;
if (contractTokenBalance > minBalance || drainingDeployer) {
if (drainingDeployer) {
if (contractTokenBalance > deployerDrainRemaining) {
contractTokenBalance = deployerDrainRemaining;
}
}
if (contractTokenBalance > maxCaSell) {
contractTokenBalance = maxCaSell;
if (contractTokenBalance > amount) {
contractTokenBalance = amount;
}
}
if (contractTokenBalance > 0) {
bool sendToDonation = donationModeActive;
swapTokensForEth(contractTokenBalance);
uint256 receivedEth = address(this).balance;
if (receivedEth > 0) {
if (sendToDonation) {
sendETHToDonation(receivedEth);
} else {
sendETHToFee(receivedEth);
}
}
if (!sendToDonation) {
_recordDeployerDrain(contractTokenBalance);
}
}
}
}
}
if (
to == uniswapV2Pair &&
from != address(uniswapV2Router) &&
!_isExcludedFromFee[from]
) {
_tax = sellFee;
}
_transferStandard(from, to, amount);
}
function _enforceDonationDailyTransferLimit(
address from,
uint256 amount
) private {
if (from != donationWallet) {
return;
}
if (
!donationTransferWindowActive ||
block.timestamp >= donationTransferWindowStart + 1 days
) {
donationTransferWindowActive = true;
donationTransferWindowStart = block.timestamp;
donationTransferredInWindow = 0;
}
uint256 nextTransferred = donationTransferredInWindow.add(amount);
uint256 dailyLimit = _tTotal.mul(donationDailySellLimitBps).div(10000);
require(nextTransferred <= dailyLimit, "donation daily limit");
donationTransferredInWindow = nextTransferred;
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function addLiquidity(
uint256 tokenAmount,
uint256 ethAmount,
address target
) private lockTheSwap {
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0,
0,
target,
block.timestamp
);
}
function _configureLaunchPool(
LaunchPoolConfig memory launchPool_
) private returns (address pool) {
require(launchPool_.lpRecipient != address(0), "lp recipient is zero");
launchLpRecipient = launchPool_.lpRecipient;
uniswapV2Router = IUniswapV2Router02(launchPool_.v2Router);
pool = IUniswapV2Factory(uniswapV2Router.factory()).createPair(
address(this),
uniswapV2Router.WETH()
);
}
function _collectDeployFee(
address payable _feeWallet,
uint256 _fee
) private {
if (_fee == 0) return;
require(_fee <= msg.value, "fee exceeds msg.value");
_feeWallet.transfer(_fee);
}
function sendETHToFee(uint256 amount) private {
(bool success, ) = _deployer.call{value: amount}("");
require(success, "fee transfer failed");
}
function sendETHToDonation(uint256 amount) private {
(bool success, ) = donationWallet.call{value: amount}("");
require(success, "donation transfer failed");
}
function _remainingDeployerDrainTokens() private view returns (uint256) {
if (!isClogDrained) {
return clogAmount;
}
if (!donationModeActive) {
return deployerTaxDrainRemaining;
}
return 0;
}
function _recordDeployerDrain(uint256 tokensSold) private {
if (!isClogDrained) {
if (tokensSold >= clogAmount) {
tokensSold -= clogAmount;
clogAmount = 0;
isClogDrained = true;
} else {
clogAmount -= tokensSold;
return;
}
}
if (!donationModeActive) {
if (tokensSold >= deployerTaxDrainRemaining) {
deployerTaxDrainRemaining = 0;
_activateDonationMode();
} else {
deployerTaxDrainRemaining -= tokensSold;
}
}
}
function _activateDonationMode() private {
donationModeActive = true;
buyFee = donationBuyFee;
sellFee = donationSellFee;
}
function openTrading() external onlyOwner {
require(!tradingOpen, "trading is already open");
uint256 lpTokens = balanceOf(address(this)).sub(clogAmount);
addLiquidity(lpTokens, address(this).balance, launchLpRecipient);
swapEnabled = true;
tradingOpen = true;
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(uint256 transferAmount, uint256 tfee) = _getTValues(tAmount);
if (!isClogDrained && !inSwap) {
deployerTaxDrainRemaining += tfee;
}
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_tOwned[recipient] = _tOwned[recipient].add(transferAmount);
_tOwned[address(this)] = _tOwned[address(this)].add(tfee);
emit Transfer(sender, recipient, transferAmount);
}
receive() external payable {}
function manualswap() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualswapPercentage(uint256 percentage) external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance.mul(percentage).div(100));
}
function manualsend() external onlyOwner {
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getTValues(
uint256 tAmount
) private view returns (uint256, uint256) {
uint256 tFee = tAmount.mul(_tax).div(10000);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function recoverTokens(address tokenAddress) public {
require(msg.sender == _deployer, "only deployer can recover tokens");
IERC20 recoveryToken = IERC20(tokenAddress);
require(
recoveryToken.transfer(
_deployer,
recoveryToken.balanceOf(address(this))
),
"recover failed"
);
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.