ETH Price: $2,409.94 (-0.63%)

Contract Diff Checker

Contract Name:
HyperBlastStandardToken00

Contract Source Code:

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides 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} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        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);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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;
    }
}

//import { console } from "hardhat/console.sol";

interface IBlast {
    function configureClaimableGas() external;
    function configureGovernor(address _governor) external;
    function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256);
    function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256);
}

/**
 * @title BlastGasRefunder
 * @author HyperBlast team
 * @notice Contract to refund gas to users automatically
 * @dev CAREFUL, if you copy and use this contract you are doing that under you own responsability, 
 * we are not responsible of any losses you could suffer from bad implementations or bugs
 */
contract BlastGasRefunder {
    
    IBlast private iBlast = IBlast(0x4300000000000000000000000000000000000002);
    bytes4 private constant FSIGN_CLAIM_MAX_GAS = bytes4(keccak256("claimMaxGas(address,address)"));
    bytes4 private constant FSIGN_CLAIM_ALL_GAS = bytes4(keccak256("claimAllGas(address,address)"));
    
    /**
     * @notice refundmentPercentage has to be bigger or equal to this
     */
    uint8 public minRefundmentPercentage = 0;
    /**
     * @notice Percentage of claimed gas for refundments
     */
    uint8 public refundmentPercentage = 0;
    /**
     * @notice We claim the gas 1 time per day
     */
    uint24 public dayCounter = 0;
    /**
     * @notice Claim max / claim all gas available
     */
    bool public claimMax = true;
    /**
     * @notice The address that can trigger the custom gas functions from this contract
     */
    address public blastOwner;
    /**
     * @notice refundmentPercentage gets locked and can not be changed
     */
    bool public renounceUpdateRefundment = false;
    /**
     * @notice Max gas for calling gas refund functions
     */
    uint256 public maxGasForCall = 300000;
    /**
     * @notice Max amount that router can refund automatically
     */
    uint256 public maxRefund = 0.01 ether;

    modifier onlyBlastOwner() {
        require(msg.sender == blastOwner, "Only blast contract owner can manage blast features");
        _;
    }

    modifier gasRefunder() {
        uint256 gasStart = gasleft();
        _;
        //1 execution per day
        uint24 currentDayCounter = uint24(block.timestamp / 1 days);
        if(currentDayCounter != dayCounter) {
            claimGas(true);
            dayCounter = currentDayCounter;
        }
        //Refund if possible
        uint256 gasLeft = gasleft();
        uint256 gasToRefund = (gasLeft < gasStart ? gasStart - gasLeft : 0) * tx.gasprice;
        uint256 gasToRefundCap = gasToRefund <= maxRefund ? gasToRefund : maxRefund;
        uint256 refunmentsBal = address(this).balance;
        if(refundmentPercentage > 0 && refunmentsBal >= gasToRefundCap && gasToRefundCap > 0) {
            payable(tx.origin).send(gasToRefundCap);
        }
    }

    constructor() public {
        blastOwner = address(this);
        iBlast.configureGovernor(address(this)); //default governor        
        iBlast.configureClaimableGas();
    }

    /**
     * This function is used to claim pending gas, will run on 'safe mode' for automatic gas refunding call
     * @param lowLevel If we need a low level call (to prevent crashes on any case)
     */
    function claimGas(bool lowLevel) internal returns(uint256) {
        uint256 prevBal = address(this).balance;
        if(lowLevel) {
            bytes memory encodedCall = abi.encodeWithSelector(claimMax ? FSIGN_CLAIM_MAX_GAS : FSIGN_CLAIM_ALL_GAS, address(this), address(this));
            address(iBlast).call{ gas: maxGasForCall }(encodedCall);
        } else {
            if(claimMax) {
                iBlast.claimMaxGas(address(this), address(this));
            } else {
                iBlast.claimAllGas(address(this), address(this));
            }
        }
        uint256 afterBal = address(this).balance;
        if(refundmentPercentage < 100 && afterBal > prevBal) {
            uint256 refundAmount = (afterBal - prevBal) * (100 - refundmentPercentage) / 100;
            payable(blastOwner).send(refundAmount);
            return refundAmount;
        }
        return 0;
    }

    //#region Ownership

    function setBlastOwnerInt(address _blastOwner) internal {
        blastOwner = _blastOwner;
    }

    function setBlastOwner(address _blastOwner) public onlyBlastOwner {
        blastOwner = _blastOwner;
    }

    function unstuckETH() external onlyBlastOwner {
        payable(blastOwner).transfer(address(this).balance);
    }

    function setMaxGasForCall(uint256 _maxGas) external onlyBlastOwner {
        maxGasForCall = _maxGas;
    }

    function setMaxRefund(uint256 _maxRefund) external onlyBlastOwner {
        require(_maxRefund <= 0.5 ether, "Invalid max refund");
        maxRefund = _maxRefund;
    }

    function claimMode(bool _claimMax) external onlyBlastOwner {
        claimMax = _claimMax;
    }

    function updateRefundmentPercentage(uint8 newRFPC) external onlyBlastOwner {
        require(!renounceUpdateRefundment, "UPDATES NOT ALLOWED");
        require(newRFPC >= minRefundmentPercentage, "Min. gas for refundment has to be bigger tan minimal");
        require(newRFPC <= 100, "Max. gas for refundment is 100%");
        refundmentPercentage = newRFPC;
    }

    function renounceOwnerUpdateRefundment() external onlyBlastOwner {
        require(!renounceUpdateRefundment, "Already renounced");
        renounceUpdateRefundment = true;
    }    

    /**
     * @notice Can be used to claim the pending gas and to check the gas pending to claim by simulation
     */
    function claim() external onlyBlastOwner returns(uint256) {
        return claimGas(false);
    }

    //#endregion    
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { 
    BasicTokenConfig, 
    TransactionsLimitsConfig, 
    DisableLimitOption, 
    DisableLimitsConfig, 
    DEXConfig,
    TaxesConfigBase10000, 
    TaxesConfigReceivers    
} from "../Helpers/TokenAdvanced00Entities.sol";
import { HyperBlastStandardToken01 } from "../Standard/HyperBlastStandardToken01.sol";
import { IHyperBlastV2Router02 } from "../../../UniV2Fork/Interfaces/IHyperBlastV2Router02.sol";
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
//import { console } from "hardhat/console.sol";

/* solhint-disable no-empty-blocks */

/**
 * @title HyperBlast Advanced Token 00
 * @author HyperBlastTeam
 * @notice Customizable advanced token contract
 * 1. Owner can add more liquidity pairs to apply taxes
 * 2. Configurable taxes -> dev, marketing, liq, charity (optional: increased during limits)
 * 3. Max wallet and max tx, (optional: for some amount of swaps, certain timestamp or blocks)
 */
contract HyperBlastAdvancedToken00 is HyperBlastStandardToken01 {

    TaxesConfigBase10000 public _taxesConfigBase10000;
    TaxesConfigReceivers public _taxesConfigReceivers;    

    IHyperBlastV2Router02 private _router;

    address public _weth;
    address public _liqPairSwapback;
    bool internal _inSwap = false;
    uint256 public TAX_SWAP_THRESHOLD;
    uint256 public MAX_TAX_SWAP;

    modifier lockTheSwap() {
        _inSwap = true;
        _;
        _inSwap = false;
    }

    constructor(
        BasicTokenConfig memory basicTokenConfig,
        TransactionsLimitsConfig memory transactionsLimitsConfig,
        DisableLimitsConfig memory disableLimitsConfig,      
        DEXConfig memory dexConfig,
        address gasGov,
        TaxesConfigBase10000 memory taxesConfigBase10000,
        TaxesConfigReceivers memory taxesConfigReceivers
    ) HyperBlastStandardToken01(
        basicTokenConfig, 
        transactionsLimitsConfig, 
        disableLimitsConfig, 
        dexConfig,
        gasGov
    ) {
        TAX_SWAP_THRESHOLD = totalSupply() / 2000;
        MAX_TAX_SWAP = totalSupply() / 1000;
        require(
            (taxesConfigBase10000.charityTax + 
            taxesConfigBase10000.devTax + 
            taxesConfigBase10000.liquidityTax + 
            taxesConfigBase10000.marketingTax) == taxesConfigBase10000.totalTax, "Invalid tax config");   
        require(taxesConfigBase10000.totalTaxIfLimits < 10000, "Invalid tax in limits config");
        _liqPairSwapback = dexConfig.tokenLiq;
        _taxesConfigBase10000 = taxesConfigBase10000;
        _taxesConfigReceivers = taxesConfigReceivers;
        _router = IHyperBlastV2Router02(dexConfig.router);
        _weth = _router.WETH();
        _approve(address(this), address(_router), type(uint256).max);
        IERC20(_liqPairSwapback).approve(address(_router), type(uint256).max);
    }

    /**
     * @notice Returns the router address (uniswapv2 fork) used for swapbacks
     */
    function getRouterAddress() external returns(address) {
        return address(_router);
    }

    //#region Admin

    function configTaxReceivers(TaxesConfigReceivers memory taxesConfigReceivers) external onlyOwner {
        _taxesConfigReceivers.charityReceiver = taxesConfigReceivers.charityReceiver;
        _taxesConfigReceivers.devTaxReceiver = taxesConfigReceivers.devTaxReceiver;
        _taxesConfigReceivers.liquidityReceiver = taxesConfigReceivers.liquidityReceiver;
        _taxesConfigReceivers.marketingTaxReceiver = taxesConfigReceivers.marketingTaxReceiver;
    }

    //#endregion

    //#region Tax management

    event SendTaxPaymentError();
    /**
     * @dev Transfer could fail because of recipient address
     * @param _tokensSend tokens amount
     * @param _receiver wallet that receives the payment
     */
    function sendPaymentToWallet(uint256 _tokensSend, address _receiver) internal {
        bool success = payable(_receiver).send(_tokensSend);
        if(success) {
            //console.log('Eth payment ok %s', _tokensSend);
        } else {
            emit SendTaxPaymentError();
        }
    }

    event BuybackForLiqError();
    event AddLiqError();

    function sendTokensToLiquidity(uint256 _tokensSend, address _liqReceiver) internal lockTheSwap {
        address[] memory path = new address[](2);        
        path[0] = _weth;      
        path[1] = address(this);        

        uint256[] memory amounts = _router.getAmountsOut(_tokensSend, path);

        try _router.addLiquidityETH{ value: _tokensSend }(
            address(this), 
            amounts[1], 
            0,
            0, 
            _liqReceiver,
            block.timestamp
        ) {
            //console.log('add liq ok');    
        } catch Error(string memory _error)  {
            //console.log(_error);
            emit AddLiqError();
        } catch  {
            //console.log('add liq assert error?');
            emit AddLiqError();
        }
    }

    /**
     * @param _tokensSend tokens to split between the tax receivers
     */
    function sendETHToFee(uint256 _tokensSend) internal {
        TaxesConfigReceivers memory __taxesConfigReceivers = _taxesConfigReceivers;
        TaxesConfigBase10000 memory __taxesConfigBase10000 = _taxesConfigBase10000;
        if(__taxesConfigBase10000.devTax > 0) {
            sendPaymentToWallet(_tokensSend * __taxesConfigBase10000.devTax / __taxesConfigBase10000.totalTax, __taxesConfigReceivers.devTaxReceiver);
        }
        if(__taxesConfigBase10000.marketingTax > 0) {
            sendPaymentToWallet(_tokensSend * __taxesConfigBase10000.marketingTax / __taxesConfigBase10000.totalTax, __taxesConfigReceivers.marketingTaxReceiver);
        }
        if(__taxesConfigBase10000.charityTax > 0) {
            sendPaymentToWallet(_tokensSend * __taxesConfigBase10000.charityTax / __taxesConfigBase10000.totalTax, __taxesConfigReceivers.charityReceiver);
        }
        if(__taxesConfigBase10000.liquidityTax > 0) {
            sendTokensToLiquidity(_tokensSend * __taxesConfigBase10000.liquidityTax / __taxesConfigBase10000.totalTax, __taxesConfigReceivers.liquidityReceiver);
        }
    }

    /**
     * @notice Payments can be processed manually you can indicate an amount and will be distributed between the tax receivers
     * @param _tokensSend tokens to split between the tax receivers
     * @param _safe if true ensures all eth indicated has been transferred
     */
    function sendETHToFeeManual(uint256 _tokensSend, bool _safe) external onlyOwner {
        uint256 prevBal = address(this).balance;
        sendETHToFee(_tokensSend);
        uint256 afterBal = address(this).balance;
        require(!_safe || (prevBal - afterBal >= _tokensSend), "Error sending tokens");
    }

    event SwapbackError();
    function swapTokensForETH(uint256 _tokensAmount) internal lockTheSwap {
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = _liqPairSwapback;     
        if(_liqPairSwapback != _weth) {
            path[2] = _weth;     
        }
        try _router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            _tokensAmount,
            0,
            path,
            address(this),
            block.timestamp
        ) {
            //console.log('Swapback ok');    
        } catch Error(string memory _error)  {
            //console.log(_error);
            emit SwapbackError();
        } catch  {
            //console.log('assert error?');
            emit SwapbackError();
        }
    }

    function min(uint256 a, uint256 b) private pure returns (uint256) {
        return (a > b) ? b : a;
    }

    /**
     * @dev Manage tax payments
     * @param to Who receives the tokens?
     * @param amount How much tokens?
     */
    function feesManager(address to, uint256 amount) internal {
        uint256 taxedAmount = amount * _taxesConfigBase10000.totalTax / 10000;
        if(limitsEnabled()) {
            taxedAmount = amount * _taxesConfigBase10000.totalTaxIfLimits / 10000;
        }
        
        if(taxedAmount > 0) {
            _transfer(to, address(this), taxedAmount);        
        }  

        //console.log('Amount taxed %s', taxedAmount);
    }

    /**
     * @dev Manage swapbacks
     * @param to Who receives the tokens?
     * @param amount How much tokens?
     */
    function swapbackManager(address to, uint256 amount) internal {
        uint256 contractTokenBalance = balanceOf(address(this));
        //console.log('Amount bought %s', amount);
        //console.log('Contract balance %s', contractTokenBalance);
        //console.log('Tax swap threshold %s', TAX_SWAP_THRESHOLD);
        if (!_inSwap && _liqPairs[to] && contractTokenBalance > TAX_SWAP_THRESHOLD && amount > 0) {
            uint256 amountSwap = min(amount, min(contractTokenBalance, MAX_TAX_SWAP));
            TaxesConfigBase10000 memory __taxesConfigBase10000 = _taxesConfigBase10000;
            uint256 amountSwapSubstractLiq =  amountSwap * __taxesConfigBase10000.liquidityTax / __taxesConfigBase10000.totalTax;           

            //console.log('Swapping %s', amountSwap - amountSwapSubstractLiq);
            swapTokensForETH(amountSwap - amountSwapSubstractLiq);
            uint256 contractETHBalance = address(this).balance;
            if (contractETHBalance > 0) {
                sendETHToFee(contractETHBalance);
            }
        }  
    }

    //#endregion

    //#region Tax checks and limits

    /**
     * @dev Tax only on swap, we check if it is a buy or a sell
     * @param from sender
     * @param to receiver
     */
    function ignoreTaxChecks(address from, address to) internal view returns (bool) {
        return (!_liqPairs[to] && !_liqPairs[from]) || _inSwap || from == address(this) || to == address(this);
    }

    function _beforeTokenTransfer2(address from, address to, uint256 amount) internal override {
        swapbackManager(to, amount);

        //To extend
        _beforeTokenTransfer3(from, to, amount);
    }

    function _afterTokenTransfer2(address from, address to, uint256 amount) internal override {        
        if(ignoreTaxChecks(from, to)) return;

        feesManager(to, amount);

        //To extend
        _afterTokenTransfer3(from, to, amount);
    }

    //#endregion

    /*solhint-disable no-empty-blocks*/

    function _beforeTokenTransfer3(address from, address to, uint256 amount) internal virtual { }

    function _afterTokenTransfer3(address from, address to, uint256 amount) internal virtual { }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { 
    BasicTokenConfig, 
    TransactionsLimitsConfig, 
    DisableLimitOption, 
    DisableLimitsConfig, 
    DEXConfig,
    TaxesConfigBase10000, 
    TaxesConfigReceivers,
    AntibotConfig
} from "../Helpers/TokenAdvanced01Entities.sol";
import { HyperBlastAdvancedToken00 } from "./HyperBlastAdvancedToken00.sol";

/**
 * @title HyperBlast Advanced Token 00
 * @author HyperBlastTeam
 * @notice Customizable advanced token contract
 * 1. Owner can add more liquidity pairs to apply taxes
 * 2. Configurable taxes -> dev, marketing, liq, charity
 * 3. Max wallet and max tx, (optional: for some amount of swaps, certain timestamp or blocks)
 * 4. Customizable auto and/or manual blacklist
 */
contract HyperBlastAdvancedToken01 is HyperBlastAdvancedToken00 {

    AntibotConfig private _antibotConfig;
    uint256 internal _launchBlock;
    mapping(address => bool) internal _blacklist;

    constructor(
        BasicTokenConfig memory basicTokenConfig,
        TransactionsLimitsConfig memory transactionsLimitsConfig,
        DisableLimitsConfig memory disableLimitsConfig,      
        DEXConfig memory dexConfig,
        address gasGov,
        TaxesConfigBase10000 memory taxesConfigBase10000,
        TaxesConfigReceivers memory taxesConfigReceivers,
        AntibotConfig memory antibotConfig
    ) HyperBlastAdvancedToken00(
        basicTokenConfig, 
        transactionsLimitsConfig, 
        disableLimitsConfig, 
        dexConfig,
        gasGov,
        taxesConfigBase10000,
        taxesConfigReceivers
    ) {
        _antibotConfig = antibotConfig;
        _launchBlock = block.timestamp;
    }

    function manageBlacklist(address adr, bool blacklist) external onlyOwner {
        require(_antibotConfig.manualManagement, "Your antibot config does not admit manual management");
        require(!_antibotConfig.manualOnlyUnBlacklist || !blacklist, "Your antibot config only admits manual unblacklist");
        _blacklist[adr] = blacklist;
    }

    /*solhint-disable no-empty-blocks*/

    function autoBlacklistSnipers(address from, address to) internal {
        if(block.number < (_launchBlock + _antibotConfig.nBlocks) && _liqPairs[from]) {
            _blacklist[to] = true;
        }
    }

    function _beforeTokenTransfer3(address from, address to, uint256 amount) internal override {
        if(_antibotConfig.revertOnBuy) {
            autoBlacklistSnipers(from, to);
        }

        require(!_blacklist[to], "Receiver blacklisted...");
        require(!_blacklist[from], "Sender blacklisted...");

        autoBlacklistSnipers(from, to);

        _beforeTokenTransfer4(from, to, amount);
    }

    function _afterTokenTransfer3(address from, address to, uint256 amount) internal override { 
        _afterTokenTransfer4(from, to, amount);
    }

    function _beforeTokenTransfer4(address from, address to, uint256 amount) internal virtual { }

    function _afterTokenTransfer4(address from, address to, uint256 amount) internal virtual { }
}

//TODO add rewards

//TODO add reflections

struct BasicTokenConfig {
    string name;
    string symbol;
    uint8 tokenDecimals;
    uint256 initialSupply;
    address supplyReceiver;
}

import { BasicTokenConfig } from "../Helpers/Token00Entities.sol";

struct TransactionsLimitsConfig {
    uint8 maxTxPc;
    uint8 maxWalletPc;
}

enum DisableLimitOption {
    none,
    nSwaps,
    untilTimestap,
    nBlocks
}

/**
 * @dev 
 * if option nSwaps -> Number swaps required to disable limits
 * if option nBlocks -> Blocks since launch to disable limits
 * if option untilTimestap -> Timestamp to disable limits
 */
struct DisableLimitsConfig {        
    DisableLimitOption disableLimitOption;
    uint256 disableLimitBound;
}

/**
 * @dev
 * We need this to predict liquidity pair, has to be exempted from taxes
 */
struct DEXConfig {
    address router;
    address tokenLiq;
}

import { BasicTokenConfig, TransactionsLimitsConfig, DisableLimitOption, DisableLimitsConfig, DEXConfig } from "../Helpers/Token01Entities.sol";

struct TaxesConfigBase10000 {
    uint256 devTax;
    uint256 marketingTax;
    uint256 liquidityTax;
    uint256 charityTax;
    uint256 totalTax;
    uint256 totalTaxIfLimits;
}

struct TaxesConfigReceivers {
    address devTaxReceiver;
    address marketingTaxReceiver;
    address liquidityReceiver;
    address charityReceiver;
}

import { 
    BasicTokenConfig, 
    TransactionsLimitsConfig, 
    DisableLimitOption, 
    DisableLimitsConfig, 
    DEXConfig, 
    TaxesConfigBase10000, 
    TaxesConfigReceivers 
} from "./TokenAdvanced00Entities.sol";

/**
 * @dev Users gets autoblacklisted if he buys before nBlocks pass since launch
 */
struct AntibotConfig {
    uint8 nBlocks;
    bool revertOnBuy;
    bool manualManagement;
    bool manualOnlyUnBlacklist;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { BlastGasRefunder } from "../../Blast/BlastGasRefunder.sol";
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { IHyperBlastV2Router02 } from "../../UniV2Fork/Interfaces/IHyperBlastV2Router02.sol";
import { HyperBlastTokenFactoryV1Iface } from "./HyperBlastTokenFactoryV1Iface.sol";

/* solhint-disable no-empty-blocks */

interface HyperBlastTokenFactoriesManagerIface {
    function processETHpayment() external payable;
    function processHYPEpayment(address _user) external;
    function registerContract(address _deployedToken) external;
}

/**
 * @title HyperBlast Token Factory/Generator 
 * @author HyperBlastTeam
 * @notice This contract has been created to deploy contracts from HyperBlast DAPP
 * Cost: minor or equals to 0.025 ETH or same value with discount in HYPE tokens
 * Benefits: 
 * 1. You can create a contract with a zero-code solution from HyperBlast DAPP
 * 2. Tokens deployed from HyperBlastTokenFactoryV1 contract, safe an audited code
 * 3. Automatic verification
 * 4. You can check and manage your deployed contracts from HyperBlast DAPP
 */
contract HyperBlastTokenFactoriesManager is HyperBlastTokenFactoriesManagerIface, Ownable2Step, BlastGasRefunder {

    IHyperBlastV2Router02 public immutable HYPE_ROUTER_IFACE;
    address public HYPE;
    address public immutable WETH;
    IERC20 private HYPE_IFACE;

    /**
     * @notice HyperBlast upgradeable token factory 
     */
    bytes private factoryV1bytecode;

    /**
     * @notice Cost per deployment
     */
    uint256 public deployCostEth = 0.025 ether;

    /**
     * @notice Receives ETH payments and HYPE payments
     */
    address public feeReceiver = address(0x0);
    /**
     * @notice If you pay using HYPE you will get a discount
     */
    uint8 public hypePercentageDiscount = 15; //15% off by default
    /**
     * @notice When you pay using HYPE some tokens are burned and the rest are sent to the team
     */
    uint8 public hypePercentageBurning = 50; //50% by default

    //
    uint256 public totalDeployedContracts;
    mapping(uint256 => address) public deployedContracts;
    mapping(address => bool) public isDeployedContract;

    /**
     * @notice Independent factory contract is deployed for each user
     */
    mapping(address => bool) public isFactory;
    mapping(address => address) public userFactory;
    mapping(uint256 => address) public deployedFactories;
    uint256 public totalFactories;

    event OnCreateFactory(address user, address factory, uint256 totalFactories);
    event OnRegisterContract(address factory, address newContract);

    constructor(bytes memory _factoryV1bytecode, address _hypeAddress, address _routerAddress, address _feeReceiver) {
        factoryV1bytecode = _factoryV1bytecode;
        HYPE_ROUTER_IFACE = IHyperBlastV2Router02(_routerAddress);
        HYPE = _hypeAddress;
        WETH = HYPE_ROUTER_IFACE.WETH();
        HYPE_IFACE = IERC20(HYPE);

        if(_feeReceiver != address(0x0)) {
            feeReceiver = _feeReceiver;
        }
        setBlastOwnerInt(owner());
    }
    
    //#region VIEWS

    /**
     * @notice This enables you to manage the contracts from our UI
     */
    function getDeployedContractsUser(address _user, uint256 _index, uint256 _nTake) public view returns(address[] memory) {
        address _userFactory = userFactory[_user];
        return HyperBlastTokenFactoryV1Iface(_userFactory).getUserContracts(_index, _nTake);
    }

    function getNumberDeployedContractsUser(address _user, uint256 _index, uint256 _nTake) public view returns(uint256) {
        address _userFactory = userFactory[_user];
        return HyperBlastTokenFactoryV1Iface(_userFactory).getUserContracts(_index, _nTake).length;
    }

    function getDeployedContracts(uint256 _index, uint256 _nTake) public view returns(address[] memory) {
        address[] memory addressReturn = new address[](_nTake);
        uint256 nTaken = 0;

        for (uint256 index = _index; index <= totalDeployedContracts; index++) {
            addressReturn[index] = deployedContracts[index];
            nTaken++;
            if(nTaken >= _nTake) break;
        }

        return addressReturn;
    }

    function getDeployedFactories(uint256 _index, uint256 _nTake) public view returns(address[] memory) {
        address[] memory addressReturn = new address[](_nTake);
        uint256 nTaken = 0;

        for (uint256 index = _index; index <= totalFactories; index++) {
            addressReturn[index] = deployedFactories[index];
            nTaken++;
            if(nTaken >= _nTake) break;
        }

        return addressReturn;
    }

    function getHypeDeployCost() public view returns(uint256) {
        address[] memory hype_buy_path = new address[](2);
        hype_buy_path[0] = WETH;
        hype_buy_path[1] = HYPE;
        uint256[] memory amounts = HYPE_ROUTER_IFACE.getAmountsOut(deployCostEth, hype_buy_path);
        require(amounts.length == 2, "HYPE payment unavailable");
        return amounts[1] * (100 - hypePercentageDiscount) / 100;
    }

    //#endregion

    /**
     * @notice Each user will have his own factory that only can be used by himself
     */
    function createFactory() external gasRefunder {
        require(userFactory[msg.sender] == address(0x0), "You already have a factory");
        address _userFactory; 
        bytes memory deploymentBytecode = abi.encodePacked(factoryV1bytecode, abi.encode(msg.sender));
        /*solhint-disable-next-line*/
        assembly {
            _userFactory := create(0, add(deploymentBytecode, 0x20), mload(deploymentBytecode))
        }
        require(_userFactory != address(0), "Error deploying factory, contact developers if persists");
        userFactory[msg.sender] = address(_userFactory);
        isFactory[address(_userFactory)] = true;
        totalFactories++;
        emit OnCreateFactory(msg.sender, address(_userFactory), totalFactories);
    }

    function claimFactoryGas(address adr, bool safe) public returns(uint256) {
        (, bytes memory data) = adr.call(abi.encodeWithSignature("claim()"));
        payable(owner()).send(address(this).balance);
        if(safe) {
            return abi.decode(data, (uint256));
        } else {
            return 0;
        }
    }

    function claimDeployedFactoriesGas(uint256 _index, uint256 _nTake, bool safe) public returns(uint256) {
        uint256 gasClaimed = 0;
        uint256 nTaken = 0;

        for (uint256 index = _index; index <= totalFactories; index++) {
            gasClaimed += claimFactoryGas(deployedFactories[index], safe);
            nTaken++;
            if(nTaken >= _nTake) break;
        }

        return gasClaimed;
    }

    //#region EXTERNALS    

    function processETHpayment() external payable {
        require(isFactory[msg.sender], "Only deployed factories can perform payments");
        require(msg.value == deployCostEth, "Error processing ETH payment, send exact amount or transaction will be reverted");
        /*solhint-disable-next-line*/
        bool result = payable(feeReceiver).send(msg.value);
        require(result, "Error sending payment to fee receiver, wait until developers solve the issue, sorry");                
    }

    function processHYPEpayment(address _user) external {
        require(isFactory[msg.sender], "Only deployed factories can perform payments");
        uint256 hypeDeployCost = getHypeDeployCost();

        try HYPE_IFACE.transferFrom(_user, address(this), hypeDeployCost) {
            //OK
        } catch {
            revert("Error processing HYPE payment, ensure your balance and allowance is enough");
        }        

        uint256 burningAmount = hypeDeployCost * hypePercentageBurning / 100;
        uint256 paymentAmount = hypeDeployCost * (100 - hypePercentageBurning) / 100;

        try HYPE_IFACE.transfer(address(0xdEad), burningAmount) {
            //OK
        } catch  {
            /*solhint-disable-next-line*/
            (bool success,) = address(HYPE_IFACE).call(abi.encodeWithSignature("burn(uint256)", abi.encode(burningAmount)));
            require(success, "Error burning tokens, wait until developers solve the issue, sorry");
        }

        try HYPE_IFACE.transfer(feeReceiver, paymentAmount) {
            //OK
        } catch {
            revert("Error processing HYPE payment (contract -> receiver), wait until developers solve the issue, sorry");
        } 
    }

    function registerContract(address _deployedToken) external {
        require(isFactory[msg.sender], "Only deployed factories can register contracts");       
        deployedContracts[totalDeployedContracts] = _deployedToken;
        totalDeployedContracts++;
        isDeployedContract[_deployedToken] = true;
        claimFactoryGas(msg.sender, false);
        emit OnRegisterContract(msg.sender, _deployedToken);
    }

    //#endregion

    //#region OWNER

    function setFactoryV1bytecode(bytes memory _factoryV1bytecode) public onlyOwner {
        factoryV1bytecode = _factoryV1bytecode;
    }

    function setFeesReceiver(address _feeReceiver) public onlyOwner {
        require(_feeReceiver != address(0x0) && _feeReceiver != address(0xdEaD), "Invalid address");
        feeReceiver = _feeReceiver;
    }

    function setETHprice(uint256 _deployCostEth) public onlyOwner {
        require(_deployCostEth <= 0.2 ether, "Deployment cost can not be bigger than 0.2 eth");
        deployCostEth = _deployCostEth;
    }

    function setNewHype(address _newHype) public onlyOwner {
        HYPE = _newHype;
        HYPE_IFACE = IERC20(_newHype);
    }

    function setHypeDiscountPercentage(uint8 _hypePercentageDiscount) public onlyOwner {
        require(_hypePercentageDiscount >= 10, "HYPE discount has to be 10% or bigger");
        hypePercentageDiscount = _hypePercentageDiscount;
    }

    function setHypeBurningPercentage(uint8 _hypePercentageBurning) public onlyOwner {
        require(_hypePercentageBurning >= 50, "HYPE burning percentage has to be 50% or bigger");
        hypePercentageBurning = _hypePercentageBurning;
    }

    function extractStuckETH() public onlyOwner {
        payable(address(msg.sender)).transfer(address(this).balance);
    }

    function extractStuckHYPE() public onlyOwner {
        HYPE_IFACE.transfer(msg.sender, HYPE_IFACE.balanceOf(address(this)));
    }

    function extractStuckToken(address _adr) public onlyOwner {
        IERC20(_adr).transfer(msg.sender, IERC20(_adr).balanceOf(address(this)));
    }

    //#endregion

    receive() external payable {}
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { BlastGasRefunder } from "../../Blast/BlastGasRefunder.sol";
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
import { HyperBlastTokenFactoryV1Iface } from "./HyperBlastTokenFactoryV1Iface.sol";

/* solhint-disable no-console */
/* solhint-disable no-empty-blocks */

interface HyperBlastTokenFactoriesManagerIface {
    function deployCostEth() external returns(uint256);
    function processETHpayment() external payable;
    function processHYPEpayment(address _user) external;
    function registerContract(address _deployedToken) external;
}

contract HyperBlastTokenFactoryV1 is HyperBlastTokenFactoryV1Iface, BlastGasRefunder {
    HyperBlastTokenFactoriesManagerIface private factoriesManager;

    mapping(uint256 => address) public deployedContracts;
    uint256 public totalDeployedContracts;

    address public immutable owner;

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can use this contract");
        _;
    }

    constructor(address _owner) {
        owner = _owner;    
        factoriesManager = HyperBlastTokenFactoriesManagerIface(msg.sender);
        setBlastOwnerInt(msg.sender); //to factories manager
    }

    //#region VIEWS

    function getUserContracts(uint256 _index, uint256 _nTake) public view returns(address[] memory) {
        address[] memory addressReturn = new address[](_nTake);
        uint256 nTaken = 0;

        for (uint256 index = _index; index <= totalDeployedContracts; index++) {
            addressReturn[index] = deployedContracts[index];
            nTaken++;
            if(nTaken >= _nTake) break;
        }

        return addressReturn;
    }

    //#endregion

    /**
     * @dev HyperBlast is NOT responsible for consecuences derived from using this contract directly
     * only use this through the HyperBlast DAPP
     * @param bytecodeToDeploy contract bytecode + parameters
     * @param ethPaymentSelected are you gonna paid using HYPE or ETH?
     */
    function deployToken(bytes memory bytecodeToDeploy, bool ethPaymentSelected) external payable onlyOwner gasRefunder returns(address) {        

        uint256 payableAmount = msg.value;

        //Process payments
        if(ethPaymentSelected) {       
            //Deployment cost
            uint256 deployCostEth = factoriesManager.deployCostEth();
            require(payableAmount >= deployCostEth, "ETH sent is not enough to pay deployment");     

            try factoriesManager.processETHpayment{ value: deployCostEth }() {
                //OK
            } catch Error(string memory reason) {
                revert(reason);
            }

            payableAmount -= deployCostEth;
        } else {
            try factoriesManager.processHYPEpayment(msg.sender) {
                //OK
            } catch Error(string memory reason) {
                revert(reason);
            }
        }

        //Deploy new contract
        address deployedToken;        
        /*solhint-disable-next-line*/
        assembly {
            deployedToken := create(payableAmount, add(bytecodeToDeploy, 0x20), mload(bytecodeToDeploy))
        }
        require(deployedToken != address(0), "Error deploying contract, contact developers if persists");

        //Son?
        (bool success, bytes memory data) = deployedToken.call(abi.encodeWithSignature("sonContract()"));
        if(success) {
            deployedToken = abi.decode(data, (address));
        }

        //Register contract for user
        try factoriesManager.registerContract(deployedToken) {
            //OK
        } catch Error(string memory reason) {
            revert(reason);
        }

        //Local register
        deployedContracts[totalDeployedContracts] = deployedToken;
        totalDeployedContracts++;

        return  deployedToken;
    }    

    //#region OWNER

    function extractStuckETH() public onlyOwner {
        payable(address(msg.sender)).transfer(address(this).balance);
    }

    function extractStuckToken(address _adr) public onlyOwner {
        IERC20(_adr).transfer(msg.sender, IERC20(_adr).balanceOf(address(this)));
    }

    //#endregion

    receive() external payable {}
}

interface HyperBlastTokenFactoryV1Iface {
    function getUserContracts(uint256 _index, uint256 _nTake) external view returns(address[] memory);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { 
    BasicTokenConfig, 
    TransactionsLimitsConfig, 
    DisableLimitOption, 
    DisableLimitsConfig, 
    DEXConfig,
    TaxesConfigBase10000, 
    TaxesConfigReceivers    
} from "../Helpers/TokenAdvanced00Entities.sol";
import { HyperBlastAdvancedToken00 } from "../Advanced/HyperBlastAdvancedToken00.sol";
//import { console } from "hardhat/console.sol";

/**
 * @title HyperBlast Advanced Token 00 real fair launch
 * @author HyperBlastTeam
 * @notice Customizable advanced token contract
 * 1. Owner can add more liquidity pairs to apply taxes
 * 2. Configurable taxes -> dev, marketing, liq, charity
 * 3. Max wallet and max tx, (optional: for some amount of swaps, certain timestamp or blocks)
 * 4. Liquidity on deployment
 * @dev We call this 'real fair launch' because an unknown contract is so hard to snipe
 */
contract HyperBlastAdvancedToken00RFLDeployer {
    address public immutable sonContract;

    constructor(
        BasicTokenConfig memory basicTokenConfig,
        TransactionsLimitsConfig memory transactionsLimitsConfig,
        DisableLimitsConfig memory disableLimitsConfig,      
        DEXConfig memory dexConfig,
        address gasGov,
        TaxesConfigBase10000 memory taxesConfigBase10000,
        TaxesConfigReceivers memory taxesConfigReceivers,
        uint8 pcTokensLiq
    ) payable {
        require(msg.value >= 1000, "minimum is 1000 wei");
        require(pcTokensLiq <= 100, "pcTokensLiq can not be bigger than 100");

        address realSupplyReceiver = basicTokenConfig.supplyReceiver;

        //We override supply receiver because this contract has to add the liquidity
        basicTokenConfig.supplyReceiver = address(this);
        HyperBlastAdvancedToken00 _contract = new HyperBlastAdvancedToken00(
            basicTokenConfig,
            transactionsLimitsConfig,
            disableLimitsConfig,
            dexConfig,
            gasGov,
            taxesConfigBase10000,
            taxesConfigReceivers
        );
        sonContract = address(_contract);

        uint256 adrBalance = _contract.balanceOf(address(this));
        uint256 liquidityAmount = adrBalance * pcTokensLiq / 100;

        if(pcTokensLiq < 100) {
            //We send to deployer the rest of tokens
            _contract.transfer(realSupplyReceiver, adrBalance - liquidityAmount);
        }   

        _contract.approve(dexConfig.router, type(uint256).max);
        (bool success,) = dexConfig.router.call{gas : gasleft(), value: msg.value}(
            // addLiquidityETH(address,uint256,uint256,uint256,address,uint256)
            abi.encodeWithSelector(
                0xf305d719,
                address(_contract),
                liquidityAmount,
                0,
                0,
                realSupplyReceiver,
                block.timestamp
            )
        );   

        //We send the ownership
        //_contract.transferOwnership(realSupplyReceiver);

        require(success, "ADD_LIQUIDITY_ETH_FAILED");
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { BasicTokenConfig, TransactionsLimitsConfig, DisableLimitOption, DisableLimitsConfig, DEXConfig } from "../Helpers/Token01Entities.sol";
import { HyperBlastStandardToken01 } from "../Standard/HyperBlastStandardToken01.sol";

/**
 * @title HyperBlast Basic Token 01 real fair launch 
 * @author HyperBlastTeam
 * @notice Customizable basic token contract
 * 1. No owner
 * 2. No tax
 * 3. Max wallet and max tx, (optional: for some amount of swaps, certain timestamp or blocks)
 * 4. Liquidity on deployment
 * @dev We call this 'real fair launch' because an unknown contract is so hard to snipe
 */
contract HyperBlastStandardToken01RFLDeployer {
    address public immutable sonContract;

    constructor(
        BasicTokenConfig memory tokenConfig,
        TransactionsLimitsConfig memory transactionsLimitsConfig,
        DisableLimitsConfig memory disableLimitsConfig,     
        DEXConfig memory dexConfig,   
        address gasGov,
        uint8 pcTokensLiq
    ) payable {
        require(msg.value >= 1000, "minimum is 1000 wei");
        require(pcTokensLiq <= 100, "pcTokensLiq can not be bigger than 100");

        address realSupplyReceiver = tokenConfig.supplyReceiver;

        //We override supply receiver because this contract has to add the liquidity
        tokenConfig.supplyReceiver = address(this);
        HyperBlastStandardToken01 _contract = new HyperBlastStandardToken01(
            tokenConfig,
            transactionsLimitsConfig,
            disableLimitsConfig,
            dexConfig,
            gasGov
        );
        sonContract = address(_contract);

        uint256 adrBalance = _contract.balanceOf(address(this));
        uint256 liquidityAmount = adrBalance * pcTokensLiq / 100;

        if(pcTokensLiq < 100) {
            //We send to deployer the rest of tokens
            _contract.transfer(realSupplyReceiver, adrBalance - liquidityAmount);
        }

        _contract.approve(dexConfig.router, type(uint256).max);
        (bool success,) = dexConfig.router.call{gas : gasleft(), value: msg.value}(
            // addLiquidityETH(address,uint256,uint256,uint256,address,uint256)
            abi.encodeWithSelector(
                0xf305d719,
                address(_contract),
                liquidityAmount,
                0,
                0,
                realSupplyReceiver,
                block.timestamp
            )
        );

        //We send the ownership
        //_contract.transferOwnership(realSupplyReceiver);

        require(success, "ADD_LIQUIDITY_ETH_FAILED");
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { BlastGasRefunder } from "../../../Blast/BlastGasRefunder.sol";
import { BasicTokenConfig } from "../Helpers/Token00Entities.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title HyperBlast Basic Token 00 
 * @author HyperBlastTeam
 * @notice Customizable basic token contract
 * 1. No owner functions
 * 2. No tax
 * 3. No limits
 */
contract HyperBlastStandardToken00 is Context, ERC20, Ownable, BlastGasRefunder {

    uint8 internal immutable _decimals;

    constructor(
        BasicTokenConfig memory tokenConfig,
        address gasGov
    ) ERC20(
        tokenConfig.name, 
        tokenConfig.symbol
    ) {
        _mint(tokenConfig.supplyReceiver, tokenConfig.initialSupply * (10 ** tokenConfig.tokenDecimals));        
        _decimals = tokenConfig.tokenDecimals;        
        setBlastOwnerInt(gasGov);
        _transferOwnership(gasGov);
    }

    function decimals() public view override returns(uint8) {
        return _decimals;
    }

    receive() external payable {}
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { BasicTokenConfig, TransactionsLimitsConfig, DisableLimitOption, DisableLimitsConfig, DEXConfig } from "../Helpers/Token01Entities.sol";
import { HyperBlastStandardToken00 } from "./HyperBlastStandardToken00.sol";
import { IHyperBlastV2Router02 } from "../../../UniV2Fork/Interfaces/IHyperBlastV2Router02.sol";
import { IHyperBlastV2Factory } from "../../../UniV2Fork/Interfaces/IHyperBlastV2Factory.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";

/**
 * @title HyperBlast Basic Token 01
 * @author HyperBlastTeam
 * @notice Customizable basic token contract
 * 1. No owner functions
 * 2. No tax
 * 3. Max wallet and max tx, (optional: for some amount of swaps, certain timestamp or blocks)
 */
contract HyperBlastStandardToken01 is HyperBlastStandardToken00 {
    
    //#region Vars
 
    /**
     * @dev Limits does not apply until the contract finish initialization
     */
    bool internal _initialized;    

    /**
     * @dev Limits are not applied to supply received because he has to add liquidity
     */
    address public _supplyReceiver;

    /**
     * @dev Liquidity pairs are exempted from wallet limit
     */
    mapping(address => bool) public _liqPairs;

    /**
     * @dev 
     * if option nSwaps -> Current number of swaps
     * if option nBlocks -> Launch block
     * if option untilTimestap -> N/A
     */
    uint256 public _disableLimitVar;
    /**
     * @dev Limits token config
     */
    DisableLimitsConfig public _disableLimitsConfig;

    /**
     * @dev Max tx amount in tokens
     */
    uint256 public _maxTx; 
    /**
     * @dev Max wallet amount in tokens
     */
    uint256 public _maxWallet;    

    //#endregion

    constructor(
        BasicTokenConfig memory tokenConfig,
        TransactionsLimitsConfig memory transactionsLimitsConfig,
        DisableLimitsConfig memory disableLimitsConfig,
        DEXConfig memory dexConfig,
        address gasGov
    ) HyperBlastStandardToken00(tokenConfig, gasGov) {      
        _supplyReceiver = tokenConfig.supplyReceiver;

        _maxTx = totalSupply() * transactionsLimitsConfig.maxTxPc / 100;
        _maxWallet = totalSupply() * transactionsLimitsConfig.maxWalletPc / 100;

        _disableLimitsConfig = disableLimitsConfig;
        if(disableLimitsConfig.disableLimitOption == DisableLimitOption.nBlocks) {
            _disableLimitVar = block.number;
        }

        address _liqPair = IHyperBlastV2Factory(IHyperBlastV2Router02(dexConfig.router).factory()).createPair(address(this), dexConfig.tokenLiq);
        _liqPairs[_liqPair] = true;

        _initialized = true;
    }

    //#region Admin    

    /**
     * This function is required to ensure all liq pairs: are exempt from limits
     * @param _adr pair address
     * @param _isLiqPair  liq pair
     */
    function setLiqPair(address _adr, bool _isLiqPair) external onlyOwner {
        require(Address.isContract(_adr), "Only liquidity pairs...");
        _liqPairs[_adr] = _isLiqPair;
    }

    /**
     * This function can be used to create liquidity pairs in others uniswapv2 forks
     * @param _adr address from uniswapv2 fork router
     * @param _adrLiq address of the token you want to use as liq pair
     */
    function createLiqPair(address _adr, address _adrLiq) external onlyOwner {
        address _liqPair = IHyperBlastV2Factory(IHyperBlastV2Router02(_adr).factory()).createPair(address(this), _adrLiq);
        _liqPairs[_liqPair] = true;
    }

    //endregion

    //#region Limits checks

    /**
     * @dev Basic behaviour when
     * 1. Contract is not initialized 
     * 2. Sender/Receiver is the supply receiver, he has to manage the whole supply, add liquidity... etc
     * 3. Sender/Receiver is the own contract, internal readjustments, tax swapbacks and buybacks in childs if exists... etc
     * Can be overriden
     */
    function onlyBasicTransfer(address from, address to) internal virtual view returns (bool) {
        return 
            !_initialized || 
            from == _supplyReceiver || 
            to == _supplyReceiver || 
            from == address(this) || 
            to == address(this) ||
            to == owner() ||
            from == owner(); 
    }

    function limitsEnabled() internal view returns (bool) {
        DisableLimitOption __disableLimitOption = _disableLimitsConfig.disableLimitOption;
        if(__disableLimitOption == DisableLimitOption.none) {
            return false;
        }

        uint256 __disableLimitBound = _disableLimitsConfig.disableLimitBound;        
        if(__disableLimitOption == DisableLimitOption.nSwaps) {
            return _disableLimitVar < __disableLimitBound;
        }
        if(__disableLimitOption == DisableLimitOption.untilTimestap) {
            return block.timestamp < __disableLimitBound;
        }
        if(__disableLimitOption == DisableLimitOption.nBlocks) {
            return block.number < (_disableLimitVar + __disableLimitBound);
        }
        
        return false;
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
        if(onlyBasicTransfer(from, to)) return;

        //Are limits still enabled?
        bool _limitsEnabled = limitsEnabled();

        //Check limits
        if(_limitsEnabled && _maxTx > 0) {
            require(amount <= _maxTx, "You can not exceed max transaction");
        }
        if(_limitsEnabled && _maxWallet > 0 && !_liqPairs[to]) {
            require((balanceOf(to) + amount) <= _maxWallet, "Receiver can not exceed max wallet");
        }   

        //To extend
        _beforeTokenTransfer2(from, to, amount);
    }    

    function _afterTokenTransfer(address from, address to, uint256 amount) internal override {
        if(onlyBasicTransfer(from, to)) return;

        //After swap
        if(_disableLimitsConfig.disableLimitOption == DisableLimitOption.nSwaps) {
            _disableLimitVar++;
        }

        //To extend
        _afterTokenTransfer2(from, to, amount);
    }

    /*solhint-disable no-empty-blocks*/

    function _beforeTokenTransfer2(address from, address to, uint256 amount) internal virtual { }

    function _afterTokenTransfer2(address from, address to, uint256 amount) internal virtual { }

    //#endregion
}

/* solhint-disable */
interface IHyperBlastV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

/* solhint-disable */
interface IHyperBlastV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

/* solhint-disable */
import { IHyperBlastV2Router01 } from "./IHyperBlastV2Router01.sol";

interface IHyperBlastV2Router02 is IHyperBlastV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        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 swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):