ETH Price: $3,392.26 (+2.29%)

Contract

0xd33d3D71C6F710fb7A94469ED958123Ab86858b1
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Harvest182028262023-09-24 2:56:23481 days ago1695524183IN
0xd33d3D71...Ab86858b1
0 ETH0.00346838.4
Harvest173536402023-05-27 23:24:11600 days ago1685229851IN
0xd33d3D71...Ab86858b1
0 ETH0.0099198623.05820233
Harvest170074882023-04-09 1:24:11649 days ago1681003451IN
0xd33d3D71...Ab86858b1
0 ETH0.0081804220.4
Harvest168466812023-03-17 9:35:47671 days ago1679045747IN
0xd33d3D71...Ab86858b1
0 ETH0.0071997318
Harvest168085312023-03-12 0:56:11677 days ago1678582571IN
0xd33d3D71...Ab86858b1
0 ETH0.0095231523.06067326
Harvest167098632023-02-26 3:54:23691 days ago1677383663IN
0xd33d3D71...Ab86858b1
0 ETH0.0086624120.14168666
Harvest165683832023-02-06 7:54:35711 days ago1675670075IN
0xd33d3D71...Ab86858b1
0 ETH0.0072367318
Harvest164087592023-01-15 0:54:35733 days ago1673744075IN
0xd33d3D71...Ab86858b1
0 ETH0.0079541219.86619764
Harvest162578602022-12-24 23:24:35754 days ago1671924275IN
0xd33d3D71...Ab86858b1
0 ETH0.0050676812
Harvest161032282022-12-03 8:54:59775 days ago1670057699IN
0xd33d3D71...Ab86858b1
0 ETH0.0050359312
Harvest160425042022-11-24 21:24:11784 days ago1669325051IN
0xd33d3D71...Ab86858b1
0 ETH0.0049041312
Harvest159879322022-11-17 6:24:11792 days ago1668666251IN
0xd33d3D71...Ab86858b1
0 ETH0.006187814.97602562
Harvest159560052022-11-12 19:23:59796 days ago1668281039IN
0xd33d3D71...Ab86858b1
0 ETH0.0059438614.08354172
Harvest159052882022-11-05 17:24:59803 days ago1667669099IN
0xd33d3D71...Ab86858b1
0 ETH0.0059880813.2
Harvest158367072022-10-27 3:24:59813 days ago1666841099IN
0xd33d3D71...Ab86858b1
0 ETH0.0047256912
Harvest157798972022-10-19 4:54:35821 days ago1666155275IN
0xd33d3D71...Ab86858b1
0 ETH0.0060910414.4
Whitelist Harves...157163192022-10-10 7:49:59830 days ago1665388199IN
0xd33d3D71...Ab86858b1
0 ETH0.00270628.54164942
Harvest157018982022-10-08 7:32:35832 days ago1665214355IN
0xd33d3D71...Ab86858b1
0 ETH0.002897656.57788722
Rebalance157018322022-10-08 7:19:23832 days ago1665213563IN
0xd33d3D71...Ab86858b1
0 ETH0.004729187.48982033

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StrategyUsdcEth05UniV3

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : strategy-univ3-usdc-eth-05-lp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "./strategy-univ3-rebalance.sol";

contract StrategyUsdcEth05UniV3 is StrategyRebalanceUniV3 {
    address private priv_pool = 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640;

    constructor(
        int24 _tickRangeMultiplier,
        uint24 _swapPoolFee,
        address _governance,
        address _strategist,
        address _controller,
        address _timelock
    )
        public
        StrategyRebalanceUniV3(
            priv_pool,
            _tickRangeMultiplier,
            _governance,
            _strategist,
            _controller,
            _timelock
        )
    {
        swapPoolFee = (_swapPoolFee != 0) ? _swapPoolFee : pool.fee();
    }

    function getName() external pure override returns (string memory) {
        return "StrategyUsdcEth05UniV3";
    }
}

File 2 of 27 : strategy-univ3-rebalance.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../../lib/erc20.sol";
import "../../lib/safe-math.sol";
import "../../lib/univ3/PoolActions.sol";
import "../../interfaces/uniswapv2.sol";
import "../../interfaces/univ3/IUniswapV3PositionsNFT.sol";
import "../../interfaces/univ3/IUniswapV3Pool.sol";
import "../../interfaces/univ3/ISwapRouter02.sol";
import "../../interfaces/controllerv2.sol";

