ETH Price: $3,257.11 (-4.65%)
Gas: 11 Gwei

Contract

0x8D35a33524C77f542cA2d1AD9c92487E34C90f20
 

Overview

ETH Balance

4.5 ETH

Eth Value

$14,657.00 (@ $3,257.11/ETH)

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Borrow198361972024-05-10 0:55:1154 days ago1715302511IN
0x8D35a335...E34C90f20
0 ETH0.000737323.09471844
Borrow198086542024-05-06 4:26:4758 days ago1714969607IN
0x8D35a335...E34C90f20
0 ETH0.000903833.79243921
Borrow197952022024-05-04 7:18:5960 days ago1714807139IN
0x8D35a335...E34C90f20
0 ETH0.001641256.88733426
Borrow197733912024-05-01 6:08:3563 days ago1714543715IN
0x8D35a335...E34C90f20
0 ETH0.001492065.84372877
Deposit197733862024-05-01 6:07:3563 days ago1714543655IN
0x8D35a335...E34C90f20
0 ETH0.000679016.22000256
Deposit Liquidit...197694092024-04-30 16:46:3564 days ago1714495595IN
0x8D35a335...E34C90f20
10 ETH0.0022269315.10905138
Deposit Liquidit...197651792024-04-30 2:36:2364 days ago1714444583IN
0x8D35a335...E34C90f20
4 ETH0.001111337.54006313
Borrow197651242024-04-30 2:25:2364 days ago1714443923IN
0x8D35a335...E34C90f20
0 ETH0.00171427.19649503
Deposit197651202024-04-30 2:24:3564 days ago1714443875IN
0x8D35a335...E34C90f20
0 ETH0.000788447.22243831
Deposit And Borr...197582592024-04-29 3:22:5965 days ago1714360979IN
0x8D35a335...E34C90f20
0 ETH0.003201884.40218027
Toggle Whitelist...194122312024-03-11 13:43:35114 days ago1710164615IN
0x8D35a335...E34C90f20
0 ETH0.0091358780.40655597
Toggle Whitelist...194122292024-03-11 13:43:11114 days ago1710164591IN
0x8D35a335...E34C90f20
0 ETH0.0100603870.60956407
Toggle Whitelist...194122272024-03-11 13:42:47114 days ago1710164567IN
0x8D35a335...E34C90f20
0 ETH0.0110301279.53362953
Toggle Whitelist...194122262024-03-11 13:42:35114 days ago1710164555IN
0x8D35a335...E34C90f20
0 ETH0.0118921180.37006032
Toggle Whitelist...194122242024-03-11 13:42:11114 days ago1710164531IN
0x8D35a335...E34C90f20
0 ETH0.008806277.50506146
Toggle Whitelist...194122222024-03-11 13:41:47114 days ago1710164507IN
0x8D35a335...E34C90f20
0 ETH0.0119441980.028674
Toggle Whitelist...194122132024-03-11 13:39:59114 days ago1710164399IN
0x8D35a335...E34C90f20
0 ETH0.0125616384.88794139
Toggle Whitelist...194121992024-03-11 13:37:11114 days ago1710164231IN
0x8D35a335...E34C90f20
0 ETH0.0125641890.58729493
Deposit Liquidit...194121022024-03-11 13:17:35114 days ago1710163055IN
0x8D35a335...E34C90f20
4 ETH0.0057956277.14748113
Deposit Liquidit...194120792024-03-11 13:12:59114 days ago1710162779IN
0x8D35a335...E34C90f20
5 ETH0.013631276.24099124
Set Enabled193914742024-03-08 15:54:59117 days ago1709913299IN
0x8D35a335...E34C90f20
0 ETH0.00296937102.6470937
Toggle Whitelist...193914622024-03-08 15:52:35117 days ago1709913155IN
0x8D35a335...E34C90f20
0 ETH0.0111611298.23119773
Toggle Whitelist...193914592024-03-08 15:51:59117 days ago1709913119IN
0x8D35a335...E34C90f20
0 ETH0.0100538590.72155854
0x60a06040193902572024-03-08 11:49:35117 days ago1709898575IN
 Create: LendingPoolExtLP
0 ETH0.4036750841.7093133

Latest 21 internal transactions

Advanced mode:
Parent Transaction Hash Block From To Value
198361972024-05-10 0:55:1154 days ago1715302511
0x8D35a335...E34C90f20
2.88568563 ETH
198361972024-05-10 0:55:1154 days ago1715302511
0x8D35a335...E34C90f20
0.02857859 ETH
198361972024-05-10 0:55:1154 days ago1715302511
0x8D35a335...E34C90f20
0.08573577 ETH
198086542024-05-06 4:26:4758 days ago1714969607
0x8D35a335...E34C90f20
1.4442028 ETH
198086542024-05-06 4:26:4758 days ago1714969607
0x8D35a335...E34C90f20
0.01394929 ETH
198086542024-05-06 4:26:4758 days ago1714969607
0x8D35a335...E34C90f20
0.04184789 ETH
197952022024-05-04 7:18:5960 days ago1714807139
0x8D35a335...E34C90f20
2.89624491 ETH
197952022024-05-04 7:18:5960 days ago1714807139
0x8D35a335...E34C90f20
0.02593877 ETH
197952022024-05-04 7:18:5960 days ago1714807139
0x8D35a335...E34C90f20
0.07781631 ETH
197733912024-05-01 6:08:3563 days ago1714543715
0x8D35a335...E34C90f20
1.93573662 ETH
197733912024-05-01 6:08:3563 days ago1714543715
0x8D35a335...E34C90f20
0.01606584 ETH
197733912024-05-01 6:08:3563 days ago1714543715
0x8D35a335...E34C90f20
0.04819753 ETH
197651242024-04-30 2:25:2364 days ago1714443923
0x8D35a335...E34C90f20
7.75960547 ETH
197651242024-04-30 2:25:2364 days ago1714443923
0x8D35a335...E34C90f20
0.06009863 ETH
197651242024-04-30 2:25:2364 days ago1714443923
0x8D35a335...E34C90f20
0.18029589 ETH
197582592024-04-29 3:22:5965 days ago1714360979
0x8D35a335...E34C90f20
0.97 ETH
197582592024-04-29 3:22:5965 days ago1714360979
0x8D35a335...E34C90f20
0.0075 ETH
197582592024-04-29 3:22:5965 days ago1714360979
0x8D35a335...E34C90f20
0.0225 ETH
193902572024-03-08 11:49:35117 days ago1709898575
0x8D35a335...E34C90f20
 Contract Creation0 ETH
193902572024-03-08 11:49:35117 days ago1709898575
0x8D35a335...E34C90f20
 Contract Creation0 ETH
193902572024-03-08 11:49:35117 days ago1709898575
0x8D35a335...E34C90f20
 Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LendingPoolExtLP

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 44 : LendingPoolExtLP.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import './HLP.sol';
import './LendingPool.sol';

contract LendingPoolExtLP is LendingPool {
  uint32 public externalLpFeePerc = (DENOMENATOR * 75) / 100;
  HLP public hlp;

  constructor(
    string memory _baseTokenURI,
    ISwapRouter __swapRouter,
    IHyperbolicProtocol __hype,
    ITwapUtils __twapUtils,
    LendingRewards __lendingRewards,
    address __WETH
  )
    LendingPool(
      _baseTokenURI,
      __swapRouter,
      __hype,
      __twapUtils,
      __lendingRewards,
      __WETH
    )
  {
    hlp = new HLP();
  }

  function depositLiquidity() external payable {
    require(msg.value > 0, 'DEPOSIT: no ETH');
    hlp.mint(_msgSender(), msg.value);
  }

  function withdrawLiquidity(uint256 _amount) external {
    hlp.burn(_msgSender(), _amount);
    (bool _sent, ) = payable(_msgSender()).call{ value: _amount }('');
    require(_sent, 'WITHDRAW: ETH not sent');
  }

  function _depositRewards(uint256 _amount) internal override {
    uint256 _externalLpRewards = (_amount * externalLpFeePerc) / DENOMENATOR;
    uint256 _hypeHolderRewards = _amount - _externalLpRewards;
    if (_externalLpRewards > 0) {
      LendingRewards _lpRewards = hlp.lendingRewards();
      _lpRewards.depositRewards{ value: _externalLpRewards }();
    }
    if (_hypeHolderRewards > 0) {
      _lendingRewards.depositRewards{ value: _hypeHolderRewards }();
    }
  }

  function setExternalLpFeePerc(uint32 _perc) external onlyOwner {
    require(_perc <= DENOMENATOR, 'lte 100%');
    externalLpFeePerc = _perc;
  }
}

File 2 of 44 : AutomationCompatibleInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AutomationCompatibleInterface {
  /**
   * @notice method that is simulated by the keepers to see if any work actually
   * needs to be performed. This method does does not actually need to be
   * executable, and since it is only ever simulated it can consume lots of gas.
   * @dev To ensure that it is never called, you may want to add the
   * cannotExecute modifier from KeeperBase to your implementation of this
   * method.
   * @param checkData specified in the upkeep registration so it is always the
   * same for a registered upkeep. This can easily be broken down into specific
   * arguments using `abi.decode`, so multiple upkeeps can be registered on the
   * same contract and easily differentiated by the contract.
   * @return upkeepNeeded boolean to indicate whether the keeper should call
   * performUpkeep or not.
   * @return performData bytes that the keeper should call performUpkeep with, if
   * upkeep is needed. If you would like to encode data to decode later, try
   * `abi.encode`.
   */
  function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);

  /**
   * @notice method that is actually executed by the keepers, via the registry.
   * The data returned by the checkUpkeep simulation will be passed into
   * this method to actually be executed.
   * @dev The input to this method should not be trusted, and the caller of the
   * method should not even be restricted to any single registry. Anyone should
   * be able call it, and the input should be validated, there is no guarantee
   * that the data passed in is the performData returned from checkUpkeep. This
   * could happen due to malicious keepers, racing keepers, or simply a state
   * change while the performUpkeep transaction is waiting for confirmation.
   * Always validate the data passed in.
   * @param performData is the data which was passed back from the checkData
   * simulation. If it is encoded, it can easily be decoded into other types by
   * calling `abi.decode`. This data should not be trusted, and should be
   * validated against the contract's current state.
   */
  function performUpkeep(bytes calldata performData) external;
}

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

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

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

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

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

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

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

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

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

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

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

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

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 6 of 44 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 8 of 44 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @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 Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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'
        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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 9 of 44 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner or approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _ownerOf(tokenId) != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId, 1);

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId, 1);

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
     * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
     * that `ownerOf(tokenId)` is `a`.
     */
    // solhint-disable-next-line func-name-mixedcase
    function __unsafe_increaseBalance(address account, uint256 amount) internal {
        _balances[account] += amount;
    }
}

File 10 of 44 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);

        if (batchSize > 1) {
            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.
            revert("ERC721Enumerable: consecutive transfers not supported");
        }

        uint256 tokenId = firstTokenId;

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 11 of 44 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 12 of 44 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 13 of 44 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 14 of 44 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 16 of 44 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 17 of 44 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 18 of 44 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 19 of 44 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 20 of 44 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // 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(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            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 for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the 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.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // 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 preconditions 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 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 21 of 44 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 22 of 44 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 23 of 44 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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;
}

File 24 of 44 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';

/// @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
{

}

File 25 of 44 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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;
}

File 26 of 44 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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
        );
}

File 27 of 44 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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);
}

File 28 of 44 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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);
}

File 29 of 44 : IUniswapV3PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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);
}

File 30 of 44 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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
        );
}

File 31 of 44 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
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;
}

File 32 of 44 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 33 of 44 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 34 of 44 : HLP.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import './LendingRewards.sol';

contract HLP is ERC20 {
  address public lendingPool;
  LendingRewards public lendingRewards;

  modifier onlyLendingPool() {
    require(_msgSender() == lendingPool, 'UNAUTHORIZED');
    _;
  }

  constructor() ERC20('HYPE LP', 'HLP') {
    lendingPool = _msgSender();
    lendingRewards = new LendingRewards(address(this));
  }

  function mint(address _wallet, uint256 _amount) external onlyLendingPool {
    _mint(_wallet, _amount);
  }

  function burn(address _wallet, uint256 _amount) external onlyLendingPool {
    _burn(_wallet, _amount);
  }

  function _canReceiveRewards(address _wallet) internal pure returns (bool) {
    return _wallet != address(0);
  }

  function _afterTokenTransfer(
    address _from,
    address _to,
    uint256 _amount
  ) internal virtual override {
    if (_canReceiveRewards(_from)) {
      lendingRewards.setShare(_from, _amount, true);
    }
    if (_canReceiveRewards(_to)) {
      lendingRewards.setShare(_to, _amount, false);
    }
  }
}

File 35 of 44 : IHyperbolicProtocol.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IHyperbolicProtocol {
  function poolBalToMarketCapRatio()
    external
    view
    returns (uint256 lendPoolETHBal, uint256 marketCapETH);

  function poolToMarketCapTarget() external view returns (uint32);
}

File 36 of 44 : IRewardsTracker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRewardsTracker {
  function claimReward() external;

  function depositRewards() external payable;

  function getShares(address wallet) external view returns (uint256);

  function setShare(
    address shareholder,
    uint256 balanceUpdate,
    bool isRemoving
  ) external;
}

File 37 of 44 : ITwapUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface ITwapUtils {
  function twapInterval() external view returns (uint32);

  function getPoolPriceUSDX96(
    address priceToken,
    address pricePool,
    address nativeStablePool,
    address WETH9,
    bool isPoolPairedWETH9
  ) external view returns (uint256);

  function getSqrtPriceX96FromPoolAndInterval(
    address uniswapV3Pool
  ) external view returns (uint160 sqrtPriceX96);

  function getSqrtPriceX96FromPriceX96(
    uint256 priceX96
  ) external pure returns (uint160 sqrtPriceX96);

  function getPriceX96FromSqrtPriceX96(
    uint160 sqrtPriceX96
  ) external pure returns (uint256 priceX96);
}

File 38 of 44 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IWETH {
  function balanceOf(address wallet) external view returns (uint256);

  function decimals() external view returns (uint8);

  function deposit() external payable;

  function withdraw(uint256 _amount) external;
}

File 39 of 44 : LendingPool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
pragma abicoder v2;

import '@chainlink/contracts/src/v0.8/automation/interfaces/AutomationCompatibleInterface.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';
import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol';
import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol';
import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol';
import './LoanToken.sol';
import './LendingPoolTokenCustodian.sol';
import './LendingRewards.sol';
import './interfaces/IHyperbolicProtocol.sol';
import './interfaces/ITwapUtils.sol';
import './interfaces/IWETH.sol';

