{"file_path":"lib/mento-core-2.5.0/contracts/oracles/ChainlinkRelayerV1.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.18;\n\nimport \"../interfaces/IChainlinkRelayer.sol\";\nimport \"foundry-chainlink-toolkit/src/interfaces/feeds/AggregatorV3Interface.sol\";\nimport { UD60x18, ud, intoUint256 } from \"prb/math/UD60x18.sol\";\n\n/**\n * @notice The minimal subset of the SortedOracles interface needed by the\n * relayer.\n * @dev SortedOracles is a Solidity 5.13 contract, thus we can't import the\n * interface directly, so we use a minimal hand-copied one.\n * See https://github.com/mento-protocol/mento-core/blob/develop/contracts/common/SortedOracles.sol\n */\ninterface ISortedOraclesMin {\n  function report(\n    address rateFeedId,\n    uint256 value,\n    address lesserKey,\n    address greaterKey\n  ) external;\n\n  function getRates(address rateFeedId)\n    external\n    returns (\n      address[] memory,\n      uint256[] memory,\n      uint256[] memory\n    );\n\n  function medianTimestamp(address rateFeedId) external view returns (uint256);\n\n  function getTokenReportExpirySeconds(address rateFeedId) external view returns (uint256);\n\n  function removeExpiredReports(address rateFeedId, uint256 n) external;\n}\n\n/**\n * @title ChainlinkRelayer\n * @notice The ChainlinkRelayer relays rate feed data from a Chainlink price feed, or\n * an aggregation of multiple Chainlink price feeds to the SortedOracles contract.\n * A separate instance should be deployed for each rate feed.\n * @dev Assumes that it is the only reporter for the given SortedOracles feed.\n * This contract aggregates multiple Chainlink price feeds in order to provide derived rate feeds\n * to the rest of the protocol. This is needed because it is more efficient for oracle providers\n * to report FX rates against the dollar and crypto-asset rates against the dollar,\n * instead of all possible combinations.\n * For example, for the Philippine Peso, Chainlink reports PHP/USD, but does not report CELO/PHP\n * which is required to pay for gas in a PHP stable token. But using both PHP/USD and CELO/USD,\n * one can create a path: CELO/USD * inverse(PHP/USD) = CELO/PHP.\n * Because of this we can provide up to four Chainlink price sources with inversion settings\n * to the relayer, a price path. The path segments are chained through multiplication and\n * inversion to derive the rate.\n */\ncontract ChainlinkRelayerV1 is IChainlinkRelayer {\n  /**\n   * @notice The number of digits after the decimal point in FixidityLib values, as used by SortedOracles.\n   * @dev See contracts/common/FixidityLib.sol\n   */\n  uint256 private constant UD60X18_TO_FIXIDITY_SCALE = 1e6; // 10 ** (24 - 18)\n\n  /// @notice The rateFeedId this relayer relays for.\n  address public immutable rateFeedId;\n\n  /// @notice The address of the SortedOracles contract to report to.\n  address public immutable sortedOracles;\n\n  /**\n   * @dev We store an array of up to four IChainlinkRelayer.ChainlinkAggregator structs\n   * in the following immutable variables.\n   * aggregator<i> stores the i-th ChainlinkAggregator.aggregator member.\n   * invert<i> stores the i-th ChainlinkAggregator.invert member.\n   * aggregatorCount stores the length of the array.\n   * These are built back up into an in-memory array in the buildAggregatorArray function.\n   */\n\n  /// @notice The addresses of the Chainlink aggregators this contract fetches data from.\n  address private immutable aggregator0;\n  address private immutable aggregator1;\n  address private immutable aggregator2;\n  address private immutable aggregator3;\n\n  /// @notice The invert setting for each aggregator, if true it flips the rate feed, i.e. CELO/USD -> USD/CELO.\n  bool private immutable invert0;\n  bool private immutable invert1;\n  bool private immutable invert2;\n  bool private immutable invert3;\n\n  /// @notice The number of aggregators provided during construction 1 <= aggregatorCount <= 4.\n  uint256 private immutable aggregatorCount;\n\n  /**\n   * @notice Maximum timestamp deviation allowed between all report timestamps pulled\n   * from the Chainlink aggregators.\n   * @dev Only relevant when aggregatorCount > 1.\n   */\n  uint256 public immutable maxTimestampSpread;\n\n  /**\n   * @notice Human-readable description of the rate feed.\n   * @dev Should only be used off-chain for easier debugging / UI generation,\n   * thus the only storage related gas spend occurs in the constructor.\n   */\n  string public rateFeedDescription;\n\n  /// @notice Used when an empty array of aggregators is passed into the constructor.\n  error NoAggregators();\n\n  /// @notice Used when more than four aggregators are passed into the constructor.\n  error TooManyAggregators();\n\n  /// @notice Used when a) there is more than 1 aggregator and the maxTimestampSpread is 0,\n  /// OR b) when there is only 1 aggregator and the maxTimestampSpread is not 0.\n  error InvalidMaxTimestampSpread();\n\n  /// @notice Used when a new price's timestamp is not newer than the most recent SortedOracles timestamp.\n  error TimestampNotNew();\n\n  /// @notice Used when a new price's timestamp would be considered expired by SortedOracles.\n  error ExpiredTimestamp();\n\n  /// @notice Used when a negative or zero price is returned by the Chainlink aggregator.\n  error InvalidPrice();\n  /**\n   * @notice Used when the spread between the earliest and latest timestamp\n   * of the aggregators is above the maximum allowed.\n   */\n  error TimestampSpreadTooHigh();\n  /**\n   * @notice Used when trying to recover from a lesser/greater revert and there are\n   * too many existing reports in SortedOracles.\n   */\n  error TooManyExistingReports();\n\n  /**\n   * @notice Used in the constructor when a ChainlinkAggregator\n   * has address(0) for an aggregator.\n   */\n  error InvalidAggregator();\n\n  /**\n   * @notice Initializes the contract and sets immutable parameters.\n   * @param _rateFeedId ID of the rate feed this relayer instance relays for.\n   * @param _rateFeedDescription The human-readable description of the reported rate feed.\n   * @param _sortedOracles Address of the SortedOracles contract to relay to.\n   * @param _maxTimestampSpread Max difference in milliseconds between the earliest and\n   *        latest timestamp of all aggregators in the price path.\n   * @param _aggregators Array of ChainlinkAggregator structs defining the price path.\n   */\n  constructor(\n    address _rateFeedId,\n    string memory _rateFeedDescription,\n    address _sortedOracles,\n    uint256 _maxTimestampSpread,\n    ChainlinkAggregator[] memory _aggregators\n  ) {\n    rateFeedId = _rateFeedId;\n    sortedOracles = _sortedOracles;\n    maxTimestampSpread = _maxTimestampSpread;\n    rateFeedDescription = _rateFeedDescription;\n\n    aggregatorCount = _aggregators.length;\n    if (aggregatorCount == 0) {\n      revert NoAggregators();\n    }\n\n    if (aggregatorCount > 4) {\n      revert TooManyAggregators();\n    }\n\n    if ((aggregatorCount > 1 && _maxTimestampSpread == 0) || (aggregatorCount == 1 && _maxTimestampSpread != 0)) {\n      revert InvalidMaxTimestampSpread();\n    }\n\n    ChainlinkAggregator[] memory aggregators = new ChainlinkAggregator[](4);\n    for (uint256 i = 0; i < _aggregators.length; i++) {\n      if (_aggregators[i].aggregator == address(0)) {\n        revert InvalidAggregator();\n      }\n\n      aggregators[i] = _aggregators[i];\n    }\n\n    aggregator0 = aggregators[0].aggregator;\n    aggregator1 = aggregators[1].aggregator;\n    aggregator2 = aggregators[2].aggregator;\n    aggregator3 = aggregators[3].aggregator;\n    invert0 = aggregators[0].invert;\n    invert1 = aggregators[1].invert;\n    invert2 = aggregators[2].invert;\n    invert3 = aggregators[3].invert;\n  }\n\n  /**\n   * @notice Get the Chainlink aggregators and their invert settings.\n   * @return An array of ChainlinkAggregator segments that compose the price path.\n   */\n  function getAggregators() external view returns (ChainlinkAggregator[] memory) {\n    return buildAggregatorArray();\n  }\n\n  /**\n   * @notice Relays data from the configured Chainlink aggregator to SortedOracles.\n   * @dev Checks the price is non-negative (Chainlink uses `int256` rather than `uint256`.\n   * @dev Converts the price to a Fixidity value, as expected by SortedOracles.\n   * @dev Performs checks on the timestamp, will revert if any fails:\n   *      - The most recent Chainlink timestamp should be strictly newer than the most\n   *        recent timestamp in SortedOracles.\n   *      - The most recent Chainlink timestamp should not be considered expired by SortedOracles.\n   *      - The spread between aggregator timestamps is less than the maxTimestampSpread.\n   */\n  function relay() external {\n    ISortedOraclesMin _sortedOracles = ISortedOraclesMin(sortedOracles);\n    ChainlinkAggregator[] memory aggregators = buildAggregatorArray();\n\n    (UD60x18 report, uint256 timestamp) = readChainlinkAggregator(aggregators[0]);\n    uint256 oldestChainlinkTs = timestamp;\n    uint256 newestChainlinkTs = timestamp;\n\n    UD60x18 nextReport;\n    for (uint256 i = 1; i < aggregators.length; i++) {\n      (nextReport, timestamp) = readChainlinkAggregator(aggregators[i]);\n      report = report.mul(nextReport);\n      oldestChainlinkTs = timestamp < oldestChainlinkTs ? timestamp : oldestChainlinkTs;\n      newestChainlinkTs = timestamp > newestChainlinkTs ? timestamp : newestChainlinkTs;\n    }\n\n    if (newestChainlinkTs - oldestChainlinkTs > maxTimestampSpread) {\n      revert TimestampSpreadTooHigh();\n    }\n\n    uint256 lastReportTs = _sortedOracles.medianTimestamp(rateFeedId);\n\n    if (lastReportTs > 0 && newestChainlinkTs <= lastReportTs) {\n      revert TimestampNotNew();\n    }\n\n    if (isTimestampExpired(newestChainlinkTs)) {\n      revert ExpiredTimestamp();\n    }\n\n    reportRate(intoUint256(report) * UD60X18_TO_FIXIDITY_SCALE);\n  }\n\n  /**\n   * @notice Report by looking up existing reports and building the lesser and greater keys.\n   * @dev Depending on the state in SortedOracles we can be in the:\n   *   - Happy path: No reports, or a single report from this relayer.\n   *     We can report with lesser and greater keys as address(0)\n   *   - Unhappy path: There are reports from other oracles.\n   *     We restrain this path by only computing lesser and greater keys when there is\n   *     at most one report from a different oracle.\n   *     We also attempt to expire reports in order to get back to the happy path.\n   * @param rate The rate to report.\n   */\n  function reportRate(uint256 rate) internal {\n    (address[] memory oracles, uint256[] memory rates, ) = ISortedOraclesMin(sortedOracles).getRates(rateFeedId);\n    uint256 numRates = oracles.length;\n\n    if (numRates == 0 || (numRates == 1 && oracles[0] == address(this))) {\n      // Happy path: SortedOracles is empty, or there is a single report from this relayer.\n      ISortedOraclesMin(sortedOracles).report(rateFeedId, rate, address(0), address(0));\n      return;\n    }\n\n    if (numRates > 2 || (numRates == 2 && oracles[0] != address(this) && oracles[1] != address(this))) {\n      revert TooManyExistingReports();\n    }\n\n    // At this point we have ensured that either:\n    // - There is a single report from another oracle.\n    // - There are two reports and one is from this relayer.\n\n    address otherOracle;\n    uint256 otherRate;\n\n    if (numRates == 1 || oracles[0] != address(this)) {\n      otherOracle = oracles[0];\n      otherRate = rates[0];\n    } else {\n      otherOracle = oracles[1];\n      otherRate = rates[1];\n    }\n\n    address lesserKey;\n    address greaterKey;\n\n    if (otherRate < rate) {\n      lesserKey = otherOracle;\n    } else {\n      greaterKey = otherOracle;\n    }\n\n    ISortedOraclesMin(sortedOracles).report(rateFeedId, rate, lesserKey, greaterKey);\n    ISortedOraclesMin(sortedOracles).removeExpiredReports(rateFeedId, 1);\n  }\n\n  /**\n   * @notice Read and validate a Chainlink report from an aggregator.\n   * It inverts the value if necessary.\n   * @return price UD60x18 report value.\n   * @return timestamp uint256 timestamp of the report.\n   */\n  function readChainlinkAggregator(ChainlinkAggregator memory aggCfg) internal view returns (UD60x18, uint256) {\n    (, int256 _price, , uint256 timestamp, ) = AggregatorV3Interface(aggCfg.aggregator).latestRoundData();\n    if (_price <= 0) {\n      revert InvalidPrice();\n    }\n    UD60x18 price = chainlinkToUD60x18(_price, aggCfg.aggregator);\n    if (aggCfg.invert) {\n      price = price.inv();\n    }\n    return (price, timestamp);\n  }\n\n  /**\n   * @notice Compose immutable variables into an in-memory array for better handling.\n   * @return aggregators An array of ChainlinkAggregator structs.\n   */\n  function buildAggregatorArray() internal view returns (ChainlinkAggregator[] memory aggregators) {\n    aggregators = new ChainlinkAggregator[](aggregatorCount);\n    unchecked {\n      aggregators[0] = ChainlinkAggregator(aggregator0, invert0);\n      if (aggregatorCount > 1) {\n        aggregators[1] = ChainlinkAggregator(aggregator1, invert1);\n        if (aggregatorCount > 2) {\n          aggregators[2] = ChainlinkAggregator(aggregator2, invert2);\n          if (aggregatorCount > 3) {\n            aggregators[3] = ChainlinkAggregator(aggregator3, invert3);\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * @notice Checks if a Chainlink price's timestamp would be expired in SortedOracles.\n   * @param timestamp The timestamp returned by the Chainlink aggregator.\n   * @return `true` if expired based on SortedOracles expiry parameter.\n   */\n  function isTimestampExpired(uint256 timestamp) internal view returns (bool) {\n    return block.timestamp - timestamp >= ISortedOraclesMin(sortedOracles).getTokenReportExpirySeconds(rateFeedId);\n  }\n\n  /**\n   * @notice Converts a Chainlink price to a UD60x18 value.\n   * @param price A price from the Chainlink aggregator.\n   * @return The converted UD60x18 value.\n   */\n  function chainlinkToUD60x18(int256 price, address aggregator) internal view returns (UD60x18) {\n    uint256 chainlinkDecimals = uint256(AggregatorV3Interface(aggregator).decimals());\n    return ud(uint256(price) * 10**(18 - chainlinkDecimals));\n  }\n}\n","deployed_bytecode":"0x608060408181526004918236101561001657600080fd5b600090813560e01c908163132e8aa71461067e5750806321b8929e146106435780637ee7f7d1146105c4578063a1bd91da14610573578063b59589d1146101ff5763e6f4c8651461006657600080fd5b346101fc57806003193601126101fc57815190808154600181811c9181811680156101f2575b60209889851082146101c65750918391899593889586529081600014610186575060011461012b575b50506100c7925095939295038261072d565b82519382859384528251928382860152825b84811061011557505050828201840152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168101030190f35b81810183015188820188015287955082016100d9565b8580527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5639492508591905b81831061016e5750889450508201016100c7386100b5565b85548884018501529485019487945091830191610156565b90506100c79593507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201018692386100b5565b8660226024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b92607f169261008c565b80fd5b50903461056f578160031936011261056f5773ffffffffffffffffffffffffffffffffffffffff90817f000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b331691610253610f02565b61026561025f8261076e565b51610ca9565b94909480926001809181925b6104bd575b50505061028390836107da565b7f000000000000000000000000000000000000000000000000000000000000000010610495578351927f071b48fc0000000000000000000000000000000000000000000000000000000084527f000000000000000000000000bacee37d31b9f022ef5d232b9fd53f05a531c169169182888501526020938481602481865afa90811561048b57889161045a575b50801515908161044f575b506104275761032b8491426107da565b9260248651809481937f6deb67990000000000000000000000000000000000000000000000000000000083528c8301525afa92831561041d5786936103e9575b505010156103c15750620f4240908181029181830414901517156103955761039290610891565b80f35b5060116024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b8390517fa3644e9f000000000000000000000000000000000000000000000000000000008152fd5b9080929350813d8311610416575b610401818361072d565b81010312610412575190388061036b565b8480fd5b503d6103f7565b84513d88823e3d90fd5b8785517fc175c1ae000000000000000000000000000000000000000000000000000000008152fd5b90508111153861031b565b90508481813d8311610484575b610471818361072d565b81010312610480575138610310565b8780fd5b503d610467565b86513d8a823e3d90fd5b8684517f5289d054000000000000000000000000000000000000000000000000000000008152fd5b90919492978151861015610567576104e66104e060208860051b85010151610ca9565b92611191565b98808210156105625750805b938082111561055b57505b947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461052f578201919081610271565b60248a60118d7f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b90506104fd565b6104f2565b979294610276565b5080fd5b50903461056f578160031936011261056f576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bacee37d31b9f022ef5d232b9fd53f05a531c169168152f35b50903461056f578160031936011261056f576105de610f02565b8151928392602080850191818652845180935281818701950193905b8382106106075786860387f35b8451805173ffffffffffffffffffffffffffffffffffffffff1687528301511515868401528796509485019493820193600191909101906105fa565b50903461056f578160031936011261056f57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b90503461056f578160031936011261056f5760209073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b33168152f35b67ffffffffffffffff81116106e257604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040810190811067ffffffffffffffff8211176106e257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176106e257604052565b80511561077b5760200190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80516001101561077b5760400190565b80516002101561077b5760600190565b80516003101561077b5760800190565b919082039182116107e757565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b67ffffffffffffffff81116106e25760051b60200190565b81601f8201121561088c5780519161084583610816565b92610853604051948561072d565b808452602092838086019260051b82010192831161088c578301905b82821061087d575050505090565b8151815290830190830161086f565b600080fd5b73ffffffffffffffffffffffffffffffffffffffff90817f000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b33166040918251907f02f55b61000000000000000000000000000000000000000000000000000000008252600094807f000000000000000000000000bacee37d31b9f022ef5d232b9fd53f05a531c1691692836004820152868160248183895af1908115610c885787908892610bad575b50805180158015610b8e575b610b1c57600281118015610ae1575b610ab85760018491148015610aa3575b15610a885761097561097d9261076e565b51169161076e565b51905b8784899310600014610a8057505b853b156104805782908751947f80e507440000000000000000000000000000000000000000000000000000000086528660048701526024860152166044840152166064820152848160848183875af18015610a7657908591610a62575b5050813b15610a5e578291604485949285935195869384927fdd34ca3b0000000000000000000000000000000000000000000000000000000084526004840152600160248401525af1908115610a555750610a44575050565b610a4e82916106ce565b6101fc5750565b513d84823e3d90fd5b8380fd5b610a6b906106ce565b610a5e5783386109eb565b84513d87823e3d90fd5b91509061098e565b610a94610a9c926107aa565b5116916107aa565b5190610980565b5080610aae8361076e565b5116301415610964565b600488517f6d79d026000000000000000000000000000000000000000000000000000000008152fd5b506002811480610b07575b8015610954575083610afd836107aa565b5116301415610954565b5083610b128361076e565b5116301415610aec565b50505050908293923b1561041257906084859283855196879485937f80e50744000000000000000000000000000000000000000000000000000000008552600485015260248401528160448401528160648401525af1908115610a555750610b82575050565b610b8b906106ce565b50565b50600181148015610945575083610ba48361076e565b51163014610945565b9150503d8088833e610bbf818361072d565b81016060828203126104805781519067ffffffffffffffff91828111610c845783019181601f84011215610c84578251610bf881610816565b93610c058b51958661072d565b818552602091828087019160051b83010191858311610c80578301905b828210610c6457505050840151818111610c605782610c4291860161082e565b9389810151918211610c6057610c5992910161082e565b5038610939565b8a80fd5b81518981168103610c7c578152908301908301610c22565b8e80fd5b8d80fd5b8980fd5b86513d89823e3d90fd5b519069ffffffffffffffffffff8216820361088c57565b9073ffffffffffffffffffffffffffffffffffffffff9160a083825116604051918280927ffeaf968c00000000000000000000000000000000000000000000000000000000825260049384915afa948515610e78576000928396610eac575b506000831315610e845760208291855116604051928380927f313ce5670000000000000000000000000000000000000000000000000000000082525afa908115610e7857600091610e3c575b5060ff1660120360128111610e0e57604d8111610e0e57600a0a91828102928184041490151715610de057602082930151610d90575b50509190565b9080925015610db257506ec097ce7bc90715b34b9f1000000000043880610d8a565b6012907f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6011907f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6011827f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6020813d8211610e70575b81610e546020938361072d565b8101031261056f57519060ff821682036101fc575060ff610d54565b3d9150610e47565b6040513d6000823e3d90fd5b506040517ebfc921000000000000000000000000000000000000000000000000000000008152fd5b9290955060a0833d8211610efa575b81610ec860a0938361072d565b810103126101fc5750610eda82610c92565b506020820151610ef1608060608501519401610c92565b50919438610d08565b3d9150610ebb565b7f000000000000000000000000000000000000000000000000000000000000000190610f2d82610816565b604090610f3c8251918261072d565b8381527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0610f6985610816565b016000805b82811061116f575050508093825190610f8682610711565b73ffffffffffffffffffffffffffffffffffffffff91827f0000000000000000000000000826492a24b1dbd1d8fcb4701b38c557ce685e9d1681527f000000000000000000000000000000000000000000000000000000000000000015156020820152610ff28461076e565b52610ffc8361076e565b506001811161100c575b50505050565b835161101781610711565b827f00000000000000000000000000000000000000000000000000000000000000001681527f00000000000000000000000000000000000000000000000000000000000000001515602082015261106d846107aa565b52611077836107aa565b50600281111561100657600390845161108f81610711565b837f00000000000000000000000000000000000000000000000000000000000000001681527f0000000000000000000000000000000000000000000000000000000000000000151560208201526110e5856107ba565b526110ef846107ba565b50116110fc575b80611006565b61116692519061110b82610711565b7f00000000000000000000000000000000000000000000000000000000000000001681527f000000000000000000000000000000000000000000000000000000000000000015156020820152611160826107ca565b526107ca565b503880806110f6565b602090855161117d81610711565b838152828481830152828701015201610f6e565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff818309818302918280831092039180830391670de0b6b3a7640000958684101561121c57908691099214611216577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699350828211900360ee1b910360121c170290565b50500490565b604491604051917f5173648d00000000000000000000000000000000000000000000000000000000835260048301526024820152fdfea164736f6c6343000812000a","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"paris","libraries":{"lib/mento-core-2.0.0/contracts/common/linkedlists/AddressLinkedList.sol":{"AddressLinkedList":"0x6200f54d73491d56b8d7a975c9ee18efb4d518df"},"lib/mento-core-2.0.0/contracts/common/linkedlists/AddressSortedLinkedListWithMedian.sol":{"AddressSortedLinkedListWithMedian":"0xed477a99035d0c1e11369f1d7a4e587893cc002b"}},"metadata":{"bytecodeHash":"none"},"optimizer":{"enabled":true,"runs":10000},"remappings":["@celo/=lib/mento-core-2.6.0/node_modules/@celo/contracts/","@chainlink/contracts/=lib/mento-core-2.6.5/lib/foundry-chainlink-toolkit/lib/chainlink-brownie-contracts/contracts/src/","@openzeppelin/=lib/mento-core-2.6.5/lib/foundry-chainlink-toolkit/lib/openzeppelin-contracts/","@prb/test/=lib/mento-core-2.6.5/lib/prb-math/lib/prb-test/src/","celo-foundry/=lib/celo-foundry/src/","celo/=node_modules/@celo/","chainlink-brownie-contracts/=lib/mento-core-2.6.5/lib/foundry-chainlink-toolkit/lib/chainlink-brownie-contracts/contracts/src/v0.6/vendor/@arbitrum/nitro-contracts/src/","contracts/=contracts/","ds-test/=lib/celo-foundry/lib/forge-std/lib/ds-test/src/","forge-std-next/=lib/forge-std-next/src/","forge-std/=lib/celo-foundry/lib/forge-std/src/","foundry-chainlink-toolkit/=lib/mento-core-2.6.5/lib/foundry-chainlink-toolkit/","mento-core-2.0.0/=lib/mento-core-2.0.0/contracts/","mento-core-2.1.0/=lib/mento-core-2.1.0/contracts/","mento-core-2.2.0/=lib/mento-core-2.2.0/contracts/","mento-core-2.3.1/=lib/mento-core-2.3.1/contracts/","mento-core-2.5.0/=lib/mento-core-2.5.0/contracts/","mento-core-2.6.0-oz/=lib/mento-core-2.6.0/lib/openzeppelin-contracts-next/","mento-core-2.6.0/=lib/mento-core-2.6.0/contracts/","mento-core-2.6.2/=lib/mento-core-2.6.2/contracts/","mento-core-2.6.3/=lib/mento-core-2.6.3/contracts/","mento-core-2.6.4/=lib/mento-core-2.6.4/contracts/","mento-core-2.6.5/=lib/mento-core-2.6.5/contracts/","mento-std/=lib/mento-core-2.6.5/lib/mento-std/src/","merkle-distributor/=lib/merkle-distributor/contracts/","openzeppelin-contracts-next/=lib/mento-core-2.6.5/lib/openzeppelin-contracts-next/","openzeppelin-contracts-upgradeable/=lib/mento-core-2.6.5/lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/mento-core-2.6.5/lib/openzeppelin-contracts-next/","openzeppelin-solidity/=lib/mento-core-2.0.0/lib/openzeppelin-contracts/","prb-math/=lib/mento-core-2.6.5/lib/prb-math/src/","prb-test/=lib/mento-core-2.6.5/lib/prb-math/lib/prb-test/src/","prb/math/=lib/mento-core-2.6.5/lib/prb-math/src/","safe-contracts/=lib/mento-core-2.6.5/lib/safe-contracts/","src/=lib/mento-core-2.6.5/lib/prb-math/src/","test/=lib/mento-core-2.6.5/test/"],"viaIR":true},"optimization_runs":10000,"sourcify_repo_url":null,"decoded_constructor_args":[["0xbAcEE37d31b9f022Ef5d232B9fD53F05a531c169",{"internalType":"address","name":"_rateFeedId","type":"address"}],["KES/USD",{"internalType":"string","name":"_rateFeedDescription","type":"string"}],["0xefB84935239dAcdecF7c5bA76d8dE40b077B7b33",{"internalType":"address","name":"_sortedOracles","type":"address"}],["0",{"internalType":"uint256","name":"_maxTimestampSpread","type":"uint256"}],[[["0x0826492a24b1dBd1d8fcB4701b38C557CE685e9D","false"]],{"components":[{"internalType":"address","name":"aggregator","type":"address"},{"internalType":"bool","name":"invert","type":"bool"}],"internalType":"struct IChainlinkRelayer.ChainlinkAggregator[]","name":"_aggregators","type":"tuple[]"}]],"compiler_version":"0.8.18+commit.87f61d96","is_verified_via_verifier_alliance":true,"verified_at":"2026-05-03T23:37:57.755696Z","implementations":[],"proxy_type":null,"external_libraries":[{"name":"AddressLinkedList","address_hash":"0x6200F54D73491d56b8d7A975C9ee18EFb4D518Df"},{"name":"AddressSortedLinkedListWithMedian","address_hash":"0xED477A99035d0c1e11369F1D7A4e587893cc002B"}],"creation_bytecode":"0x6040610200815234620005a657620018e790813803806200002081620005e0565b938439820160a083820312620005a6576200003b8362000606565b906020928385015160018060401b0390818111620005a657860193601f90848287011215620005a6578551918383116200054957601f19926200008482820185168a01620005e0565b97818952878a8383010111620005a657899060005b838110620005ab57505060009189010152620000b7858a0162000606565b60608a01519260809a8b81015190878211620005a65701888482011215620005a65780518781116200054957620000f38c8260051b01620005e0565b998c808c848152019260061b84010192818411620005a6578d01915b8383106200055f57505050508a5260a0526101e0968288528051918583116200054957600054916001958684811c941680156200053e575b8c85101462000528578b8484879611620004cb575b50508b92841160011462000465575060009262000459575b5050600019600383901b1c191690831b176000555b8451946101c0958087521562000448576004918287511162000438578651908480831192836200042e575b83156200040f575b505050620004015784519360a0850190811185821017620003ec5785528184528760005b8a8110620003c9575050826000905b6200033d575b506001600160a01b03979250879150620002119050836200061b565b51511660c0528562000223836200063f565b51511660e05285620002358362000650565b515116956101009687526200024a8362000661565b515116610120908152816200025f846200061b565b5101511515906101409182528262000277856200063f565b510151151592610160938452620002a581620002938762000650565b51015115159561018096875262000661565b5101511515946101a0958652519761125f998a620006888b39518981816102d1015281816105a001526108f9015260a05189818161022a015281816106aa01526108aa015260c05189610f9f015260e0518961101a015251886110920152518761110d01525186610fc30152518561103e015251846110b60152518361113101525182610f04015251818181610285015261065b0152f35b8151811015620003c3576001600160a01b036200035b828462000672565b51511615620003b35762000370818362000672565b516200037d828762000672565b526200038a818662000672565b5060001981146200039e57830183620001ef565b601183634e487b7160e01b6000525260246000fd5b855163029a68ed60e41b81528390fd5b620001f5565b620003d3620005c0565b60008152600083820152828288010152018890620001e0565b604183634e487b7160e01b6000525260246000fd5b508351626a65eb60e01b8152fd5b1491508162000423575b50388481620001bc565b905015153862000419565b82159350620001b4565b8551633be17a5360e21b81528390fd5b8451635a0a2c5160e11b8152600490fd5b01519050388062000174565b86949291921691600080528b6000209260005b8d828210620004b457505084116200049a575b505050811b0160005562000189565b015160001960f88460031b161c191690553880806200048b565b838501518655899790950194938401930162000478565b9091929394506000805284826000209181880160051c83019388106200051e575b9187968a92969594930160051c01915b8281106200050e57508d91506200015c565b60008155879650899101620004fc565b92508192620004ec565b634e487b7160e01b600052602260045260246000fd5b93607f169362000147565b634e487b7160e01b600052604160045260246000fd5b8a83830312620005a6578d9062000575620005c0565b91620005818562000606565b8352840151908115158203620005a6578f91928d93838201528152019201916200010f565b600080fd5b8181018301518b82018401528b920162000099565b60408051919082016001600160401b038111838210176200054957604052565b6040519190601f01601f191682016001600160401b038111838210176200054957604052565b51906001600160a01b0382168203620005a657565b805115620006295760200190565b634e487b7160e01b600052603260045260246000fd5b805160011015620006295760400190565b805160021015620006295760600190565b805160031015620006295760800190565b8051821015620006295760209160051b01019056fe608060408181526004918236101561001657600080fd5b600090813560e01c908163132e8aa71461067e5750806321b8929e146106435780637ee7f7d1146105c4578063a1bd91da14610573578063b59589d1146101ff5763e6f4c8651461006657600080fd5b346101fc57806003193601126101fc57815190808154600181811c9181811680156101f2575b60209889851082146101c65750918391899593889586529081600014610186575060011461012b575b50506100c7925095939295038261072d565b82519382859384528251928382860152825b84811061011557505050828201840152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168101030190f35b81810183015188820188015287955082016100d9565b8580527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5639492508591905b81831061016e5750889450508201016100c7386100b5565b85548884018501529485019487945091830191610156565b90506100c79593507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201018692386100b5565b8660226024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b92607f169261008c565b80fd5b50903461056f578160031936011261056f5773ffffffffffffffffffffffffffffffffffffffff90817f00000000000000000000000000000000000000000000000000000000000000001691610253610f02565b61026561025f8261076e565b51610ca9565b94909480926001809181925b6104bd575b50505061028390836107da565b7f000000000000000000000000000000000000000000000000000000000000000010610495578351927f071b48fc0000000000000000000000000000000000000000000000000000000084527f0000000000000000000000000000000000000000000000000000000000000000169182888501526020938481602481865afa90811561048b57889161045a575b50801515908161044f575b506104275761032b8491426107da565b9260248651809481937f6deb67990000000000000000000000000000000000000000000000000000000083528c8301525afa92831561041d5786936103e9575b505010156103c15750620f4240908181029181830414901517156103955761039290610891565b80f35b5060116024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b8390517fa3644e9f000000000000000000000000000000000000000000000000000000008152fd5b9080929350813d8311610416575b610401818361072d565b81010312610412575190388061036b565b8480fd5b503d6103f7565b84513d88823e3d90fd5b8785517fc175c1ae000000000000000000000000000000000000000000000000000000008152fd5b90508111153861031b565b90508481813d8311610484575b610471818361072d565b81010312610480575138610310565b8780fd5b503d610467565b86513d8a823e3d90fd5b8684517f5289d054000000000000000000000000000000000000000000000000000000008152fd5b90919492978151861015610567576104e66104e060208860051b85010151610ca9565b92611191565b98808210156105625750805b938082111561055b57505b947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461052f578201919081610271565b60248a60118d7f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b90506104fd565b6104f2565b979294610276565b5080fd5b50903461056f578160031936011261056f576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50903461056f578160031936011261056f576105de610f02565b8151928392602080850191818652845180935281818701950193905b8382106106075786860387f35b8451805173ffffffffffffffffffffffffffffffffffffffff1687528301511515868401528796509485019493820193600191909101906105fa565b50903461056f578160031936011261056f57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b90503461056f578160031936011261056f5760209073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b67ffffffffffffffff81116106e257604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040810190811067ffffffffffffffff8211176106e257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176106e257604052565b80511561077b5760200190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80516001101561077b5760400190565b80516002101561077b5760600190565b80516003101561077b5760800190565b919082039182116107e757565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b67ffffffffffffffff81116106e25760051b60200190565b81601f8201121561088c5780519161084583610816565b92610853604051948561072d565b808452602092838086019260051b82010192831161088c578301905b82821061087d575050505090565b8151815290830190830161086f565b600080fd5b73ffffffffffffffffffffffffffffffffffffffff90817f0000000000000000000000000000000000000000000000000000000000000000166040918251907f02f55b61000000000000000000000000000000000000000000000000000000008252600094807f00000000000000000000000000000000000000000000000000000000000000001692836004820152868160248183895af1908115610c885787908892610bad575b50805180158015610b8e575b610b1c57600281118015610ae1575b610ab85760018491148015610aa3575b15610a885761097561097d9261076e565b51169161076e565b51905b8784899310600014610a8057505b853b156104805782908751947f80e507440000000000000000000000000000000000000000000000000000000086528660048701526024860152166044840152166064820152848160848183875af18015610a7657908591610a62575b5050813b15610a5e578291604485949285935195869384927fdd34ca3b0000000000000000000000000000000000000000000000000000000084526004840152600160248401525af1908115610a555750610a44575050565b610a4e82916106ce565b6101fc5750565b513d84823e3d90fd5b8380fd5b610a6b906106ce565b610a5e5783386109eb565b84513d87823e3d90fd5b91509061098e565b610a94610a9c926107aa565b5116916107aa565b5190610980565b5080610aae8361076e565b5116301415610964565b600488517f6d79d026000000000000000000000000000000000000000000000000000000008152fd5b506002811480610b07575b8015610954575083610afd836107aa565b5116301415610954565b5083610b128361076e565b5116301415610aec565b50505050908293923b1561041257906084859283855196879485937f80e50744000000000000000000000000000000000000000000000000000000008552600485015260248401528160448401528160648401525af1908115610a555750610b82575050565b610b8b906106ce565b50565b50600181148015610945575083610ba48361076e565b51163014610945565b9150503d8088833e610bbf818361072d565b81016060828203126104805781519067ffffffffffffffff91828111610c845783019181601f84011215610c84578251610bf881610816565b93610c058b51958661072d565b818552602091828087019160051b83010191858311610c80578301905b828210610c6457505050840151818111610c605782610c4291860161082e565b9389810151918211610c6057610c5992910161082e565b5038610939565b8a80fd5b81518981168103610c7c578152908301908301610c22565b8e80fd5b8d80fd5b8980fd5b86513d89823e3d90fd5b519069ffffffffffffffffffff8216820361088c57565b9073ffffffffffffffffffffffffffffffffffffffff9160a083825116604051918280927ffeaf968c00000000000000000000000000000000000000000000000000000000825260049384915afa948515610e78576000928396610eac575b506000831315610e845760208291855116604051928380927f313ce5670000000000000000000000000000000000000000000000000000000082525afa908115610e7857600091610e3c575b5060ff1660120360128111610e0e57604d8111610e0e57600a0a91828102928184041490151715610de057602082930151610d90575b50509190565b9080925015610db257506ec097ce7bc90715b34b9f1000000000043880610d8a565b6012907f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6011907f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6011827f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b6020813d8211610e70575b81610e546020938361072d565b8101031261056f57519060ff821682036101fc575060ff610d54565b3d9150610e47565b6040513d6000823e3d90fd5b506040517ebfc921000000000000000000000000000000000000000000000000000000008152fd5b9290955060a0833d8211610efa575b81610ec860a0938361072d565b810103126101fc5750610eda82610c92565b506020820151610ef1608060608501519401610c92565b50919438610d08565b3d9150610ebb565b7f000000000000000000000000000000000000000000000000000000000000000090610f2d82610816565b604090610f3c8251918261072d565b8381527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0610f6985610816565b016000805b82811061116f575050508093825190610f8682610711565b73ffffffffffffffffffffffffffffffffffffffff91827f00000000000000000000000000000000000000000000000000000000000000001681527f000000000000000000000000000000000000000000000000000000000000000015156020820152610ff28461076e565b52610ffc8361076e565b506001811161100c575b50505050565b835161101781610711565b827f00000000000000000000000000000000000000000000000000000000000000001681527f00000000000000000000000000000000000000000000000000000000000000001515602082015261106d846107aa565b52611077836107aa565b50600281111561100657600390845161108f81610711565b837f00000000000000000000000000000000000000000000000000000000000000001681527f0000000000000000000000000000000000000000000000000000000000000000151560208201526110e5856107ba565b526110ef846107ba565b50116110fc575b80611006565b61116692519061110b82610711565b7f00000000000000000000000000000000000000000000000000000000000000001681527f000000000000000000000000000000000000000000000000000000000000000015156020820152611160826107ca565b526107ca565b503880806110f6565b602090855161117d81610711565b838152828481830152828701015201610f6e565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff818309818302918280831092039180830391670de0b6b3a7640000958684101561121c57908691099214611216577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699350828211900360ee1b910360121c170290565b50500490565b604491604051917f5173648d00000000000000000000000000000000000000000000000000000000835260048301526024820152fdfea164736f6c6343000812000a000000000000000000000000bacee37d31b9f022ef5d232b9fd53f05a531c16900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b33000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000074b45532f5553440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000826492a24b1dbd1d8fcb4701b38c557ce685e9d0000000000000000000000000000000000000000000000000000000000000000","name":"ChainlinkRelayerV1","is_blueprint":false,"license_type":"none","is_fully_verified":false,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"paris","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud2x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Emitted when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport {\n    PRBMath_SD59x18_IntoSD1x18_Overflow,\n    PRBMath_SD59x18_IntoSD1x18_Underflow,\n    PRBMath_SD59x18_IntoUD2x18_Overflow,\n    PRBMath_SD59x18_IntoUD2x18_Underflow,\n    PRBMath_SD59x18_IntoUD60x18_Underflow,\n    PRBMath_SD59x18_IntoUint128_Overflow,\n    PRBMath_SD59x18_IntoUint128_Underflow,\n    PRBMath_SD59x18_IntoUint256_Underflow,\n    PRBMath_SD59x18_IntoUint40_Overflow,\n    PRBMath_SD59x18_IntoUint40_Underflow\n} from \"./Errors.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for the `unwrap` function.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n    result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < uMIN_SD1x18) {\n        revert PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n    }\n    if (xInt > uMAX_SD1x18) {\n        revert PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n    }\n    if (xInt > int256(uint256(uMAX_UD2x18))) {\n        revert PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n    }\n    result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n    }\n    result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint256_Underflow(x);\n    }\n    result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint128_Underflow(x);\n    }\n    if (xInt > int256(uint256(MAX_UINT128))) {\n        revert PRBMath_SD59x18_IntoUint128_Overflow(x);\n    }\n    result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint40_Underflow(x);\n    }\n    if (xInt > int256(uint256(MAX_UINT40))) {\n        revert PRBMath_SD59x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n    result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into the SD59x18 value type.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev log2(10) as an UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev log2(e) as an UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value an UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as an UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev Zero as an UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud2x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type uint64.\n/// This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD1x18, C.intoSD59x18, C.intoUD60x18, C.intoUint256, C.intoUint128, C.intoUint40, C.unwrap } for UD2x18 global;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\nimport \"./Helpers.sol\" as H;\nimport \"./Math.sol\" as M;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD1x18, C.intoUD2x18, C.intoSD59x18, C.intoUint128, C.intoUint256, C.intoUint40, C.unwrap } for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n    M.avg,\n    M.ceil,\n    M.div,\n    M.exp,\n    M.exp2,\n    M.floor,\n    M.frac,\n    M.gm,\n    M.inv,\n    M.ln,\n    M.log10,\n    M.log2,\n    M.mul,\n    M.pow,\n    M.powu,\n    M.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n    H.add,\n    H.and,\n    H.eq,\n    H.gt,\n    H.gte,\n    H.isZero,\n    H.lshift,\n    H.lt,\n    H.lte,\n    H.mod,\n    H.neq,\n    H.or,\n    H.rshift,\n    H.sub,\n    H.uncheckedAdd,\n    H.uncheckedSub,\n    H.xor\n} for UD60x18 global;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud2x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { PRBMath_UD2x18_IntoSD1x18_Overflow, PRBMath_UD2x18_IntoUint40_Overflow } from \"./Errors.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n    uint64 xUint = UD2x18.unwrap(x);\n    if (xUint > uint64(uMAX_SD1x18)) {\n        revert PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts an UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts an UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n    result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n    result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n    uint64 xUint = UD2x18.unwrap(x);\n    if (xUint > uint64(MAX_UINT40)) {\n        revert PRBMath_UD2x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(xUint);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n    result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap an UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n    result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps an uint64 number into the UD2x18 value type.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n    result = UD2x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Helpers.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) + unwrap(y));\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) & bits);\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) == unwrap(y);\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) > unwrap(y);\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) >= unwrap(y);\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n    // This wouldn't work if x could be negative.\n    result = unwrap(x) == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) < unwrap(y);\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) <= unwrap(y);\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) % unwrap(y));\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) != unwrap(y);\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) | unwrap(y));\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) - unwrap(y));\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) + unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) - unwrap(y));\n    }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) ^ unwrap(y));\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Conversions.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts an UD60x18 number to a simple integer by dividing it by `UNIT`. Rounds towards zero in the process.\n/// @dev Rounds down in the process.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18` divided by `UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n    if (x > uMAX_UD60x18 / uUNIT) {\n        revert PRBMath_UD60x18_Convert_Overflow(x);\n    }\n    unchecked {\n        result = UD60x18.wrap(x * uUNIT);\n    }\n}\n\n/// @notice Alias for the `convert` function defined above.\n/// @dev Here for backward compatibility. Will be removed in V4.\nfunction fromUD60x18(UD60x18 x) pure returns (uint256 result) {\n    result = convert(x);\n}\n\n/// @notice Alias for the `convert` function defined above.\n/// @dev Here for backward compatibility. Will be removed in V4.\nfunction toUD60x18(uint256 x) pure returns (UD60x18 result) {\n    result = convert(x);\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/Helpers.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    return wrap(unwrap(x) + unwrap(y));\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n    return wrap(unwrap(x) & bits);\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) == unwrap(y);\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) > unwrap(y);\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) >= unwrap(y);\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n    result = unwrap(x) == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) < unwrap(y);\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) <= unwrap(y);\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) % unwrap(y));\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) != unwrap(y);\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) | unwrap(y));\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) - unwrap(y));\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) + unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) - unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(-unwrap(x));\n    }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) ^ unwrap(y));\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud2x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as an UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev log2(10) as an UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev log2(e) as an UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value an UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as an UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev Zero as an UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Math.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { msb, mulDiv, mulDiv18, prbExp2, prbSqrt } from \"../Common.sol\";\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { uHALF_UNIT, uLOG2_10, uLOG2_E, uMAX_UD60x18, uMAX_WHOLE_UD60x18, UNIT, uUNIT, ZERO } from \"./Constants.sol\";\nimport {\n    PRBMath_UD60x18_Ceil_Overflow,\n    PRBMath_UD60x18_Exp_InputTooBig,\n    PRBMath_UD60x18_Exp2_InputTooBig,\n    PRBMath_UD60x18_Gm_Overflow,\n    PRBMath_UD60x18_Log_InputTooSmall,\n    PRBMath_UD60x18_Sqrt_Overflow\n} from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y, rounding down.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n//\n/// In English, what this formula does is:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @param x The first operand as an UD60x18 number.\n/// @param y The second operand as an UD60x18 number.\n/// @return result The arithmetic average as an UD60x18 number.\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n    unchecked {\n        result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n    }\n}\n\n/// @notice Yields the smallest whole UD60x18 number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are \"1e18 - 1\" fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The least number greater than or equal to x, as an UD60x18 number.\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    if (xUint > uMAX_WHOLE_UD60x18) {\n        revert PRBMath_UD60x18_Ceil_Overflow(x);\n    }\n\n    assembly (\"memory-safe\") {\n        // Equivalent to \"x % UNIT\" but faster.\n        let remainder := mod(x, uUNIT)\n\n        // Equivalent to \"UNIT - remainder\" but faster.\n        let delta := sub(uUNIT, remainder)\n\n        // Equivalent to \"x + delta * (remainder > 0 ? 1 : 0)\" but faster.\n        result := add(x, mul(delta, gt(remainder, 0)))\n    }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number. Rounds towards zero.\n///\n/// @dev Uses `mulDiv` to enable overflow-safe multiplication and division.\n///\n/// Requirements:\n/// - The denominator cannot be zero.\n///\n/// @param x The numerator as an UD60x18 number.\n/// @param y The denominator as an UD60x18 number.\n/// @param result The quotient as an UD60x18 number.\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(mulDiv(unwrap(x), uUNIT, unwrap(y)));\n}\n\n/// @notice Calculates the natural exponent of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n/// - x must be less than 133.084258667509499441.\n///\n/// @param x The exponent as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    // Without this check, the value passed to `exp2` would be greater than 192.\n    if (xUint >= 133_084258667509499441) {\n        revert PRBMath_UD60x18_Exp_InputTooBig(x);\n    }\n\n    unchecked {\n        // We do the fixed-point multiplication inline rather than via the `mul` function to save gas.\n        uint256 doubleUnitProduct = xUint * uLOG2_E;\n        result = exp2(wrap(doubleUnitProduct / uUNIT));\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Requirements:\n/// - x must be 192 or less.\n/// - The result must fit within `MAX_UD60x18`.\n///\n/// @param x The exponent as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    // Numbers greater than or equal to 2^192 don't fit within the 192.64-bit format.\n    if (xUint >= 192e18) {\n        revert PRBMath_UD60x18_Exp2_InputTooBig(x);\n    }\n\n    // Convert x to the 192.64-bit fixed-point format.\n    uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n    // Pass x to the `prbExp2` function, which uses the 192.64-bit fixed-point number representation.\n    result = wrap(prbExp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole UD60x18 number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest integer less than or equal to x, as an UD60x18 number.\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n    assembly (\"memory-safe\") {\n        // Equivalent to \"x % UNIT\" but faster.\n        let remainder := mod(x, uUNIT)\n\n        // Equivalent to \"x - remainder * (remainder > 0 ? 1 : 0)\" but faster.\n        result := sub(x, mul(remainder, gt(remainder, 0)))\n    }\n}\n\n/// @notice Yields the excess beyond the floor of x.\n/// @dev Based on the odd function definition https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as an UD60x18 number.\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n    assembly (\"memory-safe\") {\n        result := mod(x, uUNIT)\n    }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $$sqrt(x * y)$$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit within `MAX_UD60x18`, lest it overflows.\n///\n/// @param x The first operand as an UD60x18 number.\n/// @param y The second operand as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n    if (xUint == 0 || yUint == 0) {\n        return ZERO;\n    }\n\n    unchecked {\n        // Checking for overflow this way is faster than letting Solidity do it.\n        uint256 xyUint = xUint * yUint;\n        if (xyUint / xUint != yUint) {\n            revert PRBMath_UD60x18_Gm_Overflow(x, y);\n        }\n\n        // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT`\n        // during multiplication. See the comments in the `prbSqrt` function.\n        result = wrap(prbSqrt(xyUint));\n    }\n}\n\n/// @notice Calculates 1 / x, rounding toward zero.\n///\n/// @dev Requirements:\n/// - x cannot be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as an UD60x18 number.\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n    unchecked {\n        // 1e36 is UNIT * UNIT.\n        result = wrap(1e36 / unwrap(x));\n    }\n}\n\n/// @notice Calculates the natural logarithm of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}$$.\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n/// - This doesn't return exactly 1 for 2.718281828459045235, for that more fine-grained precision is needed.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an UD60x18 number.\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n    unchecked {\n        // We do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value\n        // that `log2` can return is 196.205294292027477728.\n        result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_E);\n    }\n}\n\n/// @notice Calculates the common logarithm of x.\n///\n/// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common\n/// logarithm based on the formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an UD60x18 number.\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    if (xUint < uUNIT) {\n        revert PRBMath_UD60x18_Log_InputTooSmall(x);\n    }\n\n    // Note that the `mul` in this assembly block is the assembly multiplication operation, not the UD60x18 `mul`.\n    // prettier-ignore\n    assembly (\"memory-safe\") {\n        switch x\n        case 1 { result := mul(uUNIT, sub(0, 18)) }\n        case 10 { result := mul(uUNIT, sub(1, 18)) }\n        case 100 { result := mul(uUNIT, sub(2, 18)) }\n        case 1000 { result := mul(uUNIT, sub(3, 18)) }\n        case 10000 { result := mul(uUNIT, sub(4, 18)) }\n        case 100000 { result := mul(uUNIT, sub(5, 18)) }\n        case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n        case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n        case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n        case 1000000000000000000 { result := 0 }\n        case 10000000000000000000 { result := uUNIT }\n        case 100000000000000000000 { result := mul(uUNIT, 2) }\n        case 1000000000000000000000 { result := mul(uUNIT, 3) }\n        case 10000000000000000000000 { result := mul(uUNIT, 4) }\n        case 100000000000000000000000 { result := mul(uUNIT, 5) }\n        case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n        case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n        case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n        default {\n            result := uMAX_UD60x18\n        }\n    }\n\n    if (unwrap(result) == uMAX_UD60x18) {\n        unchecked {\n            // Do the fixed-point division inline to save gas.\n            result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_10);\n        }\n    }\n}\n\n/// @notice Calculates the binary logarithm of x.\n///\n/// @dev Based on the iterative approximation algorithm.\n/// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Requirements:\n/// - x must be greater than or equal to UNIT, otherwise the result would be negative.\n///\n/// Caveats:\n/// - The results are nor perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an UD60x18 number.\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    if (xUint < uUNIT) {\n        revert PRBMath_UD60x18_Log_InputTooSmall(x);\n    }\n\n    unchecked {\n        // Calculate the integer part of the logarithm, add it to the result and finally calculate y = x * 2^(-n).\n        uint256 n = msb(xUint / uUNIT);\n\n        // This is the integer part of the logarithm as an UD60x18 number. The operation can't overflow because n\n        // n is maximum 255 and UNIT is 1e18.\n        uint256 resultUint = n * uUNIT;\n\n        // This is $y = x * 2^{-n}$.\n        uint256 y = xUint >> n;\n\n        // If y is 1, the fractional part is zero.\n        if (y == uUNIT) {\n            return wrap(resultUint);\n        }\n\n        // Calculate the fractional part via the iterative approximation.\n        // The \"delta.rshift(1)\" part is equivalent to \"delta /= 2\", but shifting bits is faster.\n        uint256 DOUBLE_UNIT = 2e18;\n        for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n            y = (y * y) / uUNIT;\n\n            // Is y^2 > 2 and so in the range [2,4)?\n            if (y >= DOUBLE_UNIT) {\n                // Add the 2^{-m} factor to the logarithm.\n                resultUint += delta;\n\n                // Corresponds to z/2 on Wikipedia.\n                y >>= 1;\n            }\n        }\n        result = wrap(resultUint);\n    }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n/// @dev See the documentation for the `Common.mulDiv18` function.\n/// @param x The multiplicand as an UD60x18 number.\n/// @param y The multiplier as an UD60x18 number.\n/// @return result The product as an UD60x18 number.\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(mulDiv18(unwrap(x), unwrap(y)));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// Requirements:\n/// - All from `exp2`, `log2` and `mul`.\n///\n/// Caveats:\n/// - All from `exp2`, `log2` and `mul`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x Number to raise to given power y, as an UD60x18 number.\n/// @param y Exponent to raise x to, as an UD60x18 number.\n/// @return result x raised to power y, as an UD60x18 number.\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n\n    if (xUint == 0) {\n        result = yUint == 0 ? UNIT : ZERO;\n    } else {\n        if (yUint == uUNIT) {\n            result = x;\n        } else {\n            result = exp2(mul(log2(x), y));\n        }\n    }\n}\n\n/// @notice Raises x (an UD60x18 number) to the power y (unsigned basic integer) using the famous algorithm\n/// \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n///\n/// Requirements:\n/// - The result must fit within `MAX_UD60x18`.\n///\n/// Caveats:\n/// - All from \"Common.mulDiv18\".\n/// - Assumes 0^0 is 1.\n///\n/// @param x The base as an UD60x18 number.\n/// @param y The exponent as an uint256.\n/// @return result The result as an UD60x18 number.\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n    // Calculate the first iteration of the loop in advance.\n    uint256 xUint = unwrap(x);\n    uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n    // Equivalent to \"for(y /= 2; y > 0; y /= 2)\" but faster.\n    for (y >>= 1; y > 0; y >>= 1) {\n        xUint = mulDiv18(xUint, xUint);\n\n        // Equivalent to \"y % 2 == 1\" but faster.\n        if (y & 1 > 0) {\n            resultUint = mulDiv18(resultUint, xUint);\n        }\n    }\n    result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x, rounding down.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18` divided by `UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as an UD60x18 number.\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    unchecked {\n        if (xUint > uMAX_UD60x18 / uUNIT) {\n            revert PRBMath_UD60x18_Sqrt_Overflow(x);\n        }\n        // Multiply x by `UNIT` to account for the factor of `UNIT` that is picked up when multiplying two UD60x18\n        // numbers together (in this case, the two numbers are both the square root).\n        result = wrap(prbSqrt(xUint * uUNIT));\n    }\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/Common.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\n/// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n/// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n                                CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Emitted when the ending result in the fixed-point version of `mulDiv` would overflow uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Emitted when the ending result in `mulDiv` would overflow uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Emitted when attempting to run `mulDiv` with one of the inputs `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Emitted when the ending result in the signed version of `mulDiv` would overflow int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value an uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value an uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev How many trailing decimals can be represented.\nuint256 constant UNIT = 1e18;\n\n/// @dev Largest power of two that is a divisor of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/// @dev The `UNIT` number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Finds the zero-based index of the first one in the binary representation of x.\n/// @dev See the note on msb in the \"Find First Set\" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each of the steps in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n///     x >>= 128;\n///     result += 128;\n/// }\n/// ```\n///\n/// Where 128 is swapped with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// A list of the Yul instructions used below:\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as an uint256.\nfunction msb(uint256 x) pure returns (uint256 result) {\n    // 2^128\n    assembly (\"memory-safe\") {\n        let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^64\n    assembly (\"memory-safe\") {\n        let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^32\n    assembly (\"memory-safe\") {\n        let factor := shl(5, gt(x, 0xFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^16\n    assembly (\"memory-safe\") {\n        let factor := shl(4, gt(x, 0xFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^8\n    assembly (\"memory-safe\") {\n        let factor := shl(3, gt(x, 0xFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^4\n    assembly (\"memory-safe\") {\n        let factor := shl(2, gt(x, 0xF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^2\n    assembly (\"memory-safe\") {\n        let factor := shl(1, gt(x, 0x3))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^1\n    // No need to shift x any more.\n    assembly (\"memory-safe\") {\n        let factor := gt(x, 0x1)\n        result := or(result, factor)\n    }\n}\n\n/// @notice Calculates floor(x*y÷denominator) with full precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Requirements:\n/// - The denominator cannot be zero.\n/// - The result must fit within uint256.\n///\n/// Caveats:\n/// - This function does not work with fixed-point numbers.\n///\n/// @param x The multiplicand as an uint256.\n/// @param y The multiplier as an uint256.\n/// @param denominator The divisor as an uint256.\n/// @return result The result as an uint256.\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\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 (\"memory-safe\") {\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        unchecked {\n            return prod0 / denominator;\n        }\n    }\n\n    // Make sure the result is less than 2^256. Also prevents denominator == 0.\n    if (prod1 >= denominator) {\n        revert PRBMath_MulDiv_Overflow(x, y, denominator);\n    }\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 (\"memory-safe\") {\n        // Compute remainder using the mulmod Yul instruction.\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    unchecked {\n        // Does not overflow because the denominator cannot be zero at this stage in the function.\n        uint256 lpotdod = denominator & (~denominator + 1);\n        assembly (\"memory-safe\") {\n            // Divide denominator by lpotdod.\n            denominator := div(denominator, lpotdod)\n\n            // Divide [prod1 prod0] by lpotdod.\n            prod0 := div(prod0, lpotdod)\n\n            // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one.\n            lpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n        }\n\n        // Shift in bits from prod1 into prod0.\n        prod0 |= prod1 * lpotdod;\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    }\n}\n\n/// @notice Calculates floor(x*y÷1e18) with full precision.\n///\n/// @dev Variant of `mulDiv` with constant folding, i.e. in which the denominator is always 1e18. Before returning the\n/// final result, we add 1 if `(x * y) % UNIT >= HALF_UNIT`. Without this adjustment, 6.6e-19 would be truncated to 0\n/// instead of being rounded to 1e-18. See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717.\n///\n/// Requirements:\n/// - The result must fit within uint256.\n///\n/// Caveats:\n/// - The body is purposely left uncommented; to understand how this works, see the NatSpec comments in `mulDiv`.\n/// - It is assumed that the result can never be `type(uint256).max` when x and y solve the following two equations:\n///     1. x * y = type(uint256).max * UNIT\n///     2. (x * y) % UNIT >= UNIT / 2\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n    uint256 prod0;\n    uint256 prod1;\n    assembly (\"memory-safe\") {\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    if (prod1 >= UNIT) {\n        revert PRBMath_MulDiv18_Overflow(x, y);\n    }\n\n    uint256 remainder;\n    assembly (\"memory-safe\") {\n        remainder := mulmod(x, y, UNIT)\n    }\n\n    if (prod1 == 0) {\n        unchecked {\n            return prod0 / UNIT;\n        }\n    }\n\n    assembly (\"memory-safe\") {\n        result := mul(\n            or(\n                div(sub(prod0, remainder), UNIT_LPOTD),\n                mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n            ),\n            UNIT_INVERSE\n        )\n    }\n}\n\n/// @notice Calculates floor(x*y÷denominator) with full precision.\n///\n/// @dev An extension of `mulDiv` for signed numbers. Works by computing the signs and the absolute values separately.\n///\n/// Requirements:\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit within int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n    if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n        revert PRBMath_MulDivSigned_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x, y and the denominator.\n    uint256 absX;\n    uint256 absY;\n    uint256 absD;\n    unchecked {\n        absX = x < 0 ? uint256(-x) : uint256(x);\n        absY = y < 0 ? uint256(-y) : uint256(y);\n        absD = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n    }\n\n    // Compute the absolute value of (x*y)÷denominator. The result must fit within int256.\n    uint256 rAbs = mulDiv(absX, absY, absD);\n    if (rAbs > uint256(type(int256).max)) {\n        revert PRBMath_MulDivSigned_Overflow(x, y);\n    }\n\n    // Get the signs of x, y and the denominator.\n    uint256 sx;\n    uint256 sy;\n    uint256 sd;\n    assembly (\"memory-safe\") {\n        // This works thanks to two's complement.\n        // \"sgt\" stands for \"signed greater than\" and \"sub(0,1)\" is max uint256.\n        sx := sgt(x, sub(0, 1))\n        sy := sgt(y, sub(0, 1))\n        sd := sgt(denominator, sub(0, 1))\n    }\n\n    // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n    // If there are, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers.\n/// See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\nfunction prbExp2(uint256 x) pure returns (uint256 result) {\n    unchecked {\n        // Start from 0.5 in the 192.64-bit fixed-point format.\n        result = 0x800000000000000000000000000000000000000000000000;\n\n        // Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows\n        // because the initial result is 2^191 and all magic factors are less than 2^65.\n        if (x & 0xFF00000000000000 > 0) {\n            if (x & 0x8000000000000000 > 0) {\n                result = (result * 0x16A09E667F3BCC909) >> 64;\n            }\n            if (x & 0x4000000000000000 > 0) {\n                result = (result * 0x1306FE0A31B7152DF) >> 64;\n            }\n            if (x & 0x2000000000000000 > 0) {\n                result = (result * 0x1172B83C7D517ADCE) >> 64;\n            }\n            if (x & 0x1000000000000000 > 0) {\n                result = (result * 0x10B5586CF9890F62A) >> 64;\n            }\n            if (x & 0x800000000000000 > 0) {\n                result = (result * 0x1059B0D31585743AE) >> 64;\n            }\n            if (x & 0x400000000000000 > 0) {\n                result = (result * 0x102C9A3E778060EE7) >> 64;\n            }\n            if (x & 0x200000000000000 > 0) {\n                result = (result * 0x10163DA9FB33356D8) >> 64;\n            }\n            if (x & 0x100000000000000 > 0) {\n                result = (result * 0x100B1AFA5ABCBED61) >> 64;\n            }\n        }\n\n        if (x & 0xFF000000000000 > 0) {\n            if (x & 0x80000000000000 > 0) {\n                result = (result * 0x10058C86DA1C09EA2) >> 64;\n            }\n            if (x & 0x40000000000000 > 0) {\n                result = (result * 0x1002C605E2E8CEC50) >> 64;\n            }\n            if (x & 0x20000000000000 > 0) {\n                result = (result * 0x100162F3904051FA1) >> 64;\n            }\n            if (x & 0x10000000000000 > 0) {\n                result = (result * 0x1000B175EFFDC76BA) >> 64;\n            }\n            if (x & 0x8000000000000 > 0) {\n                result = (result * 0x100058BA01FB9F96D) >> 64;\n            }\n            if (x & 0x4000000000000 > 0) {\n                result = (result * 0x10002C5CC37DA9492) >> 64;\n            }\n            if (x & 0x2000000000000 > 0) {\n                result = (result * 0x1000162E525EE0547) >> 64;\n            }\n            if (x & 0x1000000000000 > 0) {\n                result = (result * 0x10000B17255775C04) >> 64;\n            }\n        }\n\n        if (x & 0xFF0000000000 > 0) {\n            if (x & 0x800000000000 > 0) {\n                result = (result * 0x1000058B91B5BC9AE) >> 64;\n            }\n            if (x & 0x400000000000 > 0) {\n                result = (result * 0x100002C5C89D5EC6D) >> 64;\n            }\n            if (x & 0x200000000000 > 0) {\n                result = (result * 0x10000162E43F4F831) >> 64;\n            }\n            if (x & 0x100000000000 > 0) {\n                result = (result * 0x100000B1721BCFC9A) >> 64;\n            }\n            if (x & 0x80000000000 > 0) {\n                result = (result * 0x10000058B90CF1E6E) >> 64;\n            }\n            if (x & 0x40000000000 > 0) {\n                result = (result * 0x1000002C5C863B73F) >> 64;\n            }\n            if (x & 0x20000000000 > 0) {\n                result = (result * 0x100000162E430E5A2) >> 64;\n            }\n            if (x & 0x10000000000 > 0) {\n                result = (result * 0x1000000B172183551) >> 64;\n            }\n        }\n\n        if (x & 0xFF00000000 > 0) {\n            if (x & 0x8000000000 > 0) {\n                result = (result * 0x100000058B90C0B49) >> 64;\n            }\n            if (x & 0x4000000000 > 0) {\n                result = (result * 0x10000002C5C8601CC) >> 64;\n            }\n            if (x & 0x2000000000 > 0) {\n                result = (result * 0x1000000162E42FFF0) >> 64;\n            }\n            if (x & 0x1000000000 > 0) {\n                result = (result * 0x10000000B17217FBB) >> 64;\n            }\n            if (x & 0x800000000 > 0) {\n                result = (result * 0x1000000058B90BFCE) >> 64;\n            }\n            if (x & 0x400000000 > 0) {\n                result = (result * 0x100000002C5C85FE3) >> 64;\n            }\n            if (x & 0x200000000 > 0) {\n                result = (result * 0x10000000162E42FF1) >> 64;\n            }\n            if (x & 0x100000000 > 0) {\n                result = (result * 0x100000000B17217F8) >> 64;\n            }\n        }\n\n        if (x & 0xFF00000000 > 0) {\n            if (x & 0x80000000 > 0) {\n                result = (result * 0x10000000058B90BFC) >> 64;\n            }\n            if (x & 0x40000000 > 0) {\n                result = (result * 0x1000000002C5C85FE) >> 64;\n            }\n            if (x & 0x20000000 > 0) {\n                result = (result * 0x100000000162E42FF) >> 64;\n            }\n            if (x & 0x10000000 > 0) {\n                result = (result * 0x1000000000B17217F) >> 64;\n            }\n            if (x & 0x8000000 > 0) {\n                result = (result * 0x100000000058B90C0) >> 64;\n            }\n            if (x & 0x4000000 > 0) {\n                result = (result * 0x10000000002C5C860) >> 64;\n            }\n            if (x & 0x2000000 > 0) {\n                result = (result * 0x1000000000162E430) >> 64;\n            }\n            if (x & 0x1000000 > 0) {\n                result = (result * 0x10000000000B17218) >> 64;\n            }\n        }\n\n        if (x & 0xFF0000 > 0) {\n            if (x & 0x800000 > 0) {\n                result = (result * 0x1000000000058B90C) >> 64;\n            }\n            if (x & 0x400000 > 0) {\n                result = (result * 0x100000000002C5C86) >> 64;\n            }\n            if (x & 0x200000 > 0) {\n                result = (result * 0x10000000000162E43) >> 64;\n            }\n            if (x & 0x100000 > 0) {\n                result = (result * 0x100000000000B1721) >> 64;\n            }\n            if (x & 0x80000 > 0) {\n                result = (result * 0x10000000000058B91) >> 64;\n            }\n            if (x & 0x40000 > 0) {\n                result = (result * 0x1000000000002C5C8) >> 64;\n            }\n            if (x & 0x20000 > 0) {\n                result = (result * 0x100000000000162E4) >> 64;\n            }\n            if (x & 0x10000 > 0) {\n                result = (result * 0x1000000000000B172) >> 64;\n            }\n        }\n\n        if (x & 0xFF00 > 0) {\n            if (x & 0x8000 > 0) {\n                result = (result * 0x100000000000058B9) >> 64;\n            }\n            if (x & 0x4000 > 0) {\n                result = (result * 0x10000000000002C5D) >> 64;\n            }\n            if (x & 0x2000 > 0) {\n                result = (result * 0x1000000000000162E) >> 64;\n            }\n            if (x & 0x1000 > 0) {\n                result = (result * 0x10000000000000B17) >> 64;\n            }\n            if (x & 0x800 > 0) {\n                result = (result * 0x1000000000000058C) >> 64;\n            }\n            if (x & 0x400 > 0) {\n                result = (result * 0x100000000000002C6) >> 64;\n            }\n            if (x & 0x200 > 0) {\n                result = (result * 0x10000000000000163) >> 64;\n            }\n            if (x & 0x100 > 0) {\n                result = (result * 0x100000000000000B1) >> 64;\n            }\n        }\n\n        if (x & 0xFF > 0) {\n            if (x & 0x80 > 0) {\n                result = (result * 0x10000000000000059) >> 64;\n            }\n            if (x & 0x40 > 0) {\n                result = (result * 0x1000000000000002C) >> 64;\n            }\n            if (x & 0x20 > 0) {\n                result = (result * 0x10000000000000016) >> 64;\n            }\n            if (x & 0x10 > 0) {\n                result = (result * 0x1000000000000000B) >> 64;\n            }\n            if (x & 0x8 > 0) {\n                result = (result * 0x10000000000000006) >> 64;\n            }\n            if (x & 0x4 > 0) {\n                result = (result * 0x10000000000000003) >> 64;\n            }\n            if (x & 0x2 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n            if (x & 0x1 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n        }\n\n        // We're doing two things at the same time:\n        //\n        //   1. Multiply the result by 2^n + 1, where \"2^n\" is the integer part and the one is added to account for\n        //      the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191\n        //      rather than 192.\n        //   2. Convert the result to the unsigned 60.18-decimal fixed-point format.\n        //\n        // This works because 2^(191-ip) = 2^ip / 2^191, where \"ip\" is the integer part \"2^n\".\n        result *= UNIT;\n        result >>= (191 - (x >> 64));\n    }\n}\n\n/// @notice Calculates the square root of x, rounding down if x is not a perfect square.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n/// Credits to OpenZeppelin for the explanations in code comments below.\n///\n/// Caveats:\n/// - This function does not work with fixed-point numbers.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as an uint256.\nfunction prbSqrt(uint256 x) pure returns (uint256 result) {\n    if (x == 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 x.\n    //\n    // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n    //\n    // $$\n    // msb(x) <= x <= 2*msb(x)$\n    // $$\n    //\n    // We write $msb(x)$ as $2^k$ and we get:\n    //\n    // $$\n    // k = log_2(x)\n    // $$\n    //\n    // Thus we can write the initial inequality as:\n    //\n    // $$\n    // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n    // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n    // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n    // $$\n    //\n    // Consequently, $2^{log_2(x) /2}` is a good first approximation of sqrt(x) with at least one correct bit.\n    uint256 xAux = uint256(x);\n    result = 1;\n    if (xAux >= 2 ** 128) {\n        xAux >>= 128;\n        result <<= 64;\n    }\n    if (xAux >= 2 ** 64) {\n        xAux >>= 64;\n        result <<= 32;\n    }\n    if (xAux >= 2 ** 32) {\n        xAux >>= 32;\n        result <<= 16;\n    }\n    if (xAux >= 2 ** 16) {\n        xAux >>= 16;\n        result <<= 8;\n    }\n    if (xAux >= 2 ** 8) {\n        xAux >>= 8;\n        result <<= 4;\n    }\n    if (xAux >= 2 ** 4) {\n        xAux >>= 4;\n        result <<= 2;\n    }\n    if (xAux >= 2 ** 2) {\n        result <<= 1;\n    }\n\n    // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n    // most 128 bits, since  it is the square root of a uint256. Newton's method converges quadratically (precision\n    // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n    // precision into the expected uint128 result.\n    unchecked {\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n\n        // Round down the result in case x is not a perfect square.\n        uint256 roundedDownResult = x / result;\n        if (result >= roundedDownResult) {\n            result = roundedDownResult;\n        }\n    }\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev log2(10) as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev log2(e) as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud2x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { PRBMath_UD2x18_IntoSD1x18_Overflow, PRBMath_UD2x18_IntoUint40_Overflow } from \"./Errors.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n    uint64 xUint = UD2x18.unwrap(x);\n    if (xUint > uint64(uMAX_SD1x18)) {\n        revert PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts an UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts an UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n    result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n    result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts an UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n    uint64 xUint = UD2x18.unwrap(x);\n    if (xUint > uint64(MAX_UINT40)) {\n        revert PRBMath_UD2x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(xUint);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n    result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap an UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n    result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps an uint64 number into the UD2x18 value type.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n    result = UD2x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd1x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Emitted when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Emitted when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Emitted when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when taking the natural exponent of a base greater than 133.084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Emitted when taking the binary exponent of a base greater than 192.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Emitted when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Emitted when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Emitted when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Emitted when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Emitted when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when raising a number to a power and hte intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Emitted when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Emitted when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/Math.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40, msb, mulDiv, mulDiv18, prbExp2, prbSqrt } from \"../Common.sol\";\nimport {\n    uHALF_UNIT,\n    uLOG2_10,\n    uLOG2_E,\n    uMAX_SD59x18,\n    uMAX_WHOLE_SD59x18,\n    uMIN_SD59x18,\n    uMIN_WHOLE_SD59x18,\n    UNIT,\n    uUNIT,\n    ZERO\n} from \"./Constants.sol\";\nimport {\n    PRBMath_SD59x18_Abs_MinSD59x18,\n    PRBMath_SD59x18_Ceil_Overflow,\n    PRBMath_SD59x18_Div_InputTooSmall,\n    PRBMath_SD59x18_Div_Overflow,\n    PRBMath_SD59x18_Exp_InputTooBig,\n    PRBMath_SD59x18_Exp2_InputTooBig,\n    PRBMath_SD59x18_Floor_Underflow,\n    PRBMath_SD59x18_Gm_Overflow,\n    PRBMath_SD59x18_Gm_NegativeProduct,\n    PRBMath_SD59x18_Log_InputTooSmall,\n    PRBMath_SD59x18_Mul_InputTooSmall,\n    PRBMath_SD59x18_Mul_Overflow,\n    PRBMath_SD59x18_Powu_Overflow,\n    PRBMath_SD59x18_Sqrt_NegativeInput,\n    PRBMath_SD59x18_Sqrt_Overflow\n} from \"./Errors.sol\";\nimport { unwrap, wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculate the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Abs_MinSD59x18();\n    }\n    result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y, rounding towards zero.\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n\n    unchecked {\n        // This is equivalent to \"x / 2 +  y / 2\" but faster.\n        // This operation can never overflow.\n        int256 sum = (xInt >> 1) + (yInt >> 1);\n\n        if (sum < 0) {\n            // If at least one of x and y is odd, we add 1 to the result, since shifting negative numbers to the right rounds\n            // down to infinity. The right part is equivalent to \"sum + (x % 2 == 1 || y % 2 == 1)\" but faster.\n            assembly (\"memory-safe\") {\n                result := add(sum, and(or(xInt, yInt), 1))\n            }\n        } else {\n            // We need to add 1 if both x and y are odd to account for the double 0.5 remainder that is truncated after shifting.\n            result = wrap(sum + (xInt & yInt & 1));\n        }\n    }\n}\n\n/// @notice Yields the smallest whole SD59x18 number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The least number greater than or equal to x, as an SD59x18 number.\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt > uMAX_WHOLE_SD59x18) {\n        revert PRBMath_SD59x18_Ceil_Overflow(x);\n    }\n\n    int256 remainder = xInt % uUNIT;\n    if (remainder == 0) {\n        result = x;\n    } else {\n        unchecked {\n            // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n            int256 resultInt = xInt - remainder;\n            if (xInt > 0) {\n                resultInt += uUNIT;\n            }\n            result = wrap(resultInt);\n        }\n    }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number. Rounds towards zero.\n///\n/// @dev This is a variant of `mulDiv` that works with signed numbers. Works by computing the signs and the absolute values\n/// separately.\n///\n/// Requirements:\n/// - All from `Common.mulDiv`.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator cannot be zero.\n/// - The result must fit within int256.\n///\n/// Caveats:\n/// - All from `Common.mulDiv`.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Div_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x and y.\n    uint256 xAbs;\n    uint256 yAbs;\n    unchecked {\n        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n    }\n\n    // Compute the absolute value (x*UNIT)÷y. The resulting value must fit within int256.\n    uint256 resultAbs = mulDiv(xAbs, uint256(uUNIT), yAbs);\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Div_Overflow(x, y);\n    }\n\n    // Check if x and y have the same sign. This works thanks to two's complement; the left-most bit is the sign bit.\n    bool sameSign = (xInt ^ yInt) > -1;\n\n    // If the inputs don't have the same sign, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n    }\n}\n\n/// @notice Calculates the natural exponent of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n/// - x must be less than 133.084258667509499441.\n///\n/// Caveats:\n/// - All from `exp2`.\n/// - For any x less than -41.446531673892822322, the result is zero.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    // Without this check, the value passed to `exp2` would be less than -59.794705707972522261.\n    if (xInt < -41_446531673892822322) {\n        return ZERO;\n    }\n\n    // Without this check, the value passed to `exp2` would be greater than 192.\n    if (xInt >= 133_084258667509499441) {\n        revert PRBMath_SD59x18_Exp_InputTooBig(x);\n    }\n\n    unchecked {\n        // Do the fixed-point multiplication inline to save gas.\n        int256 doubleUnitProduct = xInt * uLOG2_E;\n        result = exp2(wrap(doubleUnitProduct / uUNIT));\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Requirements:\n/// - x must be 192 or less.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - For any x less than -59.794705707972522261, the result is zero.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        // 2^59.794705707972522262 is the maximum number whose inverse does not truncate down to zero.\n        if (xInt < -59_794705707972522261) {\n            return ZERO;\n        }\n\n        unchecked {\n            // Do the fixed-point inversion $1/2^x$ inline to save gas. 1e36 is UNIT * UNIT.\n            result = wrap(1e36 / unwrap(exp2(wrap(-xInt))));\n        }\n    } else {\n        // 2^192 doesn't fit within the 192.64-bit format used internally in this function.\n        if (xInt >= 192e18) {\n            revert PRBMath_SD59x18_Exp2_InputTooBig(x);\n        }\n\n        unchecked {\n            // Convert x to the 192.64-bit fixed-point format.\n            uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n            // It is safe to convert the result to int256 with no checks because the maximum input allowed in this function is 192.\n            result = wrap(int256(prbExp2(x_192x64)));\n        }\n    }\n}\n\n/// @notice Yields the greatest whole SD59x18 number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest integer less than or equal to x, as an SD59x18 number.\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < uMIN_WHOLE_SD59x18) {\n        revert PRBMath_SD59x18_Floor_Underflow(x);\n    }\n\n    int256 remainder = xInt % uUNIT;\n    if (remainder == 0) {\n        result = x;\n    } else {\n        unchecked {\n            // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n            int256 resultInt = xInt - remainder;\n            if (xInt < 0) {\n                resultInt -= uUNIT;\n            }\n            result = wrap(resultInt);\n        }\n    }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. sqrt(x * y), rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit within `MAX_SD59x18`, lest it overflows.\n/// - x * y must not be negative, since this library does not handle complex numbers.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == 0 || yInt == 0) {\n        return ZERO;\n    }\n\n    unchecked {\n        // Equivalent to \"xy / x != y\". Checking for overflow this way is faster than letting Solidity do it.\n        int256 xyInt = xInt * yInt;\n        if (xyInt / xInt != yInt) {\n            revert PRBMath_SD59x18_Gm_Overflow(x, y);\n        }\n\n        // The product must not be negative, since this library does not handle complex numbers.\n        if (xyInt < 0) {\n            revert PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n        }\n\n        // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT`\n        // during multiplication. See the comments within the `prbSqrt` function.\n        uint256 resultUint = prbSqrt(uint256(xyInt));\n        result = wrap(int256(resultUint));\n    }\n}\n\n/// @notice Calculates 1 / x, rounding toward zero.\n///\n/// @dev Requirements:\n/// - x cannot be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n    // 1e36 is UNIT * UNIT.\n    result = wrap(1e36 / unwrap(x));\n}\n\n/// @notice Calculates the natural logarithm of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}$$.\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n/// - This doesn't return exactly 1 for 2.718281828459045235, for that more fine-grained precision is needed.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n    // Do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value that log2(x)\n    // can return is 195.205294292027477728.\n    result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x.\n///\n/// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common\n/// logarithm based on the formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_Log_InputTooSmall(x);\n    }\n\n    // Note that the `mul` in this block is the assembly mul operation, not the SD59x18 `mul`.\n    // prettier-ignore\n    assembly (\"memory-safe\") {\n        switch x\n        case 1 { result := mul(uUNIT, sub(0, 18)) }\n        case 10 { result := mul(uUNIT, sub(1, 18)) }\n        case 100 { result := mul(uUNIT, sub(2, 18)) }\n        case 1000 { result := mul(uUNIT, sub(3, 18)) }\n        case 10000 { result := mul(uUNIT, sub(4, 18)) }\n        case 100000 { result := mul(uUNIT, sub(5, 18)) }\n        case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n        case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n        case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n        case 1000000000000000000 { result := 0 }\n        case 10000000000000000000 { result := uUNIT }\n        case 100000000000000000000 { result := mul(uUNIT, 2) }\n        case 1000000000000000000000 { result := mul(uUNIT, 3) }\n        case 10000000000000000000000 { result := mul(uUNIT, 4) }\n        case 100000000000000000000000 { result := mul(uUNIT, 5) }\n        case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n        case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n        case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n        default {\n            result := uMAX_SD59x18\n        }\n    }\n\n    if (unwrap(result) == uMAX_SD59x18) {\n        unchecked {\n            // Do the fixed-point division inline to save gas.\n            result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_10);\n        }\n    }\n}\n\n/// @notice Calculates the binary logarithm of x.\n///\n/// @dev Based on the iterative approximation algorithm.\n/// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// Caveats:\n/// - The results are not perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt <= 0) {\n        revert PRBMath_SD59x18_Log_InputTooSmall(x);\n    }\n\n    unchecked {\n        // This works because of:\n        //\n        // $$\n        // log_2{x} = -log_2{\\frac{1}{x}}\n        // $$\n        int256 sign;\n        if (xInt >= uUNIT) {\n            sign = 1;\n        } else {\n            sign = -1;\n            // Do the fixed-point inversion inline to save gas. The numerator is UNIT * UNIT.\n            xInt = 1e36 / xInt;\n        }\n\n        // Calculate the integer part of the logarithm and add it to the result and finally calculate $y = x * 2^(-n)$.\n        uint256 n = msb(uint256(xInt / uUNIT));\n\n        // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n        // because n is maximum 255, UNIT is 1e18 and sign is either 1 or -1.\n        int256 resultInt = int256(n) * uUNIT;\n\n        // This is $y = x * 2^{-n}$.\n        int256 y = xInt >> n;\n\n        // If y is 1, the fractional part is zero.\n        if (y == uUNIT) {\n            return wrap(resultInt * sign);\n        }\n\n        // Calculate the fractional part via the iterative approximation.\n        // The \"delta >>= 1\" part is equivalent to \"delta /= 2\", but shifting bits is faster.\n        int256 DOUBLE_UNIT = 2e18;\n        for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n            y = (y * y) / uUNIT;\n\n            // Is $y^2 > 2$ and so in the range [2,4)?\n            if (y >= DOUBLE_UNIT) {\n                // Add the 2^{-m} factor to the logarithm.\n                resultInt = resultInt + delta;\n\n                // Corresponds to z/2 on Wikipedia.\n                y >>= 1;\n            }\n        }\n        resultInt *= sign;\n        result = wrap(resultInt);\n    }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev This is a variant of `mulDiv` that works with signed numbers and employs constant folding, i.e. the denominator\n/// is always 1e18.\n///\n/// Requirements:\n/// - All from `Common.mulDiv18`.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - To understand how this works in detail, see the NatSpec comments in `Common.mulDivSigned`.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Mul_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x and y.\n    uint256 xAbs;\n    uint256 yAbs;\n    unchecked {\n        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n    }\n\n    uint256 resultAbs = mulDiv18(xAbs, yAbs);\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Mul_Overflow(x, y);\n    }\n\n    // Check if x and y have the same sign. This works thanks to two's complement; the left-most bit is the sign bit.\n    bool sameSign = (xInt ^ yInt) > -1;\n\n    // If the inputs have the same sign, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n    }\n}\n\n/// @notice Raises x to the power of y.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// Requirements:\n/// - All from `exp2`, `log2` and `mul`.\n/// - x cannot be zero.\n///\n/// Caveats:\n/// - All from `exp2`, `log2` and `mul`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x Number to raise to given power y, as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n\n    if (xInt == 0) {\n        result = yInt == 0 ? UNIT : ZERO;\n    } else {\n        if (yInt == uUNIT) {\n            result = x;\n        } else {\n            result = exp2(mul(log2(x), y));\n        }\n    }\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (unsigned basic integer) using the famous algorithm\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n///\n/// Requirements:\n/// - All from `abs` and `Common.mulDiv18`.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - All from `Common.mulDiv18`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as an uint256.\n/// @return result The result as an SD59x18 number.\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n    uint256 xAbs = uint256(unwrap(abs(x)));\n\n    // Calculate the first iteration of the loop in advance.\n    uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n    // Equivalent to \"for(y /= 2; y > 0; y /= 2)\" but faster.\n    uint256 yAux = y;\n    for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n        xAbs = mulDiv18(xAbs, xAbs);\n\n        // Equivalent to \"y % 2 == 1\" but faster.\n        if (yAux & 1 > 0) {\n            resultAbs = mulDiv18(resultAbs, xAbs);\n        }\n    }\n\n    // The result must fit within `MAX_SD59x18`.\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Powu_Overflow(x, y);\n    }\n\n    unchecked {\n        // Is the base negative and the exponent an odd number?\n        int256 resultInt = int256(resultAbs);\n        bool isNegative = unwrap(x) < 0 && y & 1 == 1;\n        if (isNegative) {\n            resultInt = -resultInt;\n        }\n        result = wrap(resultInt);\n    }\n}\n\n/// @notice Calculates the square root of x, rounding down. Only the positive root is returned.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Requirements:\n/// - x cannot be negative, since this library does not handle complex numbers.\n/// - x must be less than `MAX_SD59x18` divided by `UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_Sqrt_NegativeInput(x);\n    }\n    if (xInt > uMAX_SD59x18 / uUNIT) {\n        revert PRBMath_SD59x18_Sqrt_Overflow(x);\n    }\n\n    unchecked {\n        // Multiply x by `UNIT` to account for the factor of `UNIT` that is picked up when multiplying two SD59x18\n        // numbers together (in this case, the two numbers are both the square root).\n        uint256 resultUint = prbSqrt(uint256(xInt * uUNIT));\n        result = wrap(int256(resultUint));\n    }\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport {\n    PRBMath_UD60x18_IntoSD1x18_Overflow,\n    PRBMath_UD60x18_IntoUD2x18_Overflow,\n    PRBMath_UD60x18_IntoSD59x18_Overflow,\n    PRBMath_UD60x18_IntoUint128_Overflow,\n    PRBMath_UD60x18_IntoUint40_Overflow\n} from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uint256(int256(uMAX_SD1x18))) {\n        revert PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts an UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uMAX_UD2x18) {\n        revert PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n    }\n    result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts an UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uint256(uMAX_SD59x18)) {\n        revert PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n    }\n    result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts an UD60x18 number into uint128.\n/// @dev This is basically a functional alias for the `unwrap` function.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts an UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > MAX_UINT128) {\n        revert PRBMath_UD60x18_IntoUint128_Overflow(x);\n    }\n    result = uint128(xUint);\n}\n\n/// @notice Casts an UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > MAX_UINT40) {\n        revert PRBMath_UD60x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(xUint);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps an UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps an uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\nimport \"./Helpers.sol\" as H;\nimport \"./Math.sol\" as M;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    C.intoInt256,\n    C.intoSD1x18,\n    C.intoUD2x18,\n    C.intoUD60x18,\n    C.intoUint256,\n    C.intoUint128,\n    C.intoUint40,\n    C.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    M.abs,\n    M.avg,\n    M.ceil,\n    M.div,\n    M.exp,\n    M.exp2,\n    M.floor,\n    M.frac,\n    M.gm,\n    M.inv,\n    M.log10,\n    M.log2,\n    M.ln,\n    M.mul,\n    M.pow,\n    M.powu,\n    M.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    H.add,\n    H.and,\n    H.eq,\n    H.gt,\n    H.gte,\n    H.isZero,\n    H.lshift,\n    H.lt,\n    H.lte,\n    H.mod,\n    H.neq,\n    H.or,\n    H.rshift,\n    H.sub,\n    H.uncheckedAdd,\n    H.uncheckedSub,\n    H.uncheckedUnary,\n    H.xor\n} for SD59x18 global;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport {\n    PRBMath_UD60x18_IntoSD1x18_Overflow,\n    PRBMath_UD60x18_IntoUD2x18_Overflow,\n    PRBMath_UD60x18_IntoSD59x18_Overflow,\n    PRBMath_UD60x18_IntoUint128_Overflow,\n    PRBMath_UD60x18_IntoUint40_Overflow\n} from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uint256(int256(uMAX_SD1x18))) {\n        revert PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts an UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uMAX_UD2x18) {\n        revert PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n    }\n    result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts an UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > uint256(uMAX_SD59x18)) {\n        revert PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n    }\n    result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts an UD60x18 number into uint128.\n/// @dev This is basically a functional alias for the `unwrap` function.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts an UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > MAX_UINT128) {\n        revert PRBMath_UD60x18_IntoUint128_Overflow(x);\n    }\n    result = uint128(xUint);\n}\n\n/// @notice Casts an UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n    uint256 xUint = UD60x18.unwrap(x);\n    if (xUint > MAX_UINT40) {\n        revert PRBMath_UD60x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(xUint);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps an UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps an uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n    result = UD60x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud2x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Emitted when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd1x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Math.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { msb, mulDiv, mulDiv18, prbExp2, prbSqrt } from \"../Common.sol\";\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { uHALF_UNIT, uLOG2_10, uLOG2_E, uMAX_UD60x18, uMAX_WHOLE_UD60x18, UNIT, uUNIT, ZERO } from \"./Constants.sol\";\nimport {\n    PRBMath_UD60x18_Ceil_Overflow,\n    PRBMath_UD60x18_Exp_InputTooBig,\n    PRBMath_UD60x18_Exp2_InputTooBig,\n    PRBMath_UD60x18_Gm_Overflow,\n    PRBMath_UD60x18_Log_InputTooSmall,\n    PRBMath_UD60x18_Sqrt_Overflow\n} from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y, rounding down.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n//\n/// In English, what this formula does is:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @param x The first operand as an UD60x18 number.\n/// @param y The second operand as an UD60x18 number.\n/// @return result The arithmetic average as an UD60x18 number.\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n    unchecked {\n        result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n    }\n}\n\n/// @notice Yields the smallest whole UD60x18 number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are \"1e18 - 1\" fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The least number greater than or equal to x, as an UD60x18 number.\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    if (xUint > uMAX_WHOLE_UD60x18) {\n        revert PRBMath_UD60x18_Ceil_Overflow(x);\n    }\n\n    assembly (\"memory-safe\") {\n        // Equivalent to \"x % UNIT\" but faster.\n        let remainder := mod(x, uUNIT)\n\n        // Equivalent to \"UNIT - remainder\" but faster.\n        let delta := sub(uUNIT, remainder)\n\n        // Equivalent to \"x + delta * (remainder > 0 ? 1 : 0)\" but faster.\n        result := add(x, mul(delta, gt(remainder, 0)))\n    }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number. Rounds towards zero.\n///\n/// @dev Uses `mulDiv` to enable overflow-safe multiplication and division.\n///\n/// Requirements:\n/// - The denominator cannot be zero.\n///\n/// @param x The numerator as an UD60x18 number.\n/// @param y The denominator as an UD60x18 number.\n/// @param result The quotient as an UD60x18 number.\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(mulDiv(unwrap(x), uUNIT, unwrap(y)));\n}\n\n/// @notice Calculates the natural exponent of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n/// - x must be less than 133.084258667509499441.\n///\n/// @param x The exponent as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    // Without this check, the value passed to `exp2` would be greater than 192.\n    if (xUint >= 133_084258667509499441) {\n        revert PRBMath_UD60x18_Exp_InputTooBig(x);\n    }\n\n    unchecked {\n        // We do the fixed-point multiplication inline rather than via the `mul` function to save gas.\n        uint256 doubleUnitProduct = xUint * uLOG2_E;\n        result = exp2(wrap(doubleUnitProduct / uUNIT));\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Requirements:\n/// - x must be 192 or less.\n/// - The result must fit within `MAX_UD60x18`.\n///\n/// @param x The exponent as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    // Numbers greater than or equal to 2^192 don't fit within the 192.64-bit format.\n    if (xUint >= 192e18) {\n        revert PRBMath_UD60x18_Exp2_InputTooBig(x);\n    }\n\n    // Convert x to the 192.64-bit fixed-point format.\n    uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n    // Pass x to the `prbExp2` function, which uses the 192.64-bit fixed-point number representation.\n    result = wrap(prbExp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole UD60x18 number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest integer less than or equal to x, as an UD60x18 number.\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n    assembly (\"memory-safe\") {\n        // Equivalent to \"x % UNIT\" but faster.\n        let remainder := mod(x, uUNIT)\n\n        // Equivalent to \"x - remainder * (remainder > 0 ? 1 : 0)\" but faster.\n        result := sub(x, mul(remainder, gt(remainder, 0)))\n    }\n}\n\n/// @notice Yields the excess beyond the floor of x.\n/// @dev Based on the odd function definition https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as an UD60x18 number.\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n    assembly (\"memory-safe\") {\n        result := mod(x, uUNIT)\n    }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $$sqrt(x * y)$$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit within `MAX_UD60x18`, lest it overflows.\n///\n/// @param x The first operand as an UD60x18 number.\n/// @param y The second operand as an UD60x18 number.\n/// @return result The result as an UD60x18 number.\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n    if (xUint == 0 || yUint == 0) {\n        return ZERO;\n    }\n\n    unchecked {\n        // Checking for overflow this way is faster than letting Solidity do it.\n        uint256 xyUint = xUint * yUint;\n        if (xyUint / xUint != yUint) {\n            revert PRBMath_UD60x18_Gm_Overflow(x, y);\n        }\n\n        // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT`\n        // during multiplication. See the comments in the `prbSqrt` function.\n        result = wrap(prbSqrt(xyUint));\n    }\n}\n\n/// @notice Calculates 1 / x, rounding toward zero.\n///\n/// @dev Requirements:\n/// - x cannot be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as an UD60x18 number.\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n    unchecked {\n        // 1e36 is UNIT * UNIT.\n        result = wrap(1e36 / unwrap(x));\n    }\n}\n\n/// @notice Calculates the natural logarithm of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}$$.\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n/// - This doesn't return exactly 1 for 2.718281828459045235, for that more fine-grained precision is needed.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an UD60x18 number.\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n    unchecked {\n        // We do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value\n        // that `log2` can return is 196.205294292027477728.\n        result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_E);\n    }\n}\n\n/// @notice Calculates the common logarithm of x.\n///\n/// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common\n/// logarithm based on the formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an UD60x18 number.\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    if (xUint < uUNIT) {\n        revert PRBMath_UD60x18_Log_InputTooSmall(x);\n    }\n\n    // Note that the `mul` in this assembly block is the assembly multiplication operation, not the UD60x18 `mul`.\n    // prettier-ignore\n    assembly (\"memory-safe\") {\n        switch x\n        case 1 { result := mul(uUNIT, sub(0, 18)) }\n        case 10 { result := mul(uUNIT, sub(1, 18)) }\n        case 100 { result := mul(uUNIT, sub(2, 18)) }\n        case 1000 { result := mul(uUNIT, sub(3, 18)) }\n        case 10000 { result := mul(uUNIT, sub(4, 18)) }\n        case 100000 { result := mul(uUNIT, sub(5, 18)) }\n        case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n        case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n        case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n        case 1000000000000000000 { result := 0 }\n        case 10000000000000000000 { result := uUNIT }\n        case 100000000000000000000 { result := mul(uUNIT, 2) }\n        case 1000000000000000000000 { result := mul(uUNIT, 3) }\n        case 10000000000000000000000 { result := mul(uUNIT, 4) }\n        case 100000000000000000000000 { result := mul(uUNIT, 5) }\n        case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n        case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n        case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n        default {\n            result := uMAX_UD60x18\n        }\n    }\n\n    if (unwrap(result) == uMAX_UD60x18) {\n        unchecked {\n            // Do the fixed-point division inline to save gas.\n            result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_10);\n        }\n    }\n}\n\n/// @notice Calculates the binary logarithm of x.\n///\n/// @dev Based on the iterative approximation algorithm.\n/// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Requirements:\n/// - x must be greater than or equal to UNIT, otherwise the result would be negative.\n///\n/// Caveats:\n/// - The results are nor perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an UD60x18 number.\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    if (xUint < uUNIT) {\n        revert PRBMath_UD60x18_Log_InputTooSmall(x);\n    }\n\n    unchecked {\n        // Calculate the integer part of the logarithm, add it to the result and finally calculate y = x * 2^(-n).\n        uint256 n = msb(xUint / uUNIT);\n\n        // This is the integer part of the logarithm as an UD60x18 number. The operation can't overflow because n\n        // n is maximum 255 and UNIT is 1e18.\n        uint256 resultUint = n * uUNIT;\n\n        // This is $y = x * 2^{-n}$.\n        uint256 y = xUint >> n;\n\n        // If y is 1, the fractional part is zero.\n        if (y == uUNIT) {\n            return wrap(resultUint);\n        }\n\n        // Calculate the fractional part via the iterative approximation.\n        // The \"delta.rshift(1)\" part is equivalent to \"delta /= 2\", but shifting bits is faster.\n        uint256 DOUBLE_UNIT = 2e18;\n        for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n            y = (y * y) / uUNIT;\n\n            // Is y^2 > 2 and so in the range [2,4)?\n            if (y >= DOUBLE_UNIT) {\n                // Add the 2^{-m} factor to the logarithm.\n                resultUint += delta;\n\n                // Corresponds to z/2 on Wikipedia.\n                y >>= 1;\n            }\n        }\n        result = wrap(resultUint);\n    }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n/// @dev See the documentation for the `Common.mulDiv18` function.\n/// @param x The multiplicand as an UD60x18 number.\n/// @param y The multiplier as an UD60x18 number.\n/// @return result The product as an UD60x18 number.\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(mulDiv18(unwrap(x), unwrap(y)));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// Requirements:\n/// - All from `exp2`, `log2` and `mul`.\n///\n/// Caveats:\n/// - All from `exp2`, `log2` and `mul`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x Number to raise to given power y, as an UD60x18 number.\n/// @param y Exponent to raise x to, as an UD60x18 number.\n/// @return result x raised to power y, as an UD60x18 number.\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n    uint256 yUint = unwrap(y);\n\n    if (xUint == 0) {\n        result = yUint == 0 ? UNIT : ZERO;\n    } else {\n        if (yUint == uUNIT) {\n            result = x;\n        } else {\n            result = exp2(mul(log2(x), y));\n        }\n    }\n}\n\n/// @notice Raises x (an UD60x18 number) to the power y (unsigned basic integer) using the famous algorithm\n/// \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n///\n/// Requirements:\n/// - The result must fit within `MAX_UD60x18`.\n///\n/// Caveats:\n/// - All from \"Common.mulDiv18\".\n/// - Assumes 0^0 is 1.\n///\n/// @param x The base as an UD60x18 number.\n/// @param y The exponent as an uint256.\n/// @return result The result as an UD60x18 number.\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n    // Calculate the first iteration of the loop in advance.\n    uint256 xUint = unwrap(x);\n    uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n    // Equivalent to \"for(y /= 2; y > 0; y /= 2)\" but faster.\n    for (y >>= 1; y > 0; y >>= 1) {\n        xUint = mulDiv18(xUint, xUint);\n\n        // Equivalent to \"y % 2 == 1\" but faster.\n        if (y & 1 > 0) {\n            resultUint = mulDiv18(resultUint, xUint);\n        }\n    }\n    result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x, rounding down.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18` divided by `UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as an UD60x18 number.\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n    uint256 xUint = unwrap(x);\n\n    unchecked {\n        if (xUint > uMAX_UD60x18 / uUNIT) {\n            revert PRBMath_UD60x18_Sqrt_Overflow(x);\n        }\n        // Multiply x by `UNIT` to account for the factor of `UNIT` that is picked up when multiplying two UD60x18\n        // numbers together (in this case, the two numbers are both the square root).\n        result = wrap(prbSqrt(xUint * uUNIT));\n    }\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Helpers.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) + unwrap(y));\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) & bits);\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) == unwrap(y);\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) > unwrap(y);\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) >= unwrap(y);\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n    // This wouldn't work if x could be negative.\n    result = unwrap(x) == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) < unwrap(y);\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) <= unwrap(y);\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) % unwrap(y));\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n    result = unwrap(x) != unwrap(y);\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) | unwrap(y));\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) - unwrap(y));\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) + unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) - unwrap(y));\n    }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n    result = wrap(unwrap(x) ^ unwrap(y));\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd1x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT40 } from \"../Common.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport {\n    PRBMath_SD1x18_ToUD2x18_Underflow,\n    PRBMath_SD1x18_ToUD60x18_Underflow,\n    PRBMath_SD1x18_ToUint128_Underflow,\n    PRBMath_SD1x18_ToUint256_Underflow,\n    PRBMath_SD1x18_ToUint40_Overflow,\n    PRBMath_SD1x18_ToUint40_Underflow\n} from \"./Errors.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUD2x18_Underflow(x);\n    }\n    result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUD60x18_Underflow(x);\n    }\n    result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint256_Underflow(x);\n    }\n    result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint128_Underflow(x);\n    }\n    result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint40_Underflow(x);\n    }\n    if (xInt > int64(uint64(MAX_UINT40))) {\n        revert PRBMath_SD1x18_ToUint40_Overflow(x);\n    }\n    result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n    result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n    result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into the SD1x18 value type.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n    result = SD1x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/Helpers.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { unwrap, wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    return wrap(unwrap(x) + unwrap(y));\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n    return wrap(unwrap(x) & bits);\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) == unwrap(y);\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) > unwrap(y);\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) >= unwrap(y);\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n    result = unwrap(x) == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) < unwrap(y);\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) <= unwrap(y);\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) % unwrap(y));\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n    result = unwrap(x) != unwrap(y);\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) | unwrap(y));\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) - unwrap(y));\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) + unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(unwrap(x) - unwrap(y));\n    }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n    unchecked {\n        result = wrap(-unwrap(x));\n    }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) ^ unwrap(y));\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd59x18/Math.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40, msb, mulDiv, mulDiv18, prbExp2, prbSqrt } from \"../Common.sol\";\nimport {\n    uHALF_UNIT,\n    uLOG2_10,\n    uLOG2_E,\n    uMAX_SD59x18,\n    uMAX_WHOLE_SD59x18,\n    uMIN_SD59x18,\n    uMIN_WHOLE_SD59x18,\n    UNIT,\n    uUNIT,\n    ZERO\n} from \"./Constants.sol\";\nimport {\n    PRBMath_SD59x18_Abs_MinSD59x18,\n    PRBMath_SD59x18_Ceil_Overflow,\n    PRBMath_SD59x18_Div_InputTooSmall,\n    PRBMath_SD59x18_Div_Overflow,\n    PRBMath_SD59x18_Exp_InputTooBig,\n    PRBMath_SD59x18_Exp2_InputTooBig,\n    PRBMath_SD59x18_Floor_Underflow,\n    PRBMath_SD59x18_Gm_Overflow,\n    PRBMath_SD59x18_Gm_NegativeProduct,\n    PRBMath_SD59x18_Log_InputTooSmall,\n    PRBMath_SD59x18_Mul_InputTooSmall,\n    PRBMath_SD59x18_Mul_Overflow,\n    PRBMath_SD59x18_Powu_Overflow,\n    PRBMath_SD59x18_Sqrt_NegativeInput,\n    PRBMath_SD59x18_Sqrt_Overflow\n} from \"./Errors.sol\";\nimport { unwrap, wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculate the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Abs_MinSD59x18();\n    }\n    result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y, rounding towards zero.\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n\n    unchecked {\n        // This is equivalent to \"x / 2 +  y / 2\" but faster.\n        // This operation can never overflow.\n        int256 sum = (xInt >> 1) + (yInt >> 1);\n\n        if (sum < 0) {\n            // If at least one of x and y is odd, we add 1 to the result, since shifting negative numbers to the right rounds\n            // down to infinity. The right part is equivalent to \"sum + (x % 2 == 1 || y % 2 == 1)\" but faster.\n            assembly (\"memory-safe\") {\n                result := add(sum, and(or(xInt, yInt), 1))\n            }\n        } else {\n            // We need to add 1 if both x and y are odd to account for the double 0.5 remainder that is truncated after shifting.\n            result = wrap(sum + (xInt & yInt & 1));\n        }\n    }\n}\n\n/// @notice Yields the smallest whole SD59x18 number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The least number greater than or equal to x, as an SD59x18 number.\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt > uMAX_WHOLE_SD59x18) {\n        revert PRBMath_SD59x18_Ceil_Overflow(x);\n    }\n\n    int256 remainder = xInt % uUNIT;\n    if (remainder == 0) {\n        result = x;\n    } else {\n        unchecked {\n            // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n            int256 resultInt = xInt - remainder;\n            if (xInt > 0) {\n                resultInt += uUNIT;\n            }\n            result = wrap(resultInt);\n        }\n    }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number. Rounds towards zero.\n///\n/// @dev This is a variant of `mulDiv` that works with signed numbers. Works by computing the signs and the absolute values\n/// separately.\n///\n/// Requirements:\n/// - All from `Common.mulDiv`.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator cannot be zero.\n/// - The result must fit within int256.\n///\n/// Caveats:\n/// - All from `Common.mulDiv`.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Div_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x and y.\n    uint256 xAbs;\n    uint256 yAbs;\n    unchecked {\n        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n    }\n\n    // Compute the absolute value (x*UNIT)÷y. The resulting value must fit within int256.\n    uint256 resultAbs = mulDiv(xAbs, uint256(uUNIT), yAbs);\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Div_Overflow(x, y);\n    }\n\n    // Check if x and y have the same sign. This works thanks to two's complement; the left-most bit is the sign bit.\n    bool sameSign = (xInt ^ yInt) > -1;\n\n    // If the inputs don't have the same sign, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n    }\n}\n\n/// @notice Calculates the natural exponent of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n/// - x must be less than 133.084258667509499441.\n///\n/// Caveats:\n/// - All from `exp2`.\n/// - For any x less than -41.446531673892822322, the result is zero.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    // Without this check, the value passed to `exp2` would be less than -59.794705707972522261.\n    if (xInt < -41_446531673892822322) {\n        return ZERO;\n    }\n\n    // Without this check, the value passed to `exp2` would be greater than 192.\n    if (xInt >= 133_084258667509499441) {\n        revert PRBMath_SD59x18_Exp_InputTooBig(x);\n    }\n\n    unchecked {\n        // Do the fixed-point multiplication inline to save gas.\n        int256 doubleUnitProduct = xInt * uLOG2_E;\n        result = exp2(wrap(doubleUnitProduct / uUNIT));\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Requirements:\n/// - x must be 192 or less.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - For any x less than -59.794705707972522261, the result is zero.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        // 2^59.794705707972522262 is the maximum number whose inverse does not truncate down to zero.\n        if (xInt < -59_794705707972522261) {\n            return ZERO;\n        }\n\n        unchecked {\n            // Do the fixed-point inversion $1/2^x$ inline to save gas. 1e36 is UNIT * UNIT.\n            result = wrap(1e36 / unwrap(exp2(wrap(-xInt))));\n        }\n    } else {\n        // 2^192 doesn't fit within the 192.64-bit format used internally in this function.\n        if (xInt >= 192e18) {\n            revert PRBMath_SD59x18_Exp2_InputTooBig(x);\n        }\n\n        unchecked {\n            // Convert x to the 192.64-bit fixed-point format.\n            uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n            // It is safe to convert the result to int256 with no checks because the maximum input allowed in this function is 192.\n            result = wrap(int256(prbExp2(x_192x64)));\n        }\n    }\n}\n\n/// @notice Yields the greatest whole SD59x18 number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest integer less than or equal to x, as an SD59x18 number.\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < uMIN_WHOLE_SD59x18) {\n        revert PRBMath_SD59x18_Floor_Underflow(x);\n    }\n\n    int256 remainder = xInt % uUNIT;\n    if (remainder == 0) {\n        result = x;\n    } else {\n        unchecked {\n            // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n            int256 resultInt = xInt - remainder;\n            if (xInt < 0) {\n                resultInt -= uUNIT;\n            }\n            result = wrap(resultInt);\n        }\n    }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n    result = wrap(unwrap(x) % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. sqrt(x * y), rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit within `MAX_SD59x18`, lest it overflows.\n/// - x * y must not be negative, since this library does not handle complex numbers.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == 0 || yInt == 0) {\n        return ZERO;\n    }\n\n    unchecked {\n        // Equivalent to \"xy / x != y\". Checking for overflow this way is faster than letting Solidity do it.\n        int256 xyInt = xInt * yInt;\n        if (xyInt / xInt != yInt) {\n            revert PRBMath_SD59x18_Gm_Overflow(x, y);\n        }\n\n        // The product must not be negative, since this library does not handle complex numbers.\n        if (xyInt < 0) {\n            revert PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n        }\n\n        // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT`\n        // during multiplication. See the comments within the `prbSqrt` function.\n        uint256 resultUint = prbSqrt(uint256(xyInt));\n        result = wrap(int256(resultUint));\n    }\n}\n\n/// @notice Calculates 1 / x, rounding toward zero.\n///\n/// @dev Requirements:\n/// - x cannot be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n    // 1e36 is UNIT * UNIT.\n    result = wrap(1e36 / unwrap(x));\n}\n\n/// @notice Calculates the natural logarithm of x.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}$$.\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n/// - This doesn't return exactly 1 for 2.718281828459045235, for that more fine-grained precision is needed.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n    // Do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value that log2(x)\n    // can return is 195.205294292027477728.\n    result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x.\n///\n/// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common\n/// logarithm based on the formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// Requirements:\n/// - All from `log2`.\n///\n/// Caveats:\n/// - All from `log2`.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_Log_InputTooSmall(x);\n    }\n\n    // Note that the `mul` in this block is the assembly mul operation, not the SD59x18 `mul`.\n    // prettier-ignore\n    assembly (\"memory-safe\") {\n        switch x\n        case 1 { result := mul(uUNIT, sub(0, 18)) }\n        case 10 { result := mul(uUNIT, sub(1, 18)) }\n        case 100 { result := mul(uUNIT, sub(2, 18)) }\n        case 1000 { result := mul(uUNIT, sub(3, 18)) }\n        case 10000 { result := mul(uUNIT, sub(4, 18)) }\n        case 100000 { result := mul(uUNIT, sub(5, 18)) }\n        case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n        case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n        case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n        case 1000000000000000000 { result := 0 }\n        case 10000000000000000000 { result := uUNIT }\n        case 100000000000000000000 { result := mul(uUNIT, 2) }\n        case 1000000000000000000000 { result := mul(uUNIT, 3) }\n        case 10000000000000000000000 { result := mul(uUNIT, 4) }\n        case 100000000000000000000000 { result := mul(uUNIT, 5) }\n        case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n        case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n        case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n        default {\n            result := uMAX_SD59x18\n        }\n    }\n\n    if (unwrap(result) == uMAX_SD59x18) {\n        unchecked {\n            // Do the fixed-point division inline to save gas.\n            result = wrap((unwrap(log2(x)) * uUNIT) / uLOG2_10);\n        }\n    }\n}\n\n/// @notice Calculates the binary logarithm of x.\n///\n/// @dev Based on the iterative approximation algorithm.\n/// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// Caveats:\n/// - The results are not perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt <= 0) {\n        revert PRBMath_SD59x18_Log_InputTooSmall(x);\n    }\n\n    unchecked {\n        // This works because of:\n        //\n        // $$\n        // log_2{x} = -log_2{\\frac{1}{x}}\n        // $$\n        int256 sign;\n        if (xInt >= uUNIT) {\n            sign = 1;\n        } else {\n            sign = -1;\n            // Do the fixed-point inversion inline to save gas. The numerator is UNIT * UNIT.\n            xInt = 1e36 / xInt;\n        }\n\n        // Calculate the integer part of the logarithm and add it to the result and finally calculate $y = x * 2^(-n)$.\n        uint256 n = msb(uint256(xInt / uUNIT));\n\n        // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n        // because n is maximum 255, UNIT is 1e18 and sign is either 1 or -1.\n        int256 resultInt = int256(n) * uUNIT;\n\n        // This is $y = x * 2^{-n}$.\n        int256 y = xInt >> n;\n\n        // If y is 1, the fractional part is zero.\n        if (y == uUNIT) {\n            return wrap(resultInt * sign);\n        }\n\n        // Calculate the fractional part via the iterative approximation.\n        // The \"delta >>= 1\" part is equivalent to \"delta /= 2\", but shifting bits is faster.\n        int256 DOUBLE_UNIT = 2e18;\n        for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n            y = (y * y) / uUNIT;\n\n            // Is $y^2 > 2$ and so in the range [2,4)?\n            if (y >= DOUBLE_UNIT) {\n                // Add the 2^{-m} factor to the logarithm.\n                resultInt = resultInt + delta;\n\n                // Corresponds to z/2 on Wikipedia.\n                y >>= 1;\n            }\n        }\n        resultInt *= sign;\n        result = wrap(resultInt);\n    }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev This is a variant of `mulDiv` that works with signed numbers and employs constant folding, i.e. the denominator\n/// is always 1e18.\n///\n/// Requirements:\n/// - All from `Common.mulDiv18`.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - To understand how this works in detail, see the NatSpec comments in `Common.mulDivSigned`.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n        revert PRBMath_SD59x18_Mul_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x and y.\n    uint256 xAbs;\n    uint256 yAbs;\n    unchecked {\n        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n    }\n\n    uint256 resultAbs = mulDiv18(xAbs, yAbs);\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Mul_Overflow(x, y);\n    }\n\n    // Check if x and y have the same sign. This works thanks to two's complement; the left-most bit is the sign bit.\n    bool sameSign = (xInt ^ yInt) > -1;\n\n    // If the inputs have the same sign, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n    }\n}\n\n/// @notice Raises x to the power of y.\n///\n/// @dev Based on the formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// Requirements:\n/// - All from `exp2`, `log2` and `mul`.\n/// - x cannot be zero.\n///\n/// Caveats:\n/// - All from `exp2`, `log2` and `mul`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x Number to raise to given power y, as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    int256 yInt = unwrap(y);\n\n    if (xInt == 0) {\n        result = yInt == 0 ? UNIT : ZERO;\n    } else {\n        if (yInt == uUNIT) {\n            result = x;\n        } else {\n            result = exp2(mul(log2(x), y));\n        }\n    }\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (unsigned basic integer) using the famous algorithm\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n///\n/// Requirements:\n/// - All from `abs` and `Common.mulDiv18`.\n/// - The result must fit within `MAX_SD59x18`.\n///\n/// Caveats:\n/// - All from `Common.mulDiv18`.\n/// - Assumes 0^0 is 1.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as an uint256.\n/// @return result The result as an SD59x18 number.\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n    uint256 xAbs = uint256(unwrap(abs(x)));\n\n    // Calculate the first iteration of the loop in advance.\n    uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n    // Equivalent to \"for(y /= 2; y > 0; y /= 2)\" but faster.\n    uint256 yAux = y;\n    for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n        xAbs = mulDiv18(xAbs, xAbs);\n\n        // Equivalent to \"y % 2 == 1\" but faster.\n        if (yAux & 1 > 0) {\n            resultAbs = mulDiv18(resultAbs, xAbs);\n        }\n    }\n\n    // The result must fit within `MAX_SD59x18`.\n    if (resultAbs > uint256(uMAX_SD59x18)) {\n        revert PRBMath_SD59x18_Powu_Overflow(x, y);\n    }\n\n    unchecked {\n        // Is the base negative and the exponent an odd number?\n        int256 resultInt = int256(resultAbs);\n        bool isNegative = unwrap(x) < 0 && y & 1 == 1;\n        if (isNegative) {\n            resultInt = -resultInt;\n        }\n        result = wrap(resultInt);\n    }\n}\n\n/// @notice Calculates the square root of x, rounding down. Only the positive root is returned.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Requirements:\n/// - x cannot be negative, since this library does not handle complex numbers.\n/// - x must be less than `MAX_SD59x18` divided by `UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n    int256 xInt = unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_Sqrt_NegativeInput(x);\n    }\n    if (xInt > uMAX_SD59x18 / uUNIT) {\n        revert PRBMath_SD59x18_Sqrt_Overflow(x);\n    }\n\n    unchecked {\n        // Multiply x by `UNIT` to account for the factor of `UNIT` that is picked up when multiplying two SD59x18\n        // numbers together (in this case, the two numbers are both the square root).\n        uint256 resultUint = prbSqrt(uint256(xInt * uUNIT));\n        result = wrap(int256(resultUint));\n    }\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd1x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT40 } from \"../Common.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport {\n    PRBMath_SD1x18_ToUD2x18_Underflow,\n    PRBMath_SD1x18_ToUD60x18_Underflow,\n    PRBMath_SD1x18_ToUint128_Underflow,\n    PRBMath_SD1x18_ToUint256_Underflow,\n    PRBMath_SD1x18_ToUint40_Overflow,\n    PRBMath_SD1x18_ToUint40_Underflow\n} from \"./Errors.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUD2x18_Underflow(x);\n    }\n    result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUD60x18_Underflow(x);\n    }\n    result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint256_Underflow(x);\n    }\n    result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint128_Underflow(x);\n    }\n    result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n    int64 xInt = SD1x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD1x18_ToUint40_Underflow(x);\n    }\n    if (xInt > int64(uint64(MAX_UINT40))) {\n        revert PRBMath_SD1x18_ToUint40_Overflow(x);\n    }\n    result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n    result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n    result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into the SD1x18 value type.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n    result = SD1x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud2x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as an UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\nimport \"./Helpers.sol\" as H;\nimport \"./Math.sol\" as M;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD1x18, C.intoUD2x18, C.intoSD59x18, C.intoUint128, C.intoUint256, C.intoUint40, C.unwrap } for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n    M.avg,\n    M.ceil,\n    M.div,\n    M.exp,\n    M.exp2,\n    M.floor,\n    M.frac,\n    M.gm,\n    M.inv,\n    M.ln,\n    M.log10,\n    M.log2,\n    M.mul,\n    M.pow,\n    M.powu,\n    M.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n    H.add,\n    H.and,\n    H.eq,\n    H.gt,\n    H.gte,\n    H.isZero,\n    H.lshift,\n    H.lt,\n    H.lte,\n    H.mod,\n    H.neq,\n    H.or,\n    H.rshift,\n    H.sub,\n    H.uncheckedAdd,\n    H.uncheckedSub,\n    H.xor\n} for UD60x18 global;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud2x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type uint64.\n/// This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD1x18, C.intoSD59x18, C.intoUD60x18, C.intoUint256, C.intoUint128, C.intoUint40, C.unwrap } for UD2x18 global;\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/UD60x18.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd1x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type int64.\n/// This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD59x18, C.intoUD2x18, C.intoUD60x18, C.intoUint256, C.intoUint128, C.intoUint40, C.unwrap } for SD1x18 global;\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Emitted when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Emitted when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Emitted when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when taking the natural exponent of a base greater than 133.084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Emitted when taking the binary exponent of a base greater than 192.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Emitted when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Emitted when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Emitted when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Emitted when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Emitted when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Emitted when raising a number to a power and hte intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Emitted when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Emitted when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/ud60x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Emitted when taking the natural exponent of a base greater than 133.084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Emitted when taking the binary exponent of a base greater than 192.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Emitted when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Emitted when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Emitted when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/foundry-chainlink-toolkit/src/interfaces/feeds/AggregatorV3Interface.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n  function description() external view returns (string memory);\n  function version() external view returns (uint256);\n  function getRoundData(uint80 _roundId) external view returns (\n    uint80 roundId,\n    int256 answer,\n    uint256 startedAt,\n    uint256 updatedAt,\n    uint80 answeredInRound\n  );\n  function latestRoundData() external view returns (\n    uint80 roundId,\n    int256 answer,\n    uint256 startedAt,\n    uint256 updatedAt,\n    uint80 answeredInRound\n  );\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\nimport \"./Helpers.sol\" as H;\nimport \"./Math.sol\" as M;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    C.intoInt256,\n    C.intoSD1x18,\n    C.intoUD2x18,\n    C.intoUD60x18,\n    C.intoUint256,\n    C.intoUint128,\n    C.intoUint40,\n    C.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                            MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    M.abs,\n    M.avg,\n    M.ceil,\n    M.div,\n    M.exp,\n    M.exp2,\n    M.floor,\n    M.frac,\n    M.gm,\n    M.inv,\n    M.log10,\n    M.log2,\n    M.ln,\n    M.mul,\n    M.pow,\n    M.powu,\n    M.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n    H.add,\n    H.and,\n    H.eq,\n    H.gt,\n    H.gte,\n    H.isZero,\n    H.lshift,\n    H.lt,\n    H.lte,\n    H.mod,\n    H.neq,\n    H.or,\n    H.rshift,\n    H.sub,\n    H.uncheckedAdd,\n    H.uncheckedSub,\n    H.uncheckedUnary,\n    H.xor\n} for SD59x18 global;\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/Casting.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport {\n    PRBMath_SD59x18_IntoSD1x18_Overflow,\n    PRBMath_SD59x18_IntoSD1x18_Underflow,\n    PRBMath_SD59x18_IntoUD2x18_Overflow,\n    PRBMath_SD59x18_IntoUD2x18_Underflow,\n    PRBMath_SD59x18_IntoUD60x18_Underflow,\n    PRBMath_SD59x18_IntoUint128_Overflow,\n    PRBMath_SD59x18_IntoUint128_Underflow,\n    PRBMath_SD59x18_IntoUint256_Underflow,\n    PRBMath_SD59x18_IntoUint40_Overflow,\n    PRBMath_SD59x18_IntoUint40_Underflow\n} from \"./Errors.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for the `unwrap` function.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n    result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < uMIN_SD1x18) {\n        revert PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n    }\n    if (xInt > uMAX_SD1x18) {\n        revert PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n    }\n    result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n    }\n    if (xInt > int256(uint256(uMAX_UD2x18))) {\n        revert PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n    }\n    result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n    }\n    result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint256_Underflow(x);\n    }\n    result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint128_Underflow(x);\n    }\n    if (xInt > int256(uint256(MAX_UINT128))) {\n        revert PRBMath_SD59x18_IntoUint128_Overflow(x);\n    }\n    result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n    int256 xInt = SD59x18.unwrap(x);\n    if (xInt < 0) {\n        revert PRBMath_SD59x18_IntoUint40_Underflow(x);\n    }\n    if (xInt > int256(uint256(MAX_UINT40))) {\n        revert PRBMath_SD59x18_IntoUint40_Overflow(x);\n    }\n    result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for the `wrap` function.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n    result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into the SD59x18 value type.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n    result = SD59x18.wrap(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/UD60x18.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Conversions.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts an UD60x18 number to a simple integer by dividing it by `UNIT`. Rounds towards zero in the process.\n/// @dev Rounds down in the process.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n    result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18` divided by `UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n    if (x > uMAX_UD60x18 / uUNIT) {\n        revert PRBMath_UD60x18_Convert_Overflow(x);\n    }\n    unchecked {\n        result = UD60x18.wrap(x * uUNIT);\n    }\n}\n\n/// @notice Alias for the `convert` function defined above.\n/// @dev Here for backward compatibility. Will be removed in V4.\nfunction fromUD60x18(UD60x18 x) pure returns (uint256 result) {\n    result = convert(x);\n}\n\n/// @notice Alias for the `convert` function defined above.\n/// @dev Here for backward compatibility. Will be removed in V4.\nfunction toUD60x18(uint256 x) pure returns (UD60x18 result) {\n    result = convert(x);\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd1x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n"},{"file_path":"lib/mento-core-2.6.5/lib/foundry-chainlink-toolkit/src/interfaces/feeds/AggregatorV3Interface.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n  function description() external view returns (string memory);\n  function version() external view returns (uint256);\n  function getRoundData(uint80 _roundId) external view returns (\n    uint80 roundId,\n    int256 answer,\n    uint256 startedAt,\n    uint256 updatedAt,\n    uint80 answeredInRound\n  );\n  function latestRoundData() external view returns (\n    uint80 roundId,\n    int256 answer,\n    uint256 startedAt,\n    uint256 updatedAt,\n    uint80 answeredInRound\n  );\n}\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/ud60x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Emitted when taking the natural exponent of a base greater than 133.084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Emitted when taking the binary exponent of a base greater than 192.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Emitted when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Emitted when trying to cast an UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Emitted when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Emitted when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/Common.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\n/// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n/// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n                                CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Emitted when the ending result in the fixed-point version of `mulDiv` would overflow uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Emitted when the ending result in `mulDiv` would overflow uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Emitted when attempting to run `mulDiv` with one of the inputs `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Emitted when the ending result in the signed version of `mulDiv` would overflow int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value an uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value an uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev How many trailing decimals can be represented.\nuint256 constant UNIT = 1e18;\n\n/// @dev Largest power of two that is a divisor of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/// @dev The `UNIT` number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Finds the zero-based index of the first one in the binary representation of x.\n/// @dev See the note on msb in the \"Find First Set\" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each of the steps in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n///     x >>= 128;\n///     result += 128;\n/// }\n/// ```\n///\n/// Where 128 is swapped with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// A list of the Yul instructions used below:\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as an uint256.\nfunction msb(uint256 x) pure returns (uint256 result) {\n    // 2^128\n    assembly (\"memory-safe\") {\n        let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^64\n    assembly (\"memory-safe\") {\n        let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^32\n    assembly (\"memory-safe\") {\n        let factor := shl(5, gt(x, 0xFFFFFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^16\n    assembly (\"memory-safe\") {\n        let factor := shl(4, gt(x, 0xFFFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^8\n    assembly (\"memory-safe\") {\n        let factor := shl(3, gt(x, 0xFF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^4\n    assembly (\"memory-safe\") {\n        let factor := shl(2, gt(x, 0xF))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^2\n    assembly (\"memory-safe\") {\n        let factor := shl(1, gt(x, 0x3))\n        x := shr(factor, x)\n        result := or(result, factor)\n    }\n    // 2^1\n    // No need to shift x any more.\n    assembly (\"memory-safe\") {\n        let factor := gt(x, 0x1)\n        result := or(result, factor)\n    }\n}\n\n/// @notice Calculates floor(x*y÷denominator) with full precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Requirements:\n/// - The denominator cannot be zero.\n/// - The result must fit within uint256.\n///\n/// Caveats:\n/// - This function does not work with fixed-point numbers.\n///\n/// @param x The multiplicand as an uint256.\n/// @param y The multiplier as an uint256.\n/// @param denominator The divisor as an uint256.\n/// @return result The result as an uint256.\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\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 (\"memory-safe\") {\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        unchecked {\n            return prod0 / denominator;\n        }\n    }\n\n    // Make sure the result is less than 2^256. Also prevents denominator == 0.\n    if (prod1 >= denominator) {\n        revert PRBMath_MulDiv_Overflow(x, y, denominator);\n    }\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 (\"memory-safe\") {\n        // Compute remainder using the mulmod Yul instruction.\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    unchecked {\n        // Does not overflow because the denominator cannot be zero at this stage in the function.\n        uint256 lpotdod = denominator & (~denominator + 1);\n        assembly (\"memory-safe\") {\n            // Divide denominator by lpotdod.\n            denominator := div(denominator, lpotdod)\n\n            // Divide [prod1 prod0] by lpotdod.\n            prod0 := div(prod0, lpotdod)\n\n            // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one.\n            lpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n        }\n\n        // Shift in bits from prod1 into prod0.\n        prod0 |= prod1 * lpotdod;\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    }\n}\n\n/// @notice Calculates floor(x*y÷1e18) with full precision.\n///\n/// @dev Variant of `mulDiv` with constant folding, i.e. in which the denominator is always 1e18. Before returning the\n/// final result, we add 1 if `(x * y) % UNIT >= HALF_UNIT`. Without this adjustment, 6.6e-19 would be truncated to 0\n/// instead of being rounded to 1e-18. See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717.\n///\n/// Requirements:\n/// - The result must fit within uint256.\n///\n/// Caveats:\n/// - The body is purposely left uncommented; to understand how this works, see the NatSpec comments in `mulDiv`.\n/// - It is assumed that the result can never be `type(uint256).max` when x and y solve the following two equations:\n///     1. x * y = type(uint256).max * UNIT\n///     2. (x * y) % UNIT >= UNIT / 2\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n    uint256 prod0;\n    uint256 prod1;\n    assembly (\"memory-safe\") {\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    if (prod1 >= UNIT) {\n        revert PRBMath_MulDiv18_Overflow(x, y);\n    }\n\n    uint256 remainder;\n    assembly (\"memory-safe\") {\n        remainder := mulmod(x, y, UNIT)\n    }\n\n    if (prod1 == 0) {\n        unchecked {\n            return prod0 / UNIT;\n        }\n    }\n\n    assembly (\"memory-safe\") {\n        result := mul(\n            or(\n                div(sub(prod0, remainder), UNIT_LPOTD),\n                mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n            ),\n            UNIT_INVERSE\n        )\n    }\n}\n\n/// @notice Calculates floor(x*y÷denominator) with full precision.\n///\n/// @dev An extension of `mulDiv` for signed numbers. Works by computing the signs and the absolute values separately.\n///\n/// Requirements:\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit within int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n    if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n        revert PRBMath_MulDivSigned_InputTooSmall();\n    }\n\n    // Get hold of the absolute values of x, y and the denominator.\n    uint256 absX;\n    uint256 absY;\n    uint256 absD;\n    unchecked {\n        absX = x < 0 ? uint256(-x) : uint256(x);\n        absY = y < 0 ? uint256(-y) : uint256(y);\n        absD = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n    }\n\n    // Compute the absolute value of (x*y)÷denominator. The result must fit within int256.\n    uint256 rAbs = mulDiv(absX, absY, absD);\n    if (rAbs > uint256(type(int256).max)) {\n        revert PRBMath_MulDivSigned_Overflow(x, y);\n    }\n\n    // Get the signs of x, y and the denominator.\n    uint256 sx;\n    uint256 sy;\n    uint256 sd;\n    assembly (\"memory-safe\") {\n        // This works thanks to two's complement.\n        // \"sgt\" stands for \"signed greater than\" and \"sub(0,1)\" is max uint256.\n        sx := sgt(x, sub(0, 1))\n        sy := sgt(y, sub(0, 1))\n        sd := sgt(denominator, sub(0, 1))\n    }\n\n    // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n    // If there are, the result should be negative. Otherwise, it should be positive.\n    unchecked {\n        result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);\n    }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers.\n/// See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\nfunction prbExp2(uint256 x) pure returns (uint256 result) {\n    unchecked {\n        // Start from 0.5 in the 192.64-bit fixed-point format.\n        result = 0x800000000000000000000000000000000000000000000000;\n\n        // Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows\n        // because the initial result is 2^191 and all magic factors are less than 2^65.\n        if (x & 0xFF00000000000000 > 0) {\n            if (x & 0x8000000000000000 > 0) {\n                result = (result * 0x16A09E667F3BCC909) >> 64;\n            }\n            if (x & 0x4000000000000000 > 0) {\n                result = (result * 0x1306FE0A31B7152DF) >> 64;\n            }\n            if (x & 0x2000000000000000 > 0) {\n                result = (result * 0x1172B83C7D517ADCE) >> 64;\n            }\n            if (x & 0x1000000000000000 > 0) {\n                result = (result * 0x10B5586CF9890F62A) >> 64;\n            }\n            if (x & 0x800000000000000 > 0) {\n                result = (result * 0x1059B0D31585743AE) >> 64;\n            }\n            if (x & 0x400000000000000 > 0) {\n                result = (result * 0x102C9A3E778060EE7) >> 64;\n            }\n            if (x & 0x200000000000000 > 0) {\n                result = (result * 0x10163DA9FB33356D8) >> 64;\n            }\n            if (x & 0x100000000000000 > 0) {\n                result = (result * 0x100B1AFA5ABCBED61) >> 64;\n            }\n        }\n\n        if (x & 0xFF000000000000 > 0) {\n            if (x & 0x80000000000000 > 0) {\n                result = (result * 0x10058C86DA1C09EA2) >> 64;\n            }\n            if (x & 0x40000000000000 > 0) {\n                result = (result * 0x1002C605E2E8CEC50) >> 64;\n            }\n            if (x & 0x20000000000000 > 0) {\n                result = (result * 0x100162F3904051FA1) >> 64;\n            }\n            if (x & 0x10000000000000 > 0) {\n                result = (result * 0x1000B175EFFDC76BA) >> 64;\n            }\n            if (x & 0x8000000000000 > 0) {\n                result = (result * 0x100058BA01FB9F96D) >> 64;\n            }\n            if (x & 0x4000000000000 > 0) {\n                result = (result * 0x10002C5CC37DA9492) >> 64;\n            }\n            if (x & 0x2000000000000 > 0) {\n                result = (result * 0x1000162E525EE0547) >> 64;\n            }\n            if (x & 0x1000000000000 > 0) {\n                result = (result * 0x10000B17255775C04) >> 64;\n            }\n        }\n\n        if (x & 0xFF0000000000 > 0) {\n            if (x & 0x800000000000 > 0) {\n                result = (result * 0x1000058B91B5BC9AE) >> 64;\n            }\n            if (x & 0x400000000000 > 0) {\n                result = (result * 0x100002C5C89D5EC6D) >> 64;\n            }\n            if (x & 0x200000000000 > 0) {\n                result = (result * 0x10000162E43F4F831) >> 64;\n            }\n            if (x & 0x100000000000 > 0) {\n                result = (result * 0x100000B1721BCFC9A) >> 64;\n            }\n            if (x & 0x80000000000 > 0) {\n                result = (result * 0x10000058B90CF1E6E) >> 64;\n            }\n            if (x & 0x40000000000 > 0) {\n                result = (result * 0x1000002C5C863B73F) >> 64;\n            }\n            if (x & 0x20000000000 > 0) {\n                result = (result * 0x100000162E430E5A2) >> 64;\n            }\n            if (x & 0x10000000000 > 0) {\n                result = (result * 0x1000000B172183551) >> 64;\n            }\n        }\n\n        if (x & 0xFF00000000 > 0) {\n            if (x & 0x8000000000 > 0) {\n                result = (result * 0x100000058B90C0B49) >> 64;\n            }\n            if (x & 0x4000000000 > 0) {\n                result = (result * 0x10000002C5C8601CC) >> 64;\n            }\n            if (x & 0x2000000000 > 0) {\n                result = (result * 0x1000000162E42FFF0) >> 64;\n            }\n            if (x & 0x1000000000 > 0) {\n                result = (result * 0x10000000B17217FBB) >> 64;\n            }\n            if (x & 0x800000000 > 0) {\n                result = (result * 0x1000000058B90BFCE) >> 64;\n            }\n            if (x & 0x400000000 > 0) {\n                result = (result * 0x100000002C5C85FE3) >> 64;\n            }\n            if (x & 0x200000000 > 0) {\n                result = (result * 0x10000000162E42FF1) >> 64;\n            }\n            if (x & 0x100000000 > 0) {\n                result = (result * 0x100000000B17217F8) >> 64;\n            }\n        }\n\n        if (x & 0xFF00000000 > 0) {\n            if (x & 0x80000000 > 0) {\n                result = (result * 0x10000000058B90BFC) >> 64;\n            }\n            if (x & 0x40000000 > 0) {\n                result = (result * 0x1000000002C5C85FE) >> 64;\n            }\n            if (x & 0x20000000 > 0) {\n                result = (result * 0x100000000162E42FF) >> 64;\n            }\n            if (x & 0x10000000 > 0) {\n                result = (result * 0x1000000000B17217F) >> 64;\n            }\n            if (x & 0x8000000 > 0) {\n                result = (result * 0x100000000058B90C0) >> 64;\n            }\n            if (x & 0x4000000 > 0) {\n                result = (result * 0x10000000002C5C860) >> 64;\n            }\n            if (x & 0x2000000 > 0) {\n                result = (result * 0x1000000000162E430) >> 64;\n            }\n            if (x & 0x1000000 > 0) {\n                result = (result * 0x10000000000B17218) >> 64;\n            }\n        }\n\n        if (x & 0xFF0000 > 0) {\n            if (x & 0x800000 > 0) {\n                result = (result * 0x1000000000058B90C) >> 64;\n            }\n            if (x & 0x400000 > 0) {\n                result = (result * 0x100000000002C5C86) >> 64;\n            }\n            if (x & 0x200000 > 0) {\n                result = (result * 0x10000000000162E43) >> 64;\n            }\n            if (x & 0x100000 > 0) {\n                result = (result * 0x100000000000B1721) >> 64;\n            }\n            if (x & 0x80000 > 0) {\n                result = (result * 0x10000000000058B91) >> 64;\n            }\n            if (x & 0x40000 > 0) {\n                result = (result * 0x1000000000002C5C8) >> 64;\n            }\n            if (x & 0x20000 > 0) {\n                result = (result * 0x100000000000162E4) >> 64;\n            }\n            if (x & 0x10000 > 0) {\n                result = (result * 0x1000000000000B172) >> 64;\n            }\n        }\n\n        if (x & 0xFF00 > 0) {\n            if (x & 0x8000 > 0) {\n                result = (result * 0x100000000000058B9) >> 64;\n            }\n            if (x & 0x4000 > 0) {\n                result = (result * 0x10000000000002C5D) >> 64;\n            }\n            if (x & 0x2000 > 0) {\n                result = (result * 0x1000000000000162E) >> 64;\n            }\n            if (x & 0x1000 > 0) {\n                result = (result * 0x10000000000000B17) >> 64;\n            }\n            if (x & 0x800 > 0) {\n                result = (result * 0x1000000000000058C) >> 64;\n            }\n            if (x & 0x400 > 0) {\n                result = (result * 0x100000000000002C6) >> 64;\n            }\n            if (x & 0x200 > 0) {\n                result = (result * 0x10000000000000163) >> 64;\n            }\n            if (x & 0x100 > 0) {\n                result = (result * 0x100000000000000B1) >> 64;\n            }\n        }\n\n        if (x & 0xFF > 0) {\n            if (x & 0x80 > 0) {\n                result = (result * 0x10000000000000059) >> 64;\n            }\n            if (x & 0x40 > 0) {\n                result = (result * 0x1000000000000002C) >> 64;\n            }\n            if (x & 0x20 > 0) {\n                result = (result * 0x10000000000000016) >> 64;\n            }\n            if (x & 0x10 > 0) {\n                result = (result * 0x1000000000000000B) >> 64;\n            }\n            if (x & 0x8 > 0) {\n                result = (result * 0x10000000000000006) >> 64;\n            }\n            if (x & 0x4 > 0) {\n                result = (result * 0x10000000000000003) >> 64;\n            }\n            if (x & 0x2 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n            if (x & 0x1 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n        }\n\n        // We're doing two things at the same time:\n        //\n        //   1. Multiply the result by 2^n + 1, where \"2^n\" is the integer part and the one is added to account for\n        //      the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191\n        //      rather than 192.\n        //   2. Convert the result to the unsigned 60.18-decimal fixed-point format.\n        //\n        // This works because 2^(191-ip) = 2^ip / 2^191, where \"ip\" is the integer part \"2^n\".\n        result *= UNIT;\n        result >>= (191 - (x >> 64));\n    }\n}\n\n/// @notice Calculates the square root of x, rounding down if x is not a perfect square.\n/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n/// Credits to OpenZeppelin for the explanations in code comments below.\n///\n/// Caveats:\n/// - This function does not work with fixed-point numbers.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as an uint256.\nfunction prbSqrt(uint256 x) pure returns (uint256 result) {\n    if (x == 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 x.\n    //\n    // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n    //\n    // $$\n    // msb(x) <= x <= 2*msb(x)$\n    // $$\n    //\n    // We write $msb(x)$ as $2^k$ and we get:\n    //\n    // $$\n    // k = log_2(x)\n    // $$\n    //\n    // Thus we can write the initial inequality as:\n    //\n    // $$\n    // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n    // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n    // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n    // $$\n    //\n    // Consequently, $2^{log_2(x) /2}` is a good first approximation of sqrt(x) with at least one correct bit.\n    uint256 xAux = uint256(x);\n    result = 1;\n    if (xAux >= 2 ** 128) {\n        xAux >>= 128;\n        result <<= 64;\n    }\n    if (xAux >= 2 ** 64) {\n        xAux >>= 64;\n        result <<= 32;\n    }\n    if (xAux >= 2 ** 32) {\n        xAux >>= 32;\n        result <<= 16;\n    }\n    if (xAux >= 2 ** 16) {\n        xAux >>= 16;\n        result <<= 8;\n    }\n    if (xAux >= 2 ** 8) {\n        xAux >>= 8;\n        result <<= 4;\n    }\n    if (xAux >= 2 ** 4) {\n        xAux >>= 4;\n        result <<= 2;\n    }\n    if (xAux >= 2 ** 2) {\n        result <<= 1;\n    }\n\n    // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n    // most 128 bits, since  it is the square root of a uint256. Newton's method converges quadratically (precision\n    // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n    // precision into the expected uint128 result.\n    unchecked {\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n        result = (result + x / result) >> 1;\n\n        // Round down the result in case x is not a perfect square.\n        uint256 roundedDownResult = x / result;\n        if (result >= roundedDownResult) {\n            result = roundedDownResult;\n        }\n    }\n}\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd1x18/ValueType.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"./Casting.sol\" as C;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18 decimals.\n/// The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity type int64.\n/// This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n                                    CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing { C.intoSD59x18, C.intoUD2x18, C.intoUD60x18, C.intoUint256, C.intoUint128, C.intoUint40, C.unwrap } for SD1x18 global;\n"},{"file_path":"lib/mento-core-2.6.5/lib/prb-math/src/sd1x18/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Emitted when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n"},{"file_path":"lib/mento-core-2.5.0/lib/prb-math/src/sd59x18/Constants.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev log2(10) as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev log2(e) as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit amount that implies how many trailing decimals can be represented.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n"},{"file_path":"lib/mento-core-2.5.0/contracts/interfaces/IChainlinkRelayer.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.5.13 <0.9;\npragma experimental ABIEncoderV2;\n\ninterface IChainlinkRelayer {\n  /**\n   * @notice Struct used to represent a segment in the price path.\n   * @member aggregator The address of the Chainlink aggregator.\n   * @member invert Wether to invert the aggregator's price feed, i.e. convert CELO/USD to USD/CELO.\n   */\n  struct ChainlinkAggregator {\n    address aggregator;\n    bool invert;\n  }\n\n  function rateFeedId() external returns (address);\n\n  function rateFeedDescription() external returns (string memory);\n\n  function sortedOracles() external returns (address);\n\n  function getAggregators() external returns (ChainlinkAggregator[] memory);\n\n  function maxTimestampSpread() external returns (uint256);\n\n  function relay() external;\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"_rateFeedId","type":"address"},{"internalType":"string","name":"_rateFeedDescription","type":"string"},{"internalType":"address","name":"_sortedOracles","type":"address"},{"internalType":"uint256","name":"_maxTimestampSpread","type":"uint256"},{"components":[{"internalType":"address","name":"aggregator","type":"address"},{"internalType":"bool","name":"invert","type":"bool"}],"internalType":"struct IChainlinkRelayer.ChainlinkAggregator[]","name":"_aggregators","type":"tuple[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ExpiredTimestamp","type":"error"},{"inputs":[],"name":"InvalidAggregator","type":"error"},{"inputs":[],"name":"InvalidMaxTimestampSpread","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"NoAggregators","type":"error"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"PRBMath_MulDiv18_Overflow","type":"error"},{"inputs":[],"name":"TimestampNotNew","type":"error"},{"inputs":[],"name":"TimestampSpreadTooHigh","type":"error"},{"inputs":[],"name":"TooManyAggregators","type":"error"},{"inputs":[],"name":"TooManyExistingReports","type":"error"},{"inputs":[],"name":"getAggregators","outputs":[{"components":[{"internalType":"address","name":"aggregator","type":"address"},{"internalType":"bool","name":"invert","type":"bool"}],"internalType":"struct IChainlinkRelayer.ChainlinkAggregator[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTimestampSpread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rateFeedDescription","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rateFeedId","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"relay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sortedOracles","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":true,"constructor_args":"0x000000000000000000000000bacee37d31b9f022ef5d232b9fd53f05a531c16900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b33000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000074b45532f5553440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000826492a24b1dbd1d8fcb4701b38c557ce685e9d0000000000000000000000000000000000000000000000000000000000000000"}