Address Contract Verified
Address
0x50B3AB144C9Bb8Be97a41B88Da1c776a075D4538
Balance
0 ETH
Nonce
1
Code Size
7003 bytes
Creator
0x648dBfca...6286 at tx 0xe04bb273...85d897
Indexed Transactions
0
Contract Bytecode
7003 bytes
0x60806040526004361061024a5760003560e01c80637e295bab11610139578063cc561460116100b6578063f2b9aa111161007a578063f2b9aa111461073e578063f2fde38b1461076e578063f41bed191461078e578063f7c32fd5146107a4578063fe633b02146107c4578063ffb13c1c146107e457600080fd5b8063cc56146014610678578063d7ce55b514610698578063dd62ed3e146106b8578063deb31e71146106fe578063f0f442601461071e57600080fd5b8063a51c9ace116100fd578063a51c9ace146105e1578063a7294644146105f7578063a9059cbb14610617578063b8106b9914610637578063bac8dca51461065757600080fd5b80637e295bab146105585780638da5cb5b1461056e578063938647671461058c5780639456fbcc146105ac57806395d89b41146105cc57600080fd5b806328e29c1c116101c757806361d027b31161018b57806361d027b31461049d578063634d9480146104bd578063690d8320146104ed57806370a082311461050d578063715018a61461054357600080fd5b806328e29c1c146104105780632dd9382914610426578063313ce5671461043b57806343cc8c2a146104575780635ccdf4971461048757600080fd5b806318160ddd1161020e57806318160ddd146103815780631a425616146103a05780631cb25cbc146103b657806323b872dd146103d657806328d48afc146103f657600080fd5b806306fdde0314610297578063095ea7b3146102c25780630b0987da146102f25780630c8106dc146103205780630e9a1e021461036c57600080fd5b3661029257600f5460ff16156102905734600e600082825461026c9190611777565b925050819055506000610280600e546107fa565b9050801561028e576000600e555b505b005b600080fd5b3480156102a357600080fd5b506102ac610866565b6040516102b991906117ae565b60405180910390f35b3480156102ce57600080fd5b506102e26102dd3660046117f6565b6108f8565b60405190151581526020016102b9565b3480156102fe57600080fd5b50600a5461030d9061ffff1681565b60405161ffff90911681526020016102b9565b34801561032c57600080fd5b506103547f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016102b9565b34801561037857600080fd5b50610290610912565b34801561038d57600080fd5b506002545b6040519081526020016102b9565b3480156103ac57600080fd5b50610392600b5481565b3480156103c257600080fd5b506102906103d1366004611830565b610947565b3480156103e257600080fd5b506102e26103f1366004611869565b61097b565b34801561040257600080fd5b506008546102e29060ff1681565b34801561041c57600080fd5b5061039260095481565b34801561043257600080fd5b506102906109a1565b34801561044757600080fd5b50604051601281526020016102b9565b34801561046357600080fd5b506102e26104723660046118aa565b60126020526000908152604090205460ff1681565b34801561049357600080fd5b50610392600e5481565b3480156104a957600080fd5b50600654610354906001600160a01b031681565b3480156104c957600080fd5b506102e26104d83660046118aa565b60116020526000908152604090205460ff1681565b3480156104f957600080fd5b506102906105083660046118aa565b610a01565b34801561051957600080fd5b506103926105283660046118aa565b6001600160a01b031660009081526020819052604090205490565b34801561054f57600080fd5b50610290610a94565b34801561056457600080fd5b50610392600c5481565b34801561057a57600080fd5b506005546001600160a01b0316610354565b34801561059857600080fd5b506102906105a73660046118c7565b610aa6565b3480156105b857600080fd5b506102906105c73660046118eb565b610aed565b3480156105d857600080fd5b506102ac610b9e565b3480156105ed57600080fd5b5061030d61271081565b34801561060357600080fd5b50610290610612366004611919565b610bad565b34801561062357600080fd5b506102e26106323660046117f6565b610bba565b34801561064357600080fd5b50610290610652366004611830565b610bc8565b34801561066357600080fd5b50600a5461030d9062010000900461ffff1681565b34801561068457600080fd5b50610290610693366004611830565b610bf8565b3480156106a457600080fd5b506102906106b3366004611932565b610c28565b3480156106c457600080fd5b506103926106d33660046118eb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561070a57600080fd5b50610290610719366004611919565b610c43565b34801561072a57600080fd5b506102906107393660046118aa565b610c50565b34801561074a57600080fd5b506102e26107593660046118aa565b60106020526000908152604090205460ff1681565b34801561077a57600080fd5b506102906107893660046118aa565b610c7a565b34801561079a57600080fd5b50610392600d5481565b3480156107b057600080fd5b506102906107bf3660046118c7565b610cbd565b3480156107d057600080fd5b506102906107df366004611919565b610d0c565b3480156107f057600080fd5b5061039260075481565b6000811561085e576006546040516000916001600160a01b03169047908381818185875af1925050503d806000811461084f576040519150601f19603f3d011682016040523d82523d6000602084013e610854565b606091505b5090949350505050565b506000919050565b6060600380546108759061194f565b80601f01602080910402602001604051908101604052809291908181526020018280546108a19061194f565b80156108ee5780601f106108c3576101008083540402835291602001916108ee565b820191906000526020600020905b8154815290600101906020018083116108d157829003601f168201915b5050505050905090565b600033610906818585610d1d565b60019150505b92915050565b61091a610d2a565b600d5460000361093d57604051631447a7d760e31b815260040160405180910390fd5b610945610d57565b565b61094f610d2a565b6001600160a01b0382166000908152601060205260409020805460ff19168215151790555050565b5050565b600033610989858285610f47565b610994858585610fbf565b60019150505b9392505050565b6109a9610d2a565b600e546000036109cc57604051630e1f960960e01b815260040160405180910390fd5b60006109d9600e546107fa565b9050806109f9576040516332df26b360e21b815260040160405180910390fd5b506000600e55565b610a09610d2a565b6000600e5447610a199190611989565b90506000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a68576040519150601f19603f3d011682016040523d82523d6000602084013e610a6d565b606091505b5050905080610a8f57604051634088176760e11b815260040160405180910390fd5b505050565b610a9c610d2a565b610945600061101e565b610aae610d2a565b6101f48161ffff161115610ad55760405163013d417f60e01b815260040160405180910390fd5b600a805461ffff191661ffff92909216919091179055565b610af5610d2a565b6040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610b3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b62919061199c565b9050306001600160a01b03851603610b8457600d54610b819082611989565b90505b610b986001600160a01b0383168483611070565b50505050565b6060600480546108759061194f565b610bb5610d2a565b600b55565b600033610906818585610fbf565b610bd0610d2a565b6001600160a01b0382166000908152601160205260409020805460ff19168215151790555050565b610c00610d2a565b6001600160a01b0382166000908152601260205260409020805460ff19168215151790555050565b610c30610d2a565b6008805460ff1916911515919091179055565b610c4b610d2a565b600c55565b610c58610d2a565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b610c82610d2a565b6001600160a01b038116610cb157604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610cba8161101e565b50565b610cc5610d2a565b6101f48161ffff161115610cec5760405163013d417f60e01b815260040160405180910390fd5b600a805461ffff909216620100000263ffff000019909216919091179055565b610d14610d2a565b610cba81600955565b610a8f83838360016110c2565b6005546001600160a01b031633146109455760405163118cdaa760e01b8152336004820152602401610ca8565b600f805460ff19166001179055600d54600c54811115610d765750600c545b610da1307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d83610d1d565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110610dd657610dd66119b5565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7891906119cb565b81600181518110610e8b57610e8b6119b5565b6001600160a01b03928316602091820292909201015260405163791ac94760e01b81527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063791ac94790610ef09085906000908690309042906004016119e8565b600060405180830381600087803b158015610f0a57600080fd5b505af1158015610f1e573d6000803e3d6000fd5b5050505081600d6000828254610f349190611989565b9091555050600f805460ff191690555050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610b985781811015610fb057604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610ca8565b610b98848484840360006110c2565b6001600160a01b038316610fe957604051634b637e8f60e11b815260006004820152602401610ca8565b6001600160a01b0382166110135760405163ec442f0560e01b815260006004820152602401610ca8565b610a8f838383611197565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610a8f908490611263565b6001600160a01b0384166110ec5760405163e602df0560e01b815260006004820152602401610ca8565b6001600160a01b03831661111657604051634a1406b160e11b815260006004820152602401610ca8565b6001600160a01b0380851660009081526001602090815260408083209387168352929052208290558015610b9857826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161118991815260200190565b60405180910390a350505050565b6001600160a01b03831660009081526012602052604090205460ff16156111f9576111c283836112c6565b156111d1576111d18282611322565b60006111dd8383611396565b905080156111f3576111f08483836113fe565b91505b50611258565b6001600160a01b03821660009081526012602052604090205460ff16156112585761122261142d565b600061122e848361143d565b90508015611256576112418483836113fe565b9150600b54600d541061125657611256610d57565b505b610a8f838383611486565b60006112786001600160a01b038416836115b0565b9050805160001415801561129d57508080602001905181019061129b9190611a5b565b155b15610a8f57604051635274afe760e01b81526001600160a01b0384166004820152602401610ca8565b60085460009060ff166112db5750600061090c565b6001600160a01b03831660009081526011602052604090205460ff168061131a57506001600160a01b03821660009081526011602052604090205460ff165b159392505050565b61132a6115be565b81111561134a57604051637b34d66360e11b815260040160405180910390fd5b6009548161136d846001600160a01b031660009081526020819052604090205490565b6113779190611777565b11156109775760405163185f41cb60e11b815260040160405180910390fd5b6001600160a01b03821660009081526010602052604081205460ff16156113bf5750600061090c565b600a546000906113d990610bb89061ffff1660c7196115eb565b90506127106113ec61ffff831685611a78565b6113f69190611a8f565b949350505050565b600081600d60008282546114129190611777565b909155506114239050843084611486565b6113f68284611989565b6007546000036109455743600755565b6001600160a01b03821660009081526010602052604081205460ff16156114665750600061090c565b600a546000906113d990610bb89062010000900461ffff1660c7196115eb565b6001600160a01b0383166114b15780600260008282546114a69190611777565b909155506115239050565b6001600160a01b038316600090815260208190526040902054818110156115045760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610ca8565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b03821661153f5760028054829003905561155e565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516115a391815260200190565b60405180910390a3505050565b606061099a83836000611638565b60006115e66969e10de76676d08000006001600160ff1b0369152d02c7e14af68000006115eb565b905090565b600080600a600754436115fe9190611989565b6116089190611a8f565b9050600c81111561161c578391505061099a565b6116268382611ab1565b6116309086611ae1565b91505061099a565b6060814710156116645760405163cf47918160e01b815247600482015260248101839052604401610ca8565b600080856001600160a01b031684866040516116809190611b09565b60006040518083038185875af1925050503d80600081146116bd576040519150601f19603f3d011682016040523d82523d6000602084013e6116c2565b606091505b50915091506116d28683836116dc565b9695505050505050565b6060826116f1576116ec82611738565b61099a565b815115801561170857506001600160a01b0384163b155b1561173157604051639996b31560e01b81526001600160a01b0385166004820152602401610ca8565b508061099a565b8051156117485780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561090c5761090c611761565b60005b838110156117a557818101518382015260200161178d565b50506000910152565b60208152600082518060208401526117cd81604085016020870161178a565b601f01601f19169190910160400192915050565b6001600160a01b0381168114610cba57600080fd5b6000806040838503121561180957600080fd5b8235611814816117e1565b946020939093013593505050565b8015158114610cba57600080fd5b6000806040838503121561184357600080fd5b823561184e816117e1565b9150602083013561185e81611822565b809150509250929050565b60008060006060848603121561187e57600080fd5b8335611889816117e1565b92506020840135611899816117e1565b929592945050506040919091013590565b6000602082840312156118bc57600080fd5b813561099a816117e1565b6000602082840312156118d957600080fd5b813561ffff8116811461099a57600080fd5b600080604083850312156118fe57600080fd5b8235611909816117e1565b9150602083013561185e816117e1565b60006020828403121561192b57600080fd5b5035919050565b60006020828403121561194457600080fd5b813561099a81611822565b600181811c9082168061196357607f821691505b60208210810361198357634e487b7160e01b600052602260045260246000fd5b50919050565b8181038181111561090c5761090c611761565b6000602082840312156119ae57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156119dd57600080fd5b815161099a816117e1565b600060a08201878352602087602085015260a0604085015281875180845260c08601915060208901935060005b81811015611a3a5784516001600160a01b031683529383019391830191600101611a15565b50506001600160a01b03969096166060850152505050608001529392505050565b600060208284031215611a6d57600080fd5b815161099a81611822565b808202811582820484141761090c5761090c611761565b600082611aac57634e487b7160e01b600052601260045260246000fd5b500490565b80820260008212600160ff1b84141615611acd57611acd611761565b818105831482151761090c5761090c611761565b8082018281126000831280158216821582161715611b0157611b01611761565b505092915050565b60008251611b1b81846020870161178a565b919091019291505056fea26469706673582212203c4c03e4098d9ac4d619028793095a6dad0eb74e70b8e34ea9bd1d47e9b8b6fb64736f6c63430008190033
Verified Source Code Full Match
Compiler: v0.8.25+commit.b61c2a91
EVM: paris
Optimization: Yes (200 runs)
BrAInToken.sol 276 lines
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.25;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import {IUniswapV2Factory} from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
contract BrAInToken is ERC20, Ownable {
using SafeERC20 for IERC20;
uint16 public constant TAX_DENOMINATOR = 10_000;
IUniswapV2Router02 public immutable lpRouter;
address payable public treasury = payable(address(0x7f9bfCCfb6A78643b83a8460c3dEA1bE5aD61868));
uint256 public tradingInitBlock;
bool public tradingRestricted = true;
uint256 public maximumBalance;
uint16 public finalPurchaseTaxNominator = 500;
uint16 public finalSaleTaxNominator = 500;
uint256 public taxDistributionThreshold = 2_000_000 ether;
uint256 public maximumTaxSwap = 2_000_000 ether;
uint256 public undistributedTax;
uint256 public undistributedETHTax;
bool private _distributingTax;
mapping(address => bool) public taxFree;
mapping(address => bool) public unrestricted;
mapping(address => bool) public lpPairs;
error ExceededMaximumBalance();
error ExceededMaximumPurchaseInTransaction();
error ExceededMaxTax();
error ETHWithdrawalFailed();
error NoTaxToSwap();
error NoTaxToDistribute();
error TaxDistributionFailed();
modifier distributing() {
_distributingTax = true;
_;
_distributingTax = false;
}
constructor(address _lpRouter) ERC20("BrAIn", "BAI") Ownable(msg.sender) {
address liquidityProvider = address(0xC90aF8D832258dF766E3E54976E1D712fe4353ae);
lpRouter = IUniswapV2Router02(_lpRouter);
address lpPair = _createLPPair();
_setLPPair(lpPair, true);
_setUnrestricted(msg.sender, true);
_setUnrestricted(address(this), true);
_setUnrestricted(treasury, true);
_setUnrestricted(liquidityProvider, true);
_setTaxFree(msg.sender, true);
_setTaxFree(address(this), true);
_setTaxFree(treasury, true);
_setTaxFree(liquidityProvider, true);
_distributeFunds(liquidityProvider);
_setMaximumBalance(1_000_000 ether);
}
receive() external payable {
if (_distributingTax) {
undistributedETHTax += msg.value;
bool success = _distributeTax(undistributedETHTax);
if (success) {
undistributedETHTax = 0;
}
}
}
function setLPPair(address _target, bool _isLPPair) external onlyOwner {
_setLPPair(_target, _isLPPair);
}
function setUnrestricted(address _target, bool _unrestricted) external onlyOwner {
_setUnrestricted(_target, _unrestricted);
}
function setTaxFree(address _target, bool _taxFree) external onlyOwner {
_setTaxFree(_target, _taxFree);
}
function setMaximumBalance(uint256 _maximumBalance) external onlyOwner {
_setMaximumBalance(_maximumBalance);
}
function setFinalPurchaseTaxNominator(uint16 _finalPurchaseTaxNominator) external onlyOwner {
if (_finalPurchaseTaxNominator > 500) revert ExceededMaxTax();
finalPurchaseTaxNominator = _finalPurchaseTaxNominator;
}
function setFinalSaleTaxNominator(uint16 _finalSaleTaxNominator) external onlyOwner {
if (_finalSaleTaxNominator > 500) revert ExceededMaxTax();
finalSaleTaxNominator = _finalSaleTaxNominator;
}
function setTaxDistributionThreshold(uint256 _taxDistributionThreshold) external onlyOwner {
taxDistributionThreshold = _taxDistributionThreshold;
}
function setMaximumTaxSwap(uint256 _maximumTaxSwap) external onlyOwner {
maximumTaxSwap = _maximumTaxSwap;
}
function setTradingRestricted(bool _tradingRestricted) external onlyOwner {
tradingRestricted = _tradingRestricted;
}
function setTreasury(address payable _treasury) external onlyOwner {
treasury = _treasury;
}
function withdrawETH(address payable _to) external onlyOwner {
uint256 withdrawableAmount = address(this).balance - undistributedETHTax;
(bool success,) = _to.call{value: withdrawableAmount}("");
if (!success) revert ETHWithdrawalFailed();
}
function withdrawERC20(address _token, address _to) external onlyOwner {
IERC20 token = IERC20(_token);
uint256 withdrawableAmount = token.balanceOf(address(this));
if (_token == address(this)) {
withdrawableAmount -= undistributedTax;
}
token.safeTransfer(_to, withdrawableAmount);
}
function swapTaxToETH() external onlyOwner {
if (undistributedTax == 0) revert NoTaxToSwap();
_swapTaxToETH();
}
function distributeETHTax() external onlyOwner {
if (undistributedETHTax == 0) revert NoTaxToDistribute();
bool success = _distributeTax(undistributedETHTax);
if (!success) revert TaxDistributionFailed();
undistributedETHTax = 0;
}
function _update(address from, address to, uint256 amount) internal override {
if (_isPurchase(from)) {
if (_restrictedTrade(from, to)) _checkTemporaryPurchaseRestrictions(to, amount);
uint256 tax = _calculatePurchaseTax(to, amount);
if (tax > 0) amount = _collectTax(from, amount, tax);
} else if (_isSale(to)) {
_initTrading();
uint256 tax = _calculateSaleTax(from, amount);
if (tax > 0) {
amount = _collectTax(from, amount, tax);
if (undistributedTax >= taxDistributionThreshold) {
_swapTaxToETH();
}
}
}
super._update(from, to, amount);
}
function _initTrading() private {
if (tradingInitBlock == 0) {
tradingInitBlock = block.number;
}
}
function _setLPPair(address _target, bool _isLPPair) private {
lpPairs[_target] = _isLPPair;
}
function _setUnrestricted(address _target, bool _unrestricted) private {
unrestricted[_target] = _unrestricted;
}
function _setTaxFree(address _target, bool _taxFree) private {
taxFree[_target] = _taxFree;
}
function _setMaximumBalance(uint256 _maximumBalance) private {
maximumBalance = _maximumBalance;
}
function _collectTax(address _from, uint256 _amount, uint256 _tax) private returns (uint256) {
undistributedTax += _tax;
super._update(_from, address(this), _tax);
return _amount - _tax;
}
function _distributeFunds(address liquidityProvider) private {
// Marketing & KOL
_mint(address(0xD53E25A4A3948a9Bd212a7C4f74b2ce63c9e77b1), 10_000_000 ether);
// CEX Listings
_mint(address(0xe995F01c77d60fDF0a5c76Ea95239c184fCbB59a), 5_000_000 ether);
// Development
_mint(address(0x3Ee7Be62222bA9Dc33c225EE04C2B0c5D23f0886), 5_000_000 ether);
// Team
_mint(address(0xc6514a40CbE48dB64692a308F6C7101Dc9E2f4f3), 5_000_000 ether);
// Liquidity
_mint(liquidityProvider, 75_000_000 ether);
}
function _isPurchase(address _from) private view returns (bool) {
return lpPairs[_from];
}
function _isSale(address _to) private view returns (bool) {
return lpPairs[_to];
}
function _checkTemporaryPurchaseRestrictions(address _to, uint256 _amount) private view {
if (_amount > _getMaximumPurchaseInTransaction()) revert ExceededMaximumPurchaseInTransaction();
if (balanceOf(_to) + _amount > maximumBalance) revert ExceededMaximumBalance();
}
function _calculatePurchaseTax(address _to, uint256 _amount) private view returns (uint256) {
if (taxFree[_to]) return 0;
uint16 taxNominator =
uint16(int16(_computeSteppedValue(3_000, int256(uint256(finalPurchaseTaxNominator)), -200)));
return _amount * taxNominator / TAX_DENOMINATOR;
}
function _calculateSaleTax(address _from, uint256 _amount) private view returns (uint256) {
if (taxFree[_from]) return 0;
uint16 taxNominator = uint16(int16(_computeSteppedValue(3_000, int256(uint256(finalSaleTaxNominator)), -200)));
return _amount * taxNominator / TAX_DENOMINATOR;
}
function _getMaximumPurchaseInTransaction() private view returns (uint256) {
return uint256(_computeSteppedValue(500_000 ether, type(int256).max, 100_000 ether));
}
function _computeSteppedValue(int256 _start, int256 _final, int256 _step) private view returns (int256) {
uint256 elapsedIntervals = (block.number - tradingInitBlock) / 10;
if (elapsedIntervals > 12) {
return _final;
} else {
return _start + (int256(elapsedIntervals) * _step);
}
}
function _restrictedTrade(address _from, address _to) private view returns (bool) {
if (!tradingRestricted) return false;
return !(unrestricted[_from] || unrestricted[_to]);
}
function _createLPPair() private returns (address) {
return IUniswapV2Factory(lpRouter.factory()).createPair(address(this), lpRouter.WETH());
}
function _swapTaxToETH() private distributing {
uint256 toSwap = undistributedTax;
if (toSwap > maximumTaxSwap) toSwap = maximumTaxSwap;
_approve(address(this), address(lpRouter), toSwap);
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = lpRouter.WETH();
lpRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(toSwap, 0, path, address(this), block.timestamp);
undistributedTax -= toSwap;
}
function _distributeTax(uint256 _ethAmount) private returns (bool) {
if (_ethAmount > 0) {
(bool success,) = treasury.call{value: address(this).balance}("");
return success;
}
return false;
}
}
Errors.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
}
Address.sol 151 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IUniswapV2Factory.sol 17 lines
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;
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
ERC20.sol 312 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/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";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
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;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
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;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
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);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
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);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
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);
}
}
}
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IUniswapV2Router01.sol 95 lines
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);
}
IUniswapV2Router02.sol 44 lines
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;
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
SafeERC20.sol 173 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
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);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
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);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
TAX_DENOMINATOR 0xa51c9ace → uint16
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
finalPurchaseTaxNominator 0x0b0987da → uint16
finalSaleTaxNominator 0xbac8dca5 → uint16
lpPairs 0x43cc8c2a → bool
lpRouter 0x0c8106dc → address
maximumBalance 0x28e29c1c → uint256
maximumTaxSwap 0x7e295bab → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
taxDistributionThreshold 0x1a425616 → uint256
taxFree 0xf2b9aa11 → bool
totalSupply 0x18160ddd → uint256
tradingInitBlock 0xffb13c1c → uint256
tradingRestricted 0x28d48afc → bool
treasury 0x61d027b3 → address
undistributedETHTax 0x5ccdf497 → uint256
undistributedTax 0xf41bed19 → uint256
unrestricted 0x634d9480 → bool
Write Contract 19 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 value
returns: bool
distributeETHTax 0x2dd93829
No parameters
renounceOwnership 0x715018a6
No parameters
setFinalPurchaseTaxNominator 0x93864767
uint16 _finalPurchaseTaxNominator
setFinalSaleTaxNominator 0xf7c32fd5
uint16 _finalSaleTaxNominator
setLPPair 0xcc561460
address _target
bool _isLPPair
setMaximumBalance 0xfe633b02
uint256 _maximumBalance
setMaximumTaxSwap 0xdeb31e71
uint256 _maximumTaxSwap
setTaxDistributionThreshold 0xa7294644
uint256 _taxDistributionThreshold
setTaxFree 0x1cb25cbc
address _target
bool _taxFree
setTradingRestricted 0xd7ce55b5
bool _tradingRestricted
setTreasury 0xf0f44260
address _treasury
setUnrestricted 0xb8106b99
address _target
bool _unrestricted
swapTaxToETH 0x0e9a1e02
No parameters
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdrawERC20 0x9456fbcc
address _token
address _to
withdrawETH 0x690d8320
address _to
Recent Transactions
No transactions found for this address