contract LendingPool is Ownable, AutomationCompatibleInterface {
  using SafeERC20 for ERC20;

  uint32 constant DENOMENATOR = 10000;
  uint256 Q96_2 = 2 ** (96 / 2);
  address immutable _WETH;

  bool public enabled;
  bool public liquidateDefaultCapital;
  uint32 public liquidateSlippage = (DENOMENATOR * 10) / 100; // 10%
  uint32 public maxLiquidationsPerUpkeep = 10;

  LendingPoolTokenCustodian public custodian;
  LoanToken public loanNFT;
  IHyperbolicProtocol _hype;
  LendingRewards _lendingRewards;
  ITwapUtils _twapUtils;
  ISwapRouter _swapRouter;

  mapping(address => bool) public whitelistPools;
  address[] _allWhitelistedPools;
  mapping(address => uint256) _allWhitelistPoolsInd;

  uint32 public borrowInitFee = (DENOMENATOR * 3) / 100; // 3%
  uint32 public borrowAPRMin = (DENOMENATOR * 2) / 100; // 2%
  uint32 public borrowAPRMax = (DENOMENATOR * 15) / 100; // 15%
  uint32 public liquidationLTV = (DENOMENATOR * 95) / 100; // 95%
  uint32 public maxLTVOverall = (DENOMENATOR * 50) / 100; // 50%
  // pool => LTV override
  mapping(address => uint32) public maxLTVOverride;
  // pool => current borrowed ETH
  mapping(address => uint256) public currentBorrowPerPool;
  // pool => borrow max
  mapping(address => uint256) public maxBorrowPerPool;

  struct Loan {
    uint256 created; // when the loan was first created
    address createdBy; // original wallet who created loan for lending rewards
    uint256 aprStart; // the starting timestamp we should evaluate APR fees from
    address collateralPool; // Uniswap V3 Pool of collateral token and ETH (WETH)
    uint256 amountDeposited; // amount of collateral token from collateralPool deposited
    uint256 amountETHBorrowed; // amount ETH borrowed, this and collateral deposited is used to determine LTV
  }
  // tokenId => Loan
  mapping(uint256 => Loan) public loans;

  event Deposit(
    address indexed wallet,
    uint256 indexed tokenId,
    uint256 amountCollateral
  );
  event Withdraw(
    address indexed wallet,
    uint256 indexed tokenId,
    uint256 amountCollateral
  );
  event Borrow(
    address indexed wallet,
    uint256 indexed tokenId,
    uint256 amountETH
  );
  event PayBackLoan(
    address indexed wallet,
    uint256 indexed tokenId,
    uint256 amountDesired,
    uint256 amountFees
  );
  event DeleteLoan(uint256 indexed tokenId);

  constructor(
    string memory _baseTokenURI,
    ISwapRouter __swapRouter,
    IHyperbolicProtocol __hype,
    ITwapUtils __twapUtils,
    LendingRewards __lendingRewards,
    address __WETH
  ) {
    _swapRouter = __swapRouter;
    _hype = __hype;
    _twapUtils = __twapUtils;
    _lendingRewards = __lendingRewards;
    _WETH = __WETH;

    custodian = new LendingPoolTokenCustodian(address(_hype));
    loanNFT = new LoanToken(_baseTokenURI);
    loanNFT.setRoyaltyAddress(msg.sender);
    loanNFT.transferOwnership(msg.sender);
  }

  function getLTVX96(
    uint256 _tokenId
  )
    public
    view
    returns (
      uint256 ltvX96,
      uint256 ltvWithFeesX96,
      uint256 amountETHDepositedX96,
      uint256 amountETHBorrowedX96
    )
  {
    require(loanNFT.doesTokenExist(_tokenId), 'GETLTV: loan must exist');
    Loan memory _loan = loans[_tokenId];
    uint256 _fees = calculateAPRFees(_loan.amountETHBorrowed, _loan.aprStart);
    if (_loan.amountDeposited == 0 && _loan.amountETHBorrowed == 0) {
      return (0, 0, 0, 0);
    }
    uint160 _sqrtPriceX96 = _twapUtils.getSqrtPriceX96FromPoolAndInterval(
      _loan.collateralPool
    );
    uint256 _priceX96 = _twapUtils.getPriceX96FromSqrtPriceX96(_sqrtPriceX96);
    address _token0 = IUniswapV3Pool(_loan.collateralPool).token0();
    uint256 _amountETHDepositedX96 = _token0 == _WETH
      ? _loan.amountDeposited * (FixedPoint96.Q96 ** 2 / _priceX96)
      : _priceX96 * _loan.amountDeposited;
    uint256 _amountETHBorrowedX96 = _loan.amountETHBorrowed * FixedPoint96.Q96;
    uint256 _amountETHBorrWithFeesX96 = (_loan.amountETHBorrowed + _fees) *
      FixedPoint96.Q96;
    return (
      ((_amountETHBorrowedX96 * Q96_2) / _amountETHDepositedX96) * Q96_2,
      ((_amountETHBorrWithFeesX96 * Q96_2) / _amountETHDepositedX96) * Q96_2,
      _amountETHDepositedX96,
      _amountETHBorrowedX96
    );
  }

  function getAllWhitelistedPools() external view returns (address[] memory) {
    return _allWhitelistedPools;
  }

  function getETHBalance(address _wallet) external view returns (uint256) {
    return address(_wallet).balance;
  }

  function depositAndBorrow(
    uint256 _tokenId,
    address _pool,
    uint256 _amountDepositing,
    uint256 _amountETHBorrowing
  ) external returns (uint256 tokenId) {
    _tokenId = _deposit(msg.sender, _tokenId, _pool, _amountDepositing);
    return _borrow(msg.sender, _tokenId, _amountETHBorrowing);
  }

  function deposit(uint256 _tokenId, address _pool, uint256 _amount) external {
    _deposit(msg.sender, _tokenId, _pool, _amount);
  }

  function borrow(
    uint256 _tokenId,
    uint256 _amountETHBorrowing
  ) external returns (uint256 tokenId) {
    return _borrow(msg.sender, _tokenId, _amountETHBorrowing);
  }

  function withdraw(uint256 _tokenId, uint256 _amount) external {
    _withdraw(msg.sender, _tokenId, _amount);
  }

  function payBackLoan(uint256 _tokenId) external payable {
    _payBackLoan(msg.sender, _tokenId, msg.value);
  }

  function payBackLoanAndClose(uint256 _tokenId) external payable {
    if (loans[_tokenId].amountETHBorrowed > 0) {
      _payBackLoan(msg.sender, _tokenId, msg.value);
    } else {
      require(msg.value == 0, 'PAYBACKLOSE: no ETH needed');
    }
    _withdraw(msg.sender, _tokenId, loans[_tokenId].amountDeposited);
  }

  function _deposit(
    address _wallet,
    uint256 _tokenId,
    address _pool,
    uint256 _amount
  ) internal returns (uint256) {
    require(enabled, 'DEPOSIT: not enabled');
    (uint256 __tokenId, ) = _getOrCreateLoan(_wallet, _tokenId);
    _tokenId = __tokenId;
    Loan storage _loan = loans[_tokenId];

    IUniswapV3Pool _uniPool;
    if (_loan.collateralPool == address(0)) {
      require(whitelistPools[_pool], 'DEPOSIT: bad pool0');
      _loan.created = block.timestamp;
      _loan.createdBy = _wallet;
      _loan.aprStart = block.timestamp;
      _loan.collateralPool = _pool;
      _uniPool = IUniswapV3Pool(_pool);
    } else {
      require(whitelistPools[_loan.collateralPool], 'DEPOSIT: bad pool1');
      _uniPool = IUniswapV3Pool(_loan.collateralPool);
    }
    _loan.amountDeposited += _amount;
    address _token0 = _uniPool.token0();
    if (_token0 == _WETH) {
      ERC20 _t1 = ERC20(_uniPool.token1());
      _t1.safeTransferFrom(_wallet, address(this), _amount);
      _t1.approve(address(custodian), _amount);
      custodian.process(_t1, _loan.createdBy, _amount, false);
    } else {
      ERC20 _t0 = ERC20(_token0);
      _t0.safeTransferFrom(_wallet, address(this), _amount);
      _t0.approve(address(custodian), _amount);
      custodian.process(_t0, _loan.createdBy, _amount, false);
    }
    emit Deposit(_wallet, _tokenId, _amount);
    return _tokenId;
  }

  function _withdraw(
    address _wallet,
    uint256 _tokenId,
    uint256 _amount
  ) internal {
    require(_amount > 0, 'WITHDRAW: must withdraw from loan');
    _validateLoanOwner(_wallet, _tokenId);

    Loan storage _loan = loans[_tokenId];
    require(_amount <= _loan.amountDeposited, 'WITHDRAW: too much');
    _loan.amountDeposited -= _amount;

    // get LTV info after we've removed _amount to withdraw from loan
    (, uint256 _ltvAndFeesX96, , ) = getLTVX96(_tokenId);
    if (maxLTVOverride[_loan.collateralPool] > 0) {
      require(
        _ltvAndFeesX96 <=
          (FixedPoint96.Q96 * maxLTVOverride[_loan.collateralPool]) /
            DENOMENATOR,
        'WITHDRAW: exceeds max LTV'
      );
    } else {
      require(
        _ltvAndFeesX96 <= (FixedPoint96.Q96 * maxLTVOverall) / DENOMENATOR,
        'WITHDRAW: exceeds max LTV'
      );
    }
    IUniswapV3Pool _uniPool = IUniswapV3Pool(_loan.collateralPool);
    address _token0 = _uniPool.token0();
    if (_token0 == _WETH) {
      ERC20 _t1 = ERC20(_uniPool.token1());
      custodian.process(_t1, _loan.createdBy, _amount, true);
      _t1.safeTransfer(_wallet, _amount);
    } else {
      ERC20 _t0 = ERC20(_token0);
      custodian.process(_t0, _loan.createdBy, _amount, true);
      _t0.safeTransfer(_wallet, _amount);
    }
    if (_loan.amountDeposited == 0) {
      _deleteLoan(_tokenId);
    }
    emit Withdraw(_wallet, _tokenId, _amount);
  }

  function _borrow(
    address _wallet,
    uint256 _tokenId,
    uint256 _amountETH
  ) internal returns (uint256) {
    require(enabled, 'BORROW: not enabled');
    _validateLoanOwner(_wallet, _tokenId);

    Loan storage _loan = loans[_tokenId];
    require(whitelistPools[_loan.collateralPool], 'BORROW: bad pool');

    // take out current APR fees from amount borrowing
    uint256 _amountAPRFees = calculateAPRFees(
      _loan.amountETHBorrowed,
      _loan.aprStart
    );
    _loan.aprStart = block.timestamp;
    (, , uint256 ethDepositedX96, uint256 ethBorrowedX96) = getLTVX96(_tokenId);
    uint256 ethDeposited = ethDepositedX96 / FixedPoint96.Q96;
    uint256 ethBorrowed = ethBorrowedX96 / FixedPoint96.Q96;

    uint256 _maxLoanETH = maxLTVOverride[_loan.collateralPool] > 0
      ? (ethDeposited * maxLTVOverride[_loan.collateralPool]) / DENOMENATOR
      : (ethDeposited * maxLTVOverall) / DENOMENATOR;
    require(ethBorrowed < _maxLoanETH, 'BORROW: cannot borrow');
    if (ethBorrowed + _amountETH > _maxLoanETH) {
      _amountETH = _maxLoanETH - ethBorrowed;
    }
    require(address(this).balance >= _amountETH, 'BORROW: not enough funds');

    if (maxBorrowPerPool[_loan.collateralPool] > 0) {
      require(
        currentBorrowPerPool[_loan.collateralPool] + _amountETH <=
          maxBorrowPerPool[_loan.collateralPool],
        'BORROW: exceeds pool max'
      );
    }
    currentBorrowPerPool[_loan.collateralPool] += _amountETH;
    _loan.amountETHBorrowed += _amountETH;
    uint256 _amountFees = _amountAPRFees +
      ((_amountETH * borrowInitFee) / DENOMENATOR);
    require(_amountETH > _amountFees, 'BORROW: fees more than borrow amount');

    uint256 _amountToBorrower = _amountETH - _amountFees;
    _depositRewards(_amountFees);
    (bool success, ) = payable(_wallet).call{ value: _amountToBorrower }('');
    require(success, 'BORROW: ETH not delivered');

    emit Borrow(_wallet, _tokenId, _amountETH);
    return _tokenId;
  }

  function _payBackLoan(
    address _wallet,
    uint256 _tokenId,
    uint256 _amount
  ) internal {
    require(_amount > 0, 'PAYBACK: no ETH to pay back');
    _validateLoanOwner(_wallet, _tokenId);

    Loan storage _loan = loans[_tokenId];
    // take out current APR fees from amount borrowing
    uint256 _amountAPRFees = calculateAPRFees(
      _loan.amountETHBorrowed,
      _loan.aprStart
    );
    _loan.aprStart = block.timestamp;
    require(_amount > _amountAPRFees, 'PAYBACK: must pay back above fees');
    uint256 _amountBorrowedPlusFees = _loan.amountETHBorrowed + _amountAPRFees;

    uint256 _refund;
    if (_amount > _amountBorrowedPlusFees) {
      _refund = _amount - _amountBorrowedPlusFees;
    }

    // remove amount minus fees from the amount borrowed
    currentBorrowPerPool[_loan.collateralPool] -= (_amount - _amountAPRFees) >
      currentBorrowPerPool[_loan.collateralPool]
      ? currentBorrowPerPool[_loan.collateralPool]
      : _amount - _amountAPRFees;
    _loan.amountETHBorrowed -= (_amount - _amountAPRFees) >
      _loan.amountETHBorrowed
      ? _loan.amountETHBorrowed
      : _amount - _amountAPRFees;

    if (_amountAPRFees > 0) {
      _depositRewards(_amountAPRFees);
    }
    if (_refund > 0) {
      (bool wasRefunded, ) = payable(_wallet).call{ value: _refund }('');
      require(wasRefunded, 'PAYBACK: refund unsuccessful');
    }
    emit PayBackLoan(_wallet, _tokenId, _amount, _amountAPRFees);
  }

  function _getOrCreateLoan(
    address _wallet,
    uint256 _tokenId
  ) internal returns (uint256 tokenId, bool isNewLoan) {
    if (_tokenId == 0) {
      tokenId = loanNFT.mint(_wallet);
      return (tokenId, true);
    }
    _validateLoanOwner(_wallet, _tokenId);
    tokenId = _tokenId;
    return (tokenId, false);
  }

  function _deleteLoan(uint256 _tokenId) internal {
    delete loans[_tokenId];
    loanNFT.burn(_tokenId);
    emit DeleteLoan(_tokenId);
  }

  function _depositRewards(uint256 _amount) internal virtual {
    _lendingRewards.depositRewards{ value: _amount }();
  }

  function calculateAPRFees(
    uint256 _amountETHBorrowed,
    uint256 _aprStart
  ) public view returns (uint256) {
    return
      ((block.timestamp - _aprStart) *
        calculateBorrowAPR() *
        _amountETHBorrowed) /
      DENOMENATOR /
      365 days;
  }

  function calculateBorrowAPR() public view returns (uint256) {
    (uint256 _poolBalETH, uint256 _mcETH) = _hype.poolBalToMarketCapRatio();
    uint256 _targetPoolBal = (_mcETH * _hype.poolToMarketCapTarget()) /
      DENOMENATOR;
    if (_poolBalETH < _targetPoolBal) {
      uint256 _aprLessMax = ((borrowAPRMax - borrowAPRMin) * _poolBalETH) /
        _targetPoolBal;
      return borrowAPRMax - _aprLessMax;
    }
    return borrowAPRMin;
  }

  function shouldLiquidateLoan(uint256 _tokenId) external view returns (bool) {
    return _shouldLiquidateLoan(_tokenId);
  }

  function _shouldLiquidateLoan(uint256 _tokenId) internal view returns (bool) {
    if (!loanNFT.doesTokenExist(_tokenId)) {
      return false;
    }
    (, uint256 _ltvWithFeesX96, , ) = getLTVX96(_tokenId);
    return _ltvWithFeesX96 >= (FixedPoint96.Q96 * liquidationLTV) / DENOMENATOR;
  }

  function _toggleWhitelistCollateralPool(address _pool) internal {
    if (whitelistPools[_pool]) {
      uint256 _ind = _allWhitelistPoolsInd[_pool];
      address _poolMoving = _allWhitelistedPools[
        _allWhitelistedPools.length - 1
      ];
      _allWhitelistedPools[_ind] = _poolMoving;
      _allWhitelistPoolsInd[_poolMoving] = _ind;
      delete whitelistPools[_pool];
      _allWhitelistedPools.pop();
    } else {
      // add
      whitelistPools[_pool] = true;
      _allWhitelistPoolsInd[_pool] = _allWhitelistedPools.length;
      _allWhitelistedPools.push(_pool);
    }
  }

  function checkUpkeep(
    bytes calldata
  )
    external
    view
    override
    returns (bool upkeepNeeded, bytes memory performData)
  {
    uint256[] memory _openedLoans = loanNFT.getAllOpenedLoans();
    uint256[] memory _upkeepLoans = new uint256[](maxLiquidationsPerUpkeep);
    uint32 _numUpkeeps = 0;
    for (uint256 _i = 0; _i < _openedLoans.length; _i++) {
      if (_numUpkeeps >= maxLiquidationsPerUpkeep) {
        break;
      }
      uint256 _tokenId = _openedLoans[_i];
      if (_shouldLiquidateLoan(_tokenId)) {
        upkeepNeeded = true;
        _upkeepLoans[_numUpkeeps] = _tokenId;
        _numUpkeeps++;
      }
    }

    if (upkeepNeeded) {
      performData = abi.encode(_upkeepLoans);
    }
  }

  function performUpkeep(bytes calldata performData) external override {
    uint256[] memory _upkeepLoans = abi.decode(performData, (uint256[]));
    for (uint256 _i = 0; _i < _upkeepLoans.length; _i++) {
      uint256 _tokenId = _upkeepLoans[_i];
      if (_tokenId == 0) {
        break;
      }
      if (_shouldLiquidateLoan(_tokenId)) {
        Loan memory _loan = loans[_tokenId];
        uint256 _amountDeposited = _loan.amountDeposited;
        IUniswapV3Pool _pool = IUniswapV3Pool(_loan.collateralPool);
        address _token0 = _pool.token0();
        if (_token0 == _WETH) {
          ERC20 _t1 = ERC20(_pool.token1());
          custodian.process(_t1, _loan.createdBy, _amountDeposited, true);
          _processLiquidatedTokens(_pool, _t1, _loan);
        } else {
          ERC20 _t0 = ERC20(_token0);
          custodian.process(_t0, _loan.createdBy, _amountDeposited, true);
          _processLiquidatedTokens(_pool, _t0, _loan);
        }
        _deleteLoan(_tokenId);
      }
    }
  }

  function _processLiquidatedTokens(
    IUniswapV3Pool _pool,
    ERC20 _token,
    Loan memory _loan
  ) internal {
    if (liquidateDefaultCapital && address(_token) != address(_hype)) {
      uint160 _sqrtPriceX96 = _twapUtils.getSqrtPriceX96FromPoolAndInterval(
        address(_pool)
      );
      uint256 _priceX96 = _twapUtils.getPriceX96FromSqrtPriceX96(_sqrtPriceX96);
      uint256 _priceWETHNumX96 = _pool.token1() == _WETH
        ? _priceX96
        : FixedPoint96.Q96 ** 2 / _priceX96;
      uint256 _minETHBaseFromPrice = (_priceWETHNumX96 *
        _loan.amountDeposited) / FixedPoint96.Q96;
      uint256 _minETHBase = _minETHBaseFromPrice > _loan.amountETHBorrowed
        ? _minETHBaseFromPrice
        : _loan.amountETHBorrowed;

      TransferHelper.safeApprove(
        address(_token),
        address(_swapRouter),
        _loan.amountDeposited
      );
      _swapRouter.exactInputSingle(
        ISwapRouter.ExactInputSingleParams({
          tokenIn: address(_token),
          tokenOut: _WETH,
          fee: _pool.fee(),
          recipient: address(this),
          deadline: block.timestamp,
          amountIn: _loan.amountDeposited,
          amountOutMinimum: (_minETHBase * (DENOMENATOR - liquidateSlippage)) /
            DENOMENATOR,
          sqrtPriceLimitX96: 0
        })
      );
      uint256 _balWETH = IERC20(_WETH).balanceOf(address(this));
      if (_balWETH > 0) {
        IWETH(_WETH).withdraw(_balWETH);
      }
    } else {
      _token.safeTransfer(owner(), _loan.amountDeposited);
    }
  }

  function _validateLoanOwner(address _wallet, uint256 _tokenId) internal view {
    require(_wallet == loanNFT.ownerOf(_tokenId), 'VALIDATEOWNER');
  }

  function setLiquidateDefaultCapital(bool _shouldLiq) external onlyOwner {
    require(liquidateDefaultCapital != _shouldLiq, 'SETLIQDEF');
    liquidateDefaultCapital = _shouldLiq;
  }

  function setLiquidateSlippage(uint32 _slippage) external onlyOwner {
    require(_slippage <= DENOMENATOR, 'lte 100%');
    liquidateSlippage = _slippage;
  }

  function setBorrowInitFee(uint32 _fee) external onlyOwner {
    require(_fee <= (DENOMENATOR * 30) / 100, 'SETBFEE: lte 30%');
    borrowInitFee = _fee;
  }

  function setBorrowAPRMin(uint32 _apr) external onlyOwner {
    require(_apr <= (DENOMENATOR * 10) / 100, 'SETBAPRMIN: lte 10%');
    borrowAPRMin = _apr;
  }

  function setBorrowAPRMax(uint32 _apr) external onlyOwner {
    require(_apr <= DENOMENATOR, 'SETBAPRMAX: lte 100%');
    borrowAPRMax = _apr;
  }

  function setMaxLTVOverall(uint32 _ltv) external onlyOwner {
    require(_ltv <= DENOMENATOR, 'SETLTVMAX: lte 100%');
    maxLTVOverall = _ltv;
  }

  function setMaxLTVOverride(address _pool, uint32 _ltv) external onlyOwner {
    require(_ltv <= DENOMENATOR, 'SETLTVMAX: lte 100%');
    maxLTVOverride[_pool] = _ltv;
  }

  function setMaxBorrowPerPool(
    address _pool,
    uint256 _amountETH
  ) external onlyOwner {
    maxBorrowPerPool[_pool] = _amountETH;
  }

  function setLiquidationLTV(uint32 _ltv) external onlyOwner {
    require(_ltv <= DENOMENATOR, 'SETLPLTV: lte 100%');
    liquidationLTV = _ltv;
  }

  function setMaxLiquidationsPerUpkeep(uint32 _max) external onlyOwner {
    maxLiquidationsPerUpkeep = _max;
  }

  function setEnabled(bool _enabled) external onlyOwner {
    require(enabled != _enabled, 'SETENABLED: must toggle');
    enabled = _enabled;
  }

  function toggleWhitelistCollateralPool(address _pool) external onlyOwner {
    IUniswapV3Pool _uniPool = IUniswapV3Pool(_pool);
    address _token0 = _uniPool.token0();
    address _token1 = _uniPool.token1();
    require(_token0 == _WETH || _token1 == _WETH, 'TOGGLECOLL: no ETH');

    uint32[] memory secondsAgo = new uint32[](2);
    secondsAgo[0] = 5 minutes;
    secondsAgo[1] = 0;
    _uniPool.observe(secondsAgo);

    _toggleWhitelistCollateralPool(_pool);
  }

  receive() external payable {}
}

File 40 of 44 : LendingPoolTokenCustodian.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import './RewardsTracker.sol';

contract LendingPoolTokenCustodian is Ownable, RewardsTracker {
  using SafeERC20 for IERC20;

  address public hype;

  constructor(address _hype) RewardsTracker(_hype) {
    hype = _hype;
  }

  function process(
    IERC20 _token,
    address _user,
    uint256 _balanceUpdate,
    bool _isWithdrawing
  ) external onlyOwner {
    if (_isWithdrawing) {
      _token.safeTransfer(msg.sender, _balanceUpdate);
    } else {
      _token.safeTransferFrom(msg.sender, address(this), _balanceUpdate);
    }
    if (address(_token) == hype) {
      _setShare(_user, _balanceUpdate, _isWithdrawing);
    }
  }

  receive() external payable {
    uint256 _hypeTokens = IERC20(hype).balanceOf(address(this));
    if (_hypeTokens > 0) {
      _depositRewards(msg.value);
    } else {
      (bool _success, ) = payable(owner()).call{ value: msg.value }('');
      require(_success, 'RECEIVE: did not send to owner');
    }
  }
}

File 41 of 44 : LendingRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import './RewardsTracker.sol';

contract LendingRewards is RewardsTracker {
  constructor(address _token) RewardsTracker(_token) {}
}

File 42 of 44 : BokkyPooBahsDateTimeLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

// ----------------------------------------------------------------------------
// BokkyPooBah's DateTime Library v1.00
//
// A gas-efficient Solidity date and time library
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
// Tested date range 1970/01/01 to 2345/12/31
//
// Conventions:
// Unit      | Range         | Notes
// :-------- |:-------------:|:-----
// timestamp | >= 0          | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC
// year      | 1970 ... 2345 |
// month     | 1 ... 12      |
// day       | 1 ... 31      |
// hour      | 0 ... 23      |
// minute    | 0 ... 59      |
// second    | 0 ... 59      |
// dayOfWeek | 1 ... 7       | 1 = Monday, ..., 7 = Sunday
//
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018.
//
// GNU Lesser General Public License 3.0
// https://www.gnu.org/licenses/lgpl-3.0.en.html
// ----------------------------------------------------------------------------