abstract contract StrategyRebalanceUniV3 {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;
    using PoolVariables for IUniswapV3Pool;

    // Perfomance fees - start with 20%
    uint256 public performanceTreasuryFee = 2000;
    uint256 public constant performanceTreasuryMax = 10000;

    // User accounts
    address public governance;
    address public controller;
    address public strategist;
    address public timelock;

    // Dex
    address public constant univ3Router =
        0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;

    // Tokens
    IUniswapV3Pool public pool;

    IERC20 public token0;
    IERC20 public token1;
    uint256 public tokenId;

    int24 public tick_lower;
    int24 public tick_upper;
    int24 private tickSpacing;
    int24 private tickRangeMultiplier;
    uint24 public swapPoolFee;
    uint24 private twapTime = 60;

    IUniswapV3PositionsNFT public nftManager =
        IUniswapV3PositionsNFT(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);

    mapping(address => bool) public harvesters;

    event InitialDeposited(uint256 tokenId);
    event Harvested(uint256 tokenId);
    event Deposited(
        uint256 tokenId,
        uint256 token0Balance,
        uint256 token1Balance
    );
    event Withdrawn(uint256 tokenId, uint256 _liquidity);
    event Rebalanced(uint256 tokenId, int24 _tickLower, int24 _tickUpper);

    constructor(
        address _pool,
        int24 _tickRangeMultiplier,
        address _governance,
        address _strategist,
        address _controller,
        address _timelock
    ) public {
        governance = _governance;
        strategist = _strategist;
        controller = _controller;
        timelock = _timelock;

        pool = IUniswapV3Pool(_pool);
        swapPoolFee = pool.fee();

        token0 = IERC20(pool.token0());
        token1 = IERC20(pool.token1());

        tickSpacing = pool.tickSpacing();
        tickRangeMultiplier = _tickRangeMultiplier;

        token0.safeApprove(address(nftManager), uint256(-1));
        token1.safeApprove(address(nftManager), uint256(-1));
    }

    // **** Modifiers **** //

    modifier onlyBenevolent() {
        require(
            harvesters[msg.sender] ||
                msg.sender == governance ||
                msg.sender == strategist
        );
        _;
    }

    // **** Views **** //

    function liquidityOfThis() public view returns (uint256) {
        uint256 liquidity = uint256(
            pool.liquidityForAmounts(
                token0.balanceOf(address(this)),
                token1.balanceOf(address(this)),
                tick_lower,
                tick_upper
            )
        );
        return liquidity;
    }

    function liquidityOfPool() public view returns (uint256) {
        (, , , , , , , uint128 _liquidity, , , , ) = nftManager.positions(
            tokenId
        );
        return _liquidity;
    }

    function liquidityOf() public view returns (uint256) {
        return liquidityOfThis().add(liquidityOfPool());
    }

    function getName() external pure virtual returns (string memory);

    // **** Setters **** //

    function whitelistHarvesters(address[] calldata _harvesters) external {
        require(
            msg.sender == governance ||
                msg.sender == strategist ||
                harvesters[msg.sender],
            "not authorized"
        );

        for (uint256 i = 0; i < _harvesters.length; i++) {
            harvesters[_harvesters[i]] = true;
        }
    }

    function revokeHarvesters(address[] calldata _harvesters) external {
        require(
            msg.sender == governance || msg.sender == strategist,
            "not authorized"
        );

        for (uint256 i = 0; i < _harvesters.length; i++) {
            harvesters[_harvesters[i]] = false;
        }
    }

    function setPerformanceTreasuryFee(uint256 _performanceTreasuryFee)
        external
    {
        require(msg.sender == timelock, "!timelock");
        performanceTreasuryFee = _performanceTreasuryFee;
    }

    function setSwapPoolFee(uint24 _swapPoolFee) external {
        require(msg.sender == governance, "!governance");
        swapPoolFee = _swapPoolFee;
    }

    function setStrategist(address _strategist) external {
        require(msg.sender == governance, "!governance");
        strategist = _strategist;
    }

    function setGovernance(address _governance) external {
        require(msg.sender == governance, "!governance");
        governance = _governance;
    }

    function setTimelock(address _timelock) external {
        require(msg.sender == timelock, "!timelock");
        timelock = _timelock;
    }

    function setController(address _controller) external {
        require(msg.sender == timelock, "!timelock");
        controller = _controller;
    }

    function setTwapTime(uint24 _twapTime) public {
        require(msg.sender == governance, "!governance");
        twapTime = _twapTime;
    }

    function setTickRangeMultiplier(int24 _tickRangeMultiplier) public {
        require(msg.sender == governance, "!governance");
        tickRangeMultiplier = _tickRangeMultiplier;
    }

    function amountsForLiquid() public view returns (uint256, uint256) {
        (uint256 a1, uint256 a2) = pool.amountsForLiquidity(
            1e18,
            tick_lower,
            tick_upper
        );
        return (a1, a2);
    }

    function determineTicks() public view returns (int24, int24) {
        uint32[] memory _observeTime = new uint32[](2);
        _observeTime[0] = twapTime;
        _observeTime[1] = 0;
        (int56[] memory _cumulativeTicks, ) = pool.observe(_observeTime);
        int56 _averageTick = (_cumulativeTicks[1] - _cumulativeTicks[0]) /
            twapTime;
        int24 baseThreshold = tickSpacing * tickRangeMultiplier;
        return
            PoolVariables.baseTicks(
                int24(_averageTick),
                baseThreshold,
                tickSpacing
            );
    }

    // **** State mutations **** //

    function deposit() public {
        uint256 _token0 = token0.balanceOf(address(this));
        uint256 _token1 = token1.balanceOf(address(this));

        if (_token0 > 0 && _token1 > 0) {
            nftManager.increaseLiquidity(
                IUniswapV3PositionsNFT.IncreaseLiquidityParams({
                    tokenId: tokenId,
                    amount0Desired: _token0,
                    amount1Desired: _token1,
                    amount0Min: 0,
                    amount1Min: 0,
                    deadline: block.timestamp + 300
                })
            );
        }

        emit Deposited(tokenId, _token0, _token1);
    }

    function _withdrawSome(uint256 _liquidity)
        internal
        returns (uint256, uint256)
    {
        if (_liquidity == 0) return (0, 0);

        (uint256 _a0Expect, uint256 _a1Expect) = pool.amountsForLiquidity(
            uint128(_liquidity),
            tick_lower,
            tick_upper
        );
        (uint256 amount0, uint256 amount1) = nftManager.decreaseLiquidity(
            IUniswapV3PositionsNFT.DecreaseLiquidityParams({
                tokenId: tokenId,
                liquidity: uint128(_liquidity),
                amount0Min: _a0Expect,
                amount1Min: _a1Expect,
                deadline: block.timestamp + 300
            })
        );

        //Only collect decreasedLiquidity, not trading fees.
        nftManager.collect(
            IUniswapV3PositionsNFT.CollectParams({
                tokenId: tokenId,
                recipient: address(this),
                amount0Max: uint128(amount0),
                amount1Max: uint128(amount1)
            })
        );

        return (amount0, amount1);
    }

    // Controller only function for creating additional rewards from dust
    function withdraw(IERC20 _asset) external returns (uint256 balance) {
        require(msg.sender == controller, "!controller");
        balance = _asset.balanceOf(address(this));
        _asset.safeTransfer(controller, balance);
    }

    function withdraw(uint256 _liquidity)
        external
        returns (uint256 a0, uint256 a1)
    {
        require(msg.sender == controller, "!controller");
        (a0, a1) = _withdrawSome(_liquidity);

        address _jar = IControllerV2(controller).jars(address(pool));
        require(_jar != address(0), "!jar"); // additional protection so we don't burn the funds

        token0.safeTransfer(_jar, a0);
        token1.safeTransfer(_jar, a1);

        emit Withdrawn(tokenId, _liquidity);
    }

    // Withdraw all funds, normally used when migrating strategies
    function withdrawAll() external returns (uint256 a0, uint256 a1) {
        require(msg.sender == controller, "!controller");
        _withdrawAll();
        address _jar = IControllerV2(controller).jars(address(pool));
        require(_jar != address(0), "!jar"); // additional protection so we don't burn the funds

        a0 = token0.balanceOf(address(this));
        a1 = token1.balanceOf(address(this));
        token0.safeTransfer(_jar, a0);
        token1.safeTransfer(_jar, a1);
    }

    function _withdrawAll() internal returns (uint256 a0, uint256 a1) {
        (a0, a1) = _withdrawSome(liquidityOfPool());
    }

    function harvest() public onlyBenevolent {
        uint256 _initToken0 = token0.balanceOf(address(this));
        uint256 _initToken1 = token1.balanceOf(address(this));
        nftManager.collect(
            IUniswapV3PositionsNFT.CollectParams({
                tokenId: tokenId,
                recipient: address(this),
                amount0Max: type(uint128).max,
                amount1Max: type(uint128).max
            })
        );

        nftManager.sweepToken(address(token0), 0, address(this));
        nftManager.sweepToken(address(token1), 0, address(this));

        _distributePerformanceFees(
            token0.balanceOf(address(this)).sub(_initToken0),
            token1.balanceOf(address(this)).sub(_initToken1)
        );

        _balanceProportion(tick_lower, tick_upper);

        deposit();

        emit Harvested(tokenId);
    }

    function getHarvestable() public onlyBenevolent returns (uint256, uint256) {
        //This will only update when someone mint/burn/pokes the pool.
        (uint256 _owed0, uint256 _owed1) = nftManager.collect(
            IUniswapV3PositionsNFT.CollectParams({
                tokenId: tokenId,
                recipient: address(this),
                amount0Max: type(uint128).max,
                amount1Max: type(uint128).max
            })
        );
        return (uint256(_owed0), uint256(_owed1));
    }

    function rebalance() external onlyBenevolent returns (uint256 _tokenId) {
        if (tokenId != 0) {
            uint256 _initToken0 = token0.balanceOf(address(this));
            uint256 _initToken1 = token1.balanceOf(address(this));
            (, , , , , , , uint256 _liquidity, , , , ) = nftManager.positions(
                tokenId
            );
            (uint256 _liqAmt0, uint256 _liqAmt1) = nftManager.decreaseLiquidity(
                IUniswapV3PositionsNFT.DecreaseLiquidityParams({
                    tokenId: tokenId,
                    liquidity: uint128(_liquidity),
                    amount0Min: 0,
                    amount1Min: 0,
                    deadline: block.timestamp + 300
                })
            );

            // This has to be done after DecreaseLiquidity to collect the tokens we
            // decreased and the fees at the same time.
            nftManager.collect(
                IUniswapV3PositionsNFT.CollectParams({
                    tokenId: tokenId,
                    recipient: address(this),
                    amount0Max: type(uint128).max,
                    amount1Max: type(uint128).max
                })
            );

            nftManager.sweepToken(address(token0), 0, address(this));
            nftManager.sweepToken(address(token1), 0, address(this));
            nftManager.burn(tokenId);

            _distributePerformanceFees(
                token0.balanceOf(address(this)).sub(_liqAmt0).sub(_initToken0),
                token1.balanceOf(address(this)).sub(_liqAmt1).sub(_initToken1)
            );
        }

        (int24 _tickLower, int24 _tickUpper) = determineTicks();
        _balanceProportion(_tickLower, _tickUpper);
        //Need to do this again after the swap to cover any slippage.
        uint256 _amount0Desired = token0.balanceOf(address(this));
        uint256 _amount1Desired = token1.balanceOf(address(this));

        (_tokenId, , , ) = nftManager.mint(
            IUniswapV3PositionsNFT.MintParams({
                token0: address(token0),
                token1: address(token1),
                fee: pool.fee(),
                tickLower: _tickLower,
                tickUpper: _tickUpper,
                amount0Desired: _amount0Desired,
                amount1Desired: _amount1Desired,
                amount0Min: 0,
                amount1Min: 0,
                recipient: address(this),
                deadline: block.timestamp + 300
            })
        );

        //Record updated information.
        tokenId = _tokenId;
        tick_lower = _tickLower;
        tick_upper = _tickUpper;

        if (tokenId == 0) {
            emit InitialDeposited(_tokenId);
        }

        emit Rebalanced(tokenId, _tickLower, _tickUpper);
    }

    // **** Emergency functions ****

    function execute(address _target, bytes memory _data)
        public
        payable
        returns (bytes memory response)
    {
        require(msg.sender == timelock, "!timelock");
        require(_target != address(0), "!target");

        // call contract in current context
        assembly {
            let succeeded := delegatecall(
                sub(gas(), 5000),
                _target,
                add(_data, 0x20),
                mload(_data),
                0,
                0
            )
            let size := returndatasize()

            response := mload(0x40)
            mstore(
                0x40,
                add(response, and(add(add(size, 0x20), 0x1f), not(0x1f)))
            )
            mstore(response, size)
            returndatacopy(add(response, 0x20), 0, size)

            switch iszero(succeeded)
            case 1 {
                // throw if delegatecall failed
                revert(add(response, 0x20), size)
            }
        }
    }

    // **** Internal functions ****
    function _balanceProportion(int24 _tickLower, int24 _tickUpper) internal {
        PoolVariables.Info memory _cache;

        _cache.amount0Desired = token0.balanceOf(address(this));
        _cache.amount1Desired = token1.balanceOf(address(this));

        //Get Max Liquidity for Amounts we own.
        _cache.liquidity = pool.liquidityForAmounts(
            _cache.amount0Desired,
            _cache.amount1Desired,
            _tickLower,
            _tickUpper
        );

        //Get correct amounts of each token for the liquidity we have.
        (_cache.amount0, _cache.amount1) = pool.amountsForLiquidity(
            _cache.liquidity,
            _tickLower,
            _tickUpper
        );

        //Determine Trade Direction
        bool _zeroForOne;
        if (_cache.amount1Desired == 0) {
            _zeroForOne = true;
        } else {
            _zeroForOne = PoolVariables.amountsDirection(
                _cache.amount0Desired,
                _cache.amount1Desired,
                _cache.amount0,
                _cache.amount1
            );
        }

        //Determine Amount to swap
        uint256 _amountSpecified = _zeroForOne
            ? (_cache.amount0Desired.sub(_cache.amount0).div(2))
            : (_cache.amount1Desired.sub(_cache.amount1).div(2));

        if (_amountSpecified > 0) {
            //Determine Token to swap
            address _inputToken = _zeroForOne
                ? address(token0)
                : address(token1);

            IERC20(_inputToken).safeApprove(univ3Router, 0);
            IERC20(_inputToken).safeApprove(univ3Router, _amountSpecified);

            //Swap the token imbalanced
            ISwapRouter02(univ3Router).exactInputSingle(
                ISwapRouter02.ExactInputSingleParams({
                    tokenIn: _inputToken,
                    tokenOut: _zeroForOne ? address(token1) : address(token0),
                    fee: swapPoolFee,
                    recipient: address(this),
                    amountIn: _amountSpecified,
                    amountOutMinimum: 0,
                    sqrtPriceLimitX96: 0
                })
            );
        }
    }

    function _distributePerformanceFees(uint256 _amount0, uint256 _amount1)
        internal
    {
        if (_amount0 > 0) {
            IERC20(token0).safeTransfer(
                IControllerV2(controller).treasury(),
                _amount0.mul(performanceTreasuryFee).div(performanceTreasuryMax)
            );
        }
        if (_amount1 > 0) {
            IERC20(token1).safeTransfer(
                IControllerV2(controller).treasury(),
                _amount1.mul(performanceTreasuryFee).div(performanceTreasuryMax)
            );
        }
    }

    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public pure returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 3 of 27 : erc20.sol
// File: contracts/GSN/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

import "./safe-math.sol";
import "./context.sol";

// File: contracts/token/ERC20/IERC20.sol

/**
 * @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: contracts/utils/Address.sol

/**
 * @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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(
        address target,
        bytes memory data,
        uint256 weiValue,
        string memory errorMessage
    ) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{value: weiValue}(data);
        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: contracts/token/ERC20/ERC20.sol

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

    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

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

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

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(
            sender,
            _msgSender(),
            _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")
        );
        return true;
    }

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

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

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

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

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

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

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

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

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

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

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

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

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

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

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

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

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

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

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

File 4 of 27 : safe-math.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.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, 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) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * 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);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 5 of 27 : PoolActions.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../../interfaces/univ3/IUniswapV3Pool.sol";
import "./PoolVariables.sol";
import "./SafeCast.sol";

/// @title This library is created to conduct a variety of burn liquidity methods
library PoolActions {
    using PoolVariables for IUniswapV3Pool;
    using LowGasSafeMath for uint256;
    using SafeCast for uint256;

    /**
     * @notice Withdraws liquidity in share proportion to the Sorbetto's totalSupply.
     * @param pool Uniswap V3 pool
     * @param tickLower The lower tick of the range
     * @param tickUpper The upper tick of the range
     * @param totalSupply The amount of total shares in existence
     * @param share to burn
     * @param to Recipient of amounts
     * @return amount0 Amount of token0 withdrawed
     * @return amount1 Amount of token1 withdrawed
     */
    function burnLiquidityShare(
        IUniswapV3Pool pool,
        int24 tickLower,
        int24 tickUpper,
        uint256 totalSupply,
        uint256 share,
        address to
    ) internal returns (uint256 amount0, uint256 amount1) {
        require(totalSupply > 0, "TS");
        uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper);
        uint256 liquidity = uint256(liquidityInPool).mul(share) / totalSupply;

        if (liquidity > 0) {
            (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity.toUint128());

            if (amount0 > 0 || amount1 > 0) {
                // collect liquidity share
                (amount0, amount1) = pool.collect(to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128());
            }
        }
    }

    /**
     * @notice Withdraws exact amount of liquidity
     * @param pool Uniswap V3 pool
     * @param tickLower The lower tick of the range
     * @param tickUpper The upper tick of the range
     * @param liquidity to burn
     * @param to Recipient of amounts
     * @return amount0 Amount of token0 withdrawed
     * @return amount1 Amount of token1 withdrawed
     */
    function burnExactLiquidity(
        IUniswapV3Pool pool,
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity,
        address to
    ) internal returns (uint256 amount0, uint256 amount1) {
        uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper);
        require(liquidityInPool >= liquidity, "TML");
        (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity);

        if (amount0 > 0 || amount1 > 0) {
            // collect liquidity share including earned fees
            (amount0, amount0) = pool.collect(to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128());
        }
    }

    /**
     * @notice Withdraws all liquidity in a range from Uniswap pool
     * @param pool Uniswap V3 pool
     * @param tickLower The lower tick of the range
     * @param tickUpper The upper tick of the range
     */
    function burnAllLiquidity(
        IUniswapV3Pool pool,
        int24 tickLower,
        int24 tickUpper
    ) internal {
        // Burn all liquidity in this range
        uint128 liquidity = pool.positionLiquidity(tickLower, tickUpper);
        if (liquidity > 0) {
            pool.burn(tickLower, tickUpper, liquidity);
        }

        // Collect all owed tokens
        pool.collect(address(this), tickLower, tickUpper, type(uint128).max, type(uint128).max);
    }
}

File 6 of 27 : uniswapv2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

interface UniswapRouterV2 {
    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    )
        external
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        );

    function addLiquidityETH(
        address token,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    )
        external
        payable
        returns (
            uint256 amountToken,
            uint256 amountETH,
            uint256 liquidity
        );

    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB);

    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

    function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

    function swapETHForExactTokens(
        uint256 amountOut,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function swapExactETHForTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);
}

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Transfer(address indexed from, address indexed to, uint256 value);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);

    function totalSupply() external view returns (uint256);

    function balanceOf(address owner) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function PERMIT_TYPEHASH() external pure returns (bytes32);

    function nonces(address owner) external view returns (uint256);

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    event Mint(address indexed sender, uint256 amount0, uint256 amount1);
    event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint256 amount0In,
        uint256 amount1In,
        uint256 amount0Out,
        uint256 amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint256);

    function factory() external view returns (address);

    function token0() external view returns (address);

    function token1() external view returns (address);

    function getReserves()
        external
        view
        returns (
            uint112 reserve0,
            uint112 reserve1,
            uint32 blockTimestampLast
        );

    function price0CumulativeLast() external view returns (uint256);

    function price1CumulativeLast() external view returns (uint256);

    function kLast() external view returns (uint256);

    function mint(address to) external returns (uint256 liquidity);

    function burn(address to) external returns (uint256 amount0, uint256 amount1);

    function swap(
        uint256 amount0Out,
        uint256 amount1Out,
        address to,
        bytes calldata data
    ) external;

    function skim(address to) external;

    function sync() external;
}

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint256);

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

    function allPairs(uint256) external view returns (address pair);

    function allPairsLength() external view returns (uint256);

    function feeTo() external view returns (address);

    function feeToSetter() external view returns (address);

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

File 7 of 27 : IUniswapV3PositionsNFT.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "./IERC721.sol";

// Originally INonfungiblePositionManager
interface IUniswapV3PositionsNFT is IERC721 {
    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

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

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

    /// @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 fee The fee associated with the 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, // [0]
            address operator, // [1]
            address token0, // [2]
            address token1, // [3]
            uint24 fee, // [4]
            int24 tickLower, // [5]
            int24 tickUpper, // [6]
            uint128 liquidity, // [7]
            uint256 feeGrowthInside0LastX128, // [8]
            uint256 feeGrowthInside1LastX128, // [9]
            uint128 tokensOwed0, // [10]
            uint128 tokensOwed1 // [11]
        );

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

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

    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);

    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    function burn(uint256 tokenId) external payable;

    function refundETH() external payable;

    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

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

import "./pool/IUniswapV3PoolImmutables.sol";
import "./pool/IUniswapV3PoolState.sol";
import "./pool/IUniswapV3PoolDerivedState.sol";
import "./pool/IUniswapV3PoolActions.sol";

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions
{
    function fee() external view returns (uint24);
}

File 9 of 27 : ISwapRouter02.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

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

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,
    /// and swap the entire amount, enabling contracts to send tokens before calling this function.
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params)
        external
        payable
        returns (uint256 amountOut);

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

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,
    /// and swap the entire amount, enabling contracts to send tokens before calling this function.
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params)
        external
        payable
        returns (uint256 amountOut);

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

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

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

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

File 10 of 27 : controllerv2.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

interface IControllerV2 {
    function jars(address) external view returns (address);

    function devfund() external view returns (address);

    function treasury() external view returns (address);

    function liquidityOf(address) external view returns (uint256);

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

    function earn(
        address,
        uint256,
        uint256
    ) external;

    function strategies(address) external view returns (address);

    function getUpperTick(address) external view returns (int24);

    function getLowerTick(address) external view returns (int24);
}

