币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】

  • A+
所属分类:币安BSC
摘要

添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现。


chatGPT账号

一、说明

本合约代码案例主要包括添加流动性分红LP任意币种,自动添加流动性回流底池,回流营销钱包主流代币,同时可以实现批量反机器人,反夹子阻止恶意交易功能。具体功能如下:

1、添加流动性获取LP分红任意币种,可以在合约部署时设置分红币种,也可以在合约部署完成后再动态调整分红币种。

2、自动添加流动性到指定的资金池地址,可以为BNB或者usdt的池子,也可以是自定义的任意资金池。

3、回流营销钱包主流币种,可以自定义回流币种

4、允许设置买卖不同的交易手续费。预留后期自定义调整接口,可以后期调整各个代币流向的手续费。

5、可以实现批量反机器人,防止交易开盘时的抢开盘软件恶意抢购造成的价格波动。

6、可以通过防止单块交易来反夹子软件,任何单区块交易均被封禁。

币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】

二、代码实现

1、添加流动性分红模式构造函数初始化

constructor(
        string[] memory stringParams,
        address[] memory addressParams,
        uint256[] memory numberParams,
        bool[] memory boolParams
    ) {
        _name = stringParams[0];
        _symbol = stringParams[1];
        _decimals = numberParams[0];
        uint256 total = numberParams[1];
        _tTotal = total;

        fundAddress = addressParams[0];
        currency = addressParams[1]; 
        ISwapRouter swapRouter = ISwapRouter(addressParams[2]);
        address ReceiveAddress = addressParams[3];
        ETH = addressParams[4];

        maxSwapAmount = numberParams[2];
        maxWalletAmount = numberParams[3];

        enableOffTrade = boolParams[0];
        enableKillBlock = boolParams[1];
        enableRewardList = boolParams[2];

        enableSwapLimit = boolParams[3];
        enableWalletLimit = boolParams[4];
        enableChangeTax = boolParams[5];
        currencyIsEth = boolParams[6];
        enableKillBatchBots = boolParams[7];

        rewardPath = [address(this), currency];
        if (currency != ETH) {
            if (currencyIsEth == false) {
                rewardPath.push(swapRouter.WETH());
            }
            rewardPath.push(ETH);
        }

        IERC20(currency).approve(address(swapRouter), MAX);

        _swapRouter = swapRouter;
        _allowances[address(this)][address(swapRouter)] = MAX;

        ISwapFactory swapFactory = ISwapFactory(swapRouter.factory());
        address swapPair = swapFactory.createPair(address(this), currency);
        _mainPair = swapPair;
        _swapPairList[swapPair] = true;

        _buyFundFee = numberParams[4];
        _buyLPFee = numberParams[5];
        _buyRewardFee = numberParams[6];
        

        _sellFundFee = numberParams[7];
        _sellLPFee = numberParams[8];
        _sellRewardFee = numberParams[9];

        require(_buyFundFee+_buyLPFee+_buyRewardFee<2500,"fee too high");
        require(_sellFundFee+_sellLPFee+_sellRewardFee<2500,"fee too high");

        killBatchBlockNumber = numberParams[10];
        kb = numberParams[11];

        _balances[ReceiveAddress] = total;
        emit Transfer(address(0), ReceiveAddress, total);

        _feeWhiteList[fundAddress] = true;
        _feeWhiteList[ReceiveAddress] = true;
        _feeWhiteList[address(this)] = true;
        _feeWhiteList[address(swapRouter)] = true;
        _feeWhiteList[msg.sender] = true;

        isMaxEatExempt[msg.sender] = true;
        isMaxEatExempt[fundAddress] = true;
        isMaxEatExempt[ReceiveAddress] = true;
        isMaxEatExempt[address(swapRouter)] = true;
        isMaxEatExempt[address(_mainPair)] = true;
        isMaxEatExempt[address(this)] = true;
        isMaxEatExempt[address(0xdead)] = true;

        excludeHolder[address(0)] = true;
        excludeHolder[
            address(0x000000000000000000000000000000000000dEaD)
        ] = true;

        holderRewardCondition = 10**IERC20(currency).decimals()/10;

        _tokenDistributor = new TokenDistributor(currency);
        _rewardTokenDistributor = new TokenDistributor(ETH);
    }

2、手续费兑换主流代币合约代码:

