creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@uniswap/v3-core/contracts/libraries/FullMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.0 <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        // 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 = -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    /// @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        result = mulDiv(a, b, denominator);\n        if (mulmod(a, b, denominator) > 0) {\n            require(result < type(uint256).max);\n            result++;\n        }\n    }\n}\n"
      },
      "contracts/price-getters/uniswap-v3/interfaces/AggregatorV3Interface.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function version() external view returns (uint256);\n\n  function getRoundData(\n    uint80 _roundId\n  )\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestRoundData()\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/price-getters/uniswap-v3/interfaces/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\ninterface IERC20Metadata {\n  function decimals() external view returns (uint8);\n}\n"
      },
      "contracts/price-getters/uniswap-v3/interfaces/IPriceGetter.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\ninterface IPriceGetter {\n  function getPrice() external view returns (uint256 price);\n}\n"
      },
      "contracts/price-getters/uniswap-v3/interfaces/IUniswapV3Twap.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\ninterface IUniswapV3Twap {\n  // function token0() external view returns (address);\n  // function token1() external view returns (address);\n  function estimateAmountOut(\n    address tokenIn,\n    uint128 amountIn,\n    uint32 secondsAgo\n  ) external view returns (uint amountOut, uint8 decimalsOut);\n}\n"
      },
      "contracts/price-getters/uniswap-v3/UniswapV3Oracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\nimport {FullMath} from '@uniswap/v3-core/contracts/libraries/FullMath.sol';\nimport {IERC20Metadata} from './interfaces/IERC20Metadata.sol';\nimport {AggregatorV3Interface} from './interfaces/AggregatorV3Interface.sol';\nimport {IUniswapV3Twap} from './interfaces/IUniswapV3Twap.sol';\nimport {IPriceGetter} from './interfaces/IPriceGetter.sol';\n\ncontract UniswapV3Oracle is IPriceGetter {\n  IERC20Metadata public immutable token;\n  IUniswapV3Twap public immutable twap;\n  AggregatorV3Interface public immutable aggregator;\n\n  constructor(address _token, address _twap, address _aggregator) {\n    require(_twap != address(0), '!twap');\n    twap = IUniswapV3Twap(_twap);\n    token = IERC20Metadata(_token);\n    aggregator = AggregatorV3Interface(_aggregator);\n  }\n\n  function getPrice() external view override returns (uint256 price) {\n    (uint amountOut, uint8 decimalsOut) = twap.estimateAmountOut(\n      address(token),\n      uint128(10 ** token.decimals()),\n      120\n    );\n    (, int256 answer, , , ) = aggregator.latestRoundData();\n    price = FullMath.mulDiv(amountOut, uint256(answer), 10 ** decimalsOut);\n  }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "istanbul",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}