ETH Price: $3,915.55 (-0.47%)

Contract

0x481FcFa00Ee6b2384FF0B3c3b5b29aD911c1AAA7

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Multicall183340752024-12-14 2:17:281 hr ago1734142648IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.00001510.137
Multicall183340502024-12-14 2:16:091 hr ago1734142569IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000017280.126
Withdraw Token182871422024-12-12 7:13:2244 hrs ago1733987602IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000021730.198
Multicall182871202024-12-12 7:12:1044 hrs ago1733987530IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000021870.2
Multicall182871032024-12-12 7:11:1644 hrs ago1733987476IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000039590.202
Multicall181942202024-12-08 18:10:305 days ago1733681430IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000035460.23
Withdraw Token181903342024-12-08 14:37:495 days ago1733668669IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.00001720.17
Multicall181903212024-12-08 14:37:065 days ago1733668626IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000025840.17
Withdraw Token181867682024-12-08 11:21:005 days ago1733656860IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000013960.1272
Multicall181867562024-12-08 11:20:195 days ago1733656819IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000015470.1284
Withdraw Token181559002024-12-07 7:14:356 days ago1733555675IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.00001710.169
Withdraw Token181517242024-12-07 3:26:177 days ago1733541977IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000019970.182
Multicall181516942024-12-07 3:24:377 days ago1733541877IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000028120.185
Withdraw Token180122712024-12-01 15:06:0912 days ago1733065569IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000029850.272
Multicall180122582024-12-01 15:05:2512 days ago1733065525IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000040890.268
Multicall180122332024-12-01 15:03:3712 days ago1733065417IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000050110.28
Withdraw Token179845412024-11-30 11:43:3213 days ago1732967012IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000013150.13
Multicall179845222024-11-30 11:42:2613 days ago1732966946IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000013110.12
Withdraw Token179267462024-11-28 2:45:5516 days ago1732761955IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000018660.17
Multicall179265112024-11-28 2:32:2016 days ago1732761140IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.00002280.15
Withdraw Token179238282024-11-27 23:54:5616 days ago1732751696IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000020850.19
Multicall179238072024-11-27 23:53:4216 days ago1732751622IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.00001770.22
Multicall179237792024-11-27 23:52:0616 days ago1732751526IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000035970.21
Withdraw Token179186112024-11-27 18:47:5516 days ago1732733275IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000080020.729
Withdraw Token179008672024-11-27 1:06:1617 days ago1732669576IN
QuickSwap: Algebra Farming NFT-V2
0 ETH0.000016190.16
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
182871032024-12-12 7:11:1644 hrs ago1733987476
QuickSwap: Algebra Farming NFT-V2
0.00166972 ETH
182871032024-12-12 7:11:1644 hrs ago1733987476
QuickSwap: Algebra Farming NFT-V2
0.00166972 ETH
180122332024-12-01 15:03:3712 days ago1733065417
QuickSwap: Algebra Farming NFT-V2
0.00006422 ETH
180122332024-12-01 15:03:3712 days ago1733065417
QuickSwap: Algebra Farming NFT-V2
0.00006422 ETH
178590142024-11-25 7:04:4618 days ago1732518286
QuickSwap: Algebra Farming NFT-V2
0.00107839 ETH
178590142024-11-25 7:04:4618 days ago1732518286
QuickSwap: Algebra Farming NFT-V2
0.00107839 ETH
172598442024-11-01 6:57:1542 days ago1730444235
QuickSwap: Algebra Farming NFT-V2
0.01361618 ETH
172598442024-11-01 6:57:1542 days ago1730444235
QuickSwap: Algebra Farming NFT-V2
0.01361618 ETH
168120202024-10-14 15:59:0260 days ago1728921542
QuickSwap: Algebra Farming NFT-V2
0.00003757 ETH
168120202024-10-14 15:59:0260 days ago1728921542
QuickSwap: Algebra Farming NFT-V2
0.00003757 ETH
164276762024-09-29 15:22:4975 days ago1727623369
QuickSwap: Algebra Farming NFT-V2
0.06388534 ETH
164276762024-09-29 15:22:4975 days ago1727623369
QuickSwap: Algebra Farming NFT-V2
0.06388534 ETH
164075382024-09-28 22:29:1876 days ago1727562558
QuickSwap: Algebra Farming NFT-V2
0.00009097 ETH
164075382024-09-28 22:29:1876 days ago1727562558
QuickSwap: Algebra Farming NFT-V2
0.00009097 ETH
163611502024-09-27 7:32:5277 days ago1727422372
QuickSwap: Algebra Farming NFT-V2
0.00041228 ETH
163611502024-09-27 7:32:5277 days ago1727422372
QuickSwap: Algebra Farming NFT-V2
0.00041228 ETH
162515672024-09-23 11:33:0181 days ago1727091181
QuickSwap: Algebra Farming NFT-V2
0.00024053 ETH
162515672024-09-23 11:33:0181 days ago1727091181
QuickSwap: Algebra Farming NFT-V2
0.00024053 ETH
162478332024-09-23 8:24:5181 days ago1727079891
QuickSwap: Algebra Farming NFT-V2
0.00016306 ETH
162478332024-09-23 8:24:5181 days ago1727079891
QuickSwap: Algebra Farming NFT-V2
0.00016306 ETH
162276332024-09-22 15:29:3582 days ago1727018975
QuickSwap: Algebra Farming NFT-V2
0.00352454 ETH
162276332024-09-22 15:29:3582 days ago1727018975
QuickSwap: Algebra Farming NFT-V2
0.00352454 ETH
162276272024-09-22 15:29:1982 days ago1727018959
QuickSwap: Algebra Farming NFT-V2
0.00451398 ETH
162276272024-09-22 15:29:1982 days ago1727018959
QuickSwap: Algebra Farming NFT-V2
0.00451398 ETH
160433332024-09-16 4:57:4688 days ago1726462666
QuickSwap: Algebra Farming NFT-V2
0.00352255 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FarmingCenter

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 99999999 runs

Other Settings:
default evmVersion
File 1 of 50 : FarmingCenter.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.7.6;
pragma abicoder v2;
import './interfaces/IFarmingCenter.sol';
import './interfaces/IFarmingCenterVault.sol';

import 'algebra/contracts/interfaces/IAlgebraPool.sol';
import 'algebra/contracts/interfaces/IERC20Minimal.sol';

import 'algebra-periphery/contracts/interfaces/INonfungiblePositionManager.sol';
import 'algebra-periphery/contracts/base/Multicall.sol';
import 'algebra-periphery/contracts/base/ERC721Permit.sol';

import './base/PeripheryPayments.sol';
import './libraries/IncentiveId.sol';

/// @title Algebra main farming contract
/// @dev Manages farmings and performs entry, exit and other actions.
contract FarmingCenter is IFarmingCenter, ERC721Permit, Multicall, PeripheryPayments {
    IAlgebraLimitFarming public immutable override limitFarming;
    IAlgebraEternalFarming public immutable override eternalFarming;
    INonfungiblePositionManager public immutable override nonfungiblePositionManager;
    IFarmingCenterVault public immutable override farmingCenterVault;

    /// @dev The ID of the next token that will be minted. Skips 0
    uint256 private _nextId = 1;

    /// @dev saves addresses of virtual pools for pool
    mapping(address => VirtualPoolAddresses) private _virtualPoolAddresses;

    /// @dev deposits[tokenId] => Deposit
    mapping(uint256 => Deposit) public override deposits;

    mapping(uint256 => L2Nft) public override l2Nfts;

    /// @notice Represents the deposit of a liquidity NFT
    struct Deposit {
        uint256 L2TokenId;
        uint32 numberOfFarms;
        bool inLimitFarming;
        address owner;
    }

    /// @notice Represents the nft layer 2
    struct L2Nft {
        uint96 nonce; // the nonce for permits
        address operator; // the address that is approved for spending this token
        uint256 tokenId;
    }

    constructor(
        IAlgebraLimitFarming _limitFarming,
        IAlgebraEternalFarming _eternalFarming,
        INonfungiblePositionManager _nonfungiblePositionManager,
        IFarmingCenterVault _farmingCenterVault
    )
        ERC721Permit('Algebra Farming NFT-V2', 'ALGB-FARM', '2')
        PeripheryPayments(INonfungiblePositionManager(_nonfungiblePositionManager).WNativeToken())
    {
        limitFarming = _limitFarming;
        eternalFarming = _eternalFarming;
        nonfungiblePositionManager = _nonfungiblePositionManager;
        farmingCenterVault = _farmingCenterVault;
    }

    function checkAuthorizationForToken(uint256 tokenId) private view {
        require(_isApprovedOrOwner(msg.sender, tokenId), 'Not approved');
    }

    /// @notice Upon receiving a Algebra ERC721, creates the token deposit setting owner to `from`.
    /// @inheritdoc IERC721Receiver
    function onERC721Received(
        address,
        address from,
        uint256 tokenId,
        bytes calldata
    ) external override returns (bytes4) {
        require(msg.sender == address(nonfungiblePositionManager), 'not an Algebra nft');

        uint256 id = _nextId;
        Deposit storage newDeposit = deposits[tokenId];
        (newDeposit.L2TokenId, newDeposit.owner) = (id, from);

        l2Nfts[id].tokenId = tokenId;

        _mint(from, id);
        _nextId = id + 1;

        emit DepositTransferred(tokenId, address(0), from);

        return this.onERC721Received.selector;
    }

    function _getTokenBalanceOfVault(address token) private view returns (uint256 balance) {
        return IERC20Minimal(token).balanceOf(address(farmingCenterVault));
    }

    /// @inheritdoc IFarmingCenter
    function enterFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        uint256 tokensLocked,
        bool isLimit
    ) external override {
        Deposit storage _deposit = deposits[tokenId];
        checkAuthorizationForToken(_deposit.L2TokenId);
        (uint32 numberOfFarms, bool inLimitFarming) = (_deposit.numberOfFarms, _deposit.inLimitFarming);
        numberOfFarms++;
        IAlgebraFarming _farming;
        if (isLimit) {
            require(!inLimitFarming, 'token already farmed');
            inLimitFarming = true;
            _farming = IAlgebraFarming(limitFarming);
        } else _farming = IAlgebraFarming(eternalFarming);

        (_deposit.numberOfFarms, _deposit.inLimitFarming) = (numberOfFarms, inLimitFarming);
        bytes32 incentiveId = IncentiveId.compute(key);
        (, , , , , address multiplierToken, ) = _farming.incentives(incentiveId);
        if (tokensLocked > 0) {
            uint256 balanceBefore = _getTokenBalanceOfVault(multiplierToken);
            TransferHelper.safeTransferFrom(multiplierToken, msg.sender, address(farmingCenterVault), tokensLocked);
            uint256 balanceAfter = _getTokenBalanceOfVault(multiplierToken);
            require(balanceAfter > balanceBefore, 'Insufficient tokens locked');
            tokensLocked = balanceAfter - balanceBefore;
            farmingCenterVault.lockTokens(tokenId, incentiveId, tokensLocked);
        }

        _farming.enterFarming(key, tokenId, tokensLocked);
    }

    /// @inheritdoc IFarmingCenter
    function exitFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        bool isLimit
    ) external override {
        Deposit storage deposit = deposits[tokenId];
        checkAuthorizationForToken(deposit.L2TokenId);
        IAlgebraFarming _farming;

        deposit.numberOfFarms -= 1;
        deposit.owner = msg.sender;
        if (isLimit) {
            deposit.inLimitFarming = false;
            _farming = IAlgebraFarming(limitFarming);
        } else _farming = IAlgebraFarming(eternalFarming);

        _farming.exitFarming(key, tokenId, msg.sender);

        bytes32 incentiveId = IncentiveId.compute(key);
        (, , , , , address multiplierToken, ) = _farming.incentives(incentiveId);
        if (multiplierToken != address(0)) {
            farmingCenterVault.claimTokens(multiplierToken, msg.sender, tokenId, incentiveId);
        }
    }

    /// @inheritdoc IFarmingCenter
    function collect(INonfungiblePositionManager.CollectParams memory params)
        external
        override
        returns (uint256 amount0, uint256 amount1)
    {
        checkAuthorizationForToken(deposits[params.tokenId].L2TokenId);
        if (params.recipient == address(0)) {
            params.recipient = address(this);
        }
        return nonfungiblePositionManager.collect(params);
    }

    /// @inheritdoc IFarmingCenter
    function collectRewards(IncentiveKey memory key, uint256 tokenId)
        external
        override
        returns (uint256 reward, uint256 bonusReward)
    {
        checkAuthorizationForToken(deposits[tokenId].L2TokenId);
        address _virtualPool = _virtualPoolAddresses[address(key.pool)].eternalVirtualPool;
        if (_virtualPool != address(0)) {
            IAlgebraVirtualPool(_virtualPool).increaseCumulative(uint32(block.timestamp));
        }
        (reward, bonusReward) = eternalFarming.collectRewards(key, tokenId, msg.sender);
    }

    function _claimRewardFromFarming(
        IAlgebraFarming _farming,
        IERC20Minimal rewardToken,
        address to,
        uint256 amountRequested
    ) internal returns (uint256 reward) {
        return _farming.claimRewardFrom(rewardToken, msg.sender, to, amountRequested);
    }

    /// @inheritdoc IFarmingCenter
    function claimReward(
        IERC20Minimal rewardToken,
        address to,
        uint256 amountRequestedIncentive,
        uint256 amountRequestedEternal
    ) external override returns (uint256 reward) {
        if (amountRequestedIncentive != 0) {
            reward = _claimRewardFromFarming(limitFarming, rewardToken, to, amountRequestedIncentive);
        }
        if (amountRequestedEternal != 0) {
            reward += _claimRewardFromFarming(eternalFarming, rewardToken, to, amountRequestedEternal);
        }
    }

    /// @inheritdoc IFarmingCenter
    function connectVirtualPool(IAlgebraPool pool, address newVirtualPool) external override {
        bool isLimitFarming = msg.sender == address(limitFarming);
        require(isLimitFarming || msg.sender == address(eternalFarming), 'only farming can call this');

        VirtualPoolAddresses storage virtualPools = _virtualPoolAddresses[address(pool)];
        address newIncentive;
        if (pool.activeIncentive() == address(0)) {
            newIncentive = newVirtualPool; // turn on pool directly
        } else {
            if (newVirtualPool == address(0)) {
                // turn on directly another pool if it exists
                newIncentive = isLimitFarming ? virtualPools.eternalVirtualPool : virtualPools.limitVirtualPool;
            } else {
                newIncentive = address(this); // turn on via "proxy"
            }
        }

        pool.setIncentive(newIncentive);

        if (isLimitFarming) {
            virtualPools.limitVirtualPool = newVirtualPool;
        } else {
            virtualPools.eternalVirtualPool = newVirtualPool;
        }
    }

    /// @inheritdoc IFarmingCenter
    function withdrawToken(
        uint256 tokenId,
        address to,
        bytes memory data
    ) external override {
        require(to != address(this), 'cannot withdraw to farming');
        Deposit storage deposit = deposits[tokenId];
        uint256 l2TokenId = deposit.L2TokenId;

        checkAuthorizationForToken(l2TokenId);
        require(deposit.numberOfFarms == 0, 'cannot withdraw token while farmd');

        delete l2Nfts[l2TokenId];
        _burn(l2TokenId);
        delete deposits[tokenId];

        emit DepositTransferred(tokenId, msg.sender, address(0));
        nonfungiblePositionManager.safeTransferFrom(address(this), to, tokenId, data);
    }

    /**
     * @dev This function is called by the main pool when an initialized tick is crossed and two farmings are active at same time.
     * @param nextTick The crossed tick
     * @param zeroToOne The direction
     */
    function cross(int24 nextTick, bool zeroToOne) external override {
        VirtualPoolAddresses storage _virtualPoolAddressesForPool = _virtualPoolAddresses[msg.sender];

        IAlgebraVirtualPool(_virtualPoolAddressesForPool.eternalVirtualPool).cross(nextTick, zeroToOne);
        IAlgebraVirtualPool(_virtualPoolAddressesForPool.limitVirtualPool).cross(nextTick, zeroToOne);
    }

    /**
     * @dev This function is called by the main pool at start of the swap if two farmings are active at same time.
     * @param blockTimestamp The current block timestamp, truncated
     * @return status The current farming(s) status
     */
    function increaseCumulative(uint32 blockTimestamp) external override returns (Status status) {
        VirtualPoolAddresses storage _virtualPoolAddressesForPool = _virtualPoolAddresses[msg.sender];
        Status eternalStatus = IAlgebraVirtualPool(_virtualPoolAddressesForPool.eternalVirtualPool).increaseCumulative(
            blockTimestamp
        );

        Status limitStatus = IAlgebraVirtualPool(_virtualPoolAddressesForPool.limitVirtualPool).increaseCumulative(
            blockTimestamp
        );

        if (eternalStatus == Status.ACTIVE || limitStatus == Status.ACTIVE) {
            return Status.ACTIVE;
        } else if (limitStatus == Status.NOT_STARTED) {
            return Status.NOT_STARTED;
        }

        return Status.NOT_EXIST;
    }

    function virtualPoolAddresses(address pool) external view override returns (address limitVP, address eternalVP) {
        (limitVP, eternalVP) = (
            _virtualPoolAddresses[pool].limitVirtualPool,
            _virtualPoolAddresses[pool].eternalVirtualPool
        );
    }

    function _getAndIncrementNonce(uint256 tokenId) internal override returns (uint256) {
        return uint256(l2Nfts[tokenId].nonce++);
    }

    /// @inheritdoc IERC721
    function getApproved(uint256 tokenId) public view override(ERC721, IERC721) returns (address) {
        require(_exists(tokenId), 'ERC721: approved query for nonexistent token');

        return l2Nfts[tokenId].operator;
    }

    /// @dev Overrides _approve to use the operator in the position, which is packed with the position permit nonce
    function _approve(address to, uint256 tokenId) internal override(ERC721) {
        l2Nfts[tokenId].operator = to;
        emit Approval(ownerOf(tokenId), to, tokenId);
    }
}