function swapTokenForFund(uint256 tokenAmount, uint256 swapFee)
        private
        lockTheSwap
    {

        uint256 rewardAmount = (tokenAmount *
            (_buyRewardFee + _sellRewardFee)) / swapFee;
        try _swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
            rewardAmount,
            0,
            rewardPath,
            address(_rewardTokenDistributor),
            block.timestamp
        ) {} catch { emit Failed_swapExactTokensForTokensSupportingFeeOnTransferTokens(0); }

        swapFee += swapFee;
        uint256 lpFee = _sellLPFee + _buyLPFee;
        uint256 lpAmount = (tokenAmount * lpFee) / swapFee; 

        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = currency;
        if (currencyIsEth) {
            try _swapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
                tokenAmount - lpAmount - rewardAmount,
                0,
                path,
                address(this),
                block.timestamp
            ) {} catch { emit Failed_swapExactTokensForETHSupportingFeeOnTransferTokens(); }
        } else {
            try _swapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
                tokenAmount - lpAmount - rewardAmount,
                0,
                path,
                address(_tokenDistributor),
                block.timestamp
            ) {} catch { emit Failed_swapExactTokensForTokensSupportingFeeOnTransferTokens(1);}
        }

        swapFee -= lpFee;

        IERC20 FIST = IERC20(currency);

        uint256 fistBalance = 0;
        uint256 lpFist = 0;
        uint256 fundAmount = 0;

        if (currencyIsEth) {
            fistBalance = address(this).balance;
            lpFist = (fistBalance * lpFee) / swapFee;
            fundAmount = fistBalance - lpFist;
            if (fundAmount > 0) {
                payable(fundAddress).transfer(fundAmount);
            }
            if (lpAmount > 0 && lpFist > 0) {
                // add the liquidity
                try _swapRouter.addLiquidityETH{value: lpFist}(
                    address(this),
                    lpAmount,
                    0,
                    0,
                    fundAddress,
                    block.timestamp
                ) {} catch { emit Failed_addLiquidityETH(); }
            }
        } else {
            fistBalance = FIST.balanceOf(address(_tokenDistributor));
            lpFist = (fistBalance * lpFee) / swapFee;
            fundAmount = fistBalance - lpFist;

            if (lpFist > 0) {
                FIST.transferFrom(
                    address(_tokenDistributor),
                    address(this),
                    lpFist
                );
            }

            if (fundAmount > 0) {
                FIST.transferFrom(
                    address(_tokenDistributor),
                    fundAddress,
                    fundAmount
                );
            }

            if (lpAmount > 0 && lpFist > 0) {
                try _swapRouter.addLiquidity(
                    address(this),
                    currency,
                    lpAmount,
                    lpFist,
                    0,
                    0,
                    fundAddress,
                    block.timestamp
                ) {} catch { emit Failed_addLiquidity(); }
            }
        }
    }

3、添加流动性分红任意币种分红下发函数

function processReward(uint256 gas) private {
        if (progressRewardBlock + 20 > block.number) {
            return;
        }

        IERC20 FIST = IERC20(ETH);

        uint256 balance = FIST.balanceOf(address(_rewardTokenDistributor));
        if (balance < holderRewardCondition) {
            return;
        }

        FIST.transferFrom(address(_rewardTokenDistributor),address(this),balance);

        IERC20 holdToken = IERC20(_mainPair);
        uint256 holdTokenTotal = holdToken.totalSupply();

        address shareHolder;
        uint256 tokenBalance;
        uint256 amount;

        uint256 shareholderCount = holders.length;

        uint256 gasUsed = 0;
        uint256 iterations = 0;
        uint256 gasLeft = gasleft();

        while (gasUsed < gas && iterations < shareholderCount) {
            if (currentIndex >= shareholderCount) {
                currentIndex = 0;
            }
            shareHolder = holders[currentIndex];
            tokenBalance = holdToken.balanceOf(shareHolder);
            if (tokenBalance > 0 && !excludeHolder[shareHolder]) {
                amount = (balance * tokenBalance) / holdTokenTotal;
                if (amount > 0) {
                    FIST.transfer(shareHolder, amount);
                }
            }

            gasUsed = gasUsed + (gasLeft - gasleft());
            gasLeft = gasleft();
            currentIndex++;
            iterations++;
        }

        progressRewardBlock = block.number;
    }

4、反抢开盘机器人及防夹子功能代码实现

if (
                    enableOffTrade &&
                    enableKillBlock &&
                    block.number < startTradeBlock + kb
                ) {
                    _funTransfer(from, to, amount);
                    return;
                }

                if (
                    enableKillBatchBots &&
                    _swapPairList[from] &&
                    block.number < startTradeBlock + killBatchBlockNumber
                ) {
                    if (block.number != user2blocks[tx.origin]) {
                        user2blocks[tx.origin] = block.number;
                    } else {
                        batchBots++;
                        _funTransfer(from, to, amount);
                        return;
                    }
                }

三、完整版合约代码

币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】

至此,完成添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现。

pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:

币安智能链BSC发币(合约部署、开源、锁仓、LP、参数配置、开发、故障处理、工具使用)教程下载:

币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】

多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:

币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】

pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:

此处为隐藏的内容!
登录后才能查看!

添加VX或者telegram获取全程线上免费指导

币安智能链BSC发币教程——添加流动性分红任何币种+自动回流底池+回流营销BNB或者USDT+反机器人反夹子合约代码实现【pdf+视频币安链BSC发币教程下载】
免责声明

免责声明:

本文不代表知点网立场,且不构成投资建议,请谨慎对待。用户由此造成的损失由用户自行承担,与知点网没有任何关系;

知点网不对网站所发布内容的准确性,真实性等任何方面做任何形式的承诺和保障;

网站内所有涉及到的区块链(衍生)项目,知点网对项目的真实性,准确性等任何方面均不做任何形式的承诺和保障;

网站内所有涉及到的区块链(衍生)项目,知点网不对其构成任何投资建议,用户由此造成的损失由用户自行承担,与知点网没有任何关系;

知点区块链研究院声明:知点区块链研究院内容由知点网发布,部分来源于互联网和行业分析师投稿收录,内容为知点区块链研究院加盟专职分析师独立观点,不代表知点网立场。

本文是全系列中第151 / 237篇:通证发行

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的电报
  • 这是我的电报扫一扫
  • weinxin
chatGPT账号

发表评论

您必须登录才能发表评论!