library BokkyPooBahsDateTimeLibrary {
  uint constant SECONDS_PER_DAY = 24 * 60 * 60;
  uint constant SECONDS_PER_HOUR = 60 * 60;
  uint constant SECONDS_PER_MINUTE = 60;
  int constant OFFSET19700101 = 2440588;

  uint constant DOW_MON = 1;
  uint constant DOW_TUE = 2;
  uint constant DOW_WED = 3;
  uint constant DOW_THU = 4;
  uint constant DOW_FRI = 5;
  uint constant DOW_SAT = 6;
  uint constant DOW_SUN = 7;

  // ------------------------------------------------------------------------
  // Calculate the number of days from 1970/01/01 to year/month/day using
  // the date conversion algorithm from
  //   http://aa.usno.navy.mil/faq/docs/JD_Formula.php
  // and subtracting the offset 2440588 so that 1970/01/01 is day 0
  //
  // days = day
  //      - 32075
  //      + 1461 * (year + 4800 + (month - 14) / 12) / 4
  //      + 367 * (month - 2 - (month - 14) / 12 * 12) / 12
  //      - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
  //      - offset
  // ------------------------------------------------------------------------
  function _daysFromDate(
    uint year,
    uint month,
    uint day
  ) internal pure returns (uint _days) {
    require(year >= 1970);
    int _year = int(year);
    int _month = int(month);
    int _day = int(day);

    int __days = _day -
      32075 +
      (1461 * (_year + 4800 + (_month - 14) / 12)) /
      4 +
      (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /
      12 -
      (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /
      4 -
      OFFSET19700101;

    _days = uint(__days);
  }

  // ------------------------------------------------------------------------
  // Calculate year/month/day from the number of days since 1970/01/01 using
  // the date conversion algorithm from
  //   http://aa.usno.navy.mil/faq/docs/JD_Formula.php
  // and adding the offset 2440588 so that 1970/01/01 is day 0
  //
  // int L = days + 68569 + offset
  // int N = 4 * L / 146097
  // L = L - (146097 * N + 3) / 4
  // year = 4000 * (L + 1) / 1461001
  // L = L - 1461 * year / 4 + 31
  // month = 80 * L / 2447
  // dd = L - 2447 * month / 80
  // L = month / 11
  // month = month + 2 - 12 * L
  // year = 100 * (N - 49) + year + L
  // ------------------------------------------------------------------------
  function _daysToDate(
    uint _days
  ) internal pure returns (uint year, uint month, uint day) {
    int __days = int(_days);

    int L = __days + 68569 + OFFSET19700101;
    int N = (4 * L) / 146097;
    L = L - (146097 * N + 3) / 4;
    int _year = (4000 * (L + 1)) / 1461001;
    L = L - (1461 * _year) / 4 + 31;
    int _month = (80 * L) / 2447;
    int _day = L - (2447 * _month) / 80;
    L = _month / 11;
    _month = _month + 2 - 12 * L;
    _year = 100 * (N - 49) + _year + L;

    year = uint(_year);
    month = uint(_month);
    day = uint(_day);
  }

  function timestampFromDate(
    uint year,
    uint month,
    uint day
  ) internal pure returns (uint timestamp) {
    timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;
  }

  function timestampFromDateTime(
    uint year,
    uint month,
    uint day,
    uint hour,
    uint minute,
    uint second
  ) internal pure returns (uint timestamp) {
    timestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      hour *
      SECONDS_PER_HOUR +
      minute *
      SECONDS_PER_MINUTE +
      second;
  }

  function timestampToDate(
    uint timestamp
  ) internal pure returns (uint year, uint month, uint day) {
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
  }

  function timestampToDateTime(
    uint timestamp
  )
    internal
    pure
    returns (
      uint year,
      uint month,
      uint day,
      uint hour,
      uint minute,
      uint second
    )
  {
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    uint secs = timestamp % SECONDS_PER_DAY;
    hour = secs / SECONDS_PER_HOUR;
    secs = secs % SECONDS_PER_HOUR;
    minute = secs / SECONDS_PER_MINUTE;
    second = secs % SECONDS_PER_MINUTE;
  }

  function isValidDate(
    uint year,
    uint month,
    uint day
  ) internal pure returns (bool valid) {
    if (year >= 1970 && month > 0 && month <= 12) {
      uint daysInMonth = _getDaysInMonth(year, month);
      if (day > 0 && day <= daysInMonth) {
        valid = true;
      }
    }
  }

  function isValidDateTime(
    uint year,
    uint month,
    uint day,
    uint hour,
    uint minute,
    uint second
  ) internal pure returns (bool valid) {
    if (isValidDate(year, month, day)) {
      if (hour < 24 && minute < 60 && second < 60) {
        valid = true;
      }
    }
  }

  function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    leapYear = _isLeapYear(year);
  }

  function _isLeapYear(uint year) internal pure returns (bool leapYear) {
    leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
  }

  function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {
    weekDay = getDayOfWeek(timestamp) <= DOW_FRI;
  }

  function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {
    weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;
  }

  function getDaysInMonth(
    uint timestamp
  ) internal pure returns (uint daysInMonth) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    daysInMonth = _getDaysInMonth(year, month);
  }

  function _getDaysInMonth(
    uint year,
    uint month
  ) internal pure returns (uint daysInMonth) {
    if (
      month == 1 ||
      month == 3 ||
      month == 5 ||
      month == 7 ||
      month == 8 ||
      month == 10 ||
      month == 12
    ) {
      daysInMonth = 31;
    } else if (month != 2) {
      daysInMonth = 30;
    } else {
      daysInMonth = _isLeapYear(year) ? 29 : 28;
    }
  }

  // 1 = Monday, 7 = Sunday
  function getDayOfWeek(uint timestamp) internal pure returns (uint dayOfWeek) {
    uint _days = timestamp / SECONDS_PER_DAY;
    dayOfWeek = ((_days + 3) % 7) + 1;
  }

  function getYear(uint timestamp) internal pure returns (uint year) {
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
  }

  function getMonth(uint timestamp) internal pure returns (uint month) {
    uint year;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
  }

  function getDay(uint timestamp) internal pure returns (uint day) {
    uint year;
    uint month;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
  }

  function getHour(uint timestamp) internal pure returns (uint hour) {
    uint secs = timestamp % SECONDS_PER_DAY;
    hour = secs / SECONDS_PER_HOUR;
  }

  function getMinute(uint timestamp) internal pure returns (uint minute) {
    uint secs = timestamp % SECONDS_PER_HOUR;
    minute = secs / SECONDS_PER_MINUTE;
  }

  function getSecond(uint timestamp) internal pure returns (uint second) {
    second = timestamp % SECONDS_PER_MINUTE;
  }

  function addYears(
    uint timestamp,
    uint _years
  ) internal pure returns (uint newTimestamp) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    year += _years;
    uint daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp >= timestamp);
  }

  function addMonths(
    uint timestamp,
    uint _months
  ) internal pure returns (uint newTimestamp) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    month += _months;
    year += (month - 1) / 12;
    month = ((month - 1) % 12) + 1;
    uint daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp >= timestamp);
  }

  function addDays(
    uint timestamp,
    uint _days
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp + _days * SECONDS_PER_DAY;
    require(newTimestamp >= timestamp);
  }

  function addHours(
    uint timestamp,
    uint _hours
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
    require(newTimestamp >= timestamp);
  }

  function addMinutes(
    uint timestamp,
    uint _minutes
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
    require(newTimestamp >= timestamp);
  }

  function addSeconds(
    uint timestamp,
    uint _seconds
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp + _seconds;
    require(newTimestamp >= timestamp);
  }

  function subYears(
    uint timestamp,
    uint _years
  ) internal pure returns (uint newTimestamp) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    year -= _years;
    uint daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp <= timestamp);
  }

  function subMonths(
    uint timestamp,
    uint _months
  ) internal pure returns (uint newTimestamp) {
    uint year;
    uint month;
    uint day;
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    uint yearMonth = year * 12 + (month - 1) - _months;
    year = yearMonth / 12;
    month = (yearMonth % 12) + 1;
    uint daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp <= timestamp);
  }

  function subDays(
    uint timestamp,
    uint _days
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp - _days * SECONDS_PER_DAY;
    require(newTimestamp <= timestamp);
  }

  function subHours(
    uint timestamp,
    uint _hours
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
    require(newTimestamp <= timestamp);
  }

  function subMinutes(
    uint timestamp,
    uint _minutes
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
    require(newTimestamp <= timestamp);
  }

  function subSeconds(
    uint timestamp,
    uint _seconds
  ) internal pure returns (uint newTimestamp) {
    newTimestamp = timestamp - _seconds;
    require(newTimestamp <= timestamp);
  }

  function diffYears(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _years) {
    require(fromTimestamp <= toTimestamp);
    uint fromYear;
    uint fromMonth;
    uint fromDay;
    uint toYear;
    uint toMonth;
    uint toDay;
    (fromYear, fromMonth, fromDay) = _daysToDate(
      fromTimestamp / SECONDS_PER_DAY
    );
    (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
    _years = toYear - fromYear;
  }

  function diffMonths(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _months) {
    require(fromTimestamp <= toTimestamp);
    uint fromYear;
    uint fromMonth;
    uint fromDay;
    uint toYear;
    uint toMonth;
    uint toDay;
    (fromYear, fromMonth, fromDay) = _daysToDate(
      fromTimestamp / SECONDS_PER_DAY
    );
    (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
    _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
  }

  function diffDays(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _days) {
    require(fromTimestamp <= toTimestamp);
    _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
  }

  function diffHours(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _hours) {
    require(fromTimestamp <= toTimestamp);
    _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
  }

  function diffMinutes(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _minutes) {
    require(fromTimestamp <= toTimestamp);
    _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
  }

  function diffSeconds(
    uint fromTimestamp,
    uint toTimestamp
  ) internal pure returns (uint _seconds) {
    require(fromTimestamp <= toTimestamp);
    _seconds = toTimestamp - fromTimestamp;
  }
}

File 43 of 44 : LoanToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
import '@openzeppelin/contracts/utils/Counters.sol';

contract LoanToken is ERC721Enumerable, Ownable {
  using Strings for uint256;
  using Counters for Counters.Counter;

  address public lendingPool;

  Counters.Counter internal _ids;
  string private baseTokenURI; // baseTokenURI can point to IPFS folder like https://ipfs.io/ipfs/{cid}/ while
  address public royaltyAddress;

  // Royalties basis points (percentage using 2 decimals - 1000 = 100, 500 = 50, 0 = 0)
  uint256 private royaltyBasisPoints = 50; // 5%

  uint256[] _openedLoans;
  // tokenId => _openedLoans idx
  mapping(uint256 => uint256) _openedIndex;
  // token IDs owned by user
  mapping(address => uint256[]) public allUserOwned;
  // tokenId => allUserOwned idx
  mapping(uint256 => uint256) public ownedIndex;

  event Burn(uint256 indexed tokenId, address indexed owner);
  event Mint(uint256 indexed tokenId, address indexed owner);
  event SetPaymentAddress(address indexed user);
  event SetRoyaltyAddress(address indexed user);
  event SetRoyaltyBasisPoints(uint256 indexed _royaltyBasisPoints);
  event SetBaseTokenURI(string indexed newUri);

  modifier onlyLendingPool() {
    require(msg.sender == lendingPool, 'ONLYLENDINGPOOL');
    _;
  }

  constructor(
    string memory _baseTokenURI
  ) ERC721('Hyperbolic Protocol Loan', 'lHYPE') {
    baseTokenURI = _baseTokenURI;
    lendingPool = msg.sender;
  }

  function getAllOpenedLoans() external view returns (uint256[] memory) {
    return _openedLoans;
  }

  function mint(address owner) external onlyLendingPool returns (uint256) {
    _ids.increment();
    _safeMint(owner, _ids.current());
    emit Mint(_ids.current(), owner);
    return _ids.current();
  }

  function burn(uint256 _tokenId) external onlyLendingPool {
    address _user = ownerOf(_tokenId);
    require(_exists(_tokenId));
    _burn(_tokenId);
    emit Burn(_tokenId, _user);
  }

  // Support royalty info - See {EIP-2981}: https://eips.ethereum.org/EIPS/eip-2981
  function royaltyInfo(
    uint256,
    uint256 _salePrice
  ) external view returns (address receiver, uint256 royaltyAmount) {
    return (royaltyAddress, (_salePrice * royaltyBasisPoints) / 1000);
  }

  function tokenURI(
    uint256 _tokenId
  ) public view virtual override returns (string memory) {
    require(_exists(_tokenId));
    return string(abi.encodePacked(_baseURI(), _tokenId.toString(), '.json'));
  }

  // Contract metadata URI - Support for OpenSea: https://docs.opensea.io/docs/contract-level-metadata
  function contractURI() public view returns (string memory) {
    return string(abi.encodePacked(_baseURI(), 'contract.json'));
  }

  // Override supportsInterface - See {IERC165-supportsInterface}
  function supportsInterface(
    bytes4 _interfaceId
  ) public view virtual override(ERC721Enumerable) returns (bool) {
    return super.supportsInterface(_interfaceId);
  }

  function getLastMintedTokenId() external view returns (uint256) {
    return _ids.current();
  }

  function doesTokenExist(uint256 _tokenId) external view returns (bool) {
    return _exists(_tokenId);
  }

  function setRoyaltyAddress(address _address) external onlyOwner {
    royaltyAddress = _address;
    emit SetRoyaltyAddress(_address);
  }

  function setRoyaltyBasisPoints(uint256 _points) external onlyOwner {
    royaltyBasisPoints = _points;
    emit SetRoyaltyBasisPoints(_points);
  }

  function setBaseURI(string memory _uri) external onlyOwner {
    baseTokenURI = _uri;
    emit SetBaseTokenURI(_uri);
  }

  function setLendingPool(address _addy) external onlyOwner {
    lendingPool = _addy;
  }

  function getAllUserOwned(
    address _user
  ) external view returns (uint256[] memory) {
    return allUserOwned[_user];
  }

  function _baseURI() internal view override returns (string memory) {
    return baseTokenURI;
  }

  function _mint(address to, uint256 tokenId) internal virtual override {
    super._mint(to, tokenId);
    _afterTokenTransfer(address(0), to, tokenId);
  }

  function _burn(uint256 tokenId) internal virtual override {
    address _owner = ERC721.ownerOf(tokenId);
    super._burn(tokenId);
    _afterTokenTransfer(_owner, address(0), tokenId);
  }

  function _transfer(
    address from,
    address to,
    uint256 tokenId
  ) internal virtual override {
    super._transfer(from, to, tokenId);
    _afterTokenTransfer(from, to, tokenId);
  }

  function _afterTokenTransfer(
    address _from,
    address _to,
    uint256 _tokenId
  ) internal virtual {
    // ensure token not being minted
    if (_from != address(0)) {
      // update user owned
      uint256 _currIndex = ownedIndex[_tokenId];
      uint256 _tokenIdMovingIndices = allUserOwned[_from][
        allUserOwned[_from].length - 1
      ];
      allUserOwned[_from][_currIndex] = _tokenIdMovingIndices;
      allUserOwned[_from].pop();
      ownedIndex[_tokenIdMovingIndices] = _currIndex;

      // update all opened
      uint256 _curOpenedIdx = _openedIndex[_tokenId];
      uint256 _tokenIdMoveOpened = _openedLoans[_openedLoans.length - 1];
      _openedLoans[_curOpenedIdx] = _tokenIdMoveOpened;
      _openedLoans.pop();
      _openedIndex[_tokenIdMoveOpened] = _curOpenedIdx;
    }

    // ensure token not being burned
    if (_to != address(0)) {
      // update user owned
      ownedIndex[_tokenId] = allUserOwned[_to].length;
      allUserOwned[_to].push(_tokenId);

      // update all opened
      _openedIndex[_tokenId] = _openedLoans.length;
      _openedLoans.push(_tokenId);
    }
  }
}

File 44 of 44 : RewardsTracker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import './interfaces/IRewardsTracker.sol';
import './libraries/BokkyPooBahsDateTimeLibrary.sol';

contract RewardsTracker is IRewardsTracker {
  uint256 constant MULTIPLIER = 10 ** 36;
  address public token;
  uint256 public totalStakedUsers;
  uint256 public totalSharesDeposited;

  struct Share {
    uint256 amount;
    uint256 stakedTime;
  }
  struct Reward {
    uint256 totalExcluded;
    uint256 totalRealized;
  }
  mapping(address => Share) private shares;
  mapping(address => Reward) public rewards;

  uint256 public rewardsPerShare;
  uint256 public totalDistributed;
  uint256 public totalRewards;
  mapping(uint256 => uint256) public monthlyRewards;

  event AddShares(address indexed user, uint256 amount);
  event RemoveShares(address indexed user, uint256 amount);
  event ClaimReward(address user);
  event DistributeReward(address indexed user, uint256 amount);
  event DepositRewards(address indexed user, uint256 amountTokens);

  modifier onlyToken() {
    require(msg.sender == token, 'ONLYTOKEN');
    _;
  }

  constructor(address _token) {
    token = _token;
  }

  function setShare(
    address shareholder,
    uint256 balanceUpdate,
    bool isRemoving
  ) public override onlyToken {
    _setShare(shareholder, balanceUpdate, isRemoving);
  }

  function _setShare(
    address shareholder,
    uint256 balanceUpdate,
    bool isRemoving
  ) internal {
    if (isRemoving) {
      _removeShares(shareholder, balanceUpdate);
      emit RemoveShares(shareholder, balanceUpdate);
    } else {
      _addShares(shareholder, balanceUpdate);
      emit AddShares(shareholder, balanceUpdate);
    }
  }

  function _addShares(address shareholder, uint256 amount) private {
    if (shares[shareholder].amount > 0) {
      _distributeReward(shareholder);
    }

    uint256 sharesBefore = shares[shareholder].amount;

    totalSharesDeposited += amount;
    shares[shareholder].amount += amount;
    shares[shareholder].stakedTime = block.timestamp;
    if (sharesBefore == 0 && shares[shareholder].amount > 0) {
      totalStakedUsers++;
    }
    rewards[shareholder].totalExcluded = _cumulativeRewards(
      shares[shareholder].amount
    );
  }

  function _removeShares(address shareholder, uint256 amount) private {
    require(
      shares[shareholder].amount > 0 && amount <= shares[shareholder].amount,
      'REMOVE: no shares'
    );
    _distributeReward(shareholder);

    totalSharesDeposited -= amount;
    shares[shareholder].amount -= amount;
    if (shares[shareholder].amount == 0) {
      totalStakedUsers--;
    }
    rewards[shareholder].totalExcluded = _cumulativeRewards(
      shares[shareholder].amount
    );
  }

  function depositRewards() external payable override {
    _depositRewards(msg.value);
  }

  function _depositRewards(uint256 _amount) internal {
    require(_amount > 0, 'DEPOSIT: no ETH');
    require(totalSharesDeposited > 0, 'DEPOSIT: no shares');

    totalRewards += _amount;
    uint256 _month = beginningOfMonth(block.timestamp);
    monthlyRewards[_month] += _amount;
    rewardsPerShare += (MULTIPLIER * _amount) / totalSharesDeposited;
    emit DepositRewards(msg.sender, _amount);
  }

  function _distributeReward(address shareholder) internal {
    if (shares[shareholder].amount == 0) {
      return;
    }

    uint256 amount = getUnpaid(shareholder);
    rewards[shareholder].totalRealized += amount;
    rewards[shareholder].totalExcluded = _cumulativeRewards(
      shares[shareholder].amount
    );

    if (amount > 0) {
      totalDistributed += amount;
      uint256 _balBefore = address(this).balance;
      (bool success, ) = payable(shareholder).call{ value: amount }('');
      require(success, 'DIST: could not distribute');
      require(address(this).balance >= _balBefore - amount, 'DIST: too much');
      emit DistributeReward(shareholder, amount);
    }
  }

  function claimReward() external override {
    _distributeReward(msg.sender);
    emit ClaimReward(msg.sender);
  }

  function getUnpaid(address shareholder) public view returns (uint256) {
    if (shares[shareholder].amount == 0) {
      return 0;
    }
    uint256 earnedRewards = _cumulativeRewards(shares[shareholder].amount);
    uint256 rewardsExcluded = rewards[shareholder].totalExcluded;
    if (earnedRewards <= rewardsExcluded) {
      return 0;
    }
    return earnedRewards - rewardsExcluded;
  }

  function beginningOfMonth(uint256 _timestamp) public pure returns (uint256) {
    (, , uint256 _dayOfMonth) = BokkyPooBahsDateTimeLibrary.timestampToDate(
      _timestamp
    );
    return
      _timestamp - ((_dayOfMonth - 1) * 24 * 60 * 60) - (_timestamp % 1 days);
  }

  function _cumulativeRewards(uint256 share) internal view returns (uint256) {
    return (share * rewardsPerShare) / MULTIPLIER;
  }

  function getShares(address user) external view override returns (uint256) {
    return shares[user].amount;
  }
}

Settings
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_baseTokenURI","type":"string"},{"internalType":"contract ISwapRouter","name":"__swapRouter","type":"address"},{"internalType":"contract IHyperbolicProtocol","name":"__hype","type":"address"},{"internalType":"contract ITwapUtils","name":"__twapUtils","type":"address"},{"internalType":"contract LendingRewards","name":"__lendingRewards","type":"address"},{"internalType":"address","name":"__WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountETH","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"DeleteLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountCollateral","type":"uint256"}],"name":"Deposit","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDesired","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountFees","type":"uint256"}],"name":"PayBackLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountCollateral","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amountETHBorrowing","type":"uint256"}],"name":"borrow","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"borrowAPRMax","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowAPRMin","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowInitFee","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountETHBorrowed","type":"uint256"},{"internalType":"uint256","name":"_aprStart","type":"uint256"}],"name":"calculateAPRFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateBorrowAPR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"checkUpkeep","outputs":[{"internalType":"bool","name":"upkeepNeeded","type":"bool"},{"internalType":"bytes","name":"performData","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"currentBorrowPerPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"custodian","outputs":[{"internalType":"contract LendingPoolTokenCustodian","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountDepositing","type":"uint256"},{"internalType":"uint256","name":"_amountETHBorrowing","type":"uint256"}],"name":"depositAndBorrow","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"enabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"externalLpFeePerc","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllWhitelistedPools","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"getETHBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLTVX96","outputs":[{"internalType":"uint256","name":"ltvX96","type":"uint256"},{"internalType":"uint256","name":"ltvWithFeesX96","type":"uint256"},{"internalType":"uint256","name":"amountETHDepositedX96","type":"uint256"},{"internalType":"uint256","name":"amountETHBorrowedX96","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hlp","outputs":[{"internalType":"contract HLP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidateDefaultCapital","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidateSlippage","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidationLTV","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"loanNFT","outputs":[{"internalType":"contract LoanToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loans","outputs":[{"internalType":"uint256","name":"created","type":"uint256"},{"internalType":"address","name":"createdBy","type":"address"},{"internalType":"uint256","name":"aprStart","type":"uint256"},{"internalType":"address","name":"collateralPool","type":"address"},{"internalType":"uint256","name":"amountDeposited","type":"uint256"},{"internalType":"uint256","name":"amountETHBorrowed","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxBorrowPerPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLTVOverall","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxLTVOverride","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLiquidationsPerUpkeep","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"payBackLoan","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"payBackLoanAndClose","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"performData","type":"bytes"}],"name":"performUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_apr","type":"uint32"}],"name":"setBorrowAPRMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_apr","type":"uint32"}],"name":"setBorrowAPRMin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_fee","type":"uint32"}],"name":"setBorrowInitFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_perc","type":"uint32"}],"name":"setExternalLpFeePerc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldLiq","type":"bool"}],"name":"setLiquidateDefaultCapital","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_slippage","type":"uint32"}],"name":"setLiquidateSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setLiquidationLTV","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountETH","type":"uint256"}],"name":"setMaxBorrowPerPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setMaxLTVOverall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setMaxLTVOverride","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_max","type":"uint32"}],"name":"setMaxLiquidationsPerUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"shouldLiquidateLoan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"name":"toggleWhitelistCollateralPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistPools","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040526601000000000000600155606462000020612710600a620004c4565b6200002c9190620004fb565b6002805462010000600160501b0319166201000063ffffffff939093169290920263ffffffff60301b191691909117660a0000000000001790556064620000776127106003620004c4565b620000839190620004fb565b600b805463ffffffff191663ffffffff929092169190911790556064620000ae6127106002620004c4565b620000ba9190620004fb565b600b805463ffffffff929092166401000000000263ffffffff60201b199092169190911790556064620000f1612710600f620004c4565b620000fd9190620004fb565b600b805463ffffffff92909216680100000000000000000263ffffffff60401b19909216919091179055606462000138612710605f620004c4565b620001449190620004fb565b600b805463ffffffff929092166c010000000000000000000000000263ffffffff60601b199092169190911790556064620001836127106032620004c4565b6200018f9190620004fb565b600b805463ffffffff92909216600160801b0263ffffffff60801b199092169190911790556064620001c5612710604b620004c4565b620001d19190620004fb565b6010805463ffffffff191663ffffffff92909216919091179055348015620001f857600080fd5b506040516200ae703803806200ae708339810160408190526200021b9162000586565b8585858585856200022c336200044a565b600780546001600160a01b038088166001600160a01b03199283161790925560048054878416908316811790915560068054878516908416179055600580548685169316929092179091559082166080526040516200028b906200049a565b6001600160a01b039091168152602001604051809103906000f080158015620002b8573d6000803e3d6000fd5b506002600a6101000a8154816001600160a01b0302191690836001600160a01b0316021790555085604051620002ee90620004a8565b620002fa91906200069c565b604051809103906000f08015801562000317573d6000803e3d6000fd5b50600380546001600160a01b0319166001600160a01b039290921691821790556040516303692a6d60e11b81523360048201526306d254da90602401600060405180830381600087803b1580156200036e57600080fd5b505af115801562000383573d6000803e3d6000fd5b505060035460405163f2fde38b60e01b81523360048201526001600160a01b03909116925063f2fde38b9150602401600060405180830381600087803b158015620003cd57600080fd5b505af1158015620003e2573d6000803e3d6000fd5b50505050505050505050604051620003fa90620004b6565b604051809103906000f08015801562000417573d6000803e3d6000fd5b50601060046101000a8154816001600160a01b0302191690836001600160a01b03160217905550505050505050620006d1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611692806200518b83390190565b61281e806200681d83390190565b611e35806200903b83390190565b63ffffffff818116838216028082169190828114620004f357634e487b7160e01b600052601160045260246000fd5b505092915050565b600063ffffffff808416806200052157634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200056057818101518382015260200162000546565b50506000910152565b80516001600160a01b03811681146200058157600080fd5b919050565b60008060008060008060c08789031215620005a057600080fd5b86516001600160401b0380821115620005b857600080fd5b818901915089601f830112620005cd57600080fd5b815181811115620005e257620005e26200052d565b604051601f8201601f19908116603f011681019083821181831017156200060d576200060d6200052d565b816040528281528c60208487010111156200062757600080fd5b6200063a83602083016020880162000543565b809a505050505050620006506020880162000569565b9450620006606040880162000569565b9350620006706060880162000569565b9250620006806080880162000569565b91506200069060a0880162000569565b90509295509295509295565b6020815260008251806020840152620006bd81604085016020870162000543565b601f01601f19169190910160400192915050565b608051614a5f6200072c60003960008181610ea301528181611178015281816111b301528181611dbc015281816127bc01528181612bab01528181612d0301528181612ec701528181612f5801526137880152614a5f6000f3fe6080604052600436106102cd5760003560e01c8063838122cf11610175578063b5df93f0116100dc578063d539c6d411610095578063e1ec3c681161006f578063e1ec3c6814610921578063f2c342c3146109b6578063f2fde38b146109e3578063f771183414610a0357600080fd5b8063d539c6d4146108af578063dfad7792146108e2578063e10e6bda1461090157600080fd5b8063b5df93f0146107e0578063bc157ac114610810578063c8092cf714610830578063ca593c5914610845578063cd08f9711461084d578063d45b62131461086f57600080fd5b8063930cf9731161012e578063930cf9731461072557806396e41e9e146107455780639d32a680146107655780639e4d5ddf14610785578063a4b3eb0b146107a9578063b2b8ec41146107bc57600080fd5b8063838122cf146106635780638470fc55146106835780638a05d5f9146106a35780638da5cb5b146106c35780638e6cce35146106e1578063921b2fb71461070157600080fd5b80633bb66a7b1161023457806367d4a3d3116101ed5780636e04ff0d116101c75780636e04ff0d146105f05780636faa8b3f1461061e5780636fea611114610631578063715018a61461064e57600080fd5b806367d4a3d31461057b5780636bc394d3146105a85780636bfeba53146105cc57600080fd5b80633bb66a7b146104b6578063441a3e70146104de5780634585e33b146104fe5780634e9865c71461051e578063528b1ed81461053e5780635bc7b7f31461055b57600080fd5b806323169a7b1161028657806323169a7b146103c6578063238dafe0146103e6578063328d8f721461041057806334a4117714610430578063375b74c3146104685780633a5684741461048f57600080fd5b8063051b4d07146102d9578063075ee2c8146102fb57806309fff9631461031b5780630a861f2a1461033b5780630ecbcdab1461035b5780631c57d3d31461038e57600080fd5b366102d457005b600080fd5b3480156102e557600080fd5b506102f96102f436600461410d565b610a23565b005b34801561030757600080fd5b506102f961031636600461410d565b610ac1565b34801561032757600080fd5b506102f9610336366004614146565b610b43565b34801561034757600080fd5b506102f9610356366004614172565b610b67565b34801561036757600080fd5b5061037b61037636600461418b565b610c86565b6040519081526020015b60405180910390f35b34801561039a57600080fd5b506002546103b19062010000900463ffffffff1681565b60405163ffffffff9091168152602001610385565b3480156103d257600080fd5b506102f96103e136600461410d565b610c9c565b3480156103f257600080fd5b506002546104009060ff1681565b6040519015158152602001610385565b34801561041c57600080fd5b506102f961042b3660046141bb565b610d0b565b34801561043c57600080fd5b50600354610450906001600160a01b031681565b6040516001600160a01b039091168152602001610385565b34801561047457600080fd5b5060025461045090600160501b90046001600160a01b031681565b34801561049b57600080fd5b5060105461045090600160201b90046001600160a01b031681565b3480156104c257600080fd5b5061037b6104d13660046141d8565b6001600160a01b03163190565b3480156104ea57600080fd5b506102f96104f936600461418b565b610d80565b34801561050a57600080fd5b506102f96105193660046141f5565b610d8b565b34801561052a57600080fd5b506102f961053936600461410d565b61106c565b34801561054a57600080fd5b506010546103b19063ffffffff1681565b34801561056757600080fd5b506102f96105763660046141d8565b61109d565b34801561058757600080fd5b5061037b6105963660046141d8565b600e6020526000908152604090205481565b3480156105b457600080fd5b50600b546103b190600160801b900463ffffffff1681565b3480156105d857600080fd5b506002546103b190600160301b900463ffffffff1681565b3480156105fc57600080fd5b5061061061060b3660046141f5565b611326565b6040516103859291906142b7565b6102f961062c366004614172565b6114d2565b34801561063d57600080fd5b50600b546103b19063ffffffff1681565b34801561065a57600080fd5b506102f96114e0565b34801561066f57600080fd5b5061037b61067e3660046142d2565b6114f4565b34801561068f57600080fd5b506102f961069e36600461430f565b61151a565b3480156106af57600080fd5b506104006106be366004614172565b6115a3565b3480156106cf57600080fd5b506000546001600160a01b0316610450565b3480156106ed57600080fd5b506102f96106fc36600461410d565b6115ae565b34801561070d57600080fd5b50600b546103b190600160601b900463ffffffff1681565b34801561073157600080fd5b506102f961074036600461410d565b61162a565b34801561075157600080fd5b506102f961076036600461410d565b6116b5565b34801561077157600080fd5b506102f96107803660046141bb565b611730565b34801561079157600080fd5b50600b546103b190600160201b900463ffffffff1681565b6102f96107b7366004614172565b6117a0565b3480156107c857600080fd5b50600b546103b190600160401b900463ffffffff1681565b3480156107ec57600080fd5b506104006107fb3660046141d8565b60086020526000908152604090205460ff1681565b34801561081c57600080fd5b506102f961082b366004614348565b611834565b34801561083c57600080fd5b5061037b611840565b6102f96119e8565b34801561085957600080fd5b50610862611a9e565b6040516103859190614380565b34801561087b57600080fd5b5061088f61088a366004614172565b611b00565b604080519485526020850193909352918301526060820152608001610385565b3480156108bb57600080fd5b506103b16108ca3660046141d8565b600c6020526000908152604090205463ffffffff1681565b3480156108ee57600080fd5b5060025461040090610100900460ff1681565b34801561090d57600080fd5b506102f961091c36600461410d565b611eca565b34801561092d57600080fd5b5061097d61093c366004614172565b600f6020526000908152604090208054600182015460028301546003840154600485015460059095015493946001600160a01b039384169492939091169186565b604080519687526001600160a01b03958616602088015286019390935292166060840152608083019190915260a082015260c001610385565b3480156109c257600080fd5b5061037b6109d13660046141d8565b600d6020526000908152604090205481565b3480156109ef57600080fd5b506102f96109fe3660046141d8565b611f31565b348015610a0f57600080fd5b5061037b610a1e36600461418b565b611fa7565b610a2b611fec565b6064610a3a612710600a6143e3565b610a449190614421565b63ffffffff168163ffffffff161115610a9a5760405162461bcd60e51b8152602060048201526013602482015272534554424150524d494e3a206c74652031302560681b60448201526064015b60405180910390fd5b600b805463ffffffff909216600160201b0267ffffffff0000000019909216919091179055565b610ac9611fec565b61271063ffffffff82161115610b185760405162461bcd60e51b8152602060048201526014602482015273534554424150524d41583a206c7465203130302560601b6044820152606401610a91565b600b805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055565b610b4b611fec565b6001600160a01b039091166000908152600e6020526040902055565b601054600160201b90046001600160a01b0316639dc29fac336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610bc857600080fd5b505af1158015610bdc573d6000803e3d6000fd5b505050506000610be93390565b6001600160a01b03168260405160006040518083038185875af1925050503d8060008114610c33576040519150601f19603f3d011682016040523d82523d6000602084013e610c38565b606091505b5050905080610c825760405162461bcd60e51b815260206004820152601660248201527515d2551211149055ce88115512081b9bdd081cd95b9d60521b6044820152606401610a91565b5050565b6000610c93338484612046565b90505b92915050565b610ca4611fec565b61271063ffffffff82161115610ce75760405162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b6044820152606401610a91565b6002805463ffffffff909216620100000265ffffffff000019909216919091179055565b610d13611fec565b60025481151560ff909116151503610d6d5760405162461bcd60e51b815260206004820152601760248201527f534554454e41424c45443a206d75737420746f67676c650000000000000000006044820152606401610a91565b6002805460ff1916911515919091179055565b610c8233838361252e565b6000610d99828401846144af565b905060005b8151811015611066576000828281518110610dbb57610dbb61453a565b6020026020010151905080600003610dd35750611066565b610ddc816129db565b15611053576000818152600f60209081526040808320815160c0810183528154815260018201546001600160a01b0390811682860152600283015482850152600383015416606082018190526004808401546080840181905260059094015460a08401528451630dfe168160e01b815294519296939591948593630dfe1681938284019390928290030181865afa158015610e7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9f9190614550565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031603610fc5576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3e9190614550565b6002546020870151604051633b6191dd60e01b8152929350600160501b9091046001600160a01b031691633b6191dd91610f8291859190899060019060040161456d565b600060405180830381600087803b158015610f9c57600080fd5b505af1158015610fb0573d6000803e3d6000fd5b50505050610fbf838287612a98565b50611045565b6002546020850151604051633b6191dd60e01b81528392600160501b90046001600160a01b031691633b6191dd91611006918591899060019060040161456d565b600060405180830381600087803b15801561102057600080fd5b505af1158015611034573d6000803e3d6000fd5b50505050611043838287612a98565b505b61104e85612ff8565b505050505b508061105e81614596565b915050610d9e565b50505050565b611074611fec565b6002805463ffffffff909216600160301b0269ffffffff00000000000019909216919091179055565b6110a5611fec565b60008190506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110e9190614550565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611150573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111749190614550565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614806111e757507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316145b6112285760405162461bcd60e51b81526020600482015260126024820152710a89e8e8e988a869e98987440dcde408aa8960731b6044820152606401610a91565b60408051600280825260608201835260009260208301908036833701905050905061012c8160008151811061125f5761125f61453a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061128e5761128e61453a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0385169063883bdbfd906112cf9084906004016145af565b600060405180830381865afa1580156112ec573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611314919081019061465c565b505061131f856130cb565b5050505050565b600060606000600360009054906101000a90046001600160a01b03166001600160a01b0316636800901a6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561137f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113a79190810190614728565b600254909150600090600160301b900463ffffffff1667ffffffffffffffff8111156113d5576113d5614444565b6040519080825280602002602001820160405280156113fe578160200160208202803683370190505b5090506000805b835181101561149e5760025463ffffffff600160301b9091048116908316101561149e57600084828151811061143d5761143d61453a565b60200260200101519050611450816129db565b1561148b576001965080848463ffffffff16815181106114725761147261453a565b602090810291909101015282611487816147ae565b9350505b508061149681614596565b915050611405565b5084156114c857816040516020016114b691906147d1565b60405160208183030381529060405293505b5050509250929050565b6114dd338234613250565b50565b6114e8611fec565b6114f26000613523565b565b600061150233868686613573565b945061150f338684612046565b90505b949350505050565b611522611fec565b61271063ffffffff821611156115705760405162461bcd60e51b81526020600482015260136024820152725345544c54564d41583a206c7465203130302560681b6044820152606401610a91565b6001600160a01b03919091166000908152600c60205260409020805463ffffffff191663ffffffff909216919091179055565b6000610c96826129db565b6115b6611fec565b61271063ffffffff821611156116045760405162461bcd60e51b81526020600482015260136024820152725345544c54564d41583a206c7465203130302560681b6044820152606401610a91565b600b805463ffffffff909216600160801b0263ffffffff60801b19909216919091179055565b611632611fec565b6064611641612710601e6143e3565b61164b9190614421565b63ffffffff168163ffffffff1611156116995760405162461bcd60e51b815260206004820152601060248201526f534554424645453a206c74652033302560801b6044820152606401610a91565b600b805463ffffffff191663ffffffff92909216919091179055565b6116bd611fec565b61271063ffffffff8216111561170a5760405162461bcd60e51b81526020600482015260126024820152715345544c504c54563a206c7465203130302560701b6044820152606401610a91565b600b805463ffffffff909216600160601b0263ffffffff60601b19909216919091179055565b611738611fec565b801515600260019054906101000a900460ff161515036117865760405162461bcd60e51b815260206004820152600960248201526829a2aa2624a8a222a360b91b6044820152606401610a91565b600280549115156101000261ff0019909216919091179055565b6000818152600f6020526040902060050154156117c7576117c2338234613250565b611815565b34156118155760405162461bcd60e51b815260206004820152601a60248201527f5041594241434b4c4f53453a206e6f20455448206e65656465640000000000006044820152606401610a91565b6000818152600f60205260409020600401546114dd903390839061252e565b61106633848484613573565b6000806000600460009054906101000a90046001600160a01b03166001600160a01b031663fb5ebf366040518163ffffffff1660e01b81526004016040805180830381865afa158015611897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118bb9190614809565b91509150600061271063ffffffff16600460009054906101000a90046001600160a01b03166001600160a01b0316637e3596996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611941919061482d565b6119519063ffffffff168461484a565b61195b9190614861565b9050808310156119d057600b546000908290859061198f9063ffffffff600160201b8204811691600160401b900416614875565b63ffffffff1661199f919061484a565b6119a99190614861565b600b549091506119c7908290600160401b900463ffffffff16614899565b94505050505090565b5050600b54600160201b900463ffffffff1692915050565b60003411611a2a5760405162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b6044820152606401610a91565b601054600160201b90046001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152346024820152604401600060405180830381600087803b158015611a8a57600080fd5b505af1158015611066573d6000803e3d6000fd5b60606009805480602002602001604051908101604052809291908181526020018280548015611af657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ad8575b5050505050905090565b60035460405163c3738f3f60e01b8152600481018390526000918291829182916001600160a01b039091169063c3738f3f90602401602060405180830381865afa158015611b52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7691906148ac565b611bc25760405162461bcd60e51b815260206004820152601760248201527f4745544c54563a206c6f616e206d7573742065786973740000000000000000006044820152606401610a91565b6000858152600f60209081526040808320815160c0810183528154815260018201546001600160a01b0390811694820194909452600282015492810183905260038201549093166060840152600481015460808401526005015460a08301819052919291611c2f91611fa7565b905081608001516000148015611c47575060a0820151155b15611c615760008060008095509550955095505050611ec3565b6006546060830151604051631ece4f9760e21b81526001600160a01b0391821660048201526000929190911690637b393e5c90602401602060405180830381865afa158015611cb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd89190614550565b6006546040516304e09a6160e41b81526001600160a01b03808416600483015292935060009290911690634e09a61090602401602060405180830381865afa158015611d28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4c91906148c9565b9050600084606001516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db69190614550565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614611e07576080860151611e02908461484a565b611e30565b82611e176002600160601b6149c6565b611e219190614861565b8660800151611e30919061484a565b90506000600160601b8760a00151611e48919061484a565b90506000600160601b878960a00151611e6191906149d5565b611e6b919061484a565b60015490915083611e7c828561484a565b611e869190614861565b611e90919061484a565b60015484611e9e828561484a565b611ea89190614861565b611eb2919061484a565b909c509a5091985096505050505050505b9193509193565b611ed2611fec565b61271063ffffffff82161115611f155760405162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b6044820152606401610a91565b6010805463ffffffff191663ffffffff92909216919091179055565b611f39611fec565b6001600160a01b038116611f9e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a91565b6114dd81613523565b60006301e1338061271084611fba611840565b611fc48642614899565b611fce919061484a565b611fd8919061484a565b611fe29190614861565b610c939190614861565b6000546001600160a01b031633146114f25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a91565b60025460009060ff166120915760405162461bcd60e51b81526020600482015260136024820152721093d49493d5ce881b9bdd08195b98589b1959606a1b6044820152606401610a91565b61209b8484613a95565b6000838152600f6020908152604080832060038101546001600160a01b0316845260089092529091205460ff166121075760405162461bcd60e51b815260206004820152601060248201526f1093d49493d5ce88189859081c1bdbdb60821b6044820152606401610a91565b600061211b82600501548360020154611fa7565b426002840155905060008061212f87611b00565b9350935050506000600160601b836121479190614861565b90506000612159600160601b84614861565b60038701546001600160a01b03166000908152600c60205260408120549192509063ffffffff166121b157600b54612710906121a290600160801b900463ffffffff168561484a565b6121ac9190614861565b6121ec565b60038701546001600160a01b03166000908152600c6020526040902054612710906121e29063ffffffff168561484a565b6121ec9190614861565b90508082106122355760405162461bcd60e51b8152602060048201526015602482015274424f52524f573a2063616e6e6f7420626f72726f7760581b6044820152606401610a91565b806122408a846149d5565b1115612253576122508282614899565b98505b884710156122a35760405162461bcd60e51b815260206004820152601860248201527f424f52524f573a206e6f7420656e6f7567682066756e647300000000000000006044820152606401610a91565b60038701546001600160a01b03166000908152600e6020526040902054156123475760038701546001600160a01b03166000908152600e6020908152604080832054600d909252909120546122f9908b906149d5565b11156123475760405162461bcd60e51b815260206004820152601860248201527f424f52524f573a206578636565647320706f6f6c206d617800000000000000006044820152606401610a91565b60038701546001600160a01b03166000908152600d6020526040812080548b92906123739084906149d5565b925050819055508887600501600082825461238e91906149d5565b9091555050600b54600090612710906123ad9063ffffffff168c61484a565b6123b79190614861565b6123c190886149d5565b9050808a1161241e5760405162461bcd60e51b8152602060048201526024808201527f424f52524f573a2066656573206d6f7265207468616e20626f72726f7720616d6044820152631bdd5b9d60e21b6064820152608401610a91565b600061242a828c614899565b905061243582613b52565b60008d6001600160a01b03168260405160006040518083038185875af1925050503d8060008114612482576040519150601f19603f3d011682016040523d82523d6000602084013e612487565b606091505b50509050806124d85760405162461bcd60e51b815260206004820152601960248201527f424f52524f573a20455448206e6f742064656c697665726564000000000000006044820152606401610a91565b8c8e6001600160a01b03167fe1979fe4c35e0cef342fef5668e2c8e7a7e9f5d5d1ca8fee0ac6c427fa4153af8e60405161251491815260200190565b60405180910390a3509a9c9b505050505050505050505050565b600081116125885760405162461bcd60e51b815260206004820152602160248201527f57495448445241573a206d7573742077697468647261772066726f6d206c6f616044820152603760f91b6064820152608401610a91565b6125928383613a95565b6000828152600f6020526040902060048101548211156125e95760405162461bcd60e51b81526020600482015260126024820152710ae92a89088a482ae7440e8dede40daeac6d60731b6044820152606401610a91565b818160040160008282546125fd9190614899565b909155506000905061260e84611b00565b505060038401546001600160a01b03166000908152600c602052604090205490925063ffffffff161590506126cc5760038201546001600160a01b03166000908152600c6020526040902054612710906126729063ffffffff16600160601b61484a565b61267c9190614861565b8111156126c75760405162461bcd60e51b81526020600482015260196024820152782ba4aa24222920ab9d1032bc31b2b2b2399036b0bc10262a2b60391b6044820152606401610a91565b612743565b600b54612710906126ee90600160801b900463ffffffff16600160601b61484a565b6126f89190614861565b8111156127435760405162461bcd60e51b81526020600482015260196024820152782ba4aa24222920ab9d1032bc31b2b2b2399036b0bc10262a2b60391b6044820152606401610a91565b600382015460408051630dfe168160e01b815290516001600160a01b03909216916000918391630dfe1681916004808201926020929091908290030181865afa158015612794573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b89190614550565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316036128eb576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612833573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128579190614550565b600254600180880154604051633b6191dd60e01b81529394506001600160a01b03600160501b909304831693633b6191dd9361289e938793909116918c919060040161456d565b600060405180830381600087803b1580156128b857600080fd5b505af11580156128cc573d6000803e3d6000fd5b506128e5925050506001600160a01b0382168988613cd1565b50612979565b600254600185810154604051633b6191dd60e01b81528493600160501b90046001600160a01b0390811693633b6191dd93612930938793909116918c9160040161456d565b600060405180830381600087803b15801561294a57600080fd5b505af115801561295e573d6000803e3d6000fd5b50612977925050506001600160a01b0382168988613cd1565b505b836004015460000361298e5761298e86612ff8565b85876001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568876040516129ca91815260200190565b60405180910390a350505050505050565b60035460405163c3738f3f60e01b8152600481018390526000916001600160a01b03169063c3738f3f90602401602060405180830381865afa158015612a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4991906148ac565b612a5557506000919050565b6000612a6083611b00565b5050600b549092506127109150612a8690600160601b9081900463ffffffff169061484a565b612a909190614861565b111592915050565b600254610100900460ff168015612abd57506004546001600160a01b03838116911614155b15612fc857600654604051631ece4f9760e21b81526001600160a01b0385811660048301526000921690637b393e5c90602401602060405180830381865afa158015612b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b319190614550565b6006546040516304e09a6160e41b81526001600160a01b03808416600483015292935060009290911690634e09a61090602401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba591906148c9565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c359190614550565b6001600160a01b031614612c625781612c536002600160601b6149c6565b612c5d9190614861565b612c64565b815b90506000600160601b856080015183612c7d919061484a565b612c879190614861565b905060008560a001518211612ca0578560a00151612ca2565b815b6007546080880151919250612cc29189916001600160a01b031690613d34565b600760009054906101000a90046001600160a01b03166001600160a01b031663414bf3896040518061010001604052808a6001600160a01b031681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018b6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9291906149e8565b62ffffff1681523060208201524260408201526080808b0151606083015260025491019061271090612dd09062010000900463ffffffff1682614875565b612de09063ffffffff168761484a565b612dea9190614861565b815260006020918201526040805160e085811b6001600160e01b031916825284516001600160a01b03908116600484015293850151841660248301529184015162ffffff1660448201526060840151831660648201526080840151608482015260a084015160a482015260c084015160c48201529201511660e4820152610104016020604051808303816000875af1158015612e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eae91906148c9565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015612f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3a91906148c9565b90508015612fbd57604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015612fa457600080fd5b505af1158015612fb8573d6000803e3d6000fd5b505050505b505050505050505050565b612ff3612fdd6000546001600160a01b031690565b60808301516001600160a01b0385169190613cd1565b505050565b6000818152600f60205260408082208281556001810180546001600160a01b03199081169091556002820184905560038083018054909216909155600480830185905560059092019390935591549051630852cd8d60e31b81529182018390526001600160a01b0316906342966c6890602401600060405180830381600087803b15801561308557600080fd5b505af1158015613099573d6000803e3d6000fd5b50506040518392507f40e7dd78d661cb2192925e6eeecc3f99eb4f3e7457c18ea57ddd84cd051d01f39150600090a250565b6001600160a01b03811660009081526008602052604090205460ff16156131dd576001600160a01b0381166000908152600a60205260408120546009805491929161311890600190614899565b815481106131285761312861453a565b600091825260209091200154600980546001600160a01b0390921692508291849081106131575761315761453a565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790558383168252600a8152604080832086905592861682526008905220805460ff1916905560098054806131b3576131b3614a0d565b600082815260209020810160001990810180546001600160a01b0319169055019055506114dd9050565b6001600160a01b03166000818152600860209081526040808320805460ff1916600190811790915560098054600a909452918420839055820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319169091179055565b600081116132a05760405162461bcd60e51b815260206004820152601b60248201527f5041594241434b3a206e6f2045544820746f20706179206261636b00000000006044820152606401610a91565b6132aa8383613a95565b6000828152600f60205260408120600581015460028201549192916132cf9190611fa7565b42600284015590508083116133305760405162461bcd60e51b815260206004820152602160248201527f5041594241434b3a206d75737420706179206261636b2061626f7665206665656044820152607360f81b6064820152608401610a91565b600081836005015461334291906149d5565b905060008185111561335b576133588286614899565b90505b60038401546001600160a01b03166000908152600d60205260409020546133828487614899565b11613396576133918386614899565b6133b4565b60038401546001600160a01b03166000908152600d60205260409020545b60038501546001600160a01b03166000908152600d6020526040812080549091906133e0908490614899565b909155505060058401546133f48487614899565b11613408576134038386614899565b61340e565b83600501545b8460050160008282546134219190614899565b909155505082156134355761343583613b52565b80156134e0576000876001600160a01b03168260405160006040518083038185875af1925050503d8060008114613488576040519150601f19603f3d011682016040523d82523d6000602084013e61348d565b606091505b50509050806134de5760405162461bcd60e51b815260206004820152601c60248201527f5041594241434b3a20726566756e6420756e7375636365737366756c000000006044820152606401610a91565b505b604080518681526020810185905287916001600160a01b038a16917fca92b037c5d17af773d2a576cd91e713e64b80af7c561456d811d12fc927960091016129ca565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460009060ff166135bf5760405162461bcd60e51b815260206004820152601460248201527311115413d4d2550e881b9bdd08195b98589b195960621b6044820152606401610a91565b60006135cb8686613e2d565b506000818152600f602052604081206003810154929750879350916001600160a01b0316613694576001600160a01b03861660009081526008602052604090205460ff166136505760405162461bcd60e51b815260206004820152601260248201527104445504f5349543a2062616420706f6f6c360741b6044820152606401610a91565b50428082556001820180546001600160a01b03808b166001600160a01b03199283161790925560028401929092556003830180549188169190921617905584613705565b60038201546001600160a01b031660009081526008602052604090205460ff166136f55760405162461bcd60e51b81526020600482015260126024820152714445504f5349543a2062616420706f6f6c3160701b6044820152606401610a91565b5060038101546001600160a01b03165b8482600401600082825461371991906149d5565b925050819055506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015613760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137849190614550565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031603613936576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138239190614550565b905061383a6001600160a01b0382168b308a613ecb565b60025460405163095ea7b360e01b8152600160501b9091046001600160a01b0390811660048301526024820189905282169063095ea7b3906044016020604051808303816000875af1158015613894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b891906148ac565b506002546001850154604051633b6191dd60e01b8152600160501b9092046001600160a01b0390811692633b6191dd926138fe9286929116908c9060009060040161456d565b600060405180830381600087803b15801561391857600080fd5b505af115801561392c573d6000803e3d6000fd5b5050505050613a44565b8061394c6001600160a01b0382168b308a613ecb565b60025460405163095ea7b360e01b8152600160501b9091046001600160a01b0390811660048301526024820189905282169063095ea7b3906044016020604051808303816000875af11580156139a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ca91906148ac565b506002546001850154604051633b6191dd60e01b8152600160501b9092046001600160a01b0390811692633b6191dd92613a109286929116908c9060009060040161456d565b600060405180830381600087803b158015613a2a57600080fd5b505af1158015613a3e573d6000803e3d6000fd5b50505050505b87896001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051613a8091815260200190565b60405180910390a35095979650505050505050565b6003546040516331a9108f60e11b8152600481018390526001600160a01b0390911690636352211e90602401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b029190614550565b6001600160a01b0316826001600160a01b031614610c825760405162461bcd60e51b815260206004820152600d60248201526c2b20a624a220aa22a7aba722a960991b6044820152606401610a91565b60105460009061271090613b6c9063ffffffff168461484a565b613b769190614861565b90506000613b848284614899565b90508115613c5d576000601060049054906101000a90046001600160a01b03166001600160a01b031663ac5da9526040518163ffffffff1660e01b8152600401602060405180830381865afa158015613be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c059190614550565b9050806001600160a01b031663152111f7846040518263ffffffff1660e01b81526004016000604051808303818588803b158015613c4257600080fd5b505af1158015613c56573d6000803e3d6000fd5b5050505050505b8015612ff357600560009054906101000a90046001600160a01b03166001600160a01b031663152111f7826040518263ffffffff1660e01b81526004016000604051808303818588803b158015613cb357600080fd5b505af1158015613cc7573d6000803e3d6000fd5b5050505050505050565b6040516001600160a01b038316602482015260448101829052612ff390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613f03565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691613d909190614a23565b6000604051808303816000865af19150503d8060008114613dcd576040519150601f19603f3d011682016040523d82523d6000602084013e613dd2565b606091505b5091509150818015613dfc575080511580613dfc575080806020019051810190613dfc91906148ac565b61131f5760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401610a91565b60008082600003613eb3576003546040516335313c2160e11b81526001600160a01b03868116600483015290911690636a627842906024016020604051808303816000875af1158015613e84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea891906148c9565b915060019050613ec4565b613ebd8484613a95565b5081905060005b9250929050565b6040516001600160a01b03808516602483015283166044820152606481018290526110669085906323b872dd60e01b90608401613cfd565b6000613f58826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613fd89092919063ffffffff16565b9050805160001480613f79575080806020019051810190613f7991906148ac565b612ff35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a91565b6060611512848460008585600080866001600160a01b03168587604051613fff9190614a23565b60006040518083038185875af1925050503d806000811461403c576040519150601f19603f3d011682016040523d82523d6000602084013e614041565b606091505b50915091506140528783838761405d565b979650505050505050565b606083156140cc5782516000036140c5576001600160a01b0385163b6140c55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a91565b5081611512565b61151283838151156140e15781518083602001fd5b8060405162461bcd60e51b8152600401610a919190614a3f565b63ffffffff811681146114dd57600080fd5b60006020828403121561411f57600080fd5b813561412a816140fb565b9392505050565b6001600160a01b03811681146114dd57600080fd5b6000806040838503121561415957600080fd5b823561416481614131565b946020939093013593505050565b60006020828403121561418457600080fd5b5035919050565b6000806040838503121561419e57600080fd5b50508035926020909101359150565b80151581146114dd57600080fd5b6000602082840312156141cd57600080fd5b813561412a816141ad565b6000602082840312156141ea57600080fd5b813561412a81614131565b6000806020838503121561420857600080fd5b823567ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81358181111561424357600080fd5b86602082850101111561425557600080fd5b60209290920196919550909350505050565b60005b8381101561428257818101518382015260200161426a565b50506000910152565b600081518084526142a3816020860160208601614267565b601f01601f19169290920160200192915050565b8215158152604060208201526000611512604083018461428b565b600080600080608085870312156142e857600080fd5b8435935060208501356142fa81614131565b93969395505050506040820135916060013590565b6000806040838503121561432257600080fd5b823561432d81614131565b9150602083013561433d816140fb565b809150509250929050565b60008060006060848603121561435d57600080fd5b83359250602084013561436f81614131565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156143c15783516001600160a01b03168352928401929184019160010161439c565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b63ffffffff818116838216028082169190828114614403576144036143cd565b505092915050565b634e487b7160e01b600052601260045260246000fd5b600063ffffffff808416806144385761443861440b565b92169190910492915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561448357614483614444565b604052919050565b600067ffffffffffffffff8211156144a5576144a5614444565b5060051b60200190565b600060208083850312156144c257600080fd5b823567ffffffffffffffff8111156144d957600080fd5b8301601f810185136144ea57600080fd5b80356144fd6144f88261448b565b61445a565b81815260059190911b8201830190838101908783111561451c57600080fd5b928401925b8284101561405257833582529284019290840190614521565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561456257600080fd5b815161412a81614131565b6001600160a01b0394851681529290931660208301526040820152901515606082015260800190565b6000600182016145a8576145a86143cd565b5060010190565b6020808252825182820181905260009190848201906040850190845b818110156143c157835163ffffffff16835292840192918401916001016145cb565b600082601f8301126145fe57600080fd5b8151602061460e6144f88361448b565b82815260059290921b8401810191818101908684111561462d57600080fd5b8286015b8481101561465157805161464481614131565b8352918301918301614631565b509695505050505050565b6000806040838503121561466f57600080fd5b825167ffffffffffffffff8082111561468757600080fd5b818501915085601f83011261469b57600080fd5b815160206146ab6144f88361448b565b82815260059290921b840181019181810190898411156146ca57600080fd5b948201945b838610156146f85785518060060b81146146e95760008081fd5b825294820194908201906146cf565b9188015191965090935050508082111561471157600080fd5b5061471e858286016145ed565b9150509250929050565b6000602080838503121561473b57600080fd5b825167ffffffffffffffff81111561475257600080fd5b8301601f8101851361476357600080fd5b80516147716144f88261448b565b81815260059190911b8201830190838101908783111561479057600080fd5b928401925b8284101561405257835182529284019290840190614795565b600063ffffffff8083168181036147c7576147c76143cd565b6001019392505050565b6020808252825182820181905260009190848201906040850190845b818110156143c1578351835292840192918401916001016147ed565b6000806040838503121561481c57600080fd5b505080516020909101519092909150565b60006020828403121561483f57600080fd5b815161412a816140fb565b8082028115828204841417610c9657610c966143cd565b6000826148705761487061440b565b500490565b63ffffffff828116828216039080821115614892576148926143cd565b5092915050565b81810381811115610c9657610c966143cd565b6000602082840312156148be57600080fd5b815161412a816141ad565b6000602082840312156148db57600080fd5b5051919050565b600181815b8085111561491d578160001904821115614903576149036143cd565b8085161561491057918102915b93841c93908002906148e7565b509250929050565b60008261493457506001610c96565b8161494157506000610c96565b816001811461495757600281146149615761497d565b6001915050610c96565b60ff841115614972576149726143cd565b50506001821b610c96565b5060208310610133831016604e8410600b84101617156149a0575081810a610c96565b6149aa83836148e2565b80600019048211156149be576149be6143cd565b029392505050565b6000610c9360ff841683614925565b80820180821115610c9657610c966143cd565b6000602082840312156149fa57600080fd5b815162ffffff8116811461412a57600080fd5b634e487b7160e01b600052603160045260246000fd5b60008251614a35818460208701614267565b9190910192915050565b602081526000610c93602083018461428b56fea164736f6c6343000813000a608060405234801561001057600080fd5b5060405161169238038061169283398101604081905261002f916100bd565b806100393361006d565b600180546001600160a01b039283166001600160a01b031991821617909155600a80549390921692169190911790556100ed565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100cf57600080fd5b81516001600160a01b03811681146100e657600080fd5b9392505050565b611596806100fc6000396000f3fe6080604052600436106101185760003560e01c806380bb4055116100a0578063d076eabc11610064578063d076eabc14610413578063efca2eed14610433578063f04da65b14610449578063f2fde38b1461047f578063fc0c546a1461049f57600080fd5b806380bb40551461039457806389d96917146103aa5780638da5cb5b146103ca578063b88a802f146103e8578063c7e1d0b1146103fd57600080fd5b806329cc05cf116100e757806329cc05cf146102f15780633b6191dd146103115780633c6e6789146103315780636ecf9f7b14610347578063715018a61461037f57600080fd5b8063058df06d1461024a5780630700037d1461028a5780630e15561a146102d3578063152111f7146102e957600080fd5b3661024557600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018a9190611284565b9050801561019d5761019b346104bf565b005b600080546040516001600160a01b039091169034908381818185875af1925050503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b505090508061019b5760405162461bcd60e51b815260206004820152601e60248201527f524543454956453a20646964206e6f742073656e6420746f206f776e6572000060448201526064015b60405180910390fd5b600080fd5b34801561025657600080fd5b5061027761026536600461129d565b60096020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561029657600080fd5b506102be6102a53660046112cb565b6005602052600090815260409020805460019091015482565b60408051928352602083019190915201610281565b3480156102df57600080fd5b5061027760085481565b61019b61060a565b3480156102fd57600080fd5b5061019b61030c3660046112f6565b610615565b34801561031d57600080fd5b5061019b61032c366004611338565b61066b565b34801561033d57600080fd5b5061027760035481565b34801561035357600080fd5b50600a54610367906001600160a01b031681565b6040516001600160a01b039091168152602001610281565b34801561038b57600080fd5b5061019b6106ce565b3480156103a057600080fd5b5061027760025481565b3480156103b657600080fd5b506102776103c53660046112cb565b6106e0565b3480156103d657600080fd5b506000546001600160a01b0316610367565b3480156103f457600080fd5b5061019b610768565b34801561040957600080fd5b5061027760065481565b34801561041f57600080fd5b5061027761042e36600461129d565b6107a6565b34801561043f57600080fd5b5061027760075481565b34801561045557600080fd5b506102776104643660046112cb565b6001600160a01b031660009081526004602052604090205490565b34801561048b57600080fd5b5061019b61049a3660046112cb565b61080c565b3480156104ab57600080fd5b50600154610367906001600160a01b031681565b600081116105015760405162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b604482015260640161023c565b6000600354116105485760405162461bcd60e51b81526020600482015260126024820152714445504f5349543a206e6f2073686172657360701b604482015260640161023c565b806008600082825461055a91906113a1565b909155506000905061056b426107a6565b90508160096000838152602001908152602001600020600082825461059091906113a1565b90915550506003546105b1836ec097ce7bc90715b34b9f10000000006113b4565b6105bb91906113e1565b600660008282546105cc91906113a1565b909155505060405182815233907fb9ad861b752f80117b35bea6dec99933d8a5ae360f2839ee8784b750d56134099060200160405180910390a25050565b610613346104bf565b565b6001546001600160a01b0316331461065b5760405162461bcd60e51b815260206004820152600960248201526827a7262caa27a5a2a760b91b604482015260640161023c565b610666838383610885565b505050565b610673610922565b80156106925761068d6001600160a01b038516338461097c565b6106a7565b6106a76001600160a01b0385163330856109df565b600a546001600160a01b03908116908516036106c8576106c8838383610885565b50505050565b6106d6610922565b6106136000610a17565b6001600160a01b038116600090815260046020526040812054810361070757506000919050565b6001600160a01b03821660009081526004602052604081205461072990610a67565b6001600160a01b038416600090815260056020526040902054909150808211610756575060009392505050565b61076081836113f5565b949350505050565b61077133610a97565b6040513381527f63e32091e4445d16e29c33a6b264577c2d86694021aa4e6f4dd590048f5792e89060200160405180910390a1565b6000806107b283610c88565b9250505062015180836107c59190611408565b6107d06001836113f5565b6107db9060186113b4565b6107e690603c6113b4565b6107f190603c6113b4565b6107fb90856113f5565b61080591906113f5565b9392505050565b610814610922565b6001600160a01b0381166108795760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161023c565b61088281610a17565b50565b80156108dd576108958383610cae565b826001600160a01b03167fae0577e1c96b26fbc0b9df702431f5470979d001d24f136eded791b8b6521d6f836040516108d091815260200190565b60405180910390a2505050565b6108e78383610df1565b826001600160a01b03167fba8f3777cf908803bf1f3dd58e7f4b7d3de4dbe3c234c4ccab0975d98f7cd388836040516108d091815260200190565b6000546001600160a01b031633146106135760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161023c565b6040516001600160a01b03831660248201526044810182905261066690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610f18565b6040516001600160a01b03808516602483015283166044820152606481018290526106c89085906323b872dd60e01b906084016109a8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006ec097ce7bc90715b34b9f100000000060065483610a8791906113b4565b610a9191906113e1565b92915050565b6001600160a01b0381166000908152600460205260408120549003610ab95750565b6000610ac4826106e0565b6001600160a01b038316600090815260056020526040812060010180549293508392909190610af49084906113a1565b90915550506001600160a01b038216600090815260046020526040902054610b1b90610a67565b6001600160a01b0383166000908152600560205260409020558015610c84578060076000828254610b4c91906113a1565b909155505060405147906000906001600160a01b0385169084908381818185875af1925050503d8060008114610b9e576040519150601f19603f3d011682016040523d82523d6000602084013e610ba3565b606091505b5050905080610bf45760405162461bcd60e51b815260206004820152601a60248201527f444953543a20636f756c64206e6f742064697374726962757465000000000000604482015260640161023c565b610bfe83836113f5565b471015610c3e5760405162461bcd60e51b815260206004820152600e60248201526d08892a6a87440e8dede40daeac6d60931b604482015260640161023c565b836001600160a01b03167fe8b160e373db99a103e0a2abfa029b9c3fc8b328984a1ead8a65ae68ae646db784604051610c7991815260200190565b60405180910390a250505b5050565b60008080610ca1610c9c62015180866113e1565b610fed565b9196909550909350915050565b6001600160a01b03821660009081526004602052604090205415801590610ced57506001600160a01b0382166000908152600460205260409020548111155b610d2d5760405162461bcd60e51b815260206004820152601160248201527052454d4f56453a206e6f2073686172657360781b604482015260640161023c565b610d3682610a97565b8060036000828254610d4891906113f5565b90915550506001600160a01b03821660009081526004602052604081208054839290610d759084906113f5565b90915550506001600160a01b0382166000908152600460205260408120549003610daf5760028054906000610da98361141c565b91905055505b6001600160a01b038216600090815260046020526040902054610dd190610a67565b6001600160a01b0390921660009081526005602052604090209190915550565b6001600160a01b03821660009081526004602052604090205415610e1857610e1882610a97565b6001600160a01b0382166000908152600460205260408120546003805491928492610e449084906113a1565b90915550506001600160a01b03831660009081526004602052604081208054849290610e719084906113a1565b90915550506001600160a01b03831660009081526004602052604090204260019091015580158015610eba57506001600160a01b03831660009081526004602052604090205415155b15610ed55760028054906000610ecf83611433565b91905055505b6001600160a01b038316600090815260046020526040902054610ef790610a67565b6001600160a01b039093166000908152600560205260409020929092555050565b6000610f6d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111619092919063ffffffff16565b9050805160001480610f8e575080806020019051810190610f8e919061144c565b6106665760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161023c565b60008080838162253d8c6110048362010bd9611469565b61100e9190611469565b9050600062023ab1611021836004611491565b61102b91906114c1565b9050600461103c8262023ab1611491565b611047906003611469565b61105191906114c1565b61105b90836114ef565b9150600062164b0961106e846001611469565b61107a90610fa0611491565b61108491906114c1565b90506004611094826105b5611491565b61109e91906114c1565b6110a890846114ef565b6110b390601f611469565b9250600061098f6110c5856050611491565b6110cf91906114c1565b9050600060506110e18361098f611491565b6110eb91906114c1565b6110f590866114ef565b9050611102600b836114c1565b945061110f85600c611491565b61111a836002611469565b61112491906114ef565b915084836111336031876114ef565b61113e906064611491565b6111489190611469565b6111529190611469565b9a919950975095505050505050565b6060610760848460008585600080866001600160a01b03168587604051611188919061153a565b60006040518083038185875af1925050503d80600081146111c5576040519150601f19603f3d011682016040523d82523d6000602084013e6111ca565b606091505b50915091506111db878383876111e6565b979650505050505050565b6060831561125557825160000361124e576001600160a01b0385163b61124e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161023c565b5081610760565b610760838381511561126a5781518083602001fd5b8060405162461bcd60e51b815260040161023c9190611556565b60006020828403121561129657600080fd5b5051919050565b6000602082840312156112af57600080fd5b5035919050565b6001600160a01b038116811461088257600080fd5b6000602082840312156112dd57600080fd5b8135610805816112b6565b801515811461088257600080fd5b60008060006060848603121561130b57600080fd5b8335611316816112b6565b925060208401359150604084013561132d816112e8565b809150509250925092565b6000806000806080858703121561134e57600080fd5b8435611359816112b6565b93506020850135611369816112b6565b9250604085013591506060850135611380816112e8565b939692955090935050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610a9157610a9161138b565b8082028115828204841417610a9157610a9161138b565b634e487b7160e01b600052601260045260246000fd5b6000826113f0576113f06113cb565b500490565b81810381811115610a9157610a9161138b565b600082611417576114176113cb565b500690565b60008161142b5761142b61138b565b506000190190565b6000600182016114455761144561138b565b5060010190565b60006020828403121561145e57600080fd5b8151610805816112e8565b80820182811260008312801582168215821617156114895761148961138b565b505092915050565b80820260008212600160ff1b841416156114ad576114ad61138b565b8181058314821517610a9157610a9161138b565b6000826114d0576114d06113cb565b600160ff1b8214600019841416156114ea576114ea61138b565b500590565b818103600083128015838313168383128216171561150f5761150f61138b565b5092915050565b60005b83811015611531578181015183820152602001611519565b50506000910152565b6000825161154c818460208701611516565b9190910192915050565b6020815260008251806020840152611575816040850160208701611516565b601f01601f1916919091016040019291505056fea164736f6c6343000813000a60806040526032600f553480156200001657600080fd5b506040516200281e3803806200281e83398101604081905262000039916200015e565b6040518060400160405280601881526020017f4879706572626f6c69632050726f746f636f6c204c6f616e0000000000000000815250604051806040016040528060058152602001646c4859504560d81b81525081600090816200009e9190620002c2565b506001620000ad8282620002c2565b505050620000ca620000c4620000f260201b60201c565b620000f6565b600d620000d88282620002c2565b5050600b80546001600160a01b031916331790556200038e565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200017257600080fd5b82516001600160401b03808211156200018a57600080fd5b818501915085601f8301126200019f57600080fd5b815181811115620001b457620001b462000148565b604051601f8201601f19908116603f01168101908382118183101715620001df57620001df62000148565b816040528281528886848701011115620001f857600080fd5b600093505b828410156200021c5784840186015181850187015292850192620001fd565b600086848301015280965050505050505092915050565b600181811c908216806200024857607f821691505b6020821081036200026957634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002bd57600081815260208120601f850160051c81016020861015620002985750805b601f850160051c820191505b81811015620002b957828155600101620002a4565b5050505b505050565b81516001600160401b03811115620002de57620002de62000148565b620002f681620002ef845462000233565b846200026f565b602080601f8311600181146200032e5760008415620003155750858301515b600019600386901b1c1916600185901b178555620002b9565b600085815260208120601f198616915b828110156200035f578886015182559484019460019091019084016200033e565b50858210156200037e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b612480806200039e6000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c80636800901a11610125578063ad2f852a116100ad578063c87b56dd1161007c578063c87b56dd1461048b578063e8a3d4851461049e578063e985e9c5146104a6578063f2fde38b146104e2578063ffa80136146104f557600080fd5b8063ad2f852a1461043f578063b6b8194014610452578063b88d4fde14610465578063c3738f3f1461047857600080fd5b80637974e46a116100f45780637974e46a146103f85780638da5cb5b1461040057806395d89b4114610411578063a22cb46514610419578063a59a99731461042c57600080fd5b80636800901a146103b55780636a627842146103ca57806370a08231146103dd578063715018a6146103f057600080fd5b806323b872dd116101a857806342842e0e1161017757806342842e0e1461035657806342966c68146103695780634f6ccce71461037c57806355f804b31461038f5780636352211e146103a257600080fd5b806323b872dd146102de578063274de61e146102f15780632a55205a146103115780632f745c591461034357600080fd5b8063095ea7b3116101e4578063095ea7b314610293578063113aa8b1146102a657806318160ddd146102b957806320e3fa50146102cb57600080fd5b806301ffc9a71461021657806306d254da1461023e57806306fdde0314610253578063081812fc14610268575b600080fd5b610229610224366004611d75565b610508565b60405190151581526020015b60405180910390f35b61025161024c366004611db0565b610519565b005b61025b61056b565b6040516102359190611e1b565b61027b610276366004611e2e565b6105fd565b6040516001600160a01b039091168152602001610235565b6102516102a1366004611e47565b610624565b6102516102b4366004611db0565b61073e565b6008545b604051908152602001610235565b6102bd6102d9366004611e47565b610768565b6102516102ec366004611e71565b610799565b6102bd6102ff366004611e2e565b60136020526000908152604090205481565b61032461031f366004611ead565b6107ca565b604080516001600160a01b039093168352602083019190915201610235565b6102bd610351366004611e47565b610804565b610251610364366004611e71565b61089a565b610251610377366004611e2e565b6108b5565b6102bd61038a366004611e2e565b610963565b61025161039d366004611f5b565b6109f6565b61027b6103b0366004611e2e565b610a4c565b6103bd610aac565b6040516102359190611fa4565b6102bd6103d8366004611db0565b610b03565b6102bd6103eb366004611db0565b610bbb565b610251610c41565b6102bd610c55565b600a546001600160a01b031661027b565b61025b610c65565b610251610427366004611fe8565b610c74565b600b5461027b906001600160a01b031681565b600e5461027b906001600160a01b031681565b610251610460366004611e2e565b610c83565b610251610473366004612024565b610cbe565b610229610486366004611e2e565b610cf6565b61025b610499366004611e2e565b610d01565b61025b610d4d565b6102296104b43660046120a0565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102516104f0366004611db0565b610d7b565b6103bd610503366004611db0565b610df4565b600061051382610e60565b92915050565b610521610e85565b600e80546001600160a01b0319166001600160a01b0383169081179091556040517f0f2a87e68f9d4311c1d18e960f7873198e70403a037237cdd2c583c69cdddf1f90600090a250565b60606000805461057a906120d3565b80601f01602080910402602001604051908101604052809291908181526020018280546105a6906120d3565b80156105f35780601f106105c8576101008083540402835291602001916105f3565b820191906000526020600020905b8154815290600101906020018083116105d657829003601f168201915b5050505050905090565b600061060882610edf565b506000908152600460205260409020546001600160a01b031690565b600061062f82610a4c565b9050806001600160a01b0316836001600160a01b0316036106a15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806106bd57506106bd81336104b4565b61072f5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610698565b6107398383610f2f565b505050565b610746610e85565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6012602052816000526040600020818154811061078457600080fd5b90600052602060002001600091509150505481565b6107a33382610f9d565b6107bf5760405162461bcd60e51b81526004016106989061210d565b61073983838361101c565b600e54600f5460009182916001600160a01b03909116906103e8906107ef9086612170565b6107f99190612187565b915091509250929050565b600061080f83610bbb565b82106108715760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610698565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61073983838360405180602001604052806000815250610cbe565b600b546001600160a01b031633146109015760405162461bcd60e51b815260206004820152600f60248201526e13d3931653115391125391d413d3d3608a1b6044820152606401610698565b600061090c82610a4c565b905061091782611032565b61092057600080fd5b6109298261104f565b6040516001600160a01b0382169083907ff6554c3a5d28e08c120b5a69c7edbaf52f935bd2596a60b8a18e282cd257cddb90600090a35050565b600061096e60085490565b82106109d15760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610698565b600882815481106109e4576109e46121a9565b90600052602060002001549050919050565b6109fe610e85565b600d610a0a828261220d565b5080604051610a1991906122cd565b604051908190038120907f199e933997358e1789d8b56ea8c551befeb05ce2fe3fe506199f1230f5a591b490600090a250565b6000818152600260205260408120546001600160a01b0316806105135760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610698565b606060108054806020026020016040519081016040528092919081815260200182805480156105f357602002820191906000526020600020905b815481526020019060010190808311610ae6575050505050905090565b600b546000906001600160a01b03163314610b525760405162461bcd60e51b815260206004820152600f60248201526e13d3931653115391125391d413d3d3608a1b6044820152606401610698565b610b60600c80546001019055565b610b7282610b6d600c5490565b611071565b816001600160a01b0316610b85600c5490565b6040517ff3cea5493d790af0133817606f7350a91d7f154ea52eaa79d179d4d231e5010290600090a3600c54610513565b919050565b60006001600160a01b038216610c255760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610698565b506001600160a01b031660009081526003602052604090205490565b610c49610e85565b610c53600061108b565b565b6000610c60600c5490565b905090565b60606001805461057a906120d3565b610c7f3383836110dd565b5050565b610c8b610e85565b600f81905560405181907f2ad2ae73af42f598ecb723109218def6abfe2e801eb5719ab4acbf9adc91c65d90600090a250565b610cc83383610f9d565b610ce45760405162461bcd60e51b81526004016106989061210d565b610cf0848484846111ab565b50505050565b600061051382611032565b6060610d0c82611032565b610d1557600080fd5b610d1d6111de565b610d26836111ed565b604051602001610d379291906122e9565b6040516020818303038152906040529050919050565b6060610d576111de565b604051602001610d679190612328565b604051602081830303815290604052905090565b610d83610e85565b6001600160a01b038116610de85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610698565b610df18161108b565b50565b6001600160a01b038116600090815260126020908152604091829020805483518184028101840190945280845260609392830182828015610e5457602002820191906000526020600020905b815481526020019060010190808311610e40575b50505050509050919050565b60006001600160e01b0319821663780e9d6360e01b1480610513575061051382611280565b600a546001600160a01b03163314610c535760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610698565b610ee881611032565b610df15760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610698565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610f6482610a4c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610fa983610a4c565b9050806001600160a01b0316846001600160a01b03161480610ff057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b806110145750836001600160a01b0316611009846105fd565b6001600160a01b0316145b949350505050565b6110278383836112d0565b610739838383611441565b6000908152600260205260409020546001600160a01b0316151590565b600061105a82610a4c565b90506110658261165b565b610c7f81600084611441565b610c7f8282604051806020016040528060008152506116fe565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361113e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610698565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6111b684848461101c565b6111c284848484611731565b610cf05760405162461bcd60e51b815260040161069890612359565b6060600d805461057a906120d3565b606060006111fa83611832565b600101905060008167ffffffffffffffff81111561121a5761121a611ecf565b6040519080825280601f01601f191660200182016040528015611244576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461124e57509392505050565b60006001600160e01b031982166380ac58cd60e01b14806112b157506001600160e01b03198216635b5e139f60e01b145b8061051357506301ffc9a760e01b6001600160e01b0319831614610513565b826001600160a01b03166112e382610a4c565b6001600160a01b0316146113095760405162461bcd60e51b8152600401610698906123ab565b6001600160a01b03821661136b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610698565b611378838383600161190a565b826001600160a01b031661138b82610a4c565b6001600160a01b0316146113b15760405162461bcd60e51b8152600401610698906123ab565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b038316156115d0576000818152601360209081526040808320546001600160a01b0387168452601290925282208054919291611486906001906123f0565b81548110611496576114966121a9565b906000526020600020015490508060126000876001600160a01b03166001600160a01b0316815260200190815260200160002083815481106114da576114da6121a9565b60009182526020808320909101929092556001600160a01b038716815260129091526040902080548061150f5761150f612403565b600082815260208082208301600019908101839055909201909255828252601381526040808320859055858352601190915281205460108054919291611557906001906123f0565b81548110611567576115676121a9565b906000526020600020015490508060108381548110611588576115886121a9565b60009182526020909120015560108054806115a5576115a5612403565b6000828152602080822083016000199081018390559092019092559181526011909152604090205550505b6001600160a01b03821615610739576001600160a01b039190911660009081526012602090815260408083208054858552601384528285208190556001808201835591855283852001859055601080548686526011909452918420839055820181559091527f1b6847dc741a1b0cd08d278845f9d819d87b734759afb55fe2de5cb82a9ae672015550565b600061166682610a4c565b905061167681600084600161190a565b61167f82610a4c565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6117088383611a3e565b6117156000848484611731565b6107395760405162461bcd60e51b815260040161069890612359565b60006001600160a01b0384163b1561182757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611775903390899088908890600401612419565b6020604051808303816000875af19250505080156117b0575060408051601f3d908101601f191682019092526117ad91810190612456565b60015b61180d573d8080156117de576040519150601f19603f3d011682016040523d82523d6000602084013e6117e3565b606091505b5080516000036118055760405162461bcd60e51b815260040161069890612359565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611014565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106118715772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061189d576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106118bb57662386f26fc10000830492506010015b6305f5e10083106118d3576305f5e100830492506008015b61271083106118e757612710830492506004015b606483106118f9576064830492506002015b600a83106105135760010192915050565b60018111156119795760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610698565b816001600160a01b0385166119d5576119d081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6119f8565b836001600160a01b0316856001600160a01b0316146119f8576119f88582611a54565b6001600160a01b038416611a1457611a0f81611af1565b611a37565b846001600160a01b0316846001600160a01b031614611a3757611a378482611ba0565b5050505050565b611a488282611be4565b610c7f60008383611441565b60006001611a6184610bbb565b611a6b91906123f0565b600083815260076020526040902054909150808214611abe576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611b03906001906123f0565b60008381526009602052604081205460088054939450909284908110611b2b57611b2b6121a9565b906000526020600020015490508060088381548110611b4c57611b4c6121a9565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b8457611b84612403565b6001900381819060005260206000200160009055905550505050565b6000611bab83610bbb565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611c3a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610698565b611c4381611032565b15611c905760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610698565b611c9e60008383600161190a565b611ca781611032565b15611cf45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610698565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160e01b031981168114610df157600080fd5b600060208284031215611d8757600080fd5b8135611d9281611d5f565b9392505050565b80356001600160a01b0381168114610bb657600080fd5b600060208284031215611dc257600080fd5b611d9282611d99565b60005b83811015611de6578181015183820152602001611dce565b50506000910152565b60008151808452611e07816020860160208601611dcb565b601f01601f19169290920160200192915050565b602081526000611d926020830184611def565b600060208284031215611e4057600080fd5b5035919050565b60008060408385031215611e5a57600080fd5b611e6383611d99565b946020939093013593505050565b600080600060608486031215611e8657600080fd5b611e8f84611d99565b9250611e9d60208501611d99565b9150604084013590509250925092565b60008060408385031215611ec057600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115611f0057611f00611ecf565b604051601f8501601f19908116603f01168101908282118183101715611f2857611f28611ecf565b81604052809350858152868686011115611f4157600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611f6d57600080fd5b813567ffffffffffffffff811115611f8457600080fd5b8201601f81018413611f9557600080fd5b61101484823560208401611ee5565b6020808252825182820181905260009190848201906040850190845b81811015611fdc57835183529284019291840191600101611fc0565b50909695505050505050565b60008060408385031215611ffb57600080fd5b61200483611d99565b91506020830135801515811461201957600080fd5b809150509250929050565b6000806000806080858703121561203a57600080fd5b61204385611d99565b935061205160208601611d99565b925060408501359150606085013567ffffffffffffffff81111561207457600080fd5b8501601f8101871361208557600080fd5b61209487823560208401611ee5565b91505092959194509250565b600080604083850312156120b357600080fd5b6120bc83611d99565b91506120ca60208401611d99565b90509250929050565b600181811c908216806120e757607f821691505b60208210810361210757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176105135761051361215a565b6000826121a457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b601f82111561073957600081815260208120601f850160051c810160208610156121e65750805b601f850160051c820191505b81811015612205578281556001016121f2565b505050505050565b815167ffffffffffffffff81111561222757612227611ecf565b61223b8161223584546120d3565b846121bf565b602080601f83116001811461227057600084156122585750858301515b600019600386901b1c1916600185901b178555612205565b600085815260208120601f198616915b8281101561229f57888601518255948401946001909101908401612280565b50858210156122bd5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082516122df818460208701611dcb565b9190910192915050565b600083516122fb818460208801611dcb565b83519083019061230f818360208801611dcb565b64173539b7b760d91b9101908152600501949350505050565b6000825161233a818460208701611dcb565b6c31b7b73a3930b1ba173539b7b760991b920191825250600d01919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b818103818111156105135761051361215a565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061244c90830184611def565b9695505050505050565b60006020828403121561246857600080fd5b8151611d9281611d5f56fea164736f6c6343000813000a60806040523480156200001157600080fd5b5060405180604001604052806007815260200166048595045204c560cc1b815250604051806040016040528060038152602001620484c560ec1b81525081600390816200005f9190620001b1565b5060046200006e8282620001b1565b506200007a9150503390565b600580546001600160a01b0319166001600160a01b03929092169190911790556040513090620000aa90620000fe565b6001600160a01b039091168152602001604051809103906000f080158015620000d7573d6000803e3d6000fd5b50600680546001600160a01b0319166001600160a01b03929092169190911790556200027d565b610f088062000f2d83390190565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200013757607f821691505b6020821081036200015857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001ac57600081815260208120601f850160051c81016020861015620001875750805b601f850160051c820191505b81811015620001a85782815560010162000193565b5050505b505050565b81516001600160401b03811115620001cd57620001cd6200010c565b620001e581620001de845462000122565b846200015e565b602080601f8311600181146200021d5760008415620002045750858301515b600019600386901b1c1916600185901b178555620001a8565b600085815260208120601f198616915b828110156200024e578886015182559484019460019091019084016200022d565b50858210156200026d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610ca0806200028d6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a59a997311610066578063a59a9973146101ee578063a9059cbb14610219578063ac5da9521461022c578063dd62ed3e1461023f57600080fd5b806370a082311461019757806395d89b41146101c05780639dc29fac146101c8578063a457c2d7146101db57600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461016f57806340c10f191461018257600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b610102610252565b60405161010f9190610b13565b60405180910390f35b61012b610126366004610b7d565b6102e4565b604051901515815260200161010f565b6002545b60405190815260200161010f565b61012b61015b366004610ba7565b6102fe565b6040516012815260200161010f565b61012b61017d366004610b7d565b610322565b610195610190366004610b7d565b610344565b005b61013f6101a5366004610be3565b6001600160a01b031660009081526020819052604090205490565b6101026103a9565b6101956101d6366004610b7d565b6103b8565b61012b6101e9366004610b7d565b610414565b600554610201906001600160a01b031681565b6040516001600160a01b03909116815260200161010f565b61012b610227366004610b7d565b61048f565b600654610201906001600160a01b031681565b61013f61024d366004610c05565b61049d565b60606003805461026190610c38565b80601f016020809104026020016040519081016040528092919081815260200182805461028d90610c38565b80156102da5780601f106102af576101008083540402835291602001916102da565b820191906000526020600020905b8154815290600101906020018083116102bd57829003601f168201915b5050505050905090565b6000336102f28185856104c8565b60019150505b92915050565b60003361030c8582856105ec565b610317858585610666565b506001949350505050565b6000336102f2818585610335838361049d565b61033f9190610c72565b6104c8565b6005546001600160a01b0316336001600160a01b03161461039b5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6103a58282610810565b5050565b60606004805461026190610c38565b6005546001600160a01b0316336001600160a01b03161461040a5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606401610392565b6103a582826108d7565b60003381610422828661049d565b9050838110156104825760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610392565b61031782868684036104c8565b6000336102f2818585610666565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661052a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610392565b6001600160a01b03821661058b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610392565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006105f8848461049d565b9050600019811461066057818110156106535760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610392565b61066084848484036104c8565b50505050565b6001600160a01b0383166106ca5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610392565b6001600160a01b03821661072c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610392565b6001600160a01b038316600090815260208190526040902054818110156107a45760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610392565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610660848484610a15565b6001600160a01b0382166108665760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610392565b80600260008282546108789190610c72565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36103a560008383610a15565b6001600160a01b0382166109375760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610392565b6001600160a01b038216600090815260208190526040902054818110156109ab5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610392565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610a1083600084610a15565b505050565b6001600160a01b03831615610a92576006546040516329cc05cf60e01b81526001600160a01b0385811660048301526024820184905260016044830152909116906329cc05cf90606401600060405180830381600087803b158015610a7957600080fd5b505af1158015610a8d573d6000803e3d6000fd5b505050505b6001600160a01b03821615610a10576006546040516329cc05cf60e01b81526001600160a01b0384811660048301526024820184905260006044830152909116906329cc05cf90606401600060405180830381600087803b158015610af657600080fd5b505af1158015610b0a573d6000803e3d6000fd5b50505050505050565b600060208083528351808285015260005b81811015610b4057858101830151858201604001528201610b24565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610b7857600080fd5b919050565b60008060408385031215610b9057600080fd5b610b9983610b61565b946020939093013593505050565b600080600060608486031215610bbc57600080fd5b610bc584610b61565b9250610bd360208501610b61565b9150604084013590509250925092565b600060208284031215610bf557600080fd5b610bfe82610b61565b9392505050565b60008060408385031215610c1857600080fd5b610c2183610b61565b9150610c2f60208401610b61565b90509250929050565b600181811c90821680610c4c57607f821691505b602082108103610c6c57634e487b7160e01b600052602260045260246000fd5b50919050565b808201808211156102f857634e487b7160e01b600052601160045260246000fdfea164736f6c6343000813000a608060405234801561001057600080fd5b50604051610f08380380610f0883398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610e75806100936000396000f3fe6080604052600436106100dd5760003560e01c806389d969171161007f578063d076eabc11610059578063d076eabc14610222578063efca2eed14610242578063f04da65b14610258578063fc0c546a1461028e57600080fd5b806389d96917146101d7578063b88a802f146101f7578063c7e1d0b11461020c57600080fd5b8063152111f7116100bb578063152111f71461018157806329cc05cf1461018b5780633c6e6789146101ab57806380bb4055146101c157600080fd5b8063058df06d146100e25780630700037d146101225780630e15561a1461016b575b600080fd5b3480156100ee57600080fd5b5061010f6100fd366004610c65565b60086020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561012e57600080fd5b5061015661013d366004610c9a565b6004602052600090815260409020805460019091015482565b60408051928352602083019190915201610119565b34801561017757600080fd5b5061010f60075481565b6101896102c6565b005b34801561019757600080fd5b506101896101a6366004610cb5565b6102d1565b3480156101b757600080fd5b5061010f60025481565b3480156101cd57600080fd5b5061010f60015481565b3480156101e357600080fd5b5061010f6101f2366004610c9a565b61032c565b34801561020357600080fd5b506101896103b4565b34801561021857600080fd5b5061010f60055481565b34801561022e57600080fd5b5061010f61023d366004610c65565b6103f2565b34801561024e57600080fd5b5061010f60065481565b34801561026457600080fd5b5061010f610273366004610c9a565b6001600160a01b031660009081526003602052604090205490565b34801561029a57600080fd5b506000546102ae906001600160a01b031681565b6040516001600160a01b039091168152602001610119565b6102cf34610458565b565b6000546001600160a01b0316331461031c5760405162461bcd60e51b815260206004820152600960248201526827a7262caa27a5a2a760b91b60448201526064015b60405180910390fd5b6103278383836105a3565b505050565b6001600160a01b038116600090815260036020526040812054810361035357506000919050565b6001600160a01b03821660009081526003602052604081205461037590610640565b6001600160a01b0384166000908152600460205260409020549091508082116103a2575060009392505050565b6103ac8183610d10565b949350505050565b6103bd33610670565b6040513381527f63e32091e4445d16e29c33a6b264577c2d86694021aa4e6f4dd590048f5792e89060200160405180910390a1565b6000806103fe83610861565b9250505062015180836104119190610d39565b61041c600183610d10565b610427906018610d4d565b61043290603c610d4d565b61043d90603c610d4d565b6104479085610d10565b6104519190610d10565b9392505050565b6000811161049a5760405162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b6044820152606401610313565b6000600254116104e15760405162461bcd60e51b81526020600482015260126024820152714445504f5349543a206e6f2073686172657360701b6044820152606401610313565b80600760008282546104f39190610d64565b9091555060009050610504426103f2565b9050816008600083815260200190815260200160002060008282546105299190610d64565b909155505060025461054a836ec097ce7bc90715b34b9f1000000000610d4d565b6105549190610d77565b600560008282546105659190610d64565b909155505060405182815233907fb9ad861b752f80117b35bea6dec99933d8a5ae360f2839ee8784b750d56134099060200160405180910390a25050565b80156105fb576105b38383610887565b826001600160a01b03167fae0577e1c96b26fbc0b9df702431f5470979d001d24f136eded791b8b6521d6f836040516105ee91815260200190565b60405180910390a2505050565b61060583836109ca565b826001600160a01b03167fba8f3777cf908803bf1f3dd58e7f4b7d3de4dbe3c234c4ccab0975d98f7cd388836040516105ee91815260200190565b60006ec097ce7bc90715b34b9f1000000000600554836106609190610d4d565b61066a9190610d77565b92915050565b6001600160a01b03811660009081526003602052604081205490036106925750565b600061069d8261032c565b6001600160a01b0383166000908152600460205260408120600101805492935083929091906106cd908490610d64565b90915550506001600160a01b0382166000908152600360205260409020546106f490610640565b6001600160a01b038316600090815260046020526040902055801561085d5780600660008282546107259190610d64565b909155505060405147906000906001600160a01b0385169084908381818185875af1925050503d8060008114610777576040519150601f19603f3d011682016040523d82523d6000602084013e61077c565b606091505b50509050806107cd5760405162461bcd60e51b815260206004820152601a60248201527f444953543a20636f756c64206e6f7420646973747269627574650000000000006044820152606401610313565b6107d78383610d10565b4710156108175760405162461bcd60e51b815260206004820152600e60248201526d08892a6a87440e8dede40daeac6d60931b6044820152606401610313565b836001600160a01b03167fe8b160e373db99a103e0a2abfa029b9c3fc8b328984a1ead8a65ae68ae646db78460405161085291815260200190565b60405180910390a250505b5050565b6000808061087a6108756201518086610d77565b610af1565b9196909550909350915050565b6001600160a01b038216600090815260036020526040902054158015906108c657506001600160a01b0382166000908152600360205260409020548111155b6109065760405162461bcd60e51b815260206004820152601160248201527052454d4f56453a206e6f2073686172657360781b6044820152606401610313565b61090f82610670565b80600260008282546109219190610d10565b90915550506001600160a01b0382166000908152600360205260408120805483929061094e908490610d10565b90915550506001600160a01b0382166000908152600360205260408120549003610988576001805490600061098283610d8b565b91905055505b6001600160a01b0382166000908152600360205260409020546109aa90610640565b6001600160a01b0390921660009081526004602052604090209190915550565b6001600160a01b038216600090815260036020526040902054156109f1576109f182610670565b6001600160a01b0382166000908152600360205260408120546002805491928492610a1d908490610d64565b90915550506001600160a01b03831660009081526003602052604081208054849290610a4a908490610d64565b90915550506001600160a01b03831660009081526003602052604090204260019091015580158015610a9357506001600160a01b03831660009081526003602052604090205415155b15610aae5760018054906000610aa883610da2565b91905055505b6001600160a01b038316600090815260036020526040902054610ad090610640565b6001600160a01b039093166000908152600460205260409020929092555050565b60008080838162253d8c610b088362010bd9610dbb565b610b129190610dbb565b9050600062023ab1610b25836004610de3565b610b2f9190610e13565b90506004610b408262023ab1610de3565b610b4b906003610dbb565b610b559190610e13565b610b5f9083610e41565b9150600062164b09610b72846001610dbb565b610b7e90610fa0610de3565b610b889190610e13565b90506004610b98826105b5610de3565b610ba29190610e13565b610bac9084610e41565b610bb790601f610dbb565b9250600061098f610bc9856050610de3565b610bd39190610e13565b905060006050610be58361098f610de3565b610bef9190610e13565b610bf99086610e41565b9050610c06600b83610e13565b9450610c1385600c610de3565b610c1e836002610dbb565b610c289190610e41565b91508483610c37603187610e41565b610c42906064610de3565b610c4c9190610dbb565b610c569190610dbb565b9a919950975095505050505050565b600060208284031215610c7757600080fd5b5035919050565b80356001600160a01b0381168114610c9557600080fd5b919050565b600060208284031215610cac57600080fd5b61045182610c7e565b600080600060608486031215610cca57600080fd5b610cd384610c7e565b92506020840135915060408401358015158114610cef57600080fd5b809150509250925092565b634e487b7160e01b600052601160045260246000fd5b8181038181111561066a5761066a610cfa565b634e487b7160e01b600052601260045260246000fd5b600082610d4857610d48610d23565b500690565b808202811582820484141761066a5761066a610cfa565b8082018082111561066a5761066a610cfa565b600082610d8657610d86610d23565b500490565b600081610d9a57610d9a610cfa565b506000190190565b600060018201610db457610db4610cfa565b5060010190565b8082018281126000831280158216821582161715610ddb57610ddb610cfa565b505092915050565b80820260008212600160ff1b84141615610dff57610dff610cfa565b818105831482151761066a5761066a610cfa565b600082610e2257610e22610d23565b600160ff1b821460001984141615610e3c57610e3c610cfa565b500590565b8181036000831280158383131683831282161715610e6157610e61610cfa565b509291505056fea164736f6c6343000813000a00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003a68747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e636f6d2f6c6f616e732f6574682f6578742f6d657461646174612f000000000000

Deployed Bytecode

0x6080604052600436106102cd5760003560e01c8063838122cf11610175578063b5df93f0116100dc578063d539c6d411610095578063e1ec3c681161006f578063e1ec3c6814610921578063f2c342c3146109b6578063f2fde38b146109e3578063f771183414610a0357600080fd5b8063d539c6d4146108af578063dfad7792146108e2578063e10e6bda1461090157600080fd5b8063b5df93f0146107e0578063bc157ac114610810578063c8092cf714610830578063ca593c5914610845578063cd08f9711461084d578063d45b62131461086f57600080fd5b8063930cf9731161012e578063930cf9731461072557806396e41e9e146107455780639d32a680146107655780639e4d5ddf14610785578063a4b3eb0b146107a9578063b2b8ec41146107bc57600080fd5b8063838122cf146106635780638470fc55146106835780638a05d5f9146106a35780638da5cb5b146106c35780638e6cce35146106e1578063921b2fb71461070157600080fd5b80633bb66a7b1161023457806367d4a3d3116101ed5780636e04ff0d116101c75780636e04ff0d146105f05780636faa8b3f1461061e5780636fea611114610631578063715018a61461064e57600080fd5b806367d4a3d31461057b5780636bc394d3146105a85780636bfeba53146105cc57600080fd5b80633bb66a7b146104b6578063441a3e70146104de5780634585e33b146104fe5780634e9865c71461051e578063528b1ed81461053e5780635bc7b7f31461055b57600080fd5b806323169a7b1161028657806323169a7b146103c6578063238dafe0146103e6578063328d8f721461041057806334a4117714610430578063375b74c3146104685780633a5684741461048f57600080fd5b8063051b4d07146102d9578063075ee2c8146102fb57806309fff9631461031b5780630a861f2a1461033b5780630ecbcdab1461035b5780631c57d3d31461038e57600080fd5b366102d457005b600080fd5b3480156102e557600080fd5b506102f96102f436600461410d565b610a23565b005b34801561030757600080fd5b506102f961031636600461410d565b610ac1565b34801561032757600080fd5b506102f9610336366004614146565b610b43565b34801561034757600080fd5b506102f9610356366004614172565b610b67565b34801561036757600080fd5b5061037b61037636600461418b565b610c86565b6040519081526020015b60405180910390f35b34801561039a57600080fd5b506002546103b19062010000900463ffffffff1681565b60405163ffffffff9091168152602001610385565b3480156103d257600080fd5b506102f96103e136600461410d565b610c9c565b3480156103f257600080fd5b506002546104009060ff1681565b6040519015158152602001610385565b34801561041c57600080fd5b506102f961042b3660046141bb565b610d0b565b34801561043c57600080fd5b50600354610450906001600160a01b031681565b6040516001600160a01b039091168152602001610385565b34801561047457600080fd5b5060025461045090600160501b90046001600160a01b031681565b34801561049b57600080fd5b5060105461045090600160201b90046001600160a01b031681565b3480156104c257600080fd5b5061037b6104d13660046141d8565b6001600160a01b03163190565b3480156104ea57600080fd5b506102f96104f936600461418b565b610d80565b34801561050a57600080fd5b506102f96105193660046141f5565b610d8b565b34801561052a57600080fd5b506102f961053936600461410d565b61106c565b34801561054a57600080fd5b506010546103b19063ffffffff1681565b34801561056757600080fd5b506102f96105763660046141d8565b61109d565b34801561058757600080fd5b5061037b6105963660046141d8565b600e6020526000908152604090205481565b3480156105b457600080fd5b50600b546103b190600160801b900463ffffffff1681565b3480156105d857600080fd5b506002546103b190600160301b900463ffffffff1681565b3480156105fc57600080fd5b5061061061060b3660046141f5565b611326565b6040516103859291906142b7565b6102f961062c366004614172565b6114d2565b34801561063d57600080fd5b50600b546103b19063ffffffff1681565b34801561065a57600080fd5b506102f96114e0565b34801561066f57600080fd5b5061037b61067e3660046142d2565b6114f4565b34801561068f57600080fd5b506102f961069e36600461430f565b61151a565b3480156106af57600080fd5b506104006106be366004614172565b6115a3565b3480156106cf57600080fd5b506000546001600160a01b0316610450565b3480156106ed57600080fd5b506102f96106fc36600461410d565b6115ae565b34801561070d57600080fd5b50600b546103b190600160601b900463ffffffff1681565b34801561073157600080fd5b506102f961074036600461410d565b61162a565b34801561075157600080fd5b506102f961076036600461410d565b6116b5565b34801561077157600080fd5b506102f96107803660046141bb565b611730565b34801561079157600080fd5b50600b546103b190600160201b900463ffffffff1681565b6102f96107b7366004614172565b6117a0565b3480156107c857600080fd5b50600b546103b190600160401b900463ffffffff1681565b3480156107ec57600080fd5b506104006107fb3660046141d8565b60086020526000908152604090205460ff1681565b34801561081c57600080fd5b506102f961082b366004614348565b611834565b34801561083c57600080fd5b5061037b611840565b6102f96119e8565b34801561085957600080fd5b50610862611a9e565b6040516103859190614380565b34801561087b57600080fd5b5061088f61088a366004614172565b611b00565b604080519485526020850193909352918301526060820152608001610385565b3480156108bb57600080fd5b506103b16108ca3660046141d8565b600c6020526000908152604090205463ffffffff1681565b3480156108ee57600080fd5b5060025461040090610100900460ff1681565b34801561090d57600080fd5b506102f961091c36600461410d565b611eca565b34801561092d57600080fd5b5061097d61093c366004614172565b600f6020526000908152604090208054600182015460028301546003840154600485015460059095015493946001600160a01b039384169492939091169186565b604080519687526001600160a01b03958616602088015286019390935292166060840152608083019190915260a082015260c001610385565b3480156109c257600080fd5b5061037b6109d13660046141d8565b600d6020526000908152604090205481565b3480156109ef57600080fd5b506102f96109fe3660046141d8565b611f31565b348015610a0f57600080fd5b5061037b610a1e36600461418b565b611fa7565b610a2b611fec565b6064610a3a612710600a6143e3565b610a449190614421565b63ffffffff168163ffffffff161115610a9a5760405162461bcd60e51b8152602060048201526013602482015272534554424150524d494e3a206c74652031302560681b60448201526064015b60405180910390fd5b600b805463ffffffff909216600160201b0267ffffffff0000000019909216919091179055565b610ac9611fec565b61271063ffffffff82161115610b185760405162461bcd60e51b8152602060048201526014602482015273534554424150524d41583a206c7465203130302560601b6044820152606401610a91565b600b805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055565b610b4b611fec565b6001600160a01b039091166000908152600e6020526040902055565b601054600160201b90046001600160a01b0316639dc29fac336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610bc857600080fd5b505af1158015610bdc573d6000803e3d6000fd5b505050506000610be93390565b6001600160a01b03168260405160006040518083038185875af1925050503d8060008114610c33576040519150601f19603f3d011682016040523d82523d6000602084013e610c38565b606091505b5050905080610c825760405162461bcd60e51b815260206004820152601660248201527515d2551211149055ce88115512081b9bdd081cd95b9d60521b6044820152606401610a91565b5050565b6000610c93338484612046565b90505b92915050565b610ca4611fec565b61271063ffffffff82161115610ce75760405162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b6044820152606401610a91565b6002805463ffffffff909216620100000265ffffffff000019909216919091179055565b610d13611fec565b60025481151560ff909116151503610d6d5760405162461bcd60e51b815260206004820152601760248201527f534554454e41424c45443a206d75737420746f67676c650000000000000000006044820152606401610a91565b6002805460ff1916911515919091179055565b610c8233838361252e565b6000610d99828401846144af565b905060005b8151811015611066576000828281518110610dbb57610dbb61453a565b6020026020010151905080600003610dd35750611066565b610ddc816129db565b15611053576000818152600f60209081526040808320815160c0810183528154815260018201546001600160a01b0390811682860152600283015482850152600383015416606082018190526004808401546080840181905260059094015460a08401528451630dfe168160e01b815294519296939591948593630dfe1681938284019390928290030181865afa158015610e7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9f9190614550565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b031603610fc5576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3e9190614550565b6002546020870151604051633b6191dd60e01b8152929350600160501b9091046001600160a01b031691633b6191dd91610f8291859190899060019060040161456d565b600060405180830381600087803b158015610f9c57600080fd5b505af1158015610fb0573d6000803e3d6000fd5b50505050610fbf838287612a98565b50611045565b6002546020850151604051633b6191dd60e01b81528392600160501b90046001600160a01b031691633b6191dd91611006918591899060019060040161456d565b600060405180830381600087803b15801561102057600080fd5b505af1158015611034573d6000803e3d6000fd5b50505050611043838287612a98565b505b61104e85612ff8565b505050505b508061105e81614596565b915050610d9e565b50505050565b611074611fec565b6002805463ffffffff909216600160301b0269ffffffff00000000000019909216919091179055565b6110a5611fec565b60008190506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110e9190614550565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611150573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111749190614550565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b031614806111e757507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b0316145b6112285760405162461bcd60e51b81526020600482015260126024820152710a89e8e8e988a869e98987440dcde408aa8960731b6044820152606401610a91565b60408051600280825260608201835260009260208301908036833701905050905061012c8160008151811061125f5761125f61453a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061128e5761128e61453a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0385169063883bdbfd906112cf9084906004016145af565b600060405180830381865afa1580156112ec573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611314919081019061465c565b505061131f856130cb565b5050505050565b600060606000600360009054906101000a90046001600160a01b03166001600160a01b0316636800901a6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561137f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113a79190810190614728565b600254909150600090600160301b900463ffffffff1667ffffffffffffffff8111156113d5576113d5614444565b6040519080825280602002602001820160405280156113fe578160200160208202803683370190505b5090506000805b835181101561149e5760025463ffffffff600160301b9091048116908316101561149e57600084828151811061143d5761143d61453a565b60200260200101519050611450816129db565b1561148b576001965080848463ffffffff16815181106114725761147261453a565b602090810291909101015282611487816147ae565b9350505b508061149681614596565b915050611405565b5084156114c857816040516020016114b691906147d1565b60405160208183030381529060405293505b5050509250929050565b6114dd338234613250565b50565b6114e8611fec565b6114f26000613523565b565b600061150233868686613573565b945061150f338684612046565b90505b949350505050565b611522611fec565b61271063ffffffff821611156115705760405162461bcd60e51b81526020600482015260136024820152725345544c54564d41583a206c7465203130302560681b6044820152606401610a91565b6001600160a01b03919091166000908152600c60205260409020805463ffffffff191663ffffffff909216919091179055565b6000610c96826129db565b6115b6611fec565b61271063ffffffff821611156116045760405162461bcd60e51b81526020600482015260136024820152725345544c54564d41583a206c7465203130302560681b6044820152606401610a91565b600b805463ffffffff909216600160801b0263ffffffff60801b19909216919091179055565b611632611fec565b6064611641612710601e6143e3565b61164b9190614421565b63ffffffff168163ffffffff1611156116995760405162461bcd60e51b815260206004820152601060248201526f534554424645453a206c74652033302560801b6044820152606401610a91565b600b805463ffffffff191663ffffffff92909216919091179055565b6116bd611fec565b61271063ffffffff8216111561170a5760405162461bcd60e51b81526020600482015260126024820152715345544c504c54563a206c7465203130302560701b6044820152606401610a91565b600b805463ffffffff909216600160601b0263ffffffff60601b19909216919091179055565b611738611fec565b801515600260019054906101000a900460ff161515036117865760405162461bcd60e51b815260206004820152600960248201526829a2aa2624a8a222a360b91b6044820152606401610a91565b600280549115156101000261ff0019909216919091179055565b6000818152600f6020526040902060050154156117c7576117c2338234613250565b611815565b34156118155760405162461bcd60e51b815260206004820152601a60248201527f5041594241434b4c4f53453a206e6f20455448206e65656465640000000000006044820152606401610a91565b6000818152600f60205260409020600401546114dd903390839061252e565b61106633848484613573565b6000806000600460009054906101000a90046001600160a01b03166001600160a01b031663fb5ebf366040518163ffffffff1660e01b81526004016040805180830381865afa158015611897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118bb9190614809565b91509150600061271063ffffffff16600460009054906101000a90046001600160a01b03166001600160a01b0316637e3596996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611941919061482d565b6119519063ffffffff168461484a565b61195b9190614861565b9050808310156119d057600b546000908290859061198f9063ffffffff600160201b8204811691600160401b900416614875565b63ffffffff1661199f919061484a565b6119a99190614861565b600b549091506119c7908290600160401b900463ffffffff16614899565b94505050505090565b5050600b54600160201b900463ffffffff1692915050565b60003411611a2a5760405162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b6044820152606401610a91565b601054600160201b90046001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152346024820152604401600060405180830381600087803b158015611a8a57600080fd5b505af1158015611066573d6000803e3d6000fd5b60606009805480602002602001604051908101604052809291908181526020018280548015611af657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ad8575b5050505050905090565b60035460405163c3738f3f60e01b8152600481018390526000918291829182916001600160a01b039091169063c3738f3f90602401602060405180830381865afa158015611b52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7691906148ac565b611bc25760405162461bcd60e51b815260206004820152601760248201527f4745544c54563a206c6f616e206d7573742065786973740000000000000000006044820152606401610a91565b6000858152600f60209081526040808320815160c0810183528154815260018201546001600160a01b0390811694820194909452600282015492810183905260038201549093166060840152600481015460808401526005015460a08301819052919291611c2f91611fa7565b905081608001516000148015611c47575060a0820151155b15611c615760008060008095509550955095505050611ec3565b6006546060830151604051631ece4f9760e21b81526001600160a01b0391821660048201526000929190911690637b393e5c90602401602060405180830381865afa158015611cb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd89190614550565b6006546040516304e09a6160e41b81526001600160a01b03808416600483015292935060009290911690634e09a61090602401602060405180830381865afa158015611d28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4c91906148c9565b9050600084606001516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db69190614550565b905060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b031614611e07576080860151611e02908461484a565b611e30565b82611e176002600160601b6149c6565b611e219190614861565b8660800151611e30919061484a565b90506000600160601b8760a00151611e48919061484a565b90506000600160601b878960a00151611e6191906149d5565b611e6b919061484a565b60015490915083611e7c828561484a565b611e869190614861565b611e90919061484a565b60015484611e9e828561484a565b611ea89190614861565b611eb2919061484a565b909c509a5091985096505050505050505b9193509193565b611ed2611fec565b61271063ffffffff82161115611f155760405162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b6044820152606401610a91565b6010805463ffffffff191663ffffffff92909216919091179055565b611f39611fec565b6001600160a01b038116611f9e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a91565b6114dd81613523565b60006301e1338061271084611fba611840565b611fc48642614899565b611fce919061484a565b611fd8919061484a565b611fe29190614861565b610c939190614861565b6000546001600160a01b031633146114f25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a91565b60025460009060ff166120915760405162461bcd60e51b81526020600482015260136024820152721093d49493d5ce881b9bdd08195b98589b1959606a1b6044820152606401610a91565b61209b8484613a95565b6000838152600f6020908152604080832060038101546001600160a01b0316845260089092529091205460ff166121075760405162461bcd60e51b815260206004820152601060248201526f1093d49493d5ce88189859081c1bdbdb60821b6044820152606401610a91565b600061211b82600501548360020154611fa7565b426002840155905060008061212f87611b00565b9350935050506000600160601b836121479190614861565b90506000612159600160601b84614861565b60038701546001600160a01b03166000908152600c60205260408120549192509063ffffffff166121b157600b54612710906121a290600160801b900463ffffffff168561484a565b6121ac9190614861565b6121ec565b60038701546001600160a01b03166000908152600c6020526040902054612710906121e29063ffffffff168561484a565b6121ec9190614861565b90508082106122355760405162461bcd60e51b8152602060048201526015602482015274424f52524f573a2063616e6e6f7420626f72726f7760581b6044820152606401610a91565b806122408a846149d5565b1115612253576122508282614899565b98505b884710156122a35760405162461bcd60e51b815260206004820152601860248201527f424f52524f573a206e6f7420656e6f7567682066756e647300000000000000006044820152606401610a91565b60038701546001600160a01b03166000908152600e6020526040902054156123475760038701546001600160a01b03166000908152600e6020908152604080832054600d909252909120546122f9908b906149d5565b11156123475760405162461bcd60e51b815260206004820152601860248201527f424f52524f573a206578636565647320706f6f6c206d617800000000000000006044820152606401610a91565b60038701546001600160a01b03166000908152600d6020526040812080548b92906123739084906149d5565b925050819055508887600501600082825461238e91906149d5565b9091555050600b54600090612710906123ad9063ffffffff168c61484a565b6123b79190614861565b6123c190886149d5565b9050808a1161241e5760405162461bcd60e51b8152602060048201526024808201527f424f52524f573a2066656573206d6f7265207468616e20626f72726f7720616d6044820152631bdd5b9d60e21b6064820152608401610a91565b600061242a828c614899565b905061243582613b52565b60008d6001600160a01b03168260405160006040518083038185875af1925050503d8060008114612482576040519150601f19603f3d011682016040523d82523d6000602084013e612487565b606091505b50509050806124d85760405162461bcd60e51b815260206004820152601960248201527f424f52524f573a20455448206e6f742064656c697665726564000000000000006044820152606401610a91565b8c8e6001600160a01b03167fe1979fe4c35e0cef342fef5668e2c8e7a7e9f5d5d1ca8fee0ac6c427fa4153af8e60405161251491815260200190565b60405180910390a3509a9c9b505050505050505050505050565b600081116125885760405162461bcd60e51b815260206004820152602160248201527f57495448445241573a206d7573742077697468647261772066726f6d206c6f616044820152603760f91b6064820152608401610a91565b6125928383613a95565b6000828152600f6020526040902060048101548211156125e95760405162461bcd60e51b81526020600482015260126024820152710ae92a89088a482ae7440e8dede40daeac6d60731b6044820152606401610a91565b818160040160008282546125fd9190614899565b909155506000905061260e84611b00565b505060038401546001600160a01b03166000908152600c602052604090205490925063ffffffff161590506126cc5760038201546001600160a01b03166000908152600c6020526040902054612710906126729063ffffffff16600160601b61484a565b61267c9190614861565b8111156126c75760405162461bcd60e51b81526020600482015260196024820152782ba4aa24222920ab9d1032bc31b2b2b2399036b0bc10262a2b60391b6044820152606401610a91565b612743565b600b54612710906126ee90600160801b900463ffffffff16600160601b61484a565b6126f89190614861565b8111156127435760405162461bcd60e51b81526020600482015260196024820152782ba4aa24222920ab9d1032bc31b2b2b2399036b0bc10262a2b60391b6044820152606401610a91565b600382015460408051630dfe168160e01b815290516001600160a01b03909216916000918391630dfe1681916004808201926020929091908290030181865afa158015612794573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b89190614550565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b0316036128eb576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612833573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128579190614550565b600254600180880154604051633b6191dd60e01b81529394506001600160a01b03600160501b909304831693633b6191dd9361289e938793909116918c919060040161456d565b600060405180830381600087803b1580156128b857600080fd5b505af11580156128cc573d6000803e3d6000fd5b506128e5925050506001600160a01b0382168988613cd1565b50612979565b600254600185810154604051633b6191dd60e01b81528493600160501b90046001600160a01b0390811693633b6191dd93612930938793909116918c9160040161456d565b600060405180830381600087803b15801561294a57600080fd5b505af115801561295e573d6000803e3d6000fd5b50612977925050506001600160a01b0382168988613cd1565b505b836004015460000361298e5761298e86612ff8565b85876001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568876040516129ca91815260200190565b60405180910390a350505050505050565b60035460405163c3738f3f60e01b8152600481018390526000916001600160a01b03169063c3738f3f90602401602060405180830381865afa158015612a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4991906148ac565b612a5557506000919050565b6000612a6083611b00565b5050600b549092506127109150612a8690600160601b9081900463ffffffff169061484a565b612a909190614861565b111592915050565b600254610100900460ff168015612abd57506004546001600160a01b03838116911614155b15612fc857600654604051631ece4f9760e21b81526001600160a01b0385811660048301526000921690637b393e5c90602401602060405180830381865afa158015612b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b319190614550565b6006546040516304e09a6160e41b81526001600160a01b03808416600483015292935060009290911690634e09a61090602401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba591906148c9565b905060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316866001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c359190614550565b6001600160a01b031614612c625781612c536002600160601b6149c6565b612c5d9190614861565b612c64565b815b90506000600160601b856080015183612c7d919061484a565b612c879190614861565b905060008560a001518211612ca0578560a00151612ca2565b815b6007546080880151919250612cc29189916001600160a01b031690613d34565b600760009054906101000a90046001600160a01b03166001600160a01b031663414bf3896040518061010001604052808a6001600160a01b031681526020017f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031681526020018b6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9291906149e8565b62ffffff1681523060208201524260408201526080808b0151606083015260025491019061271090612dd09062010000900463ffffffff1682614875565b612de09063ffffffff168761484a565b612dea9190614861565b815260006020918201526040805160e085811b6001600160e01b031916825284516001600160a01b03908116600484015293850151841660248301529184015162ffffff1660448201526060840151831660648201526080840151608482015260a084015160a482015260c084015160c48201529201511660e4820152610104016020604051808303816000875af1158015612e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eae91906148c9565b506040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa158015612f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3a91906148c9565b90508015612fbd57604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015612fa457600080fd5b505af1158015612fb8573d6000803e3d6000fd5b505050505b505050505050505050565b612ff3612fdd6000546001600160a01b031690565b60808301516001600160a01b0385169190613cd1565b505050565b6000818152600f60205260408082208281556001810180546001600160a01b03199081169091556002820184905560038083018054909216909155600480830185905560059092019390935591549051630852cd8d60e31b81529182018390526001600160a01b0316906342966c6890602401600060405180830381600087803b15801561308557600080fd5b505af1158015613099573d6000803e3d6000fd5b50506040518392507f40e7dd78d661cb2192925e6eeecc3f99eb4f3e7457c18ea57ddd84cd051d01f39150600090a250565b6001600160a01b03811660009081526008602052604090205460ff16156131dd576001600160a01b0381166000908152600a60205260408120546009805491929161311890600190614899565b815481106131285761312861453a565b600091825260209091200154600980546001600160a01b0390921692508291849081106131575761315761453a565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790558383168252600a8152604080832086905592861682526008905220805460ff1916905560098054806131b3576131b3614a0d565b600082815260209020810160001990810180546001600160a01b0319169055019055506114dd9050565b6001600160a01b03166000818152600860209081526040808320805460ff1916600190811790915560098054600a909452918420839055820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319169091179055565b600081116132a05760405162461bcd60e51b815260206004820152601b60248201527f5041594241434b3a206e6f2045544820746f20706179206261636b00000000006044820152606401610a91565b6132aa8383613a95565b6000828152600f60205260408120600581015460028201549192916132cf9190611fa7565b42600284015590508083116133305760405162461bcd60e51b815260206004820152602160248201527f5041594241434b3a206d75737420706179206261636b2061626f7665206665656044820152607360f81b6064820152608401610a91565b600081836005015461334291906149d5565b905060008185111561335b576133588286614899565b90505b60038401546001600160a01b03166000908152600d60205260409020546133828487614899565b11613396576133918386614899565b6133b4565b60038401546001600160a01b03166000908152600d60205260409020545b60038501546001600160a01b03166000908152600d6020526040812080549091906133e0908490614899565b909155505060058401546133f48487614899565b11613408576134038386614899565b61340e565b83600501545b8460050160008282546134219190614899565b909155505082156134355761343583613b52565b80156134e0576000876001600160a01b03168260405160006040518083038185875af1925050503d8060008114613488576040519150601f19603f3d011682016040523d82523d6000602084013e61348d565b606091505b50509050806134de5760405162461bcd60e51b815260206004820152601c60248201527f5041594241434b3a20726566756e6420756e7375636365737366756c000000006044820152606401610a91565b505b604080518681526020810185905287916001600160a01b038a16917fca92b037c5d17af773d2a576cd91e713e64b80af7c561456d811d12fc927960091016129ca565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460009060ff166135bf5760405162461bcd60e51b815260206004820152601460248201527311115413d4d2550e881b9bdd08195b98589b195960621b6044820152606401610a91565b60006135cb8686613e2d565b506000818152600f602052604081206003810154929750879350916001600160a01b0316613694576001600160a01b03861660009081526008602052604090205460ff166136505760405162461bcd60e51b815260206004820152601260248201527104445504f5349543a2062616420706f6f6c360741b6044820152606401610a91565b50428082556001820180546001600160a01b03808b166001600160a01b03199283161790925560028401929092556003830180549188169190921617905584613705565b60038201546001600160a01b031660009081526008602052604090205460ff166136f55760405162461bcd60e51b81526020600482015260126024820152714445504f5349543a2062616420706f6f6c3160701b6044820152606401610a91565b5060038101546001600160a01b03165b8482600401600082825461371991906149d5565b925050819055506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015613760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137849190614550565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b031603613936576000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138239190614550565b905061383a6001600160a01b0382168b308a613ecb565b60025460405163095ea7b360e01b8152600160501b9091046001600160a01b0390811660048301526024820189905282169063095ea7b3906044016020604051808303816000875af1158015613894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b891906148ac565b506002546001850154604051633b6191dd60e01b8152600160501b9092046001600160a01b0390811692633b6191dd926138fe9286929116908c9060009060040161456d565b600060405180830381600087803b15801561391857600080fd5b505af115801561392c573d6000803e3d6000fd5b5050505050613a44565b8061394c6001600160a01b0382168b308a613ecb565b60025460405163095ea7b360e01b8152600160501b9091046001600160a01b0390811660048301526024820189905282169063095ea7b3906044016020604051808303816000875af11580156139a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ca91906148ac565b506002546001850154604051633b6191dd60e01b8152600160501b9092046001600160a01b0390811692633b6191dd92613a109286929116908c9060009060040161456d565b600060405180830381600087803b158015613a2a57600080fd5b505af1158015613a3e573d6000803e3d6000fd5b50505050505b87896001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051613a8091815260200190565b60405180910390a35095979650505050505050565b6003546040516331a9108f60e11b8152600481018390526001600160a01b0390911690636352211e90602401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b029190614550565b6001600160a01b0316826001600160a01b031614610c825760405162461bcd60e51b815260206004820152600d60248201526c2b20a624a220aa22a7aba722a960991b6044820152606401610a91565b60105460009061271090613b6c9063ffffffff168461484a565b613b769190614861565b90506000613b848284614899565b90508115613c5d576000601060049054906101000a90046001600160a01b03166001600160a01b031663ac5da9526040518163ffffffff1660e01b8152600401602060405180830381865afa158015613be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c059190614550565b9050806001600160a01b031663152111f7846040518263ffffffff1660e01b81526004016000604051808303818588803b158015613c4257600080fd5b505af1158015613c56573d6000803e3d6000fd5b5050505050505b8015612ff357600560009054906101000a90046001600160a01b03166001600160a01b031663152111f7826040518263ffffffff1660e01b81526004016000604051808303818588803b158015613cb357600080fd5b505af1158015613cc7573d6000803e3d6000fd5b5050505050505050565b6040516001600160a01b038316602482015260448101829052612ff390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613f03565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691613d909190614a23565b6000604051808303816000865af19150503d8060008114613dcd576040519150601f19603f3d011682016040523d82523d6000602084013e613dd2565b606091505b5091509150818015613dfc575080511580613dfc575080806020019051810190613dfc91906148ac565b61131f5760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401610a91565b60008082600003613eb3576003546040516335313c2160e11b81526001600160a01b03868116600483015290911690636a627842906024016020604051808303816000875af1158015613e84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea891906148c9565b915060019050613ec4565b613ebd8484613a95565b5081905060005b9250929050565b6040516001600160a01b03808516602483015283166044820152606481018290526110669085906323b872dd60e01b90608401613cfd565b6000613f58826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613fd89092919063ffffffff16565b9050805160001480613f79575080806020019051810190613f7991906148ac565b612ff35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a91565b6060611512848460008585600080866001600160a01b03168587604051613fff9190614a23565b60006040518083038185875af1925050503d806000811461403c576040519150601f19603f3d011682016040523d82523d6000602084013e614041565b606091505b50915091506140528783838761405d565b979650505050505050565b606083156140cc5782516000036140c5576001600160a01b0385163b6140c55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a91565b5081611512565b61151283838151156140e15781518083602001fd5b8060405162461bcd60e51b8152600401610a919190614a3f565b63ffffffff811681146114dd57600080fd5b60006020828403121561411f57600080fd5b813561412a816140fb565b9392505050565b6001600160a01b03811681146114dd57600080fd5b6000806040838503121561415957600080fd5b823561416481614131565b946020939093013593505050565b60006020828403121561418457600080fd5b5035919050565b6000806040838503121561419e57600080fd5b50508035926020909101359150565b80151581146114dd57600080fd5b6000602082840312156141cd57600080fd5b813561412a816141ad565b6000602082840312156141ea57600080fd5b813561412a81614131565b6000806020838503121561420857600080fd5b823567ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81358181111561424357600080fd5b86602082850101111561425557600080fd5b60209290920196919550909350505050565b60005b8381101561428257818101518382015260200161426a565b50506000910152565b600081518084526142a3816020860160208601614267565b601f01601f19169290920160200192915050565b8215158152604060208201526000611512604083018461428b565b600080600080608085870312156142e857600080fd5b8435935060208501356142fa81614131565b93969395505050506040820135916060013590565b6000806040838503121561432257600080fd5b823561432d81614131565b9150602083013561433d816140fb565b809150509250929050565b60008060006060848603121561435d57600080fd5b83359250602084013561436f81614131565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156143c15783516001600160a01b03168352928401929184019160010161439c565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b63ffffffff818116838216028082169190828114614403576144036143cd565b505092915050565b634e487b7160e01b600052601260045260246000fd5b600063ffffffff808416806144385761443861440b565b92169190910492915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561448357614483614444565b604052919050565b600067ffffffffffffffff8211156144a5576144a5614444565b5060051b60200190565b600060208083850312156144c257600080fd5b823567ffffffffffffffff8111156144d957600080fd5b8301601f810185136144ea57600080fd5b80356144fd6144f88261448b565b61445a565b81815260059190911b8201830190838101908783111561451c57600080fd5b928401925b8284101561405257833582529284019290840190614521565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561456257600080fd5b815161412a81614131565b6001600160a01b0394851681529290931660208301526040820152901515606082015260800190565b6000600182016145a8576145a86143cd565b5060010190565b6020808252825182820181905260009190848201906040850190845b818110156143c157835163ffffffff16835292840192918401916001016145cb565b600082601f8301126145fe57600080fd5b8151602061460e6144f88361448b565b82815260059290921b8401810191818101908684111561462d57600080fd5b8286015b8481101561465157805161464481614131565b8352918301918301614631565b509695505050505050565b6000806040838503121561466f57600080fd5b825167ffffffffffffffff8082111561468757600080fd5b818501915085601f83011261469b57600080fd5b815160206146ab6144f88361448b565b82815260059290921b840181019181810190898411156146ca57600080fd5b948201945b838610156146f85785518060060b81146146e95760008081fd5b825294820194908201906146cf565b9188015191965090935050508082111561471157600080fd5b5061471e858286016145ed565b9150509250929050565b6000602080838503121561473b57600080fd5b825167ffffffffffffffff81111561475257600080fd5b8301601f8101851361476357600080fd5b80516147716144f88261448b565b81815260059190911b8201830190838101908783111561479057600080fd5b928401925b8284101561405257835182529284019290840190614795565b600063ffffffff8083168181036147c7576147c76143cd565b6001019392505050565b6020808252825182820181905260009190848201906040850190845b818110156143c1578351835292840192918401916001016147ed565b6000806040838503121561481c57600080fd5b505080516020909101519092909150565b60006020828403121561483f57600080fd5b815161412a816140fb565b8082028115828204841417610c9657610c966143cd565b6000826148705761487061440b565b500490565b63ffffffff828116828216039080821115614892576148926143cd565b5092915050565b81810381811115610c9657610c966143cd565b6000602082840312156148be57600080fd5b815161412a816141ad565b6000602082840312156148db57600080fd5b5051919050565b600181815b8085111561491d578160001904821115614903576149036143cd565b8085161561491057918102915b93841c93908002906148e7565b509250929050565b60008261493457506001610c96565b8161494157506000610c96565b816001811461495757600281146149615761497d565b6001915050610c96565b60ff841115614972576149726143cd565b50506001821b610c96565b5060208310610133831016604e8410600b84101617156149a0575081810a610c96565b6149aa83836148e2565b80600019048211156149be576149be6143cd565b029392505050565b6000610c9360ff841683614925565b80820180821115610c9657610c966143cd565b6000602082840312156149fa57600080fd5b815162ffffff8116811461412a57600080fd5b634e487b7160e01b600052603160045260246000fd5b60008251614a35818460208701614267565b9190910192915050565b602081526000610c93602083018461428b56fea164736f6c6343000813000a

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

00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003a68747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e636f6d2f6c6f616e732f6574682f6578742f6d657461646174612f000000000000

-----Decoded View---------------
Arg [0] : _baseTokenURI (string): https://api.hyperbolicprotocol.com/loans/eth/ext/metadata/
Arg [1] : __swapRouter (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [2] : __hype (address): 0x85225Ed797fd4128Ac45A992C46eA4681a7A15dA
Arg [3] : __twapUtils (address): 0xBf1858b24243Ecbcf7d940f458e36CB7401c2366
Arg [4] : __lendingRewards (address): 0x300648a601c584E6379fa0D6a31CbBFCcA6177e4
Arg [5] : __WETH (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [2] : 00000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da
Arg [3] : 000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366
Arg [4] : 000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4
Arg [5] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [6] : 000000000000000000000000000000000000000000000000000000000000003a
Arg [7] : 68747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e63
Arg [8] : 6f6d2f6c6f616e732f6574682f6578742f6d657461646174612f000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.