ETH Price: $2,736.05 (-1.91%)

Contract

0xe24794da9035EB0b6d8739369ECd894faFD9A09F
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Set Position Man...218037772025-02-08 19:07:2313 days ago1739041643IN
0xe24794da...faFD9A09F
0 ETH0.000088623

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TitanXPriceFeed

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 1 runs

Other Settings:
paris EvmVersion
File 1 of 26 : TitanXPriceFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "../../../common/uniswap/TickMath.sol";
import "../../../common/uniswap/Oracle.sol";
import "../../../common/uniswap/PoolAddress.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "../../../common/Base.sol";
import "../../../common/StableMath.sol";
import "../../../interfaces/IPriceFeed.sol";
import "@openzeppelin/contracts/utils/math/SignedMath.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol";
import "./EthPriceFeed.sol";

/**
 * @title TitanXPriceFeed
 * @notice Price feed implementation for TitanX token using Uniswap V3 TWAPs and Chainlink ETH price
 * @dev Extends EthPriceFeed to combine ETH/USD price with TitanX/ETH price from Uniswap
 */
contract TitanXPriceFeed is IPriceFeed, EthPriceFeed {
    /**
     * @dev Struct to store different timeframe prices for TitanX
     * @param spotUsd Current spot price in USD
     * @param sTwapUsd Short TWAP price in USD
     * @param lTwapUsd Long TWAP price in USD
     */
    struct PriceData {
        uint spotUsd;
        uint sTwapUsd;
        uint lTwapUsd;
    }

    // ======== STATE VARIABLES ========

    // Immutable addresses
    address public immutable positionController;
    address public immutable collateralController;
    address public immutable UNI_FACTORY;
    address public immutable TITANX;
    address public immutable WETH;

    // Mutable/set once address
    address public positionManager;

    // TWAP configuration
    uint32 public longTwapSeconds = 6 minutes;
    uint32 public shortTwapSeconds = 1 minutes;
    uint24 public constant FEE_TIER = 10000;   // 1%

    // Price averaging weights
    uint8 public shortTwapWeightInAverage = 1;
    uint8 public longTwapWeightInAverage = 2;
    // Limits the pull which the short TWAP can have on the long TWAP when calculating weighted average
    uint public maxShortTwapInfluencePCT = 10e16; // 10%

    // Circuit breaker and fee configuration
    bool public deviationTestingEnabled = true;
    bool public considerSpotInDeviationCircuitBreakerTesting = true;
    bool public advancedFeeEstimationEnabled = true;
    uint public maxOracleDeltaPCT = 5e16; // 5%
    uint public maxFeeProjection = 5e16; // 5%
    uint private constant DECIMAL_PRECISION = 1e18;

    // ======== MODIFIERS ========

    modifier onlyPC {
        require(msg.sender == positionController, "OnlyPC");
        _;
    }

    modifier onlyPM {
        require(msg.sender == positionManager, "OnlyPM");
        _;
    }

    modifier onlyPCorCC {
        require(msg.sender == positionController || msg.sender == collateralController, "OnlyPCorCC");
        _;
    }

    // ======== CONSTRUCTOR ========

    /**
     * @notice Initializes the TitanX price feed with required addresses and configuration
     * @param _uniFactoryAddress Uniswap V3 factory address
     * @param _titanX TitanX token address
     * @param _weth WETH token address
     * @param _positionController Position controller contract address
     * @param _collateralController Collateral controller contract address
     * @param _priceAggregatorAddresses Array of price aggregator addresses for ETH price feed
     */
    constructor(
        address _uniFactoryAddress,
        address _titanX,
        address _weth,
        address _positionController,
        address _collateralController,
        address[] memory _priceAggregatorAddresses
    ) {
        positionController = _positionController;
        collateralController = _collateralController;
        UNI_FACTORY = _uniFactoryAddress;
        TITANX = _titanX;
        WETH = _weth;

        address[] memory ethOracles = new address[](1);
        ethOracles[0] = _priceAggregatorAddresses[0];

        super._setAddresses(ethOracles);
    }

    // ======== EXTERNAL PRICE QUERY FUNCTIONS ========

    /**
     * @notice Fetches comprehensive price details including TWAPs and fee suggestions
     * @dev Warning: bypasses safety checks, do not use in protocol internals
     * @param utilizationPCT Current utilization percentage for fee calculation
     * @return PriceDetails struct containing price information and fee suggestions
     */
    function fetchPrice(uint utilizationPCT) public override view returns (PriceDetails memory) {
        PriceDetails memory details;
        PriceData memory priceData = PriceData(getPrice(0), getPrice(shortTwapSeconds), getPrice(longTwapSeconds));

        details.spotPrice = priceData.spotUsd;
        details.shortTwapPrice = priceData.sTwapUsd;
        details.longTwapPrice = priceData.lTwapUsd;

        details.lowestPrice = StableMath._min(priceData.sTwapUsd, priceData.lTwapUsd);
        details.highestPrice = StableMath._max(priceData.sTwapUsd, priceData.lTwapUsd);

        details.weightedAveragePrice =
            ((priceData.lTwapUsd * longTwapWeightInAverage) + (priceData.sTwapUsd * shortTwapWeightInAverage))
            /
            (longTwapWeightInAverage + shortTwapWeightInAverage);

        if (advancedFeeEstimationEnabled) {
            details.suggestedAdditiveFeePCT = _calculateSuggestedAdditiveFeePCT(utilizationPCT);
        } else {
            details.suggestedAdditiveFeePCT = 0;
        }

        return details;
    }

    /**
     * @notice Fetches the highest price between short-term and long-term TWAPs with an optional fee suggestion
     * @dev This function is restricted to the Position Manager (PM) contract only
     * @param loadIncrease The amount by which the current caller increased the load PCT
     * @param originationOrRedemptionLoadPCT The current percentage load (usage of points) for origination or redemption
     * @param testLiquidity Flag to determine if liquidity should be tested (not applicable to locked liquidity pools)
     * @param testDeviation Flag to check if price deviation checks should be performed during price data lookup
     * @return price The higher value between short-term and long-term TWAP prices in USD
     * @return suggestedAdditiveFeePCT Additional fee percentage suggested based on market conditions when advanced fee estimation is enabled, 0 otherwise
     */
    function fetchHighestPriceWithFeeSuggestion(
        uint loadIncrease,
        uint originationOrRedemptionLoadPCT,
        bool testLiquidity,
        bool testDeviation
    ) external override onlyPM returns (uint price, uint suggestedAdditiveFeePCT) {
        PriceData memory priceData = _preCheckAndLookupPriceData(testDeviation);
        uint maxPrice = StableMath._max(priceData.sTwapUsd, priceData.lTwapUsd);

        if (advancedFeeEstimationEnabled) {
            suggestedAdditiveFeePCT = _calculateSuggestedAdditiveFeePCT(originationOrRedemptionLoadPCT);
            return (maxPrice, suggestedAdditiveFeePCT);
        } else {
            return (maxPrice, 0);
        }
    }

    /**
     * @notice Fetches the lowest price between short-term and long-term TWAPs with an optional fee suggestion
     * @dev This function is restricted to the Position Controller (PC) contract only
     * @param loadIncrease The amount by which the current caller increased the load PCT
     * @param originationOrRedemptionLoadPCT The current percentage load (usage of points) for origination or redemption
     * @param testLiquidity Flag to determine if liquidity should be tested (not applicable to locked liquidity pools)
     * @param testDeviation Flag to check if price deviation checks should be performed during price data lookup
     * @return price The lower value between short-term and long-term TWAP prices in USD
     * @return suggestedAdditiveFeePCT Additional fee percentage suggested based on market conditions when advanced fee estimation is enabled, 0 otherwise
     */
    function fetchLowestPriceWithFeeSuggestion(
        uint loadIncrease,
        uint originationOrRedemptionLoadPCT,
        bool testLiquidity,
        bool testDeviation
    ) external override onlyPC returns (uint price, uint suggestedAdditiveFeePCT) {
        PriceData memory priceData = _preCheckAndLookupPriceData(testDeviation);
        uint minPrice = StableMath._min(priceData.sTwapUsd, priceData.lTwapUsd);

        if (advancedFeeEstimationEnabled) {
            suggestedAdditiveFeePCT = _calculateSuggestedAdditiveFeePCT(originationOrRedemptionLoadPCT);
            return (minPrice, suggestedAdditiveFeePCT);
        } else {
            return (minPrice, 0);
        }
    }

    /**
     * @notice Fetches the lowest TWAP price between short-term and long-term periods
     * @dev Restricted to Position Controller or Collateral Controller contracts only
     * @param testLiquidity Flag to determine if liquidity checks should be performed (not used)
     * @param testDeviation Flag to enable price deviation validation checks
     * @return price The lower value between short-term and long-term TWAP prices in USD
     */
    function fetchLowestPrice(bool testLiquidity, bool testDeviation) external override onlyPCorCC returns (uint price) {
        PriceData memory priceData = _preCheckAndLookupPriceData(testDeviation);
        price = StableMath._min(priceData.sTwapUsd, priceData.lTwapUsd);
    }

    /**
     * @notice Calculates a weighted average price using short and long-term TWAPs
     * @dev Short TWAP's influence is limited by maxShortTwapInfluencePCT. Restricted to Position Manager contract only.
     * @param testLiquidity Flag to determine if liquidity checks should be performed (not used)
     * @param testDeviation Flag to enable price deviation validation checks
     * @return price Weighted average of long and short TWAP prices, calculated as:
     *         ((longTWAP * longWeight) + (shortTWAP * shortWeight)) / (longWeight + shortWeight)
     *         Weights are configurable parameters that determine the influence of each TWAP
     */
    function fetchWeightedAveragePrice(bool testLiquidity, bool testDeviation) external override onlyPM returns (uint price) {
        PriceData memory priceData = _preCheckAndLookupPriceData(testDeviation);

        uint weightedAverage =
            ((priceData.lTwapUsd * longTwapWeightInAverage) + (priceData.sTwapUsd * shortTwapWeightInAverage))
            / (longTwapWeightInAverage + shortTwapWeightInAverage);

        uint maxDeviation = (priceData.lTwapUsd * maxShortTwapInfluencePCT) / DECIMAL_PRECISION;
        uint upperBound = priceData.lTwapUsd + maxDeviation;
        uint lowerBound = priceData.lTwapUsd - maxDeviation;

        if (weightedAverage > upperBound) {
            return upperBound;
        } else if (weightedAverage < lowerBound) {
            return lowerBound;
        } else {
            return weightedAverage;
        }
    }

    // ======== UNISWAP PRICE QUERY FUNCTIONS ========

    /**
     * @notice Gets TitanX price for specified timeframe
     * @param secondsAgo Number of seconds ago to query price
     * @return quote Price in terms of ETH
     */
    function getPrice(uint32 secondsAgo) public view returns (uint256 quote) {
        return _getPrice(secondsAgo, super.viewEthPrice());
    }

    /**
     * @notice Queries Uniswap V3 pool for historical price data between any token pair
     * @dev Handles both current (slot0) and historical (oracle) price lookups
     * @param baseToken The token to price
     * @param quoteToken The token to price against
     * @param secondsAgo Time in the past to query price for
     * @return quote The exchange rate between tokens with 18 decimal precision
     */
    function _getQuoteFromPool(
        address baseToken,
        address quoteToken,
        uint32 secondsAgo
    ) internal view returns (uint256 quote) {
        address poolAddress = PoolAddress.computeAddress(
            UNI_FACTORY,
            PoolAddress.getPoolKey(baseToken, quoteToken, FEE_TIER)
        );
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(poolAddress);

        // Limit to oldest observation
        if (oldestObservation < secondsAgo) {
            secondsAgo = oldestObservation;
        }

        uint160 sqrtPriceX96;
        if (secondsAgo == 0) {
            // Default to current price
            IUniswapV3Pool pool = IUniswapV3Pool(poolAddress);
            (sqrtPriceX96,,,,,,) = pool.slot0();
        } else {
            // Consult the Oracle Library for TWAPs
            (int24 arithmeticMeanTick,) = OracleLibrary.consult(poolAddress, secondsAgo);
            // Convert tick to sqrtPriceX96
            sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);
        }

        return OracleLibrary.getQuoteForSqrtRatioX96(sqrtPriceX96, 1e18, baseToken, quoteToken);
    }

    /**
     * @notice Fetches the ETH/TitanX exchange rate from Uniswap V3
     * @dev Wrapper around _getQuoteFromPool specifically for TitanX/WETH pair
     * @param secondsAgo Number of seconds in the past to query the price
     * @return quote The amount of ETH per TitanX with 18 decimal precision
     */
    function quoteTitanPrice(uint32 secondsAgo) public view returns (uint256 quote) {
        return _getQuoteFromPool(TITANX, WETH, secondsAgo);
    }

    // ======== PRICE VALIDATION FUNCTIONS ========

    /**
     * @dev Central function for price data collection and validation
     * @param testDeviation If true, ensures price variations are within acceptable bounds
     * @return priceData Struct containing spot price, short TWAP, and long TWAP in USD
     *
     * Safety features:
     * - Optional deviation testing via circuit breaker
     * - Uses multiple timeframe TWAPs for price volatility estimation
     * - Integrates with ETH/USD Chainlink price feed for USD conversion
     */
    function _preCheckAndLookupPriceData(bool testDeviation) private returns (PriceData memory priceData) {
        uint256 currentUsdPerEth = super.fetchEthPrice();

        priceData = PriceData(
            _getPrice(0, currentUsdPerEth),
            _getPrice(shortTwapSeconds, currentUsdPerEth),
            _getPrice(longTwapSeconds, currentUsdPerEth)
        );

        if (testDeviation && deviationTestingEnabled) {
            require(
                _priceDeviationInSafeRange(priceData, considerSpotInDeviationCircuitBreakerTesting, maxOracleDeltaPCT),
                "Significant price deviation in progress"
            );
        }
    }

    /**
     * @dev Checks if price deviation is within acceptable range
     */
    function _priceDeviationInSafeRange(
        PriceData memory priceData,
        bool considerSpot,
        uint _maxOracleDeltaPCT
    ) internal pure returns (bool) {
        uint minPrice;
        uint maxPrice;

        if (considerSpot) {
            minPrice = StableMath._min(StableMath._min(priceData.sTwapUsd, priceData.lTwapUsd), priceData.spotUsd);
            maxPrice = StableMath._max(StableMath._max(priceData.sTwapUsd, priceData.lTwapUsd), priceData.spotUsd);
        } else {
            minPrice = StableMath._min(priceData.sTwapUsd, priceData.lTwapUsd);
            maxPrice = StableMath._max(priceData.sTwapUsd, priceData.lTwapUsd);
        }

        return _calcDiff(minPrice, maxPrice) <= _maxOracleDeltaPCT;
    }

    /**
    * @dev Calculates the percentage difference between max and min prices in 18 decimal precision
    */
    function _calcDiff(uint minPrice, uint maxPrice) internal pure returns (uint) {
        return ((maxPrice - minPrice) * DECIMAL_PRECISION) / maxPrice;
    }

    // ======== PRICE STORAGE FUNCTIONS ========

    /**
     * @dev Calculates and stores price for given timeframe
     */
    function _getPrice(uint32 secondsAgo, uint currentUsdPerEth) internal virtual view returns (uint256 quote) {
        uint ethPerTitanX = quoteTitanPrice(secondsAgo);
        uint256 usdPerTitan = (currentUsdPerEth * ethPerTitanX) / 1e18;
        return usdPerTitan;
    }

    // ======== FEE CALCULATION FUNCTIONS ========

    /**
     * @dev Calculates suggested additive fee percentage based on utilization
     */
    function _calculateSuggestedAdditiveFeePCT(uint utilizationPCT) internal view returns (uint) {
        return (utilizationPCT * maxFeeProjection) / DECIMAL_PRECISION;
    }

    // ======== ADMINISTRATIVE FUNCTIONS ========

    /**
     * @notice Sets the position manager address
     * @dev Can only be called once by guardian
     * @param pm Address of the position manager
     */
    function setPositionManager(address pm) external onlyGuardian {
        require(positionManager == address(0), "positionManager has already been set");
        positionManager = pm;
    }

    /**
     * @notice Sets the maximum percentage influence that short TWAP can have on the final price
     * @param _maxInfluencePCT Maximum percentage influence (18 decimals)
     */
    function setMaxShortTwapInfluence(uint _maxInfluencePCT) external onlyGuardian {
        require(_maxInfluencePCT <= DECIMAL_PRECISION, "Influence must be <= 100%");
        maxShortTwapInfluencePCT = _maxInfluencePCT;
    }

    /**
     * @notice Enables or disables deviation testing
     * @dev Controls whether price deviation checks are performed
     * @param isOn True to enable, false to disable
     */
    function setDeviationTesting(bool isOn) external onlyGuardian {
        deviationTestingEnabled = isOn;
    }

    /**
     * @notice Sets the weight for short TWAP in price averaging
     * @dev Weight must be greater than zero
     * @param weight New weight for short TWAP
     */
    function setShortTwapWeightInAverage(uint8 weight) external onlyGuardian {
        require(weight > 0, "Weight must be greater than zero");
        shortTwapWeightInAverage = weight;
    }

    /**
     * @notice Sets the weight for long TWAP in price averaging
     * @dev Weight must be greater than zero
     * @param weight New weight for long TWAP
     */
    function setLongTwapWeightInAverage(uint8 weight) external onlyGuardian {
        require(weight > 0, "Weight must be greater than zero");
        longTwapWeightInAverage = weight;
    }

    /**
     * @notice Sets whether to consider spot price in fee estimation
     * @param consider True to consider spot price, false to ignore it
     */
    function setConsiderSpotInFeeEstimation(bool consider) external onlyGuardian {
        considerSpotInDeviationCircuitBreakerTesting = consider;
    }

    /**
     * @notice Enables or disables advanced fee estimation
     * @param isOn True to enable, false to disable
     */
    function setAdvancedFeeEstimation(bool isOn) external onlyGuardian {
        advancedFeeEstimationEnabled = isOn;
    }

    /**
     * @notice Sets the duration for long TWAP calculation
     * @dev Must be greater than short TWAP seconds and greater than 0
     * @param _newLongTwapSeconds New duration in seconds for long TWAP
     */
    function setLongTwapSeconds(uint32 _newLongTwapSeconds) external onlyGuardian {
        require(_newLongTwapSeconds > 0, "Long TWAP seconds must be greater than 0");
        require(_newLongTwapSeconds > shortTwapSeconds, "Long TWAP must be greater than short TWAP");
        longTwapSeconds = _newLongTwapSeconds;
    }

    /**
     * @notice Sets the duration for short TWAP calculation
     * @dev Must be less than long TWAP seconds and greater than 0
     * @param _newShortTwapSeconds New duration in seconds for short TWAP
     */
    function setShortTwapSeconds(uint32 _newShortTwapSeconds) external onlyGuardian {
        require(_newShortTwapSeconds > 0, "Short TWAP seconds must be greater than 0");
        require(longTwapSeconds > _newShortTwapSeconds, "Long TWAP must be greater than short TWAP");
        shortTwapSeconds = _newShortTwapSeconds;
    }

    /**
     * @notice Sets the maximum allowed oracle price deviation
     * @dev Must be between 0.5% and 100%
     * @param _newMaxOracleDeltaPCT New maximum deviation percentage (18 decimals)
     */
    function setMaxOracleDelta(uint _newMaxOracleDeltaPCT) external onlyGuardian {
        uint HALF_PCT = 5e15; // 0.5%
        require(_newMaxOracleDeltaPCT >= HALF_PCT && _newMaxOracleDeltaPCT <= DECIMAL_PRECISION,
            "Must be between 0.5% - 100%");
        maxOracleDeltaPCT = _newMaxOracleDeltaPCT;
    }

    /**
     * @notice Sets the maximum fee projection for price calculations
     * @dev Must be between 1% and 100%
     * @param mfp New maximum fee projection percentage (18 decimals)
     */
    function setMaxFeeProjection(uint mfp) external onlyGuardian {
        require(mfp >= 1e16 && mfp <= 1e18, "Max Fee Projection must be between 1% and 100%");
        maxFeeProjection = mfp;
    }
}

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

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  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 3 of 26 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

