文件 1 的 5:BEBEToken.sol
pragma solidity ^0.8.14;
import "./IERC20.sol";
import "./Context.sol";
import "./Ownable.sol";
import "./SafeMath.sol";
contract BEBEToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
string private _name = 'Bebe';
string private _symbol = 'BEBE';
uint8 private _decimals = 18;
uint256 private _totalSupply = 420690000000000 * 10 ** uint256(_decimals);
address private _fundAddress;
address private _marketingAddress;
uint256 public _fundFee = 2;
uint256 private _previousFundFee = _fundFee;
uint256 private _fundFeeTotal;
mapping(address => bool) private _isExcludedFromFee;
mapping (address => bool) private automatedMarketMakerPairs;
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
constructor (address fundAddress, address marketingAddress) {
_fundAddress = fundAddress;
_marketingAddress = marketingAddress;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[fundAddress] = true;
_isExcludedFromFee[marketingAddress] = true;
_isExcludedFromFee[address(this)] = true;
_balances[_msgSender()] = _totalSupply;
emit Transfer(address(0), _msgSender(), _totalSupply);
}
receive () external payable {}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return _decimals;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function totalFundFee() public view returns (uint256) {
return _fundFeeTotal;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != address(0), "The UniSwap pair set to the zero address");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
require(automatedMarketMakerPairs[pair] != value, "Automated market maker pair is already set to that value");
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
if(
_isExcludedFromFee[sender] ||
_isExcludedFromFee[recipient] ||
(!automatedMarketMakerPairs[sender] && !automatedMarketMakerPairs[recipient])
) {
removeAllFee();
}
_transferStandard(sender, recipient, amount);
if(
_isExcludedFromFee[sender] ||
_isExcludedFromFee[recipient] ||
(!automatedMarketMakerPairs[sender] && !automatedMarketMakerPairs[recipient])
) {
restoreAllFee();
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 tTransferAmount, uint256 tFund) = _getValues(tAmount);
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tTransferAmount);
if(
!_isExcludedFromFee[sender] &&
!_isExcludedFromFee[recipient] &&
(automatedMarketMakerPairs[sender] || automatedMarketMakerPairs[recipient])
) {
uint256 fundAmount = tFund.div(2);
_balances[_fundAddress] = _balances[_fundAddress].add(fundAmount);
_balances[_marketingAddress] = _balances[_marketingAddress].add(tFund.sub(fundAmount));
_fundFeeTotal = _fundFeeTotal.add(tFund);
emit Transfer(sender, _fundAddress, fundAmount);
emit Transfer(sender, _marketingAddress, tFund.sub(fundAmount));
}
emit Transfer(sender, recipient, tTransferAmount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function calculateFundFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_fundFee).div(
10 ** 2
);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256) {
(uint256 tTransferAmount, uint256 tFund) = _getTValues(tAmount);
return (tTransferAmount, tFund);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256) {
uint256 tFund = calculateFundFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFund);
return (tTransferAmount, tFund);
}
function removeAllFee() private {
if(_fundFee == 0) return;
_previousFundFee = _fundFee;
_fundFee = 0;
}
function restoreAllFee() private {
_fundFee = _previousFundFee;
}
}
文件 3 的 5:IERC20.sol
pragma solidity ^0.8.4;
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 4 的 5:Ownable.sol
pragma solidity ^0.8.14;
import "./Context.sol";
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 5 的 5:SafeMath.sol
pragma solidity ^0.8.4;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath#mul: OVERFLOW");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath#div: DIVISION_BY_ZERO");
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath#sub: UNDERFLOW");
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath#add: OVERFLOW");
return c;
}
function air(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath#mod: DIVISION_BY_ZERO");
return a % b;
}
}
{
"compilationTarget": {
"BEBEToken.sol": "BEBEToken"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}