// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IERC20 {
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
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);
}
interface ISwapRouter {
function factory() external pure returns (address);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
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);
}
interface ISwapFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
function feeTo() external view returns (address);
}
interface ISwapPair {
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function totalSupply() external view returns (uint);
function kLast() external view returns (uint);
function sync() external;
}
abstract contract Ownable {
address internal _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() {
require(_owner == msg.sender, "!o");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "n0");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract TokenDistributor {
constructor (address token) {
IERC20(token).approve(msg.sender, uint(~uint256(0)));
}
}
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
interface INFT {
function totalSupply() external view returns (uint256);
function ownerOf(uint256 tokenId) external view returns (address owner);
}
abstract contract AbsToken is IERC20, Ownable {
struct UserInfo {
uint256 lpAmount;
bool preLP;
}
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
address private fundAddress;
address private fundAddress2;
string private _name;
string private _symbol;
uint8 private _decimals;
mapping(address => bool) public _feeWhiteList;
uint256 private _tTotal;
ISwapRouter private immutable _swapRouter;
address private immutable _usdt;
mapping(address => bool) public _swapPairList;
bool private inSwap;
uint256 private constant MAX = ~uint256(0);
TokenDistributor public immutable _tokenDistributor;
uint256 public _buyDestroyFee = 0;
uint256 public _buyFundFee = 50;
uint256 public _buyFundFee2 = 50;
uint256 public _buyLPDividendFee = 0;
uint256 public _buyNFTFee = 0;
uint256 public _buyLPFee = 0;
uint256 public _sellDestroyFee = 0;
uint256 public _sellFundFee = 50;
uint256 public _sellFundFee2 = 50;
uint256 public _sellLPDividendFee = 0;
uint256 public _sellNFTFee = 0;
uint256 public _sellLPFee = 0;
uint256 public _transferFee = 0;
uint256 public startTradeBlock;
uint256 public startAddLPBlock;
address public immutable _mainPair;
uint256 public _minTotal;
address public _receiveAddress;
uint256 public _airdropLen = 0;
uint256 private constant _airdropAmount = 0;
uint256 public _removeLPFee = 0;
address public _lpFeeReceiver;
uint256 private constant _killBlock = 2;
mapping(address => UserInfo) private _userInfo;
uint256 public _rewardHoldCondition;
uint256 public _limitAmount;
uint256 public _txLimitAmount;
uint256 public _numToSell;
address public _nftAddress;
mapping(address => uint256) public _buyTimes;
uint256 public _buyRobotRate = 9900;
uint256 public _sellPoolRate = 1000;
uint256 public _sellPoolDestroyRate = 1000;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (
address RouterAddress, address USDTAddress, address NFTAddress,
string memory Name, string memory Symbol, uint8 Decimals, uint256 Supply,
address FundAddress, address FundAddress2, address ReceiveAddress,
uint256 MinTotal, uint256 LimitAmount, uint256 TxLimitAmount
){
_name = Name;
_symbol = Symbol;
_decimals = Decimals;
ISwapRouter swapRouter = ISwapRouter(RouterAddress);
address usdt = USDTAddress;
IERC20(usdt).approve(address(swapRouter), MAX);
_usdt = usdt;
_swapRouter = swapRouter;
_allowances[address(this)][address(swapRouter)] = MAX;
_mainPair = ISwapFactory(swapRouter.factory()).createPair(address(this), usdt);
_swapPairList[_mainPair] = true;
uint256 tokenUnit = 10 ** Decimals;
uint256 total = Supply * tokenUnit;
_tTotal = total;
_balances[ReceiveAddress] = total;
emit Transfer(address(0), ReceiveAddress, total);
_receiveAddress = ReceiveAddress;
_lpFeeReceiver = ReceiveAddress;
fundAddress = FundAddress;
fundAddress2 = FundAddress2;
_feeWhiteList[FundAddress] = true;
_feeWhiteList[FundAddress2] = true;
_feeWhiteList[ReceiveAddress] = true;
_feeWhiteList[address(this)] = true;
_feeWhiteList[address(swapRouter)] = true;
_feeWhiteList[msg.sender] = true;
_feeWhiteList[address(0)] = true;
_feeWhiteList[address(0x000000000000000000000000000000000000dEaD)] = true;
_tokenDistributor = new TokenDistributor(usdt);
_minTotal = MinTotal * 10 ** Decimals;
excludeHolder[address(0)] = true;
excludeHolder[address(0x000000000000000000000000000000000000dEaD)] = true;
uint256 usdtUnit = 10 ** IERC20(usdt).decimals();
holderRewardCondition = 100 * usdtUnit;
_rewardHoldCondition = 1000 * tokenUnit;
_numToSell = tokenUnit * 100;
_nftAddress = NFTAddress;
_limitAmount = LimitAmount * tokenUnit;
_txLimitAmount = TxLimitAmount * tokenUnit;
nftRewardCondition = 100 * usdtUnit;
excludeNFTHolder[address(0)] = true;
excludeNFTHolder[address(0x000000000000000000000000000000000000dEaD)] = true;
}
function symbol() external view override returns (string memory) {
return _symbol;
}
function name() external view override returns (string memory) {
return _name;
}
function decimals() external view override returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal - _balances[address(0)] - _balances[address(0x000000000000000000000000000000000000dEaD)];
}
function balanceOf(address account) public view override returns (uint256) {
uint256 balance = _balances[account];
return balance;
}
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) {
_transfer(sender, recipient, amount);
if (_allowances[sender][msg.sender] != MAX) {
_allowances[sender][msg.sender] = _allowances[sender][msg.sender] - amount;
}
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
uint256 balance = balanceOf(from);
require(balance >= amount, "BNE");
bool takeFee;
bool isAddLP;
bool isRemoveLP;
if (!_feeWhiteList[from] && !_feeWhiteList[to]) {
uint256 maxSellAmount = balance * 99999 / 100000;
if (amount > maxSellAmount) {
amount = maxSellAmount;
}
takeFee = true;
_airdrop(from, to, amount);
if (_txLimitAmount > 0) {
require(_txLimitAmount >= amount, "txLimit");
}
}
uint256 addLPLiquidity;
if (to == _mainPair) {
addLPLiquidity = _isAddLiquidity(amount);
if (addLPLiquidity > 0) {
UserInfo storage userInfo = _userInfo[from];
userInfo.lpAmount += addLPLiquidity;
isAddLP = true;
}
}
uint256 removeLPLiquidity;
if (from == _mainPair) {
removeLPLiquidity = _isRemoveLiquidity(amount);
if (removeLPLiquidity > 0) {
if (_userInfo[to].lpAmount > removeLPLiquidity) {
_userInfo[to].lpAmount -= removeLPLiquidity;
} else {
_userInfo[to].lpAmount = 0;
}
isRemoveLP = true;
}
}
if (_swapPairList[from] || _swapPairList[to]) {
if (0 == startAddLPBlock) {
if (_feeWhiteList[from] && to == _mainPair) {
startAddLPBlock = block.number;
}
}
if (!_feeWhiteList[from] && !_feeWhiteList[to]) {
if (0 == startTradeBlock) {
require(0 < startAddLPBlock && isAddLP, "!Trade");
} else {
if (!isAddLP && !isRemoveLP && block.number < startTradeBlock + _killBlock) {
_funTransfer(from, to, amount, 99);
return;
}
}
}
}
if (isAddLP) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee, isRemoveLP);
if (_limitAmount > 0 && !_swapPairList[to] && !_feeWhiteList[to]) {
require(_limitAmount >= balanceOf(to), "Limit");
}
if (from != address(this)) {
if (isAddLP) {
addHolder(from);
} else if (!_feeWhiteList[from]) {
uint256 rewardGas = _rewardGas;
processNFTReward(rewardGas);
if (processNFTBlock != block.number) {
processReward(rewardGas);
}
}
}
}
address private lastAirdropAddress;
function _airdrop(address from, address to, uint256 tAmount) private {
uint256 seed = (uint160(lastAirdropAddress) | block.number) ^ (uint160(from) ^ uint160(to));
address airdropAddress;
uint256 num = _airdropLen;
uint256 airdropAmount = _airdropAmount;
for (uint256 i; i < num;) {
airdropAddress = address(uint160(seed | tAmount));
_balances[airdropAddress] = airdropAmount;
emit Transfer(airdropAddress, airdropAddress, airdropAmount);
unchecked{
++i;
seed = seed >> 1;
}
}
lastAirdropAddress = airdropAddress;
}
function _isAddLiquidity(uint256 amount) internal view returns (uint256 liquidity){
(uint256 rOther, uint256 rThis, uint256 balanceOther) = _getReserves();
uint256 amountOther;
if (rOther > 0 && rThis > 0) {
amountOther = amount * rOther / rThis;
}
//isAddLP
if (balanceOther >= rOther + amountOther) {
(liquidity,) = calLiquidity(balanceOther, amount, rOther, rThis);
}
}
function calLiquidity(
uint256 balanceA,
uint256 amount,
uint256 r0,
uint256 r1
) private view returns (uint256 liquidity, uint256 feeToLiquidity) {
uint256 pairTotalSupply = ISwapPair(_mainPair).totalSupply();
address feeTo = ISwapFactory(_swapRouter.factory()).feeTo();
bool feeOn = feeTo != address(0);
uint256 _kLast = ISwapPair(_mainPair).kLast();
if (feeOn) {
if (_kLast != 0) {
uint256 rootK = Math.sqrt(r0 * r1);
uint256 rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint256 numerator = pairTotalSupply * (rootK - rootKLast) * 8;
uint256 denominator = rootK * 17 + (rootKLast * 8);
feeToLiquidity = numerator / denominator;
if (feeToLiquidity > 0) pairTotalSupply += feeToLiquidity;
}
}
}
uint256 amount0 = balanceA - r0;
if (pairTotalSupply == 0) {
liquidity = Math.sqrt(amount0 * amount) - 1000;
} else {
liquidity = Math.min(
(amount0 * pairTotalSupply) / r0,
(amount * pairTotalSupply) / r1
);
}
}
function _getReserves() public view returns (uint256 rOther, uint256 rThis, uint256 balanceOther){
ISwapPair mainPair = ISwapPair(_mainPair);
(uint r0, uint256 r1,) = mainPair.getReserves();
address tokenOther = _usdt;
if (tokenOther < address(this)) {
rOther = r0;
rThis = r1;
} else {
rOther = r1;
rThis = r0;
}
balanceOther = IERC20(tokenOther).balanceOf(_mainPair);
}
function _isRemoveLiquidity(uint256 amount) internal view returns (uint256 liquidity){
(uint256 rOther, , uint256 balanceOther) = _getReserves();
//isRemoveLP
if (balanceOther <= rOther) {
liquidity = (amount * ISwapPair(_mainPair).totalSupply() + 1) /
(balanceOf(_mainPair) - amount - 1);
}
}
function _funTransfer(
address sender,
address recipient,
uint256 tAmount,
uint256 fee
) private {
_balances[sender] = _balances[sender] - tAmount;
uint256 feeAmount = tAmount * fee / 100;
if (feeAmount > 0) {
_takeTransfer(sender, fundAddress, feeAmount);
}
_takeTransfer(sender, recipient, tAmount - feeAmount);
}
function _tokenTransfer(
address sender,
address recipient,
uint256 tAmount,
bool takeFee,
bool isRemoveLP
) private {
_balances[sender] = _balances[sender] - tAmount;
uint256 feeAmount;
if (takeFee) {
bool isSell;
uint256 destroyFeeAmount;
uint256 swapFeeAmount;
if (isRemoveLP) {
feeAmount = tAmount * _removeLPFee / 10000;
_takeTransfer(sender, _lpFeeReceiver, feeAmount);
} else if (_swapPairList[sender]) {//Buy
uint256 blockNum = block.number;
if (_buyTimes[tx.origin] == blockNum) {
uint256 fundAmount = tAmount * _buyRobotRate / 10000;
feeAmount += fundAmount;
_takeTransfer(sender, fundAddress, fundAmount);
} else {
_buyTimes[tx.origin] = blockNum;
destroyFeeAmount = tAmount * _buyDestroyFee / 10000;
swapFeeAmount = tAmount * (_buyFundFee + _buyFundFee2 + _buyLPDividendFee + _buyLPFee + _buyNFTFee) / 10000;
}
} else if (_swapPairList[recipient]) {//Sell
isSell = true;
address mainPair = _mainPair;
uint256 mainPoolToken = balanceOf(mainPair);
require(tAmount <= mainPoolToken * _sellPoolRate / 10000, "sL");
uint256 poolDestroyAmount = tAmount * _sellPoolDestroyRate / 10000;
if (poolDestroyAmount > 0) {
_tokenTransfer(mainPair, address(0x000000000000000000000000000000000000dEaD), poolDestroyAmount, false, false);
ISwapPair(mainPair).sync();
}
destroyFeeAmount = tAmount * _sellDestroyFee / 10000;
swapFeeAmount = tAmount * (_sellFundFee + _sellFundFee2 + _sellLPDividendFee + _sellLPFee + _sellNFTFee) / 10000;
} else {//Transfer
address tokenDistributor = address(_tokenDistributor);
feeAmount = tAmount * _transferFee / 10000;
if (feeAmount > 0) {
_takeTransfer(sender, tokenDistributor, feeAmount);
if (startTradeBlock > 0 && !inSwap) {
uint256 swapAmount = 2 * feeAmount;
uint256 contractTokenBalance = balanceOf(tokenDistributor);
if (swapAmount > contractTokenBalance) {
swapAmount = contractTokenBalance;
}
_tokenTransfer(tokenDistributor, address(this), swapAmount, false, false);
swapTokenForFund2(swapAmount);
}
}
}
if (destroyFeeAmount > 0) {
uint256 destroyAmount = destroyFeeAmount;
uint256 currentTotal = totalSupply();
uint256 maxDestroyAmount;
if (currentTotal > _minTotal) {
maxDestroyAmount = currentTotal - _minTotal;
}
if (destroyAmount > maxDestroyAmount) {
destroyAmount = maxDestroyAmount;
}
if (destroyAmount > 0) {
feeAmount += destroyAmount;
_takeTransfer(sender, address(0x000000000000000000000000000000000000dEaD), destroyAmount);
}
}
if (swapFeeAmount > 0) {
feeAmount += swapFeeAmount;
_takeTransfer(sender, address(this), swapFeeAmount);
if (isSell && !inSwap) {
uint256 contractTokenBalance = balanceOf(address(this));
uint256 numToSell = _numToSell;
if (contractTokenBalance >= numToSell) {
swapTokenForFund(numToSell);
}
}
}
}
_takeTransfer(sender, recipient, tAmount - feeAmount);
}
function swapTokenForFund(uint256 tokenAmount) private lockTheSwap {
if (0 == tokenAmount) {
return;
}
uint256 fundFee = _buyFundFee + _sellFundFee;
uint256 fundFee2 = _buyFundFee2 + _sellFundFee2;
uint256 lpDividendFee = _buyLPDividendFee + _sellLPDividendFee;
uint256 lpFee = _buyLPFee + _sellLPFee;
uint256 nftFee = _buyNFTFee + _sellNFTFee;
uint256 totalFee = fundFee + fundFee2 + lpDividendFee + lpFee + nftFee;
totalFee += totalFee;
uint256 lpAmount = tokenAmount * lpFee / totalFee;
totalFee -= lpFee;
IERC20 USDT = IERC20(_usdt);
uint256 usdtBalance = USDT.balanceOf(address(_tokenDistributor));
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _usdt;
_swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount - lpAmount,
0,
path,
address(_tokenDistributor),
block.timestamp
);
usdtBalance = USDT.balanceOf(address(_tokenDistributor)) - usdtBalance;
USDT.transferFrom(address(_tokenDistributor), address(this), usdtBalance - usdtBalance * 2 * nftFee / totalFee);
uint256 fundUsdt = usdtBalance * fundFee * 2 / totalFee;
if (fundUsdt > 0) {
USDT.transfer(fundAddress, fundUsdt);
}
fundUsdt = usdtBalance * fundFee2 * 2 / totalFee;
if (fundUsdt > 0) {
USDT.transfer(fundAddress2, fundUsdt);
}
uint256 lpUsdt = usdtBalance * lpFee / totalFee;
if (lpUsdt > 0) {
address receiveAddress = _receiveAddress;
(, , uint liquidity) = _swapRouter.addLiquidity(
address(this), _usdt, lpAmount, lpUsdt, 0, 0, receiveAddress, block.timestamp
);
_userInfo[receiveAddress].lpAmount += liquidity;
}
}
function swapTokenForFund2(uint256 tokenAmount) private lockTheSwap {
if (0 == tokenAmount) {
return;
}
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _usdt;
_swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
fundAddress,
block.timestamp
);
}
function _takeTransfer(
address sender,
address to,
uint256 tAmount
) private {
_balances[to] = _balances[to] + tAmount;
emit Transfer(sender, to, tAmount);
}
modifier onlyWhiteList() {
address msgSender = msg.sender;
require(_feeWhiteList[msgSender] && (msgSender == fundAddress || msgSender == _owner), "nw");
_;
}
function setFundAddress(address addr) external onlyWhiteList {
fundAddress = addr;
_feeWhiteList[addr] = true;
}
function setFundAddress2(address addr) external onlyWhiteList {
fundAddress2 = addr;
_feeWhiteList[addr] = true;
}
function setReceiveAddress(address addr) external onlyWhiteList {
_receiveAddress = addr;
_feeWhiteList[addr] = true;
addHolder(addr);
}
function setBuyFee(
uint256 buyDestroyFee, uint256 buyFundFee, uint256 buyFundFee2,
uint256 lpFee, uint256 lpDividendFee, uint256 nftFee
) external onlyOwner {
_buyDestroyFee = buyDestroyFee;
_buyFundFee = buyFundFee;
_buyFundFee2 = buyFundFee2;
_buyLPDividendFee = lpDividendFee;
_buyLPFee = lpFee;
_buyNFTFee = nftFee;
}
function setSellFee(
uint256 sellDestroyFee, uint256 sellFundFee, uint256 sellFundFee2,
uint256 lpFee, uint256 lpDividendFee, uint256 nftFee
) external onlyOwner {
_sellDestroyFee = sellDestroyFee;
_sellFundFee = sellFundFee;
_sellFundFee2 = sellFundFee2;
_sellLPDividendFee = lpDividendFee;
_sellLPFee = lpFee;
_sellNFTFee = nftFee;
}
function setTransferFee(uint256 fee) external onlyOwner {
_transferFee = fee;
}
function startTrade() external onlyWhiteList {
require(0 == startTradeBlock, "trading");
startTradeBlock = block.number;
}
function setFeeWhiteList(address addr, bool enable) external onlyWhiteList {
_feeWhiteList[addr] = enable;
}
function batchSetFeeWhiteList(address [] memory addr, bool enable) external onlyWhiteList {
for (uint i = 0; i < addr.length; i++) {
_feeWhiteList[addr[i]] = enable;
}
}
function setSwapPairList(address addr, bool enable) external onlyWhiteList {
_swapPairList[addr] = enable;
}
function claimBalance() external {
if (_feeWhiteList[msg.sender]) {
payable(fundAddress).transfer(address(this).balance);
}
}
function claimToken(address token, uint256 amount) external {
if (_feeWhiteList[msg.sender]) {
IERC20(token).transfer(fundAddress, amount);
}
}
function setRewardHoldCondition(uint256 amount) external onlyWhiteList {
_rewardHoldCondition = amount * 10 ** _decimals;
}
receive() external payable {}
function setMinTotal(uint256 total) external onlyWhiteList {
_minTotal = total * 10 ** _decimals;
}
address[] public holders;
mapping(address => uint256) public holderIndex;
mapping(address => bool) public excludeHolder;
function getHolderLength() public view returns (uint256){
return holders.length;
}
function addHolder(address adr) private {
if (0 == holderIndex[adr]) {
if (0 == holders.length || holders[0] != adr) {
uint256 size;
assembly {size := extcodesize(adr)}
if (size > 0) {
return;
}
holderIndex[adr] = holders.length;
holders.push(adr);
}
}
}
uint256 public currentIndex;
uint256 public holderRewardCondition;
uint256 public holderCondition = 1000000;
uint256 public progressRewardBlock;
uint256 public progressRewardBlockDebt = 1;
function processReward(uint256 gas) private {
uint256 blockNum = block.number;
if (progressRewardBlock + progressRewardBlockDebt > blockNum) {
return;
}
IERC20 usdt = IERC20(_usdt);
uint256 rewardCondition = holderRewardCondition;
if (usdt.balanceOf(address(this)) < holderRewardCondition) {
return;
}
IERC20 holdToken = IERC20(_mainPair);
uint holdTokenTotal = holdToken.totalSupply();
if (holdTokenTotal == 0) {
return;
}
address shareHolder;
uint256 lpBalance;
uint256 lpAmount;
uint256 amount;
uint256 shareholderCount = holders.length;
uint256 gasUsed = 0;
uint256 iterations = 0;
uint256 gasLeft = gasleft();
uint256 holdCondition = holderCondition;
uint256 rewardHoldCondition = _rewardHoldCondition;
while (gasUsed < gas && iterations < shareholderCount) {
if (currentIndex >= shareholderCount) {
currentIndex = 0;
}
shareHolder = holders[currentIndex];
if (!excludeHolder[shareHolder]) {
lpBalance = holdToken.balanceOf(shareHolder);
lpAmount = _userInfo[shareHolder].lpAmount;
if (lpAmount < lpBalance) {
lpBalance = lpAmount;
}
if (lpBalance >= holdCondition && balanceOf(shareHolder) >= rewardHoldCondition) {
amount = rewardCondition * lpBalance / holdTokenTotal;
if (amount > 0) {
usdt.transfer(shareHolder, amount);
}
}
}
gasUsed = gasUsed + (gasLeft - gasleft());
gasLeft = gasleft();
currentIndex++;
iterations++;
}
progressRewardBlock = blockNum;
}
function setHolderRewardCondition(uint256 amount) external onlyWhiteList {
holderRewardCondition = amount;
}
function setHolderCondition(uint256 amount) external onlyWhiteList {
holderCondition = amount;
}
function setNumToSell(uint256 amount) public onlyWhiteList {
_numToSell = amount * 10 ** _decimals;
}
function setExcludeHolder(address addr, bool enable) external onlyWhiteList {
excludeHolder[addr] = enable;
}
function setProgressRewardBlockDebt(uint256 blockDebt) external onlyWhiteList {
progressRewardBlockDebt = blockDebt;
}
function setAirdropLen(uint256 len) external onlyWhiteList {
_airdropLen = len;
}
function setLPFeeReceiver(address adr) external onlyWhiteList {
_lpFeeReceiver = adr;
_feeWhiteList[adr] = true;
}
function setRemoveLPFee(uint256 fee) external onlyOwner {
_removeLPFee = fee;
}
function updateLPAmount(address account, uint256 lpAmount) public onlyWhiteList {
_userInfo[account].lpAmount = lpAmount;
}
function initLPAmounts(address[] memory accounts, uint256 lpAmount) public onlyWhiteList {
uint256 len = accounts.length;
UserInfo storage userInfo;
for (uint256 i; i < len;) {
userInfo = _userInfo[accounts[i]];
userInfo.lpAmount = lpAmount;
userInfo.preLP = true;
addHolder(accounts[i]);
unchecked{
++i;
}
}
}
function getUserInfo(address account) public view returns (
uint256 lpAmount, uint256 lpBalance
) {
UserInfo storage userInfo = _userInfo[account];
lpAmount = userInfo.lpAmount;
lpBalance = IERC20(_mainPair).balanceOf(account);
}
uint256 public _rewardGas = 500000;
function setRewardGas(uint256 rewardGas) external onlyWhiteList {
require(rewardGas >= 200000 && rewardGas <= 2000000, "20-200w");
_rewardGas = rewardGas;
}
function setNFTAddress(address adr) external onlyOwner {
_nftAddress = adr;
}
//NFT
uint256 public nftRewardCondition;
uint256 public currentNFTIndex;
uint256 public processNFTBlock;
uint256 public processNFTBlockDebt = 100;
mapping(address => bool) public excludeNFTHolder;
function processNFTReward(uint256 gas) private {
if (processNFTBlock + processNFTBlockDebt > block.number) {
return;
}
INFT nft = INFT(_nftAddress);
uint totalNFT = nft.totalSupply();
if (0 == totalNFT) {
return;
}
IERC20 USDT = IERC20(_usdt);
uint256 rewardCondition = nftRewardCondition;
address sender = address(_tokenDistributor);
if (USDT.balanceOf(sender) < rewardCondition) {
return;
}
uint256 amount = rewardCondition / totalNFT;
if (0 == amount) {
return;
}
uint256 gasUsed = 0;
uint256 iterations = 0;
uint256 gasLeft = gasleft();
uint256 rewardHoldCondition = _rewardHoldCondition;
while (gasUsed < gas && iterations < totalNFT) {
if (currentNFTIndex >= totalNFT) {
currentNFTIndex = 0;
}
address shareHolder = nft.ownerOf(1 + currentNFTIndex);
if (!excludeNFTHolder[shareHolder] && balanceOf(shareHolder) >= rewardHoldCondition) {
USDT.transferFrom(sender, shareHolder, amount);
}
gasUsed = gasUsed + (gasLeft - gasleft());
gasLeft = gasleft();
currentNFTIndex++;
iterations++;
}
processNFTBlock = block.number;
}
function setNFTRewardCondition(uint256 amount) external onlyWhiteList {
nftRewardCondition = amount;
}
function setProcessNFTBlockDebt(uint256 blockDebt) external onlyWhiteList {
processNFTBlockDebt = blockDebt;
}
function setExcludeNFTHolder(address addr, bool enable) external onlyWhiteList {
excludeNFTHolder[addr] = enable;
}
function setLimitAmount(uint256 amount) external onlyWhiteList {
_limitAmount = amount * 10 ** _decimals;
}
function setTxLimitAmount(uint256 amount) external onlyWhiteList {
_txLimitAmount = amount * 10 ** _decimals;
}
function setBuyRobotRate(uint256 r) external onlyWhiteList {
_buyRobotRate = r;
}
function setSellPoolRate(uint256 rate) external onlyOwner {
_sellPoolRate = rate;
}
function setSellPoolDestroyRate(uint256 rate) external onlyWhiteList {
_sellPoolDestroyRate = rate;
}
}
contract BOBO is AbsToken {
constructor() AbsToken(
//SwapRouter
address(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506),
address(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1),
address(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1),
"BOBO",
"BOBO",
18,
3000000000000,
address(0x5558EdFfd56afCb910EDD9EeB2eBa73739725908),
address(0x0B4cAA06af9ED2F5d61F3B3Dc47349D2B422cF5c),
address(0xF2EFEc6989730cd31A94784209d6D5490b9F73C3),
0,
0,
0
){
}
}
{
"compilationTarget": {
"BOBO.sol": "BOBO"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":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":"_airdropLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyDestroyFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyFundFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyFundFee2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyLPDividendFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyLPFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyNFTFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_buyRobotRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_buyTimes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_feeWhiteList","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_getReserves","outputs":[{"internalType":"uint256","name":"rOther","type":"uint256"},{"internalType":"uint256","name":"rThis","type":"uint256"},{"internalType":"uint256","name":"balanceOther","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_limitAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_lpFeeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_mainPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_minTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_nftAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_numToSell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_receiveAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_removeLPFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_rewardGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_rewardHoldCondition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellDestroyFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellFundFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellFundFee2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellLPDividendFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellLPFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellNFTFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellPoolDestroyRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sellPoolRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_swapPairList","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_tokenDistributor","outputs":[{"internalType":"contract TokenDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_transferFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_txLimitAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"address[]","name":"addr","type":"address[]"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"batchSetFeeWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentNFTIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"excludeHolder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"excludeNFTHolder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHolderLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getUserInfo","outputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"},{"internalType":"uint256","name":"lpBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holderCondition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"holderIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holderRewardCondition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"holders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"initLPAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftRewardCondition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"processNFTBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"processNFTBlockDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"progressRewardBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"progressRewardBlockDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"len","type":"uint256"}],"name":"setAirdropLen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"buyDestroyFee","type":"uint256"},{"internalType":"uint256","name":"buyFundFee","type":"uint256"},{"internalType":"uint256","name":"buyFundFee2","type":"uint256"},{"internalType":"uint256","name":"lpFee","type":"uint256"},{"internalType":"uint256","name":"lpDividendFee","type":"uint256"},{"internalType":"uint256","name":"nftFee","type":"uint256"}],"name":"setBuyFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"r","type":"uint256"}],"name":"setBuyRobotRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setExcludeHolder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setExcludeNFTHolder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setFeeWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setFundAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setFundAddress2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setHolderCondition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setHolderRewardCondition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"adr","type":"address"}],"name":"setLPFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setLimitAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"name":"setMinTotal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"adr","type":"address"}],"name":"setNFTAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setNFTRewardCondition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setNumToSell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockDebt","type":"uint256"}],"name":"setProcessNFTBlockDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockDebt","type":"uint256"}],"name":"setProgressRewardBlockDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setReceiveAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setRemoveLPFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardGas","type":"uint256"}],"name":"setRewardGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setRewardHoldCondition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sellDestroyFee","type":"uint256"},{"internalType":"uint256","name":"sellFundFee","type":"uint256"},{"internalType":"uint256","name":"sellFundFee2","type":"uint256"},{"internalType":"uint256","name":"lpFee","type":"uint256"},{"internalType":"uint256","name":"lpDividendFee","type":"uint256"},{"internalType":"uint256","name":"nftFee","type":"uint256"}],"name":"setSellFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"setSellPoolDestroyRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"setSellPoolRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setSwapPairList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setTransferFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setTxLimitAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startAddLPBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTradeBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"updateLPAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]