File 9 of 26 : 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 10 of 26 : 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 11 of 26 : 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 12 of 26 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

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

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

File 13 of 26 : 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 14 of 26 : 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 15 of 26 : 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 16 of 26 : IQuoter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Quoter Interface
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoter {
    /// @notice Returns the amount out received for a given exact input swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee
    /// @param amountIn The amount of the first token to swap
    /// @return amountOut The amount of the last token that would be received
    function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);

    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountIn The desired input amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountOut The amount of `tokenOut` that would be received
    function quoteExactInputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountOut);

    /// @notice Returns the amount in required for a given exact output swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
    /// @param amountOut The amount of the last token to receive
    /// @return amountIn The amount of first token required to be paid
    function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);

    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountOut The desired output amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
    function quoteExactOutputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountOut,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountIn);
}

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

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

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

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

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

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

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

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

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

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

File 18 of 26 : Base.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "./BaseMath.sol";

/* Contains global system constants and common functions. */
contract Base is BaseMath {
    uint constant internal SECONDS_IN_ONE_MINUTE = 60;

    /*
     * Half-life of 12h. 12h = 720 min
     * (1/2) = d^720 => d = (1/2)^(1/720)
     */
    uint constant internal MINUTE_DECAY_FACTOR = 999037758833783000;

    /*
    * BETA: 18 digit decimal. Parameter by which to divide the redeemed fraction, in order to calc the new base rate from a redemption.
    * Corresponds to (1 / ALPHA) in the white paper.
    */
    uint constant internal BETA = 2;

    uint constant public _100pct = 1000000000000000000; // 1e18 == 100%

    // Min net debt remains a system global due to its rationale for keeping SortedPositions relatively small
    uint constant public MIN_NET_DEBT = 1800e18;

    uint constant internal PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5%

    // Gas compensation is not configurable per collateral type, as this is
    // more-so a chain specific consideration rather than collateral specific
    uint constant public GAS_COMPENSATION = 200e18;

    // A dynamic fee, which kicks in and acts as a floor if the custom min fee % attached to a collateral instance is too low.
    uint constant public DYNAMIC_BORROWING_FEE_FLOOR = DECIMAL_PRECISION / 1000 * 5; // 0.5%
    uint constant public DYNAMIC_REDEMPTION_FEE_FLOOR = DECIMAL_PRECISION / 1000 * 5; // 0.5%

    address internal positionControllerAddress;
    address internal gasPoolAddress;

    // Return the amount of Collateral to be drawn from a position's collateral and sent as gas compensation.
    function _getCollGasCompensation(uint _entireColl) internal pure returns (uint) {
        return _entireColl / PERCENT_DIVISOR;
    }

    function _requireUserAcceptsFee(uint _fee, uint _amount, uint _maxFeePercentage) internal pure {
        uint feePercentage = (_fee * DECIMAL_PRECISION) / _amount;
        require(feePercentage <= _maxFeePercentage, "Fee exceeded");
    }
}

File 19 of 26 : BaseMath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

contract BaseMath {
    uint constant public DECIMAL_PRECISION = 1e18;
}

File 20 of 26 : StableMath.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

library StableMath {
    uint internal constant DECIMAL_PRECISION = 1e18;

    /* Precision for Nominal ICR (independent of price). Rationale for the value:
     *
     * - Making it “too high” could lead to overflows.
     * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division. 
     *
     * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 ETH,
     * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.
     *
     */
    uint internal constant NICR_PRECISION = 1e20;

    function _min(uint _a, uint _b) internal pure returns (uint) {
        return (_a < _b) ? _a : _b;
    }

    function _max(uint _a, uint _b) internal pure returns (uint) {
        return (_a >= _b) ? _a : _b;
    }

    /* 
    * Multiply two decimal numbers and use normal rounding rules:
    * -round product up if 19'th mantissa digit >= 5
    * -round product down if 19'th mantissa digit < 5
    *
    * Used only inside the exponentiation, _decPow().
    */
    function decMul(uint x, uint y) internal pure returns (uint decProd) {
        uint prod_xy = x * y;
        decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION;
    }

    /* 
    * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n.
    * 
    * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity. 
    * 
    * Called by PositionManager._calcDecayedBaseRate
    *
    * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals
    * "minutes in 1000 years": 60 * 24 * 365 * 1000
    * 
    * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be
    * negligibly different from just passing the cap, since: 
    *
    * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years
    * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible
    */
    function _decPow(uint _base, uint _minutes) internal pure returns (uint) {
       
        if (_minutes > 525600000) {_minutes = 525600000;}  // cap to avoid overflow
    
        if (_minutes == 0) {return DECIMAL_PRECISION;}

        uint y = DECIMAL_PRECISION;
        uint x = _base;
        uint n = _minutes;

        // Exponentiation-by-squaring
        while (n > 1) {
            if (n % 2 == 0) {
                x = decMul(x, x);
                n = n / 2;
            } else { // if (n % 2 != 0)
                y = decMul(x, y);
                x = decMul(x, x);
                n = (n - 1) / 2;
            }
        }

        return decMul(x, y);
  }

    function _getAbsoluteDifference(uint _a, uint _b) internal pure returns (uint) {
        return (_a >= _b) ? _a - _b : _b - _a;
    }

    function _adjustDecimals(uint _val, uint8 _collDecimals) internal pure returns (uint) {
        if (_collDecimals < 18) {
            return _val * (10 ** (18 - _collDecimals));
        } else if (_collDecimals > 18) {
            // Assuming _collDecimals won't exceed 25, this should be safe from overflow.
            return _val / (10 ** (_collDecimals - 18));
        } else {
            return _val;
        }
    }

    function _computeNominalCR(uint _coll, uint _debt, uint8 _collDecimals) internal pure returns (uint) {
        if (_debt > 0) {
            _coll = _adjustDecimals(_coll, _collDecimals);
            return (_coll * NICR_PRECISION) / _debt;
        }
        // Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
        else { // if (_debt == 0)
            return type(uint256).max;
        }
    }

    function _computeCR(uint _coll, uint _debt, uint _price, uint8 _collDecimals) internal pure returns (uint) {
        // Check for zero debt to avoid division by zero
        if (_debt == 0) {
            return type(uint256).max; // Infinite CR since there's no debt.
        }

        _coll = _adjustDecimals(_coll, _collDecimals);
        uint newCollRatio = (_coll * _price) / _debt;
        return newCollRatio;
    }
}

File 21 of 26 : Oracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

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

// OpenZeppelin
import "@openzeppelin/contracts/utils/math/Math.sol";

/**
 * @notice Adapted Uniswap V3 OracleLibrary computation to be compliant with Solidity 0.8.x and later.
 *
 * Documentation for Auditors:
 *
 * Solidity Version: Updated the Solidity version pragma to ^0.8.0. This change ensures compatibility
 * with Solidity version 0.8.x.
 *
 * Safe Arithmetic Operations: Solidity 0.8.x automatically checks for arithmetic overflows/underflows.
 * Therefore, the code no longer needs to use SafeMath library (or similar) for basic arithmetic operations.
 * This change simplifies the code and reduces the potential for errors related to manual overflow/underflow checking.
 *
 * Overflow/Underflow: With the introduction of automatic overflow/underflow checks in Solidity 0.8.x, the code is inherently
 * safer and less prone to certain types of arithmetic errors.
 *
 * Removal of SafeMath Library: Since Solidity 0.8.x handles arithmetic operations safely, the use of SafeMath library
 * is omitted in this update.
 *
 * Git-style diff for the `consult` function:
 *
 * ```diff
 * function consult(address pool, uint32 secondsAgo)
 *     internal
 *     view
 *     returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
 * {
 *     require(secondsAgo != 0, 'BP');
 *
 *     uint32[] memory secondsAgos = new uint32[](2);
 *     secondsAgos[0] = secondsAgo;
 *     secondsAgos[1] = 0;
 *
 *     (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) =
 *         IUniswapV3Pool(pool).observe(secondsAgos);
 *
 *     int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
 *     uint160 secondsPerLiquidityCumulativesDelta =
 *         secondsPerLiquidityCumulativeX128s[1] - secondsPerLiquidityCumulativeX128s[0];
 *
 * -   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgo);
 * +   int56 secondsAgoInt56 = int56(uint56(secondsAgo));
 * +   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
 *     // Always round to negative infinity
 * -   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgo != 0)) arithmeticMeanTick--;
 * +   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgoInt56 != 0)) arithmeticMeanTick--;
 *
 * -   uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;
 * +   uint192 secondsAgoUint192 = uint192(secondsAgo);
 * +   uint192 secondsAgoX160 = secondsAgoUint192 * type(uint160).max;
 *     harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));
 * }
 * ```
 */

