{"file_path":"lib/mento-core-2.2.0/contracts/oracles/breakers/MedianDeltaBreaker.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport { Ownable } from \"openzeppelin-solidity/contracts/ownership/Ownable.sol\";\nimport { SafeMath } from \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\n\nimport { FixidityLib } from \"../../common/FixidityLib.sol\";\nimport { IBreaker } from \"../../interfaces/IBreaker.sol\";\nimport { ISortedOracles } from \"../../interfaces/ISortedOracles.sol\";\n\nimport { WithCooldown } from \"./WithCooldown.sol\";\nimport { WithThreshold } from \"./WithThreshold.sol\";\n\n/**\n * @title   Median Delta Breaker\n * @notice  Breaker contract that will trigger when an updated oracle median rate changes\n *          more than a configured relative threshold from the previous one. If this\n *          breaker is triggered for a rate feed it should be set to no trading mode.\n */\ncontract MedianDeltaBreaker is IBreaker, WithCooldown, WithThreshold, Ownable {\n  using SafeMath for uint256;\n  using FixidityLib for FixidityLib.Fraction;\n\n  /* ==================== Events ==================== */\n  event SmoothingFactorSet(address rateFeedId, uint256 smoothingFactor);\n  event BreakerBoxUpdated(address breakerBox);\n\n  event MedianRateEMAReset(address rateFeedID);\n\n  /* ==================== State Variables ==================== */\n  // Address of the Mento SortedOracles contract\n  ISortedOracles public sortedOracles;\n\n  // Address of the BreakerBox contract\n  address public breakerBox;\n\n  // Default smoothing factor for EMA as a Fixidity value\n  uint256 public constant DEFAULT_SMOOTHING_FACTOR = 1e24;\n\n  // Smoothing factor per rate feed\n  mapping(address => FixidityLib.Fraction) public smoothingFactors;\n\n  // EMA of the median rates per rate feed\n  mapping(address => uint256) public medianRatesEMA;\n\n  /* ==================== Constructor ==================== */\n\n  constructor(\n    uint256 _defaultCooldownTime,\n    uint256 _defaultRateChangeThreshold,\n    ISortedOracles _sortedOracles,\n    address _breakerBox,\n    address[] memory rateFeedIDs,\n    uint256[] memory rateChangeThresholds,\n    uint256[] memory cooldownTimes\n  ) public {\n    _transferOwnership(msg.sender);\n    setSortedOracles(_sortedOracles);\n    setBreakerBox(_breakerBox);\n\n    _setDefaultCooldownTime(_defaultCooldownTime);\n    _setDefaultRateChangeThreshold(_defaultRateChangeThreshold);\n    _setRateChangeThresholds(rateFeedIDs, rateChangeThresholds);\n    _setCooldownTimes(rateFeedIDs, cooldownTimes);\n  }\n\n  /* ==================== Restricted Functions ==================== */\n\n  /**\n   * @notice Sets the cooldown time to the specified value for a rate feed.\n   * @param rateFeedIDs the targeted rate feed.\n   * @param cooldownTimes The new cooldownTime value.\n   * @dev Should be set to 0 to force a manual reset.\n   */\n  function setCooldownTime(address[] calldata rateFeedIDs, uint256[] calldata cooldownTimes) external onlyOwner {\n    _setCooldownTimes(rateFeedIDs, cooldownTimes);\n  }\n\n  /**\n   * @notice Sets the cooldownTime to the specified value for a rate feed.\n   * @param cooldownTime The new cooldownTime value.\n   * @dev Should be set to 0 to force a manual reset.\n   */\n  function setDefaultCooldownTime(uint256 cooldownTime) external onlyOwner {\n    _setDefaultCooldownTime(cooldownTime);\n  }\n\n  /**\n   * @notice Sets rateChangeThreshold.\n   * @param _defaultRateChangeThreshold The new rateChangeThreshold value.\n   */\n  function setDefaultRateChangeThreshold(uint256 _defaultRateChangeThreshold) external onlyOwner {\n    _setDefaultRateChangeThreshold(_defaultRateChangeThreshold);\n  }\n\n  /**\n   * @notice Configures rate feed to rate threshold pairs.\n   * @param rateFeedIDs Collection of the addresses rate feeds.\n   * @param rateChangeThresholds Collection of the rate thresholds.\n   */\n  function setRateChangeThresholds(address[] calldata rateFeedIDs, uint256[] calldata rateChangeThresholds)\n    external\n    onlyOwner\n  {\n    _setRateChangeThresholds(rateFeedIDs, rateChangeThresholds);\n  }\n\n  /**\n   * @notice Sets the address of the sortedOracles contract.\n   * @param _sortedOracles The new address of the sorted oracles contract.\n   */\n  function setSortedOracles(ISortedOracles _sortedOracles) public onlyOwner {\n    require(address(_sortedOracles) != address(0), \"SortedOracles address must be set\");\n    sortedOracles = _sortedOracles;\n    emit SortedOraclesUpdated(address(_sortedOracles));\n  }\n\n  /**\n   * @notice Sets the address of the BreakerBox contract.\n   * @param _breakerBox The new address of the breaker box contract.\n   */\n  function setBreakerBox(address _breakerBox) public onlyOwner {\n    require(_breakerBox != address(0), \"BreakerBox address must be set\");\n    breakerBox = _breakerBox;\n    emit BreakerBoxUpdated(_breakerBox);\n  }\n\n  /*\n   * @notice Sets the smoothing factor for a rate feed.\n   * @param rateFeedID The rate feed to be updated.\n   * @param smoothingFactor The new smoothingFactor value.\n   */\n  function setSmoothingFactor(address rateFeedID, uint256 newSmoothingFactor) external onlyOwner {\n    FixidityLib.Fraction memory _newSmoothingFactor = FixidityLib.wrap(newSmoothingFactor);\n    require(_newSmoothingFactor.lte(FixidityLib.fixed1()), \"Smoothing factor must be <= 1\");\n    smoothingFactors[rateFeedID] = _newSmoothingFactor;\n    emit SmoothingFactorSet(rateFeedID, newSmoothingFactor);\n  }\n\n  /**\n   * @notice Resets the median rates EMA for a rate feed.\n   * @param rateFeedID the targeted rate feed.\n   * @dev Should be called when the breaker is disabled for a rate feed.\n   */\n  function resetMedianRateEMA(address rateFeedID) external onlyOwner {\n    require(rateFeedID != address(0), \"RateFeed address must be set\");\n    medianRatesEMA[rateFeedID] = 0;\n    emit MedianRateEMAReset(rateFeedID);\n  }\n\n  /* ==================== View Functions ==================== */\n\n  /**\n   * @notice  Get the smoothing factor for a rate feed.\n   * @param   rateFeedID The rate feed to be checked.\n   * @return  smoothingFactor The smoothingFactor for the rate feed.\n   */\n  function getSmoothingFactor(address rateFeedID) public view returns (uint256) {\n    uint256 factor = smoothingFactors[rateFeedID].unwrap();\n    if (factor == 0) {\n      return DEFAULT_SMOOTHING_FACTOR;\n    }\n    return factor;\n  }\n\n  /**\n   * @notice  Check if the current median report rate for a rate feed change, relative\n   *          to the last median report, is greater than the configured threshold.\n   *          If the change is greater than the threshold the breaker will be triggered.\n   * @param   rateFeedID The rate feed to be checked.\n   * @return  triggerBreaker  A bool indicating whether or not this breaker\n   *                          should be tripped for the rate feed.\n   */\n  function shouldTrigger(address rateFeedID) public returns (bool triggerBreaker) {\n    require(msg.sender == breakerBox, \"Caller must be the BreakerBox contract\");\n\n    (uint256 currentMedian, ) = sortedOracles.medianRate(rateFeedID);\n\n    uint256 previousRatesEMA = medianRatesEMA[rateFeedID];\n    if (previousRatesEMA == 0) {\n      // Previous recorded EMA will be 0 the first time this rate feed is checked.\n      medianRatesEMA[rateFeedID] = currentMedian;\n      return false;\n    }\n\n    FixidityLib.Fraction memory smoothingFactor = FixidityLib.wrap(getSmoothingFactor(rateFeedID));\n    medianRatesEMA[rateFeedID] = FixidityLib\n      .wrap(currentMedian)\n      .multiply(smoothingFactor)\n      .add(FixidityLib.wrap(previousRatesEMA).multiply(FixidityLib.fixed1().subtract(smoothingFactor)))\n      .unwrap();\n\n    return exceedsThreshold(previousRatesEMA, currentMedian, rateFeedID);\n  }\n\n  /**\n   * @notice  Checks whether or not the conditions have been met\n   *          for the specifed rate feed to be reset.\n   * @return  resetBreaker A bool indicating whether or not\n   *          this breaker can be reset for the given rate feed.\n   */\n  function shouldReset(address rateFeedID) external returns (bool resetBreaker) {\n    return !shouldTrigger(rateFeedID);\n  }\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c806353f5d6f1116100ee5780638da5cb5b11610097578063bfc7c45011610071578063bfc7c450146105a1578063f2fde38b146105c7578063f414c5e4146105ed578063fd165f53146105f5576101ae565b80638da5cb5b146105895780638f32d59b14610591578063a44235cb14610599576101ae565b8063715018a6116100c8578063715018a614610529578063753d8c2f146105315780638c54acdc14610563576101ae565b806353f5d6f1146104ac5780635ac3ff70146104d257806368b89d58146104ef576101ae565b806313df95c91161015b5780633151e220116101355780633151e2201461037257806339b84ecf1461039e5780634afb215e146103c45780634e510e88146103ea576101ae565b806313df95c91461031e5780631893304f146103445780632e37ff731461036a576101ae565b80630c62541e1161018c5780630c62541e146102ba5780630f42151f146102d4578063132e8aa7146102fa576101ae565b8063020323dd146101b3578063040bbd351461027757806305e047851461029d575b600080fd5b610275600480360360408110156101c957600080fd5b8101906020810181356401000000008111156101e457600080fd5b8201836020820111156101f657600080fd5b8035906020019184602083028401116401000000008311171561021857600080fd5b91939092909160208101903564010000000081111561023657600080fd5b82018360208201111561024857600080fd5b8035906020019184602083028401116401000000008311171561026a57600080fd5b50909250905061061b565b005b6102756004803603602081101561028d57600080fd5b50356001600160a01b03166106e7565b610275600480360360208110156102b357600080fd5b5035610807565b6102c261086c565b60408051918252519081900360200190f35b6102c2600480360360208110156102ea57600080fd5b50356001600160a01b031661087a565b61030261088c565b604080516001600160a01b039092168252519081900360200190f35b6102c26004803603602081101561033457600080fd5b50356001600160a01b031661089b565b6102c26004803603602081101561035a57600080fd5b50356001600160a01b03166108ee565b6102c2610900565b6102756004803603604081101561038857600080fd5b506001600160a01b038135169060200135610906565b6102c2600480360360208110156103b457600080fd5b50356001600160a01b0316610a36565b610275600480360360208110156103da57600080fd5b50356001600160a01b0316610a5e565b6102756004803603604081101561040057600080fd5b81019060208101813564010000000081111561041b57600080fd5b82018360208201111561042d57600080fd5b8035906020019184602083028401116401000000008311171561044f57600080fd5b91939092909160208101903564010000000081111561046d57600080fd5b82018360208201111561047f57600080fd5b803590602001918460208302840111640100000000831117156104a157600080fd5b509092509050610b68565b6102c2600480360360208110156104c257600080fd5b50356001600160a01b0316610c2e565b610275600480360360208110156104e857600080fd5b5035610c40565b6105156004803603602081101561050557600080fd5b50356001600160a01b0316610ca2565b604080519115158252519081900360200190f35b610275610cb4565b6105156004803603606081101561054757600080fd5b50803590602081013590604001356001600160a01b0316610d6f565b6102c26004803603602081101561057957600080fd5b50356001600160a01b0316610e74565b610302610e86565b610515610e95565b6102c2610ebb565b610275600480360360208110156105b757600080fd5b50356001600160a01b0316610ec1565b610275600480360360208110156105dd57600080fd5b50356001600160a01b0316610fc8565b61030261102a565b6105156004803603602081101561060b57600080fd5b50356001600160a01b0316611039565b610623610e95565b610674576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e1848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506111f292505050565b50505050565b6106ef610e95565b610740576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661079b576040805162461bcd60e51b815260206004820152601e60248201527f427265616b6572426f782061646472657373206d757374206265207365740000604482015290519081900360640190fd5b600680546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f21921b3b46ef2c939e85d6a14410c6e3b9ce132b66e944357ff4f789f68e00e29181900360200190a150565b61080f610e95565b610860576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6108698161141d565b50565b69d3c21bcecceda100000081565b60086020526000908152604090205481565b6005546001600160a01b031681565b6001600160a01b0381166000908152600760209081526040808320815192830190915254815281906108cc906114d8565b9050806108e65769d3c21bcecceda10000009150506108e9565b90505b919050565b60036020526000908152604090205481565b60005481565b61090e610e95565b61095f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610967611edb565b610970826114dc565b905061098a61097d6114f6565b829063ffffffff61151a16565b6109db576040805162461bcd60e51b815260206004820152601d60248201527f536d6f6f7468696e6720666163746f72206d757374206265203c3d2031000000604482015290519081900360640190fd5b6001600160a01b038316600081815260076020908152604091829020845190558151928352820184905280517f6024a1181d4b6670f0122b1101b175bd17051e91a5b57e85972a9187c3f9721c9281900390910190a1505050565b6001600160a01b038116600090815260016020526040812054806108e65750506000546108e9565b610a66610e95565b610ab7576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610afc5760405162461bcd60e51b8152600401808060200182810382526021815260200180611f5c6021913960400191505060405180910390fd5b600580546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b610b70610e95565b610bc1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e18484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061152792505050565b60016020526000908152604090205481565b610c48610e95565b610c99576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610869816116c7565b6000610cad82611039565b1592915050565b610cbc610e95565b610d0d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6004546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080516020810190915260025481526000908190610d8d906114d8565b6001600160a01b0384166000908152600360209081526040808320815192830190915254815291925090610dc0906114d8565b90508015610dcc578091505b6000610dde610dd96114f6565b6114d8565b90506000610df2828563ffffffff61170216565b90506000610e2069d3c21bcecceda1000000610e148b8563ffffffff61176316565b9063ffffffff6117bc16565b90506000610e34848763ffffffff6117fe16565b90506000610e5669d3c21bcecceda1000000610e148d8563ffffffff61176316565b9050808a1080610e655750828a115b9b9a5050505050505050505050565b60076020526000908152604090205481565b6004546001600160a01b031690565b6004546000906001600160a01b0316610eac611840565b6001600160a01b031614905090565b60025481565b610ec9610e95565b610f1a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610f75576040805162461bcd60e51b815260206004820152601c60248201527f52617465466565642061646472657373206d7573742062652073657400000000604482015290519081900360640190fd5b6001600160a01b038116600081815260086020908152604080832092909255815192835290517f76d186fb6f7faabecd3480fe1bc33d485f376eaed587ac952f4f2e9aca4c29319281900390910190a150565b610fd0610e95565b611021576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61086981611844565b6006546001600160a01b031681565b6006546000906001600160a01b031633146110855760405162461bcd60e51b8152600401808060200182810382526026815260200180611f366026913960400191505060405180910390fd5b600554604080517fef90e1b00000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301528251600094919091169263ef90e1b09260248082019391829003018186803b1580156110ea57600080fd5b505afa1580156110fe573d6000803e3d6000fd5b505050506040513d604081101561111457600080fd5b50516001600160a01b0384166000908152600860205260409020549091508061115b57506001600160a01b03831660009081526008602052604081209190915590506108e9565b611163611edb565b61117461116f8661089b565b6114dc565b90506111c5610dd96111ac6111978461118b6114f6565b9063ffffffff6118fd16565b6111a0866114dc565b9063ffffffff61197516565b6111b9846111a0886114dc565b9063ffffffff611ce716565b6001600160a01b0386166000908152600860205260409020556111e9828487610d6f565b95945050505050565b8051825114611248576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156114185760006001600160a01b031683828151811061126b57fe5b60200260200101516001600160a01b031614156112cf576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b6112d7611edb565b6112f38383815181106112e657fe5b60200260200101516114dc565b905061130d6113006114f6565b829063ffffffff611d6016565b61135e576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b806003600086858151811061136f57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a3398483815181106113d157fe5b60200260200101518484815181106113e557fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a15060010161124b565b505050565b611426816114dc565b516002556114516114356114f6565b604080516020810190915260025481529063ffffffff611d6016565b6114a2576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b5190565b6114e4611edb565b50604080516020810190915290815290565b6114fe611edb565b50604080516020810190915269d3c21bcecceda1000000815290565b8051825111155b92915050565b805182511461157d576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156114185760006001600160a01b03168382815181106115a057fe5b60200260200101516001600160a01b03161415611604576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b81818151811061161057fe5b60200260200101516001600085848151811061162857fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c83828151811061168157fe5b602002602001015183838151811061169557fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a1600101611580565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b60008282018381101561175c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60008261177257506000611521565b8282028284828161177f57fe5b041461175c5760405162461bcd60e51b8152600401808060200182810382526021815260200180611f156021913960400191505060405180910390fd5b600061175c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d67565b600061175c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e09565b3390565b6001600160a01b0381166118895760405162461bcd60e51b8152600401808060200182810382526026815260200180611eef6026913960400191505060405180910390fd5b6004546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b611905611edb565b81518351101561195c576040805162461bcd60e51b815260206004820152601f60248201527f737562737472616374696f6e20756e646572666c6f7720646574656374656400604482015290519081900360640190fd5b5060408051602081019091528151835103815292915050565b61197d611edb565b8251158061198a57508151155b156119a45750604080516020810190915260008152611521565b815169d3c21bcecceda100000014156119be575081611521565b825169d3c21bcecceda100000014156119d8575080611521565b600069d3c21bcecceda10000006119ee85611e63565b51816119f657fe5b0490506000611a0485611e98565b519050600069d3c21bcecceda1000000611a1d86611e63565b5181611a2557fe5b0490506000611a3386611e98565b5190508382028415611a9c5782858281611a4957fe5b0414611a9c576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda100000081028115611b165769d3c21bcecceda1000000828281611ac357fe5b0414611b16576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b9050808484028515611b7f5784868281611b2c57fe5b0414611b7f576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b8684028715611be55784888281611b9257fe5b0414611be5576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b611bed611ed2565b8781611bf557fe5b049650611c00611ed2565b8581611c0857fe5b0494508685028715611c715785888281611c1e57fe5b0414611c71576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b611c79611edb565b6040518060200160405280878152509050611ca281604051806020016040528087815250611ce7565b9050611cbc81604051806020016040528086815250611ce7565b9050611cd681604051806020016040528085815250611ce7565b9d9c50505050505050505050505050565b611cef611edb565b8151835190810190811015611d4b576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5190511090565b60008183611df35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611db8578181015183820152602001611da0565b50505050905090810190601f168015611de55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611dff57fe5b0495945050505050565b60008184841115611e5b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611db8578181015183820152602001611da0565b505050900390565b611e6b611edb565b604051806020016040528069d3c21bcecceda100000080856000015181611e8e57fe5b0402905292915050565b611ea0611edb565b604051806020016040528069d3c21bcecceda100000080856000015181611ec357fe5b95519504029093039092525090565b64e8d4a5100090565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206d7573742062652074686520427265616b6572426f7820636f6e7472616374536f727465644f7261636c65732061646472657373206d75737420626520736574a265627a7a723158207a2eb89744c25c339de9fe8f267099b95edbfaab1b116140e038913dcc16d60464736f6c63430005110032","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"istanbul","libraries":{"AddressLinkedList":"0x6200f54d73491d56b8d7a975c9ee18efb4d518df","AddressSortedLinkedListWithMedian":"0xed477a99035d0c1e11369f1d7a4e587893cc002b"},"optimizer":{"enabled":true,"runs":10000},"remappings":[":celo-foundry/=lib/celo-foundry/src/",":contracts/=contracts/",":ds-test/=lib/celo-foundry/lib/forge-std/lib/ds-test/src/",":forge-std-next/=lib/mento-core-2.2.0/lib/forge-std-next/src/",":forge-std/=lib/celo-foundry/lib/forge-std/src/",":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/",":openzeppelin-contracts-next/=lib/mento-core-2.2.0/lib/openzeppelin-contracts-next/",":openzeppelin-contracts-upgradeable/=lib/mento-core-2.2.0/lib/openzeppelin-contracts-upgradeable/",":openzeppelin-contracts/=lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/",":openzeppelin-solidity/=lib/mento-core-2.0.0/lib/openzeppelin-contracts/",":test/=lib/mento-core-2.0.0/test/"]},"optimization_runs":10000,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/full_match/42220/0x49349F92D2B17d491e42C8fdB02D19f072F9B5D9/","decoded_constructor_args":null,"compiler_version":"0.5.17+commit.d19bba13","is_verified_via_verifier_alliance":false,"verified_at":"2025-03-27T14:28:07.204212Z","implementations":[],"proxy_type":null,"external_libraries":[{"name":"AddressLinkedList","address_hash":"0x6200F54D73491d56b8d7A975C9ee18EFb4D518Df"},{"name":"AddressSortedLinkedListWithMedian","address_hash":"0xED477A99035d0c1e11369F1D7A4e587893cc002B"}],"creation_bytecode":"0x60806040523480156200001157600080fd5b5060405162002b4938038062002b49833981810160405260e08110156200003757600080fd5b81516020830151604080850151606086015160808701805193519597949692959194919392820192846401000000008211156200007357600080fd5b9083019060208201858111156200008957600080fd5b8251866020820283011164010000000082111715620000a757600080fd5b82525081516020918201928201910280838360005b83811015620000d6578181015183820152602001620000bc565b50505050905001604052602001805160405193929190846401000000008211156200010057600080fd5b9083019060208201858111156200011657600080fd5b82518660208202830111640100000000821117156200013457600080fd5b82525081516020918201928201910280838360005b838110156200016357818101518382015260200162000149565b50505050905001604052602001805160405193929190846401000000008211156200018d57600080fd5b908301906020820185811115620001a357600080fd5b8251866020820283011164010000000082111715620001c157600080fd5b82525081516020918201928201910280838360005b83811015620001f0578181015183820152602001620001d6565b5050505090500160405250505060006200020f620002e760201b60201c565b600480546001600160a01b0319166001600160a01b0383169081179091556040519192509060009060008051602062002b08833981519152908290a35062000260336001600160e01b03620002eb16565b62000274856001600160e01b036200037d16565b62000288846001600160e01b036200046c16565b6200029c876001600160e01b036200057016565b620002b0866001600160e01b03620005ab16565b620002c583836001600160e01b036200068916565b620002da83826001600160e01b03620008d716565b5050505050505062000b01565b3390565b6001600160a01b038116620003325760405162461bcd60e51b815260040180806020018281038252602681526020018062002ac26026913960400191505060405180910390fd5b6004546040516001600160a01b0380841692169060008051602062002b0883398151915290600090a3600480546001600160a01b0319166001600160a01b0392909216919091179055565b620003906001600160e01b0362000a7416565b620003d1576040805162461bcd60e51b8152602060048201819052602482015260008051602062002ae8833981519152604482015290519081900360640190fd5b6001600160a01b038116620004185760405162461bcd60e51b815260040180806020018281038252602181526020018062002b286021913960400191505060405180910390fd5b600580546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b6200047f6001600160e01b0362000a7416565b620004c0576040805162461bcd60e51b8152602060048201819052602482015260008051602062002ae8833981519152604482015290519081900360640190fd5b6001600160a01b0381166200051c576040805162461bcd60e51b815260206004820152601e60248201527f427265616b6572426f782061646472657373206d757374206265207365740000604482015290519081900360640190fd5b600680546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f21921b3b46ef2c939e85d6a14410c6e3b9ce132b66e944357ff4f789f68e00e29181900360200190a150565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b620005c18162000aa560201b620014dc1760201c565b5160025562000601620005df62000ac1602090811b620014f617901c565b6040805160208082019092526002548152919062001d6062000ae7821b17901c565b62000653576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b8051825114620006e0576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620008d25760006001600160a01b03168382815181106200070557fe5b60200260200101516001600160a01b031614156200075e576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b6200076862000aee565b620007928383815181106200077957fe5b602002602001015162000aa560201b620014dc1760201c565b9050620007c2620007ad62000ac160201b620014f61760201c565b8262000ae760201b62001d601790919060201c565b62000814576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b80600360008685815181106200082657fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a3398483815181106200088957fe5b60200260200101518484815181106200089e57fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a150600101620006e3565b505050565b80518251146200092e576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620008d25760006001600160a01b03168382815181106200095357fe5b60200260200101516001600160a01b03161415620009ac576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b818181518110620009b957fe5b602002602001015160016000858481518110620009d257fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c83828151811062000a2c57fe5b602002602001015183838151811062000a4157fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a160010162000931565b6004546000906001600160a01b031662000a966001600160e01b03620002e716565b6001600160a01b031614905090565b62000aaf62000aee565b50604080516020810190915290815290565b62000acb62000aee565b50604080516020810190915269d3c21bcecceda1000000815290565b5190511090565b6040518060200160405280600081525090565b611fb18062000b116000396000f3fe608060405234801561001057600080fd5b50600436106101ae5760003560e01c806353f5d6f1116100ee5780638da5cb5b11610097578063bfc7c45011610071578063bfc7c450146105a1578063f2fde38b146105c7578063f414c5e4146105ed578063fd165f53146105f5576101ae565b80638da5cb5b146105895780638f32d59b14610591578063a44235cb14610599576101ae565b8063715018a6116100c8578063715018a614610529578063753d8c2f146105315780638c54acdc14610563576101ae565b806353f5d6f1146104ac5780635ac3ff70146104d257806368b89d58146104ef576101ae565b806313df95c91161015b5780633151e220116101355780633151e2201461037257806339b84ecf1461039e5780634afb215e146103c45780634e510e88146103ea576101ae565b806313df95c91461031e5780631893304f146103445780632e37ff731461036a576101ae565b80630c62541e1161018c5780630c62541e146102ba5780630f42151f146102d4578063132e8aa7146102fa576101ae565b8063020323dd146101b3578063040bbd351461027757806305e047851461029d575b600080fd5b610275600480360360408110156101c957600080fd5b8101906020810181356401000000008111156101e457600080fd5b8201836020820111156101f657600080fd5b8035906020019184602083028401116401000000008311171561021857600080fd5b91939092909160208101903564010000000081111561023657600080fd5b82018360208201111561024857600080fd5b8035906020019184602083028401116401000000008311171561026a57600080fd5b50909250905061061b565b005b6102756004803603602081101561028d57600080fd5b50356001600160a01b03166106e7565b610275600480360360208110156102b357600080fd5b5035610807565b6102c261086c565b60408051918252519081900360200190f35b6102c2600480360360208110156102ea57600080fd5b50356001600160a01b031661087a565b61030261088c565b604080516001600160a01b039092168252519081900360200190f35b6102c26004803603602081101561033457600080fd5b50356001600160a01b031661089b565b6102c26004803603602081101561035a57600080fd5b50356001600160a01b03166108ee565b6102c2610900565b6102756004803603604081101561038857600080fd5b506001600160a01b038135169060200135610906565b6102c2600480360360208110156103b457600080fd5b50356001600160a01b0316610a36565b610275600480360360208110156103da57600080fd5b50356001600160a01b0316610a5e565b6102756004803603604081101561040057600080fd5b81019060208101813564010000000081111561041b57600080fd5b82018360208201111561042d57600080fd5b8035906020019184602083028401116401000000008311171561044f57600080fd5b91939092909160208101903564010000000081111561046d57600080fd5b82018360208201111561047f57600080fd5b803590602001918460208302840111640100000000831117156104a157600080fd5b509092509050610b68565b6102c2600480360360208110156104c257600080fd5b50356001600160a01b0316610c2e565b610275600480360360208110156104e857600080fd5b5035610c40565b6105156004803603602081101561050557600080fd5b50356001600160a01b0316610ca2565b604080519115158252519081900360200190f35b610275610cb4565b6105156004803603606081101561054757600080fd5b50803590602081013590604001356001600160a01b0316610d6f565b6102c26004803603602081101561057957600080fd5b50356001600160a01b0316610e74565b610302610e86565b610515610e95565b6102c2610ebb565b610275600480360360208110156105b757600080fd5b50356001600160a01b0316610ec1565b610275600480360360208110156105dd57600080fd5b50356001600160a01b0316610fc8565b61030261102a565b6105156004803603602081101561060b57600080fd5b50356001600160a01b0316611039565b610623610e95565b610674576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e1848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506111f292505050565b50505050565b6106ef610e95565b610740576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661079b576040805162461bcd60e51b815260206004820152601e60248201527f427265616b6572426f782061646472657373206d757374206265207365740000604482015290519081900360640190fd5b600680546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f21921b3b46ef2c939e85d6a14410c6e3b9ce132b66e944357ff4f789f68e00e29181900360200190a150565b61080f610e95565b610860576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6108698161141d565b50565b69d3c21bcecceda100000081565b60086020526000908152604090205481565b6005546001600160a01b031681565b6001600160a01b0381166000908152600760209081526040808320815192830190915254815281906108cc906114d8565b9050806108e65769d3c21bcecceda10000009150506108e9565b90505b919050565b60036020526000908152604090205481565b60005481565b61090e610e95565b61095f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610967611edb565b610970826114dc565b905061098a61097d6114f6565b829063ffffffff61151a16565b6109db576040805162461bcd60e51b815260206004820152601d60248201527f536d6f6f7468696e6720666163746f72206d757374206265203c3d2031000000604482015290519081900360640190fd5b6001600160a01b038316600081815260076020908152604091829020845190558151928352820184905280517f6024a1181d4b6670f0122b1101b175bd17051e91a5b57e85972a9187c3f9721c9281900390910190a1505050565b6001600160a01b038116600090815260016020526040812054806108e65750506000546108e9565b610a66610e95565b610ab7576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610afc5760405162461bcd60e51b8152600401808060200182810382526021815260200180611f5c6021913960400191505060405180910390fd5b600580546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b610b70610e95565b610bc1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e18484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061152792505050565b60016020526000908152604090205481565b610c48610e95565b610c99576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610869816116c7565b6000610cad82611039565b1592915050565b610cbc610e95565b610d0d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6004546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080516020810190915260025481526000908190610d8d906114d8565b6001600160a01b0384166000908152600360209081526040808320815192830190915254815291925090610dc0906114d8565b90508015610dcc578091505b6000610dde610dd96114f6565b6114d8565b90506000610df2828563ffffffff61170216565b90506000610e2069d3c21bcecceda1000000610e148b8563ffffffff61176316565b9063ffffffff6117bc16565b90506000610e34848763ffffffff6117fe16565b90506000610e5669d3c21bcecceda1000000610e148d8563ffffffff61176316565b9050808a1080610e655750828a115b9b9a5050505050505050505050565b60076020526000908152604090205481565b6004546001600160a01b031690565b6004546000906001600160a01b0316610eac611840565b6001600160a01b031614905090565b60025481565b610ec9610e95565b610f1a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610f75576040805162461bcd60e51b815260206004820152601c60248201527f52617465466565642061646472657373206d7573742062652073657400000000604482015290519081900360640190fd5b6001600160a01b038116600081815260086020908152604080832092909255815192835290517f76d186fb6f7faabecd3480fe1bc33d485f376eaed587ac952f4f2e9aca4c29319281900390910190a150565b610fd0610e95565b611021576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61086981611844565b6006546001600160a01b031681565b6006546000906001600160a01b031633146110855760405162461bcd60e51b8152600401808060200182810382526026815260200180611f366026913960400191505060405180910390fd5b600554604080517fef90e1b00000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301528251600094919091169263ef90e1b09260248082019391829003018186803b1580156110ea57600080fd5b505afa1580156110fe573d6000803e3d6000fd5b505050506040513d604081101561111457600080fd5b50516001600160a01b0384166000908152600860205260409020549091508061115b57506001600160a01b03831660009081526008602052604081209190915590506108e9565b611163611edb565b61117461116f8661089b565b6114dc565b90506111c5610dd96111ac6111978461118b6114f6565b9063ffffffff6118fd16565b6111a0866114dc565b9063ffffffff61197516565b6111b9846111a0886114dc565b9063ffffffff611ce716565b6001600160a01b0386166000908152600860205260409020556111e9828487610d6f565b95945050505050565b8051825114611248576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156114185760006001600160a01b031683828151811061126b57fe5b60200260200101516001600160a01b031614156112cf576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b6112d7611edb565b6112f38383815181106112e657fe5b60200260200101516114dc565b905061130d6113006114f6565b829063ffffffff611d6016565b61135e576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b806003600086858151811061136f57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a3398483815181106113d157fe5b60200260200101518484815181106113e557fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a15060010161124b565b505050565b611426816114dc565b516002556114516114356114f6565b604080516020810190915260025481529063ffffffff611d6016565b6114a2576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b5190565b6114e4611edb565b50604080516020810190915290815290565b6114fe611edb565b50604080516020810190915269d3c21bcecceda1000000815290565b8051825111155b92915050565b805182511461157d576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156114185760006001600160a01b03168382815181106115a057fe5b60200260200101516001600160a01b03161415611604576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b81818151811061161057fe5b60200260200101516001600085848151811061162857fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c83828151811061168157fe5b602002602001015183838151811061169557fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a1600101611580565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b60008282018381101561175c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60008261177257506000611521565b8282028284828161177f57fe5b041461175c5760405162461bcd60e51b8152600401808060200182810382526021815260200180611f156021913960400191505060405180910390fd5b600061175c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d67565b600061175c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e09565b3390565b6001600160a01b0381166118895760405162461bcd60e51b8152600401808060200182810382526026815260200180611eef6026913960400191505060405180910390fd5b6004546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b611905611edb565b81518351101561195c576040805162461bcd60e51b815260206004820152601f60248201527f737562737472616374696f6e20756e646572666c6f7720646574656374656400604482015290519081900360640190fd5b5060408051602081019091528151835103815292915050565b61197d611edb565b8251158061198a57508151155b156119a45750604080516020810190915260008152611521565b815169d3c21bcecceda100000014156119be575081611521565b825169d3c21bcecceda100000014156119d8575080611521565b600069d3c21bcecceda10000006119ee85611e63565b51816119f657fe5b0490506000611a0485611e98565b519050600069d3c21bcecceda1000000611a1d86611e63565b5181611a2557fe5b0490506000611a3386611e98565b5190508382028415611a9c5782858281611a4957fe5b0414611a9c576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda100000081028115611b165769d3c21bcecceda1000000828281611ac357fe5b0414611b16576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b9050808484028515611b7f5784868281611b2c57fe5b0414611b7f576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b8684028715611be55784888281611b9257fe5b0414611be5576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b611bed611ed2565b8781611bf557fe5b049650611c00611ed2565b8581611c0857fe5b0494508685028715611c715785888281611c1e57fe5b0414611c71576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b611c79611edb565b6040518060200160405280878152509050611ca281604051806020016040528087815250611ce7565b9050611cbc81604051806020016040528086815250611ce7565b9050611cd681604051806020016040528085815250611ce7565b9d9c50505050505050505050505050565b611cef611edb565b8151835190810190811015611d4b576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5190511090565b60008183611df35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611db8578181015183820152602001611da0565b50505050905090810190601f168015611de55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611dff57fe5b0495945050505050565b60008184841115611e5b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611db8578181015183820152602001611da0565b505050900390565b611e6b611edb565b604051806020016040528069d3c21bcecceda100000080856000015181611e8e57fe5b0402905292915050565b611ea0611edb565b604051806020016040528069d3c21bcecceda100000080856000015181611ec357fe5b95519504029093039092525090565b64e8d4a5100090565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206d7573742062652074686520427265616b6572426f7820636f6e7472616374536f727465644f7261636c65732061646472657373206d75737420626520736574a265627a7a723158207a2eb89744c25c339de9fe8f267099b95edbfaab1b116140e038913dcc16d60464736f6c634300051100324f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0536f727465644f7261636c65732061646472657373206d7573742062652073657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000efb84935239dacdecf7c5ba76d8de40b077b7b33000000000000000000000000303ed1df62fa067659b586ebee8de0ece824ab3900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","name":"MedianDeltaBreaker","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"istanbul","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"file_path":"lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/GSN/Context.sol","source_code":"pragma solidity ^0.5.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\ncontract Context {\n    // Empty internal constructor, to prevent people from mistakenly deploying\n    // an instance of this contract, which should be used via inheritance.\n    constructor () internal { }\n    // solhint-disable-previous-line no-empty-blocks\n\n    function _msgSender() internal view returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n}\n"},{"file_path":"lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/math/SafeMath.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return sub(a, b, \"SafeMath: subtraction overflow\");\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     * - Subtraction cannot overflow.\n     *\n     * _Available since v2.4.0._\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return div(a, b, \"SafeMath: division by zero\");\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     *\n     * _Available since v2.4.0._\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        // Solidity only automatically asserts when dividing by 0\n        require(b > 0, errorMessage);\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return mod(a, b, \"SafeMath: modulo by zero\");\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts with custom message when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     *\n     * _Available since v2.4.0._\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b != 0, errorMessage);\n        return a % b;\n    }\n}\n"},{"file_path":"lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/ownership/Ownable.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"../GSN/Context.sol\";\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor () internal {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(isOwner(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Returns true if the caller is the current owner.\n     */\n    function isOwner() public view returns (bool) {\n        return _msgSender() == _owner;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = address(0);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public onlyOwner {\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     */\n    function _transferOwnership(address newOwner) internal {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/common/FixidityLib.sol","source_code":"pragma solidity ^0.5.13;\n\n/**\n * @title FixidityLib\n * @author Gadi Guy, Alberto Cuesta Canada\n * @notice This library provides fixed point arithmetic with protection against\n * overflow.\n * All operations are done with uint256 and the operands must have been created\n * with any of the newFrom* functions, which shift the comma digits() to the\n * right and check for limits, or with wrap() which expects a number already\n * in the internal representation of a fraction.\n * When using this library be sure to use maxNewFixed() as the upper limit for\n * creation of fixed point numbers.\n * @dev All contained functions are pure and thus marked internal to be inlined\n * on consuming contracts at compile time for gas efficiency.\n */\nlibrary FixidityLib {\n  struct Fraction {\n    uint256 value;\n  }\n\n  /**\n   * @notice Number of positions that the comma is shifted to the right.\n   */\n  function digits() internal pure returns (uint8) {\n    return 24;\n  }\n\n  uint256 private constant FIXED1_UINT = 1000000000000000000000000;\n\n  /**\n   * @notice This is 1 in the fixed point units used in this library.\n   * @dev Test fixed1() equals 10^digits()\n   * Hardcoded to 24 digits.\n   */\n  function fixed1() internal pure returns (Fraction memory) {\n    return Fraction(FIXED1_UINT);\n  }\n\n  /**\n   * @notice Wrap a uint256 that represents a 24-decimal fraction in a Fraction\n   * struct.\n   * @param x Number that already represents a 24-decimal fraction.\n   * @return A Fraction struct with contents x.\n   */\n  function wrap(uint256 x) internal pure returns (Fraction memory) {\n    return Fraction(x);\n  }\n\n  /**\n   * @notice Unwraps the uint256 inside of a Fraction struct.\n   */\n  function unwrap(Fraction memory x) internal pure returns (uint256) {\n    return x.value;\n  }\n\n  /**\n   * @notice The amount of decimals lost on each multiplication operand.\n   * @dev Test mulPrecision() equals sqrt(fixed1)\n   */\n  function mulPrecision() internal pure returns (uint256) {\n    return 1000000000000;\n  }\n\n  /**\n   * @notice Maximum value that can be converted to fixed point. Optimize for deployment.\n   * @dev\n   * Test maxNewFixed() equals maxUint256() / fixed1()\n   */\n  function maxNewFixed() internal pure returns (uint256) {\n    return 115792089237316195423570985008687907853269984665640564;\n  }\n\n  /**\n   * @notice Converts a uint256 to fixed point Fraction\n   * @dev Test newFixed(0) returns 0\n   * Test newFixed(1) returns fixed1()\n   * Test newFixed(maxNewFixed()) returns maxNewFixed() * fixed1()\n   * Test newFixed(maxNewFixed()+1) fails\n   */\n  function newFixed(uint256 x) internal pure returns (Fraction memory) {\n    require(x <= maxNewFixed(), \"can't create fixidity number larger than maxNewFixed()\");\n    return Fraction(x * FIXED1_UINT);\n  }\n\n  /**\n   * @notice Converts a uint256 in the fixed point representation of this\n   * library to a non decimal. All decimal digits will be truncated.\n   */\n  function fromFixed(Fraction memory x) internal pure returns (uint256) {\n    return x.value / FIXED1_UINT;\n  }\n\n  /**\n   * @notice Converts two uint256 representing a fraction to fixed point units,\n   * equivalent to multiplying dividend and divisor by 10^digits().\n   * @param numerator numerator must be <= maxNewFixed()\n   * @param denominator denominator must be <= maxNewFixed() and denominator can't be 0\n   * @dev\n   * Test newFixedFraction(1,0) fails\n   * Test newFixedFraction(0,1) returns 0\n   * Test newFixedFraction(1,1) returns fixed1()\n   * Test newFixedFraction(1,fixed1()) returns 1\n   */\n  function newFixedFraction(uint256 numerator, uint256 denominator) internal pure returns (Fraction memory) {\n    Fraction memory convertedNumerator = newFixed(numerator);\n    Fraction memory convertedDenominator = newFixed(denominator);\n    return divide(convertedNumerator, convertedDenominator);\n  }\n\n  /**\n   * @notice Returns the integer part of a fixed point number.\n   * @dev\n   * Test integer(0) returns 0\n   * Test integer(fixed1()) returns fixed1()\n   * Test integer(newFixed(maxNewFixed())) returns maxNewFixed()*fixed1()\n   */\n  function integer(Fraction memory x) internal pure returns (Fraction memory) {\n    return Fraction((x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow\n  }\n\n  /**\n   * @notice Returns the fractional part of a fixed point number.\n   * In the case of a negative number the fractional is also negative.\n   * @dev\n   * Test fractional(0) returns 0\n   * Test fractional(fixed1()) returns 0\n   * Test fractional(fixed1()-1) returns 10^24-1\n   */\n  function fractional(Fraction memory x) internal pure returns (Fraction memory) {\n    return Fraction(x.value - (x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow\n  }\n\n  /**\n   * @notice x+y.\n   * @dev The maximum value that can be safely used as an addition operator is defined as\n   * maxFixedAdd = maxUint256()-1 / 2, or\n   * 57896044618658097711785492504343953926634992332820282019728792003956564819967.\n   * Test add(maxFixedAdd,maxFixedAdd) equals maxFixedAdd + maxFixedAdd\n   * Test add(maxFixedAdd+1,maxFixedAdd+1) throws\n   */\n  function add(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {\n    uint256 z = x.value + y.value;\n    require(z >= x.value, \"add overflow detected\");\n    return Fraction(z);\n  }\n\n  /**\n   * @notice x-y.\n   * @dev\n   * Test subtract(6, 10) fails\n   */\n  function subtract(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {\n    require(x.value >= y.value, \"substraction underflow detected\");\n    return Fraction(x.value - y.value);\n  }\n\n  /**\n   * @notice x*y. If any of the operators is higher than the max multiplier value it\n   * might overflow.\n   * @dev The maximum value that can be safely used as a multiplication operator\n   * (maxFixedMul) is calculated as sqrt(maxUint256()*fixed1()),\n   * or 340282366920938463463374607431768211455999999999999\n   * Test multiply(0,0) returns 0\n   * Test multiply(maxFixedMul,0) returns 0\n   * Test multiply(0,maxFixedMul) returns 0\n   * Test multiply(fixed1()/mulPrecision(),fixed1()*mulPrecision()) returns fixed1()\n   * Test multiply(maxFixedMul,maxFixedMul) is around maxUint256()\n   * Test multiply(maxFixedMul+1,maxFixedMul+1) fails\n   */\n  // solhint-disable-next-line code-complexity\n  function multiply(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {\n    if (x.value == 0 || y.value == 0) return Fraction(0);\n    if (y.value == FIXED1_UINT) return x;\n    if (x.value == FIXED1_UINT) return y;\n\n    // Separate into integer and fractional parts\n    // x = x1 + x2, y = y1 + y2\n    uint256 x1 = integer(x).value / FIXED1_UINT;\n    uint256 x2 = fractional(x).value;\n    uint256 y1 = integer(y).value / FIXED1_UINT;\n    uint256 y2 = fractional(y).value;\n\n    // (x1 + x2) * (y1 + y2) = (x1 * y1) + (x1 * y2) + (x2 * y1) + (x2 * y2)\n    uint256 x1y1 = x1 * y1;\n    if (x1 != 0) require(x1y1 / x1 == y1, \"overflow x1y1 detected\");\n\n    // x1y1 needs to be multiplied back by fixed1\n    // solhint-disable-next-line var-name-mixedcase\n    uint256 fixed_x1y1 = x1y1 * FIXED1_UINT;\n    if (x1y1 != 0) require(fixed_x1y1 / x1y1 == FIXED1_UINT, \"overflow x1y1 * fixed1 detected\");\n    x1y1 = fixed_x1y1;\n\n    uint256 x2y1 = x2 * y1;\n    if (x2 != 0) require(x2y1 / x2 == y1, \"overflow x2y1 detected\");\n\n    uint256 x1y2 = x1 * y2;\n    if (x1 != 0) require(x1y2 / x1 == y2, \"overflow x1y2 detected\");\n\n    x2 = x2 / mulPrecision();\n    y2 = y2 / mulPrecision();\n    uint256 x2y2 = x2 * y2;\n    if (x2 != 0) require(x2y2 / x2 == y2, \"overflow x2y2 detected\");\n\n    // result = fixed1() * x1 * y1 + x1 * y2 + x2 * y1 + x2 * y2 / fixed1();\n    Fraction memory result = Fraction(x1y1);\n    result = add(result, Fraction(x2y1)); // Add checks for overflow\n    result = add(result, Fraction(x1y2)); // Add checks for overflow\n    result = add(result, Fraction(x2y2)); // Add checks for overflow\n    return result;\n  }\n\n  /**\n   * @notice 1/x\n   * @dev\n   * Test reciprocal(0) fails\n   * Test reciprocal(fixed1()) returns fixed1()\n   * Test reciprocal(fixed1()*fixed1()) returns 1 // Testing how the fractional is truncated\n   * Test reciprocal(1+fixed1()*fixed1()) returns 0 // Testing how the fractional is truncated\n   * Test reciprocal(newFixedFraction(1, 1e24)) returns newFixed(1e24)\n   */\n  function reciprocal(Fraction memory x) internal pure returns (Fraction memory) {\n    require(x.value != 0, \"can't call reciprocal(0)\");\n    return Fraction((FIXED1_UINT * FIXED1_UINT) / x.value); // Can't overflow\n  }\n\n  /**\n   * @notice x/y. If the dividend is higher than the max dividend value, it\n   * might overflow. You can use multiply(x,reciprocal(y)) instead.\n   * @dev The maximum value that can be safely used as a dividend (maxNewFixed) is defined as\n   * divide(maxNewFixed,newFixedFraction(1,fixed1())) is around maxUint256().\n   * This yields the value 115792089237316195423570985008687907853269984665640564.\n   * Test maxNewFixed equals maxUint256()/fixed1()\n   * Test divide(maxNewFixed,1) equals maxNewFixed*(fixed1)\n   * Test divide(maxNewFixed+1,multiply(mulPrecision(),mulPrecision())) throws\n   * Test divide(fixed1(),0) fails\n   * Test divide(maxNewFixed,1) = maxNewFixed*(10^digits())\n   * Test divide(maxNewFixed+1,1) throws\n   */\n  function divide(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {\n    require(y.value != 0, \"can't divide by 0\");\n    // solhint-disable-next-line var-name-mixedcase\n    uint256 X = x.value * FIXED1_UINT;\n    require(X / FIXED1_UINT == x.value, \"overflow at divide\");\n    return Fraction(X / y.value);\n  }\n\n  /**\n   * @notice x > y\n   */\n  function gt(Fraction memory x, Fraction memory y) internal pure returns (bool) {\n    return x.value > y.value;\n  }\n\n  /**\n   * @notice x >= y\n   */\n  function gte(Fraction memory x, Fraction memory y) internal pure returns (bool) {\n    return x.value >= y.value;\n  }\n\n  /**\n   * @notice x < y\n   */\n  function lt(Fraction memory x, Fraction memory y) internal pure returns (bool) {\n    return x.value < y.value;\n  }\n\n  /**\n   * @notice x <= y\n   */\n  function lte(Fraction memory x, Fraction memory y) internal pure returns (bool) {\n    return x.value <= y.value;\n  }\n\n  /**\n   * @notice x == y\n   */\n  function equals(Fraction memory x, Fraction memory y) internal pure returns (bool) {\n    return x.value == y.value;\n  }\n\n  /**\n   * @notice x <= 1\n   */\n  function isProperFraction(Fraction memory x) internal pure returns (bool) {\n    return lte(x, fixed1());\n  }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/common/linkedlists/LinkedList.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\n\n/**\n * @title Maintains a doubly linked list keyed by bytes32.\n * @dev Following the `next` pointers will lead you to the head, rather than the tail.\n */\nlibrary LinkedList {\n  using SafeMath for uint256;\n\n  struct Element {\n    bytes32 previousKey;\n    bytes32 nextKey;\n    bool exists;\n  }\n\n  struct List {\n    bytes32 head;\n    bytes32 tail;\n    uint256 numElements;\n    mapping(bytes32 => Element) elements;\n  }\n\n  /**\n   * @notice Inserts an element into a doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   * @param previousKey The key of the element that comes before the element to insert.\n   * @param nextKey The key of the element that comes after the element to insert.\n   */\n  function insert(\n    List storage list,\n    bytes32 key,\n    bytes32 previousKey,\n    bytes32 nextKey\n  ) internal {\n    require(key != bytes32(0), \"Key must be defined\");\n    require(!contains(list, key), \"Can't insert an existing element\");\n    require(previousKey != key && nextKey != key, \"Key cannot be the same as previousKey or nextKey\");\n\n    Element storage element = list.elements[key];\n    element.exists = true;\n\n    if (list.numElements == 0) {\n      list.tail = key;\n      list.head = key;\n    } else {\n      require(previousKey != bytes32(0) || nextKey != bytes32(0), \"Either previousKey or nextKey must be defined\");\n\n      element.previousKey = previousKey;\n      element.nextKey = nextKey;\n\n      if (previousKey != bytes32(0)) {\n        require(contains(list, previousKey), \"If previousKey is defined, it must exist in the list\");\n        Element storage previousElement = list.elements[previousKey];\n        require(previousElement.nextKey == nextKey, \"previousKey must be adjacent to nextKey\");\n        previousElement.nextKey = key;\n      } else {\n        list.tail = key;\n      }\n\n      if (nextKey != bytes32(0)) {\n        require(contains(list, nextKey), \"If nextKey is defined, it must exist in the list\");\n        Element storage nextElement = list.elements[nextKey];\n        require(nextElement.previousKey == previousKey, \"previousKey must be adjacent to nextKey\");\n        nextElement.previousKey = key;\n      } else {\n        list.head = key;\n      }\n    }\n\n    list.numElements = list.numElements.add(1);\n  }\n\n  /**\n   * @notice Inserts an element at the tail of the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   */\n  function push(List storage list, bytes32 key) internal {\n    insert(list, key, bytes32(0), list.tail);\n  }\n\n  /**\n   * @notice Removes an element from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to remove.\n   */\n  function remove(List storage list, bytes32 key) internal {\n    Element storage element = list.elements[key];\n    require(key != bytes32(0) && contains(list, key), \"key not in list\");\n    if (element.previousKey != bytes32(0)) {\n      Element storage previousElement = list.elements[element.previousKey];\n      previousElement.nextKey = element.nextKey;\n    } else {\n      list.tail = element.nextKey;\n    }\n\n    if (element.nextKey != bytes32(0)) {\n      Element storage nextElement = list.elements[element.nextKey];\n      nextElement.previousKey = element.previousKey;\n    } else {\n      list.head = element.previousKey;\n    }\n\n    delete list.elements[key];\n    list.numElements = list.numElements.sub(1);\n  }\n\n  /**\n   * @notice Updates an element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @param previousKey The key of the element that comes before the updated element.\n   * @param nextKey The key of the element that comes after the updated element.\n   */\n  function update(\n    List storage list,\n    bytes32 key,\n    bytes32 previousKey,\n    bytes32 nextKey\n  ) internal {\n    require(key != bytes32(0) && key != previousKey && key != nextKey && contains(list, key), \"key on in list\");\n    remove(list, key);\n    insert(list, key, previousKey, nextKey);\n  }\n\n  /**\n   * @notice Returns whether or not a particular key is present in the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @return Whether or not the key is in the sorted list.\n   */\n  function contains(List storage list, bytes32 key) internal view returns (bool) {\n    return list.elements[key].exists;\n  }\n\n  /**\n   * @notice Returns the keys of the N elements at the head of the list.\n   * @param list A storage pointer to the underlying list.\n   * @param n The number of elements to return.\n   * @return The keys of the N elements at the head of the list.\n   * @dev Reverts if n is greater than the number of elements in the list.\n   */\n  function headN(List storage list, uint256 n) internal view returns (bytes32[] memory) {\n    require(n <= list.numElements, \"not enough elements\");\n    bytes32[] memory keys = new bytes32[](n);\n    bytes32 key = list.head;\n    for (uint256 i = 0; i < n; i = i.add(1)) {\n      keys[i] = key;\n      key = list.elements[key].previousKey;\n    }\n    return keys;\n  }\n\n  /**\n   * @notice Gets all element keys from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @return All element keys from head to tail.\n   */\n  function getKeys(List storage list) internal view returns (bytes32[] memory) {\n    return headN(list, list.numElements);\n  }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/common/linkedlists/SortedLinkedList.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"./LinkedList.sol\";\n\n/**\n * @title Maintains a sorted list of unsigned ints keyed by bytes32.\n */\nlibrary SortedLinkedList {\n  using SafeMath for uint256;\n  using LinkedList for LinkedList.List;\n\n  struct List {\n    LinkedList.List list;\n    mapping(bytes32 => uint256) values;\n  }\n\n  /**\n   * @notice Inserts an element into a doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   * @param value The element value.\n   * @param lesserKey The key of the element less than the element to insert.\n   * @param greaterKey The key of the element greater than the element to insert.\n   */\n  function insert(\n    List storage list,\n    bytes32 key,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) internal {\n    require(key != bytes32(0) && key != lesserKey && key != greaterKey && !contains(list, key), \"invalid key\");\n    require(\n      (lesserKey != bytes32(0) || greaterKey != bytes32(0)) || list.list.numElements == 0,\n      \"greater and lesser key zero\"\n    );\n    require(contains(list, lesserKey) || lesserKey == bytes32(0), \"invalid lesser key\");\n    require(contains(list, greaterKey) || greaterKey == bytes32(0), \"invalid greater key\");\n    (lesserKey, greaterKey) = getLesserAndGreater(list, value, lesserKey, greaterKey);\n    list.list.insert(key, lesserKey, greaterKey);\n    list.values[key] = value;\n  }\n\n  /**\n   * @notice Removes an element from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to remove.\n   */\n  function remove(List storage list, bytes32 key) internal {\n    list.list.remove(key);\n    list.values[key] = 0;\n  }\n\n  /**\n   * @notice Updates an element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @param value The element value.\n   * @param lesserKey The key of the element will be just left of `key` after the update.\n   * @param greaterKey The key of the element will be just right of `key` after the update.\n   * @dev Note that only one of \"lesserKey\" or \"greaterKey\" needs to be correct to reduce friction.\n   */\n  function update(\n    List storage list,\n    bytes32 key,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) internal {\n    remove(list, key);\n    insert(list, key, value, lesserKey, greaterKey);\n  }\n\n  /**\n   * @notice Inserts an element at the tail of the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   */\n  function push(List storage list, bytes32 key) internal {\n    insert(list, key, 0, bytes32(0), list.list.tail);\n  }\n\n  /**\n   * @notice Removes N elements from the head of the list and returns their keys.\n   * @param list A storage pointer to the underlying list.\n   * @param n The number of elements to pop.\n   * @return The keys of the popped elements.\n   */\n  function popN(List storage list, uint256 n) internal returns (bytes32[] memory) {\n    require(n <= list.list.numElements, \"not enough elements\");\n    bytes32[] memory keys = new bytes32[](n);\n    for (uint256 i = 0; i < n; i = i.add(1)) {\n      bytes32 key = list.list.head;\n      keys[i] = key;\n      remove(list, key);\n    }\n    return keys;\n  }\n\n  /**\n   * @notice Returns whether or not a particular key is present in the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @return Whether or not the key is in the sorted list.\n   */\n  function contains(List storage list, bytes32 key) internal view returns (bool) {\n    return list.list.contains(key);\n  }\n\n  /**\n   * @notice Returns the value for a particular key in the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @return The element value.\n   */\n  function getValue(List storage list, bytes32 key) internal view returns (uint256) {\n    return list.values[key];\n  }\n\n  /**\n   * @notice Gets all elements from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @return Array of all keys in the list.\n   * @return Values corresponding to keys, which will be ordered largest to smallest.\n   */\n  function getElements(List storage list) internal view returns (bytes32[] memory, uint256[] memory) {\n    bytes32[] memory keys = getKeys(list);\n    uint256[] memory values = new uint256[](keys.length);\n    for (uint256 i = 0; i < keys.length; i = i.add(1)) {\n      values[i] = list.values[keys[i]];\n    }\n    return (keys, values);\n  }\n\n  /**\n   * @notice Gets all element keys from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @return All element keys from head to tail.\n   */\n  function getKeys(List storage list) internal view returns (bytes32[] memory) {\n    return list.list.getKeys();\n  }\n\n  /**\n   * @notice Returns first N greatest elements of the list.\n   * @param list A storage pointer to the underlying list.\n   * @param n The number of elements to return.\n   * @return The keys of the first n elements.\n   * @dev Reverts if n is greater than the number of elements in the list.\n   */\n  function headN(List storage list, uint256 n) internal view returns (bytes32[] memory) {\n    return list.list.headN(n);\n  }\n\n  /**\n   * @notice Returns the keys of the elements greaterKey than and less than the provided value.\n   * @param list A storage pointer to the underlying list.\n   * @param value The element value.\n   * @param lesserKey The key of the element which could be just left of the new value.\n   * @param greaterKey The key of the element which could be just right of the new value.\n   * @return The correct lesserKey keys.\n   * @return The correct greaterKey keys.\n   */\n  function getLesserAndGreater(\n    List storage list,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) private view returns (bytes32, bytes32) {\n    // Check for one of the following conditions and fail if none are met:\n    //   1. The value is less than the current lowest value\n    //   2. The value is greater than the current greatest value\n    //   3. The value is just greater than the value for `lesserKey`\n    //   4. The value is just less than the value for `greaterKey`\n    if (lesserKey == bytes32(0) && isValueBetween(list, value, lesserKey, list.list.tail)) {\n      return (lesserKey, list.list.tail);\n    } else if (greaterKey == bytes32(0) && isValueBetween(list, value, list.list.head, greaterKey)) {\n      return (list.list.head, greaterKey);\n    } else if (\n      lesserKey != bytes32(0) && isValueBetween(list, value, lesserKey, list.list.elements[lesserKey].nextKey)\n    ) {\n      return (lesserKey, list.list.elements[lesserKey].nextKey);\n    } else if (\n      greaterKey != bytes32(0) && isValueBetween(list, value, list.list.elements[greaterKey].previousKey, greaterKey)\n    ) {\n      return (list.list.elements[greaterKey].previousKey, greaterKey);\n    } else {\n      require(false, \"get lesser and greater failure\");\n    }\n  }\n\n  /**\n   * @notice Returns whether or not a given element is between two other elements.\n   * @param list A storage pointer to the underlying list.\n   * @param value The element value.\n   * @param lesserKey The key of the element whose value should be lesserKey.\n   * @param greaterKey The key of the element whose value should be greaterKey.\n   * @return True if the given element is between the two other elements.\n   */\n  function isValueBetween(\n    List storage list,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) private view returns (bool) {\n    bool isLesser = lesserKey == bytes32(0) || list.values[lesserKey] <= value;\n    bool isGreater = greaterKey == bytes32(0) || list.values[greaterKey] >= value;\n    return isLesser && isGreater;\n  }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/common/linkedlists/SortedLinkedListWithMedian.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"./LinkedList.sol\";\nimport \"./SortedLinkedList.sol\";\n\n/**\n * @title Maintains a sorted list of unsigned ints keyed by bytes32.\n */\nlibrary SortedLinkedListWithMedian {\n  using SafeMath for uint256;\n  using SortedLinkedList for SortedLinkedList.List;\n\n  enum MedianAction {\n    None,\n    Lesser,\n    Greater\n  }\n\n  enum MedianRelation {\n    Undefined,\n    Lesser,\n    Greater,\n    Equal\n  }\n\n  struct List {\n    SortedLinkedList.List list;\n    bytes32 median;\n    mapping(bytes32 => MedianRelation) relation;\n  }\n\n  /**\n   * @notice Inserts an element into a doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   * @param value The element value.\n   * @param lesserKey The key of the element less than the element to insert.\n   * @param greaterKey The key of the element greater than the element to insert.\n   */\n  function insert(\n    List storage list,\n    bytes32 key,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) internal {\n    list.list.insert(key, value, lesserKey, greaterKey);\n    LinkedList.Element storage element = list.list.list.elements[key];\n\n    MedianAction action = MedianAction.None;\n    if (list.list.list.numElements == 1) {\n      list.median = key;\n      list.relation[key] = MedianRelation.Equal;\n    } else if (list.list.list.numElements % 2 == 1) {\n      // When we have an odd number of elements, and the element that we inserted is less than\n      // the previous median, we need to slide the median down one element, since we had previously\n      // selected the greater of the two middle elements.\n      if (element.previousKey == bytes32(0) || list.relation[element.previousKey] == MedianRelation.Lesser) {\n        action = MedianAction.Lesser;\n        list.relation[key] = MedianRelation.Lesser;\n      } else {\n        list.relation[key] = MedianRelation.Greater;\n      }\n    } else {\n      // When we have an even number of elements, and the element that we inserted is greater than\n      // the previous median, we need to slide the median up one element, since we always select\n      // the greater of the two middle elements.\n      if (element.nextKey == bytes32(0) || list.relation[element.nextKey] == MedianRelation.Greater) {\n        action = MedianAction.Greater;\n        list.relation[key] = MedianRelation.Greater;\n      } else {\n        list.relation[key] = MedianRelation.Lesser;\n      }\n    }\n    updateMedian(list, action);\n  }\n\n  /**\n   * @notice Removes an element from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to remove.\n   */\n  function remove(List storage list, bytes32 key) internal {\n    MedianAction action = MedianAction.None;\n    if (list.list.list.numElements == 0) {\n      list.median = bytes32(0);\n    } else if (list.list.list.numElements % 2 == 0) {\n      // When we have an even number of elements, we always choose the higher of the two medians.\n      // Thus, if the element we're removing is greaterKey than or equal to the median we need to\n      // slide the median left by one.\n      if (list.relation[key] == MedianRelation.Greater || list.relation[key] == MedianRelation.Equal) {\n        action = MedianAction.Lesser;\n      }\n    } else {\n      // When we don't have an even number of elements, we just choose the median value.\n      // Thus, if the element we're removing is less than or equal to the median, we need to slide\n      // median right by one.\n      if (list.relation[key] == MedianRelation.Lesser || list.relation[key] == MedianRelation.Equal) {\n        action = MedianAction.Greater;\n      }\n    }\n    updateMedian(list, action);\n\n    list.list.remove(key);\n  }\n\n  /**\n   * @notice Updates an element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @param value The element value.\n   * @param lesserKey The key of the element will be just left of `key` after the update.\n   * @param greaterKey The key of the element will be just right of `key` after the update.\n   * @dev Note that only one of \"lesserKey\" or \"greaterKey\" needs to be correct to reduce friction.\n   */\n  function update(\n    List storage list,\n    bytes32 key,\n    uint256 value,\n    bytes32 lesserKey,\n    bytes32 greaterKey\n  ) internal {\n    remove(list, key);\n    insert(list, key, value, lesserKey, greaterKey);\n  }\n\n  /**\n   * @notice Inserts an element at the tail of the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The key of the element to insert.\n   */\n  function push(List storage list, bytes32 key) internal {\n    insert(list, key, 0, bytes32(0), list.list.list.tail);\n  }\n\n  /**\n   * @notice Removes N elements from the head of the list and returns their keys.\n   * @param list A storage pointer to the underlying list.\n   * @param n The number of elements to pop.\n   * @return The keys of the popped elements.\n   */\n  function popN(List storage list, uint256 n) internal returns (bytes32[] memory) {\n    require(n <= list.list.list.numElements, \"not enough elements\");\n    bytes32[] memory keys = new bytes32[](n);\n    for (uint256 i = 0; i < n; i = i.add(1)) {\n      bytes32 key = list.list.list.head;\n      keys[i] = key;\n      remove(list, key);\n    }\n    return keys;\n  }\n\n  /**\n   * @notice Returns whether or not a particular key is present in the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @return Whether or not the key is in the sorted list.\n   */\n  function contains(List storage list, bytes32 key) internal view returns (bool) {\n    return list.list.contains(key);\n  }\n\n  /**\n   * @notice Returns the value for a particular key in the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @param key The element key.\n   * @return The element value.\n   */\n  function getValue(List storage list, bytes32 key) internal view returns (uint256) {\n    return list.list.values[key];\n  }\n\n  /**\n   * @notice Returns the median value of the sorted list.\n   * @param list A storage pointer to the underlying list.\n   * @return The median value.\n   */\n  function getMedianValue(List storage list) internal view returns (uint256) {\n    return getValue(list, list.median);\n  }\n\n  /**\n   * @notice Returns the key of the first element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @return The key of the first element in the list.\n   */\n  function getHead(List storage list) internal view returns (bytes32) {\n    return list.list.list.head;\n  }\n\n  /**\n   * @notice Returns the key of the median element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @return The key of the median element in the list.\n   */\n  function getMedian(List storage list) internal view returns (bytes32) {\n    return list.median;\n  }\n\n  /**\n   * @notice Returns the key of the last element in the list.\n   * @param list A storage pointer to the underlying list.\n   * @return The key of the last element in the list.\n   */\n  function getTail(List storage list) internal view returns (bytes32) {\n    return list.list.list.tail;\n  }\n\n  /**\n   * @notice Returns the number of elements in the list.\n   * @param list A storage pointer to the underlying list.\n   * @return The number of elements in the list.\n   */\n  function getNumElements(List storage list) internal view returns (uint256) {\n    return list.list.list.numElements;\n  }\n\n  /**\n   * @notice Gets all elements from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @return Array of all keys in the list.\n   * @return Values corresponding to keys, which will be ordered largest to smallest.\n   * @return Array of relations to median of corresponding list elements.\n   */\n  function getElements(List storage list)\n    internal\n    view\n    returns (\n      bytes32[] memory,\n      uint256[] memory,\n      MedianRelation[] memory\n    )\n  {\n    bytes32[] memory keys = getKeys(list);\n    uint256[] memory values = new uint256[](keys.length);\n    MedianRelation[] memory relations = new MedianRelation[](keys.length);\n    for (uint256 i = 0; i < keys.length; i = i.add(1)) {\n      values[i] = list.list.values[keys[i]];\n      relations[i] = list.relation[keys[i]];\n    }\n    return (keys, values, relations);\n  }\n\n  /**\n   * @notice Gets all element keys from the doubly linked list.\n   * @param list A storage pointer to the underlying list.\n   * @return All element keys from head to tail.\n   */\n  function getKeys(List storage list) internal view returns (bytes32[] memory) {\n    return list.list.getKeys();\n  }\n\n  /**\n   * @notice Moves the median pointer right or left of its current value.\n   * @param list A storage pointer to the underlying list.\n   * @param action Which direction to move the median pointer.\n   */\n  function updateMedian(List storage list, MedianAction action) private {\n    LinkedList.Element storage previousMedian = list.list.list.elements[list.median];\n    if (action == MedianAction.Lesser) {\n      list.relation[list.median] = MedianRelation.Greater;\n      list.median = previousMedian.previousKey;\n    } else if (action == MedianAction.Greater) {\n      list.relation[list.median] = MedianRelation.Lesser;\n      list.median = previousMedian.nextKey;\n    }\n    list.relation[list.median] = MedianRelation.Equal;\n  }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/interfaces/IBreaker.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\n/**\n * @title Breaker Interface\n * @notice Defines the basic interface for a Breaker\n */\ninterface IBreaker {\n  /**\n   * @notice Emitted when the sortedOracles address is updated.\n   * @param newSortedOracles The address of the new sortedOracles.\n   */\n  event SortedOraclesUpdated(address newSortedOracles);\n\n  /**\n   * @notice Retrieve the cooldown time for the breaker.\n   * @param rateFeedID The rate feed to get the cooldown for\n   * @return cooldown The amount of time that must pass before the breaker can reset.\n   * @dev when cooldown is 0 auto reset will not be attempted.\n   */\n  function getCooldown(address rateFeedID) external view returns (uint256 cooldown);\n\n  /**\n   * @notice Check if the criteria have been met, by a specified rateFeedID, to trigger the breaker.\n   * @param rateFeedID The address of the rate feed to run the check against.\n   * @return triggerBreaker A boolean indicating whether or not the breaker\n   *                        should be triggered for the given rate feed.\n   */\n  function shouldTrigger(address rateFeedID) external returns (bool triggerBreaker);\n\n  /**\n   * @notice Check if the criteria to automatically reset the breaker have been met.\n   * @param rateFeedID The address of rate feed the criteria should be checked against.\n   * @return resetBreaker A boolean indicating whether the breaker\n   *                      should be reset for the given rate feed.\n   * @dev Allows the definition of additional critera to check before reset.\n   *      If no additional criteria is needed set to !shouldTrigger();\n   */\n  function shouldReset(address rateFeedID) external returns (bool resetBreaker);\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/interfaces/ISortedOracles.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport \"../common/linkedlists/SortedLinkedListWithMedian.sol\";\n\ninterface ISortedOracles {\n  function addOracle(address, address) external;\n\n  function removeOracle(\n    address,\n    address,\n    uint256\n  ) external;\n\n  function report(\n    address,\n    uint256,\n    address,\n    address\n  ) external;\n\n  function removeExpiredReports(address, uint256) external;\n\n  function isOldestReportExpired(address token) external view returns (bool, address);\n\n  function numRates(address) external view returns (uint256);\n\n  function medianRate(address) external view returns (uint256, uint256);\n\n  function numTimestamps(address) external view returns (uint256);\n\n  function medianTimestamp(address) external view returns (uint256);\n\n  function getOracles(address) external view returns (address[] memory);\n\n  function getTimestamps(address token)\n    external\n    view\n    returns (\n      address[] memory,\n      uint256[] memory,\n      SortedLinkedListWithMedian.MedianRelation[] memory\n    );\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/oracles/breakers/WithCooldown.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\n/**\n * @title   Breaker With Cooldown\n * @notice  Utility portion of a Breaker contract which deals with the\n *          cooldown component.\n */\ncontract WithCooldown {\n  /* ==================== Events ==================== */\n  /**\n   * @notice Emitted after the cooldownTime has been updated.\n   * @param newCooldownTime The new cooldownTime of the breaker.\n   */\n  event DefaultCooldownTimeUpdated(uint256 newCooldownTime);\n\n  /**\n   * @notice Emitted after the cooldownTime has been updated.\n   * @param rateFeedID The rateFeedID targeted.\n   * @param newCooldownTime The new cooldownTime of the breaker.\n   */\n  event RateFeedCooldownTimeUpdated(address rateFeedID, uint256 newCooldownTime);\n\n  /* ==================== State Variables ==================== */\n\n  // The amount of time that must pass before the breaker can be reset for a rate feed.\n  // Should be set to 0 to force a manual reset.\n  uint256 public defaultCooldownTime;\n  mapping(address => uint256) public rateFeedCooldownTime;\n\n  /* ==================== View Functions ==================== */\n\n  /**\n   * @notice Get the cooldown time for a rateFeedID\n   * @param rateFeedID the targeted rate feed.\n   * @return the rate specific or default cooldown\n   */\n  function getCooldown(address rateFeedID) public view returns (uint256) {\n    uint256 _rateFeedCooldownTime = rateFeedCooldownTime[rateFeedID];\n    if (_rateFeedCooldownTime == 0) {\n      return defaultCooldownTime;\n    }\n    return _rateFeedCooldownTime;\n  }\n\n  /* ==================== Internal Functions ==================== */\n\n  /**\n   * @notice Sets the cooldown time to the specified value for a rate feed.\n   * @param rateFeedIDs the targeted rate feed.\n   * @param cooldownTimes The new cooldownTime value.\n   * @dev Should be set to 0 to force a manual reset.\n   */\n  function _setCooldownTimes(address[] memory rateFeedIDs, uint256[] memory cooldownTimes) internal {\n    require(rateFeedIDs.length == cooldownTimes.length, \"array length missmatch\");\n    for (uint256 i = 0; i < rateFeedIDs.length; i++) {\n      require(rateFeedIDs[i] != address(0), \"rate feed invalid\");\n      rateFeedCooldownTime[rateFeedIDs[i]] = cooldownTimes[i];\n      emit RateFeedCooldownTimeUpdated(rateFeedIDs[i], cooldownTimes[i]);\n    }\n  }\n\n  /**\n   * @notice Sets the cooldownTime to the specified value for a rate feed.\n   * @param cooldownTime The new cooldownTime value.\n   * @dev Should be set to 0 to force a manual reset.\n   */\n  function _setDefaultCooldownTime(uint256 cooldownTime) internal {\n    defaultCooldownTime = cooldownTime;\n    emit DefaultCooldownTimeUpdated(cooldownTime);\n  }\n}\n"},{"file_path":"lib/mento-core-2.2.0/contracts/oracles/breakers/WithThreshold.sol","source_code":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.5.13;\n\nimport { SafeMath } from \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport { FixidityLib } from \"../../common/FixidityLib.sol\";\n\n/**\n * @title   Breaker With Thershold\n * @notice  Utility portion of a Breaker contract which deals with\n *          managing a threshold percentage and checking two values\n * .        against it.\n */\ncontract WithThreshold {\n  using FixidityLib for FixidityLib.Fraction;\n  using SafeMath for uint256;\n\n  /* ==================== Events ==================== */\n\n  // Emitted when the default rate threshold is updated.\n  event DefaultRateChangeThresholdUpdated(uint256 defaultRateChangeThreshold);\n\n  // Emitted when the rate threshold is updated.\n  event RateChangeThresholdUpdated(address rateFeedID, uint256 rateChangeThreshold);\n\n  /* ==================== State Variables ==================== */\n\n  // The default allowed threshold for the median rate change as a Fixidity fraction.\n  FixidityLib.Fraction public defaultRateChangeThreshold;\n\n  // Maps rate feed to a threshold.\n  mapping(address => FixidityLib.Fraction) public rateChangeThreshold;\n\n  /* ==================== View Functions ==================== */\n\n  /**\n   * @notice Checks if a value is in a certain theshold of a given reference value.\n   * @dev The reference value can be the previous median (MedianDeltaBreaker) or\n   *      a static value (ValueDeltaBreaker), while the currentValue is usually\n   *      the median after the most recent report.\n   * @param referenceValue The reference value to check against.\n   * @param currentValue The current value which is checked against the reference.\n   * @param rateFeedID The specific rate ID to check threshold for.\n   * @return  Returns a bool indicating whether or not the current rate\n   *          is within the allowed threshold.\n   */\n  function exceedsThreshold(\n    uint256 referenceValue,\n    uint256 currentValue,\n    address rateFeedID\n  ) public view returns (bool) {\n    uint256 allowedThreshold = defaultRateChangeThreshold.unwrap();\n    uint256 rateSpecificThreshold = rateChangeThreshold[rateFeedID].unwrap();\n    // checks if a given rate feed id has a threshold set and reassignes it\n    if (rateSpecificThreshold != 0) allowedThreshold = rateSpecificThreshold;\n\n    uint256 fixed1 = FixidityLib.fixed1().unwrap();\n\n    uint256 maxPercent = uint256(fixed1).add(allowedThreshold);\n    uint256 maxValue = (referenceValue.mul(maxPercent)).div(10**24);\n\n    uint256 minPercent = uint256(fixed1).sub(allowedThreshold);\n    uint256 minValue = (referenceValue.mul(minPercent)).div(10**24);\n\n    return (currentValue < minValue || currentValue > maxValue);\n  }\n\n  /* ==================== Internal Functions ==================== */\n\n  /**\n   * @notice Sets rateChangeThreshold.\n   * @param _defaultRateChangeThreshold The new rateChangeThreshold value.\n   */\n  function _setDefaultRateChangeThreshold(uint256 _defaultRateChangeThreshold) internal {\n    defaultRateChangeThreshold = FixidityLib.wrap(_defaultRateChangeThreshold);\n    require(defaultRateChangeThreshold.lt(FixidityLib.fixed1()), \"value must be less than 1\");\n    emit DefaultRateChangeThresholdUpdated(_defaultRateChangeThreshold);\n  }\n\n  /**\n   * @notice Configures rate feed to rate threshold pairs.\n   * @param rateFeedIDs Collection of the addresses rate feeds.\n   * @param rateChangeThresholds Collection of the rate thresholds.\n   */\n  function _setRateChangeThresholds(address[] memory rateFeedIDs, uint256[] memory rateChangeThresholds) internal {\n    require(rateFeedIDs.length == rateChangeThresholds.length, \"array length missmatch\");\n    for (uint256 i = 0; i < rateFeedIDs.length; i++) {\n      require(rateFeedIDs[i] != address(0), \"rate feed invalid\");\n      FixidityLib.Fraction memory _rateChangeThreshold = FixidityLib.wrap(rateChangeThresholds[i]);\n      require(_rateChangeThreshold.lt(FixidityLib.fixed1()), \"value must be less than 1\");\n      rateChangeThreshold[rateFeedIDs[i]] = _rateChangeThreshold;\n      emit RateChangeThresholdUpdated(rateFeedIDs[i], rateChangeThresholds[i]);\n    }\n  }\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"uint256","name":"_defaultCooldownTime","type":"uint256"},{"internalType":"uint256","name":"_defaultRateChangeThreshold","type":"uint256"},{"internalType":"contract ISortedOracles","name":"_sortedOracles","type":"address"},{"internalType":"address","name":"_breakerBox","type":"address"},{"internalType":"address[]","name":"rateFeedIDs","type":"address[]"},{"internalType":"uint256[]","name":"rateChangeThresholds","type":"uint256[]"},{"internalType":"uint256[]","name":"cooldownTimes","type":"uint256[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"breakerBox","type":"address"}],"name":"BreakerBoxUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newCooldownTime","type":"uint256"}],"name":"DefaultCooldownTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"defaultRateChangeThreshold","type":"uint256"}],"name":"DefaultRateChangeThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rateFeedID","type":"address"}],"name":"MedianRateEMAReset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rateFeedID","type":"address"},{"indexed":false,"internalType":"uint256","name":"rateChangeThreshold","type":"uint256"}],"name":"RateChangeThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rateFeedID","type":"address"},{"indexed":false,"internalType":"uint256","name":"newCooldownTime","type":"uint256"}],"name":"RateFeedCooldownTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rateFeedId","type":"address"},{"indexed":false,"internalType":"uint256","name":"smoothingFactor","type":"uint256"}],"name":"SmoothingFactorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newSortedOracles","type":"address"}],"name":"SortedOraclesUpdated","type":"event"},{"constant":true,"inputs":[],"name":"DEFAULT_SMOOTHING_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"breakerBox","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"defaultCooldownTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"defaultRateChangeThreshold","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"referenceValue","type":"uint256"},{"internalType":"uint256","name":"currentValue","type":"uint256"},{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"exceedsThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"getCooldown","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"getSmoothingFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"medianRatesEMA","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rateChangeThreshold","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rateFeedCooldownTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"resetMedianRateEMA","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_breakerBox","type":"address"}],"name":"setBreakerBox","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"rateFeedIDs","type":"address[]"},{"internalType":"uint256[]","name":"cooldownTimes","type":"uint256[]"}],"name":"setCooldownTime","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"cooldownTime","type":"uint256"}],"name":"setDefaultCooldownTime","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_defaultRateChangeThreshold","type":"uint256"}],"name":"setDefaultRateChangeThreshold","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"rateFeedIDs","type":"address[]"},{"internalType":"uint256[]","name":"rateChangeThresholds","type":"uint256[]"}],"name":"setRateChangeThresholds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"},{"internalType":"uint256","name":"newSmoothingFactor","type":"uint256"}],"name":"setSmoothingFactor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ISortedOracles","name":"_sortedOracles","type":"address"}],"name":"setSortedOracles","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"shouldReset","outputs":[{"internalType":"bool","name":"resetBreaker","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rateFeedID","type":"address"}],"name":"shouldTrigger","outputs":[{"internalType":"bool","name":"triggerBreaker","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"smoothingFactors","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sortedOracles","outputs":[{"internalType":"contract ISortedOracles","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":null}