一、准备
该合约模式是添加流动性分红USDT到添加流动性的用户钱包地址中;营销钱包回流USDT到指定的钱包地址;自动添加流动性即自动筑池获取LP分红给营销钱包;控制开盘交易时间,限制抢开盘,开盘之初的指定块高度,增加交易手续费费。具体模式如下:
1、添加流动性获得交易分红USDT,直接到添加流动性的用户钱包地址中。
3、实现交易手续费自动添加流动性功能,返回的LP给到营销钱包地址。
4、控制买卖不同交易手续费
5、开盘pancakeswap交易所开盘时间
6、开盘指定块高度,添加交易手续费费,限制开盘即大量的抛售,同时限制抢开盘软件。
二、合约部署
1、按照以下顺序配置编译器相关的参数,编译合约文件
2、部署合约
选择metamask钱包作为web3客户端连接remix,选择要部署的目标合约名称。
在主合约文件中输入代币相关的构造函数参数信息:
a. 代币英文全称
b. 代币英文简称
c. 代币发行总量
d. 代币精度
e. uniswapv2Router地址,此次对应pancakeswapRouterv2地址
f. 输入营销钱包指定地址
三、开源合约
合约开源步骤,按照编译时相关参数选择配置即可,在此不做赘述。
四、合约源代码解析
1、构造函数源代码:
constructor ( address RouterAddress, address FISTAddress, string memory Name, string memory Symbol, uint8 Decimals, uint256 Supply, address FundAddress ){ _name = Name; _symbol = Symbol; _decimals = Decimals; ISwapRouter swapRouter = ISwapRouter(RouterAddress); IERC20(FISTAddress).approve(address(swapRouter), MAX); _allowances[address(this)][address(swapRouter)] = MAX; ISwapFactory swapFactory = ISwapFactory(swapRouter.factory()); address swapPair = swapFactory.createPair(address(this), FISTAddress); _mainPair = swapPair; uint256 total = Supply * 10 ** Decimals; _tTotal = total; _balances[ReceiveAddress] = total; emit Transfer(address(0), ReceiveAddress, total); fundAddress = FundAddress; _feeWhiteList[FundAddress] = true; _feeWhiteList[ReceiveAddress] = true; _feeWhiteList[address(this)] = true; _feeWhiteList[address(swapRouter)] = true; _feeWhiteList[msg.sender] = true; excludeHolder[address(0)] = true; excludeHolder[address(0x000000000000000000000000000000000000dEaD)] = true; holderRewardCondition = 5 * 10 ** IERC20(FISTAddress).decimals(); _tokenDistributor = new TokenDistributor(FISTAddress); }
function _transfer( address from, address to, uint256 amount ) private { require(!_blackList[from], "blackList"); require(balance >= amount, "balanceNotEnough"); if (!_feeWhiteList[from] && !_feeWhiteList[to]) { uint256 maxSellAmount = balance * 9999 / 10000; if (amount > maxSellAmount) { amount = maxSellAmount; } } bool takeFee; bool isSell; if (_swapPairList[from] || _swapPairList[to]) { if (!_feeWhiteList[from] && !_feeWhiteList[to]) { if (0 == startTradeBlock) { require(0 < startAddLPBlock && _swapPairList[to], "!startAddLP"); } if (block.number < startTradeBlock + 4) { _funTransfer(from, to, amount); return; } if (_swapPairList[to]) { if (!inSwap) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance > 0) { uint256 numTokensSellToFund = amount / 5000; if (numTokensSellToFund > contractTokenBalance) { numTokensSellToFund = contractTokenBalance; } } } } takeFee = true; } if (_swapPairList[to]) { isSell = true; } } _tokenTransfer(from, to, amount, takeFee, isSell); if (from != address(this)) { if (isSell) { addHolder; } } }
3、转换本币到USDT的核心代码
function swapTokenForFund(uint256 tokenAmount, uint256 swapFee) private lockTheSwap { uint256 lpAmount = tokenAmount * lpFee / swapFee; address[] memory path = new address[](2); path[0] = address(this); path[1] = _fist; _swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens( 0, path, address(0x0), block.timestamp ); swapFee -= lpFee; IERC20 FIST = IERC20(_fist); uint256 fistBalance = FIST.balanceOf(address(_tokenDistributor)); uint256 fundAmount = fistBalance * (_buyFundFee + _sellFundFee) * 2 / swapFee; FIST.transferFrom(address(_tokenDistributor), address(this), fistBalance - fundAmount); if (lpAmount > 0) { uint256 lpFist = fistBalance * lpFee / swapFee; if (lpFist > 0) { _swapRouter.addLiquidity( _fist, lpAmount, lpFist, 0, 0, fundAddress, block.timestamp ); } } }
function processReward(uint256 gas) private { if (progressRewardBlock + 200 > block.number) { return; } uint256 balance = FIST.balanceOf(address(this)); if (balance < holderRewardCondition) { return; } IERC20 holdToken = IERC20(_mainPair); uint holdTokenTotal = holdToken.totalSupply(); uint256 shareholderCount = holders.length; uint256 gasUsed = 0; uint256 iterations = 0; uint256 gasLeft = gasleft(); while (gasUsed < gas) { if (currentIndex >= shareholderCount) { currentIndex = 0; } shareHolder = holders[currentIndex]; if (tokenBalance > 0 && !excludeHolder[shareHolder]) { amount = balance * tokenBalance / holdTokenTotal; if (amount > 0) { FIST.transfer(shareHolder, amount); } } gasUsed = gasUsed + (gasLeft - gasleft()); gasLeft = gasleft(); iterations++; } progressRewardBlock = block.number; }
五、完整版合约源代码如下:
至此,完成添加流动性分红USDT到添加流动性的用户钱包地址,回流USDT到营销钱包,自动添加流动性自动加池、买卖不同手续费,控制合约开盘时间合约源代码及部署所有操作流程。
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:
多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:
添加VX或者telegram获取全程线上免费指导
评论前必须登录!
注册