/// @title Oracle library
/// @notice Provides functions to integrate with V3 pool oracle
library OracleLibrary {
    /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool
    /// @param pool Address of the pool that we want to observe
    /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means
    /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp
    /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp
    function consult(
        address pool,
        uint32 secondsAgo
    )
    internal
    view
    returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
    {
        require(secondsAgo != 0, "BP");

        uint32[] memory secondsAgos = new uint32[](2);
        secondsAgos[0] = secondsAgo;
        secondsAgos[1] = 0;

        (
            int56[] memory tickCumulatives,
            uint160[] memory secondsPerLiquidityCumulativeX128s
        ) = IUniswapV3Pool(pool).observe(secondsAgos);

        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
        uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[
                    1
            ] - secondsPerLiquidityCumulativeX128s[0];

        // Safe casting of secondsAgo to int56 for division
        int56 secondsAgoInt56 = int56(uint56(secondsAgo));
        arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
        // Always round to negative infinity
        if (
            tickCumulativesDelta < 0 &&
            (tickCumulativesDelta % secondsAgoInt56 != 0)
        ) arithmeticMeanTick--;

        // Safe casting of secondsAgo to uint192 for multiplication
        uint192 secondsAgoUint192 = uint192(secondsAgo);
        harmonicMeanLiquidity = uint128(
            (secondsAgoUint192 * uint192(type(uint160).max)) /
            (uint192(secondsPerLiquidityCumulativesDelta) << 32)
        );
    }

    /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation
    /// @param pool Address of Uniswap V3 pool that we want to observe
    /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool
    function getOldestObservationSecondsAgo(
        address pool
    ) internal view returns (uint32 secondsAgo) {
        (
            ,
            ,
            uint16 observationIndex,
            uint16 observationCardinality,
            ,
            ,

        ) = IUniswapV3Pool(pool).slot0();
        require(observationCardinality > 0, "NI");

        (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(
            pool
        ).observations((observationIndex + 1) % observationCardinality);

        // The next index might not be initialized if the cardinality is in the process of increasing
        // In this case the oldest observation is always in index 0
        if (!initialized) {
            (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);
        }

        secondsAgo = uint32(block.timestamp) - observationTimestamp;
    }

    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange
    /// a slightly modified version of the UniSwap library getQuoteAtTick to accept a sqrtRatioX96 as input parameter
    /// @param sqrtRatioX96 The sqrt ration
    /// @param baseAmount Amount of token to be converted
    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
    function getQuoteForSqrtRatioX96(
        uint160 sqrtRatioX96,
        uint256 baseAmount,
        address baseToken,
        address quoteToken
    ) internal pure returns (uint256 quoteAmount) {
        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself
        if (sqrtRatioX96 <= type(uint128).max) {
            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX192, baseAmount, 1 << 192)
                : Math.mulDiv(1 << 192, baseAmount, ratioX192);
        } else {
            uint256 ratioX128 = Math.mulDiv(
                sqrtRatioX96,
                sqrtRatioX96,
                1 << 64
            );
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX128, baseAmount, 1 << 128)
                : Math.mulDiv(1 << 128, baseAmount, ratioX128);
        }
    }
}

File 22 of 26 : PoolAddress.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

/**
 * @notice Adapted Uniswap V3 pool address computation to be compliant with Solidity 0.8.x and later.
 * @dev Changes were made to address the stricter type conversion rules in newer Solidity versions.
 *      Original Uniswap V3 code directly converted a uint256 to an address, which is disallowed in Solidity 0.8.x.
 *      Adaptation Steps:
 *        1. The `pool` address is computed by first hashing pool parameters.
 *        2. The resulting `uint256` hash is then explicitly cast to `uint160` before casting to `address`.
 *           This two-step conversion process is necessary due to the Solidity 0.8.x restriction.
 *           Direct conversion from `uint256` to `address` is disallowed to prevent mistakes
 *           that can occur due to the size mismatch between the types.
 *        3. Added a require statement to ensure `token0` is less than `token1`, maintaining
 *           Uniswap's invariant and preventing pool address calculation errors.
 * @param factory The Uniswap V3 factory contract address.
 * @param key The PoolKey containing token addresses and fee tier.
 * @return pool The computed address of the Uniswap V3 pool.
 * @custom:modification Explicit type conversion from `uint256` to `uint160` then to `address`.
 *
 * function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
 *     require(key.token0 < key.token1);
 *     pool = address(
 *         uint160( // Explicit conversion to uint160 added for compatibility with Solidity 0.8.x
 *             uint256(
 *                 keccak256(
 *                     abi.encodePacked(
 *                         hex'ff',
 *                         factory,
 *                         keccak256(abi.encode(key.token0, key.token1, key.fee)),
 *                         POOL_INIT_CODE_HASH
 *                     )
 *                 )
 *             )
 *         )
 *     );
 * }
 */

/// @dev This code is copied from Uniswap V3 which uses an older compiler version.
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH =
        0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;

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

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

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

File 23 of 26 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

/**
 * @notice Adapted Uniswap V3 TickMath library computation to be compliant with Solidity 0.8.x and later.
 *
 * Documentation for Auditors:
 *
 * Solidity Version: Updated the Solidity version pragma to ^0.8.0. This change ensures compatibility
 * with Solidity version 0.8.x.
 *
 * Safe Arithmetic Operations: Solidity 0.8.x automatically checks for arithmetic overflows/underflows.
 * Therefore, the code no longer needs to use the SafeMath library (or similar) for basic arithmetic operations.
 * This change simplifies the code and reduces the potential for errors related to manual overflow/underflow checking.
 *
 * Explicit Type Conversion: The explicit conversion of `MAX_TICK` from `int24` to `uint256` in the `require` statement
 * is safe and necessary for comparison with `absTick`, which is a `uint256`. This conversion is compliant with
 * Solidity 0.8.x's type system and does not introduce any arithmetic risk.
 *
 * Overflow/Underflow: With the introduction of automatic overflow/underflow checks in Solidity 0.8.x, the code is inherently
 * safer and less prone to certain types of arithmetic errors.
 *
 * Removal of SafeMath Library: Since Solidity 0.8.x handles arithmetic operations safely, the use of the SafeMath library
 * is omitted in this update.
 *
 * Git-style diff for the TickMath library:
 *
 * ```diff
 * - pragma solidity >=0.5.0 <0.8.0;
 * + pragma solidity ^0.8.0;
 *
 *   function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
 *       uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
 * -     require(absTick <= uint256(MAX_TICK), 'T');
 * +     require(absTick <= uint256(int256(MAX_TICK)), 'T'); // Explicit type conversion for Solidity 0.8.x compatibility
 *       // ... (rest of the function)
 *   }
 *
 * function getTickAtSqrtRatio(
 *     uint160 sqrtPriceX96
 * ) internal pure returns (int24 tick) {
 *     // [Code for calculating the tick based on sqrtPriceX96 remains unchanged]
 *
 * -   tick = tickLow == tickHi
 * -       ? tickLow
 * -       : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96
 * -       ? tickHi
 * -       : tickLow;
 * +   if (tickLow == tickHi) {
 * +       tick = tickLow;
 * +   } else {
 * +       tick = (getSqrtRatioAtTick(tickHi) <= sqrtPriceX96) ? tickHi : tickLow;
 * +   }
 * }
 * ```
 *
 * Note: Other than the pragma version change and the explicit type conversion in the `require` statement, the original functions
 * within the TickMath library are compatible with Solidity 0.8.x without requiring any further modifications. This is due to
 * the fact that the logic within these functions already adheres to safe arithmetic practices and does not involve operations
 * that would be affected by the 0.8.x compiler's built-in checks.
 */

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

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

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

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

        // Adjusted logic for determining the tick
        if (tickLow == tickHi) {
            tick = tickLow;
        } else {
            tick = (getSqrtRatioAtTick(tickHi) <= sqrtPriceX96)
                ? tickHi
                : tickLow;
        }
    }
}

File 24 of 26 : Guardable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

/**
 * @title Guardable
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (a guardian) that can be granted exclusive access to
 * specific functions.
 *
 * This module is essentially a renamed version of the OpenZeppelin Ownable contract.
 * The main difference is in terminology:
 * - 'owner' is renamed to 'guardian'
 * - 'ownership' concepts are renamed to 'watch' or 'guard'
 *
 * By default, the guardian account will be the one that deploys the contract. This
 * can later be changed with {transferWatch}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyGuardian`, which can be applied to your functions to restrict their use to
 * the guardian.
 */
