roberts / standard

Drew Roberts Contract Standard for ERC-20 Tokens
https://DrewRoberts.com
MIT License
0 stars 1 forks source link

removeRestrictions() Function #7

Open drewroberts opened 8 months ago

drewroberts commented 8 months ago

This function removes the max transaction and the max wallet.

drewroberts commented 8 months ago

Here are the variables limiting transactions and max wallet in my old contract standard:

        maxTransactionAmount = (totalSupply) / 50; // 2% of total supply (2,000,000 tokens)
        maxWallet = (totalSupply) / 20;  // 5% of total supply (5,000,000 tokens)

Here is the function that changes them in my old contract standard:

    function updateMaxWalletAndTxnAmount(
        uint256 newTxnNum,
        uint256 newMaxWalletNum
    ) external onlyOwner {
        require(
            newTxnNum >= ((totalSupply() * 5) / 1000),
            "ERC20: Cannot set maxTxn lower than 0.5%"
        );
        require(
            newMaxWalletNum >= ((totalSupply() * 5) / 1000),
            "ERC20: Cannot set maxWallet lower than 0.5%"
        );
        maxWallet = newMaxWalletNum;
        maxTransactionAmount = newTxnNum;
    }

Here is the part of the function that enforces the restrictions in my old contract standard:

            //when buy
            if (
                automatedMarketMakerPairs[from] &&
                !_isExcludedMaxTransactionAmount[to]
            ) {
                require(
                    amount <= maxTransactionAmount,
                    "ERC20: Buy transfer amount exceeds the maxTransactionAmount."
                );
                require(
                    amount + balanceOf(to) <= maxWallet,
                    "ERC20: Max wallet exceeded"
                );
            }
            //when sell
            else if (
                automatedMarketMakerPairs[to] &&
                !_isExcludedMaxTransactionAmount[from]
            ) {
                require(
                    amount <= maxTransactionAmount,
                    "ERC20: Sell transfer amount exceeds the maxTransactionAmount."
                );
            } else if (!_isExcludedMaxTransactionAmount[to]) {
                require(
                    amount + balanceOf(to) <= maxWallet,
                    "ERC20: Max wallet exceeded"
                );
            }

In the new contract standard, I simply want to remove the function to change them and simply use removeRestrictions() to change an anti-whale restriction boolean to true and have the enforce restrictions function conditional on that boolean so it only runs if that anti-whale restriction is set to false.