/*
https://t.me/PepegaCrypto
https://x.com/pepegacrypto
http://pepegacrypto.tech/
*/

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

contract PepegaToken {
    string public name = "Pepega";
    string public symbol = "PEPEGA";
    uint8 public decimals = 18;
    uint256 public totalSupply = 420420420 * 10**uint256(decimals);
    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    uint256 public maxPurchasePercentage = 2; // Maximum purchase percentage allowed

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    constructor() {
        balanceOf[msg.sender] = totalSupply;
    }

    function transfer(address to, uint256 value) public returns (bool) {
        require(to != address(0), "Invalid recipient address");
        require(balanceOf[msg.sender] >= value, "Insufficient balance");

        uint256 maxPurchase = (totalSupply * maxPurchasePercentage) / 100; // Calculate the maximum purchase amount
        require(value <= maxPurchase, "Purchase amount exceeds the limit");

        balanceOf[msg.sender] -= value;
        balanceOf[to] += value;
        emit Transfer(msg.sender, to, value);
        return true;
    }

    function approve(address spender, uint256 value) public returns (bool) {
        allowance[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    function transferFrom(address from, address to, uint256 value) public returns (bool) {
        require(from != address(0), "Invalid sender address");
        require(to != address(0), "Invalid recipient address");
        require(balanceOf[from] >= value, "Insufficient balance");
        require(allowance[from][msg.sender] >= value, "Allowance exceeded");

        balanceOf[from] -= value;
        balanceOf[to] += value;
        allowance[from][msg.sender] -= value;
        emit Transfer(from, to, value);
        return true;
    }
}