MATIC Price: $0.99 (-2.65%)
Gas: 162 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040268506042022-04-07 11:40:20722 days ago1649331620IN
 Create: PriceFeed
0 MATIC0.0726872230.07071101

Parent Txn Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PriceFeed

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)

File 1 of 16 : PriceFeed.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Inheritance
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "../utils/libraries/UniswapMath.sol";

// Libraries
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";

// Internal references
// AggregatorInterface from Chainlink represents a decentralized pricing network for a single currency key
import "@chainlink/contracts-0.0.10/src/v0.5/interfaces/AggregatorV2V3Interface.sol";

import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

contract PriceFeed is Initializable, ProxyOwned {
    using SafeMath for uint;

    // Decentralized oracle networks that feed into pricing aggregators
    mapping(bytes32 => AggregatorV2V3Interface) public aggregators;

    mapping(bytes32 => uint8) public currencyKeyDecimals;

    bytes32[] public aggregatorKeys;

    // List of currency keys for convenient iteration
    bytes32[] public currencyKeys;
    mapping(bytes32 => IUniswapV3Pool) public pools;

    int56 public twapInterval;

    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    address public _ETH;
    address public _wETH;

    function initialize(address _owner) external initializer {
        setOwner(_owner);
        twapInterval = 300;
    }

    /* ========== MUTATIVE FUNCTIONS ========== */
    function addAggregator(bytes32 currencyKey, address aggregatorAddress) external onlyOwner {
        AggregatorV2V3Interface aggregator = AggregatorV2V3Interface(aggregatorAddress);
        require(aggregator.latestRound() >= 0, "Given Aggregator is invalid");
        uint8 decimals = aggregator.decimals();
        require(decimals <= 18, "Aggregator decimals should be lower or equal to 18");
        if (address(aggregators[currencyKey]) == address(0)) {
            currencyKeys.push(currencyKey);
        }
        aggregators[currencyKey] = aggregator;
        currencyKeyDecimals[currencyKey] = decimals;
        emit AggregatorAdded(currencyKey, address(aggregator));
    }

    function addPool(bytes32 currencyKey, address currencyAddress, address poolAddress) external onlyOwner {
        // check if aggregator exists for given currency key
        AggregatorV2V3Interface aggregator = aggregators[currencyKey];
        require(address(aggregator) == address(0), "Aggregator already exists for key");

        IUniswapV3Pool pool = IUniswapV3Pool(poolAddress);
        address token0 = pool.token0();
        address token1 = pool.token1();
        bool token0valid = token0 == _wETH || token0 == _ETH;
        bool token1valid = token1 == _wETH || token1 == _ETH;

        // check if one of tokens is wETH or ETH
        require(token0valid || token1valid, "Pool not valid: ETH is not an asset");
        // check if currency is asset in given
        require(currencyAddress == token0 || currencyAddress == token1, "Pool not valid: currency is not an asset");
        (uint160 sqrtPriceX96, , , , , , ) = pool.slot0();
        require(sqrtPriceX96 > 0, "Pool not valid");
        if (address(pools[currencyKey]) == address(0)) {
            currencyKeys.push(currencyKey);
        }
        pools[currencyKey] = pool;
        currencyKeyDecimals[currencyKey] = 18;
        emit PoolAdded(currencyKey, address(pool));
    }

    function removeAggregator(bytes32 currencyKey) external onlyOwner {
        address aggregator = address(aggregators[currencyKey]);
        require(aggregator != address(0), "No aggregator exists for key");
        delete aggregators[currencyKey];
        delete currencyKeyDecimals[currencyKey];

        bool wasRemoved = removeFromArray(currencyKey, currencyKeys);

        if (wasRemoved) {
            emit AggregatorRemoved(currencyKey, aggregator);
        }
    }

    function removePool(bytes32 currencyKey) external onlyOwner {
        address pool = address(pools[currencyKey]);
        require(pool != address(0), "No pool exists for key");
        delete pools[currencyKey];

        bool wasRemoved = removeFromArray(currencyKey, currencyKeys);
        if (wasRemoved) {
            emit PoolRemoved(currencyKey, pool);
        }
    }

    function getRates() external view returns (uint[] memory rates) {
        uint count = 0;
        rates = new uint[](currencyKeys.length);
        for (uint i = 0; i < currencyKeys.length; i++) {
            bytes32 currencyKey = currencyKeys[i];
            rates[count++] = _getRateAndUpdatedTime(currencyKey).rate;
        }
    }

    function getCurrencies() external view returns (bytes32[] memory) {
        return currencyKeys;
    }

    function rateForCurrency(bytes32 currencyKey) external view returns (uint) {
        return _getRateAndUpdatedTime(currencyKey).rate;
    }

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time) {
        RateAndUpdatedTime memory rateAndTime = _getRateAndUpdatedTime(currencyKey);
        return (rateAndTime.rate, rateAndTime.time);
    }

    function removeFromArray(bytes32 entry, bytes32[] storage array) internal returns (bool) {
        for (uint i = 0; i < array.length; i++) {
            if (array[i] == entry) {
                delete array[i];
                array[i] = array[array.length - 1];
                array.pop();
                return true;
            }
        }
        return false;
    }

    function setTwapInterval(int56 _twapInterval) external onlyOwner {
        twapInterval = _twapInterval;
    }

    function setWETH(address token) external onlyOwner {
        _wETH = token;
        emit AddressChangedwETH(token);
    }

    function setETH(address token) external onlyOwner {
        _ETH = token;
        emit AddressChangedETH(token);
    }

    function _formatAnswer(bytes32 currencyKey, int256 rate) internal view returns (uint) {
        require(rate >= 0, "Negative rate not supported");
        if (currencyKeyDecimals[currencyKey] > 0) {
            uint multiplier = 10**uint(SafeMath.sub(18, currencyKeyDecimals[currencyKey]));
            return uint(uint(rate).mul(multiplier));
        }
        return uint(rate);
    }

    function _getRateAndUpdatedTime(bytes32 currencyKey) internal view returns (RateAndUpdatedTime memory) {
        AggregatorV2V3Interface aggregator = aggregators[currencyKey];
        IUniswapV3Pool pool = pools[currencyKey];
        require(address(aggregator) != address(0) || address(pool) != address(0), "No aggregator or pool exists for key");

        if (aggregator != AggregatorV2V3Interface(address(0))) {
            return _getAggregatorRate(address(aggregator), currencyKey);
        } else {
            require(address(aggregators["ETH"]) != address(0), "Price for ETH does not exist");
            uint256 ratio = _getPriceFromSqrtPrice(_getTwap(address(pool)));
            uint256 ethPrice = _getAggregatorRate(address(aggregators["ETH"]), "ETH").rate * 10**18; 
            address token0 = pool.token0();
            uint answer;

            if(token0 == _ETH || token0 == _wETH) {
                answer = ethPrice / ratio;
            } else {
                answer = ethPrice * ratio;
            }
            return
                RateAndUpdatedTime({
                    rate: uint216(_formatAnswer(currencyKey, int256(answer))),
                    time: uint40(block.timestamp)
                });
        }
    }

    function _getAggregatorRate(address aggregator, bytes32 currencyKey) internal view returns (RateAndUpdatedTime memory ) {
        // this view from the aggregator is the most gas efficient but it can throw when there's no data,
        // so let's call it low-level to suppress any reverts
        bytes memory payload = abi.encodeWithSignature("latestRoundData()");
        // solhint-disable avoid-low-level-calls
        (bool success, bytes memory returnData) = aggregator.staticcall(payload);

        if (success) {
            (, int256 answer, , uint256 updatedAt, ) = abi.decode(
                returnData,
                (uint80, int256, uint256, uint256, uint80)
            );
            return RateAndUpdatedTime({rate: uint216(_formatAnswer(currencyKey, answer)), time: uint40(updatedAt)});
        }
    }

    function _getTwap(address pool) internal view returns (uint160 sqrtPriceX96) {
        if (twapInterval == 0) {
            // return the current price if twapInterval == 0
            (sqrtPriceX96, , , , , , ) = IUniswapV3Pool(pool).slot0();
        } else {
            uint32[] memory secondsAgos = new uint32[](2);
            secondsAgos[0] = uint32(uint56(twapInterval));
            secondsAgos[1] = 0; // to (now)

            (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondsAgos);
            // tick(imprecise as it's an integer) to price
            sqrtPriceX96 = UniswapMath.getSqrtRatioAtTick(int24((tickCumulatives[1] - tickCumulatives[0]) / twapInterval));
        }
    }

    function _getPriceFromSqrtPrice(uint160 sqrtPriceX96) internal pure returns (uint256 priceX96) {
        uint256 price = UniswapMath.mulDiv(sqrtPriceX96, sqrtPriceX96, UniswapMath.Q96);
        return UniswapMath.mulDiv(price, 10**18, UniswapMath.Q96);
    }

    function transferCurrencyKeys() external onlyOwner {
        require(currencyKeys.length == 0, "Currency keys is not empty");
        for (uint i = 0; i < aggregatorKeys.length; i++) {
            currencyKeys[i] = aggregatorKeys[i];
        }
    }

    /* ========== EVENTS ========== */
    event AggregatorAdded(bytes32 currencyKey, address aggregator);
    event AggregatorRemoved(bytes32 currencyKey, address aggregator);
    event PoolAdded(bytes32 currencyKey, address pool);
    event PoolRemoved(bytes32 currencyKey, address pool);
    event AddressChangedETH(address token);
    event AddressChangedwETH(address token);
}

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

