creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@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/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\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/interfaces/oracles/IANKRETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IANKRETH {\n    /**\n     * @notice gets amount of Eth for given ankrEth\n     * @param amount of ankrEth\n     * @return amount of eth\n     */\n    function sharesToBonds(uint256 amount) external view returns (uint256);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/IFXUSD.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IFXUSD {\n    /**\n     * @notice gets USD NAV in 18 decimals\n     * @return NAV in USD\n     */\n    function nav() external view returns (uint256);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/IMETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IMETH {\n    /**\n     * @notice gets amount of Eth for given mEth\n     * @param mETHAmount amount of mEth\n     * @return amount of stEth\n     */\n    function mETHToETH(uint256 mETHAmount) external view returns (uint256);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/IMysoTokenManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IMysoTokenManager {\n    /**\n     * @notice gets Myso token loan amount from MysoTokenManager\n     * @return total Myso loan amount up until now\n     */\n    function totalMysoLoanAmount() external view returns (uint256);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/IRSWETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IRSWETH {\n    /**\n     * @notice gets rswETH to ETH rate\n     * @return amount of ETH per rswETH\n     */\n    function rswETHToETHRate() external view returns (uint256);\n}\n"
      },
      "contracts/peer-to-peer/interfaces/oracles/IWSTETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IWSTETH {\n    /**\n     * @notice gets amount of stEth for given wstEth\n     * @param _wstETHAmount amount of wstEth\n     * @return amount of stEth\n     */\n    function getStETHByWstETH(\n        uint256 _wstETHAmount\n    ) external view returns (uint256);\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/custom/MysoOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport {ChainlinkBase} from \"../chainlink/ChainlinkBase.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IWSTETH} from \"../../interfaces/oracles/IWSTETH.sol\";\nimport {IANKRETH} from \"../../interfaces/oracles/IANKRETH.sol\";\nimport {IMETH} from \"../../interfaces/oracles/IMETH.sol\";\nimport {IFXUSD} from \"../../interfaces/oracles/IFXUSD.sol\";\nimport {IRSWETH} from \"../../interfaces/oracles/IRSWETH.sol\";\nimport {IMysoTokenManager} from \"../../interfaces/oracles/IMysoTokenManager.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {LogExpMath} from \"./utils/LogExpMath.sol\";\nimport {IERC20Metadata} from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev supports oracles which are compatible with v2v3 or v3 interfaces\n */\ncontract MysoOracle is ChainlinkBase, Ownable {\n    struct PriceParams {\n        // maxPrice is in 8 decimals for chainlink consistency\n        uint96 maxPrice;\n        // k is in 18 decimals\n        // e.g. 8e17 is 0.8 in decimal\n        uint96 k;\n        // a and b are in terms of 1000\n        // e.g. 1770 is 1.77 in decimal\n        uint32 a;\n        uint32 b;\n    }\n    // solhint-disable var-name-mixedcase\n    address internal constant MYSO = 0x5fDe99e121F3aC02e7d6ACb081dB1f89c1e93C17;\n    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n    address internal constant WSTETH =\n        0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;\n    address internal constant METH = 0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa;\n    address internal constant FXUSD =\n        0x085780639CC2cACd35E474e71f4d000e2405d8f6;\n    address internal constant RSWETH =\n        0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0;\n    address internal constant RPL = 0xD33526068D116cE69F19A9ee46F0bd304F21A51f;\n    address internal constant CRVUSD =\n        0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E;\n    address internal constant ANKRETH =\n        0xE95A203B1a91a908F9B9CE46459d101078c2c3cb;\n    address internal constant METH_STAKING_CONTRACT =\n        0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f;\n    uint256 internal constant MYSO_IOO_BASE_CURRENCY_UNIT = 1e18; // 18 decimals for ETH based oracles\n    address internal constant ETH_USD_CHAINLINK =\n        0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;\n    address internal constant STETH_ETH_CHAINLINK =\n        0x86392dC19c0b719886221c78AB11eb8Cf5c52812;\n    address internal constant RPL_USD_CHAINLINK =\n        0x4E155eD98aFE9034b7A5962f6C84c86d869daA9d;\n    address internal constant CRVUSD_USD_CHAINLINK =\n        0xEEf0C605546958c1f899b6fB336C20671f9cD49F;\n\n    uint256 internal constant MYSO_PRICE_TIME_LOCK = 5 minutes;\n\n    address public mysoTokenManager;\n\n    PriceParams public mysoPriceParams;\n\n    event MysoTokenManagerUpdated(address newMysoTokenManager);\n\n    error NoMyso();\n\n    /**\n     * @dev constructor for MysoOracle\n     * @param _tokenAddrs array of token addresses\n     * @param _oracleAddrs array of oracle addresses\n     * @param _owner owner of the contract\n     * @param _mysoTokenManager address of myso token manager contract\n     * @param _maxPrice max price in 8 decimals\n     * @param _k k in 18 decimals\n     * @param _a a in terms of 1000\n     * @param _b b in terms of 1000\n     */\n    constructor(\n        address[] memory _tokenAddrs,\n        address[] memory _oracleAddrs,\n        address _owner,\n        address _mysoTokenManager,\n        uint96 _maxPrice,\n        uint96 _k,\n        uint32 _a,\n        uint32 _b\n    )\n        ChainlinkBase(_tokenAddrs, _oracleAddrs, MYSO_IOO_BASE_CURRENCY_UNIT)\n        Ownable()\n    {\n        mysoTokenManager = _mysoTokenManager;\n        mysoPriceParams = PriceParams(_maxPrice, _k, _a, _b);\n        _transferOwnership(_owner);\n    }\n\n    /**\n     * @dev updates myso token manager contract address\n     * @param _newMysoTokenManager new myso token manager contract address\n     */\n\n    function setMysoTokenManager(\n        address _newMysoTokenManager\n    ) external onlyOwner {\n        mysoTokenManager = _newMysoTokenManager;\n        emit MysoTokenManagerUpdated(_newMysoTokenManager);\n    }\n\n    /**\n     * @dev updates myso price params\n     * @param _maxPrice max price in 8 decimals\n     * @param _k k in 18 decimals\n     * @param _a a in terms of 1000\n     * @param _b b in terms of 1000\n     */\n    function setMysoPriceParams(\n        uint96 _maxPrice,\n        uint96 _k,\n        uint32 _a,\n        uint32 _b\n    ) external onlyOwner {\n        mysoPriceParams = PriceParams(_maxPrice, _k, _a, _b);\n    }\n\n    function getPrice(\n        address collToken,\n        address loanToken\n    ) external view override returns (uint256 collTokenPriceInLoanToken) {\n        (uint256 priceOfCollToken, uint256 priceOfLoanToken) = getRawPrices(\n            collToken,\n            loanToken\n        );\n        uint256 loanTokenDecimals = (loanToken == MYSO)\n            ? 18\n            : IERC20Metadata(loanToken).decimals();\n        collTokenPriceInLoanToken =\n            (priceOfCollToken * 10 ** loanTokenDecimals) /\n            priceOfLoanToken;\n    }\n\n    function getRawPrices(\n        address collToken,\n        address loanToken\n    )\n        public\n        view\n        override\n        returns (uint256 collTokenPriceRaw, uint256 loanTokenPriceRaw)\n    {\n        // must have at least one token is MYSO to use this oracle\n        if (collToken != MYSO && loanToken != MYSO) {\n            revert NoMyso();\n        }\n        (collTokenPriceRaw, loanTokenPriceRaw) = (\n            _getPriceOfToken(collToken),\n            _getPriceOfToken(loanToken)\n        );\n    }\n\n    function _getPriceOfToken(\n        address token\n    ) internal view virtual override returns (uint256 tokenPriceRaw) {\n        if (token == MYSO) {\n            tokenPriceRaw = _getMysoPriceInEth();\n        } else if (token == WETH) {\n            tokenPriceRaw = 1e18;\n        } else if (token == WSTETH) {\n            tokenPriceRaw = _getWstEthPrice();\n        } else if (token == METH) {\n            tokenPriceRaw = IMETH(METH_STAKING_CONTRACT).mETHToETH(1e18);\n        } else if (token == RPL) {\n            tokenPriceRaw = _getRPLPriceInEth();\n        } else if (token == ANKRETH) {\n            tokenPriceRaw = IANKRETH(ANKRETH).sharesToBonds(1e18);\n        } else if (token == FXUSD) {\n            tokenPriceRaw = _getFXUSDPriceInEth();\n        } else if (token == RSWETH) {\n            tokenPriceRaw = IRSWETH(RSWETH).rswETHToETHRate();\n        } else if (token == CRVUSD) {\n            tokenPriceRaw = _getCRVUSDPriceInEth();\n        } else {\n            tokenPriceRaw = super._getPriceOfToken(token);\n        }\n    }\n\n    function _getWstEthPrice() internal view returns (uint256 wstEthPriceRaw) {\n        uint256 stEthAmountPerWstEth = IWSTETH(WSTETH).getStETHByWstETH(1e18);\n        uint256 stEthPriceInEth = _checkAndReturnLatestRoundData(\n            (STETH_ETH_CHAINLINK)\n        );\n        wstEthPriceRaw = Math.mulDiv(\n            stEthPriceInEth,\n            stEthAmountPerWstEth,\n            1e18\n        );\n    }\n\n    function _getMysoPriceInEth()\n        internal\n        view\n        returns (uint256 mysoPriceInEth)\n    {\n        uint256 ethPriceInUsd = _checkAndReturnLatestRoundData(\n            ETH_USD_CHAINLINK\n        );\n        uint256 _totalMysoLoanAmount = IMysoTokenManager(mysoTokenManager)\n            .totalMysoLoanAmount();\n        uint256 mysoPriceInUsd = _getMysoPriceInUsd(_totalMysoLoanAmount);\n        mysoPriceInEth = Math.mulDiv(mysoPriceInUsd, 1e18, ethPriceInUsd);\n    }\n\n    function _getMysoPriceInUsd(\n        uint256 totalMysoLoanAmount\n    ) internal view returns (uint256 mysoPriceInUsd) {\n        PriceParams memory params = mysoPriceParams;\n        uint256 maxPrice = uint256(params.maxPrice);\n        uint256 k = uint256(params.k);\n        uint256 a = uint256(params.a);\n        uint256 b = uint256(params.b);\n        uint256 numerator = k * b;\n        uint256 denominator = uint256(\n            LogExpMath.exp(\n                int256(Math.mulDiv(totalMysoLoanAmount, a, 1000000000))\n            )\n        ) + (2 * b - 1000) * 1e15;\n        mysoPriceInUsd = maxPrice - Math.mulDiv(numerator, 1e5, denominator);\n    }\n\n    function _getRPLPriceInEth() internal view returns (uint256 rplPriceRaw) {\n        uint256 rplPriceInUSD = _checkAndReturnLatestRoundData(\n            (RPL_USD_CHAINLINK)\n        );\n        uint256 ethPriceInUsd = _checkAndReturnLatestRoundData(\n            ETH_USD_CHAINLINK\n        );\n        rplPriceRaw = Math.mulDiv(rplPriceInUSD, 1e18, ethPriceInUsd);\n    }\n\n    function _getCRVUSDPriceInEth()\n        internal\n        view\n        returns (uint256 crvUsdPriceRaw)\n    {\n        uint256 crvUsdPriceInUSD = _checkAndReturnLatestRoundData(\n            (CRVUSD_USD_CHAINLINK)\n        );\n        uint256 ethPriceInUsd = _checkAndReturnLatestRoundData(\n            ETH_USD_CHAINLINK\n        );\n        crvUsdPriceRaw = Math.mulDiv(crvUsdPriceInUSD, 1e18, ethPriceInUsd);\n    }\n\n    function _getFXUSDPriceInEth()\n        internal\n        view\n        returns (uint256 fxusdPriceRaw)\n    {\n        uint256 ethPriceInUsd = _checkAndReturnLatestRoundData(\n            ETH_USD_CHAINLINK\n        );\n        uint256 fxusdPriceInUSD = IFXUSD(FXUSD).nav();\n        fxusdPriceRaw = Math.mulDiv(fxusdPriceInUSD, 1e8, ethPriceInUsd);\n    }\n}\n"
      },
      "contracts/peer-to-peer/oracles/custom/utils/LogExpMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nlibrary LogExpMath {\n    // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying\n    // two numbers, and multiply by ONE when dividing them.\n\n    // All arguments and return values are 18 decimal fixed point numbers.\n\n    int256 constant ONE_18 = 1e18;\n\n    // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the\n    // case of ln36, 36 decimals.\n    int256 constant ONE_20 = 1e20;\n    int256 constant ONE_36 = 1e36;\n\n    // The domain of natural exponentiation is bound by the word size and number of decimals used.\n    //\n    // Because internally the result will be stored using 20 decimals, the largest possible result is\n    // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221.\n    // The smallest possible result is 10^(-18), which makes largest negative argument\n    // ln(10^(-18)) = -41.446531673892822312.\n    // We use 130.0 and -41.0 to have some safety margin.\n    int256 constant MAX_NATURAL_EXPONENT = 130e18;\n    int256 constant MIN_NATURAL_EXPONENT = -41e18;\n\n    // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point\n    // 256 bit integer.\n    int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17;\n    int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17;\n\n    uint256 constant MILD_EXPONENT_BOUND = 2 ** 254 / uint256(ONE_20);\n\n    // 18 decimal constants\n    int256 constant x0 = 128000000000000000000; // 2ˆ7\n    int256 constant a0 =\n        38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals)\n    int256 constant x1 = 64000000000000000000; // 2ˆ6\n    int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals)\n\n    // 20 decimal constants\n    int256 constant x2 = 3200000000000000000000; // 2ˆ5\n    int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2)\n    int256 constant x3 = 1600000000000000000000; // 2ˆ4\n    int256 constant a3 = 888611052050787263676000000; // eˆ(x3)\n    int256 constant x4 = 800000000000000000000; // 2ˆ3\n    int256 constant a4 = 298095798704172827474000; // eˆ(x4)\n    int256 constant x5 = 400000000000000000000; // 2ˆ2\n    int256 constant a5 = 5459815003314423907810; // eˆ(x5)\n    int256 constant x6 = 200000000000000000000; // 2ˆ1\n    int256 constant a6 = 738905609893065022723; // eˆ(x6)\n    int256 constant x7 = 100000000000000000000; // 2ˆ0\n    int256 constant a7 = 271828182845904523536; // eˆ(x7)\n    int256 constant x8 = 50000000000000000000; // 2ˆ-1\n    int256 constant a8 = 164872127070012814685; // eˆ(x8)\n    int256 constant x9 = 25000000000000000000; // 2ˆ-2\n    int256 constant a9 = 128402541668774148407; // eˆ(x9)\n    int256 constant x10 = 12500000000000000000; // 2ˆ-3\n    int256 constant a10 = 113314845306682631683; // eˆ(x10)\n    int256 constant x11 = 6250000000000000000; // 2ˆ-4\n    int256 constant a11 = 106449445891785942956; // eˆ(x11)\n\n    /**\n     * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent.\n     *\n     * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`.\n     */\n    function exp(int256 x) internal pure returns (int256) {\n        require(\n            x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT,\n            \"INVALID_EXPONENT\"\n        );\n\n        if (x < 0) {\n            // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it\n            // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT).\n            // Fixed point division requires multiplying by ONE_18.\n            return ((ONE_18 * ONE_18) / exp(-x));\n        }\n\n        // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n,\n        // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7\n        // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the\n        // decomposition.\n        // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this\n        // decomposition, which will be lower than the smallest x_n.\n        // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1.\n        // We mutate x by subtracting x_n, making it the remainder of the decomposition.\n\n        // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause\n        // intermediate overflows. Instead we store them as plain integers, with 0 decimals.\n        // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the\n        // decomposition.\n\n        // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct\n        // it and compute the accumulated product.\n\n        int256 firstAN;\n        if (x >= x0) {\n            x -= x0;\n            firstAN = a0;\n        } else if (x >= x1) {\n            x -= x1;\n            firstAN = a1;\n        } else {\n            firstAN = 1; // One with no decimal places\n        }\n\n        // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the\n        // smaller terms.\n        x *= 100;\n\n        // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point\n        // one. Recall that fixed point multiplication requires dividing by ONE_20.\n        int256 product = ONE_20;\n\n        if (x >= x2) {\n            x -= x2;\n            product = (product * a2) / ONE_20;\n        }\n        if (x >= x3) {\n            x -= x3;\n            product = (product * a3) / ONE_20;\n        }\n        if (x >= x4) {\n            x -= x4;\n            product = (product * a4) / ONE_20;\n        }\n        if (x >= x5) {\n            x -= x5;\n            product = (product * a5) / ONE_20;\n        }\n        if (x >= x6) {\n            x -= x6;\n            product = (product * a6) / ONE_20;\n        }\n        if (x >= x7) {\n            x -= x7;\n            product = (product * a7) / ONE_20;\n        }\n        if (x >= x8) {\n            x -= x8;\n            product = (product * a8) / ONE_20;\n        }\n        if (x >= x9) {\n            x -= x9;\n            product = (product * a9) / ONE_20;\n        }\n\n        // x10 and x11 are unnecessary here since we have high enough precision already.\n\n        // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series\n        // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!).\n\n        int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places.\n        int256 term; // Each term in the sum, where the nth term is (x^n / n!).\n\n        // The first term is simply x.\n        term = x;\n        seriesSum += term;\n\n        // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number,\n        // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not.\n\n        term = ((term * x) / ONE_20) / 2;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 3;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 4;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 5;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 6;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 7;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 8;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 9;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 10;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 11;\n        seriesSum += term;\n\n        term = ((term * x) / ONE_20) / 12;\n        seriesSum += term;\n\n        // 12 Taylor terms are sufficient for 18 decimal precision.\n\n        // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor\n        // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply\n        // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication),\n        // and then drop two digits to return an 18 decimal value.\n\n        return (((product * seriesSum) / ONE_20) * firstAN) / 100;\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}