ETH Price: $2,304.66 (+1.06%)

Contract

0x48737f645e1e8dD67CAe1311b2c42e6935c6A5E1
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Collect All Toke...160095092022-11-20 6:42:591212 days ago1668926579IN
0x48737f64...935c6A5E1
0 ETH0.0022687612.73748235
Collect Fee Char...157086302022-10-09 6:04:231254 days ago1665295463IN
0x48737f64...935c6A5E1
0 ETH0.0020206525.51433665
Collect All Toke...156024312022-09-24 9:50:111269 days ago1664013011IN
0x48737f64...935c6A5E1
0 ETH0.000701795.42189305
Collect All Toke...155109732022-09-10 21:01:071283 days ago1662843667IN
0x48737f64...935c6A5E1
0 ETH0.00063148.23021697
Withdraw155109732022-09-10 21:01:071283 days ago1662843667IN
0x48737f64...935c6A5E1
0 ETH0.003621448.23021697
Withdraw155012162022-09-09 6:15:291284 days ago1662704129IN
0x48737f64...935c6A5E1
0 ETH0.00380839.26547883
Withdraw155012132022-09-09 6:14:551284 days ago1662704095IN
0x48737f64...935c6A5E1
0 ETH0.004558289.52247602
Withdraw155012102022-09-09 6:14:371284 days ago1662704077IN
0x48737f64...935c6A5E1
0 ETH0.0056278310.65313001
Withdraw154873462022-09-07 1:00:081287 days ago1662512408IN
0x48737f64...935c6A5E1
0 ETH0.0108483117.86785982
Deposit154809822022-09-06 0:43:511288 days ago1662425031IN
0x48737f64...935c6A5E1
18.64373492 ETH0.0126146514.00324921
Modify End Block154780232022-09-05 12:59:471288 days ago1662382787IN
0x48737f64...935c6A5E1
0 ETH0.000414238.69976797
Collect All Toke...154583822022-09-02 9:32:051291 days ago1662111125IN
0x48737f64...935c6A5E1
0 ETH0.0014858711.54935309
Deposit154576412022-09-02 6:41:211291 days ago1662100881IN
0x48737f64...935c6A5E1
39.85657259 ETH0.0126650613.87661399
Deposit154508822022-09-01 4:50:441293 days ago1662007844IN
0x48737f64...935c6A5E1
0.00000389 ETH0.0109809412.17970826
Deposit154505422022-09-01 3:31:331293 days ago1662003093IN
0x48737f64...935c6A5E1
0.00000692 ETH0.0165605816.77186043
Deposit154503552022-09-01 2:51:261293 days ago1662000686IN
0x48737f64...935c6A5E1
0.00000521 ETH0.0128630313.29793206
Deposit154450742022-08-31 6:36:111293 days ago1661927771IN
0x48737f64...935c6A5E1
0.00000707 ETH0.0141706615.88223216
Deposit154448372022-08-31 5:42:001294 days ago1661924520IN
0x48737f64...935c6A5E1
0.00000806 ETH0.0118867212.67465778
Deposit154447702022-08-31 5:27:261294 days ago1661923646IN
0x48737f64...935c6A5E1
0.00000926 ETH0.0119004912.22110434
Deposit154439562022-08-31 2:15:211294 days ago1661912121IN
0x48737f64...935c6A5E1
0.00000492 ETH0.0128263713.07906302
Collect All Toke...154400132022-08-30 11:03:441294 days ago1661857424IN
0x48737f64...935c6A5E1
0 ETH0.0014314111.12723118
Deposit154396132022-08-30 9:30:181294 days ago1661851818IN
0x48737f64...935c6A5E1
0.00000427 ETH0.0095171711.32396886
Deposit154395332022-08-30 9:12:021294 days ago1661850722IN
0x48737f64...935c6A5E1
0.0000047 ETH0.0100166810.61066894
Deposit154393002022-08-30 8:20:461294 days ago1661847646IN
0x48737f64...935c6A5E1
0.0000038 ETH0.0126063713.00627649
Deposit154343402022-08-29 13:28:141295 days ago1661779694IN
0x48737f64...935c6A5E1
0.01800286 ETH0.011862611.61617125
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer157086302022-10-09 6:04:231254 days ago1665295463
0x48737f64...935c6A5E1
0.18686414 ETH
Transfer157086302022-10-09 6:04:231254 days ago1665295463
0x48737f64...935c6A5E1
0.18686414 ETH
Transfer155109732022-09-10 21:01:071283 days ago1662843667
0x48737f64...935c6A5E1
0.01565594 ETH
Transfer155109732022-09-10 21:01:071283 days ago1662843667
0x48737f64...935c6A5E1
0.01565594 ETH
Transfer155109732022-09-10 21:01:071283 days ago1662843667
0x48737f64...935c6A5E1
0.00009781 ETH
Transfer155109732022-09-10 21:01:071283 days ago1662843667
0x48737f64...935c6A5E1
0.00009781 ETH
Transfer155012162022-09-09 6:15:291284 days ago1662704129
0x48737f64...935c6A5E1
20.7653422 ETH
Transfer155012162022-09-09 6:15:291284 days ago1662704129
0x48737f64...935c6A5E1
20.7653422 ETH
Transfer155012162022-09-09 6:15:291284 days ago1662704129
0x48737f64...935c6A5E1
0.04254598 ETH
Transfer155012162022-09-09 6:15:291284 days ago1662704129
0x48737f64...935c6A5E1
0.04254598 ETH
Transfer155012132022-09-09 6:14:551284 days ago1662704095
0x48737f64...935c6A5E1
19.6037891 ETH
Transfer155012132022-09-09 6:14:551284 days ago1662704095
0x48737f64...935c6A5E1
19.6037891 ETH
Transfer155012132022-09-09 6:14:551284 days ago1662704095
0x48737f64...935c6A5E1
0.09694901 ETH
Transfer155012132022-09-09 6:14:551284 days ago1662704095
0x48737f64...935c6A5E1
0.09694901 ETH
Transfer155012102022-09-09 6:14:371284 days ago1662704077
0x48737f64...935c6A5E1
16.98555542 ETH
Transfer155012102022-09-09 6:14:371284 days ago1662704077
0x48737f64...935c6A5E1
16.98555542 ETH
Transfer155012102022-09-09 6:14:371284 days ago1662704077
0x48737f64...935c6A5E1
0.02676509 ETH
Transfer155012102022-09-09 6:14:371284 days ago1662704077
0x48737f64...935c6A5E1
0.02676509 ETH
Transfer154873462022-09-07 1:00:081287 days ago1662512408
0x48737f64...935c6A5E1
42.59318317 ETH
Transfer154873462022-09-07 1:00:081287 days ago1662512408
0x48737f64...935c6A5E1
42.59318317 ETH
Transfer154873462022-09-07 1:00:081287 days ago1662512408
0x48737f64...935c6A5E1
0.11393831 ETH
Transfer154873462022-09-07 1:00:081287 days ago1662512408
0x48737f64...935c6A5E1
0.11393831 ETH
Mint154809822022-09-06 0:43:511288 days ago1662425031
0x48737f64...935c6A5E1
18.64373492 ETH
Mint154576412022-09-02 6:41:211291 days ago1662100881
0x48737f64...935c6A5E1
39.85657259 ETH
Transfer154508822022-09-01 4:50:441293 days ago1662007844
0x48737f64...935c6A5E1
0.00000001 ETH
View All Internal Transactions
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xDc035E4b...FC9323b98
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
MiningDynamicRangeBoostVeiZi

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;

// Uncomment if needed.
// import "hardhat/console.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

import "../libraries/UniswapOracle.sol";
import "../libraries/UniswapCallingParams.sol";

import "../base/MiningBaseVeiZi.sol";


/// @title Uniswap V3 Liquidity Mining Main Contract
contract MiningDynamicRangeBoostVeiZi is MiningBaseVeiZi {
    // using Math for int24;
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.UintSet;

    using UniswapOracle for address;

    int24 internal constant TICK_MAX = 500000;
    int24 internal constant TICK_MIN = -500000;

    int24 public tickRangeLeft;
    int24 public tickRangeRight;
    
    bool public token0IsETH;
    bool public token1IsETH;

    uint256 public totalToken0;
    uint256 public totalToken1;

    /// @dev Contract of the uniV3 Nonfungible Position Manager.
    address public uniV3NFTManager;
    address public uniFactory;
    address public swapPool;

    /// @dev Record the status for a certain token for the last touched time.
    struct TokenStatus {
        uint256 nftId;
        uint256 vLiquidity;
        uint256 uniLiquidity;
        uint256 lastTouchBlock;
        uint256 amount0;
        uint256 amount1;
    }

    mapping(uint256 => TokenStatus) public tokenStatus;

    receive() external payable {}


    struct PoolParams {
        address uniV3NFTManager;
        address token0;
        address token1;
        uint24 fee;
    }
    constructor(
        PoolParams memory poolParams,
        RewardInfo[] memory _rewardInfos,
        address _veiZiAddress,
        uint256 _startBlock,
        uint256 _endBlock,
        uint24 feeChargePercent,
        address _chargeReceiver,
        int24 _tickRangeLeft,
        int24 _tickRangeRight,
        uint256 _totalValidVeiZi
    ) MiningBaseVeiZi(
        feeChargePercent, 
        poolParams.uniV3NFTManager, 
        _veiZiAddress,
        poolParams.token0, 
        poolParams.token1, 
        poolParams.fee, 
        _chargeReceiver,
        _totalValidVeiZi
    ) {
        uniV3NFTManager = poolParams.uniV3NFTManager;

        require(rewardPool.token0 < rewardPool.token1, "TOKEN0 < TOKEN1 NOT MATCH");

        uniFactory = INonfungiblePositionManager(uniV3NFTManager).factory();

        // weth has been marked in the MiningBase constructor
        token0IsETH = (rewardPool.token0 == weth);
        token1IsETH = (rewardPool.token1 == weth);

        IERC20(rewardPool.token0).safeApprove(uniV3NFTManager, type(uint256).max);
        IERC20(rewardPool.token1).safeApprove(uniV3NFTManager, type(uint256).max);

        swapPool = IUniswapV3Factory(uniFactory).getPool(rewardPool.token0, rewardPool.token1, rewardPool.fee);
        require(swapPool != address(0), "NO UNI POOL");

        // check cardinality to prevent sandwitch attach
        require(UniswapOracle.getSlot0(swapPool).observationCardinalityNext >= 50, "CAR");

        rewardInfosLen = _rewardInfos.length;
        require(rewardInfosLen > 0, "NO REWARD");
        require(rewardInfosLen < 3, "AT MOST 2 REWARDS");

        for (uint256 i = 0; i < rewardInfosLen; i++) {
            rewardInfos[i] = _rewardInfos[i];
            // we could not believe accRewardPerShare from constructor args
            rewardInfos[i].accRewardPerShare = 0;
        }

        startBlock = _startBlock;
        endBlock = _endBlock;

        lastTouchBlock = startBlock;

        totalVLiquidity = 0;

        totalToken0 = 0;
        totalToken1 = 0;

        tickRangeLeft = _tickRangeLeft;
        tickRangeRight = _tickRangeRight;
    }

    /// @notice Get the overall info for the mining contract.
    function getMiningContractInfo()
        external
        view
        returns (
            address token0_,
            address token1_,
            uint24 fee_,
            address veiZiAddress_,
            uint256 lastTouchBlock_,
            uint256 totalVLiquidity_,
            uint256 totalToken0_,
            uint256 totalToken1_,
            uint256 totalValidVeiZi_,
            uint256 startBlock_,
            uint256 endBlock_
        )
    {
        return (
            rewardPool.token0,
            rewardPool.token1,
            rewardPool.fee,
            veiZiAddress_,
            lastTouchBlock,
            totalVLiquidity,
            totalToken0,
            totalToken1,
            totalValidVeiZi,
            startBlock,
            endBlock
        );
    }

    /// @dev compute tick range converted from [oraclePrice / 2, oraclePrice * 2]
    /// @param stdTick, (tickLeft + tickRight) / 2 should not too differ from stdTick
    /// @return tickLeft
    /// @return tickRight
    function _getTickRange(int24 stdTick)
        private
        view
        returns (
            int24 tickLeft,
            int24 tickRight
        )
    {
        (int24 avgTick, , int currentTick, ) = swapPool.getAvgTickPriceWithin2Hour();
        int56 delta = int56(avgTick) - int56(stdTick);
        delta = (delta >= 0) ? delta: -delta;
        require(delta < 500, "TICK BIAS AS");
        delta = int56(currentTick) - int56(stdTick);
        delta = (delta >= 0) ? delta: -delta;
        require(delta < 500, "TICK BIAS CS");
        // tickSpacing != 0 is ensured before deploy this contract
        int24 tickSpacing = IUniswapV3Factory(uniFactory).feeAmountTickSpacing(rewardPool.fee);
        // 1.0001^6932 = 2
        tickLeft = Math.max(avgTick - tickRangeLeft, TICK_MIN);
        tickRight = Math.min(avgTick + tickRangeRight, TICK_MAX);
        // round down to times of tickSpacing
        tickLeft = Math.tickFloor(tickLeft, tickSpacing);
        // round up to times of tickSpacing
        tickRight = Math.tickUpper(tickRight, tickSpacing);
        // double check
        require(tickLeft < tickRight, "L<R");
    }

    function getOraclePrice()
        external
        view
        returns (
            int24 avgTick,
            uint160 avgSqrtPriceX96
        )
    {
        (avgTick, avgSqrtPriceX96, , ) = swapPool.getAvgTickPriceWithin2Hour();
    }

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

    function _recvTokenFromUser(address token, address user, uint256 amount) private {
        if (amount == 0) {
            return;
        }
        if (token == weth) {
            // the other token must not be weth
            require(msg.value >= amount, "ETHER INSUFFICIENT");
        } else {
            // receive token(not weth) from user
            IERC20(token).safeTransferFrom(
                user,
                address(this),
                amount
            );
        }
    }

    function _refundTokenToUser(address token, address user, uint256 amount) private {
        if (amount == 0) {
            return;
        }
        if (token == weth) {
            // the other token must not be weth
            safeTransferETH(user, amount);
        } else {
            // for token not be weth
            IERC20(token).safeTransfer(
                user,
                amount
            );
        }
    }

    function deposit(
        uint256 amount0Desired,
        uint256 amount1Desired,
        int24 stdTick
    ) external payable nonReentrant checkNormal {
        _recvTokenFromUser(rewardPool.token0, msg.sender, amount0Desired);
        _recvTokenFromUser(rewardPool.token1, msg.sender, amount1Desired);
        (int24 tickLeft, int24 tickRight) = _getTickRange(stdTick);

        TokenStatus memory newTokenStatus;

        INonfungiblePositionManager.MintParams
            memory uniParams = UniswapCallingParams.mintParams(
                rewardPool.token0, rewardPool.token1, rewardPool.fee, amount0Desired, amount1Desired, tickLeft, tickRight, type(uint256).max
            );
        uint256 actualAmount0; 
        uint256 actualAmount1;
        (
            newTokenStatus.nftId,
            newTokenStatus.uniLiquidity,
            actualAmount0,
            actualAmount1
        ) = INonfungiblePositionManager(uniV3NFTManager).mint{
            value: msg.value
        }(uniParams);

        require(newTokenStatus.uniLiquidity > 1e7, "liquidity too small!");
        newTokenStatus.vLiquidity = newTokenStatus.uniLiquidity / 1e6;

        totalToken0 += actualAmount0;
        totalToken1 += actualAmount1;
        newTokenStatus.amount0 = actualAmount0;
        newTokenStatus.amount1 = actualAmount1;

        // mark owners and append to list
        owners[newTokenStatus.nftId] = msg.sender;
        bool res = tokenIds[msg.sender].add(newTokenStatus.nftId);
        require(res);

        // refund tokens to user
        INonfungiblePositionManager(uniV3NFTManager).refundETH();
        if (actualAmount0 < amount0Desired) {
            _refundTokenToUser(rewardPool.token0, msg.sender, amount0Desired - actualAmount0);
        }
        if (actualAmount1 < amount1Desired) {
            _refundTokenToUser(rewardPool.token1, msg.sender, amount1Desired - actualAmount1);
        }

        _collectUserReward(msg.sender, false);

        _updateVLiquidity(newTokenStatus.vLiquidity, true);

        UserStatus storage user = userStatus[msg.sender];
        user.vLiquidity += newTokenStatus.vLiquidity;
        user.validVeiZi = _updateTotalAndComputeValidVeiZi(user.validVeiZi, user.veiZi, user.vLiquidity);
        require(user.validVeiZi < FixedPoints.Q128 / 6, "veiZi O");
        user.validVLiquidity = _computeValidVLiquidity(user.vLiquidity, user.veiZi);

        tokenStatus[newTokenStatus.nftId] = newTokenStatus;

        emit Deposit(msg.sender, newTokenStatus.nftId, newTokenStatus.vLiquidity);
    }

    /// @notice Widthdraw a single position.
    /// @param tokenId The related position id.
    /// @param noReward true if use want to withdraw without reward
    function withdraw(uint256 tokenId, bool noReward) external nonReentrant {
        require(owners[tokenId] == msg.sender, "NOT OWNER OR NOT EXIST");

        _collectUserReward(msg.sender, noReward || (!normal));
        TokenStatus memory t = tokenStatus[tokenId];
        totalToken0 -= t.amount0;
        totalToken1 -= t.amount1;

        _updateVLiquidity(t.vLiquidity, false);
        UserStatus storage user = userStatus[msg.sender];
        user.vLiquidity = user.vLiquidity - t.vLiquidity;
        user.validVeiZi = _updateTotalAndComputeValidVeiZi(user.validVeiZi, user.veiZi, user.vLiquidity);
        user.validVLiquidity = _computeValidVLiquidity(user.vLiquidity, user.veiZi);

        // first charge and send remain fee from uniswap to user
        (uint256 amount0, uint256 amount1) = INonfungiblePositionManager(
            uniV3NFTManager
        ).collect(
            UniswapCallingParams.collectParams(tokenId, address(this))
        );
        uint256 refundAmount0 = amount0 * feeRemainPercent / 100;
        uint256 refundAmount1 = amount1 * feeRemainPercent / 100;
        _safeTransferToken(rewardPool.token0, msg.sender, refundAmount0);
        _safeTransferToken(rewardPool.token1, msg.sender, refundAmount1);
        totalFeeCharged0 += amount0 - refundAmount0;
        totalFeeCharged1 += amount1 - refundAmount1;

        // then decrease and collect from uniswap
        INonfungiblePositionManager(uniV3NFTManager).decreaseLiquidity(
            UniswapCallingParams.decreaseLiquidityParams(tokenId, uint128(t.uniLiquidity), type(uint256).max)
        );
        (amount0, amount1) = INonfungiblePositionManager(
            uniV3NFTManager
        ).collect(
            UniswapCallingParams.collectParams(tokenId, address(this))
        );
        _safeTransferToken(rewardPool.token0, msg.sender, amount0);
        _safeTransferToken(rewardPool.token1, msg.sender, amount1);

        owners[tokenId] = address(0);
        bool res = tokenIds[msg.sender].remove(tokenId);
        require(res);

        emit Withdraw(msg.sender, tokenId);
    }

    /// @notice Collect all pending rewards.
    function collectAllTokens() external nonReentrant checkNormal {
        // owner of all token has been checked
        _collectUserReward(msg.sender, false);
    }

    // Control fuctions for the contract owner and operators.

    /// @notice If something goes wrong, we can send back user's nft and locked assets
    /// @param tokenId The related position id.
    function emergenceWithdraw(uint256 tokenId) external override onlyOwner {
        address owner = owners[tokenId];
        require(owner != address(0));
        INonfungiblePositionManager(uniV3NFTManager).safeTransferFrom(
            address(this),
            owner,
            tokenId
        );

        // makesure user cannot withdraw/depositIZI or collect reward on this nft
        owners[tokenId] = address(0);
        normal = false;
    }

}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

    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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 6 of 19 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, 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;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../uniswap/interfaces.sol";
