Contract 0x41c1995fedb7fb04fabfeed3be45ac66f0903811

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xf50411395b33dbbaaaeae0e1941f11306fa39f1d4a77ecc0091e44f3bbf0b033Transfer Ownersh...33351322021-11-25 21:19:002 days 5 hrs ago0xe3c601b1fc6564ebf5603fcad7956697761e39db IN  0x41c1995fedb7fb04fabfeed3be45ac66f09038110 ETH0.000805492248 ETH
0xda6b779158bff975a16321f2e3adc408378c5517fb9ae1dd9e350fd2eb2997310x60a0604033350722021-11-25 21:15:182 days 5 hrs ago0xe3c601b1fc6564ebf5603fcad7956697761e39db IN  Contract Creation0 ETH0.192262354064 ETH
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HyperLiquidriumFactory

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at arbiscan.io on 2021-11-25
*/

// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.7.6;

pragma solidity >=0.5.0;

/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
    /// @notice Emitted when the owner of the factory is changed
    /// @param oldOwner The owner before the owner was changed
    /// @param newOwner The owner after the owner was changed
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param pool The address of the created pool
    event PoolCreated(
        address indexed token0,
        address indexed token1,
        uint24 indexed fee,
        int24 tickSpacing,
        address pool
    );

    /// @notice Emitted when a new fee amount is enabled for pool creation via the factory
    /// @param fee The enabled fee, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
    event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);

    /// @notice Returns the current owner of the factory
    /// @dev Can be changed by the current owner via setOwner
    /// @return The address of the factory owner
    function owner() external view returns (address);

    /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
    /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
    /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
    /// @return The tick spacing
    function feeAmountTickSpacing(uint24 fee) external view returns (int24);

    /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @return pool The pool address
    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param fee The desired fee for the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
    /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
    /// are invalid.
    /// @return pool The address of the newly created pool
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);

    /// @notice Updates the owner of the factory
    /// @dev Must be called by the current owner
    /// @param _owner The new owner of the factory
    function setOwner(address _owner) external;

    /// @notice Enables a fee amount with the given tickSpacing
    /// @dev Fee amounts may never be removed once enabled
    /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
    function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}


pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}


/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}



pragma solidity 0.7.6;

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMath {
    int256 constant private _INT256_MIN = -2**255;

    /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

        int256 c = a * b;
        require(c / a == b, "SignedSafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two signed integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "SignedSafeMath: division by zero");
        require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");

        int256 c = a / b;

        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");

        return c;
    }
}

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

pragma solidity >=0.6.0 <0.8.0;

/**
 * @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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of 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 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 {_setupDecimals} is
     * called.
     *
     * 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 returns (uint8) {
        return _decimals;
    }

    /**
     * @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:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, 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}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual 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 virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        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 sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, 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:
     *
     * - `to` 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 = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(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);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(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 Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

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

pragma solidity >=0.6.2 <0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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://diligence.consensys.net/posts/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.5.11/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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}



pragma solidity >=0.6.0 <0.8.0;

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#mint
/// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface
interface IUniswapV3MintCallback {
    /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
    /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
    /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
    function uniswapV3MintCallback(
        uint256 amount0Owed,
        uint256 amount1Owed,
        bytes calldata data
    ) external;
}

pragma solidity >=0.5.0;

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= uint256(MAX_TICK), 'T');

        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;

        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        // second inequality must be < because the price can never reach the price at the max tick
        require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');
        uint256 ratio = uint256(sqrtPriceX96) << 32;

        uint256 r = ratio;
        uint256 msb = 0;

        assembly {
            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(5, gt(r, 0xFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(4, gt(r, 0xFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(3, gt(r, 0xFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(2, gt(r, 0xF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(1, gt(r, 0x3))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := gt(r, 0x1)
            msb := or(msb, f)
        }

        if (msb >= 128) r = ratio >> (msb - 127);
        else r = ratio << (127 - msb);

        int256 log_2 = (int256(msb) - 128) << 64;

        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(63, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(62, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(61, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(60, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(59, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(58, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(57, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(56, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(55, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(54, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(53, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(52, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(51, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(50, f))
        }

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

        int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
        int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

        tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
    }
}

pragma solidity >=0.4.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        // 512-bit multiply [prod1 prod0] = a * b
        // Compute the product mod 2**256 and mod 2**256 - 1
        // then use the Chinese Remainder Theorem to reconstruct
        // the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2**256 + prod0
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(a, b, not(0))
            prod0 := mul(a, b)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

        // Handle non-overflow cases, 256 by 256 division
        if (prod1 == 0) {
            require(denominator > 0);
            assembly {
                result := div(prod0, denominator)
            }
            return result;
        }

        // Make sure the result is less than 2**256.
        // Also prevents denominator == 0
        require(denominator > prod1);

        ///////////////////////////////////////////////
        // 512 by 256 division.
        ///////////////////////////////////////////////

        // Make division exact by subtracting the remainder from [prod1 prod0]
        // Compute remainder using mulmod
        uint256 remainder;
        assembly {
            remainder := mulmod(a, b, denominator)
        }
        // Subtract 256 bit number from 512 bit number
        assembly {
            prod1 := sub(prod1, gt(remainder, prod0))
            prod0 := sub(prod0, remainder)
        }

        // Factor powers of two out of denominator
        // Compute largest power of two divisor of denominator.
        // Always >= 1.
        uint256 twos = -denominator & denominator;
        // Divide denominator by power of two
        assembly {
            denominator := div(denominator, twos)
        }

        // Divide [prod1 prod0] by the factors of two
        assembly {
            prod0 := div(prod0, twos)
        }
        // Shift in bits from prod1 into prod0. For this we need
        // to flip `twos` such that it is 2**256 / twos.
        // If twos is zero, then it becomes one
        assembly {
            twos := add(div(sub(0, twos), twos), 1)
        }
        prod0 |= prod1 * twos;

        // Invert denominator mod 2**256
        // Now that denominator is an odd number, it has an inverse
        // modulo 2**256 such that denominator * inv = 1 mod 2**256.
        // Compute the inverse by starting with a seed that is correct
        // correct for four bits. That is, denominator * inv = 1 mod 2**4
        uint256 inv = (3 * denominator) ^ 2;
        // Now use Newton-Raphson iteration to improve the precision.
        // Thanks to Hensel's lifting lemma, this also works in modular
        // arithmetic, doubling the correct bits in each step.
        inv *= 2 - denominator * inv; // inverse mod 2**8
        inv *= 2 - denominator * inv; // inverse mod 2**16
        inv *= 2 - denominator * inv; // inverse mod 2**32
        inv *= 2 - denominator * inv; // inverse mod 2**64
        inv *= 2 - denominator * inv; // inverse mod 2**128
        inv *= 2 - denominator * inv; // inverse mod 2**256

        // Because the division is now exact we can divide by multiplying
        // with the modular inverse of denominator. This will give us the
        // correct result modulo 2**256. Since the precoditions guarantee
        // that the outcome is less than 2**256, this is the final result.
        // We don't need to compute the high bits of the result and prod1
        // is no longer required.
        result = prod0 * inv;
        return result;
    }

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = mulDiv(a, b, denominator);
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }
}
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

pragma solidity >=0.5.0;

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return _liquidity The amount of liquidity in the position,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

pragma solidity >=0.5.0;

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolEvents
{

}

pragma solidity >=0.4.0;

/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
    uint8 internal constant RESOLUTION = 96;
    uint256 internal constant Q96 = 0x1000000000000000000000000;
}

pragma solidity >=0.5.0;

/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
    /// @notice Downcasts uint256 to uint128
    /// @param x The uint258 to be downcasted
    /// @return y The passed value, downcasted to uint128
    function toUint128(uint256 x) private pure returns (uint128 y) {
        require((y = uint128(x)) == x);
    }

    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range
    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount0 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount0(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
        return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
    }

    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range
    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount1 The amount1 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount1(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
    }

    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount of token0 being sent in
    /// @param amount1 The amount of token1 being sent in
    /// @return liquidity The maximum amount of liquidity received
    function getLiquidityForAmounts(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
            uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);

            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
        } else {
            liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
        }
    }

    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    function getAmount0ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return
            FullMath.mulDiv(
                uint256(liquidity) << FixedPoint96.RESOLUTION,
                sqrtRatioBX96 - sqrtRatioAX96,
                sqrtRatioBX96
            ) / sqrtRatioAX96;
    }

    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount1 The amount of token1
    function getAmount1ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
    }

    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function getAmountsForLiquidity(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0, uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
        } else {
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        }
    }
}



pragma solidity 0.7.6;

interface IVault {
    function deposit(
        uint256,
        uint256,
        address
    ) external returns (uint256);

    function withdraw(
        uint256,
        address,
        address
    ) external returns (uint256, uint256);

    function rebalance(
        int24 _baseLower,
        int24 _baseUpper,
        int24 _limitLower,
        int24 _limitUpper,
        address feeRecipient,
        int256 swapQuantity
    ) external;

    function getTotalAmounts() external view returns (uint256, uint256);

    event Deposit(
        address indexed sender,
        address indexed to,
        uint256 shares,
        uint256 amount0,
        uint256 amount1
    );

    event Withdraw(
        address indexed sender,
        address indexed to,
        uint256 shares,
        uint256 amount0,
        uint256 amount1
    );

    event Rebalance(
        int24 tick,
        uint256 totalAmount0,
        uint256 totalAmount1,
        uint256 feeAmount0,
        uint256 feeAmount1,
        uint256 totalSupply
    );
}

pragma solidity 0.7.6;
pragma abicoder v2;

interface IUniversalVault {
    /* user events */

    event Locked(address delegate, address token, uint256 amount);
    event Unlocked(address delegate, address token, uint256 amount);
    event RageQuit(address delegate, address token, bool notified, string reason);

    /* data types */

    struct LockData {
        address delegate;
        address token;
        uint256 balance;
    }

    /* initialize function */

    function initialize() external;

    /* user functions */

    function lock(
        address token,
        uint256 amount,
        bytes calldata permission
    ) external;

    function unlock(
        address token,
        uint256 amount,
        bytes calldata permission
    ) external;

    function rageQuit(address delegate, address token)
        external
        returns (bool notified, string memory error);

    function transferERC20(
        address token,
        address to,
        uint256 amount
    ) external;

    function transferETH(address to, uint256 amount) external payable;

    /* pure functions */

    function calculateLockID(address delegate, address token)
        external
        pure
        returns (bytes32 lockID);

    /* getter functions */

    function getPermissionHash(
        bytes32 eip712TypeHash,
        address delegate,
        address token,
        uint256 amount,
        uint256 nonce
    ) external view returns (bytes32 permissionHash);

    function getNonce() external view returns (uint256 nonce);

    function owner() external view returns (address ownerAddress);

    function getLockSetCount() external view returns (uint256 count);

    function getLockAt(uint256 index) external view returns (LockData memory lockData);

    function getBalanceDelegated(address token, address delegate)
        external
        view
        returns (uint256 balance);

    function getBalanceLocked(address token) external view returns (uint256 balance);

    function checkBalances() external view returns (bool validity);
}


