Betarena / bta_smart

BTA Bitarena Smart Contract
GNU General Public License v3.0
0 stars 0 forks source link

BTA Add Anti-Whale mechanism #7

Closed jonsnowpt closed 2 days ago

jonsnowpt commented 1 year ago

📝 Issue Description

Implement a maximum transaction limit on a smart contract deployed on the Polygon Network. This will limit the maximum amount of tokens bought or sold in a single transaction, preventing large transactions that could potentially manipulate the market.


Maximum Transaction Limit

A maximum transaction limit should be added to the smart contract. The maximum amount of tokens bought or sold in a single transaction should be set to a reasonable value, such as 1% of the total supply of tokens.


Code Example

The following code snippet shows how to implement a maximum transaction limit on a smart contract deployed on the Polygon Network:

contract MyContract is ERC20 {
    uint256 public maxTransactionAmount;

    constructor() {
        maxTransactionAmount = totalSupply() / 100; // Set max transaction amount to 1% of total supply
    }

    function setMaxTransactionAmount(uint256 _maxTransactionAmount) external onlyOwner {
        maxTransactionAmount = _maxTransactionAmount;
    }

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        require(amount <= maxTransactionAmount, "Amount exceeds max transaction limit");
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        require(amount <= maxTransactionAmount, "Amount exceeds max transaction limit");
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), allowance(sender, _msgSender()) - amount);
        return true;
    }
}

In this code example, the maxTransactionAmount variable is set to 1% of the total supply of tokens in the constructor. The setMaxTransactionAmount function allows the contract owner to update the maximum transaction amount. The transfer and transferFrom functions have a required statement that checks whether the transferred amount is less than or equal to the maximum transaction amount. If the amount exceeds the maximum transaction amount, the transaction will be reverted.


🎯 Acceptance Criteria

migbash commented 3 months ago

🟧 UPDATE

jonsnowpt commented 2 days ago

removed.