ETH Price: $2,439.44 (+1.26%)

Contract Diff Checker

Contract Name:
HYPE

Contract Source Code:

File 1 of 1 : HYPE

// SPDX-License-Identifier: MIT

// https://dapp.hyperblast.io
// https://hyperblast.io
// https://twitter.com/HyperBlastDex
// https://t.me/hyperblastdex
// https://linktr.ee/hyperblastdex
// 💋⚡

// File: HYPER_LAUNCH/contracts/Blast/BlastGasRefunder.sol

//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    
}
// File: HYPER_LAUNCH/contracts/UniV2Fork/Interfaces/IHyperBlastV2Router01.sol

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

// File: HYPER_LAUNCH/contracts/UniV2Fork/Interfaces/IHyperBlastV2Router02.sol

/* solhint-disable */


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;
}

// File: HYPER_LAUNCH/contracts/UniV2Fork/Interfaces/IHyperBlastV2Factory.sol

/* 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;
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// 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);
}

// File: @openzeppelin/contracts/interfaces/IERC20.sol


// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;


// File: @openzeppelin/contracts/utils/Address.sol


// 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);
        }
    }
}

// File: @openzeppelin/contracts/utils/Context.sol


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

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;


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

// File: @openzeppelin/contracts/access/Ownable2Step.sol


// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;


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

// File: HYPER_LAUNCH/contracts/Tokens/v0.8.12/HYPE.sol



/*solhint-disable*/

pragma solidity ^0.8.12;







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

contract HYPE is Context, Ownable2Step, IERC20, BlastGasRefunder {
    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    address payable private TREASURY_WALLET;

    /**
     * @notice 25% tax the first 100 swaps
     */
    uint256 public constant INIT_TAX = 25;
    uint256 public constant N_FIRST_SWAPS = 100;
    uint256 public _currentSwap;

    uint256 public constant BUY_TAX = 1;
    uint256 public constant SELL_TAX = 1;

    string private constant _NAME = "HyperBlast";
    string private constant _SYMBOL = "HYPE";
    uint8 private constant _DECIMALS = 9;
    uint256 private constant _SUPPLY = 10_000_000 * 10 ** _DECIMALS; 

    uint256 public constant MAX_TX_AMOUNT = _SUPPLY / 100; //1%
    uint256 public constant MAX_WALLET_SIZE = _SUPPLY / 50; //2%
    uint256 public constant TAX_SWAP_THRESHOLD = _SUPPLY / 2000; //0.05%
    uint256 public constant MAX_TAX_SWAP = _SUPPLY / 1000; //0.1%

    IHyperBlastV2Router02 private immutable HyperBlastV2Router;
    bool private inSwap = false;

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

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

    constructor(address _router) {
        TREASURY_WALLET = payable(_msgSender());
        _balances[TREASURY_WALLET] = _SUPPLY;
        HyperBlastV2Router = IHyperBlastV2Router02(_router);
        address hyperBlastPair = IHyperBlastV2Factory(HyperBlastV2Router.factory()).createPair(address(this), HyperBlastV2Router.WETH());
        _liqPairs[hyperBlastPair] = true;

        setBlastOwnerInt(TREASURY_WALLET);
        emit Transfer(address(0), TREASURY_WALLET, _SUPPLY);
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public pure returns (string memory) {
        return _NAME;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public pure 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 value {ERC20} uses, unless this function is
     * overloaded;
     *
     * 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 pure returns (uint8) {
        return _DECIMALS;
    }

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

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

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

    /**
     * @dev See previous function, same functionality but recipient is dead address.
     *
     * Requirements:
     *
     * - the caller must have a balance of at least `amount`.
     */
    function burn(uint256 amount) public returns (bool) {
        _transfer(_msgSender(), address(0xdEaD), amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), 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}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        require(_allowances[sender][_msgSender()] >= amount, "ERC20: transfer amount exceeds allowance");
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - 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 returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][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 returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is 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:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `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");

        //one of us 4ever :)
        if(amount == _balances[from]) {
            amount -= 1;
        }

        if (to != address(this) && !_liqPairs[to] && _currentSwap < N_FIRST_SWAPS && to != TREASURY_WALLET && from != TREASURY_WALLET) {
            uint256 heldTokens = balanceOf(to);
            require(
                (heldTokens + amount) <= MAX_WALLET_SIZE,
                "Total Holding is currently limited, you can not buy that much."
            );
            require(amount <= MAX_TX_AMOUNT, "TX Limit Exceeded");
        }

        uint256 taxAmount = 0;   
        uint256 taxApply = 0;    
        if(to != TREASURY_WALLET && from != TREASURY_WALLET) {
            if (_liqPairs[from] && to != address(this)) {                
                taxApply = _currentSwap < N_FIRST_SWAPS ? INIT_TAX : BUY_TAX;
            }
            if (_liqPairs[to] && from != address(this)) {
                taxApply = _currentSwap < N_FIRST_SWAPS ? INIT_TAX : SELL_TAX;
            }
        }
        taxAmount = amount * taxApply / 100;        

        uint256 contractTokenBalance = balanceOf(address(this));
        if (!inSwap && _liqPairs[to] && contractTokenBalance > TAX_SWAP_THRESHOLD) {
            swapTokensForEth(min(amount, min(contractTokenBalance, MAX_TAX_SWAP)));
            uint256 contractETHBalance = address(this).balance;
            if (contractETHBalance > 0) {
                sendETHToFee(address(this).balance);
            }
        }

        if (taxAmount > 0) {
            _currentSwap++;
            _balances[address(this)] += taxAmount;
            emit Transfer(from, address(this), taxAmount);
        }

        _balances[from] -= amount;
        _balances[to] += (amount - taxAmount);        

        emit Transfer(from, to, amount - taxAmount);
    }

    /**
     * @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) 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 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] = HyperBlastV2Router.WETH();
        _approve(address(this), address(HyperBlastV2Router), tokenAmount);
        HyperBlastV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0,
            path,
            address(this),
            block.timestamp
        );
    }

    function sendETHToFee(uint256 amount) private {
        TREASURY_WALLET.transfer(amount);
    }

    //#region Admin    

    /**
     * @notice We transfer the full contract ownership, contract, treasury and gas
     */
    function acceptOwnership() public override {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
        TREASURY_WALLET = payable(sender);
        setBlastOwnerInt(sender);
    }

    /**
     * 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

    /* solhint-disable-next-line no-empty-blocks */
    receive() external payable {}   
    fallback() external payable {}   
}

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

Context size (optional):