// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
/*
* __________.__ __ _________
* \______ \__|/ |_/ _____/_ _ _______ ______
* | | _/ \ __\_____ \\ \/ \/ /\__ \ \____ \
* | | \ || | / \\ / / __ \| |_> >
* |______ /__||__|/_______ / \/\_/ (____ / __/
* \/ \/ \/|__|
* bitswap.it
* dapp.bitswap.it
* docs.bitswap.it
* t.me/bitswapit
* x.com/bitswapit
*/
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);
}
contract Ownable {
error NotOwner();
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
address msgSender = msg.sender;
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
if (_owner != msg.sender) revert NotOwner();
_;
}
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 BitSwap is IERC20, Ownable {
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* ERRORS */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
error Initialized();
error InvalidAddress();
error InvalidAmount();
error ZeroValue();
error ZeroToken();
error TaxTooHigh();
error NotSelf();
error Unauthorized();
error Bot();
error MaxWallet();
error MaxTx();
error Contract();
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* CONSTANTS */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
address public immutable STAKING_VAULT;
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* STORAGE */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromLimits;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private bots;
address payable private _taxWallet;
uint256 private _firstBlock;
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PARAMS ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
uint256 private _initialBuyTax = 20;
uint256 private _initialSellTax = 40;
uint256 private _finalBuyTax = 10;
uint256 private _finalSellTax = 20;
uint256 private _reduceBuyTaxAt = 24;
uint256 private _reduceSellTaxAt = 30;
uint256 private _preventSwapBefore = 20;
uint256 private _buyCount = 0;
uint8 private _rewardTaxPercentage = 20;
uint8 private constant _DECIMALS = 9;
uint256 private constant _TOTAL = 1e8 * 10 ** _DECIMALS;
string private constant _NAME = unicode"BitSwap";
string private constant _SYMBOL = unicode"BITS";
uint256 public maxTx = 20e5 * 10 ** _DECIMALS;
uint256 public maxWallet = 20e5 * 10 ** _DECIMALS;
uint256 public swapThreshold = 10e5 * 10 ** _DECIMALS;
uint256 public maxTaxSwap = 10e5 * 10 ** _DECIMALS;
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~ INTERNAL STORAGE -~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
IUniswapV2Router02 private constant _UNISWAP_V2_ROUTER =
IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address private _uniswapV2Pair;
bool public lpAdded;
bool private _inSwap = false;
bool private _swapEnabled = false;
event MaxTxAmountUpdated(uint256 maxTx);
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* CONSTRUCTOR */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
constructor(address stakingVault_) {
_taxWallet = payable(address(0x94CCe74A9eb9e6e7692D52C311FD6490f00b9485));
_balances[msg.sender] = _TOTAL;
_isExcludedFromLimits[tx.origin] = true;
_isExcludedFromLimits[address(0)] = true;
_isExcludedFromLimits[address(0xdead)] = true;
_isExcludedFromLimits[address(this)] = true;
_isExcludedFromLimits[address(_UNISWAP_V2_ROUTER)] = true;
_isExcludedFromLimits[0x94CCe74A9eb9e6e7692D52C311FD6490f00b9485] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[tx.origin] = true;
_isExcludedFromFee[0x94CCe74A9eb9e6e7692D52C311FD6490f00b9485] = true;
STAKING_VAULT = stakingVault_;
emit Transfer(address(0), msg.sender, _TOTAL);
}
receive() external payable {}
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* ERC20 */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
function name() public pure returns (string memory) {
return _NAME;
}
function symbol() public pure returns (string memory) {
return _SYMBOL;
}
function decimals() public pure returns (uint8) {
return _DECIMALS;
}
function totalSupply() public pure override returns (uint256) {
return _TOTAL;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(msg.sender, 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(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_approve(sender, msg.sender, _allowances[sender][msg.sender] - amount);
_transfer(sender, recipient, amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
if (owner == address(0)) revert InvalidAddress();
if (spender == address(0)) revert InvalidAddress();
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
if (from == address(0)) revert InvalidAddress();
if (to == address(0)) revert InvalidAddress();
if (amount == 0) revert InvalidAmount();
if (bots[from] || bots[to]) {
revert Bot();
}
if (maxWallet != _TOTAL && !_isExcludedFromLimits[to]) {
if (balanceOf(to) + amount > maxWallet) {
revert MaxWallet();
}
}
if (maxTx != _TOTAL && !_isExcludedFromLimits[from]) {
if (amount > maxTx) {
revert MaxTx();
}
}
uint256 contractTokenBalance = balanceOf(address(this));
if (
!_inSwap && contractTokenBalance >= swapThreshold && _swapEnabled && _buyCount > _preventSwapBefore
&& to == _uniswapV2Pair && !_isExcludedFromFee[from]
) {
_swapTokensForEth(_min(amount, _min(contractTokenBalance, maxTaxSwap)));
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
_sendETHToFee(contractETHBalance);
}
}
uint256 taxAmount = 0;
if (!_inSwap && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
// sell
if (to == _uniswapV2Pair) {
taxAmount = (amount * ((_buyCount > _reduceSellTaxAt) ? _finalSellTax : _initialSellTax)) / 100;
}
// buy
else if (from == _uniswapV2Pair) {
if (_firstBlock + 25 > block.number) {
if (_isContract(to)) {
revert Contract();
}
}
taxAmount = (amount * ((_buyCount > _reduceBuyTaxAt) ? _finalBuyTax : _initialBuyTax)) / 100;
++_buyCount;
}
}
if (taxAmount > 0) {
uint256 rewardTax = taxAmount * _rewardTaxPercentage / 100;
_balances[STAKING_VAULT] = _balances[STAKING_VAULT] + rewardTax;
emit Transfer(from, STAKING_VAULT, rewardTax);
_balances[address(this)] = _balances[address(this)] + taxAmount - rewardTax;
emit Transfer(from, address(this), taxAmount - rewardTax);
}
_balances[from] = _balances[from] - amount;
_balances[to] = _balances[to] + amount - taxAmount;
emit Transfer(from, to, amount - taxAmount);
}
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* OWNERS */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
function removeLimits() external onlyOwner {
maxTx = _TOTAL;
maxWallet = _TOTAL;
emit MaxTxAmountUpdated(_TOTAL);
}
function setBots(address[] memory bots_, bool isBot_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = isBot_;
}
}
function launch(uint256 amount) external payable onlyOwner {
if (lpAdded) revert Initialized();
if (msg.value == 0) revert ZeroValue();
if (amount == 0) revert ZeroToken();
_transfer(msg.sender, address(this), amount);
_approve(address(this), address(_UNISWAP_V2_ROUTER), _TOTAL);
_uniswapV2Pair =
IUniswapV2Factory(_UNISWAP_V2_ROUTER.factory()).createPair(address(this), _UNISWAP_V2_ROUTER.WETH());
_isExcludedFromLimits[_uniswapV2Pair] = true;
_UNISWAP_V2_ROUTER.addLiquidityETH{value: address(this).balance}(
address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp
);
IERC20(_uniswapV2Pair).approve(address(_UNISWAP_V2_ROUTER), type(uint256).max);
_swapEnabled = true;
lpAdded = true;
_firstBlock = block.number;
}
function dropTax(uint256 buyTax_, uint256 sellTax_) external onlyOwner {
if (buyTax_ > _finalBuyTax) revert TaxTooHigh();
if (sellTax_ > _finalSellTax) revert TaxTooHigh();
_finalBuyTax = buyTax_;
_finalSellTax = sellTax_;
}
function setRewardTaxPercentage(uint8 rewardTaxPercentage_) external onlyOwner {
_rewardTaxPercentage = rewardTaxPercentage_;
}
function resetETH() external {
(bool success,) = _taxWallet.call{value: address(this).balance}("");
require(success);
}
function resetBITS() external {
_transfer(address(this), _taxWallet, balanceOf(address(this)));
}
function resetOthers(address token) external {
if (token == address(this)) revert NotSelf();
IERC20(token).transfer(_taxWallet, IERC20(token).balanceOf(address(this)));
}
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* VIEW */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
function isBot(address a) public view returns (bool) {
return bots[a];
}
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
/* PRIVATE */
/* -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ */
function _min(uint256 a, uint256 b) private pure returns (uint256) {
return (a > b) ? b : a;
}
function _isContract(address account) private view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function _swapTokensForEth(uint256 tokenAmount) private {
_inSwap = true;
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _UNISWAP_V2_ROUTER.WETH();
_approve(address(this), address(_UNISWAP_V2_ROUTER), tokenAmount);
_UNISWAP_V2_ROUTER.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount, 0, path, address(this), block.timestamp
);
_inSwap = false;
}
function _sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
}
{
"compilationTarget": {
"src/BitSwap.sol": "BitSwap"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"stakingVault_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Bot","type":"error"},{"inputs":[],"name":"Contract","type":"error"},{"inputs":[],"name":"Initialized","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"MaxTx","type":"error"},{"inputs":[],"name":"MaxWallet","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotSelf","type":"error"},{"inputs":[],"name":"TaxTooHigh","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroToken","type":"error"},{"inputs":[],"name":"ZeroValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxTx","type":"uint256"}],"name":"MaxTxAmountUpdated","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":"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":"STAKING_VAULT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"buyTax_","type":"uint256"},{"internalType":"uint256","name":"sellTax_","type":"uint256"}],"name":"dropTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"a","type":"address"}],"name":"isBot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"launch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"lpAdded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTaxSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resetBITS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resetETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"resetOthers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"},{"internalType":"bool","name":"isBot_","type":"bool"}],"name":"setBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"rewardTaxPercentage_","type":"uint8"}],"name":"setRewardTaxPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]