import "./LogPowMath.sol";

library UniswapOracle {

    using UniswapOracle for address;

    struct Observation {
        uint32 blockTimestamp;
        int56 tickCumulative;
        uint160 secondsPerLiquidityCumulativeX128;
        bool initialized;
    }

    /// @dev query a certain observation from uniswap pool
    /// @param pool address of uniswap pool
    /// @param observationIndex index of wanted observation
    /// @return observation desired observation, see Observation to learn more
    function getObservation(address pool, uint observationIndex)
        internal
        view
        returns (Observation memory observation) 
    {
        (
            observation.blockTimestamp,
            observation.tickCumulative,
            observation.secondsPerLiquidityCumulativeX128,
            observation.initialized
        ) = IUniswapV3Pool(pool).observations(observationIndex);
    }

    /// @dev query latest and oldest observations from uniswap pool
    /// @param pool address of uniswap pool
    /// @param latestIndex index of latest observation in the pool
    /// @param observationCardinality size of observation queue in the pool
    /// @return oldestObservation
    /// @return latestObservation
    function getObservationBoundary(address pool, uint16 latestIndex, uint16 observationCardinality)
        internal
        view
        returns (Observation memory oldestObservation, Observation memory latestObservation)
    {
        uint16 oldestIndex = (latestIndex + 1) % observationCardinality;
        oldestObservation = pool.getObservation(oldestIndex);
        if (!oldestObservation.initialized) {
            oldestIndex = 0;
            oldestObservation = pool.getObservation(0);
        }
        if (latestIndex == oldestIndex) {
            // oldest observation is latest observation
            latestObservation = oldestObservation;
        } else {
            latestObservation = pool.getObservation(latestIndex);
        }
    }

    struct Slot0 {
        int24 tick;
        uint160 sqrtPriceX96;
        uint16 observationIndex;
        uint16 observationCardinality;
        uint16 observationCardinalityNext;
    }

    /// @dev view slot0 infomations from uniswap pool
    /// @param pool address of uniswap
    /// @return slot0 a Slot0 struct with necessary info, see Slot0 struct above
    function getSlot0(address pool) 
        internal
        view
        returns (Slot0 memory slot0) {
        (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            ,
        
        ) = IUniswapV3Pool(pool).slot0();
        slot0.tick = tick;
        slot0.sqrtPriceX96 = sqrtPriceX96;
        slot0.observationIndex = observationIndex;
        slot0.observationCardinality = observationCardinality;
        slot0.observationCardinalityNext = observationCardinalityNext;
    }

    // note if we call this interface, we must ensure that the 
    //    oldest observation preserved in pool is older than 2h ago
    function _getAvgTickFromTarget(address pool, uint32 targetTimestamp, int56 latestTickCumu, uint32 latestTimestamp)
        private
        view
        returns (int24 tick) 
    {
        uint32[] memory secondsAgo = new uint32[](1);
        secondsAgo[0] = uint32(block.timestamp) - targetTimestamp;

        int56[] memory tickCumulatives;
        
        (tickCumulatives,) = IUniswapV3Pool(pool).observe(secondsAgo);
        uint56 timeDelta = latestTimestamp - targetTimestamp;

        int56 tickAvg = (latestTickCumu - tickCumulatives[0]) / int56(timeDelta);
        tick = int24(tickAvg);
    }

    /// @dev compute avg tick and avg sqrt price of pool within one hour from now
    /// @param pool address of uniswap pool
    /// @return tick computed avg tick
    /// @return sqrtPriceX96 computed avg sqrt price, in the form of 96-bit fixed point number
    function getAvgTickPriceWithin2Hour(address pool)
        internal
        view
        returns (int24 tick, uint160 sqrtPriceX96, int24 currTick, uint160 currSqrtPriceX96)
    {
        Slot0 memory slot0 = pool.getSlot0();

        if (slot0.observationCardinality == 1) {
            // only 1 observation in the swap pool
            // we could simply return tick/sqrtPrice of slot0
            return (slot0.tick, slot0.sqrtPriceX96, slot0.tick, slot0.sqrtPriceX96);
        } else {
            // we will search the latest observation and the observation 1h ago 

            // 1st, we should get the boundary of the observations in the pool
            Observation memory oldestObservation;
            Observation memory latestObservation;
            (oldestObservation, latestObservation) = pool.getObservationBoundary(slot0.observationIndex, slot0.observationCardinality);
            
            if (oldestObservation.blockTimestamp == latestObservation.blockTimestamp) {
                // there is only 1 valid observation in the pool
                return (slot0.tick, slot0.sqrtPriceX96, slot0.tick, slot0.sqrtPriceX96);
            }
            uint32 twoHourAgo = uint32(block.timestamp - 7200);

            // now there must be at least 2 valid observations in the pool
            if (twoHourAgo <= oldestObservation.blockTimestamp || latestObservation.blockTimestamp <= oldestObservation.blockTimestamp + 3600) {
                // the oldest observation updated within 1h
                // we can not safely call IUniswapV3Pool.observe(...) for it 1h ago
                uint56 timeDelta = latestObservation.blockTimestamp - oldestObservation.blockTimestamp;
                int56 tickAvg = (latestObservation.tickCumulative - oldestObservation.tickCumulative) / int56(timeDelta);
                tick = int24(tickAvg);
            } else {
                // we are sure that the oldest observation is old enough
                // we can safely call IUniswapV3Pool.observe(...) for it 1h ago
                uint32 targetTimestamp = twoHourAgo;
                if (targetTimestamp + 3600 > latestObservation.blockTimestamp) {
                    targetTimestamp = latestObservation.blockTimestamp - 3600;
                }
                tick = _getAvgTickFromTarget(pool, targetTimestamp, latestObservation.tickCumulative, latestObservation.blockTimestamp);
            }
            sqrtPriceX96 = LogPowMath.getSqrtPrice(tick);
            return (tick, sqrtPriceX96, slot0.tick, slot0.sqrtPriceX96);
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../uniswap/interfaces.sol";
import "./Math.sol";

library UniswapCallingParams {
    // fill INonfungiblePositionManager.CollectParams struct to call INonfungiblePositionManager.collect(...)
    function collectParams(uint256 uniPositionID, address recipient)
        internal
        pure
        returns (INonfungiblePositionManager.CollectParams memory params)
    {
        params.tokenId = uniPositionID;
        params.recipient = recipient;
        params.amount0Max = 0xffffffffffffffffffffffffffffffff;
        params.amount1Max = 0xffffffffffffffffffffffffffffffff;
    }

    function decreaseLiquidityParams(
        uint256 uniPositionID,
        uint128 liquidity,
        uint256 deadline
    )
        internal
        pure
        returns (
            INonfungiblePositionManager.DecreaseLiquidityParams memory params
        )
    {
        params.tokenId = uniPositionID;
        params.liquidity = liquidity;
        params.amount0Min = 0;
        params.amount1Min = 0;
        params.deadline = deadline;
    }

    /// @dev fill INonfungiblePositionManager.MintParams struct to call INonfungiblePositionManager.mint(...)
    /// @param token0 one of token pair in uniswap pool, note here not necessary to ensure that token0 < token1
    /// @param token1 another token
    /// @param fee fee
    /// @param amount0 amount of token0
    /// @param amount1 amount of token1
    /// @param tickLeft tickLower
    /// @param tickRight tickUpper
    /// @param deadline deadline of mint calling
    /// @return params MintParams
    function mintParams(
        address token0,
        address token1,
        uint24 fee,
        uint256 amount0,
        uint256 amount1,
        int24 tickLeft,
        int24 tickRight,
        uint256 deadline
    )
        internal
        view
        returns (INonfungiblePositionManager.MintParams memory params)
    {
        params.fee = fee;
        params.tickLower = tickLeft;
        params.tickUpper = tickRight;
        params.deadline = deadline;
        params.recipient = address(this);
        params.amount0Min = 0;
        params.amount1Min = 0;
        if (token0 < token1) {
            params.token0 = token0;
            params.token1 = token1;
            params.amount0Desired = amount0;
            params.amount1Desired = amount1;
        } else {
            params.token0 = token1;
            params.token1 = token0;
            params.amount0Desired = amount1;
            params.amount1Desired = amount0;
        }
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;

// Uncomment if needed.
// import "hardhat/console.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

import "../libraries/FixedPoints.sol";
import "../libraries/Math.sol";
import "../uniswap/interfaces.sol";
import "../veiZi/interfaces.sol";
import "../multicall.sol";

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

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

abstract contract MiningBaseVeiZi is Ownable, Multicall, ReentrancyGuard {

    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.UintSet;

    /// @dev Last block number that the accRewardRerShare is touched.
    uint256 public lastTouchBlock;

    /// @dev The block number when NFT mining rewards starts/ends.
    uint256 public startBlock;
    uint256 public endBlock;
    struct RewardInfo {
        /// @dev Contract of the reward erc20 token.
        address rewardToken;
        /// @dev who provides reward
        address provider;
        /// @dev Accumulated Reward Tokens per share, times Q128.
        uint256 accRewardPerShare;
        /// @dev Reward amount for each block.
        uint256 rewardPerBlock;
    }

    mapping(uint256 => RewardInfo) public rewardInfos;
    uint256 public rewardInfosLen;

    /// @dev Store the owner of the NFT token
    mapping(uint256 => address) public owners;
    /// @dev The inverse mapping of owners.
    mapping(address => EnumerableSet.UintSet) internal tokenIds;

    /// @notice Current total virtual liquidity.
    uint256 public totalVLiquidity;

    uint256 public totalValidVeiZi;

    /// @notice (1 - feeRemainPercent/100) is charging rate of uniswap fee
    uint24 public feeRemainPercent;

    uint256 public totalFeeCharged0;
    uint256 public totalFeeCharged1;


    struct PoolInfo {
        address token0;
        address token1;
        uint24 fee;
    }

    PoolInfo public rewardPool;

    address public weth;

    address public chargeReceiver;

    /// @notice address of veiZi contract, address(0) for no boost
    address public veiZiAddress;

    /// @notice emit if user successfully deposit
    /// @param user user
    /// @param tokenId id of mining (same as uniswap nft token id)
    /// @param vLiquidity amount of vLiquidity in TokenStatus
    event Deposit(address indexed user, uint256 tokenId, uint256 vLiquidity);
    /// @notice emit if user successfully withdraw
    /// @param user user
    /// @param tokenId id of mining (same as uniswap nft token id)
    event Withdraw(address indexed user, uint256 tokenId);
    /// @notice emit if user successfully collect reward
    /// @param user user
    /// @param token address of reward erc-20 token
    /// @param amount amount of erc-20 token user received 
    event CollectReward(address indexed user, address token, uint256 amount);
    /// @notice emit if contract owner successfully calls modifyEndBlock(...)
    /// @param endBlock endBlock 
    event ModifyEndBlock(uint256 endBlock);
    /// @notice emit if contract owner successfully calls modifyRewardPerBlock(...)
    /// @param rewardToken address of reward erc20-token
    /// @param rewardPerBlock new reward per block of 'rewardToken'
    event ModifyRewardPerBlock(address indexed rewardToken, uint256 rewardPerBlock);
    /// @notice emit if contract owner successfully calls modifyProvider(...)
    /// @param rewardToken address of reward erc20-token
    /// @param provider New provider
    event ModifyProvider(address indexed rewardToken, address provider);

    bool public normal;
    modifier checkNormal() {
        require(normal, "has emergency withrawed");
        _;
    }

    function _setRewardPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) internal {
        (rewardPool.token0, rewardPool.token1) = (tokenA < tokenB)? (tokenA, tokenB) : (tokenB, tokenA);
        rewardPool.fee = fee;
        totalFeeCharged0 = 0;
        totalFeeCharged1 = 0;
    }

    constructor(
        uint24 _feeChargePercent, address _uniV3NFTManager, address _veiZiAddress, address tokenA, address tokenB, uint24 fee, address _chargeReceiver, uint256 _totalValidVeiZi
    ) {
        require(_feeChargePercent <= 100, "charge percent <= 100");
        feeRemainPercent = 100 - _feeChargePercent;
        // mark weth erc token
        weth = INonfungiblePositionManager(_uniV3NFTManager).WETH9();
        // receiver to receive charged uniswap fee
        chargeReceiver = _chargeReceiver;
        veiZiAddress = _veiZiAddress;
        _setRewardPool(tokenA, tokenB, fee);

        totalValidVeiZi = _totalValidVeiZi; // start totalValidVeiZi cannot be 0, otherwise all validVeiZi will be 0
        normal = true;
    }

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

    function _safeTransferToken(address token, address to, uint256 value) internal {
        if (value > 0) {
            if (token == address(weth)) {
                IWETH9(token).withdraw(value);
                _safeTransferETH(to, value);
            } else {
                IERC20(token).safeTransfer(to, value);
            }
        }
    }

    /// @notice Update reward variables to be up-to-date.
    /// @param vLiquidity vLiquidity to add or minus
    /// @param isAdd add or minus
    function _updateVLiquidity(uint256 vLiquidity, bool isAdd) internal {
        if (isAdd) {
            totalVLiquidity = totalVLiquidity + vLiquidity;
        } else {
            totalVLiquidity = totalVLiquidity - vLiquidity;
        }

        // max lockBoostMultiplier is 3
        require(totalVLiquidity <= FixedPoints.Q128 * 3, "TOO MUCH LIQUIDITY STAKED");
    }

    /// @notice Update the global status.
    function _updateGlobalStatus() internal {
        if (block.number <= lastTouchBlock) {
            return;
        }
        if (lastTouchBlock >= endBlock) {
            return;
        }
        uint256 currBlockNumber = Math.min(block.number, endBlock);
        if (totalVLiquidity == 0) {
            lastTouchBlock = currBlockNumber;
            return;
        }

        for (uint256 i = 0; i < rewardInfosLen; i++) {
            // tokenReward < 2^25 * 2^64 * 2*10, 15 years, 1000 r/block
            uint256 tokenReward = (currBlockNumber - lastTouchBlock) * rewardInfos[i].rewardPerBlock;
            // tokenReward * Q128 < 2^(25 + 64 + 10 + 128)
            rewardInfos[i].accRewardPerShare = rewardInfos[i].accRewardPerShare + ((tokenReward * FixedPoints.Q128) / totalVLiquidity);
        }
        lastTouchBlock = currBlockNumber;
    }

    struct UserStatus {
        // whether the UserStatus is inited
        bool inited;
        // total vLiquidity of the user's nft
        uint256 vLiquidity;
        uint256 validVLiquidity;
        uint256 veiZi;
        uint256 veStakingId;
        uint256 validVeiZi;
        uint256[] lastTouchAccRewardPerShare;
    }

    mapping(address => UserStatus) public userStatus;

    struct BoostInfo {
        uint256 oldValidVLiquidity;
        uint256 veStakingId;
        uint256 veiZi;
    }

    function _checkDoubleSpendingWithBoostInfo(UserStatus memory user, address userAddr) internal view returns(BoostInfo memory boostInfo) {
        if (veiZiAddress == address(0)) {
            boostInfo.veStakingId = 0;
            boostInfo.veiZi = 0;
            boostInfo.oldValidVLiquidity = user.validVLiquidity;
        } else {
            (, boostInfo.veStakingId, boostInfo.veiZi) = IVeiZi(veiZiAddress).stakingInfo(userAddr);
            if (user.veStakingId == 0) {
                // no boosting before, return origin validVLiquidity
                boostInfo.oldValidVLiquidity = user.validVLiquidity;
            } else if (boostInfo.veStakingId != user.veStakingId) {
                // double spending
                boostInfo.oldValidVLiquidity = user.vLiquidity * 4 / 10;
            } else {
                // veStakingId unchanged
                boostInfo.oldValidVLiquidity = user.validVLiquidity;
            }
        }
    }

    function _collectUserReward(address userAddr, bool noReward) internal {
        _updateGlobalStatus();
        UserStatus storage user = userStatus[userAddr];
        if (!user.inited) {
            // first time to access
            user.inited = true;
            user.lastTouchAccRewardPerShare = new uint256[](rewardInfosLen);
            for (uint256 i = 0; i < rewardInfosLen; i ++) {
                user.lastTouchAccRewardPerShare[i] = rewardInfos[i].accRewardPerShare;
            }
        }
        if (user.vLiquidity == 0) {
            for (uint256 i = 0; i < rewardInfosLen; i ++) {
                user.lastTouchAccRewardPerShare[i] = rewardInfos[i].accRewardPerShare;
            }
        }
        BoostInfo memory boostInfo = _checkDoubleSpendingWithBoostInfo(user, userAddr);

        for (uint256 i = 0; i < rewardInfosLen; i ++) {
            // note we use oldValidVLiquidity to prevent double spending of veiZi
            uint256 tokenReward = (rewardInfos[i].accRewardPerShare - user.lastTouchAccRewardPerShare[i]) * boostInfo.oldValidVLiquidity / FixedPoints.Q128;
            if (tokenReward > 0 && !noReward) {
                IERC20(rewardInfos[i].rewardToken).safeTransferFrom(
                    rewardInfos[i].provider,
                    msg.sender,
                    tokenReward
                );
                emit CollectReward(
                    msg.sender,
                    rewardInfos[i].rewardToken,
                    tokenReward
                );
            }
            user.lastTouchAccRewardPerShare[i] = rewardInfos[i].accRewardPerShare;
        }

        user.validVLiquidity = boostInfo.oldValidVLiquidity;
        user.veiZi = boostInfo.veiZi;
        user.veStakingId = boostInfo.veStakingId;

        user.validVeiZi = _updateTotalAndComputeValidVeiZi(user.validVeiZi, user.veiZi, user.vLiquidity);
        user.validVLiquidity = _computeValidVLiquidity(user.vLiquidity, user.veiZi);

    }

    /// @notice compute validVeiZi and update totalValidVeiZi, this function must be called after totalVLiquidity updated
    /// @dev totalValidVeiZi will be updated
    /// @param originValidVeiZi origin validVeiZi, 0 if newly deposit
    /// @param veiZi veiZi of this user queried from veiZi contract
    /// @param vLiquidity vLiquidity of mining
    /// @return validVeiZi computed validVeiZi for this mining
    function _updateTotalAndComputeValidVeiZi(uint256 originValidVeiZi, uint256 veiZi, uint256 vLiquidity) internal returns(uint256 validVeiZi) {
        totalValidVeiZi -= originValidVeiZi;
        if (totalVLiquidity == 0) {
            validVeiZi = 0;
        } else {
            // note vLiquidity < Q128
            validVeiZi = Math.min(veiZi, 2 * totalValidVeiZi * vLiquidity / totalVLiquidity);
            totalValidVeiZi += validVeiZi;
        }
    }

    /// @notice compute validVLiquidity
    /// @param vLiquidity origin vLiquidity
    /// @param veiZi amount of user's veiZi
    function _computeValidVLiquidity(uint256 vLiquidity, uint256 veiZi) internal virtual view returns (uint256 validVLiquidity) {
        if (totalValidVeiZi == 0) {
            validVLiquidity = vLiquidity;
        } else {
            uint256 iZiVLiquidity = vLiquidity * 4 / 10 + totalVLiquidity * veiZi / totalValidVeiZi * 6 / 10;
            validVLiquidity = Math.min(iZiVLiquidity, vLiquidity);
        }
    }

    /// @notice View function to get position ids staked here for an user.
    /// @param _user The related address.
    /// @return list of tokenId
    function getTokenIds(address _user)
        external
        view
        returns (uint256[] memory)
    {
        EnumerableSet.UintSet storage ids = tokenIds[_user];
        // push could not be used in memory array
        // we set the tokenIdList into a fixed-length array rather than dynamic
        uint256[] memory tokenIdList = new uint256[](ids.length());
        for (uint256 i = 0; i < ids.length(); i++) {
            tokenIdList[i] = ids.at(i);
        }
        return tokenIdList;
    }
    
    /// @notice Return reward multiplier over the given _from to _to block.
    /// @param _from The start block.
    /// @param _to The end block.
    function _getRewardBlockNum(uint256 _from, uint256 _to)
        internal
        view
        returns (uint256)
    {
        if (_from > _to) {
            return 0;
        }
        if (_to <= endBlock) {
            return _to - _from;
        } else if (_from >= endBlock) {
            return 0;
        } else {
            return endBlock - _from;
        }
    }

    /// @notice View function to see pending Rewards for an address.
    /// @param userAddr The related address.
    /// @return list of pending reward amount for each reward ERC20-token of this user
    function pendingRewards(address userAddr)
        public
        view
        returns (uint256[] memory)
    {
        uint256[] memory _reward = new uint256[](rewardInfosLen);
        UserStatus memory user = userStatus[userAddr];
        if (user.vLiquidity == 0) {
            for (uint256 i = 0; i < rewardInfosLen; i ++) {
                _reward[i] = 0;
            }
            return _reward;
        }
        BoostInfo memory boostInfo = _checkDoubleSpendingWithBoostInfo(user, userAddr);
        for (uint256 i = 0; i < rewardInfosLen; i++) {
            uint256 globalReward = _getRewardBlockNum(
                lastTouchBlock,
                block.number
            ) * rewardInfos[i].rewardPerBlock;
            uint256 globalRewardPerShare = rewardInfos[i].accRewardPerShare + (globalReward * FixedPoints.Q128) / totalVLiquidity;
            // here we use boostInfo.oldValidVLiquidity to prevent double spending of veiZi
            _reward[i] = (globalRewardPerShare - user.lastTouchAccRewardPerShare[i]) * boostInfo.oldValidVLiquidity / FixedPoints.Q128;
        }
        return _reward;
    }

    // Control fuctions for the contract owner and operators.

    /// @notice If something goes wrong, we can send back user's nft and locked assets
    /// @param tokenId The related position id.
    function emergenceWithdraw(uint256 tokenId) external virtual;

    /// @notice Set new reward end block.
    /// @param _endBlock New end block.
    function modifyEndBlock(uint256 _endBlock) external onlyOwner {
        require(_endBlock > block.number, "OUT OF DATE");
        _updateGlobalStatus();
        // jump if origin endBlock < block.number
        lastTouchBlock = block.number;
        endBlock = _endBlock;
        emit ModifyEndBlock(endBlock);
    }

    /// @notice Set new reward per block.
    /// @param rewardIdx which rewardInfo to modify
    /// @param _rewardPerBlock new reward per block
    function modifyRewardPerBlock(uint256 rewardIdx, uint256 _rewardPerBlock)
        external
        onlyOwner
    {
        require(rewardIdx < rewardInfosLen, "OUT OF REWARD INFO RANGE");
        _updateGlobalStatus();
        rewardInfos[rewardIdx].rewardPerBlock = _rewardPerBlock;
        emit ModifyRewardPerBlock(
            rewardInfos[rewardIdx].rewardToken,
            _rewardPerBlock
        );
    }


    /// @notice Set new reward provider.
    /// @param rewardIdx which rewardInfo to modify
    /// @param provider New provider
    function modifyProvider(uint256 rewardIdx, address provider)
        external
        onlyOwner
    {
        require(rewardIdx < rewardInfosLen, "OUT OF REWARD INFO RANGE");
        rewardInfos[rewardIdx].provider = provider;
        emit ModifyProvider(rewardInfos[rewardIdx].rewardToken, provider);
    }

    function modifyChargeReceiver(address _chargeReceiver) external onlyOwner {
        chargeReceiver = _chargeReceiver;
    }

    function collectFeeCharged() external nonReentrant {
        require(msg.sender == chargeReceiver, "NOT RECEIVER");
        _safeTransferToken(rewardPool.token0, chargeReceiver, totalFeeCharged0);
        _safeTransferToken(rewardPool.token1, chargeReceiver, totalFeeCharged1);
        totalFeeCharged0 = 0;
        totalFeeCharged1 = 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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");

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IUniswapV3Pool {
    function slot0()
    external
    view
    returns (
        uint160 sqrtPriceX96,
        int24 tick,
        uint16 observationIndex,
        uint16 observationCardinality,
        uint16 observationCardinalityNext,
        uint8 feeProtocol,
        bool unlocked
    );
    
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );

    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
}

interface IUniswapV3Factory {

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

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

}

interface INonfungiblePositionManager {

    /// @return Returns the address of the Uniswap V3 factory
    function factory() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
    struct Position {
        uint96 nonce;
        address operator;
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint128 liquidity;
        uint256 feeGrowthInside0LastX128;
        uint256 feeGrowthInside1LastX128;
        uint128 tokensOwed0;
        uint128 tokensOwed1;
    }
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );
    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }
    
    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

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

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

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

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

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    function ownerOf(uint256 tokenId) external view returns (address);

    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;


library LogPowMath {

    int24 internal constant MIN_POINT = -887272;

    int24 internal constant MAX_POINT = -MIN_POINT;


    uint160 internal constant MIN_SQRT_PRICE = 4295128739;

    uint160 internal constant MAX_SQRT_PRICE = 1461446703485210103287273052203988822378723970342;

    /// @notice sqrt(1.0001^point) in form oy 96-bit fix point num
    function getSqrtPrice(int24 point) internal pure returns (uint160 sqrtPrice_96) {
        uint256 absIdx = point < 0 ? uint256(-int256(point)) : uint256(int256(point));
        require(absIdx <= uint256(int256(MAX_POINT)), 'T');

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

        if (point > 0) value = type(uint256).max / value;

        sqrtPrice_96 = uint160((value >> 32) + (value % (1 << 32) == 0 ? 0 : 1));
    }

    // floor(log1.0001(sqrtPrice_96))
    function getLogSqrtPriceFloor(uint160 sqrtPrice_96) internal pure returns (int24 logValue) {
        // second inequality must be < because the price can nevex reach the price at the max tick
        require(sqrtPrice_96 >= MIN_SQRT_PRICE && sqrtPrice_96 < MAX_SQRT_PRICE, 'R');
        uint256 sqrtPrice_128 = uint256(sqrtPrice_96) << 32;

        uint256 x = sqrtPrice_128;
        uint256 m = 0;

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

        if (m >= 128) x = sqrtPrice_128 >> (m - 127);
        else x = sqrtPrice_128 << (127 - m);

        int256 l2 = (int256(m) - 128) << 64;

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

        int256 ls10001 = l2 * 255738958999603826347141;

        int24 logFloor = int24((ls10001 - 3402992956809132418596140100660247210) >> 128);
        int24 logUpper = int24((ls10001 + 291339464771989622907027621153398088495) >> 128);

        logValue = logFloor == logUpper ? logFloor : getSqrtPrice(logUpper) <= sqrtPrice_96 ? logUpper : logFloor;
    }

    function getLogSqrtPriceFU(uint160 sqrtPrice_96) internal pure returns (int24 logFloor, int24 logUpper) {
        // second inequality must be < because the price can nevex reach the price at the max tick
        require(sqrtPrice_96 >= MIN_SQRT_PRICE && sqrtPrice_96 < MAX_SQRT_PRICE, 'R');
        uint256 sqrtPrice_128 = uint256(sqrtPrice_96) << 32;

        uint256 x = sqrtPrice_128;
        uint256 m = 0;

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

        if (m >= 128) x = sqrtPrice_128 >> (m - 127);
        else x = sqrtPrice_128 << (127 - m);

        int256 l2 = (int256(m) - 128) << 64;

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

        int256 ls10001 = l2 * 255738958999603826347141;

        logFloor = int24((ls10001 - 3402992956809132418596140100660247210) >> 128);
        logUpper = int24((ls10001 + 291339464771989622907027621153398088495) >> 128);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @title Simple math library for Max and Min.
library Math {
    function max(int24 a, int24 b) internal pure returns (int24) {
        return a >= b ? a : b;
    }

    function min(int24 a, int24 b) internal pure returns (int24) {
        return a < b ? a : b;
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    function tickFloor(int24 tick, int24 tickSpacing)
        internal
        pure
        returns (int24)
    {
        int24 c = tick / tickSpacing;
        if (tick < 0 && tick % tickSpacing != 0) {
            c = c - 1;
        }
        c = c * tickSpacing;
        return c;
    }

    function tickUpper(int24 tick, int24 tickSpacing)
        internal
        pure
        returns (int24)
    {
        int24 c = tick / tickSpacing;
        if (tick > 0 && tick % tickSpacing != 0) {
            c = c + 1;
        }
        c = c * tickSpacing;
        return c;
    }
}

File 17 of 19 : FixedPoints.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

library FixedPoints {
    uint256 constant Q32 = (1 << 32);
    uint256 constant Q64 = (1 << 64);
    uint256 constant Q96 = (1 << 96);
    uint256 constant Q128 = (1 << 128);
    uint256 constant Q160 = (1 << 160);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IVeiZi {
    
    function stakingInfo(address user)
        external
        view
        returns (
            uint256 nftId, 
            uint256 stakeId,
            uint256 amount
        );
    
}

File 19 of 19 : multicall.sol
//  SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

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

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

            results[i] = result;
        }
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"components":[{"internalType":"address","name":"uniV3NFTManager","type":"address"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"internalType":"struct MiningDynamicRangeBoostVeiZi.PoolParams","name":"poolParams","type":"tuple"},{"components":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"provider","type":"address"},{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"internalType":"struct MiningBaseVeiZi.RewardInfo[]","name":"_rewardInfos","type":"tuple[]"},{"internalType":"address","name":"_veiZiAddress","type":"address"},{"internalType":"uint256","name":"_startBlock","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"uint24","name":"feeChargePercent","type":"uint24"},{"internalType":"address","name":"_chargeReceiver","type":"address"},{"internalType":"int24","name":"_tickRangeLeft","type":"int24"},{"internalType":"int24","name":"_tickRangeRight","type":"int24"},{"internalType":"uint256","name":"_totalValidVeiZi","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CollectReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vLiquidity","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"}],"name":"ModifyEndBlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"ModifyProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"name":"ModifyRewardPerBlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"chargeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectAllTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectFeeCharged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"int24","name":"stdTick","type":"int24"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"emergenceWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRemainPercent","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMiningContractInfo","outputs":[{"internalType":"address","name":"token0_","type":"address"},{"internalType":"address","name":"token1_","type":"address"},{"internalType":"uint24","name":"fee_","type":"uint24"},{"internalType":"address","name":"veiZiAddress_","type":"address"},{"internalType":"uint256","name":"lastTouchBlock_","type":"uint256"},{"internalType":"uint256","name":"totalVLiquidity_","type":"uint256"},{"internalType":"uint256","name":"totalToken0_","type":"uint256"},{"internalType":"uint256","name":"totalToken1_","type":"uint256"},{"internalType":"uint256","name":"totalValidVeiZi_","type":"uint256"},{"internalType":"uint256","name":"startBlock_","type":"uint256"},{"internalType":"uint256","name":"endBlock_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOraclePrice","outputs":[{"internalType":"int24","name":"avgTick","type":"int24"},{"internalType":"uint160","name":"avgSqrtPriceX96","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTouchBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_chargeReceiver","type":"address"}],"name":"modifyChargeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endBlock","type":"uint256"}],"name":"modifyEndBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardIdx","type":"uint256"},{"internalType":"address","name":"provider","type":"address"}],"name":"modifyProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardIdx","type":"uint256"},{"internalType":"uint256","name":"_rewardPerBlock","type":"uint256"}],"name":"modifyRewardPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"normal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"owners","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddr","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardInfos","outputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"provider","type":"address"},{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardInfosLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPool","outputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tickRangeLeft","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tickRangeRight","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0IsETH","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1IsETH","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenStatus","outputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"vLiquidity","type":"uint256"},{"internalType":"uint256","name":"uniLiquidity","type":"uint256"},{"internalType":"uint256","name":"lastTouchBlock","type":"uint256"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFeeCharged0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFeeCharged1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalToken0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalToken1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValidVeiZi","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniV3NFTManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userStatus","outputs":[{"internalType":"bool","name":"inited","type":"bool"},{"internalType":"uint256","name":"vLiquidity","type":"uint256"},{"internalType":"uint256","name":"validVLiquidity","type":"uint256"},{"internalType":"uint256","name":"veiZi","type":"uint256"},{"internalType":"uint256","name":"veStakingId","type":"uint256"},{"internalType":"uint256","name":"validVeiZi","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veiZiAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"noReward","type":"bool"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

0x60806040523480156200001157600080fd5b5060405162005a8d38038062005a8d833981016040819052620000349162000d68565b848a60000151898c602001518d604001518e60600151898762000066620000606200066c60201b60201c565b62000670565b60018055606462ffffff89161115620000c65760405162461bcd60e51b815260206004820152601560248201527f6368617267652070657263656e74203c3d20313030000000000000000000000060448201526064015b60405180910390fd5b620000d388606462000ffa565b600b60006101000a81548162ffffff021916908362ffffff160217905550866001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200012b57600080fd5b505afa15801562000140573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000166919062000d2c565b601080546001600160a01b03199081166001600160a01b039384161790915560118054821685841617905560128054909116918816919091179055620001ae858585620006c0565b600a5550506012805460ff60a01b1916600160a01b17905550508c51601780546001600160a01b039283166001600160a01b0319909116179055600f54600e549082169116109250620002479150505760405162461bcd60e51b815260206004820152601960248201527f544f4b454e30203c20544f4b454e31204e4f54204d41544348000000000000006044820152606401620000bd565b601760009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156200029657600080fd5b505afa158015620002ab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002d1919062000d2c565b601880546001600160a01b0319166001600160a01b03928316179055601054600e5460148054600f5461ffff60301b1990911692851693851684811466010000000000000260ff60381b19169390931790851692909214670100000000000000029190911790556017546200035692166000196200073a602090811b62001ea117901c565b601754600f5462000383916001600160a01b0391821691166000196200073a602090811b62001ea117901c565b601854600e54600f54604051630b4c774160e11b81526001600160a01b0392831660048201528282166024820152600160a01b90910462ffffff166044820152911690631698ee829060640160206040518083038186803b158015620003e857600080fd5b505afa158015620003fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000423919062000d2c565b601980546001600160a01b0319166001600160a01b039290921691821790556200047e5760405162461bcd60e51b815260206004820152600b60248201526a1393c8155392481413d3d360aa1b6044820152606401620000bd565b6032620004ab601960009054906101000a90046001600160a01b03166200089960201b62001ffd1760201c565b6080015161ffff161015620004e95760405162461bcd60e51b815260206004820152600360248201526221a0a960e91b6044820152606401620000bd565b885160068190556200052a5760405162461bcd60e51b81526020600482015260096024820152681393c8149155d0549160ba1b6044820152606401620000bd565b600360065410620005725760405162461bcd60e51b81526020600482015260116024820152704154204d4f53542032205245574152445360781b6044820152606401620000bd565b60005b6006548110156200061157898181518110620005a157634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008381526005835260408120825181546001600160a01b03199081166001600160a01b0392831617835594840151600183018054909616911617909355606090910151600383015560029091015580620006088162001054565b91505062000575565b5050600386905560049490945560029485556000600981905560158190556016556014805494860b62ffffff90811663010000000265ffffffffffff199096169290960b909516179290921790925550620010b79350505050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b816001600160a01b0316836001600160a01b031610620006e2578183620006e5565b82825b600f8054600e80546001600160a01b039586166001600160a01b031990911617905562ffffff94909416600160a01b026001600160b81b0319909416919092161791909117905550506000600c819055600d55565b801580620007c85750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156200078b57600080fd5b505afa158015620007a0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007c6919062000f30565b155b6200083c5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401620000bd565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620008949185916200098116565b505050565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526000806000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156200090657600080fd5b505afa1580156200091b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000941919062000e94565b5050600293840b90930b8a526001600160a01b0390931660208a015261ffff90811660408a01529182166060890152166080870152509395945050505050565b6000620009dd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000a5f60201b620020e1179092919060201c565b805190915015620008945780806020019051810190620009fe919062000d4b565b620008945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620000bd565b606062000a70848460008562000a7a565b90505b9392505050565b60608247101562000add5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620000bd565b6001600160a01b0385163b62000b365760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620000bd565b600080866001600160a01b0316858760405162000b54919062000f49565b60006040518083038185875af1925050503d806000811462000b93576040519150601f19603f3d011682016040523d82523d6000602084013e62000b98565b606091505b50909250905062000bab82828662000bb6565b979650505050505050565b6060831562000bc757508162000a73565b82511562000bd85782518084602001fd5b8160405162461bcd60e51b8152600401620000bd919062000f67565b805162000c01816200109e565b919050565b600082601f83011262000c17578081fd5b815160206001600160401b0382111562000c355762000c3562001088565b62000c45818360051b0162000fc7565b80838252828201915082860187848660071b890101111562000c65578586fd5b855b8581101562000cd457608080838b03121562000c81578788fd5b62000c8b62000f9c565b835162000c98816200109e565b81528387015162000ca9816200109e565b8188015260408481015190820152606080850151908201528552938501939091019060010162000c67565b5090979650505050505050565b8051801515811462000c0157600080fd5b8051600281900b811462000c0157600080fd5b805161ffff8116811462000c0157600080fd5b805162ffffff8116811462000c0157600080fd5b60006020828403121562000d3e578081fd5b815162000a73816200109e565b60006020828403121562000d5d578081fd5b62000a738262000ce1565b6000806000806000806000806000808a8c036101a081121562000d89578687fd5b608081121562000d97578687fd5b5062000da262000f9c565b8b5162000daf816200109e565b815260208c015162000dc1816200109e565b602082015260408c015162000dd6816200109e565b604082015262000de960608d0162000d18565b606082015260808c0151909a506001600160401b0381111562000e0a578687fd5b62000e188d828e0162000c06565b99505062000e2960a08c0162000bf4565b975060c08b0151965060e08b0151955062000e486101008c0162000d18565b945062000e596101208c0162000bf4565b935062000e6a6101408c0162000cf2565b925062000e7b6101608c0162000cf2565b91506101808b015190509295989b9194979a5092959850565b600080600080600080600060e0888a03121562000eaf578283fd5b875162000ebc816200109e565b965062000ecc6020890162000cf2565b955062000edc6040890162000d05565b945062000eec6060890162000d05565b935062000efc6080890162000d05565b925060a088015160ff8116811462000f12578283fd5b915062000f2260c0890162000ce1565b905092959891949750929550565b60006020828403121562000f42578081fd5b5051919050565b6000825162000f5d81846020870162001021565b9190910192915050565b602081526000825180602084015262000f8881604085016020870162001021565b601f01601f19169190910160400192915050565b604051608081016001600160401b038111828210171562000fc15762000fc162001088565b60405290565b604051601f8201601f191681016001600160401b038111828210171562000ff25762000ff262001088565b604052919050565b600062ffffff8381169083168181101562001019576200101962001072565b039392505050565b60005b838110156200103e57818101518382015260200162001024565b838111156200104e576000848401525b50505050565b60006000198214156200106b576200106b62001072565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114620010b457600080fd5b50565b6149c680620010c76000396000f3fe60806040526004361061026b5760003560e01c8063979ae58911610144578063b74d60a9116100b6578063d1c924a51161007a578063d1c924a5146108a6578063d62dd3a614610966578063d7158cd414610986578063d8cd50e21461099c578063f2fde38b146109bc578063fd255aef146109dc57600080fd5b8063b74d60a91461081a578063c772ec7c1461082f578063cc69f75e14610845578063cd785a5e14610866578063d004b0361461088657600080fd5b80639f04d135116101085780639f04d13514610710578063a529650d14610726578063a9a3f1a914610739578063ac9650d81461075d578063b01ce31f1461077d578063b532a3e2146107fa57600080fd5b8063979ae58914610662578063982697dd146106975780639a174591146106b75780639ac8eebc146106cd5780639cc0b102146106e357600080fd5b806348cd4cb1116101dd578063715018a6116101a1578063715018a61461054857806376771d4b1461055d578063796da7af1461057d57806380abfda8146105b457806389d6517f146105ca5780638da5cb5b1461064457600080fd5b806348cd4cb11461046b5780634c878ef7146104815780635e1b9e3a146104975780635f9de944146104c757806366666aa9146104e757600080fd5b80632e0c5ca21161022f5780632e0c5ca2146103a957806330c47752146103c957806331d7a262146103de57806338d074361461040b5780633a6edcce1461042b5780633fc8cef31461044b57600080fd5b8063025e7c2714610277578063083c6323146102ca5780631ed262de146102ee578063225d29a1146103045780632d6730db1461038757600080fd5b3661027257005b600080fd5b34801561028357600080fd5b506102ad61029236600461405b565b6007602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102d657600080fd5b506102e060045481565b6040519081526020016102c1565b3480156102fa57600080fd5b506102e0600a5481565b34801561031057600080fd5b5061035861031f366004613dad565b60136020526000908152604090208054600182015460028301546003840154600485015460059095015460ff9094169492939192909186565b6040805196151587526020870195909552938501929092526060840152608083015260a082015260c0016102c1565b34801561039357600080fd5b506103a76103a2366004614126565b6109fd565b005b3480156103b557600080fd5b506103a76103c436600461408b565b610adf565b3480156103d557600080fd5b506103a7610bbc565b3480156103ea57600080fd5b506103fe6103f9366004613dad565b610c48565b6040516102c191906142ea565b34801561041757600080fd5b506103a76104263660046140ba565b610ee0565b34801561043757600080fd5b506103a7610446366004613dad565b6113dc565b34801561045757600080fd5b506010546102ad906001600160a01b031681565b34801561047757600080fd5b506102e060035481565b34801561048d57600080fd5b506102e0600c5481565b3480156104a357600080fd5b50600b546104b39062ffffff1681565b60405162ffffff90911681526020016102c1565b3480156104d357600080fd5b506012546102ad906001600160a01b031681565b3480156104f357600080fd5b50600e54600f5461051d916001600160a01b039081169190811690600160a01b900462ffffff1683565b604080516001600160a01b03948516815293909216602084015262ffffff16908201526060016102c1565b34801561055457600080fd5b506103a7611428565b34801561056957600080fd5b506018546102ad906001600160a01b031681565b34801561058957600080fd5b5061059261145e565b6040805160029390930b83526001600160a01b039091166020830152016102c1565b3480156105c057600080fd5b506102e060165481565b3480156105d657600080fd5b506106196105e536600461405b565b60056020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b0395861681529490931660208501529183015260608201526080016102c1565b34801561065057600080fd5b506000546001600160a01b03166102ad565b34801561066e57600080fd5b5060145461068790670100000000000000900460ff1681565b60405190151581526020016102c1565b3480156106a357600080fd5b506019546102ad906001600160a01b031681565b3480156106c357600080fd5b506102e060065481565b3480156106d957600080fd5b506102e060095481565b3480156106ef57600080fd5b506014546106fd9060020b81565b60405160029190910b81526020016102c1565b34801561071c57600080fd5b506102e060025481565b6103a761073436600461416a565b611483565b34801561074557600080fd5b50601454610687906601000000000000900460ff1681565b61077061076b366004613dc9565b611959565b6040516102c19190614289565b34801561078957600080fd5b506107cd61079836600461405b565b601a60205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909186565b604080519687526020870195909552938501929092526060840152608083015260a082015260c0016102c1565b34801561080657600080fd5b506017546102ad906001600160a01b031681565b34801561082657600080fd5b506103a7611adb565b34801561083b57600080fd5b506102e0600d5481565b34801561085157600080fd5b506014546106fd906301000000900460020b81565b34801561087257600080fd5b506103a761088136600461405b565b611b9c565b34801561089257600080fd5b506103fe6108a1366004613dad565b611c80565b3480156108b257600080fd5b506108fb600e54600f54600254600954601554601654600a546003546004546001600160a01b039889169998881698600160a01b90980462ffffff169760009796959493929190565b604080516001600160a01b039c8d1681529a8c1660208c015262ffffff909916988a0198909852989095166060880152608087019390935260a086019190915260c085015260e0840152610100830152610120820192909252610140810191909152610160016102c1565b34801561097257600080fd5b506103a761098136600461405b565b611d58565b34801561099257600080fd5b506102e060155481565b3480156109a857600080fd5b506011546102ad906001600160a01b031681565b3480156109c857600080fd5b506103a76109d7366004613dad565b611e06565b3480156109e857600080fd5b5060125461068790600160a01b900460ff1681565b6000546001600160a01b03163314610a305760405162461bcd60e51b8152600401610a279061437f565b60405180910390fd5b6006548210610a7c5760405162461bcd60e51b81526020600482015260186024820152774f5554204f462052455741524420494e464f2052414e474560401b6044820152606401610a27565b610a846120fa565b600082815260056020908152604091829020600381018490555491518381526001600160a01b03909216917fd9a745381d3899e0a1380f3c7f56ea1bf0fb8331482527ff4984296da9580fab91015b60405180910390a25050565b6000546001600160a01b03163314610b095760405162461bcd60e51b8152600401610a279061437f565b6006548210610b555760405162461bcd60e51b81526020600482015260186024820152774f5554204f462052455741524420494e464f2052414e474560401b6044820152606401610a27565b6000828152600560209081526040918290206001810180546001600160a01b0319166001600160a01b038681169182179092559154935191825292909216917fda608212a78120f0e323cf82e77003c28512aa6eae3747c062c459901d7930159101610ad3565b60026001541415610bdf5760405162461bcd60e51b8152600401610a27906143b4565b6002600155601254600160a01b900460ff16610c375760405162461bcd60e51b81526020600482015260176024820152761a185cc8195b595c99d95b98de481dda5d1a1c985dd959604a1b6044820152606401610a27565b610c423360006121cd565b60018055565b6060600060065467ffffffffffffffff811115610c7557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c9e578160200160208202803683370190505b506001600160a01b0384166000908152601360209081526040808320815160e081018352815460ff16151581526001820154818501526002820154818401526003820154606082015260048201546080820152600582015460a082015260068201805484518187028101870190955280855296975094959094919360c0860193929190830182828015610d5057602002820191906000526020600020905b815481526020019060010190808311610d3c575b5050505050815250509050806020015160001415610dbd5760005b600654811015610db4576000838281518110610d9757634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610dac81614855565b915050610d6b565b50909392505050565b6000610dc982866125aa565b905060005b600654811015610ed657600081815260056020526040812060030154600254610df790436126d8565b610e019190614742565b90506000600954600160801b83610e189190614742565b610e2291906146a5565b600084815260056020526040902060020154610e3e91906145ff565b9050600160801b84600001518660c001518581518110610e6e57634e487b7160e01b600052603260045260246000fd5b602002602001015183610e8191906147ed565b610e8b9190614742565b610e9591906146a5565b868481518110610eb557634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080610ece90614855565b915050610dce565b5091949350505050565b60026001541415610f035760405162461bcd60e51b8152600401610a27906143b4565b60026001556000828152600760205260409020546001600160a01b03163314610f675760405162461bcd60e51b81526020600482015260166024820152751393d50813d5d391548813d4881393d50811561254d560521b6044820152606401610a27565b610f86338280610f815750601254600160a01b900460ff16155b6121cd565b6000601a60008481526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815250509050806080015160156000828254610ffa91906147ed565b909155505060a0810151601680546000906110169084906147ed565b9091555050602081015161102b906000612723565b33600090815260136020908152604090912090820151600182015461105091906147ed565b600182018190556005820154600383015461106a926127b5565b600582015560018101546003820154611083919061282d565b600282015560175460009081906001600160a01b031663fc6f78656110a888306128a9565b6040518263ffffffff1660e01b81526004016110c491906143eb565b6040805180830381600087803b1580156110dd57600080fd5b505af11580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190614147565b600b5491935091506000906064906111329062ffffff1685614742565b61113c91906146a5565b600b549091506000906064906111579062ffffff1685614742565b61116191906146a5565b600e5490915061117b906001600160a01b031633846128dd565b600f54611192906001600160a01b031633836128dd565b61119c82856147ed565b600c60008282546111ad91906145ff565b909155506111bd905081846147ed565b600d60008282546111ce91906145ff565b909155505060175460408701516001600160a01b0390911690630c49ccbe906111fb908b90600019612971565b604080516001600160e01b031960e085901b1681528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608090910151608482015260a4016040805180830381600087803b15801561126457600080fd5b505af1158015611278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129c9190614147565b50506017546001600160a01b031663fc6f78656112b98a306128a9565b6040518263ffffffff1660e01b81526004016112d591906143eb565b6040805180830381600087803b1580156112ee57600080fd5b505af1158015611302573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113269190614147565b600e549195509350611342906001600160a01b031633866128dd565b600f54611359906001600160a01b031633856128dd565b600088815260076020908152604080832080546001600160a01b03191690553383526008909152812061138c908a6129d5565b90508061139857600080fd5b60405189815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243649060200160405180910390a250506001805550505050505050565b6000546001600160a01b031633146114065760405162461bcd60e51b8152600401610a279061437f565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146114525760405162461bcd60e51b8152600401610a279061437f565b61145c60006129e1565b565b6019546000908190611478906001600160a01b0316612a31565b509194909350915050565b600260015414156114a65760405162461bcd60e51b8152600401610a27906143b4565b6002600155601254600160a01b900460ff166114fe5760405162461bcd60e51b81526020600482015260176024820152761a185cc8195b595c99d95b98de481dda5d1a1c985dd959604a1b6044820152606401610a27565b600e54611515906001600160a01b03163385612c1a565b600f5461152c906001600160a01b03163384612c1a565b60008061153883612c94565b915091506115756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600e54600f546000916115a9916001600160a01b0391821691811690600160a01b900462ffffff168a8a8989600019612ed4565b601754604051634418b22b60e11b815291925060009182916001600160a01b03169063883164569034906115e190879060040161442e565b6080604051808303818588803b1580156115fa57600080fd5b505af115801561160e573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061163391906140de565b6001600160801b03909216604088018190529287529350915062989680106116945760405162461bcd60e51b81526020600482015260146024820152736c697175696469747920746f6f20736d616c6c2160601b6044820152606401610a27565b620f424084604001516116a791906146a5565b6020850152601580548391906000906116c19084906145ff565b9250508190555080601660008282546116da91906145ff565b90915550506080840182905260a084018190528351600090815260076020908152604080832080546001600160a01b0319163390811790915587519084526008909252822061172891612fa2565b90508061173457600080fd5b601760009054906101000a90046001600160a01b03166001600160a01b03166312210e8a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561178457600080fd5b505af1158015611798573d6000803e3d6000fd5b50505050898310156117c457600e546117c4906001600160a01b0316336117bf868e6147ed565b612fae565b888210156117e757600f546117e7906001600160a01b0316336117bf858d6147ed565b6117f23360006121cd565b61180185602001516001612723565b3360009081526013602090815260408220908701516001820180549293919290919061182e9084906145ff565b9250508190555061184c8160050154826003015483600101546127b5565b60058201556118606006600160801b6146a5565b81600501541061189c5760405162461bcd60e51b81526020600482015260076024820152667665695a69204f60c81b6044820152606401610a27565b6118ae8160010154826003015461282d565b60028083019190915586516000908152601a60209081526040918290208951808255918a015160018201819055838b01519482019490945560608a0151600382015560808a0151600482015560a08a0151600590910155905133927f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159261194092909190918252602082015260400190565b60405180910390a2505060018055505050505050505050565b60608167ffffffffffffffff81111561198257634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156119b557816020015b60608152602001906001900390816119a05790505b50905060005b82811015611ad457600080308686858181106119e757634e487b7160e01b600052603260045260246000fd5b90506020028101906119f991906144f2565b604051611a0792919061425d565b600060405180830381855af49150503d8060008114611a42576040519150601f19603f3d011682016040523d82523d6000602084013e611a47565b606091505b509150915081611a9357604481511015611a6057600080fd5b60048101905080806020019051810190611a7a9190613f35565b60405162461bcd60e51b8152600401610a27919061436c565b80848481518110611ab457634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080611acc90614855565b9150506119bb565b5092915050565b60026001541415611afe5760405162461bcd60e51b8152600401610a27906143b4565b60026001556011546001600160a01b03163314611b4c5760405162461bcd60e51b815260206004820152600c60248201526b2727aa102922a1a2a4ab22a960a11b6044820152606401610a27565b600e54601154600c54611b6c926001600160a01b039081169216906128dd565b600f54601154600d54611b8c926001600160a01b039081169216906128dd565b6000600c819055600d5560018055565b6000546001600160a01b03163314611bc65760405162461bcd60e51b8152600401610a279061437f565b6000818152600760205260409020546001600160a01b031680611be857600080fd5b601754604051632142170760e11b81523060048201526001600160a01b03838116602483015260448201859052909116906342842e0e90606401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050506000928352505060076020526040902080546001600160a01b03191690556012805460ff60a01b19169055565b6001600160a01b0381166000908152600860205260408120606091611ca482612fd8565b67ffffffffffffffff811115611cca57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611cf3578160200160208202803683370190505b50905060005b611d0283612fd8565b811015611d5057611d138382612fe2565b828281518110611d3357634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611d4881614855565b915050611cf9565b509392505050565b6000546001600160a01b03163314611d825760405162461bcd60e51b8152600401610a279061437f565b438111611dbf5760405162461bcd60e51b815260206004820152600b60248201526a4f5554204f46204441544560a81b6044820152606401610a27565b611dc76120fa565b4360025560048190556040518181527f6861e667f4625c666d8000dd2fe6b7dde9a3d46381327f9e1330df56969f15be9060200160405180910390a150565b6000546001600160a01b03163314611e305760405162461bcd60e51b8152600401610a279061437f565b6001600160a01b038116611e955760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a27565b611e9e816129e1565b50565b801580611f2a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611ef057600080fd5b505afa158015611f04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f289190614073565b155b611f955760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610a27565b6040516001600160a01b038316602482015260448101829052611ff890849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612fee565b505050565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526000806000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561206957600080fd5b505afa15801561207d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a19190613fc5565b5050600293840b90930b8a526001600160a01b0390931660208a015261ffff90811660408a01529182166060890152166080870152509395945050505050565b60606120f084846000856130c0565b90505b9392505050565b600254431161210557565b6004546002541061211257565b6000612120436004546131f1565b90506009546000141561213257600255565b60005b6006548110156121c75760008181526005602052604081206003015460025461215e90856147ed565b6121689190614742565b60095490915061217c600160801b83614742565b61218691906146a5565b6000838152600560205260409020600201546121a291906145ff565b60008381526005602052604090206002015550806121bf81614855565b915050612135565b50600255565b6121d56120fa565b6001600160a01b0382166000908152601360205260409020805460ff166122ce57805460ff1916600117815560065467ffffffffffffffff81111561222a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612253578160200160208202803683370190505b50805161226a916006840191602090910190613cac565b5060005b6006548110156122cc57600081815260056020526040902060020154600683018054839081106122ae57634e487b7160e01b600052603260045260246000fd5b600091825260209091200155806122c481614855565b91505061226e565b505b600181015461233a5760005b600654811015612338576000818152600560205260409020600201546006830180548390811061231a57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001558061233081614855565b9150506122da565b505b6040805160e081018252825460ff161515815260018301546020808301919091526002840154828401526003840154606083015260048401546080830152600584015460a08301526006840180548451818402810184019095528085526000946123e69493879360c086019390918301828280156123d757602002820191906000526020600020905b8154815260200190600101908083116123c3575b505050505081525050856125aa565b905060005b600654811015612551576000600160801b836000015185600601848154811061242457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154600560008681526020019081526020016000206002015461245091906147ed565b61245a9190614742565b61246491906146a5565b9050600081118015612474575084155b156124fc576000828152600560205260409020600181015490546124a6916001600160a01b0391821691163384613207565b6000828152600560209081526040918290205482516001600160a01b03909116815290810183905233917f56cc9cf62f5a3a4367575119e524522956236e34a9a06eab7fcf9880b76b81cc910160405180910390a25b6000828152600560205260409020600201546006850180548490811061253257634e487b7160e01b600052603260045260246000fd5b600091825260209091200155508061254981614855565b9150506123eb565b5080516002830155604081015160038301819055602082015160048401556005830154600184015461258392906127b5565b60058301556001820154600383015461259c919061282d565b826002018190555050505050565b6125ce60405180606001604052806000815260200160008152602001600081525090565b6012546001600160a01b03166125fa5760006020820181905260408083019190915283015181526126d2565b60125460405163094eecb560e41b81526001600160a01b038481166004830152909116906394eecb509060240160606040518083038186803b15801561263f57600080fd5b505afa158015612653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267791906141a2565b6040840152602083015250608083015161269757604083015181526126d2565b82608001518160200151146126ca57600a836020015160046126b99190614742565b6126c391906146a5565b81526126d2565b604083015181525b92915050565b6000818311156126ea575060006126d2565b6004548211612704576126fd83836147ed565b90506126d2565b6004548310612715575060006126d2565b826004546126fd91906147ed565b801561273f578160095461273791906145ff565b600955612751565b8160095461274d91906147ed565b6009555b612760600160801b6003614742565b60095411156127b15760405162461bcd60e51b815260206004820152601960248201527f544f4f204d554348204c4951554944495459205354414b4544000000000000006044820152606401610a27565b5050565b600083600a60008282546127c991906147ed565b90915550506009546127dd575060006120f3565b61280d8360095484600a5460026127f49190614742565b6127fe9190614742565b61280891906146a5565b6131f1565b905080600a600082825461282191906145ff565b90915550509392505050565b6000600a54600014156128415750816126d2565b6000600a8054846009546128559190614742565b61285f91906146a5565b61286a906006614742565b61287491906146a5565b600a612881866004614742565b61288b91906146a5565b61289591906145ff565b90506128a181856131f1565b949350505050565b604080516080810182529283526001600160a01b039190911660208301526001600160801b03908201819052606082015290565b8015611ff8576010546001600160a01b038481169116141561295d57604051632e1a7d4d60e01b8152600481018290526001600160a01b03841690632e1a7d4d90602401600060405180830381600087803b15801561293b57600080fd5b505af115801561294f573d6000803e3d6000fd5b50505050611ff88282613245565b611ff86001600160a01b03841683836132e8565b6129ac6040518060a001604052806000815260200160006001600160801b031681526020016000815260200160008152602001600081525090565b9283526001600160801b0390911660208301526000604083018190526060830152608082015290565b60006120f38383613318565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000806000612a4b866001600160a01b0316611ffd565b9050806060015161ffff1660011415612a765780516020909101519094509250839150829050612c13565b60408051608081018252600080825260208201819052918101829052606081019190915260408051608081018252600080825260208201819052918101829052606081019190915260408301516060840151612adc916001600160a01b038b1691613435565b8051825192945090925063ffffffff91821691161415612b1057505080516020909101519094509250839150829050612c13565b6000612b1e611c20426147ed565b9050826000015163ffffffff168163ffffffff16111580612b5c57508251612b4890610e10614617565b63ffffffff16826000015163ffffffff1611155b15612ba45782518251600091612b7191614804565b63ffffffff16905060008185602001518560200151612b9091906147a8565b612b9a9190614670565b9950612bf0915050565b8151819063ffffffff16612bba82610e10614617565b63ffffffff161115612bd8578251612bd590610e1090614804565b90505b612bec8a828560200151866000015161350d565b9850505b612bf98861365a565b8451602090950151909750939550929350612c1392505050565b9193509193565b80612c2457505050565b6010546001600160a01b0384811691161415612c7f5780341015611ff85760405162461bcd60e51b8152602060048201526012602482015271115512115488125394d551919250d251539560721b6044820152606401610a27565b611ff86001600160a01b038416833084613207565b601954600090819081908190612cb2906001600160a01b0316612a31565b5060020b925050915060008560020b8360020b612ccf91906147a8565b905060008160060b1215612ceb57612ce681614902565b612ced565b805b90506101f48160060b12612d325760405162461bcd60e51b815260206004820152600c60248201526b5449434b204249415320415360a01b6044820152606401610a27565b612d40600287900b836147a8565b905060008160060b1215612d5c57612d5781614902565b612d5e565b805b90506101f48160060b12612da35760405162461bcd60e51b815260206004820152600c60248201526b5449434b204249415320435360a01b6044820152606401610a27565b601854600f546040516322afcccb60e01b8152600160a01b90910462ffffff1660048201526000916001600160a01b0316906322afcccb9060240160206040518083038186803b158015612df657600080fd5b505afa158015612e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2e9190613f19565b601454909150612e4f90612e459060020b86614761565b6207a11f19613a6f565b601454909650612e7690612e6d906301000000900460020b86614593565b6207a120613a85565b9450612e828682613a9a565b9550612e8e8582613ae4565b94508460020b8660020b12612ecb5760405162461bcd60e51b8152602060048201526003602482015262261e2960e91b6044820152606401610a27565b50505050915091565b604080516101608101825260008082526020820181905260a0820181905260c0820181905260e0820181905261010082015262ffffff881691810191909152600284810b810b606083015283810b900b60808201526101408101829052306101208201526001600160a01b03888116908a161015612f73576001600160a01b03808a1682528816602082015260a0810186905260c08101859052612f96565b6001600160a01b0380891682528916602082015260a0810185905260c081018690525b98975050505050505050565b60006120f38383613b21565b80612fb857505050565b6010546001600160a01b038481169116141561295d57611ff88282613245565b60006126d2825490565b60006120f38383613b70565b6000613043826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120e19092919063ffffffff16565b805190915015611ff857808060200190518101906130619190613efd565b611ff85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a27565b6060824710156131215760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a27565b6001600160a01b0385163b6131785760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a27565b600080866001600160a01b03168587604051613194919061426d565b60006040518083038185875af1925050503d80600081146131d1576040519150601f19603f3d011682016040523d82523d6000602084013e6131d6565b606091505b50915091506131e6828286613ba8565b979650505050505050565b600081831061320057816120f3565b5090919050565b6040516001600160a01b038085166024830152831660448201526064810182905261323f9085906323b872dd60e01b90608401611fc1565b50505050565b604080516000808252602082019092526001600160a01b03841690839060405161326f919061426d565b60006040518083038185875af1925050503d80600081146132ac576040519150601f19603f3d011682016040523d82523d6000602084013e6132b1565b606091505b5050905080611ff85760405162461bcd60e51b815260206004820152600360248201526253544560e81b6044820152606401610a27565b6040516001600160a01b038316602482015260448101829052611ff890849063a9059cbb60e01b90606401611fc1565b6000818152600183016020526040812054801561342b57600061333c6001836147ed565b8554909150600090613350906001906147ed565b90508181146133d157600086600001828154811061337e57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106133af57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b85548690806133f057634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506126d2565b60009150506126d2565b60408051608081018252600080825260208201819052918101829052606081019190915260408051608081018252600080825260208201819052918101829052606081019190915260008361348b8660016145d9565b6134959190614892565b90506134ae6001600160a01b03871661ffff8316613be1565b925082606001516134d2575060006134cf6001600160a01b03871682613be1565b92505b8061ffff168561ffff1614156134ea57829150613504565b6135016001600160a01b03871661ffff8716613be1565b91505b50935093915050565b6040805160018082528183019092526000918291906020808301908036833701905050905061353c8542614804565b8160008151811061355d57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526060906001600160a01b0388169063883bdbfd906135a190859060040161432e565b60006040518083038186803b1580156135b957600080fd5b505afa1580156135cd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135f59190810190613e39565b50905060006136048786614804565b63ffffffff1690506000818360008151811061363057634e487b7160e01b600052603260045260246000fd5b60200260200101518861364391906147a8565b61364d9190614670565b9998505050505050505050565b60008060008360020b12613671578260020b61367e565b8260020b61367e906148e8565b905061368d620d89e7196148c7565b60020b8111156136c35760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610a27565b6000600182166136d757600160801b6136e9565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615613728576080613723826ffff97272373d413259a46990580e213a614742565b901c90505b600482161561375257608061374d826ffff2e50f5f656932ef12357cf3c7fdcc614742565b901c90505b600882161561377c576080613777826fffe5caca7e10e4e61c3624eaa0941cd0614742565b901c90505b60108216156137a65760806137a1826fffcb9843d60f6159c9db58835c926644614742565b901c90505b60208216156137d05760806137cb826fff973b41fa98c081472e6896dfb254c0614742565b901c90505b60408216156137fa5760806137f5826fff2ea16466c96a3843ec78b326b52861614742565b901c90505b608082161561382457608061381f826ffe5dee046a99a2a811c461f1969c3053614742565b901c90505b61010082161561384f57608061384a826ffcbe86c7900a88aedcffc83b479aa3a4614742565b901c90505b61020082161561387a576080613875826ff987a7253ac413176f2b074cf7815e54614742565b901c90505b6104008216156138a55760806138a0826ff3392b0822b70005940c7a398e4b70f3614742565b901c90505b6108008216156138d05760806138cb826fe7159475a2c29b7443b29c7fa6e889d9614742565b901c90505b6110008216156138fb5760806138f6826fd097f3bdfd2022b8845ad8f792aa5825614742565b901c90505b612000821615613926576080613921826fa9f746462d870fdf8a65dc1f90e061e5614742565b901c90505b61400082161561395157608061394c826f70d869a156d2a1b890bb3df62baf32f7614742565b901c90505b61800082161561397c576080613977826f31be135f97d08fd981231505542fcfa6614742565b901c90505b620100008216156139a85760806139a3826f09aa508b5b7a84e1c677de54f3e99bc9614742565b901c90505b620200008216156139d35760806139ce826e5d6af8dedb81196699c329225ee604614742565b901c90505b620400008216156139fd5760806139f8826d2216e584f5fa1ea926041bedfe98614742565b901c90505b62080000821615613a25576080613a20826b048a170391f7dc42444e8fa2614742565b901c90505b60008460020b1315613a4057613a3d816000196146a5565b90505b613a4f640100000000826148b3565b15613a5b576001613a5e565b60005b6128a19060ff16602083901c6145ff565b60008160020b8360020b121561320057816120f3565b60008160020b8360020b1261320057816120f3565b600080613aa78385614636565b905060008460020b128015613ac75750613ac18385614870565b60020b15155b15613ada57613ad7600182614761565b90505b6128a183826146b9565b600080613af18385614636565b905060008460020b138015613b115750613b0b8385614870565b60020b15155b15613ada57613ad7816001614593565b6000818152600183016020526040812054613b68575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556126d2565b5060006126d2565b6000826000018281548110613b9557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60608315613bb75750816120f3565b825115613bc75782518084602001fd5b8160405162461bcd60e51b8152600401610a27919061436c565b60408051608081018252600080825260208201819052918101829052606081019190915260405163252c09d760e01b8152600481018390526001600160a01b0384169063252c09d79060240160806040518083038186803b158015613c4557600080fd5b505afa158015613c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c7d91906141cf565b151560608501526001600160a01b03166040840152600690810b900b602083015263ffffffff16815292915050565b828054828255906000526020600020908101928215613ce7579160200282015b82811115613ce7578251825591602001919060010190613ccc565b50613cf3929150613cf7565b5090565b5b80821115613cf35760008155600101613cf8565b600082601f830112613d1c578081fd5b81516020613d31613d2c8361456f565b61453e565b80838252828201915082860187848660051b8901011115613d50578586fd5b855b85811015613d77578151613d658161495e565b84529284019290840190600101613d52565b5090979650505050505050565b8051600681900b8114613d9657600080fd5b919050565b805161ffff81168114613d9657600080fd5b600060208284031215613dbe578081fd5b81356120f38161495e565b60008060208385031215613ddb578081fd5b823567ffffffffffffffff80821115613df2578283fd5b818501915085601f830112613e05578283fd5b813581811115613e13578384fd5b8660208260051b8501011115613e27578384fd5b60209290920196919550909350505050565b60008060408385031215613e4b578182fd5b825167ffffffffffffffff80821115613e62578384fd5b818501915085601f830112613e75578384fd5b81516020613e85613d2c8361456f565b8083825282820191508286018a848660051b8901011115613ea4578889fd5b8896505b84871015613ecd57613eb981613d84565b835260019690960195918301918301613ea8565b5091880151919650909350505080821115613ee6578283fd5b50613ef385828601613d0c565b9150509250929050565b600060208284031215613f0e578081fd5b81516120f381614973565b600060208284031215613f2a578081fd5b81516120f381614981565b600060208284031215613f46578081fd5b815167ffffffffffffffff80821115613f5d578283fd5b818401915084601f830112613f70578283fd5b815181811115613f8257613f82614948565b613f95601f8201601f191660200161453e565b9150808252856020828501011115613fab578384fd5b613fbc816020840160208601614829565b50949350505050565b600080600080600080600060e0888a031215613fdf578283fd5b8751613fea8161495e565b6020890151909750613ffb81614981565b955061400960408901613d9b565b945061401760608901613d9b565b935061402560808901613d9b565b925060a088015160ff8116811461403a578283fd5b60c089015190925061404b81614973565b8091505092959891949750929550565b60006020828403121561406c578081fd5b5035919050565b600060208284031215614084578081fd5b5051919050565b6000806040838503121561409d578182fd5b8235915060208301356140af8161495e565b809150509250929050565b600080604083850312156140cc578182fd5b8235915060208301356140af81614973565b600080600080608085870312156140f3578182fd5b8451935060208501516001600160801b0381168114614110578283fd5b6040860151606090960151949790965092505050565b60008060408385031215614138578182fd5b50508035926020909101359150565b60008060408385031215614159578182fd5b505080516020909101519092909150565b60008060006060848603121561417e578081fd5b8335925060208401359150604084013561419781614981565b809150509250925092565b6000806000606084860312156141b6578081fd5b8351925060208401519150604084015190509250925092565b600080600080608085870312156141e4578182fd5b845163ffffffff811681146141f7578283fd5b935061420560208601613d84565b925060408501516142158161495e565b606086015190925061422681614973565b939692955090935050565b60008151808452614249816020860160208601614829565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b6000825161427f818460208701614829565b9190910192915050565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b828110156142dd57603f198886030184526142cb858351614231565b945092850192908501906001016142af565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561432257835183529284019291840191600101614306565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561432257835163ffffffff168352928401929184019160010161434a565b6020815260006120f36020830184614231565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b81516001600160a01b031681526101608101602083015161445a60208401826001600160a01b03169052565b506040830151614471604084018262ffffff169052565b506060830151614486606084018260020b9052565b50608083015161449b608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516144e1828501826001600160a01b03169052565b505061014092830151919092015290565b6000808335601e19843603018112614508578283fd5b83018035915067ffffffffffffffff821115614522578283fd5b60200191503681900382131561453757600080fd5b9250929050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561456757614567614948565b604052919050565b600067ffffffffffffffff82111561458957614589614948565b5060051b60200190565b60008160020b8360020b82821282627fffff038213811516156145b8576145b861491c565b82627fffff190382128116156145d0576145d061491c565b50019392505050565b600061ffff8083168185168083038211156145f6576145f661491c565b01949350505050565b600082198211156146125761461261491c565b500190565b600063ffffffff8083168185168083038211156145f6576145f661491c565b60008160020b8360020b8061464d5761464d614932565b627fffff198214600019821416156146675761466761491c565b90059392505050565b60008160060b8360060b8061468757614687614932565b667fffffffffffff198214600019821416156146675761466761491c565b6000826146b4576146b4614932565b500490565b60008160020b8360020b627fffff838213848413838304851182821616156146e3576146e361491c565b627fffff19868512828116878305871216156147015761470161491c565b87871292508582058712848416161561471c5761471c61491c565b858505871281841616156147325761473261491c565b5050509290910295945050505050565b600081600019048311821515161561475c5761475c61491c565b500290565b60008160020b8360020b82811281627fffff19018312811516156147875761478761491c565b81627fffff01831381161561479e5761479e61491c565b5090039392505050565b60008160060b8360060b82811281667fffffffffffff19018312811516156147d2576147d261491c565b81667fffffffffffff01831381161561479e5761479e61491c565b6000828210156147ff576147ff61491c565b500390565b600063ffffffff838116908316818110156148215761482161491c565b039392505050565b60005b8381101561484457818101518382015260200161482c565b8381111561323f5750506000910152565b60006000198214156148695761486961491c565b5060010190565b60008260020b8061488357614883614932565b808360020b0791505092915050565b600061ffff808416806148a7576148a7614932565b92169190910692915050565b6000826148c2576148c2614932565b500690565b60008160020b627fffff198114156148e1576148e161491c565b9003919050565b6000600160ff1b8214156148fe576148fe61491c565b0390565b60008160060b667fffffffffffff198114156148e1576148e15b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611e9e57600080fd5b8015158114611e9e57600080fd5b8060020b8114611e9e57600080fdfea2646970667358221220ba8035a22f1aceb50bdeb14918578d1f567bddfb7e4bfaf5a421df8fe62e754964736f6c63430008040033000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe880000000000000000000000001a4b46696b2bb4794eb3d4c26f1c55f9170fa4c5000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000b56a454d8dac2ad4cb82337887717a2a427fcd000000000000000000000000000000000000000000000000000000000000eacf720000000000000000000000000000000000000000000000000000000000ec2a5c00000000000000000000000000000000000000000000000000000000000000280000000000000000000000003599a414b4365b118766479600c0fd135177c2d500000000000000000000000000000000000000000000000000000000000008b800000000000000000000000000000000000000000000000000000000000008b800000000000000000000000000000000000000000000021e19e0c9bab240000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009ad37205d608b8b219e6a2573f922094cec5c200000000000000000000000000ee264e74a2fd2c7a55da705b80e092f05dae5b5d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e1de1d2517b8b00

Deployed Bytecode

0x60806040526004361061026b5760003560e01c8063979ae58911610144578063b74d60a9116100b6578063d1c924a51161007a578063d1c924a5146108a6578063d62dd3a614610966578063d7158cd414610986578063d8cd50e21461099c578063f2fde38b146109bc578063fd255aef146109dc57600080fd5b8063b74d60a91461081a578063c772ec7c1461082f578063cc69f75e14610845578063cd785a5e14610866578063d004b0361461088657600080fd5b80639f04d135116101085780639f04d13514610710578063a529650d14610726578063a9a3f1a914610739578063ac9650d81461075d578063b01ce31f1461077d578063b532a3e2146107fa57600080fd5b8063979ae58914610662578063982697dd146106975780639a174591146106b75780639ac8eebc146106cd5780639cc0b102146106e357600080fd5b806348cd4cb1116101dd578063715018a6116101a1578063715018a61461054857806376771d4b1461055d578063796da7af1461057d57806380abfda8146105b457806389d6517f146105ca5780638da5cb5b1461064457600080fd5b806348cd4cb11461046b5780634c878ef7146104815780635e1b9e3a146104975780635f9de944146104c757806366666aa9146104e757600080fd5b80632e0c5ca21161022f5780632e0c5ca2146103a957806330c47752146103c957806331d7a262146103de57806338d074361461040b5780633a6edcce1461042b5780633fc8cef31461044b57600080fd5b8063025e7c2714610277578063083c6323146102ca5780631ed262de146102ee578063225d29a1146103045780632d6730db1461038757600080fd5b3661027257005b600080fd5b34801561028357600080fd5b506102ad61029236600461405b565b6007602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102d657600080fd5b506102e060045481565b6040519081526020016102c1565b3480156102fa57600080fd5b506102e0600a5481565b34801561031057600080fd5b5061035861031f366004613dad565b60136020526000908152604090208054600182015460028301546003840154600485015460059095015460ff9094169492939192909186565b6040805196151587526020870195909552938501929092526060840152608083015260a082015260c0016102c1565b34801561039357600080fd5b506103a76103a2366004614126565b6109fd565b005b3480156103b557600080fd5b506103a76103c436600461408b565b610adf565b3480156103d557600080fd5b506103a7610bbc565b3480156103ea57600080fd5b506103fe6103f9366004613dad565b610c48565b6040516102c191906142ea565b34801561041757600080fd5b506103a76104263660046140ba565b610ee0565b34801561043757600080fd5b506103a7610446366004613dad565b6113dc565b34801561045757600080fd5b506010546102ad906001600160a01b031681565b34801561047757600080fd5b506102e060035481565b34801561048d57600080fd5b506102e0600c5481565b3480156104a357600080fd5b50600b546104b39062ffffff1681565b60405162ffffff90911681526020016102c1565b3480156104d357600080fd5b506012546102ad906001600160a01b031681565b3480156104f357600080fd5b50600e54600f5461051d916001600160a01b039081169190811690600160a01b900462ffffff1683565b604080516001600160a01b03948516815293909216602084015262ffffff16908201526060016102c1565b34801561055457600080fd5b506103a7611428565b34801561056957600080fd5b506018546102ad906001600160a01b031681565b34801561058957600080fd5b5061059261145e565b6040805160029390930b83526001600160a01b039091166020830152016102c1565b3480156105c057600080fd5b506102e060165481565b3480156105d657600080fd5b506106196105e536600461405b565b60056020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b0395861681529490931660208501529183015260608201526080016102c1565b34801561065057600080fd5b506000546001600160a01b03166102ad565b34801561066e57600080fd5b5060145461068790670100000000000000900460ff1681565b60405190151581526020016102c1565b3480156106a357600080fd5b506019546102ad906001600160a01b031681565b3480156106c357600080fd5b506102e060065481565b3480156106d957600080fd5b506102e060095481565b3480156106ef57600080fd5b506014546106fd9060020b81565b60405160029190910b81526020016102c1565b34801561071c57600080fd5b506102e060025481565b6103a761073436600461416a565b611483565b34801561074557600080fd5b50601454610687906601000000000000900460ff1681565b61077061076b366004613dc9565b611959565b6040516102c19190614289565b34801561078957600080fd5b506107cd61079836600461405b565b601a60205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909186565b604080519687526020870195909552938501929092526060840152608083015260a082015260c0016102c1565b34801561080657600080fd5b506017546102ad906001600160a01b031681565b34801561082657600080fd5b506103a7611adb565b34801561083b57600080fd5b506102e0600d5481565b34801561085157600080fd5b506014546106fd906301000000900460020b81565b34801561087257600080fd5b506103a761088136600461405b565b611b9c565b34801561089257600080fd5b506103fe6108a1366004613dad565b611c80565b3480156108b257600080fd5b506108fb600e54600f54600254600954601554601654600a546003546004546001600160a01b039889169998881698600160a01b90980462ffffff169760009796959493929190565b604080516001600160a01b039c8d1681529a8c1660208c015262ffffff909916988a0198909852989095166060880152608087019390935260a086019190915260c085015260e0840152610100830152610120820192909252610140810191909152610160016102c1565b34801561097257600080fd5b506103a761098136600461405b565b611d58565b34801561099257600080fd5b506102e060155481565b3480156109a857600080fd5b506011546102ad906001600160a01b031681565b3480156109c857600080fd5b506103a76109d7366004613dad565b611e06565b3480156109e857600080fd5b5060125461068790600160a01b900460ff1681565b6000546001600160a01b03163314610a305760405162461bcd60e51b8152600401610a279061437f565b60405180910390fd5b6006548210610a7c5760405162461bcd60e51b81526020600482015260186024820152774f5554204f462052455741524420494e464f2052414e474560401b6044820152606401610a27565b610a846120fa565b600082815260056020908152604091829020600381018490555491518381526001600160a01b03909216917fd9a745381d3899e0a1380f3c7f56ea1bf0fb8331482527ff4984296da9580fab91015b60405180910390a25050565b6000546001600160a01b03163314610b095760405162461bcd60e51b8152600401610a279061437f565b6006548210610b555760405162461bcd60e51b81526020600482015260186024820152774f5554204f462052455741524420494e464f2052414e474560401b6044820152606401610a27565b6000828152600560209081526040918290206001810180546001600160a01b0319166001600160a01b038681169182179092559154935191825292909216917fda608212a78120f0e323cf82e77003c28512aa6eae3747c062c459901d7930159101610ad3565b60026001541415610bdf5760405162461bcd60e51b8152600401610a27906143b4565b6002600155601254600160a01b900460ff16610c375760405162461bcd60e51b81526020600482015260176024820152761a185cc8195b595c99d95b98de481dda5d1a1c985dd959604a1b6044820152606401610a27565b610c423360006121cd565b60018055565b6060600060065467ffffffffffffffff811115610c7557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c9e578160200160208202803683370190505b506001600160a01b0384166000908152601360209081526040808320815160e081018352815460ff16151581526001820154818501526002820154818401526003820154606082015260048201546080820152600582015460a082015260068201805484518187028101870190955280855296975094959094919360c0860193929190830182828015610d5057602002820191906000526020600020905b815481526020019060010190808311610d3c575b5050505050815250509050806020015160001415610dbd5760005b600654811015610db4576000838281518110610d9757634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610dac81614855565b915050610d6b565b50909392505050565b6000610dc982866125aa565b905060005b600654811015610ed657600081815260056020526040812060030154600254610df790436126d8565b610e019190614742565b90506000600954600160801b83610e189190614742565b610e2291906146a5565b600084815260056020526040902060020154610e3e91906145ff565b9050600160801b84600001518660c001518581518110610e6e57634e487b7160e01b600052603260045260246000fd5b602002602001015183610e8191906147ed565b610e8b9190614742565b610e9591906146a5565b868481518110610eb557634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080610ece90614855565b915050610dce565b5091949350505050565b60026001541415610f035760405162461bcd60e51b8152600401610a27906143b4565b60026001556000828152600760205260409020546001600160a01b03163314610f675760405162461bcd60e51b81526020600482015260166024820152751393d50813d5d391548813d4881393d50811561254d560521b6044820152606401610a27565b610f86338280610f815750601254600160a01b900460ff16155b6121cd565b6000601a60008481526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815250509050806080015160156000828254610ffa91906147ed565b909155505060a0810151601680546000906110169084906147ed565b9091555050602081015161102b906000612723565b33600090815260136020908152604090912090820151600182015461105091906147ed565b600182018190556005820154600383015461106a926127b5565b600582015560018101546003820154611083919061282d565b600282015560175460009081906001600160a01b031663fc6f78656110a888306128a9565b6040518263ffffffff1660e01b81526004016110c491906143eb565b6040805180830381600087803b1580156110dd57600080fd5b505af11580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190614147565b600b5491935091506000906064906111329062ffffff1685614742565b61113c91906146a5565b600b549091506000906064906111579062ffffff1685614742565b61116191906146a5565b600e5490915061117b906001600160a01b031633846128dd565b600f54611192906001600160a01b031633836128dd565b61119c82856147ed565b600c60008282546111ad91906145ff565b909155506111bd905081846147ed565b600d60008282546111ce91906145ff565b909155505060175460408701516001600160a01b0390911690630c49ccbe906111fb908b90600019612971565b604080516001600160e01b031960e085901b1681528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608090910151608482015260a4016040805180830381600087803b15801561126457600080fd5b505af1158015611278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129c9190614147565b50506017546001600160a01b031663fc6f78656112b98a306128a9565b6040518263ffffffff1660e01b81526004016112d591906143eb565b6040805180830381600087803b1580156112ee57600080fd5b505af1158015611302573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113269190614147565b600e549195509350611342906001600160a01b031633866128dd565b600f54611359906001600160a01b031633856128dd565b600088815260076020908152604080832080546001600160a01b03191690553383526008909152812061138c908a6129d5565b90508061139857600080fd5b60405189815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243649060200160405180910390a250506001805550505050505050565b6000546001600160a01b031633146114065760405162461bcd60e51b8152600401610a279061437f565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146114525760405162461bcd60e51b8152600401610a279061437f565b61145c60006129e1565b565b6019546000908190611478906001600160a01b0316612a31565b509194909350915050565b600260015414156114a65760405162461bcd60e51b8152600401610a27906143b4565b6002600155601254600160a01b900460ff166114fe5760405162461bcd60e51b81526020600482015260176024820152761a185cc8195b595c99d95b98de481dda5d1a1c985dd959604a1b6044820152606401610a27565b600e54611515906001600160a01b03163385612c1a565b600f5461152c906001600160a01b03163384612c1a565b60008061153883612c94565b915091506115756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600e54600f546000916115a9916001600160a01b0391821691811690600160a01b900462ffffff168a8a8989600019612ed4565b601754604051634418b22b60e11b815291925060009182916001600160a01b03169063883164569034906115e190879060040161442e565b6080604051808303818588803b1580156115fa57600080fd5b505af115801561160e573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061163391906140de565b6001600160801b03909216604088018190529287529350915062989680106116945760405162461bcd60e51b81526020600482015260146024820152736c697175696469747920746f6f20736d616c6c2160601b6044820152606401610a27565b620f424084604001516116a791906146a5565b6020850152601580548391906000906116c19084906145ff565b9250508190555080601660008282546116da91906145ff565b90915550506080840182905260a084018190528351600090815260076020908152604080832080546001600160a01b0319163390811790915587519084526008909252822061172891612fa2565b90508061173457600080fd5b601760009054906101000a90046001600160a01b03166001600160a01b03166312210e8a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561178457600080fd5b505af1158015611798573d6000803e3d6000fd5b50505050898310156117c457600e546117c4906001600160a01b0316336117bf868e6147ed565b612fae565b888210156117e757600f546117e7906001600160a01b0316336117bf858d6147ed565b6117f23360006121cd565b61180185602001516001612723565b3360009081526013602090815260408220908701516001820180549293919290919061182e9084906145ff565b9250508190555061184c8160050154826003015483600101546127b5565b60058201556118606006600160801b6146a5565b81600501541061189c5760405162461bcd60e51b81526020600482015260076024820152667665695a69204f60c81b6044820152606401610a27565b6118ae8160010154826003015461282d565b60028083019190915586516000908152601a60209081526040918290208951808255918a015160018201819055838b01519482019490945560608a0151600382015560808a0151600482015560a08a0151600590910155905133927f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159261194092909190918252602082015260400190565b60405180910390a2505060018055505050505050505050565b60608167ffffffffffffffff81111561198257634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156119b557816020015b60608152602001906001900390816119a05790505b50905060005b82811015611ad457600080308686858181106119e757634e487b7160e01b600052603260045260246000fd5b90506020028101906119f991906144f2565b604051611a0792919061425d565b600060405180830381855af49150503d8060008114611a42576040519150601f19603f3d011682016040523d82523d6000602084013e611a47565b606091505b509150915081611a9357604481511015611a6057600080fd5b60048101905080806020019051810190611a7a9190613f35565b60405162461bcd60e51b8152600401610a27919061436c565b80848481518110611ab457634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080611acc90614855565b9150506119bb565b5092915050565b60026001541415611afe5760405162461bcd60e51b8152600401610a27906143b4565b60026001556011546001600160a01b03163314611b4c5760405162461bcd60e51b815260206004820152600c60248201526b2727aa102922a1a2a4ab22a960a11b6044820152606401610a27565b600e54601154600c54611b6c926001600160a01b039081169216906128dd565b600f54601154600d54611b8c926001600160a01b039081169216906128dd565b6000600c819055600d5560018055565b6000546001600160a01b03163314611bc65760405162461bcd60e51b8152600401610a279061437f565b6000818152600760205260409020546001600160a01b031680611be857600080fd5b601754604051632142170760e11b81523060048201526001600160a01b03838116602483015260448201859052909116906342842e0e90606401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050506000928352505060076020526040902080546001600160a01b03191690556012805460ff60a01b19169055565b6001600160a01b0381166000908152600860205260408120606091611ca482612fd8565b67ffffffffffffffff811115611cca57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611cf3578160200160208202803683370190505b50905060005b611d0283612fd8565b811015611d5057611d138382612fe2565b828281518110611d3357634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611d4881614855565b915050611cf9565b509392505050565b6000546001600160a01b03163314611d825760405162461bcd60e51b8152600401610a279061437f565b438111611dbf5760405162461bcd60e51b815260206004820152600b60248201526a4f5554204f46204441544560a81b6044820152606401610a27565b611dc76120fa565b4360025560048190556040518181527f6861e667f4625c666d8000dd2fe6b7dde9a3d46381327f9e1330df56969f15be9060200160405180910390a150565b6000546001600160a01b03163314611e305760405162461bcd60e51b8152600401610a279061437f565b6001600160a01b038116611e955760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a27565b611e9e816129e1565b50565b801580611f2a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611ef057600080fd5b505afa158015611f04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f289190614073565b155b611f955760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610a27565b6040516001600160a01b038316602482015260448101829052611ff890849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612fee565b505050565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526000806000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561206957600080fd5b505afa15801561207d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a19190613fc5565b5050600293840b90930b8a526001600160a01b0390931660208a015261ffff90811660408a01529182166060890152166080870152509395945050505050565b60606120f084846000856130c0565b90505b9392505050565b600254431161210557565b6004546002541061211257565b6000612120436004546131f1565b90506009546000141561213257600255565b60005b6006548110156121c75760008181526005602052604081206003015460025461215e90856147ed565b6121689190614742565b60095490915061217c600160801b83614742565b61218691906146a5565b6000838152600560205260409020600201546121a291906145ff565b60008381526005602052604090206002015550806121bf81614855565b915050612135565b50600255565b6121d56120fa565b6001600160a01b0382166000908152601360205260409020805460ff166122ce57805460ff1916600117815560065467ffffffffffffffff81111561222a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612253578160200160208202803683370190505b50805161226a916006840191602090910190613cac565b5060005b6006548110156122cc57600081815260056020526040902060020154600683018054839081106122ae57634e487b7160e01b600052603260045260246000fd5b600091825260209091200155806122c481614855565b91505061226e565b505b600181015461233a5760005b600654811015612338576000818152600560205260409020600201546006830180548390811061231a57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001558061233081614855565b9150506122da565b505b6040805160e081018252825460ff161515815260018301546020808301919091526002840154828401526003840154606083015260048401546080830152600584015460a08301526006840180548451818402810184019095528085526000946123e69493879360c086019390918301828280156123d757602002820191906000526020600020905b8154815260200190600101908083116123c3575b505050505081525050856125aa565b905060005b600654811015612551576000600160801b836000015185600601848154811061242457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154600560008681526020019081526020016000206002015461245091906147ed565b61245a9190614742565b61246491906146a5565b9050600081118015612474575084155b156124fc576000828152600560205260409020600181015490546124a6916001600160a01b0391821691163384613207565b6000828152600560209081526040918290205482516001600160a01b03909116815290810183905233917f56cc9cf62f5a3a4367575119e524522956236e34a9a06eab7fcf9880b76b81cc910160405180910390a25b6000828152600560205260409020600201546006850180548490811061253257634e487b7160e01b600052603260045260246000fd5b600091825260209091200155508061254981614855565b9150506123eb565b5080516002830155604081015160038301819055602082015160048401556005830154600184015461258392906127b5565b60058301556001820154600383015461259c919061282d565b826002018190555050505050565b6125ce60405180606001604052806000815260200160008152602001600081525090565b6012546001600160a01b03166125fa5760006020820181905260408083019190915283015181526126d2565b60125460405163094eecb560e41b81526001600160a01b038481166004830152909116906394eecb509060240160606040518083038186803b15801561263f57600080fd5b505afa158015612653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267791906141a2565b6040840152602083015250608083015161269757604083015181526126d2565b82608001518160200151146126ca57600a836020015160046126b99190614742565b6126c391906146a5565b81526126d2565b604083015181525b92915050565b6000818311156126ea575060006126d2565b6004548211612704576126fd83836147ed565b90506126d2565b6004548310612715575060006126d2565b826004546126fd91906147ed565b801561273f578160095461273791906145ff565b600955612751565b8160095461274d91906147ed565b6009555b612760600160801b6003614742565b60095411156127b15760405162461bcd60e51b815260206004820152601960248201527f544f4f204d554348204c4951554944495459205354414b4544000000000000006044820152606401610a27565b5050565b600083600a60008282546127c991906147ed565b90915550506009546127dd575060006120f3565b61280d8360095484600a5460026127f49190614742565b6127fe9190614742565b61280891906146a5565b6131f1565b905080600a600082825461282191906145ff565b90915550509392505050565b6000600a54600014156128415750816126d2565b6000600a8054846009546128559190614742565b61285f91906146a5565b61286a906006614742565b61287491906146a5565b600a612881866004614742565b61288b91906146a5565b61289591906145ff565b90506128a181856131f1565b949350505050565b604080516080810182529283526001600160a01b039190911660208301526001600160801b03908201819052606082015290565b8015611ff8576010546001600160a01b038481169116141561295d57604051632e1a7d4d60e01b8152600481018290526001600160a01b03841690632e1a7d4d90602401600060405180830381600087803b15801561293b57600080fd5b505af115801561294f573d6000803e3d6000fd5b50505050611ff88282613245565b611ff86001600160a01b03841683836132e8565b6129ac6040518060a001604052806000815260200160006001600160801b031681526020016000815260200160008152602001600081525090565b9283526001600160801b0390911660208301526000604083018190526060830152608082015290565b60006120f38383613318565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000806000612a4b866001600160a01b0316611ffd565b9050806060015161ffff1660011415612a765780516020909101519094509250839150829050612c13565b60408051608081018252600080825260208201819052918101829052606081019190915260408051608081018252600080825260208201819052918101829052606081019190915260408301516060840151612adc916001600160a01b038b1691613435565b8051825192945090925063ffffffff91821691161415612b1057505080516020909101519094509250839150829050612c13565b6000612b1e611c20426147ed565b9050826000015163ffffffff168163ffffffff16111580612b5c57508251612b4890610e10614617565b63ffffffff16826000015163ffffffff1611155b15612ba45782518251600091612b7191614804565b63ffffffff16905060008185602001518560200151612b9091906147a8565b612b9a9190614670565b9950612bf0915050565b8151819063ffffffff16612bba82610e10614617565b63ffffffff161115612bd8578251612bd590610e1090614804565b90505b612bec8a828560200151866000015161350d565b9850505b612bf98861365a565b8451602090950151909750939550929350612c1392505050565b9193509193565b80612c2457505050565b6010546001600160a01b0384811691161415612c7f5780341015611ff85760405162461bcd60e51b8152602060048201526012602482015271115512115488125394d551919250d251539560721b6044820152606401610a27565b611ff86001600160a01b038416833084613207565b601954600090819081908190612cb2906001600160a01b0316612a31565b5060020b925050915060008560020b8360020b612ccf91906147a8565b905060008160060b1215612ceb57612ce681614902565b612ced565b805b90506101f48160060b12612d325760405162461bcd60e51b815260206004820152600c60248201526b5449434b204249415320415360a01b6044820152606401610a27565b612d40600287900b836147a8565b905060008160060b1215612d5c57612d5781614902565b612d5e565b805b90506101f48160060b12612da35760405162461bcd60e51b815260206004820152600c60248201526b5449434b204249415320435360a01b6044820152606401610a27565b601854600f546040516322afcccb60e01b8152600160a01b90910462ffffff1660048201526000916001600160a01b0316906322afcccb9060240160206040518083038186803b158015612df657600080fd5b505afa158015612e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2e9190613f19565b601454909150612e4f90612e459060020b86614761565b6207a11f19613a6f565b601454909650612e7690612e6d906301000000900460020b86614593565b6207a120613a85565b9450612e828682613a9a565b9550612e8e8582613ae4565b94508460020b8660020b12612ecb5760405162461bcd60e51b8152602060048201526003602482015262261e2960e91b6044820152606401610a27565b50505050915091565b604080516101608101825260008082526020820181905260a0820181905260c0820181905260e0820181905261010082015262ffffff881691810191909152600284810b810b606083015283810b900b60808201526101408101829052306101208201526001600160a01b03888116908a161015612f73576001600160a01b03808a1682528816602082015260a0810186905260c08101859052612f96565b6001600160a01b0380891682528916602082015260a0810185905260c081018690525b98975050505050505050565b60006120f38383613b21565b80612fb857505050565b6010546001600160a01b038481169116141561295d57611ff88282613245565b60006126d2825490565b60006120f38383613b70565b6000613043826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120e19092919063ffffffff16565b805190915015611ff857808060200190518101906130619190613efd565b611ff85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a27565b6060824710156131215760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a27565b6001600160a01b0385163b6131785760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a27565b600080866001600160a01b03168587604051613194919061426d565b60006040518083038185875af1925050503d80600081146131d1576040519150601f19603f3d011682016040523d82523d6000602084013e6131d6565b606091505b50915091506131e6828286613ba8565b979650505050505050565b600081831061320057816120f3565b5090919050565b6040516001600160a01b038085166024830152831660448201526064810182905261323f9085906323b872dd60e01b90608401611fc1565b50505050565b604080516000808252602082019092526001600160a01b03841690839060405161326f919061426d565b60006040518083038185875af1925050503d80600081146132ac576040519150601f19603f3d011682016040523d82523d6000602084013e6132b1565b606091505b5050905080611ff85760405162461bcd60e51b815260206004820152600360248201526253544560e81b6044820152606401610a27565b6040516001600160a01b038316602482015260448101829052611ff890849063a9059cbb60e01b90606401611fc1565b6000818152600183016020526040812054801561342b57600061333c6001836147ed565b8554909150600090613350906001906147ed565b90508181146133d157600086600001828154811061337e57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106133af57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b85548690806133f057634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506126d2565b60009150506126d2565b60408051608081018252600080825260208201819052918101829052606081019190915260408051608081018252600080825260208201819052918101829052606081019190915260008361348b8660016145d9565b6134959190614892565b90506134ae6001600160a01b03871661ffff8316613be1565b925082606001516134d2575060006134cf6001600160a01b03871682613be1565b92505b8061ffff168561ffff1614156134ea57829150613504565b6135016001600160a01b03871661ffff8716613be1565b91505b50935093915050565b6040805160018082528183019092526000918291906020808301908036833701905050905061353c8542614804565b8160008151811061355d57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526060906001600160a01b0388169063883bdbfd906135a190859060040161432e565b60006040518083038186803b1580156135b957600080fd5b505afa1580156135cd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135f59190810190613e39565b50905060006136048786614804565b63ffffffff1690506000818360008151811061363057634e487b7160e01b600052603260045260246000fd5b60200260200101518861364391906147a8565b61364d9190614670565b9998505050505050505050565b60008060008360020b12613671578260020b61367e565b8260020b61367e906148e8565b905061368d620d89e7196148c7565b60020b8111156136c35760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610a27565b6000600182166136d757600160801b6136e9565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615613728576080613723826ffff97272373d413259a46990580e213a614742565b901c90505b600482161561375257608061374d826ffff2e50f5f656932ef12357cf3c7fdcc614742565b901c90505b600882161561377c576080613777826fffe5caca7e10e4e61c3624eaa0941cd0614742565b901c90505b60108216156137a65760806137a1826fffcb9843d60f6159c9db58835c926644614742565b901c90505b60208216156137d05760806137cb826fff973b41fa98c081472e6896dfb254c0614742565b901c90505b60408216156137fa5760806137f5826fff2ea16466c96a3843ec78b326b52861614742565b901c90505b608082161561382457608061381f826ffe5dee046a99a2a811c461f1969c3053614742565b901c90505b61010082161561384f57608061384a826ffcbe86c7900a88aedcffc83b479aa3a4614742565b901c90505b61020082161561387a576080613875826ff987a7253ac413176f2b074cf7815e54614742565b901c90505b6104008216156138a55760806138a0826ff3392b0822b70005940c7a398e4b70f3614742565b901c90505b6108008216156138d05760806138cb826fe7159475a2c29b7443b29c7fa6e889d9614742565b901c90505b6110008216156138fb5760806138f6826fd097f3bdfd2022b8845ad8f792aa5825614742565b901c90505b612000821615613926576080613921826fa9f746462d870fdf8a65dc1f90e061e5614742565b901c90505b61400082161561395157608061394c826f70d869a156d2a1b890bb3df62baf32f7614742565b901c90505b61800082161561397c576080613977826f31be135f97d08fd981231505542fcfa6614742565b901c90505b620100008216156139a85760806139a3826f09aa508b5b7a84e1c677de54f3e99bc9614742565b901c90505b620200008216156139d35760806139ce826e5d6af8dedb81196699c329225ee604614742565b901c90505b620400008216156139fd5760806139f8826d2216e584f5fa1ea926041bedfe98614742565b901c90505b62080000821615613a25576080613a20826b048a170391f7dc42444e8fa2614742565b901c90505b60008460020b1315613a4057613a3d816000196146a5565b90505b613a4f640100000000826148b3565b15613a5b576001613a5e565b60005b6128a19060ff16602083901c6145ff565b60008160020b8360020b121561320057816120f3565b60008160020b8360020b1261320057816120f3565b600080613aa78385614636565b905060008460020b128015613ac75750613ac18385614870565b60020b15155b15613ada57613ad7600182614761565b90505b6128a183826146b9565b600080613af18385614636565b905060008460020b138015613b115750613b0b8385614870565b60020b15155b15613ada57613ad7816001614593565b6000818152600183016020526040812054613b68575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556126d2565b5060006126d2565b6000826000018281548110613b9557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60608315613bb75750816120f3565b825115613bc75782518084602001fd5b8160405162461bcd60e51b8152600401610a27919061436c565b60408051608081018252600080825260208201819052918101829052606081019190915260405163252c09d760e01b8152600481018390526001600160a01b0384169063252c09d79060240160806040518083038186803b158015613c4557600080fd5b505afa158015613c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c7d91906141cf565b151560608501526001600160a01b03166040840152600690810b900b602083015263ffffffff16815292915050565b828054828255906000526020600020908101928215613ce7579160200282015b82811115613ce7578251825591602001919060010190613ccc565b50613cf3929150613cf7565b5090565b5b80821115613cf35760008155600101613cf8565b600082601f830112613d1c578081fd5b81516020613d31613d2c8361456f565b61453e565b80838252828201915082860187848660051b8901011115613d50578586fd5b855b85811015613d77578151613d658161495e565b84529284019290840190600101613d52565b5090979650505050505050565b8051600681900b8114613d9657600080fd5b919050565b805161ffff81168114613d9657600080fd5b600060208284031215613dbe578081fd5b81356120f38161495e565b60008060208385031215613ddb578081fd5b823567ffffffffffffffff80821115613df2578283fd5b818501915085601f830112613e05578283fd5b813581811115613e13578384fd5b8660208260051b8501011115613e27578384fd5b60209290920196919550909350505050565b60008060408385031215613e4b578182fd5b825167ffffffffffffffff80821115613e62578384fd5b818501915085601f830112613e75578384fd5b81516020613e85613d2c8361456f565b8083825282820191508286018a848660051b8901011115613ea4578889fd5b8896505b84871015613ecd57613eb981613d84565b835260019690960195918301918301613ea8565b5091880151919650909350505080821115613ee6578283fd5b50613ef385828601613d0c565b9150509250929050565b600060208284031215613f0e578081fd5b81516120f381614973565b600060208284031215613f2a578081fd5b81516120f381614981565b600060208284031215613f46578081fd5b815167ffffffffffffffff80821115613f5d578283fd5b818401915084601f830112613f70578283fd5b815181811115613f8257613f82614948565b613f95601f8201601f191660200161453e565b9150808252856020828501011115613fab578384fd5b613fbc816020840160208601614829565b50949350505050565b600080600080600080600060e0888a031215613fdf578283fd5b8751613fea8161495e565b6020890151909750613ffb81614981565b955061400960408901613d9b565b945061401760608901613d9b565b935061402560808901613d9b565b925060a088015160ff8116811461403a578283fd5b60c089015190925061404b81614973565b8091505092959891949750929550565b60006020828403121561406c578081fd5b5035919050565b600060208284031215614084578081fd5b5051919050565b6000806040838503121561409d578182fd5b8235915060208301356140af8161495e565b809150509250929050565b600080604083850312156140cc578182fd5b8235915060208301356140af81614973565b600080600080608085870312156140f3578182fd5b8451935060208501516001600160801b0381168114614110578283fd5b6040860151606090960151949790965092505050565b60008060408385031215614138578182fd5b50508035926020909101359150565b60008060408385031215614159578182fd5b505080516020909101519092909150565b60008060006060848603121561417e578081fd5b8335925060208401359150604084013561419781614981565b809150509250925092565b6000806000606084860312156141b6578081fd5b8351925060208401519150604084015190509250925092565b600080600080608085870312156141e4578182fd5b845163ffffffff811681146141f7578283fd5b935061420560208601613d84565b925060408501516142158161495e565b606086015190925061422681614973565b939692955090935050565b60008151808452614249816020860160208601614829565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b6000825161427f818460208701614829565b9190910192915050565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b828110156142dd57603f198886030184526142cb858351614231565b945092850192908501906001016142af565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561432257835183529284019291840191600101614306565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561432257835163ffffffff168352928401929184019160010161434a565b6020815260006120f36020830184614231565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b81516001600160a01b031681526101608101602083015161445a60208401826001600160a01b03169052565b506040830151614471604084018262ffffff169052565b506060830151614486606084018260020b9052565b50608083015161449b608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516144e1828501826001600160a01b03169052565b505061014092830151919092015290565b6000808335601e19843603018112614508578283fd5b83018035915067ffffffffffffffff821115614522578283fd5b60200191503681900382131561453757600080fd5b9250929050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561456757614567614948565b604052919050565b600067ffffffffffffffff82111561458957614589614948565b5060051b60200190565b60008160020b8360020b82821282627fffff038213811516156145b8576145b861491c565b82627fffff190382128116156145d0576145d061491c565b50019392505050565b600061ffff8083168185168083038211156145f6576145f661491c565b01949350505050565b600082198211156146125761461261491c565b500190565b600063ffffffff8083168185168083038211156145f6576145f661491c565b60008160020b8360020b8061464d5761464d614932565b627fffff198214600019821416156146675761466761491c565b90059392505050565b60008160060b8360060b8061468757614687614932565b667fffffffffffff198214600019821416156146675761466761491c565b6000826146b4576146b4614932565b500490565b60008160020b8360020b627fffff838213848413838304851182821616156146e3576146e361491c565b627fffff19868512828116878305871216156147015761470161491c565b87871292508582058712848416161561471c5761471c61491c565b858505871281841616156147325761473261491c565b5050509290910295945050505050565b600081600019048311821515161561475c5761475c61491c565b500290565b60008160020b8360020b82811281627fffff19018312811516156147875761478761491c565b81627fffff01831381161561479e5761479e61491c565b5090039392505050565b60008160060b8360060b82811281667fffffffffffff19018312811516156147d2576147d261491c565b81667fffffffffffff01831381161561479e5761479e61491c565b6000828210156147ff576147ff61491c565b500390565b600063ffffffff838116908316818110156148215761482161491c565b039392505050565b60005b8381101561484457818101518382015260200161482c565b8381111561323f5750506000910152565b60006000198214156148695761486961491c565b5060010190565b60008260020b8061488357614883614932565b808360020b0791505092915050565b600061ffff808416806148a7576148a7614932565b92169190910692915050565b6000826148c2576148c2614932565b500690565b60008160020b627fffff198114156148e1576148e161491c565b9003919050565b6000600160ff1b8214156148fe576148fe61491c565b0390565b60008160060b667fffffffffffff198114156148e1576148e15b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611e9e57600080fd5b8015158114611e9e57600080fd5b8060020b8114611e9e57600080fdfea2646970667358221220ba8035a22f1aceb50bdeb14918578d1f567bddfb7e4bfaf5a421df8fe62e754964736f6c63430008040033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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