币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】

  • A+
所属分类:以太坊ETH 币安BSC

chatGPT账号

币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】

一、说明

所谓扫描挖矿即根据NFT的tokenid值遍历每一个持币地址,将交易手续费跨池为USDT或者直接将本币分红给NFT的每个单品持有者,即完成扫描NFT的每一个tokenID获取挖矿收益,也称为持有NFT扫描挖矿。

LP质押挖矿根据用户deposit到质押合约里的LP数量来实时计算用户获取到本币分红收益,挖矿新币种收益,自动添加流动性返回的LP加权分红收益。用户通过dapp界面主动claim产生的质押分红收益。在质押挖矿合约中,用户们可以随时灵活的存取LP并且赎回产生的分红收益

二、合约代码实现

1、扫描NFT的tokenID挖矿收益代码

function processLargeNFTReward(uint256 gas) private {
        if (processLargeNFTBlock + processLargeNFTBlockDebt > block.number) {
            return;
        }
        uint totalNFT = nft.totalSupply();
        if (0 == totalNFT) {
            return;
        }
        uint256 rewardCondition = nftRewardCondition;
        address sender = address(_tokenDistributor);
        if (balanceOf(address(sender)) < rewardCondition) {
            return;
        }

        uint256 amount = rewardCondition / totalNFT;

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

        address shareHolder;
        uint256 limitAmount = _limitAmount;
        uint256 shareHolderBalance;

        while (gasUsed < gas && iterations < totalNFT) {
            if (currentLargeNFTIndex >= totalNFT) {
                currentLargeNFTIndex = 0;
            }
            if (!excludeNFTHolder[shareHolder]) {
                if (0 == limitAmount || _feeWhiteList[shareHolder]) {
                    _tokenTransfer(sender, shareHolder, amount, false);
                    _nftReward[shareHolder] += amount;
                } else {
                    shareHolderBalance = balanceOf(shareHolder);
                    if (shareHolderBalance + amount <= limitAmount) {
                        _tokenTransfer(sender, shareHolder, amount, false);
                        _nftReward[shareHolder] += amount;
                    }
                }
            }

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

        processLargeNFTBlock = block.number;
    }

2、质押LP deposit方法实现

function deposit(uint256 amount, address invitor) external {
        require(amount > 0, "=0");
        address account = msg.sender;
        UserInfo storage user = userInfo[account];
        if (!user.isActive) {
            user.isActive = true;
            if (userInfo[invitor].isActive) {
                _invitor[account] = invitor;
                _binder[invitor].push(account);
            }
        }
        _calReward(user);

        IERC20(_lpToken).transferFrom(msg.sender, address(this), amount);

        user.amount += amount;
        poolInfo.totalAmount += amount;
        IRewardToken(_rewardToken).minusLPAmount(account, amount);

        user.rewardTokenDebt = user.amount * poolInfo.accTokenPerShare / 1e18;
        user.rewardLPDebt = user.amount * poolInfo.accLPPerShare / 1e18;
        user.rewardMintDebt = user.amount * poolInfo.accMintPerShare / 1e18;
    }

3、取回lp合约代码实现

function withdraw() public {
        address account = msg.sender;
        UserInfo storage user = userInfo[account];
        _calReward(user);

        uint256 amount = user.amount;

        IERC20(_lpToken).transfer(msg.sender, amount);

        user.amount -= amount;
        poolInfo.totalAmount -= amount;
        IRewardToken(_rewardToken).addLPAmount(account, amount);

        user.rewardTokenDebt = user.amount * poolInfo.accTokenPerShare / 1e18;
        user.rewardLPDebt = user.amount * poolInfo.accLPPerShare / 1e18;
        user.rewardMintDebt = user.amount * poolInfo.accMintPerShare / 1e18;
    }

4、claim赎回质押挖矿收益分红代码

function claim() public {
        address account = msg.sender;
        UserInfo storage user = userInfo[account];
        _calReward(user);
        uint256 pendingToken = user.calTokenReward;
        if (pendingToken > 0) {
            IRewardToken rewardToken = IRewardToken(_rewardToken);
            uint256 limitAmount = rewardToken._limitAmount();
            if (!rewardToken._feeWhiteList(account) && limitAmount > 0 && rewardToken.balanceOf(account) + pendingToken > limitAmount) {
                pendingToken = 0;
            }
            if (pendingToken > 0) {
                rewardToken.transfer(account, pendingToken);
                user.calTokenReward = 0;
            }
        }
        uint256 pendingLP = user.calLPReward;
        if (pendingLP > 0) {
            IERC20(_lpToken).transfer(account, pendingLP);
            user.calLPReward = 0;
            IRewardToken(_rewardToken).addLPAmount(account,pendingLP);
        }
        uint256 pendingMint = user.calMintReward;
        if (pendingMint > 0) {
            IERC20 mintRewardToken = IERC20(_mintRewardToken);
            address invitor = _invitor[account];
            if (address(0) != invitor) {
                uint256 inviteAmount = pendingMint * _inviteFee / 10000;
                if (inviteAmount > 0) {
                    pendingMint -= inviteAmount;
                    mintRewardToken.transfer(invitor, inviteAmount);
                }
            }
            mintRewardToken.transfer(account, pendingMint);
            user.calMintReward = 0;
        }
    }

5、业务主合约与LP质押挖矿合约同步映射LP数量代码

function minusLPAmount(address account, uint256 amount) public {
        require(_lpDividendPool == msg.sender, "rq DividendPool");
        (uint256 lpAmount, uint256 lpLockAmount, uint256 releaseAmount, uint256 lpBalance) = getUserInfo(account);
        if (lpLockAmount > 0) {
            require(lpBalance + releaseAmount >= lpLockAmount, "rq Lock");
        }
        require(lpAmount >= amount, ">userLP");
        _userInfo[account].lpAmount -= amount;
    }

    function addLPAmount(address account, uint256 amount) public {
        require(_lpDividendPool == msg.sender, "rq DividendPool");
        _userInfo[account].lpAmount += amount;
    }

三、业务主合约+LP质押挖矿合约完整版本合约源代码

币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】

源码及合约部署、开源、上线交易所、动态参数配置教程下载地址:

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

至此,完成扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现所有操作流程。

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

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

币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】

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

币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】

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

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

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

币安BSC智能链发币教程——扫描挖矿+NFT循环扫描分红本币+lp质押挖矿产出新币的合约代码实现【pdf+视频BSC发币教程下载】
免责声明

免责声明:

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

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

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

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

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

本文是全系列中第210 / 238篇:通证发行

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

发表评论

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