// Clone of syntetix contract without constructor
contract ProxyOwned {
    address public owner;
    address public nominatedOwner;
    bool private _initialized;
    bool private _transferredAtInit;

    function setOwner(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        require(!_initialized, "Already initialized, use nominateNewOwner");
        _initialized = true;
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
        require(proxyAddress != address(0), "Invalid address");
        require(!_transferredAtInit, "Already transferred");
        owner = proxyAddress;
        _transferredAtInit = true;
        emit OwnerChanged(owner, proxyAddress);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}

File 3 of 16 : UniswapMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Math library for computing sqrt prices from ticks and vice versa; Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision;
/// Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits

library UniswapMath {
    uint256 internal constant Q192 = 0x1000000000000000000000000000000000000000000000000;
    uint256 internal constant Q96 = 0x1000000000000000000000000;

    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

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

    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        // 512-bit multiply [prod1 prod0] = a * b
        // Compute the product mod 2**256 and mod 2**256 - 1
        // then use the Chinese Remainder Theorem to reconstruct
        // the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2**256 + prod0
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(a, b, not(0))
            prod0 := mul(a, b)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

        uint256 r = ratio;
        uint256 msb = 0;

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

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

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

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

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

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

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

File 4 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 5 of 16 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

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

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

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

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

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

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

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

File 6 of 16 : AggregatorV2V3Interface.sol
pragma solidity >=0.5.0;

import "./AggregatorInterface.sol";
import "./AggregatorV3Interface.sol";

/**
 * @title The V2 & V3 Aggregator Interface
 * @notice Solidity V0.5 does not allow interfaces to inherit from other
 * interfaces so this contract is a combination of v0.5 AggregatorInterface.sol
 * and v0.5 AggregatorV3Interface.sol.
 */
interface AggregatorV2V3Interface {
  //
  // V2 Interface:
  //
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);

  //
  // V3 Interface:
  //
  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

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

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

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

}

File 8 of 16 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

File 9 of 16 : AggregatorInterface.sol
pragma solidity >=0.5.0;

interface AggregatorInterface {
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}

File 10 of 16 : AggregatorV3Interface.sol
pragma solidity >=0.5.0;

interface AggregatorV3Interface {

  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"AddressChangedETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"AddressChangedwETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"pool","type":"address"}],"name":"PoolAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"pool","type":"address"}],"name":"PoolRemoved","type":"event"},{"inputs":[],"name":"_ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_wETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"address","name":"aggregatorAddress","type":"address"}],"name":"addAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"address","name":"poolAddress","type":"address"}],"name":"addPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"aggregatorKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"aggregators","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currencyKeyDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"currencyKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrencies","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRates","outputs":[{"internalType":"uint256[]","name":"rates","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"pools","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateAndUpdatedTime","outputs":[{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateForCurrency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"removeAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"removePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"setETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int56","name":"_twapInterval","type":"int56"}],"name":"setTwapInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"setWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferCurrencyKeys","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"twapInterval","outputs":[{"internalType":"int56","name":"","type":"int56"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50612ac6806100206000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80637103353e116100f9578063b295ad3411610097578063c0c7df6f11610071578063c0c7df6f146103ee578063c3b83f5f14610401578063c4d66de814610414578063e4d8f8a61461042757600080fd5b8063b295ad341461037d578063b40ee76d146103b2578063b5217bb4146103c557600080fd5b80638da5cb5b116100d35780638da5cb5b1461033657806399a440f61461034f5780639accab5514610362578063ac82f6081461036a57600080fd5b80637103353e146102f257806379ba50971461031b5780637a5a2a981461032357600080fd5b80634308a94f1161016657806353a47bb71161014057806353a47bb7146102855780635b769f3c146102b05780635db99af2146102c357806361c661de146102dd57600080fd5b80634308a94f14610234578063464612401461025c5780634f72def61461026457600080fd5b806313af4035146101ae5780631627540c146101c35780632bed9e0c146101d65780633b824b8c146101e95780633c1d5df0146101fc5780633f0e084f14610221575b600080fd5b6101c16101bc3660046123ec565b61043a565b005b6101c16101d13660046123ec565b61057a565b6101c16101e43660046124ea565b6105d0565b6101c16101f7366004612531565b6106c6565b6007546102099060060b81565b60405160069190910b81526020015b60405180910390f35b6101c161022f366004612502565b610b23565b6102476102423660046124ea565b610da6565b60408051928352602083019190915201610218565b6101c1610dd9565b6102776102723660046124ea565b610eac565b604051908152602001610218565b600154610298906001600160a01b031681565b6040516001600160a01b039091168152602001610218565b6101c16102be3660046123ec565b610ecd565b60075461029890600160381b90046001600160a01b031681565b6102e5610f23565b60405161021891906126e0565b6102986103003660046124ea565b6002602052600090815260409020546001600160a01b031681565b6101c1610f7b565b6101c16103313660046123ec565b611078565b600054610298906201000090046001600160a01b031681565b61027761035d3660046124ea565b6110de565b6102e56110ee565b6102776103783660046124ea565b6111e7565b6103a061038b3660046124ea565b60036020526000908152604090205460ff1681565b60405160ff9091168152602001610218565b6101c16103c0366004612572565b611202565b6102986103d33660046124ea565b6006602052600090815260409020546001600160a01b031681565b600854610298906001600160a01b031681565b6101c161040f3660046123ec565b611231565b6101c16104223660046123ec565b61134a565b6101c16104353660046124ea565b611421565b6001600160a01b0381166104955760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156105015760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b606482015260840161048c565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6105826114f4565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200161056f565b6105d86114f4565b6000818152600260205260409020546001600160a01b03168061063d5760405162461bcd60e51b815260206004820152601c60248201527f4e6f2061676772656761746f722065786973747320666f72206b657900000000604482015260640161048c565b600082815260026020908152604080832080546001600160a01b031916905560039091528120805460ff1916905561067683600561156e565b905080156106c157604080518481526001600160a01b03841660208201527fec70e890fc7db7de4059b114c9093a1f41283d18ffcfbcac45566feea4d4f77791015b60405180910390a15b505050565b6106ce6114f4565b6000838152600260205260409020546001600160a01b0316801561073e5760405162461bcd60e51b815260206004820152602160248201527f41676772656761746f7220616c72656164792065786973747320666f72206b656044820152607960f81b606482015260840161048c565b60008290506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561077e57600080fd5b505afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b69190612408565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156107f357600080fd5b505afa158015610807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082b9190612408565b6008549091506000906001600160a01b038481169116148061086157506007546001600160a01b03848116600160381b90920416145b6008549091506000906001600160a01b038481169116148061089757506007546001600160a01b03848116600160381b90920416145b905081806108a25750805b6108fa5760405162461bcd60e51b815260206004820152602360248201527f506f6f6c206e6f742076616c69643a20455448206973206e6f7420616e2061736044820152621cd95d60ea1b606482015260840161048c565b836001600160a01b0316886001600160a01b0316148061092b5750826001600160a01b0316886001600160a01b0316145b6109885760405162461bcd60e51b815260206004820152602860248201527f506f6f6c206e6f742076616c69643a2063757272656e6379206973206e6f7420604482015267185b88185cdcd95d60c21b606482015260840161048c565b6000856001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156109c357600080fd5b505afa1580156109d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fb919061258e565b50505050505090506000816001600160a01b031611610a4d5760405162461bcd60e51b815260206004820152600e60248201526d141bdbdb081b9bdd081d985b1a5960921b604482015260640161048c565b60008a8152600660205260409020546001600160a01b0316610a9f57600580546001810182556000919091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0018a90555b60008a815260066020908152604080832080546001600160a01b038b166001600160a01b031990911681179091556003835292819020805460ff1916601217905580518d8152918201929092527ffd0fa7919fbe3857a4236750e8d3e42ac691881d2f31c50ebe4cfc2a7705ee80910160405180910390a150505050505050505050565b610b2b6114f4565b60008190506000816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6b57600080fd5b505afa158015610b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba39190612626565b1015610bf15760405162461bcd60e51b815260206004820152601b60248201527f476976656e2041676772656761746f7220697320696e76616c69640000000000604482015260640161048c565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2c57600080fd5b505afa158015610c40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c64919061268d565b905060128160ff161115610cd55760405162461bcd60e51b815260206004820152603260248201527f41676772656761746f7220646563696d616c732073686f756c64206265206c6f6044820152710eecae440dee440cae2eac2d840e8de4062760731b606482015260840161048c565b6000848152600260205260409020546001600160a01b0316610d2757600580546001810182556000919091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0018490555b600084815260026020908152604080832080546001600160a01b0319166001600160a01b0387169081179091556003835292819020805460ff191660ff86161790558051878152918201929092527f0bcae573430f69c5361e5d76534d3f61d2d803958778680cd74be9dc6299bc63910160405180910390a150505050565b6000806000610db48461169b565b80516020909101516001600160d81b039091169564ffffffffff909116945092505050565b610de16114f4565b60055415610e315760405162461bcd60e51b815260206004820152601a60248201527f43757272656e6379206b657973206973206e6f7420656d707479000000000000604482015260640161048c565b60005b600454811015610ea95760048181548110610e5f57634e487b7160e01b600052603260045260246000fd5b906000526020600020015460058281548110610e8b57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015580610ea1816129c0565b915050610e34565b50565b60048181548110610ebc57600080fd5b600091825260209091200154905081565b610ed56114f4565b600880546001600160a01b0319166001600160a01b0383169081179091556040519081527f8121e397d1abdd9a4231e6d2a3da170b653b62342667c1ed8697d07f560836eb9060200161056f565b60606005805480602002602001604051908101604052809291908181526020018280548015610f7157602002820191906000526020600020905b815481526020019060010190808311610f5d575b5050505050905090565b6001546001600160a01b03163314610ff35760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b606482015260840161048c565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6110806114f4565b60078054670100000000000000600160d81b031916600160381b6001600160a01b038416908102919091179091556040519081527f9869fd5d75bcb7e8ecd63be9bdc2491f03bf7773f4f978ae21d550598f89a5ca9060200161056f565b60058181548110610ebc57600080fd5b60055460609060009067ffffffffffffffff81111561111d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611146578160200160208202803683370190505b50915060005b6005548110156111e25760006005828154811061117957634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905061118f8161169b565b516001600160d81b031684846111a4816129c0565b9550815181106111c457634e487b7160e01b600052603260045260246000fd5b602090810291909101015250806111da816129c0565b91505061114c565b505090565b60006111f28261169b565b516001600160d81b031692915050565b61120a6114f4565b6007805460069290920b66ffffffffffffff1666ffffffffffffff19909216919091179055565b6112396114f4565b6001600160a01b0381166112815760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161048c565b600154600160a81b900460ff16156112d15760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b604482015260640161048c565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910161056f565b600054610100900460ff166113655760005460ff1615611369565b303b155b6113cc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161048c565b600054610100900460ff161580156113ee576000805461ffff19166101011790555b6113f78261043a565b6007805466ffffffffffffff191661012c179055801561141d576000805461ff00191690555b5050565b6114296114f4565b6000818152600660205260409020546001600160a01b0316806114875760405162461bcd60e51b81526020600482015260166024820152754e6f20706f6f6c2065786973747320666f72206b657960501b604482015260640161048c565b600082815260066020526040812080546001600160a01b03191690556114ae83600561156e565b905080156106c157604080518481526001600160a01b03841660208201527fec6c5a212891ee59cd0846cf5c9bb92c3cb05e7dc0191e73abec1ac38822b97391016106b8565b6000546201000090046001600160a01b0316331461156c5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b606482015260840161048c565b565b6000805b825481101561168f578383828154811061159c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154141561167d578281815481106115cd57634e487b7160e01b600052603260045260246000fd5b6000918252602082200155825483906115e8906001906129a9565b8154811061160657634e487b7160e01b600052603260045260246000fd5b906000526020600020015483828154811061163157634e487b7160e01b600052603260045260246000fd5b90600052602060002001819055508280548061165d57634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590556001915050611695565b80611687816129c0565b915050611572565b50600090505b92915050565b60408051808201909152600080825260208201526000828152600260209081526040808320546006909252909120546001600160a01b039182169116811515806116ed57506001600160a01b03811615155b6117455760405162461bcd60e51b8152602060048201526024808201527f4e6f2061676772656761746f72206f7220706f6f6c2065786973747320666f72604482015263206b657960e01b606482015260840161048c565b6001600160a01b038216156117665761175e828561196f565b949350505050565b6208aa8960eb1b60005260026020527fd9402e47e68a5154d8f9cdc9d4ffcf4a300546026372c3b04224fbe62656c601546001600160a01b03166117ec5760405162461bcd60e51b815260206004820152601c60248201527f507269636520666f722045544820646f6573206e6f7420657869737400000000604482015260640161048c565b60006117ff6117fa83611a74565b611ca9565b6208aa8960eb1b600081815260026020527fd9402e47e68a5154d8f9cdc9d4ffcf4a300546026372c3b04224fbe62656c601549293509161184b916001600160a01b039091169061196f565b5161185e90670de0b6b3a764000061290c565b6001600160d81b031690506000836001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118dc9190612408565b6007549091506000906001600160a01b03808416600160381b90920416148061191257506008546001600160a01b038381169116145b1561192857611921848461280d565b9050611935565b611932848461293b565b90505b604051806040016040528061194a8a84611ce4565b6001600160d81b0316815264ffffffffff421660209091015298975050505050505050565b604080518082019091526000808252602082015260408051600481526024810182526020810180516001600160e01b0316633fabe5a360e21b179052905160009081906001600160a01b038716906119c89085906126a7565b600060405180830381855afa9150503d8060008114611a03576040519150601f19603f3d011682016040523d82523d6000602084013e611a08565b606091505b50915091508115611a6b5760008082806020019051810190611a2a919061263e565b509350509250506040518060400160405280611a468985611ce4565b6001600160d81b031681526020018264ffffffffff1681525095505050505050611695565b50505092915050565b600754600090600690810b900b611b0557816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af6919061258e565b50949550611ca4945050505050565b6040805160028082526060820183526000926020830190803683375050600754825192935060060b91839150600090611b4e57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110611b8b57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611bcf908590600401612724565b60006040518083038186803b158015611be757600080fd5b505afa158015611bfb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c239190810190612424565b50905061175e600760009054906101000a900460060b82600081518110611c5a57634e487b7160e01b600052603260045260246000fd5b602002602001015183600181518110611c8357634e487b7160e01b600052603260045260246000fd5b6020026020010151611c95919061295a565b611c9f91906127cf565b611d90565b919050565b600080611cc46001600160a01b03841680600160601b6121a5565b9050611cdd81670de0b6b3a7640000600160601b6121a5565b9392505050565b600080821215611d365760405162461bcd60e51b815260206004820152601b60248201527f4e656761746976652072617465206e6f7420737570706f727465640000000000604482015260640161048c565b60008381526003602052604090205460ff1615611d8a57600083815260036020526040812054611d6b9060129060ff1661231f565b611d7690600a612864565b9050611d82838261232b565b915050611695565b50919050565b60008060008360020b12611da7578260020b611db4565b8260020b611db490612a10565b9050611dc3620d89e7196129ef565b60020b811115611df95760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161048c565b600060018216611e0d57600160801b611e1f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611e5e576080611e59826ffff97272373d413259a46990580e213a61293b565b901c90505b6004821615611e88576080611e83826ffff2e50f5f656932ef12357cf3c7fdcc61293b565b901c90505b6008821615611eb2576080611ead826fffe5caca7e10e4e61c3624eaa0941cd061293b565b901c90505b6010821615611edc576080611ed7826fffcb9843d60f6159c9db58835c92664461293b565b901c90505b6020821615611f06576080611f01826fff973b41fa98c081472e6896dfb254c061293b565b901c90505b6040821615611f30576080611f2b826fff2ea16466c96a3843ec78b326b5286161293b565b901c90505b6080821615611f5a576080611f55826ffe5dee046a99a2a811c461f1969c305361293b565b901c90505b610100821615611f85576080611f80826ffcbe86c7900a88aedcffc83b479aa3a461293b565b901c90505b610200821615611fb0576080611fab826ff987a7253ac413176f2b074cf7815e5461293b565b901c90505b610400821615611fdb576080611fd6826ff3392b0822b70005940c7a398e4b70f361293b565b901c90505b610800821615612006576080612001826fe7159475a2c29b7443b29c7fa6e889d961293b565b901c90505b61100082161561203157608061202c826fd097f3bdfd2022b8845ad8f792aa582561293b565b901c90505b61200082161561205c576080612057826fa9f746462d870fdf8a65dc1f90e061e561293b565b901c90505b614000821615612087576080612082826f70d869a156d2a1b890bb3df62baf32f761293b565b901c90505b6180008216156120b25760806120ad826f31be135f97d08fd981231505542fcfa661293b565b901c90505b620100008216156120de5760806120d9826f09aa508b5b7a84e1c677de54f3e99bc961293b565b901c90505b62020000821615612109576080612104826e5d6af8dedb81196699c329225ee60461293b565b901c90505b6204000082161561213357608061212e826d2216e584f5fa1ea926041bedfe9861293b565b901c90505b6208000082161561215b576080612156826b048a170391f7dc42444e8fa261293b565b901c90505b60008460020b1315612176576121738160001961280d565b90505b612185640100000000826129db565b15612191576001612194565b60005b61175e9060ff16602083901c6127b7565b6000808060001985870985870292508281108382030391505080600014156121df57600084116121d457600080fd5b508290049050611cdd565b8084116121eb57600080fd5b600084868809808403938111909203919050600061220b861960016127b7565b861695869004959384900493600081900304600101905061222c818461293b565b90931792600061223d87600361293b565b600218905061224c818861293b565b6122579060026129a9565b612261908261293b565b905061226d818861293b565b6122789060026129a9565b612282908261293b565b905061228e818861293b565b6122999060026129a9565b6122a3908261293b565b90506122af818861293b565b6122ba9060026129a9565b6122c4908261293b565b90506122d0818861293b565b6122db9060026129a9565b6122e5908261293b565b90506122f1818861293b565b6122fc9060026129a9565b612306908261293b565b9050612312818661293b565b9998505050505050505050565b6000611cdd82846129a9565b6000611cdd828461293b565b600082601f830112612347578081fd5b8151602061235c61235783612793565b612762565b80838252828201915082860187848660051b890101111561237b578586fd5b855b858110156123a257815161239081612a6c565b8452928401929084019060010161237d565b5090979650505050505050565b805161ffff81168114611ca457600080fd5b805169ffffffffffffffffffff81168114611ca457600080fd5b805160ff81168114611ca457600080fd5b6000602082840312156123fd578081fd5b8135611cdd81612a6c565b600060208284031215612419578081fd5b8151611cdd81612a6c565b60008060408385031215612436578081fd5b825167ffffffffffffffff8082111561244d578283fd5b818501915085601f830112612460578283fd5b8151602061247061235783612793565b8083825282820191508286018a848660051b890101111561248f578788fd5b8796505b848710156124ba5780516124a681612a81565b835260019690960195918301918301612493565b50918801519196509093505050808211156124d3578283fd5b506124e085828601612337565b9150509250929050565b6000602082840312156124fb578081fd5b5035919050565b60008060408385031215612514578182fd5b82359150602083013561252681612a6c565b809150509250929050565b600080600060608486031215612545578081fd5b83359250602084013561255781612a6c565b9150604084013561256781612a6c565b809150509250925092565b600060208284031215612583578081fd5b8135611cdd81612a81565b600080600080600080600060e0888a0312156125a8578283fd5b87516125b381612a6c565b8097505060208801518060020b81146125ca578384fd5b95506125d8604089016123af565b94506125e6606089016123af565b93506125f4608089016123af565b925061260260a089016123db565b915060c08801518015158114612616578182fd5b8091505092959891949750929550565b600060208284031215612637578081fd5b5051919050565b600080600080600060a08688031215612655578283fd5b61265e866123c1565b9450602086015193506040860151925060608601519150612681608087016123c1565b90509295509295909350565b60006020828403121561269e578081fd5b611cdd826123db565b60008251815b818110156126c757602081860181015185830152016126ad565b818111156126d55782828501525b509190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015612718578351835292840192918401916001016126fc565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561271857835163ffffffff1683529284019291840191600101612740565b604051601f8201601f1916810167ffffffffffffffff8111828210171561278b5761278b612a56565b604052919050565b600067ffffffffffffffff8211156127ad576127ad612a56565b5060051b60200190565b600082198211156127ca576127ca612a2a565b500190565b60008160060b8360060b806127e6576127e6612a40565b667fffffffffffff1982146000198214161561280457612804612a2a565b90059392505050565b60008261281c5761281c612a40565b500490565b600181815b8085111561285c57816000190482111561284257612842612a2a565b8085161561284f57918102915b93841c9390800290612826565b509250929050565b6000611cdd838360008261287a57506001611695565b8161288757506000611695565b816001811461289d57600281146128a7576128c3565b6001915050611695565b60ff8411156128b8576128b8612a2a565b50506001821b611695565b5060208310610133831016604e8410600b84101617156128e6575081810a611695565b6128f08383612821565b806000190482111561290457612904612a2a565b029392505050565b60006001600160d81b038281168482168115158284048211161561293257612932612a2a565b02949350505050565b600081600019048311821515161561295557612955612a2a565b500290565b60008160060b8360060b82811281667fffffffffffff190183128115161561298457612984612a2a565b81667fffffffffffff01831381161561299f5761299f612a2a565b5090039392505050565b6000828210156129bb576129bb612a2a565b500390565b60006000198214156129d4576129d4612a2a565b5060010190565b6000826129ea576129ea612a40565b500690565b60008160020b627fffff19811415612a0957612a09612a2a565b9003919050565b6000600160ff1b821415612a2657612a26612a2a565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ea957600080fd5b8060060b8114610ea957600080fdfea2646970667358221220dc24d43308bf90c00d546fdc42ba1157bca5549f16e1d6c89650ba6f2b786c2564736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80637103353e116100f9578063b295ad3411610097578063c0c7df6f11610071578063c0c7df6f146103ee578063c3b83f5f14610401578063c4d66de814610414578063e4d8f8a61461042757600080fd5b8063b295ad341461037d578063b40ee76d146103b2578063b5217bb4146103c557600080fd5b80638da5cb5b116100d35780638da5cb5b1461033657806399a440f61461034f5780639accab5514610362578063ac82f6081461036a57600080fd5b80637103353e146102f257806379ba50971461031b5780637a5a2a981461032357600080fd5b80634308a94f1161016657806353a47bb71161014057806353a47bb7146102855780635b769f3c146102b05780635db99af2146102c357806361c661de146102dd57600080fd5b80634308a94f14610234578063464612401461025c5780634f72def61461026457600080fd5b806313af4035146101ae5780631627540c146101c35780632bed9e0c146101d65780633b824b8c146101e95780633c1d5df0146101fc5780633f0e084f14610221575b600080fd5b6101c16101bc3660046123ec565b61043a565b005b6101c16101d13660046123ec565b61057a565b6101c16101e43660046124ea565b6105d0565b6101c16101f7366004612531565b6106c6565b6007546102099060060b81565b60405160069190910b81526020015b60405180910390f35b6101c161022f366004612502565b610b23565b6102476102423660046124ea565b610da6565b60408051928352602083019190915201610218565b6101c1610dd9565b6102776102723660046124ea565b610eac565b604051908152602001610218565b600154610298906001600160a01b031681565b6040516001600160a01b039091168152602001610218565b6101c16102be3660046123ec565b610ecd565b60075461029890600160381b90046001600160a01b031681565b6102e5610f23565b60405161021891906126e0565b6102986103003660046124ea565b6002602052600090815260409020546001600160a01b031681565b6101c1610f7b565b6101c16103313660046123ec565b611078565b600054610298906201000090046001600160a01b031681565b61027761035d3660046124ea565b6110de565b6102e56110ee565b6102776103783660046124ea565b6111e7565b6103a061038b3660046124ea565b60036020526000908152604090205460ff1681565b60405160ff9091168152602001610218565b6101c16103c0366004612572565b611202565b6102986103d33660046124ea565b6006602052600090815260409020546001600160a01b031681565b600854610298906001600160a01b031681565b6101c161040f3660046123ec565b611231565b6101c16104223660046123ec565b61134a565b6101c16104353660046124ea565b611421565b6001600160a01b0381166104955760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156105015760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b606482015260840161048c565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6105826114f4565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200161056f565b6105d86114f4565b6000818152600260205260409020546001600160a01b03168061063d5760405162461bcd60e51b815260206004820152601c60248201527f4e6f2061676772656761746f722065786973747320666f72206b657900000000604482015260640161048c565b600082815260026020908152604080832080546001600160a01b031916905560039091528120805460ff1916905561067683600561156e565b905080156106c157604080518481526001600160a01b03841660208201527fec70e890fc7db7de4059b114c9093a1f41283d18ffcfbcac45566feea4d4f77791015b60405180910390a15b505050565b6106ce6114f4565b6000838152600260205260409020546001600160a01b0316801561073e5760405162461bcd60e51b815260206004820152602160248201527f41676772656761746f7220616c72656164792065786973747320666f72206b656044820152607960f81b606482015260840161048c565b60008290506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561077e57600080fd5b505afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b69190612408565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156107f357600080fd5b505afa158015610807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082b9190612408565b6008549091506000906001600160a01b038481169116148061086157506007546001600160a01b03848116600160381b90920416145b6008549091506000906001600160a01b038481169116148061089757506007546001600160a01b03848116600160381b90920416145b905081806108a25750805b6108fa5760405162461bcd60e51b815260206004820152602360248201527f506f6f6c206e6f742076616c69643a20455448206973206e6f7420616e2061736044820152621cd95d60ea1b606482015260840161048c565b836001600160a01b0316886001600160a01b0316148061092b5750826001600160a01b0316886001600160a01b0316145b6109885760405162461bcd60e51b815260206004820152602860248201527f506f6f6c206e6f742076616c69643a2063757272656e6379206973206e6f7420604482015267185b88185cdcd95d60c21b606482015260840161048c565b6000856001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156109c357600080fd5b505afa1580156109d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fb919061258e565b50505050505090506000816001600160a01b031611610a4d5760405162461bcd60e51b815260206004820152600e60248201526d141bdbdb081b9bdd081d985b1a5960921b604482015260640161048c565b60008a8152600660205260409020546001600160a01b0316610a9f57600580546001810182556000919091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0018a90555b60008a815260066020908152604080832080546001600160a01b038b166001600160a01b031990911681179091556003835292819020805460ff1916601217905580518d8152918201929092527ffd0fa7919fbe3857a4236750e8d3e42ac691881d2f31c50ebe4cfc2a7705ee80910160405180910390a150505050505050505050565b610b2b6114f4565b60008190506000816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6b57600080fd5b505afa158015610b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba39190612626565b1015610bf15760405162461bcd60e51b815260206004820152601b60248201527f476976656e2041676772656761746f7220697320696e76616c69640000000000604482015260640161048c565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2c57600080fd5b505afa158015610c40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c64919061268d565b905060128160ff161115610cd55760405162461bcd60e51b815260206004820152603260248201527f41676772656761746f7220646563696d616c732073686f756c64206265206c6f6044820152710eecae440dee440cae2eac2d840e8de4062760731b606482015260840161048c565b6000848152600260205260409020546001600160a01b0316610d2757600580546001810182556000919091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0018490555b600084815260026020908152604080832080546001600160a01b0319166001600160a01b0387169081179091556003835292819020805460ff191660ff86161790558051878152918201929092527f0bcae573430f69c5361e5d76534d3f61d2d803958778680cd74be9dc6299bc63910160405180910390a150505050565b6000806000610db48461169b565b80516020909101516001600160d81b039091169564ffffffffff909116945092505050565b610de16114f4565b60055415610e315760405162461bcd60e51b815260206004820152601a60248201527f43757272656e6379206b657973206973206e6f7420656d707479000000000000604482015260640161048c565b60005b600454811015610ea95760048181548110610e5f57634e487b7160e01b600052603260045260246000fd5b906000526020600020015460058281548110610e8b57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015580610ea1816129c0565b915050610e34565b50565b60048181548110610ebc57600080fd5b600091825260209091200154905081565b610ed56114f4565b600880546001600160a01b0319166001600160a01b0383169081179091556040519081527f8121e397d1abdd9a4231e6d2a3da170b653b62342667c1ed8697d07f560836eb9060200161056f565b60606005805480602002602001604051908101604052809291908181526020018280548015610f7157602002820191906000526020600020905b815481526020019060010190808311610f5d575b5050505050905090565b6001546001600160a01b03163314610ff35760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b606482015260840161048c565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6110806114f4565b60078054670100000000000000600160d81b031916600160381b6001600160a01b038416908102919091179091556040519081527f9869fd5d75bcb7e8ecd63be9bdc2491f03bf7773f4f978ae21d550598f89a5ca9060200161056f565b60058181548110610ebc57600080fd5b60055460609060009067ffffffffffffffff81111561111d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611146578160200160208202803683370190505b50915060005b6005548110156111e25760006005828154811061117957634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905061118f8161169b565b516001600160d81b031684846111a4816129c0565b9550815181106111c457634e487b7160e01b600052603260045260246000fd5b602090810291909101015250806111da816129c0565b91505061114c565b505090565b60006111f28261169b565b516001600160d81b031692915050565b61120a6114f4565b6007805460069290920b66ffffffffffffff1666ffffffffffffff19909216919091179055565b6112396114f4565b6001600160a01b0381166112815760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161048c565b600154600160a81b900460ff16156112d15760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b604482015260640161048c565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910161056f565b600054610100900460ff166113655760005460ff1615611369565b303b155b6113cc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161048c565b600054610100900460ff161580156113ee576000805461ffff19166101011790555b6113f78261043a565b6007805466ffffffffffffff191661012c179055801561141d576000805461ff00191690555b5050565b6114296114f4565b6000818152600660205260409020546001600160a01b0316806114875760405162461bcd60e51b81526020600482015260166024820152754e6f20706f6f6c2065786973747320666f72206b657960501b604482015260640161048c565b600082815260066020526040812080546001600160a01b03191690556114ae83600561156e565b905080156106c157604080518481526001600160a01b03841660208201527fec6c5a212891ee59cd0846cf5c9bb92c3cb05e7dc0191e73abec1ac38822b97391016106b8565b6000546201000090046001600160a01b0316331461156c5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b606482015260840161048c565b565b6000805b825481101561168f578383828154811061159c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154141561167d578281815481106115cd57634e487b7160e01b600052603260045260246000fd5b6000918252602082200155825483906115e8906001906129a9565b8154811061160657634e487b7160e01b600052603260045260246000fd5b906000526020600020015483828154811061163157634e487b7160e01b600052603260045260246000fd5b90600052602060002001819055508280548061165d57634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590556001915050611695565b80611687816129c0565b915050611572565b50600090505b92915050565b60408051808201909152600080825260208201526000828152600260209081526040808320546006909252909120546001600160a01b039182169116811515806116ed57506001600160a01b03811615155b6117455760405162461bcd60e51b8152602060048201526024808201527f4e6f2061676772656761746f72206f7220706f6f6c2065786973747320666f72604482015263206b657960e01b606482015260840161048c565b6001600160a01b038216156117665761175e828561196f565b949350505050565b6208aa8960eb1b60005260026020527fd9402e47e68a5154d8f9cdc9d4ffcf4a300546026372c3b04224fbe62656c601546001600160a01b03166117ec5760405162461bcd60e51b815260206004820152601c60248201527f507269636520666f722045544820646f6573206e6f7420657869737400000000604482015260640161048c565b60006117ff6117fa83611a74565b611ca9565b6208aa8960eb1b600081815260026020527fd9402e47e68a5154d8f9cdc9d4ffcf4a300546026372c3b04224fbe62656c601549293509161184b916001600160a01b039091169061196f565b5161185e90670de0b6b3a764000061290c565b6001600160d81b031690506000836001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118dc9190612408565b6007549091506000906001600160a01b03808416600160381b90920416148061191257506008546001600160a01b038381169116145b1561192857611921848461280d565b9050611935565b611932848461293b565b90505b604051806040016040528061194a8a84611ce4565b6001600160d81b0316815264ffffffffff421660209091015298975050505050505050565b604080518082019091526000808252602082015260408051600481526024810182526020810180516001600160e01b0316633fabe5a360e21b179052905160009081906001600160a01b038716906119c89085906126a7565b600060405180830381855afa9150503d8060008114611a03576040519150601f19603f3d011682016040523d82523d6000602084013e611a08565b606091505b50915091508115611a6b5760008082806020019051810190611a2a919061263e565b509350509250506040518060400160405280611a468985611ce4565b6001600160d81b031681526020018264ffffffffff1681525095505050505050611695565b50505092915050565b600754600090600690810b900b611b0557816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af6919061258e565b50949550611ca4945050505050565b6040805160028082526060820183526000926020830190803683375050600754825192935060060b91839150600090611b4e57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110611b8b57634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611bcf908590600401612724565b60006040518083038186803b158015611be757600080fd5b505afa158015611bfb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c239190810190612424565b50905061175e600760009054906101000a900460060b82600081518110611c5a57634e487b7160e01b600052603260045260246000fd5b602002602001015183600181518110611c8357634e487b7160e01b600052603260045260246000fd5b6020026020010151611c95919061295a565b611c9f91906127cf565b611d90565b919050565b600080611cc46001600160a01b03841680600160601b6121a5565b9050611cdd81670de0b6b3a7640000600160601b6121a5565b9392505050565b600080821215611d365760405162461bcd60e51b815260206004820152601b60248201527f4e656761746976652072617465206e6f7420737570706f727465640000000000604482015260640161048c565b60008381526003602052604090205460ff1615611d8a57600083815260036020526040812054611d6b9060129060ff1661231f565b611d7690600a612864565b9050611d82838261232b565b915050611695565b50919050565b60008060008360020b12611da7578260020b611db4565b8260020b611db490612a10565b9050611dc3620d89e7196129ef565b60020b811115611df95760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161048c565b600060018216611e0d57600160801b611e1f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611e5e576080611e59826ffff97272373d413259a46990580e213a61293b565b901c90505b6004821615611e88576080611e83826ffff2e50f5f656932ef12357cf3c7fdcc61293b565b901c90505b6008821615611eb2576080611ead826fffe5caca7e10e4e61c3624eaa0941cd061293b565b901c90505b6010821615611edc576080611ed7826fffcb9843d60f6159c9db58835c92664461293b565b901c90505b6020821615611f06576080611f01826fff973b41fa98c081472e6896dfb254c061293b565b901c90505b6040821615611f30576080611f2b826fff2ea16466c96a3843ec78b326b5286161293b565b901c90505b6080821615611f5a576080611f55826ffe5dee046a99a2a811c461f1969c305361293b565b901c90505b610100821615611f85576080611f80826ffcbe86c7900a88aedcffc83b479aa3a461293b565b901c90505b610200821615611fb0576080611fab826ff987a7253ac413176f2b074cf7815e5461293b565b901c90505b610400821615611fdb576080611fd6826ff3392b0822b70005940c7a398e4b70f361293b565b901c90505b610800821615612006576080612001826fe7159475a2c29b7443b29c7fa6e889d961293b565b901c90505b61100082161561203157608061202c826fd097f3bdfd2022b8845ad8f792aa582561293b565b901c90505b61200082161561205c576080612057826fa9f746462d870fdf8a65dc1f90e061e561293b565b901c90505b614000821615612087576080612082826f70d869a156d2a1b890bb3df62baf32f761293b565b901c90505b6180008216156120b25760806120ad826f31be135f97d08fd981231505542fcfa661293b565b901c90505b620100008216156120de5760806120d9826f09aa508b5b7a84e1c677de54f3e99bc961293b565b901c90505b62020000821615612109576080612104826e5d6af8dedb81196699c329225ee60461293b565b901c90505b6204000082161561213357608061212e826d2216e584f5fa1ea926041bedfe9861293b565b901c90505b6208000082161561215b576080612156826b048a170391f7dc42444e8fa261293b565b901c90505b60008460020b1315612176576121738160001961280d565b90505b612185640100000000826129db565b15612191576001612194565b60005b61175e9060ff16602083901c6127b7565b6000808060001985870985870292508281108382030391505080600014156121df57600084116121d457600080fd5b508290049050611cdd565b8084116121eb57600080fd5b600084868809808403938111909203919050600061220b861960016127b7565b861695869004959384900493600081900304600101905061222c818461293b565b90931792600061223d87600361293b565b600218905061224c818861293b565b6122579060026129a9565b612261908261293b565b905061226d818861293b565b6122789060026129a9565b612282908261293b565b905061228e818861293b565b6122999060026129a9565b6122a3908261293b565b90506122af818861293b565b6122ba9060026129a9565b6122c4908261293b565b90506122d0818861293b565b6122db9060026129a9565b6122e5908261293b565b90506122f1818861293b565b6122fc9060026129a9565b612306908261293b565b9050612312818661293b565b9998505050505050505050565b6000611cdd82846129a9565b6000611cdd828461293b565b600082601f830112612347578081fd5b8151602061235c61235783612793565b612762565b80838252828201915082860187848660051b890101111561237b578586fd5b855b858110156123a257815161239081612a6c565b8452928401929084019060010161237d565b5090979650505050505050565b805161ffff81168114611ca457600080fd5b805169ffffffffffffffffffff81168114611ca457600080fd5b805160ff81168114611ca457600080fd5b6000602082840312156123fd578081fd5b8135611cdd81612a6c565b600060208284031215612419578081fd5b8151611cdd81612a6c565b60008060408385031215612436578081fd5b825167ffffffffffffffff8082111561244d578283fd5b818501915085601f830112612460578283fd5b8151602061247061235783612793565b8083825282820191508286018a848660051b890101111561248f578788fd5b8796505b848710156124ba5780516124a681612a81565b835260019690960195918301918301612493565b50918801519196509093505050808211156124d3578283fd5b506124e085828601612337565b9150509250929050565b6000602082840312156124fb578081fd5b5035919050565b60008060408385031215612514578182fd5b82359150602083013561252681612a6c565b809150509250929050565b600080600060608486031215612545578081fd5b83359250602084013561255781612a6c565b9150604084013561256781612a6c565b809150509250925092565b600060208284031215612583578081fd5b8135611cdd81612a81565b600080600080600080600060e0888a0312156125a8578283fd5b87516125b381612a6c565b8097505060208801518060020b81146125ca578384fd5b95506125d8604089016123af565b94506125e6606089016123af565b93506125f4608089016123af565b925061260260a089016123db565b915060c08801518015158114612616578182fd5b8091505092959891949750929550565b600060208284031215612637578081fd5b5051919050565b600080600080600060a08688031215612655578283fd5b61265e866123c1565b9450602086015193506040860151925060608601519150612681608087016123c1565b90509295509295909350565b60006020828403121561269e578081fd5b611cdd826123db565b60008251815b818110156126c757602081860181015185830152016126ad565b818111156126d55782828501525b509190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015612718578351835292840192918401916001016126fc565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561271857835163ffffffff1683529284019291840191600101612740565b604051601f8201601f1916810167ffffffffffffffff8111828210171561278b5761278b612a56565b604052919050565b600067ffffffffffffffff8211156127ad576127ad612a56565b5060051b60200190565b600082198211156127ca576127ca612a2a565b500190565b60008160060b8360060b806127e6576127e6612a40565b667fffffffffffff1982146000198214161561280457612804612a2a565b90059392505050565b60008261281c5761281c612a40565b500490565b600181815b8085111561285c57816000190482111561284257612842612a2a565b8085161561284f57918102915b93841c9390800290612826565b509250929050565b6000611cdd838360008261287a57506001611695565b8161288757506000611695565b816001811461289d57600281146128a7576128c3565b6001915050611695565b60ff8411156128b8576128b8612a2a565b50506001821b611695565b5060208310610133831016604e8410600b84101617156128e6575081810a611695565b6128f08383612821565b806000190482111561290457612904612a2a565b029392505050565b60006001600160d81b038281168482168115158284048211161561293257612932612a2a565b02949350505050565b600081600019048311821515161561295557612955612a2a565b500290565b60008160060b8360060b82811281667fffffffffffff190183128115161561298457612984612a2a565b81667fffffffffffff01831381161561299f5761299f612a2a565b5090039392505050565b6000828210156129bb576129bb612a2a565b500390565b60006000198214156129d4576129d4612a2a565b5060010190565b6000826129ea576129ea612a40565b500690565b60008160020b627fffff19811415612a0957612a09612a2a565b9003919050565b6000600160ff1b821415612a2657612a26612a2a565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ea957600080fd5b8060060b8114610ea957600080fdfea2646970667358221220dc24d43308bf90c00d546fdc42ba1157bca5549f16e1d6c89650ba6f2b786c2564736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.