File 11 of 27 : context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.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 payable(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 12 of 27 : PoolVariables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "./LiquidityAmounts.sol";
import "../../interfaces/univ3/IUniswapV3Pool.sol";
import "./TickMath.sol";
import "./PositionKey.sol";
import "./LowGasSafeMath.sol";
import "./SqrtPriceMath.sol";

/// @title Liquidity and ticks functions
/// @notice Provides functions for computing liquidity and ticks for token amounts and prices
library PoolVariables {
    using LowGasSafeMath for uint256;

    // Cache struct for calculations
    struct Info {
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0;
        uint256 amount1;
        uint128 liquidity;
        int24 tickLower;
        int24 tickUpper;
    }

    /// @dev Wrapper around `LiquidityAmounts.getAmountsForLiquidity()`.
    /// @param pool Uniswap V3 pool
    /// @param liquidity  The liquidity being valued
    /// @param _tickLower The lower tick of the range
    /// @param _tickUpper The upper tick of the range
    /// @return amounts of token0 and token1 that corresponds to liquidity
    function amountsForLiquidity(
        IUniswapV3Pool pool,
        uint128 liquidity,
        int24 _tickLower,
        int24 _tickUpper
    ) internal view returns (uint256, uint256) {
        //Get current price from the pool
        (uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
        return
            LiquidityAmounts.getAmountsForLiquidity(
                sqrtRatioX96,
                TickMath.getSqrtRatioAtTick(_tickLower),
                TickMath.getSqrtRatioAtTick(_tickUpper),
                liquidity
            );
    }

    /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmounts()`.
    /// @param pool Uniswap V3 pool
    /// @param amount0 The amount of token0
    /// @param amount1 The amount of token1
    /// @param _tickLower The lower tick of the range
    /// @param _tickUpper The upper tick of the range
    /// @return The maximum amount of liquidity that can be held amount0 and amount1
    function liquidityForAmounts(
        IUniswapV3Pool pool,
        uint256 amount0,
        uint256 amount1,
        int24 _tickLower,
        int24 _tickUpper
    ) internal view returns (uint128) {
        //Get current price from the pool
        (uint160 sqrtRatioX96, , , , , , ) = pool.slot0();

        return
            LiquidityAmounts.getLiquidityForAmounts(
                sqrtRatioX96,
                TickMath.getSqrtRatioAtTick(_tickLower),
                TickMath.getSqrtRatioAtTick(_tickUpper),
                amount0,
                amount1
            );
    }

    /// @dev Amounts of token0 and token1 held in contract position.
    /// @param pool Uniswap V3 pool
    /// @param _tickLower The lower tick of the range
    /// @param _tickUpper The upper tick of the range
    /// @return amount0 The amount of token0 held in position
    /// @return amount1 The amount of token1 held in position
    function positionAmounts(
        IUniswapV3Pool pool,
        int24 _tickLower,
        int24 _tickUpper
    ) internal view returns (uint256 amount0, uint256 amount1) {
        //Compute position key
        bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper);
        //Get Position.Info for specified ticks
        (uint128 liquidity, , , uint128 tokensOwed0, uint128 tokensOwed1) = pool.positions(positionKey);
        // Calc amounts of token0 and token1 including fees
        (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper);
        amount0 = amount0.add(uint256(tokensOwed0));
        amount1 = amount1.add(uint256(tokensOwed1));
    }

    /// @dev Amount of liquidity in contract position.
    /// @param pool Uniswap V3 pool
    /// @param _tickLower The lower tick of the range
    /// @param _tickUpper The upper tick of the range
    /// @return liquidity stored in position
    function positionLiquidity(
        IUniswapV3Pool pool,
        int24 _tickLower,
        int24 _tickUpper
    ) internal view returns (uint128 liquidity) {
        //Compute position key
        bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper);
        //Get liquidity stored in position
        (liquidity, , , , ) = pool.positions(positionKey);
    }

    /// @dev Common checks for valid tick inputs.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    function checkRange(int24 tickLower, int24 tickUpper) internal pure {
        require(tickLower < tickUpper, "TLU");
        require(tickLower >= TickMath.MIN_TICK, "TLM");
        require(tickUpper <= TickMath.MAX_TICK, "TUM");
    }

    /// @dev Rounds tick down towards negative infinity so that it's a multiple
    /// of `tickSpacing`.
    function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) {
        int24 compressed = tick / tickSpacing;
        if (tick < 0 && tick % tickSpacing != 0) compressed--;
        return compressed * tickSpacing;
    }

    /// @dev Gets ticks with proportion equivalent to desired amount
    /// @param pool Uniswap V3 pool
    /// @param amount0Desired The desired amount of token0
    /// @param amount1Desired The desired amount of token1
    /// @param baseThreshold The range for upper and lower ticks
    /// @param tickSpacing The pool tick spacing
    /// @return tickLower The lower tick of the range
    /// @return tickUpper The upper tick of the range
    function getPositionTicks(
        IUniswapV3Pool pool,
        uint256 amount0Desired,
        uint256 amount1Desired,
        int24 baseThreshold,
        int24 tickSpacing
    ) internal view returns (int24 tickLower, int24 tickUpper) {
        Info memory cache = Info(amount0Desired, amount1Desired, 0, 0, 0, 0, 0);
        // Get current price and tick from the pool
        (uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
        //Calc base ticks
        (cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing);
        //Calc amounts of token0 and token1 that can be stored in base range
        (cache.amount0, cache.amount1) = amountsForTicks(
            pool,
            cache.amount0Desired,
            cache.amount1Desired,
            cache.tickLower,
            cache.tickUpper
        );
        //Liquidity that can be stored in base range
        cache.liquidity = liquidityForAmounts(pool, cache.amount0, cache.amount1, cache.tickLower, cache.tickUpper);
        //Get imbalanced token
        bool zeroGreaterOne = amountsDirection(
            cache.amount0Desired,
            cache.amount1Desired,
            cache.amount0,
            cache.amount1
        );
        //Calc new tick(upper or lower) for imbalanced token
        if (zeroGreaterOne) {
            uint160 nextSqrtPrice0 = SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp(
                sqrtPriceX96,
                cache.liquidity,
                cache.amount0Desired,
                false
            );
            cache.tickUpper = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice0), tickSpacing);
        } else {
            uint160 nextSqrtPrice1 = SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown(
                sqrtPriceX96,
                cache.liquidity,
                cache.amount1Desired,
                false
            );
            cache.tickLower = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice1), tickSpacing);
        }
        checkRange(cache.tickLower, cache.tickUpper);

        tickLower = cache.tickLower;
        tickUpper = cache.tickUpper;
    }

    /// @dev Gets amounts of token0 and token1 that can be stored in range of upper and lower ticks
    /// @param pool Uniswap V3 pool
    /// @param amount0Desired The desired amount of token0
    /// @param amount1Desired The desired amount of token1
    /// @param _tickLower The lower tick of the range
    /// @param _tickUpper The upper tick of the range
    /// @return amount0 amounts of token0 that can be stored in range
    /// @return amount1 amounts of token1 that can be stored in range
    function amountsForTicks(
        IUniswapV3Pool pool,
        uint256 amount0Desired,
        uint256 amount1Desired,
        int24 _tickLower,
        int24 _tickUpper
    ) internal view returns (uint256 amount0, uint256 amount1) {
        uint128 liquidity = liquidityForAmounts(pool, amount0Desired, amount1Desired, _tickLower, _tickUpper);

        (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper);
    }

    /// @dev Calc base ticks depending on base threshold and tickspacing
    function baseTicks(
        int24 currentTick,
        int24 baseThreshold,
        int24 tickSpacing
    ) internal pure returns (int24 tickLower, int24 tickUpper) {
        int24 tickFloor = floor(currentTick, tickSpacing);

        tickLower = tickFloor - baseThreshold;
        tickUpper = tickFloor + baseThreshold;
    }

    /// @dev Get imbalanced token
    /// @param amount0Desired The desired amount of token0
    /// @param amount1Desired The desired amount of token1
    /// @param amount0 Amounts of token0 that can be stored in base range
    /// @param amount1 Amounts of token1 that can be stored in base range
    /// @return zeroGreaterOne true if token0 is imbalanced. False if token1 is imbalanced
    function amountsDirection(
        uint256 amount0Desired,
        uint256 amount1Desired,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (bool zeroGreaterOne) {
        zeroGreaterOne = amount0Desired.sub(amount0).mul(amount1Desired) >
            amount1Desired.sub(amount1).mul(amount0Desired)
            ? true
            : false;
    }

    // Check price has not moved a lot recently. This mitigates price
    // manipulation during rebalance and also prevents placing orders
    // when it's too volatile.
    function checkDeviation(
        IUniswapV3Pool pool,
        int24 maxTwapDeviation,
        uint32 twapDuration
    ) internal view {
        (, int24 currentTick, , , , , ) = pool.slot0();
        int24 twap = getTwap(pool, twapDuration);
        int24 deviation = currentTick > twap ? currentTick - twap : twap - currentTick;
        require(deviation <= maxTwapDeviation, "PSC");
    }

    /// @dev Fetches time-weighted average price in ticks from Uniswap pool for specified duration
    function getTwap(IUniswapV3Pool pool, uint32 twapDuration) internal view returns (int24) {
        uint32 _twapDuration = twapDuration;
        uint32[] memory secondsAgo = new uint32[](2);
        secondsAgo[0] = _twapDuration;
        secondsAgo[1] = 0;

        (int56[] memory tickCumulatives, ) = pool.observe(secondsAgo);
        return int24((tickCumulatives[1] - tickCumulatives[0]) / _twapDuration);
    }
}

File 13 of 27 : SafeCast.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
    /// @notice Cast a uint256 to a uint160, revert on overflow
    /// @param y The uint256 to be downcasted
    /// @return z The downcasted integer, now type uint160
    function toUint160(uint256 y) internal pure returns (uint160 z) {
        require((z = uint160(y)) == y);
    }

    /// @notice Cast a uint256 to a uint128, revert on overflow
    /// @param y The uint256 to be downcasted
    /// @return z The downcasted integer, now type uint128
    function toUint128(uint256 y) internal pure returns (uint128 z) {
        require((z = uint128(y)) == y);
    }

    /// @notice Cast a int256 to a int128, revert on overflow or underflow
    /// @param y The int256 to be downcasted
    /// @return z The downcasted integer, now type int128
    function toInt128(int256 y) internal pure returns (int128 z) {
        require((z = int128(y)) == y);
    }

    /// @notice Cast a uint256 to a int256, revert on overflow
    /// @param y The uint256 to be casted
    /// @return z The casted integer, now type int256
    function toInt256(uint256 y) internal pure returns (int256 z) {
        require(y < 2**255);
        z = int256(y);
    }
}

File 14 of 27 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The 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, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);
}

File 15 of 27 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

File 16 of 27 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

File 17 of 27 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

File 18 of 27 : LiquidityAmounts.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "./FullMath.sol";
import "./FixedPoint96.sol";

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

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

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

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

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

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

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

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

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

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

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

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

File 19 of 27 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.6.0;

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

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

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

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

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

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

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

        uint256 r = ratio;
        uint256 msb = 0;

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

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

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

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

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

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

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

File 20 of 27 : PositionKey.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

library PositionKey {
    /// @dev Returns the key of the position in the core library
    function compute(
        address owner,
        int24 tickLower,
        int24 tickUpper
    ) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(owner, tickLower, tickUpper));
    }
}

File 21 of 27 : LowGasSafeMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.6.12;

/// @title Optimized overflow and underflow safe math operations
/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost
library LowGasSafeMath {
    /// @notice Returns x + y, reverts if sum overflows uint256
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x + y) >= x);
    }

    /// @notice Returns x - y, reverts if underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x - y) <= x);
    }

    /// @notice Returns x * y, reverts if overflows
    /// @param x The multiplicand
    /// @param y The multiplier
    /// @return z The product of x and y
    function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require(x == 0 || (z = x * y) / x == y);
    }

    /// @notice Returns x - y, reverts if underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub(
        uint256 x,
        uint256 y,
        string memory errorMessage
    ) internal pure returns (uint256 z) {
        require((z = x - y) <= x, errorMessage);
    }

    /// @notice Returns x + y, reverts if overflows or underflows
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add(int256 x, int256 y) internal pure returns (int256 z) {
        require((z = x + y) >= x == (y >= 0));
    }

    /// @notice Returns x - y, reverts if overflows or underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub(int256 x, int256 y) internal pure returns (int256 z) {
        require((z = x - y) <= x == (y >= 0));
    }

    /// @notice Returns x + y, reverts if sum overflows uint128
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add128(uint128 x, uint128 y) internal pure returns (uint128 z) {
        require((z = x + y) >= x);
    }

    /// @notice Returns x - y, reverts if underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub128(uint128 x, uint128 y) internal pure returns (uint128 z) {
        require((z = x - y) <= x);
    }

    /// @notice Returns x * y, reverts if overflows
    /// @param x The multiplicand
    /// @param y The multiplier
    /// @return z The product of x and y
    function mul128(uint128 x, uint128 y) internal pure returns (uint128 z) {
        require(x == 0 || (z = x * y) / x == y);
    }

    /// @notice Returns x + y, reverts if sum overflows uint128
    /// @param x The augend
    /// @param y The addend
    /// @return z The sum of x and y
    function add160(uint160 x, uint160 y) internal pure returns (uint160 z) {
        require((z = x + y) >= x);
    }

    /// @notice Returns x - y, reverts if underflows
    /// @param x The minuend
    /// @param y The subtrahend
    /// @return z The difference of x and y
    function sub160(uint160 x, uint160 y) internal pure returns (uint160 z) {
        require((z = x - y) <= x);
    }

    /// @notice Returns x * y, reverts if overflows
    /// @param x The multiplicand
    /// @param y The multiplier
    /// @return z The product of x and y
    function mul160(uint160 x, uint160 y) internal pure returns (uint160 z) {
        require(x == 0 || (z = x * y) / x == y);
    }
}

File 22 of 27 : SqrtPriceMath.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;

import "./LowGasSafeMath.sol";
import "./SafeCast.sol";

import "./FullMath.sol";
import "./UnsafeMath.sol";
import "./FixedPoint96.sol";

/// @title Functions based on Q64.96 sqrt price and liquidity
/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas
library SqrtPriceMath {
    using LowGasSafeMath for uint256;
    using SafeCast for uint256;

    /// @notice Gets the next sqrt price given a delta of token0
    /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least
    /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the
    /// price less in order to not send too much output.
    /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),
    /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).
    /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta
    /// @param liquidity The amount of usable liquidity
    /// @param amount How much of token0 to add or remove from virtual reserves
    /// @param add Whether to add or remove the amount of token0
    /// @return The price after adding or removing amount, depending on add
    function getNextSqrtPriceFromAmount0RoundingUp(
        uint160 sqrtPX96,
        uint128 liquidity,
        uint256 amount,
        bool add
    ) internal pure returns (uint160) {
        // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price
        if (amount == 0) return sqrtPX96;
        uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;

        if (add) {
            uint256 product;
            if ((product = amount * sqrtPX96) / amount == sqrtPX96) {
                uint256 denominator = numerator1 + product;
                if (denominator >= numerator1)
                    // always fits in 160 bits
                    return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));
            }

            return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));
        } else {
            uint256 product;
            // if the product overflows, we know the denominator underflows
            // in addition, we must check that the denominator does not underflow
            require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);
            uint256 denominator = numerator1 - product;
            return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();
        }
    }

    /// @notice Gets the next sqrt price given a delta of token1
    /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least
    /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the
    /// price less in order to not send too much output.
    /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity
    /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta
    /// @param liquidity The amount of usable liquidity
    /// @param amount How much of token1 to add, or remove, from virtual reserves
    /// @param add Whether to add, or remove, the amount of token1
    /// @return The price after adding or removing `amount`
    function getNextSqrtPriceFromAmount1RoundingDown(
        uint160 sqrtPX96,
        uint128 liquidity,
        uint256 amount,
        bool add
    ) internal pure returns (uint160) {
        // if we're adding (subtracting), rounding down requires rounding the quotient down (up)
        // in both cases, avoid a mulDiv for most inputs
        if (add) {
            uint256 quotient = (
                amount <= type(uint160).max
                    ? (amount << FixedPoint96.RESOLUTION) / liquidity
                    : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)
            );

            return uint256(sqrtPX96).add(quotient).toUint160();
        } else {
            uint256 quotient = (
                amount <= type(uint160).max
                    ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)
                    : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)
            );

            require(sqrtPX96 > quotient);
            // always fits 160 bits
            return uint160(sqrtPX96 - quotient);
        }
    }
}

File 23 of 27 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

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

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

File 24 of 27 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

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

File 25 of 27 : UnsafeMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Math functions that do not check inputs or outputs
/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks
library UnsafeMath {
    /// @notice Returns ceil(x / y)
    /// @dev division by 0 has unspecified behavior, and must be checked externally
    /// @param x The dividend
    /// @param y The divisor
    /// @return z The quotient, ceil(x / y)
    function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        assembly {
            z := add(div(x, y), gt(mod(x, y), 0))
        }
    }

    /// @notice Returns floor(x / y)
    /// @dev division by 0 has unspecified behavior, and must be checked externally
    /// @param x The dividend
    /// @param y The divisor
    /// @return z The quotient, floor(x / y)
    function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
        assembly {
            z := div(x, y)
        }
    }
}

File 26 of 27 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "./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 27 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"int24","name":"_tickRangeMultiplier","type":"int24"},{"internalType":"uint24","name":"_swapPoolFee","type":"uint24"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_strategist","type":"address"},{"internalType":"address","name":"_controller","type":"address"},{"internalType":"address","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token0Balance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token1Balance","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Harvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InitialDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"int24","name":"_tickLower","type":"int24"},{"indexed":false,"internalType":"int24","name":"_tickUpper","type":"int24"}],"name":"Rebalanced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_liquidity","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"amountsForLiquid","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"determineTicks","outputs":[{"internalType":"int24","name":"","type":"int24"},{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"execute","outputs":[{"internalType":"bytes","name":"response","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getHarvestable","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"harvesters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityOfPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityOfThis","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftManager","outputs":[{"internalType":"contract IUniswapV3PositionsNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"performanceTreasuryFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performanceTreasuryMax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebalance","outputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_harvesters","type":"address[]"}],"name":"revokeHarvesters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_performanceTreasuryFee","type":"uint256"}],"name":"setPerformanceTreasuryFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategist","type":"address"}],"name":"setStrategist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"_swapPoolFee","type":"uint24"}],"name":"setSwapPoolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"_tickRangeMultiplier","type":"int24"}],"name":"setTickRangeMultiplier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_timelock","type":"address"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"_twapTime","type":"uint24"}],"name":"setTwapTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strategist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapPoolFee","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tick_lower","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tick_upper","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelock","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"univ3Router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_harvesters","type":"address[]"}],"name":"whitelistHarvesters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidity","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"a0","type":"uint256"},{"internalType":"uint256","name":"a1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_asset","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[{"internalType":"uint256","name":"a0","type":"uint256"},{"internalType":"uint256","name":"a1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60806040526107d060005560098054600f607a1b62ffffff60781b19909116179055600a80546001600160a01b031990811673c36442b4a4522e871399cd717abdd847ab11fe8817909155600c80549091167388e6a0c2ddd26feeb64f039a2c41296fcb3f56401790553480156200007657600080fd5b5060405162004eb138038062004eb18339810160408190526200009991620007f4565b600c54600180546001600160a01b038781166001600160a01b03199283161790925560038054878416908316179055600280548684169083161790556004805485841690831617815560058054909216938316938417918290556040805163ddca3f4360e01b815290518b948a948a948a948a94929093169263ddca3f439281830192602092829003018186803b1580156200013457600080fd5b505afa15801562000149573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200016f91906200087b565b6009600c6101000a81548162ffffff021916908362ffffff160217905550600560009054906101000a90046001600160a01b03166001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015620001dc57600080fd5b505afa158015620001f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200021791906200078f565b600680546001600160a01b0319166001600160a01b039283161790556005546040805163d21220a760e01b81529051919092169163d21220a7916004808301926020929190829003018186803b1580156200027157600080fd5b505afa15801562000286573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002ac91906200078f565b600780546001600160a01b0319166001600160a01b03928316179055600554604080516334324e9f60e21b81529051919092169163d0c93a7c916004808301926020929190829003018186803b1580156200030657600080fd5b505afa1580156200031b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003419190620007d6565b60098054600288810b62ffffff90811669010000000000000000000262ffffff60481b199590920b1666010000000000000262ffffff60301b199092169190911792909216919091179055600a54600654620003bc916001600160a01b039182169116600019620023cb620004ba602090811b91909117901c565b600a54600754620003e9916001600160a01b039182169116600019620004ba602090811b620023cb17901c565b5050505050508462ffffff16600014156200048e57600560009054906101000a90046001600160a01b03166001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b1580156200044d57600080fd5b505afa15801562000462573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200048891906200087b565b62000490565b845b6009600c6101000a81548162ffffff021916908362ffffff16021790555050505050505062000a5f565b801580620005495750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90620004f39030908690600401620008d1565b60206040518083038186803b1580156200050c57600080fd5b505afa15801562000521573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200054791906200089a565b155b620005715760405162461bcd60e51b81526004016200056890620009ba565b60405180910390fd5b620005cc8363095ea7b360e01b848460405160240162000593929190620008eb565b60408051808303601f190181529190526020810180516001600160e01b0319939093166001600160e01b0393841617905290620005d116565b505050565b60606200062d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200066d60201b620024c5179092919060201c565b805190915015620005cc57808060200190518101906200064e9190620007b4565b620005cc5760405162461bcd60e51b8152600401620005689062000970565b60606200067e848460008562000686565b949350505050565b6060620006938562000758565b620006b25760405162461bcd60e51b8152600401620005689062000939565b60006060866001600160a01b03168587604051620006d19190620008b3565b60006040518083038185875af1925050503d806000811462000710576040519150601f19603f3d011682016040523d82523d6000602084013e62000715565b606091505b509150915081156200072b5791506200067e9050565b8051156200073c5780518082602001fd5b8360405162461bcd60e51b815260040162000568919062000904565b3b151590565b80516001600160a01b03811681146200077657600080fd5b92915050565b8051600281900b81146200077657600080fd5b600060208284031215620007a1578081fd5b620007ad83836200075e565b9392505050565b600060208284031215620007c6578081fd5b81518015158114620007ad578182fd5b600060208284031215620007e8578081fd5b620007ad83836200077c565b60008060008060008060c087890312156200080d578182fd5b6200081988886200077c565b955060208701516200082b8162000a4a565b94506200083c88604089016200075e565b93506200084d88606089016200075e565b92506200085e88608089016200075e565b91506200086f8860a089016200075e565b90509295509295509295565b6000602082840312156200088d578081fd5b8151620007ad8162000a4a565b600060208284031215620008ac578081fd5b5051919050565b60008251620008c781846020870162000a17565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b60006020825282518060208401526200092581604085016020870162000a17565b601f01601f19169190910160400192915050565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b60005b8381101562000a3457818101518382015260200162000a1a565b8381111562000a44576000848401525b50505050565b62ffffff8116811462000a5c57600080fd5b50565b6144428062000a6f6000396000f3fe6080604052600436106102455760003560e01c80635af1b1d711610139578063c7b9d530116100b6578063e88b91ea1161007a578063e88b91ea1461062d578063ef27c85314610642578063f05abc6214610657578063f77c47911461066c578063fb3e5ea414610681578063fedb19c3146106a157610245565b8063c7b9d530146105ac578063cfd35427146105cc578063d0e30db0146105ee578063d21220a714610603578063d33219b41461061857610245565b806392eefe9b116100fd57806392eefe9b14610517578063a9c472b214610537578063ab033ea91461054c578063b1f55bd41461056c578063bdacb3031461058c57610245565b80635af1b1d71461048b5780635ddfcda4146104ab5780637d7c2a1c146104c0578063853828b6146104d557806387976583146104ea57610245565b80631d7c5660116101c75780633ced19291161018b5780633ced1929146104175780634641257d1461042c57806351cff8d91461044157806359739ec4146104615780635aa6e6751461047657610245565b80631d7c56601461038b5780631fe4a686146103ad578063249fb9b4146103c257806326e886c6146103e25780632e1a7d4d146103f757610245565b806316f0115b1161020e57806316f0115b1461030957806317d70f7c1461031e57806317d7de7c146103335780631c4d7ddc146103555780631cff79cd1461037857610245565b8062bf2b221461024a5780630547104d146102755780630dfe1681146102985780630e364fb6146102ba578063150b7a02146102dc575b600080fd5b34801561025657600080fd5b5061025f6106c1565b60405161026c9190614316565b60405180910390f35b34801561028157600080fd5b5061028a6107fd565b60405161026c929190614339565b3480156102a457600080fd5b506102ad6108fb565b60405161026c9190613de9565b3480156102c657600080fd5b506102da6102d5366004613994565b61090a565b005b3480156102e857600080fd5b506102fc6102f73660046138dc565b6109d3565b60405161026c9190613ea8565b34801561031557600080fd5b506102ad6109e4565b34801561032a57600080fd5b5061025f6109f3565b34801561033f57600080fd5b506103486109f9565b60405161026c9190613ebd565b34801561036157600080fd5b5061036a610a29565b60405161026c929190613ede565b610348610386366004613946565b610bbf565b34801561039757600080fd5b506103a0610c62565b60405161026c9190613ed0565b3480156103b957600080fd5b506102ad610c72565b3480156103ce57600080fd5b506102da6103dd366004613c0d565b610c81565b3480156103ee57600080fd5b5061025f610cb0565b34801561040357600080fd5b5061028a610412366004613c0d565b610cb6565b34801561042357600080fd5b506102ad610e12565b34801561043857600080fd5b506102da610e2a565b34801561044d57600080fd5b5061025f61045c3660046138a4565b611222565b34801561046d57600080fd5b5061025f6112ed565b34801561048257600080fd5b506102ad6112f3565b34801561049757600080fd5b506102da6104a6366004613bd5565b611302565b3480156104b757600080fd5b5061025f611350565b3480156104cc57600080fd5b5061025f611370565b3480156104e157600080fd5b5061028a611bde565b3480156104f657600080fd5b5061050a6105053660046138a4565b611dfe565b60405161026c9190613e9d565b34801561052357600080fd5b506102da6105323660046138a4565b611e13565b34801561054357600080fd5b5061025f611e5f565b34801561055857600080fd5b506102da6105673660046138a4565b611f02565b34801561057857600080fd5b506102da610587366004613994565b611f4e565b34801561059857600080fd5b506102da6105a73660046138a4565b611fef565b3480156105b857600080fd5b506102da6105c73660046138a4565b61203b565b3480156105d857600080fd5b506105e1612087565b60405161026c9190614306565b3480156105fa57600080fd5b506102da612099565b34801561060f57600080fd5b506102ad6122a3565b34801561062457600080fd5b506102ad6122b2565b34801561063957600080fd5b506102ad6122c1565b34801561064e57600080fd5b506103a06122d0565b34801561066357600080fd5b5061028a6122d9565b34801561067857600080fd5b506102ad612316565b34801561068d57600080fd5b506102da61069c366004613bd5565b612325565b3480156106ad57600080fd5b506102da6106bc366004613adb565b612373565b6006546040516370a0823160e01b815260009182916107ee916001600160a01b0316906370a08231906106f8903090600401613de9565b60206040518083038186803b15801561071057600080fd5b505afa158015610724573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107489190613c25565b6007546040516370a0823160e01b81526001600160a01b03909116906370a0823190610778903090600401613de9565b60206040518083038186803b15801561079057600080fd5b505afa1580156107a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c89190613c25565b6009546005546001600160a01b0316929190600281810b9163010000009004900b6124de565b6001600160801b031691505090565b336000908152600b6020526040812054819060ff168061082757506001546001600160a01b031633145b8061083c57506003546001600160a01b031633145b61084557600080fd5b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b815260009283926001600160a01b039091169163fc6f78659161089f91600401614130565b6040805180830381600087803b1580156108b857600080fd5b505af11580156108cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f09190613c79565b909450925050509091565b6006546001600160a01b031681565b6001546001600160a01b031633148061092d57506003546001600160a01b031633145b806109475750336000908152600b602052604090205460ff165b61096c5760405162461bcd60e51b815260040161096390613faf565b60405180910390fd5b60005b818110156109ce576001600b600085858581811061098957fe5b905060200201602081019061099e91906138a4565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010161096f565b505050565b630a85bd0160e11b5b949350505050565b6005546001600160a01b031681565b60085481565b6040805180820190915260168152755374726174656779557364634574683035556e69563360501b602082015290565b604080516002808252606080830184526000938493919290602083019080368337019050506009548151919250600160781b900462ffffff16908290600090610a6e57fe5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610a9757fe5b63ffffffff9092166020928302919091019091015260055460405163883bdbfd60e01b81526060916001600160a01b03169063883bdbfd90610add908590600401613e53565b60006040518083038186803b158015610af557600080fd5b505afa158015610b09573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b319190810190613a03565b50905060006009600f9054906101000a900462ffffff1662ffffff1682600081518110610b5a57fe5b602002602001015183600181518110610b6f57fe5b60200260200101510360060b81610b8257fe5b600954919005915066010000000000008104600290810b600160481b909204900b810290610bb39083908390612584565b95509550505050509091565b6004546060906001600160a01b03163314610bec5760405162461bcd60e51b8152600401610963906140b7565b6001600160a01b038316610c125760405162461bcd60e51b815260040161096390613f17565b600080835160208501866113885a03f43d6040519250601f19601f6020830101168301604052808352806000602085013e811560018114610c5257610c59565b8160208501fd5b50505092915050565b6009546301000000900460020b81565b6003546001600160a01b031681565b6004546001600160a01b03163314610cab5760405162461bcd60e51b8152600401610963906140b7565b600055565b61271081565b60025460009081906001600160a01b03163314610ce55760405162461bcd60e51b815260040161096390613f38565b610cee836125a1565b600254600554604051636535246160e11b81529395509193506000926001600160a01b039182169263ca6a48c292610d2b92911690600401613de9565b60206040518083038186803b158015610d4357600080fd5b505afa158015610d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7b91906138c0565b90506001600160a01b038116610da35760405162461bcd60e51b815260040161096390614018565b600654610dba906001600160a01b03168285612760565b600754610dd1906001600160a01b03168284612760565b7f0c875c8d391179c5cf7ad8303d268efd50b8beb78b671f85cd54bfb91eb8ef4060085485604051610e04929190614339565b60405180910390a150915091565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b336000908152600b602052604090205460ff1680610e5257506001546001600160a01b031633145b80610e6757506003546001600160a01b031633145b610e7057600080fd5b6006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610ea1903090600401613de9565b60206040518083038186803b158015610eb957600080fd5b505afa158015610ecd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef19190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610f27903090600401613de9565b60206040518083038186803b158015610f3f57600080fd5b505afa158015610f53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f779190613c25565b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81529293506001600160a01b039091169163fc6f786591610fcf91600401614130565b6040805180830381600087803b158015610fe857600080fd5b505af1158015610ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110209190613c79565b5050600a5460065460405163df2ab5bb60e01b81526001600160a01b039283169263df2ab5bb9261105b929116906000903090600401613e17565b600060405180830381600087803b15801561107557600080fd5b505af1158015611089573d6000803e3d6000fd5b5050600a5460075460405163df2ab5bb60e01b81526001600160a01b03928316945063df2ab5bb93506110c792909116906000903090600401613e17565b600060405180830381600087803b1580156110e157600080fd5b505af11580156110f5573d6000803e3d6000fd5b50506006546040516370a0823160e01b81526111c29350611187925085916001600160a01b0316906370a0823190611131903090600401613de9565b60206040518083038186803b15801561114957600080fd5b505afa15801561115d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111819190613c25565b9061277f565b6007546040516370a0823160e01b81526111bd9185916001600160a01b03909116906370a0823190611131903090600401613de9565b6127ca565b6009546111dd90600281810b9163010000009004900b612938565b6111e5612099565b7f8e55ccfc9778ff8eba1646d765cf1982537ce0f9257054a17b48aad7452501836008546040516112169190614316565b60405180910390a15050565b6002546000906001600160a01b0316331461124f5760405162461bcd60e51b815260040161096390613f38565b6040516370a0823160e01b81526001600160a01b038316906370a082319061127b903090600401613de9565b60206040518083038186803b15801561129357600080fd5b505afa1580156112a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cb9190613c25565b6002549091506112e8906001600160a01b03848116911683612760565b919050565b60005481565b6001546001600160a01b031681565b6001546001600160a01b0316331461132c5760405162461bcd60e51b815260040161096390613ef2565b6009805462ffffff909216600160781b0262ffffff60781b19909216919091179055565b600061136b61135d611e5f565b6113656106c1565b90612cbc565b905090565b336000908152600b602052604081205460ff168061139857506001546001600160a01b031633145b806113ad57506003546001600160a01b031633145b6113b657600080fd5b60085415611895576006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906113ef903090600401613de9565b60206040518083038186803b15801561140757600080fd5b505afa15801561141b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143f9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611475903090600401613de9565b60206040518083038186803b15801561148d57600080fd5b505afa1580156114a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c59190613c25565b600a5460085460405163133f757160e31b81529293506000926001600160a01b03909216916399fbab88916114fc91600401614316565b6101806040518083038186803b15801561151557600080fd5b505afa158015611529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154d9190613c9c565b505050506001600160801b0316975050505050505050600080600a60009054906101000a90046001600160a01b03166001600160a01b0316630c49ccbe6040518060a001604052806008548152602001866001600160801b0316815260200160008152602001600081526020014261012c018152506040518263ffffffff1660e01b81526004016115de9190614173565b6040805180830381600087803b1580156115f757600080fd5b505af115801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f9190613c79565b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81529395509193506001600160a01b03169163fc6f78659161168891600401614130565b6040805180830381600087803b1580156116a157600080fd5b505af11580156116b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d99190613c79565b5050600a5460065460405163df2ab5bb60e01b81526001600160a01b039283169263df2ab5bb92611714929116906000903090600401613e17565b600060405180830381600087803b15801561172e57600080fd5b505af1158015611742573d6000803e3d6000fd5b5050600a5460075460405163df2ab5bb60e01b81526001600160a01b03928316945063df2ab5bb935061178092909116906000903090600401613e17565b600060405180830381600087803b15801561179a57600080fd5b505af11580156117ae573d6000803e3d6000fd5b5050600a54600854604051630852cd8d60e31b81526001600160a01b0390921693506342966c6892506117e391600401614316565b600060405180830381600087803b1580156117fd57600080fd5b505af1158015611811573d6000803e3d6000fd5b50506006546040516370a0823160e01b815261188f9350611853925088916111819187916001600160a01b0316906370a0823190611131903090600401613de9565b6007546040516370a0823160e01b81526111bd9188916111819187916001600160a01b03909116906370a0823190611131903090600401613de9565b50505050505b6000806118a0610a29565b915091506118ae8282612938565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906118df903090600401613de9565b60206040518083038186803b1580156118f757600080fd5b505afa15801561190b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192f9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611965903090600401613de9565b60206040518083038186803b15801561197d57600080fd5b505afa158015611991573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b59190613c25565b600a5460408051610160810182526006546001600160a01b0390811682526007548116602080840191909152600554845163ddca3f4360e01b81528551979850958316966388316456969495860194919093169263ddca3f4392600480840193919291829003018186803b158015611a2c57600080fd5b505afa158015611a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a649190613bf1565b62ffffff1681526020018760020b81526020018660020b81526020018581526020018481526020016000815260200160008152602001306001600160a01b031681526020014261012c018152506040518263ffffffff1660e01b8152600401611acd9190614258565b608060405180830381600087803b158015611ae757600080fd5b505af1158015611afb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1f9190613c3d565b50505060088190556009805462ffffff1916600287810b62ffffff9081169290921765ffffff000000191663010000009188900b9290921602179055945084611b9a577f747c5e78fb5f01e96acc105d1f2a147e11deef8eff1e2cf6498e3790106feb3285604051611b919190614316565b60405180910390a15b7f3e23da686e1f40c469c91f3009f25bd78f5098ad5624b4fedf44e47f0714656b6008548585604051611bcf9392919061431f565b60405180910390a15050505090565b60025460009081906001600160a01b03163314611c0d5760405162461bcd60e51b815260040161096390613f38565b611c15612ce1565b5050600254600554604051636535246160e11b81526000926001600160a01b039081169263ca6a48c292611c4f9290911690600401613de9565b60206040518083038186803b158015611c6757600080fd5b505afa158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f91906138c0565b90506001600160a01b038116611cc75760405162461bcd60e51b815260040161096390614018565b6006546040516370a0823160e01b81526001600160a01b03909116906370a0823190611cf7903090600401613de9565b60206040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d479190613c25565b6007546040516370a0823160e01b81529194506001600160a01b0316906370a0823190611d78903090600401613de9565b60206040518083038186803b158015611d9057600080fd5b505afa158015611da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc89190613c25565b600654909250611de2906001600160a01b03168285612760565b600754611df9906001600160a01b03168284612760565b509091565b600b6020526000908152604090205460ff1681565b6004546001600160a01b03163314611e3d5760405162461bcd60e51b8152600401610963906140b7565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600a5460085460405163133f757160e31b815260009283926001600160a01b03909116916399fbab8891611e9591600401614316565b6101806040518083038186803b158015611eae57600080fd5b505afa158015611ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee69190613c9c565b50506001600160801b039092169a505050505050505050505090565b6001546001600160a01b03163314611f2c5760405162461bcd60e51b815260040161096390613ef2565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b0316331480611f7157506003546001600160a01b031633145b611f8d5760405162461bcd60e51b815260040161096390613faf565b60005b818110156109ce576000600b6000858585818110611faa57fe5b9050602002016020810190611fbf91906138a4565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611f90565b6004546001600160a01b031633146120195760405162461bcd60e51b8152600401610963906140b7565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146120655760405162461bcd60e51b815260040161096390613ef2565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600954600160601b900462ffffff1681565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906120ca903090600401613de9565b60206040518083038186803b1580156120e257600080fd5b505afa1580156120f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211a9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612150903090600401613de9565b60206040518083038186803b15801561216857600080fd5b505afa15801561217c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a09190613c25565b90506000821180156121b25750600081115b1561226e57600a546040805160c081018252600854815260208101859052808201849052600060608201819052608082015261012c420160a0820152905163219f5d1760e01b81526001600160a01b039092169163219f5d179161221891600401614214565b606060405180830381600087803b15801561223257600080fd5b505af1158015612246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226a9190613af7565b5050505b7f1ca606821992e3b34613b5b29c0bbade3a907b2969d7f9f2927f726fa4baccfb600854838360405161121693929190614347565b6007546001600160a01b031681565b6004546001600160a01b031681565b600a546001600160a01b031681565b60095460020b81565b6009546005546000918291829182916108f0916001600160a01b0390911690670de0b6b3a764000090600281810b9163010000009004900b612cfd565b6002546001600160a01b031681565b6001546001600160a01b0316331461234f5760405162461bcd60e51b815260040161096390613ef2565b6009805462ffffff909216600160601b0262ffffff60601b19909216919091179055565b6001546001600160a01b0316331461239d5760405162461bcd60e51b815260040161096390613ef2565b6009805460029290920b62ffffff16600160481b026bffffff00000000000000000019909216919091179055565b8015806124535750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906124019030908690600401613dfd565b60206040518083038186803b15801561241957600080fd5b505afa15801561242d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124519190613c25565b155b61246f5760405162461bcd60e51b8152600401610963906140da565b6109ce8363095ea7b360e01b848460405160240161248e929190613e3a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612da6565b60606124d48484600085612e35565b90505b9392505050565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561251a57600080fd5b505afa15801561252e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125529190613b38565b50505050505090506125778161256786612ef9565b61257086612ef9565b8989613212565b9150505b95945050505050565b600080600061259386856132d4565b858103979501955050505050565b600080826125b45750600090508061275b565b60095460055460009182916125e5916001600160a01b03909116908790600281810b9163010000009004900b612cfd565b600a546040805160a08101825260085481526001600160801b038a1660208201528082018590526060810184905261012c420160808201529051630624e65f60e11b815293955091935060009283926001600160a01b0390921691630c49ccbe916126539190600401614173565b6040805180830381600087803b15801561266c57600080fd5b505af1158015612680573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a49190613c79565b600a546040805160808101825260085481523060208201526001600160801b038086168284015284166060820152905163fc6f786560e01b81529395509193506001600160a01b03169163fc6f78659161270091600401614130565b6040805180830381600087803b15801561271957600080fd5b505af115801561272d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127519190613c79565b5091955093505050505b915091565b6109ce8363a9059cbb60e01b848460405160240161248e929190613e3a565b60006127c183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613320565b90505b92915050565b811561288257600254604080516361d027b360e01b81529051612882926001600160a01b0316916361d027b3916004808301926020929190829003018186803b15801561281657600080fd5b505afa15801561282a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284e91906138c0565b61286f6127106128696000548761334c90919063ffffffff16565b90613386565b6006546001600160a01b03169190612760565b801561293457600254604080516361d027b360e01b81529051612934926001600160a01b0316916361d027b3916004808301926020929190829003018186803b1580156128ce57600080fd5b505afa1580156128e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290691906138c0565b6129216127106128696000548661334c90919063ffffffff16565b6007546001600160a01b03169190612760565b5050565b61294061371c565b6006546040516370a0823160e01b81526001600160a01b03909116906370a0823190612970903090600401613de9565b60206040518083038186803b15801561298857600080fd5b505afa15801561299c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c09190613c25565b81526007546040516370a0823160e01b81526001600160a01b03909116906370a08231906129f2903090600401613de9565b60206040518083038186803b158015612a0a57600080fd5b505afa158015612a1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a429190613c25565b602082018190528151600554612a66926001600160a01b03909116919086866124de565b6001600160801b031660808201819052600554612a90916001600160a01b03909116908585612cfd565b606083015260408201526020810151600090612aae57506001612acd565b612aca82600001518360200151846040015185606001516133c8565b90505b600081612af957612af460026128698560600151866020015161277f90919063ffffffff16565b612b10565b60408301518351612b10916002916128699161277f565b90508015612cb557600082612b30576007546001600160a01b0316612b3d565b6006546001600160a01b03165b9050612b686001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc4560006123cb565b612b906001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc45846123cb565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03166304e45aaf6040518060e00160405280846001600160a01b0316815260200186612be3576006546001600160a01b0316612bf0565b6007546001600160a01b03165b6001600160a01b031681526020016009600c9054906101000a900462ffffff1662ffffff168152602001306001600160a01b031681526020018581526020016000815260200160006001600160a01b03168152506040518263ffffffff1660e01b8152600401612c6091906141b6565b602060405180830381600087803b158015612c7a57600080fd5b505af1158015612c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb29190613c25565b50505b5050505050565b6000828201838110156127c15760405162461bcd60e51b815260040161096390613f5d565b600080612cf4612cef611e5f565b6125a1565b90939092509050565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612d3b57600080fd5b505afa158015612d4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d739190613b38565b5050505050509050612d9781612d8887612ef9565b612d9187612ef9565b89613403565b92509250505b94509492505050565b6060612dfb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124c59092919063ffffffff16565b8051909150156109ce5780806020019051810190612e199190613abb565b6109ce5760405162461bcd60e51b81526004016109639061406d565b6060612e408561349e565b612e5c5760405162461bcd60e51b815260040161096390614036565b60006060866001600160a01b03168587604051612e799190613dcd565b60006040518083038185875af1925050503d8060008114612eb6576040519150601f19603f3d011682016040523d82523d6000602084013e612ebb565b606091505b50915091508115612ecf5791506109dc9050565b805115612edf5780518082602001fd5b8360405162461bcd60e51b81526004016109639190613ebd565b60008060008360020b12612f10578260020b612f18565b8260020b6000035b9050620d89e8811115612f3d5760405162461bcd60e51b815260040161096390613f94565b600060018216612f5157600160801b612f63565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612f97576ffff97272373d413259a46990580e213a0260801c5b6004821615612fb6576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615612fd5576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615612ff4576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615613013576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615613032576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615613051576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615613071576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615613091576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156130b1576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156130d1576fe7159475a2c29b7443b29c7fa6e889d90260801c5b6110008216156130f1576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615613111576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615613131576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615613151576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615613172576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615613192576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156131b1576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156131ce576b048a170391f7dc42444e8fa20260801c5b60008460020b13156131e95780600019816131e557fe5b0490505b6401000000008106156131fd576001613200565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b03161115613232579293925b846001600160a01b0316866001600160a01b03161161325d576132568585856134a4565b905061257b565b836001600160a01b0316866001600160a01b031610156132bf5760006132848786866134a4565b90506000613293878986613507565b9050806001600160801b0316826001600160801b0316106132b457806132b6565b815b9250505061257b565b6132ca858584613507565b9695505050505050565b6000808260020b8460020b816132e657fe5b05905060008460020b12801561330d57508260020b8460020b8161330657fe5b0760020b15155b1561331757600019015b90910292915050565b600081848411156133445760405162461bcd60e51b81526004016109639190613ebd565b505050900390565b60008261335b575060006127c4565b8282028284828161336857fe5b04146127c15760405162461bcd60e51b815260040161096390613fd7565b60006127c183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613544565b60006133de856133d8868561357b565b9061358b565b6133ec856133d8888761357b565b116133f857600061257b565b600195945050505050565b600080836001600160a01b0316856001600160a01b03161115613424579293925b846001600160a01b0316866001600160a01b03161161344f576134488585856135af565b9150612d9d565b836001600160a01b0316866001600160a01b03161015613488576134748685856135af565b9150613481858785613618565b9050612d9d565b613493858585613618565b905094509492505050565b3b151590565b6000826001600160a01b0316846001600160a01b031611156134c4579192915b60006134e7856001600160a01b0316856001600160a01b0316600160601b613657565b905061257b61350284838888036001600160a01b0316613657565b613706565b6000826001600160a01b0316846001600160a01b03161115613527579192915b6124d461350283600160601b8787036001600160a01b0316613657565b600081836135655760405162461bcd60e51b81526004016109639190613ebd565b50600083858161357157fe5b0495945050505050565b808203828111156127c457600080fd5b60008215806135a6575050818102818382816135a357fe5b04145b6127c457600080fd5b6000826001600160a01b0316846001600160a01b031611156135cf579192915b836001600160a01b0316613608606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316613657565b8161360f57fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115613638579192915b6124d4826001600160801b03168585036001600160a01b0316600160601b5b600080806000198587098686029250828110908390030390508061368d576000841161368257600080fd5b5082900490506124d7565b80841161369957600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b806001600160801b03811681146112e857600080fd5b6040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090565b80516127c4816143d4565b600082601f830112613783578081fd5b815161379661379182614384565b61435d565b8181529150602080830190848101818402860182018710156137b757600080fd5b60005b848110156137df5781516137cd816143d4565b845292820192908201906001016137ba565b505050505092915050565b600082601f8301126137fa578081fd5b813567ffffffffffffffff811115613810578182fd5b613823601f8201601f191660200161435d565b915080825283602082850101111561383a57600080fd5b8060208401602084013760009082016020015292915050565b80516127c4816143ec565b8051600681900b81146127c457600080fd5b80516001600160801b03811681146127c457600080fd5b805161ffff811681146127c457600080fd5b80516127c4816143fb565b6000602082840312156138b5578081fd5b81356127c1816143d4565b6000602082840312156138d1578081fd5b81516127c1816143d4565b600080600080608085870312156138f1578283fd5b84356138fc816143d4565b9350602085013561390c816143d4565b925060408501359150606085013567ffffffffffffffff81111561392e578182fd5b61393a878288016137ea565b91505092959194509250565b60008060408385031215613958578182fd5b8235613963816143d4565b9150602083013567ffffffffffffffff81111561397e578182fd5b61398a858286016137ea565b9150509250929050565b600080602083850312156139a6578182fd5b823567ffffffffffffffff808211156139bd578384fd5b818501915085601f8301126139d0578384fd5b8135818111156139de578485fd5b86602080830285010111156139f1578485fd5b60209290920196919550909350505050565b60008060408385031215613a15578182fd5b825167ffffffffffffffff80821115613a2c578384fd5b818501915085601f830112613a3f578384fd5b8151613a4d61379182614384565b80828252602080830192508086018a828387028901011115613a6d578889fd5b8896505b84871015613a9757613a838b8261385e565b845260019690960195928101928101613a71565b508801519096509350505080821115613aae578283fd5b5061398a85828601613773565b600060208284031215613acc578081fd5b815180151581146127c1578182fd5b600060208284031215613aec578081fd5b81356127c1816143ec565b600080600060608486031215613b0b578081fd5b83516001600160801b0381168114613b21578182fd5b602085015160409095015190969495509392505050565b600080600080600080600060e0888a031215613b52578485fd5b8751613b5d816143d4565b6020890151909750613b6e816143ec565b9550613b7d8960408a01613887565b9450613b8c8960608a01613887565b9350613b9b8960808a01613887565b925060a088015160ff81168114613bb0578283fd5b60c08901519092508015158114613bc5578182fd5b8091505092959891949750929550565b600060208284031215613be6578081fd5b81356127c1816143fb565b600060208284031215613c02578081fd5b81516127c1816143fb565b600060208284031215613c1e578081fd5b5035919050565b600060208284031215613c36578081fd5b5051919050565b60008060008060808587031215613c52578182fd5b84519350613c638660208701613870565b6040860151606090960151949790965092505050565b60008060408385031215613c8b578182fd5b505080516020909101519092909150565b6000806000806000806000806000806000806101808d8f031215613cbe578586fd5b8c516bffffffffffffffffffffffff81168114613cd9578687fd5b9b50613ce88e60208f01613768565b9a50613cf78e60408f01613768565b9950613d068e60608f01613768565b9850613d158e60808f01613899565b9750613d248e60a08f01613853565b9650613d338e60c08f01613853565b9550613d428e60e08f01613870565b94506101008d015193506101208d01519250613d628e6101408f01613870565b9150613d728e6101608f01613870565b90509295989b509295989b509295989b565b6001600160a01b03169052565b60008151808452613da98160208601602086016143a4565b601f01601f19169290920160200192915050565b60020b9052565b62ffffff169052565b60008251613ddf8184602087016143a4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015613e9157835163ffffffff1683529284019291840191600101613e6f565b50909695505050505050565b901515815260200190565b6001600160e01b031991909116815260200190565b6000602082526127c16020830184613d91565b60029190910b815260200190565b600292830b8152910b602082015260400190565b6020808252600b908201526a21676f7665726e616e636560a81b604082015260600190565b602080825260079082015266085d185c99d95d60ca1b604082015260600190565b6020808252600b908201526a10b1b7b73a3937b63632b960a91b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526004908201526310b530b960e11b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152682174696d656c6f636b60b81b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c092830151169181019190915260e00190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b60006101608201905061426c828451613d84565b602083015161427e6020840182613d84565b5060408301516142916040840182613dc4565b5060608301516142a46060840182613dbd565b5060808301516142b76080840182613dbd565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516142f582850182613d84565b505061014092830151919092015290565b62ffffff91909116815260200190565b90815260200190565b928352600291820b6020840152900b604082015260600190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561437c57600080fd5b604052919050565b600067ffffffffffffffff82111561439a578081fd5b5060209081020190565b60005b838110156143bf5781810151838201526020016143a7565b838111156143ce576000848401525b50505050565b6001600160a01b03811681146143e957600080fd5b50565b8060020b81146143e957600080fd5b62ffffff811681146143e957600080fdfea2646970667358221220db75b9a3d24d3344d91e82d8271ad4555a98ca0e416c87efbd8370f7feff75cf64736f6c634300060c003300000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000009d074e37d408542fd38be78848e8814afb38db17000000000000000000000000acfe4511ce883c14c4ea40563f176c3c09b4c47c0000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce36370000000000000000000000009d074e37d408542fd38be78848e8814afb38db17

Deployed Bytecode

0x6080604052600436106102455760003560e01c80635af1b1d711610139578063c7b9d530116100b6578063e88b91ea1161007a578063e88b91ea1461062d578063ef27c85314610642578063f05abc6214610657578063f77c47911461066c578063fb3e5ea414610681578063fedb19c3146106a157610245565b8063c7b9d530146105ac578063cfd35427146105cc578063d0e30db0146105ee578063d21220a714610603578063d33219b41461061857610245565b806392eefe9b116100fd57806392eefe9b14610517578063a9c472b214610537578063ab033ea91461054c578063b1f55bd41461056c578063bdacb3031461058c57610245565b80635af1b1d71461048b5780635ddfcda4146104ab5780637d7c2a1c146104c0578063853828b6146104d557806387976583146104ea57610245565b80631d7c5660116101c75780633ced19291161018b5780633ced1929146104175780634641257d1461042c57806351cff8d91461044157806359739ec4146104615780635aa6e6751461047657610245565b80631d7c56601461038b5780631fe4a686146103ad578063249fb9b4146103c257806326e886c6146103e25780632e1a7d4d146103f757610245565b806316f0115b1161020e57806316f0115b1461030957806317d70f7c1461031e57806317d7de7c146103335780631c4d7ddc146103555780631cff79cd1461037857610245565b8062bf2b221461024a5780630547104d146102755780630dfe1681146102985780630e364fb6146102ba578063150b7a02146102dc575b600080fd5b34801561025657600080fd5b5061025f6106c1565b60405161026c9190614316565b60405180910390f35b34801561028157600080fd5b5061028a6107fd565b60405161026c929190614339565b3480156102a457600080fd5b506102ad6108fb565b60405161026c9190613de9565b3480156102c657600080fd5b506102da6102d5366004613994565b61090a565b005b3480156102e857600080fd5b506102fc6102f73660046138dc565b6109d3565b60405161026c9190613ea8565b34801561031557600080fd5b506102ad6109e4565b34801561032a57600080fd5b5061025f6109f3565b34801561033f57600080fd5b506103486109f9565b60405161026c9190613ebd565b34801561036157600080fd5b5061036a610a29565b60405161026c929190613ede565b610348610386366004613946565b610bbf565b34801561039757600080fd5b506103a0610c62565b60405161026c9190613ed0565b3480156103b957600080fd5b506102ad610c72565b3480156103ce57600080fd5b506102da6103dd366004613c0d565b610c81565b3480156103ee57600080fd5b5061025f610cb0565b34801561040357600080fd5b5061028a610412366004613c0d565b610cb6565b34801561042357600080fd5b506102ad610e12565b34801561043857600080fd5b506102da610e2a565b34801561044d57600080fd5b5061025f61045c3660046138a4565b611222565b34801561046d57600080fd5b5061025f6112ed565b34801561048257600080fd5b506102ad6112f3565b34801561049757600080fd5b506102da6104a6366004613bd5565b611302565b3480156104b757600080fd5b5061025f611350565b3480156104cc57600080fd5b5061025f611370565b3480156104e157600080fd5b5061028a611bde565b3480156104f657600080fd5b5061050a6105053660046138a4565b611dfe565b60405161026c9190613e9d565b34801561052357600080fd5b506102da6105323660046138a4565b611e13565b34801561054357600080fd5b5061025f611e5f565b34801561055857600080fd5b506102da6105673660046138a4565b611f02565b34801561057857600080fd5b506102da610587366004613994565b611f4e565b34801561059857600080fd5b506102da6105a73660046138a4565b611fef565b3480156105b857600080fd5b506102da6105c73660046138a4565b61203b565b3480156105d857600080fd5b506105e1612087565b60405161026c9190614306565b3480156105fa57600080fd5b506102da612099565b34801561060f57600080fd5b506102ad6122a3565b34801561062457600080fd5b506102ad6122b2565b34801561063957600080fd5b506102ad6122c1565b34801561064e57600080fd5b506103a06122d0565b34801561066357600080fd5b5061028a6122d9565b34801561067857600080fd5b506102ad612316565b34801561068d57600080fd5b506102da61069c366004613bd5565b612325565b3480156106ad57600080fd5b506102da6106bc366004613adb565b612373565b6006546040516370a0823160e01b815260009182916107ee916001600160a01b0316906370a08231906106f8903090600401613de9565b60206040518083038186803b15801561071057600080fd5b505afa158015610724573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107489190613c25565b6007546040516370a0823160e01b81526001600160a01b03909116906370a0823190610778903090600401613de9565b60206040518083038186803b15801561079057600080fd5b505afa1580156107a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c89190613c25565b6009546005546001600160a01b0316929190600281810b9163010000009004900b6124de565b6001600160801b031691505090565b336000908152600b6020526040812054819060ff168061082757506001546001600160a01b031633145b8061083c57506003546001600160a01b031633145b61084557600080fd5b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b815260009283926001600160a01b039091169163fc6f78659161089f91600401614130565b6040805180830381600087803b1580156108b857600080fd5b505af11580156108cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f09190613c79565b909450925050509091565b6006546001600160a01b031681565b6001546001600160a01b031633148061092d57506003546001600160a01b031633145b806109475750336000908152600b602052604090205460ff165b61096c5760405162461bcd60e51b815260040161096390613faf565b60405180910390fd5b60005b818110156109ce576001600b600085858581811061098957fe5b905060200201602081019061099e91906138a4565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010161096f565b505050565b630a85bd0160e11b5b949350505050565b6005546001600160a01b031681565b60085481565b6040805180820190915260168152755374726174656779557364634574683035556e69563360501b602082015290565b604080516002808252606080830184526000938493919290602083019080368337019050506009548151919250600160781b900462ffffff16908290600090610a6e57fe5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610a9757fe5b63ffffffff9092166020928302919091019091015260055460405163883bdbfd60e01b81526060916001600160a01b03169063883bdbfd90610add908590600401613e53565b60006040518083038186803b158015610af557600080fd5b505afa158015610b09573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b319190810190613a03565b50905060006009600f9054906101000a900462ffffff1662ffffff1682600081518110610b5a57fe5b602002602001015183600181518110610b6f57fe5b60200260200101510360060b81610b8257fe5b600954919005915066010000000000008104600290810b600160481b909204900b810290610bb39083908390612584565b95509550505050509091565b6004546060906001600160a01b03163314610bec5760405162461bcd60e51b8152600401610963906140b7565b6001600160a01b038316610c125760405162461bcd60e51b815260040161096390613f17565b600080835160208501866113885a03f43d6040519250601f19601f6020830101168301604052808352806000602085013e811560018114610c5257610c59565b8160208501fd5b50505092915050565b6009546301000000900460020b81565b6003546001600160a01b031681565b6004546001600160a01b03163314610cab5760405162461bcd60e51b8152600401610963906140b7565b600055565b61271081565b60025460009081906001600160a01b03163314610ce55760405162461bcd60e51b815260040161096390613f38565b610cee836125a1565b600254600554604051636535246160e11b81529395509193506000926001600160a01b039182169263ca6a48c292610d2b92911690600401613de9565b60206040518083038186803b158015610d4357600080fd5b505afa158015610d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7b91906138c0565b90506001600160a01b038116610da35760405162461bcd60e51b815260040161096390614018565b600654610dba906001600160a01b03168285612760565b600754610dd1906001600160a01b03168284612760565b7f0c875c8d391179c5cf7ad8303d268efd50b8beb78b671f85cd54bfb91eb8ef4060085485604051610e04929190614339565b60405180910390a150915091565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b336000908152600b602052604090205460ff1680610e5257506001546001600160a01b031633145b80610e6757506003546001600160a01b031633145b610e7057600080fd5b6006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610ea1903090600401613de9565b60206040518083038186803b158015610eb957600080fd5b505afa158015610ecd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef19190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610f27903090600401613de9565b60206040518083038186803b158015610f3f57600080fd5b505afa158015610f53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f779190613c25565b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81529293506001600160a01b039091169163fc6f786591610fcf91600401614130565b6040805180830381600087803b158015610fe857600080fd5b505af1158015610ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110209190613c79565b5050600a5460065460405163df2ab5bb60e01b81526001600160a01b039283169263df2ab5bb9261105b929116906000903090600401613e17565b600060405180830381600087803b15801561107557600080fd5b505af1158015611089573d6000803e3d6000fd5b5050600a5460075460405163df2ab5bb60e01b81526001600160a01b03928316945063df2ab5bb93506110c792909116906000903090600401613e17565b600060405180830381600087803b1580156110e157600080fd5b505af11580156110f5573d6000803e3d6000fd5b50506006546040516370a0823160e01b81526111c29350611187925085916001600160a01b0316906370a0823190611131903090600401613de9565b60206040518083038186803b15801561114957600080fd5b505afa15801561115d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111819190613c25565b9061277f565b6007546040516370a0823160e01b81526111bd9185916001600160a01b03909116906370a0823190611131903090600401613de9565b6127ca565b6009546111dd90600281810b9163010000009004900b612938565b6111e5612099565b7f8e55ccfc9778ff8eba1646d765cf1982537ce0f9257054a17b48aad7452501836008546040516112169190614316565b60405180910390a15050565b6002546000906001600160a01b0316331461124f5760405162461bcd60e51b815260040161096390613f38565b6040516370a0823160e01b81526001600160a01b038316906370a082319061127b903090600401613de9565b60206040518083038186803b15801561129357600080fd5b505afa1580156112a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cb9190613c25565b6002549091506112e8906001600160a01b03848116911683612760565b919050565b60005481565b6001546001600160a01b031681565b6001546001600160a01b0316331461132c5760405162461bcd60e51b815260040161096390613ef2565b6009805462ffffff909216600160781b0262ffffff60781b19909216919091179055565b600061136b61135d611e5f565b6113656106c1565b90612cbc565b905090565b336000908152600b602052604081205460ff168061139857506001546001600160a01b031633145b806113ad57506003546001600160a01b031633145b6113b657600080fd5b60085415611895576006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906113ef903090600401613de9565b60206040518083038186803b15801561140757600080fd5b505afa15801561141b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143f9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611475903090600401613de9565b60206040518083038186803b15801561148d57600080fd5b505afa1580156114a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c59190613c25565b600a5460085460405163133f757160e31b81529293506000926001600160a01b03909216916399fbab88916114fc91600401614316565b6101806040518083038186803b15801561151557600080fd5b505afa158015611529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154d9190613c9c565b505050506001600160801b0316975050505050505050600080600a60009054906101000a90046001600160a01b03166001600160a01b0316630c49ccbe6040518060a001604052806008548152602001866001600160801b0316815260200160008152602001600081526020014261012c018152506040518263ffffffff1660e01b81526004016115de9190614173565b6040805180830381600087803b1580156115f757600080fd5b505af115801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f9190613c79565b600a546040805160808101825260085481523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81529395509193506001600160a01b03169163fc6f78659161168891600401614130565b6040805180830381600087803b1580156116a157600080fd5b505af11580156116b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d99190613c79565b5050600a5460065460405163df2ab5bb60e01b81526001600160a01b039283169263df2ab5bb92611714929116906000903090600401613e17565b600060405180830381600087803b15801561172e57600080fd5b505af1158015611742573d6000803e3d6000fd5b5050600a5460075460405163df2ab5bb60e01b81526001600160a01b03928316945063df2ab5bb935061178092909116906000903090600401613e17565b600060405180830381600087803b15801561179a57600080fd5b505af11580156117ae573d6000803e3d6000fd5b5050600a54600854604051630852cd8d60e31b81526001600160a01b0390921693506342966c6892506117e391600401614316565b600060405180830381600087803b1580156117fd57600080fd5b505af1158015611811573d6000803e3d6000fd5b50506006546040516370a0823160e01b815261188f9350611853925088916111819187916001600160a01b0316906370a0823190611131903090600401613de9565b6007546040516370a0823160e01b81526111bd9188916111819187916001600160a01b03909116906370a0823190611131903090600401613de9565b50505050505b6000806118a0610a29565b915091506118ae8282612938565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906118df903090600401613de9565b60206040518083038186803b1580156118f757600080fd5b505afa15801561190b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192f9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611965903090600401613de9565b60206040518083038186803b15801561197d57600080fd5b505afa158015611991573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b59190613c25565b600a5460408051610160810182526006546001600160a01b0390811682526007548116602080840191909152600554845163ddca3f4360e01b81528551979850958316966388316456969495860194919093169263ddca3f4392600480840193919291829003018186803b158015611a2c57600080fd5b505afa158015611a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a649190613bf1565b62ffffff1681526020018760020b81526020018660020b81526020018581526020018481526020016000815260200160008152602001306001600160a01b031681526020014261012c018152506040518263ffffffff1660e01b8152600401611acd9190614258565b608060405180830381600087803b158015611ae757600080fd5b505af1158015611afb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1f9190613c3d565b50505060088190556009805462ffffff1916600287810b62ffffff9081169290921765ffffff000000191663010000009188900b9290921602179055945084611b9a577f747c5e78fb5f01e96acc105d1f2a147e11deef8eff1e2cf6498e3790106feb3285604051611b919190614316565b60405180910390a15b7f3e23da686e1f40c469c91f3009f25bd78f5098ad5624b4fedf44e47f0714656b6008548585604051611bcf9392919061431f565b60405180910390a15050505090565b60025460009081906001600160a01b03163314611c0d5760405162461bcd60e51b815260040161096390613f38565b611c15612ce1565b5050600254600554604051636535246160e11b81526000926001600160a01b039081169263ca6a48c292611c4f9290911690600401613de9565b60206040518083038186803b158015611c6757600080fd5b505afa158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f91906138c0565b90506001600160a01b038116611cc75760405162461bcd60e51b815260040161096390614018565b6006546040516370a0823160e01b81526001600160a01b03909116906370a0823190611cf7903090600401613de9565b60206040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d479190613c25565b6007546040516370a0823160e01b81529194506001600160a01b0316906370a0823190611d78903090600401613de9565b60206040518083038186803b158015611d9057600080fd5b505afa158015611da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc89190613c25565b600654909250611de2906001600160a01b03168285612760565b600754611df9906001600160a01b03168284612760565b509091565b600b6020526000908152604090205460ff1681565b6004546001600160a01b03163314611e3d5760405162461bcd60e51b8152600401610963906140b7565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600a5460085460405163133f757160e31b815260009283926001600160a01b03909116916399fbab8891611e9591600401614316565b6101806040518083038186803b158015611eae57600080fd5b505afa158015611ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee69190613c9c565b50506001600160801b039092169a505050505050505050505090565b6001546001600160a01b03163314611f2c5760405162461bcd60e51b815260040161096390613ef2565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b0316331480611f7157506003546001600160a01b031633145b611f8d5760405162461bcd60e51b815260040161096390613faf565b60005b818110156109ce576000600b6000858585818110611faa57fe5b9050602002016020810190611fbf91906138a4565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611f90565b6004546001600160a01b031633146120195760405162461bcd60e51b8152600401610963906140b7565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146120655760405162461bcd60e51b815260040161096390613ef2565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600954600160601b900462ffffff1681565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906120ca903090600401613de9565b60206040518083038186803b1580156120e257600080fd5b505afa1580156120f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211a9190613c25565b6007546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612150903090600401613de9565b60206040518083038186803b15801561216857600080fd5b505afa15801561217c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a09190613c25565b90506000821180156121b25750600081115b1561226e57600a546040805160c081018252600854815260208101859052808201849052600060608201819052608082015261012c420160a0820152905163219f5d1760e01b81526001600160a01b039092169163219f5d179161221891600401614214565b606060405180830381600087803b15801561223257600080fd5b505af1158015612246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226a9190613af7565b5050505b7f1ca606821992e3b34613b5b29c0bbade3a907b2969d7f9f2927f726fa4baccfb600854838360405161121693929190614347565b6007546001600160a01b031681565b6004546001600160a01b031681565b600a546001600160a01b031681565b60095460020b81565b6009546005546000918291829182916108f0916001600160a01b0390911690670de0b6b3a764000090600281810b9163010000009004900b612cfd565b6002546001600160a01b031681565b6001546001600160a01b0316331461234f5760405162461bcd60e51b815260040161096390613ef2565b6009805462ffffff909216600160601b0262ffffff60601b19909216919091179055565b6001546001600160a01b0316331461239d5760405162461bcd60e51b815260040161096390613ef2565b6009805460029290920b62ffffff16600160481b026bffffff00000000000000000019909216919091179055565b8015806124535750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906124019030908690600401613dfd565b60206040518083038186803b15801561241957600080fd5b505afa15801561242d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124519190613c25565b155b61246f5760405162461bcd60e51b8152600401610963906140da565b6109ce8363095ea7b360e01b848460405160240161248e929190613e3a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612da6565b60606124d48484600085612e35565b90505b9392505050565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561251a57600080fd5b505afa15801561252e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125529190613b38565b50505050505090506125778161256786612ef9565b61257086612ef9565b8989613212565b9150505b95945050505050565b600080600061259386856132d4565b858103979501955050505050565b600080826125b45750600090508061275b565b60095460055460009182916125e5916001600160a01b03909116908790600281810b9163010000009004900b612cfd565b600a546040805160a08101825260085481526001600160801b038a1660208201528082018590526060810184905261012c420160808201529051630624e65f60e11b815293955091935060009283926001600160a01b0390921691630c49ccbe916126539190600401614173565b6040805180830381600087803b15801561266c57600080fd5b505af1158015612680573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a49190613c79565b600a546040805160808101825260085481523060208201526001600160801b038086168284015284166060820152905163fc6f786560e01b81529395509193506001600160a01b03169163fc6f78659161270091600401614130565b6040805180830381600087803b15801561271957600080fd5b505af115801561272d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127519190613c79565b5091955093505050505b915091565b6109ce8363a9059cbb60e01b848460405160240161248e929190613e3a565b60006127c183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613320565b90505b92915050565b811561288257600254604080516361d027b360e01b81529051612882926001600160a01b0316916361d027b3916004808301926020929190829003018186803b15801561281657600080fd5b505afa15801561282a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284e91906138c0565b61286f6127106128696000548761334c90919063ffffffff16565b90613386565b6006546001600160a01b03169190612760565b801561293457600254604080516361d027b360e01b81529051612934926001600160a01b0316916361d027b3916004808301926020929190829003018186803b1580156128ce57600080fd5b505afa1580156128e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290691906138c0565b6129216127106128696000548661334c90919063ffffffff16565b6007546001600160a01b03169190612760565b5050565b61294061371c565b6006546040516370a0823160e01b81526001600160a01b03909116906370a0823190612970903090600401613de9565b60206040518083038186803b15801561298857600080fd5b505afa15801561299c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c09190613c25565b81526007546040516370a0823160e01b81526001600160a01b03909116906370a08231906129f2903090600401613de9565b60206040518083038186803b158015612a0a57600080fd5b505afa158015612a1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a429190613c25565b602082018190528151600554612a66926001600160a01b03909116919086866124de565b6001600160801b031660808201819052600554612a90916001600160a01b03909116908585612cfd565b606083015260408201526020810151600090612aae57506001612acd565b612aca82600001518360200151846040015185606001516133c8565b90505b600081612af957612af460026128698560600151866020015161277f90919063ffffffff16565b612b10565b60408301518351612b10916002916128699161277f565b90508015612cb557600082612b30576007546001600160a01b0316612b3d565b6006546001600160a01b03165b9050612b686001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc4560006123cb565b612b906001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc45846123cb565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03166304e45aaf6040518060e00160405280846001600160a01b0316815260200186612be3576006546001600160a01b0316612bf0565b6007546001600160a01b03165b6001600160a01b031681526020016009600c9054906101000a900462ffffff1662ffffff168152602001306001600160a01b031681526020018581526020016000815260200160006001600160a01b03168152506040518263ffffffff1660e01b8152600401612c6091906141b6565b602060405180830381600087803b158015612c7a57600080fd5b505af1158015612c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb29190613c25565b50505b5050505050565b6000828201838110156127c15760405162461bcd60e51b815260040161096390613f5d565b600080612cf4612cef611e5f565b6125a1565b90939092509050565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612d3b57600080fd5b505afa158015612d4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d739190613b38565b5050505050509050612d9781612d8887612ef9565b612d9187612ef9565b89613403565b92509250505b94509492505050565b6060612dfb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124c59092919063ffffffff16565b8051909150156109ce5780806020019051810190612e199190613abb565b6109ce5760405162461bcd60e51b81526004016109639061406d565b6060612e408561349e565b612e5c5760405162461bcd60e51b815260040161096390614036565b60006060866001600160a01b03168587604051612e799190613dcd565b60006040518083038185875af1925050503d8060008114612eb6576040519150601f19603f3d011682016040523d82523d6000602084013e612ebb565b606091505b50915091508115612ecf5791506109dc9050565b805115612edf5780518082602001fd5b8360405162461bcd60e51b81526004016109639190613ebd565b60008060008360020b12612f10578260020b612f18565b8260020b6000035b9050620d89e8811115612f3d5760405162461bcd60e51b815260040161096390613f94565b600060018216612f5157600160801b612f63565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612f97576ffff97272373d413259a46990580e213a0260801c5b6004821615612fb6576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615612fd5576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615612ff4576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615613013576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615613032576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615613051576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615613071576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615613091576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156130b1576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156130d1576fe7159475a2c29b7443b29c7fa6e889d90260801c5b6110008216156130f1576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615613111576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615613131576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615613151576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615613172576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615613192576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156131b1576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156131ce576b048a170391f7dc42444e8fa20260801c5b60008460020b13156131e95780600019816131e557fe5b0490505b6401000000008106156131fd576001613200565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b03161115613232579293925b846001600160a01b0316866001600160a01b03161161325d576132568585856134a4565b905061257b565b836001600160a01b0316866001600160a01b031610156132bf5760006132848786866134a4565b90506000613293878986613507565b9050806001600160801b0316826001600160801b0316106132b457806132b6565b815b9250505061257b565b6132ca858584613507565b9695505050505050565b6000808260020b8460020b816132e657fe5b05905060008460020b12801561330d57508260020b8460020b8161330657fe5b0760020b15155b1561331757600019015b90910292915050565b600081848411156133445760405162461bcd60e51b81526004016109639190613ebd565b505050900390565b60008261335b575060006127c4565b8282028284828161336857fe5b04146127c15760405162461bcd60e51b815260040161096390613fd7565b60006127c183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613544565b60006133de856133d8868561357b565b9061358b565b6133ec856133d8888761357b565b116133f857600061257b565b600195945050505050565b600080836001600160a01b0316856001600160a01b03161115613424579293925b846001600160a01b0316866001600160a01b03161161344f576134488585856135af565b9150612d9d565b836001600160a01b0316866001600160a01b03161015613488576134748685856135af565b9150613481858785613618565b9050612d9d565b613493858585613618565b905094509492505050565b3b151590565b6000826001600160a01b0316846001600160a01b031611156134c4579192915b60006134e7856001600160a01b0316856001600160a01b0316600160601b613657565b905061257b61350284838888036001600160a01b0316613657565b613706565b6000826001600160a01b0316846001600160a01b03161115613527579192915b6124d461350283600160601b8787036001600160a01b0316613657565b600081836135655760405162461bcd60e51b81526004016109639190613ebd565b50600083858161357157fe5b0495945050505050565b808203828111156127c457600080fd5b60008215806135a6575050818102818382816135a357fe5b04145b6127c457600080fd5b6000826001600160a01b0316846001600160a01b031611156135cf579192915b836001600160a01b0316613608606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316613657565b8161360f57fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115613638579192915b6124d4826001600160801b03168585036001600160a01b0316600160601b5b600080806000198587098686029250828110908390030390508061368d576000841161368257600080fd5b5082900490506124d7565b80841161369957600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b806001600160801b03811681146112e857600080fd5b6040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090565b80516127c4816143d4565b600082601f830112613783578081fd5b815161379661379182614384565b61435d565b8181529150602080830190848101818402860182018710156137b757600080fd5b60005b848110156137df5781516137cd816143d4565b845292820192908201906001016137ba565b505050505092915050565b600082601f8301126137fa578081fd5b813567ffffffffffffffff811115613810578182fd5b613823601f8201601f191660200161435d565b915080825283602082850101111561383a57600080fd5b8060208401602084013760009082016020015292915050565b80516127c4816143ec565b8051600681900b81146127c457600080fd5b80516001600160801b03811681146127c457600080fd5b805161ffff811681146127c457600080fd5b80516127c4816143fb565b6000602082840312156138b5578081fd5b81356127c1816143d4565b6000602082840312156138d1578081fd5b81516127c1816143d4565b600080600080608085870312156138f1578283fd5b84356138fc816143d4565b9350602085013561390c816143d4565b925060408501359150606085013567ffffffffffffffff81111561392e578182fd5b61393a878288016137ea565b91505092959194509250565b60008060408385031215613958578182fd5b8235613963816143d4565b9150602083013567ffffffffffffffff81111561397e578182fd5b61398a858286016137ea565b9150509250929050565b600080602083850312156139a6578182fd5b823567ffffffffffffffff808211156139bd578384fd5b818501915085601f8301126139d0578384fd5b8135818111156139de578485fd5b86602080830285010111156139f1578485fd5b60209290920196919550909350505050565b60008060408385031215613a15578182fd5b825167ffffffffffffffff80821115613a2c578384fd5b818501915085601f830112613a3f578384fd5b8151613a4d61379182614384565b80828252602080830192508086018a828387028901011115613a6d578889fd5b8896505b84871015613a9757613a838b8261385e565b845260019690960195928101928101613a71565b508801519096509350505080821115613aae578283fd5b5061398a85828601613773565b600060208284031215613acc578081fd5b815180151581146127c1578182fd5b600060208284031215613aec578081fd5b81356127c1816143ec565b600080600060608486031215613b0b578081fd5b83516001600160801b0381168114613b21578182fd5b602085015160409095015190969495509392505050565b600080600080600080600060e0888a031215613b52578485fd5b8751613b5d816143d4565b6020890151909750613b6e816143ec565b9550613b7d8960408a01613887565b9450613b8c8960608a01613887565b9350613b9b8960808a01613887565b925060a088015160ff81168114613bb0578283fd5b60c08901519092508015158114613bc5578182fd5b8091505092959891949750929550565b600060208284031215613be6578081fd5b81356127c1816143fb565b600060208284031215613c02578081fd5b81516127c1816143fb565b600060208284031215613c1e578081fd5b5035919050565b600060208284031215613c36578081fd5b5051919050565b60008060008060808587031215613c52578182fd5b84519350613c638660208701613870565b6040860151606090960151949790965092505050565b60008060408385031215613c8b578182fd5b505080516020909101519092909150565b6000806000806000806000806000806000806101808d8f031215613cbe578586fd5b8c516bffffffffffffffffffffffff81168114613cd9578687fd5b9b50613ce88e60208f01613768565b9a50613cf78e60408f01613768565b9950613d068e60608f01613768565b9850613d158e60808f01613899565b9750613d248e60a08f01613853565b9650613d338e60c08f01613853565b9550613d428e60e08f01613870565b94506101008d015193506101208d01519250613d628e6101408f01613870565b9150613d728e6101608f01613870565b90509295989b509295989b509295989b565b6001600160a01b03169052565b60008151808452613da98160208601602086016143a4565b601f01601f19169290920160200192915050565b60020b9052565b62ffffff169052565b60008251613ddf8184602087016143a4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015613e9157835163ffffffff1683529284019291840191600101613e6f565b50909695505050505050565b901515815260200190565b6001600160e01b031991909116815260200190565b6000602082526127c16020830184613d91565b60029190910b815260200190565b600292830b8152910b602082015260400190565b6020808252600b908201526a21676f7665726e616e636560a81b604082015260600190565b602080825260079082015266085d185c99d95d60ca1b604082015260600190565b6020808252600b908201526a10b1b7b73a3937b63632b960a91b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526004908201526310b530b960e11b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152682174696d656c6f636b60b81b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c092830151169181019190915260e00190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b60006101608201905061426c828451613d84565b602083015161427e6020840182613d84565b5060408301516142916040840182613dc4565b5060608301516142a46060840182613dbd565b5060808301516142b76080840182613dbd565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516142f582850182613d84565b505061014092830151919092015290565b62ffffff91909116815260200190565b90815260200190565b928352600291820b6020840152900b604082015260600190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561437c57600080fd5b604052919050565b600067ffffffffffffffff82111561439a578081fd5b5060209081020190565b60005b838110156143bf5781810151838201526020016143a7565b838111156143ce576000848401525b50505050565b6001600160a01b03811681146143e957600080fd5b50565b8060020b81146143e957600080fd5b62ffffff811681146143e957600080fdfea2646970667358221220db75b9a3d24d3344d91e82d8271ad4555a98ca0e416c87efbd8370f7feff75cf64736f6c634300060c0033

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

00000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000009d074e37d408542fd38be78848e8814afb38db17000000000000000000000000acfe4511ce883c14c4ea40563f176c3c09b4c47c0000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce36370000000000000000000000009d074e37d408542fd38be78848e8814afb38db17

-----Decoded View---------------
Arg [0] : _tickRangeMultiplier (int24): 250
Arg [1] : _swapPoolFee (uint24): 500
Arg [2] : _governance (address): 0x9d074E37d408542FD38be78848e8814AFB38db17
Arg [3] : _strategist (address): 0xaCfE4511CE883C14c4eA40563F176C3C09b4c47C
Arg [4] : _controller (address): 0x7B5916C61bCEeaa2646cf49D9541ac6F5DCe3637
Arg [5] : _timelock (address): 0x9d074E37d408542FD38be78848e8814AFB38db17

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000fa
Arg [1] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [2] : 0000000000000000000000009d074e37d408542fd38be78848e8814afb38db17
Arg [3] : 000000000000000000000000acfe4511ce883c14c4ea40563f176c3c09b4c47c
Arg [4] : 0000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce3637
Arg [5] : 0000000000000000000000009d074e37d408542fd38be78848e8814afb38db17


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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.