/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

// @title HyperLiquidrium
// @notice A Uniswap V2-like interface with fungible liquidity to Uniswap V3
// which allows for arbitrary liquidity provision: one-sided, lop-sided, and
// balanced.
contract HyperLiquidrium is IVault, IUniswapV3MintCallback, IUniswapV3SwapCallback, ERC20, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;
    using SignedSafeMath for int256;

    address public owner;

    IUniswapV3Pool public pool;
    IERC20 public immutable token0;
    IERC20 public immutable token1;
    uint24 public immutable fee;
    int24 public immutable tickSpacing;

    int24 public baseLower;
    int24 public baseUpper;
    int24 public limitLower;
    int24 public limitUpper;

    // The following three variables server the very important purpose of
    // limiting inventory risk and the arbitrage opportunities made possible by
    // our instant deposit & withdrawal.
    // If, in the ETHUSDT pool at an ETH price of 2500 USDT, I deposit 100k
    // USDT in a pool with 40 WETH, and then directly afterwards withdraw 50k
    // USDT and 20 WETH (this is of equivalent dollar value), I drastically
    // change the pool composition and additionally decreases deployed capital
    // by 50%. Keeping a maxTotalSupply just above our current total supply
    // means that large amounts of funds can't be deposited all at once to
    // create a large imbalance of funds or to sideline many funds.
    // Additionally, deposit maximums prevent users from using the pool as
    // a counterparty to trade assets against while avoiding uniswap fees
    // & slippage--if someone were to try to do this with a large amount of
    // capital they would be overwhelmed by the gas fees necessary to call
    // deposit & withdrawal many times.
    uint256 public deposit0Max;
    uint256 public deposit1Max;
    uint256 public maxTotalSupply;

    uint256 constant public PRECISION = 1e36;


    event NewMaxSupply(uint256 newSupply);
    event TokensDepositMax(uint256 token0Max, uint256 token1Max);


    // @param _pool Uniswap V3 pool for which liquidity is managed
    // @param _owner Owner of the HyperLiquidrium
    constructor(
        address _pool,
        address _owner
    ) ERC20("Fungible Liquidity", "LIQ") {
        pool = IUniswapV3Pool(_pool);
        token0 = IERC20(pool.token0());
        token1 = IERC20(pool.token1());
        fee = pool.fee();
        tickSpacing = pool.tickSpacing();

        owner = _owner;

        maxTotalSupply = 0; // no cap
        deposit0Max = uint256(-1); // max uint256
        deposit1Max = uint256(-1); // max uint256
    }

    // @notice Distributes shares to depositor equal to the token1 value of his
    // deposit multiplied by the ratio of total liquidity shares issued divided
    // by the pool's AUM measured in token1 value.
    // @param deposit0 Amount of token0 transfered from sender to HyperLiquidrium
    // @param deposit1 Amount of token0 transfered from sender to HyperLiquidrium
    // @param to Address to which liquidity tokens are minted
    // @return shares Quantity of liquidity tokens minted as a result of deposit
    function deposit(
        uint256 deposit0,
        uint256 deposit1,
        address to
    ) external nonReentrant override returns (uint256 shares) {
        require(deposit0 > 0 || deposit1 > 0, "deposits must be nonzero");
        require(deposit0 < deposit0Max && deposit1 < deposit1Max, "deposits must be less than maximum amounts");
        require(to != address(0) && to != address(this), "to");

        // update fees for inclusion in total pool amounts
        (uint128 baseLiquidity,,) = _position(baseLower, baseUpper);
        if (baseLiquidity > 0) {
            pool.burn(baseLower, baseUpper, 0);
        }
        (uint128 limitLiquidity,,)  = _position(limitLower, limitUpper);
        if (limitLiquidity > 0) {
            pool.burn(limitLower, limitUpper, 0);
        }

        uint160 sqrtPrice = TickMath.getSqrtRatioAtTick(currentTick());
        uint256 price = FullMath.mulDiv(uint256(sqrtPrice).mul(uint256(sqrtPrice)), PRECISION, 2**(96 * 2));

        (uint256 pool0, uint256 pool1) = getTotalAmounts();

        uint256 deposit0PricedInToken1 = deposit0.mul(price).div(PRECISION);
        shares = deposit1.add(deposit0PricedInToken1);

        if (deposit0 > 0) {
          token0.safeTransferFrom(msg.sender, address(this), deposit0);
        }
        if (deposit1 > 0) {
          token1.safeTransferFrom(msg.sender, address(this), deposit1);
        }

        if (totalSupply() != 0) {
          uint256 pool0PricedInToken1 = pool0.mul(price).div(PRECISION);
          shares = shares.mul(totalSupply()).div(pool0PricedInToken1.add(pool1));
        }
        _mint(to, shares);
        emit Deposit(msg.sender, to, shares, deposit0, deposit1);
        // Check total supply cap not exceeded. A value of 0 means no limit.
        require(maxTotalSupply == 0 || totalSupply() <= maxTotalSupply, "maxTotalSupply");
    }

    // @notice Redeems shares by sending out a percentage of the HyperLiquidrium's
    // AUM--this percentage is equal to the percentage of total issued shares
    // represented by the redeeemed shares.
    // @param shares Number of liquidity tokens to redeem as pool assets
    // @param to Address to which redeemed pool assets are sent
    // @param from Address from which liquidity tokens are sent
    // @return amount0 Amount of token0 redeemed by the submitted liquidity tokens
    // @return amount1 Amount of token1 redeemed by the submitted liquidity tokens
    function withdraw(
        uint256 shares,
        address to,
        address from
    ) external nonReentrant override returns (uint256 amount0, uint256 amount1) {
        require(shares > 0, "shares");
        require(to != address(0), "to");
        require(from == msg.sender || IUniversalVault(from).owner() == msg.sender, "Sender must own the tokens");

        // Withdraw liquidity from Uniswap pool
        (uint256 base0, uint256 base1) =
            _burnLiquidity(baseLower, baseUpper, _liquidityForShares(baseLower, baseUpper, shares), to, false);
        (uint256 limit0, uint256 limit1) =
            _burnLiquidity(limitLower, limitUpper, _liquidityForShares(limitLower, limitUpper, shares), to, false);

        // Push tokens proportional to unused balances
        uint256 totalSupply = totalSupply();
        uint256 unusedAmount0 = token0.balanceOf(address(this)).mul(shares).div(totalSupply);
        uint256 unusedAmount1 = token1.balanceOf(address(this)).mul(shares).div(totalSupply);
        if (unusedAmount0 > 0) token0.safeTransfer(to, unusedAmount0);
        if (unusedAmount1 > 0) token1.safeTransfer(to, unusedAmount1);

        amount0 = base0.add(limit0).add(unusedAmount0);
        amount1 = base1.add(limit1).add(unusedAmount1);

        _burn(from, shares);

        emit Withdraw(from, to, shares, amount0, amount1);
    }

    // @notice Updates HyperLiquidrium's LP positions.
    // @dev The base position is placed first with as much liquidity as
    // possible and is typically symmetric around the current price. This order
    // should use up all of one token, leaving some unused quantity of the
    // other. This unused amount is then placed as a single-sided order.
    // @param _baseLower The lower tick of the base position
    // @param _baseUpper The upper tick of the base position
    // @param _limitLower The lower tick of the limit position
    // @param _limitUpper The upper tick of the limit position
    // @param feeRecipient Address of recipient of 10% of earned fees since last rebalance
    // @param swapQuantity Quantity of tokens to swap; if quantity is positive,
    // `swapQuantity` token0 are swaped for token1, if negative, `swapQuantity`
    // token1 is swaped for token0
    function rebalance(
        int24 _baseLower,
        int24 _baseUpper,
        int24 _limitLower,
        int24 _limitUpper,
        address feeRecipient,
        int256 swapQuantity
    ) external nonReentrant override onlyOwner {
        require(_baseLower < _baseUpper && _baseLower % tickSpacing == 0 && _baseUpper % tickSpacing == 0,
                "base position invalid");
        require(_limitLower < _limitUpper && _limitLower % tickSpacing == 0 && _limitUpper % tickSpacing == 0,
                "limit position invalid");

        // update fees
        (uint128 baseLiquidity,,) = _position(baseLower, baseUpper);
        if (baseLiquidity > 0) {
            pool.burn(baseLower, baseUpper, 0);
        }
        (uint128 limitLiquidity,,)  = _position(limitLower, limitUpper);
        if (limitLiquidity > 0) {
            pool.burn(limitLower, limitUpper, 0);
        }

        // Withdraw all liquidity and collect all fees from Uniswap pool
        (, uint256 feesLimit0, uint256 feesLimit1) = _position(baseLower, baseUpper);
        (, uint256 feesBase0, uint256 feesBase1)  = _position(limitLower, limitUpper);

        uint256 fees0 = feesBase0.add(feesLimit0);
        uint256 fees1 = feesBase1.add(feesLimit1);
        _burnLiquidity(baseLower, baseUpper, baseLiquidity, address(this), true);
        _burnLiquidity(limitLower, limitUpper, limitLiquidity, address(this), true);

        // transfer 15% of fees for Liquidrium buybacks
        if(fees0 > 0) token0.safeTransfer(feeRecipient, fees0.mul(3).div(20)); 
        if(fees1 > 0) token1.safeTransfer(feeRecipient, fees1.mul(3).div(20));

        emit Rebalance(
            currentTick(),
            token0.balanceOf(address(this)),
            token1.balanceOf(address(this)),
            fees0,
            fees1,
            totalSupply()
        );

        // swap tokens if required
        if (swapQuantity != 0) {
            pool.swap(
                address(this),
                swapQuantity > 0,
                swapQuantity > 0 ? swapQuantity : -swapQuantity,
                swapQuantity > 0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1,
                abi.encode(address(this))
            );
        }

        baseLower = _baseLower;
        baseUpper = _baseUpper;
        baseLiquidity = _liquidityForAmounts(
            baseLower,
            baseUpper,
            token0.balanceOf(address(this)),
            token1.balanceOf(address(this))
        );
        _mintLiquidity(baseLower, baseUpper, baseLiquidity, address(this));

        limitLower = _limitLower;
        limitUpper = _limitUpper;
        limitLiquidity = _liquidityForAmounts(
            limitLower,
            limitUpper,
            token0.balanceOf(address(this)),
            token1.balanceOf(address(this))
        );
        _mintLiquidity(limitLower, limitUpper, limitLiquidity, address(this));
    }

    function _mintLiquidity(
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity,
        address payer
    ) internal returns (uint256 amount0, uint256 amount1) {
      if (liquidity > 0) {
            (amount0, amount1) = pool.mint(
                address(this),
                tickLower,
                tickUpper,
                liquidity,
                abi.encode(payer)
            );
        }
    }

    function _burnLiquidity(
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity,
        address to,
        bool collectAll
    ) internal returns (uint256 amount0, uint256 amount1) {
        if (liquidity > 0) {
            // Burn liquidity
            (uint256 owed0, uint256 owed1) = pool.burn(tickLower, tickUpper, liquidity);

            // Collect amount owed
            uint128 collect0 = collectAll ? type(uint128).max : _uint128Safe(owed0);
            uint128 collect1 = collectAll ? type(uint128).max : _uint128Safe(owed1);
            if (collect0 > 0 || collect1 > 0) {
                (amount0, amount1) = pool.collect(to, tickLower, tickUpper, collect0, collect1);
            }
        }
    }

    function _liquidityForShares(
        int24 tickLower,
        int24 tickUpper,
        uint256 shares
    ) internal view returns (uint128) {
        (uint128 position,,) = _position(tickLower, tickUpper);
        return _uint128Safe(uint256(position).mul(shares).div(totalSupply()));
    }

    function _position(int24 tickLower, int24 tickUpper)
        internal
        view
        returns (uint128 liquidity, uint128 tokensOwed0, uint128 tokensOwed1)
    {
        bytes32 positionKey = keccak256(abi.encodePacked(address(this), tickLower, tickUpper));
        (liquidity, , , tokensOwed0, tokensOwed1) = pool.positions(positionKey);
    }

    function uniswapV3MintCallback(
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external override {
        require(msg.sender == address(pool), "not pool");
        address payer = abi.decode(data, (address));

        if (payer == address(this)) {
            if (amount0 > 0) token0.safeTransfer(msg.sender, amount0);
            if (amount1 > 0) token1.safeTransfer(msg.sender, amount1);
        } else {
            if (amount0 > 0) token0.safeTransferFrom(payer, msg.sender, amount0);
            if (amount1 > 0) token1.safeTransferFrom(payer, msg.sender, amount1);
        }
    }

    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external override {
        require(msg.sender == address(pool), "not pool");
        address payer = abi.decode(data, (address));

        if (amount0Delta > 0) {
            if (payer == address(this)) {
                token0.safeTransfer(msg.sender, uint256(amount0Delta));
            } else {
                token0.safeTransferFrom(payer, msg.sender, uint256(amount0Delta));
            }
        } else if (amount1Delta > 0) {
            if (payer == address(this)) {
                token1.safeTransfer(msg.sender, uint256(amount1Delta));
            } else {
                token1.safeTransferFrom(payer, msg.sender, uint256(amount1Delta));
            }
        }
    }

    // @return total0 Quantity of token0 in both positions and unused in the HyperLiquidrium
    // @return total1 Quantity of token1 in both positions and unused in the HyperLiquidrium
    function getTotalAmounts() public view override returns (uint256 total0, uint256 total1) {
        (, uint256 base0, uint256 base1) = getBasePosition();
        (, uint256 limit0, uint256 limit1) = getLimitPosition();
        total0 = token0.balanceOf(address(this)).add(base0).add(limit0);
        total1 = token1.balanceOf(address(this)).add(base1).add(limit1);
    }

    // @return liquidity Amount of total liquidity in the base position
    // @return amount0 Estimated amount of token0 that could be collected by
    // burning the base position
    // @return amount1 Estimated amount of token1 that could be collected by
    // burning the base position
    function getBasePosition()
        public
        view
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        )
    {
        (uint128 positionLiquidity, uint128 tokensOwed0, uint128 tokensOwed1) = _position(baseLower, baseUpper);
        (amount0, amount1) = _amountsForLiquidity(baseLower, baseUpper, positionLiquidity);
        amount0 = amount0.add(uint256(tokensOwed0));
        amount1 = amount1.add(uint256(tokensOwed1));
        liquidity = positionLiquidity;
    }

    // @return liquidity Amount of total liquidity in the limit position
    // @return amount0 Estimated amount of token0 that could be collected by
    // burning the limit position
    // @return amount1 Estimated amount of token1 that could be collected by
    // burning the limit position
    function getLimitPosition()
        public
        view
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        )
    {
        (uint128 positionLiquidity, uint128 tokensOwed0, uint128 tokensOwed1) = _position(limitLower, limitUpper);
        (amount0, amount1) = _amountsForLiquidity(limitLower, limitUpper, positionLiquidity);
        amount0 = amount0.add(uint256(tokensOwed0));
        amount1 = amount1.add(uint256(tokensOwed1));
        liquidity = positionLiquidity;
    }

    function _amountsForLiquidity(
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity
    ) internal view returns (uint256, uint256) {
        (uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
        return
            LiquidityAmounts.getAmountsForLiquidity(
                sqrtRatioX96,
                TickMath.getSqrtRatioAtTick(tickLower),
                TickMath.getSqrtRatioAtTick(tickUpper),
                liquidity
            );
    }

    function _liquidityForAmounts(
        int24 tickLower,
        int24 tickUpper,
        uint256 amount0,
        uint256 amount1
    ) internal view returns (uint128) {
        (uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
        return
            LiquidityAmounts.getLiquidityForAmounts(
                sqrtRatioX96,
                TickMath.getSqrtRatioAtTick(tickLower),
                TickMath.getSqrtRatioAtTick(tickUpper),
                amount0,
                amount1
            );
    }

    // @return tick Uniswap pool's current price tick
    function currentTick() public view returns (int24 tick) {
        (, tick, , , , , ) = pool.slot0();
    }

    function _uint128Safe(uint256 x) internal pure returns (uint128) {
        assert(x <= type(uint128).max);
        return uint128(x);
    }

    // @param _maxTotalSupply The maximum liquidity token supply the contract allows
    function setMaxTotalSupply(uint256 _maxTotalSupply) external onlyOwner {
        maxTotalSupply = _maxTotalSupply;
        emit NewMaxSupply(_maxTotalSupply);
    }

    // @param _deposit0Max The maximum amount of token0 allowed in a deposit
    // @param _deposit1Max The maximum amount of token1 allowed in a deposit
    function setDepositMax(uint256 _deposit0Max, uint256 _deposit1Max) external onlyOwner {
        deposit0Max = _deposit0Max;
        deposit1Max = _deposit1Max;
        emit TokensDepositMax(_deposit0Max, _deposit1Max);
    }

    modifier onlyOwner {
        require(msg.sender == owner, "only owner");
        _;
    }
}



contract HyperLiquidriumFactory is Ownable, ReentrancyGuard  {
    IUniswapV3Factory public immutable uniswapV3Factory;
    mapping(address => mapping(address => mapping(uint24 => address))) public getHyperLiquidrium; // toke0, token1, fee -> hyperliquidrium address
    address[] public allHyperLiquidriums;

    event HyperLiquidriumCreated(address token0, address token1, uint24 fee, address hyperliquidrium, uint256);

    constructor(address _uniswapV3Factory) {
        uniswapV3Factory = IUniswapV3Factory(_uniswapV3Factory);
    }

    function allHyperLiquidriumsLength() external view returns (uint256) {
        return allHyperLiquidriums.length;
    }

    function createHyperLiquidrium(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external nonReentrant onlyOwner returns (address hyperliquidrium) {
        require(tokenA != tokenB, 'SF: IDENTICAL_ADDRESSES'); // TODO: using PoolAddress library (uniswap-v3-periphery)
        (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'SF: ZERO_ADDRESS');
        require(getHyperLiquidrium[token0][token1][fee] == address(0), 'SF: HyperLiquidrium_EXISTS');
        int24 tickSpacing = uniswapV3Factory.feeAmountTickSpacing(fee);
        require(tickSpacing != 0, 'SF: INCORRECT_FEE');
        address pool = uniswapV3Factory.getPool(token0, token1, fee);
        if (pool == address(0)) {
            pool = uniswapV3Factory.createPool(token0, token1, fee);
        }
        hyperliquidrium = address(
            new HyperLiquidrium{salt: keccak256(abi.encodePacked(token0, token1, fee, tickSpacing))}(pool, owner())
        );

        getHyperLiquidrium[token0][token1][fee] = hyperliquidrium;
        getHyperLiquidrium[token1][token0][fee] = hyperliquidrium; // populate mapping in the reverse direction
        allHyperLiquidriums.push(hyperliquidrium);
        emit HyperLiquidriumCreated(token0, token1, fee, hyperliquidrium, allHyperLiquidriums.length);
    }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_uniswapV3Factory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token0","type":"address"},{"indexed":false,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"uint24","name":"fee","type":"uint24"},{"indexed":false,"internalType":"address","name":"hyperliquidrium","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"HyperLiquidriumCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allHyperLiquidriums","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allHyperLiquidriumsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"createHyperLiquidrium","outputs":[{"internalType":"address","name":"hyperliquidrium","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint24","name":"","type":"uint24"}],"name":"getHyperLiquidrium","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV3Factory","outputs":[{"internalType":"contract IUniswapV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b506040516150ce3803806150ce83398101604081905261002f916100a0565b600061003961009c565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001805560601b6001600160601b0319166080526100ce565b3390565b6000602082840312156100b1578081fd5b81516001600160a01b03811681146100c7578182fd5b9392505050565b60805160601c614fd46100fa600039806102d552806103a3528061045a52806106695250614fd46000f3fe60806040523480156200001157600080fd5b5060043610620000825760003560e01c806333cf8cc61462000087578063477ec90414620000b65780635b54918214620000cd578063715018a614620000d75780638da5cb5b14620000e3578063dd686fb614620000ed578063f2fde38b1462000104578063f9784e3b146200011b575b600080fd5b6200009e62000098366004620008d5565b62000134565b604051620000ad919062000933565b60405180910390f35b6200009e620000c73660046200085b565b6200015f565b6200009e62000667565b620000e16200068b565b005b6200009e6200070a565b6200009e620000fe3660046200085b565b62000719565b620000e16200011536600462000816565b62000745565b62000125620007fe565b604051620000ad919062000b3d565b600381815481106200014557600080fd5b6000918252602090912001546001600160a01b0316905081565b600060026001541415620001905760405162461bcd60e51b8152600401620001879062000acb565b60405180910390fd5b60026001556200019f62000804565b6001600160a01b0316620001b26200070a565b6001600160a01b031614620001db5760405162461bcd60e51b8152600401620001879062000a31565b826001600160a01b0316846001600160a01b03161415620002105760405162461bcd60e51b8152600401620001879062000a9a565b600080846001600160a01b0316866001600160a01b0316106200023557848662000238565b85855b90925090506001600160a01b038216620002665760405162461bcd60e51b81526004016200018790620009c1565b6001600160a01b0382811660009081526002602090815260408083208585168452825280832062ffffff891684529091529020541615620002bb5760405162461bcd60e51b8152600401620001879062000a66565b6040516322afcccb60e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906322afcccb906200030c90889060040162000b2d565b60206040518083038186803b1580156200032557600080fd5b505afa1580156200033a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003609190620008b2565b90508060020b60001415620003895760405162461bcd60e51b8152600401620001879062000b02565b604051630b4c774160e11b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631698ee8290620003de90879087908b9060040162000961565b60206040518083038186803b158015620003f757600080fd5b505afa1580156200040c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200043291906200083c565b90506001600160a01b038116620004ee5760405163a167129560e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a1671295906200049590879087908b9060040162000961565b602060405180830381600087803b158015620004b057600080fd5b505af1158015620004c5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004eb91906200083c565b90505b83838784604051602001620005079493929190620008ee565b6040516020818303038152906040528051906020012081620005286200070a565b604051620005369062000808565b6200054392919062000947565b8190604051809103906000f590508015801562000564573d6000803e3d6000fd5b506001600160a01b0380861660008181526002602081815260408084208a871680865290835281852062ffffff8f168087529084528286208054988a166001600160a01b0319998a168117909155918652938352818520958552948252808420928452919052808220805485168417905560038054600181018255928190527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9092018054909416909217909255905490519196507f1c7bccf502c05203da4e5d360412a960899e8e16bce9b5fe08ecb68c3c591d64916200064f91879187918b918b919062000989565b60405180910390a15050600180555090949350505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6200069562000804565b6001600160a01b0316620006a86200070a565b6001600160a01b031614620006d15760405162461bcd60e51b8152600401620001879062000a31565b600080546040516001600160a01b039091169060008051602062004f7f833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60026020908152600093845260408085208252928452828420905282529020546001600160a01b031681565b6200074f62000804565b6001600160a01b0316620007626200070a565b6001600160a01b0316146200078b5760405162461bcd60e51b8152600401620001879062000a31565b6001600160a01b038116620007b45760405162461bcd60e51b81526004016200018790620009eb565b600080546040516001600160a01b038085169392169160008051602062004f7f83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60035490565b3390565b61441f8062000b6083390190565b60006020828403121562000828578081fd5b8135620008358162000b46565b9392505050565b6000602082840312156200084e578081fd5b8151620008358162000b46565b60008060006060848603121562000870578182fd5b83356200087d8162000b46565b925060208401356200088f8162000b46565b9150604084013562ffffff81168114620008a7578182fd5b809150509250925092565b600060208284031215620008c4578081fd5b81518060020b811462000835578182fd5b600060208284031215620008e7578081fd5b5035919050565b6001600160601b0319606095861b811682529390941b90921660148401526001600160e81b031960e891821b16602884015260029190910b901b602b820152602e0190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b6001600160a01b039586168152938516602085015262ffffff9290921660408401529092166060820152608081019190915260a00190565b60208082526010908201526f53463a205a45524f5f4144445245535360801b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601a908201527953463a2048797065724c69717569647269756d5f45584953545360301b604082015260600190565b60208082526017908201527653463a204944454e544943414c5f41444452455353455360481b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526011908201527053463a20494e434f52524543545f46454560781b604082015260600190565b62ffffff91909116815260200190565b90815260200190565b6001600160a01b038116811462000b5c57600080fd5b5056fe6101006040523480156200001257600080fd5b506040516200441f3803806200441f83398101604081905262000035916200043d565b6040518060400160405280601281526020017146756e6769626c65204c697175696469747960701b815250604051806040016040528060038152602001624c495160e81b81525081600390805190602001906200009492919062000350565b508051620000aa90600490602084019062000350565b50506005805460ff19166012179055506001600655600880546001600160a01b038085166001600160a01b0319909216919091179182905560408051630dfe168160e01b815290519290911691630dfe168191600480820192602092909190829003018186803b1580156200011e57600080fd5b505afa15801562000133573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000159919062000419565b60601b6001600160601b0319166080526008546040805163d21220a760e01b815290516001600160a01b039092169163d21220a791600480820192602092909190829003018186803b158015620001af57600080fd5b505afa158015620001c4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001ea919062000419565b60601b6001600160601b03191660a0526008546040805163ddca3f4360e01b815290516001600160a01b039092169163ddca3f4391600480820192602092909190829003018186803b1580156200024057600080fd5b505afa15801562000255573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027b919062000497565b60e81b6001600160e81b03191660c052600854604080516334324e9f60e21b815290516001600160a01b039092169163d0c93a7c91600480820192602092909190829003018186803b158015620002d157600080fd5b505afa158015620002e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200030c919062000474565b600290810b900b60e81b60e052600780546001600160a01b0319166001600160a01b0392909216919091179055506000600b556000196009819055600a55620004bc565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620003885760008555620003d3565b82601f10620003a357805160ff1916838001178555620003d3565b82800160010185558215620003d3579182015b82811115620003d3578251825591602001919060010190620003b6565b50620003e1929150620003e5565b5090565b5b80821115620003e15760008155600101620003e6565b80516001600160a01b03811681146200041457600080fd5b919050565b6000602082840312156200042b578081fd5b6200043682620003fc565b9392505050565b6000806040838503121562000450578081fd5b6200045b83620003fc565b91506200046b60208401620003fc565b90509250929050565b60006020828403121562000486578081fd5b81518060020b811462000436578182fd5b600060208284031215620004a9578081fd5b815162ffffff8116811462000436578182fd5b60805160601c60a05160601c60c05160e81c60e05160e81c613e9a62000585600039806107b852806107f4528061085552806108915280611c27525080611e37525080610bde5280610ce15280610f8d52806114af52806119a85280611a415280611bd15280611c4b5280611d615280611ddb5280611f525280611f8652508061052d5280610b935280610c455280610edc52806110a9528061147452806118fa5280611a075280611b2b5280611d275280611da05280611eca5280611f035250613e9a6000f3fe608060405234801561001057600080fd5b50600436106101ac5760003560e01c8063065e5360146101b157806306fdde03146101cf578063095ea7b3146101e45780630dfe1681146102045780630f35bcac1461021957806316f0115b1461022157806318160ddd1461022957806323b872dd1461023e5780632ab4d05214610251578063313ce56714610259578063395093511461026e5780633e091ee9146102815780633f3e4c11146102965780634d461fbb146102a957806351e87af7146102b1578063549f6dc9146102b9578063648cab85146102cc57806370a08231146102d4578063888a9134146102e75780638da5cb5b146102ef5780638dbdbe6d146102f757806395d89b411461030a578063a049de6b14610312578063a457c2d714610329578063a9059cbb1461033c578063aaf5eb681461034f578063b460af9414610357578063c4a7761e14610378578063d0c93a7c14610380578063d21220a714610388578063d2eabcfc14610390578063d348799714610398578063dd62ed3e146103ab578063ddca3f43146103be578063fa082743146103d3578063fa461e33146103db575b600080fd5b6101b96103ee565b6040516101c6919061374c565b60405180910390f35b6101d7610477565b6040516101c691906137ad565b6101f76101f2366004613295565b61050d565b6040516101c69190613738565b61020c61052b565b6040516101c6919061362a565b6101b961054f565b61020c61055f565b61023161056e565b6040516101c69190613743565b6101f761024c366004613255565b610574565b6102316105fc565b610261610602565b6040516101c69190613d4e565b6101f761027c366004613295565b61060b565b61029461028f36600461354f565b610659565b005b6102946102a43660046134de565b6106d4565b61023161073e565b6101b9610744565b6102946102c73660046132da565b610754565b610231611131565b6102316102e23660046131e5565b611137565b6101b9611156565b61020c611166565b610231610305366004613570565b611175565b6101d76115c8565b61031a611629565b6040516101c693929190613cf9565b6101f7610337366004613295565b6116bf565b6101f761034a366004613295565b611727565b61023161173b565b61036a61036536600461350e565b61174d565b6040516101c6929190613d2a565b61036a611afe565b6101b9611c25565b61020c611c49565b61031a611c6d565b6102946103a636600461359d565b611cc9565b6102316103b936600461321d565b611e0a565b6103c6611e35565b6040516101c69190613d1a565b6101b9611e59565b6102946103e9366004613375565b611e69565b60085460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b15801561043357600080fd5b505afa158015610447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046b919061344d565b50939695505050505050565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105035780601f106104d857610100808354040283529160200191610503565b820191906000526020600020905b8154815290600101906020018083116104e657829003601f168201915b5050505050905090565b600061052161051a611fae565b8484611fb2565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600160e81b900460020b81565b6008546001600160a01b031681565b60025490565b6000610581848484612066565b6105f18461058d611fae565b6105ec85604051806060016040528060288152602001613df8602891396001600160a01b038a166000908152600160205260408120906105cb611fae565b6001600160a01b031681526020810191909152604001600020549190612169565b611fb2565b5060015b9392505050565b600b5481565b60055460ff1690565b6000610521610618611fae565b846105ec8560016000610629611fae565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612195565b6007546001600160a01b0316331461068c5760405162461bcd60e51b815260040161068390613a8a565b60405180910390fd5b6009829055600a8190556040517f0a334ebaa543e2dc05c8c097dc454bc727966f3a2627a1e0c99de05e7f61777f906106c89084908490613d2a565b60405180910390a15050565b6007546001600160a01b031633146106fe5760405162461bcd60e51b815260040161068390613a8a565b600b8190556040517f870e95cc902be0a1f894ff08bb13ab98999fdb581790629f18dd80eb4da06cca90610733908390613743565b60405180910390a150565b600a5481565b600854600160d01b900460020b81565b600260065414156107775760405162461bcd60e51b815260040161068390613c8b565b60026006556007546001600160a01b031633146107a65760405162461bcd60e51b815260040161068390613a8a565b8460020b8660020b1280156107eb57507f000000000000000000000000000000000000000000000000000000000000000060020b8660020b816107e557fe5b0760020b155b801561082757507f000000000000000000000000000000000000000000000000000000000000000060020b8560020b8161082157fe5b0760020b155b6108435760405162461bcd60e51b815260040161068390613803565b8260020b8460020b12801561088857507f000000000000000000000000000000000000000000000000000000000000000060020b8460020b8161088257fe5b0760020b155b80156108c457507f000000000000000000000000000000000000000000000000000000000000000060020b8360020b816108be57fe5b0760020b155b6108e05760405162461bcd60e51b815260040161068390613a19565b60085460009061090590600160a01b8104600290810b91600160b81b9004900b6121ba565b50909150506001600160801b038116156109b55760085460405163a34123a760e01b81526001600160a01b0382169163a34123a79161096191600160a01b8104600290810b92600160b81b909204900b9060009060040161375a565b6040805180830381600087803b15801561097a57600080fd5b505af115801561098e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b29190613352565b50505b6008546000906109da90600160d01b8104600290810b91600160e81b9004900b6121ba565b50909150506001600160801b03811615610a8a5760085460405163a34123a760e01b81526001600160a01b0382169163a34123a791610a3691600160d01b8104600290810b92600160e81b909204900b9060009060040161375a565b6040805180830381600087803b158015610a4f57600080fd5b505af1158015610a63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a879190613352565b50505b6008546000908190610ab190600160a01b8104600290810b91600160b81b9004900b6121ba565b6008546001600160801b03928316955091169250600091508190610aea90600160d01b8104600290810b91600160e81b9004900b6121ba565b6001600160801b03918216945016915060009050610b088386612195565b90506000610b168386612195565b600854909150610b3f90600160a01b8104600290810b91600160b81b9004900b8a30600161227e565b5050600854610b6790600160d01b8104600290810b91600160e81b9004900b8930600161227e565b50508115610bba57610bba8a610b896014610b8386600361242d565b90612467565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190612499565b8015610c0557610c058a610bd46014610b8385600361242d565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190612499565b7fbc4c20ad04f161d631d9ce94d27659391196415aa3c42f6a71c62e905ece782d610c2e6103ee565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190610c7a90309060040161362a565b60206040518083038186803b158015610c9257600080fd5b505afa158015610ca6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cca91906134f6565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190610d1690309060040161362a565b60206040518083038186803b158015610d2e57600080fd5b505afa158015610d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6691906134f6565b8585610d7061056e565b604051610d8296959493929190613780565b60405180910390a18815610e73576008546001600160a01b031663128acb083060008c1380610db4578c600003610db6565b8c5b60008e13610dd85773fffd8963efd1fc6a506488495d951d5263988d25610ddf565b6401000276a45b30604051602001610df0919061362a565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401610e1f959493929190613662565b6040805180830381600087803b158015610e3857600080fd5b505af1158015610e4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e709190613352565b50505b8d600860146101000a81548162ffffff021916908360020b62ffffff1602179055508c600860176101000a81548162ffffff021916908360020b62ffffff160217905550611017600860149054906101000a900460020b600860179054906101000a900460020b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610f26919061362a565b60206040518083038186803b158015610f3e57600080fd5b505afa158015610f52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7691906134f6565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190610fc290309060040161362a565b60206040518083038186803b158015610fda57600080fd5b505afa158015610fee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101291906134f6565b6124f4565b60085490985061103e90600160a01b8104600290810b91600160b81b9004900b8a306125ac565b50508b6008601a6101000a81548162ffffff021916908360020b62ffffff1602179055508a6008601d6101000a81548162ffffff021916908360020b62ffffff1602179055506110f36008601a9054906101000a900460020b6008601d9054906101000a900460020b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610f26919061362a565b60085490975061111a90600160d01b8104600290810b91600160e81b9004900b89306125ac565b505060016006555050505050505050505050505050565b60095481565b6001600160a01b0381166000908152602081905260409020545b919050565b600854600160b81b900460020b81565b6007546001600160a01b031681565b60006002600654141561119a5760405162461bcd60e51b815260040161068390613c8b565b6002600655831515806111ad5750600083115b6111c95760405162461bcd60e51b815260040161068390613998565b600954841080156111db5750600a5483105b6111f75760405162461bcd60e51b815260040161068390613b0f565b6001600160a01b0382161580159061121857506001600160a01b0382163014155b6112345760405162461bcd60e51b815260040161068390613832565b60085460009061125990600160a01b8104600290810b91600160b81b9004900b6121ba565b50909150506001600160801b038116156113095760085460405163a34123a760e01b81526001600160a01b0382169163a34123a7916112b591600160a01b8104600290810b92600160b81b909204900b9060009060040161375a565b6040805180830381600087803b1580156112ce57600080fd5b505af11580156112e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113069190613352565b50505b60085460009061132e90600160d01b8104600290810b91600160e81b9004900b6121ba565b50909150506001600160801b038116156113de5760085460405163a34123a760e01b81526001600160a01b0382169163a34123a79161138a91600160d01b8104600290810b92600160e81b909204900b9060009060040161375a565b6040805180830381600087803b1580156113a357600080fd5b505af11580156113b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113db9190613352565b50505b60006113f06113eb6103ee565b61267b565b9050600061142361140a6001600160a01b0384168061242d565b6a0c097ce7bc90715b34b9f160241b600160c01b612989565b9050600080611430611afe565b909250905060006114536a0c097ce7bc90715b34b9f160241b610b838d8761242d565b905061145f8a82612195565b97508a1561149c5761149c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308e612a38565b89156114d7576114d76001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308d612a38565b6114df61056e565b156115275760006115026a0c097ce7bc90715b34b9f160241b610b83868861242d565b90506115236115118285612195565b610b8361151c61056e565b8c9061242d565b9850505b6115318989612a5f565b886001600160a01b0316336001600160a01b03167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68a8e8e60405161157893929190613d38565b60405180910390a3600b5415806115985750600b5461159561056e565b11155b6115b45760405162461bcd60e51b815260040161068390613c19565b505060016006555093979650505050505050565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105035780601f106104d857610100808354040283529160200191610503565b60008060008060008061165a6008601a9054906101000a900460020b6008601d9054906101000a900460020b6121ba565b600854929550909350915061168590600160d01b8104600290810b91600160e81b9004900b85612b0d565b909550935061169d856001600160801b038416612195565b94506116b2846001600160801b038316612195565b9350829550505050909192565b60006105216116cc611fae565b846105ec85604051806060016040528060258152602001613e4060259139600160006116f6611fae565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612169565b6000610521611734611fae565b8484612066565b6a0c097ce7bc90715b34b9f160241b81565b600080600260065414156117735760405162461bcd60e51b815260040161068390613c8b565b6002600655846117955760405162461bcd60e51b815260040161068390613aae565b6001600160a01b0384166117bb5760405162461bcd60e51b815260040161068390613832565b6001600160a01b0383163314806118535750336001600160a01b0316836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561181057600080fd5b505afa158015611824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118489190613201565b6001600160a01b0316145b61186f5760405162461bcd60e51b8152600401610683906139ca565b60085460009081906118a490600160a01b8104600290810b91600160b81b9004900b61189c82828c612bc9565b89600061227e565b600854919350915060009081906118de90600160d01b8104600290810b91600160e81b9004900b6118d682828e612bc9565b8b600061227e565b9150915060006118ec61056e565b9050600061199a82610b838d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611944919061362a565b60206040518083038186803b15801561195c57600080fd5b505afa158015611970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199491906134f6565b9061242d565b905060006119f283610b838e7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611944919061362a565b90508115611a2e57611a2e6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168c84612499565b8015611a6857611a686001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168c83612499565b611a7c82611a768988612195565b90612195565b9850611a8c81611a768887612195565b9750611a988a8d612c09565b8a6001600160a01b03168a6001600160a01b03167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8e8c8c604051611adf93929190613d38565b60405180910390a3505050505050506001600681905550935093915050565b600080600080611b0c611c6d565b9250925050600080611b1c611629565b9250925050611bc582611a76867f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611b75919061362a565b60206040518083038186803b158015611b8d57600080fd5b505afa158015611ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7691906134f6565b9550611c1b81611a76857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611b75919061362a565b9450505050509091565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080600080600080611c9e600860149054906101000a900460020b600860179054906101000a900460020b6121ba565b600854929550909350915061168590600160a01b8104600290810b91600160b81b9004900b85612b0d565b6008546001600160a01b03163314611cf35760405162461bcd60e51b81526004016106839061384e565b6000611d01828401846131e5565b90506001600160a01b038116301415611d8d578415611d4e57611d4e6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163387612499565b8315611d8857611d886001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163386612499565b611e03565b8415611dc857611dc86001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016823388612a38565b8315611e0357611e036001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016823387612a38565b5050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600160a01b900460020b81565b6008546001600160a01b03163314611e935760405162461bcd60e51b81526004016106839061384e565b6000611ea1828401846131e5565b90506000851315611f2b576001600160a01b038116301415611ef657611ef16001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163387612499565b611d88565b611d886001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016823388612a38565b6000841315611e03576001600160a01b038116301415611f7957611d886001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163386612499565b611e036001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016823387612a38565b3390565b6001600160a01b038316611fd85760405162461bcd60e51b815260040161068390613b9e565b6001600160a01b038216611ffe5760405162461bcd60e51b815260040161068390613870565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590612059908590613743565b60405180910390a3505050565b6001600160a01b03831661208c5760405162461bcd60e51b815260040161068390613b59565b6001600160a01b0382166120b25760405162461bcd60e51b8152600401610683906137c0565b6120bd8383836124ef565b6120fa81604051806060016040528060268152602001613dd2602691396001600160a01b0386166000908152602081905260409020549190612169565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546121299082612195565b6001600160a01b038084166000818152602081905260409081902093909355915190851690600080516020613e2083398151915290612059908590613743565b6000818484111561218d5760405162461bcd60e51b815260040161068391906137ad565b505050900390565b6000828201838110156105f55760405162461bcd60e51b8152600401610683906138b2565b6000806000803086866040516020016121d5939291906135de565b60408051601f1981840301815290829052805160209091012060085463514ea4bf60e01b83529092506001600160a01b03169063514ea4bf9061221c908490600401613743565b60a06040518083038186803b15801561223457600080fd5b505afa158015612248573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226c91906133f7565b939a9099509297509195505050505050565b6000806001600160801b038516156124235760085460405163a34123a760e01b815260009182916001600160a01b039091169063a34123a7906122c9908c908c908c9060040161375a565b6040805180830381600087803b1580156122e257600080fd5b505af11580156122f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231a9190613352565b915091506000856123335761232e83612ccd565b61233c565b6001600160801b035b90506000866123535761234e83612ccd565b61235c565b6001600160801b035b90506000826001600160801b0316118061237f57506000816001600160801b0316115b1561241e576008546040516309e3d67b60e31b81526001600160a01b0390911690634f1eb3d8906123bc908b908f908f90889088906004016136e2565b6040805180830381600087803b1580156123d557600080fd5b505af11580156123e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240d91906133c5565b6001600160801b0391821697501694505b505050505b9550959350505050565b60008261243c57506000610525565b8282028284828161244957fe5b04146105f55760405162461bcd60e51b815260040161068390613a49565b60008082116124885760405162461bcd60e51b815260040161068390613964565b81838161249157fe5b049392505050565b6124ef8363a9059cbb60e01b84846040516024016124b892919061371f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612ce4565b505050565b600080600860009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561254557600080fd5b505afa158015612559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257d919061344d565b50505050505090506125a2816125928861267b565b61259b8861267b565b8787612d73565b9695505050505050565b6000806001600160801b03841615612672576008546040516001600160a01b0390911690633c8a7d8d9030908990899089906125ec908a9060200161362a565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161261b95949392919061369d565b6040805180830381600087803b15801561263457600080fd5b505af1158015612648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266c9190613352565b90925090505b94509492505050565b60008060008360020b12612692578260020b61269a565b8260020b6000035b9050620d89e88111156126bf5760405162461bcd60e51b8152600401610683906139fe565b6000600182166126d357600160801b6126e5565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b03169050600282161561270f576ffff97272373d413259a46990580e213a0260801c5b600482161561272e576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561274d576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561276c576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561278b576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156127aa576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156127c9576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156127e9576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615612809576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615612829576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615612849576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615612869576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615612889576fa9f746462d870fdf8a65dc1f90e061e50260801c5b6140008216156128a9576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156128c9576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156128ea576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b6202000082161561290a576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615612929576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615612946576b048a170391f7dc42444e8fa20260801c5b60008460020b131561296157806000198161295d57fe5b0490505b600160201b810615612974576001612977565b60005b60ff16602082901c0192505050919050565b60008080600019858709868602925082811090839003039050806129bf57600084116129b457600080fd5b5082900490506105f5565b8084116129cb57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b612a59846323b872dd60e01b8585856040516024016124b89392919061363e565b50505050565b6001600160a01b038216612a855760405162461bcd60e51b815260040161068390613cc2565b612a91600083836124ef565b600254612a9e9082612195565b6002556001600160a01b038216600090815260208190526040902054612ac49082612195565b6001600160a01b038316600081815260208190526040808220939093559151909190600080516020613e2083398151915290612b01908590613743565b60405180910390a35050565b6000806000600860009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612b6057600080fd5b505afa158015612b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b98919061344d565b5050505050509050612bbc81612bad8861267b565b612bb68861267b565b87612e2b565b9250925050935093915050565b600080612bd685856121ba565b50509050612c00612bfb612be861056e565b610b836001600160801b0385168761242d565b612ccd565b95945050505050565b6001600160a01b038216612c2f5760405162461bcd60e51b815260040161068390613ace565b612c3b826000836124ef565b612c7881604051806060016040528060228152602001613db0602291396001600160a01b0385166000908152602081905260409020549190612169565b6001600160a01b038316600090815260208190526040902055600254612c9e9082612ec6565b6002556040516000906001600160a01b03841690600080516020613e2083398151915290612b01908590613743565b60006001600160801b03821115612ce057fe5b5090565b6000612d39826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612eee9092919063ffffffff16565b8051909150156124ef5780806020019051810190612d5791906132c0565b6124ef5760405162461bcd60e51b815260040161068390613c41565b6000836001600160a01b0316856001600160a01b03161115612d93579293925b846001600160a01b0316866001600160a01b031611612dbe57612db7858585612f05565b9050612c00565b836001600160a01b0316866001600160a01b03161015612e20576000612de5878686612f05565b90506000612df4878986612f68565b9050806001600160801b0316826001600160801b031610612e155780612e17565b815b92505050612c00565b6125a2858584612f68565b600080836001600160a01b0316856001600160a01b03161115612e4c579293925b846001600160a01b0316866001600160a01b031611612e7757612e70858585612fa5565b9150612672565b836001600160a01b0316866001600160a01b03161015612eb057612e9c868585612fa5565b9150612ea985878561300e565b9050612672565b612ebb85858561300e565b905094509492505050565b600082821115612ee85760405162461bcd60e51b8152600401610683906138e7565b50900390565b6060612efd8484600085613051565b949350505050565b6000826001600160a01b0316846001600160a01b03161115612f25579192915b6000612f48856001600160a01b0316856001600160a01b0316600160601b612989565b9050612c00612f6384838888036001600160a01b0316612989565b613111565b6000826001600160a01b0316846001600160a01b03161115612f88579192915b612efd612f6383600160601b8787036001600160a01b0316612989565b6000826001600160a01b0316846001600160a01b03161115612fc5579192915b836001600160a01b0316612ffe606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316612989565b8161300557fe5b04949350505050565b6000826001600160a01b0316846001600160a01b0316111561302e579192915b612efd826001600160801b03168585036001600160a01b0316600160601b612989565b6060824710156130735760405162461bcd60e51b81526004016106839061391e565b61307c85613127565b6130985760405162461bcd60e51b815260040161068390613be2565b600080866001600160a01b031685876040516130b4919061360e565b60006040518083038185875af1925050503d80600081146130f1576040519150601f19603f3d011682016040523d82523d6000602084013e6130f6565b606091505b509150915061310682828661312d565b979650505050505050565b806001600160801b038116811461115157600080fd5b3b151590565b6060831561313c5750816105f5565b82511561314c5782518084602001fd5b8160405162461bcd60e51b815260040161068391906137ad565b8051801515811461115157600080fd5b60008083601f840112613187578182fd5b5081356001600160401b0381111561319d578182fd5b6020830191508360208285010111156131b557600080fd5b9250929050565b80516001600160801b038116811461115157600080fd5b805161ffff8116811461115157600080fd5b6000602082840312156131f6578081fd5b81356105f581613d88565b600060208284031215613212578081fd5b81516105f581613d88565b6000806040838503121561322f578081fd5b823561323a81613d88565b9150602083013561324a81613d88565b809150509250929050565b600080600060608486031215613269578081fd5b833561327481613d88565b9250602084013561328481613d88565b929592945050506040919091013590565b600080604083850312156132a7578182fd5b82356132b281613d88565b946020939093013593505050565b6000602082840312156132d1578081fd5b6105f582613166565b60008060008060008060c087890312156132f2578182fd5b86356132fd81613da0565b9550602087013561330d81613da0565b9450604087013561331d81613da0565b9350606087013561332d81613da0565b9250608087013561333d81613d88565b8092505060a087013590509295509295509295565b60008060408385031215613364578182fd5b505080516020909101519092909150565b6000806000806060858703121561338a578384fd5b843593506020850135925060408501356001600160401b038111156133ad578283fd5b6133b987828801613176565b95989497509550505050565b600080604083850312156133d7578182fd5b6133e0836131bc565b91506133ee602084016131bc565b90509250929050565b600080600080600060a0868803121561340e578283fd5b613417866131bc565b94506020860151935060408601519250613433606087016131bc565b9150613441608087016131bc565b90509295509295909350565b600080600080600080600060e0888a031215613467578485fd5b875161347281613d88565b602089015190975061348381613da0565b9550613491604089016131d3565b945061349f606089016131d3565b93506134ad608089016131d3565b925060a088015160ff811681146134c2578182fd5b91506134d060c08901613166565b905092959891949750929550565b6000602082840312156134ef578081fd5b5035919050565b600060208284031215613507578081fd5b5051919050565b600080600060608486031215613522578081fd5b83359250602084013561353481613d88565b9150604084013561354481613d88565b809150509250925092565b60008060408385031215613561578182fd5b50508035926020909101359150565b600080600060608486031215613584578081fd5b8335925060208401359150604084013561354481613d88565b6000806000806060858703121561338a578182fd5b600081518084526135ca816020860160208601613d5c565b601f01601f19169290920160200192915050565b60609390931b6001600160601b0319168352600291820b60e890811b6014850152910b901b6017820152601a0190565b60008251613620818460208701613d5c565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a060808201819052600090613106908301846135b2565b6001600160a01b0386168152600285810b602083015284900b60408201526001600160801b038316606082015260a060808201819052600090613106908301846135b2565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b60029190910b815260200190565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b60029690960b8652602086019490945260408501929092526060840152608083015260a082015260c00190565b6000602082526105f560208301846135b2565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526015908201527418985cd9481c1bdcda5d1a5bdb881a5b9d985b1a59605a1b604082015260600190565b602080825260029082015261746f60f01b604082015260600190565b6020808252600890820152671b9bdd081c1bdbdb60c21b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a9082015279536166654d6174683a206469766973696f6e206279207a65726f60301b604082015260600190565b6020808252601890820152776465706f73697473206d757374206265206e6f6e7a65726f60401b604082015260600190565b6020808252601a908201527953656e646572206d757374206f776e2074686520746f6b656e7360301b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b6020808252601690820152751b1a5b5a5d081c1bdcda5d1a5bdb881a5b9d985b1a5960521b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252600a908201526937b7363c9037bbb732b960b11b604082015260600190565b60208082526006908201526573686172657360d01b604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b6020808252602a908201527f6465706f73697473206d757374206265206c657373207468616e206d6178696d604082015269756d20616d6f756e747360b01b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600e908201526d6d6178546f74616c537570706c7960901b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6001600160801b039390931683526020830191909152604082015260600190565b62ffffff91909116815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60ff91909116815260200190565b60005b83811015613d77578181015183820152602001613d5f565b83811115612a595750506000910152565b6001600160a01b0381168114613d9d57600080fd5b50565b8060020b8114613d9d57600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220245883d4688ecfbb3b6a98b15dc8df70bf644c65f2fdfd5aa90c0cfdd2fec7f564736f6c634300070600338be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0a2646970667358221220f26bfb23b4e4313dc1cbfa05630205810136ccb33b652ce46d969e720a8ecf0664736f6c634300070600330000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984

-----Decoded View---------------
Arg [0] : _uniswapV3Factory (address): 0x1f98431c8ad98523631ae4a59f267346ea31f984

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984


Deployed ByteCode Sourcemap

115808:2074:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;116082:36;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;116492:1387;;;;;;:::i;:::-;;:::i;115876:51::-;;;:::i;6743:148::-;;;:::i;:::-;;6092:87;;;:::i;115934:92::-;;;;;;:::i;:::-;;:::i;7046:244::-;;;;;;:::i;:::-;;:::i;116363:121::-;;;:::i;:::-;;;;;;;:::i;116082:36::-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;116082:36:0;;-1:-1:-1;116082:36:0;:::o;116492:1387::-;116642:23;96126:1;96724:7;;:19;;96716:63;;;;-1:-1:-1;;;96716:63:0;;;;;;;:::i;:::-;;;;;;;;;96126:1;96857:7;:18;6323:12:::1;:10;:12::i;:::-;-1:-1:-1::0;;;;;6312:23:0::1;:7;:5;:7::i;:::-;-1:-1:-1::0;;;;;6312:23:0::1;;6304:68;;;;-1:-1:-1::0;;;6304:68:0::1;;;;;;;:::i;:::-;116696:6:::2;-1:-1:-1::0;;;;;116686:16:0::2;:6;-1:-1:-1::0;;;;;116686:16:0::2;;;116678:52;;;;-1:-1:-1::0;;;116678:52:0::2;;;;;;;:::i;:::-;116800:14;116816::::0;116843:6:::2;-1:-1:-1::0;;;;;116834:15:0::2;:6;-1:-1:-1::0;;;;;116834:15:0::2;;:53;;116872:6;116880;116834:53;;;116853:6;116861;116834:53;116799:88:::0;;-1:-1:-1;116799:88:0;-1:-1:-1;;;;;;116906:20:0;::::2;116898:49;;;;-1:-1:-1::0;;;116898:49:0::2;;;;;;;:::i;:::-;-1:-1:-1::0;;;;;116966:26:0;;::::2;117017:1;116966:26:::0;;;:18:::2;:26;::::0;;;;;;;:34;;::::2;::::0;;;;;;;:39:::2;::::0;::::2;::::0;;;;;;;;::::2;:53:::0;116958:92:::2;;;;-1:-1:-1::0;;;116958:92:0::2;;;;;;;:::i;:::-;117081:42;::::0;-1:-1:-1;;;117081:42:0;;117061:17:::2;::::0;-1:-1:-1;;;;;117081:16:0::2;:37;::::0;::::2;::::0;:42:::2;::::0;117119:3;;117081:42:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;117061:62;;117142:11;:16;;117157:1;117142:16;;117134:46;;;;-1:-1:-1::0;;;117134:46:0::2;;;;;;;:::i;:::-;117206:45;::::0;-1:-1:-1;;;117206:45:0;;117191:12:::2;::::0;-1:-1:-1;;;;;117206:16:0::2;:24;::::0;::::2;::::0;:45:::2;::::0;117231:6;;117239;;117247:3;;117206:45:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;117191:60:::0;-1:-1:-1;;;;;;117266:18:0;::::2;117262:106;;117308:48;::::0;-1:-1:-1;;;117308:48:0;;-1:-1:-1;;;;;117308:16:0::2;:27;::::0;::::2;::::0;:48:::2;::::0;117336:6;;117344;;117352:3;;117308:48:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;117301:55;;117262:106;117471:6;117479;117487:3;117492:11;117454:50;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;117444:61;;;;;;117507:4;117513:7;:5;:7::i;:::-;117418:103;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;;;;;117545:26:0;;::::2;;::::0;;;:18:::2;:26;::::0;;;;;;;:34;;::::2;::::0;;;;;;;;;:39:::2;::::0;::::2;::::0;;;;;;;;;:57;;;;::::2;-1:-1:-1::0;;;;;;117545:57:0;;::::2;::::0;::::2;::::0;;;117613:26;;;;;;;;;:34;;;;;;;;;:39;;;;;;;;;:57;;;::::2;::::0;::::2;::::0;;117726:19:::2;:41:::0;;117545:57;117726:41;::::2;::::0;;;;;;;;;::::2;::::0;;;;::::2;::::0;;::::2;::::0;;;117844:26;;117783:88;;117378:154;;-1:-1:-1;117783:88:0::2;::::0;::::2;::::0;117564:6;;117572;;117580:3;;117378:154;;117844:26;117783:88:::2;:::i;:::-;;;;;;;;-1:-1:-1::0;;96082:1:0;97036:22;;-1:-1:-1;116492:1387:0;;;-1:-1:-1;;;;116492:1387:0:o;115876:51::-;;;:::o;6743:148::-;6323:12;:10;:12::i;:::-;-1:-1:-1;;;;;6312:23:0;:7;:5;:7::i;:::-;-1:-1:-1;;;;;6312:23:0;;6304:68;;;;-1:-1:-1;;;6304:68:0;;;;;;;:::i;:::-;6850:1:::1;6834:6:::0;;6813:40:::1;::::0;-1:-1:-1;;;;;6834:6:0;;::::1;::::0;-1:-1:-1;;;;;;;;;;;6813:40:0;6850:1;;6813:40:::1;6881:1;6864:19:::0;;-1:-1:-1;;;;;;6864:19:0::1;::::0;;6743:148::o;6092:87::-;6138:7;6165:6;-1:-1:-1;;;;;6165:6:0;6092:87;:::o;115934:92::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;115934:92:0;;:::o;7046:244::-;6323:12;:10;:12::i;:::-;-1:-1:-1;;;;;6312:23:0;:7;:5;:7::i;:::-;-1:-1:-1;;;;;6312:23:0;;6304:68;;;;-1:-1:-1;;;6304:68:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;7135:22:0;::::1;7127:73;;;;-1:-1:-1::0;;;7127:73:0::1;;;;;;;:::i;:::-;7237:6;::::0;;7216:38:::1;::::0;-1:-1:-1;;;;;7216:38:0;;::::1;::::0;7237:6;::::1;::::0;-1:-1:-1;;;;;;;;;;;7216:38:0;::::1;7265:6;:17:::0;;-1:-1:-1;;;;;;7265:17:0::1;-1:-1:-1::0;;;;;7265:17:0;;;::::1;::::0;;;::::1;::::0;;7046:244::o;116363:121::-;116450:19;:26;116363:121;:::o;4719:106::-;4807:10;4719:106;:::o;-1:-1:-1:-;;;;;;;;:::o;14:259:1:-;;126:2;114:9;105:7;101:23;97:32;94:2;;;147:6;139;132:22;94:2;191:9;178:23;210:33;237:5;210:33;:::i;:::-;262:5;84:189;-1:-1:-1;;;84:189:1:o;278:263::-;;401:2;389:9;380:7;376:23;372:32;369:2;;;422:6;414;407:22;369:2;459:9;453:16;478:33;505:5;478:33;:::i;546:582::-;;;;691:2;679:9;670:7;666:23;662:32;659:2;;;712:6;704;697:22;659:2;756:9;743:23;775:33;802:5;775:33;:::i;:::-;827:5;-1:-1:-1;884:2:1;869:18;;856:32;897:35;856:32;897:35;:::i;:::-;951:7;-1:-1:-1;1010:2:1;995:18;;982:32;1058:8;1045:22;;1033:35;;1023:2;;1087:6;1079;1072:22;1023:2;1115:7;1105:17;;;649:479;;;;;:::o;1133:297::-;;1254:2;1242:9;1233:7;1229:23;1225:32;1222:2;;;1275:6;1267;1260:22;1222:2;1312:9;1306:16;1365:5;1362:1;1351:20;1344:5;1341:31;1331:2;;1391:6;1383;1376:22;1435:190;;1547:2;1535:9;1526:7;1522:23;1518:32;1515:2;;;1568:6;1560;1553:22;1515:2;-1:-1:-1;1596:23:1;;1505:120;-1:-1:-1;1505:120:1:o;1630:509::-;-1:-1:-1;;;;;;1859:2:1;1895:15;;;1891:24;;1879:37;;1950:15;;;;1946:24;;;1941:2;1932:12;;1925:46;-1:-1:-1;;;;;;2027:3:1;2005:16;;;2001:41;1996:2;1987:12;;1980:63;2093:1;2082:21;;;;2073:31;;2068:2;2059:12;;2052:53;2130:2;2121:12;;1827:312::o;2144:203::-;-1:-1:-1;;;;;2308:32:1;;;;2290:51;;2278:2;2263:18;;2245:102::o;2352:304::-;-1:-1:-1;;;;;2582:15:1;;;2564:34;;2634:15;;2629:2;2614:18;;2607:43;2514:2;2499:18;;2481:175::o;2661:388::-;-1:-1:-1;;;;;2917:15:1;;;2899:34;;2969:15;;;;2964:2;2949:18;;2942:43;3033:8;3021:21;;;3016:2;3001:18;;2994:49;2849:2;2834:18;;2816:233::o;3054:541::-;-1:-1:-1;;;;;3367:15:1;;;3349:34;;3419:15;;;3414:2;3399:18;;3392:43;3483:8;3471:21;;;;3466:2;3451:18;;3444:49;3529:15;;;3524:2;3509:18;;3502:43;3576:3;3561:19;;3554:35;;;;3298:3;3283:19;;3265:330::o;3832:340::-;4034:2;4016:21;;;4073:2;4053:18;;;4046:30;-1:-1:-1;;;4107:2:1;4092:18;;4085:46;4163:2;4148:18;;4006:166::o;4177:402::-;4379:2;4361:21;;;4418:2;4398:18;;;4391:30;4457:34;4452:2;4437:18;;4430:62;-1:-1:-1;;;4523:2:1;4508:18;;4501:36;4569:3;4554:19;;4351:228::o;4584:356::-;4786:2;4768:21;;;4805:18;;;4798:30;4864:34;4859:2;4844:18;;4837:62;4931:2;4916:18;;4758:182::o;4945:350::-;5147:2;5129:21;;;5186:2;5166:18;;;5159:30;-1:-1:-1;;;5220:2:1;5205:18;;5198:56;5286:2;5271:18;;5119:176::o;5300:347::-;5502:2;5484:21;;;5541:2;5521:18;;;5514:30;-1:-1:-1;;;5575:2:1;5560:18;;5553:53;5638:2;5623:18;;5474:173::o;5652:355::-;5854:2;5836:21;;;5893:2;5873:18;;;5866:30;5932:33;5927:2;5912:18;;5905:61;5998:2;5983:18;;5826:181::o;6012:341::-;6214:2;6196:21;;;6253:2;6233:18;;;6226:30;-1:-1:-1;;;6287:2:1;6272:18;;6265:47;6344:2;6329:18;;6186:167::o;6358:190::-;6532:8;6520:21;;;;6502:40;;6490:2;6475:18;;6457:91::o;6553:177::-;6699:25;;;6687:2;6672:18;;6654:76::o;6735:133::-;-1:-1:-1;;;;;6812:31:1;;6802:42;;6792:2;;6858:1;6855;6848:12;6792:2;6782:86;:::o

Swarm Source

ipfs://f26bfb23b4e4313dc1cbfa05630205810136ccb33b652ce46d969e720a8ecf06
Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.