creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/oracle/OracleModule.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// Oracle core\nimport {ChainlinkAdapter} from \"./Adapters/ChainlinkAdapter.sol\";\nimport {UniswapAdapter} from \"./Adapters/UniswapAdapter.sol\";\nimport {AssetInfo} from \"../core/Structs.sol\";\n\n// Utils\nimport {Ownable} from \"../utils/Ownable.sol\";\nimport {PercentageMath} from \"../utils/PercentageMath.sol\";\n\n// Interfaces\nimport {AggregatorInterface} from \"./Adapters/ChainlinkAdapter.sol\";\n\n///@title OracleModule contract\n///@notice Handle oracle logic, fetch price from chainlink and uniswap v3 TWAP, implement circuit\n/// breaker\n///        in case of oracle failure the contract will revert.\ncontract OracleModule is ChainlinkAdapter, UniswapAdapter, Ownable {\n  struct OracleData {\n    uint256 clPrice;\n    uint256 clTimestamp;\n    uint256 quoteTokenUsdPrice;\n    uint256 uniPrice;\n  }\n\n  /*//////////////////////////////////////////////////////////////\n                                STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice ETH address for chainlink price feed\n  address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n  ///@notice WBTC address\n  address constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;\n\n  ///@notice WETH address for Uniswap\n  address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n  ///@notice Period for checking if chainlink data is stale\n  ///@dev At init set at 25 hours, most of the chainlink feed have an heartbeat of 24h\n  uint256 public stalePeriod;\n\n  ///@notice twapPeriods for uniswap v3 to be compared\n  uint32 public twapPeriodLong;\n  uint32 public twapPeriodShort;\n\n  ///@notice Threshold of deviation for oracle price\n  uint256 public deviationThreshold;\n\n  ///@notice In case of wrong oracle data we return a manual gwei price\n  uint256 public manualGweiPrice;\n\n  ///@notice By default USD pricing, but can be set to ETH pricing --> Allow some assets with no USD\n  /// pair on chainlink\n  mapping(address => bool) public useChainlinkEthPair;\n\n  constructor(address _feedRegistry, address _gasFeed) Ownable(msg.sender) {\n    // mainnet 0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf\n    setChainlinkFeedRegistry(_feedRegistry);\n    // mainnet 0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C\n    setGasFeedAddress(_gasFeed);\n    setDeviationThreshold(500); // 5%\n    setTwapPeriodLong(1800);\n    setTwapPeriodShort(60);\n    setStalePeriod(90_000); //25hours\n    setManualGweiPrice(50e9);\n  }\n  /*//////////////////////////////////////////////////////////////\n                                 ADMIN\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice Set the address of the chainlink registry\n  ///@param feedRegistry Address of the chainlink registry\n  ///@dev Address 0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf\n  function setChainlinkFeedRegistry(address feedRegistry) public onlyOwner {\n    clRegistry = feedRegistry;\n  }\n\n  ///@notice Set the address of the gas feed\n  ///@param _gasFeed Address of the gas feed\n  ///@dev Address 0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C\n  function setGasFeedAddress(address _gasFeed) public onlyOwner {\n    gasFeed = AggregatorInterface(_gasFeed);\n  }\n\n  ///@notice Set the long TWAP window for querying Uniswap price\n  ///@param _twapPeriodLong TWAP period in seconds\n  function setTwapPeriodLong(uint32 _twapPeriodLong) public onlyOwner {\n    twapPeriodLong = _twapPeriodLong;\n  }\n\n  ///@notice Set the short TWAP window for querying Uniswap price\n  ///@param _twapPeriodShort TWAP period in seconds\n  function setTwapPeriodShort(uint32 _twapPeriodShort) public onlyOwner {\n    twapPeriodShort = _twapPeriodShort;\n  }\n\n  ///@notice Set the stale period\n  ///@param _stalePeriod Stale period in seconds\n  function setStalePeriod(uint256 _stalePeriod) public onlyOwner {\n    stalePeriod = _stalePeriod;\n  }\n\n  ///@notice Set the deviation threshold\n  ///@param _deviationThreshold Deviation threshold in percentage (500 -> 5%)\n  function setDeviationThreshold(uint256 _deviationThreshold) public onlyOwner {\n    deviationThreshold = _deviationThreshold;\n  }\n\n  ///@notice Set the manual gwei price\n  ///@param _gweiPrice Gwei price\n  ///@dev In case of gas feed failure we return this gwei price\n  function setManualGweiPrice(uint256 _gweiPrice) public onlyOwner {\n    manualGweiPrice = _gweiPrice;\n  }\n\n  ///@notice Set the useChainlinkEthPair mapping\n  ///@param asset Address of the asset\n  ///@dev By default if not set use USD pair in chainlink\n  function setUseChainlinkEthPair(address asset, bool _useChainlinkEthPair) external onlyOwner {\n    useChainlinkEthPair[asset] = _useChainlinkEthPair;\n  }\n\n  /*//////////////////////////////////////////////////////////////\n                                 EXTERNAL\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice Get the price of an asset in USD\n  ///@param assetAddress Address of the asset to fetch price\n  ///@param assetInfo AssetInfo struct\n  ///@return Price of the asset in USD\n  function getPriceInUSD(address assetAddress, AssetInfo calldata assetInfo)\n    external\n    view\n    returns (uint256)\n  {\n    OracleData memory oracleData;\n\n    // We fetch price from chainlink we cover WBTC / ETH / ERC20 price\n    oracleData = assetAddress == WBTC\n      ? _setWbtcPrice(oracleData, assetAddress)\n      : _setChainlinkPrice(oracleData, assetAddress);\n\n    // We fetch the quoteToken price (i.e USDC/USD price)\n    oracleData = _setQuoteTokenChainlinkPrice(oracleData, assetInfo);\n\n    // If uniswap pool exist we get price from uniswap\n    assetInfo.uniswapPool != address(0)\n      ? _setUniswapPrice(oracleData, assetAddress, assetInfo)\n      : oracleData;\n\n    // We convert uniswap price in USD (ASSET/WETH => WETH/USD or ASSET/DAI ==> DAI/USD)\n    oracleData = _convertToUSD(oracleData);\n\n    // We check if price is stale\n    oracleData = _checkForStaleness(oracleData);\n\n    // If both oracle are available we check if they are congruent\n    if (_isChainlinkValid(oracleData) && _isUniswapValid(oracleData)) {\n      // Price deviation we return 0\n      if (!_isInRange(oracleData.clPrice, oracleData.uniPrice)) {\n        return 0;\n      } else {\n        // Return mean price\n        return _mean(oracleData.clPrice, oracleData.uniPrice);\n      }\n      // If only chainlink we use chainlink\n    } else if (_isChainlinkValid(oracleData) && !_isUniswapValid(oracleData)) {\n      return oracleData.clPrice;\n\n      // If only uniswap we use uniswap\n    } else if (!_isChainlinkValid(oracleData) && _isUniswapValid(oracleData)) {\n      return oracleData.uniPrice;\n    } else {\n      // If no correct oracle we return 0\n      return 0;\n    }\n  }\n\n  ///@notice Get gwei price\n  function getGweiPrice() external view returns (uint256) {\n    uint256 gweiPrice = _getGweiPrice();\n    uint256 correctedPrice = gweiPrice != 0 ? gweiPrice : manualGweiPrice;\n    return correctedPrice;\n  }\n\n  /*//////////////////////////////////////////////////////////////\n                                 INTERNAL\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice Write chainlink asset price and timestamp in OracleData\n  ///@param oracleData OracleData struct\n  ///@param asset Address of the asset to fetch price\n  ///@return OracleData struct\n  function _setChainlinkPrice(OracleData memory oracleData, address asset)\n    internal\n    view\n    returns (OracleData memory)\n  {\n    address clQuoteToken = useChainlinkEthPair[asset] == false ? USD : ETH;\n    (uint256 price, uint256 timestamp) =\n      asset == WETH ? _getChainlinkPrice(ETH, USD) : _getChainlinkPrice(asset, clQuoteToken);\n\n    if (clQuoteToken == ETH) {\n      (uint256 ethPrice,) = _getChainlinkPrice(ETH, USD);\n      price = price * ethPrice / 1e18;\n    }\n\n    oracleData.clPrice = price;\n    oracleData.clTimestamp = timestamp;\n    return oracleData;\n  }\n\n  ///@notice Write chainlink WBTC/USD (via WBTC/BTC => BTC/USD) pair price and timestamp in\n  /// OracleData\n  ///@param oracleData OracleData struct\n  ///@param wbtcAddress wbtc address\n  ///@return OracleData object\n  function _setWbtcPrice(OracleData memory oracleData, address wbtcAddress)\n    internal\n    view\n    returns (OracleData memory)\n  {\n    (uint256 wtbcPair, uint256 wTimestamp) = _getChainlink_wBtcPairPrice(wbtcAddress);\n    (uint256 btcusd, uint256 bTimestamp) = _getChainlinkPrice(BTC, USD);\n    oracleData.clPrice = wtbcPair * btcusd / 1e18;\n    oracleData.clTimestamp = wTimestamp;\n    if (_isStale(wTimestamp) || _isStale(bTimestamp)) {\n      oracleData.clPrice = 0;\n      oracleData.clTimestamp = 0;\n    }\n    return oracleData;\n  }\n\n  ///@notice Write quoteTokenPrice from chainlink (get USDC/USD; DAI/USD; USDT/USD)\n  ///@return OracleData object\n  function _setQuoteTokenChainlinkPrice(OracleData memory oracleData, AssetInfo calldata assetInfo)\n    internal\n    view\n    returns (OracleData memory)\n  {\n    (uint256 price, uint256 quoteTimestamp) = assetInfo.uniswapQuoteToken == WETH\n      ? _getChainlinkPrice(ETH, USD)\n      : _getChainlinkPrice(assetInfo.uniswapQuoteToken, USD);\n    oracleData.quoteTokenUsdPrice = _isStale(quoteTimestamp) ? 0 : price;\n    return oracleData;\n  }\n\n  ///@notice Write uniswap price and timestamp in OracleData\n  function _setUniswapPrice(\n    OracleData memory oracleData,\n    address asset,\n    AssetInfo calldata assetInfo\n  ) internal view returns (OracleData memory) {\n    // compare long and short TWAP, return 0 if deviationThreshold exceeded\n    uint256 priceShortTwap = _getUniswapPrice(asset, assetInfo, twapPeriodShort);\n    uint256 priceLongTwap = _getUniswapPrice(asset, assetInfo, twapPeriodLong);\n\n    if (_isInRange(priceShortTwap, priceLongTwap)) oracleData.uniPrice = priceLongTwap;\n    else oracleData.uniPrice = 0;\n    return oracleData;\n  }\n\n  ///@notice Convert ASSET/WETH pair price in ASSET/USD\n  ///@param oracleData OracleData struct\n  ///@return OracleData object\n  function _convertToUSD(OracleData memory oracleData) internal pure returns (OracleData memory) {\n    oracleData.uniPrice = oracleData.uniPrice * oracleData.quoteTokenUsdPrice / 1e18;\n    return oracleData;\n  }\n\n  ///@notice If Chainlink data is stale set data to 0\n  ///@param oracleData OracleData struct\n  ///@return OracleData object\n  function _checkForStaleness(OracleData memory oracleData)\n    internal\n    view\n    returns (OracleData memory)\n  {\n    if (_isStale(oracleData.clTimestamp)) {\n      oracleData.clPrice = 0;\n      oracleData.clTimestamp = 0;\n    }\n    return oracleData;\n  }\n\n  ///@notice Check if chainlink data is stale\n  ///@return Bool\n  function _isStale(uint256 timestamp) internal view returns (bool) {\n    return block.timestamp - timestamp <= stalePeriod ? false : true;\n  }\n\n  ///@notice Check if chainlink is valid\n  ///@param oracleData OracleData struct\n  ///@return Bool\n  function _isChainlinkValid(OracleData memory oracleData) internal view returns (bool) {\n    if (\n      oracleData.clPrice == 0 || oracleData.clTimestamp == 0\n        || oracleData.clTimestamp > block.timestamp\n    ) return false;\n    else return true;\n  }\n\n  ///@notice Check if Uniswap is valid\n  ///@param oracleData OracleData struct\n  ///@return Bool\n  function _isUniswapValid(OracleData memory oracleData) internal pure returns (bool) {\n    return oracleData.uniPrice == 0 ? false : true;\n  }\n\n  ///@notice Check if value are within the range\n  function _isInRange(uint256 priceA, uint256 priceB) internal view returns (bool) {\n    uint256 lowerBound = PercentageMath.percentSub(priceA, deviationThreshold);\n    uint256 upperBound = PercentageMath.percentAdd(priceA, deviationThreshold);\n\n    if (priceB < lowerBound || priceB > upperBound) return false;\n    else return true;\n  }\n\n  function _mean(uint256 priceA, uint256 priceB) internal pure returns (uint256) {\n    return (priceA + priceB) / 2;\n  }\n}\n"
      },
      "contracts/oracle/Adapters/ChainlinkAdapter.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {FeedRegistryInterface} from \"./FeedRegistryInterface.sol\";\n\ninterface Aggregator {\n  function minAnswer() external view returns (int192);\n  function maxAnswer() external view returns (int192);\n}\n\ninterface AggregatorInterface {\n  function aggregator() external view returns (address);\n  function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80);\n}\n\nabstract contract ChainlinkAdapter {\n  ///@notice Address of the Chainlink feed registry\n  address public clRegistry;\n\n  ///@notice Address of the Gas Oracle feed\n  AggregatorInterface public gasFeed;\n\n  ///@notice BTC address for chainlink price feed\n  address constant BTC = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n  ///@notice Denominations used to query price in USD\n  address public constant USD = address(840);\n\n  ///@notice Query the chainlink price for a given asset\n  ///@param asset address of the asset to query\n  ///@return Price and Timestamp, return 0 if there is no feed\n  function _getChainlinkPrice(address asset, address clQuoteToken)\n    internal\n    view\n    returns (uint256, uint256)\n  {\n    try FeedRegistryInterface(clRegistry).latestRoundData(asset, clQuoteToken) returns (\n      uint80, int256 clPrice, uint256, uint256 updatedAt, uint80\n    ) {\n      uint256 decimals = FeedRegistryInterface(clRegistry).decimals(asset, clQuoteToken);\n      address aggregator = FeedRegistryInterface(clRegistry).getFeed(asset, clQuoteToken);\n      uint256 price = _chainlinkAnswerIsInRange(aggregator, clPrice)\n        ? uint256(clPrice) * (10 ** (18 - decimals))\n        : 0;\n      return (price, updatedAt);\n    } catch {\n      uint256 price = 0;\n      uint256 timestamp = 0;\n      return (price, timestamp);\n    }\n  }\n\n  function _chainlinkAnswerIsInRange(address aggregator, int256 clPrice)\n    internal\n    view\n    returns (bool)\n  {\n    int192 minAnswer = Aggregator(aggregator).minAnswer();\n    int192 maxAnswer = Aggregator(aggregator).maxAnswer();\n    return clPrice > minAnswer && clPrice < maxAnswer;\n  }\n\n  function _getChainlink_wBtcPairPrice(address wbtc) internal view returns (uint256, uint256) {\n    (, int256 wbtcPairPrice,, uint256 updatedAt,) =\n      FeedRegistryInterface(clRegistry).latestRoundData(wbtc, BTC);\n    uint256 decimals = FeedRegistryInterface(clRegistry).decimals(wbtc, BTC);\n    uint256 adjustedPairPrice = uint256(wbtcPairPrice) * (10 ** (18 - decimals));\n    return (adjustedPairPrice, updatedAt);\n  }\n\n  function _getGweiPrice() internal view returns (uint256) {\n    try gasFeed.latestRoundData() returns (uint80, int256 gweiPrice, uint256, uint256, uint80) {\n      address aggregator = gasFeed.aggregator();\n      int192 minAnswer = Aggregator(aggregator).minAnswer();\n      int192 maxAnswer = Aggregator(aggregator).maxAnswer();\n      bool isInRange = gweiPrice > minAnswer && gweiPrice < maxAnswer;\n      uint256 adjustedGweiPrice = isInRange ? uint256(gweiPrice) : 0;\n      return adjustedGweiPrice;\n    } catch {\n      return 0;\n    }\n  }\n}\n"
      },
      "contracts/utils/PercentageMath.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary PercentageMath {\n  ///\tCONSTANTS ///\n\n  uint256 internal constant PERCENTAGE_FACTOR = 1e4; // 100.00%\n  uint256 internal constant HALF_PERCENTAGE_FACTOR = 0.5e4; // 50.00%\n  uint256 internal constant MAX_UINT256 = 2 ** 256 - 1;\n  uint256 internal constant MAX_UINT256_MINUS_HALF_PERCENTAGE = 2 ** 256 - 1 - 0.5e4;\n\n  /// INTERNAL ///\n\n  ///@notice Check if value are within the range\n  function _isInRange(uint256 valA, uint256 valB, uint256 deviationThreshold)\n    internal\n    pure\n    returns (bool)\n  {\n    uint256 lowerBound = percentSub(valA, deviationThreshold);\n    uint256 upperBound = percentAdd(valA, deviationThreshold);\n    if (valB < lowerBound || valB > upperBound) return false;\n    else return true;\n  }\n\n  /// @notice Executes a percentage addition (x * (1 + p)), rounded up.\n  /// @param x The value to which to add the percentage.\n  /// @param percentage The percentage of the value to add.\n  /// @return y The result of the addition.\n  function percentAdd(uint256 x, uint256 percentage) internal pure returns (uint256 y) {\n    // Must revert if\n    // PERCENTAGE_FACTOR + percentage > type(uint256).max\n    //     or x * (PERCENTAGE_FACTOR + percentage) + HALF_PERCENTAGE_FACTOR > type(uint256).max\n    // <=> percentage > type(uint256).max - PERCENTAGE_FACTOR\n    //     or x > (type(uint256).max - HALF_PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR + percentage)\n    // Note: PERCENTAGE_FACTOR + percentage >= PERCENTAGE_FACTOR > 0\n    assembly {\n      y := add(PERCENTAGE_FACTOR, percentage) // Temporary assignment to save gas.\n\n      if or(\n        gt(percentage, sub(MAX_UINT256, PERCENTAGE_FACTOR)),\n        gt(x, div(MAX_UINT256_MINUS_HALF_PERCENTAGE, y))\n      ) { revert(0, 0) }\n\n      y := div(add(mul(x, y), HALF_PERCENTAGE_FACTOR), PERCENTAGE_FACTOR)\n    }\n  }\n\n  /// @notice Executes a percentage subtraction (x * (1 - p)), rounded up.\n  /// @param x The value to which to subtract the percentage.\n  /// @param percentage The percentage of the value to subtract.\n  /// @return y The result of the subtraction.\n  function percentSub(uint256 x, uint256 percentage) internal pure returns (uint256 y) {\n    // Must revert if\n    // percentage > PERCENTAGE_FACTOR\n    //     or x * (PERCENTAGE_FACTOR - percentage) + HALF_PERCENTAGE_FACTOR > type(uint256).max\n    // <=> percentage > PERCENTAGE_FACTOR\n    //     or ((PERCENTAGE_FACTOR - percentage) > 0 and x > (type(uint256).max -\n    // HALF_PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR - percentage))\n    assembly {\n      y := sub(PERCENTAGE_FACTOR, percentage) // Temporary assignment to save gas.\n\n      if or(\n        gt(percentage, PERCENTAGE_FACTOR), mul(y, gt(x, div(MAX_UINT256_MINUS_HALF_PERCENTAGE, y)))\n      ) { revert(0, 0) }\n\n      y := div(add(mul(x, y), HALF_PERCENTAGE_FACTOR), PERCENTAGE_FACTOR)\n    }\n  }\n}\n"
      },
      "contracts/utils/Ownable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.19;\n\n///@title Ownable contract\n/// @notice Simple 2step owner authorization combining solmate and OZ implementation\nabstract contract Ownable {\n  /*//////////////////////////////////////////////////////////////\n                             STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice Address of the owner\n  address public owner;\n\n  ///@notice Address of the pending owner\n  address public pendingOwner;\n\n  /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n  event OwnershipTransferred(address indexed user, address indexed newOner);\n  event OwnershipTransferStarted(address indexed user, address indexed newOwner);\n  event OwnershipTransferCanceled(address indexed pendingOwner);\n\n  /*//////////////////////////////////////////////////////////////\n                                 ERROR\n    //////////////////////////////////////////////////////////////*/\n\n  error Unauthorized();\n\n  /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n  constructor(address _owner) {\n    owner = _owner;\n\n    emit OwnershipTransferred(address(0), _owner);\n  }\n\n  /*//////////////////////////////////////////////////////////////\n                             OWNERSHIP LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n  ///@notice Transfer ownership to a new address\n  ///@param newOwner address of the new owner\n  ///@dev newOwner have to acceptOwnership\n  function transferOwnership(address newOwner) external onlyOwner {\n    pendingOwner = newOwner;\n    emit OwnershipTransferStarted(msg.sender, pendingOwner);\n  }\n\n  ///@notice NewOwner accept the ownership, it transfer the ownership to newOwner\n  function acceptOwnership() external {\n    if (msg.sender != pendingOwner) revert Unauthorized();\n    address oldOwner = owner;\n    owner = pendingOwner;\n    delete pendingOwner;\n    emit OwnershipTransferred(oldOwner, owner);\n  }\n\n  ///@notice Cancel the ownership transfer\n  function cancelTransferOwnership() external onlyOwner {\n    emit OwnershipTransferCanceled(pendingOwner);\n    delete pendingOwner;\n  }\n\n  modifier onlyOwner() {\n    if (msg.sender != owner) revert Unauthorized();\n    _;\n  }\n}\n"
      },
      "contracts/core/Structs.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nstruct AssetInfo {\n  uint72 targetConcentration;\n  address uniswapPool;\n  int72 incentiveFactor;\n  uint8 assetDecimals;\n  uint8 quoteTokenDecimals;\n  address uniswapQuoteToken;\n  bool isSupported;\n}\n\nstruct ProtocolData {\n  ///@notice Protocol AUM in USD\n  uint256 aum;\n  ///@notice multiplicator for the tax equation, 100% = 100e18\n  uint72 taxFactor;\n  ///@notice Max deviation allowed between AUM from keeper and registry\n  uint16 maxAumDeviationAllowed; // Default val 200 == 2 %\n  ///@notice block number where AUM was last updated\n  uint48 lastAUMUpdateBlock;\n  ///@notice annual fee on AUM, in % per year 100% = 100e18\n  uint72 managementFee;\n  ///@notice last block.timestamp when fee was collected\n  uint48 lastFeeCollectionTime;\n}\n\nstruct UserRequest {\n  address asset;\n  uint256 amount;\n}\n\nstruct RequestData {\n  uint32 id;\n  address requestor;\n  address[] assetIn;\n  uint256[] amountIn;\n  address[] assetOut;\n  uint256[] amountOut;\n  bool keepGovRights;\n  uint256 slippageChecker;\n}\n\nstruct RequestQ {\n  uint64 start;\n  uint64 end;\n  mapping(uint64 => RequestData) requestData;\n}\n\nstruct ProcessParam {\n  uint256 targetConc;\n  uint256 currentConc;\n  uint256 usdValue;\n  uint256 taxableAmount;\n  uint256 taxInUSD;\n  uint256 sharesBeforeTax;\n  uint256 sharesAfterTax;\n}\n\nstruct RebalanceParam {\n  address asset;\n  uint256 assetTotalAmount;\n  uint256 assetProxyAmount;\n  uint256 assetPrice;\n  uint256 sTrsyTotalSupply;\n  uint256 trsyPrice;\n}\n"
      },
      "contracts/oracle/Adapters/UniswapAdapter.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {AssetInfo} from \"../../core/Structs.sol\";\nimport {OracleLibrary} from \"../../lib/v3-periphery/contracts/libraries/OracleLibrary.sol\";\nimport {IUniswapV3Pool} from \"../../lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\nimport \"../../lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast.sol\";\nimport \"../../lib/synthetix-v3/utils/core-contracts/contracts/utils/DecimalMath.sol\";\n\nabstract contract UniswapAdapter {\n  using SafeCastU256 for uint256;\n  using SafeCastU160 for uint160;\n  using SafeCastU56 for uint56;\n  using SafeCastU32 for uint32;\n  using SafeCastI56 for int56;\n  using SafeCastI256 for int256;\n  using DecimalMath for int256;\n\n  function _getUniswapPrice(address asset, AssetInfo calldata assetInfo, uint32 twapPeriod)\n    internal\n    view\n    returns (uint256)\n  {\n    uint256 baseAmount = 10 ** assetInfo.assetDecimals;\n    uint256 factor = (18 - assetInfo.quoteTokenDecimals); // 18 decimals\n    uint256 finalPrice;\n\n    uint32[] memory secondsAgos = new uint32[](2);\n    secondsAgos[0] = twapPeriod;\n    secondsAgos[1] = 0;\n\n    try IUniswapV3Pool(assetInfo.uniswapPool).observe(secondsAgos) returns (\n      int56[] memory tickCumulatives, uint160[] memory\n    ) {\n      int24 tick = _computeTick(tickCumulatives, twapPeriod);\n\n      int256 price = OracleLibrary.getQuoteAtTick(\n        tick, baseAmount.to128(), asset, assetInfo.uniswapQuoteToken\n      ).toInt();\n\n      finalPrice = factor > 0\n        ? price.upscale(factor).toUint()\n        : price.downscale((-factor.toInt()).toUint()).toUint();\n      return finalPrice;\n    } catch {\n      return finalPrice;\n    }\n  }\n\n  function _computeTick(int56[] memory tickCumulatives, uint32 twapPeriod)\n    internal\n    pure\n    returns (int24)\n  {\n    int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\n\n    int24 tick = (tickCumulativesDelta / twapPeriod.to56().toInt()).to24();\n\n    if (tickCumulativesDelta < 0 && (tickCumulativesDelta % twapPeriod.to256().toInt() != 0)) {\n      tick--;\n    }\n    return tick;\n  }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/DecimalMath.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\nimport \"./SafeCast.sol\";\n\n/**\n * @title Utility library used to represent \"decimals\" (fixed point numbers) with integers, with two different levels of precision.\n *\n * They are represented by N * UNIT, where UNIT is the number of decimals of precision in the representation.\n *\n * Examples:\n * 1) Given UNIT = 100\n * then if A = 50, A represents the decimal 0.50\n * 2) Given UNIT = 1000000000000000000\n * then if A = 500000000000000000, A represents the decimal 0.500000000000000000\n *\n * Note: An accompanying naming convention of the postfix \"D<Precision>\" is helpful with this utility. I.e. if a variable \"myValue\" represents a low resolution decimal, it should be named \"myValueD18\", and if it was a high resolution decimal \"myValueD27\". While scaling, intermediate precision decimals like \"myValue45\" could arise. Non-decimals should have no postfix, i.e. just \"myValue\".\n *\n * Important: Multiplication and division operations are currently not supported for high precision decimals. Using these operations on them will yield incorrect results and fail silently.\n */\nlibrary DecimalMath {\n    using SafeCastU256 for uint256;\n    using SafeCastI256 for int256;\n\n    // solhint-disable numcast/safe-cast\n\n    // Numbers representing 1.0 (low precision).\n    uint256 public constant UNIT = 1e18;\n    int256 public constant UNIT_INT = int256(UNIT);\n    uint128 public constant UNIT_UINT128 = uint128(UNIT);\n    int128 public constant UNIT_INT128 = int128(UNIT_INT);\n\n    // Numbers representing 1.0 (high precision).\n    uint256 public constant UNIT_PRECISE = 1e27;\n    int256 public constant UNIT_PRECISE_INT = int256(UNIT_PRECISE);\n    int128 public constant UNIT_PRECISE_INT128 = int128(UNIT_PRECISE_INT);\n\n    // Precision scaling, (used to scale down/up from one precision to the other).\n    uint256 public constant PRECISION_FACTOR = 9; // 27 - 18 = 9 :)\n\n    // solhint-enable numcast/safe-cast\n\n    // -----------------\n    // uint256\n    // -----------------\n\n    /**\n     * @dev Multiplies two low precision decimals.\n     *\n     * Since the two numbers are assumed to be fixed point numbers,\n     * (x * UNIT) * (y * UNIT) = x * y * UNIT ^ 2,\n     * the result is divided by UNIT to remove double scaling.\n     */\n    function mulDecimal(uint256 x, uint256 y) internal pure returns (uint256 z) {\n        return (x * y) / UNIT;\n    }\n\n    /**\n     * @dev Divides two low precision decimals.\n     *\n     * Since the two numbers are assumed to be fixed point numbers,\n     * (x * UNIT) / (y * UNIT) = x / y (Decimal representation is lost),\n     * x is first scaled up to end up with a decimal representation.\n     */\n    function divDecimal(uint256 x, uint256 y) internal pure returns (uint256 z) {\n        return (x * UNIT) / y;\n    }\n\n    /**\n     * @dev Scales up a value.\n     *\n     * E.g. if value is not a decimal, a scale up by 18 makes it a low precision decimal.\n     * If value is a low precision decimal, a scale up by 9 makes it a high precision decimal.\n     */\n    function upscale(uint x, uint factor) internal pure returns (uint) {\n        return x * 10 ** factor;\n    }\n\n    /**\n     * @dev Scales down a value.\n     *\n     * E.g. if value is a high precision decimal, a scale down by 9 makes it a low precision decimal.\n     * If value is a low precision decimal, a scale down by 9 makes it a regular integer.\n     *\n     * Scaling down a regular integer would not make sense.\n     */\n    function downscale(uint x, uint factor) internal pure returns (uint) {\n        return x / 10 ** factor;\n    }\n\n    // -----------------\n    // uint128\n    // -----------------\n\n    // Note: Overloading doesn't seem to work for similar types, i.e. int256 and int128, uint256 and uint128, etc, so explicitly naming the functions differently here.\n\n    /**\n     * @dev See mulDecimal for uint256.\n     */\n    function mulDecimalUint128(uint128 x, uint128 y) internal pure returns (uint128) {\n        return (x * y) / UNIT_UINT128;\n    }\n\n    /**\n     * @dev See divDecimal for uint256.\n     */\n    function divDecimalUint128(uint128 x, uint128 y) internal pure returns (uint128) {\n        return (x * UNIT_UINT128) / y;\n    }\n\n    /**\n     * @dev See upscale for uint256.\n     */\n    function upscaleUint128(uint128 x, uint factor) internal pure returns (uint128) {\n        return x * (10 ** factor).to128();\n    }\n\n    /**\n     * @dev See downscale for uint256.\n     */\n    function downscaleUint128(uint128 x, uint factor) internal pure returns (uint128) {\n        return x / (10 ** factor).to128();\n    }\n\n    // -----------------\n    // int256\n    // -----------------\n\n    /**\n     * @dev See mulDecimal for uint256.\n     */\n    function mulDecimal(int256 x, int256 y) internal pure returns (int256) {\n        return (x * y) / UNIT_INT;\n    }\n\n    /**\n     * @dev See divDecimal for uint256.\n     */\n    function divDecimal(int256 x, int256 y) internal pure returns (int256) {\n        return (x * UNIT_INT) / y;\n    }\n\n    /**\n     * @dev See upscale for uint256.\n     */\n    function upscale(int x, uint factor) internal pure returns (int) {\n        return x * (10 ** factor).toInt();\n    }\n\n    /**\n     * @dev See downscale for uint256.\n     */\n    function downscale(int x, uint factor) internal pure returns (int) {\n        return x / (10 ** factor).toInt();\n    }\n\n    // -----------------\n    // int128\n    // -----------------\n\n    /**\n     * @dev See mulDecimal for uint256.\n     */\n    function mulDecimalInt128(int128 x, int128 y) internal pure returns (int128) {\n        return (x * y) / UNIT_INT128;\n    }\n\n    /**\n     * @dev See divDecimal for uint256.\n     */\n    function divDecimalInt128(int128 x, int128 y) internal pure returns (int128) {\n        return (x * UNIT_INT128) / y;\n    }\n\n    /**\n     * @dev See upscale for uint256.\n     */\n    function upscaleInt128(int128 x, uint factor) internal pure returns (int128) {\n        return x * ((10 ** factor).toInt()).to128();\n    }\n\n    /**\n     * @dev See downscale for uint256.\n     */\n    function downscaleInt128(int128 x, uint factor) internal pure returns (int128) {\n        return x / ((10 ** factor).toInt().to128());\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * Utilities that convert numeric types avoiding silent overflows.\n */\nimport \"./SafeCast/SafeCastU32.sol\";\nimport \"./SafeCast/SafeCastI32.sol\";\nimport \"./SafeCast/SafeCastI24.sol\";\nimport \"./SafeCast/SafeCastU56.sol\";\nimport \"./SafeCast/SafeCastI56.sol\";\nimport \"./SafeCast/SafeCastU64.sol\";\nimport \"./SafeCast/SafeCastI128.sol\";\nimport \"./SafeCast/SafeCastI256.sol\";\nimport \"./SafeCast/SafeCastU128.sol\";\nimport \"./SafeCast/SafeCastU160.sol\";\nimport \"./SafeCast/SafeCastU256.sol\";\nimport \"./SafeCast/SafeCastAddress.sol\";\nimport \"./SafeCast/SafeCastBytes32.sol\";\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';\nimport {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';\nimport {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';\nimport {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';\nimport {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';\nimport {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';\nimport {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol';\n\n/// @title The interface for a Uniswap V3 Pool\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\n/// to the ERC20 specification\n/// @dev The pool interface is broken up into many smaller pieces\ninterface IUniswapV3Pool is\n    IUniswapV3PoolImmutables,\n    IUniswapV3PoolState,\n    IUniswapV3PoolDerivedState,\n    IUniswapV3PoolActions,\n    IUniswapV3PoolOwnerActions,\n    IUniswapV3PoolErrors,\n    IUniswapV3PoolEvents\n{\n\n}\n"
      },
      "contracts/lib/v3-periphery/contracts/libraries/OracleLibrary.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0 <0.9.0;\n\nimport '../../../v3-core/contracts/libraries/FullMath.sol';\nimport '../../../v3-core/contracts/libraries/TickMath.sol';\nimport '../../../v3-core/contracts/interfaces/IUniswapV3Pool.sol';\n\n/// @title Oracle library\n/// @notice Provides functions to integrate with V3 pool oracle\nlibrary OracleLibrary {\n    /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool\n    /// @param pool Address of the pool that we want to observe\n    /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means\n    /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp\n    /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp\n    function consult(address pool, uint32 secondsAgo)\n        internal\n        view\n        returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)\n    {\n        require(secondsAgo != 0, 'BP');\n\n        uint32[] memory secondsAgos = new uint32[](2);\n        secondsAgos[0] = secondsAgo;\n        secondsAgos[1] = 0;\n\n        (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) = IUniswapV3Pool(pool)\n            .observe(secondsAgos);\n\n        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\n        uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[1] -\n            secondsPerLiquidityCumulativeX128s[0];\n\n        arithmeticMeanTick = int24(tickCumulativesDelta / int56(uint56(secondsAgo)));\n        // Always round to negative infinity\n        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int56(uint56(secondsAgo)) != 0)) arithmeticMeanTick--;\n\n        // We are multiplying here instead of shifting to ensure that harmonicMeanLiquidity doesn't overflow uint128\n        uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;\n        harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));\n    }\n\n    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange\n    /// @param tick Tick value used to calculate the quote\n    /// @param baseAmount Amount of token to be converted\n    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination\n    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination\n    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken\n    function getQuoteAtTick(\n        int24 tick,\n        uint128 baseAmount,\n        address baseToken,\n        address quoteToken\n    ) internal pure returns (uint256 quoteAmount) {\n        uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);\n\n        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself\n        if (sqrtRatioX96 <= type(uint128).max) {\n            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;\n            quoteAmount = baseToken < quoteToken\n                ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)\n                : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);\n        } else {\n            uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);\n            quoteAmount = baseToken < quoteToken\n                ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)\n                : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);\n        }\n    }\n\n    /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation\n    /// @param pool Address of Uniswap V3 pool that we want to observe\n    /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool\n    function getOldestObservationSecondsAgo(address pool) internal view returns (uint32 secondsAgo) {\n        (, , uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();\n        require(observationCardinality > 0, 'NI');\n\n        (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(pool).observations(\n            (observationIndex + 1) % observationCardinality\n        );\n\n        // The next index might not be initialized if the cardinality is in the process of increasing\n        // In this case the oldest observation is always in index 0\n        if (!initialized) {\n            (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);\n        }\n\n        unchecked {\n            secondsAgo = uint32(block.timestamp) - observationTimestamp;\n        }\n    }\n\n    /// @notice Given a pool, it returns the tick value as of the start of the current block\n    /// @param pool Address of Uniswap V3 pool\n    /// @return The tick that the pool was in at the start of the current block\n    function getBlockStartingTickAndLiquidity(address pool) internal view returns (int24, uint128) {\n        (, int24 tick, uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();\n\n        // 2 observations are needed to reliably calculate the block starting tick\n        require(observationCardinality > 1, 'NEO');\n\n        // If the latest observation occurred in the past, then no tick-changing trades have happened in this block\n        // therefore the tick in `slot0` is the same as at the beginning of the current block.\n        // We don't need to check if this observation is initialized - it is guaranteed to be.\n        (\n            uint32 observationTimestamp,\n            int56 tickCumulative,\n            uint160 secondsPerLiquidityCumulativeX128,\n\n        ) = IUniswapV3Pool(pool).observations(observationIndex);\n        if (observationTimestamp != uint32(block.timestamp)) {\n            return (tick, IUniswapV3Pool(pool).liquidity());\n        }\n\n        uint256 prevIndex = (uint256(observationIndex) + observationCardinality - 1) % observationCardinality;\n        (\n            uint32 prevObservationTimestamp,\n            int56 prevTickCumulative,\n            uint160 prevSecondsPerLiquidityCumulativeX128,\n            bool prevInitialized\n        ) = IUniswapV3Pool(pool).observations(prevIndex);\n\n        require(prevInitialized, 'ONI');\n\n        uint32 delta = observationTimestamp - prevObservationTimestamp;\n        tick = int24((tickCumulative - int56(uint56(prevTickCumulative))) / int56(uint56(delta)));\n        uint128 liquidity = uint128(\n            (uint192(delta) * type(uint160).max) /\n                (uint192(secondsPerLiquidityCumulativeX128 - prevSecondsPerLiquidityCumulativeX128) << 32)\n        );\n        return (tick, liquidity);\n    }\n\n    /// @notice Information for calculating a weighted arithmetic mean tick\n    struct WeightedTickData {\n        int24 tick;\n        uint128 weight;\n    }\n\n    /// @notice Given an array of ticks and weights, calculates the weighted arithmetic mean tick\n    /// @param weightedTickData An array of ticks and weights\n    /// @return weightedArithmeticMeanTick The weighted arithmetic mean tick\n    /// @dev Each entry of `weightedTickData` should represents ticks from pools with the same underlying pool tokens. If they do not,\n    /// extreme care must be taken to ensure that ticks are comparable (including decimal differences).\n    /// @dev Note that the weighted arithmetic mean tick corresponds to the weighted geometric mean price.\n    function getWeightedArithmeticMeanTick(WeightedTickData[] memory weightedTickData)\n        internal\n        pure\n        returns (int24 weightedArithmeticMeanTick)\n    {\n        // Accumulates the sum of products between each tick and its weight\n        int256 numerator;\n\n        // Accumulates the sum of the weights\n        uint256 denominator;\n\n        // Products fit in 152 bits, so it would take an array of length ~2**104 to overflow this logic\n        for (uint256 i; i < weightedTickData.length; i++) {\n            numerator += weightedTickData[i].tick * int256(uint256(weightedTickData[i].weight));\n            denominator += weightedTickData[i].weight;\n        }\n\n        weightedArithmeticMeanTick = int24(numerator / int256(denominator));\n        // Always round to negative infinity\n        if (numerator < 0 && (numerator % int256(denominator) != 0)) weightedArithmeticMeanTick--;\n    }\n\n    /// @notice Returns the \"synthetic\" tick which represents the price of the first entry in `tokens` in terms of the last\n    /// @dev Useful for calculating relative prices along routes.\n    /// @dev There must be one tick for each pairwise set of tokens.\n    /// @param tokens The token contract addresses\n    /// @param ticks The ticks, representing the price of each token pair in `tokens`\n    /// @return syntheticTick The synthetic tick, representing the relative price of the outermost tokens in `tokens`\n    function getChainedPrice(address[] memory tokens, int24[] memory ticks)\n        internal\n        pure\n        returns (int256 syntheticTick)\n    {\n        require(tokens.length - 1 == ticks.length, 'DL');\n        for (uint256 i = 1; i <= ticks.length; i++) {\n            // check the tokens for address sort order, then accumulate the\n            // ticks into the running synthetic tick, ensuring that intermediate tokens \"cancel out\"\n            tokens[i - 1] < tokens[i] ? syntheticTick += ticks[i - 1] : syntheticTick -= ticks[i - 1];\n        }\n    }\n}\n"
      },
      "contracts/oracle/Adapters/FeedRegistryInterface.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.19;\n\ninterface FeedRegistryInterface {\n  function decimals(address base, address quote) external view returns (uint8);\n\n  function getFeed(address base, address quote) external view returns (address);\n\n  function latestRoundData(address base, address quote)\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n}\n"
      },
      "contracts/lib/v3-core/contracts/libraries/TickMath.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n    error T();\n    error R();\n\n    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n    int24 internal constant MIN_TICK = -887272;\n    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n    int24 internal constant MAX_TICK = -MIN_TICK;\n\n    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n    uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n    /// @notice Calculates sqrt(1.0001^tick) * 2^96\n    /// @dev Throws if |tick| > max tick\n    /// @param tick The input tick for the above formula\n    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n    /// at the given tick\n    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n        unchecked {\n            uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n            if (absTick > uint256(int256(MAX_TICK))) revert T();\n\n            uint256 ratio = absTick & 0x1 != 0\n                ? 0xfffcb933bd6fad37aa2d162d1a594001\n                : 0x100000000000000000000000000000000;\n            if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n            if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n            if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n            if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n            if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n            if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n            if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n            if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n            if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n            if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n            if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n            if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n            if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n            if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n            if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n            if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n            if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n            if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n            if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n            if (tick > 0) ratio = type(uint256).max / ratio;\n\n            // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n            // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n            // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n            sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n        }\n    }\n\n    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n    /// ever return.\n    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n        unchecked {\n            // second inequality must be < because the price can never reach the price at the max tick\n            if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();\n            uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n            uint256 r = ratio;\n            uint256 msb = 0;\n\n            assembly {\n                let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(5, gt(r, 0xFFFFFFFF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(4, gt(r, 0xFFFF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(3, gt(r, 0xFF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(2, gt(r, 0xF))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := shl(1, gt(r, 0x3))\n                msb := or(msb, f)\n                r := shr(f, r)\n            }\n            assembly {\n                let f := gt(r, 0x1)\n                msb := or(msb, f)\n            }\n\n            if (msb >= 128) r = ratio >> (msb - 127);\n            else r = ratio << (127 - msb);\n\n            int256 log_2 = (int256(msb) - 128) << 64;\n\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(63, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(62, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(61, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(60, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(59, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(58, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(57, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(56, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(55, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(54, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(53, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(52, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(51, f))\n                r := shr(f, r)\n            }\n            assembly {\n                r := shr(127, mul(r, r))\n                let f := shr(128, r)\n                log_2 := or(log_2, shl(50, f))\n            }\n\n            int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n            int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n            int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n            tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n        }\n    }\n}\n"
      },
      "contracts/lib/v3-core/contracts/libraries/FullMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n    function mulDiv(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = a * b\n            // Compute the product mod 2**256 and mod 2**256 - 1\n            // then use the Chinese Remainder Theorem to reconstruct\n            // the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2**256 + prod0\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(a, b, not(0))\n                prod0 := mul(a, b)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division\n            if (prod1 == 0) {\n                require(denominator > 0);\n                assembly {\n                    result := div(prod0, denominator)\n                }\n                return result;\n            }\n\n            // Make sure the result is less than 2**256.\n            // Also prevents denominator == 0\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0]\n            // Compute remainder using mulmod\n            uint256 remainder;\n            assembly {\n                remainder := mulmod(a, b, denominator)\n            }\n            // Subtract 256 bit number from 512 bit number\n            assembly {\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator\n            // Compute largest power of two divisor of denominator.\n            // Always >= 1.\n            uint256 twos = (0 - denominator) & denominator;\n            // Divide denominator by power of two\n            assembly {\n                denominator := div(denominator, twos)\n            }\n\n            // Divide [prod1 prod0] by the factors of two\n            assembly {\n                prod0 := div(prod0, twos)\n            }\n            // Shift in bits from prod1 into prod0. For this we need\n            // to flip `twos` such that it is 2**256 / twos.\n            // If twos is zero, then it becomes one\n            assembly {\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2**256\n            // Now that denominator is an odd number, it has an inverse\n            // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n            // Compute the inverse by starting with a seed that is correct\n            // correct for four bits. That is, denominator * inv = 1 mod 2**4\n            uint256 inv = (3 * denominator) ^ 2;\n            // Now use Newton-Raphson iteration to improve the precision.\n            // Thanks to Hensel's lifting lemma, this also works in modular\n            // arithmetic, doubling the correct bits in each step.\n            inv *= 2 - denominator * inv; // inverse mod 2**8\n            inv *= 2 - denominator * inv; // inverse mod 2**16\n            inv *= 2 - denominator * inv; // inverse mod 2**32\n            inv *= 2 - denominator * inv; // inverse mod 2**64\n            inv *= 2 - denominator * inv; // inverse mod 2**128\n            inv *= 2 - denominator * inv; // inverse mod 2**256\n\n            // Because the division is now exact we can divide by multiplying\n            // with the modular inverse of denominator. This will give us the\n            // correct result modulo 2**256. Since the precoditions guarantee\n            // that the outcome is less than 2**256, this is the final result.\n            // We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inv;\n            return result;\n        }\n    }\n\n    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    function mulDivRoundingUp(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            result = mulDiv(a, b, denominator);\n            if (mulmod(a, b, denominator) > 0) {\n                require(result < type(uint256).max);\n                result++;\n            }\n        }\n    }\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Events emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IUniswapV3PoolEvents {\n    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\n    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\n    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\n    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\n    event Initialize(uint160 sqrtPriceX96, int24 tick);\n\n    /// @notice Emitted when liquidity is minted for a given position\n    /// @param sender The address that minted the liquidity\n    /// @param owner The owner of the position and recipient of any minted liquidity\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity minted to the position range\n    /// @param amount0 How much token0 was required for the minted liquidity\n    /// @param amount1 How much token1 was required for the minted liquidity\n    event Mint(\n        address sender,\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted when fees are collected by the owner of a position\n    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\n    /// @param owner The owner of the position for which fees are collected\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount0 The amount of token0 fees collected\n    /// @param amount1 The amount of token1 fees collected\n    event Collect(\n        address indexed owner,\n        address recipient,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount0,\n        uint128 amount1\n    );\n\n    /// @notice Emitted when a position's liquidity is removed\n    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\n    /// @param owner The owner of the position for which liquidity is removed\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity to remove\n    /// @param amount0 The amount of token0 withdrawn\n    /// @param amount1 The amount of token1 withdrawn\n    event Burn(\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted by the pool for any swaps between token0 and token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the output of the swap\n    /// @param amount0 The delta of the token0 balance of the pool\n    /// @param amount1 The delta of the token1 balance of the pool\n    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\n    /// @param liquidity The liquidity of the pool after the swap\n    /// @param tick The log base 1.0001 of price of the pool after the swap\n    event Swap(\n        address indexed sender,\n        address indexed recipient,\n        int256 amount0,\n        int256 amount1,\n        uint160 sqrtPriceX96,\n        uint128 liquidity,\n        int24 tick\n    );\n\n    /// @notice Emitted by the pool for any flashes of token0/token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the tokens from flash\n    /// @param amount0 The amount of token0 that was flashed\n    /// @param amount1 The amount of token1 that was flashed\n    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\n    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\n    event Flash(\n        address indexed sender,\n        address indexed recipient,\n        uint256 amount0,\n        uint256 amount1,\n        uint256 paid0,\n        uint256 paid1\n    );\n\n    /// @notice Emitted by the pool for increases to the number of observations that can be stored\n    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\n    /// just before a mint/swap/burn.\n    /// @param observationCardinalityNextOld The previous value of the next observation cardinality\n    /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n    event IncreaseObservationCardinalityNext(\n        uint16 observationCardinalityNextOld,\n        uint16 observationCardinalityNextNew\n    );\n\n    /// @notice Emitted when the protocol fee is changed by the pool\n    /// @param feeProtocol0Old The previous value of the token0 protocol fee\n    /// @param feeProtocol1Old The previous value of the token1 protocol fee\n    /// @param feeProtocol0New The updated value of the token0 protocol fee\n    /// @param feeProtocol1New The updated value of the token1 protocol fee\n    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\n\n    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\n    /// @param sender The address that collects the protocol fees\n    /// @param recipient The address that receives the collected protocol fees\n    /// @param amount0 The amount of token0 protocol fees that is withdrawn\n    /// @param amount0 The amount of token1 protocol fees that is withdrawn\n    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolErrors.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Errors emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IUniswapV3PoolErrors {\n    error LOK();\n    error TLU();\n    error TLM();\n    error TUM();\n    error AI();\n    error M0();\n    error M1();\n    error AS();\n    error IIA();\n    error L();\n    error F0();\n    error F1();\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissioned pool actions\n/// @notice Contains pool methods that may only be called by the factory owner\ninterface IUniswapV3PoolOwnerActions {\n    /// @notice Set the denominator of the protocol's % share of the fees\n    /// @param feeProtocol0 new protocol fee for token0 of the pool\n    /// @param feeProtocol1 new protocol fee for token1 of the pool\n    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\n\n    /// @notice Collect the protocol fee accrued to the pool\n    /// @param recipient The address to which collected protocol fees should be sent\n    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\n    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\n    /// @return amount0 The protocol fee collected in token0\n    /// @return amount1 The protocol fee collected in token1\n    function collectProtocol(\n        address recipient,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n    /// @notice Sets the initial price for the pool\n    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n    function initialize(uint160 sqrtPriceX96) external;\n\n    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n    /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n    /// @param recipient The address for which the liquidity will be created\n    /// @param tickLower The lower tick of the position in which to add liquidity\n    /// @param tickUpper The upper tick of the position in which to add liquidity\n    /// @param amount The amount of liquidity to mint\n    /// @param data Any data that should be passed through to the callback\n    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    function mint(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount,\n        bytes calldata data\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Collects tokens owed to a position\n    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n    /// @param recipient The address which should receive the fees collected\n    /// @param tickLower The lower tick of the position for which to collect fees\n    /// @param tickUpper The upper tick of the position for which to collect fees\n    /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n    /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n    /// @return amount0 The amount of fees collected in token0\n    /// @return amount1 The amount of fees collected in token1\n    function collect(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n\n    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n    /// @dev Fees must be collected separately via a call to #collect\n    /// @param tickLower The lower tick of the position for which to burn liquidity\n    /// @param tickUpper The upper tick of the position for which to burn liquidity\n    /// @param amount How much liquidity to burn\n    /// @return amount0 The amount of token0 sent to the recipient\n    /// @return amount1 The amount of token1 sent to the recipient\n    function burn(\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Swap token0 for token1, or token1 for token0\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n    /// @param recipient The address to receive the output of the swap\n    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n    /// @param data Any data to be passed through to the callback\n    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n    function swap(\n        address recipient,\n        bool zeroForOne,\n        int256 amountSpecified,\n        uint160 sqrtPriceLimitX96,\n        bytes calldata data\n    ) external returns (int256 amount0, int256 amount1);\n\n    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n    /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n    /// @param recipient The address which will receive the token0 and token1 amounts\n    /// @param amount0 The amount of token0 to send\n    /// @param amount1 The amount of token1 to send\n    /// @param data Any data to be passed through to the callback\n    function flash(\n        address recipient,\n        uint256 amount0,\n        uint256 amount1,\n        bytes calldata data\n    ) external;\n\n    /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n    /// the input observationCardinalityNext.\n    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that is not stored\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\n/// blockchain. The functions here may have variable gas costs.\ninterface IUniswapV3PoolDerivedState {\n    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\n    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\n    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\n    /// you must call it with secondsAgos = [3600, 0].\n    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\n    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\n    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\n    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\n    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\n    /// timestamp\n    function observe(uint32[] calldata secondsAgos)\n        external\n        view\n        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\n\n    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\n    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\n    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\n    /// snapshot is taken and the second snapshot is taken.\n    /// @param tickLower The lower tick of the range\n    /// @param tickUpper The upper tick of the range\n    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\n    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\n    /// @return secondsInside The snapshot of seconds per liquidity for the range\n    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\n        external\n        view\n        returns (\n            int56 tickCumulativeInside,\n            uint160 secondsPerLiquidityInsideX128,\n            uint32 secondsInside\n        );\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\n/// per transaction\ninterface IUniswapV3PoolState {\n    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\n    /// when accessed externally.\n    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\n    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.\n    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\n    /// boundary.\n    /// @return observationIndex The index of the last oracle observation that was written,\n    /// @return observationCardinality The current maximum number of observations stored in the pool,\n    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.\n    /// @return feeProtocol The protocol fee for both tokens of the pool.\n    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\n    /// 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.\n    /// unlocked Whether the pool is currently locked to reentrancy\n    function slot0()\n        external\n        view\n        returns (\n            uint160 sqrtPriceX96,\n            int24 tick,\n            uint16 observationIndex,\n            uint16 observationCardinality,\n            uint16 observationCardinalityNext,\n            uint8 feeProtocol,\n            bool unlocked\n        );\n\n    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal0X128() external view returns (uint256);\n\n    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal1X128() external view returns (uint256);\n\n    /// @notice The amounts of token0 and token1 that are owed to the protocol\n    /// @dev Protocol fees will never exceed uint128 max in either token\n    function protocolFees() external view returns (uint128 token0, uint128 token1);\n\n    /// @notice The currently in range liquidity available to the pool\n    /// @dev This value has no relationship to the total liquidity across all ticks\n    /// @return The liquidity at the current price of the pool\n    function liquidity() external view returns (uint128);\n\n    /// @notice Look up information about a specific tick in the pool\n    /// @param tick The tick to look up\n    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or\n    /// tick upper\n    /// @return liquidityNet how much liquidity changes when the pool price crosses the tick,\n    /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\n    /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\n    /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\n    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\n    /// @return secondsOutside the seconds spent on the other side of the tick from the current tick,\n    /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\n    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\n    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\n    /// a specific position.\n    function ticks(int24 tick)\n        external\n        view\n        returns (\n            uint128 liquidityGross,\n            int128 liquidityNet,\n            uint256 feeGrowthOutside0X128,\n            uint256 feeGrowthOutside1X128,\n            int56 tickCumulativeOutside,\n            uint160 secondsPerLiquidityOutsideX128,\n            uint32 secondsOutside,\n            bool initialized\n        );\n\n    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\n    function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n    /// @notice Returns the information about a position by the position's key\n    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\n    /// @return liquidity The amount of liquidity in the position,\n    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\n    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\n    /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\n    /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\n    function positions(bytes32 key)\n        external\n        view\n        returns (\n            uint128 liquidity,\n            uint256 feeGrowthInside0LastX128,\n            uint256 feeGrowthInside1LastX128,\n            uint128 tokensOwed0,\n            uint128 tokensOwed1\n        );\n\n    /// @notice Returns data about a specific observation index\n    /// @param index The element of the observations array to fetch\n    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\n    /// ago, rather than at a specific index in the array.\n    /// @return blockTimestamp The timestamp of the observation,\n    /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\n    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,\n    /// @return initialized whether the observation has been initialized and the values are safe to use\n    function observations(uint256 index)\n        external\n        view\n        returns (\n            uint32 blockTimestamp,\n            int56 tickCumulative,\n            uint160 secondsPerLiquidityCumulativeX128,\n            bool initialized\n        );\n}\n"
      },
      "contracts/lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n    /// @return The contract address\n    function factory() external view returns (address);\n\n    /// @notice The first of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token0() external view returns (address);\n\n    /// @notice The second of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token1() external view returns (address);\n\n    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n    /// @return The fee\n    function fee() external view returns (uint24);\n\n    /// @notice The pool tick spacing\n    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n    /// This value is an int24 to avoid casting even though it is always positive.\n    /// @return The tick spacing\n    function tickSpacing() external view returns (int24);\n\n    /// @notice The maximum amount of position liquidity that can use any tick in the range\n    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n    /// @return The max amount of liquidity per tick\n    function maxLiquidityPerTick() external view returns (uint128);\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastBytes32.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastBytes32 {\n    function toAddress(bytes32 x) internal pure returns (address) {\n        return address(uint160(uint256(x)));\n    }\n\n    function toUint(bytes32 x) internal pure returns (uint) {\n        return uint(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastAddress.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastAddress {\n    function toBytes32(address x) internal pure returns (bytes32) {\n        return bytes32(uint256(uint160(x)));\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU256.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU256 {\n    error OverflowUint256ToUint128();\n    error OverflowUint256ToInt256();\n    error OverflowUint256ToUint64();\n    error OverflowUint256ToUint32();\n    error OverflowUint256ToUint160();\n\n    function to128(uint256 x) internal pure returns (uint128) {\n        // -------------------------------o===============================>\n        // -------------------------------o===============>xxxxxxxxxxxxxxxx\n        if (x > type(uint128).max) {\n            revert OverflowUint256ToUint128();\n        }\n\n        return uint128(x);\n    }\n\n    function to64(uint256 x) internal pure returns (uint64) {\n        // -------------------------------o===============================>\n        // -------------------------------o======>xxxxxxxxxxxxxxxxxxxxxxxxx\n        if (x > type(uint64).max) {\n            revert OverflowUint256ToUint64();\n        }\n\n        return uint64(x);\n    }\n\n    function to32(uint256 x) internal pure returns (uint32) {\n        // -------------------------------o===============================>\n        // -------------------------------o===>xxxxxxxxxxxxxxxxxxxxxxxxxxxx\n        if (x > type(uint32).max) {\n            revert OverflowUint256ToUint32();\n        }\n\n        return uint32(x);\n    }\n\n    function to160(uint256 x) internal pure returns (uint160) {\n        // -------------------------------o===============================>\n        // -------------------------------o==================>xxxxxxxxxxxxx\n        if (x > type(uint160).max) {\n            revert OverflowUint256ToUint160();\n        }\n\n        return uint160(x);\n    }\n\n    function toBytes32(uint256 x) internal pure returns (bytes32) {\n        return bytes32(x);\n    }\n\n    function toInt(uint256 x) internal pure returns (int256) {\n        // -------------------------------o===============================>\n        // ----<==========================o===========================>xxxx\n        if (x > uint256(type(int256).max)) {\n            revert OverflowUint256ToInt256();\n        }\n\n        return int256(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU160.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU160 {\n    function to256(uint160 x) internal pure returns (uint256) {\n        return uint256(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU128.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU128 {\n    error OverflowUint128ToInt128();\n\n    function to256(uint128 x) internal pure returns (uint256) {\n        return uint256(x);\n    }\n\n    function toInt(uint128 x) internal pure returns (int128) {\n        // -------------------------------o===============>----------------\n        // ----------------<==============o==============>x----------------\n        if (x > uint128(type(int128).max)) {\n            revert OverflowUint128ToInt128();\n        }\n\n        return int128(x);\n    }\n\n    function toBytes32(uint128 x) internal pure returns (bytes32) {\n        return bytes32(uint256(x));\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastI256.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastI256 {\n    error OverflowInt256ToUint256();\n    error OverflowInt256ToInt128();\n    error OverflowInt256ToInt24();\n\n    function to128(int256 x) internal pure returns (int128) {\n        // ----<==========================o===========================>----\n        // ----xxxxxxxxxxxx<==============o==============>xxxxxxxxxxxxx----\n        if (x < int256(type(int128).min) || x > int256(type(int128).max)) {\n            revert OverflowInt256ToInt128();\n        }\n\n        return int128(x);\n    }\n\n    function to24(int256 x) internal pure returns (int24) {\n        // ----<==========================o===========================>----\n        // ----xxxxxxxxxxxxxxxxxxxx<======o=======>xxxxxxxxxxxxxxxxxxxx----\n        if (x < int256(type(int24).min) || x > int256(type(int24).max)) {\n            revert OverflowInt256ToInt24();\n        }\n\n        return int24(x);\n    }\n\n    function toUint(int256 x) internal pure returns (uint256) {\n        // ----<==========================o===========================>----\n        // ----xxxxxxxxxxxxxxxxxxxxxxxxxxxo===============================>\n        if (x < 0) {\n            revert OverflowInt256ToUint256();\n        }\n\n        return uint256(x);\n    }\n\n    function zero() internal pure returns (int256) {\n        return int256(0);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastI128.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastI128 {\n    error OverflowInt128ToUint128();\n    error OverflowInt128ToInt32();\n\n    function toUint(int128 x) internal pure returns (uint128) {\n        // ----------------<==============o==============>-----------------\n        // ----------------xxxxxxxxxxxxxxxo===============>----------------\n        if (x < 0) {\n            revert OverflowInt128ToUint128();\n        }\n\n        return uint128(x);\n    }\n\n    function to256(int128 x) internal pure returns (int256) {\n        return int256(x);\n    }\n\n    function to32(int128 x) internal pure returns (int32) {\n        // ----------------<==============o==============>-----------------\n        // ----------------xxxxxxxxxxxx<==o==>xxxxxxxxxxxx-----------------\n        if (x < int(type(int32).min) || x > int(type(int32).max)) {\n            revert OverflowInt128ToInt32();\n        }\n\n        return int32(x);\n    }\n\n    function zero() internal pure returns (int128) {\n        return int128(0);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU64.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU64 {\n    error OverflowUint64ToInt64();\n\n    function toInt(uint64 x) internal pure returns (int64) {\n        // -------------------------------o=========>----------------------\n        // ----------------------<========o========>x----------------------\n        if (x > uint64(type(int64).max)) {\n            revert OverflowUint64ToInt64();\n        }\n\n        return int64(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastI56.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastI56 {\n    error OverflowInt56ToInt24();\n\n    function to24(int56 x) internal pure returns (int24) {\n        // ----------------------<========o========>-----------------------\n        // ----------------------xxx<=====o=====>xxx-----------------------\n        if (x < int(type(int24).min) || x > int(type(int24).max)) {\n            revert OverflowInt56ToInt24();\n        }\n\n        return int24(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU56.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU56 {\n    error OverflowUint56ToInt56();\n\n    function toInt(uint56 x) internal pure returns (int56) {\n        // -------------------------------o=========>----------------------\n        // ----------------------<========o========>x----------------------\n        if (x > uint56(type(int56).max)) {\n            revert OverflowUint56ToInt56();\n        }\n\n        return int56(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastI24.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastI24 {\n    function to256(int24 x) internal pure returns (int256) {\n        return int256(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastI32.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastI32 {\n    error OverflowInt32ToUint32();\n\n    function toUint(int32 x) internal pure returns (uint32) {\n        // ----------------------<========o========>----------------------\n        // ----------------------xxxxxxxxxo=========>----------------------\n        if (x < 0) {\n            revert OverflowInt32ToUint32();\n        }\n\n        return uint32(x);\n    }\n}\n"
      },
      "contracts/lib/synthetix-v3/utils/core-contracts/contracts/utils/SafeCast/SafeCastU32.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.11 <0.9.0;\n\n/**\n * @title See SafeCast.sol.\n */\nlibrary SafeCastU32 {\n    error OverflowUint32ToInt32();\n\n    function toInt(uint32 x) internal pure returns (int32) {\n        // -------------------------------o=========>----------------------\n        // ----------------------<========o========>x----------------------\n        if (x > uint32(type(int32).max)) {\n            revert OverflowUint32ToInt32();\n        }\n\n        return int32(x);\n    }\n\n    function to256(uint32 x) internal pure returns (uint256) {\n        return uint256(x);\n    }\n\n    function to56(uint32 x) internal pure returns (uint56) {\n        return uint56(x);\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}