abstract contract Guardable {
    address private _guardian;

    event WatchTransferred(address indexed previousGuardian, address indexed newGuardian);

    /**
     * @dev Initializes the contract setting the deployer as the initial guardian.
     */
    constructor() {
        _transferWatch(msg.sender);
    }

    /**
     * @dev Throws if called by any account other than the guardian.
     */
    modifier onlyGuardian() {
        _checkGuardian();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the guardian.
     */
    function _checkGuardian() internal view virtual {
        require(guardian() == msg.sender, "Guardable: caller is not the guardian");
    }

    /**
     * @dev Leaves the contract without guardian. It will not be possible to call
     * `onlyGuardian` functions anymore. Can only be called by the current guardian.
     *
     * NOTE: Renouncing guardianship will leave the contract without a guardian,
     * thereby removing any functionality that is only available to the guardian.
     */
    function releaseGuard() public virtual onlyGuardian {
        _transferWatch(address(0));
    }

    /**
     * @dev Transfers guardianship of the contract to a new account (`newGuardian`).
     * Can only be called by the current guardian.
     */
    function transferWatch(address newGuardian) public virtual onlyGuardian {
        require(newGuardian != address(0), "Guardable: new guardian is the zero address");
        _transferWatch(newGuardian);
    }

    /**
     * @dev Transfers guardianship of the contract to a new account (`newGuardian`).
     * Internal function without access restriction.
     */
    function _transferWatch(address newGuardian) internal virtual {
        address oldGuardian = _guardian;
        _guardian = newGuardian;
        emit WatchTransferred(oldGuardian, newGuardian);
    }
}

File 25 of 26 : IPriceFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

/// @title IPriceFeed Interface
/// @notice Interface for price feed contracts that provide various price-related functionalities
interface IPriceFeed {
    /// @notice Enum to represent the current operational mode of the oracle
    enum OracleMode {AUTOMATED, FALLBACK}

    /// @notice Struct to hold detailed price information
    struct PriceDetails {
        uint lowestPrice;
        uint highestPrice;
        uint weightedAveragePrice;
        uint spotPrice;
        uint shortTwapPrice;
        uint longTwapPrice;
        uint suggestedAdditiveFeePCT;
        OracleMode currentMode;
    }

    /// @notice Fetches the current price details
    /// @param utilizationPCT The current utilization percentage
    /// @return A PriceDetails struct containing various price metrics
    function fetchPrice(uint utilizationPCT) external view returns (PriceDetails memory);

    /// @notice Fetches the weighted average price, used during liquidations
    /// @param testLiquidity Whether to test for liquidity
    /// @param testDeviation Whether to test for price deviation
    /// @return price The weighted average price
    function fetchWeightedAveragePrice(bool testLiquidity, bool testDeviation) external returns (uint price);

    /// @notice Fetches the lowest price, used when exiting escrow or testing for under-collateralized positions
    /// @param testLiquidity Whether to test for liquidity
    /// @param testDeviation Whether to test for price deviation
    /// @return price The lowest price
    function fetchLowestPrice(bool testLiquidity, bool testDeviation) external returns (uint price);

    /// @notice Fetches the lowest price with a fee suggestion, used when issuing new debt
    /// @param loadIncrease The increase in load
    /// @param originationOrRedemptionLoadPCT The origination or redemption load percentage
    /// @param testLiquidity Whether to test for liquidity
    /// @param testDeviation Whether to test for price deviation
    /// @return price The lowest price
    /// @return suggestedAdditiveFeePCT The suggested additive fee percentage
    function fetchLowestPriceWithFeeSuggestion(
        uint loadIncrease,
        uint originationOrRedemptionLoadPCT,
        bool testLiquidity,
        bool testDeviation
    ) external returns (uint price, uint suggestedAdditiveFeePCT);

    /// @notice Fetches the highest price with a fee suggestion, used during redemptions
    /// @param loadIncrease The increase in load
    /// @param originationOrRedemptionLoadPCT The origination or redemption load percentage
    /// @param testLiquidity Whether to test for liquidity
    /// @param testDeviation Whether to test for price deviation
    /// @return price The highest price
    /// @return suggestedAdditiveFeePCT The suggested additive fee percentage
    function fetchHighestPriceWithFeeSuggestion(
        uint loadIncrease,
        uint originationOrRedemptionLoadPCT,
        bool testLiquidity,
        bool testDeviation
    ) external returns (uint price, uint suggestedAdditiveFeePCT);
}

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

pragma solidity 0.8.21;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "../../../common/StableMath.sol";
import "../../../interfaces/IPriceFeed.sol";
import "../../../Guardable.sol";

/**
 * @title EthPriceFeed
 * @notice Abstract contract that manages and validates ETH price data from Chainlink oracles
 * @dev Implements circuit breaker functionality and price validation for Chainlink ETH price feed
 */
abstract contract EthPriceFeed is Guardable {
    /**
     * @dev Struct to store Chainlink oracle response data
     * @param roundId The round ID from Chainlink
     * @param answer The price answer from Chainlink
     * @param timestamp The timestamp of the price update
     * @param success Whether the Chainlink call was successful
     * @param decimals The number of decimals in the price data
     */
    struct ChainlinkResponse {
        uint80 roundId;
        int256 answer;
        uint256 timestamp;
        bool success;
        uint8 decimals;
    }

    // ======== STATE VARIABLES ========

    // Constants
    uint constant public TARGET_DIGITS = 18;  // Used to convert a price answer to an 18-digit precision uint
    uint constant public TIMEOUT = 14400;  // 4 hours: 60 * 60 * 4
    uint constant public MAX_ALLOWED_DEVIATION = 75e16; // 75% maximum allowed deviation setting
    uint constant public MIN_ALLOWED_DEVIATION = 20e16; // 20% minimum allowed deviation setting

    // Configurable deviation threshold
    uint public maxPriceDeviationFromPreviousRound = 3e17; // Default 30%

    // If true, immediately reverts if external call uses all gas instead of trying to set oracle as broken
    bool public oogGriefingProtectionEnabled = true;

    // Price feed state
    AggregatorV3Interface public priceAggregator;
    enum Status {chainlinkWorking, chainlinkBroken}
    Status public status;

    uint public lastGoodPrice;  // The last good price seen from the oracle by Usdx

    // ======== EVENTS ========

    event LastGoodPriceUpdated(uint _lastGoodPrice);
    event PriceFeedStatusChanged(Status newStatus);
    event MaxDeviationUpdated(uint oldDeviation, uint newDeviation);
    event GriefingProtectionEnabled(bool enabled);

    // ======== ERRORS ========

    error InsufficientGasForExternalCall(string target);

    // ======== EXTERNAL FUNCTIONS ========

    /**
     * @notice Updates the maximum allowed price deviation between rounds
     * @param newDeviation New maximum deviation value (with 18 decimal precision)
     * @dev Can only be called by guardian, must be between MIN_ALLOWED_DEVIATION and MAX_ALLOWED_DEVIATION
     */
    function setMaxPriceDeviation(uint newDeviation) external onlyGuardian {
        require(newDeviation >= MIN_ALLOWED_DEVIATION, "Deviation below minimum threshold");
        require(newDeviation <= MAX_ALLOWED_DEVIATION, "Deviation above maximum threshold");

        uint oldDeviation = maxPriceDeviationFromPreviousRound;
        maxPriceDeviationFromPreviousRound = newDeviation;

        emit MaxDeviationUpdated(oldDeviation, newDeviation);
    }

    function setGriefingProtection(bool enabled) external onlyGuardian {
        oogGriefingProtectionEnabled = enabled;
        emit GriefingProtectionEnabled(oogGriefingProtectionEnabled);
    }

    /**
     * @notice Fetches the current ETH price from Chainlink
     * @return Current ETH price with 18 decimal precision
     * @dev Reverts if the circuit breaker is active (status is chainlinkBroken), but if triggered, returns last good price.
     */
    function fetchEthPrice() public returns (uint) {
        require(status == Status.chainlinkWorking, "Chainlink Oracle Circuit Broken");
        ChainlinkResponse memory chainlinkResponse = _getCurrentChainlinkResponse();

        if(_badChainlinkResponse(chainlinkResponse)) {
            return _tripBreakerAndReturnFinalLastGoodPrice();
        } else {
            if (_isFrozenOrDeviated(chainlinkResponse)) {
                return _tripBreakerAndReturnFinalLastGoodPrice();
            } else {
                return _storeChainlinkPrice(chainlinkResponse);
            }
        }
    }

    /**
     * @notice View function to get the current ETH price
     * @return Current ETH price or last good price if there are issues with Chainlink
     */
    function viewEthPrice() public view returns (uint) {
        ChainlinkResponse memory chainlinkResponse = _getCurrentChainlinkResponse();

        if(_badChainlinkResponse(chainlinkResponse)) {
            return lastGoodPrice;
        } else {
            if (_isFrozenOrDeviated(chainlinkResponse)) {
                return lastGoodPrice;
            } else {
                return _scaleChainlinkPriceByDigits(uint256(chainlinkResponse.answer), chainlinkResponse.decimals);
            }
        }
    }

    /**
     * @notice Allows guardian to reset the circuit breaker and set a new price to continue from
     * @param newPrice The new price to set after resetting
     * @dev Can only be called by guardian when status is chainlinkBroken
     */
    function resetBreaker(uint newPrice) external onlyGuardian {
        require(status == Status.chainlinkBroken, "PriceFeed must be broken to intervene");
        _storePrice(newPrice);
        _changeStatus(Status.chainlinkWorking);
    }

    // ======== INTERNAL SETUP FUNCTIONS ========

    /**
     * @dev Sets up the price feed with Chainlink oracle addresses and initial price
     * @param _priceAggregatorAddresses Array of price aggregator addresses (only first one is used)
     */
    function _setAddresses(address[] memory _priceAggregatorAddresses) internal {
        priceAggregator = AggregatorV3Interface(_priceAggregatorAddresses[0]);
        status = Status.chainlinkWorking;

        ChainlinkResponse memory chainlinkResponse = _getCurrentChainlinkResponse();
        ChainlinkResponse memory prevChainlinkResponse = _getPrevChainlinkResponse(chainlinkResponse.roundId, chainlinkResponse.decimals);

        require(!_chainlinkIsBroken(chainlinkResponse, prevChainlinkResponse) && !_chainlinkIsFrozen(chainlinkResponse),
            "PriceFeed: Chainlink must be working and current");

        _storeChainlinkPrice(chainlinkResponse);
    }

    // ======== CHAINLINK INTERACTION FUNCTIONS ========

    /**
     * @dev Gets the current price data from Chainlink
     * @return chainlinkResponse Current Chainlink response
     */
    function _getCurrentChainlinkResponse() internal view returns (ChainlinkResponse memory chainlinkResponse) {
        uint256 gasBeforeDecimals = gasleft();

        // First, try to get current decimal precision:
        try priceAggregator.decimals() returns (uint8 decimals) {
            // If call to Chainlink succeeds, record the current decimal precision
            chainlinkResponse.decimals = decimals;
        } catch {
            // Require that enough gas was provided to prevent an OOG revert in the external call
            // causing a shutdown. Instead, just revert. Slightly conservative, as it includes gas used
            // in the check itself.
            if (
                gasleft() <= gasBeforeDecimals / 64 &&
                oogGriefingProtectionEnabled
            ) {revert InsufficientGasForExternalCall("decimals()");}

            // If call to Chainlink aggregator reverts, return a zero response with success = false
            return chainlinkResponse;
        }

        uint256 gasBeforeRoundData = gasleft();
        // Secondly, try to get latest price data:
        try priceAggregator.latestRoundData() returns
        (
            uint80 roundId,
            int256 answer,
            uint256 /* startedAt */,
            uint256 timestamp,
            uint80 /* answeredInRound */
        )
        {
            // If call to Chainlink succeeds, return the response and success = true
            chainlinkResponse.roundId = roundId;
            chainlinkResponse.answer = answer;
            chainlinkResponse.timestamp = timestamp;
            chainlinkResponse.success = true;
            return chainlinkResponse;
        } catch {
            // Require that enough gas was provided to prevent an OOG revert in the external call
            // causing a shutdown. Instead, just revert. Slightly conservative, as it includes gas used
            // in the check itself.
            if (
                gasleft() <= gasBeforeRoundData / 64 &&
                oogGriefingProtectionEnabled
            ) {revert InsufficientGasForExternalCall("latestRoundData()");}

            // If call to Chainlink aggregator reverts, return a zero response with success = false
            return chainlinkResponse;
        }
    }

    /**
     * @dev Gets the previous round's price data from Chainlink
     * @param _currentRoundId Current round ID
     * @param _currentDecimals Current decimal precision
     * @return prevChainlinkResponse Previous round's Chainlink response
     */
    function _getPrevChainlinkResponse(uint80 _currentRoundId, uint8 _currentDecimals) internal view returns (ChainlinkResponse memory prevChainlinkResponse) {
        /*
        * NOTE: Chainlink only offers a current decimals() value - there is no way to obtain the decimal precision used in a
        * previous round.  We assume the decimals used in the previous round are the same as the current round.
        */

        uint gasBefore = gasleft();
        // Try to get the price data from the previous round:
        try priceAggregator.getRoundData(_currentRoundId - 1) returns
        (
            uint80 roundId,
            int256 answer,
            uint256 /* startedAt */,
            uint256 timestamp,
            uint80 /* answeredInRound */
        )
        {
            // If call to Chainlink succeeds, return the response and success = true
            prevChainlinkResponse.roundId = roundId;
            prevChainlinkResponse.answer = answer;
            prevChainlinkResponse.timestamp = timestamp;
            prevChainlinkResponse.decimals = _currentDecimals;
            prevChainlinkResponse.success = true;
            return prevChainlinkResponse;
        } catch {
            // Require that enough gas was provided to prevent an OOG revert in the external call
            // causing a shutdown. Instead, just revert. Slightly conservative, as it includes gas used
            // in the check itself.
            if (
                gasleft() <= gasBefore / 64 &&
                oogGriefingProtectionEnabled
            ) {revert InsufficientGasForExternalCall("getRoundData()");}

            // If call to Chainlink aggregator reverts, return a zero response with success = false
            return prevChainlinkResponse;
        }
    }

    // ======== PRICE VALIDATION FUNCTIONS ========

    /**
     * @dev Checks if either current or previous Chainlink response is invalid
     * @param _currentResponse Current Chainlink response
     * @param _prevResponse Previous Chainlink response
     * @return bool True if either response is invalid
     */
    function _chainlinkIsBroken(ChainlinkResponse memory _currentResponse, ChainlinkResponse memory _prevResponse) internal view returns (bool) {
        return _badChainlinkResponse(_currentResponse) || _badChainlinkResponse(_prevResponse);
    }

    /**
     * @dev Validates a Chainlink response
     * @param _response Chainlink response to validate
     * @return bool True if the response is invalid
     */
    function _badChainlinkResponse(ChainlinkResponse memory _response) internal view returns (bool) {
        // Check for response call reverted
        if (!_response.success) {return true;}
        // Check for an invalid roundId that is 0
        if (_response.roundId == 0) {return true;}
        // Check for an invalid timeStamp that is 0, or in the future
        if (_response.timestamp == 0 || _response.timestamp > block.timestamp) {return true;}
        // Check for non-positive price
        if (_response.answer <= 0) {return true;}

        return false;
    }

    /**
     * @dev Checks if the Chainlink response is too old
     * @param _response Chainlink response to check
     * @return bool True if the response is older than TIMEOUT
     */
    function _chainlinkIsFrozen(ChainlinkResponse memory _response) internal view returns (bool) {
        return (block.timestamp - _response.timestamp) > TIMEOUT;
    }

    /**
     * @dev Checks if price change between responses exceeds maximum allowed deviation
     * @param _currentResponse Current Chainlink response
     * @param _prevResponse Previous Chainlink response
     * @return bool True if price change exceeds maximum allowed deviation
     */
    function _chainlinkPriceChangeAboveMax(ChainlinkResponse memory _currentResponse, ChainlinkResponse memory _prevResponse) internal view returns (bool) {
        uint currentScaledPrice = _scaleChainlinkPriceByDigits(uint256(_currentResponse.answer), _currentResponse.decimals);
        uint prevScaledPrice = _scaleChainlinkPriceByDigits(uint256(_prevResponse.answer), _prevResponse.decimals);

        uint minPrice = StableMath._min(currentScaledPrice, prevScaledPrice);
        uint maxPrice = StableMath._max(currentScaledPrice, prevScaledPrice);

        /*
        * Use the larger price as the denominator:
        * - If price decreased, the percentage deviation is in relation to the the previous price.
        * - If price increased, the percentage deviation is in relation to the current price.
        */
        uint percentDeviation = ((maxPrice - minPrice) * StableMath.DECIMAL_PRECISION) / maxPrice;

        // Return true if price deviation exceeds the configured maximum
        return percentDeviation > maxPriceDeviationFromPreviousRound;
    }

    /**
     * @dev Checks if the current Chainlink response is frozen or has deviated too much from previous
     * @param current Current Chainlink response
     * @return bool True if price feed is frozen or has deviated too much
     */
    function _isFrozenOrDeviated(ChainlinkResponse memory current) internal view returns (bool) {
        ChainlinkResponse memory prev = _getPrevChainlinkResponse(current.roundId, current.decimals);
        return _badChainlinkResponse(prev) || _chainlinkIsFrozen(current) || _chainlinkPriceChangeAboveMax(current, prev);
    }

    // ======== PRICE STORAGE AND SCALING FUNCTIONS ========

    /**
     * @dev Scales Chainlink price to target decimal precision
     * @param _price Raw price from Chainlink
     * @param _answerDigits Decimal precision of the Chainlink price
     * @return uint Scaled price with TARGET_DIGITS precision
     */
    function _scaleChainlinkPriceByDigits(uint256 _price, uint256 _answerDigits) internal pure returns (uint) {
        /*
        * Convert the price returned by the Chainlink oracle to an 18-digit decimal for use by usdx.
        * At date of usdx launch, Chainlink uses an 8-digit price, but we also handle the possibility of
        * future changes.
        */
        uint price;
        if (_answerDigits >= TARGET_DIGITS) {
            // Scale the returned price value down to usdx's target precision
            price = _price / (10 ** (_answerDigits - TARGET_DIGITS));
        }
        else if (_answerDigits < TARGET_DIGITS) {
            // Scale the returned price value up to usdx's target precision
            price = _price * (10 ** (TARGET_DIGITS - _answerDigits));
        }
        return price;
    }

    /**
     * @dev Stores a new price and emits an event
     * @param _currentPrice New price to store
     */
    function _storePrice(uint _currentPrice) internal {
        lastGoodPrice = _currentPrice;
        emit LastGoodPriceUpdated(_currentPrice);
    }

    /**
     * @dev Stores a Chainlink price after scaling it to target precision
     * @param _chainlinkResponse Chainlink response containing the price to store
     * @return uint Stored scaled price
     */
    function _storeChainlinkPrice(ChainlinkResponse memory _chainlinkResponse) internal returns (uint) {
        uint scaledChainlinkPrice = _scaleChainlinkPriceByDigits(uint256(_chainlinkResponse.answer), _chainlinkResponse.decimals);
        _storePrice(scaledChainlinkPrice);
        return scaledChainlinkPrice;
    }

    // ======== STATUS MANAGEMENT FUNCTIONS ========

    /**
     * @dev Internal function to change the status of the price feed
     * @param _status New status to set
     */
    function _changeStatus(Status _status) internal {
        status = _status;
        emit PriceFeedStatusChanged(_status);
    }

    /**
     * @dev Internal function to trip the circuit breaker and return the last good price
     * @return Last good price before the circuit breaker was triggered
     */
    function _tripBreakerAndReturnFinalLastGoodPrice() internal returns (uint) {
        _changeStatus(Status.chainlinkBroken);
        return lastGoodPrice;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_uniFactoryAddress","type":"address"},{"internalType":"address","name":"_titanX","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_positionController","type":"address"},{"internalType":"address","name":"_collateralController","type":"address"},{"internalType":"address[]","name":"_priceAggregatorAddresses","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"target","type":"string"}],"name":"InsufficientGasForExternalCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"GriefingProtectionEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_lastGoodPrice","type":"uint256"}],"name":"LastGoodPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldDeviation","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newDeviation","type":"uint256"}],"name":"MaxDeviationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum EthPriceFeed.Status","name":"newStatus","type":"uint8"}],"name":"PriceFeedStatusChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGuardian","type":"address"},{"indexed":true,"internalType":"address","name":"newGuardian","type":"address"}],"name":"WatchTransferred","type":"event"},{"inputs":[],"name":"FEE_TIER","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ALLOWED_DEVIATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_ALLOWED_DEVIATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TARGET_DIGITS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIMEOUT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TITANX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNI_FACTORY","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":"advancedFeeEstimationEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"considerSpotInDeviationCircuitBreakerTesting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deviationTestingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fetchEthPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"loadIncrease","type":"uint256"},{"internalType":"uint256","name":"originationOrRedemptionLoadPCT","type":"uint256"},{"internalType":"bool","name":"testLiquidity","type":"bool"},{"internalType":"bool","name":"testDeviation","type":"bool"}],"name":"fetchHighestPriceWithFeeSuggestion","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"suggestedAdditiveFeePCT","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"testLiquidity","type":"bool"},{"internalType":"bool","name":"testDeviation","type":"bool"}],"name":"fetchLowestPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"loadIncrease","type":"uint256"},{"internalType":"uint256","name":"originationOrRedemptionLoadPCT","type":"uint256"},{"internalType":"bool","name":"testLiquidity","type":"bool"},{"internalType":"bool","name":"testDeviation","type":"bool"}],"name":"fetchLowestPriceWithFeeSuggestion","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"suggestedAdditiveFeePCT","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"utilizationPCT","type":"uint256"}],"name":"fetchPrice","outputs":[{"components":[{"internalType":"uint256","name":"lowestPrice","type":"uint256"},{"internalType":"uint256","name":"highestPrice","type":"uint256"},{"internalType":"uint256","name":"weightedAveragePrice","type":"uint256"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"shortTwapPrice","type":"uint256"},{"internalType":"uint256","name":"longTwapPrice","type":"uint256"},{"internalType":"uint256","name":"suggestedAdditiveFeePCT","type":"uint256"},{"internalType":"enum IPriceFeed.OracleMode","name":"currentMode","type":"uint8"}],"internalType":"struct IPriceFeed.PriceDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"testLiquidity","type":"bool"},{"internalType":"bool","name":"testDeviation","type":"bool"}],"name":"fetchWeightedAveragePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"secondsAgo","type":"uint32"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastGoodPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"longTwapSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"longTwapWeightInAverage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFeeProjection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxOracleDeltaPCT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPriceDeviationFromPreviousRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxShortTwapInfluencePCT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oogGriefingProtectionEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceAggregator","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"secondsAgo","type":"uint32"}],"name":"quoteTitanPrice","outputs":[{"internalType":"uint256","name":"quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"releaseGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"resetBreaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isOn","type":"bool"}],"name":"setAdvancedFeeEstimation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"consider","type":"bool"}],"name":"setConsiderSpotInFeeEstimation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isOn","type":"bool"}],"name":"setDeviationTesting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setGriefingProtection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_newLongTwapSeconds","type":"uint32"}],"name":"setLongTwapSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"weight","type":"uint8"}],"name":"setLongTwapWeightInAverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mfp","type":"uint256"}],"name":"setMaxFeeProjection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaxOracleDeltaPCT","type":"uint256"}],"name":"setMaxOracleDelta","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newDeviation","type":"uint256"}],"name":"setMaxPriceDeviation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxInfluencePCT","type":"uint256"}],"name":"setMaxShortTwapInfluence","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pm","type":"address"}],"name":"setPositionManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_newShortTwapSeconds","type":"uint32"}],"name":"setShortTwapSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"weight","type":"uint8"}],"name":"setShortTwapWeightInAverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortTwapSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"shortTwapWeightInAverage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"status","outputs":[{"internalType":"enum EthPriceFeed.Status","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"transferWatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"viewEthPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