File 2 of 50 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
abstract contract ERC165 is IERC165 {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    constructor () {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
}

File 3 of 50 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 4 of 50 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 50 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

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

File 6 of 50 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings for uint256;

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping (address => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.UintToAddressMap private _tokenOwners;

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping (uint256 => string) private _tokenURIs;

    // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

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

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
    }

    /**
     * @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) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(base, tokenId.toString()));
    }

    /**
    * @dev Returns the base URI set via {_setBaseURI}. This will be
    * automatically added as a prefix in {tokenURI} to each token's URI, or
    * to the token ID if no specific URI is set for that token ID.
    */
    function baseURI() public view virtual returns (string memory) {
        return _baseURI;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

    /**
     * @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 || ERC721.isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_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: transfer caller is not owner nor 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: transfer caller is not owner nor 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 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 _tokenOwners.contains(tokenId);
    }

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

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `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);

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId); // internal owner

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

        // Clear approvals
        _approve(address(0), tokenId);

        // Clear metadata (if any)
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

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

    /**
     * @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 of token that is not own"); // internal owner
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function _setBaseURI(string memory baseURI_) internal virtual {
        _baseURI = baseURI_;
    }

    /**
     * @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()) {
            return true;
        }
        bytes memory returndata = to.functionCall(abi.encodeWithSelector(
            IERC721Receiver(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721: transfer to non ERC721Receiver implementer");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

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

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

File 7 of 50 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

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

File 8 of 50 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 tokenId);

    /**
     * @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 9 of 50 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 10 of 50 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 11 of 50 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 12 of 50 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

File 13 of 50 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function _remove(Map storage map, bytes32 key) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function _contains(Map storage map, bytes32 key) private view returns (bool) {
        return map._indexes[key] != 0;
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

   /**
    * @dev Returns the key-value pair stored at position `index` in the map. O(1).
    *
    * Note that there are no guarantees on the ordering of entries inside the
    * array, and it may change when more entries are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
        require(map._entries.length > index, "EnumerableMap: index out of bounds");

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        uint256 keyIndex = map._indexes[key];
        if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
        return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
        return _remove(map._inner, bytes32(key));
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
        return _contains(map._inner, bytes32(key));
    }

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return _length(map._inner);
    }

   /**
    * @dev Returns the element stored at position `index` in the set. O(1).
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

File 14 of 50 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 15 of 50 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 16 of 50 : BlockTimestamp.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

/// @title Function for getting block timestamp
/// @dev Base contract that is overridden for tests
abstract contract BlockTimestamp {
    /// @dev Method that exists purely to be overridden for tests
    /// @return The current block timestamp
    function _blockTimestamp() internal view virtual returns (uint256) {
        return block.timestamp;
    }
}

File 17 of 50 : ERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/utils/Address.sol';

import '../libraries/ChainId.sol';
import '../interfaces/external/IERC1271.sol';
import '../interfaces/IERC721Permit.sol';
import './BlockTimestamp.sol';

/// @title ERC721 with permit
/// @notice Nonfungible tokens that support an approve via signature, i.e. permit
abstract contract ERC721Permit is BlockTimestamp, ERC721, IERC721Permit {
    /// @dev Gets the current nonce for a token ID and then increments it, returning the original value
    function _getAndIncrementNonce(uint256 tokenId) internal virtual returns (uint256);

    /// @dev The hash of the name used in the permit signature verification
    bytes32 private immutable nameHash;

    /// @dev The hash of the version string used in the permit signature verification
    bytes32 private immutable versionHash;

    /// @notice Computes the nameHash and versionHash
    constructor(
        string memory name_,
        string memory symbol_,
        string memory version_
    ) ERC721(name_, symbol_) {
        nameHash = keccak256(bytes(name_));
        versionHash = keccak256(bytes(version_));
    }

    /// @inheritdoc IERC721Permit
    function DOMAIN_SEPARATOR() public view override returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    // keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')
                    0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                    nameHash,
                    versionHash,
                    ChainId.get(),
                    address(this)
                )
            );
    }

    /// @inheritdoc IERC721Permit
    /// @dev Value is equal to keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)");
    bytes32 public constant override PERMIT_TYPEHASH =
        0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad;

    /// @inheritdoc IERC721Permit
    function permit(
        address spender,
        uint256 tokenId,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable override {
        require(_blockTimestamp() <= deadline, 'Permit expired');

        bytes32 digest = keccak256(
            abi.encodePacked(
                '\x19\x01',
                DOMAIN_SEPARATOR(),
                keccak256(abi.encode(PERMIT_TYPEHASH, spender, tokenId, _getAndIncrementNonce(tokenId), deadline))
            )
        );
        address owner = ownerOf(tokenId);
        require(spender != owner, 'ERC721Permit: approval to current owner');

        if (Address.isContract(owner)) {
            require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, 'Unauthorized');
        } else {
            address recoveredAddress = ecrecover(digest, v, r, s);
            require(recoveredAddress != address(0), 'Invalid signature');
            require(recoveredAddress == owner, 'Unauthorized');
        }

        _approve(spender, tokenId);
    }
}

File 18 of 50 : Multicall.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;

import '../interfaces/IMulticall.sol';

/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall is IMulticall {
    /// @inheritdoc IMulticall
    function multicall(bytes[] calldata data) external payable override returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}

File 19 of 50 : IERC1271.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Interface for verifying contract-based account signatures
/// @notice Interface that verifies provided signature for the data
/// @dev Interface defined by EIP-1271
interface IERC1271 {
    /// @notice Returns whether the provided signature is valid for the provided data
    /// @dev MUST return the bytes4 magic value 0x1626ba7e when function passes.
    /// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5).
    /// MUST allow external calls.
    /// @param hash Hash of the data to be signed
    /// @param signature Signature byte array associated with _data
    /// @return magicValue The bytes4 magic value 0x1626ba7e
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 20 of 50 : IWNativeToken.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

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

/// @title Interface for WNativeToken
interface IWNativeToken is IERC20 {
    /// @notice Deposit ether to get wrapped ether
    function deposit() external payable;

    /// @notice Withdraw wrapped ether to get ether
    function withdraw(uint256) external;
}

File 21 of 50 : IERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
    /// @notice The permit typehash used in the permit signature
    /// @return The typehash for the permit
    function PERMIT_TYPEHASH() external pure returns (bytes32);

    /// @notice The domain separator used in the permit signature
    /// @return The domain separator used in encoding of permit signature
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice Approve of a specific token ID for spending by spender via signature
    /// @param spender The account that is being approved
    /// @param tokenId The ID of the token that is being approved for spending
    /// @param deadline The deadline timestamp by which the call must be mined for the approve to work
    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
    function permit(
        address spender,
        uint256 tokenId,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;
}

File 22 of 50 : IMulticall.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Multicall interface
/// @notice Enables calling multiple methods in a single call to the contract
interface IMulticall {
    /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed
    /// @dev The `msg.value` should not be trusted for any method callable from multicall.
    /// @param data The encoded function data for each of the calls to make to this contract
    /// @return results The results from each of the calls passed in via data
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
}

File 23 of 50 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';

import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
import '../libraries/PoolAddress.sol';

/// @title Non-fungible token for positions
/// @notice Wraps Algebra positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface INonfungiblePositionManager is
    IPoolInitializer,
    IPeripheryPayments,
    IPeripheryImmutableState,
    IERC721Metadata,
    IERC721Enumerable,
    IERC721Permit
{
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param actualLiquidity the actual liquidity that was added into a pool. Could differ from
    /// _liquidity_ when using FeeOnTransfer tokens
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(
        uint256 indexed tokenId,
        uint128 liquidity,
        uint128 actualLiquidity,
        uint256 amount0,
        uint256 amount1,
        address pool
    );
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

    /// @notice Returns the position information associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the position
    /// @return nonce The nonce for permits
    /// @return operator The address that is approved for spending
    /// @return token0 The address of the token0 for a specific pool
    /// @return token1 The address of the token1 for a specific pool
    /// @return tickLower The lower end of the tick range for the position
    /// @return tickUpper The higher end of the tick range for the position
    /// @return liquidity The liquidity of the position
    /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
    /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
    /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
    /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    struct MintParams {
        address token0;
        address token1;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    /// @notice Creates a new position wrapped in a NFT
    /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
    /// a method does not exist, i.e. the pool is assumed to be initialized.
    /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
    /// @return tokenId The ID of the token that represents the minted position
    /// @return liquidity The amount of liquidity for this position
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
    /// @param params tokenId The ID of the token for which liquidity is being increased,
    /// amount0Desired The desired amount of token0 to be spent,
    /// amount1Desired The desired amount of token1 to be spent,
    /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
    /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return liquidity The new liquidity amount as a result of the increase
    /// @return amount0 The amount of token0 to achieve resulting liquidity
    /// @return amount1 The amount of token1 to achieve resulting liquidity
    function increaseLiquidity(IncreaseLiquidityParams calldata params)
        external
        payable
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Decreases the amount of liquidity in a position and accounts it to the position
    /// @param params tokenId The ID of the token for which liquidity is being decreased,
    /// amount The amount by which liquidity will be decreased,
    /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
    /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return amount0 The amount of token0 accounted to the position's tokens owed
    /// @return amount1 The amount of token1 accounted to the position's tokens owed
    function decreaseLiquidity(DecreaseLiquidityParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);

    /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
    /// must be collected first.
    /// @param tokenId The ID of the token that is being burned
    function burn(uint256 tokenId) external payable;
}

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

/// @title Immutable state
/// @notice Functions that return immutable state of the router
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPeripheryImmutableState {
    /// @return Returns the address of the Algebra factory
    function factory() external view returns (address);

    /// @return Returns the address of the pool Deployer
    function poolDeployer() external view returns (address);

    /// @return Returns the address of WNativeToken
    function WNativeToken() external view returns (address);
}

File 25 of 50 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of NativeToken
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WNativeToken balance and sends it to recipient as NativeToken.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WNativeToken from users.
    /// @param amountMinimum The minimum amount of WNativeToken to unwrap
    /// @param recipient The address receiving NativeToken
    function unwrapWNativeToken(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any NativeToken balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundNativeToken() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

File 26 of 50 : IPoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPoolInitializer {
    /// @notice Creates a new pool if it does not exist, then initializes if not initialized
    /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
    /// @param token0 The contract address of token0 of the pool
    /// @param token1 The contract address of token1 of the pool
    /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
    /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
    function createAndInitializePoolIfNecessary(
        address token0,
        address token1,
        uint160 sqrtPriceX96
    ) external payable returns (address pool);
}

File 27 of 50 : ChainId.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.0;

/// @title Function for getting the current chain ID
library ChainId {
    /// @dev Gets the current chain ID
    /// @return chainId The current chain ID
    function get() internal pure returns (uint256 chainId) {
        assembly {
            chainId := chainid()
        }
    }
}

File 28 of 50 : PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH = 0x6ec6c9c8091d160c0aa74b2b14ba9c1717e95093bd3ac085cee99a49aab294a4;

    /// @notice The identifying key of the pool
    struct PoolKey {
        address token0;
        address token1;
    }

    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels
    /// @param tokenA The first token of a pool, unsorted
    /// @param tokenB The second token of a pool, unsorted
    /// @return Poolkey The pool details with ordered token0 and token1 assignments
    function getPoolKey(address tokenA, address tokenB) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB});
    }

    /// @notice Deterministically computes the pool address given the factory and PoolKey
    /// @param factory The Algebra factory contract address
    /// @param key The PoolKey
    /// @return pool The contract address of the V3 pool
    function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        pool = address(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex'ff',
                        factory,
                        keccak256(abi.encode(key.token0, key.token1)),
                        POOL_INIT_CODE_HASH
                    )
                )
            )
        );
    }
}

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

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

/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
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 NativeToken to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferNative(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 30 of 50 : IAlgebraPool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import './pool/IAlgebraPoolImmutables.sol';
import './pool/IAlgebraPoolState.sol';
import './pool/IAlgebraPoolDerivedState.sol';
import './pool/IAlgebraPoolActions.sol';
import './pool/IAlgebraPoolPermissionedActions.sol';
import './pool/IAlgebraPoolEvents.sol';

/**
 * @title The interface for a Algebra Pool
 * @dev The pool interface is broken up into many smaller pieces.
 * Credit to Uniswap Labs under GPL-2.0-or-later license:
 * https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
 */
interface IAlgebraPool is
  IAlgebraPoolImmutables,
  IAlgebraPoolState,
  IAlgebraPoolDerivedState,
  IAlgebraPoolActions,
  IAlgebraPoolPermissionedActions,
  IAlgebraPoolEvents
{
  // used only for combining interfaces
}

File 31 of 50 : IAlgebraPoolDeployer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/**
 * @title An interface for a contract that is capable of deploying Algebra Pools
 * @notice A contract that constructs a pool must implement this to pass arguments to the pool
 * @dev This is used to avoid having constructor arguments in the pool contract, which results in the init code hash
 * of the pool being constant allowing the CREATE2 address of the pool to be cheaply computed on-chain.
 * Credit to Uniswap Labs under GPL-2.0-or-later license:
 * https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
 */
interface IAlgebraPoolDeployer {
  /**
   *  @notice Emitted when the factory address is changed
   *  @param factory The factory address after the address was changed
   */
  event Factory(address indexed factory);

  /**
   * @notice Get the parameters to be used in constructing the pool, set transiently during pool creation.
   * @dev Called by the pool constructor to fetch the parameters of the pool
   * Returns dataStorage The pools associated dataStorage
   * Returns factory The factory address
   * Returns token0 The first token of the pool by address sort order
   * Returns token1 The second token of the pool by address sort order
   */
  function parameters()
    external
    view
    returns (
      address dataStorage,
      address factory,
      address token0,
      address token1
    );

  /**
   * @dev Deploys a pool with the given parameters by transiently setting the parameters storage slot and then
   * clearing it after deploying the pool.
   * @param dataStorage The pools associated dataStorage
   * @param factory The contract address of the Algebra factory
   * @param token0 The first token of the pool by address sort order
   * @param token1 The second token of the pool by address sort order
   * @return pool The deployed pool's address
   */
  function deploy(
    address dataStorage,
    address factory,
    address token0,
    address token1
  ) external returns (address pool);

  /**
   * @dev Sets the factory address to the poolDeployer for permissioned actions
   * @param factory The address of the Algebra factory
   */
  function setFactory(address factory) external;
}

File 32 of 50 : IAlgebraVirtualPool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IAlgebraVirtualPool {
  enum Status {
    NOT_EXIST,
    ACTIVE,
    NOT_STARTED
  }

  /**
   * @dev This function is called by the main pool when an initialized tick is crossed there.
   * If the tick is also initialized in a virtual pool it should be crossed too
   * @param nextTick The crossed tick
   * @param zeroToOne The direction
   */
  function cross(int24 nextTick, bool zeroToOne) external;

  /**
   * @dev This function is called from the main pool before every swap To increase seconds per liquidity
   * cumulative considering previous timestamp and liquidity. The liquidity is stored in a virtual pool
   * @param currentTimestamp The timestamp of the current swap
   * @return Status The status of virtual pool
   */
  function increaseCumulative(uint32 currentTimestamp) external returns (Status);
}

File 33 of 50 : IDataStorageOperator.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
pragma abicoder v2;

import '../libraries/AdaptiveFee.sol';

interface IDataStorageOperator {
  event FeeConfiguration(AdaptiveFee.Configuration feeConfig);

  /**
   * @notice Returns data belonging to a certain timepoint
   * @param index The index of timepoint in the array
   * @dev There is more convenient function to fetch a timepoint: observe(). Which requires not an index but seconds
   * @return initialized Whether the timepoint has been initialized and the values are safe to use,
   * blockTimestamp The timestamp of the observation,
   * tickCumulative The tick multiplied by seconds elapsed for the life of the pool as of the timepoint timestamp,
   * secondsPerLiquidityCumulative The seconds per in range liquidity for the life of the pool as of the timepoint timestamp,
   * volatilityCumulative Cumulative standard deviation for the life of the pool as of the timepoint timestamp,
   * averageTick Time-weighted average tick,
   * volumePerLiquidityCumulative Cumulative swap volume per liquidity for the life of the pool as of the timepoint timestamp
   */
  function timepoints(uint256 index)
    external
    view
    returns (
      bool initialized,
      uint32 blockTimestamp,
      int56 tickCumulative,
      uint160 secondsPerLiquidityCumulative,
      uint88 volatilityCumulative,
      int24 averageTick,
      uint144 volumePerLiquidityCumulative
    );

  /// @notice Initialize the dataStorage array by writing the first slot. Called once for the lifecycle of the timepoints array
  /// @param time The time of the dataStorage initialization, via block.timestamp truncated to uint32
  /// @param tick Initial tick
  function initialize(uint32 time, int24 tick) external;

  /// @dev Reverts if an timepoint at or before the desired timepoint timestamp does not exist.
  /// 0 may be passed as `secondsAgo' to return the current cumulative values.
  /// If called with a timestamp falling between two timepoints, returns the counterfactual accumulator values
  /// at exactly the timestamp between the two timepoints.
  /// @param time The current block timestamp
  /// @param secondsAgo The amount of time to look back, in seconds, at which point to return an timepoint
  /// @param tick The current tick
  /// @param index The index of the timepoint that was most recently written to the timepoints array
  /// @param liquidity The current in-range pool liquidity
  /// @return tickCumulative The cumulative tick since the pool was first initialized, as of `secondsAgo`
  /// @return secondsPerLiquidityCumulative The cumulative seconds / max(1, liquidity) since the pool was first initialized, as of `secondsAgo`
  /// @return volatilityCumulative The cumulative volatility value since the pool was first initialized, as of `secondsAgo`
  /// @return volumePerAvgLiquidity The cumulative volume per liquidity value since the pool was first initialized, as of `secondsAgo`
  function getSingleTimepoint(
    uint32 time,
    uint32 secondsAgo,
    int24 tick,
    uint16 index,
    uint128 liquidity
  )
    external
    view
    returns (
      int56 tickCumulative,
      uint160 secondsPerLiquidityCumulative,
      uint112 volatilityCumulative,
      uint256 volumePerAvgLiquidity
    );

  /// @notice Returns the accumulator values as of each time seconds ago from the given time in the array of `secondsAgos`
  /// @dev Reverts if `secondsAgos` > oldest timepoint
  /// @param time The current block.timestamp
  /// @param secondsAgos Each amount of time to look back, in seconds, at which point to return an timepoint
  /// @param tick The current tick
  /// @param index The index of the timepoint that was most recently written to the timepoints array
  /// @param liquidity The current in-range pool liquidity
  /// @return tickCumulatives The cumulative tick since the pool was first initialized, as of each `secondsAgo`
  /// @return secondsPerLiquidityCumulatives The cumulative seconds / max(1, liquidity) since the pool was first initialized, as of each `secondsAgo`
  /// @return volatilityCumulatives The cumulative volatility values since the pool was first initialized, as of each `secondsAgo`
  /// @return volumePerAvgLiquiditys The cumulative volume per liquidity values since the pool was first initialized, as of each `secondsAgo`
  function getTimepoints(
    uint32 time,
    uint32[] memory secondsAgos,
    int24 tick,
    uint16 index,
    uint128 liquidity
  )
    external
    view
    returns (
      int56[] memory tickCumulatives,
      uint160[] memory secondsPerLiquidityCumulatives,
      uint112[] memory volatilityCumulatives,
      uint256[] memory volumePerAvgLiquiditys
    );

  /// @notice Returns average volatility in the range from time-WINDOW to time
  /// @param time The current block.timestamp
  /// @param tick The current tick
  /// @param index The index of the timepoint that was most recently written to the timepoints array
  /// @param liquidity The current in-range pool liquidity
  /// @return TWVolatilityAverage The average volatility in the recent range
  /// @return TWVolumePerLiqAverage The average volume per liquidity in the recent range
  function getAverages(
    uint32 time,
    int24 tick,
    uint16 index,
    uint128 liquidity
  ) external view returns (uint112 TWVolatilityAverage, uint256 TWVolumePerLiqAverage);

  /// @notice Writes an dataStorage timepoint to the array
  /// @dev Writable at most once per block. Index represents the most recently written element. index must be tracked externally.
  /// @param index The index of the timepoint that was most recently written to the timepoints array
  /// @param blockTimestamp The timestamp of the new timepoint
  /// @param tick The active tick at the time of the new timepoint
  /// @param liquidity The total in-range liquidity at the time of the new timepoint
  /// @param volumePerLiquidity The gmean(volumes)/liquidity at the time of the new timepoint
  /// @return indexUpdated The new index of the most recently written element in the dataStorage array
  function write(
    uint16 index,
    uint32 blockTimestamp,
    int24 tick,
    uint128 liquidity,
    uint128 volumePerLiquidity
  ) external returns (uint16 indexUpdated);

  /// @notice Changes fee configuration for the pool
  function changeFeeConfiguration(AdaptiveFee.Configuration calldata feeConfig) external;

  /// @notice Calculates gmean(volume/liquidity) for block
  /// @param liquidity The current in-range pool liquidity
  /// @param amount0 Total amount of swapped token0
  /// @param amount1 Total amount of swapped token1
  /// @return volumePerLiquidity gmean(volume/liquidity) capped by 100000 << 64
  function calculateVolumePerLiquidity(
    uint128 liquidity,
    int256 amount0,
    int256 amount1
  ) external pure returns (uint128 volumePerLiquidity);

  /// @return windowLength Length of window used to calculate averages
  function window() external view returns (uint32 windowLength);

  /// @notice Calculates fee based on combination of sigmoids
  /// @param time The current block.timestamp
  /// @param tick The current tick
  /// @param index The index of the timepoint that was most recently written to the timepoints array
  /// @param liquidity The current in-range pool liquidity
  /// @return fee The fee in hundredths of a bip, i.e. 1e-6
  function getFee(
    uint32 time,
    int24 tick,
    uint16 index,
    uint128 liquidity
  ) external view returns (uint16 fee);
}

File 34 of 50 : IERC20Minimal.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Minimal ERC20 interface for Algebra
/// @notice Contains a subset of the full ERC20 interface that is used in Algebra
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IERC20Minimal {
  /// @notice Returns the balance of a token
  /// @param account The account for which to look up the number of tokens it has, i.e. its balance
  /// @return The number of tokens held by the account
  function balanceOf(address account) external view returns (uint256);

  /// @notice Transfers the amount of token from the `msg.sender` to the recipient
  /// @param recipient The account that will receive the amount transferred
  /// @param amount The number of tokens to send from the sender to the recipient
  /// @return Returns true for a successful transfer, false for an unsuccessful transfer
  function transfer(address recipient, uint256 amount) external returns (bool);

  /// @notice Returns the current allowance given to a spender by an owner
  /// @param owner The account of the token owner
  /// @param spender The account of the token spender
  /// @return The current allowance granted by `owner` to `spender`
  function allowance(address owner, address spender) external view returns (uint256);

  /// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
  /// @param spender The account which will be allowed to spend a given amount of the owners tokens
  /// @param amount The amount of tokens allowed to be used by `spender`
  /// @return Returns true for a successful approval, false for unsuccessful
  function approve(address spender, uint256 amount) external returns (bool);

  /// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
  /// @param sender The account from which the transfer will be initiated
  /// @param recipient The recipient of the transfer
  /// @param amount The amount of the transfer
  /// @return Returns true for a successful transfer, false for unsuccessful
  function transferFrom(
    address sender,
    address recipient,
    uint256 amount
  ) external returns (bool);

  /// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
  /// @param from The account from which the tokens were sent, i.e. the balance decreased
  /// @param to The account to which the tokens were sent, i.e. the balance increased
  /// @param value The amount of tokens that were transferred
  event Transfer(address indexed from, address indexed to, uint256 value);

  /// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
  /// @param owner The account that approved spending of its tokens
  /// @param spender The account for which the spending allowance was modified
  /// @param value The new allowance from the owner to the spender
  event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 35 of 50 : IAlgebraPoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolActions {
  /**
   * @notice Sets the initial price for the pool
   * @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
   * @param price the initial sqrt price of the pool as a Q64.96
   */
  function initialize(uint160 price) external;

  /**
   * @notice Adds liquidity for the given recipient/bottomTick/topTick position
   * @dev The caller of this method receives a callback in the form of IAlgebraMintCallback# AlgebraMintCallback
   * in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
   * on bottomTick, topTick, the amount of liquidity, and the current price.
   * @param sender The address which will receive potential surplus of paid tokens
   * @param recipient The address for which the liquidity will be created
   * @param bottomTick The lower tick of the position in which to add liquidity
   * @param topTick The upper tick of the position in which to add liquidity
   * @param amount The desired 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
   * @return liquidityActual The actual minted amount of liquidity
   */
  function mint(
    address sender,
    address recipient,
    int24 bottomTick,
    int24 topTick,
    uint128 amount,
    bytes calldata data
  )
    external
    returns (
      uint256 amount0,
      uint256 amount1,
      uint128 liquidityActual
    );

  /**
   * @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 bottomTick The lower tick of the position for which to collect fees
   * @param topTick 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 bottomTick,
    int24 topTick,
    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 bottomTick The lower tick of the position for which to burn liquidity
   * @param topTick 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 bottomTick,
    int24 topTick,
    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 IAlgebraSwapCallback# AlgebraSwapCallback
   * @param recipient The address to receive the output of the swap
   * @param zeroToOne 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 limitSqrtPrice 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. If using the Router it should contain
   * SwapRouter#SwapCallbackData
   * @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 zeroToOne,
    int256 amountSpecified,
    uint160 limitSqrtPrice,
    bytes calldata data
  ) external returns (int256 amount0, int256 amount1);

  /**
   * @notice Swap token0 for token1, or token1 for token0 (tokens that have fee on transfer)
   * @dev The caller of this method receives a callback in the form of I AlgebraSwapCallback# AlgebraSwapCallback
   * @param sender The address called this function (Comes from the Router)
   * @param recipient The address to receive the output of the swap
   * @param zeroToOne 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 limitSqrtPrice 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. If using the Router it should contain
   * SwapRouter#SwapCallbackData
   * @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 swapSupportingFeeOnInputTokens(
    address sender,
    address recipient,
    bool zeroToOne,
    int256 amountSpecified,
    uint160 limitSqrtPrice,
    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 IAlgebraFlashCallback# AlgebraFlashCallback
   * @dev All excess tokens paid in the callback are distributed to liquidity providers as an additional fee. So this method can be used
   * to donate underlying tokens 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;
}

File 36 of 50 : IAlgebraPoolDerivedState.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.
 * @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
 * https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
 */
interface IAlgebraPoolDerivedState {
  /**
   * @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 secondsPerLiquidityCumulatives Cumulative seconds per liquidity-in-range value as of each `secondsAgos`
   * from the current block timestamp
   * @return volatilityCumulatives Cumulative standard deviation as of each `secondsAgos`
   * @return volumePerAvgLiquiditys Cumulative swap volume per liquidity as of each `secondsAgos`
   */
  function getTimepoints(uint32[] calldata secondsAgos)
    external
    view
    returns (
      int56[] memory tickCumulatives,
      uint160[] memory secondsPerLiquidityCumulatives,
      uint112[] memory volatilityCumulatives,
      uint256[] memory volumePerAvgLiquiditys
    );

  /**
   * @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 bottomTick The lower tick of the range
   * @param topTick The upper tick of the range
   * @return innerTickCumulative The snapshot of the tick accumulator for the range
   * @return innerSecondsSpentPerLiquidity The snapshot of seconds per liquidity for the range
   * @return innerSecondsSpent The snapshot of the number of seconds during which the price was in this range
   */
  function getInnerCumulatives(int24 bottomTick, int24 topTick)
    external
    view
    returns (
      int56 innerTickCumulative,
      uint160 innerSecondsSpentPerLiquidity,
      uint32 innerSecondsSpent
    );
}

File 37 of 50 : IAlgebraPoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolEvents {
  /**
   * @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 price 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 price, 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 bottomTick The lower tick of the position
   * @param topTick The upper tick of the position
   * @param liquidityAmount 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 bottomTick,
    int24 indexed topTick,
    uint128 liquidityAmount,
    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 recipient The address that received fees
   * @param bottomTick The lower tick of the position
   * @param topTick 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 bottomTick, int24 indexed topTick, 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 bottomTick The lower tick of the position
   * @param topTick The upper tick of the position
   * @param liquidityAmount 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 bottomTick, int24 indexed topTick, uint128 liquidityAmount, 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 price 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 price, 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 when the community fee is changed by the pool
   * @param communityFee0New The updated value of the token0 community fee percent
   * @param communityFee1New The updated value of the token1 community fee percent
   */
  event CommunityFee(uint8 communityFee0New, uint8 communityFee1New);

  /**
   * @notice Emitted when new activeIncentive is set
   * @param virtualPoolAddress The address of a virtual pool associated with the current active incentive
   */
  event Incentive(address indexed virtualPoolAddress);

  /**
   * @notice Emitted when the fee changes
   * @param fee The value of the token fee
   */
  event Fee(uint16 fee);

  /**
   * @notice Emitted when the LiquidityCooldown changes
   * @param liquidityCooldown The value of locktime for added liquidity
   */
  event LiquidityCooldown(uint32 liquidityCooldown);
}

File 38 of 50 : IAlgebraPoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import '../IDataStorageOperator.sol';

/// @title Pool state that never changes
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolImmutables {
  /**
   * @notice The contract that stores all the timepoints and can perform actions with them
   * @return The operator address
   */
  function dataStorageOperator() external view returns (address);

  /**
   * @notice The contract that deployed the pool, which must adhere to the IAlgebraFactory 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 tick spacing
   * @dev Ticks can only be used at multiples of this value
   * e.g.: a tickSpacing of 60 means ticks can be initialized every 60th tick, i.e., ..., -120, -60, 0, 60, 120, ...
   * 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 39 of 50 : IAlgebraPoolPermissionedActions.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 or tokenomics
 * @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
 * https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
 */
interface IAlgebraPoolPermissionedActions {
  /**
   * @notice Set the community's % share of the fees. Cannot exceed 25% (250)
   * @param communityFee0 new community fee percent for token0 of the pool in thousandths (1e-3)
   * @param communityFee1 new community fee percent for token1 of the pool in thousandths (1e-3)
   */
  function setCommunityFee(uint8 communityFee0, uint8 communityFee1) external;

  /**
   * @notice Sets an active incentive
   * @param virtualPoolAddress The address of a virtual pool associated with the incentive
   */
  function setIncentive(address virtualPoolAddress) external;

  /**
   * @notice Sets new lock time for added liquidity
   * @param newLiquidityCooldown The time in seconds
   */
  function setLiquidityCooldown(uint32 newLiquidityCooldown) external;
}

File 40 of 50 : IAlgebraPoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolState {
  /**
   * @notice The globalState structure in the pool stores many values but requires only one slot
   * and is exposed as a single method to save gas when accessed externally.
   * @return price The current price of the pool as a sqrt(token1/token0) Q64.96 value;
   * Returns tick The current tick of the pool, i.e. according to the last tick transition that was run;
   * Returns This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(price) if the price is on a tick
   * boundary;
   * Returns fee The last pool fee value in hundredths of a bip, i.e. 1e-6;
   * Returns timepointIndex The index of the last written timepoint;
   * Returns communityFeeToken0 The community fee percentage of the swap fee in thousandths (1e-3) for token0;
   * Returns communityFeeToken1 The community fee percentage of the swap fee in thousandths (1e-3) for token1;
   * Returns unlocked Whether the pool is currently locked to reentrancy;
   */
  function globalState()
    external
    view
    returns (
      uint160 price,
      int24 tick,
      uint16 fee,
      uint16 timepointIndex,
      uint8 communityFeeToken0,
      uint8 communityFeeToken1,
      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 totalFeeGrowth0Token() 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 totalFeeGrowth1Token() external view returns (uint256);

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

  /**
   * @notice Look up information about a specific tick in the pool
   * @dev This is a public structure, so the `return` natspec tags are omitted.
   * @param tick The tick to look up
   * @return liquidityTotal the total amount of position liquidity that uses the pool either as tick lower or
   * tick upper;
   * Returns liquidityDelta how much liquidity changes when the pool price crosses the tick;
   * Returns outerFeeGrowth0Token the fee growth on the other side of the tick from the current tick in token0;
   * Returns outerFeeGrowth1Token the fee growth on the other side of the tick from the current tick in token1;
   * Returns outerTickCumulative the cumulative tick value on the other side of the tick from the current tick;
   * Returns outerSecondsPerLiquidity the seconds spent per liquidity on the other side of the tick from the current tick;
   * Returns outerSecondsSpent the seconds spent on the other side of the tick from the current tick;
   * Returns initialized Set to true if the tick is initialized, i.e. liquidityTotal is greater than 0
   * otherwise equal to false. Outside values can only be used if the tick is initialized.
   * 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 liquidityTotal,
      int128 liquidityDelta,
      uint256 outerFeeGrowth0Token,
      uint256 outerFeeGrowth1Token,
      int56 outerTickCumulative,
      uint160 outerSecondsPerLiquidity,
      uint32 outerSecondsSpent,
      bool initialized
    );

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

  /**
   * @notice Returns the information about a position by the position's key
   * @dev This is a public mapping of structures, so the `return` natspec tags are omitted.
   * @param key The position's key is a hash of a preimage composed by the owner, bottomTick and topTick
   * @return liquidityAmount The amount of liquidity in the position;
   * Returns lastLiquidityAddTimestamp Timestamp of last adding of liquidity;
   * Returns innerFeeGrowth0Token Fee growth of token0 inside the tick range as of the last mint/burn/poke;
   * Returns innerFeeGrowth1Token Fee growth of token1 inside the tick range as of the last mint/burn/poke;
   * Returns fees0 The computed amount of token0 owed to the position as of the last mint/burn/poke;
   * Returns fees1 The computed amount of token1 owed to the position as of the last mint/burn/poke
   */
  function positions(bytes32 key)
    external
    view
    returns (
      uint128 liquidityAmount,
      uint32 lastLiquidityAddTimestamp,
      uint256 innerFeeGrowth0Token,
      uint256 innerFeeGrowth1Token,
      uint128 fees0,
      uint128 fees1
    );

  /**
   * @notice Returns data about a specific timepoint index
   * @param index The element of the timepoints array to fetch
   * @dev You most likely want to use #getTimepoints() instead of this method to get an timepoint as of some amount of time
   * ago, rather than at a specific index in the array.
   * This is a public mapping of structures, so the `return` natspec tags are omitted.
   * @return initialized whether the timepoint has been initialized and the values are safe to use;
   * Returns blockTimestamp The timestamp of the timepoint;
   * Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the timepoint timestamp;
   * Returns secondsPerLiquidityCumulative the seconds per in range liquidity for the life of the pool as of the timepoint timestamp;
   * Returns volatilityCumulative Cumulative standard deviation for the life of the pool as of the timepoint timestamp;
   * Returns averageTick Time-weighted average tick;
   * Returns volumePerLiquidityCumulative Cumulative swap volume per liquidity for the life of the pool as of the timepoint timestamp;
   */
  function timepoints(uint256 index)
    external
    view
    returns (
      bool initialized,
      uint32 blockTimestamp,
      int56 tickCumulative,
      uint160 secondsPerLiquidityCumulative,
      uint88 volatilityCumulative,
      int24 averageTick,
      uint144 volumePerLiquidityCumulative
    );

  /**
   * @notice Returns the information about active incentive
   * @dev if there is no active incentive at the moment, virtualPool,endTimestamp,startTimestamp would be equal to 0
   * @return virtualPool The address of a virtual pool associated with the current active incentive
   */
  function activeIncentive() external view returns (address virtualPool);

  /**
   * @notice Returns the lock time for added liquidity
   */
  function liquidityCooldown() external view returns (uint32 cooldownInSeconds);
}

File 41 of 50 : AdaptiveFee.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.7.6;

import './Constants.sol';

/// @title AdaptiveFee
/// @notice Calculates fee based on combination of sigmoids
library AdaptiveFee {
  // alpha1 + alpha2 + baseFee must be <= type(uint16).max
  struct Configuration {
    uint16 alpha1; // max value of the first sigmoid
    uint16 alpha2; // max value of the second sigmoid
    uint32 beta1; // shift along the x-axis for the first sigmoid
    uint32 beta2; // shift along the x-axis for the second sigmoid
    uint16 gamma1; // horizontal stretch factor for the first sigmoid
    uint16 gamma2; // horizontal stretch factor for the second sigmoid
    uint32 volumeBeta; // shift along the x-axis for the outer volume-sigmoid
    uint16 volumeGamma; // horizontal stretch factor the outer volume-sigmoid
    uint16 baseFee; // minimum possible fee
  }

  /// @notice Calculates fee based on formula:
  /// baseFee + sigmoidVolume(sigmoid1(volatility, volumePerLiquidity) + sigmoid2(volatility, volumePerLiquidity))
  /// maximum value capped by baseFee + alpha1 + alpha2
  function getFee(
    uint88 volatility,
    uint256 volumePerLiquidity,
    Configuration memory config
  ) internal pure returns (uint16 fee) {
    uint256 sumOfSigmoids = sigmoid(volatility, config.gamma1, config.alpha1, config.beta1) +
      sigmoid(volatility, config.gamma2, config.alpha2, config.beta2);

    if (sumOfSigmoids > type(uint16).max) {
      // should be impossible, just in case
      sumOfSigmoids = type(uint16).max;
    }

    return uint16(config.baseFee + sigmoid(volumePerLiquidity, config.volumeGamma, uint16(sumOfSigmoids), config.volumeBeta)); // safe since alpha1 + alpha2 + baseFee _must_ be <= type(uint16).max
  }

  /// @notice calculates α / (1 + e^( (β-x) / γ))
  /// that is a sigmoid with a maximum value of α, x-shifted by β, and stretched by γ
  /// @dev returns uint256 for fuzzy testing. Guaranteed that the result is not greater than alpha
  function sigmoid(
    uint256 x,
    uint16 g,
    uint16 alpha,
    uint256 beta
  ) internal pure returns (uint256 res) {
    if (x > beta) {
      x = x - beta;
      if (x >= 6 * uint256(g)) return alpha; // so x < 19 bits
      uint256 g8 = uint256(g)**8; // < 128 bits (8*16)
      uint256 ex = exp(x, g, g8); // < 155 bits
      res = (alpha * ex) / (g8 + ex); // in worst case: (16 + 155 bits) / 155 bits
      // so res <= alpha
    } else {
      x = beta - x;
      if (x >= 6 * uint256(g)) return 0; // so x < 19 bits
      uint256 g8 = uint256(g)**8; // < 128 bits (8*16)
      uint256 ex = g8 + exp(x, g, g8); // < 156 bits
      res = (alpha * g8) / ex; // in worst case: (16 + 128 bits) / 156 bits
      // g8 <= ex, so res <= alpha
    }
  }

  /// @notice calculates e^(x/g) * g^8 in a series, since (around zero):
  /// e^x = 1 + x + x^2/2 + ... + x^n/n! + ...
  /// e^(x/g) = 1 + x/g + x^2/(2*g^2) + ... + x^(n)/(g^n * n!) + ...
  function exp(
    uint256 x,
    uint16 g,
    uint256 gHighestDegree
  ) internal pure returns (uint256 res) {
    // calculating:
    // g**8 + x * g**7 + (x**2 * g**6) / 2 + (x**3 * g**5) / 6 + (x**4 * g**4) / 24 + (x**5 * g**3) / 120 + (x**6 * g^2) / 720 + x**7 * g / 5040 + x**8 / 40320

    // x**8 < 152 bits (19*8) and g**8 < 128 bits (8*16)
    // so each summand < 152 bits and res < 155 bits
    uint256 xLowestDegree = x;
    res = gHighestDegree; // g**8

    gHighestDegree /= g; // g**7
    res += xLowestDegree * gHighestDegree;

    gHighestDegree /= g; // g**6
    xLowestDegree *= x; // x**2
    res += (xLowestDegree * gHighestDegree) / 2;

    gHighestDegree /= g; // g**5
    xLowestDegree *= x; // x**3
    res += (xLowestDegree * gHighestDegree) / 6;

    gHighestDegree /= g; // g**4
    xLowestDegree *= x; // x**4
    res += (xLowestDegree * gHighestDegree) / 24;

    gHighestDegree /= g; // g**3
    xLowestDegree *= x; // x**5
    res += (xLowestDegree * gHighestDegree) / 120;

    gHighestDegree /= g; // g**2
    xLowestDegree *= x; // x**6
    res += (xLowestDegree * gHighestDegree) / 720;

    xLowestDegree *= x; // x**7
    res += (xLowestDegree * g) / 5040 + (xLowestDegree * x) / (40320);
  }
}

File 42 of 50 : Constants.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

library Constants {
  uint8 internal constant RESOLUTION = 96;
  uint256 internal constant Q96 = 0x1000000000000000000000000;
  uint256 internal constant Q128 = 0x100000000000000000000000000000000;
  // fee value in hundredths of a bip, i.e. 1e-6
  uint16 internal constant BASE_FEE = 100;
  int24 internal constant TICK_SPACING = 60;

  // max(uint128) / ( (MAX_TICK - MIN_TICK) / TICK_SPACING )
  uint128 internal constant MAX_LIQUIDITY_PER_TICK = 11505743598341114571880798222544994;

  uint32 internal constant MAX_LIQUIDITY_COOLDOWN = 1 days;
  uint8 internal constant MAX_COMMUNITY_FEE = 250;
  uint256 internal constant COMMUNITY_FEE_DENOMINATOR = 1000;
}

File 43 of 50 : PeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

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

import 'algebra-periphery/contracts/interfaces/IPeripheryPayments.sol';
import 'algebra-periphery/contracts/interfaces/external/IWNativeToken.sol';

import 'algebra-periphery/contracts/libraries/TransferHelper.sol';

abstract contract PeripheryPayments is IPeripheryPayments {
    address public immutable WNativeToken;

    constructor(address _WNativeToken) {
        WNativeToken = _WNativeToken;
    }

    receive() external payable {
        require(msg.sender == WNativeToken, 'Not WNativeToken');
    }

    /// @inheritdoc IPeripheryPayments
    function unwrapWNativeToken(uint256 amountMinimum, address recipient) external payable override {
        uint256 balanceWNativeToken = IWNativeToken(WNativeToken).balanceOf(address(this));
        require(balanceWNativeToken >= amountMinimum, 'Insufficient WNativeToken');

        if (balanceWNativeToken > 0) {
            IWNativeToken(WNativeToken).withdraw(balanceWNativeToken);
            TransferHelper.safeTransferNative(recipient, balanceWNativeToken);
        }
    }

    /// @inheritdoc IPeripheryPayments
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable override {
        uint256 balanceToken = IERC20(token).balanceOf(address(this));
        require(balanceToken >= amountMinimum, 'Insufficient token');

        if (balanceToken > 0) {
            TransferHelper.safeTransfer(token, recipient, balanceToken);
        }
    }

    /// @inheritdoc IPeripheryPayments
    function refundNativeToken() external payable override {
        if (address(this).balance > 0) TransferHelper.safeTransferNative(msg.sender, address(this).balance);
    }
}

File 44 of 50 : IAlgebraEternalFarming.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;
import '../../../interfaces/IAlgebraFarming.sol';

/// @title Algebra Eternal Farming Interface
/// @notice Allows farming nonfungible liquidity tokens in exchange for reward tokens without locking NFT for incentive time
interface IAlgebraEternalFarming is IAlgebraFarming {
    struct IncentiveParams {
        uint256 reward; // The amount of reward tokens to be distributed
        uint256 bonusReward; // The amount of bonus reward tokens to be distributed
        uint128 rewardRate; // The rate of reward distribution per second
        uint128 bonusRewardRate; // The rate of bonus reward distribution per second
        uint24 minimalPositionWidth; // The minimal allowed width of position (tickUpper - tickLower)
        address multiplierToken; // The address of token which can be locked to get liquidity multiplier
    }

    /// @notice Event emitted when reward rates were changed
    /// @param rewardRate The new rate of main token distribution per sec
    /// @param bonusRewardRate The new rate of bonus token distribution per sec
    /// @param incentiveId The ID of the incentive for which rates were changed
    event RewardsRatesChanged(uint128 rewardRate, uint128 bonusRewardRate, bytes32 incentiveId);

    /// @notice Event emitted when rewards were added
    /// @param tokenId The ID of the token for which rewards were collected
    /// @param incentiveId The ID of the incentive for which rewards were collected
    /// @param rewardAmount Collected amount of reward
    /// @param bonusRewardAmount Collected amount of bonus reward
    event RewardsCollected(uint256 tokenId, bytes32 incentiveId, uint256 rewardAmount, uint256 bonusRewardAmount);

    /// @notice Returns information about a farmd liquidity NFT
    /// @param tokenId The ID of the farmd token
    /// @param incentiveId The ID of the incentive for which the token is farmd
    /// @return liquidity The amount of liquidity in the NFT as of the last time the rewards were computed,
    /// tickLower The lower tick of position,
    /// tickUpper The upper tick of position,
    /// innerRewardGrowth0 The last saved reward0 growth inside position,
    /// innerRewardGrowth1 The last saved reward1 growth inside position
    function farms(uint256 tokenId, bytes32 incentiveId)
        external
        view
        returns (
            uint128 liquidity,
            int24 tickLower,
            int24 tickUpper,
            uint256 innerRewardGrowth0,
            uint256 innerRewardGrowth1
        );

    /// @notice Creates a new liquidity mining incentive program
    /// @param key Details of the incentive to create
    /// @param params Params of incentive
    /// @param tiers The amounts of locked token for liquidity multipliers
    /// @return virtualPool The virtual pool
    function createEternalFarming(
        IncentiveKey memory key,
        IncentiveParams memory params,
        Tiers calldata tiers
    ) external returns (address virtualPool);

    function addRewards(
        IncentiveKey memory key,
        uint256 rewardAmount,
        uint256 bonusRewardAmount
    ) external;

    function setRates(
        IncentiveKey memory key,
        uint128 rewardRate,
        uint128 bonusRewardRate
    ) external;

    function collectRewards(
        IncentiveKey memory key,
        uint256 tokenId,
        address _owner
    ) external returns (uint256 reward, uint256 bonusReward);

    /// @notice Event emitted when a liquidity mining incentive has been created
    /// @param rewardToken The token being distributed as a reward
    /// @param bonusRewardToken The token being distributed as a bonus reward
    /// @param pool The Algebra pool
    /// @param virtualPool The virtual pool address
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    /// @param reward The amount of reward tokens to be distributed
    /// @param bonusReward The amount of bonus reward tokens to be distributed
    /// @param tiers The amounts of locked token for liquidity multipliers
    /// @param multiplierToken The address of token which can be locked to get liquidity multiplier
    /// @param minimalAllowedPositionWidth The minimal allowed position width (tickUpper - tickLower)
    event EternalFarmingCreated(
        IERC20Minimal indexed rewardToken,
        IERC20Minimal indexed bonusRewardToken,
        IAlgebraPool indexed pool,
        address virtualPool,
        uint256 startTime,
        uint256 endTime,
        uint256 reward,
        uint256 bonusReward,
        Tiers tiers,
        address multiplierToken,
        uint24 minimalAllowedPositionWidth
    );
}

File 45 of 50 : IAlgebraLimitFarming.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;

import '../../../interfaces/IAlgebraFarming.sol';

/// @title Algebra Farming Interface
/// @notice Allows farming nonfungible liquidity tokens in exchange for reward tokens
interface IAlgebraLimitFarming is IAlgebraFarming {
    struct IncentiveParams {
        uint256 reward; // The amount of reward tokens to be distributed
        uint256 bonusReward; // The amount of bonus reward tokens to be distributed
        uint24 minimalPositionWidth; // The minimal allowed width of position (tickUpper - tickLower)
        address multiplierToken; // The address of token which can be locked to get liquidity multiplier
        uint32 enterStartTime; // The time when enter should become possible
    }

    /// @notice The max duration of an incentive in seconds
    function maxIncentiveDuration() external view returns (uint256);

    /// @notice The max amount of seconds into the future the incentive startTime can be set
    function maxIncentiveStartLeadTime() external view returns (uint256);

    /// @notice Returns information about a farmd liquidity NFT
    /// @param tokenId The ID of the farmd token
    /// @param incentiveId The ID of the incentive for which the token is farmd
    /// @return liquidity The amount of liquidity in the NFT as of the last time the rewards were computed,
    /// tickLower The lower end of the tick range for the position,
    /// tickUpper The upper end of the tick range for the position
    function farms(uint256 tokenId, bytes32 incentiveId)
        external
        view
        returns (
            uint128 liquidity,
            int24 tickLower,
            int24 tickUpper
        );

    function createLimitFarming(
        IncentiveKey memory key,
        Tiers calldata tiers,
        IncentiveParams memory params
    ) external returns (address virtualPool);

    function addRewards(
        IncentiveKey memory key,
        uint256 reward,
        uint256 bonusReward
    ) external;

    function decreaseRewardsAmount(
        IncentiveKey memory key,
        uint256 rewardAmount,
        uint256 bonusRewardAmount
    ) external;

    /// @notice Event emitted when a liquidity mining incentive has been created
    /// @param rewardToken The token being distributed as a reward
    /// @param bonusRewardToken The token being distributed as a bonus reward
    /// @param pool The Algebra pool
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    /// @param reward The amount of reward tokens to be distributed
    /// @param bonusReward The amount of bonus reward tokens to be distributed
    /// @param tiers The amounts of locked token for liquidity multipliers
    /// @param multiplierToken The address of token which can be locked to get liquidity multiplier
    /// @param minimalAllowedPositionWidth The minimal allowed position width (tickUpper - tickLower)
    /// @param enterStartTime The time when enter becomes possible
    event LimitFarmingCreated(
        IERC20Minimal indexed rewardToken,
        IERC20Minimal indexed bonusRewardToken,
        IAlgebraPool indexed pool,
        uint256 startTime,
        uint256 endTime,
        uint256 reward,
        uint256 bonusReward,
        Tiers tiers,
        address multiplierToken,
        uint24 minimalAllowedPositionWidth,
        uint32 enterStartTime
    );

    event RewardAmountsDecreased(uint256 reward, uint256 bonusReward, bytes32 incentiveId);
}

File 46 of 50 : IAlgebraFarming.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;

import 'algebra/contracts/interfaces/IAlgebraPoolDeployer.sol';
import 'algebra/contracts/interfaces/IAlgebraPool.sol';
import 'algebra/contracts/interfaces/IERC20Minimal.sol';
import 'algebra-periphery/contracts/interfaces/INonfungiblePositionManager.sol';

import './IFarmingCenter.sol';
import './IIncentiveKey.sol';

/// @title Algebra Farming Interface
/// @notice Allows farming nonfungible liquidity tokens in exchange for reward tokens
interface IAlgebraFarming is IIncentiveKey {
    /// @notice The nonfungible position manager with which this farming contract is compatible
    function nonfungiblePositionManager() external view returns (INonfungiblePositionManager);

    /// @notice The farming Center
    function farmingCenter() external view returns (IFarmingCenter);

    /// @notice The pool deployer
    function deployer() external returns (IAlgebraPoolDeployer);

    /// @notice Updates the incentive maker
    /// @param _incentiveMaker The new incentive maker address
    function setIncentiveMaker(address _incentiveMaker) external;

    struct Tiers {
        // amount of token to reach the tier
        uint256 tokenAmountForTier1;
        uint256 tokenAmountForTier2;
        uint256 tokenAmountForTier3;
        // 1 = 0.01%
        uint32 tier1Multiplier;
        uint32 tier2Multiplier;
        uint32 tier3Multiplier;
    }

    /// @notice Represents a farming incentive
    /// @param incentiveId The ID of the incentive computed from its parameters
    function incentives(bytes32 incentiveId)
        external
        view
        returns (
            uint256 totalReward,
            uint256 bonusReward,
            address virtualPoolAddress,
            uint24 minimalPositionWidth,
            uint224 totalLiquidity,
            address multiplierToken,
            Tiers memory tiers
        );

    /// @notice Detach incentive from the pool
    /// @param key The key of the incentive
    function detachIncentive(IncentiveKey memory key) external;

    /// @notice Attach incentive to the pool
    /// @param key The key of the incentive
    function attachIncentive(IncentiveKey memory key) external;

    /// @notice Returns amounts of reward tokens owed to a given address according to the last time all farms were updated
    /// @param owner The owner for which the rewards owed are checked
    /// @param rewardToken The token for which to check rewards
    /// @return rewardsOwed The amount of the reward token claimable by the owner
    function rewards(address owner, IERC20Minimal rewardToken) external view returns (uint256 rewardsOwed);

    /// @notice Updates farming center address
    /// @param _farmingCenter The new farming center contract address
    function setFarmingCenterAddress(address _farmingCenter) external;

    /// @notice enter farming for Algebra LP token
    /// @param key The key of the incentive for which to enterFarming the NFT
    /// @param tokenId The ID of the token to exitFarming
    /// @param tokensLocked The amount of tokens locked for boost
    function enterFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        uint256 tokensLocked
    ) external;

    /// @notice exitFarmings for Algebra LP token
    /// @param key The key of the incentive for which to exitFarming the NFT
    /// @param tokenId The ID of the token to exitFarming
    /// @param _owner Owner of the token
    function exitFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        address _owner
    ) external;

    /// @notice Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to`
    /// @param rewardToken The token being distributed as a reward
    /// @param to The address where claimed rewards will be sent to
    /// @param amountRequested The amount of reward tokens to claim. Claims entire reward amount if set to 0.
    /// @return reward The amount of reward tokens claimed
    function claimReward(
        IERC20Minimal rewardToken,
        address to,
        uint256 amountRequested
    ) external returns (uint256 reward);

    /// @notice Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to`
    /// @notice only for FarmingCenter
    /// @param rewardToken The token being distributed as a reward
    /// @param from The address of position owner
    /// @param to The address where claimed rewards will be sent to
    /// @param amountRequested The amount of reward tokens to claim. Claims entire reward amount if set to 0.
    /// @return reward The amount of reward tokens claimed
    function claimRewardFrom(
        IERC20Minimal rewardToken,
        address from,
        address to,
        uint256 amountRequested
    ) external returns (uint256 reward);

    /// @notice Calculates the reward amount that will be received for the given farm
    /// @param key The key of the incentive
    /// @param tokenId The ID of the token
    /// @return reward The reward accrued to the NFT for the given incentive thus far
    /// @return bonusReward The bonus reward accrued to the NFT for the given incentive thus far
    function getRewardInfo(IncentiveKey memory key, uint256 tokenId)
        external
        returns (uint256 reward, uint256 bonusReward);

    /// @notice Event emitted when a liquidity mining incentive has been stopped from the outside
    /// @param rewardToken The token being distributed as a reward
    /// @param bonusRewardToken The token being distributed as a bonus reward
    /// @param pool The Algebra pool
    /// @param virtualPool The detached virtual pool address
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    event IncentiveDetached(
        IERC20Minimal indexed rewardToken,
        IERC20Minimal indexed bonusRewardToken,
        IAlgebraPool indexed pool,
        address virtualPool,
        uint256 startTime,
        uint256 endTime
    );

    /// @notice Event emitted when a liquidity mining incentive has been runned again from the outside
    /// @param rewardToken The token being distributed as a reward
    /// @param bonusRewardToken The token being distributed as a bonus reward
    /// @param pool The Algebra pool
    /// @param virtualPool The attached virtual pool address
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    event IncentiveAttached(
        IERC20Minimal indexed rewardToken,
        IERC20Minimal indexed bonusRewardToken,
        IAlgebraPool indexed pool,
        address virtualPool,
        uint256 startTime,
        uint256 endTime
    );

    /// @notice Event emitted when a Algebra LP token has been farmd
    /// @param tokenId The unique identifier of an Algebra LP token
    /// @param incentiveId The incentive in which the token is farming
    /// @param liquidity The amount of liquidity farmd
    /// @param tokensLocked The amount of tokens locked for multiplier
    event FarmEntered(uint256 indexed tokenId, bytes32 indexed incentiveId, uint128 liquidity, uint256 tokensLocked);

    /// @notice Event emitted when a Algebra LP token has been exitFarmingd
    /// @param tokenId The unique identifier of an Algebra LP token
    /// @param incentiveId The incentive in which the token is farming
    /// @param rewardAddress The token being distributed as a reward
    /// @param bonusRewardToken The token being distributed as a bonus reward
    /// @param owner The address where claimed rewards were sent to
    /// @param reward The amount of reward tokens to be distributed
    /// @param bonusReward The amount of bonus reward tokens to be distributed
    event FarmEnded(
        uint256 indexed tokenId,
        bytes32 indexed incentiveId,
        address indexed rewardAddress,
        address bonusRewardToken,
        address owner,
        uint256 reward,
        uint256 bonusReward
    );

    /// @notice Emitted when the incentive maker is changed
    /// @param incentiveMaker The incentive maker after the address was changed
    event IncentiveMaker(address indexed incentiveMaker);

    /// @notice Emitted when the farming center is changed
    /// @param farmingCenter The farming center after the address was changed
    event FarmingCenter(address indexed farmingCenter);

    /// @notice Event emitted when rewards were added
    /// @param rewardAmount The additional amount of main token
    /// @param bonusRewardAmount The additional amount of bonus token
    /// @param incentiveId The ID of the incentive for which rewards were added
    event RewardsAdded(uint256 rewardAmount, uint256 bonusRewardAmount, bytes32 incentiveId);

    /// @notice Event emitted when a reward token has been claimed
    /// @param to The address where claimed rewards were sent to
    /// @param reward The amount of reward tokens claimed
    /// @param rewardAddress The token reward address
    /// @param owner The address where claimed rewards were sent to
    event RewardClaimed(address indexed to, uint256 reward, address indexed rewardAddress, address indexed owner);
}

File 47 of 50 : IFarmingCenter.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
pragma abicoder v2;

import 'algebra/contracts/interfaces/IAlgebraPool.sol';
import 'algebra/contracts/interfaces/IAlgebraVirtualPool.sol';
import 'algebra/contracts/interfaces/IERC20Minimal.sol';

import 'algebra-periphery/contracts/interfaces/IMulticall.sol';
import 'algebra-periphery/contracts/interfaces/INonfungiblePositionManager.sol';

import 'algebra-periphery/contracts/interfaces/IPeripheryPayments.sol';

import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';

import '../farmings/limitFarming/interfaces/IAlgebraLimitFarming.sol';
import '../farmings/eternalFarming/interfaces/IAlgebraEternalFarming.sol';
import './IFarmingCenterVault.sol';
import './IIncentiveKey.sol';

interface IFarmingCenter is
    IAlgebraVirtualPool,
    IERC721Receiver,
    IIncentiveKey,
    IMulticall,
    IERC721Permit,
    IPeripheryPayments
{
    struct VirtualPoolAddresses {
        address eternalVirtualPool;
        address limitVirtualPool;
    }

    function virtualPoolAddresses(address) external view returns (address, address);

    /// @notice The nonfungible position manager with which this farming contract is compatible
    function nonfungiblePositionManager() external view returns (INonfungiblePositionManager);

    function limitFarming() external view returns (IAlgebraLimitFarming);

    function eternalFarming() external view returns (IAlgebraEternalFarming);

    function farmingCenterVault() external view returns (IFarmingCenterVault);

    function l2Nfts(uint256)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            uint256 tokenId
        );

    /// @notice Returns information about a deposited NFT
    /// @param tokenId The ID of the deposit (and token) that is being transferred
    /// @return L2TokenId The nft layer2 id,
    /// numberOfFarms The number of farms,
    /// inLimitFarming The parameter showing if the token is in the limit farm,
    /// owner The owner of deposit
    function deposits(uint256 tokenId)
        external
        view
        returns (
            uint256 L2TokenId,
            uint32 numberOfFarms,
            bool inLimitFarming,
            address owner
        );

    /// @notice Updates activeIncentive in AlgebraPool
    /// @dev only farming can do it
    /// @param pool The AlgebraPool for which farming was created
    /// @param virtualPool The virtual pool to be connected
    function connectVirtualPool(IAlgebraPool pool, address virtualPool) external;

    /// @notice Enters in incentive (time-limited or eternal farming) with NFT-position token
    /// @dev token must be deposited in FarmingCenter
    /// @param key The incentive event key
    /// @param tokenId The id of position NFT
    /// @param tokensLocked Amount of tokens to lock for liquidity multiplier (if tiers are used)
    /// @param isLimit Is incentive time-limited or eternal
    function enterFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        uint256 tokensLocked,
        bool isLimit
    ) external;

    /// @notice Exits from incentive (time-limited or eternal farming) with NFT-position token
    /// @param key The incentive event key
    /// @param tokenId The id of position NFT
    /// @param isLimit Is incentive time-limited or eternal
    function exitFarming(
        IncentiveKey memory key,
        uint256 tokenId,
        bool isLimit
    ) external;

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @dev "proxies" to NonfungiblePositionManager
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(INonfungiblePositionManager.CollectParams calldata params)
        external
        returns (uint256 amount0, uint256 amount1);

    /// @notice Used to collect reward from eternal farming. Then reward can be claimed.
    /// @param key The incentive event key
    /// @param tokenId The id of position NFT
    /// @return reward The amount of collected reward
    /// @return bonusReward The amount of collected  bonus reward
    function collectRewards(IncentiveKey memory key, uint256 tokenId)
        external
        returns (uint256 reward, uint256 bonusReward);

    /// @notice Used to claim and send rewards from farming(s)
    /// @dev can be used via static call to get current rewards for user
    /// @param rewardToken The token that is a reward
    /// @param to The address to be rewarded
    /// @param amountRequestedIncentive Amount to claim in incentive (limit) farming
    /// @param amountRequestedEternal Amount to claim in eternal farming
    /// @return reward The summary amount of claimed rewards
    function claimReward(
        IERC20Minimal rewardToken,
        address to,
        uint256 amountRequestedIncentive,
        uint256 amountRequestedEternal
    ) external returns (uint256 reward);

    /// @notice Withdraw Algebra NFT-position token
    /// @dev can be used via static call to get current rewards for user
    /// @param tokenId The id of position NFT
    /// @param to New owner of position NFT
    /// @param data The additional data for NonfungiblePositionManager
    function withdrawToken(
        uint256 tokenId,
        address to,
        bytes memory data
    ) external;

    /// @notice Emitted when ownership of a deposit changes
    /// @param tokenId The ID of the deposit (and token) that is being transferred
    /// @param oldOwner The owner before the deposit was transferred
    /// @param newOwner The owner after the deposit was transferred
    event DepositTransferred(uint256 indexed tokenId, address indexed oldOwner, address indexed newOwner);
}

File 48 of 50 : IFarmingCenterVault.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.7.6;

interface IFarmingCenterVault {
    function claimTokens(
        address token,
        address to,
        uint256 tokenId,
        bytes32 incentiveId
    ) external;

    function setFarmingCenter(address farming) external;

    function lockTokens(
        uint256 tokenId,
        bytes32 incentiveId,
        uint256 tokenAmount
    ) external;

    function balances(uint256 tokenId, bytes32 incentiveId) external view returns (uint256 balance);
}

File 49 of 50 : IIncentiveKey.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;

import 'algebra/contracts/interfaces/IERC20Minimal.sol';
import 'algebra/contracts/interfaces/IAlgebraPool.sol';

interface IIncentiveKey {
    /// @param rewardToken The token being distributed as a reward
    /// @param bonusRewardToken The bonus token being distributed as a reward
    /// @param pool The Algebra pool
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    struct IncentiveKey {
        IERC20Minimal rewardToken;
        IERC20Minimal bonusRewardToken;
        IAlgebraPool pool;
        uint256 startTime;
        uint256 endTime;
    }
}

File 50 of 50 : IncentiveId.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;

import '../interfaces/IIncentiveKey.sol';

library IncentiveId {
    /// @notice Calculate the key for a staking incentive
    /// @param key The components used to compute the incentive identifier
    /// @return incentiveId The identifier for the incentive
    function compute(IIncentiveKey.IncentiveKey memory key) internal pure returns (bytes32 incentiveId) {
        return keccak256(abi.encode(key));
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IAlgebraLimitFarming","name":"_limitFarming","type":"address"},{"internalType":"contract IAlgebraEternalFarming","name":"_eternalFarming","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"_nonfungiblePositionManager","type":"address"},{"internalType":"contract IFarmingCenterVault","name":"_farmingCenterVault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"DepositTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WNativeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20Minimal","name":"rewardToken","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amountRequestedIncentive","type":"uint256"},{"internalType":"uint256","name":"amountRequestedEternal","type":"uint256"}],"name":"claimReward","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectParams","name":"params","type":"tuple"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20Minimal","name":"rewardToken","type":"address"},{"internalType":"contract IERC20Minimal","name":"bonusRewardToken","type":"address"},{"internalType":"contract IAlgebraPool","name":"pool","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"internalType":"struct IIncentiveKey.IncentiveKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"collectRewards","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"},{"internalType":"uint256","name":"bonusReward","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IAlgebraPool","name":"pool","type":"address"},{"internalType":"address","name":"newVirtualPool","type":"address"}],"name":"connectVirtualPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"nextTick","type":"int24"},{"internalType":"bool","name":"zeroToOne","type":"bool"}],"name":"cross","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"deposits","outputs":[{"internalType":"uint256","name":"L2TokenId","type":"uint256"},{"internalType":"uint32","name":"numberOfFarms","type":"uint32"},{"internalType":"bool","name":"inLimitFarming","type":"bool"},{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20Minimal","name":"rewardToken","type":"address"},{"internalType":"contract IERC20Minimal","name":"bonusRewardToken","type":"address"},{"internalType":"contract IAlgebraPool","name":"pool","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"internalType":"struct IIncentiveKey.IncentiveKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"tokensLocked","type":"uint256"},{"internalType":"bool","name":"isLimit","type":"bool"}],"name":"enterFarming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eternalFarming","outputs":[{"internalType":"contract IAlgebraEternalFarming","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20Minimal","name":"rewardToken","type":"address"},{"internalType":"contract IERC20Minimal","name":"bonusRewardToken","type":"address"},{"internalType":"contract IAlgebraPool","name":"pool","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"internalType":"struct IIncentiveKey.IncentiveKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"isLimit","type":"bool"}],"name":"exitFarming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"farmingCenterVault","outputs":[{"internalType":"contract IFarmingCenterVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"blockTimestamp","type":"uint32"}],"name":"increaseCumulative","outputs":[{"internalType":"enum IAlgebraVirtualPool.Status","name":"status","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"l2Nfts","outputs":[{"internalType":"uint96","name":"nonce","type":"uint96"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitFarming","outputs":[{"internalType":"contract IAlgebraLimitFarming","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonfungiblePositionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"refundNativeToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWNativeToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"virtualPoolAddresses","outputs":[{"internalType":"address","name":"limitVP","type":"address"},{"internalType":"address","name":"eternalVP","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101606040526001600a553480156200001757600080fd5b5060405162006287380380620062878339810160408190526200003a9162000347565b816001600160a01b0316638af3ac856040518163ffffffff1660e01b815260040160206040518083038186803b1580156200007457600080fd5b505afa15801562000089573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000af919062000321565b6040518060400160405280601681526020017f416c6765627261204661726d696e67204e46542d56320000000000000000000081525060405180604001604052806009815260200168414c47422d4641524d60b81b815250604051806040016040528060018152602001601960f91b81525082826200013b6301ffc9a760e01b620001f060201b60201c565b81516200015090600690602085019062000275565b5080516200016690600790602084019062000275565b50620001796380ac58cd60e01b620001f0565b6200018b635b5e139f60e01b620001f0565b6200019d63780e9d6360e01b620001f0565b50508251602093840120608052805192019190912060a052506001600160601b0319606091821b811660c05294811b851660e05292831b84166101005290821b831661012052901b1661014052620003c7565b6001600160e01b0319808216141562000250576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002ad5760008555620002f8565b82601f10620002c857805160ff1916838001178555620002f8565b82800160010185558215620002f8579182015b82811115620002f8578251825591602001919060010190620002db565b50620003069291506200030a565b5090565b5b808211156200030657600081556001016200030b565b60006020828403121562000333578081fd5b81516200034081620003ae565b9392505050565b600080600080608085870312156200035d578283fd5b84516200036a81620003ae565b60208601519094506200037d81620003ae565b60408601519093506200039081620003ae565b6060860151909250620003a381620003ae565b939692955090935050565b6001600160a01b0381168114620003c457600080fd5b50565b60805160a05160c05160601c60e05160601c6101005160601c6101205160601c6101405160601c615dfe620004896000398061101e52806110cb528061156e52806125365280613610525080610ce3528061181a5280612914528061320b525080610ee152806113ca52806119bf5280612d73528061301852806132dc525080610eba52806113a3528061274a5280612d3352806132a75250806102f25280611ac45280611bee528061251252508061162a5250806116095250615dfe6000f3fe6080604052600436106102d55760003560e01c806369bc35b211610179578063ac9650d8116100d6578063d8a900b11161008a578063e985e9c511610064578063e985e9c51461083f578063fc6f78651461085f578063fd188ca41461087f57610380565b8063d8a900b1146107f7578063de2356d114610817578063df2ab5bb1461082c57610380565b8063b44a2722116100bb578063b44a2722146107a2578063b88d4fde146107b7578063c87b56dd146107d757610380565b8063ac9650d814610752578063b02c43d01461077257610380565b80638af3ac851161012d57806395d89b411161011257806395d89b4114610708578063a22cb4651461071d578063a5f6072f1461073d57610380565b80638af3ac85146106de5780639205ac2e146106f357610380565b806370a082311161015e57806370a082311461067e5780637ac2ff7b1461069e5780637f376059146106b157610380565b806369bc35b2146106565780636c0360eb1461066957610380565b80632f745c59116102325780633c423f0b116101e657806342842e0e116101c057806342842e0e146105f65780634f6ccce7146106165780636352211e1461063657610380565b80633c423f0b146105a05780633e785878146105c057806341865270146105ee57610380565b806332dc5a251161021757806332dc5a251461053d57806334267cbc1461056b5780633644e5151461058b57610380565b80632f745c591461050857806330adf81f1461052857610380565b8063095ea7b31161028957806318160ddd1161026e57806318160ddd146104a657806322872ce2146104c857806323b872dd146104e857610380565b8063095ea7b314610459578063150b7a021461047957610380565b806303a05df9116102ba57806303a05df9146103db57806306fdde031461040a578063081812fc1461042c57610380565b806301342b191461038557806301ffc9a7146103a557610380565b36610380573373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461037e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420574e6174697665546f6b656e00000000000000000000000000000000604482015290519081900360640190fd5b005b600080fd5b34801561039157600080fd5b5061037e6103a03660046150c0565b61089f565b3480156103b157600080fd5b506103c56103c036600461500a565b6109c9565b6040516103d29190615688565b60405180910390f35b3480156103e757600080fd5b506103fb6103f636600461526a565b610a04565b6040516103d293929190615a6c565b34801561041657600080fd5b5061041f610a54565b6040516103d29190615729565b34801561043857600080fd5b5061044c61044736600461526a565b610b08565b6040516103d29190615543565b34801561046557600080fd5b5061037e610474366004614ecf565b610b8b565b34801561048557600080fd5b50610499610494366004614d97565b610cc9565b6040516103d2919061569c565b3480156104b257600080fd5b506104bb610e2d565b6040516103d29190615693565b3480156104d457600080fd5b5061037e6104e3366004615223565b610e3e565b3480156104f457600080fd5b5061037e610503366004614d57565b6111cd565b34801561051457600080fd5b506104bb610523366004614ecf565b61123e565b34801561053457600080fd5b506104bb611276565b34801561054957600080fd5b5061055d610558366004614ce7565b61129a565b6040516103d29291906155ad565b34801561057757600080fd5b5061037e6105863660046151e7565b6112d0565b34801561059757600080fd5b506104bb6115e4565b3480156105ac57600080fd5b5061037e6105bb3660046152be565b6116af565b3480156105cc57600080fd5b506105e06105db3660046151bd565b61188e565b6040516103d2929190615a14565b61037e611a55565b34801561060257600080fd5b5061037e610611366004614d57565b611a67565b34801561062257600080fd5b506104bb61063136600461526a565b611a82565b34801561064257600080fd5b5061044c61065136600461526a565b611a98565b61037e61066436600461529a565b611ac0565b34801561067557600080fd5b5061041f611c81565b34801561068a57600080fd5b506104bb610699366004614ce7565b611d00565b61037e6106ac366004614f3b565b611d9c565b3480156106bd57600080fd5b506106d16106cc366004615481565b612343565b6040516103d29190615700565b3480156106ea57600080fd5b5061044c612510565b3480156106ff57600080fd5b5061044c612534565b34801561071457600080fd5b5061041f612558565b34801561072957600080fd5b5061037e610738366004614e9b565b6125d7565b34801561074957600080fd5b5061044c612748565b610765610760366004614f9b565b61276c565b6040516103d2919061560a565b34801561077e57600080fd5b5061079261078d36600461526a565b6128c6565b6040516103d29493929190615a22565b3480156107ae57600080fd5b5061044c612912565b3480156107c357600080fd5b5061037e6107d2366004614e31565b612936565b3480156107e357600080fd5b5061041f6107f236600461526a565b6129ae565b34801561080357600080fd5b5061037e61081236600461504a565b612d1b565b34801561082357600080fd5b5061044c613016565b61037e61083a366004614efa565b61303a565b34801561084b57600080fd5b506103c561085a366004614d1f565b613151565b34801561086b57600080fd5b506105e061087a36600461514c565b61318c565b34801561088b57600080fd5b506104bb61089a36600461505c565b61329a565b336000908152600b602052604090819020805491517f01342b19000000000000000000000000000000000000000000000000000000008152909173ffffffffffffffffffffffffffffffffffffffff16906301342b19906109069086908690600401615714565b600060405180830381600087803b15801561092057600080fd5b505af1158015610934573d6000803e3d6000fd5b50505060018201546040517f01342b1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691506301342b19906109929086908690600401615714565b600060405180830381600087803b1580156109ac57600080fd5b505af11580156109c0573d6000803e3d6000fd5b50505050505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526020819052604090205460ff165b919050565b600d60205260009081526040902080546001909101546bffffffffffffffffffffffff8216916c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff169083565b60068054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b820191906000526020600020905b815481529060010190602001808311610ae157829003601f168201915b5050505050905090565b6000610b138261330d565b610b52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061583e565b60405180910390fd5b506000908152600d60205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1690565b6000610b9682611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180615da06021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c3c61331a565b73ffffffffffffffffffffffffffffffffffffffff161480610c655750610c658161085a61331a565b610cba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180615c9b6038913960400191505060405180910390fd5b610cc4838361331e565b505050565b60003373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610d3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615909565b600a546000858152600c60209081526040808320600180820180547fffffffffffffff0000000000000000000000000000000000000000ffffffffff166501000000000073ffffffffffffffffffffffffffffffffffffffff8e1602179055858255858552600d909352922001869055610db487836133bc565b60018201600a5560405173ffffffffffffffffffffffffffffffffffffffff88169060009088907fcdfc765b85e1048bee3c6a0f9d1c91fc7c4631f5fe5745a55fc6843db5c3260f908390a4507f150b7a0200000000000000000000000000000000000000000000000000000000979650505050505050565b6000610e396002613545565b905090565b6000838152600c602052604090208054610e5790613550565b60018181015463ffffffff811690910190640100000000900460ff1660008415610ede578115610eb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061573c565b50600190507f0000000000000000000000000000000000000000000000000000000000000000610f01565b507f00000000000000000000000000000000000000000000000000000000000000005b6001840180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff1664010000000084151502177fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff85161790556000610f6b89613593565b905060008273ffffffffffffffffffffffffffffffffffffffff166360777795836040518263ffffffff1660e01b8152600401610fa89190615693565b6101806040518083038186803b158015610fc157600080fd5b505afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff99190615338565b50955050505050506000881115611139576000611015826135c3565b905061104382337f00000000000000000000000000000000000000000000000000000000000000008c613688565b600061104e836135c3565b9050818111611089576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061589b565b6040517f2113e8170000000000000000000000000000000000000000000000000000000081528282039a5073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690632113e81790611104908e9088908f906004016159fe565b600060405180830381600087803b15801561111e57600080fd5b505af1158015611132573d6000803e3d6000fd5b5050505050505b6040517ff43930a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063f43930a39061118f908d908d908d906004016159df565b600060405180830381600087803b1580156111a957600080fd5b505af11580156111bd573d6000803e3d6000fd5b5050505050505050505050505050565b6111de6111d861331a565b8261386d565b611233576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180615dc16031913960400191505060405180910390fd5b610cc4838383613957565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040812061126d9083613b32565b90505b92915050565b7f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad81565b73ffffffffffffffffffffffffffffffffffffffff9081166000908152600b602052604090206001810154905490821692911690565b6000828152600c6020526040902080546112e990613550565b6001810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000811663ffffffff9182167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01909116177fffffffffffffff0000000000000000000000000000000000000000ffffffffff16336501000000000002179055600082156113c757506001810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff1690557f00000000000000000000000000000000000000000000000000000000000000006113ea565b507f00000000000000000000000000000000000000000000000000000000000000005b6040517f0705506b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690630705506b90611440908890889033906004016159a7565b600060405180830381600087803b15801561145a57600080fd5b505af115801561146e573d6000803e3d6000fd5b50505050600061147d86613593565b905060008273ffffffffffffffffffffffffffffffffffffffff166360777795836040518263ffffffff1660e01b81526004016114ba9190615693565b6101806040518083038186803b1580156114d357600080fd5b505afa1580156114e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150b9190615338565b509550505073ffffffffffffffffffffffffffffffffffffffff84161592506109c0915050576040517f92ae44e100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906392ae44e1906115a990849033908b9088906004016155d4565b600060405180830381600087803b1580156115c357600080fd5b505af11580156115d7573d6000803e3d6000fd5b5050505050505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611651613b3e565b30604051602001808681526020018581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019550505050505060405160208183030381529060405280519060200120905090565b73ffffffffffffffffffffffffffffffffffffffff82163014156116ff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b49906157d0565b6000838152600c60205260409020805461171881613550565b600182015463ffffffff161561175a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615773565b6000818152600d602052604081208181556001015561177881613b42565b6000858152600c602052604080822082815560010180547fffffffffffffff0000000000000000000000000000000000000000000000000016905551339087907fcdfc765b85e1048bee3c6a0f9d1c91fc7c4631f5fe5745a55fc6843db5c3260f908490a46040517fb88d4fde00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063b88d4fde9061185590309088908a908990600401615564565b600060405180830381600087803b15801561186f57600080fd5b505af1158015611883573d6000803e3d6000fd5b505050505050505050565b6000818152600c602052604081205481906118a890613550565b60408085015173ffffffffffffffffffffffffffffffffffffffff9081166000908152600b6020529190912054168015611982576040517f7f37605900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690637f3760599061192e904290600401615a5b565b602060405180830381600087803b15801561194857600080fd5b505af115801561195c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198091906150a1565b505b6040517ffe4282fb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fe4282fb906119f8908890889033906004016159a7565b6040805180830381600087803b158015611a1157600080fd5b505af1158015611a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a499190615315565b90969095509350505050565b4715611a6557611a653347613c47565b565b610cc483838360405180602001604052806000815250612936565b600080611a90600284613d95565b509392505050565b600061127082604051806060016040528060298152602001615cfd6029913960029190613db3565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611b4957600080fd5b505afa158015611b5d573d6000803e3d6000fd5b505050506040513d6020811015611b7357600080fd5b5051905082811015611be657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496e73756666696369656e7420574e6174697665546f6b656e00000000000000604482015290519081900360640190fd5b8015610cc4577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611c5f57600080fd5b505af1158015611c73573d6000803e3d6000fd5b50505050610cc48282613c47565b60098054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b600073ffffffffffffffffffffffffffffffffffffffff8216611d6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615cd3602a913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902061127090613545565b83611da5613dca565b1115611e1257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5065726d69742065787069726564000000000000000000000000000000000000604482015290519081900360640190fd5b6000611e1c6115e4565b7f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8888611e4881613dce565b6040805160208082019690965273ffffffffffffffffffffffffffffffffffffffff909416848201526060840192909252608083015260a08083018a90528151808403909101815260c0830182528051908401207f190100000000000000000000000000000000000000000000000000000000000060e084015260e283019490945261010280830194909452805180830390940184526101229091019052815191012090506000611ef887611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff161415611f7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180615c246027913960400191505060405180910390fd5b611f8881613e20565b1561218a576040805160208082018790528183018690527fff0000000000000000000000000000000000000000000000000000000000000060f889901b16606083015282516041818403018152606183018085527f1626ba7e0000000000000000000000000000000000000000000000000000000090526065830186815260858401948552815160a5850152815173ffffffffffffffffffffffffffffffffffffffff871695631626ba7e958995919260c59091019185019080838360005b8381101561205f578181015183820152602001612047565b50505050905090810190601f16801561208c5780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b1580156120aa57600080fd5b505afa1580156120be573d6000803e3d6000fd5b505050506040513d60208110156120d457600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f1626ba7e000000000000000000000000000000000000000000000000000000001461218557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e617574686f72697a65640000000000000000000000000000000000000000604482015290519081900360640190fd5b61232f565b600060018387878760405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156121e6573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661229357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c6964207369676e6174757265000000000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461232d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e617574686f72697a65640000000000000000000000000000000000000000604482015290519081900360640190fd5b505b612339888861331e565b5050505050505050565b336000908152600b6020526040808220805491517f7f3760590000000000000000000000000000000000000000000000000000000081529091839173ffffffffffffffffffffffffffffffffffffffff90911690637f376059906123ab908790600401615a5b565b602060405180830381600087803b1580156123c557600080fd5b505af11580156123d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fd91906150a1565b60018301546040517f7f37605900000000000000000000000000000000000000000000000000000000815291925060009173ffffffffffffffffffffffffffffffffffffffff90911690637f3760599061245b908890600401615a5b565b602060405180830381600087803b15801561247557600080fd5b505af1158015612489573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124ad91906150a1565b905060018260028111156124bd57fe5b14806124d4575060018160028111156124d257fe5b145b156124e557600193505050506109ff565b60028160028111156124f357fe5b141561250557600293505050506109ff565b506000949350505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60078054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b6125df61331a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561267957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b806005600061268661331a565b73ffffffffffffffffffffffffffffffffffffffff90811682526020808301939093526040918201600090812091871680825291909352912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016921515929092179091556126f561331a565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60608167ffffffffffffffff8111801561278557600080fd5b506040519080825280602002602001820160405280156127b957816020015b60608152602001906001900390816127a45790505b50905060005b828110156128bf57600080308686858181106127d757fe5b90506020028101906127e99190615aa8565b6040516127f7929190615533565b600060405180830381855af49150503d8060008114612832576040519150601f19603f3d011682016040523d82523d6000602084013e612837565b606091505b50915091508161289d5760448151101561285057600080fd5b6004810190508080602001905181019061286a91906150e2565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499190615729565b808484815181106128aa57fe5b602090810291909101015250506001016127bf565b5092915050565b600c602052600090815260409020805460019091015463ffffffff811690640100000000810460ff169065010000000000900473ffffffffffffffffffffffffffffffffffffffff1684565b7f000000000000000000000000000000000000000000000000000000000000000081565b61294761294161331a565b8361386d565b61299c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180615dc16031913960400191505060405180910390fd5b6129a884848484613e26565b50505050565b60606129b98261330d565b612a0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180615d71602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190921691909104601f810185900485028201850190935282815292909190830182828015612abf5780601f10612a9457610100808354040283529160200191612abf565b820191906000526020600020905b815481529060010190602001808311612aa257829003601f168201915b505050505090506000612ad0611c81565b9050805160001415612ae4575090506109ff565b815115612bff5780826040516020018083805190602001908083835b60208310612b3d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612b00565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b60208310612bc157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612b84565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506109ff565b80612c0985613e92565b6040516020018083805190602001908083835b60208310612c5957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612c1c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b60208310612cdd57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612ca0565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148080612d9557503373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016145b612dcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b49906158d2565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600b6020908152604080832081517ffacb0eb1000000000000000000000000000000000000000000000000000000008152915190948493909263facb0eb19260048083019392829003018186803b158015612e4157600080fd5b505afa158015612e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e799190614d03565b73ffffffffffffffffffffffffffffffffffffffff161415612e9c575082612eff565b73ffffffffffffffffffffffffffffffffffffffff8416612efc5782612edc57600182015473ffffffffffffffffffffffffffffffffffffffff16612ef5565b815473ffffffffffffffffffffffffffffffffffffffff165b9050612eff565b50305b6040517f7c1fe0c800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff861690637c1fe0c890612f51908490600401615543565b600060405180830381600087803b158015612f6b57600080fd5b505af1158015612f7f573d6000803e3d6000fd5b505050508215612fd0576001820180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905561300f565b81547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85161782555b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156130a357600080fd5b505afa1580156130b7573d6000803e3d6000fd5b505050506040513d60208110156130cd57600080fd5b505190508281101561314057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e73756666696369656e7420746f6b656e0000000000000000000000000000604482015290519081900360640190fd5b80156129a8576129a8848383613fbf565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b80516000908152600c602052604081205481906131a890613550565b602083015173ffffffffffffffffffffffffffffffffffffffff166131ce573060208401525b6040517ffc6f786500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc6f786590613240908690600401615940565b6040805180830381600087803b15801561325957600080fd5b505af115801561326d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132919190615315565b91509150915091565b600082156132d1576132ce7f0000000000000000000000000000000000000000000000000000000000000000868686614194565b90505b8115613305576133037f0000000000000000000000000000000000000000000000000000000000000000868685614194565b015b949350505050565b600061127060028361424a565b3390565b6000818152600d6020526040902080546bffffffffffffffffffffffff166c0100000000000000000000000073ffffffffffffffffffffffffffffffffffffffff851690810291909117909155819061337682611a98565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b73ffffffffffffffffffffffffffffffffffffffff821661343e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6134478161330d565b156134b357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b6134bf60008383610cc4565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090206134ee9082614256565b506134fb60028284614262565b50604051819073ffffffffffffffffffffffffffffffffffffffff8416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600061127082614285565b61355a338261386d565b613590576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615807565b50565b6000816040516020016135a69190615999565b604051602081830303815290604052805190602001209050919050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190613638907f000000000000000000000000000000000000000000000000000000000000000090600401615543565b60206040518083038186803b15801561365057600080fd5b505afa158015613664573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112709190615282565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000178152925182516000948594938a169392918291908083835b6020831061376557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613728565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146137c7576040519150601f19603f3d011682016040523d82523d6000602084013e6137cc565b606091505b50915091508180156137fa5750805115806137fa57508080602001905160208110156137f757600080fd5b50515b61386557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f5354460000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b505050505050565b60006138788261330d565b6138cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615c6f602c913960400191505060405180910390fd5b60006138d883611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061394757508373ffffffffffffffffffffffffffffffffffffffff1661392f84610b08565b73ffffffffffffffffffffffffffffffffffffffff16145b8061330557506133058185613151565b8273ffffffffffffffffffffffffffffffffffffffff1661397782611a98565b73ffffffffffffffffffffffffffffffffffffffff16146139e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180615d486029913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216613a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180615c4b6024913960400191505060405180910390fd5b613a5a838383610cc4565b613a6560008261331e565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600160205260409020613a949082614289565b5073ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020613ac49082614256565b50613ad160028284614262565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061126d8383614295565b4690565b6000613b4d82611a98565b9050613b5b81600084610cc4565b613b6660008361331e565b60008281526008602052604090205460027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600184161502019091160415613bc2576000828152600860205260408120613bc291614b7f565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600160205260409020613bf19083614289565b50613bfd600283614313565b50604051829060009073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff84169083906040518082805190602001908083835b60208310613cbe57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613c81565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d20576040519150601f19603f3d011682016040523d82523d6000602084013e613d25565b606091505b5050905080610cc457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f5354450000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000808080613da4868661431f565b909450925050505b9250929050565b6000613dc08484846143b4565b90505b9392505050565b4290565b6000908152600d6020526040902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000811660016bffffffffffffffffffffffff9283169081019092161790915590565b3b151590565b613e31848484613957565b613e3d84848484614498565b6129a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180615bf26032913960400191505060405180910390fd5b606081613ed3575060408051808201909152600181527f300000000000000000000000000000000000000000000000000000000000000060208201526109ff565b8160005b8115613eeb57600101600a82049150613ed7565b60008167ffffffffffffffff81118015613f0457600080fd5b506040519080825280601f01601f191660200182016040528015613f2f576020820181803683370190505b5085935090507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82015b8315613fb657600a840660300160f81b82828060019003935081518110613f7c57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350613f59565b50949350505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251825160009485949389169392918291908083835b6020831061409457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614057565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146140f6576040519150601f19603f3d011682016040523d82523d6000602084013e6140fb565b606091505b5091509150818015614129575080511580614129575080806020019051602081101561412657600080fd5b50515b61300f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f5354000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6040517f0a53075400000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff861690630a530754906141ef9087903390889088906004016156c9565b602060405180830381600087803b15801561420957600080fd5b505af115801561421d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142419190615282565b95945050505050565b600061126d83836146a8565b600061126d83836146c0565b6000613dc0848473ffffffffffffffffffffffffffffffffffffffff851661470a565b5490565b600061126d83836147a1565b815460009082106142f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180615bd06022913960400191505060405180910390fd5b82600001828154811061430057fe5b9060005260206000200154905092915050565b600061126d8383614885565b81546000908190831061437d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180615d266022913960400191505060405180910390fd5b600084600001848154811061438e57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281614469576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561442e578181015183820152602001614416565b50505050905090810190601f16801561445b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061447c57fe5b9060005260206000209060020201600101549150509392505050565b60006144b98473ffffffffffffffffffffffffffffffffffffffff16613e20565b6144c557506001613305565b600061463d7f150b7a02000000000000000000000000000000000000000000000000000000006144f361331a565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561457457818101518382015260200161455c565b50505050905090810190601f1680156145a15780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001615bf26032913973ffffffffffffffffffffffffffffffffffffffff88169190614995565b9050600081806020019051602081101561465657600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001492505050949350505050565b60009081526001919091016020526040902054151590565b60006146cc83836146a8565b61470257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611270565b506000611270565b60008281526001840160205260408120548061476f575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055613dc3565b8285600001600183038154811061478257fe5b9060005260206000209060020201600101819055506000915050613dc3565b6000818152600183016020526040812054801561487b5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106147f257fe5b906000526020600020015490508087600001848154811061480f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061483f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611270565b6000915050611270565b6000818152600183016020526040812054801561487b5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106148d657fe5b90600052602060002090600202019050808760000184815481106148f657fe5b60009182526020808320845460029093020191825560019384015491840191909155835482528983019052604090209084019055865487908061493557fe5b6000828152602080822060027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840201828155600190810183905592909355888152898201909252604082209190915594506112709350505050565b6060613dc08484600085856149a985613e20565b614a1457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310614a7d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614a40565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614adf576040519150601f19603f3d011682016040523d82523d6000602084013e614ae4565b606091505b5091509150614af4828286614aff565b979650505050505050565b60608315614b0e575081613dc3565b825115614b1e5782518084602001fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181815284516024840152845185939192839260440191908501908083836000831561442e578181015183820152602001614416565b50805460018160011615610100020316600290046000825580601f10614ba55750613590565b601f01602090049060005260206000209081019061359091905b80821115614bd35760008155600101614bbf565b5090565b803580151581146109ff57600080fd5b600082601f830112614bf7578081fd5b8135614c0a614c0582615b2f565b615b0b565b818152846020838601011115614c1e578283fd5b816020850160208301379081016020019190915292915050565b600060a08284031215614c49578081fd5b60405160a0810181811067ffffffffffffffff82111715614c6657fe5b6040529050808235614c7781615b9b565b81526020830135614c8781615b9b565b60208201526040830135614c9a81615b9b565b8060408301525060608301356060820152608083013560808201525092915050565b80356fffffffffffffffffffffffffffffffff811681146109ff57600080fd5b80516109ff81615bbd565b600060208284031215614cf8578081fd5b8135613dc381615b9b565b600060208284031215614d14578081fd5b8151613dc381615b9b565b60008060408385031215614d31578081fd5b8235614d3c81615b9b565b91506020830135614d4c81615b9b565b809150509250929050565b600080600060608486031215614d6b578081fd5b8335614d7681615b9b565b92506020840135614d8681615b9b565b929592945050506040919091013590565b600080600080600060808688031215614dae578283fd5b8535614db981615b9b565b94506020860135614dc981615b9b565b935060408601359250606086013567ffffffffffffffff80821115614dec578283fd5b818801915088601f830112614dff578283fd5b813581811115614e0d578384fd5b896020828501011115614e1e578384fd5b9699959850939650602001949392505050565b60008060008060808587031215614e46578182fd5b8435614e5181615b9b565b93506020850135614e6181615b9b565b925060408501359150606085013567ffffffffffffffff811115614e83578182fd5b614e8f87828801614be7565b91505092959194509250565b60008060408385031215614ead578182fd5b8235614eb881615b9b565b9150614ec660208401614bd7565b90509250929050565b60008060408385031215614ee1578182fd5b8235614eec81615b9b565b946020939093013593505050565b600080600060608486031215614f0e578081fd5b8335614f1981615b9b565b9250602084013591506040840135614f3081615b9b565b809150509250925092565b60008060008060008060c08789031215614f53578384fd5b8635614f5e81615b9b565b95506020870135945060408701359350606087013560ff81168114614f81578182fd5b9598949750929560808101359460a0909101359350915050565b60008060208385031215614fad578182fd5b823567ffffffffffffffff80821115614fc4578384fd5b818501915085601f830112614fd7578384fd5b813581811115614fe5578485fd5b8660208083028501011115614ff8578485fd5b60209290920196919550909350505050565b60006020828403121561501b578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114613dc3578182fd5b60008060408385031215614d31578182fd5b60008060008060808587031215615071578182fd5b843561507c81615b9b565b9350602085013561508c81615b9b565b93969395505050506040820135916060013590565b6000602082840312156150b2578081fd5b815160038110613dc3578182fd5b600080604083850312156150d2578182fd5b82358060020b8114614eb8578283fd5b6000602082840312156150f3578081fd5b815167ffffffffffffffff811115615109578182fd5b8201601f81018413615119578182fd5b8051615127614c0582615b2f565b81815285602083850101111561513b578384fd5b614241826020830160208601615b6f565b60006080828403121561515d578081fd5b6040516080810181811067ffffffffffffffff8211171561517a57fe5b60405282358152602083013561518f81615b9b565b60208201526151a060408401614cbc565b60408201526151b160608401614cbc565b60608201529392505050565b60008060c083850312156151cf578182fd5b6151d98484614c38565b9460a0939093013593505050565b600080600060e084860312156151fb578081fd5b6152058585614c38565b925060a0840135915061521a60c08501614bd7565b90509250925092565b6000806000806101008587031215615239578182fd5b6152438686614c38565b935060a0850135925060c0850135915061525f60e08601614bd7565b905092959194509250565b60006020828403121561527b578081fd5b5035919050565b600060208284031215615293578081fd5b5051919050565b600080604083850312156152ac578182fd5b823591506020830135614d4c81615b9b565b6000806000606084860312156152d2578081fd5b8335925060208401356152e481615b9b565b9150604084013567ffffffffffffffff8111156152ff578182fd5b61530b86828701614be7565b9150509250925092565b60008060408385031215615327578182fd5b505080516020909101519092909150565b6000806000806000806000878903610180811215615354578586fd5b8851975060208901519650604089015161536d81615b9b565b60608a015190965062ffffff81168114615385578283fd5b60808a01519095507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146153b6578283fd5b60a08a01519094506153c781615b9b565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40820112156153f8578182fd5b5060405160c0810181811067ffffffffffffffff8211171561541657fe5b806040525060c0890151815260e08901516020820152610100890151604082015261012089015161544681615bbd565b606082015261014089015161545a81615bbd565b608082015261546c6101608a01614cdc565b60a08201528091505092959891949750929550565b600060208284031215615492578081fd5b8135613dc381615bbd565b600081518084526154b5816020860160208601615b6f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff8082511683528060208301511660208401528060408301511660408401525060608101516060830152608081015160808301525050565b6000828483379101908152919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b600073ffffffffffffffffffffffffffffffffffffffff8087168352808616602084015250836040830152608060608301526155a3608083018461549d565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561567b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845261566985835161549d565b9450928501929085019060010161562f565b5092979650505050505050565b901515815260200190565b90815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b602081016003831061570e57fe5b91905290565b60029290920b82521515602082015260400190565b60006020825261126d602083018461549d565b60208082526014908201527f746f6b656e20616c7265616479206661726d6564000000000000000000000000604082015260600190565b60208082526021908201527f63616e6e6f7420776974686472617720746f6b656e207768696c65206661726d60408201527f6400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f63616e6e6f7420776974686472617720746f206661726d696e67000000000000604082015260600190565b6020808252600c908201527f4e6f7420617070726f7665640000000000000000000000000000000000000000604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201527f697374656e7420746f6b656e0000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f496e73756666696369656e7420746f6b656e73206c6f636b6564000000000000604082015260600190565b6020808252601a908201527f6f6e6c79206661726d696e672063616e2063616c6c2074686973000000000000604082015260600190565b60208082526012908201527f6e6f7420616e20416c6765627261206e66740000000000000000000000000000604082015260600190565b8151815260208083015173ffffffffffffffffffffffffffffffffffffffff16908201526040808301516fffffffffffffffffffffffffffffffff90811691830191909152606092830151169181019190915260800190565b60a0810161127082846154e7565b60e081016159b582866154e7565b8360a083015273ffffffffffffffffffffffffffffffffffffffff831660c0830152949350505050565b60e081016159ed82866154e7565b60a082019390935260c00152919050565b9283526020830191909152604082015260600190565b918252602082015260400190565b93845263ffffffff9290921660208401521515604083015273ffffffffffffffffffffffffffffffffffffffff16606082015260800190565b63ffffffff91909116815260200190565b6bffffffffffffffffffffffff93909316835273ffffffffffffffffffffffffffffffffffffffff919091166020830152604082015260600190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615adc578283fd5b83018035915067ffffffffffffffff821115615af6578283fd5b602001915036819003821315613dac57600080fd5b60405181810167ffffffffffffffff81118282101715615b2757fe5b604052919050565b600067ffffffffffffffff821115615b4357fe5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b83811015615b8a578181015183820152602001615b72565b838111156129a85750506000910152565b73ffffffffffffffffffffffffffffffffffffffff8116811461359057600080fd5b63ffffffff8116811461359057600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732315065726d69743a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a164736f6c6343000706000a00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd07590000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b1000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c969

Deployed Bytecode

0x6080604052600436106102d55760003560e01c806369bc35b211610179578063ac9650d8116100d6578063d8a900b11161008a578063e985e9c511610064578063e985e9c51461083f578063fc6f78651461085f578063fd188ca41461087f57610380565b8063d8a900b1146107f7578063de2356d114610817578063df2ab5bb1461082c57610380565b8063b44a2722116100bb578063b44a2722146107a2578063b88d4fde146107b7578063c87b56dd146107d757610380565b8063ac9650d814610752578063b02c43d01461077257610380565b80638af3ac851161012d57806395d89b411161011257806395d89b4114610708578063a22cb4651461071d578063a5f6072f1461073d57610380565b80638af3ac85146106de5780639205ac2e146106f357610380565b806370a082311161015e57806370a082311461067e5780637ac2ff7b1461069e5780637f376059146106b157610380565b806369bc35b2146106565780636c0360eb1461066957610380565b80632f745c59116102325780633c423f0b116101e657806342842e0e116101c057806342842e0e146105f65780634f6ccce7146106165780636352211e1461063657610380565b80633c423f0b146105a05780633e785878146105c057806341865270146105ee57610380565b806332dc5a251161021757806332dc5a251461053d57806334267cbc1461056b5780633644e5151461058b57610380565b80632f745c591461050857806330adf81f1461052857610380565b8063095ea7b31161028957806318160ddd1161026e57806318160ddd146104a657806322872ce2146104c857806323b872dd146104e857610380565b8063095ea7b314610459578063150b7a021461047957610380565b806303a05df9116102ba57806303a05df9146103db57806306fdde031461040a578063081812fc1461042c57610380565b806301342b191461038557806301ffc9a7146103a557610380565b36610380573373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e9161461037e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420574e6174697665546f6b656e00000000000000000000000000000000604482015290519081900360640190fd5b005b600080fd5b34801561039157600080fd5b5061037e6103a03660046150c0565b61089f565b3480156103b157600080fd5b506103c56103c036600461500a565b6109c9565b6040516103d29190615688565b60405180910390f35b3480156103e757600080fd5b506103fb6103f636600461526a565b610a04565b6040516103d293929190615a6c565b34801561041657600080fd5b5061041f610a54565b6040516103d29190615729565b34801561043857600080fd5b5061044c61044736600461526a565b610b08565b6040516103d29190615543565b34801561046557600080fd5b5061037e610474366004614ecf565b610b8b565b34801561048557600080fd5b50610499610494366004614d97565b610cc9565b6040516103d2919061569c565b3480156104b257600080fd5b506104bb610e2d565b6040516103d29190615693565b3480156104d457600080fd5b5061037e6104e3366004615223565b610e3e565b3480156104f457600080fd5b5061037e610503366004614d57565b6111cd565b34801561051457600080fd5b506104bb610523366004614ecf565b61123e565b34801561053457600080fd5b506104bb611276565b34801561054957600080fd5b5061055d610558366004614ce7565b61129a565b6040516103d29291906155ad565b34801561057757600080fd5b5061037e6105863660046151e7565b6112d0565b34801561059757600080fd5b506104bb6115e4565b3480156105ac57600080fd5b5061037e6105bb3660046152be565b6116af565b3480156105cc57600080fd5b506105e06105db3660046151bd565b61188e565b6040516103d2929190615a14565b61037e611a55565b34801561060257600080fd5b5061037e610611366004614d57565b611a67565b34801561062257600080fd5b506104bb61063136600461526a565b611a82565b34801561064257600080fd5b5061044c61065136600461526a565b611a98565b61037e61066436600461529a565b611ac0565b34801561067557600080fd5b5061041f611c81565b34801561068a57600080fd5b506104bb610699366004614ce7565b611d00565b61037e6106ac366004614f3b565b611d9c565b3480156106bd57600080fd5b506106d16106cc366004615481565b612343565b6040516103d29190615700565b3480156106ea57600080fd5b5061044c612510565b3480156106ff57600080fd5b5061044c612534565b34801561071457600080fd5b5061041f612558565b34801561072957600080fd5b5061037e610738366004614e9b565b6125d7565b34801561074957600080fd5b5061044c612748565b610765610760366004614f9b565b61276c565b6040516103d2919061560a565b34801561077e57600080fd5b5061079261078d36600461526a565b6128c6565b6040516103d29493929190615a22565b3480156107ae57600080fd5b5061044c612912565b3480156107c357600080fd5b5061037e6107d2366004614e31565b612936565b3480156107e357600080fd5b5061041f6107f236600461526a565b6129ae565b34801561080357600080fd5b5061037e61081236600461504a565b612d1b565b34801561082357600080fd5b5061044c613016565b61037e61083a366004614efa565b61303a565b34801561084b57600080fd5b506103c561085a366004614d1f565b613151565b34801561086b57600080fd5b506105e061087a36600461514c565b61318c565b34801561088b57600080fd5b506104bb61089a36600461505c565b61329a565b336000908152600b602052604090819020805491517f01342b19000000000000000000000000000000000000000000000000000000008152909173ffffffffffffffffffffffffffffffffffffffff16906301342b19906109069086908690600401615714565b600060405180830381600087803b15801561092057600080fd5b505af1158015610934573d6000803e3d6000fd5b50505060018201546040517f01342b1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691506301342b19906109929086908690600401615714565b600060405180830381600087803b1580156109ac57600080fd5b505af11580156109c0573d6000803e3d6000fd5b50505050505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526020819052604090205460ff165b919050565b600d60205260009081526040902080546001909101546bffffffffffffffffffffffff8216916c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff169083565b60068054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b820191906000526020600020905b815481529060010190602001808311610ae157829003601f168201915b5050505050905090565b6000610b138261330d565b610b52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061583e565b60405180910390fd5b506000908152600d60205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1690565b6000610b9682611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180615da06021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c3c61331a565b73ffffffffffffffffffffffffffffffffffffffff161480610c655750610c658161085a61331a565b610cba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180615c9b6038913960400191505060405180910390fd5b610cc4838361331e565b505050565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b11614610d3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615909565b600a546000858152600c60209081526040808320600180820180547fffffffffffffff0000000000000000000000000000000000000000ffffffffff166501000000000073ffffffffffffffffffffffffffffffffffffffff8e1602179055858255858552600d909352922001869055610db487836133bc565b60018201600a5560405173ffffffffffffffffffffffffffffffffffffffff88169060009088907fcdfc765b85e1048bee3c6a0f9d1c91fc7c4631f5fe5745a55fc6843db5c3260f908390a4507f150b7a0200000000000000000000000000000000000000000000000000000000979650505050505050565b6000610e396002613545565b905090565b6000838152600c602052604090208054610e5790613550565b60018181015463ffffffff811690910190640100000000900460ff1660008415610ede578115610eb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061573c565b50600190507f00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd0759610f01565b507f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e5b6001840180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff1664010000000084151502177fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff85161790556000610f6b89613593565b905060008273ffffffffffffffffffffffffffffffffffffffff166360777795836040518263ffffffff1660e01b8152600401610fa89190615693565b6101806040518083038186803b158015610fc157600080fd5b505afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff99190615338565b50955050505050506000881115611139576000611015826135c3565b905061104382337f000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c9698c613688565b600061104e836135c3565b9050818111611089576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499061589b565b6040517f2113e8170000000000000000000000000000000000000000000000000000000081528282039a5073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c9691690632113e81790611104908e9088908f906004016159fe565b600060405180830381600087803b15801561111e57600080fd5b505af1158015611132573d6000803e3d6000fd5b5050505050505b6040517ff43930a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063f43930a39061118f908d908d908d906004016159df565b600060405180830381600087803b1580156111a957600080fd5b505af11580156111bd573d6000803e3d6000fd5b5050505050505050505050505050565b6111de6111d861331a565b8261386d565b611233576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180615dc16031913960400191505060405180910390fd5b610cc4838383613957565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040812061126d9083613b32565b90505b92915050565b7f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad81565b73ffffffffffffffffffffffffffffffffffffffff9081166000908152600b602052604090206001810154905490821692911690565b6000828152600c6020526040902080546112e990613550565b6001810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000811663ffffffff9182167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01909116177fffffffffffffff0000000000000000000000000000000000000000ffffffffff16336501000000000002179055600082156113c757506001810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff1690557f00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd07596113ea565b507f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e5b6040517f0705506b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690630705506b90611440908890889033906004016159a7565b600060405180830381600087803b15801561145a57600080fd5b505af115801561146e573d6000803e3d6000fd5b50505050600061147d86613593565b905060008273ffffffffffffffffffffffffffffffffffffffff166360777795836040518263ffffffff1660e01b81526004016114ba9190615693565b6101806040518083038186803b1580156114d357600080fd5b505afa1580156114e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150b9190615338565b509550505073ffffffffffffffffffffffffffffffffffffffff84161592506109c0915050576040517f92ae44e100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c96916906392ae44e1906115a990849033908b9088906004016155d4565b600060405180830381600087803b1580156115c357600080fd5b505af11580156115d7573d6000803e3d6000fd5b5050505050505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fc87d4fc585a701870df088fa6b1e15b85efc30f88431a410977d8a4fc01d527e7fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5611651613b3e565b30604051602001808681526020018581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019550505050505060405160208183030381529060405280519060200120905090565b73ffffffffffffffffffffffffffffffffffffffff82163014156116ff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b49906157d0565b6000838152600c60205260409020805461171881613550565b600182015463ffffffff161561175a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615773565b6000818152600d602052604081208181556001015561177881613b42565b6000858152600c602052604080822082815560010180547fffffffffffffff0000000000000000000000000000000000000000000000000016905551339087907fcdfc765b85e1048bee3c6a0f9d1c91fc7c4631f5fe5745a55fc6843db5c3260f908490a46040517fb88d4fde00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b1169063b88d4fde9061185590309088908a908990600401615564565b600060405180830381600087803b15801561186f57600080fd5b505af1158015611883573d6000803e3d6000fd5b505050505050505050565b6000818152600c602052604081205481906118a890613550565b60408085015173ffffffffffffffffffffffffffffffffffffffff9081166000908152600b6020529190912054168015611982576040517f7f37605900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690637f3760599061192e904290600401615a5b565b602060405180830381600087803b15801561194857600080fd5b505af115801561195c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198091906150a1565b505b6040517ffe4282fb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e169063fe4282fb906119f8908890889033906004016159a7565b6040805180830381600087803b158015611a1157600080fd5b505af1158015611a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a499190615315565b90969095509350505050565b4715611a6557611a653347613c47565b565b610cc483838360405180602001604052806000815250612936565b600080611a90600284613d95565b509392505050565b600061127082604051806060016040528060298152602001615cfd6029913960029190613db3565b60007f0000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e973ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611b4957600080fd5b505afa158015611b5d573d6000803e3d6000fd5b505050506040513d6020811015611b7357600080fd5b5051905082811015611be657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496e73756666696369656e7420574e6174697665546f6b656e00000000000000604482015290519081900360640190fd5b8015610cc4577f0000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e973ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611c5f57600080fd5b505af1158015611c73573d6000803e3d6000fd5b50505050610cc48282613c47565b60098054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b600073ffffffffffffffffffffffffffffffffffffffff8216611d6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615cd3602a913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902061127090613545565b83611da5613dca565b1115611e1257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5065726d69742065787069726564000000000000000000000000000000000000604482015290519081900360640190fd5b6000611e1c6115e4565b7f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8888611e4881613dce565b6040805160208082019690965273ffffffffffffffffffffffffffffffffffffffff909416848201526060840192909252608083015260a08083018a90528151808403909101815260c0830182528051908401207f190100000000000000000000000000000000000000000000000000000000000060e084015260e283019490945261010280830194909452805180830390940184526101229091019052815191012090506000611ef887611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff161415611f7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180615c246027913960400191505060405180910390fd5b611f8881613e20565b1561218a576040805160208082018790528183018690527fff0000000000000000000000000000000000000000000000000000000000000060f889901b16606083015282516041818403018152606183018085527f1626ba7e0000000000000000000000000000000000000000000000000000000090526065830186815260858401948552815160a5850152815173ffffffffffffffffffffffffffffffffffffffff871695631626ba7e958995919260c59091019185019080838360005b8381101561205f578181015183820152602001612047565b50505050905090810190601f16801561208c5780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b1580156120aa57600080fd5b505afa1580156120be573d6000803e3d6000fd5b505050506040513d60208110156120d457600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f1626ba7e000000000000000000000000000000000000000000000000000000001461218557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e617574686f72697a65640000000000000000000000000000000000000000604482015290519081900360640190fd5b61232f565b600060018387878760405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156121e6573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661229357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c6964207369676e6174757265000000000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461232d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e617574686f72697a65640000000000000000000000000000000000000000604482015290519081900360640190fd5b505b612339888861331e565b5050505050505050565b336000908152600b6020526040808220805491517f7f3760590000000000000000000000000000000000000000000000000000000081529091839173ffffffffffffffffffffffffffffffffffffffff90911690637f376059906123ab908790600401615a5b565b602060405180830381600087803b1580156123c557600080fd5b505af11580156123d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fd91906150a1565b60018301546040517f7f37605900000000000000000000000000000000000000000000000000000000815291925060009173ffffffffffffffffffffffffffffffffffffffff90911690637f3760599061245b908890600401615a5b565b602060405180830381600087803b15801561247557600080fd5b505af1158015612489573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124ad91906150a1565b905060018260028111156124bd57fe5b14806124d4575060018160028111156124d257fe5b145b156124e557600193505050506109ff565b60028160028111156124f357fe5b141561250557600293505050506109ff565b506000949350505050565b7f0000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e981565b7f000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c96981565b60078054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610afe5780601f10610ad357610100808354040283529160200191610afe565b6125df61331a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561267957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b806005600061268661331a565b73ffffffffffffffffffffffffffffffffffffffff90811682526020808301939093526040918201600090812091871680825291909352912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016921515929092179091556126f561331a565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b7f00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd075981565b60608167ffffffffffffffff8111801561278557600080fd5b506040519080825280602002602001820160405280156127b957816020015b60608152602001906001900390816127a45790505b50905060005b828110156128bf57600080308686858181106127d757fe5b90506020028101906127e99190615aa8565b6040516127f7929190615533565b600060405180830381855af49150503d8060008114612832576040519150601f19603f3d011682016040523d82523d6000602084013e612837565b606091505b50915091508161289d5760448151101561285057600080fd5b6004810190508080602001905181019061286a91906150e2565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b499190615729565b808484815181106128aa57fe5b602090810291909101015250506001016127bf565b5092915050565b600c602052600090815260409020805460019091015463ffffffff811690640100000000810460ff169065010000000000900473ffffffffffffffffffffffffffffffffffffffff1684565b7f000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b181565b61294761294161331a565b8361386d565b61299c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180615dc16031913960400191505060405180910390fd5b6129a884848484613e26565b50505050565b60606129b98261330d565b612a0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180615d71602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190921691909104601f810185900485028201850190935282815292909190830182828015612abf5780601f10612a9457610100808354040283529160200191612abf565b820191906000526020600020905b815481529060010190602001808311612aa257829003601f168201915b505050505090506000612ad0611c81565b9050805160001415612ae4575090506109ff565b815115612bff5780826040516020018083805190602001908083835b60208310612b3d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612b00565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b60208310612bc157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612b84565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506109ff565b80612c0985613e92565b6040516020018083805190602001908083835b60208310612c5957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612c1c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b60208310612cdd57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612ca0565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd075916148080612d9557503373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e16145b612dcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b49906158d2565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600b6020908152604080832081517ffacb0eb1000000000000000000000000000000000000000000000000000000008152915190948493909263facb0eb19260048083019392829003018186803b158015612e4157600080fd5b505afa158015612e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e799190614d03565b73ffffffffffffffffffffffffffffffffffffffff161415612e9c575082612eff565b73ffffffffffffffffffffffffffffffffffffffff8416612efc5782612edc57600182015473ffffffffffffffffffffffffffffffffffffffff16612ef5565b815473ffffffffffffffffffffffffffffffffffffffff165b9050612eff565b50305b6040517f7c1fe0c800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff861690637c1fe0c890612f51908490600401615543565b600060405180830381600087803b158015612f6b57600080fd5b505af1158015612f7f573d6000803e3d6000fd5b505050508215612fd0576001820180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905561300f565b81547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85161782555b5050505050565b7f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e81565b60008373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156130a357600080fd5b505afa1580156130b7573d6000803e3d6000fd5b505050506040513d60208110156130cd57600080fd5b505190508281101561314057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e73756666696369656e7420746f6b656e0000000000000000000000000000604482015290519081900360640190fd5b80156129a8576129a8848383613fbf565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b80516000908152600c602052604081205481906131a890613550565b602083015173ffffffffffffffffffffffffffffffffffffffff166131ce573060208401525b6040517ffc6f786500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b1169063fc6f786590613240908690600401615940565b6040805180830381600087803b15801561325957600080fd5b505af115801561326d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132919190615315565b91509150915091565b600082156132d1576132ce7f00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd0759868686614194565b90505b8115613305576133037f0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e868685614194565b015b949350505050565b600061127060028361424a565b3390565b6000818152600d6020526040902080546bffffffffffffffffffffffff166c0100000000000000000000000073ffffffffffffffffffffffffffffffffffffffff851690810291909117909155819061337682611a98565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b73ffffffffffffffffffffffffffffffffffffffff821661343e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6134478161330d565b156134b357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b6134bf60008383610cc4565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090206134ee9082614256565b506134fb60028284614262565b50604051819073ffffffffffffffffffffffffffffffffffffffff8416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600061127082614285565b61355a338261386d565b613590576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4990615807565b50565b6000816040516020016135a69190615999565b604051602081830303815290604052805190602001209050919050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190613638907f000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c96990600401615543565b60206040518083038186803b15801561365057600080fd5b505afa158015613664573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112709190615282565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000178152925182516000948594938a169392918291908083835b6020831061376557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613728565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146137c7576040519150601f19603f3d011682016040523d82523d6000602084013e6137cc565b606091505b50915091508180156137fa5750805115806137fa57508080602001905160208110156137f757600080fd5b50515b61386557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f5354460000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b505050505050565b60006138788261330d565b6138cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615c6f602c913960400191505060405180910390fd5b60006138d883611a98565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061394757508373ffffffffffffffffffffffffffffffffffffffff1661392f84610b08565b73ffffffffffffffffffffffffffffffffffffffff16145b8061330557506133058185613151565b8273ffffffffffffffffffffffffffffffffffffffff1661397782611a98565b73ffffffffffffffffffffffffffffffffffffffff16146139e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180615d486029913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216613a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180615c4b6024913960400191505060405180910390fd5b613a5a838383610cc4565b613a6560008261331e565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600160205260409020613a949082614289565b5073ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020613ac49082614256565b50613ad160028284614262565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061126d8383614295565b4690565b6000613b4d82611a98565b9050613b5b81600084610cc4565b613b6660008361331e565b60008281526008602052604090205460027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600184161502019091160415613bc2576000828152600860205260408120613bc291614b7f565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600160205260409020613bf19083614289565b50613bfd600283614313565b50604051829060009073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff84169083906040518082805190602001908083835b60208310613cbe57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101613c81565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d20576040519150601f19603f3d011682016040523d82523d6000602084013e613d25565b606091505b5050905080610cc457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600360248201527f5354450000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000808080613da4868661431f565b909450925050505b9250929050565b6000613dc08484846143b4565b90505b9392505050565b4290565b6000908152600d6020526040902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000811660016bffffffffffffffffffffffff9283169081019092161790915590565b3b151590565b613e31848484613957565b613e3d84848484614498565b6129a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180615bf26032913960400191505060405180910390fd5b606081613ed3575060408051808201909152600181527f300000000000000000000000000000000000000000000000000000000000000060208201526109ff565b8160005b8115613eeb57600101600a82049150613ed7565b60008167ffffffffffffffff81118015613f0457600080fd5b506040519080825280601f01601f191660200182016040528015613f2f576020820181803683370190505b5085935090507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82015b8315613fb657600a840660300160f81b82828060019003935081518110613f7c57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350613f59565b50949350505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251825160009485949389169392918291908083835b6020831061409457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614057565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146140f6576040519150601f19603f3d011682016040523d82523d6000602084013e6140fb565b606091505b5091509150818015614129575080511580614129575080806020019051602081101561412657600080fd5b50515b61300f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f5354000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6040517f0a53075400000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff861690630a530754906141ef9087903390889088906004016156c9565b602060405180830381600087803b15801561420957600080fd5b505af115801561421d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142419190615282565b95945050505050565b600061126d83836146a8565b600061126d83836146c0565b6000613dc0848473ffffffffffffffffffffffffffffffffffffffff851661470a565b5490565b600061126d83836147a1565b815460009082106142f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180615bd06022913960400191505060405180910390fd5b82600001828154811061430057fe5b9060005260206000200154905092915050565b600061126d8383614885565b81546000908190831061437d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180615d266022913960400191505060405180910390fd5b600084600001848154811061438e57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281614469576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561442e578181015183820152602001614416565b50505050905090810190601f16801561445b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061447c57fe5b9060005260206000209060020201600101549150509392505050565b60006144b98473ffffffffffffffffffffffffffffffffffffffff16613e20565b6144c557506001613305565b600061463d7f150b7a02000000000000000000000000000000000000000000000000000000006144f361331a565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561457457818101518382015260200161455c565b50505050905090810190601f1680156145a15780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001615bf26032913973ffffffffffffffffffffffffffffffffffffffff88169190614995565b9050600081806020019051602081101561465657600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001492505050949350505050565b60009081526001919091016020526040902054151590565b60006146cc83836146a8565b61470257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611270565b506000611270565b60008281526001840160205260408120548061476f575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055613dc3565b8285600001600183038154811061478257fe5b9060005260206000209060020201600101819055506000915050613dc3565b6000818152600183016020526040812054801561487b5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106147f257fe5b906000526020600020015490508087600001848154811061480f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061483f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611270565b6000915050611270565b6000818152600183016020526040812054801561487b5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106148d657fe5b90600052602060002090600202019050808760000184815481106148f657fe5b60009182526020808320845460029093020191825560019384015491840191909155835482528983019052604090209084019055865487908061493557fe5b6000828152602080822060027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840201828155600190810183905592909355888152898201909252604082209190915594506112709350505050565b6060613dc08484600085856149a985613e20565b614a1457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310614a7d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614a40565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614adf576040519150601f19603f3d011682016040523d82523d6000602084013e614ae4565b606091505b5091509150614af4828286614aff565b979650505050505050565b60608315614b0e575081613dc3565b825115614b1e5782518084602001fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181815284516024840152845185939192839260440191908501908083836000831561442e578181015183820152602001614416565b50805460018160011615610100020316600290046000825580601f10614ba55750613590565b601f01602090049060005260206000209081019061359091905b80821115614bd35760008155600101614bbf565b5090565b803580151581146109ff57600080fd5b600082601f830112614bf7578081fd5b8135614c0a614c0582615b2f565b615b0b565b818152846020838601011115614c1e578283fd5b816020850160208301379081016020019190915292915050565b600060a08284031215614c49578081fd5b60405160a0810181811067ffffffffffffffff82111715614c6657fe5b6040529050808235614c7781615b9b565b81526020830135614c8781615b9b565b60208201526040830135614c9a81615b9b565b8060408301525060608301356060820152608083013560808201525092915050565b80356fffffffffffffffffffffffffffffffff811681146109ff57600080fd5b80516109ff81615bbd565b600060208284031215614cf8578081fd5b8135613dc381615b9b565b600060208284031215614d14578081fd5b8151613dc381615b9b565b60008060408385031215614d31578081fd5b8235614d3c81615b9b565b91506020830135614d4c81615b9b565b809150509250929050565b600080600060608486031215614d6b578081fd5b8335614d7681615b9b565b92506020840135614d8681615b9b565b929592945050506040919091013590565b600080600080600060808688031215614dae578283fd5b8535614db981615b9b565b94506020860135614dc981615b9b565b935060408601359250606086013567ffffffffffffffff80821115614dec578283fd5b818801915088601f830112614dff578283fd5b813581811115614e0d578384fd5b896020828501011115614e1e578384fd5b9699959850939650602001949392505050565b60008060008060808587031215614e46578182fd5b8435614e5181615b9b565b93506020850135614e6181615b9b565b925060408501359150606085013567ffffffffffffffff811115614e83578182fd5b614e8f87828801614be7565b91505092959194509250565b60008060408385031215614ead578182fd5b8235614eb881615b9b565b9150614ec660208401614bd7565b90509250929050565b60008060408385031215614ee1578182fd5b8235614eec81615b9b565b946020939093013593505050565b600080600060608486031215614f0e578081fd5b8335614f1981615b9b565b9250602084013591506040840135614f3081615b9b565b809150509250925092565b60008060008060008060c08789031215614f53578384fd5b8635614f5e81615b9b565b95506020870135945060408701359350606087013560ff81168114614f81578182fd5b9598949750929560808101359460a0909101359350915050565b60008060208385031215614fad578182fd5b823567ffffffffffffffff80821115614fc4578384fd5b818501915085601f830112614fd7578384fd5b813581811115614fe5578485fd5b8660208083028501011115614ff8578485fd5b60209290920196919550909350505050565b60006020828403121561501b578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114613dc3578182fd5b60008060408385031215614d31578182fd5b60008060008060808587031215615071578182fd5b843561507c81615b9b565b9350602085013561508c81615b9b565b93969395505050506040820135916060013590565b6000602082840312156150b2578081fd5b815160038110613dc3578182fd5b600080604083850312156150d2578182fd5b82358060020b8114614eb8578283fd5b6000602082840312156150f3578081fd5b815167ffffffffffffffff811115615109578182fd5b8201601f81018413615119578182fd5b8051615127614c0582615b2f565b81815285602083850101111561513b578384fd5b614241826020830160208601615b6f565b60006080828403121561515d578081fd5b6040516080810181811067ffffffffffffffff8211171561517a57fe5b60405282358152602083013561518f81615b9b565b60208201526151a060408401614cbc565b60408201526151b160608401614cbc565b60608201529392505050565b60008060c083850312156151cf578182fd5b6151d98484614c38565b9460a0939093013593505050565b600080600060e084860312156151fb578081fd5b6152058585614c38565b925060a0840135915061521a60c08501614bd7565b90509250925092565b6000806000806101008587031215615239578182fd5b6152438686614c38565b935060a0850135925060c0850135915061525f60e08601614bd7565b905092959194509250565b60006020828403121561527b578081fd5b5035919050565b600060208284031215615293578081fd5b5051919050565b600080604083850312156152ac578182fd5b823591506020830135614d4c81615b9b565b6000806000606084860312156152d2578081fd5b8335925060208401356152e481615b9b565b9150604084013567ffffffffffffffff8111156152ff578182fd5b61530b86828701614be7565b9150509250925092565b60008060408385031215615327578182fd5b505080516020909101519092909150565b6000806000806000806000878903610180811215615354578586fd5b8851975060208901519650604089015161536d81615b9b565b60608a015190965062ffffff81168114615385578283fd5b60808a01519095507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146153b6578283fd5b60a08a01519094506153c781615b9b565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40820112156153f8578182fd5b5060405160c0810181811067ffffffffffffffff8211171561541657fe5b806040525060c0890151815260e08901516020820152610100890151604082015261012089015161544681615bbd565b606082015261014089015161545a81615bbd565b608082015261546c6101608a01614cdc565b60a08201528091505092959891949750929550565b600060208284031215615492578081fd5b8135613dc381615bbd565b600081518084526154b5816020860160208601615b6f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff8082511683528060208301511660208401528060408301511660408401525060608101516060830152608081015160808301525050565b6000828483379101908152919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b600073ffffffffffffffffffffffffffffffffffffffff8087168352808616602084015250836040830152608060608301526155a3608083018461549d565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561567b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845261566985835161549d565b9450928501929085019060010161562f565b5092979650505050505050565b901515815260200190565b90815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b602081016003831061570e57fe5b91905290565b60029290920b82521515602082015260400190565b60006020825261126d602083018461549d565b60208082526014908201527f746f6b656e20616c7265616479206661726d6564000000000000000000000000604082015260600190565b60208082526021908201527f63616e6e6f7420776974686472617720746f6b656e207768696c65206661726d60408201527f6400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f63616e6e6f7420776974686472617720746f206661726d696e67000000000000604082015260600190565b6020808252600c908201527f4e6f7420617070726f7665640000000000000000000000000000000000000000604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201527f697374656e7420746f6b656e0000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f496e73756666696369656e7420746f6b656e73206c6f636b6564000000000000604082015260600190565b6020808252601a908201527f6f6e6c79206661726d696e672063616e2063616c6c2074686973000000000000604082015260600190565b60208082526012908201527f6e6f7420616e20416c6765627261206e66740000000000000000000000000000604082015260600190565b8151815260208083015173ffffffffffffffffffffffffffffffffffffffff16908201526040808301516fffffffffffffffffffffffffffffffff90811691830191909152606092830151169181019190915260800190565b60a0810161127082846154e7565b60e081016159b582866154e7565b8360a083015273ffffffffffffffffffffffffffffffffffffffff831660c0830152949350505050565b60e081016159ed82866154e7565b60a082019390935260c00152919050565b9283526020830191909152604082015260600190565b918252602082015260400190565b93845263ffffffff9290921660208401521515604083015273ffffffffffffffffffffffffffffffffffffffff16606082015260800190565b63ffffffff91909116815260200190565b6bffffffffffffffffffffffff93909316835273ffffffffffffffffffffffffffffffffffffffff919091166020830152604082015260600190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615adc578283fd5b83018035915067ffffffffffffffff821115615af6578283fd5b602001915036819003821315613dac57600080fd5b60405181810167ffffffffffffffff81118282101715615b2757fe5b604052919050565b600067ffffffffffffffff821115615b4357fe5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b83811015615b8a578181015183820152602001615b72565b838111156129a85750506000910152565b73ffffffffffffffffffffffffffffffffffffffff8116811461359057600080fd5b63ffffffff8116811461359057600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732315065726d69743a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a164736f6c6343000706000a

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

00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd07590000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b1000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c969

-----Decoded View---------------
Arg [0] : _limitFarming (address): 0x17bE2Ed4409d8e6c22d46dE599f7C9Af40bD0759
Arg [1] : _eternalFarming (address): 0x1fd3f47B363f5b844eD7B7FAB6ceb679A367621E
Arg [2] : _nonfungiblePositionManager (address): 0xd8E1E7009802c914b0d39B31Fc1759A865b727B1
Arg [3] : _farmingCenterVault (address): 0x930388c769Da7B4616493d47B5D093D8ec26C969

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000017be2ed4409d8e6c22d46de599f7c9af40bd0759
Arg [1] : 0000000000000000000000001fd3f47b363f5b844ed7b7fab6ceb679a367621e
Arg [2] : 000000000000000000000000d8e1e7009802c914b0d39b31fc1759a865b727b1
Arg [3] : 000000000000000000000000930388c769da7b4616493d47b5d093d8ec26c969


Block Transaction Gas Used Reward
view all blocks sequenced

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
[ 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.