creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct 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(x, y, not(0))\n                prod0 := mul(x, y)\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                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "contracts/Constants.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.19;\n\nlibrary Constants {\n    uint256 internal constant YEAR_IN_SECONDS = 365 days;\n    uint256 internal constant BASE = 1e18;\n    uint256 internal constant MAX_FEE_PER_ANNUM = 0.05e18; // 5% max in base\n    uint256 internal constant MAX_SWAP_PROTOCOL_FEE = 0.01e18; // 1% max in base\n    uint256 internal constant MAX_TOTAL_PROTOCOL_FEE = 0.05e18; // 5% max in base\n    uint256 internal constant MAX_P2POOL_PROTOCOL_FEE = 0.05e18; // 5% max in base\n    uint256 internal constant MIN_TIME_BETWEEN_EARLIEST_REPAY_AND_EXPIRY =\n        1 days;\n    uint256 internal constant MAX_PRICE_UPDATE_TIMESTAMP_DIVERGENCE = 1 days;\n    uint256 internal constant SEQUENCER_GRACE_PERIOD = 1 hours;\n    uint256 internal constant MIN_UNSUBSCRIBE_GRACE_PERIOD = 1 days;\n    uint256 internal constant MAX_UNSUBSCRIBE_GRACE_PERIOD = 14 days;\n    uint256 internal constant MIN_CONVERSION_GRACE_PERIOD = 1 days;\n    uint256 internal constant MIN_REPAYMENT_GRACE_PERIOD = 1 days;\n    uint256 internal constant LOAN_EXECUTION_GRACE_PERIOD = 1 days;\n    uint256 internal constant MAX_CONVERSION_AND_REPAYMENT_GRACE_PERIOD =\n        30 days;\n    uint256 internal constant MIN_TIME_UNTIL_FIRST_DUE_DATE = 1 days;\n    uint256 internal constant MIN_TIME_BETWEEN_DUE_DATES = 7 days;\n    uint256 internal constant MIN_WAIT_UNTIL_EARLIEST_UNSUBSCRIBE = 60 seconds;\n    uint256 internal constant MAX_ARRANGER_FEE = 0.5e18; // 50% max in base\n    uint256 internal constant LOAN_TERMS_UPDATE_COOL_OFF_PERIOD = 15 minutes;\n    uint256 internal constant MAX_REPAYMENT_SCHEDULE_LENGTH = 20;\n    uint256 internal constant SINGLE_WRAPPER_MIN_MINT = 1000; // in wei\n}\n"
      },
      "contracts/Errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nlibrary Errors {\n    error UnregisteredVault();\n    error InvalidDelegatee();\n    error InvalidSender();\n    error InvalidFee();\n    error InsufficientSendAmount();\n    error NoOracle();\n    error InvalidOracleAnswer();\n    error InvalidOracleDecimals();\n    error InvalidOracleVersion();\n    error InvalidAddress();\n    error InvalidArrayLength();\n    error InvalidQuote();\n    error OutdatedQuote();\n    error InvalidOffChainSignature();\n    error InvalidOffChainMerkleProof();\n    error InvalidCollUnlock();\n    error InvalidAmount();\n    error UnknownOnChainQuote();\n    error NeitherTokenIsGOHM();\n    error NoLpTokens();\n    error ZeroReserve();\n    error IncorrectGaugeForLpToken();\n    error InvalidGaugeIndex();\n    error AlreadyStaked();\n    error InvalidWithdrawAmount();\n    error InvalidBorrower();\n    error OutsideValidRepayWindow();\n    error InvalidRepayAmount();\n    error ReclaimAmountIsZero();\n    error UnregisteredGateway();\n    error NonWhitelistedOracle();\n    error NonWhitelistedCompartment();\n    error NonWhitelistedCallback();\n    error NonWhitelistedToken();\n    error LtvHigherThanMax();\n    error InsufficientVaultFunds();\n    error InvalidInterestRateFactor();\n    error InconsistentUnlockTokenAddresses();\n    error InvalidEarliestRepay();\n    error InvalidNewMinNumOfSigners();\n    error AlreadySigner();\n    error InvalidArrayIndex();\n    error InvalidSignerRemoveInfo();\n    error InvalidSendAmount();\n    error TooSmallLoanAmount();\n    error DeadlinePassed();\n    error WithdrawEntered();\n    error DuplicateAddresses();\n    error OnChainQuoteAlreadyAdded();\n    error OffChainQuoteHasBeenInvalidated();\n    error Uninitialized();\n    error InvalidRepaymentScheduleLength();\n    error FirstDueDateTooCloseOrPassed();\n    error InvalidGracePeriod();\n    error UnregisteredLoanProposal();\n    error NotInSubscriptionPhase();\n    error NotInUnsubscriptionPhase();\n    error InsufficientBalance();\n    error InsufficientFreeSubscriptionSpace();\n    error BeforeEarliestUnsubscribe();\n    error InconsistentLastLoanTermsUpdateTime();\n    error InvalidActionForCurrentStatus();\n    error FellShortOfTotalSubscriptionTarget();\n    error InvalidRollBackRequest();\n    error UnsubscriptionAmountTooLarge();\n    error InvalidSubscriptionRange();\n    error InvalidMaxTotalSubscriptions();\n    error OutsideConversionTimeWindow();\n    error OutsideRepaymentTimeWindow();\n    error NoDefault();\n    error LoanIsFullyRepaid();\n    error RepaymentIdxTooLarge();\n    error AlreadyClaimed();\n    error AlreadyConverted();\n    error InvalidDueDates();\n    error LoanTokenDueIsZero();\n    error WaitForLoanTermsCoolOffPeriod();\n    error ZeroConversionAmount();\n    error InvalidNewOwnerProposal();\n    error CollateralMustBeCompartmentalized();\n    error InvalidCompartmentForToken();\n    error InvalidSignature();\n    error InvalidUpdate();\n    error CannotClaimOutdatedStatus();\n    error DelegateReducedBalance();\n    error FundingPoolAlreadyExists();\n    error InvalidLender();\n    error NonIncreasingTokenAddrs();\n    error NonIncreasingNonFungibleTokenIds();\n    error TransferToWrappedTokenFailed();\n    error TransferFromWrappedTokenFailed();\n    error StateAlreadySet();\n    error ReclaimableCollateralAmountZero();\n    error InvalidSwap();\n    error InvalidUpfrontFee();\n    error InvalidOracleTolerance();\n    error ReserveRatiosSkewedFromOraclePrice();\n    error SequencerDown();\n    error GracePeriodNotOver();\n    error LoanExpired();\n    error NoDsEth();\n    error TooShortTwapInterval();\n    error TooLongTwapInterval();\n    error TwapExceedsThreshold();\n    error Reentrancy();\n    error TokenNotStuck();\n    error InconsistentExpTransferFee();\n    error InconsistentExpVaultBalIncrease();\n    error DepositLockActive();\n    error DisallowedSubscriptionLockup();\n    error IncorrectLoanAmount();\n    error Disabled();\n    error CannotRemintUnlessZeroSupply();\n    error TokensStillMissingFromWrapper();\n    error OnlyMintFromSingleTokenWrapper();\n    error NonMintableTokenState();\n    error NoTokensTransferred();\n    error TokenAlreadyCountedInWrapper();\n    error TokenNotOwnedByWrapper();\n    error TokenDoesNotBelongInWrapper(address tokenAddr, uint256 tokenId);\n    error InvalidMintAmount();\n    error QuoteViolatesPolicy();\n    error AlreadyPublished();\n    error PolicyAlreadySet();\n    error NoPolicyToDelete();\n    error InvalidTenorBounds();\n    error InvalidLtvBounds();\n    error InvalidLoanPerCollBounds();\n    error InvalidMinApr();\n    error NoPolicy();\n    error InvalidMinFee();\n}\n"
      },
      "contracts/peer-to-peer/interfaces/IOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.19;\n\ninterface IOracle {\n    /**\n     * @notice function checks oracle validity and calculates collTokenPriceInLoanToken\n     * @param collToken address of coll token\n     * @param loanToken address of loan token\n     * @return collTokenPriceInLoanToken collateral price denominated in loan token\n     */\n    function getPrice(\n        address collToken,\n        address loanToken\n    ) external view returns (uint256 collTokenPriceInLoanToken);\n\n    /**\n     * @notice function checks oracle validity and retrieves prices in base currency unit\n     * @param collToken address of coll token\n     * @param loanToken address of loan token\n     * @return collTokenPriceRaw and loanTokenPriceRaw denominated in base currency unit\n     */\n    function getRawPrices(\n        address collToken,\n        address loanToken\n    )\n        external\n        view\n        returns (uint256 collTokenPriceRaw, uint256 loanTokenPriceRaw);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/chainlink/AggregatorV3Interface.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface AggregatorV3Interface {\n    function decimals() external view returns (uint8);\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/peer-to-peer/oracles/chainlink/ChainlinkBase.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport {IERC20Metadata} from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport {AggregatorV3Interface} from \"../../interfaces/oracles/chainlink/AggregatorV3Interface.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {Constants} from \"../../../Constants.sol\";\nimport {Errors} from \"../../../Errors.sol\";\nimport {IOracle} from \"../../interfaces/IOracle.sol\";\n\n/**\n * @dev supports oracles which are compatible with v2v3 or v3 interfaces\n */\nabstract contract ChainlinkBase is IOracle {\n    // solhint-disable var-name-mixedcase\n    uint256 public immutable BASE_CURRENCY_UNIT;\n    mapping(address => address) public oracleAddrs;\n\n    constructor(\n        address[] memory _tokenAddrs,\n        address[] memory _oracleAddrs,\n        uint256 baseCurrencyUnit\n    ) {\n        uint256 tokenAddrsLength = _tokenAddrs.length;\n        if (tokenAddrsLength == 0 || tokenAddrsLength != _oracleAddrs.length) {\n            revert Errors.InvalidArrayLength();\n        }\n        uint8 oracleDecimals;\n        uint256 version;\n        for (uint256 i; i < tokenAddrsLength; ) {\n            if (_tokenAddrs[i] == address(0) || _oracleAddrs[i] == address(0)) {\n                revert Errors.InvalidAddress();\n            }\n            oracleDecimals = AggregatorV3Interface(_oracleAddrs[i]).decimals();\n            if (10 ** oracleDecimals != baseCurrencyUnit) {\n                revert Errors.InvalidOracleDecimals();\n            }\n            version = AggregatorV3Interface(_oracleAddrs[i]).version();\n            if (version != 4) {\n                revert Errors.InvalidOracleVersion();\n            }\n            oracleAddrs[_tokenAddrs[i]] = _oracleAddrs[i];\n            unchecked {\n                ++i;\n            }\n        }\n        BASE_CURRENCY_UNIT = baseCurrencyUnit;\n    }\n\n    function getPrice(\n        address collToken,\n        address loanToken\n    ) external view virtual returns (uint256 collTokenPriceInLoanToken) {\n        (uint256 priceOfCollToken, uint256 priceOfLoanToken) = getRawPrices(\n            collToken,\n            loanToken\n        );\n        uint256 loanTokenDecimals = IERC20Metadata(loanToken).decimals();\n        collTokenPriceInLoanToken = Math.mulDiv(\n            priceOfCollToken,\n            10 ** loanTokenDecimals,\n            priceOfLoanToken\n        );\n    }\n\n    function getRawPrices(\n        address collToken,\n        address loanToken\n    )\n        public\n        view\n        virtual\n        returns (uint256 collTokenPriceRaw, uint256 loanTokenPriceRaw)\n    {\n        (collTokenPriceRaw, loanTokenPriceRaw) = (\n            _getPriceOfToken(collToken),\n            _getPriceOfToken(loanToken)\n        );\n    }\n\n    function _getPriceOfToken(\n        address token\n    ) internal view virtual returns (uint256 tokenPriceRaw) {\n        address oracleAddr = oracleAddrs[token];\n        if (oracleAddr == address(0)) {\n            revert Errors.NoOracle();\n        }\n        tokenPriceRaw = _checkAndReturnLatestRoundData(oracleAddr);\n    }\n\n    function _checkAndReturnLatestRoundData(\n        address oracleAddr\n    ) internal view virtual returns (uint256 tokenPriceRaw) {\n        (\n            uint80 roundId,\n            int256 answer,\n            ,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        ) = AggregatorV3Interface(oracleAddr).latestRoundData();\n        if (\n            roundId == 0 ||\n            answeredInRound < roundId ||\n            answer < 1 ||\n            updatedAt > block.timestamp ||\n            updatedAt + Constants.MAX_PRICE_UPDATE_TIMESTAMP_DIVERGENCE <\n            block.timestamp\n        ) {\n            revert Errors.InvalidOracleAnswer();\n        }\n        tokenPriceRaw = uint256(answer);\n    }\n}\n"
      },
      "contracts/peer-to-peer/oracles/chainlink/ChainlinkBasic.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport {ChainlinkBase} from \"./ChainlinkBase.sol\";\nimport {Errors} from \"../../../Errors.sol\";\n\n/**\n * @dev supports oracles which are compatible with v2v3 or v3 interfaces\n */\ncontract ChainlinkBasic is ChainlinkBase {\n    // solhint-disable var-name-mixedcase\n    address public immutable BASE_CURRENCY;\n\n    constructor(\n        address[] memory _tokenAddrs,\n        address[] memory _oracleAddrs,\n        address baseCurrency,\n        uint256 baseCurrencyUnit\n    ) ChainlinkBase(_tokenAddrs, _oracleAddrs, baseCurrencyUnit) {\n        if (baseCurrency == address(0)) {\n            revert Errors.InvalidAddress();\n        }\n        BASE_CURRENCY = baseCurrency;\n    }\n\n    function _getPriceOfToken(\n        address token\n    ) internal view virtual override returns (uint256 tokenPriceRaw) {\n        tokenPriceRaw = token == BASE_CURRENCY\n            ? BASE_CURRENCY_UNIT\n            : super._getPriceOfToken(token);\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}