610120604052670429d069189e000060019081556002805460ff1916909117905560048054600160a01b600160f01b0319167d02010000003c00000168000000000000000000000000000000000000000017905567016345785d8a00006005556006805462ffffff19166201010117905566b1a2bc2ec5000060078190556008553480156200008d57600080fd5b5060405162003e9c38038062003e9c833981016040819052620000b091620007ee565b620000bb3362000167565b6001600160a01b0383811660805282811660a05286811660c05285811660e05284166101005260408051600180825281830190925260009160208083019080368337019050509050816000815181106200011957620001196200091f565b6020026020010151816000815181106200013757620001376200091f565b6001600160a01b03909216602092830291909101909101526200015a81620001b7565b5050505050505062000b5e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d9190a35050565b80600081518110620001cd57620001cd6200091f565b6020908102919091010151600280546001600160a01b039092166101000260ff60a81b1916610100600160b01b0319909216919091179055600062000211620002cf565b905060006200022f82600001518360800151620004c660201b60201c565b90506200023d828262000600565b158015620002535750620002518262000626565b155b620002be5760405162461bcd60e51b815260206004820152603060248201527f5072696365466565643a20436861696e6c696e6b206d75737420626520776f7260448201526f1ada5b99c8185b990818dd5c9c995b9d60821b60648201526084015b60405180910390fd5b620002c98262000644565b50505050565b620002d96200078d565b60005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000350575060408051601f3d908101601f191682019092526200034d9181019062000935565b60015b620003b5576200036260408262000970565b5a1115801562000374575060025460ff165b15620003b1576040516317e6281f60e11b815260206004820152600a602482015269646563696d616c73282960b01b6044820152606401620002b5565b5090565b60ff16608083015260005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa92505050801562000434575060408051601f3d908101601f191682019092526200043191810190620009ab565b60015b620004a1576200044660408262000970565b5a1115801562000458575060025460ff165b156200049c576040516317e6281f60e11b81526020600482015260116024820152706c6174657374526f756e6444617461282960781b6044820152606401620002b5565b505090565b506001600160501b039093168652506020850152604084015250506001606082015290565b620004d06200078d565b60005a60025490915061010090046001600160a01b0316639a6fc8f5620004f960018762000a00565b6040516001600160e01b031960e084901b1681526001600160501b03909116600482015260240160a060405180830381865afa9250505080156200055c575060408051601f3d908101601f191682019092526200055991810190620009ab565b60015b620005c8576200056e60408262000970565b5a1115801562000580575060025460ff165b15620005c1576040516317e6281f60e11b815260206004820152600e60248201526d676574526f756e6444617461282960901b6044820152606401620002b5565b50620005fa565b506001600160501b03909316855250602084015260408301525060ff8216608082015260016060820152620005fa565b505b92915050565b60006200060d8362000671565b806200061f57506200061f8262000671565b9392505050565b60006138408260400151426200063d919062000a23565b1192915050565b600080620006648360200151846080015160ff16620006e060201b60201c565b9050620005fa8162000752565b600081606001516200068557506001919050565b81516001600160501b0316600003620006a057506001919050565b60408201511580620006b55750428260400151115b15620006c357506001919050565b6000826020015113620006d857506001919050565b506000919050565b600080601283106200071a57620006f960128462000a23565b6200070690600a62000b36565b62000712908562000970565b90506200061f565b60128310156200061f576200073183601262000a23565b6200073e90600a62000b36565b6200074a908562000b44565b949350505050565b60038190556040518181527f4d29de21de555af78a62fc82dd4bc05e9ae5b0660a37f04729527e0f22780cd39060200160405180910390a150565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b80516001600160a01b0381168114620007d357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c087890312156200080857600080fd5b6200081387620007bb565b9550602062000824818901620007bb565b95506200083460408901620007bb565b94506200084460608901620007bb565b93506200085460808901620007bb565b60a08901519093506001600160401b03808211156200087257600080fd5b818a0191508a601f8301126200088757600080fd5b8151818111156200089c576200089c620007d8565b8060051b604051601f19603f83011681018181108582111715620008c457620008c4620007d8565b60405291825284820192508381018501918d831115620008e357600080fd5b938501935b828510156200090c57620008fc85620007bb565b84529385019392850192620008e8565b8096505050505050509295509295509295565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156200094857600080fd5b815160ff811681146200061f57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000826200098e57634e487b7160e01b600052601260045260246000fd5b500490565b80516001600160501b0381168114620007d357600080fd5b600080600080600060a08688031215620009c457600080fd5b620009cf8662000993565b9450602086015193506040860151925060608601519150620009f46080870162000993565b90509295509295909350565b6001600160501b03828116828216039080821115620005f857620005f86200095a565b81810381811115620005fa57620005fa6200095a565b600181815b8085111562000a7a57816000190482111562000a5e5762000a5e6200095a565b8085161562000a6c57918102915b93841c939080029062000a3e565b509250929050565b60008262000a9357506001620005fa565b8162000aa257506000620005fa565b816001811462000abb576002811462000ac65762000ae6565b6001915050620005fa565b60ff84111562000ada5762000ada6200095a565b50506001821b620005fa565b5060208310610133831016604e8410600b841016171562000b0b575081810a620005fa565b62000b17838362000a39565b806000190482111562000b2e5762000b2e6200095a565b029392505050565b60006200061f838362000a82565b8082028115828204841417620005fa57620005fa6200095a565b60805160a05160c05160e051610100516132cf62000bcd6000396000818161052f01526111bf015260008181610556015261119e0152600081816104c6015261198501526000818161043001526110e70152600081816102650152818161088401526110b501526132cf6000f3fe608060405234801561001057600080fd5b506004361061025b5760003560e01c8062551c06146102605780630490be83146102a457806311449b61146102bb57806313b54255146102ca5780631559f782146102d35780631be5c92f146102f3578063200d2ed2146102fb5780632217455a1461031c57806322cb9c6f14610324578063243a6e6c1461034c5780632f60d071146103555780633078fff51461035f57806334a93f25146103775780633b213c961461038a5780633c669cf31461039d578063452a9320146103c357806348c9d067146103cb5780634c69a6c9146103e85780634e778334146104055780635760f2e314610418578063690767881461042b5780636999948d14610452578063791b98bc146104655780637c9e639f14610478578063835bf12b1461048757806383786dc61461049b57806386317531146104ae57806389fc0056146104c1578063931cc314146104e857806399ce6575146104fb5780639ee4c0571461050e578063a1694d8e14610521578063ad5c46481461052a578063af528c1914610551578063b566aa1a14610578578063c0f5fef61461058b578063c0f6d7e01461059e578063cf0b00c6146105b1578063d09d6810146105c4578063d541d9e6146105f0578063d8cb4c0b14610603578063da26663a14610616578063e7d5dcbd14610629578063e82673661461063c578063e847a1bd14610645578063f2041b3814610658578063f548ef4614610660578063f56f48f21461066d578063f5dc275514610676578063fca29b7e14610688578063fd8f3a211461069f578063ff29dd96146106b2575b600080fd5b6102877f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6102ad60035481565b60405190815260200161029b565b6102ad6702c68af0bb14000081565b6102ad60085481565b6102e66102e13660046128ee565b6106c5565b60405161029b919061293b565b6102ad601281565b60025461030f90600160a81b900460ff1681565b60405161029b919061299f565b6102ad61081e565b6103376103323660046129c0565b610876565b6040805192835260208301919091520161029b565b6102ad60015481565b61035d61093f565b005b6002546102879061010090046001600160a01b031681565b61035d610385366004612a1f565b610953565b61035d610398366004612a4b565b6109d1565b6004546103b190600160e01b900460ff1681565b60405160ff909116815260200161029b565b610287610a1c565b6002546103d89060ff1681565b604051901515815260200161029b565b6103f161271081565b60405162ffffff909116815260200161029b565b61035d610413366004612a68565b610a2b565b61035d610426366004612a1f565b610a4f565b6102877f000000000000000000000000000000000000000000000000000000000000000081565b61035d6104603660046128ee565b610ade565b600454610287906001600160a01b031681565b6102ad670a688906bd8b000081565b6004546103b190600160e81b900460ff1681565b61035d6104a93660046128ee565b610b6d565b61035d6104bc366004612a97565b610bce565b6102877f000000000000000000000000000000000000000000000000000000000000000081565b61035d6104f63660046128ee565b610c95565b61035d610509366004612a4b565b610d2b565b61035d61051c3660046128ee565b610d76565b6102ad60055481565b6102877f000000000000000000000000000000000000000000000000000000000000000081565b6102877f000000000000000000000000000000000000000000000000000000000000000081565b6102ad610586366004612ab4565b610e87565b61035d610599366004612a68565b610fbe565b61035d6105ac3660046128ee565b610fe0565b6103376105bf3660046129c0565b611058565b6004546105db90600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161029b565b6102ad6105fe366004612ab4565b6110a8565b61035d610611366004612a68565b611169565b6102ad610624366004612a97565b611184565b6006546103d89062010000900460ff1681565b6102ad60075481565b6102ad610653366004612a97565b611197565b6102ad6111e4565b6006546103d89060ff1681565b6102ad61384081565b6006546103d890610100900460ff1681565b6004546105db90600160c01b900463ffffffff1681565b61035d6106ad366004612a97565b611293565b61035d6106c0366004612a68565b61135a565b6106cd61286b565b6106d561286b565b600060405180606001604052806106ec6000611184565b815260200161070c600460189054906101000a900463ffffffff16611184565b815260200161072c600460149054906101000a900463ffffffff16611184565b905280516060840152602081018051608085015260408201805160a08601529051905191925061075b916113b0565b82526020810151604082015161077191906113c8565b60208301526004546107969060ff600160e01b8204811691600160e81b900416612b03565b600454602083015160ff928316926107b692600160e01b90041690612b1c565b60045460408401516107d291600160e81b900460ff1690612b1c565b6107dc9190612b33565b6107e69190612b5c565b604083015260065462010000900460ff161561080f57610805846113d8565b60c0830152610817565b600060c08301525b5092915050565b6000806108296113fb565b9050610834816115da565b1561084157505060035490565b61084a81611644565b1561085757505060035490565b61086c8160200151826080015160ff16611683565b91505090565b5090565b600080336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146108df5760405162461bcd60e51b81526020600482015260066024820152654f6e6c79504360d01b60448201526064015b60405180910390fd5b60006108ea846116de565b90506000610900826020015183604001516113b0565b60065490915062010000900460ff16156109295761091d876113d8565b92508093505050610936565b9250600091506109369050565b94509492505050565b6109476117fc565b6109516000611869565b565b61095b6117fc565b6001600160a01b0381166109c55760405162461bcd60e51b815260206004820152602b60248201527f477561726461626c653a206e657720677561726469616e20697320746865207a60448201526a65726f206164647265737360a81b60648201526084016108d6565b6109ce81611869565b50565b6109d96117fc565b60008160ff16116109fc5760405162461bcd60e51b81526004016108d690612b70565b6004805460ff909216600160e01b0260ff60e01b19909216919091179055565b6000546001600160a01b031690565b610a336117fc565b60068054911515620100000262ff000019909216919091179055565b610a576117fc565b6004546001600160a01b031615610abc5760405162461bcd60e51b8152602060048201526024808201527f706f736974696f6e4d616e616765722068617320616c7265616479206265656e604482015263081cd95d60e21b60648201526084016108d6565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b610ae66117fc565b662386f26fc100008110158015610b055750670de0b6b3a76400008111155b610b685760405162461bcd60e51b815260206004820152602e60248201527f4d6178204665652050726f6a656374696f6e206d75737420626520626574776560448201526d656e20312520616e64203130302560901b60648201526084016108d6565b600855565b610b756117fc565b670de0b6b3a7640000811115610bc95760405162461bcd60e51b8152602060048201526019602482015278496e666c75656e6365206d757374206265203c3d203130302560381b60448201526064016108d6565b600555565b610bd66117fc565b60008163ffffffff1611610c3e5760405162461bcd60e51b815260206004820152602960248201527f53686f72742054574150207365636f6e6473206d75737420626520677265617460448201526806572207468616e20360bc1b60648201526084016108d6565b60045463ffffffff808316600160a01b9092041611610c6f5760405162461bcd60e51b81526004016108d690612ba5565b6004805463ffffffff909216600160c01b0263ffffffff60c01b19909216919091179055565b610c9d6117fc565b6001600254600160a81b900460ff166001811115610cbd57610cbd612907565b14610d185760405162461bcd60e51b815260206004820152602560248201527f507269636546656564206d7573742062652062726f6b656e20746f20696e74656044820152647276656e6560d81b60648201526084016108d6565b610d21816118b9565b6109ce60006118ee565b610d336117fc565b60008160ff1611610d565760405162461bcd60e51b81526004016108d690612b70565b6004805460ff909216600160e81b0260ff60e81b19909216919091179055565b610d7e6117fc565b6702c68af0bb140000811015610de05760405162461bcd60e51b815260206004820152602160248201527f446576696174696f6e2062656c6f77206d696e696d756d207468726573686f6c6044820152601960fa1b60648201526084016108d6565b670a688906bd8b0000811115610e425760405162461bcd60e51b815260206004820152602160248201527f446576696174696f6e2061626f7665206d6178696d756d207468726573686f6c6044820152601960fa1b60648201526084016108d6565b600180549082905560408051828152602081018490527fea7b0359048504e79474eaaa05294b49265fc4e7b0a0c3737aaa22412e90f16e910160405180910390a15050565b6004546000906001600160a01b03163314610eb45760405162461bcd60e51b81526004016108d690612bee565b6000610ebf836116de565b600454909150600090610ee59060ff600160e01b8204811691600160e81b900416612b03565b600454602084015160ff92831692610f0592600160e01b90041690612b1c565b6004546040850151610f2191600160e81b900460ff1690612b1c565b610f2b9190612b33565b610f359190612b5c565b90506000670de0b6b3a76400006005548460400151610f549190612b1c565b610f5e9190612b5c565b90506000818460400151610f729190612b33565b90506000828560400151610f869190612c0e565b905081841115610f9c57509350610fb892505050565b80841015610fb0579450610fb89350505050565b509193505050505b92915050565b610fc66117fc565b600680549115156101000261ff0019909216919091179055565b610fe86117fc565b6611c37937e080008082108015906110085750670de0b6b3a76400008211155b6110525760405162461bcd60e51b815260206004820152601b60248201527a4d757374206265206265747765656e20302e3525202d203130302560281b60448201526064016108d6565b50600755565b60045460009081906001600160a01b031633146110875760405162461bcd60e51b81526004016108d690612bee565b6000611092846116de565b90506000610900826020015183604001516113c8565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806111095750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6111425760405162461bcd60e51b815260206004820152600a6024820152694f6e6c7950436f72434360b01b60448201526064016108d6565b600061114d836116de565b9050611161816020015182604001516113b0565b949350505050565b6111716117fc565b6006805460ff1916911515919091179055565b6000610fb88261119261081e565b611947565b6000610fb87f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000008461197d565b600080600254600160a81b900460ff16600181111561120557611205612907565b146112525760405162461bcd60e51b815260206004820152601f60248201527f436861696e6c696e6b204f7261636c6520436972637569742042726f6b656e0060448201526064016108d6565b600061125c6113fb565b9050611267816115da565b156112745761086c611a9f565b61127d81611644565b1561128a5761086c611a9f565b61086c81611ab2565b61129b6117fc565b60008163ffffffff16116113025760405162461bcd60e51b815260206004820152602860248201527f4c6f6e672054574150207365636f6e6473206d75737420626520677265617465604482015267072207468616e20360c41b60648201526084016108d6565b60045463ffffffff600160c01b9091048116908216116113345760405162461bcd60e51b81526004016108d690612ba5565b6004805463ffffffff909216600160a01b0263ffffffff60a01b19909216919091179055565b6113626117fc565b6002805460ff191682151590811790915560405160ff909116151581527fab9c7aa16f84e4e5d12316e868fc65e8610fd13cc34831d13edc42cc6991c7a5906020015b60405180910390a150565b60008183106113bf57816113c1565b825b9392505050565b6000818310156113bf57816113c1565b6000670de0b6b3a7640000600854836113f19190612b1c565b610fb89190612b5c565b6114036128c0565b60005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611477575060408051601f3d908101601f1916820190925261147491810190612c21565b60015b6114d257611486604082612b5c565b5a11158015611497575060025460ff165b15610872576040516317e6281f60e11b815260206004820152600a602482015269646563696d616c73282960b01b60448201526064016108d6565b60ff16608083015260005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa92505050801561154e575060408051601f3d908101601f1916820190925261154b91810190612c5a565b60015b6115b55761155d604082612b5c565b5a1115801561156e575060025460ff165b156115b0576040516317e6281f60e11b81526020600482015260116024820152706c6174657374526f756e6444617461282960781b60448201526064016108d6565b505090565b506001600160501b039093168652506020850152604084015250506001606082015290565b600081606001516115ed57506001919050565b81516001600160501b031660000361160757506001919050565b6040820151158061161b5750428260400151115b1561162857506001919050565b600082602001511361163c57506001919050565b506000919050565b60008061165983600001518460800151611ad5565b9050611664816115da565b80611673575061167383611bf8565b806113c157506113c18382611c14565b600080601283106116b557611699601284612c0e565b6116a490600a612d8e565b6116ae9085612b5c565b90506113c1565b60128310156113c1576116c9836012612c0e565b6116d490600a612d8e565b6111619085612b1c565b61170260405180606001604052806000815260200160008152602001600081525090565b600061170c6111e4565b90506040518060600160405280611724600084611947565b8152602001611745600460189054906101000a900463ffffffff1684611947565b8152602001611766600460149054906101000a900463ffffffff1684611947565b90529150828015611779575060065460ff165b156117f65761179a82600660019054906101000a900460ff16600754611c9d565b6117f65760405162461bcd60e51b815260206004820152602760248201527f5369676e69666963616e7420707269636520646576696174696f6e20696e2070604482015266726f677265737360c81b60648201526084016108d6565b50919050565b33611805610a1c565b6001600160a01b0316146109515760405162461bcd60e51b815260206004820152602560248201527f477561726461626c653a2063616c6c6572206973206e6f742074686520677561604482015264393234b0b760d91b60648201526084016108d6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d9190a35050565b60038190556040518181527f4d29de21de555af78a62fc82dd4bc05e9ae5b0660a37f04729527e0f22780cd3906020016113a5565b6002805482919060ff60a81b1916600160a81b83600181111561191357611913612907565b02179055507f5c57579a8214fe4f710c1c56fa829f045b9fa6d225a744225a30c32188064d4e816040516113a5919061299f565b60008061195384611197565b90506000670de0b6b3a764000061196a8386612b1c565b6119749190612b5c565b95945050505050565b6000806119b67f00000000000000000000000000000000000000000000000000000000000000006119b18787612710611d29565b611d94565b905060006119c382611e78565b90508363ffffffff168163ffffffff1610156119dd578093505b60008463ffffffff16600003611a64576000839050806001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611a30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a549190612dac565b50949650611a8095505050505050565b6000611a70848761203b565b509050611a7c8161227e565b9150505b611a9481670de0b6b3a7640000898961268b565b979650505050505050565b6000611aab60016118ee565b5060035490565b600080611aca8360200151846080015160ff16611683565b9050610fb8816118b9565b611add6128c0565b60005a60025490915061010090046001600160a01b0316639a6fc8f5611b04600187612e45565b6040516001600160e01b031960e084901b1681526001600160501b03909116600482015260240160a060405180830381865afa925050508015611b64575060408051601f3d908101601f19168201909252611b6191810190612c5a565b60015b611bc957611b73604082612b5c565b5a11158015611b84575060025460ff165b15611bc3576040516317e6281f60e11b815260206004820152600e60248201526d676574526f756e6444617461282960901b60448201526064016108d6565b50610fb8565b506001600160501b03909316855250602084015260408301525060ff8216608082015260016060820152610fb8565b6000613840826040015142611c0d9190612c0e565b1192915050565b600080611c2c8460200151856080015160ff16611683565b90506000611c458460200151856080015160ff16611683565b90506000611c5383836113b0565b90506000611c6184846113c8565b9050600081670de0b6b3a7640000611c798583612c0e565b611c839190612b1c565b611c8d9190612b5c565b6001541098975050505050505050565b60008060008415611ce957611cc4611cbd876020015188604001516113b0565b87516113b0565b9150611ce2611cdb876020015188604001516113c8565b87516113c8565b9050611d12565b611cfb866020015187604001516113b0565b9150611d0f866020015187604001516113c8565b90505b83611d1d8383612757565b11159695505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b03161115611d64579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b600081602001516001600160a01b031682600001516001600160a01b031610611dbc57600080fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b6000806000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edf9190612dac565b50505093509350505060008161ffff1611611f215760405162461bcd60e51b81526020600482015260026024820152614e4960f01b60448201526064016108d6565b6000806001600160a01b03861663252c09d784611f3f876001612e65565b611f499190612e80565b6040516001600160e01b031960e084901b16815261ffff9091166004820152602401608060405180830381865afa158015611f88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fac9190612eb3565b935050509150806120275760405163252c09d760e01b8152600060048201526001600160a01b0387169063252c09d790602401608060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120209190612eb3565b5091935050505b6120318242612f03565b9695505050505050565b6000808263ffffffff166000036120795760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016108d6565b60408051600280825260608201835260009260208301908036833701905050905083816000815181106120ae576120ae612f36565b602002602001019063ffffffff16908163ffffffff16815250506000816001815181106120dd576120dd612f36565b602002602001019063ffffffff16908163ffffffff1681525050600080866001600160a01b031663883bdbfd846040518263ffffffff1660e01b81526004016121269190612f4c565b600060405180830381865afa158015612143573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261216b919081019061305d565b9150915060008260008151811061218457612184612f36565b60200260200101518360018151811061219f5761219f612f36565b60200260200101516121b1919061311f565b90506000826000815181106121c8576121c8612f36565b6020026020010151836001815181106121e3576121e3612f36565b60200260200101516121f5919061314c565b905063ffffffff8816612208818461316c565b975060008360060b128015612228575061222281846131aa565b60060b15155b1561223b5787612237816131cc565b9850505b63ffffffff8916600160201b600160c01b03602084901b166122646001600160a01b03836131ef565b61226e9190613221565b9750505050505050509250929050565b60008060008360020b12612295578260020b6122a2565b8260020b6122a290613247565b90506122b1620d89e719613263565b60020b8111156122e75760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016108d6565b6000816001166000036122fe57600160801b612310565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615612345576080612340826ffff97272373d413259a46990580e213a612b1c565b901c90505b600482161561236f57608061236a826ffff2e50f5f656932ef12357cf3c7fdcc612b1c565b901c90505b6008821615612399576080612394826fffe5caca7e10e4e61c3624eaa0941cd0612b1c565b901c90505b60108216156123c35760806123be826fffcb9843d60f6159c9db58835c926644612b1c565b901c90505b60208216156123ed5760806123e8826fff973b41fa98c081472e6896dfb254c0612b1c565b901c90505b6040821615612417576080612412826fff2ea16466c96a3843ec78b326b52861612b1c565b901c90505b608082161561244157608061243c826ffe5dee046a99a2a811c461f1969c3053612b1c565b901c90505b61010082161561246c576080612467826ffcbe86c7900a88aedcffc83b479aa3a4612b1c565b901c90505b610200821615612497576080612492826ff987a7253ac413176f2b074cf7815e54612b1c565b901c90505b6104008216156124c25760806124bd826ff3392b0822b70005940c7a398e4b70f3612b1c565b901c90505b6108008216156124ed5760806124e8826fe7159475a2c29b7443b29c7fa6e889d9612b1c565b901c90505b611000821615612518576080612513826fd097f3bdfd2022b8845ad8f792aa5825612b1c565b901c90505b61200082161561254357608061253e826fa9f746462d870fdf8a65dc1f90e061e5612b1c565b901c90505b61400082161561256e576080612569826f70d869a156d2a1b890bb3df62baf32f7612b1c565b901c90505b618000821615612599576080612594826f31be135f97d08fd981231505542fcfa6612b1c565b901c90505b620100008216156125c55760806125c0826f09aa508b5b7a84e1c677de54f3e99bc9612b1c565b901c90505b620200008216156125f05760806125eb826e5d6af8dedb81196699c329225ee604612b1c565b901c90505b6204000082161561261a576080612615826d2216e584f5fa1ea926041bedfe98612b1c565b901c90505b6208000082161561264257608061263d826b048a170391f7dc42444e8fa2612b1c565b901c90505b60008460020b131561265d5761265a81600019612b5c565b90505b61266b600160201b82613285565b1561267757600161267a565b60005b6111619060ff16602083901c612b33565b60006001600160801b036001600160a01b038616116126ff5760006126b96001600160a01b03871680612b1c565b9050826001600160a01b0316846001600160a01b0316106126e8576126e3600160c01b8683612781565b6126f7565b6126f78186600160c01b612781565b915050611161565b60006127196001600160a01b03871680600160401b612781565b9050826001600160a01b0316846001600160a01b03161061274857612743600160801b8683612781565b612031565b6120318186600160801b612781565b600081670de0b6b3a764000061276d8583612c0e565b6127779190612b1c565b6113c19190612b5c565b60008080600019858709858702925082811083820303915050806000036127bb578382816127b1576127b1612b46565b04925050506113c1565b8084116128025760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b60448201526064016108d6565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600060018111156128bb576128bb612907565b905290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60006020828403121561290057600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600281106109ce57634e487b7160e01b600052602160045260246000fd5b600061010082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e08301516129928161291d565b8060e08401525092915050565b602081016129ac8361291d565b91905290565b80151581146109ce57600080fd5b600080600080608085870312156129d657600080fd5b843593506020850135925060408501356129ef816129b2565b915060608501356129ff816129b2565b939692955090935050565b6001600160a01b03811681146109ce57600080fd5b600060208284031215612a3157600080fd5b81356113c181612a0a565b60ff811681146109ce57600080fd5b600060208284031215612a5d57600080fd5b81356113c181612a3c565b600060208284031215612a7a57600080fd5b81356113c1816129b2565b63ffffffff811681146109ce57600080fd5b600060208284031215612aa957600080fd5b81356113c181612a85565b60008060408385031215612ac757600080fd5b8235612ad2816129b2565b91506020830135612ae2816129b2565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b60ff8181168382160190811115610fb857610fb8612aed565b8082028115828204841417610fb857610fb8612aed565b80820180821115610fb857610fb8612aed565b634e487b7160e01b600052601260045260246000fd5b600082612b6b57612b6b612b46565b500490565b6020808252818101527f576569676874206d7573742062652067726561746572207468616e207a65726f604082015260600190565b60208082526029908201527f4c6f6e672054574150206d7573742062652067726561746572207468616e20736040820152680686f727420545741560bc1b606082015260800190565b6020808252600690820152654f6e6c79504d60d01b604082015260600190565b81810381811115610fb857610fb8612aed565b600060208284031215612c3357600080fd5b81516113c181612a3c565b80516001600160501b0381168114612c5557600080fd5b919050565b600080600080600060a08688031215612c7257600080fd5b612c7b86612c3e565b9450602086015193506040860151925060608601519150612c9e60808701612c3e565b90509295509295909350565b600181815b80851115612ce5578160001904821115612ccb57612ccb612aed565b80851615612cd857918102915b93841c9390800290612caf565b509250929050565b600082612cfc57506001610fb8565b81612d0957506000610fb8565b8160018114612d1f5760028114612d2957612d45565b6001915050610fb8565b60ff841115612d3a57612d3a612aed565b50506001821b610fb8565b5060208310610133831016604e8410600b8410161715612d68575081810a610fb8565b612d728383612caa565b8060001904821115612d8657612d86612aed565b029392505050565b60006113c18383612ced565b805161ffff81168114612c5557600080fd5b600080600080600080600060e0888a031215612dc757600080fd5b8751612dd281612a0a565b8097505060208801518060020b8114612dea57600080fd5b9550612df860408901612d9a565b9450612e0660608901612d9a565b9350612e1460808901612d9a565b925060a0880151612e2481612a3c565b60c0890151909250612e35816129b2565b8091505092959891949750929550565b6001600160501b0382811682821603908082111561081757610817612aed565b61ffff81811683821601908082111561081757610817612aed565b600061ffff80841680612e9557612e95612b46565b92169190910692915050565b8051600681900b8114612c5557600080fd5b60008060008060808587031215612ec957600080fd5b8451612ed481612a85565b9350612ee260208601612ea1565b92506040850151612ef281612a0a565b60608601519092506129ff816129b2565b63ffffffff82811682821603908082111561081757610817612aed565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252825182820181905260009190848201906040850190845b81811015612f8a57835163ffffffff1683529284019291840191600101612f68565b50909695505050505050565b604051601f8201601f191681016001600160401b0381118282101715612fbe57612fbe612f20565b604052919050565b60006001600160401b03821115612fdf57612fdf612f20565b5060051b60200190565b600082601f830112612ffa57600080fd5b8151602061300f61300a83612fc6565b612f96565b82815260059290921b8401810191818101908684111561302e57600080fd5b8286015b8481101561305257805161304581612a0a565b8352918301918301613032565b509695505050505050565b6000806040838503121561307057600080fd5b82516001600160401b038082111561308757600080fd5b818501915085601f83011261309b57600080fd5b815160206130ab61300a83612fc6565b82815260059290921b840181019181810190898411156130ca57600080fd5b948201945b838610156130ef576130e086612ea1565b825294820194908201906130cf565b9188015191965090935050508082111561310857600080fd5b5061311585828601612fe9565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715610fb857610fb8612aed565b6001600160a01b0382811682821603908082111561081757610817612aed565b60008160060b8360060b8061318357613183612b46565b667fffffffffffff198214600019821416156131a1576131a1612aed565b90059392505050565b60008260060b806131bd576131bd612b46565b808360060b0791505092915050565b60008160020b627fffff1981036131e5576131e5612aed565b6000190192915050565b6001600160c01b0382811682821681810283169291811582850482141761321857613218612aed565b50505092915050565b60006001600160c01b038381168061323b5761323b612b46565b92169190910492915050565b6000600160ff1b820161325c5761325c612aed565b5060000390565b60008160020b627fffff19810361327c5761327c612aed565b60000392915050565b60008261329457613294612b46565b50069056fea2646970667358221220e0159516d482f2e59df7d32fa0d866f09818f35baa58269e0a78661ff1bb5cdb64736f6c634300081500330000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b0000000000000000000000001e7460c8527282fd15b4bc7bbc451cd20d95b14e00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061025b5760003560e01c8062551c06146102605780630490be83146102a457806311449b61146102bb57806313b54255146102ca5780631559f782146102d35780631be5c92f146102f3578063200d2ed2146102fb5780632217455a1461031c57806322cb9c6f14610324578063243a6e6c1461034c5780632f60d071146103555780633078fff51461035f57806334a93f25146103775780633b213c961461038a5780633c669cf31461039d578063452a9320146103c357806348c9d067146103cb5780634c69a6c9146103e85780634e778334146104055780635760f2e314610418578063690767881461042b5780636999948d14610452578063791b98bc146104655780637c9e639f14610478578063835bf12b1461048757806383786dc61461049b57806386317531146104ae57806389fc0056146104c1578063931cc314146104e857806399ce6575146104fb5780639ee4c0571461050e578063a1694d8e14610521578063ad5c46481461052a578063af528c1914610551578063b566aa1a14610578578063c0f5fef61461058b578063c0f6d7e01461059e578063cf0b00c6146105b1578063d09d6810146105c4578063d541d9e6146105f0578063d8cb4c0b14610603578063da26663a14610616578063e7d5dcbd14610629578063e82673661461063c578063e847a1bd14610645578063f2041b3814610658578063f548ef4614610660578063f56f48f21461066d578063f5dc275514610676578063fca29b7e14610688578063fd8f3a211461069f578063ff29dd96146106b2575b600080fd5b6102877f000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b81565b6040516001600160a01b0390911681526020015b60405180910390f35b6102ad60035481565b60405190815260200161029b565b6102ad6702c68af0bb14000081565b6102ad60085481565b6102e66102e13660046128ee565b6106c5565b60405161029b919061293b565b6102ad601281565b60025461030f90600160a81b900460ff1681565b60405161029b919061299f565b6102ad61081e565b6103376103323660046129c0565b610876565b6040805192835260208301919091520161029b565b6102ad60015481565b61035d61093f565b005b6002546102879061010090046001600160a01b031681565b61035d610385366004612a1f565b610953565b61035d610398366004612a4b565b6109d1565b6004546103b190600160e01b900460ff1681565b60405160ff909116815260200161029b565b610287610a1c565b6002546103d89060ff1681565b604051901515815260200161029b565b6103f161271081565b60405162ffffff909116815260200161029b565b61035d610413366004612a68565b610a2b565b61035d610426366004612a1f565b610a4f565b6102877f0000000000000000000000001e7460c8527282fd15b4bc7bbc451cd20d95b14e81565b61035d6104603660046128ee565b610ade565b600454610287906001600160a01b031681565b6102ad670a688906bd8b000081565b6004546103b190600160e81b900460ff1681565b61035d6104a93660046128ee565b610b6d565b61035d6104bc366004612a97565b610bce565b6102877f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b61035d6104f63660046128ee565b610c95565b61035d610509366004612a4b565b610d2b565b61035d61051c3660046128ee565b610d76565b6102ad60055481565b6102877f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6102877f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b181565b6102ad610586366004612ab4565b610e87565b61035d610599366004612a68565b610fbe565b61035d6105ac3660046128ee565b610fe0565b6103376105bf3660046129c0565b611058565b6004546105db90600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161029b565b6102ad6105fe366004612ab4565b6110a8565b61035d610611366004612a68565b611169565b6102ad610624366004612a97565b611184565b6006546103d89062010000900460ff1681565b6102ad60075481565b6102ad610653366004612a97565b611197565b6102ad6111e4565b6006546103d89060ff1681565b6102ad61384081565b6006546103d890610100900460ff1681565b6004546105db90600160c01b900463ffffffff1681565b61035d6106ad366004612a97565b611293565b61035d6106c0366004612a68565b61135a565b6106cd61286b565b6106d561286b565b600060405180606001604052806106ec6000611184565b815260200161070c600460189054906101000a900463ffffffff16611184565b815260200161072c600460149054906101000a900463ffffffff16611184565b905280516060840152602081018051608085015260408201805160a08601529051905191925061075b916113b0565b82526020810151604082015161077191906113c8565b60208301526004546107969060ff600160e01b8204811691600160e81b900416612b03565b600454602083015160ff928316926107b692600160e01b90041690612b1c565b60045460408401516107d291600160e81b900460ff1690612b1c565b6107dc9190612b33565b6107e69190612b5c565b604083015260065462010000900460ff161561080f57610805846113d8565b60c0830152610817565b600060c08301525b5092915050565b6000806108296113fb565b9050610834816115da565b1561084157505060035490565b61084a81611644565b1561085757505060035490565b61086c8160200151826080015160ff16611683565b91505090565b5090565b600080336001600160a01b037f000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b16146108df5760405162461bcd60e51b81526020600482015260066024820152654f6e6c79504360d01b60448201526064015b60405180910390fd5b60006108ea846116de565b90506000610900826020015183604001516113b0565b60065490915062010000900460ff16156109295761091d876113d8565b92508093505050610936565b9250600091506109369050565b94509492505050565b6109476117fc565b6109516000611869565b565b61095b6117fc565b6001600160a01b0381166109c55760405162461bcd60e51b815260206004820152602b60248201527f477561726461626c653a206e657720677561726469616e20697320746865207a60448201526a65726f206164647265737360a81b60648201526084016108d6565b6109ce81611869565b50565b6109d96117fc565b60008160ff16116109fc5760405162461bcd60e51b81526004016108d690612b70565b6004805460ff909216600160e01b0260ff60e01b19909216919091179055565b6000546001600160a01b031690565b610a336117fc565b60068054911515620100000262ff000019909216919091179055565b610a576117fc565b6004546001600160a01b031615610abc5760405162461bcd60e51b8152602060048201526024808201527f706f736974696f6e4d616e616765722068617320616c7265616479206265656e604482015263081cd95d60e21b60648201526084016108d6565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b610ae66117fc565b662386f26fc100008110158015610b055750670de0b6b3a76400008111155b610b685760405162461bcd60e51b815260206004820152602e60248201527f4d6178204665652050726f6a656374696f6e206d75737420626520626574776560448201526d656e20312520616e64203130302560901b60648201526084016108d6565b600855565b610b756117fc565b670de0b6b3a7640000811115610bc95760405162461bcd60e51b8152602060048201526019602482015278496e666c75656e6365206d757374206265203c3d203130302560381b60448201526064016108d6565b600555565b610bd66117fc565b60008163ffffffff1611610c3e5760405162461bcd60e51b815260206004820152602960248201527f53686f72742054574150207365636f6e6473206d75737420626520677265617460448201526806572207468616e20360bc1b60648201526084016108d6565b60045463ffffffff808316600160a01b9092041611610c6f5760405162461bcd60e51b81526004016108d690612ba5565b6004805463ffffffff909216600160c01b0263ffffffff60c01b19909216919091179055565b610c9d6117fc565b6001600254600160a81b900460ff166001811115610cbd57610cbd612907565b14610d185760405162461bcd60e51b815260206004820152602560248201527f507269636546656564206d7573742062652062726f6b656e20746f20696e74656044820152647276656e6560d81b60648201526084016108d6565b610d21816118b9565b6109ce60006118ee565b610d336117fc565b60008160ff1611610d565760405162461bcd60e51b81526004016108d690612b70565b6004805460ff909216600160e81b0260ff60e81b19909216919091179055565b610d7e6117fc565b6702c68af0bb140000811015610de05760405162461bcd60e51b815260206004820152602160248201527f446576696174696f6e2062656c6f77206d696e696d756d207468726573686f6c6044820152601960fa1b60648201526084016108d6565b670a688906bd8b0000811115610e425760405162461bcd60e51b815260206004820152602160248201527f446576696174696f6e2061626f7665206d6178696d756d207468726573686f6c6044820152601960fa1b60648201526084016108d6565b600180549082905560408051828152602081018490527fea7b0359048504e79474eaaa05294b49265fc4e7b0a0c3737aaa22412e90f16e910160405180910390a15050565b6004546000906001600160a01b03163314610eb45760405162461bcd60e51b81526004016108d690612bee565b6000610ebf836116de565b600454909150600090610ee59060ff600160e01b8204811691600160e81b900416612b03565b600454602084015160ff92831692610f0592600160e01b90041690612b1c565b6004546040850151610f2191600160e81b900460ff1690612b1c565b610f2b9190612b33565b610f359190612b5c565b90506000670de0b6b3a76400006005548460400151610f549190612b1c565b610f5e9190612b5c565b90506000818460400151610f729190612b33565b90506000828560400151610f869190612c0e565b905081841115610f9c57509350610fb892505050565b80841015610fb0579450610fb89350505050565b509193505050505b92915050565b610fc66117fc565b600680549115156101000261ff0019909216919091179055565b610fe86117fc565b6611c37937e080008082108015906110085750670de0b6b3a76400008211155b6110525760405162461bcd60e51b815260206004820152601b60248201527a4d757374206265206265747765656e20302e3525202d203130302560281b60448201526064016108d6565b50600755565b60045460009081906001600160a01b031633146110875760405162461bcd60e51b81526004016108d690612bee565b6000611092846116de565b90506000610900826020015183604001516113c8565b6000336001600160a01b037f000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b1614806111095750336001600160a01b037f0000000000000000000000001e7460c8527282fd15b4bc7bbc451cd20d95b14e16145b6111425760405162461bcd60e51b815260206004820152600a6024820152694f6e6c7950436f72434360b01b60448201526064016108d6565b600061114d836116de565b9050611161816020015182604001516113b0565b949350505050565b6111716117fc565b6006805460ff1916911515919091179055565b6000610fb88261119261081e565b611947565b6000610fb87f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b17f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28461197d565b600080600254600160a81b900460ff16600181111561120557611205612907565b146112525760405162461bcd60e51b815260206004820152601f60248201527f436861696e6c696e6b204f7261636c6520436972637569742042726f6b656e0060448201526064016108d6565b600061125c6113fb565b9050611267816115da565b156112745761086c611a9f565b61127d81611644565b1561128a5761086c611a9f565b61086c81611ab2565b61129b6117fc565b60008163ffffffff16116113025760405162461bcd60e51b815260206004820152602860248201527f4c6f6e672054574150207365636f6e6473206d75737420626520677265617465604482015267072207468616e20360c41b60648201526084016108d6565b60045463ffffffff600160c01b9091048116908216116113345760405162461bcd60e51b81526004016108d690612ba5565b6004805463ffffffff909216600160a01b0263ffffffff60a01b19909216919091179055565b6113626117fc565b6002805460ff191682151590811790915560405160ff909116151581527fab9c7aa16f84e4e5d12316e868fc65e8610fd13cc34831d13edc42cc6991c7a5906020015b60405180910390a150565b60008183106113bf57816113c1565b825b9392505050565b6000818310156113bf57816113c1565b6000670de0b6b3a7640000600854836113f19190612b1c565b610fb89190612b5c565b6114036128c0565b60005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611477575060408051601f3d908101601f1916820190925261147491810190612c21565b60015b6114d257611486604082612b5c565b5a11158015611497575060025460ff165b15610872576040516317e6281f60e11b815260206004820152600a602482015269646563696d616c73282960b01b60448201526064016108d6565b60ff16608083015260005a9050600260019054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa92505050801561154e575060408051601f3d908101601f1916820190925261154b91810190612c5a565b60015b6115b55761155d604082612b5c565b5a1115801561156e575060025460ff165b156115b0576040516317e6281f60e11b81526020600482015260116024820152706c6174657374526f756e6444617461282960781b60448201526064016108d6565b505090565b506001600160501b039093168652506020850152604084015250506001606082015290565b600081606001516115ed57506001919050565b81516001600160501b031660000361160757506001919050565b6040820151158061161b5750428260400151115b1561162857506001919050565b600082602001511361163c57506001919050565b506000919050565b60008061165983600001518460800151611ad5565b9050611664816115da565b80611673575061167383611bf8565b806113c157506113c18382611c14565b600080601283106116b557611699601284612c0e565b6116a490600a612d8e565b6116ae9085612b5c565b90506113c1565b60128310156113c1576116c9836012612c0e565b6116d490600a612d8e565b6111619085612b1c565b61170260405180606001604052806000815260200160008152602001600081525090565b600061170c6111e4565b90506040518060600160405280611724600084611947565b8152602001611745600460189054906101000a900463ffffffff1684611947565b8152602001611766600460149054906101000a900463ffffffff1684611947565b90529150828015611779575060065460ff165b156117f65761179a82600660019054906101000a900460ff16600754611c9d565b6117f65760405162461bcd60e51b815260206004820152602760248201527f5369676e69666963616e7420707269636520646576696174696f6e20696e2070604482015266726f677265737360c81b60648201526084016108d6565b50919050565b33611805610a1c565b6001600160a01b0316146109515760405162461bcd60e51b815260206004820152602560248201527f477561726461626c653a2063616c6c6572206973206e6f742074686520677561604482015264393234b0b760d91b60648201526084016108d6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d9190a35050565b60038190556040518181527f4d29de21de555af78a62fc82dd4bc05e9ae5b0660a37f04729527e0f22780cd3906020016113a5565b6002805482919060ff60a81b1916600160a81b83600181111561191357611913612907565b02179055507f5c57579a8214fe4f710c1c56fa829f045b9fa6d225a744225a30c32188064d4e816040516113a5919061299f565b60008061195384611197565b90506000670de0b6b3a764000061196a8386612b1c565b6119749190612b5c565b95945050505050565b6000806119b67f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9846119b18787612710611d29565b611d94565b905060006119c382611e78565b90508363ffffffff168163ffffffff1610156119dd578093505b60008463ffffffff16600003611a64576000839050806001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611a30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a549190612dac565b50949650611a8095505050505050565b6000611a70848761203b565b509050611a7c8161227e565b9150505b611a9481670de0b6b3a7640000898961268b565b979650505050505050565b6000611aab60016118ee565b5060035490565b600080611aca8360200151846080015160ff16611683565b9050610fb8816118b9565b611add6128c0565b60005a60025490915061010090046001600160a01b0316639a6fc8f5611b04600187612e45565b6040516001600160e01b031960e084901b1681526001600160501b03909116600482015260240160a060405180830381865afa925050508015611b64575060408051601f3d908101601f19168201909252611b6191810190612c5a565b60015b611bc957611b73604082612b5c565b5a11158015611b84575060025460ff165b15611bc3576040516317e6281f60e11b815260206004820152600e60248201526d676574526f756e6444617461282960901b60448201526064016108d6565b50610fb8565b506001600160501b03909316855250602084015260408301525060ff8216608082015260016060820152610fb8565b6000613840826040015142611c0d9190612c0e565b1192915050565b600080611c2c8460200151856080015160ff16611683565b90506000611c458460200151856080015160ff16611683565b90506000611c5383836113b0565b90506000611c6184846113c8565b9050600081670de0b6b3a7640000611c798583612c0e565b611c839190612b1c565b611c8d9190612b5c565b6001541098975050505050505050565b60008060008415611ce957611cc4611cbd876020015188604001516113b0565b87516113b0565b9150611ce2611cdb876020015188604001516113c8565b87516113c8565b9050611d12565b611cfb866020015187604001516113b0565b9150611d0f866020015187604001516113c8565b90505b83611d1d8383612757565b11159695505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b03161115611d64579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b600081602001516001600160a01b031682600001516001600160a01b031610611dbc57600080fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b6000806000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edf9190612dac565b50505093509350505060008161ffff1611611f215760405162461bcd60e51b81526020600482015260026024820152614e4960f01b60448201526064016108d6565b6000806001600160a01b03861663252c09d784611f3f876001612e65565b611f499190612e80565b6040516001600160e01b031960e084901b16815261ffff9091166004820152602401608060405180830381865afa158015611f88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fac9190612eb3565b935050509150806120275760405163252c09d760e01b8152600060048201526001600160a01b0387169063252c09d790602401608060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120209190612eb3565b5091935050505b6120318242612f03565b9695505050505050565b6000808263ffffffff166000036120795760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016108d6565b60408051600280825260608201835260009260208301908036833701905050905083816000815181106120ae576120ae612f36565b602002602001019063ffffffff16908163ffffffff16815250506000816001815181106120dd576120dd612f36565b602002602001019063ffffffff16908163ffffffff1681525050600080866001600160a01b031663883bdbfd846040518263ffffffff1660e01b81526004016121269190612f4c565b600060405180830381865afa158015612143573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261216b919081019061305d565b9150915060008260008151811061218457612184612f36565b60200260200101518360018151811061219f5761219f612f36565b60200260200101516121b1919061311f565b90506000826000815181106121c8576121c8612f36565b6020026020010151836001815181106121e3576121e3612f36565b60200260200101516121f5919061314c565b905063ffffffff8816612208818461316c565b975060008360060b128015612228575061222281846131aa565b60060b15155b1561223b5787612237816131cc565b9850505b63ffffffff8916600160201b600160c01b03602084901b166122646001600160a01b03836131ef565b61226e9190613221565b9750505050505050509250929050565b60008060008360020b12612295578260020b6122a2565b8260020b6122a290613247565b90506122b1620d89e719613263565b60020b8111156122e75760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016108d6565b6000816001166000036122fe57600160801b612310565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615612345576080612340826ffff97272373d413259a46990580e213a612b1c565b901c90505b600482161561236f57608061236a826ffff2e50f5f656932ef12357cf3c7fdcc612b1c565b901c90505b6008821615612399576080612394826fffe5caca7e10e4e61c3624eaa0941cd0612b1c565b901c90505b60108216156123c35760806123be826fffcb9843d60f6159c9db58835c926644612b1c565b901c90505b60208216156123ed5760806123e8826fff973b41fa98c081472e6896dfb254c0612b1c565b901c90505b6040821615612417576080612412826fff2ea16466c96a3843ec78b326b52861612b1c565b901c90505b608082161561244157608061243c826ffe5dee046a99a2a811c461f1969c3053612b1c565b901c90505b61010082161561246c576080612467826ffcbe86c7900a88aedcffc83b479aa3a4612b1c565b901c90505b610200821615612497576080612492826ff987a7253ac413176f2b074cf7815e54612b1c565b901c90505b6104008216156124c25760806124bd826ff3392b0822b70005940c7a398e4b70f3612b1c565b901c90505b6108008216156124ed5760806124e8826fe7159475a2c29b7443b29c7fa6e889d9612b1c565b901c90505b611000821615612518576080612513826fd097f3bdfd2022b8845ad8f792aa5825612b1c565b901c90505b61200082161561254357608061253e826fa9f746462d870fdf8a65dc1f90e061e5612b1c565b901c90505b61400082161561256e576080612569826f70d869a156d2a1b890bb3df62baf32f7612b1c565b901c90505b618000821615612599576080612594826f31be135f97d08fd981231505542fcfa6612b1c565b901c90505b620100008216156125c55760806125c0826f09aa508b5b7a84e1c677de54f3e99bc9612b1c565b901c90505b620200008216156125f05760806125eb826e5d6af8dedb81196699c329225ee604612b1c565b901c90505b6204000082161561261a576080612615826d2216e584f5fa1ea926041bedfe98612b1c565b901c90505b6208000082161561264257608061263d826b048a170391f7dc42444e8fa2612b1c565b901c90505b60008460020b131561265d5761265a81600019612b5c565b90505b61266b600160201b82613285565b1561267757600161267a565b60005b6111619060ff16602083901c612b33565b60006001600160801b036001600160a01b038616116126ff5760006126b96001600160a01b03871680612b1c565b9050826001600160a01b0316846001600160a01b0316106126e8576126e3600160c01b8683612781565b6126f7565b6126f78186600160c01b612781565b915050611161565b60006127196001600160a01b03871680600160401b612781565b9050826001600160a01b0316846001600160a01b03161061274857612743600160801b8683612781565b612031565b6120318186600160801b612781565b600081670de0b6b3a764000061276d8583612c0e565b6127779190612b1c565b6113c19190612b5c565b60008080600019858709858702925082811083820303915050806000036127bb578382816127b1576127b1612b46565b04925050506113c1565b8084116128025760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b60448201526064016108d6565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600060018111156128bb576128bb612907565b905290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60006020828403121561290057600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600281106109ce57634e487b7160e01b600052602160045260246000fd5b600061010082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e08301516129928161291d565b8060e08401525092915050565b602081016129ac8361291d565b91905290565b80151581146109ce57600080fd5b600080600080608085870312156129d657600080fd5b843593506020850135925060408501356129ef816129b2565b915060608501356129ff816129b2565b939692955090935050565b6001600160a01b03811681146109ce57600080fd5b600060208284031215612a3157600080fd5b81356113c181612a0a565b60ff811681146109ce57600080fd5b600060208284031215612a5d57600080fd5b81356113c181612a3c565b600060208284031215612a7a57600080fd5b81356113c1816129b2565b63ffffffff811681146109ce57600080fd5b600060208284031215612aa957600080fd5b81356113c181612a85565b60008060408385031215612ac757600080fd5b8235612ad2816129b2565b91506020830135612ae2816129b2565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b60ff8181168382160190811115610fb857610fb8612aed565b8082028115828204841417610fb857610fb8612aed565b80820180821115610fb857610fb8612aed565b634e487b7160e01b600052601260045260246000fd5b600082612b6b57612b6b612b46565b500490565b6020808252818101527f576569676874206d7573742062652067726561746572207468616e207a65726f604082015260600190565b60208082526029908201527f4c6f6e672054574150206d7573742062652067726561746572207468616e20736040820152680686f727420545741560bc1b606082015260800190565b6020808252600690820152654f6e6c79504d60d01b604082015260600190565b81810381811115610fb857610fb8612aed565b600060208284031215612c3357600080fd5b81516113c181612a3c565b80516001600160501b0381168114612c5557600080fd5b919050565b600080600080600060a08688031215612c7257600080fd5b612c7b86612c3e565b9450602086015193506040860151925060608601519150612c9e60808701612c3e565b90509295509295909350565b600181815b80851115612ce5578160001904821115612ccb57612ccb612aed565b80851615612cd857918102915b93841c9390800290612caf565b509250929050565b600082612cfc57506001610fb8565b81612d0957506000610fb8565b8160018114612d1f5760028114612d2957612d45565b6001915050610fb8565b60ff841115612d3a57612d3a612aed565b50506001821b610fb8565b5060208310610133831016604e8410600b8410161715612d68575081810a610fb8565b612d728383612caa565b8060001904821115612d8657612d86612aed565b029392505050565b60006113c18383612ced565b805161ffff81168114612c5557600080fd5b600080600080600080600060e0888a031215612dc757600080fd5b8751612dd281612a0a565b8097505060208801518060020b8114612dea57600080fd5b9550612df860408901612d9a565b9450612e0660608901612d9a565b9350612e1460808901612d9a565b925060a0880151612e2481612a3c565b60c0890151909250612e35816129b2565b8091505092959891949750929550565b6001600160501b0382811682821603908082111561081757610817612aed565b61ffff81811683821601908082111561081757610817612aed565b600061ffff80841680612e9557612e95612b46565b92169190910692915050565b8051600681900b8114612c5557600080fd5b60008060008060808587031215612ec957600080fd5b8451612ed481612a85565b9350612ee260208601612ea1565b92506040850151612ef281612a0a565b60608601519092506129ff816129b2565b63ffffffff82811682821603908082111561081757610817612aed565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252825182820181905260009190848201906040850190845b81811015612f8a57835163ffffffff1683529284019291840191600101612f68565b50909695505050505050565b604051601f8201601f191681016001600160401b0381118282101715612fbe57612fbe612f20565b604052919050565b60006001600160401b03821115612fdf57612fdf612f20565b5060051b60200190565b600082601f830112612ffa57600080fd5b8151602061300f61300a83612fc6565b612f96565b82815260059290921b8401810191818101908684111561302e57600080fd5b8286015b8481101561305257805161304581612a0a565b8352918301918301613032565b509695505050505050565b6000806040838503121561307057600080fd5b82516001600160401b038082111561308757600080fd5b818501915085601f83011261309b57600080fd5b815160206130ab61300a83612fc6565b82815260059290921b840181019181810190898411156130ca57600080fd5b948201945b838610156130ef576130e086612ea1565b825294820194908201906130cf565b9188015191965090935050508082111561310857600080fd5b5061311585828601612fe9565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715610fb857610fb8612aed565b6001600160a01b0382811682821603908082111561081757610817612aed565b60008160060b8360060b8061318357613183612b46565b667fffffffffffff198214600019821416156131a1576131a1612aed565b90059392505050565b60008260060b806131bd576131bd612b46565b808360060b0791505092915050565b60008160020b627fffff1981036131e5576131e5612aed565b6000190192915050565b6001600160c01b0382811682821681810283169291811582850482141761321857613218612aed565b50505092915050565b60006001600160c01b038381168061323b5761323b612b46565b92169190910492915050565b6000600160ff1b820161325c5761325c612aed565b5060000390565b60008160020b627fffff19810361327c5761327c612aed565b60000392915050565b60008261329457613294612b46565b50069056fea2646970667358221220e0159516d482f2e59df7d32fa0d866f09818f35baa58269e0a78661ff1bb5cdb64736f6c63430008150033

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

0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b0000000000000000000000001e7460c8527282fd15b4bc7bbc451cd20d95b14e00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

-----Decoded View---------------
Arg [0] : _uniFactoryAddress (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
Arg [1] : _titanX (address): 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : _positionController (address): 0xad29b3738EA37F1EB8a8F6745aEef51399fCE57B
Arg [4] : _collateralController (address): 0x1E7460c8527282fd15b4bC7bBC451Cd20d95b14E
Arg [5] : _priceAggregatorAddresses (address[]): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Arg [1] : 000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 000000000000000000000000ad29b3738ea37f1eb8a8f6745aeef51399fce57b
Arg [4] : 0000000000000000000000001e7460c8527282fd15b4bc7bbc451cd20d95b14e
Arg [5] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [7] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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